• Public
  • Public/Protected
  • All

Module util


This package is part of NDNts, Named Data Networking libraries for the modern web.

This package contains general utilities used in NDNts codebase. This package cannot depend on other NDNts packages.



console: Console = ...

Console on stderr.

crypto: Crypto = ...


  • asDataView(a: BufferSource): DataView
  • flatMapOnce<T, R>(f: (item: T) => Iterable<R> | AsyncIterable<R>, iterable: AsyncIterable<T>): AsyncIterable<R>
  • Map and flatten once. This differs from flatMap in streaming-iterables, which recursively flattens the result.

    Type parameters

    • T

    • R


    • f: (item: T) => Iterable<R> | AsyncIterable<R>
        • (item: T): Iterable<R> | AsyncIterable<R>
        • Parameters

          • item: T

          Returns Iterable<R> | AsyncIterable<R>

    • iterable: AsyncIterable<T>

    Returns AsyncIterable<R>

  • fromHex(s: string): Uint8Array
  • Convert hexadecimal string to byte array.

    If the input is not a valid hexadecimal string, result will be incorrect.


    • s: string

    Returns Uint8Array

  • fromUtf8(buf: Uint8Array): string
  • safeIter<T>(iterable: AsyncIterable<T>, onError?: (err?: unknown) => void): AsyncIterableIterator<T>
  • Yield all values from an iterable but catch any error.

    Type parameters

    • T


    • iterable: AsyncIterable<T>
    • Optional onError: (err?: unknown) => void
        • (err?: unknown): void
        • Parameters

          • Optional err: unknown

          Returns void

    Returns AsyncIterableIterator<T>

  • sha256(input: Uint8Array): Promise<Uint8Array>
  • timingSafeEqual(a: Uint8Array, b: Uint8Array): boolean
  • toHex(buf: Uint8Array): string
  • toUtf8(s: string): Uint8Array

Generated using TypeDoc