DEV Community

Discussion on: Turn any non fluent API into a fluent one - tap tap tap

Collapse
 
baso53 profile image
Sebastijan Grabar • Edited

This only works for mutable operations on data structures. Image you use the filter function on the array (or map or reduce).

const { tap } = require('taptaptap');

const arr = [1, 2, 3];
const mappedArr = tap(arr).map(val => val * 2);

mappedArr[0] === arr[0] // the value returned from the map function is the old array
Collapse
 
michi profile image
Michael Z

Yup, unnecessary in such cases.