1.0.15 • Published 8 years ago

delayed-call v1.0.15

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

delayed-call

Version  Build Status  Coverage Status  PRs Welcome  XO code style

For making delayed function calls

Pass any number of arguments to the delayed function. Delayed calls can be cleared between creation and execution. Clear single delayed call or all at once.

Install

$ npm install --save delayed-call

API

create(ms, fn, ...args)

Create a delayed call

Parameters

ms : number
Delay in milliseconds.

fn : function
The function to be called after the delay.

...args : *
Optional. Any number of arguments supplied to the delayed function.

Returns

id : number
The id of the delayed call.

Usage

const delayedCall = require('delayed-call');
delayedCall.create(500, () => {
    console.log('I am delayed');
});

// Prints "I am delayed" after 500 ms.
delayedCall.create(1000, (arg1, arg2) => {
  console.log(arg1 + ' ' + arg2);
}, 'Hello', 'world!');

// Prints "Hello world!" after 1000 ms.

 

clearById(id)

Clear a single created delayed call

Parameters

id : number
The id of the delayed call to be cleared.

Usage

const delayId = delayedCall.create(500, () => {
    console.log('Hello!');
});

delayedCall.clearById(delayId);

// Prints nothing.
// The delayed call is cleared before execution.

 

clearAll()

Clear all created delayed calls

Usage

delayedCall.create(500, () => {
    console.log('Hello');
});
delayedCall.create(1000, () => {
    console.log('world!');
});

delayedCall.clearAll();

// Prints nothing.
// The delayed calls are cleared before execution.

 

License

MIT © Finn-Olav Myrvold

1.0.15

8 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

8 years ago

1.0.10

8 years ago

1.0.9

8 years ago

1.0.8

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago