utils-js
A collection of utilities and constants for NNS/SNS projects.

Table of contents
Installation
You can use utils-js
by installing it in your project.
npm i @dfinity/utils
The bundle needs peer dependencies, be sure that following resources are available in your project as well.
npm i @dfinity/agent @dfinity/candid @dfinity/principal
Features
utils-js
implements following features:
:toolbox: Functions
:gear: defaultAgent
Function | Type |
---|
defaultAgent | () => Agent |
:gear: createServices
Function | Type |
---|
createServices | <T>({ options: { canisterId, serviceOverride, certifiedServiceOverride, agent: agentOption, }, idlFactory, certifiedIdlFactory, }: { options: RequiredCanisterOptions<T>; idlFactory: InterfaceFactory; certifiedIdlFactory: InterfaceFactory; }) => { ...; } |
:gear: assertNonNullish
Function | Type |
---|
assertNonNullish | <T>(value: T, message?: string) => asserts value is NonNullable<T> |
:gear: toNullable
Function | Type |
---|
toNullable | <T>(value?: T) => [] or [T] |
:gear: fromNullable
Function | Type |
---|
fromNullable | <T>(value: [] or [T]) => T |
:gear: fromDefinedNullable
Function | Type |
---|
fromDefinedNullable | <T>(value: [] or [T]) => T |
:factory: NullishError
Constructors
public
Parameters: