Skip to content

Instantly share code, notes, and snippets.

@icyJoseph
Created June 13, 2018 04:36
Show Gist options
  • Save icyJoseph/729f18a57c8e6b498f40690c12b14574 to your computer and use it in GitHub Desktop.
Save icyJoseph/729f18a57c8e6b498f40690c12b14574 to your computer and use it in GitHub Desktop.
Functional Pack
export const curry = f => a => (...b) => f(a,...b)
export const pipe = (...funcs) => (...args) => funcs.reduce((res, func, i) => (i === 0 ? func(...res) : func(res)), args);
export const mapf = (func, arr) => arr.map(func);
export const filterf = (func, arr) => arr.filter(func);
export const flatten = arr => [].concat(...arr);
export const take = (n, m = 0) => arr => arr.slice(m, n + m);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment