Skip to content

v2.0.0

Latest

Choose a tag to compare

@ppeeou ppeeou released this 08 Aug 08:19
· 9 commits to main since this release

v2.0.0

FxTS v2 modernizes the entire toolchain: faster runtime output, 22 new utilities,
literal-preserving type inference, and packaging that is verified correct in every
module-resolution mode.

💥 Breaking Changes

TypeScript 5.5+ is now required

The supported minimum moves from TS 4.2 to TS 5.5 (released June 2024), in line
with the current ecosystem baseline. This enables the new literal-preserving
inference below.

The es5 build tier is removed

dist/cjs and dist/esm now both target es2018 (Node.js 10+ and all modern JS
engines), and the @fxts/core/esm5 subpath is gone. If you target legacy (ES5-only)
browsers, transpile node_modules with your bundler, or use the CDN UMD bundle
(fx.min.js, still es5 + polyfill).

Corrected typings for moduleResolution: node16/nodenext

ESM consumers previously received CommonJS-typed declarations. Typings are now
format-matched, so code that relied on the incorrect CJS typing (e.g.
import fxts = require("@fxts/core") from ESM) will surface proper type errors.

⚡ Performance

The CJS build (the package main, what Node.js servers load) is no longer
down-leveled to ES5. Lazy pipelines run 1.5–1.8× faster on Node
(pipe(map + filter + toArray): ~222ms → ~128ms, 1,000 elements × 2,000 iterations,
Node 24) with native iteration instead of tslib helper calls.

✨ 22 New Functions

  • Object — merge (immutable deep merge, prototype-pollution safe), cloneDeep
    (circular refs, class instances, Map/Set/TypedArray), mapValues, mapKeys,
    zipObject
  • Aggregation — minBy / maxBy / sumBy / meanBy (Iterable & AsyncIterable,
    curried)
  • Lazy — union, windowed (overlapping sliding windows, the counterpart of
    chunk)
  • Predicate — isEqual (deep equality), isPlainObject, isFunction,
    isNotNil (narrows T | null | undefined to T — pairs with filter)
  • String — camelCase, kebabCase, snakeCase, capitalize (unicode-aware
    word splitting)
  • Misc — once, escapeRegExp, castArray

🎯 Sharper Type Inference

const type parameters preserve literal keys without as const:

zipObject(["a", "b"], [1, 2]);
// v1: Record<string, number> → v2: Record<"a" | "b", number>

countBy((a) => a.type, [{ type: "x" }, { type: "y" }]);
// v1: Record<string, number> → v2: { x: number; y: number }
groupBy / indexBy infer per-key result types the same way. On TS 5.5+,
partition also benefits from inferred type predicates for plain boolean callbacks.

📦 Packaging
arethetypeswrong reports zero problems across node10 / node16-CJS /
node16-ESM / bundler for every subpath — format-split typings, restored deep-import
types (@fxts/core/Lazy/take) for classic resolution, and a CI gate that keeps it
that way.