Created
August 19, 2016 03:54
-
-
Save zephraph/af67e3757cda6f980ee62890c24f61c9 to your computer and use it in GitHub Desktop.
Streamify the things
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 streamify = (tree) => | |
pipe( | |
keys, | |
filter(key => tree.hasOwnProperty(key)), | |
map(key => ({ | |
[`${key}$`]: typeof tree[key] === 'function' && typeof tree[key].then === 'function' | |
? (...args) => K.fromPromise(tree[key].apply(null, args)) | |
: typeof tree[key] === 'object' | |
? streamify(tree[key]) | |
: tree[key] | |
})), | |
mergeAll | |
)(tree); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment