@reliverse/relinka 1.1.7 → 1.1.8

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.
Files changed (121) hide show
  1. package/dist-npm/components/anykey/index.js +57 -77
  2. package/dist-npm/components/block/block.js +48 -61
  3. package/dist-npm/components/checkbox/index.js +178 -211
  4. package/dist-npm/components/confirm/confirm-main.js +85 -122
  5. package/dist-npm/components/confirm/confirm-three.js +24 -27
  6. package/dist-npm/components/confirm/index.js +36 -45
  7. package/dist-npm/components/core/Separator.js +15 -17
  8. package/dist-npm/components/core/create-prompt.js +101 -124
  9. package/dist-npm/components/core/errors.js +19 -15
  10. package/dist-npm/components/core/hook-engine.js +91 -120
  11. package/dist-npm/components/core/index.js +12 -12
  12. package/dist-npm/components/core/key.js +16 -6
  13. package/dist-npm/components/core/lines.js +45 -54
  14. package/dist-npm/components/core/make-theme.js +21 -30
  15. package/dist-npm/components/core/position.js +27 -23
  16. package/dist-npm/components/core/promise-polyfill.js +11 -14
  17. package/dist-npm/components/core/screen-manager.js +59 -74
  18. package/dist-npm/components/core/theme.js +22 -32
  19. package/dist-npm/components/core/use-effect.js +9 -15
  20. package/dist-npm/components/core/use-keypress.js +19 -23
  21. package/dist-npm/components/core/use-memo.js +10 -16
  22. package/dist-npm/components/core/use-pagination.js +33 -32
  23. package/dist-npm/components/core/use-prefix.js +40 -38
  24. package/dist-npm/components/core/use-ref.js +2 -5
  25. package/dist-npm/components/core/use-state.js +15 -23
  26. package/dist-npm/components/core/useKeyPress.js +14 -17
  27. package/dist-npm/components/core/usePromptState.js +8 -14
  28. package/dist-npm/components/core/utils.js +7 -16
  29. package/dist-npm/components/date/date.js +173 -204
  30. package/dist-npm/components/editor/index.js +71 -92
  31. package/dist-npm/components/expand/index.js +96 -124
  32. package/dist-npm/components/figures/index.js +283 -294
  33. package/dist-npm/components/input/index.js +61 -87
  34. package/dist-npm/components/input/text-main.js +97 -124
  35. package/dist-npm/components/input/text.js +24 -28
  36. package/dist-npm/components/instance/basic.js +17 -25
  37. package/dist-npm/components/instance/browser.js +14 -18
  38. package/dist-npm/components/instance/reporter/basic.js +46 -65
  39. package/dist-npm/components/instance/reporter/browser.js +44 -47
  40. package/dist-npm/components/instance/reporter/fancy.js +83 -96
  41. package/dist-npm/components/instance/shared.js +2 -2
  42. package/dist-npm/components/mono/mono.js +52 -62
  43. package/dist-npm/components/mono/monoTwo.js +35 -49
  44. package/dist-npm/components/multiselect/group-multiselect.js +55 -71
  45. package/dist-npm/components/multiselect/multi-select-two.js +97 -130
  46. package/dist-npm/components/multiselect/multi-select.js +43 -49
  47. package/dist-npm/components/multiselect/multiselect-main.d.ts +1 -0
  48. package/dist-npm/components/multiselect/multiselect-main.js +158 -145
  49. package/dist-npm/components/multiselect/num-multi-select.js +97 -130
  50. package/dist-npm/components/multiselect/num-multiselect-main.js +24 -35
  51. package/dist-npm/components/next-steps/next-steps.js +23 -25
  52. package/dist-npm/components/number/index.js +78 -112
  53. package/dist-npm/components/number/number-main.js +95 -2
  54. package/dist-npm/components/password/index.js +54 -73
  55. package/dist-npm/components/password/password-main.js +119 -2
  56. package/dist-npm/components/password/password-three.js +26 -30
  57. package/dist-npm/components/progressbar/ProgressBar.js +45 -64
  58. package/dist-npm/components/progressbar/helper.js +33 -40
  59. package/dist-npm/components/progressbar/index.js +1 -1
  60. package/dist-npm/components/prompts/create.js +29 -44
  61. package/dist-npm/components/prompts/index.d.ts +1 -0
  62. package/dist-npm/components/prompts/index.js +46 -45
  63. package/dist-npm/components/prompts/prompt.js +211 -260
  64. package/dist-npm/components/prompts/promptTwo.js +561 -605
  65. package/dist-npm/components/prompts/relinka.js +237 -295
  66. package/dist-npm/components/range/range.js +247 -294
  67. package/dist-npm/components/rawlist/index.js +87 -107
  68. package/dist-npm/components/results/results.js +31 -37
  69. package/dist-npm/components/search/index.js +148 -193
  70. package/dist-npm/components/select/index.js +148 -186
  71. package/dist-npm/components/select/num-select-main.js +27 -27
  72. package/dist-npm/components/select/num-select.js +124 -5
  73. package/dist-npm/components/select/select-key.js +24 -25
  74. package/dist-npm/components/select/select-main.d.ts +1 -0
  75. package/dist-npm/components/select/select-main.js +143 -133
  76. package/dist-npm/components/select/select-three.js +32 -36
  77. package/dist-npm/components/select/select-two.js +94 -87
  78. package/dist-npm/components/spinner/index.js +107 -136
  79. package/dist-npm/components/st-end/end.js +34 -26
  80. package/dist-npm/components/st-end/start.js +29 -15
  81. package/dist-npm/components/toggle/index.js +113 -137
  82. package/dist-npm/components/visual/animate/animate.js +53 -10
  83. package/dist-npm/components/visual/ascii-art/ascii-art.js +12 -1
  84. package/dist-npm/main.js +1 -0
  85. package/dist-npm/testing/index.js +58 -83
  86. package/dist-npm/types/general.d.ts +1 -1
  87. package/dist-npm/types/general.js +0 -1
  88. package/dist-npm/types/index.js +2 -3
  89. package/dist-npm/types/keypress.js +35 -36
  90. package/dist-npm/types/readline.js +0 -1
  91. package/dist-npm/types/relinka.js +0 -1
  92. package/dist-npm/types/utils.js +0 -1
  93. package/dist-npm/utils/box.js +135 -137
  94. package/dist-npm/utils/color.js +65 -74
  95. package/dist-npm/utils/colorize.js +124 -156
  96. package/dist-npm/utils/component.js +532 -657
  97. package/dist-npm/utils/constants.js +64 -63
  98. package/dist-npm/utils/core.js +2 -3
  99. package/dist-npm/utils/decoder.js +244 -223
  100. package/dist-npm/utils/error.js +4 -9
  101. package/dist-npm/utils/errors.js +14 -4
  102. package/dist-npm/utils/format.js +19 -24
  103. package/dist-npm/utils/keypress.js +316 -414
  104. package/dist-npm/utils/log.js +11 -15
  105. package/dist-npm/utils/mapping.js +45 -52
  106. package/dist-npm/utils/messages.js +196 -183
  107. package/dist-npm/utils/platforms.js +16 -20
  108. package/dist-npm/utils/prompt-tmp.js +235 -286
  109. package/dist-npm/utils/prompt-two.js +235 -286
  110. package/dist-npm/utils/readline.js +5 -7
  111. package/dist-npm/utils/skeleton.js +130 -170
  112. package/dist-npm/utils/stream.js +2 -2
  113. package/dist-npm/utils/string.js +44 -58
  114. package/dist-npm/utils/terminal.js +23 -34
  115. package/dist-npm/utils/tree.js +30 -41
  116. package/dist-npm/utils/types.js +0 -1
  117. package/dist-npm/utils/utils.js +8 -8
  118. package/dist-npm/utils/variants.js +36 -44
  119. package/package.json +14 -14
  120. package/dist-npm/mod.js +0 -2
  121. /package/dist-npm/{mod.d.ts → main.d.ts} +0 -0
@@ -1,67 +1,68 @@
1
1
  export const LogLevels = {
2
- silent: Number.NEGATIVE_INFINITY,
3
- fatal: 0,
4
- error: 0,
5
- warn: 1,
6
- log: 2,
7
- info: 3,
8
- success: 3,
9
- fail: 3,
10
- ready: 3,
11
- start: 3,
12
- box: 3,
13
- debug: 4,
14
- trace: 5,
15
- verbose: Number.POSITIVE_INFINITY,
2
+ silent: Number.NEGATIVE_INFINITY,
3
+ fatal: 0,
4
+ error: 0,
5
+ warn: 1,
6
+ log: 2,
7
+ info: 3,
8
+ success: 3,
9
+ fail: 3,
10
+ ready: 3,
11
+ start: 3,
12
+ box: 3,
13
+ debug: 4,
14
+ trace: 5,
15
+ verbose: Number.POSITIVE_INFINITY
16
16
  };
17
17
  export const LogTypes = {
18
- silent: {
19
- level: -1,
20
- },
21
-
22
- fatal: {
23
- level: LogLevels.fatal,
24
- },
25
- error: {
26
- level: LogLevels.error,
27
- },
28
-
29
- warn: {
30
- level: LogLevels.warn,
31
- },
32
-
33
- log: {
34
- level: LogLevels.log,
35
- },
36
-
37
- info: {
38
- level: LogLevels.info,
39
- },
40
- success: {
41
- level: LogLevels.success,
42
- },
43
- fail: {
44
- level: LogLevels.fail,
45
- },
46
- ready: {
47
- level: LogLevels.info,
48
- },
49
- start: {
50
- level: LogLevels.info,
51
- },
52
- box: {
53
- level: LogLevels.info,
54
- },
55
-
56
- debug: {
57
- level: LogLevels.debug,
58
- },
59
-
60
- trace: {
61
- level: LogLevels.trace,
62
- },
63
-
64
- verbose: {
65
- level: LogLevels.verbose,
66
- },
18
+
19
+ silent: {
20
+ level: -1
21
+ },
22
+
23
+ fatal: {
24
+ level: LogLevels.fatal
25
+ },
26
+ error: {
27
+ level: LogLevels.error
28
+ },
29
+
30
+ warn: {
31
+ level: LogLevels.warn
32
+ },
33
+
34
+ log: {
35
+ level: LogLevels.log
36
+ },
37
+
38
+ info: {
39
+ level: LogLevels.info
40
+ },
41
+ success: {
42
+ level: LogLevels.success
43
+ },
44
+ fail: {
45
+ level: LogLevels.fail
46
+ },
47
+ ready: {
48
+ level: LogLevels.info
49
+ },
50
+ start: {
51
+ level: LogLevels.info
52
+ },
53
+ box: {
54
+ level: LogLevels.info
55
+ },
56
+
57
+ debug: {
58
+ level: LogLevels.debug
59
+ },
60
+
61
+ trace: {
62
+ level: LogLevels.trace
63
+ },
64
+
65
+ verbose: {
66
+ level: LogLevels.verbose
67
+ }
67
68
  };
@@ -1,3 +1,2 @@
1
- export {createRelinka} from '../components/prompts/relinka.js';
2
- export * from '../components/instance/shared.js';
3
-
1
+ export { createRelinka } from "../components/prompts/relinka.js";
2
+ export * from "../components/instance/shared.js";
@@ -1,260 +1,281 @@
1
- import {Buffer} from 'safe-buffer';
2
-
3
- const isString = (a) => typeof a === 'string';
1
+ import { Buffer } from "safe-buffer";
4
2
  const isEncoding = Buffer.isEncoding || function(encoding) {
5
- const enc = String(encoding).toLowerCase();
6
-
7
- switch(enc) {
8
- case 'hex':
9
- case 'utf8':
10
- case 'utf-8':
11
- case 'ascii':
12
- case 'binary':
13
- case 'base64':
14
- case 'ucs2':
15
- case 'ucs-2':
16
- case 'utf16le':
17
- case 'utf-16le':
18
- case 'raw':
19
- return true;
20
-
3
+ const enc = String(encoding).toLowerCase();
4
+ switch (enc) {
5
+ case "hex":
6
+ case "utf8":
7
+ case "utf-8":
8
+ case "ascii":
9
+ case "binary":
10
+ case "base64":
11
+ case "ucs2":
12
+ case "ucs-2":
13
+ case "utf16le":
14
+ case "utf-16le":
15
+ case "raw":
16
+ return true;
21
17
  default:
22
- return false;
23
- }
18
+ return false;
19
+ }
24
20
  };
25
-
26
21
  function _normalizeEncoding(enc) {
27
- if (!enc) {
28
- return 'utf8';
29
- }
30
-
31
- let retried = false;
32
- let encoding = String(enc);
33
-
34
- while (true) {
35
- switch(encoding) {
36
- case 'utf8':
37
- case 'utf-8':
38
- return 'utf8';
39
-
40
- case 'ucs2':
41
- case 'ucs-2':
42
- case 'utf16le':
43
- case 'utf-16le':
44
- return 'utf16le';
45
-
46
- case 'latin1':
47
- case 'binary':
48
- return 'latin1';
49
-
50
- case 'base64':
51
- case 'ascii':
52
- case 'hex':
53
- return encoding;
54
-
55
- default:
56
- if (retried) {
57
- return void 0;
58
- }
59
-
60
- encoding = encoding.toLowerCase();
61
- retried = true;
22
+ if (!enc) {
23
+ return "utf8";
24
+ }
25
+ let retried = false;
26
+ let encoding = String(enc);
27
+ while (true) {
28
+ switch (encoding) {
29
+ case "utf8":
30
+ case "utf-8":
31
+ return "utf8";
32
+ case "ucs2":
33
+ case "ucs-2":
34
+ case "utf16le":
35
+ case "utf-16le":
36
+ return "utf16le";
37
+ case "latin1":
38
+ case "binary":
39
+ return "latin1";
40
+ case "base64":
41
+ case "ascii":
42
+ case "hex":
43
+ return encoding;
44
+ default:
45
+ if (retried) {
46
+ return void 0;
62
47
  }
48
+ encoding = encoding.toLowerCase();
49
+ retried = true;
63
50
  }
51
+ }
64
52
  }
65
-
66
53
  function normalizeEncoding(enc) {
67
- const nenc = _normalizeEncoding(enc);
68
-
69
- if (!isString(nenc) && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) {
70
- throw Error(`Unknown encoding: ${enc}`);
71
- }
72
-
73
- return nenc || enc;
54
+ const nenc = _normalizeEncoding(enc);
55
+ if (typeof nenc !== "string" && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) {
56
+ throw new Error("Unknown encoding: " + enc);
57
+ }
58
+ return nenc || enc;
74
59
  }
75
-
76
60
  export class StringDecoder {
77
- encoding;
78
- lastNeed;
79
- lastTotal;
80
- lastChar;
81
- fillLast;
82
- text;
83
- endFn;
84
- writeFn;
85
- constructor(encoding) {
86
- this.encoding = normalizeEncoding(encoding);
87
- let nb;
88
-
89
- switch(this.encoding) {
90
- case 'utf16le':
91
- this.text = utf16Text;
92
- this.endFn = utf16End;
93
- nb = 4;
94
- break;
95
-
96
- case 'utf8':
97
- this.fillLast = utf8FillLast;
98
- nb = 4;
99
- break;
100
-
101
- case 'base64':
102
- this.text = base64Text;
103
- this.endFn = base64End;
104
- nb = 3;
105
- break;
106
-
107
- default:
108
- this.writeFn = simpleWrite;
109
- this.endFn = simpleEnd;
110
- return;
111
- }
112
-
113
- this.lastNeed = 0;
114
- this.lastTotal = 0;
115
- this.lastChar = Buffer.allocUnsafe(nb);
116
- this.writeFn = this.write.bind(this);
61
+ encoding;
62
+ lastNeed;
63
+ lastTotal;
64
+ lastChar;
65
+ fillLast;
66
+ text;
67
+ endFn;
68
+ writeFn;
69
+ constructor(encoding) {
70
+ this.encoding = normalizeEncoding(encoding);
71
+ let nb;
72
+ switch (this.encoding) {
73
+ case "utf16le":
74
+ this.text = utf16Text;
75
+ this.endFn = utf16End;
76
+ nb = 4;
77
+ break;
78
+ case "utf8":
79
+ this.fillLast = utf8FillLast;
80
+ nb = 4;
81
+ break;
82
+ case "base64":
83
+ this.text = base64Text;
84
+ this.endFn = base64End;
85
+ nb = 3;
86
+ break;
87
+ default:
88
+ this.writeFn = simpleWrite;
89
+ this.endFn = simpleEnd;
90
+ return;
117
91
  }
118
-
92
+ this.lastNeed = 0;
93
+ this.lastTotal = 0;
94
+ this.lastChar = Buffer.allocUnsafe(nb);
95
+ this.writeFn = this.write.bind(this);
96
+ }
119
97
  write(buf) {
120
- if (!buf.length) {
121
- return '';
122
- }
123
-
124
- let r;
125
- let i;
126
-
127
- if (this.lastNeed) {
128
- r = this.fillLast(buf);
129
- if (r === void 0) {
130
- return '';
131
- }
132
-
133
- i = this.lastNeed;
134
- this.lastNeed = 0;
135
- } else {
136
- i = 0;
137
- }
138
-
139
- if (i < buf.length) {
140
- return r ? r + (this.text ? this.text(buf, i) : '') : this.text ? this.text(buf, i) : '';
141
- }
142
-
143
- return r || '';
98
+ if (buf.length === 0) {
99
+ return "";
100
+ }
101
+ let r;
102
+ let i;
103
+ if (this.lastNeed) {
104
+ r = this.fillLast(buf);
105
+ if (r === void 0) {
106
+ return "";
107
+ }
108
+ i = this.lastNeed;
109
+ this.lastNeed = 0;
110
+ } else {
111
+ i = 0;
112
+ }
113
+ if (i < buf.length) {
114
+ return r ? r + (this.text ? this.text(buf, i) : "") : this.text ? this.text(buf, i) : "";
144
115
  }
145
- /**
116
+ return r || "";
117
+ }
118
+ /**
146
119
  * Ends the decoding and returns any remaining characters.
147
120
  * @param buf - Optional buffer to write before ending.
148
121
  * @returns The final decoded string.
149
122
  */
150
- end(buf) {
151
- return this.endFn?.(buf) ?? '';
123
+ end(buf) {
124
+ const result = this.endFn?.(buf) ?? "";
125
+ return result;
126
+ }
127
+ }
128
+ function utf8FillLast(buf) {
129
+ const p = this.lastTotal - this.lastNeed;
130
+ const r = utf8CheckExtraBytes(this, buf, p);
131
+ if (r !== void 0) {
132
+ return r;
133
+ }
134
+ if (this.lastNeed <= buf.length) {
135
+ buf.copy(this.lastChar, p, 0, this.lastNeed);
136
+ return this.lastChar.toString(this.encoding, 0, this.lastTotal);
137
+ }
138
+ buf.copy(this.lastChar, p, 0, buf.length);
139
+ this.lastNeed -= buf.length;
140
+ }
141
+ function utf8Text(buf, i) {
142
+ const total = utf8CheckIncomplete(this, buf, i);
143
+ if (!this.lastNeed) {
144
+ return buf.toString("utf8", i);
145
+ }
146
+ this.lastTotal = total;
147
+ const end = buf.length - (total - this.lastNeed);
148
+ buf.copy(this.lastChar, 0, end);
149
+ return buf.toString("utf8", i, end);
150
+ }
151
+ function utf8End(buf) {
152
+ const r = buf?.length ? this.write(buf) : "";
153
+ if (this.lastNeed) {
154
+ return r + "\uFFFD";
155
+ }
156
+ return r;
157
+ }
158
+ function utf8CheckByte(byte) {
159
+ if (byte <= 127) {
160
+ return 0;
161
+ } else if (byte >> 5 === 6) {
162
+ return 2;
163
+ } else if (byte >> 4 === 14) {
164
+ return 3;
165
+ } else if (byte >> 3 === 30) {
166
+ return 4;
167
+ }
168
+ return byte >> 6 === 2 ? -1 : -2;
169
+ }
170
+ function utf8CheckIncomplete(self, buf, i) {
171
+ let j = buf.length - 1;
172
+ if (j < i) {
173
+ return 0;
174
+ }
175
+ let nb = utf8CheckByte(buf[j]);
176
+ if (nb >= 0) {
177
+ if (nb > 0) {
178
+ self.lastNeed = nb - 1;
152
179
  }
153
- }function utf8FillLast(buf) {
154
- const p = this.lastTotal - this.lastNeed;
155
- const r = utf8CheckExtraBytes(this, buf);
156
-
157
- if (r !== void 0) {
158
- return r;
180
+ return nb;
181
+ }
182
+ if (--j < i || nb === -2) {
183
+ return 0;
184
+ }
185
+ nb = utf8CheckByte(buf[j]);
186
+ if (nb >= 0) {
187
+ if (nb > 0) {
188
+ self.lastNeed = nb - 2;
159
189
  }
160
-
161
- if (this.lastNeed <= buf.length) {
162
- buf.copy(this.lastChar, p, 0, this.lastNeed);
163
- return this.lastChar.toString(this.encoding, 0, this.lastTotal);
190
+ return nb;
191
+ }
192
+ if (--j < i || nb === -2) {
193
+ return 0;
194
+ }
195
+ nb = utf8CheckByte(buf[j]);
196
+ if (nb >= 0) {
197
+ if (nb > 0) {
198
+ if (nb === 2) {
199
+ nb = 0;
200
+ } else {
201
+ self.lastNeed = nb - 3;
202
+ }
164
203
  }
165
-
166
- buf.copy(this.lastChar, p, 0, buf.length);
167
- this.lastNeed -= buf.length;
204
+ return nb;
205
+ }
206
+ return 0;
168
207
  }
169
-
170
- function utf8CheckExtraBytes(self, buf) {
171
- if ((buf[0] & 192) !== 128) {
172
- self.lastNeed = 0;
173
- return '\uFFFD';
208
+ function utf8CheckExtraBytes(self, buf, p) {
209
+ if ((buf[0] & 192) !== 128) {
210
+ self.lastNeed = 0;
211
+ return "\uFFFD";
212
+ }
213
+ if (self.lastNeed > 1 && buf.length > 1) {
214
+ if ((buf[1] & 192) !== 128) {
215
+ self.lastNeed = 1;
216
+ return "\uFFFD";
174
217
  }
175
-
176
- if (self.lastNeed > 1 && buf.length > 1) {
177
- if ((buf[1] & 192) !== 128) {
178
- self.lastNeed = 1;
179
- return '\uFFFD';
180
- }
181
-
182
- if (self.lastNeed > 2 && buf.length > 2 && (buf[2] & 192) !== 128) {
183
- self.lastNeed = 2;
184
- return '\uFFFD';
185
- }
218
+ if (self.lastNeed > 2 && buf.length > 2) {
219
+ if ((buf[2] & 192) !== 128) {
220
+ self.lastNeed = 2;
221
+ return "\uFFFD";
222
+ }
186
223
  }
224
+ }
187
225
  }
188
-
189
226
  function utf16Text(buf, i) {
190
- if (!((buf.length - i) % 2)) {
191
- const r = buf.toString('utf16le', i);
192
-
193
- if (r) {
194
- const c = r.charCodeAt(r.length - 1);
195
-
196
- if (c >= 55_296 && c <= 56_319) {
197
- this.lastNeed = 2;
198
- this.lastTotal = 4;
199
- this.lastChar[0] = buf[buf.length - 2];
200
- this.lastChar[1] = buf[buf.length - 1];
201
- return r.slice(0, -1);
202
- }
203
- }
204
-
205
- return r;
227
+ if ((buf.length - i) % 2 === 0) {
228
+ const r = buf.toString("utf16le", i);
229
+ if (r) {
230
+ const c = r.charCodeAt(r.length - 1);
231
+ if (c >= 55296 && c <= 56319) {
232
+ this.lastNeed = 2;
233
+ this.lastTotal = 4;
234
+ this.lastChar[0] = buf[buf.length - 2];
235
+ this.lastChar[1] = buf[buf.length - 1];
236
+ return r.slice(0, -1);
237
+ }
206
238
  }
207
-
208
- this.lastNeed = 1;
209
- this.lastTotal = 2;
210
- this.lastChar[0] = buf[buf.length - 1];
211
- return buf.toString('utf16le', i, buf.length - 1);
239
+ return r;
240
+ }
241
+ this.lastNeed = 1;
242
+ this.lastTotal = 2;
243
+ this.lastChar[0] = buf[buf.length - 1];
244
+ return buf.toString("utf16le", i, buf.length - 1);
212
245
  }
213
-
214
246
  function utf16End(buf) {
215
- const r = buf?.length ? this.write(buf) : '';
216
-
217
- if (this.lastNeed) {
218
- const end = this.lastTotal - this.lastNeed;
219
- return r + this.lastChar.toString('utf16le', 0, end);
220
- }
221
-
222
- return r;
247
+ const r = buf?.length ? this.write(buf) : "";
248
+ if (this.lastNeed) {
249
+ const end = this.lastTotal - this.lastNeed;
250
+ return r + this.lastChar.toString("utf16le", 0, end);
251
+ }
252
+ return r;
223
253
  }
224
-
225
254
  function base64Text(buf, i) {
226
- const n = (buf.length - i) % 3;
227
-
228
- if (!n) {
229
- return buf.toString('base64', i);
230
- }
231
-
232
- this.lastNeed = 3 - n;
233
- this.lastTotal = 3;
234
- if (n === 1) {
235
- this.lastChar[0] = buf[buf.length - 1];
236
- } else {
237
- this.lastChar[0] = buf[buf.length - 2];
238
- this.lastChar[1] = buf[buf.length - 1];
239
- }
240
-
241
- return buf.toString('base64', i, buf.length - n);
255
+ const n = (buf.length - i) % 3;
256
+ if (n === 0) {
257
+ return buf.toString("base64", i);
258
+ }
259
+ this.lastNeed = 3 - n;
260
+ this.lastTotal = 3;
261
+ if (n === 1) {
262
+ this.lastChar[0] = buf[buf.length - 1];
263
+ } else {
264
+ this.lastChar[0] = buf[buf.length - 2];
265
+ this.lastChar[1] = buf[buf.length - 1];
266
+ }
267
+ return buf.toString("base64", i, buf.length - n);
242
268
  }
243
-
244
269
  function base64End(buf) {
245
- const r = buf?.length ? this.write(buf) : '';
246
-
247
- if (this.lastNeed) {
248
- return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
249
- }
250
-
251
- return r;
270
+ const r = buf?.length ? this.write(buf) : "";
271
+ if (this.lastNeed) {
272
+ return r + this.lastChar.toString("base64", 0, 3 - this.lastNeed);
273
+ }
274
+ return r;
252
275
  }
253
-
254
276
  function simpleWrite(buf) {
255
- return buf.toString(this.encoding);
277
+ return buf.toString(this.encoding);
256
278
  }
257
-
258
279
  function simpleEnd(buf) {
259
- return buf?.length ? this.write(buf) : '';
280
+ return buf?.length ? this.write(buf) : "";
260
281
  }
@@ -1,11 +1,6 @@
1
- import {sep} from 'node:path';
2
- import process from 'node:process';
3
-
1
+ import { sep } from "node:path";
4
2
  export function parseStack(stack) {
5
- const cwd = process.cwd() + sep;
6
-
7
- return stack
8
- .split('\n')
9
- .splice(1)
10
- .map((l) => l.trim().replace('file://', '').replace(cwd, ''));
3
+ const cwd = process.cwd() + sep;
4
+ const lines = stack.split("\n").splice(1).map((l) => l.trim().replace("file://", "").replace(cwd, ""));
5
+ return lines;
11
6
  }