3.0.4-d • Published 6 years ago

throttled-async v3.0.4-d

Weekly downloads
54
License
ISC
Repository
github
Last release
6 years ago

Deprecated in favor to Wraperizer.throttleAsync. No longer support.

Throttled

Create wrapper for a function that returns a promise. Uses to throttle frequent or repeated calls.

Parameters

  • fn function function that returns a promise
  • config object? config object
    • config.stay function function that checks is fn invokes is necessary (optional, default function(){returnfalse})
    • config.logs any? determines is internal logs needed

Examples

const Throttled = require('throttled-async');

const config = {}

const fn = (params) => new Promise((resolve, reject) => setTimeout(() => resolve(params), 100));

let throttled = new Throttled(fn, config);
let params = {};
const r1 = throttled.run(params); // will invoke `fn` and return Promise
const r2 = throttled.run(params); // will return old Promise

setTimeout(() => {
	const r3 = throttled.run(params); // will invoke `fn` and return new Promise
}, 300)

run

invokes fn and returns resulting promise

Parameters

  • params Object arguments for fn call
  • Throws Error throws an error if result returned fn is not a Promise

Returns Promise

stay

getter - returns current stay function

Returns function

stay

setter - set new value of stay function

Parameters

  • Throws Error throws an error if value is not a function
3.0.4-d

6 years ago

3.0.4

7 years ago

3.0.3

7 years ago

3.0.2

7 years ago

3.0.1

7 years ago

2.0.11

7 years ago

2.0.10

7 years ago

2.0.9

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago