New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

risposta

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

risposta

functions from async.js implemented using promises

  • 0.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

risposta

Functions from caolan/async implemented using promises.

Internally risposta uses the popular Promise implementation Q and the new faster Promise library bluebird.

The inital code for risposta is based off this gist by @wavdad. risposta is feature complete with async.js. For example the implemenation of async.series & async.parallel by @wavdad does not support the ability to pass in a object containing task functions as properties. This meas that you can easily replace async with risposta.

The tests for risposta is actually the nodeunit tests from async converted to Mocha and promisified.

Usage

Install it via;

npm install risposta
/** This will initilize the bluebird implementation of async
* you can also call .q() to initilize the implementation of
* async using Q
*/

var async = require('risposta').bluebird();

async.series

async.series([
  function(callback){
    setTimeout(function(){
      callback(null, 2);
    }, 100);
  },

  function(callback){
    setTimeout(function(){
      callback(null, 'a', 'b');
    }, 50)
  },

  function(callback){
    setTimeout(function(){
      callback(null, 3);
    }, 110)
  }
]).then(function(results){
  console.log(results); 
  // result is [ 2, [ 'a', 'b' ], 3 ] ] ]
});

Most of the examples in the README.md of async is supported by risposta. Just keep in mind that there is no optional callback you always get a promise.

For example, the example for async.times is done like so;

// Pretend this is some complicated async factory
var createUser = function(id, callback) {
  callback(null, {
    id: 'user' + id
  })
}
// generate 5 users
async.times(5, function(n, next){
  createUser(n, function(err, user) {
    next(err, user)
  })
}).then(function(users) {
  // we should now have 5 users
});

risposta : Italian - [Noun] answer, reply, response

Keywords

FAQs

Package last updated on 27 Feb 2014

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc