Last active
August 15, 2019 07:57
-
-
Save 0xlkda/898a1c8fb3320767e0ee54ecb10e7568 to your computer and use it in GitHub Desktop.
Snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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