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

davy

v1.3.0

Published

Promises/A+ implementation

Downloads

270

Readme

Davy Jones

Yet another Promises/A+ implementation optimized for speed and simplicity.

API

new Davy(resolver)

Create a new promise. The passed in function will receive functions resolve, reject as its arguments which can be called to seal the fate of the created promise.

.then(onFulfilled, onRejected)

Returns a new promise chained from this promise. The new promise will be rejected or resolved defer on the passed onFulfill, onReject and the state of this promise.

.catch(handler)

This is a catch-all exception handler, shortcut for calling .then(null, handler) on this promise. Any exception happening in a .then-chain will propagate to nearest .catch handler.

.progress(handler)

This is a progress handler, shortcut for calling .then(null, null, handler) on this promise.

.throw(handler)

Like .catch, but any unhandled rejection that ends up here will be thrown as an error.

.finally(handler)

Pass a handler that will be called regardless of this promise's fate. Returns a new promise chained from this promise.

.spread(onFulfilled, onRejected)

Like calling .then, but the fulfillment value or rejection reason is assumed to be an array, which is flattened to the formal parameters of the handlers.

Davy.resolve(value)

Returns a Promise object that is resolved with the given value. If the value is a thenable (i.e. has a then method), the returned promise will "follow" that thenable, adopting its eventual state; otherwise the returned promise will be fulfilled with the value.

Davy.reject(reason)

Returns a Promise object that is rejected with the given reason.

Davy.defer()

Create a promise with undecided fate and return a Resolver to control it.

Davy.all(iterable)

Returns a promise that resolves when all of the promises in iterable have resolved. The result is passed an array of values from all the promises. If something passed in the iterable array is not a promise, it's converted to one by Promise.cast. If any of the passed in promises rejects, the all Promise immediately rejects with the value of the promise that rejected, discarding all the other promises whether or not they have resolved.

Davy.race(iterable)

Returns a promise that either resolves when the first promise in the iterable resolves, or rejects when the first promise in the iterable rejects.

Davy.wrap(nodeFunction)

Returns a function that will wrap the given nodeFunction. Instead of taking a callback, the returned function will return a promise whose fate is decided by the callback behavior of the given node function. The node function should conform to node.js convention of accepting a callback as last argument and calling that callback with error as the first argument and success value on the second argument.

Davy.traverse(promiseTree, treePath)

Returns a promise that will be fullfiled with the result of the tree and subtrees resolved values.