UNPKG

3.1 kBTypeScriptView Raw
1declare module 'buffer' {
2 import { BinaryLike } from 'node:crypto';
3 export const INSPECT_MAX_BYTES: number;
4 export const kMaxLength: number;
5 export const kStringMaxLength: number;
6 export const constants: {
7 MAX_LENGTH: number;
8 MAX_STRING_LENGTH: number;
9 };
10 const BuffType: typeof Buffer;
11
12 export type TranscodeEncoding = "ascii" | "utf8" | "utf16le" | "ucs2" | "latin1" | "binary";
13
14 export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
15
16 export const SlowBuffer: {
17 /** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */
18 new(size: number): Buffer;
19 prototype: Buffer;
20 };
21 /**
22 * @experimental
23 */
24 export interface BlobOptions {
25 /**
26 * @default 'utf8'
27 */
28 encoding?: BufferEncoding | undefined;
29 /**
30 * The Blob content-type. The intent is for `type` to convey
31 * the MIME media type of the data, however no validation of the type format
32 * is performed.
33 */
34 type?: string | undefined;
35 }
36 /**
37 * A [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) encapsulates immutable, raw data that can be safely shared across
38 * multiple worker threads.
39 * @since v14.18.0
40 * @experimental
41 */
42 export class Blob {
43 /**
44 * The total size of the `Blob` in bytes.
45 * @since v14.18.0
46 */
47 readonly size: number;
48 /**
49 * The content-type of the `Blob`.
50 * @since v14.18.0
51 */
52 readonly type: string;
53 /**
54 * Creates a new `Blob` object containing a concatenation of the given sources.
55 *
56 * {ArrayBuffer}, {TypedArray}, {DataView}, and {Buffer} sources are copied into
57 * the 'Blob' and can therefore be safely modified after the 'Blob' is created.
58 *
59 * String sources are also copied into the `Blob`.
60 */
61 constructor(sources: Array<BinaryLike | Blob>, options?: BlobOptions);
62 /**
63 * Returns a promise that fulfills with an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer) containing a copy of
64 * the `Blob` data.
65 * @since v14.18.0
66 */
67 arrayBuffer(): Promise<ArrayBuffer>;
68 /**
69 * Creates and returns a new `Blob` containing a subset of this `Blob` objects
70 * data. The original `Blob` is not altered.
71 * @since v14.18.0
72 * @param start The starting index.
73 * @param end The ending index.
74 * @param type The content-type for the new `Blob`
75 */
76 slice(start?: number, end?: number, type?: string): Blob;
77 /**
78 * Returns a promise that fulfills with the contents of the `Blob` decoded as a
79 * UTF-8 string.
80 * @since v14.18.0
81 */
82 text(): Promise<string>;
83 }
84
85 export { BuffType as Buffer };
86}
87declare module 'node:buffer' {
88 export * from 'buffer';
89}
90
\No newline at end of file