4.5.0 - 2024-07-xx
- static
from
: improve typing for returned instance type. This allows subclassing theArr
class and receiving the correct class instance type
4.4.0 - 2024-02-20
compact
: refined return type for truthy values
sort
: make thecomparator
parameter optional- bump dependencies
- bump dependencies in GitHub Actions testing workflow
4.3.0 - 2023-03-12
- implement the
Iterable
interface via[Symbol.iterator]
to allow iterators andfor..of
loops
- bump dependencies
4.2.0 - 2022-12-28
join(separatorOrCallback, finalGlue?)
method now supports a callback function as a separator and a final glue string. The final glue will be used to join the last item onto the resulting string
- bump dependencies
- refined package exports
4.1.0 - 2022-11-02
reject
method: inverse offilter
, removing all items satisfying the provided callback functionunique
method: keep only unique items in the arrayuniqueBy
method: keep only unique items in the array identified by a givenselector
function
- bump dependencies
isIterable
now checks whether the given input implements aSymbol.iterator
function
4.0.0 - 2022-08-08
append
method: an alias for thepush
method, adding an item to the end of the arrayprepend
method: an alias for theunshift
method, adding an item to the beginning of the array
- bump dependencies
- require Node.js v16 or higher; drop support for Node.js v12 and v14
3.2.0 - 2022-05-06
- support callback in
groupBy
const products = [ { name: 'Macbook', price: 2500 }, { name: 'Macbook', price: 3000 }, { name: 'iPhone', price: 1000 } ] Arr.from(products).groupBy(product => { return product.name }) // Macbook: [ // { name: 'Macbook', price: 2500 }, // { name: 'Macbook', price: 3000 } // ], // iPhone: [ // { name: 'iPhone', price: 1000 } // ]
- bump dependency
3.1.0 - 2022-03-22
forEach
: perform a givenaction
for each item in the array
3.0.0 - 2022-03-12
- refine the array creation when using strings
- using
Arr.from
with strings will wrap the string values into an array instead of creating an array of the string’s individual characters - the changed string handling now properly resolves return values when using the
diff
method
2.2.0 - 2022-02-22
has(valueOrCallback)
method: added support for a callback function in thehas
method allowing users a refined handling to determine if a value is included in the array
- bump dependency
2.1.0 - 2022-02-11
reduce()
method: runs a given reducer function on each item in the array and passes the accumulator to the next iterationgroupBy()
method: group the array by a given key
2.0.0 - 2022-01-21
- export the
Arr
full class - improved typing for the
isArray
andisNotArray
methods detecting whether the given input is an array has()
method: determine whether the array contains a given valueisMissing()
method: determine whether the array is missing a given valuemap()
method: returns a new array instance containing the results of applying a given transform function to each item in the arrayflatMap()
method: returns a new array instance containing the results of applying a given transform function to each item in the array and flatten the mapped results one level deep
- moved the static
from
,isArray
, andisNotArray
methods to theArr
class
Arr.from
does not accept a mapping function anymore- I don’t use this feature and it caused troubles with the setup
- a workaround to run a mapping function:
Arr.from(...items).map(…)
- you must use
Arr.from(...items)
instead ofArr(...items)
// before import { Arr } from '@supercharge/arrays' const array = Arr([1, 2, 3]) // now import { Arr } from '@supercharge/arrays' const array = Arr.from([1, 2, 3])
1.2.0 - 2022-01-12
- static
.from(iterable)
method: works likeArray.from
, transforms and wraps the giveniterable
toArray()
method: returns the wrapped values as a plain JavaScript array (it’s an alias forall()
)
1.1.0 - 2022-01-10
at(index)
method: returns the item at the givenindex
orundefined
if the index exceeds the arrayfind(predicate)
: returns the first item in the array matching the givenpredicate
function, orundefined
if no such item was foundfindIndex(predicate)
: returns the index of the first element in the set where the givenpredicate
function istrue
. Returns -1 otherwiselast(predicate?)
: returns the last array item when called without a predicate function. If you provide a predicate function this method is an alias forfindLast
findLast(predicate)
: returns the last item in the set matching the given predicate function
1.0.1 - 2022-01-07
- bump dependencies
- refined typings making sure the raw input type is resolved properly
1.0.0
release 🚀 🎉