@dfinity/utils 2.13.1-next-2025-07-01 → 2.13.1-next-2025-07-07

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.
Files changed (2) hide show
  1. package/README.md +112 -0
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -85,6 +85,10 @@ Parameters:
85
85
 
86
86
  - `amount`: - in string format
87
87
 
88
+ Returns:
89
+
90
+ bigint | FromStringToTokenError
91
+
88
92
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L12)
89
93
 
90
94
  #### :gear: isNullish
@@ -99,6 +103,10 @@ Parameters:
99
103
 
100
104
  - `argument`: - The argument to check.
101
105
 
106
+ Returns:
107
+
108
+ `true` if the argument is null or undefined; otherwise, `false`.
109
+
102
110
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L8)
103
111
 
104
112
  #### :gear: nonNullish
@@ -113,6 +121,10 @@ Parameters:
113
121
 
114
122
  - `argument`: - The argument to check.
115
123
 
124
+ Returns:
125
+
126
+ `true` if the argument is not null or undefined; otherwise, `false`.
127
+
116
128
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L19)
117
129
 
118
130
  #### :gear: notEmptyString
@@ -127,6 +139,10 @@ Parameters:
127
139
 
128
140
  - `value`: - The value to check.
129
141
 
142
+ Returns:
143
+
144
+ `true` if the value is not null, not undefined, and not an empty string; otherwise, `false`.
145
+
130
146
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L29)
131
147
 
132
148
  #### :gear: isEmptyString
@@ -141,6 +157,10 @@ Parameters:
141
157
 
142
158
  - `value`: - The value to check.
143
159
 
160
+ Returns:
161
+
162
+ Type predicate indicating if the value is null, undefined, or an empty string.
163
+
144
164
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L39)
145
165
 
146
166
  #### :gear: queryAndUpdate
@@ -179,6 +199,10 @@ Parameters:
179
199
  - `params.identity`: The identity to use for the request.
180
200
  - `params.resolution`: The resolution to use. Default is `race`.
181
201
 
202
+ Returns:
203
+
204
+ A promise that resolves when the request is done.
205
+
182
206
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/services/query.ts#L36)
183
207
 
184
208
  #### :gear: defaultAgent
@@ -189,6 +213,10 @@ Get a default agent that connects to mainnet with the anonymous identity.
189
213
  | -------------- | ------------- |
190
214
  | `defaultAgent` | `() => Agent` |
191
215
 
216
+ Returns:
217
+
218
+ The default agent to use
219
+
192
220
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L14)
193
221
 
194
222
  #### :gear: createAgent
@@ -334,6 +362,10 @@ Parameters:
334
362
 
335
363
  - `input`: The input array to encode.
336
364
 
365
+ Returns:
366
+
367
+ A Base32 string encoding the input.
368
+
337
369
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/base32.utils.ts#L21)
338
370
 
339
371
  #### :gear: decodeBase32
@@ -363,6 +395,10 @@ Parameters:
363
395
 
364
396
  - `uint8Array`: - The Uint8Array containing binary data to be encoded.
365
397
 
398
+ Returns:
399
+
400
+ - The base64 encoded string representation of the binary data.
401
+
366
402
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/base64.utils.ts#L7)
367
403
 
368
404
  #### :gear: base64ToUint8Array
@@ -377,6 +413,10 @@ Parameters:
377
413
 
378
414
  - `base64String`: - The base64 encoded string to be decoded.
379
415
 
416
+ Returns:
417
+
418
+ - The Uint8Array representation of the decoded binary data.
419
+
380
420
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/base64.utils.ts#L16)
381
421
 
382
422
  #### :gear: bigEndianCrc32
@@ -407,6 +447,10 @@ Parameters:
407
447
  - `_key`: - Ignored. Only provided for API compatibility.
408
448
  - `value`: - The value to transform before stringification.
409
449
 
450
+ Returns:
451
+
452
+ The transformed value if it matches a known type, otherwise the original value.
453
+
410
454
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/json.utils.ts#L22)
411
455
 
412
456
  #### :gear: jsonReviver
@@ -430,6 +474,10 @@ Parameters:
430
474
  - `_key`: - Ignored but provided for API compatibility.
431
475
  - `value`: - The parsed value to transform.
432
476
 
477
+ Returns:
478
+
479
+ The reconstructed value if it matches a known type, otherwise the original value.
480
+
433
481
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/json.utils.ts#L53)
434
482
 
435
483
  #### :gear: hashObject
@@ -447,6 +495,10 @@ Parameters:
447
495
 
448
496
  - `params`: - The object to hash.
449
497
 
498
+ Returns:
499
+
500
+ A promise that resolves to the hex string of the SHA-256 hash.
501
+
450
502
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/crypto.utils.ts#L14)
451
503
 
452
504
  #### :gear: hashText
@@ -464,6 +516,10 @@ Parameters:
464
516
 
465
517
  - `text`: - The text to hash.
466
518
 
519
+ Returns:
520
+
521
+ A promise that resolves to the hex string of the SHA-256 hash.
522
+
467
523
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/crypto.utils.ts#L31)
468
524
 
469
525
  #### :gear: secondsToDuration
@@ -480,6 +536,10 @@ Parameters:
480
536
  - `options.seconds`: - The number of seconds to convert.
481
537
  - `options.i18n`: - The i18n object for customizing language and units. Defaults to English.
482
538
 
539
+ Returns:
540
+
541
+ The human-readable duration string.
542
+
483
543
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/date.utils.ts#L43)
484
544
 
485
545
  #### :gear: nowInBigIntNanoSeconds
@@ -490,6 +550,10 @@ Returns the current timestamp in nanoseconds as a `bigint`.
490
550
  | ------------------------ | -------------- |
491
551
  | `nowInBigIntNanoSeconds` | `() => bigint` |
492
552
 
553
+ Returns:
554
+
555
+ The current timestamp in nanoseconds.
556
+
493
557
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/date.utils.ts#L123)
494
558
 
495
559
  #### :gear: toBigIntNanoSeconds
@@ -504,6 +568,10 @@ Parameters:
504
568
 
505
569
  - `date`: - The `Date` object to convert.
506
570
 
571
+ Returns:
572
+
573
+ The timestamp in nanoseconds.
574
+
507
575
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/date.utils.ts#L132)
508
576
 
509
577
  #### :gear: debounce
@@ -523,6 +591,10 @@ Parameters:
523
591
  - `func`: - The function to debounce. It will only be called after no new calls happen within the specified timeout.
524
592
  - `timeout`: - The debounce delay in milliseconds. Defaults to 300ms if not provided or invalid.
525
593
 
594
+ Returns:
595
+
596
+ A debounced version of the original function.
597
+
526
598
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/debounce.utils.ts#L13)
527
599
 
528
600
  #### :gear: toNullable
@@ -537,6 +609,10 @@ Parameters:
537
609
 
538
610
  - `value`: - The value to convert into a Candid-style variant.
539
611
 
612
+ Returns:
613
+
614
+ A Candid-style variant representation: an empty array for `null` and `undefined` or an array with the value.
615
+
540
616
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L12)
541
617
 
542
618
  #### :gear: fromNullable
@@ -551,6 +627,10 @@ Parameters:
551
627
 
552
628
  - `value`: - A Candid-style variant representing an optional value.
553
629
 
630
+ Returns:
631
+
632
+ The extracted value, or `undefined` if the array is empty.
633
+
554
634
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L22)
555
635
 
556
636
  #### :gear: fromDefinedNullable
@@ -566,6 +646,10 @@ Parameters:
566
646
 
567
647
  - `value`: - A Candid-style variant representing an optional value.
568
648
 
649
+ Returns:
650
+
651
+ The extracted value.
652
+
569
653
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L34)
570
654
 
571
655
  #### :gear: fromNullishNullable
@@ -580,6 +664,10 @@ Parameters:
580
664
 
581
665
  - `value`: - A Candid-style variant or `undefined`.
582
666
 
667
+ Returns:
668
+
669
+ The extracted value, or `undefined` if the input is nullish or the array is empty.
670
+
583
671
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L49)
584
672
 
585
673
  #### :gear: principalToSubAccount
@@ -611,6 +699,10 @@ Parameters:
611
699
  - `params.minVersion`: Ex: "1.0.0"
612
700
  - `params.currentVersion`: Ex: "2.0.0"
613
701
 
702
+ Returns:
703
+
704
+ boolean
705
+
614
706
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/version.utils.ts#L34)
615
707
 
616
708
  ### :wrench: Constants
@@ -709,6 +801,10 @@ Parameters:
709
801
  | ------- | -------------- |
710
802
  | `toE8s` | `() => bigint` |
711
803
 
804
+ Returns:
805
+
806
+ The amount of e8s.
807
+
712
808
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L224)
713
809
 
714
810
  ### :factory: TokenAmountV2
@@ -785,6 +881,10 @@ Parameters:
785
881
  | -------- | -------------- |
786
882
  | `toUlps` | `() => bigint` |
787
883
 
884
+ Returns:
885
+
886
+ The amount of ulps.
887
+
788
888
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L324)
789
889
 
790
890
  ##### :gear: toE8s
@@ -793,6 +893,10 @@ Parameters:
793
893
  | ------- | -------------- |
794
894
  | `toE8s` | `() => bigint` |
795
895
 
896
+ Returns:
897
+
898
+ The amount of ulps in e8s precision
899
+
796
900
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/parser/token.ts#L332)
797
901
 
798
902
  ### :factory: Canister
@@ -829,6 +933,10 @@ Parameters:
829
933
  - `config.fetchRootKey`: - Whether to fetch the root key for certificate validation.
830
934
  - `config.host`: - The host to connect to.
831
935
 
936
+ Returns:
937
+
938
+ A new instance of `AgentManager`.
939
+
832
940
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L72)
833
941
 
834
942
  #### Methods
@@ -851,6 +959,10 @@ Parameters:
851
959
 
852
960
  - `identity`: - The identity to be used to create the agent.
853
961
 
962
+ Returns:
963
+
964
+ The HttpAgent associated with the given identity.
965
+
854
966
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/agent.utils.ts#L85)
855
967
 
856
968
  ##### :gear: clearAgents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfinity/utils",
3
- "version": "2.13.1-next-2025-07-01",
3
+ "version": "2.13.1-next-2025-07-07",
4
4
  "description": "A collection of utilities and constants for NNS/SNS projects.",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/cjs/index.cjs.js",