distribute-js

3.0.1 • Public • Published

DistributeJs

Distribute anonymous function executions over a defined timespan

Build Status Dependency Status

Install

$ npm i -S distribute-js

Usage

const Distribution = require('distribute-js');
const collection = new Distribution();
 
collection.add(() => {
    console.log(1);
});
 
collection.add(() => {
    console.log(2);
});
 
const promise = distribution.in(2000).run();
promise.resolve((distribution) => {
    console.log(distribution);
});

API

Methods

add(callable)

Method to add a new function to the stack.

Arguments
Argument Type Description
callable Function Function to be added to the execution stack.

in(timespan)

Method to set the timespan in which all functions should be executed.

Arguments
Argument Type Description
timespan Number Timespan in milliseconds.

run()

Method to execute the call stack. Returns a Promise.

License

GPL-2.0 © Willi Eßer

Package Sidebar

Install

npm i distribute-js

Weekly Downloads

0

Version

3.0.1

License

GPL-2.0

Last publish

Collaborators

  • troublete