Skip to content

Instantly share code, notes, and snippets.

@0xlkda
Last active August 15, 2019 07:57
Show Gist options
  • Save 0xlkda/898a1c8fb3320767e0ee54ecb10e7568 to your computer and use it in GitHub Desktop.
Save 0xlkda/898a1c8fb3320767e0ee54ecb10e7568 to your computer and use it in GitHub Desktop.
Snippets
// Dead simple functions
const curry = fn => (...args) => fn.bind(null, ...args);
const map = curry((fn, arr) => arr.map(fn));
const join = curry((str, arr) => arr.join(str));
const split = curry((splitOn, str) => str.split(splitOn));
// keyBy :: String -> Array -> Object
const keyBy = curry((keyField, arr) =>
Object.assign({}, ...arr.map(item => ({[item[keyField]]: item}))));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment