by thomas_moon · 5y ago · 0 comments
This example:
// Status quo
return filter(obj, negate(cb(predicate)), context);
// With pipes
return cb(predicate) |> _.negate(%) |> _.filter(obj, %, context);
Should in my opinion be written as: let result = cb(predicate)
result = _.negate(result)
result = _.filter(obj, result, context)
return result
The main benefit of this is its experience and almost language agnostic. You see a variable defined and it's run through a series of functions before being returned. What's the point of removing a few characters?edits: figure out how to format code, don't omit things
return cb(predicate) |> negate |> filter;edit: wasn't to isn't
Notably, on the first point, you proposed version drops two input variables from the other two versions, and on the second, the pipes version would correspond to the “status quo” version if the “_." prefixes were dropped.
It looks like you've made your proposed version look cleaner by both omitting required elements from it and adding unnecessary (and code-breaking) elements to the with-pipes version.