rahad-all-downloader 2.1.15 → 2.1.17
Sign up to get free protection for your applications and to get access to all the features.
- package/.github/workflows/Run.yml +20 -0
- package/README.md +0 -1
- package/index.js +1 -1
- package/package.json +4 -2
- package/.cache/nix/binary-cache-v6.sqlite +0 -0
- package/.cache/nix/binary-cache-v6.sqlite-journal +0 -0
- package/.cache/replit/modules/nix.res +0 -1
- package/.cache/replit/modules/nodejs-20.res +0 -1
- package/.cache/replit/modules/replit.res +0 -1
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/replit/nix/env.json +0 -1
- package/.cache/typescript/5.4/node_modules/.package-lock.json +0 -137
- package/.cache/typescript/5.4/node_modules/@types/caseless/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/@types/caseless/README.md +0 -48
- package/.cache/typescript/5.4/node_modules/@types/caseless/index.d.ts +0 -29
- package/.cache/typescript/5.4/node_modules/@types/caseless/package.json +0 -35
- package/.cache/typescript/5.4/node_modules/@types/node/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/@types/node/README.md +0 -15
- package/.cache/typescript/5.4/node_modules/@types/node/assert/strict.d.ts +0 -8
- package/.cache/typescript/5.4/node_modules/@types/node/assert.d.ts +0 -1040
- package/.cache/typescript/5.4/node_modules/@types/node/async_hooks.d.ts +0 -541
- package/.cache/typescript/5.4/node_modules/@types/node/buffer.d.ts +0 -2363
- package/.cache/typescript/5.4/node_modules/@types/node/child_process.d.ts +0 -1544
- package/.cache/typescript/5.4/node_modules/@types/node/cluster.d.ts +0 -578
- package/.cache/typescript/5.4/node_modules/@types/node/console.d.ts +0 -452
- package/.cache/typescript/5.4/node_modules/@types/node/constants.d.ts +0 -19
- package/.cache/typescript/5.4/node_modules/@types/node/crypto.d.ts +0 -4523
- package/.cache/typescript/5.4/node_modules/@types/node/dgram.d.ts +0 -596
- package/.cache/typescript/5.4/node_modules/@types/node/diagnostics_channel.d.ts +0 -554
- package/.cache/typescript/5.4/node_modules/@types/node/dns/promises.d.ts +0 -474
- package/.cache/typescript/5.4/node_modules/@types/node/dns.d.ts +0 -864
- package/.cache/typescript/5.4/node_modules/@types/node/dom-events.d.ts +0 -124
- package/.cache/typescript/5.4/node_modules/@types/node/domain.d.ts +0 -170
- package/.cache/typescript/5.4/node_modules/@types/node/events.d.ts +0 -909
- package/.cache/typescript/5.4/node_modules/@types/node/fs/promises.d.ts +0 -1245
- package/.cache/typescript/5.4/node_modules/@types/node/fs.d.ts +0 -4317
- package/.cache/typescript/5.4/node_modules/@types/node/globals.d.ts +0 -411
- package/.cache/typescript/5.4/node_modules/@types/node/globals.global.d.ts +0 -1
- package/.cache/typescript/5.4/node_modules/@types/node/http.d.ts +0 -1908
- package/.cache/typescript/5.4/node_modules/@types/node/http2.d.ts +0 -2418
- package/.cache/typescript/5.4/node_modules/@types/node/https.d.ts +0 -550
- package/.cache/typescript/5.4/node_modules/@types/node/index.d.ts +0 -89
- package/.cache/typescript/5.4/node_modules/@types/node/inspector.d.ts +0 -2746
- package/.cache/typescript/5.4/node_modules/@types/node/module.d.ts +0 -315
- package/.cache/typescript/5.4/node_modules/@types/node/net.d.ts +0 -999
- package/.cache/typescript/5.4/node_modules/@types/node/os.d.ts +0 -495
- package/.cache/typescript/5.4/node_modules/@types/node/package.json +0 -217
- package/.cache/typescript/5.4/node_modules/@types/node/path.d.ts +0 -191
- package/.cache/typescript/5.4/node_modules/@types/node/perf_hooks.d.ts +0 -905
- package/.cache/typescript/5.4/node_modules/@types/node/process.d.ts +0 -1754
- package/.cache/typescript/5.4/node_modules/@types/node/punycode.d.ts +0 -117
- package/.cache/typescript/5.4/node_modules/@types/node/querystring.d.ts +0 -153
- package/.cache/typescript/5.4/node_modules/@types/node/readline/promises.d.ts +0 -150
- package/.cache/typescript/5.4/node_modules/@types/node/readline.d.ts +0 -540
- package/.cache/typescript/5.4/node_modules/@types/node/repl.d.ts +0 -430
- package/.cache/typescript/5.4/node_modules/@types/node/sea.d.ts +0 -153
- package/.cache/typescript/5.4/node_modules/@types/node/stream/consumers.d.ts +0 -12
- package/.cache/typescript/5.4/node_modules/@types/node/stream/promises.d.ts +0 -83
- package/.cache/typescript/5.4/node_modules/@types/node/stream/web.d.ts +0 -367
- package/.cache/typescript/5.4/node_modules/@types/node/stream.d.ts +0 -1707
- package/.cache/typescript/5.4/node_modules/@types/node/string_decoder.d.ts +0 -67
- package/.cache/typescript/5.4/node_modules/@types/node/test.d.ts +0 -1718
- package/.cache/typescript/5.4/node_modules/@types/node/timers/promises.d.ts +0 -97
- package/.cache/typescript/5.4/node_modules/@types/node/timers.d.ts +0 -240
- package/.cache/typescript/5.4/node_modules/@types/node/tls.d.ts +0 -1217
- package/.cache/typescript/5.4/node_modules/@types/node/trace_events.d.ts +0 -197
- package/.cache/typescript/5.4/node_modules/@types/node/tty.d.ts +0 -208
- package/.cache/typescript/5.4/node_modules/@types/node/url.d.ts +0 -952
- package/.cache/typescript/5.4/node_modules/@types/node/util.d.ts +0 -2292
- package/.cache/typescript/5.4/node_modules/@types/node/v8.d.ts +0 -808
- package/.cache/typescript/5.4/node_modules/@types/node/vm.d.ts +0 -924
- package/.cache/typescript/5.4/node_modules/@types/node/wasi.d.ts +0 -181
- package/.cache/typescript/5.4/node_modules/@types/node/worker_threads.d.ts +0 -691
- package/.cache/typescript/5.4/node_modules/@types/node/zlib.d.ts +0 -530
- package/.cache/typescript/5.4/node_modules/@types/node-fetch/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/@types/node-fetch/README.md +0 -15
- package/.cache/typescript/5.4/node_modules/@types/node-fetch/externals.d.ts +0 -32
- package/.cache/typescript/5.4/node_modules/@types/node-fetch/index.d.ts +0 -238
- package/.cache/typescript/5.4/node_modules/@types/node-fetch/package.json +0 -83
- package/.cache/typescript/5.4/node_modules/@types/request/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/@types/request/README.md +0 -15
- package/.cache/typescript/5.4/node_modules/@types/request/index.d.ts +0 -395
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/License +0 -19
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md +0 -350
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/README.md.bak +0 -350
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/index.d.ts +0 -51
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/browser.js +0 -2
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/form_data.js +0 -483
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/lib/populate.js +0 -10
- package/.cache/typescript/5.4/node_modules/@types/request/node_modules/form-data/package.json +0 -68
- package/.cache/typescript/5.4/node_modules/@types/request/package.json +0 -70
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/README.md +0 -15
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/index.d.ts +0 -321
- package/.cache/typescript/5.4/node_modules/@types/tough-cookie/package.json +0 -35
- package/.cache/typescript/5.4/node_modules/asynckit/LICENSE +0 -21
- package/.cache/typescript/5.4/node_modules/asynckit/README.md +0 -233
- package/.cache/typescript/5.4/node_modules/asynckit/bench.js +0 -76
- package/.cache/typescript/5.4/node_modules/asynckit/index.js +0 -6
- package/.cache/typescript/5.4/node_modules/asynckit/lib/abort.js +0 -29
- package/.cache/typescript/5.4/node_modules/asynckit/lib/async.js +0 -34
- package/.cache/typescript/5.4/node_modules/asynckit/lib/defer.js +0 -26
- package/.cache/typescript/5.4/node_modules/asynckit/lib/iterate.js +0 -75
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_asynckit.js +0 -91
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_parallel.js +0 -25
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial.js +0 -25
- package/.cache/typescript/5.4/node_modules/asynckit/lib/readable_serial_ordered.js +0 -29
- package/.cache/typescript/5.4/node_modules/asynckit/lib/state.js +0 -37
- package/.cache/typescript/5.4/node_modules/asynckit/lib/streamify.js +0 -141
- package/.cache/typescript/5.4/node_modules/asynckit/lib/terminator.js +0 -29
- package/.cache/typescript/5.4/node_modules/asynckit/package.json +0 -63
- package/.cache/typescript/5.4/node_modules/asynckit/parallel.js +0 -43
- package/.cache/typescript/5.4/node_modules/asynckit/serial.js +0 -17
- package/.cache/typescript/5.4/node_modules/asynckit/serialOrdered.js +0 -75
- package/.cache/typescript/5.4/node_modules/asynckit/stream.js +0 -21
- package/.cache/typescript/5.4/node_modules/combined-stream/License +0 -19
- package/.cache/typescript/5.4/node_modules/combined-stream/Readme.md +0 -138
- package/.cache/typescript/5.4/node_modules/combined-stream/lib/combined_stream.js +0 -208
- package/.cache/typescript/5.4/node_modules/combined-stream/package.json +0 -25
- package/.cache/typescript/5.4/node_modules/combined-stream/yarn.lock +0 -17
- package/.cache/typescript/5.4/node_modules/delayed-stream/License +0 -19
- package/.cache/typescript/5.4/node_modules/delayed-stream/Makefile +0 -7
- package/.cache/typescript/5.4/node_modules/delayed-stream/Readme.md +0 -141
- package/.cache/typescript/5.4/node_modules/delayed-stream/lib/delayed_stream.js +0 -107
- package/.cache/typescript/5.4/node_modules/delayed-stream/package.json +0 -27
- package/.cache/typescript/5.4/node_modules/form-data/License +0 -19
- package/.cache/typescript/5.4/node_modules/form-data/README.md.bak +0 -358
- package/.cache/typescript/5.4/node_modules/form-data/Readme.md +0 -358
- package/.cache/typescript/5.4/node_modules/form-data/index.d.ts +0 -62
- package/.cache/typescript/5.4/node_modules/form-data/lib/browser.js +0 -2
- package/.cache/typescript/5.4/node_modules/form-data/lib/form_data.js +0 -501
- package/.cache/typescript/5.4/node_modules/form-data/lib/populate.js +0 -10
- package/.cache/typescript/5.4/node_modules/form-data/package.json +0 -68
- package/.cache/typescript/5.4/node_modules/mime-db/HISTORY.md +0 -507
- package/.cache/typescript/5.4/node_modules/mime-db/LICENSE +0 -23
- package/.cache/typescript/5.4/node_modules/mime-db/README.md +0 -100
- package/.cache/typescript/5.4/node_modules/mime-db/db.json +0 -8519
- package/.cache/typescript/5.4/node_modules/mime-db/index.js +0 -12
- package/.cache/typescript/5.4/node_modules/mime-db/package.json +0 -60
- package/.cache/typescript/5.4/node_modules/mime-types/HISTORY.md +0 -397
- package/.cache/typescript/5.4/node_modules/mime-types/LICENSE +0 -23
- package/.cache/typescript/5.4/node_modules/mime-types/README.md +0 -113
- package/.cache/typescript/5.4/node_modules/mime-types/index.js +0 -188
- package/.cache/typescript/5.4/node_modules/mime-types/package.json +0 -44
- package/.cache/typescript/5.4/node_modules/types-registry/README.md +0 -2
- package/.cache/typescript/5.4/node_modules/types-registry/index.json +0 -1
- package/.cache/typescript/5.4/node_modules/types-registry/package.json +0 -20
- package/.cache/typescript/5.4/node_modules/undici-types/README.md +0 -6
- package/.cache/typescript/5.4/node_modules/undici-types/agent.d.ts +0 -31
- package/.cache/typescript/5.4/node_modules/undici-types/api.d.ts +0 -43
- package/.cache/typescript/5.4/node_modules/undici-types/balanced-pool.d.ts +0 -18
- package/.cache/typescript/5.4/node_modules/undici-types/cache.d.ts +0 -36
- package/.cache/typescript/5.4/node_modules/undici-types/client.d.ts +0 -97
- package/.cache/typescript/5.4/node_modules/undici-types/connector.d.ts +0 -34
- package/.cache/typescript/5.4/node_modules/undici-types/content-type.d.ts +0 -21
- package/.cache/typescript/5.4/node_modules/undici-types/cookies.d.ts +0 -28
- package/.cache/typescript/5.4/node_modules/undici-types/diagnostics-channel.d.ts +0 -67
- package/.cache/typescript/5.4/node_modules/undici-types/dispatcher.d.ts +0 -241
- package/.cache/typescript/5.4/node_modules/undici-types/errors.d.ts +0 -128
- package/.cache/typescript/5.4/node_modules/undici-types/fetch.d.ts +0 -209
- package/.cache/typescript/5.4/node_modules/undici-types/file.d.ts +0 -39
- package/.cache/typescript/5.4/node_modules/undici-types/filereader.d.ts +0 -54
- package/.cache/typescript/5.4/node_modules/undici-types/formdata.d.ts +0 -108
- package/.cache/typescript/5.4/node_modules/undici-types/global-dispatcher.d.ts +0 -9
- package/.cache/typescript/5.4/node_modules/undici-types/global-origin.d.ts +0 -7
- package/.cache/typescript/5.4/node_modules/undici-types/handlers.d.ts +0 -9
- package/.cache/typescript/5.4/node_modules/undici-types/header.d.ts +0 -4
- package/.cache/typescript/5.4/node_modules/undici-types/index.d.ts +0 -63
- package/.cache/typescript/5.4/node_modules/undici-types/interceptors.d.ts +0 -5
- package/.cache/typescript/5.4/node_modules/undici-types/mock-agent.d.ts +0 -50
- package/.cache/typescript/5.4/node_modules/undici-types/mock-client.d.ts +0 -25
- package/.cache/typescript/5.4/node_modules/undici-types/mock-errors.d.ts +0 -12
- package/.cache/typescript/5.4/node_modules/undici-types/mock-interceptor.d.ts +0 -93
- package/.cache/typescript/5.4/node_modules/undici-types/mock-pool.d.ts +0 -25
- package/.cache/typescript/5.4/node_modules/undici-types/package.json +0 -55
- package/.cache/typescript/5.4/node_modules/undici-types/patch.d.ts +0 -71
- package/.cache/typescript/5.4/node_modules/undici-types/pool-stats.d.ts +0 -19
- package/.cache/typescript/5.4/node_modules/undici-types/pool.d.ts +0 -28
- package/.cache/typescript/5.4/node_modules/undici-types/proxy-agent.d.ts +0 -30
- package/.cache/typescript/5.4/node_modules/undici-types/readable.d.ts +0 -61
- package/.cache/typescript/5.4/node_modules/undici-types/webidl.d.ts +0 -220
- package/.cache/typescript/5.4/node_modules/undici-types/websocket.d.ts +0 -131
- package/.cache/typescript/5.4/package-lock.json +0 -146
- package/.cache/typescript/5.4/package.json +0 -1
- package/.replit +0 -21
- package/replit.nix +0 -3
@@ -1,2363 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* `Buffer` objects are used to represent a fixed-length sequence of bytes. Many
|
3
|
-
* Node.js APIs support `Buffer`s.
|
4
|
-
*
|
5
|
-
* The `Buffer` class is a subclass of JavaScript's [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) class and
|
6
|
-
* extends it with methods that cover additional use cases. Node.js APIs accept
|
7
|
-
* plain [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) s wherever `Buffer`s are supported as well.
|
8
|
-
*
|
9
|
-
* While the `Buffer` class is available within the global scope, it is still
|
10
|
-
* recommended to explicitly reference it via an import or require statement.
|
11
|
-
*
|
12
|
-
* ```js
|
13
|
-
* import { Buffer } from 'node:buffer';
|
14
|
-
*
|
15
|
-
* // Creates a zero-filled Buffer of length 10.
|
16
|
-
* const buf1 = Buffer.alloc(10);
|
17
|
-
*
|
18
|
-
* // Creates a Buffer of length 10,
|
19
|
-
* // filled with bytes which all have the value `1`.
|
20
|
-
* const buf2 = Buffer.alloc(10, 1);
|
21
|
-
*
|
22
|
-
* // Creates an uninitialized buffer of length 10.
|
23
|
-
* // This is faster than calling Buffer.alloc() but the returned
|
24
|
-
* // Buffer instance might contain old data that needs to be
|
25
|
-
* // overwritten using fill(), write(), or other functions that fill the Buffer's
|
26
|
-
* // contents.
|
27
|
-
* const buf3 = Buffer.allocUnsafe(10);
|
28
|
-
*
|
29
|
-
* // Creates a Buffer containing the bytes [1, 2, 3].
|
30
|
-
* const buf4 = Buffer.from([1, 2, 3]);
|
31
|
-
*
|
32
|
-
* // Creates a Buffer containing the bytes [1, 1, 1, 1] – the entries
|
33
|
-
* // are all truncated using `(value & 255)` to fit into the range 0–255.
|
34
|
-
* const buf5 = Buffer.from([257, 257.5, -255, '1']);
|
35
|
-
*
|
36
|
-
* // Creates a Buffer containing the UTF-8-encoded bytes for the string 'tést':
|
37
|
-
* // [0x74, 0xc3, 0xa9, 0x73, 0x74] (in hexadecimal notation)
|
38
|
-
* // [116, 195, 169, 115, 116] (in decimal notation)
|
39
|
-
* const buf6 = Buffer.from('tést');
|
40
|
-
*
|
41
|
-
* // Creates a Buffer containing the Latin-1 bytes [0x74, 0xe9, 0x73, 0x74].
|
42
|
-
* const buf7 = Buffer.from('tést', 'latin1');
|
43
|
-
* ```
|
44
|
-
* @see [source](https://github.com/nodejs/node/blob/v20.13.1/lib/buffer.js)
|
45
|
-
*/
|
46
|
-
declare module "buffer" {
|
47
|
-
import { BinaryLike } from "node:crypto";
|
48
|
-
import { ReadableStream as WebReadableStream } from "node:stream/web";
|
49
|
-
/**
|
50
|
-
* This function returns `true` if `input` contains only valid UTF-8-encoded data,
|
51
|
-
* including the case in which `input` is empty.
|
52
|
-
*
|
53
|
-
* Throws if the `input` is a detached array buffer.
|
54
|
-
* @since v19.4.0, v18.14.0
|
55
|
-
* @param input The input to validate.
|
56
|
-
*/
|
57
|
-
export function isUtf8(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;
|
58
|
-
/**
|
59
|
-
* This function returns `true` if `input` contains only valid ASCII-encoded data,
|
60
|
-
* including the case in which `input` is empty.
|
61
|
-
*
|
62
|
-
* Throws if the `input` is a detached array buffer.
|
63
|
-
* @since v19.6.0, v18.15.0
|
64
|
-
* @param input The input to validate.
|
65
|
-
*/
|
66
|
-
export function isAscii(input: Buffer | ArrayBuffer | NodeJS.TypedArray): boolean;
|
67
|
-
export const INSPECT_MAX_BYTES: number;
|
68
|
-
export const kMaxLength: number;
|
69
|
-
export const kStringMaxLength: number;
|
70
|
-
export const constants: {
|
71
|
-
MAX_LENGTH: number;
|
72
|
-
MAX_STRING_LENGTH: number;
|
73
|
-
};
|
74
|
-
export type TranscodeEncoding =
|
75
|
-
| "ascii"
|
76
|
-
| "utf8"
|
77
|
-
| "utf-8"
|
78
|
-
| "utf16le"
|
79
|
-
| "utf-16le"
|
80
|
-
| "ucs2"
|
81
|
-
| "ucs-2"
|
82
|
-
| "latin1"
|
83
|
-
| "binary";
|
84
|
-
/**
|
85
|
-
* Re-encodes the given `Buffer` or `Uint8Array` instance from one character
|
86
|
-
* encoding to another. Returns a new `Buffer` instance.
|
87
|
-
*
|
88
|
-
* Throws if the `fromEnc` or `toEnc` specify invalid character encodings or if
|
89
|
-
* conversion from `fromEnc` to `toEnc` is not permitted.
|
90
|
-
*
|
91
|
-
* Encodings supported by `buffer.transcode()` are: `'ascii'`, `'utf8'`, `'utf16le'`, `'ucs2'`, `'latin1'`, and `'binary'`.
|
92
|
-
*
|
93
|
-
* The transcoding process will use substitution characters if a given byte
|
94
|
-
* sequence cannot be adequately represented in the target encoding. For instance:
|
95
|
-
*
|
96
|
-
* ```js
|
97
|
-
* import { Buffer, transcode } from 'node:buffer';
|
98
|
-
*
|
99
|
-
* const newBuf = transcode(Buffer.from('€'), 'utf8', 'ascii');
|
100
|
-
* console.log(newBuf.toString('ascii'));
|
101
|
-
* // Prints: '?'
|
102
|
-
* ```
|
103
|
-
*
|
104
|
-
* Because the Euro (`€`) sign is not representable in US-ASCII, it is replaced
|
105
|
-
* with `?` in the transcoded `Buffer`.
|
106
|
-
* @since v7.1.0
|
107
|
-
* @param source A `Buffer` or `Uint8Array` instance.
|
108
|
-
* @param fromEnc The current encoding.
|
109
|
-
* @param toEnc To target encoding.
|
110
|
-
*/
|
111
|
-
export function transcode(source: Uint8Array, fromEnc: TranscodeEncoding, toEnc: TranscodeEncoding): Buffer;
|
112
|
-
export const SlowBuffer: {
|
113
|
-
/** @deprecated since v6.0.0, use `Buffer.allocUnsafeSlow()` */
|
114
|
-
new(size: number): Buffer;
|
115
|
-
prototype: Buffer;
|
116
|
-
};
|
117
|
-
/**
|
118
|
-
* Resolves a `'blob:nodedata:...'` an associated `Blob` object registered using
|
119
|
-
* a prior call to `URL.createObjectURL()`.
|
120
|
-
* @since v16.7.0
|
121
|
-
* @experimental
|
122
|
-
* @param id A `'blob:nodedata:...` URL string returned by a prior call to `URL.createObjectURL()`.
|
123
|
-
*/
|
124
|
-
export function resolveObjectURL(id: string): Blob | undefined;
|
125
|
-
export { Buffer };
|
126
|
-
/**
|
127
|
-
* @experimental
|
128
|
-
*/
|
129
|
-
export interface BlobOptions {
|
130
|
-
/**
|
131
|
-
* One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts
|
132
|
-
* will be converted to the platform native line-ending as specified by `require('node:os').EOL`.
|
133
|
-
*/
|
134
|
-
endings?: "transparent" | "native";
|
135
|
-
/**
|
136
|
-
* The Blob content-type. The intent is for `type` to convey
|
137
|
-
* the MIME media type of the data, however no validation of the type format
|
138
|
-
* is performed.
|
139
|
-
*/
|
140
|
-
type?: string | undefined;
|
141
|
-
}
|
142
|
-
/**
|
143
|
-
* A [`Blob`](https://developer.mozilla.org/en-US/docs/Web/API/Blob) encapsulates immutable, raw data that can be safely shared across
|
144
|
-
* multiple worker threads.
|
145
|
-
* @since v15.7.0, v14.18.0
|
146
|
-
*/
|
147
|
-
export class Blob {
|
148
|
-
/**
|
149
|
-
* The total size of the `Blob` in bytes.
|
150
|
-
* @since v15.7.0, v14.18.0
|
151
|
-
*/
|
152
|
-
readonly size: number;
|
153
|
-
/**
|
154
|
-
* The content-type of the `Blob`.
|
155
|
-
* @since v15.7.0, v14.18.0
|
156
|
-
*/
|
157
|
-
readonly type: string;
|
158
|
-
/**
|
159
|
-
* Creates a new `Blob` object containing a concatenation of the given sources.
|
160
|
-
*
|
161
|
-
* {ArrayBuffer}, {TypedArray}, {DataView}, and {Buffer} sources are copied into
|
162
|
-
* the 'Blob' and can therefore be safely modified after the 'Blob' is created.
|
163
|
-
*
|
164
|
-
* String sources are also copied into the `Blob`.
|
165
|
-
*/
|
166
|
-
constructor(sources: Array<ArrayBuffer | BinaryLike | Blob>, options?: BlobOptions);
|
167
|
-
/**
|
168
|
-
* 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
|
169
|
-
* the `Blob` data.
|
170
|
-
* @since v15.7.0, v14.18.0
|
171
|
-
*/
|
172
|
-
arrayBuffer(): Promise<ArrayBuffer>;
|
173
|
-
/**
|
174
|
-
* Creates and returns a new `Blob` containing a subset of this `Blob` objects
|
175
|
-
* data. The original `Blob` is not altered.
|
176
|
-
* @since v15.7.0, v14.18.0
|
177
|
-
* @param start The starting index.
|
178
|
-
* @param end The ending index.
|
179
|
-
* @param type The content-type for the new `Blob`
|
180
|
-
*/
|
181
|
-
slice(start?: number, end?: number, type?: string): Blob;
|
182
|
-
/**
|
183
|
-
* Returns a promise that fulfills with the contents of the `Blob` decoded as a
|
184
|
-
* UTF-8 string.
|
185
|
-
* @since v15.7.0, v14.18.0
|
186
|
-
*/
|
187
|
-
text(): Promise<string>;
|
188
|
-
/**
|
189
|
-
* Returns a new `ReadableStream` that allows the content of the `Blob` to be read.
|
190
|
-
* @since v16.7.0
|
191
|
-
*/
|
192
|
-
stream(): WebReadableStream;
|
193
|
-
}
|
194
|
-
export interface FileOptions {
|
195
|
-
/**
|
196
|
-
* One of either `'transparent'` or `'native'`. When set to `'native'`, line endings in string source parts will be
|
197
|
-
* converted to the platform native line-ending as specified by `require('node:os').EOL`.
|
198
|
-
*/
|
199
|
-
endings?: "native" | "transparent";
|
200
|
-
/** The File content-type. */
|
201
|
-
type?: string;
|
202
|
-
/** The last modified date of the file. `Default`: Date.now(). */
|
203
|
-
lastModified?: number;
|
204
|
-
}
|
205
|
-
/**
|
206
|
-
* A [`File`](https://developer.mozilla.org/en-US/docs/Web/API/File) provides information about files.
|
207
|
-
* @since v19.2.0, v18.13.0
|
208
|
-
*/
|
209
|
-
export class File extends Blob {
|
210
|
-
constructor(sources: Array<BinaryLike | Blob>, fileName: string, options?: FileOptions);
|
211
|
-
/**
|
212
|
-
* The name of the `File`.
|
213
|
-
* @since v19.2.0, v18.13.0
|
214
|
-
*/
|
215
|
-
readonly name: string;
|
216
|
-
/**
|
217
|
-
* The last modified date of the `File`.
|
218
|
-
* @since v19.2.0, v18.13.0
|
219
|
-
*/
|
220
|
-
readonly lastModified: number;
|
221
|
-
}
|
222
|
-
export import atob = globalThis.atob;
|
223
|
-
export import btoa = globalThis.btoa;
|
224
|
-
import { Blob as NodeBlob } from "buffer";
|
225
|
-
// This conditional type will be the existing global Blob in a browser, or
|
226
|
-
// the copy below in a Node environment.
|
227
|
-
type __Blob = typeof globalThis extends { onmessage: any; Blob: any } ? {} : NodeBlob;
|
228
|
-
global {
|
229
|
-
namespace NodeJS {
|
230
|
-
export { BufferEncoding };
|
231
|
-
}
|
232
|
-
// Buffer class
|
233
|
-
type BufferEncoding =
|
234
|
-
| "ascii"
|
235
|
-
| "utf8"
|
236
|
-
| "utf-8"
|
237
|
-
| "utf16le"
|
238
|
-
| "utf-16le"
|
239
|
-
| "ucs2"
|
240
|
-
| "ucs-2"
|
241
|
-
| "base64"
|
242
|
-
| "base64url"
|
243
|
-
| "latin1"
|
244
|
-
| "binary"
|
245
|
-
| "hex";
|
246
|
-
type WithImplicitCoercion<T> =
|
247
|
-
| T
|
248
|
-
| {
|
249
|
-
valueOf(): T;
|
250
|
-
};
|
251
|
-
/**
|
252
|
-
* Raw data is stored in instances of the Buffer class.
|
253
|
-
* A Buffer is similar to an array of integers but corresponds to a raw memory allocation outside the V8 heap. A Buffer cannot be resized.
|
254
|
-
* Valid string encodings: 'ascii'|'utf8'|'utf16le'|'ucs2'(alias of 'utf16le')|'base64'|'base64url'|'binary'(deprecated)|'hex'
|
255
|
-
*/
|
256
|
-
interface BufferConstructor {
|
257
|
-
/**
|
258
|
-
* Allocates a new buffer containing the given {str}.
|
259
|
-
*
|
260
|
-
* @param str String to store in buffer.
|
261
|
-
* @param encoding encoding to use, optional. Default is 'utf8'
|
262
|
-
* @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
|
263
|
-
*/
|
264
|
-
new(str: string, encoding?: BufferEncoding): Buffer;
|
265
|
-
/**
|
266
|
-
* Allocates a new buffer of {size} octets.
|
267
|
-
*
|
268
|
-
* @param size count of octets to allocate.
|
269
|
-
* @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
|
270
|
-
*/
|
271
|
-
new(size: number): Buffer;
|
272
|
-
/**
|
273
|
-
* Allocates a new buffer containing the given {array} of octets.
|
274
|
-
*
|
275
|
-
* @param array The octets to store.
|
276
|
-
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
277
|
-
*/
|
278
|
-
new(array: Uint8Array): Buffer;
|
279
|
-
/**
|
280
|
-
* Produces a Buffer backed by the same allocated memory as
|
281
|
-
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
282
|
-
*
|
283
|
-
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
284
|
-
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
285
|
-
*/
|
286
|
-
new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
|
287
|
-
/**
|
288
|
-
* Allocates a new buffer containing the given {array} of octets.
|
289
|
-
*
|
290
|
-
* @param array The octets to store.
|
291
|
-
* @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
|
292
|
-
*/
|
293
|
-
new(array: readonly any[]): Buffer;
|
294
|
-
/**
|
295
|
-
* Copies the passed {buffer} data onto a new {Buffer} instance.
|
296
|
-
*
|
297
|
-
* @param buffer The buffer to copy.
|
298
|
-
* @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
|
299
|
-
*/
|
300
|
-
new(buffer: Buffer): Buffer;
|
301
|
-
/**
|
302
|
-
* Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
|
303
|
-
* Array entries outside that range will be truncated to fit into it.
|
304
|
-
*
|
305
|
-
* ```js
|
306
|
-
* import { Buffer } from 'node:buffer';
|
307
|
-
*
|
308
|
-
* // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
|
309
|
-
* const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
|
310
|
-
* ```
|
311
|
-
*
|
312
|
-
* If `array` is an `Array`\-like object (that is, one with a `length` property of
|
313
|
-
* type `number`), it is treated as if it is an array, unless it is a `Buffer` or
|
314
|
-
* a `Uint8Array`. This means all other `TypedArray` variants get treated as an `Array`. To create a `Buffer` from the bytes backing a `TypedArray`, use `Buffer.copyBytesFrom()`.
|
315
|
-
*
|
316
|
-
* A `TypeError` will be thrown if `array` is not an `Array` or another type
|
317
|
-
* appropriate for `Buffer.from()` variants.
|
318
|
-
*
|
319
|
-
* `Buffer.from(array)` and `Buffer.from(string)` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
320
|
-
* @since v5.10.0
|
321
|
-
*/
|
322
|
-
from(
|
323
|
-
arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
|
324
|
-
byteOffset?: number,
|
325
|
-
length?: number,
|
326
|
-
): Buffer;
|
327
|
-
/**
|
328
|
-
* Creates a new Buffer using the passed {data}
|
329
|
-
* @param data data to create a new Buffer
|
330
|
-
*/
|
331
|
-
from(data: Uint8Array | readonly number[]): Buffer;
|
332
|
-
from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer;
|
333
|
-
/**
|
334
|
-
* Creates a new Buffer containing the given JavaScript string {str}.
|
335
|
-
* If provided, the {encoding} parameter identifies the character encoding.
|
336
|
-
* If not provided, {encoding} defaults to 'utf8'.
|
337
|
-
*/
|
338
|
-
from(
|
339
|
-
str:
|
340
|
-
| WithImplicitCoercion<string>
|
341
|
-
| {
|
342
|
-
[Symbol.toPrimitive](hint: "string"): string;
|
343
|
-
},
|
344
|
-
encoding?: BufferEncoding,
|
345
|
-
): Buffer;
|
346
|
-
/**
|
347
|
-
* Creates a new Buffer using the passed {data}
|
348
|
-
* @param values to create a new Buffer
|
349
|
-
*/
|
350
|
-
of(...items: number[]): Buffer;
|
351
|
-
/**
|
352
|
-
* Returns `true` if `obj` is a `Buffer`, `false` otherwise.
|
353
|
-
*
|
354
|
-
* ```js
|
355
|
-
* import { Buffer } from 'node:buffer';
|
356
|
-
*
|
357
|
-
* Buffer.isBuffer(Buffer.alloc(10)); // true
|
358
|
-
* Buffer.isBuffer(Buffer.from('foo')); // true
|
359
|
-
* Buffer.isBuffer('a string'); // false
|
360
|
-
* Buffer.isBuffer([]); // false
|
361
|
-
* Buffer.isBuffer(new Uint8Array(1024)); // false
|
362
|
-
* ```
|
363
|
-
* @since v0.1.101
|
364
|
-
*/
|
365
|
-
isBuffer(obj: any): obj is Buffer;
|
366
|
-
/**
|
367
|
-
* Returns `true` if `encoding` is the name of a supported character encoding,
|
368
|
-
* or `false` otherwise.
|
369
|
-
*
|
370
|
-
* ```js
|
371
|
-
* import { Buffer } from 'node:buffer';
|
372
|
-
*
|
373
|
-
* console.log(Buffer.isEncoding('utf8'));
|
374
|
-
* // Prints: true
|
375
|
-
*
|
376
|
-
* console.log(Buffer.isEncoding('hex'));
|
377
|
-
* // Prints: true
|
378
|
-
*
|
379
|
-
* console.log(Buffer.isEncoding('utf/8'));
|
380
|
-
* // Prints: false
|
381
|
-
*
|
382
|
-
* console.log(Buffer.isEncoding(''));
|
383
|
-
* // Prints: false
|
384
|
-
* ```
|
385
|
-
* @since v0.9.1
|
386
|
-
* @param encoding A character encoding name to check.
|
387
|
-
*/
|
388
|
-
isEncoding(encoding: string): encoding is BufferEncoding;
|
389
|
-
/**
|
390
|
-
* Returns the byte length of a string when encoded using `encoding`.
|
391
|
-
* This is not the same as [`String.prototype.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length), which does not account
|
392
|
-
* for the encoding that is used to convert the string into bytes.
|
393
|
-
*
|
394
|
-
* For `'base64'`, `'base64url'`, and `'hex'`, this function assumes valid input.
|
395
|
-
* For strings that contain non-base64/hex-encoded data (e.g. whitespace), the
|
396
|
-
* return value might be greater than the length of a `Buffer` created from the
|
397
|
-
* string.
|
398
|
-
*
|
399
|
-
* ```js
|
400
|
-
* import { Buffer } from 'node:buffer';
|
401
|
-
*
|
402
|
-
* const str = '\u00bd + \u00bc = \u00be';
|
403
|
-
*
|
404
|
-
* console.log(`${str}: ${str.length} characters, ` +
|
405
|
-
* `${Buffer.byteLength(str, 'utf8')} bytes`);
|
406
|
-
* // Prints: ½ + ¼ = ¾: 9 characters, 12 bytes
|
407
|
-
* ```
|
408
|
-
*
|
409
|
-
* When `string` is a
|
410
|
-
* `Buffer`/[`DataView`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView)/[`TypedArray`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/-
|
411
|
-
* Reference/Global_Objects/TypedArray)/[`ArrayBuffer`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer)/[`SharedArrayBuffer`](https://develop-
|
412
|
-
* er.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer), the byte length as reported by `.byteLength`is returned.
|
413
|
-
* @since v0.1.90
|
414
|
-
* @param string A value to calculate the length of.
|
415
|
-
* @param [encoding='utf8'] If `string` is a string, this is its encoding.
|
416
|
-
* @return The number of bytes contained within `string`.
|
417
|
-
*/
|
418
|
-
byteLength(
|
419
|
-
string: string | Buffer | NodeJS.ArrayBufferView | ArrayBuffer | SharedArrayBuffer,
|
420
|
-
encoding?: BufferEncoding,
|
421
|
-
): number;
|
422
|
-
/**
|
423
|
-
* Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
|
424
|
-
*
|
425
|
-
* If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
|
426
|
-
*
|
427
|
-
* If `totalLength` is not provided, it is calculated from the `Buffer` instances
|
428
|
-
* in `list` by adding their lengths.
|
429
|
-
*
|
430
|
-
* If `totalLength` is provided, it is coerced to an unsigned integer. If the
|
431
|
-
* combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
|
432
|
-
* truncated to `totalLength`.
|
433
|
-
*
|
434
|
-
* ```js
|
435
|
-
* import { Buffer } from 'node:buffer';
|
436
|
-
*
|
437
|
-
* // Create a single `Buffer` from a list of three `Buffer` instances.
|
438
|
-
*
|
439
|
-
* const buf1 = Buffer.alloc(10);
|
440
|
-
* const buf2 = Buffer.alloc(14);
|
441
|
-
* const buf3 = Buffer.alloc(18);
|
442
|
-
* const totalLength = buf1.length + buf2.length + buf3.length;
|
443
|
-
*
|
444
|
-
* console.log(totalLength);
|
445
|
-
* // Prints: 42
|
446
|
-
*
|
447
|
-
* const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
|
448
|
-
*
|
449
|
-
* console.log(bufA);
|
450
|
-
* // Prints: <Buffer 00 00 00 00 ...>
|
451
|
-
* console.log(bufA.length);
|
452
|
-
* // Prints: 42
|
453
|
-
* ```
|
454
|
-
*
|
455
|
-
* `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
|
456
|
-
* @since v0.7.11
|
457
|
-
* @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
|
458
|
-
* @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
|
459
|
-
*/
|
460
|
-
concat(list: readonly Uint8Array[], totalLength?: number): Buffer;
|
461
|
-
/**
|
462
|
-
* Copies the underlying memory of `view` into a new `Buffer`.
|
463
|
-
*
|
464
|
-
* ```js
|
465
|
-
* const u16 = new Uint16Array([0, 0xffff]);
|
466
|
-
* const buf = Buffer.copyBytesFrom(u16, 1, 1);
|
467
|
-
* u16[1] = 0;
|
468
|
-
* console.log(buf.length); // 2
|
469
|
-
* console.log(buf[0]); // 255
|
470
|
-
* console.log(buf[1]); // 255
|
471
|
-
* ```
|
472
|
-
* @since v19.8.0
|
473
|
-
* @param view The {TypedArray} to copy.
|
474
|
-
* @param [offset=0] The starting offset within `view`.
|
475
|
-
* @param [length=view.length - offset] The number of elements from `view` to copy.
|
476
|
-
*/
|
477
|
-
copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer;
|
478
|
-
/**
|
479
|
-
* Compares `buf1` to `buf2`, typically for the purpose of sorting arrays of `Buffer` instances. This is equivalent to calling `buf1.compare(buf2)`.
|
480
|
-
*
|
481
|
-
* ```js
|
482
|
-
* import { Buffer } from 'node:buffer';
|
483
|
-
*
|
484
|
-
* const buf1 = Buffer.from('1234');
|
485
|
-
* const buf2 = Buffer.from('0123');
|
486
|
-
* const arr = [buf1, buf2];
|
487
|
-
*
|
488
|
-
* console.log(arr.sort(Buffer.compare));
|
489
|
-
* // Prints: [ <Buffer 30 31 32 33>, <Buffer 31 32 33 34> ]
|
490
|
-
* // (This result is equal to: [buf2, buf1].)
|
491
|
-
* ```
|
492
|
-
* @since v0.11.13
|
493
|
-
* @return Either `-1`, `0`, or `1`, depending on the result of the comparison. See `compare` for details.
|
494
|
-
*/
|
495
|
-
compare(buf1: Uint8Array, buf2: Uint8Array): -1 | 0 | 1;
|
496
|
-
/**
|
497
|
-
* Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
|
498
|
-
*
|
499
|
-
* ```js
|
500
|
-
* import { Buffer } from 'node:buffer';
|
501
|
-
*
|
502
|
-
* const buf = Buffer.alloc(5);
|
503
|
-
*
|
504
|
-
* console.log(buf);
|
505
|
-
* // Prints: <Buffer 00 00 00 00 00>
|
506
|
-
* ```
|
507
|
-
*
|
508
|
-
* If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
509
|
-
*
|
510
|
-
* If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
|
511
|
-
*
|
512
|
-
* ```js
|
513
|
-
* import { Buffer } from 'node:buffer';
|
514
|
-
*
|
515
|
-
* const buf = Buffer.alloc(5, 'a');
|
516
|
-
*
|
517
|
-
* console.log(buf);
|
518
|
-
* // Prints: <Buffer 61 61 61 61 61>
|
519
|
-
* ```
|
520
|
-
*
|
521
|
-
* If both `fill` and `encoding` are specified, the allocated `Buffer` will be
|
522
|
-
* initialized by calling `buf.fill(fill, encoding)`.
|
523
|
-
*
|
524
|
-
* ```js
|
525
|
-
* import { Buffer } from 'node:buffer';
|
526
|
-
*
|
527
|
-
* const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
|
528
|
-
*
|
529
|
-
* console.log(buf);
|
530
|
-
* // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
|
531
|
-
* ```
|
532
|
-
*
|
533
|
-
* Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
|
534
|
-
* contents will never contain sensitive data from previous allocations, including
|
535
|
-
* data that might not have been allocated for `Buffer`s.
|
536
|
-
*
|
537
|
-
* A `TypeError` will be thrown if `size` is not a number.
|
538
|
-
* @since v5.10.0
|
539
|
-
* @param size The desired length of the new `Buffer`.
|
540
|
-
* @param [fill=0] A value to pre-fill the new `Buffer` with.
|
541
|
-
* @param [encoding='utf8'] If `fill` is a string, this is its encoding.
|
542
|
-
*/
|
543
|
-
alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
|
544
|
-
/**
|
545
|
-
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
|
546
|
-
*
|
547
|
-
* The underlying memory for `Buffer` instances created in this way is _not_
|
548
|
-
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `Buffer.alloc()` instead to initialize`Buffer` instances with zeroes.
|
549
|
-
*
|
550
|
-
* ```js
|
551
|
-
* import { Buffer } from 'node:buffer';
|
552
|
-
*
|
553
|
-
* const buf = Buffer.allocUnsafe(10);
|
554
|
-
*
|
555
|
-
* console.log(buf);
|
556
|
-
* // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
|
557
|
-
*
|
558
|
-
* buf.fill(0);
|
559
|
-
*
|
560
|
-
* console.log(buf);
|
561
|
-
* // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
|
562
|
-
* ```
|
563
|
-
*
|
564
|
-
* A `TypeError` will be thrown if `size` is not a number.
|
565
|
-
*
|
566
|
-
* The `Buffer` module pre-allocates an internal `Buffer` instance of
|
567
|
-
* size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
|
568
|
-
* and `Buffer.concat()` only when `size` is less than `Buffer.poolSize >>> 1` (floor of `Buffer.poolSize` divided by two).
|
569
|
-
*
|
570
|
-
* Use of this pre-allocated internal memory pool is a key difference between
|
571
|
-
* calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
|
572
|
-
* Specifically, `Buffer.alloc(size, fill)` will _never_ use the internal `Buffer`pool, while `Buffer.allocUnsafe(size).fill(fill)`_will_ use the internal`Buffer` pool if `size` is less
|
573
|
-
* than or equal to half `Buffer.poolSize`. The
|
574
|
-
* difference is subtle but can be important when an application requires the
|
575
|
-
* additional performance that `Buffer.allocUnsafe()` provides.
|
576
|
-
* @since v5.10.0
|
577
|
-
* @param size The desired length of the new `Buffer`.
|
578
|
-
*/
|
579
|
-
allocUnsafe(size: number): Buffer;
|
580
|
-
/**
|
581
|
-
* Allocates a new `Buffer` of `size` bytes. If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown. A zero-length `Buffer` is created if
|
582
|
-
* `size` is 0.
|
583
|
-
*
|
584
|
-
* The underlying memory for `Buffer` instances created in this way is _not_
|
585
|
-
* _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
|
586
|
-
* such `Buffer` instances with zeroes.
|
587
|
-
*
|
588
|
-
* When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
|
589
|
-
* allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
|
590
|
-
* allows applications to avoid the garbage collection overhead of creating many
|
591
|
-
* individually allocated `Buffer` instances. This approach improves both
|
592
|
-
* performance and memory usage by eliminating the need to track and clean up as
|
593
|
-
* many individual `ArrayBuffer` objects.
|
594
|
-
*
|
595
|
-
* However, in the case where a developer may need to retain a small chunk of
|
596
|
-
* memory from a pool for an indeterminate amount of time, it may be appropriate
|
597
|
-
* to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
|
598
|
-
* then copying out the relevant bits.
|
599
|
-
*
|
600
|
-
* ```js
|
601
|
-
* import { Buffer } from 'node:buffer';
|
602
|
-
*
|
603
|
-
* // Need to keep around a few small chunks of memory.
|
604
|
-
* const store = [];
|
605
|
-
*
|
606
|
-
* socket.on('readable', () => {
|
607
|
-
* let data;
|
608
|
-
* while (null !== (data = readable.read())) {
|
609
|
-
* // Allocate for retained data.
|
610
|
-
* const sb = Buffer.allocUnsafeSlow(10);
|
611
|
-
*
|
612
|
-
* // Copy the data into the new allocation.
|
613
|
-
* data.copy(sb, 0, 0, 10);
|
614
|
-
*
|
615
|
-
* store.push(sb);
|
616
|
-
* }
|
617
|
-
* });
|
618
|
-
* ```
|
619
|
-
*
|
620
|
-
* A `TypeError` will be thrown if `size` is not a number.
|
621
|
-
* @since v5.12.0
|
622
|
-
* @param size The desired length of the new `Buffer`.
|
623
|
-
*/
|
624
|
-
allocUnsafeSlow(size: number): Buffer;
|
625
|
-
/**
|
626
|
-
* This is the size (in bytes) of pre-allocated internal `Buffer` instances used
|
627
|
-
* for pooling. This value may be modified.
|
628
|
-
* @since v0.11.3
|
629
|
-
*/
|
630
|
-
poolSize: number;
|
631
|
-
}
|
632
|
-
interface Buffer extends Uint8Array {
|
633
|
-
/**
|
634
|
-
* Writes `string` to `buf` at `offset` according to the character encoding in`encoding`. The `length` parameter is the number of bytes to write. If `buf` did
|
635
|
-
* not contain enough space to fit the entire string, only part of `string` will be
|
636
|
-
* written. However, partially encoded characters will not be written.
|
637
|
-
*
|
638
|
-
* ```js
|
639
|
-
* import { Buffer } from 'node:buffer';
|
640
|
-
*
|
641
|
-
* const buf = Buffer.alloc(256);
|
642
|
-
*
|
643
|
-
* const len = buf.write('\u00bd + \u00bc = \u00be', 0);
|
644
|
-
*
|
645
|
-
* console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`);
|
646
|
-
* // Prints: 12 bytes: ½ + ¼ = ¾
|
647
|
-
*
|
648
|
-
* const buffer = Buffer.alloc(10);
|
649
|
-
*
|
650
|
-
* const length = buffer.write('abcd', 8);
|
651
|
-
*
|
652
|
-
* console.log(`${length} bytes: ${buffer.toString('utf8', 8, 10)}`);
|
653
|
-
* // Prints: 2 bytes : ab
|
654
|
-
* ```
|
655
|
-
* @since v0.1.90
|
656
|
-
* @param string String to write to `buf`.
|
657
|
-
* @param [offset=0] Number of bytes to skip before starting to write `string`.
|
658
|
-
* @param [length=buf.length - offset] Maximum number of bytes to write (written bytes will not exceed `buf.length - offset`).
|
659
|
-
* @param [encoding='utf8'] The character encoding of `string`.
|
660
|
-
* @return Number of bytes written.
|
661
|
-
*/
|
662
|
-
write(string: string, encoding?: BufferEncoding): number;
|
663
|
-
write(string: string, offset: number, encoding?: BufferEncoding): number;
|
664
|
-
write(string: string, offset: number, length: number, encoding?: BufferEncoding): number;
|
665
|
-
/**
|
666
|
-
* Decodes `buf` to a string according to the specified character encoding in`encoding`. `start` and `end` may be passed to decode only a subset of `buf`.
|
667
|
-
*
|
668
|
-
* If `encoding` is `'utf8'` and a byte sequence in the input is not valid UTF-8,
|
669
|
-
* then each invalid byte is replaced with the replacement character `U+FFFD`.
|
670
|
-
*
|
671
|
-
* The maximum length of a string instance (in UTF-16 code units) is available
|
672
|
-
* as {@link constants.MAX_STRING_LENGTH}.
|
673
|
-
*
|
674
|
-
* ```js
|
675
|
-
* import { Buffer } from 'node:buffer';
|
676
|
-
*
|
677
|
-
* const buf1 = Buffer.allocUnsafe(26);
|
678
|
-
*
|
679
|
-
* for (let i = 0; i < 26; i++) {
|
680
|
-
* // 97 is the decimal ASCII value for 'a'.
|
681
|
-
* buf1[i] = i + 97;
|
682
|
-
* }
|
683
|
-
*
|
684
|
-
* console.log(buf1.toString('utf8'));
|
685
|
-
* // Prints: abcdefghijklmnopqrstuvwxyz
|
686
|
-
* console.log(buf1.toString('utf8', 0, 5));
|
687
|
-
* // Prints: abcde
|
688
|
-
*
|
689
|
-
* const buf2 = Buffer.from('tést');
|
690
|
-
*
|
691
|
-
* console.log(buf2.toString('hex'));
|
692
|
-
* // Prints: 74c3a97374
|
693
|
-
* console.log(buf2.toString('utf8', 0, 3));
|
694
|
-
* // Prints: té
|
695
|
-
* console.log(buf2.toString(undefined, 0, 3));
|
696
|
-
* // Prints: té
|
697
|
-
* ```
|
698
|
-
* @since v0.1.90
|
699
|
-
* @param [encoding='utf8'] The character encoding to use.
|
700
|
-
* @param [start=0] The byte offset to start decoding at.
|
701
|
-
* @param [end=buf.length] The byte offset to stop decoding at (not inclusive).
|
702
|
-
*/
|
703
|
-
toString(encoding?: BufferEncoding, start?: number, end?: number): string;
|
704
|
-
/**
|
705
|
-
* Returns a JSON representation of `buf`. [`JSON.stringify()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) implicitly calls
|
706
|
-
* this function when stringifying a `Buffer` instance.
|
707
|
-
*
|
708
|
-
* `Buffer.from()` accepts objects in the format returned from this method.
|
709
|
-
* In particular, `Buffer.from(buf.toJSON())` works like `Buffer.from(buf)`.
|
710
|
-
*
|
711
|
-
* ```js
|
712
|
-
* import { Buffer } from 'node:buffer';
|
713
|
-
*
|
714
|
-
* const buf = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5]);
|
715
|
-
* const json = JSON.stringify(buf);
|
716
|
-
*
|
717
|
-
* console.log(json);
|
718
|
-
* // Prints: {"type":"Buffer","data":[1,2,3,4,5]}
|
719
|
-
*
|
720
|
-
* const copy = JSON.parse(json, (key, value) => {
|
721
|
-
* return value && value.type === 'Buffer' ?
|
722
|
-
* Buffer.from(value) :
|
723
|
-
* value;
|
724
|
-
* });
|
725
|
-
*
|
726
|
-
* console.log(copy);
|
727
|
-
* // Prints: <Buffer 01 02 03 04 05>
|
728
|
-
* ```
|
729
|
-
* @since v0.9.2
|
730
|
-
*/
|
731
|
-
toJSON(): {
|
732
|
-
type: "Buffer";
|
733
|
-
data: number[];
|
734
|
-
};
|
735
|
-
/**
|
736
|
-
* Returns `true` if both `buf` and `otherBuffer` have exactly the same bytes,`false` otherwise. Equivalent to `buf.compare(otherBuffer) === 0`.
|
737
|
-
*
|
738
|
-
* ```js
|
739
|
-
* import { Buffer } from 'node:buffer';
|
740
|
-
*
|
741
|
-
* const buf1 = Buffer.from('ABC');
|
742
|
-
* const buf2 = Buffer.from('414243', 'hex');
|
743
|
-
* const buf3 = Buffer.from('ABCD');
|
744
|
-
*
|
745
|
-
* console.log(buf1.equals(buf2));
|
746
|
-
* // Prints: true
|
747
|
-
* console.log(buf1.equals(buf3));
|
748
|
-
* // Prints: false
|
749
|
-
* ```
|
750
|
-
* @since v0.11.13
|
751
|
-
* @param otherBuffer A `Buffer` or {@link Uint8Array} with which to compare `buf`.
|
752
|
-
*/
|
753
|
-
equals(otherBuffer: Uint8Array): boolean;
|
754
|
-
/**
|
755
|
-
* Compares `buf` with `target` and returns a number indicating whether `buf`comes before, after, or is the same as `target` in sort order.
|
756
|
-
* Comparison is based on the actual sequence of bytes in each `Buffer`.
|
757
|
-
*
|
758
|
-
* * `0` is returned if `target` is the same as `buf`
|
759
|
-
* * `1` is returned if `target` should come _before_`buf` when sorted.
|
760
|
-
* * `-1` is returned if `target` should come _after_`buf` when sorted.
|
761
|
-
*
|
762
|
-
* ```js
|
763
|
-
* import { Buffer } from 'node:buffer';
|
764
|
-
*
|
765
|
-
* const buf1 = Buffer.from('ABC');
|
766
|
-
* const buf2 = Buffer.from('BCD');
|
767
|
-
* const buf3 = Buffer.from('ABCD');
|
768
|
-
*
|
769
|
-
* console.log(buf1.compare(buf1));
|
770
|
-
* // Prints: 0
|
771
|
-
* console.log(buf1.compare(buf2));
|
772
|
-
* // Prints: -1
|
773
|
-
* console.log(buf1.compare(buf3));
|
774
|
-
* // Prints: -1
|
775
|
-
* console.log(buf2.compare(buf1));
|
776
|
-
* // Prints: 1
|
777
|
-
* console.log(buf2.compare(buf3));
|
778
|
-
* // Prints: 1
|
779
|
-
* console.log([buf1, buf2, buf3].sort(Buffer.compare));
|
780
|
-
* // Prints: [ <Buffer 41 42 43>, <Buffer 41 42 43 44>, <Buffer 42 43 44> ]
|
781
|
-
* // (This result is equal to: [buf1, buf3, buf2].)
|
782
|
-
* ```
|
783
|
-
*
|
784
|
-
* The optional `targetStart`, `targetEnd`, `sourceStart`, and `sourceEnd` arguments can be used to limit the comparison to specific ranges within `target` and `buf` respectively.
|
785
|
-
*
|
786
|
-
* ```js
|
787
|
-
* import { Buffer } from 'node:buffer';
|
788
|
-
*
|
789
|
-
* const buf1 = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8, 9]);
|
790
|
-
* const buf2 = Buffer.from([5, 6, 7, 8, 9, 1, 2, 3, 4]);
|
791
|
-
*
|
792
|
-
* console.log(buf1.compare(buf2, 5, 9, 0, 4));
|
793
|
-
* // Prints: 0
|
794
|
-
* console.log(buf1.compare(buf2, 0, 6, 4));
|
795
|
-
* // Prints: -1
|
796
|
-
* console.log(buf1.compare(buf2, 5, 6, 5));
|
797
|
-
* // Prints: 1
|
798
|
-
* ```
|
799
|
-
*
|
800
|
-
* `ERR_OUT_OF_RANGE` is thrown if `targetStart < 0`, `sourceStart < 0`, `targetEnd > target.byteLength`, or `sourceEnd > source.byteLength`.
|
801
|
-
* @since v0.11.13
|
802
|
-
* @param target A `Buffer` or {@link Uint8Array} with which to compare `buf`.
|
803
|
-
* @param [targetStart=0] The offset within `target` at which to begin comparison.
|
804
|
-
* @param [targetEnd=target.length] The offset within `target` at which to end comparison (not inclusive).
|
805
|
-
* @param [sourceStart=0] The offset within `buf` at which to begin comparison.
|
806
|
-
* @param [sourceEnd=buf.length] The offset within `buf` at which to end comparison (not inclusive).
|
807
|
-
*/
|
808
|
-
compare(
|
809
|
-
target: Uint8Array,
|
810
|
-
targetStart?: number,
|
811
|
-
targetEnd?: number,
|
812
|
-
sourceStart?: number,
|
813
|
-
sourceEnd?: number,
|
814
|
-
): -1 | 0 | 1;
|
815
|
-
/**
|
816
|
-
* Copies data from a region of `buf` to a region in `target`, even if the `target`memory region overlaps with `buf`.
|
817
|
-
*
|
818
|
-
* [`TypedArray.prototype.set()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/set) performs the same operation, and is available
|
819
|
-
* for all TypedArrays, including Node.js `Buffer`s, although it takes
|
820
|
-
* different function arguments.
|
821
|
-
*
|
822
|
-
* ```js
|
823
|
-
* import { Buffer } from 'node:buffer';
|
824
|
-
*
|
825
|
-
* // Create two `Buffer` instances.
|
826
|
-
* const buf1 = Buffer.allocUnsafe(26);
|
827
|
-
* const buf2 = Buffer.allocUnsafe(26).fill('!');
|
828
|
-
*
|
829
|
-
* for (let i = 0; i < 26; i++) {
|
830
|
-
* // 97 is the decimal ASCII value for 'a'.
|
831
|
-
* buf1[i] = i + 97;
|
832
|
-
* }
|
833
|
-
*
|
834
|
-
* // Copy `buf1` bytes 16 through 19 into `buf2` starting at byte 8 of `buf2`.
|
835
|
-
* buf1.copy(buf2, 8, 16, 20);
|
836
|
-
* // This is equivalent to:
|
837
|
-
* // buf2.set(buf1.subarray(16, 20), 8);
|
838
|
-
*
|
839
|
-
* console.log(buf2.toString('ascii', 0, 25));
|
840
|
-
* // Prints: !!!!!!!!qrst!!!!!!!!!!!!!
|
841
|
-
* ```
|
842
|
-
*
|
843
|
-
* ```js
|
844
|
-
* import { Buffer } from 'node:buffer';
|
845
|
-
*
|
846
|
-
* // Create a `Buffer` and copy data from one region to an overlapping region
|
847
|
-
* // within the same `Buffer`.
|
848
|
-
*
|
849
|
-
* const buf = Buffer.allocUnsafe(26);
|
850
|
-
*
|
851
|
-
* for (let i = 0; i < 26; i++) {
|
852
|
-
* // 97 is the decimal ASCII value for 'a'.
|
853
|
-
* buf[i] = i + 97;
|
854
|
-
* }
|
855
|
-
*
|
856
|
-
* buf.copy(buf, 0, 4, 10);
|
857
|
-
*
|
858
|
-
* console.log(buf.toString());
|
859
|
-
* // Prints: efghijghijklmnopqrstuvwxyz
|
860
|
-
* ```
|
861
|
-
* @since v0.1.90
|
862
|
-
* @param target A `Buffer` or {@link Uint8Array} to copy into.
|
863
|
-
* @param [targetStart=0] The offset within `target` at which to begin writing.
|
864
|
-
* @param [sourceStart=0] The offset within `buf` from which to begin copying.
|
865
|
-
* @param [sourceEnd=buf.length] The offset within `buf` at which to stop copying (not inclusive).
|
866
|
-
* @return The number of bytes copied.
|
867
|
-
*/
|
868
|
-
copy(target: Uint8Array, targetStart?: number, sourceStart?: number, sourceEnd?: number): number;
|
869
|
-
/**
|
870
|
-
* Returns a new `Buffer` that references the same memory as the original, but
|
871
|
-
* offset and cropped by the `start` and `end` indices.
|
872
|
-
*
|
873
|
-
* This method is not compatible with the `Uint8Array.prototype.slice()`,
|
874
|
-
* which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
|
875
|
-
*
|
876
|
-
* ```js
|
877
|
-
* import { Buffer } from 'node:buffer';
|
878
|
-
*
|
879
|
-
* const buf = Buffer.from('buffer');
|
880
|
-
*
|
881
|
-
* const copiedBuf = Uint8Array.prototype.slice.call(buf);
|
882
|
-
* copiedBuf[0]++;
|
883
|
-
* console.log(copiedBuf.toString());
|
884
|
-
* // Prints: cuffer
|
885
|
-
*
|
886
|
-
* console.log(buf.toString());
|
887
|
-
* // Prints: buffer
|
888
|
-
*
|
889
|
-
* // With buf.slice(), the original buffer is modified.
|
890
|
-
* const notReallyCopiedBuf = buf.slice();
|
891
|
-
* notReallyCopiedBuf[0]++;
|
892
|
-
* console.log(notReallyCopiedBuf.toString());
|
893
|
-
* // Prints: cuffer
|
894
|
-
* console.log(buf.toString());
|
895
|
-
* // Also prints: cuffer (!)
|
896
|
-
* ```
|
897
|
-
* @since v0.3.0
|
898
|
-
* @deprecated Use `subarray` instead.
|
899
|
-
* @param [start=0] Where the new `Buffer` will start.
|
900
|
-
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
901
|
-
*/
|
902
|
-
slice(start?: number, end?: number): Buffer;
|
903
|
-
/**
|
904
|
-
* Returns a new `Buffer` that references the same memory as the original, but
|
905
|
-
* offset and cropped by the `start` and `end` indices.
|
906
|
-
*
|
907
|
-
* Specifying `end` greater than `buf.length` will return the same result as
|
908
|
-
* that of `end` equal to `buf.length`.
|
909
|
-
*
|
910
|
-
* This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
|
911
|
-
*
|
912
|
-
* Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
|
913
|
-
*
|
914
|
-
* ```js
|
915
|
-
* import { Buffer } from 'node:buffer';
|
916
|
-
*
|
917
|
-
* // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
|
918
|
-
* // from the original `Buffer`.
|
919
|
-
*
|
920
|
-
* const buf1 = Buffer.allocUnsafe(26);
|
921
|
-
*
|
922
|
-
* for (let i = 0; i < 26; i++) {
|
923
|
-
* // 97 is the decimal ASCII value for 'a'.
|
924
|
-
* buf1[i] = i + 97;
|
925
|
-
* }
|
926
|
-
*
|
927
|
-
* const buf2 = buf1.subarray(0, 3);
|
928
|
-
*
|
929
|
-
* console.log(buf2.toString('ascii', 0, buf2.length));
|
930
|
-
* // Prints: abc
|
931
|
-
*
|
932
|
-
* buf1[0] = 33;
|
933
|
-
*
|
934
|
-
* console.log(buf2.toString('ascii', 0, buf2.length));
|
935
|
-
* // Prints: !bc
|
936
|
-
* ```
|
937
|
-
*
|
938
|
-
* Specifying negative indexes causes the slice to be generated relative to the
|
939
|
-
* end of `buf` rather than the beginning.
|
940
|
-
*
|
941
|
-
* ```js
|
942
|
-
* import { Buffer } from 'node:buffer';
|
943
|
-
*
|
944
|
-
* const buf = Buffer.from('buffer');
|
945
|
-
*
|
946
|
-
* console.log(buf.subarray(-6, -1).toString());
|
947
|
-
* // Prints: buffe
|
948
|
-
* // (Equivalent to buf.subarray(0, 5).)
|
949
|
-
*
|
950
|
-
* console.log(buf.subarray(-6, -2).toString());
|
951
|
-
* // Prints: buff
|
952
|
-
* // (Equivalent to buf.subarray(0, 4).)
|
953
|
-
*
|
954
|
-
* console.log(buf.subarray(-5, -2).toString());
|
955
|
-
* // Prints: uff
|
956
|
-
* // (Equivalent to buf.subarray(1, 4).)
|
957
|
-
* ```
|
958
|
-
* @since v3.0.0
|
959
|
-
* @param [start=0] Where the new `Buffer` will start.
|
960
|
-
* @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
|
961
|
-
*/
|
962
|
-
subarray(start?: number, end?: number): Buffer;
|
963
|
-
/**
|
964
|
-
* Writes `value` to `buf` at the specified `offset` as big-endian.
|
965
|
-
*
|
966
|
-
* `value` is interpreted and written as a two's complement signed integer.
|
967
|
-
*
|
968
|
-
* ```js
|
969
|
-
* import { Buffer } from 'node:buffer';
|
970
|
-
*
|
971
|
-
* const buf = Buffer.allocUnsafe(8);
|
972
|
-
*
|
973
|
-
* buf.writeBigInt64BE(0x0102030405060708n, 0);
|
974
|
-
*
|
975
|
-
* console.log(buf);
|
976
|
-
* // Prints: <Buffer 01 02 03 04 05 06 07 08>
|
977
|
-
* ```
|
978
|
-
* @since v12.0.0, v10.20.0
|
979
|
-
* @param value Number to be written to `buf`.
|
980
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
|
981
|
-
* @return `offset` plus the number of bytes written.
|
982
|
-
*/
|
983
|
-
writeBigInt64BE(value: bigint, offset?: number): number;
|
984
|
-
/**
|
985
|
-
* Writes `value` to `buf` at the specified `offset` as little-endian.
|
986
|
-
*
|
987
|
-
* `value` is interpreted and written as a two's complement signed integer.
|
988
|
-
*
|
989
|
-
* ```js
|
990
|
-
* import { Buffer } from 'node:buffer';
|
991
|
-
*
|
992
|
-
* const buf = Buffer.allocUnsafe(8);
|
993
|
-
*
|
994
|
-
* buf.writeBigInt64LE(0x0102030405060708n, 0);
|
995
|
-
*
|
996
|
-
* console.log(buf);
|
997
|
-
* // Prints: <Buffer 08 07 06 05 04 03 02 01>
|
998
|
-
* ```
|
999
|
-
* @since v12.0.0, v10.20.0
|
1000
|
-
* @param value Number to be written to `buf`.
|
1001
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
|
1002
|
-
* @return `offset` plus the number of bytes written.
|
1003
|
-
*/
|
1004
|
-
writeBigInt64LE(value: bigint, offset?: number): number;
|
1005
|
-
/**
|
1006
|
-
* Writes `value` to `buf` at the specified `offset` as big-endian.
|
1007
|
-
*
|
1008
|
-
* This function is also available under the `writeBigUint64BE` alias.
|
1009
|
-
*
|
1010
|
-
* ```js
|
1011
|
-
* import { Buffer } from 'node:buffer';
|
1012
|
-
*
|
1013
|
-
* const buf = Buffer.allocUnsafe(8);
|
1014
|
-
*
|
1015
|
-
* buf.writeBigUInt64BE(0xdecafafecacefaden, 0);
|
1016
|
-
*
|
1017
|
-
* console.log(buf);
|
1018
|
-
* // Prints: <Buffer de ca fa fe ca ce fa de>
|
1019
|
-
* ```
|
1020
|
-
* @since v12.0.0, v10.20.0
|
1021
|
-
* @param value Number to be written to `buf`.
|
1022
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
|
1023
|
-
* @return `offset` plus the number of bytes written.
|
1024
|
-
*/
|
1025
|
-
writeBigUInt64BE(value: bigint, offset?: number): number;
|
1026
|
-
/**
|
1027
|
-
* @alias Buffer.writeBigUInt64BE
|
1028
|
-
* @since v14.10.0, v12.19.0
|
1029
|
-
*/
|
1030
|
-
writeBigUint64BE(value: bigint, offset?: number): number;
|
1031
|
-
/**
|
1032
|
-
* Writes `value` to `buf` at the specified `offset` as little-endian
|
1033
|
-
*
|
1034
|
-
* ```js
|
1035
|
-
* import { Buffer } from 'node:buffer';
|
1036
|
-
*
|
1037
|
-
* const buf = Buffer.allocUnsafe(8);
|
1038
|
-
*
|
1039
|
-
* buf.writeBigUInt64LE(0xdecafafecacefaden, 0);
|
1040
|
-
*
|
1041
|
-
* console.log(buf);
|
1042
|
-
* // Prints: <Buffer de fa ce ca fe fa ca de>
|
1043
|
-
* ```
|
1044
|
-
*
|
1045
|
-
* This function is also available under the `writeBigUint64LE` alias.
|
1046
|
-
* @since v12.0.0, v10.20.0
|
1047
|
-
* @param value Number to be written to `buf`.
|
1048
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy: `0 <= offset <= buf.length - 8`.
|
1049
|
-
* @return `offset` plus the number of bytes written.
|
1050
|
-
*/
|
1051
|
-
writeBigUInt64LE(value: bigint, offset?: number): number;
|
1052
|
-
/**
|
1053
|
-
* @alias Buffer.writeBigUInt64LE
|
1054
|
-
* @since v14.10.0, v12.19.0
|
1055
|
-
*/
|
1056
|
-
writeBigUint64LE(value: bigint, offset?: number): number;
|
1057
|
-
/**
|
1058
|
-
* Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
|
1059
|
-
* when `value` is anything other than an unsigned integer.
|
1060
|
-
*
|
1061
|
-
* This function is also available under the `writeUintLE` alias.
|
1062
|
-
*
|
1063
|
-
* ```js
|
1064
|
-
* import { Buffer } from 'node:buffer';
|
1065
|
-
*
|
1066
|
-
* const buf = Buffer.allocUnsafe(6);
|
1067
|
-
*
|
1068
|
-
* buf.writeUIntLE(0x1234567890ab, 0, 6);
|
1069
|
-
*
|
1070
|
-
* console.log(buf);
|
1071
|
-
* // Prints: <Buffer ab 90 78 56 34 12>
|
1072
|
-
* ```
|
1073
|
-
* @since v0.5.5
|
1074
|
-
* @param value Number to be written to `buf`.
|
1075
|
-
* @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
1076
|
-
* @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
|
1077
|
-
* @return `offset` plus the number of bytes written.
|
1078
|
-
*/
|
1079
|
-
writeUIntLE(value: number, offset: number, byteLength: number): number;
|
1080
|
-
/**
|
1081
|
-
* @alias Buffer.writeUIntLE
|
1082
|
-
* @since v14.9.0, v12.19.0
|
1083
|
-
*/
|
1084
|
-
writeUintLE(value: number, offset: number, byteLength: number): number;
|
1085
|
-
/**
|
1086
|
-
* Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined
|
1087
|
-
* when `value` is anything other than an unsigned integer.
|
1088
|
-
*
|
1089
|
-
* This function is also available under the `writeUintBE` alias.
|
1090
|
-
*
|
1091
|
-
* ```js
|
1092
|
-
* import { Buffer } from 'node:buffer';
|
1093
|
-
*
|
1094
|
-
* const buf = Buffer.allocUnsafe(6);
|
1095
|
-
*
|
1096
|
-
* buf.writeUIntBE(0x1234567890ab, 0, 6);
|
1097
|
-
*
|
1098
|
-
* console.log(buf);
|
1099
|
-
* // Prints: <Buffer 12 34 56 78 90 ab>
|
1100
|
-
* ```
|
1101
|
-
* @since v0.5.5
|
1102
|
-
* @param value Number to be written to `buf`.
|
1103
|
-
* @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
1104
|
-
* @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
|
1105
|
-
* @return `offset` plus the number of bytes written.
|
1106
|
-
*/
|
1107
|
-
writeUIntBE(value: number, offset: number, byteLength: number): number;
|
1108
|
-
/**
|
1109
|
-
* @alias Buffer.writeUIntBE
|
1110
|
-
* @since v14.9.0, v12.19.0
|
1111
|
-
*/
|
1112
|
-
writeUintBE(value: number, offset: number, byteLength: number): number;
|
1113
|
-
/**
|
1114
|
-
* Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as little-endian. Supports up to 48 bits of accuracy. Behavior is undefined
|
1115
|
-
* when `value` is anything other than a signed integer.
|
1116
|
-
*
|
1117
|
-
* ```js
|
1118
|
-
* import { Buffer } from 'node:buffer';
|
1119
|
-
*
|
1120
|
-
* const buf = Buffer.allocUnsafe(6);
|
1121
|
-
*
|
1122
|
-
* buf.writeIntLE(0x1234567890ab, 0, 6);
|
1123
|
-
*
|
1124
|
-
* console.log(buf);
|
1125
|
-
* // Prints: <Buffer ab 90 78 56 34 12>
|
1126
|
-
* ```
|
1127
|
-
* @since v0.11.15
|
1128
|
-
* @param value Number to be written to `buf`.
|
1129
|
-
* @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
1130
|
-
* @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
|
1131
|
-
* @return `offset` plus the number of bytes written.
|
1132
|
-
*/
|
1133
|
-
writeIntLE(value: number, offset: number, byteLength: number): number;
|
1134
|
-
/**
|
1135
|
-
* Writes `byteLength` bytes of `value` to `buf` at the specified `offset`as big-endian. Supports up to 48 bits of accuracy. Behavior is undefined when`value` is anything other than a
|
1136
|
-
* signed integer.
|
1137
|
-
*
|
1138
|
-
* ```js
|
1139
|
-
* import { Buffer } from 'node:buffer';
|
1140
|
-
*
|
1141
|
-
* const buf = Buffer.allocUnsafe(6);
|
1142
|
-
*
|
1143
|
-
* buf.writeIntBE(0x1234567890ab, 0, 6);
|
1144
|
-
*
|
1145
|
-
* console.log(buf);
|
1146
|
-
* // Prints: <Buffer 12 34 56 78 90 ab>
|
1147
|
-
* ```
|
1148
|
-
* @since v0.11.15
|
1149
|
-
* @param value Number to be written to `buf`.
|
1150
|
-
* @param offset Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
1151
|
-
* @param byteLength Number of bytes to write. Must satisfy `0 < byteLength <= 6`.
|
1152
|
-
* @return `offset` plus the number of bytes written.
|
1153
|
-
*/
|
1154
|
-
writeIntBE(value: number, offset: number, byteLength: number): number;
|
1155
|
-
/**
|
1156
|
-
* Reads an unsigned, big-endian 64-bit integer from `buf` at the specified`offset`.
|
1157
|
-
*
|
1158
|
-
* This function is also available under the `readBigUint64BE` alias.
|
1159
|
-
*
|
1160
|
-
* ```js
|
1161
|
-
* import { Buffer } from 'node:buffer';
|
1162
|
-
*
|
1163
|
-
* const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
|
1164
|
-
*
|
1165
|
-
* console.log(buf.readBigUInt64BE(0));
|
1166
|
-
* // Prints: 4294967295n
|
1167
|
-
* ```
|
1168
|
-
* @since v12.0.0, v10.20.0
|
1169
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
|
1170
|
-
*/
|
1171
|
-
readBigUInt64BE(offset?: number): bigint;
|
1172
|
-
/**
|
1173
|
-
* @alias Buffer.readBigUInt64BE
|
1174
|
-
* @since v14.10.0, v12.19.0
|
1175
|
-
*/
|
1176
|
-
readBigUint64BE(offset?: number): bigint;
|
1177
|
-
/**
|
1178
|
-
* Reads an unsigned, little-endian 64-bit integer from `buf` at the specified`offset`.
|
1179
|
-
*
|
1180
|
-
* This function is also available under the `readBigUint64LE` alias.
|
1181
|
-
*
|
1182
|
-
* ```js
|
1183
|
-
* import { Buffer } from 'node:buffer';
|
1184
|
-
*
|
1185
|
-
* const buf = Buffer.from([0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
|
1186
|
-
*
|
1187
|
-
* console.log(buf.readBigUInt64LE(0));
|
1188
|
-
* // Prints: 18446744069414584320n
|
1189
|
-
* ```
|
1190
|
-
* @since v12.0.0, v10.20.0
|
1191
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
|
1192
|
-
*/
|
1193
|
-
readBigUInt64LE(offset?: number): bigint;
|
1194
|
-
/**
|
1195
|
-
* @alias Buffer.readBigUInt64LE
|
1196
|
-
* @since v14.10.0, v12.19.0
|
1197
|
-
*/
|
1198
|
-
readBigUint64LE(offset?: number): bigint;
|
1199
|
-
/**
|
1200
|
-
* Reads a signed, big-endian 64-bit integer from `buf` at the specified `offset`.
|
1201
|
-
*
|
1202
|
-
* Integers read from a `Buffer` are interpreted as two's complement signed
|
1203
|
-
* values.
|
1204
|
-
* @since v12.0.0, v10.20.0
|
1205
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
|
1206
|
-
*/
|
1207
|
-
readBigInt64BE(offset?: number): bigint;
|
1208
|
-
/**
|
1209
|
-
* Reads a signed, little-endian 64-bit integer from `buf` at the specified`offset`.
|
1210
|
-
*
|
1211
|
-
* Integers read from a `Buffer` are interpreted as two's complement signed
|
1212
|
-
* values.
|
1213
|
-
* @since v12.0.0, v10.20.0
|
1214
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy: `0 <= offset <= buf.length - 8`.
|
1215
|
-
*/
|
1216
|
-
readBigInt64LE(offset?: number): bigint;
|
1217
|
-
/**
|
1218
|
-
* Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned, little-endian integer supporting
|
1219
|
-
* up to 48 bits of accuracy.
|
1220
|
-
*
|
1221
|
-
* This function is also available under the `readUintLE` alias.
|
1222
|
-
*
|
1223
|
-
* ```js
|
1224
|
-
* import { Buffer } from 'node:buffer';
|
1225
|
-
*
|
1226
|
-
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
1227
|
-
*
|
1228
|
-
* console.log(buf.readUIntLE(0, 6).toString(16));
|
1229
|
-
* // Prints: ab9078563412
|
1230
|
-
* ```
|
1231
|
-
* @since v0.11.15
|
1232
|
-
* @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
1233
|
-
* @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
|
1234
|
-
*/
|
1235
|
-
readUIntLE(offset: number, byteLength: number): number;
|
1236
|
-
/**
|
1237
|
-
* @alias Buffer.readUIntLE
|
1238
|
-
* @since v14.9.0, v12.19.0
|
1239
|
-
*/
|
1240
|
-
readUintLE(offset: number, byteLength: number): number;
|
1241
|
-
/**
|
1242
|
-
* Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as an unsigned big-endian integer supporting
|
1243
|
-
* up to 48 bits of accuracy.
|
1244
|
-
*
|
1245
|
-
* This function is also available under the `readUintBE` alias.
|
1246
|
-
*
|
1247
|
-
* ```js
|
1248
|
-
* import { Buffer } from 'node:buffer';
|
1249
|
-
*
|
1250
|
-
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
1251
|
-
*
|
1252
|
-
* console.log(buf.readUIntBE(0, 6).toString(16));
|
1253
|
-
* // Prints: 1234567890ab
|
1254
|
-
* console.log(buf.readUIntBE(1, 6).toString(16));
|
1255
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1256
|
-
* ```
|
1257
|
-
* @since v0.11.15
|
1258
|
-
* @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
1259
|
-
* @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
|
1260
|
-
*/
|
1261
|
-
readUIntBE(offset: number, byteLength: number): number;
|
1262
|
-
/**
|
1263
|
-
* @alias Buffer.readUIntBE
|
1264
|
-
* @since v14.9.0, v12.19.0
|
1265
|
-
*/
|
1266
|
-
readUintBE(offset: number, byteLength: number): number;
|
1267
|
-
/**
|
1268
|
-
* Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a little-endian, two's complement signed value
|
1269
|
-
* supporting up to 48 bits of accuracy.
|
1270
|
-
*
|
1271
|
-
* ```js
|
1272
|
-
* import { Buffer } from 'node:buffer';
|
1273
|
-
*
|
1274
|
-
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
1275
|
-
*
|
1276
|
-
* console.log(buf.readIntLE(0, 6).toString(16));
|
1277
|
-
* // Prints: -546f87a9cbee
|
1278
|
-
* ```
|
1279
|
-
* @since v0.11.15
|
1280
|
-
* @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
1281
|
-
* @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
|
1282
|
-
*/
|
1283
|
-
readIntLE(offset: number, byteLength: number): number;
|
1284
|
-
/**
|
1285
|
-
* Reads `byteLength` number of bytes from `buf` at the specified `offset` and interprets the result as a big-endian, two's complement signed value
|
1286
|
-
* supporting up to 48 bits of accuracy.
|
1287
|
-
*
|
1288
|
-
* ```js
|
1289
|
-
* import { Buffer } from 'node:buffer';
|
1290
|
-
*
|
1291
|
-
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]);
|
1292
|
-
*
|
1293
|
-
* console.log(buf.readIntBE(0, 6).toString(16));
|
1294
|
-
* // Prints: 1234567890ab
|
1295
|
-
* console.log(buf.readIntBE(1, 6).toString(16));
|
1296
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1297
|
-
* console.log(buf.readIntBE(1, 0).toString(16));
|
1298
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1299
|
-
* ```
|
1300
|
-
* @since v0.11.15
|
1301
|
-
* @param offset Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - byteLength`.
|
1302
|
-
* @param byteLength Number of bytes to read. Must satisfy `0 < byteLength <= 6`.
|
1303
|
-
*/
|
1304
|
-
readIntBE(offset: number, byteLength: number): number;
|
1305
|
-
/**
|
1306
|
-
* Reads an unsigned 8-bit integer from `buf` at the specified `offset`.
|
1307
|
-
*
|
1308
|
-
* This function is also available under the `readUint8` alias.
|
1309
|
-
*
|
1310
|
-
* ```js
|
1311
|
-
* import { Buffer } from 'node:buffer';
|
1312
|
-
*
|
1313
|
-
* const buf = Buffer.from([1, -2]);
|
1314
|
-
*
|
1315
|
-
* console.log(buf.readUInt8(0));
|
1316
|
-
* // Prints: 1
|
1317
|
-
* console.log(buf.readUInt8(1));
|
1318
|
-
* // Prints: 254
|
1319
|
-
* console.log(buf.readUInt8(2));
|
1320
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1321
|
-
* ```
|
1322
|
-
* @since v0.5.0
|
1323
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
|
1324
|
-
*/
|
1325
|
-
readUInt8(offset?: number): number;
|
1326
|
-
/**
|
1327
|
-
* @alias Buffer.readUInt8
|
1328
|
-
* @since v14.9.0, v12.19.0
|
1329
|
-
*/
|
1330
|
-
readUint8(offset?: number): number;
|
1331
|
-
/**
|
1332
|
-
* Reads an unsigned, little-endian 16-bit integer from `buf` at the specified `offset`.
|
1333
|
-
*
|
1334
|
-
* This function is also available under the `readUint16LE` alias.
|
1335
|
-
*
|
1336
|
-
* ```js
|
1337
|
-
* import { Buffer } from 'node:buffer';
|
1338
|
-
*
|
1339
|
-
* const buf = Buffer.from([0x12, 0x34, 0x56]);
|
1340
|
-
*
|
1341
|
-
* console.log(buf.readUInt16LE(0).toString(16));
|
1342
|
-
* // Prints: 3412
|
1343
|
-
* console.log(buf.readUInt16LE(1).toString(16));
|
1344
|
-
* // Prints: 5634
|
1345
|
-
* console.log(buf.readUInt16LE(2).toString(16));
|
1346
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1347
|
-
* ```
|
1348
|
-
* @since v0.5.5
|
1349
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
|
1350
|
-
*/
|
1351
|
-
readUInt16LE(offset?: number): number;
|
1352
|
-
/**
|
1353
|
-
* @alias Buffer.readUInt16LE
|
1354
|
-
* @since v14.9.0, v12.19.0
|
1355
|
-
*/
|
1356
|
-
readUint16LE(offset?: number): number;
|
1357
|
-
/**
|
1358
|
-
* Reads an unsigned, big-endian 16-bit integer from `buf` at the specified`offset`.
|
1359
|
-
*
|
1360
|
-
* This function is also available under the `readUint16BE` alias.
|
1361
|
-
*
|
1362
|
-
* ```js
|
1363
|
-
* import { Buffer } from 'node:buffer';
|
1364
|
-
*
|
1365
|
-
* const buf = Buffer.from([0x12, 0x34, 0x56]);
|
1366
|
-
*
|
1367
|
-
* console.log(buf.readUInt16BE(0).toString(16));
|
1368
|
-
* // Prints: 1234
|
1369
|
-
* console.log(buf.readUInt16BE(1).toString(16));
|
1370
|
-
* // Prints: 3456
|
1371
|
-
* ```
|
1372
|
-
* @since v0.5.5
|
1373
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
|
1374
|
-
*/
|
1375
|
-
readUInt16BE(offset?: number): number;
|
1376
|
-
/**
|
1377
|
-
* @alias Buffer.readUInt16BE
|
1378
|
-
* @since v14.9.0, v12.19.0
|
1379
|
-
*/
|
1380
|
-
readUint16BE(offset?: number): number;
|
1381
|
-
/**
|
1382
|
-
* Reads an unsigned, little-endian 32-bit integer from `buf` at the specified`offset`.
|
1383
|
-
*
|
1384
|
-
* This function is also available under the `readUint32LE` alias.
|
1385
|
-
*
|
1386
|
-
* ```js
|
1387
|
-
* import { Buffer } from 'node:buffer';
|
1388
|
-
*
|
1389
|
-
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
|
1390
|
-
*
|
1391
|
-
* console.log(buf.readUInt32LE(0).toString(16));
|
1392
|
-
* // Prints: 78563412
|
1393
|
-
* console.log(buf.readUInt32LE(1).toString(16));
|
1394
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1395
|
-
* ```
|
1396
|
-
* @since v0.5.5
|
1397
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
1398
|
-
*/
|
1399
|
-
readUInt32LE(offset?: number): number;
|
1400
|
-
/**
|
1401
|
-
* @alias Buffer.readUInt32LE
|
1402
|
-
* @since v14.9.0, v12.19.0
|
1403
|
-
*/
|
1404
|
-
readUint32LE(offset?: number): number;
|
1405
|
-
/**
|
1406
|
-
* Reads an unsigned, big-endian 32-bit integer from `buf` at the specified`offset`.
|
1407
|
-
*
|
1408
|
-
* This function is also available under the `readUint32BE` alias.
|
1409
|
-
*
|
1410
|
-
* ```js
|
1411
|
-
* import { Buffer } from 'node:buffer';
|
1412
|
-
*
|
1413
|
-
* const buf = Buffer.from([0x12, 0x34, 0x56, 0x78]);
|
1414
|
-
*
|
1415
|
-
* console.log(buf.readUInt32BE(0).toString(16));
|
1416
|
-
* // Prints: 12345678
|
1417
|
-
* ```
|
1418
|
-
* @since v0.5.5
|
1419
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
1420
|
-
*/
|
1421
|
-
readUInt32BE(offset?: number): number;
|
1422
|
-
/**
|
1423
|
-
* @alias Buffer.readUInt32BE
|
1424
|
-
* @since v14.9.0, v12.19.0
|
1425
|
-
*/
|
1426
|
-
readUint32BE(offset?: number): number;
|
1427
|
-
/**
|
1428
|
-
* Reads a signed 8-bit integer from `buf` at the specified `offset`.
|
1429
|
-
*
|
1430
|
-
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
1431
|
-
*
|
1432
|
-
* ```js
|
1433
|
-
* import { Buffer } from 'node:buffer';
|
1434
|
-
*
|
1435
|
-
* const buf = Buffer.from([-1, 5]);
|
1436
|
-
*
|
1437
|
-
* console.log(buf.readInt8(0));
|
1438
|
-
* // Prints: -1
|
1439
|
-
* console.log(buf.readInt8(1));
|
1440
|
-
* // Prints: 5
|
1441
|
-
* console.log(buf.readInt8(2));
|
1442
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1443
|
-
* ```
|
1444
|
-
* @since v0.5.0
|
1445
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 1`.
|
1446
|
-
*/
|
1447
|
-
readInt8(offset?: number): number;
|
1448
|
-
/**
|
1449
|
-
* Reads a signed, little-endian 16-bit integer from `buf` at the specified`offset`.
|
1450
|
-
*
|
1451
|
-
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
1452
|
-
*
|
1453
|
-
* ```js
|
1454
|
-
* import { Buffer } from 'node:buffer';
|
1455
|
-
*
|
1456
|
-
* const buf = Buffer.from([0, 5]);
|
1457
|
-
*
|
1458
|
-
* console.log(buf.readInt16LE(0));
|
1459
|
-
* // Prints: 1280
|
1460
|
-
* console.log(buf.readInt16LE(1));
|
1461
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1462
|
-
* ```
|
1463
|
-
* @since v0.5.5
|
1464
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
|
1465
|
-
*/
|
1466
|
-
readInt16LE(offset?: number): number;
|
1467
|
-
/**
|
1468
|
-
* Reads a signed, big-endian 16-bit integer from `buf` at the specified `offset`.
|
1469
|
-
*
|
1470
|
-
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
1471
|
-
*
|
1472
|
-
* ```js
|
1473
|
-
* import { Buffer } from 'node:buffer';
|
1474
|
-
*
|
1475
|
-
* const buf = Buffer.from([0, 5]);
|
1476
|
-
*
|
1477
|
-
* console.log(buf.readInt16BE(0));
|
1478
|
-
* // Prints: 5
|
1479
|
-
* ```
|
1480
|
-
* @since v0.5.5
|
1481
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 2`.
|
1482
|
-
*/
|
1483
|
-
readInt16BE(offset?: number): number;
|
1484
|
-
/**
|
1485
|
-
* Reads a signed, little-endian 32-bit integer from `buf` at the specified`offset`.
|
1486
|
-
*
|
1487
|
-
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
1488
|
-
*
|
1489
|
-
* ```js
|
1490
|
-
* import { Buffer } from 'node:buffer';
|
1491
|
-
*
|
1492
|
-
* const buf = Buffer.from([0, 0, 0, 5]);
|
1493
|
-
*
|
1494
|
-
* console.log(buf.readInt32LE(0));
|
1495
|
-
* // Prints: 83886080
|
1496
|
-
* console.log(buf.readInt32LE(1));
|
1497
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1498
|
-
* ```
|
1499
|
-
* @since v0.5.5
|
1500
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
1501
|
-
*/
|
1502
|
-
readInt32LE(offset?: number): number;
|
1503
|
-
/**
|
1504
|
-
* Reads a signed, big-endian 32-bit integer from `buf` at the specified `offset`.
|
1505
|
-
*
|
1506
|
-
* Integers read from a `Buffer` are interpreted as two's complement signed values.
|
1507
|
-
*
|
1508
|
-
* ```js
|
1509
|
-
* import { Buffer } from 'node:buffer';
|
1510
|
-
*
|
1511
|
-
* const buf = Buffer.from([0, 0, 0, 5]);
|
1512
|
-
*
|
1513
|
-
* console.log(buf.readInt32BE(0));
|
1514
|
-
* // Prints: 5
|
1515
|
-
* ```
|
1516
|
-
* @since v0.5.5
|
1517
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
1518
|
-
*/
|
1519
|
-
readInt32BE(offset?: number): number;
|
1520
|
-
/**
|
1521
|
-
* Reads a 32-bit, little-endian float from `buf` at the specified `offset`.
|
1522
|
-
*
|
1523
|
-
* ```js
|
1524
|
-
* import { Buffer } from 'node:buffer';
|
1525
|
-
*
|
1526
|
-
* const buf = Buffer.from([1, 2, 3, 4]);
|
1527
|
-
*
|
1528
|
-
* console.log(buf.readFloatLE(0));
|
1529
|
-
* // Prints: 1.539989614439558e-36
|
1530
|
-
* console.log(buf.readFloatLE(1));
|
1531
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1532
|
-
* ```
|
1533
|
-
* @since v0.11.15
|
1534
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
1535
|
-
*/
|
1536
|
-
readFloatLE(offset?: number): number;
|
1537
|
-
/**
|
1538
|
-
* Reads a 32-bit, big-endian float from `buf` at the specified `offset`.
|
1539
|
-
*
|
1540
|
-
* ```js
|
1541
|
-
* import { Buffer } from 'node:buffer';
|
1542
|
-
*
|
1543
|
-
* const buf = Buffer.from([1, 2, 3, 4]);
|
1544
|
-
*
|
1545
|
-
* console.log(buf.readFloatBE(0));
|
1546
|
-
* // Prints: 2.387939260590663e-38
|
1547
|
-
* ```
|
1548
|
-
* @since v0.11.15
|
1549
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 4`.
|
1550
|
-
*/
|
1551
|
-
readFloatBE(offset?: number): number;
|
1552
|
-
/**
|
1553
|
-
* Reads a 64-bit, little-endian double from `buf` at the specified `offset`.
|
1554
|
-
*
|
1555
|
-
* ```js
|
1556
|
-
* import { Buffer } from 'node:buffer';
|
1557
|
-
*
|
1558
|
-
* const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
|
1559
|
-
*
|
1560
|
-
* console.log(buf.readDoubleLE(0));
|
1561
|
-
* // Prints: 5.447603722011605e-270
|
1562
|
-
* console.log(buf.readDoubleLE(1));
|
1563
|
-
* // Throws ERR_OUT_OF_RANGE.
|
1564
|
-
* ```
|
1565
|
-
* @since v0.11.15
|
1566
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
|
1567
|
-
*/
|
1568
|
-
readDoubleLE(offset?: number): number;
|
1569
|
-
/**
|
1570
|
-
* Reads a 64-bit, big-endian double from `buf` at the specified `offset`.
|
1571
|
-
*
|
1572
|
-
* ```js
|
1573
|
-
* import { Buffer } from 'node:buffer';
|
1574
|
-
*
|
1575
|
-
* const buf = Buffer.from([1, 2, 3, 4, 5, 6, 7, 8]);
|
1576
|
-
*
|
1577
|
-
* console.log(buf.readDoubleBE(0));
|
1578
|
-
* // Prints: 8.20788039913184e-304
|
1579
|
-
* ```
|
1580
|
-
* @since v0.11.15
|
1581
|
-
* @param [offset=0] Number of bytes to skip before starting to read. Must satisfy `0 <= offset <= buf.length - 8`.
|
1582
|
-
*/
|
1583
|
-
readDoubleBE(offset?: number): number;
|
1584
|
-
reverse(): this;
|
1585
|
-
/**
|
1586
|
-
* Interprets `buf` as an array of unsigned 16-bit integers and swaps the
|
1587
|
-
* byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 2.
|
1588
|
-
*
|
1589
|
-
* ```js
|
1590
|
-
* import { Buffer } from 'node:buffer';
|
1591
|
-
*
|
1592
|
-
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
1593
|
-
*
|
1594
|
-
* console.log(buf1);
|
1595
|
-
* // Prints: <Buffer 01 02 03 04 05 06 07 08>
|
1596
|
-
*
|
1597
|
-
* buf1.swap16();
|
1598
|
-
*
|
1599
|
-
* console.log(buf1);
|
1600
|
-
* // Prints: <Buffer 02 01 04 03 06 05 08 07>
|
1601
|
-
*
|
1602
|
-
* const buf2 = Buffer.from([0x1, 0x2, 0x3]);
|
1603
|
-
*
|
1604
|
-
* buf2.swap16();
|
1605
|
-
* // Throws ERR_INVALID_BUFFER_SIZE.
|
1606
|
-
* ```
|
1607
|
-
*
|
1608
|
-
* One convenient use of `buf.swap16()` is to perform a fast in-place conversion
|
1609
|
-
* between UTF-16 little-endian and UTF-16 big-endian:
|
1610
|
-
*
|
1611
|
-
* ```js
|
1612
|
-
* import { Buffer } from 'node:buffer';
|
1613
|
-
*
|
1614
|
-
* const buf = Buffer.from('This is little-endian UTF-16', 'utf16le');
|
1615
|
-
* buf.swap16(); // Convert to big-endian UTF-16 text.
|
1616
|
-
* ```
|
1617
|
-
* @since v5.10.0
|
1618
|
-
* @return A reference to `buf`.
|
1619
|
-
*/
|
1620
|
-
swap16(): Buffer;
|
1621
|
-
/**
|
1622
|
-
* Interprets `buf` as an array of unsigned 32-bit integers and swaps the
|
1623
|
-
* byte order _in-place_. Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 4.
|
1624
|
-
*
|
1625
|
-
* ```js
|
1626
|
-
* import { Buffer } from 'node:buffer';
|
1627
|
-
*
|
1628
|
-
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
1629
|
-
*
|
1630
|
-
* console.log(buf1);
|
1631
|
-
* // Prints: <Buffer 01 02 03 04 05 06 07 08>
|
1632
|
-
*
|
1633
|
-
* buf1.swap32();
|
1634
|
-
*
|
1635
|
-
* console.log(buf1);
|
1636
|
-
* // Prints: <Buffer 04 03 02 01 08 07 06 05>
|
1637
|
-
*
|
1638
|
-
* const buf2 = Buffer.from([0x1, 0x2, 0x3]);
|
1639
|
-
*
|
1640
|
-
* buf2.swap32();
|
1641
|
-
* // Throws ERR_INVALID_BUFFER_SIZE.
|
1642
|
-
* ```
|
1643
|
-
* @since v5.10.0
|
1644
|
-
* @return A reference to `buf`.
|
1645
|
-
*/
|
1646
|
-
swap32(): Buffer;
|
1647
|
-
/**
|
1648
|
-
* Interprets `buf` as an array of 64-bit numbers and swaps byte order _in-place_.
|
1649
|
-
* Throws `ERR_INVALID_BUFFER_SIZE` if `buf.length` is not a multiple of 8.
|
1650
|
-
*
|
1651
|
-
* ```js
|
1652
|
-
* import { Buffer } from 'node:buffer';
|
1653
|
-
*
|
1654
|
-
* const buf1 = Buffer.from([0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8]);
|
1655
|
-
*
|
1656
|
-
* console.log(buf1);
|
1657
|
-
* // Prints: <Buffer 01 02 03 04 05 06 07 08>
|
1658
|
-
*
|
1659
|
-
* buf1.swap64();
|
1660
|
-
*
|
1661
|
-
* console.log(buf1);
|
1662
|
-
* // Prints: <Buffer 08 07 06 05 04 03 02 01>
|
1663
|
-
*
|
1664
|
-
* const buf2 = Buffer.from([0x1, 0x2, 0x3]);
|
1665
|
-
*
|
1666
|
-
* buf2.swap64();
|
1667
|
-
* // Throws ERR_INVALID_BUFFER_SIZE.
|
1668
|
-
* ```
|
1669
|
-
* @since v6.3.0
|
1670
|
-
* @return A reference to `buf`.
|
1671
|
-
*/
|
1672
|
-
swap64(): Buffer;
|
1673
|
-
/**
|
1674
|
-
* Writes `value` to `buf` at the specified `offset`. `value` must be a
|
1675
|
-
* valid unsigned 8-bit integer. Behavior is undefined when `value` is anything
|
1676
|
-
* other than an unsigned 8-bit integer.
|
1677
|
-
*
|
1678
|
-
* This function is also available under the `writeUint8` alias.
|
1679
|
-
*
|
1680
|
-
* ```js
|
1681
|
-
* import { Buffer } from 'node:buffer';
|
1682
|
-
*
|
1683
|
-
* const buf = Buffer.allocUnsafe(4);
|
1684
|
-
*
|
1685
|
-
* buf.writeUInt8(0x3, 0);
|
1686
|
-
* buf.writeUInt8(0x4, 1);
|
1687
|
-
* buf.writeUInt8(0x23, 2);
|
1688
|
-
* buf.writeUInt8(0x42, 3);
|
1689
|
-
*
|
1690
|
-
* console.log(buf);
|
1691
|
-
* // Prints: <Buffer 03 04 23 42>
|
1692
|
-
* ```
|
1693
|
-
* @since v0.5.0
|
1694
|
-
* @param value Number to be written to `buf`.
|
1695
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
|
1696
|
-
* @return `offset` plus the number of bytes written.
|
1697
|
-
*/
|
1698
|
-
writeUInt8(value: number, offset?: number): number;
|
1699
|
-
/**
|
1700
|
-
* @alias Buffer.writeUInt8
|
1701
|
-
* @since v14.9.0, v12.19.0
|
1702
|
-
*/
|
1703
|
-
writeUint8(value: number, offset?: number): number;
|
1704
|
-
/**
|
1705
|
-
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid unsigned 16-bit integer. Behavior is undefined when `value` is
|
1706
|
-
* anything other than an unsigned 16-bit integer.
|
1707
|
-
*
|
1708
|
-
* This function is also available under the `writeUint16LE` alias.
|
1709
|
-
*
|
1710
|
-
* ```js
|
1711
|
-
* import { Buffer } from 'node:buffer';
|
1712
|
-
*
|
1713
|
-
* const buf = Buffer.allocUnsafe(4);
|
1714
|
-
*
|
1715
|
-
* buf.writeUInt16LE(0xdead, 0);
|
1716
|
-
* buf.writeUInt16LE(0xbeef, 2);
|
1717
|
-
*
|
1718
|
-
* console.log(buf);
|
1719
|
-
* // Prints: <Buffer ad de ef be>
|
1720
|
-
* ```
|
1721
|
-
* @since v0.5.5
|
1722
|
-
* @param value Number to be written to `buf`.
|
1723
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
|
1724
|
-
* @return `offset` plus the number of bytes written.
|
1725
|
-
*/
|
1726
|
-
writeUInt16LE(value: number, offset?: number): number;
|
1727
|
-
/**
|
1728
|
-
* @alias Buffer.writeUInt16LE
|
1729
|
-
* @since v14.9.0, v12.19.0
|
1730
|
-
*/
|
1731
|
-
writeUint16LE(value: number, offset?: number): number;
|
1732
|
-
/**
|
1733
|
-
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid unsigned 16-bit integer. Behavior is undefined when `value`is anything other than an
|
1734
|
-
* unsigned 16-bit integer.
|
1735
|
-
*
|
1736
|
-
* This function is also available under the `writeUint16BE` alias.
|
1737
|
-
*
|
1738
|
-
* ```js
|
1739
|
-
* import { Buffer } from 'node:buffer';
|
1740
|
-
*
|
1741
|
-
* const buf = Buffer.allocUnsafe(4);
|
1742
|
-
*
|
1743
|
-
* buf.writeUInt16BE(0xdead, 0);
|
1744
|
-
* buf.writeUInt16BE(0xbeef, 2);
|
1745
|
-
*
|
1746
|
-
* console.log(buf);
|
1747
|
-
* // Prints: <Buffer de ad be ef>
|
1748
|
-
* ```
|
1749
|
-
* @since v0.5.5
|
1750
|
-
* @param value Number to be written to `buf`.
|
1751
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
|
1752
|
-
* @return `offset` plus the number of bytes written.
|
1753
|
-
*/
|
1754
|
-
writeUInt16BE(value: number, offset?: number): number;
|
1755
|
-
/**
|
1756
|
-
* @alias Buffer.writeUInt16BE
|
1757
|
-
* @since v14.9.0, v12.19.0
|
1758
|
-
*/
|
1759
|
-
writeUint16BE(value: number, offset?: number): number;
|
1760
|
-
/**
|
1761
|
-
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid unsigned 32-bit integer. Behavior is undefined when `value` is
|
1762
|
-
* anything other than an unsigned 32-bit integer.
|
1763
|
-
*
|
1764
|
-
* This function is also available under the `writeUint32LE` alias.
|
1765
|
-
*
|
1766
|
-
* ```js
|
1767
|
-
* import { Buffer } from 'node:buffer';
|
1768
|
-
*
|
1769
|
-
* const buf = Buffer.allocUnsafe(4);
|
1770
|
-
*
|
1771
|
-
* buf.writeUInt32LE(0xfeedface, 0);
|
1772
|
-
*
|
1773
|
-
* console.log(buf);
|
1774
|
-
* // Prints: <Buffer ce fa ed fe>
|
1775
|
-
* ```
|
1776
|
-
* @since v0.5.5
|
1777
|
-
* @param value Number to be written to `buf`.
|
1778
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
1779
|
-
* @return `offset` plus the number of bytes written.
|
1780
|
-
*/
|
1781
|
-
writeUInt32LE(value: number, offset?: number): number;
|
1782
|
-
/**
|
1783
|
-
* @alias Buffer.writeUInt32LE
|
1784
|
-
* @since v14.9.0, v12.19.0
|
1785
|
-
*/
|
1786
|
-
writeUint32LE(value: number, offset?: number): number;
|
1787
|
-
/**
|
1788
|
-
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid unsigned 32-bit integer. Behavior is undefined when `value`is anything other than an
|
1789
|
-
* unsigned 32-bit integer.
|
1790
|
-
*
|
1791
|
-
* This function is also available under the `writeUint32BE` alias.
|
1792
|
-
*
|
1793
|
-
* ```js
|
1794
|
-
* import { Buffer } from 'node:buffer';
|
1795
|
-
*
|
1796
|
-
* const buf = Buffer.allocUnsafe(4);
|
1797
|
-
*
|
1798
|
-
* buf.writeUInt32BE(0xfeedface, 0);
|
1799
|
-
*
|
1800
|
-
* console.log(buf);
|
1801
|
-
* // Prints: <Buffer fe ed fa ce>
|
1802
|
-
* ```
|
1803
|
-
* @since v0.5.5
|
1804
|
-
* @param value Number to be written to `buf`.
|
1805
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
1806
|
-
* @return `offset` plus the number of bytes written.
|
1807
|
-
*/
|
1808
|
-
writeUInt32BE(value: number, offset?: number): number;
|
1809
|
-
/**
|
1810
|
-
* @alias Buffer.writeUInt32BE
|
1811
|
-
* @since v14.9.0, v12.19.0
|
1812
|
-
*/
|
1813
|
-
writeUint32BE(value: number, offset?: number): number;
|
1814
|
-
/**
|
1815
|
-
* Writes `value` to `buf` at the specified `offset`. `value` must be a valid
|
1816
|
-
* signed 8-bit integer. Behavior is undefined when `value` is anything other than
|
1817
|
-
* a signed 8-bit integer.
|
1818
|
-
*
|
1819
|
-
* `value` is interpreted and written as a two's complement signed integer.
|
1820
|
-
*
|
1821
|
-
* ```js
|
1822
|
-
* import { Buffer } from 'node:buffer';
|
1823
|
-
*
|
1824
|
-
* const buf = Buffer.allocUnsafe(2);
|
1825
|
-
*
|
1826
|
-
* buf.writeInt8(2, 0);
|
1827
|
-
* buf.writeInt8(-2, 1);
|
1828
|
-
*
|
1829
|
-
* console.log(buf);
|
1830
|
-
* // Prints: <Buffer 02 fe>
|
1831
|
-
* ```
|
1832
|
-
* @since v0.5.0
|
1833
|
-
* @param value Number to be written to `buf`.
|
1834
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 1`.
|
1835
|
-
* @return `offset` plus the number of bytes written.
|
1836
|
-
*/
|
1837
|
-
writeInt8(value: number, offset?: number): number;
|
1838
|
-
/**
|
1839
|
-
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid signed 16-bit integer. Behavior is undefined when `value` is
|
1840
|
-
* anything other than a signed 16-bit integer.
|
1841
|
-
*
|
1842
|
-
* The `value` is interpreted and written as a two's complement signed integer.
|
1843
|
-
*
|
1844
|
-
* ```js
|
1845
|
-
* import { Buffer } from 'node:buffer';
|
1846
|
-
*
|
1847
|
-
* const buf = Buffer.allocUnsafe(2);
|
1848
|
-
*
|
1849
|
-
* buf.writeInt16LE(0x0304, 0);
|
1850
|
-
*
|
1851
|
-
* console.log(buf);
|
1852
|
-
* // Prints: <Buffer 04 03>
|
1853
|
-
* ```
|
1854
|
-
* @since v0.5.5
|
1855
|
-
* @param value Number to be written to `buf`.
|
1856
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
|
1857
|
-
* @return `offset` plus the number of bytes written.
|
1858
|
-
*/
|
1859
|
-
writeInt16LE(value: number, offset?: number): number;
|
1860
|
-
/**
|
1861
|
-
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid signed 16-bit integer. Behavior is undefined when `value` is
|
1862
|
-
* anything other than a signed 16-bit integer.
|
1863
|
-
*
|
1864
|
-
* The `value` is interpreted and written as a two's complement signed integer.
|
1865
|
-
*
|
1866
|
-
* ```js
|
1867
|
-
* import { Buffer } from 'node:buffer';
|
1868
|
-
*
|
1869
|
-
* const buf = Buffer.allocUnsafe(2);
|
1870
|
-
*
|
1871
|
-
* buf.writeInt16BE(0x0102, 0);
|
1872
|
-
*
|
1873
|
-
* console.log(buf);
|
1874
|
-
* // Prints: <Buffer 01 02>
|
1875
|
-
* ```
|
1876
|
-
* @since v0.5.5
|
1877
|
-
* @param value Number to be written to `buf`.
|
1878
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 2`.
|
1879
|
-
* @return `offset` plus the number of bytes written.
|
1880
|
-
*/
|
1881
|
-
writeInt16BE(value: number, offset?: number): number;
|
1882
|
-
/**
|
1883
|
-
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a valid signed 32-bit integer. Behavior is undefined when `value` is
|
1884
|
-
* anything other than a signed 32-bit integer.
|
1885
|
-
*
|
1886
|
-
* The `value` is interpreted and written as a two's complement signed integer.
|
1887
|
-
*
|
1888
|
-
* ```js
|
1889
|
-
* import { Buffer } from 'node:buffer';
|
1890
|
-
*
|
1891
|
-
* const buf = Buffer.allocUnsafe(4);
|
1892
|
-
*
|
1893
|
-
* buf.writeInt32LE(0x05060708, 0);
|
1894
|
-
*
|
1895
|
-
* console.log(buf);
|
1896
|
-
* // Prints: <Buffer 08 07 06 05>
|
1897
|
-
* ```
|
1898
|
-
* @since v0.5.5
|
1899
|
-
* @param value Number to be written to `buf`.
|
1900
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
1901
|
-
* @return `offset` plus the number of bytes written.
|
1902
|
-
*/
|
1903
|
-
writeInt32LE(value: number, offset?: number): number;
|
1904
|
-
/**
|
1905
|
-
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a valid signed 32-bit integer. Behavior is undefined when `value` is
|
1906
|
-
* anything other than a signed 32-bit integer.
|
1907
|
-
*
|
1908
|
-
* The `value` is interpreted and written as a two's complement signed integer.
|
1909
|
-
*
|
1910
|
-
* ```js
|
1911
|
-
* import { Buffer } from 'node:buffer';
|
1912
|
-
*
|
1913
|
-
* const buf = Buffer.allocUnsafe(4);
|
1914
|
-
*
|
1915
|
-
* buf.writeInt32BE(0x01020304, 0);
|
1916
|
-
*
|
1917
|
-
* console.log(buf);
|
1918
|
-
* // Prints: <Buffer 01 02 03 04>
|
1919
|
-
* ```
|
1920
|
-
* @since v0.5.5
|
1921
|
-
* @param value Number to be written to `buf`.
|
1922
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
1923
|
-
* @return `offset` plus the number of bytes written.
|
1924
|
-
*/
|
1925
|
-
writeInt32BE(value: number, offset?: number): number;
|
1926
|
-
/**
|
1927
|
-
* Writes `value` to `buf` at the specified `offset` as little-endian. Behavior is
|
1928
|
-
* undefined when `value` is anything other than a JavaScript number.
|
1929
|
-
*
|
1930
|
-
* ```js
|
1931
|
-
* import { Buffer } from 'node:buffer';
|
1932
|
-
*
|
1933
|
-
* const buf = Buffer.allocUnsafe(4);
|
1934
|
-
*
|
1935
|
-
* buf.writeFloatLE(0xcafebabe, 0);
|
1936
|
-
*
|
1937
|
-
* console.log(buf);
|
1938
|
-
* // Prints: <Buffer bb fe 4a 4f>
|
1939
|
-
* ```
|
1940
|
-
* @since v0.11.15
|
1941
|
-
* @param value Number to be written to `buf`.
|
1942
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
1943
|
-
* @return `offset` plus the number of bytes written.
|
1944
|
-
*/
|
1945
|
-
writeFloatLE(value: number, offset?: number): number;
|
1946
|
-
/**
|
1947
|
-
* Writes `value` to `buf` at the specified `offset` as big-endian. Behavior is
|
1948
|
-
* undefined when `value` is anything other than a JavaScript number.
|
1949
|
-
*
|
1950
|
-
* ```js
|
1951
|
-
* import { Buffer } from 'node:buffer';
|
1952
|
-
*
|
1953
|
-
* const buf = Buffer.allocUnsafe(4);
|
1954
|
-
*
|
1955
|
-
* buf.writeFloatBE(0xcafebabe, 0);
|
1956
|
-
*
|
1957
|
-
* console.log(buf);
|
1958
|
-
* // Prints: <Buffer 4f 4a fe bb>
|
1959
|
-
* ```
|
1960
|
-
* @since v0.11.15
|
1961
|
-
* @param value Number to be written to `buf`.
|
1962
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 4`.
|
1963
|
-
* @return `offset` plus the number of bytes written.
|
1964
|
-
*/
|
1965
|
-
writeFloatBE(value: number, offset?: number): number;
|
1966
|
-
/**
|
1967
|
-
* Writes `value` to `buf` at the specified `offset` as little-endian. The `value` must be a JavaScript number. Behavior is undefined when `value` is anything
|
1968
|
-
* other than a JavaScript number.
|
1969
|
-
*
|
1970
|
-
* ```js
|
1971
|
-
* import { Buffer } from 'node:buffer';
|
1972
|
-
*
|
1973
|
-
* const buf = Buffer.allocUnsafe(8);
|
1974
|
-
*
|
1975
|
-
* buf.writeDoubleLE(123.456, 0);
|
1976
|
-
*
|
1977
|
-
* console.log(buf);
|
1978
|
-
* // Prints: <Buffer 77 be 9f 1a 2f dd 5e 40>
|
1979
|
-
* ```
|
1980
|
-
* @since v0.11.15
|
1981
|
-
* @param value Number to be written to `buf`.
|
1982
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
|
1983
|
-
* @return `offset` plus the number of bytes written.
|
1984
|
-
*/
|
1985
|
-
writeDoubleLE(value: number, offset?: number): number;
|
1986
|
-
/**
|
1987
|
-
* Writes `value` to `buf` at the specified `offset` as big-endian. The `value` must be a JavaScript number. Behavior is undefined when `value` is anything
|
1988
|
-
* other than a JavaScript number.
|
1989
|
-
*
|
1990
|
-
* ```js
|
1991
|
-
* import { Buffer } from 'node:buffer';
|
1992
|
-
*
|
1993
|
-
* const buf = Buffer.allocUnsafe(8);
|
1994
|
-
*
|
1995
|
-
* buf.writeDoubleBE(123.456, 0);
|
1996
|
-
*
|
1997
|
-
* console.log(buf);
|
1998
|
-
* // Prints: <Buffer 40 5e dd 2f 1a 9f be 77>
|
1999
|
-
* ```
|
2000
|
-
* @since v0.11.15
|
2001
|
-
* @param value Number to be written to `buf`.
|
2002
|
-
* @param [offset=0] Number of bytes to skip before starting to write. Must satisfy `0 <= offset <= buf.length - 8`.
|
2003
|
-
* @return `offset` plus the number of bytes written.
|
2004
|
-
*/
|
2005
|
-
writeDoubleBE(value: number, offset?: number): number;
|
2006
|
-
/**
|
2007
|
-
* Fills `buf` with the specified `value`. If the `offset` and `end` are not given,
|
2008
|
-
* the entire `buf` will be filled:
|
2009
|
-
*
|
2010
|
-
* ```js
|
2011
|
-
* import { Buffer } from 'node:buffer';
|
2012
|
-
*
|
2013
|
-
* // Fill a `Buffer` with the ASCII character 'h'.
|
2014
|
-
*
|
2015
|
-
* const b = Buffer.allocUnsafe(50).fill('h');
|
2016
|
-
*
|
2017
|
-
* console.log(b.toString());
|
2018
|
-
* // Prints: hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
|
2019
|
-
*
|
2020
|
-
* // Fill a buffer with empty string
|
2021
|
-
* const c = Buffer.allocUnsafe(5).fill('');
|
2022
|
-
*
|
2023
|
-
* console.log(c.fill(''));
|
2024
|
-
* // Prints: <Buffer 00 00 00 00 00>
|
2025
|
-
* ```
|
2026
|
-
*
|
2027
|
-
* `value` is coerced to a `uint32` value if it is not a string, `Buffer`, or
|
2028
|
-
* integer. If the resulting integer is greater than `255` (decimal), `buf` will be
|
2029
|
-
* filled with `value & 255`.
|
2030
|
-
*
|
2031
|
-
* If the final write of a `fill()` operation falls on a multi-byte character,
|
2032
|
-
* then only the bytes of that character that fit into `buf` are written:
|
2033
|
-
*
|
2034
|
-
* ```js
|
2035
|
-
* import { Buffer } from 'node:buffer';
|
2036
|
-
*
|
2037
|
-
* // Fill a `Buffer` with character that takes up two bytes in UTF-8.
|
2038
|
-
*
|
2039
|
-
* console.log(Buffer.allocUnsafe(5).fill('\u0222'));
|
2040
|
-
* // Prints: <Buffer c8 a2 c8 a2 c8>
|
2041
|
-
* ```
|
2042
|
-
*
|
2043
|
-
* If `value` contains invalid characters, it is truncated; if no valid
|
2044
|
-
* fill data remains, an exception is thrown:
|
2045
|
-
*
|
2046
|
-
* ```js
|
2047
|
-
* import { Buffer } from 'node:buffer';
|
2048
|
-
*
|
2049
|
-
* const buf = Buffer.allocUnsafe(5);
|
2050
|
-
*
|
2051
|
-
* console.log(buf.fill('a'));
|
2052
|
-
* // Prints: <Buffer 61 61 61 61 61>
|
2053
|
-
* console.log(buf.fill('aazz', 'hex'));
|
2054
|
-
* // Prints: <Buffer aa aa aa aa aa>
|
2055
|
-
* console.log(buf.fill('zz', 'hex'));
|
2056
|
-
* // Throws an exception.
|
2057
|
-
* ```
|
2058
|
-
* @since v0.5.0
|
2059
|
-
* @param value The value with which to fill `buf`. Empty value (string, Uint8Array, Buffer) is coerced to `0`.
|
2060
|
-
* @param [offset=0] Number of bytes to skip before starting to fill `buf`.
|
2061
|
-
* @param [end=buf.length] Where to stop filling `buf` (not inclusive).
|
2062
|
-
* @param [encoding='utf8'] The encoding for `value` if `value` is a string.
|
2063
|
-
* @return A reference to `buf`.
|
2064
|
-
*/
|
2065
|
-
fill(value: string | Uint8Array | number, offset?: number, end?: number, encoding?: BufferEncoding): this;
|
2066
|
-
/**
|
2067
|
-
* If `value` is:
|
2068
|
-
*
|
2069
|
-
* * a string, `value` is interpreted according to the character encoding in `encoding`.
|
2070
|
-
* * a `Buffer` or [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array), `value` will be used in its entirety.
|
2071
|
-
* To compare a partial `Buffer`, use `buf.subarray`.
|
2072
|
-
* * a number, `value` will be interpreted as an unsigned 8-bit integer
|
2073
|
-
* value between `0` and `255`.
|
2074
|
-
*
|
2075
|
-
* ```js
|
2076
|
-
* import { Buffer } from 'node:buffer';
|
2077
|
-
*
|
2078
|
-
* const buf = Buffer.from('this is a buffer');
|
2079
|
-
*
|
2080
|
-
* console.log(buf.indexOf('this'));
|
2081
|
-
* // Prints: 0
|
2082
|
-
* console.log(buf.indexOf('is'));
|
2083
|
-
* // Prints: 2
|
2084
|
-
* console.log(buf.indexOf(Buffer.from('a buffer')));
|
2085
|
-
* // Prints: 8
|
2086
|
-
* console.log(buf.indexOf(97));
|
2087
|
-
* // Prints: 8 (97 is the decimal ASCII value for 'a')
|
2088
|
-
* console.log(buf.indexOf(Buffer.from('a buffer example')));
|
2089
|
-
* // Prints: -1
|
2090
|
-
* console.log(buf.indexOf(Buffer.from('a buffer example').slice(0, 8)));
|
2091
|
-
* // Prints: 8
|
2092
|
-
*
|
2093
|
-
* const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
|
2094
|
-
*
|
2095
|
-
* console.log(utf16Buffer.indexOf('\u03a3', 0, 'utf16le'));
|
2096
|
-
* // Prints: 4
|
2097
|
-
* console.log(utf16Buffer.indexOf('\u03a3', -4, 'utf16le'));
|
2098
|
-
* // Prints: 6
|
2099
|
-
* ```
|
2100
|
-
*
|
2101
|
-
* If `value` is not a string, number, or `Buffer`, this method will throw a `TypeError`. If `value` is a number, it will be coerced to a valid byte value,
|
2102
|
-
* an integer between 0 and 255.
|
2103
|
-
*
|
2104
|
-
* If `byteOffset` is not a number, it will be coerced to a number. If the result
|
2105
|
-
* of coercion is `NaN` or `0`, then the entire buffer will be searched. This
|
2106
|
-
* behavior matches [`String.prototype.indexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf).
|
2107
|
-
*
|
2108
|
-
* ```js
|
2109
|
-
* import { Buffer } from 'node:buffer';
|
2110
|
-
*
|
2111
|
-
* const b = Buffer.from('abcdef');
|
2112
|
-
*
|
2113
|
-
* // Passing a value that's a number, but not a valid byte.
|
2114
|
-
* // Prints: 2, equivalent to searching for 99 or 'c'.
|
2115
|
-
* console.log(b.indexOf(99.9));
|
2116
|
-
* console.log(b.indexOf(256 + 99));
|
2117
|
-
*
|
2118
|
-
* // Passing a byteOffset that coerces to NaN or 0.
|
2119
|
-
* // Prints: 1, searching the whole buffer.
|
2120
|
-
* console.log(b.indexOf('b', undefined));
|
2121
|
-
* console.log(b.indexOf('b', {}));
|
2122
|
-
* console.log(b.indexOf('b', null));
|
2123
|
-
* console.log(b.indexOf('b', []));
|
2124
|
-
* ```
|
2125
|
-
*
|
2126
|
-
* If `value` is an empty string or empty `Buffer` and `byteOffset` is less
|
2127
|
-
* than `buf.length`, `byteOffset` will be returned. If `value` is empty and`byteOffset` is at least `buf.length`, `buf.length` will be returned.
|
2128
|
-
* @since v1.5.0
|
2129
|
-
* @param value What to search for.
|
2130
|
-
* @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
|
2131
|
-
* @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
|
2132
|
-
* @return The index of the first occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
|
2133
|
-
*/
|
2134
|
-
indexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
|
2135
|
-
/**
|
2136
|
-
* Identical to `buf.indexOf()`, except the last occurrence of `value` is found
|
2137
|
-
* rather than the first occurrence.
|
2138
|
-
*
|
2139
|
-
* ```js
|
2140
|
-
* import { Buffer } from 'node:buffer';
|
2141
|
-
*
|
2142
|
-
* const buf = Buffer.from('this buffer is a buffer');
|
2143
|
-
*
|
2144
|
-
* console.log(buf.lastIndexOf('this'));
|
2145
|
-
* // Prints: 0
|
2146
|
-
* console.log(buf.lastIndexOf('buffer'));
|
2147
|
-
* // Prints: 17
|
2148
|
-
* console.log(buf.lastIndexOf(Buffer.from('buffer')));
|
2149
|
-
* // Prints: 17
|
2150
|
-
* console.log(buf.lastIndexOf(97));
|
2151
|
-
* // Prints: 15 (97 is the decimal ASCII value for 'a')
|
2152
|
-
* console.log(buf.lastIndexOf(Buffer.from('yolo')));
|
2153
|
-
* // Prints: -1
|
2154
|
-
* console.log(buf.lastIndexOf('buffer', 5));
|
2155
|
-
* // Prints: 5
|
2156
|
-
* console.log(buf.lastIndexOf('buffer', 4));
|
2157
|
-
* // Prints: -1
|
2158
|
-
*
|
2159
|
-
* const utf16Buffer = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'utf16le');
|
2160
|
-
*
|
2161
|
-
* console.log(utf16Buffer.lastIndexOf('\u03a3', undefined, 'utf16le'));
|
2162
|
-
* // Prints: 6
|
2163
|
-
* console.log(utf16Buffer.lastIndexOf('\u03a3', -5, 'utf16le'));
|
2164
|
-
* // Prints: 4
|
2165
|
-
* ```
|
2166
|
-
*
|
2167
|
-
* If `value` is not a string, number, or `Buffer`, this method will throw a `TypeError`. If `value` is a number, it will be coerced to a valid byte value,
|
2168
|
-
* an integer between 0 and 255.
|
2169
|
-
*
|
2170
|
-
* If `byteOffset` is not a number, it will be coerced to a number. Any arguments
|
2171
|
-
* that coerce to `NaN`, like `{}` or `undefined`, will search the whole buffer.
|
2172
|
-
* This behavior matches [`String.prototype.lastIndexOf()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/lastIndexOf).
|
2173
|
-
*
|
2174
|
-
* ```js
|
2175
|
-
* import { Buffer } from 'node:buffer';
|
2176
|
-
*
|
2177
|
-
* const b = Buffer.from('abcdef');
|
2178
|
-
*
|
2179
|
-
* // Passing a value that's a number, but not a valid byte.
|
2180
|
-
* // Prints: 2, equivalent to searching for 99 or 'c'.
|
2181
|
-
* console.log(b.lastIndexOf(99.9));
|
2182
|
-
* console.log(b.lastIndexOf(256 + 99));
|
2183
|
-
*
|
2184
|
-
* // Passing a byteOffset that coerces to NaN.
|
2185
|
-
* // Prints: 1, searching the whole buffer.
|
2186
|
-
* console.log(b.lastIndexOf('b', undefined));
|
2187
|
-
* console.log(b.lastIndexOf('b', {}));
|
2188
|
-
*
|
2189
|
-
* // Passing a byteOffset that coerces to 0.
|
2190
|
-
* // Prints: -1, equivalent to passing 0.
|
2191
|
-
* console.log(b.lastIndexOf('b', null));
|
2192
|
-
* console.log(b.lastIndexOf('b', []));
|
2193
|
-
* ```
|
2194
|
-
*
|
2195
|
-
* If `value` is an empty string or empty `Buffer`, `byteOffset` will be returned.
|
2196
|
-
* @since v6.0.0
|
2197
|
-
* @param value What to search for.
|
2198
|
-
* @param [byteOffset=buf.length - 1] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
|
2199
|
-
* @param [encoding='utf8'] If `value` is a string, this is the encoding used to determine the binary representation of the string that will be searched for in `buf`.
|
2200
|
-
* @return The index of the last occurrence of `value` in `buf`, or `-1` if `buf` does not contain `value`.
|
2201
|
-
*/
|
2202
|
-
lastIndexOf(value: string | number | Uint8Array, byteOffset?: number, encoding?: BufferEncoding): number;
|
2203
|
-
/**
|
2204
|
-
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `[index, byte]` pairs from the contents
|
2205
|
-
* of `buf`.
|
2206
|
-
*
|
2207
|
-
* ```js
|
2208
|
-
* import { Buffer } from 'node:buffer';
|
2209
|
-
*
|
2210
|
-
* // Log the entire contents of a `Buffer`.
|
2211
|
-
*
|
2212
|
-
* const buf = Buffer.from('buffer');
|
2213
|
-
*
|
2214
|
-
* for (const pair of buf.entries()) {
|
2215
|
-
* console.log(pair);
|
2216
|
-
* }
|
2217
|
-
* // Prints:
|
2218
|
-
* // [0, 98]
|
2219
|
-
* // [1, 117]
|
2220
|
-
* // [2, 102]
|
2221
|
-
* // [3, 102]
|
2222
|
-
* // [4, 101]
|
2223
|
-
* // [5, 114]
|
2224
|
-
* ```
|
2225
|
-
* @since v1.1.0
|
2226
|
-
*/
|
2227
|
-
entries(): IterableIterator<[number, number]>;
|
2228
|
-
/**
|
2229
|
-
* Equivalent to `buf.indexOf() !== -1`.
|
2230
|
-
*
|
2231
|
-
* ```js
|
2232
|
-
* import { Buffer } from 'node:buffer';
|
2233
|
-
*
|
2234
|
-
* const buf = Buffer.from('this is a buffer');
|
2235
|
-
*
|
2236
|
-
* console.log(buf.includes('this'));
|
2237
|
-
* // Prints: true
|
2238
|
-
* console.log(buf.includes('is'));
|
2239
|
-
* // Prints: true
|
2240
|
-
* console.log(buf.includes(Buffer.from('a buffer')));
|
2241
|
-
* // Prints: true
|
2242
|
-
* console.log(buf.includes(97));
|
2243
|
-
* // Prints: true (97 is the decimal ASCII value for 'a')
|
2244
|
-
* console.log(buf.includes(Buffer.from('a buffer example')));
|
2245
|
-
* // Prints: false
|
2246
|
-
* console.log(buf.includes(Buffer.from('a buffer example').slice(0, 8)));
|
2247
|
-
* // Prints: true
|
2248
|
-
* console.log(buf.includes('this', 4));
|
2249
|
-
* // Prints: false
|
2250
|
-
* ```
|
2251
|
-
* @since v5.3.0
|
2252
|
-
* @param value What to search for.
|
2253
|
-
* @param [byteOffset=0] Where to begin searching in `buf`. If negative, then offset is calculated from the end of `buf`.
|
2254
|
-
* @param [encoding='utf8'] If `value` is a string, this is its encoding.
|
2255
|
-
* @return `true` if `value` was found in `buf`, `false` otherwise.
|
2256
|
-
*/
|
2257
|
-
includes(value: string | number | Buffer, byteOffset?: number, encoding?: BufferEncoding): boolean;
|
2258
|
-
/**
|
2259
|
-
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) of `buf` keys (indices).
|
2260
|
-
*
|
2261
|
-
* ```js
|
2262
|
-
* import { Buffer } from 'node:buffer';
|
2263
|
-
*
|
2264
|
-
* const buf = Buffer.from('buffer');
|
2265
|
-
*
|
2266
|
-
* for (const key of buf.keys()) {
|
2267
|
-
* console.log(key);
|
2268
|
-
* }
|
2269
|
-
* // Prints:
|
2270
|
-
* // 0
|
2271
|
-
* // 1
|
2272
|
-
* // 2
|
2273
|
-
* // 3
|
2274
|
-
* // 4
|
2275
|
-
* // 5
|
2276
|
-
* ```
|
2277
|
-
* @since v1.1.0
|
2278
|
-
*/
|
2279
|
-
keys(): IterableIterator<number>;
|
2280
|
-
/**
|
2281
|
-
* Creates and returns an [iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols) for `buf` values (bytes). This function is
|
2282
|
-
* called automatically when a `Buffer` is used in a `for..of` statement.
|
2283
|
-
*
|
2284
|
-
* ```js
|
2285
|
-
* import { Buffer } from 'node:buffer';
|
2286
|
-
*
|
2287
|
-
* const buf = Buffer.from('buffer');
|
2288
|
-
*
|
2289
|
-
* for (const value of buf.values()) {
|
2290
|
-
* console.log(value);
|
2291
|
-
* }
|
2292
|
-
* // Prints:
|
2293
|
-
* // 98
|
2294
|
-
* // 117
|
2295
|
-
* // 102
|
2296
|
-
* // 102
|
2297
|
-
* // 101
|
2298
|
-
* // 114
|
2299
|
-
*
|
2300
|
-
* for (const value of buf) {
|
2301
|
-
* console.log(value);
|
2302
|
-
* }
|
2303
|
-
* // Prints:
|
2304
|
-
* // 98
|
2305
|
-
* // 117
|
2306
|
-
* // 102
|
2307
|
-
* // 102
|
2308
|
-
* // 101
|
2309
|
-
* // 114
|
2310
|
-
* ```
|
2311
|
-
* @since v1.1.0
|
2312
|
-
*/
|
2313
|
-
values(): IterableIterator<number>;
|
2314
|
-
}
|
2315
|
-
var Buffer: BufferConstructor;
|
2316
|
-
/**
|
2317
|
-
* Decodes a string of Base64-encoded data into bytes, and encodes those bytes
|
2318
|
-
* into a string using Latin-1 (ISO-8859-1).
|
2319
|
-
*
|
2320
|
-
* The `data` may be any JavaScript-value that can be coerced into a string.
|
2321
|
-
*
|
2322
|
-
* **This function is only provided for compatibility with legacy web platform APIs**
|
2323
|
-
* **and should never be used in new code, because they use strings to represent**
|
2324
|
-
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
2325
|
-
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
2326
|
-
* **and binary data should be performed using `Buffer.from(str, 'base64')` and `buf.toString('base64')`.**
|
2327
|
-
* @since v15.13.0, v14.17.0
|
2328
|
-
* @legacy Use `Buffer.from(data, 'base64')` instead.
|
2329
|
-
* @param data The Base64-encoded input string.
|
2330
|
-
*/
|
2331
|
-
function atob(data: string): string;
|
2332
|
-
/**
|
2333
|
-
* Decodes a string into bytes using Latin-1 (ISO-8859), and encodes those bytes
|
2334
|
-
* into a string using Base64.
|
2335
|
-
*
|
2336
|
-
* The `data` may be any JavaScript-value that can be coerced into a string.
|
2337
|
-
*
|
2338
|
-
* **This function is only provided for compatibility with legacy web platform APIs**
|
2339
|
-
* **and should never be used in new code, because they use strings to represent**
|
2340
|
-
* **binary data and predate the introduction of typed arrays in JavaScript.**
|
2341
|
-
* **For code running using Node.js APIs, converting between base64-encoded strings**
|
2342
|
-
* **and binary data should be performed using `Buffer.from(str, 'base64')` and `buf.toString('base64')`.**
|
2343
|
-
* @since v15.13.0, v14.17.0
|
2344
|
-
* @legacy Use `buf.toString('base64')` instead.
|
2345
|
-
* @param data An ASCII (Latin1) string.
|
2346
|
-
*/
|
2347
|
-
function btoa(data: string): string;
|
2348
|
-
interface Blob extends __Blob {}
|
2349
|
-
/**
|
2350
|
-
* `Blob` class is a global reference for `require('node:buffer').Blob`
|
2351
|
-
* https://nodejs.org/api/buffer.html#class-blob
|
2352
|
-
* @since v18.0.0
|
2353
|
-
*/
|
2354
|
-
var Blob: typeof globalThis extends {
|
2355
|
-
onmessage: any;
|
2356
|
-
Blob: infer T;
|
2357
|
-
} ? T
|
2358
|
-
: typeof NodeBlob;
|
2359
|
-
}
|
2360
|
-
}
|
2361
|
-
declare module "node:buffer" {
|
2362
|
-
export * from "buffer";
|
2363
|
-
}
|