Created
February 7, 2011 11:26
-
-
Save rjp/814271 to your computer and use it in GitHub Desktop.
Fear my metaprogramming sk1llz
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 sys = require('sys'); | |
var l = [ | |
{ unread: 4, sub: 1 }, | |
{ unread: 0, sub: 1 }, | |
{ unread: 4, sub: 0 } | |
]; | |
filters = process.env.filter; if (filters == undefined) { filters = ""; } | |
a = ['true']; | |
if (filters.match(/\bsub\b/)) { a.push("d.sub"); } | |
if (filters.match(/\bunread\b/)) { a.push("d.unread > 0"); } | |
b = "g=function(a,f,d,c){if("+a.join(' && ')+"){c(true,d);}else{c(false,undefine | |
d);}}"; | |
eval(b); | |
for(var x in l) { | |
g(1,1,l[x],function(t,d){sys.puts(t+" "+sys.inspect(d))}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment