🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

commandemitter

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

commandemitter

wrapper for EventEmitter which queues events and add `done` method to them. Each event becomes command which is triggered after previous command is done.

0.0.1
latest
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

wrapper for EventEmitter which queues events and add done method to them. Each event becomes command which is triggered after previous command is done.

API: createCommandEmitter(ee: {emit, on}) : {command, on};

example:


const assert = require('assert');
const {createCommandEmitter} = require('commandemitter');
const {EventEmitter} = require('events');

const ee = new EventEmitter;
const ce = createCommandEmitter(ee);
const animals = [];

ce.on('doge', ({done}) => {
    animals.push('doge');
});

ce.on('doge', ({type, done}) => {
    setTimeout(() => {
        done();
    }, 100);
});

ce.on('animal', ({type, done}) => {
    animals.push(type);
    done();
});

ce.command('doge');
ce.command('animal', {type: 'cat'});
ce.command('animal', {type: 'squirrel'});

setTimeout(() => {
    assert.deepEqual(animals, ['doge', 'cat', 'squirrel']);
    done();
}, 600)

FAQs

Package last updated on 06 Dec 2016

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