🚀 DAY 5 OF LAUNCH WEEK: Introducing Socket Firewall Enterprise.Learn more →
Socket
Book a DemoInstallSign in
Socket

to-async-function

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

to-async-function

Create an async function from anything (promise, stream, object)

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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
  });
}

Keywords

async function

FAQs

Package last updated on 22 Mar 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts