poku 4.3.1-canary.e84e648d → 4.3.1

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.
@@ -21,7 +21,7 @@ exports.results = {
21
21
  skipped: 0,
22
22
  todo: 0,
23
23
  };
24
- exports.VERSION = '4.3.1-canary.e84e648d';
24
+ exports.VERSION = '4.3.1';
25
25
  exports.deepOptions = [];
26
26
  exports.GLOBAL = {
27
27
  cwd: (0, node_process_1.cwd)(),
@@ -1,9 +1,6 @@
1
1
  /**
2
2
  * Adapted from https://github.com/wellwelwel/jsonc.min
3
3
  */
4
- declare class JsoncProcessor {
5
- toJSON(content: string): string;
6
- parse<T = unknown>(text: string): T;
7
- }
8
- export declare const JSONC: JsoncProcessor;
9
- export {};
4
+ export declare const JSONC: {
5
+ parse: <T = unknown>(text: string) => T;
6
+ };
@@ -4,54 +4,96 @@ exports.JSONC = void 0;
4
4
  /**
5
5
  * Adapted from https://github.com/wellwelwel/jsonc.min
6
6
  */
7
- class JsoncProcessor {
8
- toJSON(content) {
7
+ exports.JSONC = (() => {
8
+ const DOUBLE_QUOTE = 0x22;
9
+ const BACKSLASH = 0x5c;
10
+ const SLASH = 0x2f;
11
+ const ASTERISK = 0x2a;
12
+ const COMMA = 0x2c;
13
+ const CLOSE_BRACKET = 0x5d;
14
+ const CLOSE_BRACE = 0x7d;
15
+ const SPACE = 0x20;
16
+ const BOM = 0xfeff;
17
+ const toJSON = (content) => {
18
+ const offset = content.charCodeAt(0) === BOM ? 1 : 0;
9
19
  const length = content.length;
10
- let inBlockComment = false;
11
- let inString = false;
12
- let skipChar = false;
13
20
  let result = '';
14
- for (let i = 0; i < length; i++) {
15
- const char = content[i];
16
- if (skipChar) {
17
- skipChar = false;
18
- continue;
19
- }
20
- if (inBlockComment) {
21
- if (char === '*' && content[i + 1] === '/') {
22
- inBlockComment = false;
23
- skipChar = true;
21
+ let segment = offset;
22
+ let pendingComma = false;
23
+ let cursor = offset;
24
+ while (cursor < length) {
25
+ const current = content.charCodeAt(cursor);
26
+ if (current === DOUBLE_QUOTE) {
27
+ if (pendingComma) {
28
+ result += `,${content.slice(segment, cursor)}`;
29
+ segment = cursor;
30
+ pendingComma = false;
31
+ }
32
+ cursor++;
33
+ for (;;) {
34
+ const closing = content.indexOf('"', cursor);
35
+ if (closing === -1) {
36
+ cursor = length;
37
+ break;
38
+ }
39
+ let backslashes = 0;
40
+ for (let pos = closing - 1; pos >= cursor && content.charCodeAt(pos) === BACKSLASH; pos--) {
41
+ backslashes++;
42
+ }
43
+ cursor = closing + 1;
44
+ if ((backslashes & 1) === 0) {
45
+ break;
46
+ }
24
47
  }
25
48
  continue;
26
49
  }
27
- if (inString) {
28
- if (char === '"' && content[i - 1] !== '\\')
29
- inString = false;
30
- result += char;
31
- continue;
50
+ if (current === SLASH) {
51
+ const next = content.charCodeAt(cursor + 1);
52
+ if (next === SLASH) {
53
+ result += content.slice(segment, cursor);
54
+ const endOfLine = content.indexOf('\n', cursor + 2);
55
+ cursor = endOfLine === -1 ? length : endOfLine;
56
+ segment = cursor;
57
+ continue;
58
+ }
59
+ if (next === ASTERISK) {
60
+ result += content.slice(segment, cursor);
61
+ const endOfBlock = content.indexOf('*/', cursor + 2);
62
+ cursor = endOfBlock === -1 ? length : endOfBlock + 2;
63
+ segment = cursor;
64
+ continue;
65
+ }
32
66
  }
33
- if (char === '"') {
34
- inString = true;
35
- result += char;
67
+ if (current === COMMA) {
68
+ if (pendingComma) {
69
+ result += `,${content.slice(segment, cursor)}`;
70
+ }
71
+ else {
72
+ result += content.slice(segment, cursor);
73
+ }
74
+ segment = cursor + 1;
75
+ pendingComma = true;
76
+ cursor++;
36
77
  continue;
37
78
  }
38
- if (char === '/' && content[i + 1] === '*') {
39
- inBlockComment = true;
40
- skipChar = true;
79
+ if (current === CLOSE_BRACKET || current === CLOSE_BRACE) {
80
+ pendingComma = false;
81
+ cursor++;
41
82
  continue;
42
83
  }
43
- if (char === '/' && content[i + 1] === '/') {
44
- while (i < length && content[i] !== '\n')
45
- i++;
46
- continue;
84
+ if (pendingComma && current > SPACE) {
85
+ result += `,${content.slice(segment, cursor)}`;
86
+ segment = cursor;
87
+ pendingComma = false;
47
88
  }
48
- result += char;
89
+ cursor++;
90
+ }
91
+ if (pendingComma) {
92
+ result += ',';
49
93
  }
94
+ result += content.slice(segment, length);
50
95
  return result;
51
- }
52
- parse(text) {
53
- const cleanContent = this.toJSON(text);
54
- return JSON.parse(cleanContent);
55
- }
56
- }
57
- exports.JSONC = new JsoncProcessor();
96
+ };
97
+ const parse = (text) => JSON.parse(toJSON(text));
98
+ return { parse };
99
+ })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poku",
3
- "version": "4.3.1-canary.e84e648d",
3
+ "version": "4.3.1",
4
4
  "description": "🐷 Poku makes testing easy for Node.js, Bun, Deno, and you at the same time.",
5
5
  "main": "./lib/modules/index.js",
6
6
  "exports": {