Created
May 31, 2018 10:46
-
-
Save Announcement/a8aed599ca2ab30adda4713166849292 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const pickByName = (obj, prop) => obj[prop]; | |
const pickAndTransformValue = (obj, [prop, transformer]) => | |
transformer(obj[prop]); | |
const addProps = (obj, [prop, secondProp]) => obj[prop] + obj[secondProp]; | |
const $pickByName = object => property => object[property] | |
const $pickAndTransformValue = object => ([property, transformer]) => transformer(object[property]) | |
const $addProps = object => ([prop, secondProp]) => object[prop] + object[secondProp]; | |
const $$pickByName = curry(pickByName) | |
const $$pickAndTransformValue = curry(pickAndTransformValue) | |
const $$addProps = curry(addProps) | |
function curry (f) { | |
let $args = [] | |
return g | |
function g (...xyz) { | |
if ($args.length + xyz.length < f.length) { | |
$args = $args.concat(xyz) | |
return g | |
} | |
return f(...$args, ...xyz) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment