checked in missing node_module dependencies that are required

This commit is contained in:
Steve Gill
2015-11-02 17:07:12 -08:00
parent 49870d2d63
commit 43dc7c68a6
20 changed files with 366 additions and 54 deletions
@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,36 @@
# wrappy
Callback wrapping utility
## USAGE
```javascript
var wrappy = require("wrappy")
// var wrapper = wrappy(wrapperFunction)
// make sure a cb is called only once
// See also: http://npm.im/once for this specific use case
var once = wrappy(function (cb) {
var called = false
return function () {
if (called) return
called = true
return cb.apply(this, arguments)
}
})
function printBoo () {
console.log('boo')
}
// has some rando property
printBoo.iAmBooPrinter = true
var onlyPrintOnce = once(printBoo)
onlyPrintOnce() // prints 'boo'
onlyPrintOnce() // does nothing
// random property is retained!
assert.equal(onlyPrintOnce.iAmBooPrinter, true)
```
@@ -0,0 +1,36 @@
{
"name": "wrappy",
"version": "1.0.1",
"description": "Callback wrapping utility",
"main": "wrappy.js",
"directories": {
"test": "test"
},
"dependencies": {},
"devDependencies": {
"tap": "^0.4.12"
},
"scripts": {
"test": "tap test/*.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/npm/wrappy.git"
},
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/npm/wrappy/issues"
},
"homepage": "https://github.com/npm/wrappy",
"readme": "# wrappy\n\nCallback wrapping utility\n\n## USAGE\n\n```javascript\nvar wrappy = require(\"wrappy\")\n\n// var wrapper = wrappy(wrapperFunction)\n\n// make sure a cb is called only once\n// See also: http://npm.im/once for this specific use case\nvar once = wrappy(function (cb) {\n var called = false\n return function () {\n if (called) return\n called = true\n return cb.apply(this, arguments)\n }\n})\n\nfunction printBoo () {\n console.log('boo')\n}\n// has some rando property\nprintBoo.iAmBooPrinter = true\n\nvar onlyPrintOnce = once(printBoo)\n\nonlyPrintOnce() // prints 'boo'\nonlyPrintOnce() // does nothing\n\n// random property is retained!\nassert.equal(onlyPrintOnce.iAmBooPrinter, true)\n```\n",
"readmeFilename": "README.md",
"_id": "wrappy@1.0.1",
"_shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739",
"_resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz",
"_from": "wrappy@>=1.0.0 <2.0.0"
}
@@ -0,0 +1,51 @@
var test = require('tap').test
var wrappy = require('../wrappy.js')
test('basic', function (t) {
function onceifier (cb) {
var called = false
return function () {
if (called) return
called = true
return cb.apply(this, arguments)
}
}
onceifier.iAmOnce = {}
var once = wrappy(onceifier)
t.equal(once.iAmOnce, onceifier.iAmOnce)
var called = 0
function boo () {
t.equal(called, 0)
called++
}
// has some rando property
boo.iAmBoo = true
var onlyPrintOnce = once(boo)
onlyPrintOnce() // prints 'boo'
onlyPrintOnce() // does nothing
t.equal(called, 1)
// random property is retained!
t.equal(onlyPrintOnce.iAmBoo, true)
var logs = []
var logwrap = wrappy(function (msg, cb) {
logs.push(msg + ' wrapping cb')
return function () {
logs.push(msg + ' before cb')
var ret = cb.apply(this, arguments)
logs.push(msg + ' after cb')
}
})
var c = logwrap('foo', function () {
t.same(logs, [ 'foo wrapping cb', 'foo before cb' ])
})
c()
t.same(logs, [ 'foo wrapping cb', 'foo before cb', 'foo after cb' ])
t.end()
})
@@ -0,0 +1,33 @@
// Returns a wrapper function that returns a wrapped callback
// The wrapper function should do some stuff, and return a
// presumably different callback function.
// This makes sure that own properties are retained, so that
// decorations and such are not lost along the way.
module.exports = wrappy
function wrappy (fn, cb) {
if (fn && cb) return wrappy(fn)(cb)
if (typeof fn !== 'function')
throw new TypeError('need wrapper function')
Object.keys(fn).forEach(function (k) {
wrapper[k] = fn[k]
})
return wrapper
function wrapper() {
var args = new Array(arguments.length)
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i]
}
var ret = fn.apply(this, args)
var cb = args[args.length-1]
if (typeof ret === 'function' && ret !== cb) {
Object.keys(cb).forEach(function (k) {
ret[k] = cb[k]
})
}
return ret
}
}
@@ -0,0 +1,15 @@
The ISC License
Copyright (c) Isaac Z. Schlueter and Contributors
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,36 @@
# wrappy
Callback wrapping utility
## USAGE
```javascript
var wrappy = require("wrappy")
// var wrapper = wrappy(wrapperFunction)
// make sure a cb is called only once
// See also: http://npm.im/once for this specific use case
var once = wrappy(function (cb) {
var called = false
return function () {
if (called) return
called = true
return cb.apply(this, arguments)
}
})
function printBoo () {
console.log('boo')
}
// has some rando property
printBoo.iAmBooPrinter = true
var onlyPrintOnce = once(printBoo)
onlyPrintOnce() // prints 'boo'
onlyPrintOnce() // does nothing
// random property is retained!
assert.equal(onlyPrintOnce.iAmBooPrinter, true)
```
@@ -0,0 +1,36 @@
{
"name": "wrappy",
"version": "1.0.1",
"description": "Callback wrapping utility",
"main": "wrappy.js",
"directories": {
"test": "test"
},
"dependencies": {},
"devDependencies": {
"tap": "^0.4.12"
},
"scripts": {
"test": "tap test/*.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/npm/wrappy.git"
},
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"license": "ISC",
"bugs": {
"url": "https://github.com/npm/wrappy/issues"
},
"homepage": "https://github.com/npm/wrappy",
"readme": "# wrappy\n\nCallback wrapping utility\n\n## USAGE\n\n```javascript\nvar wrappy = require(\"wrappy\")\n\n// var wrapper = wrappy(wrapperFunction)\n\n// make sure a cb is called only once\n// See also: http://npm.im/once for this specific use case\nvar once = wrappy(function (cb) {\n var called = false\n return function () {\n if (called) return\n called = true\n return cb.apply(this, arguments)\n }\n})\n\nfunction printBoo () {\n console.log('boo')\n}\n// has some rando property\nprintBoo.iAmBooPrinter = true\n\nvar onlyPrintOnce = once(printBoo)\n\nonlyPrintOnce() // prints 'boo'\nonlyPrintOnce() // does nothing\n\n// random property is retained!\nassert.equal(onlyPrintOnce.iAmBooPrinter, true)\n```\n",
"readmeFilename": "README.md",
"_id": "wrappy@1.0.1",
"_shasum": "1e65969965ccbc2db4548c6b84a6f2c5aedd4739",
"_resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.1.tgz",
"_from": "wrappy@>=1.0.0 <2.0.0"
}
@@ -0,0 +1,51 @@
var test = require('tap').test
var wrappy = require('../wrappy.js')
test('basic', function (t) {
function onceifier (cb) {
var called = false
return function () {
if (called) return
called = true
return cb.apply(this, arguments)
}
}
onceifier.iAmOnce = {}
var once = wrappy(onceifier)
t.equal(once.iAmOnce, onceifier.iAmOnce)
var called = 0
function boo () {
t.equal(called, 0)
called++
}
// has some rando property
boo.iAmBoo = true
var onlyPrintOnce = once(boo)
onlyPrintOnce() // prints 'boo'
onlyPrintOnce() // does nothing
t.equal(called, 1)
// random property is retained!
t.equal(onlyPrintOnce.iAmBoo, true)
var logs = []
var logwrap = wrappy(function (msg, cb) {
logs.push(msg + ' wrapping cb')
return function () {
logs.push(msg + ' before cb')
var ret = cb.apply(this, arguments)
logs.push(msg + ' after cb')
}
})
var c = logwrap('foo', function () {
t.same(logs, [ 'foo wrapping cb', 'foo before cb' ])
})
c()
t.same(logs, [ 'foo wrapping cb', 'foo before cb', 'foo after cb' ])
t.end()
})
@@ -0,0 +1,33 @@
// Returns a wrapper function that returns a wrapped callback
// The wrapper function should do some stuff, and return a
// presumably different callback function.
// This makes sure that own properties are retained, so that
// decorations and such are not lost along the way.
module.exports = wrappy
function wrappy (fn, cb) {
if (fn && cb) return wrappy(fn)(cb)
if (typeof fn !== 'function')
throw new TypeError('need wrapper function')
Object.keys(fn).forEach(function (k) {
wrapper[k] = fn[k]
})
return wrapper
function wrapper() {
var args = new Array(arguments.length)
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i]
}
var ret = fn.apply(this, args)
var cb = args[args.length-1]
if (typeof ret === 'function' && ret !== cb) {
Object.keys(cb).forEach(function (k) {
ret[k] = cb[k]
})
}
return ret
}
}