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/libtxt2bin
CHANGED
|
@@ -27,82 +27,222 @@
|
|
|
27
27
|
* If not, see <https://www.gnu.org/licenses/>.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
+
/* eslint-disable
|
|
31
|
+
no-unused-vars */
|
|
32
|
+
|
|
33
|
+
const
|
|
34
|
+
_base64_stream_module =
|
|
35
|
+
require(
|
|
36
|
+
"base64-stream");
|
|
37
|
+
const
|
|
38
|
+
_fs_module =
|
|
39
|
+
require(
|
|
40
|
+
"fs");
|
|
41
|
+
const
|
|
42
|
+
_write_stream_create =
|
|
43
|
+
_fs_module.createWriteStream;
|
|
44
|
+
const
|
|
45
|
+
_read_stream_create =
|
|
46
|
+
_fs_module.createReadStream;
|
|
47
|
+
const
|
|
48
|
+
_stat =
|
|
49
|
+
_fs_module.stat;
|
|
50
|
+
const
|
|
51
|
+
_promise =
|
|
52
|
+
require(
|
|
53
|
+
"bluebird");
|
|
54
|
+
/* global
|
|
55
|
+
_promise_reject */
|
|
56
|
+
const
|
|
57
|
+
_promise_reject =
|
|
58
|
+
_promise.reject;
|
|
59
|
+
/* global
|
|
60
|
+
_promise_resolve */
|
|
61
|
+
const
|
|
62
|
+
_promise_resolve =
|
|
63
|
+
_promise.resolve;
|
|
64
|
+
const
|
|
65
|
+
_promisify =
|
|
66
|
+
_promise.promisify;
|
|
67
|
+
/* global
|
|
68
|
+
_map_series */
|
|
69
|
+
const
|
|
70
|
+
_map_series =
|
|
71
|
+
_promise.mapSeries;
|
|
30
72
|
const
|
|
31
73
|
_libcrash =
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
74
|
+
require(
|
|
75
|
+
'crash-js');
|
|
76
|
+
/* global
|
|
77
|
+
_cat */
|
|
78
|
+
const
|
|
79
|
+
_cat =
|
|
80
|
+
_libcrash._cat;
|
|
81
|
+
/* global
|
|
82
|
+
_ext_rm */
|
|
83
|
+
const
|
|
84
|
+
_ext_rm =
|
|
85
|
+
_libcrash._ext_rm;
|
|
86
|
+
/* global
|
|
87
|
+
_file_append */
|
|
88
|
+
const
|
|
89
|
+
_file_append =
|
|
90
|
+
_libcrash._file_append;
|
|
91
|
+
/* global
|
|
92
|
+
_file_read */
|
|
93
|
+
const
|
|
94
|
+
_file_read =
|
|
95
|
+
_libcrash._file_read;
|
|
96
|
+
/* global
|
|
97
|
+
_fs_worker_start */
|
|
98
|
+
const
|
|
99
|
+
_fs_worker_start =
|
|
100
|
+
_libcrash._fs_worker_start;
|
|
101
|
+
/* global
|
|
102
|
+
_json_read */
|
|
103
|
+
const
|
|
104
|
+
_json_read =
|
|
105
|
+
_libcrash._json_read;
|
|
106
|
+
/* global
|
|
107
|
+
_ls */
|
|
108
|
+
const
|
|
109
|
+
_ls =
|
|
110
|
+
_libcrash._ls;
|
|
111
|
+
/* global
|
|
112
|
+
_mkdir */
|
|
113
|
+
const
|
|
114
|
+
_mkdir =
|
|
115
|
+
_libcrash._mkdir;
|
|
116
|
+
/* global
|
|
117
|
+
_mktemp */
|
|
118
|
+
const
|
|
119
|
+
_mktemp =
|
|
120
|
+
_libcrash._mktemp;
|
|
121
|
+
/* global
|
|
122
|
+
_msg_info */
|
|
123
|
+
const
|
|
124
|
+
_msg_info =
|
|
125
|
+
_libcrash._msg_info;
|
|
126
|
+
/* global
|
|
127
|
+
_msg_error */
|
|
128
|
+
const
|
|
129
|
+
_msg_error =
|
|
130
|
+
_libcrash._msg_error;
|
|
131
|
+
/* global
|
|
132
|
+
_path_join */
|
|
133
|
+
const
|
|
134
|
+
_path_join =
|
|
135
|
+
_libcrash._path_join;
|
|
54
136
|
|
|
55
137
|
async function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
138
|
+
_assemble(
|
|
139
|
+
_input_files,
|
|
140
|
+
_output_file,
|
|
141
|
+
_argument_type) {
|
|
59
142
|
let
|
|
60
|
-
|
|
61
|
-
_dir_content,
|
|
62
|
-
_content,
|
|
143
|
+
_data,
|
|
63
144
|
_dir,
|
|
64
145
|
_file,
|
|
65
146
|
_msg,
|
|
66
147
|
_worker;
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
148
|
+
if ( _argument_type == "list" ) {
|
|
149
|
+
const
|
|
150
|
+
_list =
|
|
151
|
+
_input_files[
|
|
152
|
+
0];
|
|
153
|
+
_msg =
|
|
154
|
+
`Merging files from list at ` +
|
|
155
|
+
`'${_list}' into '${_output_file}'.`;
|
|
156
|
+
}
|
|
157
|
+
else if ( _argument_type == "file" ) {
|
|
158
|
+
_msg =
|
|
159
|
+
`Merging '${_input_files}' into ` +
|
|
160
|
+
`'${_output_file}'.`;
|
|
161
|
+
}
|
|
77
162
|
_msg_info(
|
|
78
163
|
_msg);
|
|
79
|
-
|
|
80
|
-
|
|
164
|
+
const
|
|
165
|
+
_fs_worker_started =
|
|
166
|
+
await _fs_worker_start(
|
|
167
|
+
"fs-worker.js");
|
|
168
|
+
for ( _file of _input_files ) {
|
|
169
|
+
_data =
|
|
170
|
+
_file_read(
|
|
171
|
+
_file);
|
|
172
|
+
_file_append(
|
|
173
|
+
_data,
|
|
174
|
+
_output_file);
|
|
175
|
+
}
|
|
81
176
|
_msg =
|
|
82
|
-
`
|
|
177
|
+
`Merging finished.`;
|
|
83
178
|
_msg_info(
|
|
84
179
|
_msg);
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function
|
|
183
|
+
_base64_decode(
|
|
184
|
+
_output_file,
|
|
185
|
+
_input_files,
|
|
186
|
+
_argument_type) {
|
|
187
|
+
let
|
|
188
|
+
_data,
|
|
189
|
+
_msg,
|
|
190
|
+
_txt;
|
|
191
|
+
if ( typeof(
|
|
192
|
+
_input_files) == "undefined" ||
|
|
193
|
+
_input_files == [] ||
|
|
194
|
+
_input_files == "" ) {
|
|
195
|
+
_msg =
|
|
196
|
+
"No input files given in input.";
|
|
197
|
+
_msg_error(
|
|
198
|
+
_msg,
|
|
199
|
+
1);
|
|
200
|
+
}
|
|
201
|
+
_txt =
|
|
202
|
+
_input_files[
|
|
203
|
+
0];
|
|
204
|
+
if ( 0 < _input_files.length ) {
|
|
205
|
+
_txt =
|
|
206
|
+
_path_join( [
|
|
207
|
+
_mktemp(),
|
|
208
|
+
"merge.base64" ]);
|
|
209
|
+
_assemble(
|
|
210
|
+
_txt,
|
|
211
|
+
_input_files,
|
|
212
|
+
_argument_type);
|
|
213
|
+
}
|
|
88
214
|
_msg =
|
|
89
|
-
`
|
|
215
|
+
`Decoding '${_txt}' into '${_output_file}'`;
|
|
90
216
|
_msg_info(
|
|
91
217
|
_msg);
|
|
92
|
-
_dir_content =
|
|
93
|
-
_ls(
|
|
94
|
-
"/").unwrap();
|
|
95
218
|
console.log(
|
|
96
|
-
|
|
97
|
-
_msg =
|
|
98
|
-
`Content of directory '${_dir}':`;
|
|
99
|
-
_msg_info(
|
|
100
|
-
_msg);
|
|
101
|
-
_dir_content =
|
|
102
|
-
_ls(
|
|
103
|
-
_dir).unwrap();
|
|
219
|
+
_base64_stream_module);
|
|
104
220
|
console.log(
|
|
105
|
-
|
|
221
|
+
_base64_stream_module.Base64Encode);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function
|
|
225
|
+
_txt2bin(
|
|
226
|
+
_output_file,
|
|
227
|
+
_encoding_format,
|
|
228
|
+
_argument_type,
|
|
229
|
+
_input_files) {
|
|
230
|
+
if ( _argument_type == "list" ) {
|
|
231
|
+
const
|
|
232
|
+
_list =
|
|
233
|
+
_input_files[
|
|
234
|
+
0];
|
|
235
|
+
_input_files =
|
|
236
|
+
_cat(
|
|
237
|
+
_list).split(
|
|
238
|
+
"\n");
|
|
239
|
+
}
|
|
240
|
+
if ( _encoding_format == "base64" ) {
|
|
241
|
+
_base64_decode(
|
|
242
|
+
_output_file,
|
|
243
|
+
_input_files,
|
|
244
|
+
_argument_type);
|
|
245
|
+
}
|
|
106
246
|
}
|
|
107
247
|
|
|
108
248
|
module.exports = {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name":
|
|
3
3
|
"encoding-tools",
|
|
4
4
|
"version":
|
|
5
|
-
"0.0.
|
|
5
|
+
"0.0.6",
|
|
6
6
|
"description":
|
|
7
7
|
"A multi-language collection of encoding tools.",
|
|
8
8
|
"funding": {
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"COPYING",
|
|
21
21
|
"README.md",
|
|
22
22
|
"bin2txt",
|
|
23
|
+
"dist",
|
|
23
24
|
"encoding-tools",
|
|
24
25
|
"libbin2txt",
|
|
25
26
|
"libtxt2bin",
|
|
26
|
-
"fs-worker.js",
|
|
27
27
|
"fs-worker.webpack.config.js",
|
|
28
28
|
"index.html",
|
|
29
29
|
"package.json",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
"https://github.com/themartiancompany/encoding-tools",
|
|
41
41
|
"bugs": {
|
|
42
42
|
"url":
|
|
43
|
-
"https://github.com/themartiancompany/encoding-tools/issues"
|
|
43
|
+
"https://github.com/themartiancompany/encoding-tools.js/issues"
|
|
44
44
|
},
|
|
45
45
|
"repository": {
|
|
46
46
|
"type":
|
|
47
47
|
"git",
|
|
48
48
|
"url":
|
|
49
|
-
"git+https://github.com/themartiancompany/encoding-tools.git"
|
|
49
|
+
"git+https://github.com/themartiancompany/encoding-tools.js.git"
|
|
50
50
|
},
|
|
51
51
|
"license":
|
|
52
52
|
"AGPL-3.0-or-later",
|
|
@@ -60,25 +60,29 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"crash-js-webpack":
|
|
63
|
-
"^0.0.
|
|
63
|
+
"^0.0.12",
|
|
64
64
|
"eslint":
|
|
65
|
-
"^10.0
|
|
65
|
+
"^10.3.0",
|
|
66
66
|
"globals":
|
|
67
67
|
"^17.3.0",
|
|
68
68
|
"@eslint/js":
|
|
69
69
|
"^10.0.1",
|
|
70
70
|
"safely-serve":
|
|
71
71
|
"^0.0.9",
|
|
72
|
+
"stream-browserify":
|
|
73
|
+
"^3.0.0",
|
|
72
74
|
"webpack":
|
|
73
75
|
"^5.102.1",
|
|
74
76
|
"webpack-cli":
|
|
75
77
|
"^6.0.1"
|
|
76
78
|
},
|
|
77
79
|
"dependencies": {
|
|
80
|
+
"base64-stream":
|
|
81
|
+
"^1.0.0",
|
|
78
82
|
"crash-js":
|
|
79
|
-
"^0.1.
|
|
83
|
+
"^0.1.116",
|
|
80
84
|
"tmcsplit":
|
|
81
|
-
"^0.0.
|
|
85
|
+
"^0.0.10",
|
|
82
86
|
"yargs":
|
|
83
87
|
"18.0.0"
|
|
84
88
|
},
|
|
@@ -86,16 +90,33 @@
|
|
|
86
90
|
"commonjs",
|
|
87
91
|
"main":
|
|
88
92
|
"encoding-tools",
|
|
89
|
-
"bin":
|
|
90
|
-
|
|
91
|
-
|
|
93
|
+
"bin": {
|
|
94
|
+
"bin2txt":
|
|
95
|
+
"bin2txt",
|
|
96
|
+
"bin2txt.js":
|
|
97
|
+
"bin2txt",
|
|
98
|
+
"txt2bin":
|
|
99
|
+
"txt2bin",
|
|
100
|
+
"txt2bin.js":
|
|
101
|
+
"txt2bin"
|
|
102
|
+
},
|
|
92
103
|
"scripts": {
|
|
93
104
|
"build-fs-worker":
|
|
94
|
-
"npx webpack --mode 'production' --config 'fs-worker.webpack.config.cjs' --stats-error-details",
|
|
105
|
+
"npx webpack --mode 'production' --config 'fs-worker.webpack.config.cjs' --stats-error-details && for _target in 'bin2txt' 'encoding-tools' 'libbin2txt' 'libtxt2bin' 'txt2bin'; do cp 'fs-worker.js' 'dist/'${_target}; done",
|
|
106
|
+
"build-encoding-tools":
|
|
107
|
+
"npx webpack --mode 'production' --config 'webpack.config.cjs' --stats-error-details && mv 'libbin2txt.js' 'dist/encoding-tools'",
|
|
108
|
+
"build-libbin2txt":
|
|
109
|
+
"npx webpack --mode 'production' --config 'libbin2txt.webpack.config.cjs' --stats-error-details && mv 'libbin2txt.js' 'dist/libbin2txt'",
|
|
110
|
+
"build-libtxt2bin":
|
|
111
|
+
"npx webpack --mode 'production' --config 'libtxt2bin.webpack.config.cjs' --stats-error-details && mv 'libtxt2bin.js' 'dist/libtxt2bin'",
|
|
95
112
|
"build-lib":
|
|
96
|
-
"
|
|
113
|
+
"npm run build-encoding-tools && npm run build-libbin2txt && npm run build-libtxt2bin",
|
|
114
|
+
"build-bin2txt":
|
|
115
|
+
"npx webpack --mode 'production' --config 'bin2txt.webpack.config.cjs' --stats-error-details && mv 'bin2txt.js' 'dist/bin2txt'",
|
|
116
|
+
"build-txt2bin":
|
|
117
|
+
"npx webpack --mode 'production' --config 'txt2bin.webpack.config.cjs' --stats-error-details && mv 'txt2bin.js' 'dist/txt2bin'",
|
|
97
118
|
"build-bin":
|
|
98
|
-
"
|
|
119
|
+
"npm run build-bin2txt && npm run build-txt2bin",
|
|
99
120
|
"build":
|
|
100
121
|
"npm run lint && npm run build-fs-worker && npm run build-lib && npm run build-bin",
|
|
101
122
|
"lint":
|
|
@@ -103,7 +124,7 @@
|
|
|
103
124
|
"publish-pnm":
|
|
104
125
|
"npm run build && npm publish --access public",
|
|
105
126
|
"start":
|
|
106
|
-
"npx safely-serve
|
|
127
|
+
"npx safely-serve 'dist/encoding-tools'",
|
|
107
128
|
"test":
|
|
108
129
|
"echo \"Error: no test specified\" && exit 1"
|
|
109
130
|
}
|