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

r3b-promise

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

r3b-promise

A minimal promise implementation

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

promise

A very minimal Promise implementation. Creates a simple deferred object with utility methods for sequential or parallel execution. that's it.

var Promise= require('r3b-promise');

function asyncTask(options, callback){
  //do something
  callback();
}

function postProcessingTask(err, result){
  //process
}

function process(options){
  var p = new Promise();
  asyncTask(options, function(err, result){
    p.done(err, result);
  }
  return p;
}

function run(){
  process({}).then(postProcessingTask);
}

function runInParallel(){
  Promise.join([
    asyncTask({property:'value1'}),
    asyncTask({property:'value2'}),
    asyncTask({property:'value3'}),
  ]).then(function(errors, results){
    errors.forEach(function(err){
      //handle error
    });
    results.forEach(function(result){
      //handle result
    });
  });
}

function step(err, data){
  var p = new Promise();
  passItOn(function(err, result){
    p.done(err, result);
  }
  return p;
}
function runInSequence(){
  Promise.chain([
    step({property:'value1'}),
    step({property:'value2'}),
    step({property:'value3'}),
  ]);
}

Keywords

FAQs

Package last updated on 02 Apr 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