encoding-tools 0.0.1 → 0.0.4

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/README.md ADDED
@@ -0,0 +1,85 @@
1
+ [comment]: <> (SPDX-License-Identifier: AGPL-3.0)
2
+
3
+ [comment]: <> (------------------------------------------------------)
4
+ [comment]: <> (Copyright © 2024, 2025, 2026 Pellegrino Prevete)
5
+ [comment]: <> (All rights reserved)
6
+ [comment]: <> (------------------------------------------------------)
7
+
8
+ [comment]: <> (This program is free software: you can redistribute)
9
+ [comment]: <> (it and/or modify it under the terms of the GNU Affero)
10
+ [comment]: <> (General Public License as published by the Free)
11
+ [comment]: <> (Software Foundation, either version 3 of the License.)
12
+
13
+ [comment]: <> (This program is distributed in the hope that it will be)
14
+ [comment]: <> (useful, but WITHOUT ANY WARRANTY; without even the)
15
+ [comment]: <> (implied warranty of MERCHANTABILITY or FITNESS FOR)
16
+ [comment]: <> (A PARTICULAR PURPOSE. See the)
17
+ [comment]: <> (See the GNU Affero General Public License for)
18
+ [comment]: <> (more details.)
19
+
20
+ [comment]: <> (You should have received a copy of the GNU Affero)
21
+ [comment]: <> (General Public License along with this program.)
22
+ [comment]: <> (If not, see <https://www.gnu.org/licenses/>.)
23
+
24
+ # Encoding Tools (`encoding-tools.js`)
25
+
26
+ Simple, easy to read and use collection of Javascript
27
+ encoding tools.
28
+
29
+ This collection is the Javascript programming
30
+ language implementation of
31
+ [Encoding Tools](
32
+ https://github.com/themartiancompany/encoding-tools),
33
+ in which it is included.
34
+
35
+ The tools are a dependency for the
36
+ [Ethereum Virtual Machine File System](
37
+ https://github.com/themartiancompany/evmfs)
38
+ and for the uncensorable Twitter.
39
+
40
+ They depend on the `base64` encoding tool
41
+ and the
42
+ [Crash Javascript](
43
+ https://github.com/themartiancompany/crash-js)
44
+ library.
45
+
46
+ ## Installation
47
+
48
+ The tools in this source repo
49
+ can be installed from source using GNU Make.
50
+
51
+ ```bash
52
+ make \
53
+ install
54
+ ```
55
+
56
+ The collection has been officially published
57
+ on the the uncensorable
58
+ [Ur](
59
+ https://github.com/themartiancompany/ur)
60
+ user repository and application store as
61
+ `encoding-tools`.
62
+ The source code is published on the
63
+ [Ethereum Virtual Machine File System](
64
+ https://github.com/themartiancompany/evmfs)
65
+ so it can't possibly be taken down.
66
+
67
+ To install it from there just type
68
+
69
+ ```bash
70
+ ur \
71
+ encoding-tools
72
+ ```
73
+
74
+ A censorable HTTP Github mirror of the recipe published there,
75
+ containing a full list of the software dependencies needed to run the
76
+ tools is hosted on
77
+ [encoding-tools-ur](
78
+ https://github.com/themartiancompany/encoding-tools-ur).
79
+ Be aware the mirror could go offline any time as Github and more
80
+ in general all HTTP resources are inherently unstable and censorable.
81
+
82
+ ## License
83
+
84
+ This program is released by Pellegrino Prevete under the terms
85
+ of the GNU Affero General Public License version 3.
package/bin2txt CHANGED
@@ -2,63 +2,117 @@
2
2
 
3
3
  // SPDX-License-Identifier: AGPL-3.0-or-later
4
4
 
5
- // ----------------------------------------------------------------------
6
- // Copyright © 2024, 2025 Pellegrino Prevete
7
- //
8
- // All rights reserved
9
- // ----------------------------------------------------------------------
10
- //
11
- // This program is free software: you can redistribute it and/or modify
12
- // it under the terms of the GNU Affero General Public License as published by
13
- // the Free Software Foundation, either version 3 of the License, or
14
- // (at your option) any later version.
15
- //
16
- // This program is distributed in the hope that it will be useful,
17
- // but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- // GNU Affero General Public License for more details.
20
- //
21
- // You should have received a copy of the GNU Affero General Public License
22
- // along with this program. If not, see <https://www.gnu.org/licenses/>.
5
+ /** ----------------------------------------------------------------
6
+ * bin2txt
7
+ * ----------------------------------------------------------------
8
+ * Copyright ©
9
+ * Pellegrino Prevete
10
+ * 2024, 2025, 2026
11
+ *
12
+ * All rights reserved
13
+ * ----------------------------------------------------------------
14
+ *
15
+ * This program is free software: you can redistribute it and/or
16
+ * modify it under the terms of the GNU General Public License as
17
+ * published by the Free Software Foundation, either version 3 of
18
+ * the License, or (at your option) any later version.
19
+ *
20
+ * This program is distributed in the hope that it will be useful,
21
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23
+ * GNU General Public License for more details.
24
+ *
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program.
27
+ * If not, see <https://www.gnu.org/licenses/>.
28
+ */
23
29
 
24
30
  const
25
31
  _libcrash =
26
32
  require(
27
33
  'crash-js');
28
- _cmdline_check =
29
- _libcrash._cmdline_check;
30
- _msg_info =
31
- _libcrash._msg_info;
32
- _msg_error =
33
- _libcrash._msg_error;
34
+ /* global
35
+ _cmdline_check */
36
+ const
37
+ _cmdline_check =
38
+ _libcrash._cmdline_check;
39
+ /* global
40
+ _msg_info */
41
+ const
42
+ _msg_info =
43
+ _libcrash._msg_info;
44
+ /* global
45
+ _msg_error */
46
+ const
47
+ _msg_error =
48
+ _libcrash._msg_error;
49
+ /* global
50
+ _argv_get */
51
+ const
52
+ _argv_get =
53
+ _libcrash._argv_get;
54
+
34
55
  const
35
56
  _encoding_tools =
36
57
  require(
37
58
  "./encoding-tools");
59
+ /* global
60
+ _bin2txt */
38
61
  _bin2txt =
39
62
  _encoding_tools._bin2txt;
40
63
 
41
64
  function
42
65
  _global_variables() {
66
+ /* global
67
+ app_name:
68
+ writable */
43
69
  app_name =
44
70
  "bin2txt";
71
+ /* global
72
+ app_opts:
73
+ writable */
74
+ app_opts =
75
+ [];
76
+ /* global
77
+ encoding_format:
78
+ writable */
45
79
  encoding_format =
46
80
  "";
81
+ /* global
82
+ buffer_size:
83
+ writable */
47
84
  buffer_size =
48
85
  "";
86
+ /* global
87
+ string_length:
88
+ writable */
49
89
  string_length =
50
90
  "";
91
+ /* global
92
+ in_file:
93
+ writable */
51
94
  in_file =
52
95
  "";
96
+ /* global
97
+ out_txt_prefix:
98
+ writable */
53
99
  out_txt_prefix =
54
100
  "";
101
+ /* global
102
+ amount_only:
103
+ writable */
104
+ amount_only =
105
+ "";
106
+ /* global
107
+ quiet:
108
+ writable */
55
109
  quiet =
56
110
  "";
57
111
  }
58
112
 
59
113
  function
60
114
  _overrides_set() {
61
- if ( target_message == "" ) {
115
+ if ( encoding_format == "" ) {
62
116
  encoding_format =
63
117
  "base64";
64
118
  }
@@ -137,7 +191,7 @@ function
137
191
  " -v --verbose Enable verbose output."
138
192
  ];
139
193
  for ( _line of _text ) {
140
- _msg_info(
194
+ console.log(
141
195
  _line);
142
196
  }
143
197
  process.exit(
@@ -148,25 +202,33 @@ function
148
202
  _cmdline_parse() {
149
203
  let
150
204
  _argv,
205
+ _help_display,
151
206
  _msg;
152
207
  _argv =
153
- _yargv_get();
208
+ _argv_get();
209
+ _options =
210
+ _argv[
211
+ "_"];
154
212
  quiet =
155
213
  "y";
156
214
  runtime_environment =
157
215
  "node";
158
- help_display =
159
- _argv[
160
- "help"] ||
161
- _argv[
162
- "h"];
163
- if ( help_display ) {
216
+ if ( _options.indexOf(
217
+ "--help") > -1 ||
218
+ _options.indexOf(
219
+ "-h") > -1) {
220
+ _help_display =
221
+ true;
222
+ }
223
+ if ( _help_display ) {
164
224
  quiet =
165
225
  "n";
166
226
  _usage(
167
227
  0);
168
228
  }
169
- if ( _argv[
229
+ if ( typeof(
230
+ _argv) == "undefined" ||
231
+ _argv[
170
232
  "_"].length < 1 ) {
171
233
  _msg =
172
234
  "Input file argument required.";
@@ -183,7 +245,8 @@ function
183
245
  if ( _argv[
184
246
  "_"].length < 2 ) {
185
247
  out_txt_prefix =
186
- in_file + ".base64"
248
+ in_file +
249
+ ".base64";
187
250
  }
188
251
  if ( "s" in _argv ) {
189
252
  string_length =
@@ -238,16 +301,18 @@ function
238
301
 
239
302
  _global_variables();
240
303
  if ( _cmdline_check(
241
- "bin2txt") == true ) {
304
+ "bin2txt.js") == true ) {
242
305
  _cmdline_parse();
243
306
  }
244
- else {
245
- _url_parse();
246
- }
307
+ _overrides_set();
247
308
  _config_show();
248
309
  app_opts = [
249
310
  in_file,
250
- out_txt_prefix
311
+ out_txt_prefix,
312
+ encoding_format,
313
+ string_length,
314
+ buffer_size,
315
+ amount_only
251
316
  ];
252
317
  _bin2txt.apply(
253
318
  null,