- Officially drop Node 16 support (it may still work)
- Fix missing top-level exports for
izipLongest3
andintersperse
- Actually export the new itertool at the top level
- Add new
dupes(iterable, keyFn?)
function, which returns groups of all duplicate items in iterable.
- Add missing export for
repeat
- Type output types of all itertools more precisely
Fixes a bug where some iterators would render an inputted generator unusable, causing it to no longer be consumable after the iterable returns.
Example:
function* gen() {
yield 1;
yield 2;
yield 3;
yield 4;
}
const lazy = gen();
// [1, 2]
Array.from(islice(lazy, 0, 2));
Array.from(lazy);
// ❌ Previously: []
// ✅ Now correctly: [3, 4]
This bug only happened when the source was a generator. It did not happen on a normal iterable.
Similar bugs were present in:
find()
islice()
takewhile()
dropwhile()
No other iterables were affected by this bug. This is the same bug that was
fixed in 2.2.2 for reduce()
, so many thanks again for surfacing this edge
case, @quangloc99! 🙏
- Fix
reduce()
bug where using it on a lazy generator would produce the wrong result (thanks for finding, @quangloc99 🙏!)
- Fix
islice()
regression where it wasn't stopping on infinite iterables (thanks for finding, @Kareem-Medhat 🙏!)
- Move to ESM by default
- Drop support for node 12.x and 14.x
(they probably still work, but they're EoL)
- Improve tree-shakability when used in bundlers
- Improve documentation
- Fix a bug in
reduce()
in a very small edge case
The following functions retain richer type information about their arguments:
ifilter()
filter()
partition()
For example, TypeScript will now know the following:
const items = [3, "hi", -7, "foo", 13];
function isNum(value: unknown): value is number {
return typeof value === "number";
}
const numbers: number[] = filter(items, isNum); // ✅
const [numbers, strings] = partition(items, isNum); // ✅
// ^^^^^^^ ^^^^^^^ string[]
// number[]
-
Add new
find(iterable, pred)
function, which is almost the same asfirst(iterable, pred)
but behaves slightly more intuitive in the case where no predicate function is given. -
Fix bug in
chunked()
withsize=1
Breaking changes:
- Rewritten source code in TypeScript (instead of Flow)
- Modern ESM and CJS dual exports (fully tree-shakable when using ESM)
- Massively reduced bundle size
- Targeted ES2015 (instead of ES5)
- Support only TypeScript versions >= 4.3
- Drop Flow support*
- Drop Node 10.x support
icompact
,compact
, andcompactObject
functions will now also removenull
values, not onlyundefined
(*: I'm still open to bundling Flow types within this package, but only if
that can be supported in a maintenance-free way, for example by using a script
that will generate *.flow
files from TypeScript source files. If someone can
add support for that, I'm open to pull requests! 🙏 )
- Add missing re-export of
islice
at the top level
- TypeScript support!
- Declare official support for Node 16.x
- Drop support for Node 13.x (unstable release)
- Include an error code with every FlowFixMe suppression (Flow 0.132.x compatibility)
- New itertool:
heads()
- Export
roundrobin()
at the top level
- Fix bug in
chunked()
when input is exactly dividable
- Export
count()
function at the top level 🤦♂️
- Internal change to make the code Flow 0.105.x compatible. Basically stops
using array spreads (
[...things]
) in favor ofArray.from()
.
- Remove direct code dependency on
regenerator-runtime
(let@babel/runtime
manage it)
- Switch to Babel 7
- Export
filter
at the top level
- New build system
- Cleaner NPM package contents
- Drop support for Node 7
- Make itertools.js fully Flow Strict
- Export
permutations()
at the top-level
- Add port of
groupby()
function (see #87, thanks @sgenoud!)
- declare library to be side effect free (to help optimize webpack v4 builds)
- Include regenerator runtime via babel-runtime
- Make
regenerator-runtime
a normal runtime dependency
- Lower required version of
regenerator-runtime
- Properly declare dependency on
regenerator-runtime
- Fix bug in
cycle()
with infinite inputs
Started keeping a CHANGELOG.