dotfiles/.vscode/extensions/saviorisdead.RustyCode-0.18.0/node_modules/once/once.js

22 lines
417 B
JavaScript
Raw Normal View History

2016-09-11 09:29:13 +01:00
var wrappy = require('wrappy')
module.exports = wrappy(once)
once.proto = once(function () {
Object.defineProperty(Function.prototype, 'once', {
value: function () {
return once(this)
},
configurable: true
})
})
function once (fn) {
var f = function () {
if (f.called) return f.value
f.called = true
return f.value = fn.apply(this, arguments)
}
f.called = false
return f
}