| /* [ '1:2', '3:4', '5:6' ] */ | ||
| var zip = require('./hof').zip_with; | ||
| zip(function concat(a,b) { return a + ':' + b; }, | ||
| [1,3,5], [2,4,6,8], [], function (ac) { | ||
| console.error(ac); | ||
| }); |
+1
-1
| { "name" : "p" | ||
| , "description" : "pattern matching in javascript for asyncronous iteration" | ||
| , "author" : "nuno job <nunojobpinto@gmail.com> (http://nunojob.com/)" | ||
| , "version" : "0.0.3" | ||
| , "version" : "0.0.4" | ||
| , "main" : "./pattern.js" | ||
@@ -6,0 +6,0 @@ , "homepage" : "https://github.com/dscape/p" |
+4
-3
@@ -12,4 +12,4 @@ (function () { // stack refers to registered patterns | ||
| if(arity===arguments.length) { // # arguments match arity, execute | ||
| var j = 0; // we need explicit control over j, cant be reset by :il | ||
| ol: for(var i=0; i<arguments.length; i++) { // for each argument | ||
| var j = 0, i=0; // we need explicit control over vars | ||
| ol: for(; i<arguments.length; i++) { // for each argument | ||
| il: for(; j<stack.length; j++) { // for pattern in the stack | ||
@@ -27,4 +27,5 @@ var s = stack[j]; // get the current pattern | ||
| log(' ✗ ', s[i], '===', arguments[i]); | ||
| i=0; | ||
| // dont break and set ok to false if this is the last element | ||
| if(stack.length!==j+1) { j=0; log(' ⥁'); continue; } } } | ||
| if(stack.length!==j+1) { log(' ⥁'); continue; } } } | ||
| var f = s[s.length-1]; | ||
@@ -31,0 +32,0 @@ log(' ' + (typeof f === 'function' ? 'ƒ' : 'λ'), f.name || f); |
+1
-1
@@ -32,3 +32,3 @@ var map = require('../pattern') | ||
| zip_with(f, l1, l2, ac, cb, function all(f, l1, l2, ac, cb) { | ||
| ac.push(f(l1.shift, l2.shift)); | ||
| ac.push(f(l1.shift(), l2.shift())); | ||
| zip_with(f, l1, l2, ac, cb); | ||
@@ -35,0 +35,0 @@ }); |
| var zip = require('./hof').zip_with; | ||
| zip(function concat(a,b) { return a + ':' + b; }, | ||
| [1,3,5], [2,4,6,8], [], function (ac) { | ||
| console.log(ac); | ||
| }); |
11049
0.26%178
1.14%