Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

once@1.1.1

  • Loading branch information...
commit 7b26c04df16d2042193dd94be37874ad9895caa2 1 parent 8808e63
@isaacs isaacs authored
View
27 node_modules/once/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) Isaac Z. Schlueter ("Author")
+All rights reserved.
+
+The BSD License
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
View
33 node_modules/once/README.md
@@ -0,0 +1,33 @@
+# once
+
+Only call a function once.
+
+## usage
+
+```javascript
+var once = require('once')
+
+function load (file, cb) {
+ cb = once(cb)
+ loader.load('file')
+ loader.once('load', cb)
+ loader.once('error', cb)
+}
+```
+
+Or add to the Function.prototype in a responsible way:
+
+```javascript
+// only has to be done once
+require('once').proto()
+
+function load (file, cb) {
+ cb = cb.once()
+ loader.load('file')
+ loader.once('load', cb)
+ loader.once('error', cb)
+}
+```
+
+Ironically, the prototype feature makes this module twice as
+complicated as necessary.
View
19 node_modules/once/once.js
@@ -0,0 +1,19 @@
+module.exports = once
+
+once.proto = once(function () {
+ Object.defineProperty(Function.prototype, 'once', {
+ value: function () {
+ return once(this)
+ },
+ configurable: true
+ })
+})
+
+function once (fn) {
+ var called = false
+ return function () {
+ if (called) return
+ called = true
+ return fn.apply(this, arguments)
+ }
+}
View
35 node_modules/once/package.json
@@ -0,0 +1,35 @@
+{
+ "name": "once",
+ "version": "1.1.1",
+ "description": "Run a function exactly one time",
+ "main": "once.js",
+ "directories": {
+ "test": "test"
+ },
+ "dependencies": {},
+ "devDependencies": {
+ "tap": "~0.3.0"
+ },
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/isaacs/once"
+ },
+ "keywords": [
+ "once",
+ "function",
+ "one",
+ "single"
+ ],
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "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",
+ "_id": "once@1.1.1",
+ "_from": "once"
+}
View
18 node_modules/once/test/once.js
@@ -0,0 +1,18 @@
+var test = require('tap').test
+var once = require('../once.js')
+
+test('once', function (t) {
+ var f = 0
+ var foo = once(function (g) {
+ t.equal(f, 0)
+ f ++
+ return f + g + this
+ })
+ for (var i = 0; i < 1E3; i++) {
+ t.same(f, i === 0 ? 0 : 1)
+ var g = foo.call(1, 1)
+ t.same(g, i === 0 ? 3 : undefined)
+ t.same(f, 1)
+ }
+ t.end()
+})
View
6 package.json
@@ -68,7 +68,8 @@
"osenv": "0",
"lockfile": ">=0.2",
"retry": "~0.6.0",
- "couch-login": "~0.1.6"
+ "couch-login": "~0.1.6",
+ "once": "~1.1.1"
},
"bundleDependencies": [
"semver",
@@ -105,7 +106,8 @@
"osenv",
"lockfile",
"retry",
- "couch-login"
+ "couch-login",
+ "once"
],
"devDependencies": {
"ronn": "~0.3.6",
Please sign in to comment.
Something went wrong with that request. Please try again.