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

@berlysia/remote-switch

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@berlysia/remote-switch

remote-switch =====

  • 0.1.0
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

remote-switch

Promise wrapper for remote resolve/reject.

Description

Making 'chain of Promise' but not want to execute immediately,

Requirement

No deps, but Promise required.

Usage

var RemoteSwitch = require('@berlysia/remote-switch');
var rs = new RemoteSwitch;
var log = console.log.bind(console);

rs
.then(function(){return 123})
.then(log)
.then(function(){return 456})
.then(log);
// no output

rs.fire(); // wrapped rs.resolve(), method chainable
// 123
// 456

rs
.then(function(){return 123})
.then(log)
.then(function(){return 456})
.then(log);
// 123
// 456

rs.then(func) is syntax sugar of promise = promise.then(func).

if you want to access last promise, rs.current is what you want.

rs
.then(function(){return 123})
.then(console.log.bind(console))
.then(spy)
.then(assert(!spy.called))
.then(()=>assert(spy.called))
.fire();
// => ok!

Install

npm install @berlysia/remote-switch

Licence

MIT

Author

berlysia

FAQs

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

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