Skip to content

Instantly share code, notes, and snippets.

@boombang
Created April 6, 2019 18:30
Show Gist options
  • Save boombang/f8d6ea2cf954084f7043fd77efddc214 to your computer and use it in GitHub Desktop.
Save boombang/f8d6ea2cf954084f7043fd77efddc214 to your computer and use it in GitHub Desktop.
//array.js
export function each(collection, callback) {
//something interesting
}
export function filter(collection, callback) {
//something interesting
each(collection, ...)
//something interesting
}
export function map(collection, iterator) {
//something interesting
each(collection, ...)
//something interesting
}
export function reduce(collection, iterator, accumulator) {
//something interesting
each(collection, ...)
//something interesting
}
//index.js
import * as Utils from ‘./utils.js’;
Utils.each([1, 2, 3], function(x) { console.log(x) });
//or
import * as Utils from ‘./utils.js’;
Utils.filter([1, 2, 3], function(x) { return x === 2 });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment