Options
All
  • Public
  • Public/Protected
  • All
Menu

@cosmjs/utils Documentation

Index

Functions

  • arrayContentEquals<T>(a: ArrayLike<T>, b: ArrayLike<T>): boolean
  • Compares the content of two arrays-like objects for equality.

    Equality is defined as having equal length and element values, where element equality means === returning true.

    This allows you to compare the content of a Buffer, Uint8Array or number[], ignoring the specific type. As a consequence, this returns different results than Jasmine's toEqual, which ensures elements have the same type.

    Type Parameters

    • T extends string | number | boolean

    Parameters

    • a: ArrayLike<T>
    • b: ArrayLike<T>

    Returns boolean

  • arrayContentStartsWith<T>(a: ArrayLike<T>, b: ArrayLike<T>): boolean
  • Checks if a starts with the contents of b.

    This requires equality of the element values, where element equality means === returning true.

    This allows you to compare the content of a Buffer, Uint8Array or number[], ignoring the specific type. As a consequence, this returns different results than Jasmine's toEqual, which ensures elements have the same type.

    Type Parameters

    • T extends string | number | boolean

    Parameters

    • a: ArrayLike<T>
    • b: ArrayLike<T>

    Returns boolean

  • assert(condition: any, msg?: string): asserts condition
  • Parameters

    • condition: any
    • Optional msg: string

    Returns asserts condition

  • assertDefined<T>(value: undefined | T, msg?: string): asserts value is T
  • Type Parameters

    • T

    Parameters

    • value: undefined | T
    • Optional msg: string

    Returns asserts value is T

  • assertDefinedAndNotNull<T>(value: undefined | null | T, msg?: string): asserts value is T
  • Type Parameters

    • T

    Parameters

    • value: undefined | null | T
    • Optional msg: string

    Returns asserts value is T

  • isDefined<X>(value: undefined | X): value is X
  • Checks if input is not undefined in a TypeScript-friendly way.

    This is convenient to use in e.g. Array.filter as it will convert the type of a Array<Foo | undefined> to Array<Foo>.

    Type Parameters

    • X

    Parameters

    • value: undefined | X

    Returns value is X

  • isNonNullObject(data: unknown): data is object
  • isUint8Array(data: unknown): data is Uint8Array
  • Checks if data is an Uint8Array. Note: Buffer is treated as not a Uint8Array

    Parameters

    • data: unknown

    Returns data is Uint8Array

  • sleep(ms: number): Promise<void>
  • Parameters

    • ms: number

    Returns Promise<void>

Generated using TypeDoc