tmcsplit 0.0.1 → 0.0.2
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/AUTHORS.rst +1 -1
- package/README.md +36 -238
- package/eslint.config.mjs +67 -25
- package/fs-worker.js +1 -0
- package/fs-worker.webpack.config.cjs +1 -1
- package/libtmcsplit +98 -0
- package/libtmcsplit.webpack.config.cjs +96 -0
- package/package.json +16 -9
- package/tmcsplit +215 -125
- package/tmcsplit.js +2 -0
- package/webpack.config.cjs +64 -4
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name":
|
|
3
3
|
"tmcsplit",
|
|
4
4
|
"version":
|
|
5
|
-
"0.0.
|
|
5
|
+
"0.0.2",
|
|
6
6
|
"description":
|
|
7
7
|
"Basic Javascript implementation of GNU Split.",
|
|
8
8
|
"funding": {
|
|
@@ -57,11 +57,15 @@
|
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"crash-js-webpack":
|
|
60
|
-
"^0.0.
|
|
60
|
+
"^0.0.3",
|
|
61
61
|
"eslint":
|
|
62
|
-
"^
|
|
63
|
-
"
|
|
64
|
-
"^
|
|
62
|
+
"^10.0.0",
|
|
63
|
+
"globals":
|
|
64
|
+
"^17.3.0",
|
|
65
|
+
"@eslint/js":
|
|
66
|
+
"^10.0.1",
|
|
67
|
+
"safely-serve":
|
|
68
|
+
"^0.0.9",
|
|
65
69
|
"webpack":
|
|
66
70
|
"^5.102.1",
|
|
67
71
|
"webpack-cli":
|
|
@@ -69,14 +73,17 @@
|
|
|
69
73
|
},
|
|
70
74
|
"dependencies": {
|
|
71
75
|
"crash-js":
|
|
72
|
-
"^0.1.
|
|
76
|
+
"^0.1.73",
|
|
73
77
|
"split-file":
|
|
74
|
-
"npm:@themartiancompany/split-file@2.3.
|
|
78
|
+
"npm:@themartiancompany/split-file@2.3.12"
|
|
75
79
|
},
|
|
76
80
|
"type":
|
|
77
81
|
"commonjs",
|
|
78
82
|
"main":
|
|
79
|
-
"
|
|
83
|
+
"libtmcsplit",
|
|
84
|
+
"bin":
|
|
85
|
+
{ "tmcsplit":
|
|
86
|
+
"tmcsplit" },
|
|
80
87
|
"scripts": {
|
|
81
88
|
"build-fs-worker":
|
|
82
89
|
"npx webpack --mode 'production' --config 'fs-worker.webpack.config.cjs' --stats-error-details",
|
|
@@ -91,7 +98,7 @@
|
|
|
91
98
|
"publish-pnm":
|
|
92
99
|
"npm run build && npm publish --access public",
|
|
93
100
|
"start":
|
|
94
|
-
"
|
|
101
|
+
"npx safely-serve --help # index.html --port 3000 --https --no-cache",
|
|
95
102
|
"test":
|
|
96
103
|
"echo \"Error: no test specified\" && exit 1"
|
|
97
104
|
}
|
package/tmcsplit
CHANGED
|
@@ -2,58 +2,136 @@
|
|
|
2
2
|
|
|
3
3
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
5
|
+
/** ----------------------------------------------------------------------
|
|
6
|
+
* tmcsplit
|
|
7
|
+
* ----------------------------------------------------------------------
|
|
8
|
+
* Copyright ©
|
|
9
|
+
* Pellegrino Prevete
|
|
10
|
+
* 2024, 2025, 2026
|
|
11
|
+
*
|
|
12
|
+
* All rights reserved
|
|
13
|
+
* ----------------------------------------------------------------------
|
|
14
|
+
*
|
|
15
|
+
* This program is free software: you can redistribute it and/or modify
|
|
16
|
+
* it under the terms of the GNU General Public License as published by
|
|
17
|
+
* the Free Software Foundation, either version 3 of the License, or
|
|
18
|
+
* (at your option) any later version.
|
|
19
|
+
*
|
|
20
|
+
* This program is distributed in the hope that it will be useful,
|
|
21
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
22
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
23
|
+
* GNU General Public License for more details.
|
|
24
|
+
*
|
|
25
|
+
* You should have received a copy of the GNU General Public License
|
|
26
|
+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/* eslint
|
|
30
|
+
no-unused-vars: [
|
|
31
|
+
"error",
|
|
32
|
+
{ "vars":
|
|
33
|
+
"local",
|
|
34
|
+
"argsIgnorePattern":
|
|
35
|
+
"output_prefix" } ] */
|
|
23
36
|
|
|
24
37
|
const
|
|
25
38
|
_libcrash =
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
39
|
+
require(
|
|
40
|
+
'crash-js');
|
|
41
|
+
/* global
|
|
42
|
+
_argv_url_get */
|
|
43
|
+
const
|
|
44
|
+
_argv_url_get =
|
|
45
|
+
_libcrash._argv_url_get;
|
|
46
|
+
/* global
|
|
47
|
+
_cmdline_check */
|
|
48
|
+
const
|
|
49
|
+
_cmdline_check =
|
|
50
|
+
_libcrash._cmdline_check;
|
|
51
|
+
/* global
|
|
52
|
+
_msg_info */
|
|
53
|
+
const
|
|
54
|
+
_msg_info =
|
|
55
|
+
_libcrash._msg_info;
|
|
56
|
+
/* global
|
|
57
|
+
_msg_error */
|
|
58
|
+
const
|
|
32
59
|
_msg_error =
|
|
33
60
|
_libcrash._msg_error;
|
|
61
|
+
/* global
|
|
62
|
+
_yargv_get */
|
|
63
|
+
const
|
|
64
|
+
_yargv_get =
|
|
65
|
+
_libcrash._yargv_get;
|
|
34
66
|
const
|
|
35
67
|
_split_module =
|
|
36
68
|
require(
|
|
37
69
|
"./libtmcsplit");
|
|
38
|
-
|
|
39
|
-
|
|
70
|
+
/* global
|
|
71
|
+
_tmcsplit */
|
|
72
|
+
const
|
|
73
|
+
_split =
|
|
74
|
+
_split_module._split;
|
|
40
75
|
|
|
41
76
|
function
|
|
42
77
|
_global_variables() {
|
|
78
|
+
/* global
|
|
79
|
+
app_name:
|
|
80
|
+
writable */
|
|
43
81
|
app_name =
|
|
44
82
|
"tmcsplit";
|
|
83
|
+
/* global
|
|
84
|
+
app_opts:
|
|
85
|
+
writable */
|
|
86
|
+
app_opts =
|
|
87
|
+
[];
|
|
88
|
+
/* global
|
|
89
|
+
runtime_environment:
|
|
90
|
+
writable */
|
|
91
|
+
runtime_environment =
|
|
92
|
+
"";
|
|
93
|
+
/* global
|
|
94
|
+
numeric_suffix:
|
|
95
|
+
writable */
|
|
96
|
+
numeric_suffix =
|
|
97
|
+
"";
|
|
98
|
+
/* global
|
|
99
|
+
suffix_length:
|
|
100
|
+
writable */
|
|
45
101
|
suffix_length =
|
|
46
102
|
"";
|
|
103
|
+
/* global
|
|
104
|
+
chunks_amount:
|
|
105
|
+
writable */
|
|
47
106
|
chunks_amount =
|
|
48
107
|
"";
|
|
49
|
-
string_length =
|
|
50
|
-
|
|
108
|
+
// string_length =
|
|
109
|
+
// "";
|
|
110
|
+
/* global
|
|
111
|
+
size_max:
|
|
112
|
+
writable */
|
|
51
113
|
size_max =
|
|
52
114
|
"";
|
|
115
|
+
/* global
|
|
116
|
+
input_file:
|
|
117
|
+
writable */
|
|
118
|
+
input_file =
|
|
119
|
+
"";
|
|
120
|
+
/* global
|
|
121
|
+
output_prefix:
|
|
122
|
+
writable */
|
|
53
123
|
output_prefix =
|
|
54
124
|
"";
|
|
125
|
+
/* global
|
|
126
|
+
quiet:
|
|
127
|
+
writable */
|
|
55
128
|
quiet =
|
|
56
129
|
"";
|
|
130
|
+
/* global
|
|
131
|
+
verbose:
|
|
132
|
+
writable */
|
|
133
|
+
verbose =
|
|
134
|
+
"";
|
|
57
135
|
}
|
|
58
136
|
|
|
59
137
|
function
|
|
@@ -64,24 +142,24 @@ function
|
|
|
64
142
|
}
|
|
65
143
|
if ( output_prefix == "" ) {
|
|
66
144
|
output_prefix =
|
|
67
|
-
|
|
145
|
+
input_file + ".";
|
|
68
146
|
}
|
|
69
147
|
}
|
|
70
148
|
|
|
71
149
|
function
|
|
72
150
|
_config_show() {
|
|
73
151
|
let
|
|
74
|
-
_line
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
152
|
+
_line;
|
|
153
|
+
const
|
|
154
|
+
_text = [
|
|
155
|
+
`${app_name} configuration:`,
|
|
156
|
+
` Runtime environment: ${runtime_environment}`,
|
|
157
|
+
` Suffix length: ${suffix_length}`,
|
|
158
|
+
` Maximum chunk size: ${size_max} bytes`,
|
|
159
|
+
` Amount of chunks: ${chunks_amount}`,
|
|
160
|
+
` In file: ${input_file}`,
|
|
161
|
+
` Out files prefix: ${output_prefix}`,
|
|
162
|
+
];
|
|
85
163
|
for ( _line of _text ) {
|
|
86
164
|
_msg_info(
|
|
87
165
|
_line);
|
|
@@ -92,62 +170,67 @@ function
|
|
|
92
170
|
_usage(
|
|
93
171
|
_exit_code) {
|
|
94
172
|
let
|
|
95
|
-
_line
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
173
|
+
_line;
|
|
174
|
+
const
|
|
175
|
+
_text = [
|
|
176
|
+
"Output pieces of FILE to PREFIXaa, PREFIXab, ...",
|
|
177
|
+
"default size is 1000 lines, and default PREFIX is 'x'.",
|
|
178
|
+
"",
|
|
179
|
+
"Usage:",
|
|
180
|
+
"",
|
|
181
|
+
" tmcsplit",
|
|
182
|
+
" <in-file>",
|
|
183
|
+
" <out-txt-prefix>",
|
|
184
|
+
"",
|
|
185
|
+
" arguments:",
|
|
186
|
+
" <in-file> An input file.",
|
|
187
|
+
" <out-file-prefix> Prefix for the output",
|
|
188
|
+
" file(s).",
|
|
189
|
+
"",
|
|
190
|
+
" options:",
|
|
191
|
+
"",
|
|
192
|
+
" -a, --suffix-length=N Generate suffixes of",
|
|
193
|
+
" length N.",
|
|
194
|
+
` Default: '${suffix_length}'`,
|
|
195
|
+
" --additional-suffix=SUFFIX append an additional SUFFIX",
|
|
196
|
+
" to file names.",
|
|
197
|
+
" -b, --bytes=SIZE Put SIZE bytes per output",
|
|
198
|
+
" file.",
|
|
199
|
+
" -C, --line-bytes=SIZE Put at most SIZE bytes of",
|
|
200
|
+
" records per output file.",
|
|
201
|
+
" -d Use numeric suffixes",
|
|
202
|
+
" starting at 0, not",
|
|
203
|
+
" alphabetic.",
|
|
204
|
+
" --numeric-suffixes[=FROM] Same as -d, but allow",
|
|
205
|
+
" setting the start value.",
|
|
206
|
+
" -l, --lines=NUMBER Put NUMBER lines/records",
|
|
207
|
+
" per output file.",
|
|
208
|
+
" -n, --number=CHUNKS Generate CHUNKS output",
|
|
209
|
+
" files; see explanation",
|
|
210
|
+
" below",
|
|
211
|
+
" -t, --separator=SEP Use SEP instead of newline",
|
|
212
|
+
" as the record separator;",
|
|
213
|
+
" '\0' (zero) specifies the",
|
|
214
|
+
" NUL character.",
|
|
215
|
+
"",
|
|
216
|
+
" -h --help This message.",
|
|
217
|
+
" -v --verbose Enable verbose output.",
|
|
218
|
+
"",
|
|
219
|
+
"The SIZE argument is an integer and optional",
|
|
220
|
+
"unit (example: 10K is 10*1024).",
|
|
221
|
+
"Units are K,M,G,T,P,E,Z,Y,R,Q (powers of 1024)",
|
|
222
|
+
"or KB,MB,... (powers of 1000).",
|
|
223
|
+
"Binary prefixes can be used, too: KiB=K, MiB=M, and so on.",
|
|
224
|
+
"",
|
|
225
|
+
"CHUNKS may be:",
|
|
226
|
+
" N split into N files based on size of input",
|
|
227
|
+
" K/N output Kth of N to standard output",
|
|
228
|
+
" l/N split into N files without splitting lines/records",
|
|
229
|
+
" l/K/N output Kth of N to standard output without",
|
|
230
|
+
" splitting lines/records",
|
|
231
|
+
];
|
|
149
232
|
for ( _line of _text ) {
|
|
150
|
-
|
|
233
|
+
console.log(
|
|
151
234
|
_line);
|
|
152
235
|
}
|
|
153
236
|
process.exit(
|
|
@@ -157,13 +240,12 @@ function
|
|
|
157
240
|
function
|
|
158
241
|
_cmdline_parse_help(
|
|
159
242
|
_argv) {
|
|
160
|
-
|
|
161
|
-
_help_display
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
"h"];
|
|
243
|
+
const
|
|
244
|
+
_help_display =
|
|
245
|
+
_argv[
|
|
246
|
+
"help"] ||
|
|
247
|
+
_argv[
|
|
248
|
+
"h"];
|
|
167
249
|
if ( _help_display ) {
|
|
168
250
|
quiet =
|
|
169
251
|
"n";
|
|
@@ -177,8 +259,9 @@ function
|
|
|
177
259
|
_argv) {
|
|
178
260
|
if ( _argv[
|
|
179
261
|
"_"].length < 1 ) {
|
|
180
|
-
|
|
181
|
-
|
|
262
|
+
const
|
|
263
|
+
_msg =
|
|
264
|
+
"Input file argument required.";
|
|
182
265
|
_msg_error(
|
|
183
266
|
_msg,
|
|
184
267
|
0);
|
|
@@ -189,16 +272,14 @@ function
|
|
|
189
272
|
|
|
190
273
|
function
|
|
191
274
|
_cmdline_parse() {
|
|
192
|
-
|
|
193
|
-
_argv
|
|
194
|
-
|
|
195
|
-
_argv =
|
|
196
|
-
_yargv_get();
|
|
275
|
+
const
|
|
276
|
+
_argv =
|
|
277
|
+
_yargv_get();
|
|
197
278
|
quiet =
|
|
198
279
|
"y";
|
|
199
280
|
runtime_environment =
|
|
200
281
|
"node";
|
|
201
|
-
|
|
282
|
+
_cmdline_parse_help(
|
|
202
283
|
_argv);
|
|
203
284
|
_input_args_check(
|
|
204
285
|
_argv);
|
|
@@ -209,7 +290,7 @@ function
|
|
|
209
290
|
if ( _argv[
|
|
210
291
|
"_"].length < 2 ) {
|
|
211
292
|
output_prefix =
|
|
212
|
-
input_file
|
|
293
|
+
`${input_file}.`;
|
|
213
294
|
}
|
|
214
295
|
if ( "a" in _argv ) {
|
|
215
296
|
suffix_length =
|
|
@@ -221,12 +302,21 @@ function
|
|
|
221
302
|
_argv[
|
|
222
303
|
"suffix-length"];
|
|
223
304
|
}
|
|
305
|
+
if ( "d" in _argv ) {
|
|
306
|
+
numeric_suffix =
|
|
307
|
+
true;
|
|
308
|
+
}
|
|
309
|
+
if ( "suffix-length" in _argv ) {
|
|
310
|
+
suffix_length =
|
|
311
|
+
_argv[
|
|
312
|
+
"suffix-length"];
|
|
313
|
+
}
|
|
224
314
|
chunks_amount =
|
|
225
315
|
_argv[
|
|
226
316
|
"chunks-amount"] ||
|
|
227
317
|
_argv[
|
|
228
318
|
"n"];
|
|
229
|
-
|
|
319
|
+
size_max =
|
|
230
320
|
_argv[
|
|
231
321
|
"size-max"] ||
|
|
232
322
|
_argv[
|
|
@@ -244,27 +334,26 @@ function
|
|
|
244
334
|
|
|
245
335
|
function
|
|
246
336
|
_url_parse() {
|
|
247
|
-
|
|
248
|
-
_argv
|
|
337
|
+
const
|
|
338
|
+
_argv =
|
|
339
|
+
_argv_url_get();
|
|
249
340
|
runtime_environment =
|
|
250
341
|
"browser";
|
|
251
|
-
_argv =
|
|
252
|
-
_argv_url_get();
|
|
253
342
|
input_file =
|
|
254
|
-
|
|
255
|
-
"input_file"
|
|
343
|
+
_argv[
|
|
344
|
+
"input_file"][
|
|
256
345
|
0];
|
|
257
346
|
output_prefix =
|
|
258
|
-
_argv_url_get
|
|
259
|
-
"output_prefix"
|
|
347
|
+
_argv_url_get[
|
|
348
|
+
"output_prefix"][
|
|
260
349
|
0];
|
|
261
350
|
chunks_amount =
|
|
262
|
-
_argv_url_get
|
|
263
|
-
"chunks_amount"
|
|
351
|
+
_argv_url_get[
|
|
352
|
+
"chunks_amount"][
|
|
264
353
|
0];
|
|
265
354
|
quiet =
|
|
266
|
-
_argv_url_get
|
|
267
|
-
"quiet"
|
|
355
|
+
_argv_url_get[
|
|
356
|
+
"quiet"];
|
|
268
357
|
if ( quiet.length === 0 ) {
|
|
269
358
|
quiet =
|
|
270
359
|
"n";
|
|
@@ -272,6 +361,7 @@ function
|
|
|
272
361
|
}
|
|
273
362
|
|
|
274
363
|
_global_variables();
|
|
364
|
+
_overrides_set();
|
|
275
365
|
if ( _cmdline_check(
|
|
276
366
|
"tmcsplit") == true ) {
|
|
277
367
|
_cmdline_parse();
|
|
@@ -286,6 +376,6 @@ app_opts = [
|
|
|
286
376
|
chunks_amount,
|
|
287
377
|
size_max
|
|
288
378
|
];
|
|
289
|
-
|
|
379
|
+
_split.apply(
|
|
290
380
|
null,
|
|
291
381
|
app_opts);
|