Call Once
Limit dangerous function calls.
Install
$ npm install call-once
Usage
var callOnce = require( 'call-once' )
var wrapped = callOnce( function( n ){
setupNuclearTestPlant()
return true
})
wrapped()
wrapped()
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()
})
president.on( 'changed_mind', function(){
setup.unblock()
})
Note: in reality this is more useful for stuff like promise resolutions on a timeout