encoding-tools 0.0.10 → 0.0.12
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/bin2txt +0 -1
- package/encoding-tools +5 -0
- package/libbin2txt +0 -5
- package/libtxt2bin +98 -19
- package/package.json +5 -3
- package/txt2bin +17 -5
- package/dist/bin2txt/bin2txt.js +0 -2
- package/dist/bin2txt/fs-worker.js +0 -1
- package/dist/encoding-tools/encoding-tools.js +0 -2
- package/dist/encoding-tools/fs-worker.js +0 -1
- package/dist/libbin2txt/fs-worker.js +0 -1
- package/dist/libbin2txt/libbin2txt.js +0 -2
- package/dist/libtxt2bin/fs-worker.js +0 -1
- package/dist/libtxt2bin/libtxt2bin.js +0 -2
- package/dist/txt2bin/fs-worker.js +0 -1
- package/dist/txt2bin/txt2bin.js +0 -2
package/bin2txt
CHANGED
package/encoding-tools
CHANGED
|
@@ -36,6 +36,9 @@ const
|
|
|
36
36
|
_txt2bin_module =
|
|
37
37
|
require(
|
|
38
38
|
"./libtxt2bin");
|
|
39
|
+
const
|
|
40
|
+
_input_texts_check =
|
|
41
|
+
_txt2bin_module._input_texts_check;
|
|
39
42
|
const
|
|
40
43
|
_txt2bin =
|
|
41
44
|
_txt2bin_module._txt2bin;
|
|
@@ -43,6 +46,8 @@ const
|
|
|
43
46
|
module.exports = {
|
|
44
47
|
_bin2txt:
|
|
45
48
|
_bin2txt,
|
|
49
|
+
_input_texts_check:
|
|
50
|
+
_input_texts_check,
|
|
46
51
|
_txt2bin:
|
|
47
52
|
_txt2bin
|
|
48
53
|
};
|
package/libbin2txt
CHANGED
package/libtxt2bin
CHANGED
|
@@ -34,10 +34,13 @@ const
|
|
|
34
34
|
_base64_stream_module =
|
|
35
35
|
require(
|
|
36
36
|
"base64-stream");
|
|
37
|
+
const
|
|
38
|
+
_base64_decode_stream =
|
|
39
|
+
_base64_stream_module.Base64Decode;
|
|
37
40
|
const
|
|
38
41
|
_fs_module =
|
|
39
42
|
require(
|
|
40
|
-
"
|
|
43
|
+
"tmcfs");
|
|
41
44
|
const
|
|
42
45
|
_write_stream_create =
|
|
43
46
|
_fs_module.createWriteStream;
|
|
@@ -88,6 +91,11 @@ const
|
|
|
88
91
|
const
|
|
89
92
|
_file_append =
|
|
90
93
|
_libcrash._file_append;
|
|
94
|
+
/* global
|
|
95
|
+
_file_exists */
|
|
96
|
+
const
|
|
97
|
+
_file_exists =
|
|
98
|
+
_libcrash._file_exists;
|
|
91
99
|
/* global
|
|
92
100
|
_file_read */
|
|
93
101
|
const
|
|
@@ -136,8 +144,8 @@ const
|
|
|
136
144
|
|
|
137
145
|
async function
|
|
138
146
|
_assemble(
|
|
139
|
-
_input_files,
|
|
140
147
|
_output_file,
|
|
148
|
+
_input_files,
|
|
141
149
|
_argument_type) {
|
|
142
150
|
let
|
|
143
151
|
_data,
|
|
@@ -170,16 +178,17 @@ async function
|
|
|
170
178
|
_file_read(
|
|
171
179
|
_file);
|
|
172
180
|
_file_append(
|
|
173
|
-
|
|
174
|
-
|
|
181
|
+
_output_file,
|
|
182
|
+
_data);
|
|
175
183
|
}
|
|
176
184
|
_msg =
|
|
177
185
|
`Merging finished.`;
|
|
178
186
|
_msg_info(
|
|
179
187
|
_msg);
|
|
188
|
+
return true;
|
|
180
189
|
}
|
|
181
190
|
|
|
182
|
-
function
|
|
191
|
+
async function
|
|
183
192
|
_base64_decode(
|
|
184
193
|
_output_file,
|
|
185
194
|
_input_files,
|
|
@@ -202,31 +211,92 @@ function
|
|
|
202
211
|
_input_files[
|
|
203
212
|
0];
|
|
204
213
|
if ( 0 < _input_files.length ) {
|
|
214
|
+
const
|
|
215
|
+
_tmp_dir =
|
|
216
|
+
await _mktemp();
|
|
205
217
|
_txt =
|
|
206
218
|
_path_join( [
|
|
207
|
-
|
|
219
|
+
_tmp_dir,
|
|
208
220
|
"merge.base64" ]);
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
221
|
+
const
|
|
222
|
+
_assembled =
|
|
223
|
+
await _assemble(
|
|
224
|
+
_txt,
|
|
225
|
+
_input_files,
|
|
226
|
+
_argument_type);
|
|
213
227
|
}
|
|
214
228
|
_msg =
|
|
215
229
|
`Decoding '${_txt}' into '${_output_file}'`;
|
|
216
230
|
_msg_info(
|
|
217
231
|
_msg);
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
232
|
+
const
|
|
233
|
+
_read_opts =
|
|
234
|
+
{"encoding":
|
|
235
|
+
null,
|
|
236
|
+
"flag":
|
|
237
|
+
'r'};
|
|
238
|
+
const
|
|
239
|
+
_txt_stream =
|
|
240
|
+
_read_stream_create(
|
|
241
|
+
_txt);
|
|
242
|
+
const
|
|
243
|
+
_output_file_stream =
|
|
244
|
+
_write_stream_create(
|
|
245
|
+
_output_file);
|
|
246
|
+
const
|
|
247
|
+
_base64_decoder =
|
|
248
|
+
new _base64_decode_stream();
|
|
249
|
+
const
|
|
250
|
+
_write_stream =
|
|
251
|
+
_txt_stream.pipe(
|
|
252
|
+
_base64_decoder).pipe(
|
|
253
|
+
_output_file_stream);
|
|
254
|
+
return _write_stream;
|
|
222
255
|
}
|
|
223
256
|
|
|
224
257
|
function
|
|
258
|
+
_input_texts_check(
|
|
259
|
+
_input_texts) {
|
|
260
|
+
let
|
|
261
|
+
_file,
|
|
262
|
+
_input_file_exists;
|
|
263
|
+
for ( _file of _input_texts ) {
|
|
264
|
+
_input_file_exists =
|
|
265
|
+
_file_exists(
|
|
266
|
+
_file);
|
|
267
|
+
if ( ! _input_file_exists ) {
|
|
268
|
+
const
|
|
269
|
+
_msg =
|
|
270
|
+
`Input file '${_file}' does not ` +
|
|
271
|
+
`exist.`;
|
|
272
|
+
_msg_error(
|
|
273
|
+
_msg,
|
|
274
|
+
1);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
async function
|
|
225
280
|
_txt2bin(
|
|
226
281
|
_output_file,
|
|
227
282
|
_encoding_format,
|
|
228
283
|
_argument_type,
|
|
229
|
-
_input_files
|
|
284
|
+
_input_files,
|
|
285
|
+
_input_files_sanity_check) {
|
|
286
|
+
const
|
|
287
|
+
_input_files_sanity_check_type =
|
|
288
|
+
typeof(
|
|
289
|
+
_input_files_sanity_check);
|
|
290
|
+
if ( _input_files_sanity_check_type == "undefined" ||
|
|
291
|
+
_input_files_sanity_check == "" ||
|
|
292
|
+
_input_files_sanity_check == "true" ) {
|
|
293
|
+
_input_files_sanity_check =
|
|
294
|
+
true;
|
|
295
|
+
}
|
|
296
|
+
if ( _input_files_sanity_check == "false" ) {
|
|
297
|
+
_input_files_sanity_check =
|
|
298
|
+
false;
|
|
299
|
+
}
|
|
230
300
|
if ( _argument_type == "list" ) {
|
|
231
301
|
const
|
|
232
302
|
_list =
|
|
@@ -237,15 +307,24 @@ function
|
|
|
237
307
|
_list).split(
|
|
238
308
|
"\n");
|
|
239
309
|
}
|
|
310
|
+
if ( _input_files_sanity_check ) {
|
|
311
|
+
_input_texts_check(
|
|
312
|
+
_input_files);
|
|
313
|
+
}
|
|
240
314
|
if ( _encoding_format == "base64" ) {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
315
|
+
const
|
|
316
|
+
_write_stream =
|
|
317
|
+
await _base64_decode(
|
|
318
|
+
_output_file,
|
|
319
|
+
_input_files,
|
|
320
|
+
_argument_type);
|
|
321
|
+
return _write_stream;
|
|
245
322
|
}
|
|
246
323
|
}
|
|
247
324
|
|
|
248
325
|
module.exports = {
|
|
326
|
+
_input_texts_check:
|
|
327
|
+
_input_texts_check,
|
|
249
328
|
_txt2bin:
|
|
250
329
|
_txt2bin
|
|
251
330
|
};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name":
|
|
3
3
|
"encoding-tools",
|
|
4
4
|
"version":
|
|
5
|
-
"0.0.
|
|
5
|
+
"0.0.12",
|
|
6
6
|
"description":
|
|
7
7
|
"A multi-language collection of encoding tools.",
|
|
8
8
|
"funding": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"crash-js-webpack":
|
|
63
|
-
"^0.0.
|
|
63
|
+
"^0.0.26",
|
|
64
64
|
"eslint":
|
|
65
65
|
"^10.3.0",
|
|
66
66
|
"globals":
|
|
@@ -80,7 +80,9 @@
|
|
|
80
80
|
"base64-stream":
|
|
81
81
|
"^1.0.0",
|
|
82
82
|
"crash-js":
|
|
83
|
-
"^0.1.
|
|
83
|
+
"^0.1.133",
|
|
84
|
+
"tmcfs":
|
|
85
|
+
"npm:@themartiancompany/fs@^0.0.12",
|
|
84
86
|
"tmcsplit":
|
|
85
87
|
"^0.0.10",
|
|
86
88
|
"yargs":
|
package/txt2bin
CHANGED
|
@@ -122,6 +122,11 @@ const
|
|
|
122
122
|
_encoding_tools =
|
|
123
123
|
require(
|
|
124
124
|
"./encoding-tools");
|
|
125
|
+
/* global
|
|
126
|
+
_input_texts_check */
|
|
127
|
+
const
|
|
128
|
+
_input_texts_check =
|
|
129
|
+
_encoding_tools._input_texts_check;
|
|
125
130
|
/* global
|
|
126
131
|
_txt2bin */
|
|
127
132
|
const
|
|
@@ -180,7 +185,7 @@ function
|
|
|
180
185
|
_line;
|
|
181
186
|
const
|
|
182
187
|
_text = [
|
|
183
|
-
`
|
|
188
|
+
` Make date: ${make_date}`,
|
|
184
189
|
` Runtime environment: ${runtime_environment}`,
|
|
185
190
|
` Argument type: ${argument_type}`,
|
|
186
191
|
` Encoding format: ${encoding_format}`,
|
|
@@ -251,6 +256,8 @@ function
|
|
|
251
256
|
argument_type =
|
|
252
257
|
"file";
|
|
253
258
|
}
|
|
259
|
+
_input_texts_check(
|
|
260
|
+
input_texts);
|
|
254
261
|
}
|
|
255
262
|
|
|
256
263
|
function
|
|
@@ -279,11 +286,13 @@ function
|
|
|
279
286
|
"y";
|
|
280
287
|
_help_display =
|
|
281
288
|
false;
|
|
282
|
-
if (
|
|
289
|
+
if ( _argv[
|
|
290
|
+
"h"]) {
|
|
283
291
|
_help_display =
|
|
284
292
|
true;
|
|
285
293
|
}
|
|
286
|
-
if (
|
|
294
|
+
if ( _argv[
|
|
295
|
+
"help"] ) {
|
|
287
296
|
_help_display =
|
|
288
297
|
true;
|
|
289
298
|
}
|
|
@@ -343,11 +352,13 @@ function
|
|
|
343
352
|
_argv[
|
|
344
353
|
"encoding-format"];
|
|
345
354
|
}
|
|
346
|
-
if (
|
|
355
|
+
if ( _argv[
|
|
356
|
+
"v"] ) {
|
|
347
357
|
verbose =
|
|
348
358
|
true;
|
|
349
359
|
}
|
|
350
|
-
if (
|
|
360
|
+
if ( _argv[
|
|
361
|
+
"verbose"] ) {
|
|
351
362
|
verbose =
|
|
352
363
|
true;
|
|
353
364
|
}
|
|
@@ -397,6 +408,7 @@ if ( _cmdline_check(
|
|
|
397
408
|
else {
|
|
398
409
|
_url_parse();
|
|
399
410
|
}
|
|
411
|
+
_overrides_set();
|
|
400
412
|
_config_show();
|
|
401
413
|
app_opts = [
|
|
402
414
|
output_file,
|