Socket
Book a DemoInstallSign in
Socket

deferred-method

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

deferred-method

Queue method invocations until something is ready

latest
Source
npmnpm
Version
1.0.1
Version published
Weekly downloads
86
86.96%
Maintainers
1
Weekly downloads
 
Created
Source

deferred-method

Queue method invocations until something is ready

Example

Instead of having to do:

var nsq = require('nsq.js');

var writer = nsq.writer();

writer.once('ready', function(){
  writer.publish('topic', 'message');
  writer.publish('topic', 'message');
  writer.publish('topic', 'message');
});

you can do this:

var deferred = require('deferred-method');
var nsq = require('nsq.js');

var writer = nsq.writer();
deferred(writer, 'publish');

writer.publish('topic', 'message');
writer.publish('topic', 'message');
writer.publish('topic', 'message');

Since emitting a "ready" event is most common, deferred-method listens to it by default, unless don't specify your own ready function:

deferred(writer, 'publish', writer.once.bind(writer, 'ready'));

Installation

$ npm install deferred-method

License

MIT

FAQs

Package last updated on 01 May 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