UNPKG

multiformats

Version:

Interface for multihash, multicodec, multibase and CID

31 lines 1.38 kB
export declare const empty: Uint8Array<ArrayBuffer>; export declare function toHex(d: Uint8Array): string; export declare function fromHex(hex: string): Uint8Array<ArrayBuffer>; export declare function equals(aa: Uint8Array, bb: Uint8Array): boolean; /** * Normalize binary input to a plain `Uint8Array` backed by an `ArrayBuffer`. * * Returns the input itself when it is already a plain `Uint8Array` over an * `ArrayBuffer`, otherwise a fresh view (or, for `SharedArrayBuffer`-backed * input, a copy) over the same bytes. * * Throws if input is not a recognised binary type. */ export declare function coerce(o: ArrayBufferView | ArrayBuffer | Uint8Array): Uint8Array<ArrayBuffer>; export declare function isBinary(o: unknown): o is ArrayBuffer | ArrayBufferView; /** * Convert the passed string into a byte array, constraining each character * value to a single byte */ export declare function fromString(str: string): Uint8Array<ArrayBuffer>; /** * Convert the passed byte array to a string, interpreting each byte as a single * character */ export declare function toString(b: Uint8Array): string; /** * Ensures `b` is backed by an ArrayBuffer - if not a new Uint8Array will be * created and the contents of `b` copied into it. */ export declare function toArrayBufferBackedArray(b: Uint8Array): Uint8Array<ArrayBuffer>; //# sourceMappingURL=bytes.d.ts.map