0.1.2 • Published 4 years ago
node-singleflight v0.1.2
node-singleflight
provides a duplicate function call suppression
If a duplicate comes in, the duplicate caller waits for the original to complete and receives the same results.
Notice
argument func may need to set up timeout in some ways, otherwise it may create too many listeners and cause memory leak
Install
Yarn
yarn add node-singleflightNPM
npm install node-singleflight --saveUsage
- See do.test.js File
const singleflight = require('node-singleflight')
async function example() {
let data = singleflight.Do('SomeKey', async () => {
let data = await doSomething()
let processed = processData(data)
return processed
})
return data
}