async-listener
Polyfill exporting trevnorris's 0.11+ asyncListener API.
Last updated 6 years ago by watson .
BSD-2-Clause · Repository · Bugs · Original npm · Tarball · package.json
$ npm install async-listener 
SYNC missed versions from official npm registry.

NPM

Build status

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.

Current Tags

  • 0.6.10                                ...           latest (6 years ago)

36 Versions

  • 0.6.10                                ...           6 years ago
  • 0.6.9                                ...           7 years ago
  • 0.6.8                                ...           7 years ago
  • 0.6.7                                ...           7 years ago
  • 0.6.6                                ...           7 years ago
  • 0.6.5                                ...           8 years ago
  • 0.6.4                                ...           8 years ago
  • 0.6.3                                ...           8 years ago
  • 0.6.2                                ...           8 years ago
  • 0.6.1                                ...           8 years ago
  • 0.6.0                                ...           9 years ago
  • 0.5.8                                ...           9 years ago
  • 0.5.7                                ...           9 years ago
  • 0.5.6                                ...           9 years ago
  • 0.5.5                                ...           9 years ago
  • 0.5.4 [deprecated]           ...           9 years ago
  • 0.5.3                                ...           9 years ago
  • 0.5.2                                ...           10 years ago
  • 0.5.1                                ...           10 years ago
  • 0.5.0                                ...           10 years ago
  • 0.4.7                                ...           10 years ago
  • 0.4.6                                ...           10 years ago
  • 0.4.5                                ...           11 years ago
  • 0.4.4                                ...           11 years ago
  • 0.4.3                                ...           11 years ago
  • 0.4.2                                ...           11 years ago
  • 0.4.1                                ...           11 years ago
  • 0.4.0                                ...           11 years ago
  • 0.3.0                                ...           11 years ago
  • 0.2.2                                ...           11 years ago
  • 0.2.1                                ...           11 years ago
  • 0.2.0                                ...           11 years ago
  • 0.1.2                                ...           11 years ago
  • 0.1.1                                ...           11 years ago
  • 0.0.3                                ...           11 years ago
  • 0.0.2                                ...           11 years ago
Downloads
Total 2
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE