Releases: dphilipson/transducist
v2.2.0
New Features
-
Now takes TypeScript type guards into account when using
filter
,remove
,takeWhile
, andfind
. For example,function isNumber(x: unknown): x is number { return typeof x === "number"; } chainFrom(["a", 1, "b", 2]) .filter(isNumber) .toArray(); // Return type inferred as number[], previously (string | number)[].
Thanks to @icehaunter for the suggestion!
v2.1.2
Bug fixes
- Fixes the CommonJS build, which was incorrectly being built the same way as the ES modules build.
v2.1.1
Bug fixes
- Fixed TypeScript return type on
.max()
and.min()
.
v2.1.0
New features
- Added
.flatten()
transform.
v2.0.0
Many improvements to typing and some new goodies. 🎉
New features
-
Chains now have
.sum()
,.min
,.max()
, and.average()
methods. Previously, to use this functionality one would writechainFrom([1, 2, 3]).reduce(toSum()); // -> 6
Now this can be written with the more ergonomic
chainFrom([1, 2, 3]).sum(); // -> 6
This is now possible to make typesafe because of TypeScript's (relatively) new conditional types.
-
Add new helpers for creating iterables: range, repeat, iterate, and cycle.
-
.toObject()
and.toObjectGroupBy()
now accept numeric or symbol keys. Previously, only strings were accepted, which led to awkward string conversions when specifying the key:chainFrom([{ id: 1, name: "asteele" }, { id: 2, name: "kkavanagh" }]) .toObject(u => u.id + "", u => u.name) .toArray(); // -> { 1: "asteele", 2: "kkavanagh" }
Now this can be written without the extra string conversion:
chainFrom([{ id: 1, name: "asteele" }, { id: 2, name: "kkavanagh" }]) .toObject(u => u.id , u => u.name) .toArray(); // -> { 1: "asteele", 2: "kkavanagh" }
Breaking Changes
-
rangeIterator()
has been removed in favor ofrange()
. Note thatrange()
differs fromrangeIterator()
in that it returns anIterable
instead of anIterator
. This has the advantage that it can be reused (the oldrangeIterable
could only be consumed once), but it is a breaking change if your code directly called iterator methods. -
Standalone
toMax()
,toMin()
,toSum()
, andtoAverage()
reductions renamed tomax()
,min()
,sum
, andaverage()
respectively, to be consistent with the new chain methods.
Fix ESModule vs CommonJS build issue
The ESM build was incorrectly being built as CommonJS, now fixed.
Use "module" field in package.json to automatically choose ES modules vs CommonJS
v1.0.2
Minor build fixes
- CommonJS distribution now marks classes as
/**@__PURE__**/
, just as the ES2015 distribution does.
v1.0.1
(Deprecated) Also distribute CommonJS module
By default, Transducist uses ES modules in order to take advantage of tree shaking optimizations in Webpack or Rollup, but this is inconvenient for use in Node environments. We now provide a CommonJS distribution as well, available as
const { chainFrom } = require("transducist/cjs");
This feature has since been deprecated. package.json
is now configured to automatically use CommonJS when needed.
v1.0.0
1.0.0 is Here 🎉
The API of this library hasn't changed for some time, and it has seen extensive production use since the last release. The time has come to announce 1.0.0 and commit to stability.
No changes since the previous version.