@talismn/util 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +17 -88
- package/dist/index.d.mts.map +1 -1
- package/dist/index.d.ts +17 -88
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +159 -98
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +155 -97
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import bignumber_default from "bignumber.js";
|
|
2
2
|
import { Observable, OperatorFunction, ReplaySubject, Subject } from "rxjs";
|
|
3
|
-
//#region src/addTrailingSlash.d.ts
|
|
4
3
|
export declare const addTrailingSlash: (url: string) => string;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/assert.d.ts
|
|
7
4
|
/**
|
|
8
5
|
* @name assert
|
|
9
6
|
* @description Throws an Error with the given message if the condition is falsy.
|
|
@@ -11,8 +8,6 @@ export declare const addTrailingSlash: (url: string) => string;
|
|
|
11
8
|
* assert(chain, "Chain not found")
|
|
12
9
|
**/
|
|
13
10
|
export declare function assert(condition: unknown, message: string | (() => string)): asserts condition;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/BigMath.d.ts
|
|
16
11
|
/**
|
|
17
12
|
* Javascript's `Math` library for `BigInt`.
|
|
18
13
|
* Taken from https://stackoverflow.com/questions/51867270/is-there-a-library-similar-to-math-that-supports-javascript-bigint/64953280#64953280
|
|
@@ -23,13 +18,9 @@ export declare const BigMath: {
|
|
|
23
18
|
min(value: bigint, ...values: bigint[]): bigint;
|
|
24
19
|
max(value: bigint, ...values: bigint[]): bigint;
|
|
25
20
|
};
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/isHexString.d.ts
|
|
28
21
|
export type HexString = `0x${string}`;
|
|
29
22
|
export declare const REGEX_HEX_STRING: RegExp;
|
|
30
23
|
export declare const isHexString: (value: unknown) => value is HexString;
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/bytes.d.ts
|
|
33
24
|
/**
|
|
34
25
|
* Byte / hex primitives, drop-in equivalents of the `@polkadot/util` helpers we used to depend on.
|
|
35
26
|
* Semantics intentionally match polkadot-js for migration safety.
|
|
@@ -54,8 +45,6 @@ export declare const isAsciiPrintable: (value?: string | Uint8Array | null) => b
|
|
|
54
45
|
/** Wraps bytes with `<Bytes>...</Bytes>` for raw-message signing, unless already wrapped */
|
|
55
46
|
export declare const u8aWrapBytes: (value: string | Uint8Array) => Uint8Array;
|
|
56
47
|
export declare const u8aUnwrapBytes: (value: string | Uint8Array) => Uint8Array;
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/timeSlicer.d.ts
|
|
59
48
|
/**
|
|
60
49
|
* Default CPU budget for a single synchronous slice of chunked work.
|
|
61
50
|
* ~50-60% of a 60fps frame, leaving the rest for the host (user interactions, rendering).
|
|
@@ -105,8 +94,6 @@ export declare const newAbortError: () => Error;
|
|
|
105
94
|
* A single slicer can be shared across multiple phases of work so the budget spans them.
|
|
106
95
|
*/
|
|
107
96
|
export declare const createTimeSlicer: ({ budgetMs, signal, now, label }?: TimeSlicerOptions) => TimeSlicer;
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/chunkedArray.d.ts
|
|
110
97
|
export type ChunkedOptions = {
|
|
111
98
|
/** max synchronous work per slice, in milliseconds (ignored when `slicer` is provided) */
|
|
112
99
|
budgetMs?: number;
|
|
@@ -137,8 +124,6 @@ export declare const keyByWithYield: <T>(items: readonly T[], keyFn: (item: T, i
|
|
|
137
124
|
export declare const arrayItemsEqualWithYield: <T>(a: readonly T[] | undefined, b: readonly T[] | undefined, options?: ChunkedOptions & {
|
|
138
125
|
isItemEqual?: (x: T, y: T) => boolean;
|
|
139
126
|
}) => Promise<boolean>;
|
|
140
|
-
//#endregion
|
|
141
|
-
//#region src/deferred.d.ts
|
|
142
127
|
/**
|
|
143
128
|
* In TypeScript, a deferred promise refers to a pattern that involves creating a promise that can be
|
|
144
129
|
* resolved or rejected at a later point in time, typically by code outside of the current function scope.
|
|
@@ -154,15 +139,11 @@ export declare function Deferred<T>(): {
|
|
|
154
139
|
isResolved: () => boolean;
|
|
155
140
|
isRejected: () => boolean;
|
|
156
141
|
};
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/FunctionPropertyNames.d.ts
|
|
159
142
|
/** biome-ignore-all lint/complexity/noBannedTypes: legacy */
|
|
160
143
|
export type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T];
|
|
161
144
|
export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
|
|
162
145
|
export type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T];
|
|
163
146
|
export type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
|
|
164
|
-
//#endregion
|
|
165
|
-
//#region src/firstThenDebounce.d.ts
|
|
166
147
|
/**
|
|
167
148
|
* An rxjs operator which:
|
|
168
149
|
*
|
|
@@ -170,8 +151,10 @@ export type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
|
|
|
170
151
|
* 2. Debounces any future values by `timeout` ms.
|
|
171
152
|
*/
|
|
172
153
|
export declare const firstThenDebounce: <T>(timeout: number) => OperatorFunction<T, T>;
|
|
173
|
-
|
|
174
|
-
|
|
154
|
+
type FormatCurrencyOptions = Omit<Intl.NumberFormatOptions, "style" | "currency">;
|
|
155
|
+
export declare const getCurrencyFractionDigits: (currency: string) => number;
|
|
156
|
+
export declare const formatCurrencyToParts: (amount: number, currency: string, options?: FormatCurrencyOptions) => Intl.NumberFormatPart[];
|
|
157
|
+
export declare const formatCurrency: (amount: number, currency: string, options?: FormatCurrencyOptions) => string;
|
|
175
158
|
export declare const MAX_DECIMALS_FORMAT = 12;
|
|
176
159
|
/**
|
|
177
160
|
* Custom decimal number formatting for Talisman
|
|
@@ -182,15 +165,19 @@ export declare const MAX_DECIMALS_FORMAT = 12;
|
|
|
182
165
|
* @param options formatting options
|
|
183
166
|
* @returns the formatted value
|
|
184
167
|
*/
|
|
185
|
-
export declare const formatDecimals: (num?: string | number | null |
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/formatPrice.d.ts
|
|
168
|
+
export declare const formatDecimals: (num?: string | number | null | bignumber_default, digits?: number, options?: Partial<Intl.NumberFormatOptions>, locale?: string) => string;
|
|
188
169
|
export declare const formatPrice: (price: number, currency: string, compact: boolean) => string;
|
|
189
|
-
|
|
190
|
-
|
|
170
|
+
export type CompactPriceParts = {
|
|
171
|
+
kind: "plain";
|
|
172
|
+
text: string;
|
|
173
|
+
} | {
|
|
174
|
+
kind: "collapsedZeros";
|
|
175
|
+
head: string;
|
|
176
|
+
zeroCount: number;
|
|
177
|
+
tail: string;
|
|
178
|
+
};
|
|
179
|
+
export declare const formatCompactPrice: (price: number, currency: string) => CompactPriceParts;
|
|
191
180
|
export declare const getErrorMessage: (error: unknown, fallback?: string) => string;
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region src/getLoadable.d.ts
|
|
194
181
|
type LoadableError = {
|
|
195
182
|
name: string;
|
|
196
183
|
message: string;
|
|
@@ -214,8 +201,6 @@ export type LoadableOptions = {
|
|
|
214
201
|
refreshInterval?: number;
|
|
215
202
|
};
|
|
216
203
|
export declare function getLoadable$<T>(factory: () => Promise<T>, options?: LoadableOptions): Observable<Loadable<T>>;
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/getLoadableQuery.d.ts
|
|
219
204
|
export type GetLoadableQueryParams<TArgs extends unknown[], TResult> = {
|
|
220
205
|
namespace: string;
|
|
221
206
|
args: TArgs;
|
|
@@ -230,8 +215,6 @@ export type GetLoadableQueryParams<TArgs extends unknown[], TResult> = {
|
|
|
230
215
|
* TODO: consolidate with getQuery$
|
|
231
216
|
*/
|
|
232
217
|
export declare const getLoadableQuery$: <TArgs extends unknown[], TResult>(params: GetLoadableQueryParams<TArgs, TResult>) => Observable<Loadable<TResult>>;
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region src/getQuery.d.ts
|
|
235
218
|
export type QueryStatus = "loading" | "loaded" | "error";
|
|
236
219
|
export type QueryResult<T, S extends QueryStatus = "loading" | "loaded" | "error"> = S extends "loading" ? {
|
|
237
220
|
status: "loading";
|
|
@@ -277,8 +260,6 @@ type QueryOptions<Output, Args> = {
|
|
|
277
260
|
* @deprecated use getLoadableQuery$ instead
|
|
278
261
|
*/
|
|
279
262
|
export declare const getQuery$: <Output, Args>({ namespace, args, queryFn, defaultValue, refreshInterval, serializer }: QueryOptions<Output, Args>) => Observable<QueryResult<Output>>;
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region src/getSharedObservable.d.ts
|
|
282
263
|
/**
|
|
283
264
|
* When using react-rxjs hooks and state observables, the options are used as weak map keys.
|
|
284
265
|
* This means that if the options object is recreated on each render, the observable will be recreated as well.
|
|
@@ -295,27 +276,13 @@ export declare const getQuery$: <Output, Args>({ namespace, args, queryFn, defau
|
|
|
295
276
|
* @returns
|
|
296
277
|
*/
|
|
297
278
|
export declare const getSharedObservable: <Args, Output, ObsOutput = Observable<Output>>(namespace: string, args: Args, createObservable: (args: Args) => ObsOutput, serializer?: (args: Args) => string) => ObsOutput;
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/hasOwnProperty.d.ts
|
|
300
279
|
export declare function hasOwnProperty<X, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region src/isAbortError.d.ts
|
|
303
280
|
export declare const isAbortError: (error: unknown) => boolean;
|
|
304
|
-
//#endregion
|
|
305
|
-
//#region src/isArrayOf.d.ts
|
|
306
281
|
export declare function isArrayOf<T, P extends Array<unknown>>(array: unknown[], func: new (...args: P) => T): array is T[];
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region src/isAscii.d.ts
|
|
309
282
|
export declare const isAscii: (str: string) => boolean;
|
|
310
|
-
//#endregion
|
|
311
|
-
//#region src/isBigInt.d.ts
|
|
312
283
|
export declare const isBigInt: (value: unknown) => value is bigint;
|
|
313
|
-
//#endregion
|
|
314
|
-
//#region src/isBooleanTrue.d.ts
|
|
315
284
|
/** @deprecated use isTruthy instead */
|
|
316
285
|
export declare const isBooleanTrue: <T>(x: T | null | undefined) => x is T;
|
|
317
|
-
//#endregion
|
|
318
|
-
//#region src/isErrorOfName.d.ts
|
|
319
286
|
/**
|
|
320
287
|
* Robust replacement for `error instanceof SomeErrorClass` when the class comes from a
|
|
321
288
|
* package that gets bundled into multiple chunks/contexts (e.g. viem, @solana/web3.js).
|
|
@@ -328,8 +295,6 @@ export declare const isBooleanTrue: <T>(x: T | null | undefined) => x is T;
|
|
|
328
295
|
* duck-type the shape instead.
|
|
329
296
|
*/
|
|
330
297
|
export declare const isErrorOfName: (error: unknown, ...names: string[]) => boolean;
|
|
331
|
-
//#endregion
|
|
332
|
-
//#region src/isNotNil.d.ts
|
|
333
298
|
/**
|
|
334
299
|
* WARNING: This function only checks against null or undefined, it does not coerce the value.
|
|
335
300
|
* ie: false and 0 are considered not nil
|
|
@@ -339,20 +304,12 @@ export declare const isErrorOfName: (error: unknown, ...names: string[]) => bool
|
|
|
339
304
|
* @returns whether the value is neither null nor undefined
|
|
340
305
|
*/
|
|
341
306
|
export declare const isNotNil: <T>(value: T | null | undefined) => value is T;
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region src/isPromise.d.ts
|
|
344
307
|
export declare const isPromise: <T = any>(value: any) => value is Promise<T>;
|
|
345
|
-
//#endregion
|
|
346
|
-
//#region src/isSubject.d.ts
|
|
347
308
|
/**
|
|
348
309
|
* Tests to see if an object is an RxJS {@link Subject}.
|
|
349
310
|
*/
|
|
350
311
|
export declare function isSubject<T>(object?: Subject<T> | object): object is Subject<T>;
|
|
351
|
-
//#endregion
|
|
352
|
-
//#region src/isTruthy.d.ts
|
|
353
312
|
export declare const isTruthy: <T>(value: T | null | undefined) => value is T;
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region src/jsActivityHook.d.ts
|
|
356
313
|
/**
|
|
357
314
|
* Optional host-provided JS-activity hook.
|
|
358
315
|
*
|
|
@@ -365,8 +322,6 @@ export declare const isTruthy: <T>(value: T | null | undefined) => value is T;
|
|
|
365
322
|
* can call it unconditionally from hot paths.
|
|
366
323
|
*/
|
|
367
324
|
export declare const reportJsActivity: (label: string, durationMs?: number) => void;
|
|
368
|
-
//#endregion
|
|
369
|
-
//#region src/keepAlive.d.ts
|
|
370
325
|
/**
|
|
371
326
|
* An RxJS operator that keeps the source observable alive for a specified duration
|
|
372
327
|
* after all subscribers have unsubscribed. This prevents expensive re-subscriptions
|
|
@@ -383,8 +338,6 @@ export declare const reportJsActivity: (label: string, durationMs?: number) => v
|
|
|
383
338
|
* ```
|
|
384
339
|
*/
|
|
385
340
|
export declare const keepAlive: <T>(timeout: number) => OperatorFunction<T, T>;
|
|
386
|
-
//#endregion
|
|
387
|
-
//#region src/lruMap.d.ts
|
|
388
341
|
/**
|
|
389
342
|
* A Map with a maximum size and least-recently-used eviction.
|
|
390
343
|
*
|
|
@@ -402,8 +355,6 @@ export declare class LruMap<K, V> {
|
|
|
402
355
|
clear(): void;
|
|
403
356
|
get size(): number;
|
|
404
357
|
}
|
|
405
|
-
//#endregion
|
|
406
|
-
//#region src/mapChunked.d.ts
|
|
407
358
|
export type ChunkedProjectContext = {
|
|
408
359
|
/** thread the slicer through chunked helpers (mapWithYield etc.) so the budget spans them */
|
|
409
360
|
slicer: TimeSlicer;
|
|
@@ -434,16 +385,10 @@ export declare const concatMapChunked: <T, R>(project: (value: T, ctx: ChunkedPr
|
|
|
434
385
|
budgetMs?: number;
|
|
435
386
|
label?: string;
|
|
436
387
|
}) => OperatorFunction<T, R>;
|
|
437
|
-
//#endregion
|
|
438
|
-
//#region src/Prettify.d.ts
|
|
439
388
|
export type Prettify<T> = { [K in keyof T]: T[K]; } & {};
|
|
440
|
-
//#endregion
|
|
441
|
-
//#region src/planckToTokens.d.ts
|
|
442
389
|
export declare function planckToTokens(planck: string, tokenDecimals: number): string;
|
|
443
390
|
export declare function planckToTokens(planck: string, tokenDecimals?: number): string | undefined;
|
|
444
391
|
export declare function planckToTokens(planck?: string, tokenDecimals?: number): string | undefined;
|
|
445
|
-
//#endregion
|
|
446
|
-
//#region src/replaySubjectFrom.d.ts
|
|
447
392
|
/**
|
|
448
393
|
* Turns a value into a {@link ReplaySubject} of size 1.
|
|
449
394
|
*
|
|
@@ -455,11 +400,7 @@ export declare function planckToTokens(planck?: string, tokenDecimals?: number):
|
|
|
455
400
|
* For any other type of value, it will be immediately published into the {@link ReplaySubject}.
|
|
456
401
|
*/
|
|
457
402
|
export declare const replaySubjectFrom: <T>(initialValue: T | Promise<T> | ReplaySubject<T>) => ReplaySubject<T>;
|
|
458
|
-
//#endregion
|
|
459
|
-
//#region src/sleep.d.ts
|
|
460
403
|
export declare const sleep: (ms: number) => Promise<void>;
|
|
461
|
-
//#endregion
|
|
462
|
-
//#region src/splitSubject.d.ts
|
|
463
404
|
/**
|
|
464
405
|
* Takes a subject and splits it into two parts:
|
|
465
406
|
*
|
|
@@ -470,8 +411,6 @@ export declare const sleep: (ms: number) => Promise<void>;
|
|
|
470
411
|
* of these parts to external code and keep the other part private.
|
|
471
412
|
*/
|
|
472
413
|
export declare function splitSubject<T>(subject: Subject<T>): readonly [(value: T) => void, Observable<T>];
|
|
473
|
-
//#endregion
|
|
474
|
-
//#region src/stripHexPrefix.d.ts
|
|
475
414
|
/**
|
|
476
415
|
* @name stripHexPrefix
|
|
477
416
|
* @description Removes a leading `0x` prefix from a string, if present.
|
|
@@ -482,16 +421,10 @@ export declare function splitSubject<T>(subject: Subject<T>): readonly [(value:
|
|
|
482
421
|
* stripHexPrefix("1234") // "1234"
|
|
483
422
|
**/
|
|
484
423
|
export declare const stripHexPrefix: (str: string) => string;
|
|
485
|
-
//#endregion
|
|
486
|
-
//#region src/throwAfter.d.ts
|
|
487
424
|
export declare const throwAfter: (ms: number, reason: string) => Promise<never>;
|
|
488
|
-
//#endregion
|
|
489
|
-
//#region src/tokensToPlanck.d.ts
|
|
490
425
|
export declare function tokensToPlanck(tokens: string, tokenDecimals: number): string;
|
|
491
426
|
export declare function tokensToPlanck(tokens: string, tokenDecimals?: number): string | undefined;
|
|
492
427
|
export declare function tokensToPlanck(tokens?: string, tokenDecimals?: number): string | undefined;
|
|
493
|
-
//#endregion
|
|
494
|
-
//#region src/validateArrayWithYield.d.ts
|
|
495
428
|
export type ItemParseResult<T, E> = {
|
|
496
429
|
success: true;
|
|
497
430
|
data: T;
|
|
@@ -518,8 +451,6 @@ export type ArrayValidationResult<T, E> = {
|
|
|
518
451
|
* Zod-agnostic on purpose: this package has no zod dependency.
|
|
519
452
|
*/
|
|
520
453
|
export declare const validateArrayWithYield: <T, E>(items: readonly unknown[], parseItem: (item: unknown, index: number) => ItemParseResult<T, E>, options?: ChunkedOptions) => Promise<ArrayValidationResult<T, E>>;
|
|
521
|
-
//#endregion
|
|
522
|
-
//#region src/validateHexString.d.ts
|
|
523
454
|
/**
|
|
524
455
|
* @name validateHexString
|
|
525
456
|
* @description Checks if a string is a hex string. Required to account for type differences between different polkadot libraries
|
|
@@ -531,8 +462,6 @@ export declare const validateArrayWithYield: <T, E>(items: readonly unknown[], p
|
|
|
531
462
|
* validateHexString(1234) // Error: Expected a string
|
|
532
463
|
**/
|
|
533
464
|
export declare const validateHexString: (str: string) => `0x${string}`;
|
|
534
|
-
//#endregion
|
|
535
|
-
//#region src/yieldToEventLoop.d.ts
|
|
536
465
|
export declare const yieldToEventLoop: () => Promise<void>;
|
|
537
|
-
|
|
466
|
+
export {};
|
|
538
467
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/addTrailingSlash.ts","../src/assert.ts","../src/BigMath.ts","../src/isHexString.ts","../src/bytes.ts","../src/timeSlicer.ts","../src/chunkedArray.ts","../src/deferred.ts","../src/FunctionPropertyNames.ts","../src/firstThenDebounce.ts","../src/formatDecimals.ts","../src/formatPrice.ts","../src/getErrorMessage.ts","../src/getLoadable.ts","../src/getLoadableQuery.ts","../src/getQuery.ts","../src/getSharedObservable.ts","../src/hasOwnProperty.ts","../src/isAbortError.ts","../src/isArrayOf.ts","../src/isAscii.ts","../src/isBigInt.ts","../src/isBooleanTrue.ts","../src/isErrorOfName.ts","../src/isNotNil.ts","../src/isPromise.ts","../src/isSubject.ts","../src/isTruthy.ts","../src/jsActivityHook.ts","../src/keepAlive.ts","../src/lruMap.ts","../src/mapChunked.ts","../src/Prettify.ts","../src/planckToTokens.ts","../src/replaySubjectFrom.ts","../src/sleep.ts","../src/splitSubject.ts","../src/stripHexPrefix.ts","../src/throwAfter.ts","../src/tokensToPlanck.ts","../src/validateArrayWithYield.ts","../src/validateHexString.ts","../src/yieldToEventLoop.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":["BigNumber"],"sources":["../src/addTrailingSlash.ts","../src/assert.ts","../src/BigMath.ts","../src/isHexString.ts","../src/bytes.ts","../src/timeSlicer.ts","../src/chunkedArray.ts","../src/deferred.ts","../src/FunctionPropertyNames.ts","../src/firstThenDebounce.ts","../src/formatCurrency.ts","../src/formatDecimals.ts","../src/formatPrice.ts","../src/getErrorMessage.ts","../src/getLoadable.ts","../src/getLoadableQuery.ts","../src/getQuery.ts","../src/getSharedObservable.ts","../src/hasOwnProperty.ts","../src/isAbortError.ts","../src/isArrayOf.ts","../src/isAscii.ts","../src/isBigInt.ts","../src/isBooleanTrue.ts","../src/isErrorOfName.ts","../src/isNotNil.ts","../src/isPromise.ts","../src/isSubject.ts","../src/isTruthy.ts","../src/jsActivityHook.ts","../src/keepAlive.ts","../src/lruMap.ts","../src/mapChunked.ts","../src/Prettify.ts","../src/planckToTokens.ts","../src/replaySubjectFrom.ts","../src/sleep.ts","../src/splitSubject.ts","../src/stripHexP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E;EAChE;EAAmB;MAC9B,iBAAiB,GAAG;;;;;;qBAQV,mBAAoB,GAAG,GAAC,UACzB,OAAO,GAAG,KAAK,uBAAuB,kBAAkB,QAAQ,IAAE;EAChE;EAAmB;MAC9B,iBAAiB,GAAG;YCnEX,SAAS,QAClB,WAAW,IAAI,EAAE;wBCCJ,eAAe,gBAAgB;wBAC/B,eAAe,gBAAgB;wBAC/B,eAAe,iBAAiB;;;;;;;;;;;qBCUnC,oBAAqB,GAAC,cACnB,IAAI,QAAQ,KAAK,cAAc,OAC5C,cAAc;qBChBJ,QAAK,eAAc;;;;;;;;;;wBCWhB,aAAa,GAAG,SAAS,QAAQ,gBAAE,OAC5B,YAAC,WAAA;;;;;;;;;;qBCHX,iBAAc;qBCTd,aAAU,YAAc,mBAAgB;wBCErC,eAAe,gBAAgB;wBAC/B,eAAe,gBAAgB;wBAC/B,eAAe,iBAAiB;YCFpC,gBAAgB,GAAG;EAAO;EAAe,MAAM;;EAAQ;EAAgB,OAAO;;YAE9E,sBAAsB,GAAG;EAC/B;EAAe,MAAM;;EACrB;EAAgB;IAAU;IAAe,OAAO;;;;;;;;;;;qBAUzC,yBAAgC,GAAG,GAAC,2BACtB,YACb,eAAe,kBAAkB,gBAAgB,GAAG,IAAE,UACxD,mBACT,QAAQ,sBAAsB,GAAG;;;;;;;;;;;qBCVvB,oBAAiB;qBCkBjB,wBAAuB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import bignumber_default from "bignumber.js";
|
|
2
2
|
import { Observable, OperatorFunction, ReplaySubject, Subject } from "rxjs";
|
|
3
|
-
//#region src/addTrailingSlash.d.ts
|
|
4
3
|
export declare const addTrailingSlash: (url: string) => string;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/assert.d.ts
|
|
7
4
|
/**
|
|
8
5
|
* @name assert
|
|
9
6
|
* @description Throws an Error with the given message if the condition is falsy.
|
|
@@ -11,8 +8,6 @@ export declare const addTrailingSlash: (url: string) => string;
|
|
|
11
8
|
* assert(chain, "Chain not found")
|
|
12
9
|
**/
|
|
13
10
|
export declare function assert(condition: unknown, message: string | (() => string)): asserts condition;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/BigMath.d.ts
|
|
16
11
|
/**
|
|
17
12
|
* Javascript's `Math` library for `BigInt`.
|
|
18
13
|
* Taken from https://stackoverflow.com/questions/51867270/is-there-a-library-similar-to-math-that-supports-javascript-bigint/64953280#64953280
|
|
@@ -23,13 +18,9 @@ export declare const BigMath: {
|
|
|
23
18
|
min(value: bigint, ...values: bigint[]): bigint;
|
|
24
19
|
max(value: bigint, ...values: bigint[]): bigint;
|
|
25
20
|
};
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/isHexString.d.ts
|
|
28
21
|
export type HexString = `0x${string}`;
|
|
29
22
|
export declare const REGEX_HEX_STRING: RegExp;
|
|
30
23
|
export declare const isHexString: (value: unknown) => value is HexString;
|
|
31
|
-
//#endregion
|
|
32
|
-
//#region src/bytes.d.ts
|
|
33
24
|
/**
|
|
34
25
|
* Byte / hex primitives, drop-in equivalents of the `@polkadot/util` helpers we used to depend on.
|
|
35
26
|
* Semantics intentionally match polkadot-js for migration safety.
|
|
@@ -54,8 +45,6 @@ export declare const isAsciiPrintable: (value?: string | Uint8Array | null) => b
|
|
|
54
45
|
/** Wraps bytes with `<Bytes>...</Bytes>` for raw-message signing, unless already wrapped */
|
|
55
46
|
export declare const u8aWrapBytes: (value: string | Uint8Array) => Uint8Array;
|
|
56
47
|
export declare const u8aUnwrapBytes: (value: string | Uint8Array) => Uint8Array;
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/timeSlicer.d.ts
|
|
59
48
|
/**
|
|
60
49
|
* Default CPU budget for a single synchronous slice of chunked work.
|
|
61
50
|
* ~50-60% of a 60fps frame, leaving the rest for the host (user interactions, rendering).
|
|
@@ -105,8 +94,6 @@ export declare const newAbortError: () => Error;
|
|
|
105
94
|
* A single slicer can be shared across multiple phases of work so the budget spans them.
|
|
106
95
|
*/
|
|
107
96
|
export declare const createTimeSlicer: ({ budgetMs, signal, now, label }?: TimeSlicerOptions) => TimeSlicer;
|
|
108
|
-
//#endregion
|
|
109
|
-
//#region src/chunkedArray.d.ts
|
|
110
97
|
export type ChunkedOptions = {
|
|
111
98
|
/** max synchronous work per slice, in milliseconds (ignored when `slicer` is provided) */
|
|
112
99
|
budgetMs?: number;
|
|
@@ -137,8 +124,6 @@ export declare const keyByWithYield: <T>(items: readonly T[], keyFn: (item: T, i
|
|
|
137
124
|
export declare const arrayItemsEqualWithYield: <T>(a: readonly T[] | undefined, b: readonly T[] | undefined, options?: ChunkedOptions & {
|
|
138
125
|
isItemEqual?: (x: T, y: T) => boolean;
|
|
139
126
|
}) => Promise<boolean>;
|
|
140
|
-
//#endregion
|
|
141
|
-
//#region src/deferred.d.ts
|
|
142
127
|
/**
|
|
143
128
|
* In TypeScript, a deferred promise refers to a pattern that involves creating a promise that can be
|
|
144
129
|
* resolved or rejected at a later point in time, typically by code outside of the current function scope.
|
|
@@ -154,15 +139,11 @@ export declare function Deferred<T>(): {
|
|
|
154
139
|
isResolved: () => boolean;
|
|
155
140
|
isRejected: () => boolean;
|
|
156
141
|
};
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region src/FunctionPropertyNames.d.ts
|
|
159
142
|
/** biome-ignore-all lint/complexity/noBannedTypes: legacy */
|
|
160
143
|
export type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never; }[keyof T];
|
|
161
144
|
export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>;
|
|
162
145
|
export type NonFunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? never : K; }[keyof T];
|
|
163
146
|
export type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
|
|
164
|
-
//#endregion
|
|
165
|
-
//#region src/firstThenDebounce.d.ts
|
|
166
147
|
/**
|
|
167
148
|
* An rxjs operator which:
|
|
168
149
|
*
|
|
@@ -170,8 +151,10 @@ export type NonFunctionProperties<T> = Pick<T, NonFunctionPropertyNames<T>>;
|
|
|
170
151
|
* 2. Debounces any future values by `timeout` ms.
|
|
171
152
|
*/
|
|
172
153
|
export declare const firstThenDebounce: <T>(timeout: number) => OperatorFunction<T, T>;
|
|
173
|
-
|
|
174
|
-
|
|
154
|
+
type FormatCurrencyOptions = Omit<Intl.NumberFormatOptions, "style" | "currency">;
|
|
155
|
+
export declare const getCurrencyFractionDigits: (currency: string) => number;
|
|
156
|
+
export declare const formatCurrencyToParts: (amount: number, currency: string, options?: FormatCurrencyOptions) => Intl.NumberFormatPart[];
|
|
157
|
+
export declare const formatCurrency: (amount: number, currency: string, options?: FormatCurrencyOptions) => string;
|
|
175
158
|
export declare const MAX_DECIMALS_FORMAT = 12;
|
|
176
159
|
/**
|
|
177
160
|
* Custom decimal number formatting for Talisman
|
|
@@ -182,15 +165,19 @@ export declare const MAX_DECIMALS_FORMAT = 12;
|
|
|
182
165
|
* @param options formatting options
|
|
183
166
|
* @returns the formatted value
|
|
184
167
|
*/
|
|
185
|
-
export declare const formatDecimals: (num?: string | number | null |
|
|
186
|
-
//#endregion
|
|
187
|
-
//#region src/formatPrice.d.ts
|
|
168
|
+
export declare const formatDecimals: (num?: string | number | null | bignumber_default, digits?: number, options?: Partial<Intl.NumberFormatOptions>, locale?: string) => string;
|
|
188
169
|
export declare const formatPrice: (price: number, currency: string, compact: boolean) => string;
|
|
189
|
-
|
|
190
|
-
|
|
170
|
+
export type CompactPriceParts = {
|
|
171
|
+
kind: "plain";
|
|
172
|
+
text: string;
|
|
173
|
+
} | {
|
|
174
|
+
kind: "collapsedZeros";
|
|
175
|
+
head: string;
|
|
176
|
+
zeroCount: number;
|
|
177
|
+
tail: string;
|
|
178
|
+
};
|
|
179
|
+
export declare const formatCompactPrice: (price: number, currency: string) => CompactPriceParts;
|
|
191
180
|
export declare const getErrorMessage: (error: unknown, fallback?: string) => string;
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region src/getLoadable.d.ts
|
|
194
181
|
type LoadableError = {
|
|
195
182
|
name: string;
|
|
196
183
|
message: string;
|
|
@@ -214,8 +201,6 @@ export type LoadableOptions = {
|
|
|
214
201
|
refreshInterval?: number;
|
|
215
202
|
};
|
|
216
203
|
export declare function getLoadable$<T>(factory: () => Promise<T>, options?: LoadableOptions): Observable<Loadable<T>>;
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/getLoadableQuery.d.ts
|
|
219
204
|
export type GetLoadableQueryParams<TArgs extends unknown[], TResult> = {
|
|
220
205
|
namespace: string;
|
|
221
206
|
args: TArgs;
|
|
@@ -230,8 +215,6 @@ export type GetLoadableQueryParams<TArgs extends unknown[], TResult> = {
|
|
|
230
215
|
* TODO: consolidate with getQuery$
|
|
231
216
|
*/
|
|
232
217
|
export declare const getLoadableQuery$: <TArgs extends unknown[], TResult>(params: GetLoadableQueryParams<TArgs, TResult>) => Observable<Loadable<TResult>>;
|
|
233
|
-
//#endregion
|
|
234
|
-
//#region src/getQuery.d.ts
|
|
235
218
|
export type QueryStatus = "loading" | "loaded" | "error";
|
|
236
219
|
export type QueryResult<T, S extends QueryStatus = "loading" | "loaded" | "error"> = S extends "loading" ? {
|
|
237
220
|
status: "loading";
|
|
@@ -277,8 +260,6 @@ type QueryOptions<Output, Args> = {
|
|
|
277
260
|
* @deprecated use getLoadableQuery$ instead
|
|
278
261
|
*/
|
|
279
262
|
export declare const getQuery$: <Output, Args>({ namespace, args, queryFn, defaultValue, refreshInterval, serializer }: QueryOptions<Output, Args>) => Observable<QueryResult<Output>>;
|
|
280
|
-
//#endregion
|
|
281
|
-
//#region src/getSharedObservable.d.ts
|
|
282
263
|
/**
|
|
283
264
|
* When using react-rxjs hooks and state observables, the options are used as weak map keys.
|
|
284
265
|
* This means that if the options object is recreated on each render, the observable will be recreated as well.
|
|
@@ -295,27 +276,13 @@ export declare const getQuery$: <Output, Args>({ namespace, args, queryFn, defau
|
|
|
295
276
|
* @returns
|
|
296
277
|
*/
|
|
297
278
|
export declare const getSharedObservable: <Args, Output, ObsOutput = Observable<Output>>(namespace: string, args: Args, createObservable: (args: Args) => ObsOutput, serializer?: (args: Args) => string) => ObsOutput;
|
|
298
|
-
//#endregion
|
|
299
|
-
//#region src/hasOwnProperty.d.ts
|
|
300
279
|
export declare function hasOwnProperty<X, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
|
|
301
|
-
//#endregion
|
|
302
|
-
//#region src/isAbortError.d.ts
|
|
303
280
|
export declare const isAbortError: (error: unknown) => boolean;
|
|
304
|
-
//#endregion
|
|
305
|
-
//#region src/isArrayOf.d.ts
|
|
306
281
|
export declare function isArrayOf<T, P extends Array<unknown>>(array: unknown[], func: new (...args: P) => T): array is T[];
|
|
307
|
-
//#endregion
|
|
308
|
-
//#region src/isAscii.d.ts
|
|
309
282
|
export declare const isAscii: (str: string) => boolean;
|
|
310
|
-
//#endregion
|
|
311
|
-
//#region src/isBigInt.d.ts
|
|
312
283
|
export declare const isBigInt: (value: unknown) => value is bigint;
|
|
313
|
-
//#endregion
|
|
314
|
-
//#region src/isBooleanTrue.d.ts
|
|
315
284
|
/** @deprecated use isTruthy instead */
|
|
316
285
|
export declare const isBooleanTrue: <T>(x: T | null | undefined) => x is T;
|
|
317
|
-
//#endregion
|
|
318
|
-
//#region src/isErrorOfName.d.ts
|
|
319
286
|
/**
|
|
320
287
|
* Robust replacement for `error instanceof SomeErrorClass` when the class comes from a
|
|
321
288
|
* package that gets bundled into multiple chunks/contexts (e.g. viem, @solana/web3.js).
|
|
@@ -328,8 +295,6 @@ export declare const isBooleanTrue: <T>(x: T | null | undefined) => x is T;
|
|
|
328
295
|
* duck-type the shape instead.
|
|
329
296
|
*/
|
|
330
297
|
export declare const isErrorOfName: (error: unknown, ...names: string[]) => boolean;
|
|
331
|
-
//#endregion
|
|
332
|
-
//#region src/isNotNil.d.ts
|
|
333
298
|
/**
|
|
334
299
|
* WARNING: This function only checks against null or undefined, it does not coerce the value.
|
|
335
300
|
* ie: false and 0 are considered not nil
|
|
@@ -339,20 +304,12 @@ export declare const isErrorOfName: (error: unknown, ...names: string[]) => bool
|
|
|
339
304
|
* @returns whether the value is neither null nor undefined
|
|
340
305
|
*/
|
|
341
306
|
export declare const isNotNil: <T>(value: T | null | undefined) => value is T;
|
|
342
|
-
//#endregion
|
|
343
|
-
//#region src/isPromise.d.ts
|
|
344
307
|
export declare const isPromise: <T = any>(value: any) => value is Promise<T>;
|
|
345
|
-
//#endregion
|
|
346
|
-
//#region src/isSubject.d.ts
|
|
347
308
|
/**
|
|
348
309
|
* Tests to see if an object is an RxJS {@link Subject}.
|
|
349
310
|
*/
|
|
350
311
|
export declare function isSubject<T>(object?: Subject<T> | object): object is Subject<T>;
|
|
351
|
-
//#endregion
|
|
352
|
-
//#region src/isTruthy.d.ts
|
|
353
312
|
export declare const isTruthy: <T>(value: T | null | undefined) => value is T;
|
|
354
|
-
//#endregion
|
|
355
|
-
//#region src/jsActivityHook.d.ts
|
|
356
313
|
/**
|
|
357
314
|
* Optional host-provided JS-activity hook.
|
|
358
315
|
*
|
|
@@ -365,8 +322,6 @@ export declare const isTruthy: <T>(value: T | null | undefined) => value is T;
|
|
|
365
322
|
* can call it unconditionally from hot paths.
|
|
366
323
|
*/
|
|
367
324
|
export declare const reportJsActivity: (label: string, durationMs?: number) => void;
|
|
368
|
-
//#endregion
|
|
369
|
-
//#region src/keepAlive.d.ts
|
|
370
325
|
/**
|
|
371
326
|
* An RxJS operator that keeps the source observable alive for a specified duration
|
|
372
327
|
* after all subscribers have unsubscribed. This prevents expensive re-subscriptions
|
|
@@ -383,8 +338,6 @@ export declare const reportJsActivity: (label: string, durationMs?: number) => v
|
|
|
383
338
|
* ```
|
|
384
339
|
*/
|
|
385
340
|
export declare const keepAlive: <T>(timeout: number) => OperatorFunction<T, T>;
|
|
386
|
-
//#endregion
|
|
387
|
-
//#region src/lruMap.d.ts
|
|
388
341
|
/**
|
|
389
342
|
* A Map with a maximum size and least-recently-used eviction.
|
|
390
343
|
*
|
|
@@ -402,8 +355,6 @@ export declare class LruMap<K, V> {
|
|
|
402
355
|
clear(): void;
|
|
403
356
|
get size(): number;
|
|
404
357
|
}
|
|
405
|
-
//#endregion
|
|
406
|
-
//#region src/mapChunked.d.ts
|
|
407
358
|
export type ChunkedProjectContext = {
|
|
408
359
|
/** thread the slicer through chunked helpers (mapWithYield etc.) so the budget spans them */
|
|
409
360
|
slicer: TimeSlicer;
|
|
@@ -434,16 +385,10 @@ export declare const concatMapChunked: <T, R>(project: (value: T, ctx: ChunkedPr
|
|
|
434
385
|
budgetMs?: number;
|
|
435
386
|
label?: string;
|
|
436
387
|
}) => OperatorFunction<T, R>;
|
|
437
|
-
//#endregion
|
|
438
|
-
//#region src/Prettify.d.ts
|
|
439
388
|
export type Prettify<T> = { [K in keyof T]: T[K]; } & {};
|
|
440
|
-
//#endregion
|
|
441
|
-
//#region src/planckToTokens.d.ts
|
|
442
389
|
export declare function planckToTokens(planck: string, tokenDecimals: number): string;
|
|
443
390
|
export declare function planckToTokens(planck: string, tokenDecimals?: number): string | undefined;
|
|
444
391
|
export declare function planckToTokens(planck?: string, tokenDecimals?: number): string | undefined;
|
|
445
|
-
//#endregion
|
|
446
|
-
//#region src/replaySubjectFrom.d.ts
|
|
447
392
|
/**
|
|
448
393
|
* Turns a value into a {@link ReplaySubject} of size 1.
|
|
449
394
|
*
|
|
@@ -455,11 +400,7 @@ export declare function planckToTokens(planck?: string, tokenDecimals?: number):
|
|
|
455
400
|
* For any other type of value, it will be immediately published into the {@link ReplaySubject}.
|
|
456
401
|
*/
|
|
457
402
|
export declare const replaySubjectFrom: <T>(initialValue: T | Promise<T> | ReplaySubject<T>) => ReplaySubject<T>;
|
|
458
|
-
//#endregion
|
|
459
|
-
//#region src/sleep.d.ts
|
|
460
403
|
export declare const sleep: (ms: number) => Promise<void>;
|
|
461
|
-
//#endregion
|
|
462
|
-
//#region src/splitSubject.d.ts
|
|
463
404
|
/**
|
|
464
405
|
* Takes a subject and splits it into two parts:
|
|
465
406
|
*
|
|
@@ -470,8 +411,6 @@ export declare const sleep: (ms: number) => Promise<void>;
|
|
|
470
411
|
* of these parts to external code and keep the other part private.
|
|
471
412
|
*/
|
|
472
413
|
export declare function splitSubject<T>(subject: Subject<T>): readonly [(value: T) => void, Observable<T>];
|
|
473
|
-
//#endregion
|
|
474
|
-
//#region src/stripHexPrefix.d.ts
|
|
475
414
|
/**
|
|
476
415
|
* @name stripHexPrefix
|
|
477
416
|
* @description Removes a leading `0x` prefix from a string, if present.
|
|
@@ -482,16 +421,10 @@ export declare function splitSubject<T>(subject: Subject<T>): readonly [(value:
|
|
|
482
421
|
* stripHexPrefix("1234") // "1234"
|
|
483
422
|
**/
|
|
484
423
|
export declare const stripHexPrefix: (str: string) => string;
|
|
485
|
-
//#endregion
|
|
486
|
-
//#region src/throwAfter.d.ts
|
|
487
424
|
export declare const throwAfter: (ms: number, reason: string) => Promise<never>;
|
|
488
|
-
//#endregion
|
|
489
|
-
//#region src/tokensToPlanck.d.ts
|
|
490
425
|
export declare function tokensToPlanck(tokens: string, tokenDecimals: number): string;
|
|
491
426
|
export declare function tokensToPlanck(tokens: string, tokenDecimals?: number): string | undefined;
|
|
492
427
|
export declare function tokensToPlanck(tokens?: string, tokenDecimals?: number): string | undefined;
|
|
493
|
-
//#endregion
|
|
494
|
-
//#region src/validateArrayWithYield.d.ts
|
|
495
428
|
export type ItemParseResult<T, E> = {
|
|
496
429
|
success: true;
|
|
497
430
|
data: T;
|
|
@@ -518,8 +451,6 @@ export type ArrayValidationResult<T, E> = {
|
|
|
518
451
|
* Zod-agnostic on purpose: this package has no zod dependency.
|
|
519
452
|
*/
|
|
520
453
|
export declare const validateArrayWithYield: <T, E>(items: readonly unknown[], parseItem: (item: unknown, index: number) => ItemParseResult<T, E>, options?: ChunkedOptions) => Promise<ArrayValidationResult<T, E>>;
|
|
521
|
-
//#endregion
|
|
522
|
-
//#region src/validateHexString.d.ts
|
|
523
454
|
/**
|
|
524
455
|
* @name validateHexString
|
|
525
456
|
* @description Checks if a string is a hex string. Required to account for type differences between different polkadot libraries
|
|
@@ -531,8 +462,6 @@ export declare const validateArrayWithYield: <T, E>(items: readonly unknown[], p
|
|
|
531
462
|
* validateHexString(1234) // Error: Expected a string
|
|
532
463
|
**/
|
|
533
464
|
export declare const validateHexString: (str: string) => `0x${string}`;
|
|
534
|
-
//#endregion
|
|
535
|
-
//#region src/yieldToEventLoop.d.ts
|
|
536
465
|
export declare const yieldToEventLoop: () => Promise<void>;
|
|
537
|
-
|
|
466
|
+
export {};
|
|
538
467
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/addTrailingSlash.ts","../src/assert.ts","../src/BigMath.ts","../src/isHexString.ts","../src/bytes.ts","../src/timeSlicer.ts","../src/chunkedArray.ts","../src/deferred.ts","../src/FunctionPropertyNames.ts","../src/firstThenDebounce.ts","../src/formatDecimals.ts","../src/formatPrice.ts","../src/getErrorMessage.ts","../src/getLoadable.ts","../src/getLoadableQuery.ts","../src/getQuery.ts","../src/getSharedObservable.ts","../src/hasOwnProperty.ts","../src/isAbortError.ts","../src/isArrayOf.ts","../src/isAscii.ts","../src/isBigInt.ts","../src/isBooleanTrue.ts","../src/isErrorOfName.ts","../src/isNotNil.ts","../src/isPromise.ts","../src/isSubject.ts","../src/isTruthy.ts","../src/jsActivityHook.ts","../src/keepAlive.ts","../src/lruMap.ts","../src/mapChunked.ts","../src/Prettify.ts","../src/planckToTokens.ts","../src/replaySubjectFrom.ts","../src/sleep.ts","../src/splitSubject.ts","../src/stripHexPrefix.ts","../src/throwAfter.ts","../src/tokensToPlanck.ts","../src/validateArrayWithYield.ts","../src/validateHexString.ts","../src/yieldToEventLoop.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["BigNumber"],"sources":["../src/addTrailingSlash.ts","../src/assert.ts","../src/BigMath.ts","../src/isHexString.ts","../src/bytes.ts","../src/timeSlicer.ts","../src/chunkedArray.ts","../src/deferred.ts","../src/FunctionPropertyNames.ts","../src/firstThenDebounce.ts","../src/formatCurrency.ts","../src/formatDecimals.ts","../src/formatPrice.ts","../src/getErrorMessage.ts","../src/getLoadable.ts","../src/getLoadableQuery.ts","../src/getQuery.ts","../src/getSharedObservable.ts","../src/hasOwnProperty.ts","../src/isAbortError.ts","../src/isArrayOf.ts","../src/isAscii.ts","../src/isBigInt.ts","../src/isBooleanTrue.ts","../src/isErrorOfName.ts","../src/isNotNil.ts","../src/isPromise.ts","../src/isSubject.ts","../src/isTruthy.ts","../src/jsActivityHook.ts","../src/keepAlive.ts","../src/lruMap.ts","../src/mapChunked.ts","../src/Prettify.ts","../src/planckToTokens.ts","../src/replaySubjectFrom.ts","../src/sleep.ts","../src/splitSubject.ts","../src/stripHexPrefix.ts","../src/throwAfter.ts","../src/tokensToPlanck.ts","../src/validateArrayWithYield.ts","../src/validateHexString.ts","../src/yieldToEventLoop.ts"],"mappings":";;qBAAa,mBAAgB;;;;;;;wBCMb,OAAO,oBAAoB,2CAA2C;;;;;qBCFzE;EACX,IAAG;EAGH,KAAI;EAIJ,IAAG,kBAAc;EAIjB,IAAG,kBAAc;;YChBP;qBAEC,kBAAgB;qBAEhB,cAAW,mBAAqB,SAAS;;;;;qBCGzC,WAAQ,wBAA0B;qBAalC,WAAQ,QAAY,sBAAoB;qBAOxC,cAAW,0BAA4B;qBAGvC,cAAW,QAAY;qBAGvB,cAAW;qBAEX,cAAW;qBAEX,cAAW,0BAA4B;;qBAOvC,WAAQ,4BAAgC,sBAAoB;qBAO5D,eAAS,4BAAmC,kBAAgB;qBAW5D,QAAK,YAAgB,YAAU,YAAc;qBAO7C,SAAM,YAAgB,YAAU,YAAc;;;;;qBAe9C,mBAAgB,iBAAqB;;qBAgBrC,eAAY,gBAAoB,eAAa;qBAK7C,iBAAc,gBAAoB,eAAa;;;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