6.0.0 - 2023-11-xx
- removed JSdoc annotations from methods, TypeScript already provides proper typing
- require Node.js v20
- migrate this package to ESM
5.0.1 - 2022-10-29
- refined typings for methods returning promise- and non-promise values
5.0.0 - 2022-10-29
- bump dependencies
- require Node.js v16, drop support for Node.js v12 and v14
4.4.0 - 2022-10-29
- bump dependencies
any|some
: only check necessary items instead of going through all items and checking the results afterwards
4.3.0 - 2022-04-02
- refine type in
forEach
allowingany
return value from the callback
4.2.0 - 2022-02-10
- refine
groupBy
typings and retrieve available keys
- bump dependencies
4.1.0 - 2022-01-09
- add
mapIf
method: runs themap
method only if the givencondition
istrue
. Otherwise returns the items unchanged
4.0.1 - 2022-01-08
- refined typings
4.0.0 - 2022-01-08
- bump dependencies
- move to UVU and c8 for testing (we previously used
@hapi/lab
and@hapi/code
)
-
use named exports
// now const { Collect } = require('@supercharge/collections') // before const Collect = require('@supercharge/collections')
-
remove synchronous collection: everything is async now and must be awaited
// now const { Collect } = require('@supercharge/collections') const numsGreater5 = await Collect([5, 6, 7]).filter(num => num > 5) // before const Collect = require('@supercharge/collections') const numsGreater5 = Collect([5, 6, 7]).filter(num => num > 5).all()
-
removed iterator support: we had iterators for synchronous collections in
@supercharge/collections
v3. Because@supercharge/collections
v4 is now fully async, we’re going to add async iterators. In a later feature release. For now, we’re shipping v4 without async iterators. We appreciate a pull request if you want to add iterator support :)
3.2.1 - 2021-11-05
- bump dependencies
- change order of typings allowing the compiler to pick the stricter ones first
3.2.0 - 2021-10-13
- add iterator support to synchronous collections
- bump dependencies
- run tests for Node.js v16
- rename
master
branch tomain
- refactor tests to remove the dependency for Sinon
- remove Sinon dependency
3.1.4 - 2021-02-05
- fixed types for
first
andshift
3.1.3 - 2021-01-28
- fixed another typing issue for
flatMap
3.1.2 - 2021-01-07
- fixed typings for
map
andflatMap
3.1.1 - 2021-01-03
- fixed types: make
predicate
parameter optional forCollection#first
3.1.0 - 2020-12-02
- bump dependencies
- change typings to allow single values and arrays (
T | T[]
) when creating collections
3.0.0 - 2020-09-03
- synchronous collections by default
- all collections were async by default until versions
2.x
, you had to await every collection pipeline - this changes with the release of version
3.0
: all collections are sync by default - synchronous collections work like JavaScript’s array methods
- you must explicitly call
collection.all()
to retrieve the resulting array from a synchronous collection
- all collections were async by default until versions
- a collection becomes async as soon as you provide an async callback method to methods like
map
,filter
,find
, and so on:
- bump dependencies
- change
main
entrypoint inpackage.json
todist
folder
- remove
index.js
file which acted as a middleman to export fromdist
folder
- collections are now synchronous by default, meaning you don’t need to await a collection if you’re not using an async callback
Synchronous collections work like JavaScript’s Array methods. For example, the following pipeline stays a synchronous pipeline:
const Collect = require('@supercharge/collections')
const collection = Collect([1, 2, 3, 4, 5])
.map(item => item * 2)
.filter(item => item > 5)
.sort((a, b) => b -a)
// on sync collections, you must explicitly call `.all()` to retrieve the result
const result = collection.all()
// [10, 8, 6]
In comparison, a collection becomes async as soon as you provide an async callback method to methods like map
, filter
, find
, and so on:
const Collect = require('@supercharge/collections')
const collection = Collect([1, 2, 3, 4, 5])
.map(async item => item * 2) // the collection is async from here on
.filter(item => item > 5)
.sort((a, b) => b -a)
// async collections must be awaited
const result = await collection
// [10, 8, 6]
2.4.0 - 2020-07-21
uniqueBy(callback)
method: create a collection of unique items where each unique item is identified by a value returned from thecallback
- GitHub Action to publish the package in the GitHub Package Registry
2.3.0 - 2020-07-19
flatten()
method: flatten the collection one level deep- typed collections: improved TypeScript type definitions enable IntelliSense (when possible) inside callback methods
2.2.0 - 2020-07-02
filterIf(condition, callback)
method: a variant of the thefilter
method only filtering the collection if thecondition
evaluates to true
2.1.0 - 2020-06-30
count
method
2.0.0 - 2020-05-21
- TypeScript typings
- collection pipelines are now awaitable: no need to call
.all()
to retrieve the result- before:
await Collect([1, 2, 3]).map(...).filter().all()
- now:
await Collect([1, 2, 3]).map(...).filter()
- before:
- bump dependencies
- moved code base to TypeScript to automatically generate type definitions
- all
xSeries
methods become the default and were removed- for example:
mapSeries
becomesmap
and themapSeries
method was removed - the methods running async functions in parallel were removed in favor of the sequence versions
- I found myself defaulting to the
xSeries
methods because I typically don’t want to handle the side-effects of parallel processing on a large collections. That’s why the methods iterating over the items in sequence are the new default.
- for example:
Note: there are no new xParallel
methods to fill the gap for the missing methods processing async tasks in parallel. If you need the parallel methods, I’m happy to support you on a pull request.
1.13.0 - 2020-03-26
unique
supports a string or callback function as a parameter to identify unique values
1.12.2 - 2020-03-12
findSeries
now stops when the first matching item is found
1.12.1 - 2020-03-12
has
: usesfindSeries
instead offind
to determine whether the condition matches
1.12.0 - 2020-02-11
.pluck()
method.any()
method as an alias for.some()
.anySeries()
method as an alias for.someSeries()
- bump deps
1.11.0 - 2020-01-30
.groupBy()
method
- bump deps
1.10.0 - 2020-01-22
.tap()
method.hasDuplicates()
method
- an empty value creates an empty collection, example:
Collect(null).all()
returns an empty array[]
1.9.1 - 2020-01-07
- reduce package size by defining published
files
inpackage.json
- bump deps
- refine example in readme
.travis.yml
and moved to GitHub Actions for testing
1.9.0 - 2019-10-26
.pop()
method
1.8.0 - 2019-10-24
.last()
method
- bump deps
1.7.0 - 2019-10-11
.median()
method
1.6.0 - 2019-10-10
.sum()
method.avg()
method.min()
method.max()
method.join()
method.sort()
method.diff()
method.union()
method.intersect()
method.toJSON()
method.reverse()
method
- bump dependencies
1.5.1 - 2019-09-24
- bump dependencies
- refine examples in Readme
1.5.0 - 2019-09-23
.has()
method.first()
method.clone()
method.unshift()
method
1.4.1 - 2019-07-25
- Initializing the Collection won't automatically flatten the given array
1.4.0 - 2019-07-24
.someSeries()
method.everySeries()
method
- clone the array passed to the collection to remove the reference. This ensures that collection operations won't affect the original array's data
1.3.0 - 2019-07-23
.push()
method.shift()
method.concat()
method
1.2.1 - 2019-07-19
- keywords in
package.json
1.2.0 - 2019-07-19
.chunk()
method.slice()
method.splice()
method.findSeries()
method.filterSeries()
method.rejectSeries()
method.take()
method.takeAndRemove()
method
- internal refactoring from individual files for each method to a single
Collections
class - added NPM script to list all tests (
npm run list-tests
) - added NPM script to run a single test (
npm run test single <id>
: get the ID from the list of tests)
1.1.0 - 2019-07-15
.size()
method.isEmpty()
method.isNotEmpty()
method.reject()
method (as an inverse method to.filter()
).forEachSeries()
method (it was implemented for 1.0, but not exported 😅)
- bump dev dependencies
- refined docblocks for methods
1.0.0
release 🚀 🎉