npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

covenant

v0.0.12

Published

Covenant is a tight and performant Promises/A+ implementation written in Coffeescript. Covenant passes the Promises/A+ Test Suite (Version 1.1).

Downloads

14

Readme

covenant

Covenant is a 64-line Promises/A+ implementation written in Coffeescript. Covenant passes the Promises/A+ Test Suite. It compiles to under 200 lines of javascript, less than 500 bytes without compression.

Installation

Download it, clone it, or npm install wizardwerdna/covenant

Covenant has no dependencies, but does use process.nextTick, found in modern Browsers. If process.nextTick is not a function, Covenant falls back to setImmediate, and then to setTimeout. If you are using ancient browsers, it is highly recommended that you use a shim to implement (fake) nextTick and/or setImmediate.

The API

// load the coffeescript compiler (unless running precompiled version)
// and then follow up with obvious variations of the coffeescript below
require('coffee-script');
# alternatively, simply transpile a direct javascript file and use that
# instead
coffee -c node_modules/covenant/covenant.coffee
# get the Promise class
Covenant = require('covenant').Covenant

# create a new pending promise
covenant = new Covenant

# fulfill it
covenant.fulfill(value)

# reject it
covenant.reject(reason)

# schedule asynchronous handers
covenant.then onFulfilled, onRejected

Why another promise implementation?

I set out to write Covenant, just for myself, so to achieve a better understanding of the nuances of the Promise pattern. The Promises/A+ specification seemed elegant, but I couldn't seem to grok it without more. Reading the code of various compliant mplementations was helpful, but I still didn't seem to own it. I began the experiment by "cowboy" coding a first set, using the test suite to verify that things were working. Finally, I discarded that code as one to throw away, and rebuilt it in pure BDD red-green-refactor style.

Having a well-understood testbed for promises, I will probably extend covenant to a more full-featured implementation.

Credits

I am indebted, in particular, to the work of Brian Cavalier, whose when.js, and avow.js libraries illuminate what can be done both in a full-featured and minimalist implementation.

Running the tests

  1. clone the respository
  2. npm install
  3. npm test

License

MIT License, Copyright (c) 2013 Andrew C. Greenberg ([email protected])