Socket
Socket
Sign inDemoInstall

@tootallnate/once

Package Overview
Dependencies
0
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @tootallnate/once

Creates a Promise that waits for a single event


Version published
Weekly downloads
26M
decreased by-9.59%
Maintainers
1
Install size
4.62 kB
Created
Weekly downloads
 

Package description

What is @tootallnate/once?

The @tootallnate/once package is designed to ensure a given function can only be called once. It is particularly useful in scenarios where you want to prevent duplicate execution of event handlers or other functions that should only run a single time during the lifecycle of an application.

What are @tootallnate/once's main functionalities?

Ensuring a function is only called once

This feature allows you to wrap any function with `once` to ensure it can only be executed a single time. Subsequent calls to the wrapped function will have no effect, preventing duplicate execution.

const once = require('@tootallnate/once');

function myFunction() {
  console.log('This will only be logged once.');
}

const wrappedFunction = once(myFunction);
wrappedFunction(); // Logs: 'This will only be logged once.'
wrappedFunction(); // Does nothing on subsequent calls.

Other packages similar to @tootallnate/once

FAQs

Last updated on 20 Apr 2020

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