1.0.2 • Published 9 months ago
once-noop v1.0.2
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