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

@datadog/async-listener

v0.1.0

Published

Polyfill exporting trevnorris's 0.11+ asyncListener API.

Downloads

9,060

Readme

NPM

Build status

This fork of async-listener makes the following changes:

  • For promises, .then() callbacks are bound to the context in which .then() was called instead of the context in which resolve() was called.
  • The API below is exported by the library instead of being attached directly to process. This avoids conflicts with the existing implementation. However, it means this fork cannot be used as a polyfill.

process.addAsyncListener polyfill

This is an implementation of Trevor Norris's process.{addAsyncListener,removeAsyncListener} API for adding behavior to async calls. You can see his implementation (currently a work in progress) on Node.js core pull request #6011. This polyfill / shim is intended for use in versions of Node prior to whatever version of Node in which Trevor's changes finally land (anticipated at the time of this writing as 0.11.7).

Here's his documentation of the intended API, which will probably get cleaned up here later:

createAsyncListener(callbacks[, initialStorage])

  • callbacks {Object}
  • initialStorage {Value}

Returns a constructed AsyncListener object. Which can then be passed to process.addAsyncListener() and process.removeAsyncListener(). Each function parameter is as follows:

  1. callbacks: An Object which may contain four optional fields:
    • create: A function (storage) that is called when an asynchronous event is queued. Recives the storage attached to the listener. storage can be created by passing an initialStorage argument during construction, or by returning a Value from create which will be attached to the listener and overwrite the initialStorage.
    • before: A function (context, storage) that is called immediately before the asynchronous callback is about to run. It will be passed both the context (i.e. this) of the calling function and the storage.
    • after: A function (context, storage) called immediately after the asynchronous event's callback is run. Note that if the event's callback throws during execution this will not be called.
    • error: A function (storage, error) called if the event's callback threw. If error returns true then Node will assume the error has been properly handled and resume execution normally.
  2. initialStorage: A Value (i.e. anything) that will be, by default, attached to all new event instances. This will be overwritten if a Value is returned by create().

addAsyncListener(callbacks[, initialStorage])

addAsyncListener(asyncListener)

Returns a constructed AsyncListener object and immediately adds it to the listening queue.

removeAsyncListener(asyncListener)

Removes the asyncListener from the listening queue.