@anthropic-ai/claude-code 0.2.9 → 0.2.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/cli.mjs +497 -479
  2. package/package.json +3 -2
  3. package/scripts/preinstall.js +15 -0
  4. package/vendor/sdk/node_modules/@types/node/LICENSE +0 -21
  5. package/vendor/sdk/node_modules/@types/node/README.md +0 -15
  6. package/vendor/sdk/node_modules/@types/node/assert/strict.d.ts +0 -8
  7. package/vendor/sdk/node_modules/@types/node/assert.d.ts +0 -985
  8. package/vendor/sdk/node_modules/@types/node/async_hooks.d.ts +0 -522
  9. package/vendor/sdk/node_modules/@types/node/buffer.buffer.d.ts +0 -385
  10. package/vendor/sdk/node_modules/@types/node/buffer.d.ts +0 -1903
  11. package/vendor/sdk/node_modules/@types/node/child_process.d.ts +0 -1549
  12. package/vendor/sdk/node_modules/@types/node/cluster.d.ts +0 -578
  13. package/vendor/sdk/node_modules/@types/node/compatibility/disposable.d.ts +0 -14
  14. package/vendor/sdk/node_modules/@types/node/compatibility/index.d.ts +0 -9
  15. package/vendor/sdk/node_modules/@types/node/compatibility/indexable.d.ts +0 -20
  16. package/vendor/sdk/node_modules/@types/node/compatibility/iterators.d.ts +0 -20
  17. package/vendor/sdk/node_modules/@types/node/console.d.ts +0 -452
  18. package/vendor/sdk/node_modules/@types/node/constants.d.ts +0 -19
  19. package/vendor/sdk/node_modules/@types/node/crypto.d.ts +0 -4453
  20. package/vendor/sdk/node_modules/@types/node/dgram.d.ts +0 -596
  21. package/vendor/sdk/node_modules/@types/node/diagnostics_channel.d.ts +0 -546
  22. package/vendor/sdk/node_modules/@types/node/dns/promises.d.ts +0 -475
  23. package/vendor/sdk/node_modules/@types/node/dns.d.ts +0 -853
  24. package/vendor/sdk/node_modules/@types/node/dom-events.d.ts +0 -124
  25. package/vendor/sdk/node_modules/@types/node/domain.d.ts +0 -170
  26. package/vendor/sdk/node_modules/@types/node/events.d.ts +0 -819
  27. package/vendor/sdk/node_modules/@types/node/fs/promises.d.ts +0 -1205
  28. package/vendor/sdk/node_modules/@types/node/fs.d.ts +0 -4237
  29. package/vendor/sdk/node_modules/@types/node/globals.d.ts +0 -442
  30. package/vendor/sdk/node_modules/@types/node/globals.typedarray.d.ts +0 -21
  31. package/vendor/sdk/node_modules/@types/node/http.d.ts +0 -1839
  32. package/vendor/sdk/node_modules/@types/node/http2.d.ts +0 -2517
  33. package/vendor/sdk/node_modules/@types/node/https.d.ts +0 -544
  34. package/vendor/sdk/node_modules/@types/node/index.d.ts +0 -90
  35. package/vendor/sdk/node_modules/@types/node/inspector.d.ts +0 -2775
  36. package/vendor/sdk/node_modules/@types/node/module.d.ts +0 -291
  37. package/vendor/sdk/node_modules/@types/node/net.d.ts +0 -924
  38. package/vendor/sdk/node_modules/@types/node/os.d.ts +0 -473
  39. package/vendor/sdk/node_modules/@types/node/package.json +0 -225
  40. package/vendor/sdk/node_modules/@types/node/path.d.ts +0 -191
  41. package/vendor/sdk/node_modules/@types/node/perf_hooks.d.ts +0 -753
  42. package/vendor/sdk/node_modules/@types/node/process.d.ts +0 -1553
  43. package/vendor/sdk/node_modules/@types/node/punycode.d.ts +0 -117
  44. package/vendor/sdk/node_modules/@types/node/querystring.d.ts +0 -141
  45. package/vendor/sdk/node_modules/@types/node/readline/promises.d.ts +0 -154
  46. package/vendor/sdk/node_modules/@types/node/readline.d.ts +0 -715
  47. package/vendor/sdk/node_modules/@types/node/repl.d.ts +0 -430
  48. package/vendor/sdk/node_modules/@types/node/stream/consumers.d.ts +0 -12
  49. package/vendor/sdk/node_modules/@types/node/stream/promises.d.ts +0 -90
  50. package/vendor/sdk/node_modules/@types/node/stream/web.d.ts +0 -523
  51. package/vendor/sdk/node_modules/@types/node/stream.d.ts +0 -1731
  52. package/vendor/sdk/node_modules/@types/node/string_decoder.d.ts +0 -67
  53. package/vendor/sdk/node_modules/@types/node/test.d.ts +0 -1245
  54. package/vendor/sdk/node_modules/@types/node/timers/promises.d.ts +0 -93
  55. package/vendor/sdk/node_modules/@types/node/timers.d.ts +0 -126
  56. package/vendor/sdk/node_modules/@types/node/tls.d.ts +0 -1203
  57. package/vendor/sdk/node_modules/@types/node/trace_events.d.ts +0 -171
  58. package/vendor/sdk/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +0 -385
  59. package/vendor/sdk/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +0 -19
  60. package/vendor/sdk/node_modules/@types/node/ts5.6/index.d.ts +0 -90
  61. package/vendor/sdk/node_modules/@types/node/tty.d.ts +0 -206
  62. package/vendor/sdk/node_modules/@types/node/url.d.ts +0 -957
  63. package/vendor/sdk/node_modules/@types/node/util.d.ts +0 -2083
  64. package/vendor/sdk/node_modules/@types/node/v8.d.ts +0 -753
  65. package/vendor/sdk/node_modules/@types/node/vm.d.ts +0 -666
  66. package/vendor/sdk/node_modules/@types/node/wasi.d.ts +0 -160
  67. package/vendor/sdk/node_modules/@types/node/worker_threads.d.ts +0 -695
  68. package/vendor/sdk/node_modules/@types/node/zlib.d.ts +0 -517
  69. package/vendor/sdk/node_modules/undici-types/README.md +0 -6
  70. package/vendor/sdk/node_modules/undici-types/agent.d.ts +0 -31
  71. package/vendor/sdk/node_modules/undici-types/api.d.ts +0 -43
  72. package/vendor/sdk/node_modules/undici-types/balanced-pool.d.ts +0 -18
  73. package/vendor/sdk/node_modules/undici-types/cache.d.ts +0 -36
  74. package/vendor/sdk/node_modules/undici-types/client.d.ts +0 -97
  75. package/vendor/sdk/node_modules/undici-types/connector.d.ts +0 -34
  76. package/vendor/sdk/node_modules/undici-types/content-type.d.ts +0 -21
  77. package/vendor/sdk/node_modules/undici-types/cookies.d.ts +0 -28
  78. package/vendor/sdk/node_modules/undici-types/diagnostics-channel.d.ts +0 -67
  79. package/vendor/sdk/node_modules/undici-types/dispatcher.d.ts +0 -241
  80. package/vendor/sdk/node_modules/undici-types/errors.d.ts +0 -128
  81. package/vendor/sdk/node_modules/undici-types/fetch.d.ts +0 -209
  82. package/vendor/sdk/node_modules/undici-types/file.d.ts +0 -39
  83. package/vendor/sdk/node_modules/undici-types/filereader.d.ts +0 -54
  84. package/vendor/sdk/node_modules/undici-types/formdata.d.ts +0 -108
  85. package/vendor/sdk/node_modules/undici-types/global-dispatcher.d.ts +0 -9
  86. package/vendor/sdk/node_modules/undici-types/global-origin.d.ts +0 -7
  87. package/vendor/sdk/node_modules/undici-types/handlers.d.ts +0 -9
  88. package/vendor/sdk/node_modules/undici-types/header.d.ts +0 -4
  89. package/vendor/sdk/node_modules/undici-types/index.d.ts +0 -63
  90. package/vendor/sdk/node_modules/undici-types/interceptors.d.ts +0 -5
  91. package/vendor/sdk/node_modules/undici-types/mock-agent.d.ts +0 -50
  92. package/vendor/sdk/node_modules/undici-types/mock-client.d.ts +0 -25
  93. package/vendor/sdk/node_modules/undici-types/mock-errors.d.ts +0 -12
  94. package/vendor/sdk/node_modules/undici-types/mock-interceptor.d.ts +0 -93
  95. package/vendor/sdk/node_modules/undici-types/mock-pool.d.ts +0 -25
  96. package/vendor/sdk/node_modules/undici-types/package.json +0 -55
  97. package/vendor/sdk/node_modules/undici-types/patch.d.ts +0 -71
  98. package/vendor/sdk/node_modules/undici-types/pool-stats.d.ts +0 -19
  99. package/vendor/sdk/node_modules/undici-types/pool.d.ts +0 -28
  100. package/vendor/sdk/node_modules/undici-types/proxy-agent.d.ts +0 -30
  101. package/vendor/sdk/node_modules/undici-types/readable.d.ts +0 -61
  102. package/vendor/sdk/node_modules/undici-types/webidl.d.ts +0 -220
  103. package/vendor/sdk/node_modules/undici-types/websocket.d.ts +0 -131
@@ -1,171 +0,0 @@
1
- /**
2
- * The `trace_events` module provides a mechanism to centralize tracing information
3
- * generated by V8, Node.js core, and userspace code.
4
- *
5
- * Tracing can be enabled with the `--trace-event-categories` command-line flag
6
- * or by using the `trace_events` module. The `--trace-event-categories` flag
7
- * accepts a list of comma-separated category names.
8
- *
9
- * The available categories are:
10
- *
11
- * * `node`: An empty placeholder.
12
- * * `node.async_hooks`: Enables capture of detailed `async_hooks` trace data.
13
- * The `async_hooks` events have a unique `asyncId` and a special `triggerId` `triggerAsyncId` property.
14
- * * `node.bootstrap`: Enables capture of Node.js bootstrap milestones.
15
- * * `node.console`: Enables capture of `console.time()` and `console.count()` output.
16
- * * `node.dns.native`: Enables capture of trace data for DNS queries.
17
- * * `node.environment`: Enables capture of Node.js Environment milestones.
18
- * * `node.fs.sync`: Enables capture of trace data for file system sync methods.
19
- * * `node.perf`: Enables capture of `Performance API` measurements.
20
- * * `node.perf.usertiming`: Enables capture of only Performance API User Timing
21
- * measures and marks.
22
- * * `node.perf.timerify`: Enables capture of only Performance API timerify
23
- * measurements.
24
- * * `node.promises.rejections`: Enables capture of trace data tracking the number
25
- * of unhandled Promise rejections and handled-after-rejections.
26
- * * `node.vm.script`: Enables capture of trace data for the `vm` module's`runInNewContext()`, `runInContext()`, and `runInThisContext()` methods.
27
- * * `v8`: The `V8` events are GC, compiling, and execution related.
28
- *
29
- * By default the `node`, `node.async_hooks`, and `v8` categories are enabled.
30
- *
31
- * ```bash
32
- * node --trace-event-categories v8,node,node.async_hooks server.js
33
- * ```
34
- *
35
- * Prior versions of Node.js required the use of the `--trace-events-enabled`flag to enable trace events. This requirement has been removed. However, the`--trace-events-enabled` flag _may_ still be
36
- * used and will enable the`node`, `node.async_hooks`, and `v8` trace event categories by default.
37
- *
38
- * ```bash
39
- * node --trace-events-enabled
40
- *
41
- * # is equivalent to
42
- *
43
- * node --trace-event-categories v8,node,node.async_hooks
44
- * ```
45
- *
46
- * Alternatively, trace events may be enabled using the `trace_events` module:
47
- *
48
- * ```js
49
- * import trace_events from 'node:trace_events';
50
- * const tracing = trace_events.createTracing({ categories: ['node.perf'] });
51
- * tracing.enable(); // Enable trace event capture for the 'node.perf' category
52
- *
53
- * // do work
54
- *
55
- * tracing.disable(); // Disable trace event capture for the 'node.perf' category
56
- * ```
57
- *
58
- * Running Node.js with tracing enabled will produce log files that can be opened
59
- * in the [`chrome://tracing`](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool) tab of Chrome.
60
- *
61
- * The logging file is by default called `node_trace.${rotation}.log`, where`${rotation}` is an incrementing log-rotation id. The filepath pattern can
62
- * be specified with `--trace-event-file-pattern` that accepts a template
63
- * string that supports `${rotation}` and `${pid}`:
64
- *
65
- * ```bash
66
- * node --trace-event-categories v8 --trace-event-file-pattern '${pid}-${rotation}.log' server.js
67
- * ```
68
- *
69
- * To guarantee that the log file is properly generated after signal events like`SIGINT`, `SIGTERM`, or `SIGBREAK`, make sure to have the appropriate handlers
70
- * in your code, such as:
71
- *
72
- * ```js
73
- * process.on('SIGINT', function onSigint() {
74
- * console.info('Received SIGINT.');
75
- * process.exit(130); // Or applicable exit code depending on OS and signal
76
- * });
77
- * ```
78
- *
79
- * The tracing system uses the same time source
80
- * as the one used by `process.hrtime()`.
81
- * However the trace-event timestamps are expressed in microseconds,
82
- * unlike `process.hrtime()` which returns nanoseconds.
83
- *
84
- * The features from this module are not available in `Worker` threads.
85
- * @experimental
86
- * @see [source](https://github.com/nodejs/node/blob/v18.0.0/lib/trace_events.js)
87
- */
88
- declare module "trace_events" {
89
- /**
90
- * The `Tracing` object is used to enable or disable tracing for sets of
91
- * categories. Instances are created using the
92
- * `trace_events.createTracing()` method.
93
- *
94
- * When created, the `Tracing` object is disabled. Calling the
95
- * `tracing.enable()` method adds the categories to the set of enabled trace
96
- * event categories. Calling `tracing.disable()` will remove the categories
97
- * from the set of enabled trace event categories.
98
- */
99
- interface Tracing {
100
- /**
101
- * A comma-separated list of the trace event categories covered by this
102
- * `Tracing` object.
103
- */
104
- readonly categories: string;
105
- /**
106
- * Disables this `Tracing` object.
107
- *
108
- * Only trace event categories _not_ covered by other enabled `Tracing`
109
- * objects and _not_ specified by the `--trace-event-categories` flag
110
- * will be disabled.
111
- */
112
- disable(): void;
113
- /**
114
- * Enables this `Tracing` object for the set of categories covered by
115
- * the `Tracing` object.
116
- */
117
- enable(): void;
118
- /**
119
- * `true` only if the `Tracing` object has been enabled.
120
- */
121
- readonly enabled: boolean;
122
- }
123
- interface CreateTracingOptions {
124
- /**
125
- * An array of trace category names. Values included in the array are
126
- * coerced to a string when possible. An error will be thrown if the
127
- * value cannot be coerced.
128
- */
129
- categories: string[];
130
- }
131
- /**
132
- * Creates and returns a `Tracing` object for the given set of `categories`.
133
- *
134
- * ```js
135
- * import trace_events from 'node:trace_events';
136
- * const categories = ['node.perf', 'node.async_hooks'];
137
- * const tracing = trace_events.createTracing({ categories });
138
- * tracing.enable();
139
- * // do stuff
140
- * tracing.disable();
141
- * ```
142
- * @since v10.0.0
143
- * @return .
144
- */
145
- function createTracing(options: CreateTracingOptions): Tracing;
146
- /**
147
- * Returns a comma-separated list of all currently-enabled trace event
148
- * categories. The current set of enabled trace event categories is determined
149
- * by the _union_ of all currently-enabled `Tracing` objects and any categories
150
- * enabled using the `--trace-event-categories` flag.
151
- *
152
- * Given the file `test.js` below, the command`node --trace-event-categories node.perf test.js` will print`'node.async_hooks,node.perf'` to the console.
153
- *
154
- * ```js
155
- * import trace_events from 'node:trace_events';
156
- * const t1 = trace_events.createTracing({ categories: ['node.async_hooks'] });
157
- * const t2 = trace_events.createTracing({ categories: ['node.perf'] });
158
- * const t3 = trace_events.createTracing({ categories: ['v8'] });
159
- *
160
- * t1.enable();
161
- * t2.enable();
162
- *
163
- * console.log(trace_events.getEnabledCategories());
164
- * ```
165
- * @since v10.0.0
166
- */
167
- function getEnabledCategories(): string | undefined;
168
- }
169
- declare module "node:trace_events" {
170
- export * from "trace_events";
171
- }
@@ -1,385 +0,0 @@
1
- declare module "buffer" {
2
- global {
3
- interface BufferConstructor {
4
- // see ../buffer.d.ts for implementation shared with all TypeScript versions
5
-
6
- /**
7
- * Allocates a new buffer containing the given {str}.
8
- *
9
- * @param str String to store in buffer.
10
- * @param encoding encoding to use, optional. Default is 'utf8'
11
- * @deprecated since v10.0.0 - Use `Buffer.from(string[, encoding])` instead.
12
- */
13
- new(str: string, encoding?: BufferEncoding): Buffer;
14
- /**
15
- * Allocates a new buffer of {size} octets.
16
- *
17
- * @param size count of octets to allocate.
18
- * @deprecated since v10.0.0 - Use `Buffer.alloc()` instead (also see `Buffer.allocUnsafe()`).
19
- */
20
- new(size: number): Buffer;
21
- /**
22
- * Allocates a new buffer containing the given {array} of octets.
23
- *
24
- * @param array The octets to store.
25
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
26
- */
27
- new(array: Uint8Array): Buffer;
28
- /**
29
- * Produces a Buffer backed by the same allocated memory as
30
- * the given {ArrayBuffer}/{SharedArrayBuffer}.
31
- *
32
- * @param arrayBuffer The ArrayBuffer with which to share memory.
33
- * @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
34
- */
35
- new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
36
- /**
37
- * Allocates a new buffer containing the given {array} of octets.
38
- *
39
- * @param array The octets to store.
40
- * @deprecated since v10.0.0 - Use `Buffer.from(array)` instead.
41
- */
42
- new(array: readonly any[]): Buffer;
43
- /**
44
- * Copies the passed {buffer} data onto a new {Buffer} instance.
45
- *
46
- * @param buffer The buffer to copy.
47
- * @deprecated since v10.0.0 - Use `Buffer.from(buffer)` instead.
48
- */
49
- new(buffer: Buffer): Buffer;
50
- /**
51
- * Allocates a new `Buffer` using an `array` of bytes in the range `0` – `255`.
52
- * Array entries outside that range will be truncated to fit into it.
53
- *
54
- * ```js
55
- * import { Buffer } from 'node:buffer';
56
- *
57
- * // Creates a new Buffer containing the UTF-8 bytes of the string 'buffer'.
58
- * const buf = Buffer.from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);
59
- * ```
60
- *
61
- * If `array` is an `Array`\-like object (that is, one with a `length` property of
62
- * type `number`), it is treated as if it is an array, unless it is a `Buffer` or
63
- * 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()`.
64
- *
65
- * A `TypeError` will be thrown if `array` is not an `Array` or another type
66
- * appropriate for `Buffer.from()` variants.
67
- *
68
- * `Buffer.from(array)` and `Buffer.from(string)` may also use the internal`Buffer` pool like `Buffer.allocUnsafe()` does.
69
- * @since v5.10.0
70
- */
71
- from(
72
- arrayBuffer: WithImplicitCoercion<ArrayBuffer | SharedArrayBuffer>,
73
- byteOffset?: number,
74
- length?: number,
75
- ): Buffer;
76
- /**
77
- * Creates a new Buffer using the passed {data}
78
- * @param data data to create a new Buffer
79
- */
80
- from(data: Uint8Array | readonly number[]): Buffer;
81
- from(data: WithImplicitCoercion<Uint8Array | readonly number[] | string>): Buffer;
82
- /**
83
- * Creates a new Buffer containing the given JavaScript string {str}.
84
- * If provided, the {encoding} parameter identifies the character encoding.
85
- * If not provided, {encoding} defaults to 'utf8'.
86
- */
87
- from(
88
- str:
89
- | WithImplicitCoercion<string>
90
- | {
91
- [Symbol.toPrimitive](hint: "string"): string;
92
- },
93
- encoding?: BufferEncoding,
94
- ): Buffer;
95
- /**
96
- * Creates a new Buffer using the passed {data}
97
- * @param values to create a new Buffer
98
- */
99
- of(...items: number[]): Buffer;
100
- /**
101
- * Returns a new `Buffer` which is the result of concatenating all the `Buffer` instances in the `list` together.
102
- *
103
- * If the list has no items, or if the `totalLength` is 0, then a new zero-length `Buffer` is returned.
104
- *
105
- * If `totalLength` is not provided, it is calculated from the `Buffer` instances
106
- * in `list` by adding their lengths.
107
- *
108
- * If `totalLength` is provided, it is coerced to an unsigned integer. If the
109
- * combined length of the `Buffer`s in `list` exceeds `totalLength`, the result is
110
- * truncated to `totalLength`.
111
- *
112
- * ```js
113
- * import { Buffer } from 'node:buffer';
114
- *
115
- * // Create a single `Buffer` from a list of three `Buffer` instances.
116
- *
117
- * const buf1 = Buffer.alloc(10);
118
- * const buf2 = Buffer.alloc(14);
119
- * const buf3 = Buffer.alloc(18);
120
- * const totalLength = buf1.length + buf2.length + buf3.length;
121
- *
122
- * console.log(totalLength);
123
- * // Prints: 42
124
- *
125
- * const bufA = Buffer.concat([buf1, buf2, buf3], totalLength);
126
- *
127
- * console.log(bufA);
128
- * // Prints: <Buffer 00 00 00 00 ...>
129
- * console.log(bufA.length);
130
- * // Prints: 42
131
- * ```
132
- *
133
- * `Buffer.concat()` may also use the internal `Buffer` pool like `Buffer.allocUnsafe()` does.
134
- * @since v0.7.11
135
- * @param list List of `Buffer` or {@link Uint8Array} instances to concatenate.
136
- * @param totalLength Total length of the `Buffer` instances in `list` when concatenated.
137
- */
138
- concat(list: readonly Uint8Array[], totalLength?: number): Buffer;
139
- /**
140
- * Copies the underlying memory of `view` into a new `Buffer`.
141
- *
142
- * ```js
143
- * const u16 = new Uint16Array([0, 0xffff]);
144
- * const buf = Buffer.copyBytesFrom(u16, 1, 1);
145
- * u16[1] = 0;
146
- * console.log(buf.length); // 2
147
- * console.log(buf[0]); // 255
148
- * console.log(buf[1]); // 255
149
- * ```
150
- * @since v18.16.0
151
- * @param view The {TypedArray} to copy.
152
- * @param [offset=0] The starting offset within `view`.
153
- * @param [length=view.length - offset] The number of elements from `view` to copy.
154
- */
155
- copyBytesFrom(view: NodeJS.TypedArray, offset?: number, length?: number): Buffer;
156
- /**
157
- * Allocates a new `Buffer` of `size` bytes. If `fill` is `undefined`, the`Buffer` will be zero-filled.
158
- *
159
- * ```js
160
- * import { Buffer } from 'node:buffer';
161
- *
162
- * const buf = Buffer.alloc(5);
163
- *
164
- * console.log(buf);
165
- * // Prints: <Buffer 00 00 00 00 00>
166
- * ```
167
- *
168
- * If `size` is larger than {@link constants.MAX_LENGTH} or smaller than 0, `ERR_OUT_OF_RANGE` is thrown.
169
- *
170
- * If `fill` is specified, the allocated `Buffer` will be initialized by calling `buf.fill(fill)`.
171
- *
172
- * ```js
173
- * import { Buffer } from 'node:buffer';
174
- *
175
- * const buf = Buffer.alloc(5, 'a');
176
- *
177
- * console.log(buf);
178
- * // Prints: <Buffer 61 61 61 61 61>
179
- * ```
180
- *
181
- * If both `fill` and `encoding` are specified, the allocated `Buffer` will be
182
- * initialized by calling `buf.fill(fill, encoding)`.
183
- *
184
- * ```js
185
- * import { Buffer } from 'node:buffer';
186
- *
187
- * const buf = Buffer.alloc(11, 'aGVsbG8gd29ybGQ=', 'base64');
188
- *
189
- * console.log(buf);
190
- * // Prints: <Buffer 68 65 6c 6c 6f 20 77 6f 72 6c 64>
191
- * ```
192
- *
193
- * Calling `Buffer.alloc()` can be measurably slower than the alternative `Buffer.allocUnsafe()` but ensures that the newly created `Buffer` instance
194
- * contents will never contain sensitive data from previous allocations, including
195
- * data that might not have been allocated for `Buffer`s.
196
- *
197
- * A `TypeError` will be thrown if `size` is not a number.
198
- * @since v5.10.0
199
- * @param size The desired length of the new `Buffer`.
200
- * @param [fill=0] A value to pre-fill the new `Buffer` with.
201
- * @param [encoding='utf8'] If `fill` is a string, this is its encoding.
202
- */
203
- alloc(size: number, fill?: string | Uint8Array | number, encoding?: BufferEncoding): Buffer;
204
- /**
205
- * 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.
206
- *
207
- * The underlying memory for `Buffer` instances created in this way is _not_
208
- * _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.
209
- *
210
- * ```js
211
- * import { Buffer } from 'node:buffer';
212
- *
213
- * const buf = Buffer.allocUnsafe(10);
214
- *
215
- * console.log(buf);
216
- * // Prints (contents may vary): <Buffer a0 8b 28 3f 01 00 00 00 50 32>
217
- *
218
- * buf.fill(0);
219
- *
220
- * console.log(buf);
221
- * // Prints: <Buffer 00 00 00 00 00 00 00 00 00 00>
222
- * ```
223
- *
224
- * A `TypeError` will be thrown if `size` is not a number.
225
- *
226
- * The `Buffer` module pre-allocates an internal `Buffer` instance of
227
- * size `Buffer.poolSize` that is used as a pool for the fast allocation of new `Buffer` instances created using `Buffer.allocUnsafe()`, `Buffer.from(array)`,
228
- * and `Buffer.concat()` only when `size` is less than `Buffer.poolSize >> 1` (floor of `Buffer.poolSize` divided by two).
229
- *
230
- * Use of this pre-allocated internal memory pool is a key difference between
231
- * calling `Buffer.alloc(size, fill)` vs. `Buffer.allocUnsafe(size).fill(fill)`.
232
- * 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
233
- * than or equal to half `Buffer.poolSize`. The
234
- * difference is subtle but can be important when an application requires the
235
- * additional performance that `Buffer.allocUnsafe()` provides.
236
- * @since v5.10.0
237
- * @param size The desired length of the new `Buffer`.
238
- */
239
- allocUnsafe(size: number): Buffer;
240
- /**
241
- * 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
242
- * `size` is 0.
243
- *
244
- * The underlying memory for `Buffer` instances created in this way is _not_
245
- * _initialized_. The contents of the newly created `Buffer` are unknown and _may contain sensitive data_. Use `buf.fill(0)` to initialize
246
- * such `Buffer` instances with zeroes.
247
- *
248
- * When using `Buffer.allocUnsafe()` to allocate new `Buffer` instances,
249
- * allocations under 4 KiB are sliced from a single pre-allocated `Buffer`. This
250
- * allows applications to avoid the garbage collection overhead of creating many
251
- * individually allocated `Buffer` instances. This approach improves both
252
- * performance and memory usage by eliminating the need to track and clean up as
253
- * many individual `ArrayBuffer` objects.
254
- *
255
- * However, in the case where a developer may need to retain a small chunk of
256
- * memory from a pool for an indeterminate amount of time, it may be appropriate
257
- * to create an un-pooled `Buffer` instance using `Buffer.allocUnsafeSlow()` and
258
- * then copying out the relevant bits.
259
- *
260
- * ```js
261
- * import { Buffer } from 'node:buffer';
262
- *
263
- * // Need to keep around a few small chunks of memory.
264
- * const store = [];
265
- *
266
- * socket.on('readable', () => {
267
- * let data;
268
- * while (null !== (data = readable.read())) {
269
- * // Allocate for retained data.
270
- * const sb = Buffer.allocUnsafeSlow(10);
271
- *
272
- * // Copy the data into the new allocation.
273
- * data.copy(sb, 0, 0, 10);
274
- *
275
- * store.push(sb);
276
- * }
277
- * });
278
- * ```
279
- *
280
- * A `TypeError` will be thrown if `size` is not a number.
281
- * @since v5.12.0
282
- * @param size The desired length of the new `Buffer`.
283
- */
284
- allocUnsafeSlow(size: number): Buffer;
285
- }
286
- interface Buffer extends Uint8Array {
287
- // see ../buffer.d.ts for implementation shared with all TypeScript versions
288
-
289
- /**
290
- * Returns a new `Buffer` that references the same memory as the original, but
291
- * offset and cropped by the `start` and `end` indices.
292
- *
293
- * This method is not compatible with the `Uint8Array.prototype.slice()`,
294
- * which is a superclass of `Buffer`. To copy the slice, use`Uint8Array.prototype.slice()`.
295
- *
296
- * ```js
297
- * import { Buffer } from 'node:buffer';
298
- *
299
- * const buf = Buffer.from('buffer');
300
- *
301
- * const copiedBuf = Uint8Array.prototype.slice.call(buf);
302
- * copiedBuf[0]++;
303
- * console.log(copiedBuf.toString());
304
- * // Prints: cuffer
305
- *
306
- * console.log(buf.toString());
307
- * // Prints: buffer
308
- *
309
- * // With buf.slice(), the original buffer is modified.
310
- * const notReallyCopiedBuf = buf.slice();
311
- * notReallyCopiedBuf[0]++;
312
- * console.log(notReallyCopiedBuf.toString());
313
- * // Prints: cuffer
314
- * console.log(buf.toString());
315
- * // Also prints: cuffer (!)
316
- * ```
317
- * @since v0.3.0
318
- * @deprecated Use `subarray` instead.
319
- * @param [start=0] Where the new `Buffer` will start.
320
- * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
321
- */
322
- slice(start?: number, end?: number): Buffer;
323
- /**
324
- * Returns a new `Buffer` that references the same memory as the original, but
325
- * offset and cropped by the `start` and `end` indices.
326
- *
327
- * Specifying `end` greater than `buf.length` will return the same result as
328
- * that of `end` equal to `buf.length`.
329
- *
330
- * This method is inherited from [`TypedArray.prototype.subarray()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypedArray/subarray).
331
- *
332
- * Modifying the new `Buffer` slice will modify the memory in the original `Buffer`because the allocated memory of the two objects overlap.
333
- *
334
- * ```js
335
- * import { Buffer } from 'node:buffer';
336
- *
337
- * // Create a `Buffer` with the ASCII alphabet, take a slice, and modify one byte
338
- * // from the original `Buffer`.
339
- *
340
- * const buf1 = Buffer.allocUnsafe(26);
341
- *
342
- * for (let i = 0; i < 26; i++) {
343
- * // 97 is the decimal ASCII value for 'a'.
344
- * buf1[i] = i + 97;
345
- * }
346
- *
347
- * const buf2 = buf1.subarray(0, 3);
348
- *
349
- * console.log(buf2.toString('ascii', 0, buf2.length));
350
- * // Prints: abc
351
- *
352
- * buf1[0] = 33;
353
- *
354
- * console.log(buf2.toString('ascii', 0, buf2.length));
355
- * // Prints: !bc
356
- * ```
357
- *
358
- * Specifying negative indexes causes the slice to be generated relative to the
359
- * end of `buf` rather than the beginning.
360
- *
361
- * ```js
362
- * import { Buffer } from 'node:buffer';
363
- *
364
- * const buf = Buffer.from('buffer');
365
- *
366
- * console.log(buf.subarray(-6, -1).toString());
367
- * // Prints: buffe
368
- * // (Equivalent to buf.subarray(0, 5).)
369
- *
370
- * console.log(buf.subarray(-6, -2).toString());
371
- * // Prints: buff
372
- * // (Equivalent to buf.subarray(0, 4).)
373
- *
374
- * console.log(buf.subarray(-5, -2).toString());
375
- * // Prints: uff
376
- * // (Equivalent to buf.subarray(1, 4).)
377
- * ```
378
- * @since v3.0.0
379
- * @param [start=0] Where the new `Buffer` will start.
380
- * @param [end=buf.length] Where the new `Buffer` will end (not inclusive).
381
- */
382
- subarray(start?: number, end?: number): Buffer;
383
- }
384
- }
385
- }
@@ -1,19 +0,0 @@
1
- export {}; // Make this a module
2
-
3
- declare global {
4
- namespace NodeJS {
5
- type TypedArray =
6
- | Uint8Array
7
- | Uint8ClampedArray
8
- | Uint16Array
9
- | Uint32Array
10
- | Int8Array
11
- | Int16Array
12
- | Int32Array
13
- | BigUint64Array
14
- | BigInt64Array
15
- | Float32Array
16
- | Float64Array;
17
- type ArrayBufferView = TypedArray | DataView;
18
- }
19
- }
@@ -1,90 +0,0 @@
1
- /**
2
- * License for programmatically and manually incorporated
3
- * documentation aka. `JSDoc` from https://github.com/nodejs/node/tree/master/doc
4
- *
5
- * Copyright Node.js contributors. All rights reserved.
6
- * Permission is hereby granted, free of charge, to any person obtaining a copy
7
- * of this software and associated documentation files (the "Software"), to
8
- * deal in the Software without restriction, including without limitation the
9
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
- * sell copies of the Software, and to permit persons to whom the Software is
11
- * furnished to do so, subject to the following conditions:
12
- *
13
- * The above copyright notice and this permission notice shall be included in
14
- * all copies or substantial portions of the Software.
15
- *
16
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
- * IN THE SOFTWARE.
23
- */
24
-
25
- // NOTE: These definitions support Node.js and TypeScript 4.9 through 5.6.
26
-
27
- // Reference required TypeScript libs:
28
- /// <reference lib="es2020" />
29
-
30
- // TypeScript backwards-compatibility definitions:
31
- /// <reference path="../compatibility/index.d.ts" />
32
-
33
- // Definitions specific to TypeScript 4.9 through 5.6:
34
- /// <reference path="./globals.typedarray.d.ts" />
35
- /// <reference path="./buffer.buffer.d.ts" />
36
-
37
- // Definitions for Node.js modules that are not specific to any version of TypeScript:
38
- /// <reference path="../globals.d.ts" />
39
- /// <reference path="../assert.d.ts" />
40
- /// <reference path="../assert/strict.d.ts" />
41
- /// <reference path="../async_hooks.d.ts" />
42
- /// <reference path="../buffer.d.ts" />
43
- /// <reference path="../child_process.d.ts" />
44
- /// <reference path="../cluster.d.ts" />
45
- /// <reference path="../console.d.ts" />
46
- /// <reference path="../constants.d.ts" />
47
- /// <reference path="../crypto.d.ts" />
48
- /// <reference path="../dgram.d.ts" />
49
- /// <reference path="../diagnostics_channel.d.ts" />
50
- /// <reference path="../dns.d.ts" />
51
- /// <reference path="../dns/promises.d.ts" />
52
- /// <reference path="../dns/promises.d.ts" />
53
- /// <reference path="../domain.d.ts" />
54
- /// <reference path="../dom-events.d.ts" />
55
- /// <reference path="../events.d.ts" />
56
- /// <reference path="../fs.d.ts" />
57
- /// <reference path="../fs/promises.d.ts" />
58
- /// <reference path="../http.d.ts" />
59
- /// <reference path="../http2.d.ts" />
60
- /// <reference path="../https.d.ts" />
61
- /// <reference path="../inspector.d.ts" />
62
- /// <reference path="../module.d.ts" />
63
- /// <reference path="../net.d.ts" />
64
- /// <reference path="../os.d.ts" />
65
- /// <reference path="../path.d.ts" />
66
- /// <reference path="../perf_hooks.d.ts" />
67
- /// <reference path="../process.d.ts" />
68
- /// <reference path="../punycode.d.ts" />
69
- /// <reference path="../querystring.d.ts" />
70
- /// <reference path="../readline.d.ts" />
71
- /// <reference path="../readline/promises.d.ts" />
72
- /// <reference path="../repl.d.ts" />
73
- /// <reference path="../stream.d.ts" />
74
- /// <reference path="../stream/promises.d.ts" />
75
- /// <reference path="../stream/consumers.d.ts" />
76
- /// <reference path="../stream/web.d.ts" />
77
- /// <reference path="../string_decoder.d.ts" />
78
- /// <reference path="../test.d.ts" />
79
- /// <reference path="../timers.d.ts" />
80
- /// <reference path="../timers/promises.d.ts" />
81
- /// <reference path="../tls.d.ts" />
82
- /// <reference path="../trace_events.d.ts" />
83
- /// <reference path="../tty.d.ts" />
84
- /// <reference path="../url.d.ts" />
85
- /// <reference path="../util.d.ts" />
86
- /// <reference path="../v8.d.ts" />
87
- /// <reference path="../vm.d.ts" />
88
- /// <reference path="../wasi.d.ts" />
89
- /// <reference path="../worker_threads.d.ts" />
90
- /// <reference path="../zlib.d.ts" />