|
|
|
|
|
by thomas_moon
1702 days ago
|
|
Seems to be trying to solve a problem that I would consider an anti pattern (attempting to 1 line everything). Someone else mentioned temporary vars and I think thats appropriate and equal if not better syntactically. 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 |
|