encoding-tools 0.0.2 → 0.0.6
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 +18 -12
- package/README.md +4 -0
- package/bin2txt +187 -86
- package/{fs-worker.js → dist/bin2txt/fs-worker.js} +1 -1
- package/dist/bin2txt/index.html +31 -0
- package/dist/encoding-tools/fs-worker.js +1 -0
- package/dist/encoding-tools/index.html +31 -0
- package/dist/libbin2txt/fs-worker.js +1 -0
- package/dist/libbin2txt/index.html +31 -0
- package/dist/libtxt2bin/fs-worker.js +1 -0
- package/dist/libtxt2bin/index.html +31 -0
- package/dist/txt2bin/fs-worker.js +1 -0
- package/dist/txt2bin/index.html +31 -0
- package/encoding-tools +48 -0
- package/libbin2txt +379 -93
- package/libtxt2bin +197 -57
- package/package.json +36 -15
- package/txt2bin +306 -140
package/txt2bin
CHANGED
|
@@ -27,193 +27,355 @@
|
|
|
27
27
|
* If not, see <https://www.gnu.org/licenses/>.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
+
/* eslint-disable
|
|
31
|
+
no-unused-vars */
|
|
32
|
+
|
|
33
|
+
// Crash Javascript global variables
|
|
34
|
+
|
|
35
|
+
/* global
|
|
36
|
+
quiet:
|
|
37
|
+
writable */
|
|
38
|
+
/* global
|
|
39
|
+
runtime_environment:
|
|
40
|
+
writable */
|
|
41
|
+
|
|
30
42
|
const
|
|
31
43
|
_libcrash =
|
|
32
44
|
require(
|
|
33
45
|
'crash-js');
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
/* global
|
|
47
|
+
_argv_get */
|
|
48
|
+
const
|
|
49
|
+
_argv_get =
|
|
50
|
+
_libcrash._argv_get;
|
|
51
|
+
/* global
|
|
52
|
+
_argv_url_get */
|
|
53
|
+
const
|
|
54
|
+
_argv_url_get =
|
|
55
|
+
_libcrash._argv_url_get;
|
|
56
|
+
/* global
|
|
57
|
+
_cmdline_check */
|
|
58
|
+
const
|
|
59
|
+
_cmdline_check =
|
|
60
|
+
_libcrash._cmdline_check;
|
|
61
|
+
/* global
|
|
62
|
+
_error_display */
|
|
63
|
+
const
|
|
64
|
+
_error_display =
|
|
65
|
+
_libcrash._error_display;
|
|
66
|
+
/* global
|
|
67
|
+
_ext_rm */
|
|
68
|
+
const
|
|
69
|
+
_ext_rm =
|
|
70
|
+
_libcrash._ext_rm;
|
|
71
|
+
/* global
|
|
72
|
+
_file_read */
|
|
73
|
+
const
|
|
74
|
+
_file_read =
|
|
75
|
+
_libcrash._file_read;
|
|
76
|
+
/* global
|
|
77
|
+
_file_write */
|
|
78
|
+
const
|
|
44
79
|
_file_write =
|
|
45
80
|
_libcrash._file_write;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
81
|
+
/* global
|
|
82
|
+
_fs_worker_start */
|
|
83
|
+
const
|
|
84
|
+
_fs_worker_start =
|
|
85
|
+
_libcrash._fs_worker_start;
|
|
86
|
+
/* global
|
|
87
|
+
_get_date_human */
|
|
88
|
+
const
|
|
89
|
+
_get_date_human =
|
|
90
|
+
_libcrash._get_date_human;
|
|
91
|
+
/* global
|
|
92
|
+
_json_read */
|
|
93
|
+
const
|
|
94
|
+
_json_read =
|
|
95
|
+
_libcrash._json_read;
|
|
96
|
+
/* global
|
|
97
|
+
_ls */
|
|
98
|
+
const
|
|
99
|
+
_ls =
|
|
100
|
+
_libcrash._ls;
|
|
101
|
+
/* global
|
|
102
|
+
_mkdir */
|
|
103
|
+
const
|
|
104
|
+
_mkdir =
|
|
105
|
+
_libcrash._mkdir;
|
|
106
|
+
/* global
|
|
107
|
+
_msg_info */
|
|
108
|
+
const
|
|
109
|
+
_msg_info =
|
|
110
|
+
_libcrash._msg_info;
|
|
111
|
+
/* global
|
|
112
|
+
_msg_error */
|
|
113
|
+
const
|
|
114
|
+
_msg_error =
|
|
115
|
+
_libcrash._msg_error;
|
|
116
|
+
/* global
|
|
117
|
+
_process_exit */
|
|
118
|
+
const
|
|
119
|
+
_process_exit =
|
|
120
|
+
_libcrash._process_exit;
|
|
121
|
+
const
|
|
122
|
+
_encoding_tools =
|
|
123
|
+
require(
|
|
124
|
+
"./encoding-tools");
|
|
125
|
+
/* global
|
|
126
|
+
_txt2bin */
|
|
127
|
+
const
|
|
128
|
+
_txt2bin =
|
|
129
|
+
_encoding_tools._txt2bin;
|
|
58
130
|
|
|
59
131
|
function
|
|
60
132
|
_global_variables() {
|
|
133
|
+
/* global
|
|
134
|
+
app_name:
|
|
135
|
+
writable */
|
|
61
136
|
app_name =
|
|
62
|
-
"
|
|
63
|
-
|
|
137
|
+
"txt2bin";
|
|
138
|
+
/* global
|
|
139
|
+
app_opts:
|
|
140
|
+
writable */
|
|
141
|
+
app_opts =
|
|
142
|
+
[];
|
|
143
|
+
/* global
|
|
144
|
+
make_date:
|
|
145
|
+
writable */
|
|
146
|
+
make_date =
|
|
64
147
|
"";
|
|
65
|
-
|
|
148
|
+
/* global
|
|
149
|
+
output_file:
|
|
150
|
+
writable */
|
|
151
|
+
output_file =
|
|
66
152
|
"";
|
|
67
|
-
|
|
153
|
+
/* global
|
|
154
|
+
encoding_format:
|
|
155
|
+
writable */
|
|
156
|
+
encoding_format =
|
|
68
157
|
"";
|
|
158
|
+
/* global
|
|
159
|
+
argument_type:
|
|
160
|
+
writable */
|
|
161
|
+
argument_type =
|
|
162
|
+
"";
|
|
163
|
+
/* global
|
|
164
|
+
input_texts:
|
|
165
|
+
writable */
|
|
166
|
+
input_texts =
|
|
167
|
+
[];
|
|
69
168
|
quiet =
|
|
70
169
|
"";
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
_target_planet) {
|
|
77
|
-
let
|
|
78
|
-
_agent,
|
|
79
|
-
_dir_content,
|
|
80
|
-
_content,
|
|
81
|
-
_dir,
|
|
82
|
-
_file,
|
|
83
|
-
_msg,
|
|
84
|
-
_worker;
|
|
85
|
-
_dir =
|
|
86
|
-
"/test_dir";
|
|
87
|
-
_file =
|
|
88
|
-
`${_dir}/test_file`;
|
|
89
|
-
_content =
|
|
90
|
-
`${_target_message} ${_target_planet}`;
|
|
91
|
-
await _fs_worker_start(
|
|
92
|
-
"fs-worker.js");
|
|
93
|
-
_msg =
|
|
94
|
-
`Creating directory '${_dir}':`;
|
|
95
|
-
_msg_info(
|
|
96
|
-
_msg);
|
|
97
|
-
_mkdir(
|
|
98
|
-
_dir);
|
|
99
|
-
_msg =
|
|
100
|
-
`Writing content '${_content}' to file '${_file}':`;
|
|
101
|
-
_msg_info(
|
|
102
|
-
_msg);
|
|
103
|
-
_file_write(
|
|
104
|
-
_file,
|
|
105
|
-
_content);
|
|
106
|
-
_msg =
|
|
107
|
-
`Content of directory '/':`;
|
|
108
|
-
_msg_info(
|
|
109
|
-
_msg);
|
|
110
|
-
_dir_content =
|
|
111
|
-
_ls(
|
|
112
|
-
"/").unwrap();
|
|
113
|
-
console.log(
|
|
114
|
-
_dir_content);
|
|
115
|
-
_msg =
|
|
116
|
-
`Content of directory '${_dir}':`;
|
|
117
|
-
_msg_info(
|
|
118
|
-
_msg);
|
|
119
|
-
_dir_content =
|
|
120
|
-
_ls(
|
|
121
|
-
_dir).unwrap();
|
|
122
|
-
console.log(
|
|
123
|
-
_dir_content);
|
|
170
|
+
/* global
|
|
171
|
+
verbose:
|
|
172
|
+
writable */
|
|
173
|
+
verbose =
|
|
174
|
+
"";
|
|
124
175
|
}
|
|
125
176
|
|
|
126
177
|
function
|
|
127
178
|
_config_show() {
|
|
128
179
|
let
|
|
129
|
-
_line
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
180
|
+
_line;
|
|
181
|
+
const
|
|
182
|
+
_text = [
|
|
183
|
+
` Call date: ${make_date}`,
|
|
184
|
+
` Runtime environment: ${runtime_environment}`,
|
|
185
|
+
` Argument type: ${argument_type}`,
|
|
186
|
+
` Encoding format: ${encoding_format}`,
|
|
187
|
+
` Output file: ${output_file}`,
|
|
188
|
+
` Input text file(s): ${input_texts}`,
|
|
189
|
+
];
|
|
136
190
|
for ( _line of _text ) {
|
|
137
191
|
_msg_info(
|
|
138
192
|
_line);
|
|
139
193
|
}
|
|
140
194
|
}
|
|
141
195
|
|
|
142
|
-
|
|
143
196
|
function
|
|
144
197
|
_usage(
|
|
145
198
|
_exit_code) {
|
|
146
199
|
let
|
|
147
|
-
_line
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
200
|
+
_line;
|
|
201
|
+
const
|
|
202
|
+
_text = [
|
|
203
|
+
"",
|
|
204
|
+
"Converts text to binary.",
|
|
205
|
+
"",
|
|
206
|
+
"Usage:",
|
|
207
|
+
` ${app_name}`,
|
|
208
|
+
` [options]`,
|
|
209
|
+
` <out-file>`,
|
|
210
|
+
` [in-text]`,
|
|
211
|
+
"",
|
|
212
|
+
" options:",
|
|
213
|
+
" -t, --argument-type Possible values are 'file' and",
|
|
214
|
+
" <type> 'list'.",
|
|
215
|
+
" When it is 'file' the arguments",
|
|
216
|
+
" are the encoded file paths,",
|
|
217
|
+
" when it is 'list' the argument is",
|
|
218
|
+
" a file containing the paths of the",
|
|
219
|
+
" encoded files.",
|
|
220
|
+
` Default: '${argument_type}`,
|
|
221
|
+
" -f --encoding-format Encoding format ('base64').",
|
|
222
|
+
` <format> Default: '${encoding_format}'`,
|
|
223
|
+
"",
|
|
224
|
+
" -h This message.",
|
|
225
|
+
" -v Enable verbose output",
|
|
226
|
+
""
|
|
227
|
+
];
|
|
162
228
|
for ( _line of _text ) {
|
|
163
229
|
_msg_info(
|
|
164
230
|
_line);
|
|
165
231
|
}
|
|
166
|
-
|
|
232
|
+
_process_exit(
|
|
167
233
|
_exit_code);
|
|
168
234
|
}
|
|
169
235
|
|
|
236
|
+
function
|
|
237
|
+
_overrides_set() {
|
|
238
|
+
if ( make_date == "" ) {
|
|
239
|
+
make_date =
|
|
240
|
+
_get_date_human();
|
|
241
|
+
}
|
|
242
|
+
if ( encoding_format == "" ||
|
|
243
|
+
typeof(
|
|
244
|
+
encoding_format) == "undefined" ) {
|
|
245
|
+
encoding_format =
|
|
246
|
+
"base64";
|
|
247
|
+
}
|
|
248
|
+
if ( argument_type == "" ||
|
|
249
|
+
typeof(
|
|
250
|
+
argument_type) == "undefined" ) {
|
|
251
|
+
argument_type =
|
|
252
|
+
"file";
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
170
256
|
function
|
|
171
257
|
_cmdline_parse() {
|
|
258
|
+
let
|
|
259
|
+
_help_display,
|
|
260
|
+
_msg;
|
|
261
|
+
const
|
|
262
|
+
_argv_args = {
|
|
263
|
+
"booleans": [
|
|
264
|
+
"h",
|
|
265
|
+
"help",
|
|
266
|
+
"v",
|
|
267
|
+
"verbose"
|
|
268
|
+
]
|
|
269
|
+
};
|
|
270
|
+
const
|
|
271
|
+
_argv =
|
|
272
|
+
_argv_get(
|
|
273
|
+
_argv_args);
|
|
274
|
+
const
|
|
275
|
+
_options =
|
|
276
|
+
_argv[
|
|
277
|
+
"_"];
|
|
172
278
|
quiet =
|
|
173
279
|
"y";
|
|
280
|
+
_help_display =
|
|
281
|
+
false;
|
|
282
|
+
if ( "h" in _argv ) {
|
|
283
|
+
_help_display =
|
|
284
|
+
true;
|
|
285
|
+
}
|
|
286
|
+
if ( "help" in _argv ) {
|
|
287
|
+
_help_display =
|
|
288
|
+
true;
|
|
289
|
+
}
|
|
174
290
|
runtime_environment =
|
|
175
291
|
"node";
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
292
|
+
if ( _options.indexOf(
|
|
293
|
+
"--help") > -1 ||
|
|
294
|
+
_options.indexOf(
|
|
295
|
+
"-h") > -1) {
|
|
296
|
+
_help_display =
|
|
297
|
+
true;
|
|
298
|
+
}
|
|
299
|
+
if ( _help_display ) {
|
|
300
|
+
quiet =
|
|
301
|
+
"n";
|
|
302
|
+
_overrides_set();
|
|
303
|
+
_usage(
|
|
304
|
+
0);
|
|
305
|
+
}
|
|
306
|
+
if ( typeof(
|
|
307
|
+
_argv) == "undefined" ||
|
|
308
|
+
_argv[
|
|
309
|
+
"_"].length < 1 ) {
|
|
310
|
+
_msg =
|
|
311
|
+
"Input file argument required.";
|
|
312
|
+
_msg_error(
|
|
313
|
+
_msg,
|
|
314
|
+
0);
|
|
315
|
+
_usage(
|
|
316
|
+
1);
|
|
317
|
+
}
|
|
318
|
+
output_file =
|
|
319
|
+
_argv[
|
|
320
|
+
"_"][
|
|
321
|
+
0];
|
|
322
|
+
input_texts =
|
|
323
|
+
_argv[
|
|
324
|
+
"_"].slice(
|
|
325
|
+
1);
|
|
326
|
+
if ( "t" in _argv ) {
|
|
327
|
+
argument_type =
|
|
328
|
+
_argv[
|
|
329
|
+
"t"];
|
|
330
|
+
}
|
|
331
|
+
if ( "argument-type" in _argv ) {
|
|
332
|
+
argument_type =
|
|
333
|
+
_argv[
|
|
334
|
+
"argument-type"];
|
|
335
|
+
}
|
|
336
|
+
if ( "f" in _argv ) {
|
|
337
|
+
encoding_format =
|
|
338
|
+
_argv[
|
|
339
|
+
"f"];
|
|
340
|
+
}
|
|
341
|
+
if ( "encoding-format" in _argv ) {
|
|
342
|
+
encoding_format =
|
|
343
|
+
_argv[
|
|
344
|
+
"encoding-format"];
|
|
345
|
+
}
|
|
346
|
+
if ( "v" in _argv ) {
|
|
347
|
+
verbose =
|
|
348
|
+
true;
|
|
349
|
+
}
|
|
350
|
+
if ( "verbose" in _argv ) {
|
|
351
|
+
verbose =
|
|
352
|
+
true;
|
|
353
|
+
}
|
|
354
|
+
if ( verbose ) {
|
|
355
|
+
quiet =
|
|
356
|
+
"n";
|
|
357
|
+
}
|
|
201
358
|
}
|
|
202
359
|
|
|
203
360
|
function
|
|
204
361
|
_url_parse() {
|
|
205
|
-
let
|
|
206
|
-
_argv;
|
|
207
362
|
runtime_environment =
|
|
208
363
|
"browser";
|
|
209
|
-
|
|
210
|
-
_argv_url_get(
|
|
211
|
-
|
|
364
|
+
encoding_format =
|
|
365
|
+
_argv_url_get(
|
|
366
|
+
"encoding_format")[
|
|
367
|
+
0];
|
|
368
|
+
argument_type =
|
|
369
|
+
_argv_url_get(
|
|
370
|
+
"argument_type")[
|
|
371
|
+
0];
|
|
372
|
+
output_file =
|
|
212
373
|
_argv_url_get(
|
|
213
|
-
"
|
|
214
|
-
|
|
374
|
+
"output_file")[
|
|
375
|
+
0];
|
|
376
|
+
input_texts =
|
|
215
377
|
_argv_url_get(
|
|
216
|
-
"
|
|
378
|
+
"input_texts");
|
|
217
379
|
quiet =
|
|
218
380
|
_argv_url_get(
|
|
219
381
|
"quiet");
|
|
@@ -227,7 +389,9 @@ _global_variables();
|
|
|
227
389
|
|
|
228
390
|
_global_variables();
|
|
229
391
|
if ( _cmdline_check(
|
|
230
|
-
"
|
|
392
|
+
"txt2bin") ||
|
|
393
|
+
_cmdline_check(
|
|
394
|
+
"txt2bin.js") ) {
|
|
231
395
|
_cmdline_parse();
|
|
232
396
|
}
|
|
233
397
|
else {
|
|
@@ -235,9 +399,11 @@ else {
|
|
|
235
399
|
}
|
|
236
400
|
_config_show();
|
|
237
401
|
app_opts = [
|
|
238
|
-
|
|
239
|
-
|
|
402
|
+
output_file,
|
|
403
|
+
encoding_format,
|
|
404
|
+
argument_type,
|
|
405
|
+
input_texts
|
|
240
406
|
];
|
|
241
|
-
|
|
407
|
+
_txt2bin.apply(
|
|
242
408
|
null,
|
|
243
409
|
app_opts);
|