8 ms·
An easier alternative is to wrap the value into an array, then use `.map()` for each function in the chain, and finally escape the value with `[0]` I made a si
by aabbcc1241 4y ago
An easier alternative is to wrap the value into an array, then use `.map()` for each function in the chain, and finally escape the value with `[0]`
I made a similar data structure[1] to allow adding side effect (no return value) as part of the chained function.
[1] https://github.com/beenotung/tslib/blob/9f9a9274c1e13be7ba838bea644089210d802034/src/pipe.ts#L60-L79 https://github.com/beenotung/tslib/blob/9f9a9274c1e13be7ba83...
- jhardy54 4y agoThis works great for small datasets, but often you’ll have to eventually use streams rather than arrays. I’ve used pull-stream to do this in the past.
- andreareina 4y ago.use is a nice quality of life feature!
- reeeeee 4y agoIf you extract this `Chain` class to a separate package, I would gladly reuse it in my applications. I've been thinking about creating a `Vavr`[0] clone in typescript, as I really like the syntax used in that library, especially the `Try` construct. [0] https://www.vavr.io/ https://www.vavr.io/