once-noop
v1.0.2
Published
A noop function that can only be run once
Downloads
124
Maintainers
Readme
once-noop
A noop function that can only be called once. Usage:
const onceNoop = require('once-noop')
onceNoop.doNothing() // does absolutely nothing except set itself to a function that throws an error the next time
onceNoop.doNothing() // throws an error
If you want to create new noop functions that can only be called once, require the factory
const onceNoopFactory = require('once-noop/factory')
const myNoopInstance = onceNoopFactory()
const myOtherNoopInstance = onceNoopFactory()
myNoopInstance.doNothing() // does nothing
myOtherNoopInstance.doNothing() // does nothing
myOtherNoopInstance.doNothing() // throw error because called twice