tap(), pipe() and improved groupBy() and unique() added to Array
Folllowing flooent Strings, flooent Arrays now also provide the tap()
and pipe()
methods:
pipe
Executes callback and transforms result back into a flooent array.
const someMethodToBePipedThrough = array => array.append(1)
given([]).pipe(someMethodToBePipedThrough) // [1]
tap
Tap into the chain without modifying the array.
given([])
.append(1)
.tap(array => console.log(array))
.append(2)
// ...
Both groupBy()
and unique()
have been given the option to pass in a callback as the key to be used for comparison.
const items = [{ id: 1, name: 'music' }, { id: 2, name: 'movie' }, { id: 3, name: 'MUSIC' }]
given(items).unique(item => item.name.toLowerCase()) // [{ id: 1, name: 'music' }, { id: 2, name: 'movie' }]
const items = [{ id: 1, name: 'Music' }, { id: 2, name: 'movie' }, { id: 3, name: 'music' }]
given(items).groupBy(item => item.name.toUpperCase())