@evobug_com/safe-ts-feature-node 0.1.0 → 0.3.0
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/README.md +4 -2
- package/node-api.json +48 -85
- package/package.json +162 -3
- package/safe/buffer.d.ts +155 -0
- package/safe/buffer.js +582 -0
- package/safe/child_process.d.ts +32 -0
- package/safe/child_process.js +21 -0
- package/safe/core.d.ts +36 -0
- package/safe/core.js +25 -0
- package/safe/crypto.d.ts +105 -0
- package/safe/crypto.js +205 -0
- package/safe/dgram.d.ts +26 -0
- package/safe/dgram.js +76 -0
- package/safe/dns/promises.d.ts +136 -0
- package/safe/dns/promises.js +262 -0
- package/safe/errors.d.ts +155 -0
- package/safe/errors.js +32 -0
- package/safe/events.d.ts +11 -0
- package/safe/events.js +14 -0
- package/safe/ffi.d.ts +23 -0
- package/safe/ffi.js +57 -0
- package/safe/fs/promises.d.ts +168 -0
- package/safe/fs/promises.js +366 -0
- package/safe/fs.d.ts +201 -0
- package/safe/fs.js +422 -0
- package/safe/globals.d.ts +87 -0
- package/safe/globals.js +232 -0
- package/safe/http.d.ts +34 -0
- package/safe/http.js +85 -0
- package/safe/http2.d.ts +26 -0
- package/safe/http2.js +61 -0
- package/safe/https.d.ts +21 -0
- package/safe/https.js +29 -0
- package/safe/inspector/promises.d.ts +200 -0
- package/safe/inspector/promises.js +13 -0
- package/safe/inspector.d.ts +8 -0
- package/safe/inspector.js +13 -0
- package/safe/module.d.ts +21 -0
- package/safe/module.js +45 -0
- package/safe/net.d.ts +11 -0
- package/safe/net.js +17 -0
- package/safe/os.d.ts +20 -0
- package/safe/os.js +29 -0
- package/safe/perf_hooks.d.ts +11 -0
- package/safe/perf_hooks.js +12 -0
- package/safe/process.d.ts +31 -0
- package/safe/process.js +97 -0
- package/safe/punycode.d.ts +10 -0
- package/safe/punycode.js +21 -0
- package/safe/querystring.d.ts +11 -0
- package/safe/querystring.js +21 -0
- package/safe/readline/promises.d.ts +12 -0
- package/safe/readline/promises.js +13 -0
- package/safe/runtime.d.ts +10 -0
- package/safe/runtime.js +16 -0
- package/safe/sqlite.d.ts +54 -0
- package/safe/sqlite.js +118 -0
- package/safe/stream/consumers.d.ts +19 -0
- package/safe/stream/consumers.js +54 -0
- package/safe/stream/promises.d.ts +26 -0
- package/safe/stream/promises.js +22 -0
- package/safe/stream/web.d.ts +18 -0
- package/safe/stream/web.js +37 -0
- package/safe/stream.d.ts +29 -0
- package/safe/stream.js +62 -0
- package/safe/tls.d.ts +27 -0
- package/safe/tls.js +65 -0
- package/safe/url.d.ts +28 -0
- package/safe/url.js +57 -0
- package/safe/util.d.ts +13 -0
- package/safe/util.js +25 -0
- package/safe/v8.d.ts +28 -0
- package/safe/v8.js +85 -0
- package/safe/vm.d.ts +23 -0
- package/safe/vm.js +69 -0
- package/safe/wasi.d.ts +10 -0
- package/safe/wasi.js +20 -0
- package/safe/worker_threads.d.ts +31 -0
- package/safe/worker_threads.js +62 -0
- package/safe/zlib.d.ts +61 -0
- package/safe/zlib.js +214 -0
- package/safe-ts.json +1722 -490
package/safe/buffer.js
ADDED
|
@@ -0,0 +1,582 @@
|
|
|
1
|
+
// @safe-ts std
|
|
2
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
3
|
+
import * as $module from "node:buffer";
|
|
4
|
+
import { Err } from "@evobug_com/safe-ts-std/result";
|
|
5
|
+
import { failed, ok } from "./runtime.js";
|
|
6
|
+
export * from "node:buffer";
|
|
7
|
+
|
|
8
|
+
export function arrayBuffer(self, ...args) {
|
|
9
|
+
try {
|
|
10
|
+
return Promise.resolve(self.arrayBuffer(...args)).then(ok, failed);
|
|
11
|
+
} catch (error) {
|
|
12
|
+
return Promise.resolve(new Err(error));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function atob(...args) {
|
|
17
|
+
try {
|
|
18
|
+
return $module.atob(...args);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
return new Err(error);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function btoa(...args) {
|
|
25
|
+
try {
|
|
26
|
+
return $module.btoa(...args);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
return new Err(error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function bytes(self, ...args) {
|
|
33
|
+
try {
|
|
34
|
+
return Promise.resolve(self.bytes(...args)).then(ok, failed);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
return Promise.resolve(new Err(error));
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function readBigInt64BE(self, ...args) {
|
|
41
|
+
try {
|
|
42
|
+
return self.readBigInt64BE(...args);
|
|
43
|
+
} catch (error) {
|
|
44
|
+
return new Err(error);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function readBigInt64LE(self, ...args) {
|
|
49
|
+
try {
|
|
50
|
+
return self.readBigInt64LE(...args);
|
|
51
|
+
} catch (error) {
|
|
52
|
+
return new Err(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function readBigUint64BE(self, ...args) {
|
|
57
|
+
try {
|
|
58
|
+
return self.readBigUint64BE(...args);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
return new Err(error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function readBigUInt64BE(self, ...args) {
|
|
65
|
+
try {
|
|
66
|
+
return self.readBigUInt64BE(...args);
|
|
67
|
+
} catch (error) {
|
|
68
|
+
return new Err(error);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function readBigUint64LE(self, ...args) {
|
|
73
|
+
try {
|
|
74
|
+
return self.readBigUint64LE(...args);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
return new Err(error);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function readBigUInt64LE(self, ...args) {
|
|
81
|
+
try {
|
|
82
|
+
return self.readBigUInt64LE(...args);
|
|
83
|
+
} catch (error) {
|
|
84
|
+
return new Err(error);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function readDoubleBE(self, ...args) {
|
|
89
|
+
try {
|
|
90
|
+
return self.readDoubleBE(...args);
|
|
91
|
+
} catch (error) {
|
|
92
|
+
return new Err(error);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function readDoubleLE(self, ...args) {
|
|
97
|
+
try {
|
|
98
|
+
return self.readDoubleLE(...args);
|
|
99
|
+
} catch (error) {
|
|
100
|
+
return new Err(error);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function readFloatBE(self, ...args) {
|
|
105
|
+
try {
|
|
106
|
+
return self.readFloatBE(...args);
|
|
107
|
+
} catch (error) {
|
|
108
|
+
return new Err(error);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function readFloatLE(self, ...args) {
|
|
113
|
+
try {
|
|
114
|
+
return self.readFloatLE(...args);
|
|
115
|
+
} catch (error) {
|
|
116
|
+
return new Err(error);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function readInt16BE(self, ...args) {
|
|
121
|
+
try {
|
|
122
|
+
return self.readInt16BE(...args);
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return new Err(error);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function readInt16LE(self, ...args) {
|
|
129
|
+
try {
|
|
130
|
+
return self.readInt16LE(...args);
|
|
131
|
+
} catch (error) {
|
|
132
|
+
return new Err(error);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function readInt32BE(self, ...args) {
|
|
137
|
+
try {
|
|
138
|
+
return self.readInt32BE(...args);
|
|
139
|
+
} catch (error) {
|
|
140
|
+
return new Err(error);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function readInt32LE(self, ...args) {
|
|
145
|
+
try {
|
|
146
|
+
return self.readInt32LE(...args);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
return new Err(error);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export function readInt8(self, ...args) {
|
|
153
|
+
try {
|
|
154
|
+
return self.readInt8(...args);
|
|
155
|
+
} catch (error) {
|
|
156
|
+
return new Err(error);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function readIntBE(self, ...args) {
|
|
161
|
+
try {
|
|
162
|
+
return self.readIntBE(...args);
|
|
163
|
+
} catch (error) {
|
|
164
|
+
return new Err(error);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function readIntLE(self, ...args) {
|
|
169
|
+
try {
|
|
170
|
+
return self.readIntLE(...args);
|
|
171
|
+
} catch (error) {
|
|
172
|
+
return new Err(error);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function readUint16BE(self, ...args) {
|
|
177
|
+
try {
|
|
178
|
+
return self.readUint16BE(...args);
|
|
179
|
+
} catch (error) {
|
|
180
|
+
return new Err(error);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export function readUInt16BE(self, ...args) {
|
|
185
|
+
try {
|
|
186
|
+
return self.readUInt16BE(...args);
|
|
187
|
+
} catch (error) {
|
|
188
|
+
return new Err(error);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function readUint16LE(self, ...args) {
|
|
193
|
+
try {
|
|
194
|
+
return self.readUint16LE(...args);
|
|
195
|
+
} catch (error) {
|
|
196
|
+
return new Err(error);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
export function readUInt16LE(self, ...args) {
|
|
201
|
+
try {
|
|
202
|
+
return self.readUInt16LE(...args);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
return new Err(error);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function readUint32BE(self, ...args) {
|
|
209
|
+
try {
|
|
210
|
+
return self.readUint32BE(...args);
|
|
211
|
+
} catch (error) {
|
|
212
|
+
return new Err(error);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export function readUInt32BE(self, ...args) {
|
|
217
|
+
try {
|
|
218
|
+
return self.readUInt32BE(...args);
|
|
219
|
+
} catch (error) {
|
|
220
|
+
return new Err(error);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export function readUint32LE(self, ...args) {
|
|
225
|
+
try {
|
|
226
|
+
return self.readUint32LE(...args);
|
|
227
|
+
} catch (error) {
|
|
228
|
+
return new Err(error);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function readUInt32LE(self, ...args) {
|
|
233
|
+
try {
|
|
234
|
+
return self.readUInt32LE(...args);
|
|
235
|
+
} catch (error) {
|
|
236
|
+
return new Err(error);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export function readUint8(self, ...args) {
|
|
241
|
+
try {
|
|
242
|
+
return self.readUint8(...args);
|
|
243
|
+
} catch (error) {
|
|
244
|
+
return new Err(error);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export function readUInt8(self, ...args) {
|
|
249
|
+
try {
|
|
250
|
+
return self.readUInt8(...args);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
return new Err(error);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function readUintBE(self, ...args) {
|
|
257
|
+
try {
|
|
258
|
+
return self.readUintBE(...args);
|
|
259
|
+
} catch (error) {
|
|
260
|
+
return new Err(error);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function readUIntBE(self, ...args) {
|
|
265
|
+
try {
|
|
266
|
+
return self.readUIntBE(...args);
|
|
267
|
+
} catch (error) {
|
|
268
|
+
return new Err(error);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export function readUintLE(self, ...args) {
|
|
273
|
+
try {
|
|
274
|
+
return self.readUintLE(...args);
|
|
275
|
+
} catch (error) {
|
|
276
|
+
return new Err(error);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export function readUIntLE(self, ...args) {
|
|
281
|
+
try {
|
|
282
|
+
return self.readUIntLE(...args);
|
|
283
|
+
} catch (error) {
|
|
284
|
+
return new Err(error);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export function swap16(self, ...args) {
|
|
289
|
+
try {
|
|
290
|
+
return self.swap16(...args);
|
|
291
|
+
} catch (error) {
|
|
292
|
+
return new Err(error);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export function swap32(self, ...args) {
|
|
297
|
+
try {
|
|
298
|
+
return self.swap32(...args);
|
|
299
|
+
} catch (error) {
|
|
300
|
+
return new Err(error);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
export function swap64(self, ...args) {
|
|
305
|
+
try {
|
|
306
|
+
return self.swap64(...args);
|
|
307
|
+
} catch (error) {
|
|
308
|
+
return new Err(error);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
export function text(self, ...args) {
|
|
313
|
+
try {
|
|
314
|
+
return Promise.resolve(self.text(...args)).then(ok, failed);
|
|
315
|
+
} catch (error) {
|
|
316
|
+
return Promise.resolve(new Err(error));
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export function transcode(...args) {
|
|
321
|
+
try {
|
|
322
|
+
return $module.transcode(...args);
|
|
323
|
+
} catch (error) {
|
|
324
|
+
return new Err(error);
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
export function write(self, ...args) {
|
|
329
|
+
try {
|
|
330
|
+
return self.write(...args);
|
|
331
|
+
} catch (error) {
|
|
332
|
+
return new Err(error);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
export function writeBigInt64BE(self, ...args) {
|
|
337
|
+
try {
|
|
338
|
+
return self.writeBigInt64BE(...args);
|
|
339
|
+
} catch (error) {
|
|
340
|
+
return new Err(error);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
export function writeBigInt64LE(self, ...args) {
|
|
345
|
+
try {
|
|
346
|
+
return self.writeBigInt64LE(...args);
|
|
347
|
+
} catch (error) {
|
|
348
|
+
return new Err(error);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
export function writeBigUint64BE(self, ...args) {
|
|
353
|
+
try {
|
|
354
|
+
return self.writeBigUint64BE(...args);
|
|
355
|
+
} catch (error) {
|
|
356
|
+
return new Err(error);
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
export function writeBigUInt64BE(self, ...args) {
|
|
361
|
+
try {
|
|
362
|
+
return self.writeBigUInt64BE(...args);
|
|
363
|
+
} catch (error) {
|
|
364
|
+
return new Err(error);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
export function writeBigUint64LE(self, ...args) {
|
|
369
|
+
try {
|
|
370
|
+
return self.writeBigUint64LE(...args);
|
|
371
|
+
} catch (error) {
|
|
372
|
+
return new Err(error);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export function writeBigUInt64LE(self, ...args) {
|
|
377
|
+
try {
|
|
378
|
+
return self.writeBigUInt64LE(...args);
|
|
379
|
+
} catch (error) {
|
|
380
|
+
return new Err(error);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export function writeDoubleBE(self, ...args) {
|
|
385
|
+
try {
|
|
386
|
+
return self.writeDoubleBE(...args);
|
|
387
|
+
} catch (error) {
|
|
388
|
+
return new Err(error);
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
export function writeDoubleLE(self, ...args) {
|
|
393
|
+
try {
|
|
394
|
+
return self.writeDoubleLE(...args);
|
|
395
|
+
} catch (error) {
|
|
396
|
+
return new Err(error);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export function writeFloatBE(self, ...args) {
|
|
401
|
+
try {
|
|
402
|
+
return self.writeFloatBE(...args);
|
|
403
|
+
} catch (error) {
|
|
404
|
+
return new Err(error);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export function writeFloatLE(self, ...args) {
|
|
409
|
+
try {
|
|
410
|
+
return self.writeFloatLE(...args);
|
|
411
|
+
} catch (error) {
|
|
412
|
+
return new Err(error);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
export function writeInt16BE(self, ...args) {
|
|
417
|
+
try {
|
|
418
|
+
return self.writeInt16BE(...args);
|
|
419
|
+
} catch (error) {
|
|
420
|
+
return new Err(error);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
export function writeInt16LE(self, ...args) {
|
|
425
|
+
try {
|
|
426
|
+
return self.writeInt16LE(...args);
|
|
427
|
+
} catch (error) {
|
|
428
|
+
return new Err(error);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export function writeInt32BE(self, ...args) {
|
|
433
|
+
try {
|
|
434
|
+
return self.writeInt32BE(...args);
|
|
435
|
+
} catch (error) {
|
|
436
|
+
return new Err(error);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export function writeInt32LE(self, ...args) {
|
|
441
|
+
try {
|
|
442
|
+
return self.writeInt32LE(...args);
|
|
443
|
+
} catch (error) {
|
|
444
|
+
return new Err(error);
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
export function writeInt8(self, ...args) {
|
|
449
|
+
try {
|
|
450
|
+
return self.writeInt8(...args);
|
|
451
|
+
} catch (error) {
|
|
452
|
+
return new Err(error);
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
export function writeIntBE(self, ...args) {
|
|
457
|
+
try {
|
|
458
|
+
return self.writeIntBE(...args);
|
|
459
|
+
} catch (error) {
|
|
460
|
+
return new Err(error);
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export function writeIntLE(self, ...args) {
|
|
465
|
+
try {
|
|
466
|
+
return self.writeIntLE(...args);
|
|
467
|
+
} catch (error) {
|
|
468
|
+
return new Err(error);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
export function writeUint16BE(self, ...args) {
|
|
473
|
+
try {
|
|
474
|
+
return self.writeUint16BE(...args);
|
|
475
|
+
} catch (error) {
|
|
476
|
+
return new Err(error);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
export function writeUInt16BE(self, ...args) {
|
|
481
|
+
try {
|
|
482
|
+
return self.writeUInt16BE(...args);
|
|
483
|
+
} catch (error) {
|
|
484
|
+
return new Err(error);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export function writeUint16LE(self, ...args) {
|
|
489
|
+
try {
|
|
490
|
+
return self.writeUint16LE(...args);
|
|
491
|
+
} catch (error) {
|
|
492
|
+
return new Err(error);
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
export function writeUInt16LE(self, ...args) {
|
|
497
|
+
try {
|
|
498
|
+
return self.writeUInt16LE(...args);
|
|
499
|
+
} catch (error) {
|
|
500
|
+
return new Err(error);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export function writeUint32BE(self, ...args) {
|
|
505
|
+
try {
|
|
506
|
+
return self.writeUint32BE(...args);
|
|
507
|
+
} catch (error) {
|
|
508
|
+
return new Err(error);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
export function writeUInt32BE(self, ...args) {
|
|
513
|
+
try {
|
|
514
|
+
return self.writeUInt32BE(...args);
|
|
515
|
+
} catch (error) {
|
|
516
|
+
return new Err(error);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export function writeUint32LE(self, ...args) {
|
|
521
|
+
try {
|
|
522
|
+
return self.writeUint32LE(...args);
|
|
523
|
+
} catch (error) {
|
|
524
|
+
return new Err(error);
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
export function writeUInt32LE(self, ...args) {
|
|
529
|
+
try {
|
|
530
|
+
return self.writeUInt32LE(...args);
|
|
531
|
+
} catch (error) {
|
|
532
|
+
return new Err(error);
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
export function writeUint8(self, ...args) {
|
|
537
|
+
try {
|
|
538
|
+
return self.writeUint8(...args);
|
|
539
|
+
} catch (error) {
|
|
540
|
+
return new Err(error);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
export function writeUInt8(self, ...args) {
|
|
545
|
+
try {
|
|
546
|
+
return self.writeUInt8(...args);
|
|
547
|
+
} catch (error) {
|
|
548
|
+
return new Err(error);
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export function writeUintBE(self, ...args) {
|
|
553
|
+
try {
|
|
554
|
+
return self.writeUintBE(...args);
|
|
555
|
+
} catch (error) {
|
|
556
|
+
return new Err(error);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
export function writeUIntBE(self, ...args) {
|
|
561
|
+
try {
|
|
562
|
+
return self.writeUIntBE(...args);
|
|
563
|
+
} catch (error) {
|
|
564
|
+
return new Err(error);
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
export function writeUintLE(self, ...args) {
|
|
569
|
+
try {
|
|
570
|
+
return self.writeUintLE(...args);
|
|
571
|
+
} catch (error) {
|
|
572
|
+
return new Err(error);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
export function writeUIntLE(self, ...args) {
|
|
577
|
+
try {
|
|
578
|
+
return self.writeUIntLE(...args);
|
|
579
|
+
} catch (error) {
|
|
580
|
+
return new Err(error);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
import type { Result } from "@evobug_com/safe-ts-std/result";
|
|
4
|
+
import type { PlainError, SystemError } from "./errors.js";
|
|
5
|
+
import type * as $buffer from "node:buffer";
|
|
6
|
+
import type * as $child_process from "node:child_process";
|
|
7
|
+
export * from "node:child_process";
|
|
8
|
+
|
|
9
|
+
/** `execFileSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
10
|
+
export declare function execFileSync(file: string): Result<$buffer.NonSharedBuffer, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
11
|
+
/** `execFileSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
12
|
+
export declare function execFileSync(file: string, options: $child_process.ExecFileSyncOptionsWithStringEncoding): Result<string, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
13
|
+
/** `execFileSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
14
|
+
export declare function execFileSync(file: string, options: $child_process.ExecFileSyncOptionsWithBufferEncoding): Result<$buffer.NonSharedBuffer, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
15
|
+
/** `execFileSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
16
|
+
export declare function execFileSync(file: string, options?: $child_process.ExecFileSyncOptions): Result<string | $buffer.NonSharedBuffer, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
17
|
+
/** `execFileSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
18
|
+
export declare function execFileSync(file: string, args: readonly string[]): Result<$buffer.NonSharedBuffer, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
19
|
+
/** `execFileSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
20
|
+
export declare function execFileSync(file: string, args: readonly string[], options: $child_process.ExecFileSyncOptionsWithStringEncoding): Result<string, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
21
|
+
/** `execFileSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
22
|
+
export declare function execFileSync(file: string, args: readonly string[], options: $child_process.ExecFileSyncOptionsWithBufferEncoding): Result<$buffer.NonSharedBuffer, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
23
|
+
/** `execFileSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
24
|
+
export declare function execFileSync(file: string, args?: readonly string[], options?: $child_process.ExecFileSyncOptions): Result<string | $buffer.NonSharedBuffer, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
25
|
+
/** `execSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
26
|
+
export declare function execSync(command: string): Result<$buffer.NonSharedBuffer, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
27
|
+
/** `execSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
28
|
+
export declare function execSync(command: string, options: $child_process.ExecSyncOptionsWithStringEncoding): Result<string, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
29
|
+
/** `execSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
30
|
+
export declare function execSync(command: string, options: $child_process.ExecSyncOptionsWithBufferEncoding): Result<$buffer.NonSharedBuffer, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
31
|
+
/** `execSync()` (node:child_process), with what it throws returned as an `Err`: `Error {status, signal, output, pid, stdout, stderr} | Error [E*] {errno, syscall: 'spawnSync *', path, spawnargs, error, status, signal, output, pid, stdout?, stderr?}`. */
|
|
32
|
+
export declare function execSync(command: string, options?: $child_process.ExecSyncOptions): Result<string | $buffer.NonSharedBuffer, PlainError<"Error", { status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout: Buffer | string; stderr: Buffer | string }> | SystemError<`spawnSync ${string}`, { path: string; spawnargs: string[]; error: Error; status: number | null; signal: NodeJS.Signals | null; output: Array<Buffer | string | null>; pid: number; stdout?: Buffer | string; stderr?: Buffer | string }>>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// @safe-ts std
|
|
2
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
3
|
+
import * as $module from "node:child_process";
|
|
4
|
+
import { Err } from "@evobug_com/safe-ts-std/result";
|
|
5
|
+
export * from "node:child_process";
|
|
6
|
+
|
|
7
|
+
export function execFileSync(...args) {
|
|
8
|
+
try {
|
|
9
|
+
return $module.execFileSync(...args);
|
|
10
|
+
} catch (error) {
|
|
11
|
+
return new Err(error);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function execSync(...args) {
|
|
16
|
+
try {
|
|
17
|
+
return $module.execSync(...args);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
return new Err(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
package/safe/core.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
2
|
+
// The error types every pack's safe versions use, written from the pack's `error` texts
|
|
3
|
+
// (docs/guide/libraries.md#what-error-says), and their guards.
|
|
4
|
+
|
|
5
|
+
/** The class each error name of the notation stands for. */
|
|
6
|
+
export interface ErrorClasses {
|
|
7
|
+
Error: Error;
|
|
8
|
+
TypeError: TypeError;
|
|
9
|
+
RangeError: RangeError;
|
|
10
|
+
SyntaxError: SyntaxError;
|
|
11
|
+
URIError: URIError;
|
|
12
|
+
ReferenceError: ReferenceError;
|
|
13
|
+
}
|
|
14
|
+
type ClassOf<Name extends string> = Name extends keyof ErrorClasses ? ErrorClasses[Name] : Error;
|
|
15
|
+
|
|
16
|
+
/** `Name {props}`: an error without a `code`. `PlainError<"TypeError", { cause: unknown }>` is `TypeError {cause}`. */
|
|
17
|
+
export type PlainError<Name extends string = string, Props extends object = {}> = ClassOf<Name> & {
|
|
18
|
+
readonly name: Name;
|
|
19
|
+
readonly code?: undefined;
|
|
20
|
+
} & Readonly<Props>;
|
|
21
|
+
|
|
22
|
+
/** `Name [CODE] {props}`: an error with a `code`. `CodedError<"ERR_X", "TypeError">` is `TypeError [ERR_X]`. */
|
|
23
|
+
export type CodedError<Code extends string = string, Name extends string = string, Props extends object = {}> = ClassOf<Name> & {
|
|
24
|
+
readonly name: Name;
|
|
25
|
+
readonly code: Code;
|
|
26
|
+
} & Readonly<Props>;
|
|
27
|
+
|
|
28
|
+
/** `DOMException [Name]`: a DOMException with that `name`. */
|
|
29
|
+
export type DOMError<Name extends string = string> = DOMException & { readonly name: Name };
|
|
30
|
+
|
|
31
|
+
/** Is `e` an error of class `name` (any, if left out) without a `code`? */
|
|
32
|
+
export declare function isPlainError<Name extends string = string>(e: unknown, name?: Name): e is PlainError<Name>;
|
|
33
|
+
/** Is `e` an error whose `code` is `code` (any string, if left out)? */
|
|
34
|
+
export declare function isCodedError<Code extends string = string>(e: unknown, code?: Code): e is CodedError<Code>;
|
|
35
|
+
/** Is `e` a DOMException named `name` (any, if left out)? */
|
|
36
|
+
export declare function isDOMException<Name extends string = string>(e: unknown, name?: Name): e is DOMError<Name>;
|
package/safe/core.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// @safe-ts std
|
|
2
|
+
// Generated from node-api.json and @types/node by `npm run generate:safe` (packages/pack-kit/generate.ts): do not edit.
|
|
3
|
+
// The error types every pack's safe versions use, and their guards (core.d.ts).
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Is it an error object? `Error.isError` where there is one (it sees errors from other realms
|
|
7
|
+
* too), or an instance of Error: a browser's own error classes that aren't real errors to
|
|
8
|
+
* `Error.isError` (Firefox's `OverconstrainedError`) are.
|
|
9
|
+
*/
|
|
10
|
+
const isError = typeof Error.isError === "function" ? (e) => Error.isError(e) || e instanceof Error : (e) => e instanceof Error;
|
|
11
|
+
|
|
12
|
+
/** `Name {props}`: an error of class `name` (any, if left out) without a `code`. */
|
|
13
|
+
export function isPlainError(e, name) {
|
|
14
|
+
return isError(e) && e.code === undefined && (name === undefined || e.name === name);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** `Name [CODE] {props}`: an error whose `code` is `code` (any string, if left out). */
|
|
18
|
+
export function isCodedError(e, code) {
|
|
19
|
+
return isError(e) && typeof e.code === "string" && (code === undefined || e.code === code);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** `DOMException [Name]`: a DOMException named `name` (any, if left out). */
|
|
23
|
+
export function isDOMException(e, name) {
|
|
24
|
+
return typeof DOMException === "function" && e instanceof DOMException && (name === undefined || e.name === name);
|
|
25
|
+
}
|