Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .size-limit.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,12 @@
"limit": "850 B",
"brotli": true
},
{
"name": "@peerigon/typescript-toolkit/runtime",
"path": "dist/runtime/runtime.js",
"limit": "375 B",
"brotli": true
},
{
"name": "@peerigon/typescript-toolkit/signals",
"path": "dist/signals/signals.js",
Expand All @@ -128,7 +134,7 @@
{
"name": "@peerigon/typescript-toolkit/sleep",
"path": "dist/sleep/sleep.js",
"limit": "175 B",
"limit": "190 B",
"brotli": true
},
{
Expand Down
55 changes: 28 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,34 @@ import { assert } from "@peerigon/typescript-toolkit/assert";

## Utilities

| Module | Description | Docs |
| ---------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | --------------------------------------------------- |
| [`api`](./src/api/README.md) | Define a typed JSON API client with an overridable hook pipeline | [→](./src/api/README.md) |
| [`api/rate-limit`](./src/api/rate-limit/README.md) | Rate-limited `fetch` for `defineApi` (pacing + Retry-After) | [→](./src/api/rate-limit/README.md) |
| [`api/result`](./src/api/result/README.md) | `defineApiResult` — like `defineApi`, but returns `Result.Sync` | [→](./src/api/result/README.md) |
| [`assert`](./src/assert/README.md) | Assert a value is not `null` or `undefined`, with TypeScript narrowing | [→](./src/assert/README.md) |
| [`concurrency/once`](./src/concurrency/once/README.md) | Run an async function at most once (single-flight + cache) | [→](./src/concurrency/once/README.md) |
| [`concurrency/once/result`](./src/concurrency/once/result/README.md) | `once` with a synchronous `Result` snapshot | [→](./src/concurrency/once/result/README.md) |
| [`concurrency/exactlyOnce`](./src/concurrency/exactlyOnce/README.md) | Invoke an async function exactly once; second call throws | [→](./src/concurrency/exactlyOnce/README.md) |
| [`concurrency/exactlyOnce/result`](./src/concurrency/exactlyOnce/result/README.md) | `exactlyOnce` with a synchronous `Result` snapshot | [→](./src/concurrency/exactlyOnce/result/README.md) |
| [`concurrency/mutex`](./src/concurrency/mutex/README.md) | Serialize async tasks (concurrency 1) | [→](./src/concurrency/mutex/README.md) |
| [`concurrency/rate-limit`](./src/concurrency/rate-limit/README.md) | Pace async task starts (`max` per sliding `interval`) | [→](./src/concurrency/rate-limit/README.md) |
| [`need`](./src/need/README.md) | Assert a value is not `null` or `undefined` and return it with a narrowed type | [→](./src/need/README.md) |
| [`no-null`](./src/no-null/README.md) | Convert between `null` and `undefined` in JSON-like values (runtime + types) | [→](./src/no-null/README.md) |
| [`dedupe`](./src/dedupe/README.md) | Remove duplicate values from an array while preserving first-occurrence order | [→](./src/dedupe/README.md) |
| [`emitter`](./src/emitter/README.md) | Minimal typed event emitter with payload objects per event | [→](./src/emitter/README.md) |
| [`enums`](./src/enums/README.md) | Lightweight string-enum alternative for `erasableSyntaxOnly` TypeScript projects | [→](./src/enums/README.md) |
| [`map-leaves`](./src/map-leaves/README.md) | Deeply map leaves in JSON-like values (mutates arrays/objects in place) | [→](./src/map-leaves/README.md) |
| [`match`](./src/match/README.md) | Exhaustive pattern matching with compile-time case checks, similar to `switch` | [→](./src/match/README.md) |
| [`metadata`](./src/metadata/README.md) | Typed metadata attached to objects via per-channel WeakMap stores | [→](./src/metadata/README.md) |
| [`namespace`](./src/namespace/README.md) | Hierarchical namespaces with exclusive member claims and dotted prefixes | [→](./src/namespace/README.md) |
| [`result`](./src/result/README.md) | Type-safe error handling with pending, success, and error states | [→](./src/result/README.md) |
| [`signals`](./src/signals/README.md) | Push-based reactive state with explicit watchers and `signal.from` adapters | [→](./src/signals/README.md) |
| [`sleep`](./src/sleep/README.md) | Promise-based delay with optional `AbortSignal` cancellation | [→](./src/sleep/README.md) |
| [`stable-stringify`](./src/stable-stringify/README.md) | Deterministic stringify for JSON + Map/Set/BigInt/Symbol/Date/RegExp | [→](./src/stable-stringify/README.md) |
| [`stable-stringify/json`](./src/stable-stringify/json/README.md) | JSON-only deterministic `JSON.stringify` with sorted object keys | [→](./src/stable-stringify/json/README.md) |
| [`unwrap`](./src/unwrap/README.md) | Extract values from `Result` or nullable types, with optional fallback support | [→](./src/unwrap/README.md) |
| Module | Description | Docs |
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | --------------------------------------------------- |
| [`api`](./src/api/README.md) | Define a typed JSON API client with an overridable hook pipeline | [→](./src/api/README.md) |
| [`api/rate-limit`](./src/api/rate-limit/README.md) | Rate-limited `fetch` for `defineApi` (pacing + Retry-After) | [→](./src/api/rate-limit/README.md) |
| [`api/result`](./src/api/result/README.md) | `defineApiResult` — like `defineApi`, but returns `Result.Sync` | [→](./src/api/result/README.md) |
| [`assert`](./src/assert/README.md) | Assert a value is not `null` or `undefined`, with TypeScript narrowing | [→](./src/assert/README.md) |
| [`concurrency/once`](./src/concurrency/once/README.md) | Run an async function at most once (single-flight + cache) | [→](./src/concurrency/once/README.md) |
| [`concurrency/once/result`](./src/concurrency/once/result/README.md) | `once` with a synchronous `Result` snapshot | [→](./src/concurrency/once/result/README.md) |
| [`concurrency/exactlyOnce`](./src/concurrency/exactlyOnce/README.md) | Invoke an async function exactly once; second call throws | [→](./src/concurrency/exactlyOnce/README.md) |
| [`concurrency/exactlyOnce/result`](./src/concurrency/exactlyOnce/result/README.md) | `exactlyOnce` with a synchronous `Result` snapshot | [→](./src/concurrency/exactlyOnce/result/README.md) |
| [`concurrency/mutex`](./src/concurrency/mutex/README.md) | Serialize async tasks (concurrency 1) | [→](./src/concurrency/mutex/README.md) |
| [`concurrency/rate-limit`](./src/concurrency/rate-limit/README.md) | Pace async task starts (`max` per sliding `interval`) | [→](./src/concurrency/rate-limit/README.md) |
| [`need`](./src/need/README.md) | Assert a value is not `null` or `undefined` and return it with a narrowed type | [→](./src/need/README.md) |
| [`no-null`](./src/no-null/README.md) | Convert between `null` and `undefined` in JSON-like values (runtime + types) | [→](./src/no-null/README.md) |
| [`dedupe`](./src/dedupe/README.md) | Remove duplicate values from an array while preserving first-occurrence order | [→](./src/dedupe/README.md) |
| [`emitter`](./src/emitter/README.md) | Minimal typed event emitter with payload objects per event | [→](./src/emitter/README.md) |
| [`enums`](./src/enums/README.md) | Lightweight string-enum alternative for `erasableSyntaxOnly` TypeScript projects | [→](./src/enums/README.md) |
| [`map-leaves`](./src/map-leaves/README.md) | Deeply map leaves in JSON-like values (mutates arrays/objects in place) | [→](./src/map-leaves/README.md) |
| [`match`](./src/match/README.md) | Exhaustive pattern matching with compile-time case checks, similar to `switch` | [→](./src/match/README.md) |
| [`metadata`](./src/metadata/README.md) | Typed metadata attached to objects via per-channel WeakMap stores | [→](./src/metadata/README.md) |
| [`namespace`](./src/namespace/README.md) | Hierarchical namespaces with exclusive member claims and dotted prefixes | [→](./src/namespace/README.md) |
| [`result`](./src/result/README.md) | Type-safe error handling with pending, success, and error states | [→](./src/result/README.md) |
| [`runtime`](./src/runtime/README.md) | Generator-based runtime for the generator context pattern, with type-safe `yield*` | [→](./src/runtime/README.md) |
| [`signals`](./src/signals/README.md) | Push-based reactive state with explicit watchers and `signal.from` adapters | [→](./src/signals/README.md) |
| [`sleep`](./src/sleep/README.md) | Promise-based delay with optional `AbortSignal` cancellation | [→](./src/sleep/README.md) |
| [`stable-stringify`](./src/stable-stringify/README.md) | Deterministic stringify for JSON + Map/Set/BigInt/Symbol/Date/RegExp | [→](./src/stable-stringify/README.md) |
| [`stable-stringify/json`](./src/stable-stringify/json/README.md) | JSON-only deterministic `JSON.stringify` with sorted object keys | [→](./src/stable-stringify/json/README.md) |
| [`unwrap`](./src/unwrap/README.md) | Extract values from `Result` or nullable types, with optional fallback support | [→](./src/unwrap/README.md) |

## License

Expand Down
1 change: 1 addition & 0 deletions jsr.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"./need": "./src/need/need.ts",
"./no-null": "./src/no-null/no-null.ts",
"./result": "./src/result/result.ts",
"./runtime": "./src/runtime/runtime.ts",
"./signals": "./src/signals/signals.ts",
"./sleep": "./src/sleep/sleep.ts",
"./stable-stringify": "./src/stable-stringify/stable-stringify.ts",
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"./need": "./dist/need/need.js",
"./no-null": "./dist/no-null/no-null.js",
"./result": "./dist/result/result.js",
"./runtime": "./dist/runtime/runtime.js",
"./signals": "./dist/signals/signals.js",
"./sleep": "./dist/sleep/sleep.js",
"./stable-stringify": "./dist/stable-stringify/stable-stringify.js",
Expand Down
2 changes: 1 addition & 1 deletion src/api/rate-limit/rate-limit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ const isRateLimited = (response: Response) =>
*/
export const parseRetryAfter = (
value: string | null,
now = Date.now(),
now: number = Date.now(),
): number | undefined => {
if (value === null || value === "") {
return undefined;
Expand Down
Loading
Loading