Skip to content

Commit

Permalink
added fab.collect, an n-ary app that eats unary apps until it sees co…
Browse files Browse the repository at this point in the history
…llect.end, at which point it returns an array of apps.
  • Loading branch information
jed committed Apr 27, 2010
1 parent 0f5739f commit 52dafba
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions apps/fab.collect.js
@@ -0,0 +1,23 @@
exports.name = "fab.collect";
exports.summary = "Collects apps until fab.collect.end appears, then returns an app that responds with the apps collected."
exports.requires = [ "fab.body" ];

var fab = { body: require( "./fab.body" ).app };

exports.app = ( function() {
collect.end = end;
return collect;

function collect( app ) {
var apps = [];

return ( function collect( app ) {
return app == end || fab.end
? fab.body( apps )
: apps.push( app ) && collect;

})( app );
}

function end(){}
})();

0 comments on commit 52dafba

Please sign in to comment.