PluginProbe ʕ •ᴥ•ʔ
GPTranslate – Multilingual AI Translation for WordPress: Automatically Translate Websites / 2.28
GPTranslate – Multilingual AI Translation for WordPress: Automatically Translate Websites v2.28
2.33.7 2.33.6 2.33.5 2.33.2 2.32.10 2.33 2.33.1 2.32.6 2.32.7 2.32.8 trunk 2.10.3 2.10.4 2.10.5 2.10.6 2.11 2.12 2.13 2.14 2.14.1 2.15 2.15.1 2.16.1 2.16.2 2.17 2.18 2.18.1 2.18.2 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.25.1 2.25.2 2.26 2.27 2.27.10 2.27.5 2.28 2.28.1 2.29 2.30 2.31 2.32 2.32.5
gptranslate / assets / js / jsonrepair / streaming / buffer / InputBuffer.js
gptranslate / assets / js / jsonrepair / streaming / buffer Last commit date
InputBuffer.js 3 months ago InputBuffer.js.map 3 months ago OutputBuffer.js 3 months ago OutputBuffer.js.map 3 months ago
InputBuffer.js
69 lines
1 export function createInputBuffer() {
2 let buffer = '';
3 let offset = 0;
4 let currentLength = 0;
5 let closed = false;
6 function ensure(index) {
7 if (index < offset) {
8 throw new Error("".concat(indexOutOfRangeMessage, " (index: ").concat(index, ", offset: ").concat(offset, ")"));
9 }
10 if (index >= currentLength) {
11 if (!closed) {
12 throw new Error("".concat(indexOutOfRangeMessage, " (index: ").concat(index, ")"));
13 }
14 }
15 }
16 function push(chunk) {
17 buffer += chunk;
18 currentLength += chunk.length;
19 }
20 function flush(position) {
21 if (position > currentLength) {
22 return;
23 }
24 buffer = buffer.substring(position - offset);
25 offset = position;
26 }
27 function charAt(index) {
28 ensure(index);
29 return buffer.charAt(index - offset);
30 }
31 function charCodeAt(index) {
32 ensure(index);
33 return buffer.charCodeAt(index - offset);
34 }
35 function substring(start, end) {
36 ensure(end - 1); // -1 because end is excluded
37 ensure(start);
38 return buffer.slice(start - offset, end - offset);
39 }
40 function length() {
41 if (!closed) {
42 throw new Error('Cannot get length: input is not yet closed');
43 }
44 return currentLength;
45 }
46 function isEnd(index) {
47 if (!closed) {
48 ensure(index);
49 }
50 return index >= currentLength;
51 }
52 function close() {
53 closed = true;
54 }
55 return {
56 push,
57 flush,
58 charAt,
59 charCodeAt,
60 substring,
61 length,
62 currentLength: () => currentLength,
63 currentBufferSize: () => buffer.length,
64 isEnd,
65 close
66 };
67 }
68 const indexOutOfRangeMessage = 'Index out of range, please configure a larger buffer size';
69 //# sourceMappingURL=InputBuffer.js.map