mirror of
https://github.com/deployphp/action.git
synced 2025-04-19 18:46:46 +00:00
Add n_m
This commit is contained in:
parent
d2f712fdfb
commit
9087c4d893
137 changed files with 8838 additions and 1 deletions
33
node_modules/wrappy/wrappy.js
generated
vendored
Normal file
33
node_modules/wrappy/wrappy.js
generated
vendored
Normal file
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue