Socket
Socket
Sign inDemoInstall

lodash.once

Package Overview
Dependencies
0
Maintainers
3
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

lodash.once

The lodash method `_.once` exported as a module.


Version published
Maintainers
3
Weekly downloads
13,481,568
decreased by-8.7%

Weekly downloads

Package description

What is lodash.once?

The lodash.once package is a utility that allows you to create a function that can only be called once. After the first call, subsequent calls to the function will return the result of the first call without executing the function again. This is useful for initializing resources or other actions that should only happen once.

What are lodash.once's main functionalities?

Creating a function that can only be called once

This feature allows you to create a function that will only execute its body once and will return the result of the first execution on subsequent calls.

const once = require('lodash.once');
const initialize = once(() => {
  console.log('Initialization complete.');
  return 'Initialized';
});

console.log(initialize()); // Output: Initialization complete.
console.log(initialize()); // Output: Initialized (without logging 'Initialization complete.' again)

Other packages similar to lodash.once

Readme

Source

lodash.once v4.1.1

The lodash method _.once exported as a Node.js module.

Installation

Using npm:

$ {sudo -H} npm i -g npm
$ npm i --save lodash.once

In Node.js:

var once = require('lodash.once');

See the documentation or package source for more details.

Keywords

FAQs

Last updated on 13 Aug 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc