1.0.0 • Published 9 years ago

revelator v1.0.0

Weekly downloads
1
License
MIT
Repository
-
Last release
9 years ago

Revelator

An alternative to promisify

Convert error-first callbacks to revealing constructor pattern callbacks as used by the native ES6 Promise constructor.

Usage

function asyncOp(val, cb) {
   setTimeout(cb, 500, null, {val: val})
}

function doAsync(val) {
  return new Promise(revelator(asyncOp, val));
}

Why

  • Directly using the Promise API seems clearer and cleaner
  • This may (with some adaptation) have future uses beyond promises (e.g. the browser Streams API)

Contribution