async-args
Advanced tools
Comparing version 1.3.2 to 1.3.3
93
index.js
var jp = require('jsonpointer') | ||
var nextTick | ||
if (process && process.nextTick) { | ||
nextTick = function nextTick (next, args) { | ||
var callback = nextApplyFactory(next, args) | ||
process.nextTick(callback) | ||
} | ||
} else { | ||
nextTick = function nextTick(next, args) { | ||
var callback = nextApplyFactory(next, args) | ||
setTimeout(callback, 0) | ||
} | ||
} | ||
function nextApplyFactory(next, args){ | ||
return function nextApply(){ | ||
function nextApplyFactory (next, args) { | ||
return function nextApply () { | ||
next.apply(next, args) | ||
@@ -22,6 +9,6 @@ } | ||
function storeMetaFactory(lookup) { | ||
return function storeFactory() { | ||
function storeMetaFactory (lookup) { | ||
return function storeFactory () { | ||
var keys = Array.prototype.slice.call(arguments) | ||
return function store() { | ||
return function store () { | ||
var args = Array.prototype.slice.call(arguments) | ||
@@ -38,3 +25,3 @@ var lastArgIndex = args.length - 1 | ||
args.unshift(null) | ||
nextTick(next, args) | ||
process.nextTick(nextApplyFactory(next, args)) | ||
} | ||
@@ -44,6 +31,6 @@ } | ||
function valuesMetaFactory(lookup) { | ||
return function valuesFactory() { | ||
function valuesMetaFactory (lookup) { | ||
return function valuesFactory () { | ||
var keys = Array.prototype.slice.call(arguments) | ||
return function values() { | ||
return function values () { | ||
var args = Array.prototype.slice.call(arguments) | ||
@@ -58,3 +45,3 @@ var lastArgIndex = args.length - 1 | ||
args.unshift(null) | ||
nextTick(next, args) | ||
process.nextTick(nextApplyFactory(next, args)) | ||
} | ||
@@ -64,6 +51,6 @@ } | ||
function appendValuesMetaFactory(lookup) { | ||
return function appendValuesFactory() { | ||
function appendValuesMetaFactory (lookup) { | ||
return function appendValuesFactory () { | ||
var keys = Array.prototype.slice.call(arguments) | ||
return function appendValues() { | ||
return function appendValues () { | ||
var args = Array.prototype.slice.call(arguments) | ||
@@ -80,3 +67,3 @@ var lastArgIndex = args.length - 1 | ||
args.unshift(null) | ||
nextTick(next, args) | ||
process.nextTick(nextApplyFactory(next, args)) | ||
} | ||
@@ -86,7 +73,7 @@ } | ||
function prependValuesMetaFactory(lookup) { | ||
return function prependValuesFactory() { | ||
function prependValuesMetaFactory (lookup) { | ||
return function prependValuesFactory () { | ||
var keys = Array.prototype.slice.call(arguments) | ||
keys.reverse() | ||
return function prependValues() { | ||
return function prependValues () { | ||
var args = Array.prototype.slice.call(arguments) | ||
@@ -103,3 +90,3 @@ var lastArgIndex = args.length - 1 | ||
args.unshift(null) | ||
nextTick(next, args) | ||
process.nextTick(nextApplyFactory(next, args)) | ||
} | ||
@@ -109,5 +96,5 @@ } | ||
function constantsFactory() { | ||
function constantsFactory () { | ||
var outterArgs = Array.prototype.slice.call(arguments) | ||
return function constants() { | ||
return function constants () { | ||
var args = Array.prototype.slice.call(arguments) | ||
@@ -118,9 +105,9 @@ var lastArgIndex = args.length - 1 | ||
args.unshift(null) | ||
nextTick(next, args) | ||
process.nextTick(nextApplyFactory(next, args)) | ||
} | ||
} | ||
function appendConstantsFactory() { | ||
function appendConstantsFactory () { | ||
var outterArgs = Array.prototype.slice.call(arguments) | ||
return function appendConstants() { | ||
return function appendConstants () { | ||
var args = Array.prototype.slice.call(arguments) | ||
@@ -132,9 +119,9 @@ var lastArgIndex = args.length - 1 | ||
args.unshift(null) | ||
nextTick(next, args) | ||
process.nextTick(nextApplyFactory(next, args)) | ||
} | ||
} | ||
function prependConstantsFactory() { | ||
function prependConstantsFactory () { | ||
var outterArgs = Array.prototype.slice.call(arguments) | ||
return function prependConstants() { | ||
return function prependConstants () { | ||
var args = Array.prototype.slice.call(arguments) | ||
@@ -146,9 +133,9 @@ var lastArgIndex = args.length - 1 | ||
args.unshift(null) | ||
nextTick(next, args) | ||
process.nextTick(nextApplyFactory(next, args)) | ||
} | ||
} | ||
function selectFactory (){ | ||
function selectFactory () { | ||
var selectArgs = Array.prototype.slice.call(arguments) | ||
return function select(){ | ||
return function select () { | ||
var args = Array.prototype.slice.call(arguments) | ||
@@ -159,10 +146,10 @@ var lastArgIndex = args.length - 1 | ||
var newArgs = [] | ||
for (var i = 0; i < selectArgs.length; i++){ | ||
for (var i = 0; i < selectArgs.length; i++) { | ||
var selectArg = selectArgs[i] | ||
if (selectArg){ | ||
if (selectArg) { | ||
var arg = args[i] | ||
if (typeof selectArg === 'string' && selectArg.indexOf('/') === 0){ | ||
if (typeof selectArg === 'string' && selectArg.indexOf('/') === 0) { | ||
newArgs.push(jp.get(arg, selectArg)) | ||
} else if (selectArg instanceof Array){ | ||
for (var j = 0; j < selectArg.length; j++){ | ||
} else if (selectArg instanceof Array) { | ||
for (var j = 0; j < selectArg.length; j++) { | ||
newArgs.push(jp.get(arg, selectArg[j])) | ||
@@ -176,3 +163,3 @@ } | ||
newArgs.unshift(null) | ||
nextTick(next, newArgs) | ||
process.nextTick(nextApplyFactory(next, newArgs)) | ||
} | ||
@@ -182,5 +169,5 @@ } | ||
function debugFactory (msg, logger) { | ||
msg = msg || 'AsyncArgs:' | ||
msg = msg || 'AsyncArgs:' | ||
logger = logger || console.log | ||
return function constants() { | ||
return function constants () { | ||
var args = Array.prototype.slice.call(arguments) | ||
@@ -192,7 +179,7 @@ var lastArgIndex = args.length - 1 | ||
args.unshift(null) | ||
nextTick(next, args) | ||
process.nextTick(nextApplyFactory(next, args)) | ||
} | ||
} | ||
function AsyncArgs(lookup) { | ||
function AsyncArgs (lookup) { | ||
lookup = lookup || {} | ||
@@ -218,2 +205,2 @@ return { | ||
module.exports = AsyncArgs | ||
module.exports = AsyncArgs |
{ | ||
"name": "async-args", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "A utility for use in conjunction with async.", | ||
@@ -8,3 +8,5 @@ "main": "index.js", | ||
"test": "tape tests/*.test.js", | ||
"test-auto": "fsmonitor -s '!.*' faucet" | ||
"test-auto": "fsmonitor -s '!.*' faucet", | ||
"standard": "standard", | ||
"standard-format": "standard-format -w; standard" | ||
}, | ||
@@ -24,4 +26,6 @@ "repository": { | ||
"faucet": "0.0.1", | ||
"tape": "^4.5.1", | ||
"fsmonitor": "^0.2.4" | ||
"fsmonitor": "^0.2.4", | ||
"standard": "^6.0.8", | ||
"standard-format": "^2.1.1", | ||
"tape": "^4.5.1" | ||
}, | ||
@@ -28,0 +32,0 @@ "dependencies": { |
13809
5
176