Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

recant

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

recant

A promise library that violates everything you know about promises.

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-25%
Maintainers
1
Weekly downloads
 
Created
Source

Recant

A promise library that violates everything you know about promises.

Things You Can Do

*Create promises where the resolver can reset the promise to resolve/reject again. *Create deferreds that can be reset to resolve/reject again. Again

Why on earth would you do this?

*Create a promise that always resolves with an open connection (reset the promise on conn.close or conn.err) *Pipeline dynamic dependencies through normal promise symantics

Usage

Install via NPM

$ npm install recant

Example- Promise

var recant = require('recant') ;
var promise = recant.promise(function(resolve,reject,notify,reset){
	
	var connPromise = connection.open() ;
	connPromise.then(function(conn){	
		resolve(conn) ;
		conn.on('close',reset) ;
	}).then(null,function(err){
		reject(err) ;
	})
	
})

Example- Deferred

var recant = require('recant') ;
var deferred = recant.defer() ;
var promise = deferred.promise ;

deferred.resolve(val); // as of now, all promise.then calls will resolve with a value
deferred.reset() ; // now, all promise.then calls ( against the same promise ) will be pending until resolved or rejected again
deferred.reject(err) ; // now, all promise.then calls will be rejected as the state has changed

Keywords

FAQs

Package last updated on 19 Nov 2013

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