Skip to content

Instantly share code, notes, and snippets.

@indongyoo
Last active April 3, 2018 12:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save indongyoo/4ea5e0934a42e1066419fb4afb6ffad4 to your computer and use it in GitHub Desktop.
Save indongyoo/4ea5e0934a42e1066419fb4afb6ffad4 to your computer and use it in GitHub Desktop.
const { map } = Functional;
console.log( map(a => a + 1, [1, 2]) );
// [2, 3]
console.log( map(a => a + 1, {a: 1, b: 2}) );
// {a: 2, b: 3}
console.log( map(a => a + 1, new Map([['a', 1], ['b', 2]])) );
// Map(2) {"a" => 2, "b" => 3}
console.log( map(a => a + 1, Promise.resolve(1)) );
// Promise {<resolved>: 2}
const f = map(a => a + 1, _=> 1);
console.log(f);
// (..._) => f(coll(..._))
console.log(f());
// 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment