Skip to content

Instantly share code, notes, and snippets.

@Lexicality
Created October 28, 2015 19:30
Show Gist options
  • Save Lexicality/13154874845eeab4a3b3 to your computer and use it in GitHub Desktop.
Save Lexicality/13154874845eeab4a3b3 to your computer and use it in GitHub Desktop.
filter = function(pred, iterable) {
return {
[Symbol.iterator]: () => {
const it = iterable[Symbol.iterator]();
return {
next: () => {
let next;
while (next = it.next(), !next.done) {
if (!pred(next.value)) {
continue;
}
break;
}
return next;
}
};
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment