@tothalex/cloud 0.0.40

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.
package/src/util.d.ts ADDED
@@ -0,0 +1,240 @@
1
+ /**
2
+ * The `util` module supports the needs of LLRT internal APIs. Many of the
3
+ * utilities are useful for application and module developers as well. To access
4
+ * it:
5
+ *
6
+ * ```js
7
+ * import util from 'util';
8
+ * ```
9
+ * @see [source](https://github.com/nodejs/node/blob/v22.x/lib/util.js)
10
+ */
11
+ declare module "util" {
12
+ /**
13
+ * The `util.format()` method returns a formatted string using the first argument
14
+ * as a `printf`-like format string which can contain zero or more format
15
+ * specifiers. Each specifier is replaced with the converted value from the
16
+ * corresponding argument. Supported specifiers are:
17
+ *
18
+ * If a specifier does not have a corresponding argument, it is not replaced:
19
+ *
20
+ * ```js
21
+ * util.format('%s:%s', 'foo');
22
+ * // Returns: 'foo:%s'
23
+ * ```
24
+ *
25
+ * Values that are not part of the format string are formatted using `util.inspect()` if their type is not `string`.
26
+ *
27
+ * If there are more arguments passed to the `util.format()` method than the
28
+ * number of specifiers, the extra arguments are concatenated to the returned
29
+ * string, separated by spaces:
30
+ *
31
+ * ```js
32
+ * util.format('%s:%s', 'foo', 'bar', 'baz');
33
+ * // Returns: 'foo:bar baz'
34
+ * ```
35
+ *
36
+ * If the first argument does not contain a valid format specifier, `util.format()` returns a string that is the concatenation of all arguments separated by spaces:
37
+ *
38
+ * ```js
39
+ * util.format(1, 2, 3);
40
+ * // Returns: '1 2 3'
41
+ * ```
42
+ *
43
+ * If only one argument is passed to `util.format()`, it is returned as it is
44
+ * without any formatting:
45
+ *
46
+ * ```js
47
+ * util.format('%% %s');
48
+ * // Returns: '%% %s'
49
+ * ```
50
+ *
51
+ * `util.format()` is a synchronous method that is intended as a debugging tool.
52
+ * Some input values can have a significant performance overhead that can block the
53
+ * event loop. Use this function with care and never in a hot code path.
54
+ * @param format A `printf`-like format string.
55
+ */
56
+ export function format(format?: any, ...param: any[]): string;
57
+ /**
58
+ * Usage of `util.inherits()` is discouraged. Please use the ES6 `class` and `extends` keywords to get language level inheritance support. Also note
59
+ * that the two styles are [semantically incompatible](https://github.com/nodejs/node/issues/4179).
60
+ *
61
+ * Inherit the prototype methods from one [constructor](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor) into another. The
62
+ * prototype of `constructor` will be set to a new object created from `superConstructor`.
63
+ *
64
+ * This mainly adds some input validation on top of`Object.setPrototypeOf(constructor.prototype, superConstructor.prototype)`.
65
+ * As an additional convenience, `superConstructor` will be accessible
66
+ * through the `constructor.super_` property.
67
+ *
68
+ * ```js
69
+ * import util from 'util';
70
+ * import EventEmitter from 'events';
71
+ *
72
+ * function MyStream() {
73
+ * EventEmitter.call(this);
74
+ * }
75
+ *
76
+ * util.inherits(MyStream, EventEmitter);
77
+ *
78
+ * MyStream.prototype.write = function(data) {
79
+ * this.emit('data', data);
80
+ * };
81
+ *
82
+ * const stream = new MyStream();
83
+ *
84
+ * console.log(stream instanceof EventEmitter); // true
85
+ * console.log(MyStream.super_ === EventEmitter); // true
86
+ *
87
+ * stream.on('data', (data) => {
88
+ * console.log(`Received data: "${data}"`);
89
+ * });
90
+ * stream.write('It works!'); // Received data: "It works!"
91
+ * ```
92
+ *
93
+ * ES6 example using `class` and `extends`:
94
+ *
95
+ * ```js
96
+ * import EventEmitter from 'events';
97
+ *
98
+ * class MyStream extends EventEmitter {
99
+ * write(data) {
100
+ * this.emit('data', data);
101
+ * }
102
+ * }
103
+ *
104
+ * const stream = new MyStream();
105
+ *
106
+ * stream.on('data', (data) => {
107
+ * console.log(`Received data: "${data}"`);
108
+ * });
109
+ * stream.write('With ES6');
110
+ * ```
111
+ * @legacy Use ES2015 class syntax and `extends` keyword instead.
112
+ */
113
+ export function inherits(
114
+ constructor: unknown,
115
+ superConstructor: unknown
116
+ ): void;
117
+ /**
118
+ * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextDecoder` API.
119
+ *
120
+ * ```js
121
+ * const decoder = new TextDecoder();
122
+ * const u8arr = new Uint8Array([72, 101, 108, 108, 111]);
123
+ * console.log(decoder.decode(u8arr)); // Hello
124
+ * ```
125
+ */
126
+ export class TextDecoder {
127
+ /**
128
+ * The encoding supported by the `TextDecoder` instance.
129
+ */
130
+ readonly encoding: string;
131
+ /**
132
+ * The value will be `true` if decoding errors result in a `TypeError` being
133
+ * thrown.
134
+ */
135
+ readonly fatal: boolean;
136
+ /**
137
+ * The value will be `true` if the decoding result will include the byte order
138
+ * mark.
139
+ */
140
+ readonly ignoreBOM: boolean;
141
+ constructor(
142
+ encoding?: string,
143
+ options?: {
144
+ fatal?: boolean | undefined;
145
+ ignoreBOM?: boolean | undefined;
146
+ }
147
+ );
148
+ /**
149
+ * Decodes the `input` and returns a string. If `options.stream` is `true`, any
150
+ * incomplete byte sequences occurring at the end of the `input` are buffered
151
+ * internally and emitted after the next call to `textDecoder.decode()`.
152
+ *
153
+ * If `textDecoder.fatal` is `true`, decoding errors that occur will result in a `TypeError` being thrown.
154
+ * @param input An `ArrayBuffer`, `DataView`, or `TypedArray` instance containing the encoded data.
155
+ */
156
+ decode(
157
+ input?: QuickJS.ArrayBufferView | ArrayBuffer | null,
158
+ options?: {
159
+ stream?: boolean | undefined;
160
+ }
161
+ ): string;
162
+ }
163
+ export interface EncodeIntoResult {
164
+ /**
165
+ * The read Unicode code units of input.
166
+ */
167
+ read: number;
168
+ /**
169
+ * The written UTF-8 bytes of output.
170
+ */
171
+ written: number;
172
+ }
173
+ //// TextEncoder/Decoder
174
+ /**
175
+ * An implementation of the [WHATWG Encoding Standard](https://encoding.spec.whatwg.org/) `TextEncoder` API. All
176
+ * instances of `TextEncoder` only support UTF-8 encoding.
177
+ *
178
+ * ```js
179
+ * const encoder = new TextEncoder();
180
+ * const uint8array = encoder.encode('this is some data');
181
+ * ```
182
+ *
183
+ * The `TextEncoder` class is also available on the global object.
184
+ */
185
+ export class TextEncoder {
186
+ /**
187
+ * The encoding supported by the `TextEncoder` instance. Always set to `'utf-8'`.
188
+ */
189
+ readonly encoding: string;
190
+ /**
191
+ * UTF-8 encodes the `input` string and returns a `Uint8Array` containing the
192
+ * encoded bytes.
193
+ * @param [input='an empty string'] The text to encode.
194
+ */
195
+ encode(input?: string): Uint8Array;
196
+ /**
197
+ * UTF-8 encodes the `src` string to the `dest` Uint8Array and returns an object
198
+ * containing the read Unicode code units and written UTF-8 bytes.
199
+ *
200
+ * ```js
201
+ * const encoder = new TextEncoder();
202
+ * const src = 'this is some data';
203
+ * const dest = new Uint8Array(10);
204
+ * const { read, written } = encoder.encodeInto(src, dest);
205
+ * ```
206
+ * @param src The text to encode.
207
+ * @param dest The array to hold the encode result.
208
+ */
209
+ encodeInto(src: string, dest: Uint8Array): EncodeIntoResult;
210
+ }
211
+ import {
212
+ TextDecoder as _TextDecoder,
213
+ TextEncoder as _TextEncoder,
214
+ } from "util";
215
+ global {
216
+ /**
217
+ * `TextDecoder` class is a global reference for `import { TextDecoder } from 'util'`
218
+ * https://nodejs.org/api/globals.html#textdecoder
219
+ */
220
+ var TextDecoder: typeof globalThis extends {
221
+ onmessage: any;
222
+ TextDecoder: infer TextDecoder;
223
+ }
224
+ ? TextDecoder
225
+ : typeof _TextDecoder;
226
+ /**
227
+ * `TextEncoder` class is a global reference for `import { TextEncoder } from 'util'`
228
+ * https://nodejs.org/api/globals.html#textencoder
229
+ */
230
+ var TextEncoder: typeof globalThis extends {
231
+ onmessage: any;
232
+ TextEncoder: infer TextEncoder;
233
+ }
234
+ ? TextEncoder
235
+ : typeof _TextEncoder;
236
+ }
237
+ }
238
+ declare module "util" {
239
+ export * from "util";
240
+ }
package/src/zlib.d.ts ADDED
@@ -0,0 +1,149 @@
1
+ /**
2
+ * The `zlib` module provides compression functionality implemented using
3
+ * Gzip, Deflate/Inflate, Brotli and Zstandard.
4
+ *
5
+ * To access it:
6
+ *
7
+ * ```js
8
+ * import * as zlib from 'zlib';
9
+ * ```
10
+ *
11
+ * It is possible to compress or decompress data in a single step:
12
+ *
13
+ * ```js
14
+ * mport * as zlib from 'zlib';
15
+ *
16
+ * const input = '.................................';
17
+ * zlib.deflate(input, (err, buffer) => {
18
+ * if (err) {
19
+ * console.error('An error occurred:', err);
20
+ * process.exitCode = 1;
21
+ * }
22
+ * console.log(buffer.toString('base64'));
23
+ * });
24
+ *
25
+ * const buffer = Buffer.from('CwWASGVsbG8gV29ybGQD', 'base64');
26
+ * zlib.brotliDecompress(buffer, (err, buffer) => {
27
+ * if (err) {
28
+ * console.error('An error occurred:', err);
29
+ * process.exitCode = 1;
30
+ * }
31
+ * console.log(buffer.toString());
32
+ * });
33
+ *
34
+ * ```
35
+ */
36
+ declare module "zlib" {
37
+ import { Buffer } from "buffer";
38
+
39
+ interface ZlibOptions {
40
+ level?: number | undefined; // compression only
41
+ }
42
+ interface ZstdOptions {
43
+ level?: number | undefined; // compression only
44
+ }
45
+ type InputType = string | ArrayBuffer | QuickJS.ArrayBufferView;
46
+ type CompressCallback = (error: Error | null, result: Buffer) => void;
47
+
48
+ /**
49
+ * Compress a chunk of data with `Deflate`.
50
+ */
51
+ function deflate(buf: InputType, callback: CompressCallback): void;
52
+ function deflate(
53
+ buf: InputType,
54
+ options: ZlibOptions,
55
+ callback: CompressCallback
56
+ ): void;
57
+ /**
58
+ * Compress a chunk of data with `Deflate`.
59
+ */
60
+ function deflateSync(buf: InputType, options?: ZlibOptions): Buffer;
61
+
62
+ /**
63
+ * Compress a chunk of data with `DeflateRaw`.
64
+ */
65
+ function deflateRaw(buf: InputType, callback: CompressCallback): void;
66
+ function deflateRaw(
67
+ buf: InputType,
68
+ options: ZlibOptions,
69
+ callback: CompressCallback
70
+ ): void;
71
+ /**
72
+ * Compress a chunk of data with `DeflateRaw`.
73
+ */
74
+ function deflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
75
+
76
+ /**
77
+ * Compress a chunk of data with `Gzip`.
78
+ */
79
+ function gzip(buf: InputType, callback: CompressCallback): void;
80
+ function gzip(
81
+ buf: InputType,
82
+ options: ZlibOptions,
83
+ callback: CompressCallback
84
+ ): void;
85
+ /**
86
+ * Compress a chunk of data with `Gzip`.
87
+ */
88
+ function gzipSync(buf: InputType, options?: ZlibOptions): Buffer;
89
+
90
+ /**
91
+ * Decompress a chunk of data with `Inflate`.
92
+ */
93
+ function inflate(buf: InputType, callback: CompressCallback): void;
94
+ function inflate(
95
+ buf: InputType,
96
+ options: ZlibOptions,
97
+ callback: CompressCallback
98
+ ): void;
99
+ /**
100
+ * Decompress a chunk of data with `Inflate`.
101
+ */
102
+ function inflateSync(buf: InputType, options?: ZlibOptions): Buffer;
103
+
104
+ /**
105
+ * Decompress a chunk of data with `InflateRaw`.
106
+ */
107
+ function inflateRaw(buf: InputType, callback: CompressCallback): void;
108
+ function inflateRaw(
109
+ buf: InputType,
110
+ options: ZlibOptions,
111
+ callback: CompressCallback
112
+ ): void;
113
+ /**
114
+ * Decompress a chunk of data with `InflateRaw`.
115
+ */
116
+ function inflateRawSync(buf: InputType, options?: ZlibOptions): Buffer;
117
+
118
+ /**
119
+ * Decompress a chunk of data with `Gunzip`.
120
+ */
121
+ function gunzip(buf: InputType, callback: CompressCallback): void;
122
+ function gunzip(
123
+ buf: InputType,
124
+ options: ZlibOptions,
125
+ callback: CompressCallback
126
+ ): void;
127
+ /**
128
+ * Decompress a chunk of data with `Gunzip`.
129
+ */
130
+ function gunzipSync(buf: InputType, options?: ZlibOptions): Buffer;
131
+
132
+ /**
133
+ * Compress a chunk of data with `BrotliCompress`.
134
+ */
135
+ function brotliCompress(buf: InputType, callback: CompressCallback): void;
136
+ /**
137
+ * Compress a chunk of data with `BrotliCompress`.
138
+ */
139
+ function brotliCompressSync(buf: InputType): Buffer;
140
+
141
+ /**
142
+ * Decompress a chunk of data with `BrotliDecompress`.
143
+ */
144
+ function brotliDecompress(buf: InputType, callback: CompressCallback): void;
145
+ /**
146
+ * Decompress a chunk of data with `BrotliDecompress`.
147
+ */
148
+ function brotliDecompressSync(buf: InputType): Buffer;
149
+ }