Re:Pipe Operator (|>) For JavaScript
by ed_balls on Friday January 20, 2023 @12:17PM
(#34456334)
Quite often I rewrite the code from
```
return validate(get_response(value))
```
or
```
value = get_response(value)
value = validate(value)
return value
```
into
```
res = get_response(value)
new_res = validate(res)
return new_res
```
Why? Easier to read and when Sentry throws an error I have each value from the call stack. Much easer to debug. In the example 2 you can accidentally move a line and not notice the error.
```
return validate(get_response(value))
```
or
```
value = get_response(value)
value = validate(value)
return value
```
into
```
res = get_response(value)
new_res = validate(res)
return new_res
```
Why? Easier to read and when Sentry throws an error I have each value from the call stack. Much easer to debug. In the example 2 you can accidentally move a line and not notice the error.