1.0.0 • Published 9 years ago

to-async-function v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

to-async-function

Create a async function from anything (promises, streams, objects and async functions)

Install

npm install --save to-async-function

Example

To convert any type of dataSources to async function

var toAsyncFunction = require('to-async-function');


var dataSource; // can be promises, streams, objects and async functions
var converted = toAsyncFunction(dataSource);

converted(function(err,data){
  // will return when dataSource data is ready

  // err: datasource reported errors if applicable
  // data: data returned from
});

To create a lib that can take any type of external data source promises, streams, etc... :

var toAsyncFunction = require('to-async-function');

// someLib first argument can be any type of data source!!!
function someLib(dataSource){
  var dataSource = toAsyncFunction(dataSource);

  dataSource(function(err,data){
    // do something
  });
}
1.0.0

9 years ago

0.1.0

9 years ago