Add Map.rename, Array.move, and more
Added
rename
Renames the given key with the new key if found, keeping the original insertion order.
given.map({ one: 1, to: 2, three: 3 })
.rename('to', 'two')
.keys() // ['one', 'two', 'three']
move
Moves an item in the array using the given source index to either "before" or "after" the given target.
given.array(['b', 'a', 'c']).move(0, 'after', 1) // ['a', 'b', 'c']
given.array(['b', 'a', 'c']).move(0, 'before', 2) // ['a', 'b', 'c']
given.array(['b', 'a', 'c']).move(1, 'before', 0) // ['a', 'b', 'c']
Pointer API additions
value
Returns the value for current pointer position.
given.array(['music', 'tech']).at(1).value() // ['music', 'tech']
step
Steps forward or backwards given the number of steps.
given.array(['music', 'tech']).at(1).step(-1).value() // ['music']
Fixes
- The callback in
Array.reject
now accepts the index as the second argument