Comparing version 0.0.0 to 0.0.1
22
index.js
@@ -16,12 +16,28 @@ module.exports = andThen; | ||
callback = arguments[ hasFirstValue ? 1 : 0 ], | ||
params; | ||
bind, currentValue, params; | ||
function next(i/* [, currentValue ] */){ | ||
params = arguments.length > 1 ? [ arguments[1] ] : []; | ||
currentValue = arguments[1]; | ||
params = arguments.length > 1 ? [ currentValue ] : []; | ||
if(typeof functions[i] == 'string'){ | ||
bind = functions[i]; | ||
return next(i+1, currentValue); | ||
} | ||
if(bind != undefined && params[0]){ | ||
params[0] = currentValue[bind]; | ||
} | ||
params.push(function(error, newValue){ | ||
if(error) return callback(error, params[0]); | ||
if(error) return callback(error, currentValue); | ||
if(bind != undefined) { | ||
currentValue[ bind ] = newValue; | ||
bind = undefined; | ||
newValue = currentValue; | ||
} | ||
if( i + 1 >= functions.length ) return callback(undefined, newValue); | ||
@@ -28,0 +44,0 @@ |
{ | ||
"name": "andthen", | ||
"version": "0.0.0", | ||
"version": "0.0.1", | ||
"description": "Async function composition with parameter fixing abiliy.", | ||
@@ -13,3 +13,3 @@ "main": "index.js", | ||
"repository": { | ||
"url": "git@github.com:azer\/andthen.git", | ||
"url": "git@github.com:azer/andthen.git", | ||
"type": "git" | ||
@@ -16,0 +16,0 @@ }, |
@@ -21,3 +21,3 @@ ## andthen | ||
andThen(getContent, 'posts', getPosts, 'images', getImages)(function(error, contents){ | ||
andThen(getContents, 'posts', getPosts, 'images', getImages)(function(error, contents){ | ||
@@ -24,0 +24,0 @@ contents.posts |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3622
39