encoding-tools 0.0.9 → 0.0.10

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/libbin2txt CHANGED
@@ -135,7 +135,8 @@ async function
135
135
  _out,
136
136
  _buffer_size_bytes) {
137
137
  let
138
- _msg;
138
+ _msg,
139
+ _output_files;
139
140
  const
140
141
  _size_max =
141
142
  0;
@@ -153,56 +154,69 @@ async function
153
154
  Math.ceil(
154
155
  _in_size_bytes /
155
156
  _buffer_size_bytes);
156
- _msg =
157
- `Splitting file '${_in}' in ` +
158
- `'${_blocks_total}' blocks of ` +
159
- `'${_buffer_size_bytes}' bytes.`;
160
- _msg_info(
161
- _msg);
162
- const
163
- _split_opts = [
164
- _in,
165
- `${_out}.block.`,
166
- _blocks_total,
167
- _size_max
168
- ];
169
- const
157
+ if ( 1 < _blocks_total ) {
158
+ _msg =
159
+ `Splitting file '${_in}' in ` +
160
+ `'${_blocks_total}' blocks of ` +
161
+ `'${_buffer_size_bytes}' bytes.`;
162
+ _msg_info(
163
+ _msg);
164
+ const
165
+ _split_opts = [
166
+ _in,
167
+ `${_out}.block.`,
168
+ _blocks_total,
169
+ _size_max
170
+ ];
170
171
  _output_files =
171
172
  await _split.apply(
172
173
  null,
173
174
  _split_opts);
174
- _msg =
175
- "Done.";
176
- _msg_info(
177
- _msg);
175
+ _msg =
176
+ "Done.";
177
+ _msg_info(
178
+ _msg);
179
+ }
180
+ else {
181
+ _output_files = [
182
+ _in
183
+ ];
184
+ }
178
185
  return _output_files;
179
186
  }
180
187
 
181
- function
188
+ async function
182
189
  _base64_block_encode(
183
190
  _file) {
184
191
  let
185
192
  _string;
193
+ const
194
+ _cat_opts = {
195
+ "encoding":
196
+ null,
197
+ "flag":
198
+ "r"};
186
199
  const
187
200
  _content =
188
201
  _cat(
189
- _file);
202
+ _file,
203
+ _cat_opts);
190
204
  if ( typeof window === 'undefined' &&
191
205
  ( typeof global !== 'undefined' &&
192
206
  global.global === global ) &&
193
207
  typeof __webpack_require__ !== 'function' ) {
194
- const
195
- _buffer =
196
- Buffer.from(
197
- _content);
208
+ // const
209
+ // _buffer =
210
+ // await Buffer.from(
211
+ // _content);
198
212
  _string =
199
- _buffer.toString(
213
+ _content.toString(
200
214
  "base64");
201
215
  }
202
216
  else {
203
217
  _string =
204
- btoa(
205
- _string);
218
+ await btoa(
219
+ _content);
206
220
  }
207
221
  return _string;
208
222
  }
@@ -230,6 +244,7 @@ async function
230
244
  _chunk_current +
231
245
  _total /
232
246
  _length);
247
+ console.log("prefix", _prefix);
233
248
  if ( _chunks < 2 ) {
234
249
  _out =
235
250
  _prefix;
@@ -264,7 +279,7 @@ async function
264
279
  _msg_info(
265
280
  _msg);
266
281
  if ( _chunk < _chunks ) {
267
- _printf(
282
+ _file_write(
268
283
  _out,
269
284
  _cut);
270
285
  }
@@ -282,7 +297,7 @@ async function
282
297
  _msg);
283
298
  _file_write(
284
299
  _out,
285
- _cut);
300
+ `${_cut}\n`);
286
301
  }
287
302
  }
288
303
  }
@@ -307,7 +322,7 @@ async function
307
322
  _msg;
308
323
  const
309
324
  _txt =
310
- _base64_block_encode(
325
+ await _base64_block_encode(
311
326
  _block);
312
327
  _msg =
313
328
  `Block '${_block}' encoded ` +
@@ -374,12 +389,11 @@ async function
374
389
  _amount_only) {
375
390
  let
376
391
  _block,
377
- _chunk_current,
378
- _chunks_total,
379
392
  _block_current,
380
393
  _block_last,
394
+ _chunk_current,
395
+ _chunks_total,
381
396
  _msg,
382
- _rm_args,
383
397
  _worker;
384
398
  if ( typeof window !== 'undefined' ) {
385
399
  const
@@ -423,7 +437,7 @@ async function
423
437
  }
424
438
  if ( _format === "base64" ) {
425
439
  _chunk_current =
426
- _base64_encode(
440
+ await _base64_encode(
427
441
  _block,
428
442
  _chunk_current,
429
443
  _length,
@@ -444,11 +458,18 @@ async function
444
458
  1);
445
459
  }
446
460
  }
461
+ const
462
+ _rm_args =
463
+ [];
447
464
  for ( _block of _blocks ) {
448
- _rm_args = [
449
- _block
450
- ];
451
- _rm(
465
+ if ( _block != _in ) {
466
+ _rm_args.push(
467
+ _block);
468
+ }
469
+ }
470
+ if ( 0 < _rm_args.length ) {
471
+ _rm.apply(
472
+ null,
452
473
  _rm_args);
453
474
  }
454
475
  if ( _amount_only === "true" ) {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name":
3
3
  "encoding-tools",
4
4
  "version":
5
- "0.0.9",
5
+ "0.0.10",
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.19",
63
+ "^0.0.20",
64
64
  "eslint":
65
65
  "^10.3.0",
66
66
  "globals":
@@ -80,7 +80,7 @@
80
80
  "base64-stream":
81
81
  "^1.0.0",
82
82
  "crash-js":
83
- "^0.1.125",
83
+ "^0.1.127",
84
84
  "tmcsplit":
85
85
  "^0.0.10",
86
86
  "yargs":