/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ /** * Declare the subset of node:Buffer functionality we want to make available instead of * exposing the entirely of Node's typings. These serve as the public interface * of the browser and node implementation. */ /** * Set of supported encodings for string to buffer conversion. * * @internal */ export type IsoBufferEncoding = "utf8" | "utf-8" | "base64"; /** * Minimal Buffer interface for our usages in the browser or Node environments. * * @internal */ export interface IsoBuffer extends Uint8Array { /** * Convert the buffer to a string. * Only supports encoding the whole string (unlike the Node `Buffer` equivalent) * and only utf8 and base64 encodings. * * @param encoding - The encoding to use. */ toString(encoding?: IsoBufferEncoding): string; } /** * Constructor for {@link (IsoBuffer:type)}. * * @internal */ export interface IsoBufferConstructor { readonly prototype: IsoBuffer; new (length: number): IsoBuffer; new (array: ArrayLike): IsoBuffer; new (buffer: TArrayBuffer, byteOffset?: number, length?: number): IsoBuffer; /** * Creates a new `IsoBuffer` containing `string`. The `encoding` parameter identifies * the character encoding to be used when converting `string` into bytes. * * @param string - A string to encode. * @param encoding - The encoding of `string`. **Default:** `'utf8'`. * * @privateRemarks * Node buffer.buffer.d.ts declaration: * `from(string: WithImplicitCoercion, encoding?: IsoBufferEncoding): Buffer;` */ from(string: string, encoding?: IsoBufferEncoding): IsoBuffer; /** * Allocates a new `IsoBuffer` using an `array` of bytes in the range `0` – `255`. * Array entries outside that range will be truncated to fit into it. * * @param value - `Uint8Array`. * * @remarks * This is limited to `Uint8Array` input to match Node implementation that * takes `ArrayLike` and returns `IsoBuffer`. * * @privateRemarks * Node buffer.buffer.d.ts declaration: * `from(array: WithImplicitCoercion>): IsoBuffer;` */ from(array: Uint8Array): IsoBuffer; /** * This creates a view of the `ArrayBuffer` without copying the underlying * memory. For example, when passed a reference to the `.buffer` property of a * `TypedArray` instance, the newly created `Buffer` will share the same * allocated memory as the `TypedArray`'s underlying `ArrayBuffer`. * * @param arrayBuffer - An `ArrayBuffer`, `SharedArrayBuffer`, for example the * `.buffer` property of a `TypedArray`. * @param byteOffset - Index of first byte to expose. **Default:** `0`. * @param length - Number of bytes to expose. **Default:** * `arrayBuffer.byteLength - byteOffset`. * * @privateRemarks * Node buffer.buffer.d.ts declaration: * ``` * public static from>( * arrayBuffer: TArrayBuffer, * byteOffset?: number, * length?: number, * ): Buffer>; * ``` */ from(arrayBuffer: TArrayBuffer, byteOffset?: number, length?: number): IsoBuffer; isBuffer(obj: unknown): obj is IsoBuffer; } //# sourceMappingURL=buffer.d.ts.map