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
Shared utility functions for Firefly projects.
npm install @dimensiondev/utils
# or
pnpm add @dimensiondev/utils-
anySignal— combines multipleAbortSignals 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 externalresolveandrejecthandles. -
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 Classes — typed error classes:
AbortError,AuthenticationError,ForbiddenError,InvalidResultError,NetworkError,NotAllowedError,NotFoundError,NotImplementedError,SeverityError,TimeoutError,UnauthorizedError,UnreachableError,UserRejectionError.
-
assert— runtime assertion with TypeScript type narrowing viaasserts condition. -
unreachable— exhaustiveness checker that throws at runtime;safeUnreachablelogs instead. -
createPredicate— creates a type-guard function from a list of candidate values.
-
asyncIteratorToArray— drains an async iterable into an array, filtering outErrorvalues. -
compose— right-to-left function composition. -
createLookupTableResolver— creates a key-to-value resolver with fallback support. -
getEnumAsArray— converts a TypeScript enum to an array of{ key, value }pairs.
-
bom— SSR-safe accessors for browser globals (window,document,location,navigator,localStorage). -
classNames— joins CSS class names conditionally. -
hexToRGBA— converts a hex colour string torgba(). -
parseJson— safely parses a JSON string, returningundefinedon failure. -
parseUrl— parses a URL string with optional automatic protocol injection. -
isMilliseconds/isUnix— detects the format of a numeric timestamp string.
MIT