Skip to content

Instantly share code, notes, and snippets.

@rjp
Created February 7, 2011 11:26
Show Gist options
  • Save rjp/814271 to your computer and use it in GitHub Desktop.
Save rjp/814271 to your computer and use it in GitHub Desktop.
Fear my metaprogramming sk1llz
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