Skip to content

utils 1.0.1

Install from the command line:
Learn more about npm packages
$ npm install @dimensiondev/utils@1.0.1
Install via package.json:
"@dimensiondev/utils": "1.0.1"

About this version

@dimensiondev/utils

Shared utility functions for Firefly projects.

npm install @dimensiondev/utils
# or
pnpm add @dimensiondev/utils

Utilities

Async & Control Flow

  • anySignal — combines multiple AbortSignals into one that aborts when any of them abort.
  • attemptUntil — tries async functions sequentially until one succeeds, with fallback.
  • createBatcher — batches individual requests into grouped fetches with deduplication.
  • defer — creates a promise with external resolve and reject handles.
  • delay — returns a promise that resolves after a given number of milliseconds.
  • once — prevents concurrent execution of an async function, throwing if called while running.
  • retry — retries an async operation with configurable attempts and interval.
  • squashCallback — deduplicates concurrent async calls, sharing one in-flight promise per key.
  • timeout — rejects a promise if it does not settle within a given time limit.

Error Handling

  • Error Classes — typed error classes: AbortError, AuthenticationError, ForbiddenError, InvalidResultError, NetworkError, NotAllowedError, NotFoundError, NotImplementedError, SeverityError, TimeoutError, UnauthorizedError, UnreachableError, UserRejectionError.

Type Safety & Assertions

  • assert — runtime assertion with TypeScript type narrowing via asserts condition.
  • unreachable — exhaustiveness checker that throws at runtime; safeUnreachable logs instead.
  • createPredicate — creates a type-guard function from a list of candidate values.

Data & Collections

Utilities

  • bom — SSR-safe accessors for browser globals (window, document, location, navigator, localStorage).
  • classNames — joins CSS class names conditionally.
  • hexToRGBA — converts a hex colour string to rgba().
  • parseJson — safely parses a JSON string, returning undefined on failure.
  • parseUrl — parses a URL string with optional automatic protocol injection.
  • isMilliseconds / isUnix — detects the format of a numeric timestamp string.

License

MIT

Details


Assets

  • utils-1.0.1.tgz

Download activity

  • Total downloads 1
  • Last 30 days 1
  • Last week 1
  • Today 1