Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const myFunctions = {
- 'filter': predicate => function*() {
- for (const item of this) {
- if (predicate(item)) {
- yield item;
- }
- }
- },
- 'map': mapper => function*() { /* ... */ }
- };
- for (const fun of Object.keys(myFunctions)) {
- List.prototype[fun] = function (...args) {
- return new List(myFunctions[fun].apply(this, args));
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement