.map is the only option here. If the problem is process return value you can do this.
.map
process
myArr.map(item => (process(item), item)) .filter( somelogic ) .map(item => postProcessSome(item));
If process doesn't mutate item that should be fine. You could even make a helper function.
item
const tap = (fn) => (value) => (fn(value), value); array.map(tap(item => process(item))) // ... the rest
Comma operator for implied return from arrow function is kinda gnarly... though I guess that's a matter of personal style preference.
TIL comma operator! Thanks!
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
.map
is the only option here. If the problem isprocess
return value you can do this.If
process
doesn't mutateitem
that should be fine. You could even make a helper function.Comma operator for implied return from arrow function is kinda gnarly... though I guess that's a matter of personal style preference.
TIL comma operator! Thanks!