v1.1.0 — Equatable & Cloneable contracts
Highlights
Two new cross-cutting contracts for value-object types are introduced, and Point is the first to adopt them.
What's new
Equatable<T>
interface Equatable<T> {
isEqualWith(other: T): boolean;
}Purpose: explicit, type-safe value equality for immutable types.
Cloneable<T>
interface Cloneable<T> {
clone(): T;
}Purpose: request an independent copy of a value object without relying on structural tricks.
Point now implements both
const a = new Point(3, 5);
const b = a.clone();
a.isEqualWith(b); // true
a === b; // falsePoint.isEqualWithuses exact coordinate equality (===). No epsilon tolerance — this keeps behavior predictable; usetoBeCloseToin tests or a dedicated helper when floating-point slack is needed.Point.clone()returns a brand-newPointinstance with identical coordinates.
Public API additions
Equatable<T>— exported from the root of the package.Cloneable<T>— exported from the root of the package.Point.isEqualWith(other: Point): booleanPoint.clone(): Point
Internal changes
- New directory
src/contracts/hosts cross-cutting interfaces. Re-exported viasrc/index.ts. - CI pipeline (
.github/workflows/ci.yml) and publish pipeline (.github/workflows/publish.yml) added. - Biome rule
style.useBlockStatements: errorenabled.
Tests & coverage
- Test count: 132 → 142 (9 new tests for
isEqualWith/clone, plus one Polyline test tweak). - Coverage stays at 100% on statements, branches, functions, and lines.
Compatibility
- Non-breaking. All prior APIs are unchanged.
- Node.js
>= 18, TypeScript>= 4.5.
What's next
- Adopt
Equatable/CloneableonBoundingBox,Segment,Polyline,Rectangle, andShapeGroupin a follow-up release.
Full changelog: v1.0.0...v1.1.0