Skip to content

Modernize to v2.0.0 — TypeScript, ESM-only, universal clock - #12

Merged
onury merged 6 commits into
masterfrom
v2-modernize
Jul 23, 2026
Merged

Modernize to v2.0.0 — TypeScript, ESM-only, universal clock#12
onury merged 6 commits into
masterfrom
v2-modernize

Conversation

@onury

@onury onury commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Ground-up modernization of perfy to the current package standard. Breaking release → 2.0.0.

Highlights

  • ESM-only TypeScript rewrite. src/ (Perfy, PerfyItem, PerfyError, clock, IPerfyResult); build is tsc → lib/, no bundler.
  • Universal high-resolution clock. Prefers process.hrtime.bigint() (exact integer nanoseconds on Node.js), falls back to performance.now() in browsers/Deno/Bun/workers. Elapsed time is computed with integer-nanosecond math (no float drift). Closes the long-standing browser-support request.
  • Streamlined, JSON-safe result object — dropped the redundant full* aliases and seconds; milliseconds/nanoseconds now report totals.
  • PerfyError with stable machine-readable codes.
  • Perfy class for isolated registries + an injectable clock (deterministic tests).

Quality

  • 100% coverage (statements, branches, functions, lines) + 100% Stryker mutation score (93/93 killed).
  • Biome + Vitest + Stryker; CI on Node.js 22 & 24.

Breaking changes

  • require('perfy') removed — use import perfy from 'perfy'.
  • Node.js ≥ 22 (older runtimes/browsers via the performance.now() fallback).
  • Result object streamlined — see the migration table in CHANGELOG.md.

npm publish remains a manual step for the maintainer after merge & release.

onury added 2 commits July 23, 2026 02:11
Full rewrite of perfy to the current package standard:

- ESM-only TypeScript; build is tsc -> lib/ (no bundler).
- Universal high-resolution clock: process.hrtime.bigint() preferred,
  performance.now() fallback — runs in Node.js, browsers, Deno and Bun
  (closes the long-standing browser-support request). Elapsed time is
  computed with integer-nanosecond math, avoiding float drift.
- Streamlined, JSON-safe result object (dropped redundant aliases;
  milliseconds/nanoseconds now report totals).
- PerfyError with stable machine-readable codes.
- Perfy class for isolated registries + injectable clock.
- Biome + Vitest + Stryker: 100% coverage (4 metrics) and 100% mutation
  score; CI on Node 22 & 24.

BREAKING CHANGE: ESM-only — require('perfy') no longer works, use
`import perfy from 'perfy'`. Requires Node.js >= 22 (browsers/Deno/Bun
via the performance.now() fallback). The result object was streamlined:
`seconds`, `fullSeconds`, `fullMilliseconds` and `fullNanoseconds` are
removed, and `milliseconds`/`nanoseconds` now report the total elapsed
time. See CHANGELOG.md for the migration table.
A zero-arg task that returns a thenable is now awaited; exec resolves to
the IPerfyResult once it settles (rejections propagate). The callback
(done) and synchronous forms are unchanged. 100% coverage + mutation.
onury added 4 commits July 23, 2026 02:38
Aligns with the house style (accesscontrol/configuard export named) and
modern ESM/TS guidance: one canonical import name, better greppability,
no redundant default+named pair for the same singleton.

BREAKING CHANGE: import { perfy } from 'perfy' — the default import
(import perfy from 'perfy') is no longer available.
@onury
onury merged commit 833aa0d into master Jul 23, 2026
2 checks passed
@onury
onury deleted the v2-modernize branch July 23, 2026 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant