File
Blob: src/node/internal/buffer.d.ts
| 1 | // Copyright (c) 2026 Cloudflare, Inc. |
| 2 | // Licensed under the Apache 2.0 license found in the LICENSE file or at: |
| 3 | // https://opensource.org/licenses/Apache-2.0 |
| 4 | |
| 5 | // Type definitions for c++ implementation |
| 6 | |
| 7 | interface CompareOptions { |
| 8 | aStart?: number; |
| 9 | aEnd?: number; |
| 10 | bStart?: number; |
| 11 | bEnd?: number; |
| 12 | } |
| 13 | |
| 14 | type BufferSource = ArrayBufferView | ArrayBuffer; |
| 15 | |
| 16 | export type Encoding = number; |
| 17 | |
| 18 | export function byteLength(value: string): number; |
| 19 | export function compare( |
| 20 | a: Uint8Array, |
| 21 | b: Uint8Array, |
| 22 | options?: CompareOptions |
| 23 | ): number; |
| 24 | export function concat(list: Uint8Array[], length: number): Uint8Array; |
| 25 | export function decodeString(value: string, encoding: Encoding): Uint8Array; |
| 26 | export function fillImpl( |
| 27 | buffer: Uint8Array, |
| 28 | value: string | BufferSource, |
| 29 | start: number, |
| 30 | end: number, |
| 31 | encoding?: Encoding |
| 32 | ): void; |
| 33 | export function indexOf( |
| 34 | buffer: Uint8Array, |
| 35 | value: string | Uint8Array, |
| 36 | byteOffset?: number, |
| 37 | encoding?: Encoding, |
| 38 | findLast?: boolean |
| 39 | ): number | undefined; |
| 40 | export function swap(buffer: Uint8Array, size: 16 | 32 | 64): void; |
| 41 | export function toString( |
| 42 | buffer: Uint8Array, |
| 43 | start: number, |
| 44 | end: number, |
| 45 | encoding: Encoding |
| 46 | ): string; |
| 47 | export function write( |
| 48 | buffer: Uint8Array, |
| 49 | value: string, |
| 50 | offset: number, |
| 51 | length: number, |
| 52 | encoding: Encoding |
| 53 | ): void; |
| 54 | export function decode(buffer: Uint8Array, state: Uint8Array): string; |
| 55 | export function flush(state: Uint8Array): string; |
| 56 | export function isAscii(value: ArrayBufferView): boolean; |
| 57 | export function isUtf8(value: ArrayBufferView): boolean; |
| 58 | export function transcode( |
| 59 | source: ArrayBufferView, |
| 60 | fromEncoding: Encoding, |
| 61 | toEncoding: Encoding |
| 62 | ): Uint8Array; |
| 63 | |
| 64 | export const ASCII: Encoding; |
| 65 | export const LATIN1: Encoding; |
| 66 | export const UTF8: Encoding; |
| 67 | export const UTF16LE: Encoding; |
| 68 | export const BASE64: Encoding; |
| 69 | export const BASE64URL: Encoding; |
| 70 | export const HEX: Encoding; |