Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

async-once

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-once

Guarantee a node-style async function is only executed once.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
120
increased by37.93%
Maintainers
2
Weekly downloads
 
Created
Source

async-once

NPM version Downloads Build Status Coveralls Status

Guarantee a node-style async function is only executed once.

Usage

var once = require('async-once');

var count = 0;

var myAsyncFunc = once(function (cb) {
  count++;
  cb(null, count);
});

myAsyncFunc(function (err, result) {
  assert(result === 1);
});

myAsyncFunc(function (err, result) {
  assert(result === 1);
});

assert(count === 1);

API

once(fn)

Takes a node-style async function (fn) to ensure it's only called once. The function should accept a callback as its last parameter which is called with cb(err, result). Returns a function that can be called any number of times but will only execute once. Arguments passed to the returned function will be passed to the fn.

License

MIT

Keywords

FAQs

Package last updated on 28 Jun 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc