1.1.19 • Published 7 years ago
@hsk81/buffered v1.1.19
@hsk81/buffered
A Node.js module that returns a buffered and cancelable version for the provided function. The buffered function does not execute before the specified delay passes upon which it executes exactly once, no matter have many times it gets invoked in between. Also upon the invocation of the buffering function a promise is returned. Further, the cancellation of a particular invocation is only possible while the specified delay has not passed.
Usage
Install
npm install @hsk81/buffered --saveRequire
var lib = require('@hsk81/buffered');Examples
var buffered = require('@hsk81/buffered').buffered;
var fn = buffered((t) => {
    return new Date() - t;
}, 200);
fn(new Date()).then((res) => {
    console.debug(res);
}).catch((err) => {
    console.error(err);
});var buffered = require('@hsk81/buffered').buffered;
var fn = buffered(() => {
    throw new Error("won't be thrown");
}, 600);
fn().then((res) => { // won't execute (due to `fn.cancel`)
    console.debug(res);
}).catch((err) => {
    console.error(err);
});
fn.cancel();Development
Build
npm run buildLint
npm run lintwith fixes:
npm run lint:fixTest
npm run testCover
npm run coverLicense
© 2018 Hasan Karahan
1.1.19
7 years ago
1.1.18
7 years ago
1.1.17
7 years ago
1.1.15
7 years ago
1.1.14
7 years ago
1.1.13
7 years ago
1.1.12
7 years ago
1.1.11
7 years ago
1.1.10
7 years ago
1.1.9
7 years ago
1.1.8
7 years ago
1.1.6
7 years ago
1.1.5
7 years ago
1.1.4
7 years ago
1.1.3
7 years ago
1.1.2
7 years ago
1.1.1
7 years ago
1.1.0
7 years ago
1.0.6
7 years ago
1.0.5
7 years ago
1.0.4
7 years ago
1.0.3
7 years ago
1.0.2
7 years ago