DEV Community

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

baso53 profile image
Sebastijan Grabar • Edited on

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
michi profile image
Michael Z Author

Yup, unnecessary in such cases.