Skip to main content
Module

x/polkadot/util/buffer/toU8a.ts

Package publishing for deno.land/x/polkadot
Go to Latest
File

/** * @name bufferToU8a * @summary Creates a Uint8Array value from a Buffer object. * @description * `null` inputs returns an empty result, `Buffer` values return the actual value as a `Uint8Array`. Anything that is not a `Buffer` object throws an error. * @example * <BR> * * ```javascript * import { bufferToU8a } from 'https://deno.land/x/polkadot@0.2.33/util/mod.ts'; * * bufferToU8a(Buffer.from([1, 2, 3])); * ``` */export function bufferToU8a (buffer?: Buffer | number[] | null): Uint8Array { return new Uint8Array(buffer || []);}