Comparing version 1.2.0 to 1.3.0
@@ -14,5 +14,5 @@ module.exports = once | ||
var f = function () { | ||
if (f.called) return | ||
if (f.called) return f.value | ||
f.called = true | ||
return fn.apply(this, arguments) | ||
return f.value = fn.apply(this, arguments) | ||
} | ||
@@ -19,0 +19,0 @@ f.called = false |
{ | ||
"name": "once", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Run a function exactly one time", | ||
@@ -5,0 +5,0 @@ "main": "once.js", |
@@ -35,3 +35,6 @@ # once | ||
To check whether you function has been called, use `fn.called`: | ||
To check whether you function has been called, use `fn.called`. Once the | ||
function is called for the first time the return value of the original | ||
function is saved in `fn.value` and subsequent calls will continue to | ||
return this value. | ||
@@ -49,2 +52,2 @@ ```javascript | ||
} | ||
``` | ||
``` |
@@ -16,3 +16,3 @@ var test = require('tap').test | ||
t.ok(foo.called) | ||
t.same(g, i === 0 ? 3 : undefined) | ||
t.same(g, 3) | ||
t.same(f, 1) | ||
@@ -19,0 +19,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3600
52