Modernize to v2.0.0 — TypeScript, ESM-only, universal clock - #12
Merged
Conversation
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.
This was referenced Jul 22, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ground-up modernization of perfy to the current package standard. Breaking release →
2.0.0.Highlights
src/(Perfy,PerfyItem,PerfyError,clock,IPerfyResult); build istsc → lib/, no bundler.process.hrtime.bigint()(exact integer nanoseconds on Node.js), falls back toperformance.now()in browsers/Deno/Bun/workers. Elapsed time is computed with integer-nanosecond math (no float drift). Closes the long-standing browser-support request.full*aliases andseconds;milliseconds/nanosecondsnow report totals.PerfyErrorwith stable machine-readablecodes.Perfyclass for isolated registries + an injectable clock (deterministic tests).Quality
Breaking changes
require('perfy')removed — useimport perfy from 'perfy'.performance.now()fallback).npm publish remains a manual step for the maintainer after merge & release.