@dfinity/utils 2.1.2 → 2.1.3-next-2024-03-25

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/README.md CHANGED
@@ -90,9 +90,9 @@ Get a default agent that connects to mainnet with the anonymous identity.
90
90
 
91
91
  Create an agent for a given identity
92
92
 
93
- | Function | Type |
94
- | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
95
- | `createAgent` | `({ identity, host, fetchRootKey, verifyQuerySignatures, }: { identity: Identity; host?: string; fetchRootKey?: boolean; verifyQuerySignatures?: boolean; }) => Promise<HttpAgent>` |
93
+ | Function | Type |
94
+ | ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
95
+ | `createAgent` | `({ identity, host, fetchRootKey, verifyQuerySignatures, }: { identity: Identity; host?: string or undefined; fetchRootKey?: boolean or undefined; verifyQuerySignatures?: boolean or undefined; }) => Promise<HttpAgent>` |
96
96
 
97
97
  Parameters:
98
98
 
@@ -105,17 +105,17 @@ Parameters:
105
105
 
106
106
  #### :gear: createServices
107
107
 
108
- | Function | Type |
109
- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
110
- | `createServices` | `<T>({ options: { canisterId, serviceOverride, certifiedServiceOverride, agent: agentOption, callTransform, queryTransform, }, idlFactory, certifiedIdlFactory, }: { options: Required<Pick<CanisterOptions<T>, "canisterId">> and Omit<CanisterOptions<T>, "canisterId"> & Pick<...>; idlFactory: InterfaceFactory; certifiedId...` |
108
+ | Function | Type |
109
+ | ---------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
110
+ | `createServices` | `<T>({ options: { canisterId, serviceOverride, certifiedServiceOverride, agent: agentOption, callTransform, queryTransform, }, idlFactory, certifiedIdlFactory, }: { options: Required<Pick<CanisterOptions<T>, "canisterId">> and Omit<CanisterOptions<T>, "canisterId"> and Pick<...>; idlFactory: InterfaceFactory; certifiedId...` |
111
111
 
112
112
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/actor.utils.ts#L13)
113
113
 
114
114
  #### :gear: assertNonNullish
115
115
 
116
- | Function | Type |
117
- | ------------------ | -------------------------------------------------------------------- |
118
- | `assertNonNullish` | `<T>(value: T, message?: string) => asserts value is NonNullable<T>` |
116
+ | Function | Type |
117
+ | ------------------ | --------------------------------------------------------------------------------- |
118
+ | `assertNonNullish` | `<T>(value: T, message?: string or undefined) => asserts value is NonNullable<T>` |
119
119
 
120
120
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/asserts.utils.ts#L7)
121
121
 
@@ -240,21 +240,23 @@ Parameters:
240
240
 
241
241
  Convert seconds to a human-readable duration, such as "6 days, 10 hours."
242
242
 
243
- | Function | Type |
244
- | ------------------- | ------------------------------------------------------------------------------------ |
245
- | `secondsToDuration` | `({ seconds, i18n, }: { seconds: bigint; i18n?: I18nSecondsToDuration; }) => string` |
243
+ | Function | Type |
244
+ | ------------------- | ------------------------------------------------------------------------------------------------- |
245
+ | `secondsToDuration` | `({ seconds, i18n, }: { seconds: bigint; i18n?: I18nSecondsToDuration or undefined; }) => string` |
246
246
 
247
247
  Parameters:
248
248
 
249
249
  - `options`: - The options object.
250
+ - `options.seconds`: - The number of seconds to convert.
251
+ - `options.i18n`: - The i18n object for customizing language and units. Defaults to English.
250
252
 
251
253
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/date.utils.ts#L43)
252
254
 
253
255
  #### :gear: debounce
254
256
 
255
- | Function | Type |
256
- | ---------- | -------------------------------------------------------------------- |
257
- | `debounce` | `(func: Function, timeout?: number) => (...args: unknown[]) => void` |
257
+ | Function | Type |
258
+ | ---------- | --------------------------------------------------------------------------------- |
259
+ | `debounce` | `(func: Function, timeout?: number or undefined) => (...args: unknown[]) => void` |
258
260
 
259
261
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/debounce.utils.ts#L2)
260
262
 
@@ -262,9 +264,9 @@ Parameters:
262
264
 
263
265
  Is null or undefined
264
266
 
265
- | Function | Type |
266
- | ----------- | -------------------------------------- |
267
- | `isNullish` | `<T>(argument: T) => argument is null` |
267
+ | Function | Type |
268
+ | ----------- | ------------------------------------------------------------------------ |
269
+ | `isNullish` | `<T>(argument: T or null or undefined) => argument is null or undefined` |
268
270
 
269
271
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L2)
270
272
 
@@ -272,9 +274,9 @@ Is null or undefined
272
274
 
273
275
  Not null and not undefined
274
276
 
275
- | Function | Type |
276
- | ------------ | ------------------------------------------------ |
277
- | `nonNullish` | `<T>(argument: T) => argument is NonNullable<T>` |
277
+ | Function | Type |
278
+ | ------------ | --------------------------------------------------------------------- |
279
+ | `nonNullish` | `<T>(argument: T or null or undefined) => argument is NonNullable<T>` |
278
280
 
279
281
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L7)
280
282
 
@@ -282,25 +284,25 @@ Not null and not undefined
282
284
 
283
285
  Not null and not undefined and not empty
284
286
 
285
- | Function | Type |
286
- | ---------------- | ---------------------------- |
287
- | `notEmptyString` | `(value: string) => boolean` |
287
+ | Function | Type |
288
+ | ---------------- | ------------------------------------------------- |
289
+ | `notEmptyString` | `(value: string or null or undefined) => boolean` |
288
290
 
289
291
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/nullish.utils.ts#L12)
290
292
 
291
293
  #### :gear: toNullable
292
294
 
293
- | Function | Type |
294
- | ------------ | ----------------------------- |
295
- | `toNullable` | `<T>(value?: T) => [] or [T]` |
295
+ | Function | Type |
296
+ | ------------ | -------------------------------------------------- |
297
+ | `toNullable` | `<T>(value?: T or null or undefined) => [] or [T]` |
296
298
 
297
299
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L4)
298
300
 
299
301
  #### :gear: fromNullable
300
302
 
301
- | Function | Type |
302
- | -------------- | ---------------------------- |
303
- | `fromNullable` | `<T>(value: [] or [T]) => T` |
303
+ | Function | Type |
304
+ | -------------- | ----------------------------------------- |
305
+ | `fromNullable` | `<T>(value: [] or [T]) => T or undefined` |
304
306
 
305
307
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/did.utils.ts#L8)
306
308
 
@@ -356,6 +358,11 @@ Tags after patch version are ignored, e.g. 1.0.0-beta.1 is considered equal to 1
356
358
  | ---------------- | ----------------------------------------------------------------------------------------------- |
357
359
  | `smallerVersion` | `({ minVersion, currentVersion, }: { minVersion: string; currentVersion: string; }) => boolean` |
358
360
 
361
+ Parameters:
362
+
363
+ - `params.minVersion`: Ex: "1.0.0"
364
+ - `params.currentVersion`: Ex: "2.0.0"
365
+
359
366
  [:link: Source](https://github.com/dfinity/ic-js/tree/main/packages/utils/src/utils/version.utils.ts#L28)
360
367
 
361
368
  ### :wrench: Constants
@@ -4,7 +4,7 @@ import type { Principal } from "@dfinity/principal";
4
4
  import type { CanisterOptions } from "../types/canister.options";
5
5
  type RequiredCanisterOptions<T> = Required<Pick<CanisterOptions<T>, "canisterId">> & Omit<CanisterOptions<T>, "canisterId">;
6
6
  export declare const createServices: <T>({ options: { canisterId, serviceOverride, certifiedServiceOverride, agent: agentOption, callTransform, queryTransform, }, idlFactory, certifiedIdlFactory, }: {
7
- options: Required<Pick<CanisterOptions<T>, "canisterId">> & Omit<CanisterOptions<T>, "canisterId"> & Pick<ActorConfig, "queryTransform" | "callTransform">;
7
+ options: RequiredCanisterOptions<T> & Pick<ActorConfig, "queryTransform" | "callTransform">;
8
8
  idlFactory: IDL.InterfaceFactory;
9
9
  certifiedIdlFactory: IDL.InterfaceFactory;
10
10
  }) => {
@@ -1,3 +1,3 @@
1
- export declare const toNullable: <T>(value?: T | null | undefined) => [] | [T];
1
+ export declare const toNullable: <T>(value?: T | null) => [] | [T];
2
2
  export declare const fromNullable: <T>(value: [] | [T]) => T | undefined;
3
3
  export declare const fromDefinedNullable: <T>(value: [] | [T]) => T;
@@ -1,6 +1,6 @@
1
1
  /** Is null or undefined */
2
- export declare const isNullish: <T>(argument: T | null | undefined) => argument is null | undefined;
2
+ export declare const isNullish: <T>(argument: T | undefined | null) => argument is null | undefined;
3
3
  /** Not null and not undefined */
4
- export declare const nonNullish: <T>(argument: T | null | undefined) => argument is NonNullable<T>;
4
+ export declare const nonNullish: <T>(argument: T | undefined | null) => argument is NonNullable<T>;
5
5
  /** Not null and not undefined and not empty */
6
6
  export declare const notEmptyString: (value: string | undefined | null) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfinity/utils",
3
- "version": "2.1.2",
3
+ "version": "2.1.3-next-2024-03-25",
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",
@@ -47,8 +47,8 @@
47
47
  "service-nervous-system"
48
48
  ],
49
49
  "peerDependencies": {
50
- "@dfinity/agent": "^1.0.1",
51
- "@dfinity/candid": "^1.0.1",
52
- "@dfinity/principal": "^1.0.1"
50
+ "@dfinity/agent": "*",
51
+ "@dfinity/candid": "*",
52
+ "@dfinity/principal": "*"
53
53
  }
54
- }
54
+ }