Skip to content

Instantly share code, notes, and snippets.

@kiris
Created February 28, 2014 04:36
Show Gist options
  • Save kiris/9265331 to your computer and use it in GitHub Desktop.
Save kiris/9265331 to your computer and use it in GitHub Desktop.
function collect(array, fn, scope) {
var results = [],
r,
i = 0,
index = 0,
len = array.length;
for (; i < len; i++) {
r = fn.call(scope, array[i], i, array);
if (r !== null) {
results[index] = r;
index++;
}
}
return results;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment