assertNotNull |
Return value typed without null and undefined, or throw an AssertError when it is null or undefined. |
asyncOf |
Create an AsyncIterable from a list of values. |
cast |
Return value typed as T. The same as value as T: an unchecked type assertion with no runtime effect. As a function call it fits in expression chains and is easy to search for. |
chainMaybePromise |
Apply fn to a value that might be a Promise, staying synchronous when the value is synchronous: a plain value is transformed immediately (no microtask), a Promise is chained with .then. |
collect |
Collect all values from an iterable into an array. |
defer |
Creates an async disposable with cancellation, resume, and double-dispose protection. |
deferSync |
Creates a sync disposable with cancellation, resume, and double-dispose protection. |
ensureString |
Normalize a value that could be a string, array of strings, null, or undefined into a single string or undefined. |
enumerate |
Yield [index, value] tuples for an iterable. |
enumerateAsync |
Always-async enumerate. Unlike enumerate on a sync iterable, this for awaits the source, so Promise values inside a sync iterable are awaited (sequentially, in order) before being yielded. |
hoursToMs |
Convert hours to milliseconds (hours * 3_600_000). No rounding or validation. For calendar-aware durations, use the Temporal helpers in @xtandard/lib/temporal. |
isAsyncDisposable |
Check if a value has a Symbol.asyncDispose method (async disposable), i.e. whether it can be bound with await using. |
isAsyncGenerator |
Type guard for AsyncGenerator. |
isAsyncIterable |
Type guard for AsyncIterable. |
isDisposable |
Check if a value is disposable, sync or async: it has a Symbol.dispose or a Symbol.asyncDispose method. Use it in generic cleanup code, then narrow with isAsyncDisposable / isSyncDisposable to pick the call. |
isGenerator |
Type guard for sync Generator. |
isIterable |
Type guard for Iterable. |
isIterator |
Type guard for Iterator. |
isPromise |
Type guard for Promise-like values (thenables). Uses instanceof first (fast path), then duck-typing for non-native thenables. |
isSyncDisposable |
Check if a value has a Symbol.dispose method (sync disposable), i.e. whether it can be bound with using. |
jaroWinklerDistance |
The Jaro-Winkler similarity of two strings (1 = identical), under its old, misleading name. Returns exactly what jaroWinklerSimilarity returns, including 1 for two empty strings. |
jaroWinklerSimilarity |
Calculate the Jaro-Winkler similarity of two strings: a score from 0 (nothing in common) to 1 (identical). Two empty strings are identical (1); one empty string scores 0. Case-insensitive unless caseSensitive: true. |
log |
Log values to the console while preserving useful TypeScript inference. |
makeDisposable |
Wrap a resource with an asyncDispose handler so it can be used with await using. |
minutesToMs |
Convert minutes to milliseconds (minutes * 60_000). No rounding or validation. |
naturalSortCompare |
Natural sort comparator (Finder/Explorer-like). Numbers within strings are compared numerically, not lexicographically. |
prepareLoaderResult |
Map a batch of DB results back to the original keys in order. |
range |
Create an eager range array (exclusive end). |
rangeLazy |
Create a lazy range generator (exclusive end). |
resolveMaybePromise |
Resolve a value that might already be synchronous or might be a Promise. |
resolveStreamSource |
Resolve a stream source - calls the factory if it’s a function, otherwise returns the instance directly. |
secondsToMs |
Convert seconds to milliseconds (seconds * 1000). No rounding or validation. |
toAsyncIterable |
Convert an Iterable/Iterator/AsyncIterable/AsyncIterator into an AsyncIterable. |
toIterator |
Convert an Iterable or Iterator into an Iterator. |
tryCatch |
Convert a promise (or function) into a tuple result: [data, error]. |
tryCatchSync |
Convert a sync function call into a tuple result: [data, error]. |
valueOrThrow |
Return a fallback value or throw, depending on a caller-supplied flag. Call it on the invalid path of a function that offers both a lenient and a strict mode. |
wait |
Sleep for a given amount of time. |