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

call-once

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

call-once

Call a function once and no more

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Call Once

Limit dangerous function calls.

Install

$ npm install call-once

Usage

// Simple usage
var callOnce = require( 'call-once' )
var wrapped = callOnce( function( n ){
  setupNuclearTestPlant()
  return true
})

wrapped() // => true
wrapped() // => undefined
// Blocking and unblocking wrapped functions
var callOnce = require( 'call-once' )
var setup = callOnce( function( n ){
  setupNuclearTestPlant()
  return true
})

powerPlant.on( 'constructed', function(){
  setup()
})

president.on( 'cancel_project', function(){
  setup.block() // will prevent the function from being called at all
})

president.on( 'changed_mind', function(){
  setup.unblock() // will allow the function to be called again
})

Note: in reality this is more useful for stuff like promise resolutions on a timeout

Keywords

FAQs

Package last updated on 11 Sep 2015

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