@robinpath/cli 1.75.0 → 1.76.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 +111 -111
- package/dist/cli.mjs +7 -3
- package/modules/_helpers.js +33 -33
- package/modules/assert.js +270 -270
- package/modules/buffer.js +245 -245
- package/modules/child.js +176 -176
- package/modules/crypto.js +352 -352
- package/modules/dns.js +146 -146
- package/modules/events.js +174 -174
- package/modules/file.js +361 -361
- package/modules/http.js +268 -268
- package/modules/index.js +76 -76
- package/modules/net.js +189 -189
- package/modules/os.js +219 -219
- package/modules/path.js +162 -162
- package/modules/process.js +214 -214
- package/modules/stream.js +322 -322
- package/modules/string_decoder.js +106 -106
- package/modules/timer.js +167 -167
- package/modules/tls.js +264 -264
- package/modules/tty.js +169 -169
- package/modules/url.js +189 -189
- package/modules/util.js +275 -275
- package/modules/zlib.js +126 -126
- package/package.json +1 -1
package/modules/zlib.js
CHANGED
|
@@ -1,126 +1,126 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Native zlib module for RobinPath.
|
|
3
|
-
* Compression and decompression utilities.
|
|
4
|
-
*/
|
|
5
|
-
import {
|
|
6
|
-
gzip as _gzip, gunzip as _gunzip,
|
|
7
|
-
deflate as _deflate, inflate as _inflate,
|
|
8
|
-
brotliCompress as _brotliCompress, brotliDecompress as _brotliDecompress
|
|
9
|
-
} from 'node:zlib';
|
|
10
|
-
import { toStr, requireArgs } from './_helpers.js';
|
|
11
|
-
|
|
12
|
-
function promisify(fn, input) {
|
|
13
|
-
return new Promise((resolve, reject) => {
|
|
14
|
-
fn(input, (err, result) => {
|
|
15
|
-
if (err) reject(err);
|
|
16
|
-
else resolve(result);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export const ZlibFunctions = {
|
|
22
|
-
|
|
23
|
-
gzip: async (args) => {
|
|
24
|
-
requireArgs('zlib.gzip', args, 1);
|
|
25
|
-
const input = Buffer.from(toStr(args[0]));
|
|
26
|
-
const result = await promisify(_gzip, input);
|
|
27
|
-
return result.toString('base64');
|
|
28
|
-
},
|
|
29
|
-
|
|
30
|
-
gunzip: async (args) => {
|
|
31
|
-
requireArgs('zlib.gunzip', args, 1);
|
|
32
|
-
const input = Buffer.from(toStr(args[0]), 'base64');
|
|
33
|
-
const result = await promisify(_gunzip, input);
|
|
34
|
-
return result.toString('utf-8');
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
deflate: async (args) => {
|
|
38
|
-
requireArgs('zlib.deflate', args, 1);
|
|
39
|
-
const input = Buffer.from(toStr(args[0]));
|
|
40
|
-
const result = await promisify(_deflate, input);
|
|
41
|
-
return result.toString('base64');
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
inflate: async (args) => {
|
|
45
|
-
requireArgs('zlib.inflate', args, 1);
|
|
46
|
-
const input = Buffer.from(toStr(args[0]), 'base64');
|
|
47
|
-
const result = await promisify(_inflate, input);
|
|
48
|
-
return result.toString('utf-8');
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
brotliCompress: async (args) => {
|
|
52
|
-
requireArgs('zlib.brotliCompress', args, 1);
|
|
53
|
-
const input = Buffer.from(toStr(args[0]));
|
|
54
|
-
const result = await promisify(_brotliCompress, input);
|
|
55
|
-
return result.toString('base64');
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
brotliDecompress: async (args) => {
|
|
59
|
-
requireArgs('zlib.brotliDecompress', args, 1);
|
|
60
|
-
const input = Buffer.from(toStr(args[0]), 'base64');
|
|
61
|
-
const result = await promisify(_brotliDecompress, input);
|
|
62
|
-
return result.toString('utf-8');
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
compressSize: async (args) => {
|
|
66
|
-
requireArgs('zlib.compressSize', args, 1);
|
|
67
|
-
const input = Buffer.from(toStr(args[0]));
|
|
68
|
-
const compressed = await promisify(_gzip, input);
|
|
69
|
-
return {
|
|
70
|
-
original: input.length,
|
|
71
|
-
compressed: compressed.length,
|
|
72
|
-
ratio: Math.round(compressed.length / input.length * 10000) / 100
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export const ZlibFunctionMetadata = {
|
|
78
|
-
gzip: {
|
|
79
|
-
description: 'Gzip compress a string',
|
|
80
|
-
parameters: [{ name: 'data', dataType: 'string', description: 'Data to compress', formInputType: 'textarea', required: true }],
|
|
81
|
-
returnType: 'string', returnDescription: 'Base64-encoded gzipped data', example: 'zlib.gzip "hello world"'
|
|
82
|
-
},
|
|
83
|
-
gunzip: {
|
|
84
|
-
description: 'Decompress gzipped data',
|
|
85
|
-
parameters: [{ name: 'data', dataType: 'string', description: 'Base64-encoded gzipped data', formInputType: 'text', required: true }],
|
|
86
|
-
returnType: 'string', returnDescription: 'Decompressed string', example: 'zlib.gunzip $compressed'
|
|
87
|
-
},
|
|
88
|
-
deflate: {
|
|
89
|
-
description: 'Deflate compress a string',
|
|
90
|
-
parameters: [{ name: 'data', dataType: 'string', description: 'Data to compress', formInputType: 'textarea', required: true }],
|
|
91
|
-
returnType: 'string', returnDescription: 'Base64-encoded deflated data', example: 'zlib.deflate "hello world"'
|
|
92
|
-
},
|
|
93
|
-
inflate: {
|
|
94
|
-
description: 'Decompress deflated data',
|
|
95
|
-
parameters: [{ name: 'data', dataType: 'string', description: 'Base64-encoded deflated data', formInputType: 'text', required: true }],
|
|
96
|
-
returnType: 'string', returnDescription: 'Decompressed string', example: 'zlib.inflate $compressed'
|
|
97
|
-
},
|
|
98
|
-
brotliCompress: {
|
|
99
|
-
description: 'Brotli compress a string',
|
|
100
|
-
parameters: [{ name: 'data', dataType: 'string', description: 'Data to compress', formInputType: 'textarea', required: true }],
|
|
101
|
-
returnType: 'string', returnDescription: 'Base64-encoded brotli data', example: 'zlib.brotliCompress "hello world"'
|
|
102
|
-
},
|
|
103
|
-
brotliDecompress: {
|
|
104
|
-
description: 'Decompress brotli data',
|
|
105
|
-
parameters: [{ name: 'data', dataType: 'string', description: 'Base64-encoded brotli data', formInputType: 'text', required: true }],
|
|
106
|
-
returnType: 'string', returnDescription: 'Decompressed string', example: 'zlib.brotliDecompress $compressed'
|
|
107
|
-
},
|
|
108
|
-
compressSize: {
|
|
109
|
-
description: 'Show compression ratio (gzip)',
|
|
110
|
-
parameters: [{ name: 'data', dataType: 'string', description: 'Data to analyze', formInputType: 'textarea', required: true }],
|
|
111
|
-
returnType: 'object', returnDescription: 'Object with original, compressed, ratio', example: 'zlib.compressSize "hello world hello world"'
|
|
112
|
-
}
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const ZlibModuleMetadata = {
|
|
116
|
-
description: 'Compression: gzip, deflate, brotli compress/decompress',
|
|
117
|
-
methods: Object.keys(ZlibFunctions)
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
export default {
|
|
121
|
-
name: 'zlib',
|
|
122
|
-
functions: ZlibFunctions,
|
|
123
|
-
functionMetadata: ZlibFunctionMetadata,
|
|
124
|
-
moduleMetadata: ZlibModuleMetadata,
|
|
125
|
-
global: false
|
|
126
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Native zlib module for RobinPath.
|
|
3
|
+
* Compression and decompression utilities.
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
gzip as _gzip, gunzip as _gunzip,
|
|
7
|
+
deflate as _deflate, inflate as _inflate,
|
|
8
|
+
brotliCompress as _brotliCompress, brotliDecompress as _brotliDecompress
|
|
9
|
+
} from 'node:zlib';
|
|
10
|
+
import { toStr, requireArgs } from './_helpers.js';
|
|
11
|
+
|
|
12
|
+
function promisify(fn, input) {
|
|
13
|
+
return new Promise((resolve, reject) => {
|
|
14
|
+
fn(input, (err, result) => {
|
|
15
|
+
if (err) reject(err);
|
|
16
|
+
else resolve(result);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const ZlibFunctions = {
|
|
22
|
+
|
|
23
|
+
gzip: async (args) => {
|
|
24
|
+
requireArgs('zlib.gzip', args, 1);
|
|
25
|
+
const input = Buffer.from(toStr(args[0]));
|
|
26
|
+
const result = await promisify(_gzip, input);
|
|
27
|
+
return result.toString('base64');
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
gunzip: async (args) => {
|
|
31
|
+
requireArgs('zlib.gunzip', args, 1);
|
|
32
|
+
const input = Buffer.from(toStr(args[0]), 'base64');
|
|
33
|
+
const result = await promisify(_gunzip, input);
|
|
34
|
+
return result.toString('utf-8');
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
deflate: async (args) => {
|
|
38
|
+
requireArgs('zlib.deflate', args, 1);
|
|
39
|
+
const input = Buffer.from(toStr(args[0]));
|
|
40
|
+
const result = await promisify(_deflate, input);
|
|
41
|
+
return result.toString('base64');
|
|
42
|
+
},
|
|
43
|
+
|
|
44
|
+
inflate: async (args) => {
|
|
45
|
+
requireArgs('zlib.inflate', args, 1);
|
|
46
|
+
const input = Buffer.from(toStr(args[0]), 'base64');
|
|
47
|
+
const result = await promisify(_inflate, input);
|
|
48
|
+
return result.toString('utf-8');
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
brotliCompress: async (args) => {
|
|
52
|
+
requireArgs('zlib.brotliCompress', args, 1);
|
|
53
|
+
const input = Buffer.from(toStr(args[0]));
|
|
54
|
+
const result = await promisify(_brotliCompress, input);
|
|
55
|
+
return result.toString('base64');
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
brotliDecompress: async (args) => {
|
|
59
|
+
requireArgs('zlib.brotliDecompress', args, 1);
|
|
60
|
+
const input = Buffer.from(toStr(args[0]), 'base64');
|
|
61
|
+
const result = await promisify(_brotliDecompress, input);
|
|
62
|
+
return result.toString('utf-8');
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
compressSize: async (args) => {
|
|
66
|
+
requireArgs('zlib.compressSize', args, 1);
|
|
67
|
+
const input = Buffer.from(toStr(args[0]));
|
|
68
|
+
const compressed = await promisify(_gzip, input);
|
|
69
|
+
return {
|
|
70
|
+
original: input.length,
|
|
71
|
+
compressed: compressed.length,
|
|
72
|
+
ratio: Math.round(compressed.length / input.length * 10000) / 100
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export const ZlibFunctionMetadata = {
|
|
78
|
+
gzip: {
|
|
79
|
+
description: 'Gzip compress a string',
|
|
80
|
+
parameters: [{ name: 'data', dataType: 'string', description: 'Data to compress', formInputType: 'textarea', required: true }],
|
|
81
|
+
returnType: 'string', returnDescription: 'Base64-encoded gzipped data', example: 'zlib.gzip "hello world"'
|
|
82
|
+
},
|
|
83
|
+
gunzip: {
|
|
84
|
+
description: 'Decompress gzipped data',
|
|
85
|
+
parameters: [{ name: 'data', dataType: 'string', description: 'Base64-encoded gzipped data', formInputType: 'text', required: true }],
|
|
86
|
+
returnType: 'string', returnDescription: 'Decompressed string', example: 'zlib.gunzip $compressed'
|
|
87
|
+
},
|
|
88
|
+
deflate: {
|
|
89
|
+
description: 'Deflate compress a string',
|
|
90
|
+
parameters: [{ name: 'data', dataType: 'string', description: 'Data to compress', formInputType: 'textarea', required: true }],
|
|
91
|
+
returnType: 'string', returnDescription: 'Base64-encoded deflated data', example: 'zlib.deflate "hello world"'
|
|
92
|
+
},
|
|
93
|
+
inflate: {
|
|
94
|
+
description: 'Decompress deflated data',
|
|
95
|
+
parameters: [{ name: 'data', dataType: 'string', description: 'Base64-encoded deflated data', formInputType: 'text', required: true }],
|
|
96
|
+
returnType: 'string', returnDescription: 'Decompressed string', example: 'zlib.inflate $compressed'
|
|
97
|
+
},
|
|
98
|
+
brotliCompress: {
|
|
99
|
+
description: 'Brotli compress a string',
|
|
100
|
+
parameters: [{ name: 'data', dataType: 'string', description: 'Data to compress', formInputType: 'textarea', required: true }],
|
|
101
|
+
returnType: 'string', returnDescription: 'Base64-encoded brotli data', example: 'zlib.brotliCompress "hello world"'
|
|
102
|
+
},
|
|
103
|
+
brotliDecompress: {
|
|
104
|
+
description: 'Decompress brotli data',
|
|
105
|
+
parameters: [{ name: 'data', dataType: 'string', description: 'Base64-encoded brotli data', formInputType: 'text', required: true }],
|
|
106
|
+
returnType: 'string', returnDescription: 'Decompressed string', example: 'zlib.brotliDecompress $compressed'
|
|
107
|
+
},
|
|
108
|
+
compressSize: {
|
|
109
|
+
description: 'Show compression ratio (gzip)',
|
|
110
|
+
parameters: [{ name: 'data', dataType: 'string', description: 'Data to analyze', formInputType: 'textarea', required: true }],
|
|
111
|
+
returnType: 'object', returnDescription: 'Object with original, compressed, ratio', example: 'zlib.compressSize "hello world hello world"'
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export const ZlibModuleMetadata = {
|
|
116
|
+
description: 'Compression: gzip, deflate, brotli compress/decompress',
|
|
117
|
+
methods: Object.keys(ZlibFunctions)
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export default {
|
|
121
|
+
name: 'zlib',
|
|
122
|
+
functions: ZlibFunctions,
|
|
123
|
+
functionMetadata: ZlibFunctionMetadata,
|
|
124
|
+
moduleMetadata: ZlibModuleMetadata,
|
|
125
|
+
global: false
|
|
126
|
+
};
|