Although the code has materially changed, this was originally based on the make iterator function in moutjs, and externalized to a module. Thanks to the moutjs team for the inspiration.
Copyright (c) 2012, 2013 moutjs team and contributors (http://moutjs.com)
var iterator = require('{%= name %}');
Regex
var arr = ['a', 'b', 'c', 'd', 'e', 'f'];
var fn = iterator(/[a-c]/);
console.log(arr.filter(fn));
//=> ['a', 'b', 'c'];
Objects
var fn = iterator({ a: 1, b: { c: 2 } });
console.log(fn({ a: 1, b: { c: 2, d: 3 } }));
//=> true
console.log(fn({ a: 1, b: { c: 3 } }));
//=> false