Forbid the use of _.chain
In lodash/fp
, it is not recommended to use _.chain(x)
or _(x)
to chain commands. Instead, it is recommended to use _.flow
/_.compose/_.flowRight
.
For more information on why to avoid _.chain
, please read this article
const value = [1, 2, 3];
_(value)
.filter(x => x > 1)
.map(x => x * x)
.value();
_.chain(value)
.filter(x => x > 1)
.map(x => x * x)
.value();
_.flow(
_.filter(x => x > 1),
_.map(x => x * x)
)(value);
_.compose(
_.map(x => x * x),
_.filter(x => x > 1)
)(value);