node-singleflight

0.1.2 • Public • Published

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-singleflight

NPM

npm install node-singleflight --save

Usage

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
}

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    30
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    30
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i node-singleflight

Weekly Downloads

22

Version

0.1.2

License

MIT

Unpacked Size

6.01 kB

Total Files

13

Last publish

Collaborators

  • mustard-mh