Comparing version 0.0.5 to 0.1.1
18
kgo.js
@@ -8,3 +8,3 @@ var run = require('./run'), | ||
results = {}, | ||
errorHandlers; | ||
errorHandlers = {}; | ||
@@ -20,17 +20,3 @@ function kgoFn(name, dependencies, fn){ | ||
fn = dependencies; | ||
var details = fnRegex.exec(fn.toString()); | ||
if(!details){ | ||
throw "Functions must have named arguments"; | ||
} | ||
dependencies = details[1].split(','); | ||
// We don't care about the callback | ||
dependencies = dependencies.slice(0,-1); | ||
for(var i = 0; i < dependencies.length; i++) { | ||
dependencies[i] = dependencies[i].trim(); | ||
} | ||
dependencies = []; | ||
} | ||
@@ -37,0 +23,0 @@ |
{ | ||
"name": "kgo", | ||
"version": "0.0.5", | ||
"version": "0.1.1", | ||
"description": "Flow control the super easy way", | ||
@@ -5,0 +5,0 @@ "main": "kgo.js", |
@@ -12,7 +12,7 @@ kgo | ||
kgo is black magic, use it with caution. | ||
kgo(result name, [dependencies], asynchronous function); | ||
kgo(result name, asynchronous function); | ||
where result name is an arbitrary string that can be concidered a name for the output of the function, | ||
where result name is an arbitrary string that can be concidered a name for the output of the function | ||
dependencies is an array of strings that map to the output of another function, | ||
@@ -23,3 +23,3 @@ and asynchronous function is a function that, when complete, calls a callback with its results. | ||
kgo(name, fn)(name, fn)(name, fn) | ||
kgo(name, deps, fn)(name, deps, fn)(name, deps, fn) | ||
@@ -34,6 +34,2 @@ ## Example | ||
note: functions ****MUST**** have argument names that match the named result of other functions! | ||
another note: functions ****MUST**** define a callback as the last argument. | ||
kgo('things', function(cb){ | ||
@@ -53,3 +49,3 @@ | ||
})('whatsits', function(things, stuff, cb){ | ||
})('whatsits', ['things', 'stuff'], function(things, stuff, cb){ | ||
@@ -61,3 +57,3 @@ //Something async | ||
})('dooby', function(things, cb){ | ||
})('dooby', ['things'], function(things, cb){ | ||
@@ -69,3 +65,3 @@ //Something async | ||
})(function(whatsits, dooby, cb){ | ||
})(['whatsits', 'dooby'], function(whatsits, dooby, cb){ | ||
@@ -79,8 +75,2 @@ //Done | ||
## HOW!??!?! | ||
kgo toStrings the functions, figures out their parameters, stirs over high heat, adds eye of newt and then profit. | ||
USE WITH CAUTION! | ||
## Errors | ||
@@ -92,40 +82,9 @@ | ||
kgo('things', function(cb){ | ||
//Something async | ||
setTimeout(function(){ | ||
cb(null, 1); | ||
}, 100); | ||
})('stuff', function(cb){ | ||
//Something async | ||
setTimeout(function(){ | ||
cb(new Error('Whoops')); | ||
}, 100); | ||
})(function(things, stuff, cb){ | ||
//Something async | ||
setTimeout(function(){ | ||
console.log(things, stuff); | ||
cb() | ||
}, 100); | ||
}).errors({ | ||
kgo | ||
(calles) | ||
(more calles) | ||
.errors({ | ||
'stuff':function(error){ | ||
// will recieve the Whoops error. | ||
} | ||
}); | ||
You can also use the totally safe implementation. | ||
The syntax is slightly different: | ||
kgo(name, [named results], function); | ||
But that's boring. | ||
}); |
@@ -11,14 +11,14 @@ var kgo = require('./kgo'); | ||
}, 100); | ||
})('whatsits', function(things, stuff, cb){ | ||
})('whatsits', ['things', 'stuff'], function(things, stuff, cb){ | ||
setTimeout(function(){ | ||
cb(null, things + stuff); | ||
}, 100); | ||
})('dooby', function(things, cb){ | ||
})('dooby', ['things'], function(things, cb){ | ||
setTimeout(function(){ | ||
cb(null, things/2); | ||
}, 100); | ||
})(function(whatsits, dooby, cb){ | ||
})(['whatsits', 'dooby'], function(whatsits, dooby, cb){ | ||
console.log(whatsits, dooby); | ||
})(function(whatsits, cb){ | ||
})(['whatsits'], function(whatsits, cb){ | ||
console.log(whatsits); | ||
}); |
var kgo = require('./kgo'); | ||
kgo(function things(cb){ | ||
kgo('things', function(cb){ | ||
setTimeout(function(){ | ||
cb(null, 1); | ||
}, 100); | ||
})(function stuff(cb){ | ||
})('stuff', function(cb){ | ||
setTimeout(function(){ | ||
cb('some error'); | ||
}, 100); | ||
})(function whatsits(things, stuff, cb){ | ||
})('whatsits', ['things', 'stuff'], function(things, stuff, cb){ | ||
setTimeout(function(){ | ||
cb(null, things + stuff); | ||
}, 100); | ||
})(function dooby(things, cb){ | ||
})('dooby', ['things'], function(things, cb){ | ||
setTimeout(function(){ | ||
cb(null, things/2); | ||
}, 100); | ||
})(function majigger(whatsits, dooby, cb){ | ||
})('majigger', ['whatsits', 'dooby'], function(whatsits, dooby, cb){ | ||
console.log(whatsits, dooby); | ||
@@ -21,0 +21,0 @@ }).errors({ |
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
5526
128
82