How to pipe? #217
-
Hey team, comparable libraries provide the option to pipe operations, i.e.: const DATA = [
{ name: "john", age: 20, gender: "m" },
{ name: "marry", age: 22, gender: "f" },
{ name: "samara", age: 24, gender: "f" },
{ name: "paula", age: 24, gender: "f" },
{ name: "bill", age: 33, gender: "m" },
];
_(DATA)
.filter((x) => x.gender === "f")
// ^ 'x' should be typed properly as a Record
.groupBy((x) => x.age)
// ^ same here
.value();
I am familiar with chain and compose however all the examples point to custom functions, as opposed to the first party Radashi functions. I suspect this is because Radashi always expects the data as an input. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hey @yamcodes, thanks for bringing this up. Your example appears to be an anti-pattern, since tree-shaking wouldn't be possible. However, I'd be open to a PR that makes it easier to combine Radashi functions with Alternatively, there are many popular, actively maintained, FP-focused libraries to choose from, like fp-ts or ramda (though I can't vouch for their quality). As such, it's not an explicit goal of Radashi to compete in that arena. |
Beta Was this translation helpful? Give feedback.
Hey @yamcodes, thanks for bringing this up. Your example appears to be an anti-pattern, since tree-shaking wouldn't be possible. However, I'd be open to a PR that makes it easier to combine Radashi functions with
chain
andcompose
(presumedly by re-arranging the data arguments to be last in an optionalradashi/fp
submodule).Alternatively, there are many popular, actively maintained, FP-focused libraries to choose from, like fp-ts or ramda (though I can't vouch for their quality). As such, it's not an explicit goal of Radashi to compete in that arena.