Skip to content
File

Blob: src/node/internal/buffer.d.ts

typescript71 lines
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 
7interface CompareOptions {
8 aStart?: number;
9 aEnd?: number;
10 bStart?: number;
11 bEnd?: number;
12}
13 
14type BufferSource = ArrayBufferView | ArrayBuffer;
15 
16export type Encoding = number;
17 
18export function byteLength(value: string): number;
19export function compare(
20 a: Uint8Array,
21 b: Uint8Array,
22 options?: CompareOptions
23): number;
24export function concat(list: Uint8Array[], length: number): Uint8Array;
25export function decodeString(value: string, encoding: Encoding): Uint8Array;
26export function fillImpl(
27 buffer: Uint8Array,
28 value: string | BufferSource,
29 start: number,
30 end: number,
31 encoding?: Encoding
32): void;
33export function indexOf(
34 buffer: Uint8Array,
35 value: string | Uint8Array,
36 byteOffset?: number,
37 encoding?: Encoding,
38 findLast?: boolean
39): number | undefined;
40export function swap(buffer: Uint8Array, size: 16 | 32 | 64): void;
41export function toString(
42 buffer: Uint8Array,
43 start: number,
44 end: number,
45 encoding: Encoding
46): string;
47export function write(
48 buffer: Uint8Array,
49 value: string,
50 offset: number,
51 length: number,
52 encoding: Encoding
53): void;
54export function decode(buffer: Uint8Array, state: Uint8Array): string;
55export function flush(state: Uint8Array): string;
56export function isAscii(value: ArrayBufferView): boolean;
57export function isUtf8(value: ArrayBufferView): boolean;
58export function transcode(
59 source: ArrayBufferView,
60 fromEncoding: Encoding,
61 toEncoding: Encoding
62): Uint8Array;
63 
64export const ASCII: Encoding;
65export const LATIN1: Encoding;
66export const UTF8: Encoding;
67export const UTF16LE: Encoding;
68export const BASE64: Encoding;
69export const BASE64URL: Encoding;
70export const HEX: Encoding;