Initial commit
[yaffs-website] / node_modules / end-of-stream / node_modules / once / once.js
1 var wrappy = require('wrappy')
2 module.exports = wrappy(once)
3
4 once.proto = once(function () {
5   Object.defineProperty(Function.prototype, 'once', {
6     value: function () {
7       return once(this)
8     },
9     configurable: true
10   })
11 })
12
13 function once (fn) {
14   var f = function () {
15     if (f.called) return f.value
16     f.called = true
17     return f.value = fn.apply(this, arguments)
18   }
19   f.called = false
20   return f
21 }