Skip to content

Instantly share code, notes, and snippets.

@zephraph
Created August 19, 2016 03:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zephraph/af67e3757cda6f980ee62890c24f61c9 to your computer and use it in GitHub Desktop.
Save zephraph/af67e3757cda6f980ee62890c24f61c9 to your computer and use it in GitHub Desktop.
Streamify the things
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