-
-
Save bga/1923417 to your computer and use it in GitHub Desktop.
z
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var match = [] | |
var _finalizeExpr = function(match) { | |
var vs = match[0] | |
var _iter = match[1] | |
var _done = match[2] | |
var i = 0 | |
var _iterWrappper = function() { | |
if(i === vs.length) { | |
_done() | |
} | |
else { | |
_iter(vs[i], _iterWrappper) | |
i++ | |
} | |
} | |
_iterWrappper() | |
}; | |
([Array, Fn] | |
.map(function(v) { | |
return v.prototype | |
}) | |
.forEach(function(v) { | |
v.valueOf = function() { var that = this; | |
_log(typeof(that)) | |
if( | |
that instanceof Array && match.length === 0 | |
|| that instanceof Fn && match.length === 1 | |
|| that instanceof Fn && match.length === 2 | |
) { | |
match.push(that) | |
if(match.length === 3) { | |
_finalizeExpr(match.concat()) | |
match = [] | |
} | |
} | |
else { | |
_log('break') | |
match = [] | |
} | |
} | |
}) | |
); | |
([1, 2, 3] | |
| function(v, _next) { | |
setTimeout(function() { | |
_log(v) | |
_next() | |
}, 1000) | |
} | |
| function() { | |
_log('end') | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cute hack.