Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.