Created
April 3, 2018 11:59
-
-
Save indongyoo/9a22de092433578f3aae2e7f585a8dcd to your computer and use it in GitHub Desktop.
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
const map = curry2((f, coll) => | |
coll instanceof Function ? | |
(..._) => f(coll(..._)) | |
: | |
coll instanceof Promise ? | |
coll.then(f) | |
: | |
coll instanceof Map ? | |
reduce((m, [k, v]) => then(val => m.set(k, val), f(v)), new Map, coll.entries()) | |
: | |
hasIter(coll) ? | |
reduce((arr, v) => then(v=> (arr.push(v), arr), f(v)), [], coll) | |
: | |
isObject(coll) ? | |
reduce((o, [k, v]) => then(v => (o[k] = v, o), f(v)), {}, ObjIter.entries(coll)) | |
: | |
[] // else | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment