{ "_args": [ [ { "raw": "once@^1.3.0", "scope": null, "escapedName": "once", "name": "once", "rawSpec": "^1.3.0", "spec": ">=1.3.0 <2.0.0", "type": "range" }, "/home/jdaugherty/work/GT2/GT2-Android/node_modules/glob" ] ], "_from": "once@>=1.3.0 <2.0.0", "_id": "once@1.4.0", "_inCache": true, "_location": "/once", "_nodeVersion": "6.5.0", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", "tmp": "tmp/once-1.4.0.tgz_1473196269128_0.537820661207661" }, "_npmUser": { "name": "isaacs", "email": "i@izs.me" }, "_npmVersion": "3.10.7", "_phantomChildren": {}, "_requested": { "raw": "once@^1.3.0", "scope": null, "escapedName": "once", "name": "once", "rawSpec": "^1.3.0", "spec": ">=1.3.0 <2.0.0", "type": "range" }, "_requiredBy": [ "/glob", "/globby/glob", "/inflight", "/rimraf/glob", "/xdl/glob" ], "_resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "_shasum": "583b1aa775961d4b113ac17d9c50baef9dd76bd1", "_shrinkwrap": null, "_spec": "once@^1.3.0", "_where": "/home/jdaugherty/work/GT2/GT2-Android/node_modules/glob", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", "url": "http://blog.izs.me/" }, "bugs": { "url": "https://github.com/isaacs/once/issues" }, "dependencies": { "wrappy": "1" }, "description": "Run a function exactly one time", "devDependencies": { "tap": "^7.0.1" }, "directories": { "test": "test" }, "dist": { "shasum": "583b1aa775961d4b113ac17d9c50baef9dd76bd1", "tarball": "https://registry.npmjs.org/once/-/once-1.4.0.tgz" }, "files": [ "once.js" ], "gitHead": "0e614d9f5a7e6f0305c625f6b581f6d80b33b8a6", "homepage": "https://github.com/isaacs/once#readme", "keywords": [ "once", "function", "one", "single" ], "license": "ISC", "main": "once.js", "maintainers": [ { "name": "isaacs", "email": "i@izs.me" } ], "name": "once", "optionalDependencies": {}, "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\n## `once.strict(func)`\n\nThrow an error if the function is called twice.\n\nSome functions are expected to be called only once. Using `once` for them would\npotentially hide logical errors.\n\nIn the example below, the `greet` function has to call the callback only once:\n\n```javascript\nfunction greet (name, cb) {\n // return is missing from the if statement\n // when no name is passed, the callback is called twice\n if (!name) cb('Hello anonymous')\n cb('Hello ' + name)\n}\n\nfunction log (msg) {\n console.log(msg)\n}\n\n// this will print 'Hello anonymous' but the logical error will be missed\ngreet(null, once(msg))\n\n// once.strict will print 'Hello anonymous' and throw an error when the callback will be called the second time\ngreet(null, once.strict(msg))\n```\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git://github.com/isaacs/once.git" }, "scripts": { "test": "tap test/*.js" }, "version": "1.4.0" }