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

once

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

once

Run a function exactly one time

  • 1.4.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
51M
decreased by-3.77%
Maintainers
1
Weekly downloads
 
Created

What is once?

The 'once' npm package is a utility that allows you to ensure a function can only be called once. It is useful for preventing duplicate initialization, handling setup tasks that should only run a single time, or ensuring a callback is only executed once in response to an event or the resolution of a Promise.

What are once's main functionalities?

Ensuring a function is only called once

This feature is used to wrap a function so that it can only be executed once. Subsequent calls to the function will have no effect, and the original return value will be returned.

const once = require('once');
const myFunction = once(() => {
  console.log('This will only be logged once.');
});

myFunction(); // logs 'This will only be logged once.'
myFunction(); // does nothing

Other packages similar to once

Keywords

FAQs

Package last updated on 06 Sep 2016

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