Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorForrest L Norvell <forrest@npmjs.com>2014-10-17 09:08:51 +0400
committerForrest L Norvell <forrest@npmjs.com>2014-10-17 09:08:51 +0400
commitc87b00f82f92434ee77831915012c77a6c244c39 (patch)
treee1105b8e96bc32d82ba3e0a701274c8e3d584324 /node_modules/once
parent01ec790fd47def56eda6abb3b8d809093e8f493f (diff)
once@1.3.1
Wraps once with wrappy.
Diffstat (limited to 'node_modules/once')
-rw-r--r--node_modules/once/once.js3
-rw-r--r--node_modules/once/package.json33
-rw-r--r--node_modules/once/test/once.js7
3 files changed, 34 insertions, 9 deletions
diff --git a/node_modules/once/once.js b/node_modules/once/once.js
index 0770a73cd..2e1e721bf 100644
--- a/node_modules/once/once.js
+++ b/node_modules/once/once.js
@@ -1,4 +1,5 @@
-module.exports = once
+var wrappy = require('wrappy')
+module.exports = wrappy(once)
once.proto = once(function () {
Object.defineProperty(Function.prototype, 'once', {
diff --git a/node_modules/once/package.json b/node_modules/once/package.json
index 96af3dedf..eb8a4217a 100644
--- a/node_modules/once/package.json
+++ b/node_modules/once/package.json
@@ -1,12 +1,14 @@
{
"name": "once",
- "version": "1.3.0",
+ "version": "1.3.1",
"description": "Run a function exactly one time",
"main": "once.js",
"directories": {
"test": "test"
},
- "dependencies": {},
+ "dependencies": {
+ "wrappy": "1"
+ },
"devDependencies": {
"tap": "~0.3.0"
},
@@ -29,11 +31,30 @@
"url": "http://blog.izs.me/"
},
"license": "BSD",
- "readme": "# once\n\nOnly call a function once.\n\n## usage\n\n```javascript\nvar once = require('once')\n\nfunction load (file, cb) {\n cb = once(cb)\n loader.load('file')\n loader.once('load', cb)\n loader.once('error', cb)\n}\n```\n\nOr add to the Function.prototype in a responsible way:\n\n```javascript\n// only has to be done once\nrequire('once').proto()\n\nfunction load (file, cb) {\n cb = cb.once()\n loader.load('file')\n loader.once('load', cb)\n loader.once('error', cb)\n}\n```\n\nIronically, the prototype feature makes this module twice as\ncomplicated as necessary.\n\nTo check whether you function has been called, use `fn.called`. Once the\nfunction is called for the first time the return value of the original\nfunction is saved in `fn.value` and subsequent calls will continue to\nreturn this value.\n\n```javascript\nvar once = require('once')\n\nfunction load (cb) {\n cb = once(cb)\n var stream = createStream()\n stream.once('data', cb)\n stream.once('end', function () {\n if (!cb.called) cb(new Error('not found'))\n })\n}\n```\n",
- "readmeFilename": "README.md",
+ "gitHead": "c90ac02a74f433ce47f6938869e68dd6196ffc2c",
"bugs": {
"url": "https://github.com/isaacs/once/issues"
},
- "_id": "once@1.3.0",
- "_from": "once@latest"
+ "homepage": "https://github.com/isaacs/once",
+ "_id": "once@1.3.1",
+ "_shasum": "f3f3e4da5b7d27b5c732969ee3e67e729457b31f",
+ "_from": "once@>=1.3.1 <2.0.0",
+ "_npmVersion": "2.0.0",
+ "_nodeVersion": "0.10.31",
+ "_npmUser": {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ },
+ "maintainers": [
+ {
+ "name": "isaacs",
+ "email": "i@izs.me"
+ }
+ ],
+ "dist": {
+ "shasum": "f3f3e4da5b7d27b5c732969ee3e67e729457b31f",
+ "tarball": "http://registry.npmjs.org/once/-/once-1.3.1.tgz"
+ },
+ "_resolved": "https://registry.npmjs.org/once/-/once-1.3.1.tgz",
+ "readme": "ERROR: No README data found!"
}
diff --git a/node_modules/once/test/once.js b/node_modules/once/test/once.js
index a77951f11..c618360df 100644
--- a/node_modules/once/test/once.js
+++ b/node_modules/once/test/once.js
@@ -3,11 +3,14 @@ var once = require('../once.js')
test('once', function (t) {
var f = 0
- var foo = once(function (g) {
+ function fn (g) {
t.equal(f, 0)
f ++
return f + g + this
- })
+ }
+ fn.ownProperty = {}
+ var foo = once(fn)
+ t.equal(fn.ownProperty, foo.ownProperty)
t.notOk(foo.called)
for (var i = 0; i < 1E3; i++) {
t.same(f, i === 0 ? 0 : 1)