encoding-tools 0.0.4 → 0.0.7

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/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
- require(
33
- 'crash-js');
34
- _error_display =
35
- _libcrash._error_display;
36
- _ext_rm =
37
- _libcrash._ext_rm;
38
- _file_read =
39
- _libcrash._file_read;
40
- _file_write =
41
- _libcrash._file_write;
42
- _fs_worker_start =
43
- _libcrash._fs_worker_start;
44
- _json_read =
45
- _libcrash._json_read;
46
- _ls =
47
- _libcrash._ls;
48
- _mkdir =
49
- _libcrash._mkdir;
50
- _msg_info =
51
- _libcrash._msg_info;
52
- _msg_error =
53
- _libcrash._msg_error;
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
- _ahsi(
57
- _target_message,
58
- _target_planet) {
138
+ _assemble(
139
+ _input_files,
140
+ _output_file,
141
+ _argument_type) {
59
142
  let
60
- _agent,
61
- _dir_content,
62
- _content,
143
+ _data,
63
144
  _dir,
64
145
  _file,
65
146
  _msg,
66
147
  _worker;
67
- _dir =
68
- "/test_dir";
69
- _file =
70
- `${_dir}/test_file`;
71
- _content =
72
- `${_target_message} ${_target_planet}`;
73
- await _fs_worker_start(
74
- "fs-worker.js");
75
- _msg =
76
- `Creating directory '${_dir}':`;
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
- _mkdir(
80
- _dir);
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
- `Writing content '${_content}' to file '${_file}':`;
177
+ `Merging finished.`;
83
178
  _msg_info(
84
179
  _msg);
85
- _file_write(
86
- _file,
87
- _content);
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
- `Content of directory '/':`;
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
- _dir_content);
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
- _dir_content);
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.4",
5
+ "0.0.7",
6
6
  "description":
7
7
  "A multi-language collection of encoding tools.",
8
8
  "funding": {
@@ -19,19 +19,16 @@
19
19
  "AUTHORS.rst",
20
20
  "COPYING",
21
21
  "README.md",
22
- "bin2txt.js",
22
+ "bin2txt",
23
+ "dist",
23
24
  "encoding-tools",
24
25
  "libbin2txt",
25
- "libbin2txt.js",
26
26
  "libtxt2bin",
27
- "libtxt2bin.js",
28
- "fs-worker.js",
29
27
  "fs-worker.webpack.config.js",
30
28
  "index.html",
31
29
  "package.json",
32
30
  "serve.json",
33
31
  "txt2bin",
34
- "txt2bin.js",
35
32
  "webpack.config.js"
36
33
  ],
37
34
  "keywords": [
@@ -43,13 +40,13 @@
43
40
  "https://github.com/themartiancompany/encoding-tools",
44
41
  "bugs": {
45
42
  "url":
46
- "https://github.com/themartiancompany/encoding-tools/issues"
43
+ "https://github.com/themartiancompany/encoding-tools.js/issues"
47
44
  },
48
45
  "repository": {
49
46
  "type":
50
47
  "git",
51
48
  "url":
52
- "git+https://github.com/themartiancompany/encoding-tools.git"
49
+ "git+https://github.com/themartiancompany/encoding-tools.js.git"
53
50
  },
54
51
  "license":
55
52
  "AGPL-3.0-or-later",
@@ -63,27 +60,29 @@
63
60
  },
64
61
  "devDependencies": {
65
62
  "crash-js-webpack":
66
- "^0.0.3",
67
- "flatted":
68
- "3.4.1",
63
+ "^0.0.13",
69
64
  "eslint":
70
- "^10.0.3",
65
+ "^10.3.0",
71
66
  "globals":
72
67
  "^17.3.0",
73
68
  "@eslint/js":
74
69
  "^10.0.1",
75
70
  "safely-serve":
76
71
  "^0.0.9",
72
+ "stream-browserify":
73
+ "^3.0.0",
77
74
  "webpack":
78
75
  "^5.102.1",
79
76
  "webpack-cli":
80
77
  "^6.0.1"
81
78
  },
82
79
  "dependencies": {
80
+ "base64-stream":
81
+ "^1.0.0",
83
82
  "crash-js":
84
- "^0.1.81",
83
+ "^0.1.117",
85
84
  "tmcsplit":
86
- "^0.0.9",
85
+ "^0.0.10",
87
86
  "yargs":
88
87
  "18.0.0"
89
88
  },
@@ -91,16 +90,33 @@
91
90
  "commonjs",
92
91
  "main":
93
92
  "encoding-tools",
94
- "bin":
95
- { "bin2txt.js":
96
- "bin2txt" },
93
+ "bin": {
94
+ "bin2txt":
95
+ "bin2txt",
96
+ "bin2txt.js":
97
+ "bin2txt",
98
+ "txt2bin":
99
+ "txt2bin",
100
+ "txt2bin.js":
101
+ "txt2bin"
102
+ },
97
103
  "scripts": {
98
104
  "build-fs-worker":
99
- "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'",
100
112
  "build-lib":
101
- "npx webpack --mode 'production' --config 'libbin2txt.webpack.config.cjs' --stats-error-details && npx webpack --mode 'production' --config 'libtxt2bin.webpack.config.cjs' --stats-error-details",
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'",
102
118
  "build-bin":
103
- "npx webpack --mode 'production' --config 'bin2txt.webpack.config.cjs' --stats-error-details && npx webpack --mode 'production' --config 'txt2bin.webpack.config.cjs' --stats-error-details",
119
+ "npm run build-bin2txt && npm run build-txt2bin",
104
120
  "build":
105
121
  "npm run lint && npm run build-fs-worker && npm run build-lib && npm run build-bin",
106
122
  "lint":
@@ -108,7 +124,7 @@
108
124
  "publish-pnm":
109
125
  "npm run build && npm publish --access public",
110
126
  "start":
111
- "npx safely-serve --help # index.html --port 3000 --https --no-cache",
127
+ "npx safely-serve 'dist/encoding-tools'",
112
128
  "test":
113
129
  "echo \"Error: no test specified\" && exit 1"
114
130
  }