@stryke/fs 0.33.72 → 0.33.73

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 (117) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/copy-file.cjs +7 -8
  3. package/dist/copy-file.d.cts +1 -1
  4. package/dist/copy-file.d.mts +1 -1
  5. package/dist/copy-file.mjs +1 -2
  6. package/dist/copy-file.mjs.map +1 -1
  7. package/dist/get-parent-path.d.cts +1 -1
  8. package/dist/get-parent-path.d.cts.map +1 -1
  9. package/dist/get-parent-path.d.mts +1 -1
  10. package/dist/get-parent-path.d.mts.map +1 -1
  11. package/dist/get-workspace-root.d.cts +4 -4
  12. package/dist/get-workspace-root.d.mts +4 -4
  13. package/dist/json.cjs +9 -10
  14. package/dist/json.d.cts +1 -1
  15. package/dist/json.d.mts +1 -1
  16. package/dist/json.mjs +3 -4
  17. package/dist/json.mjs.map +1 -1
  18. package/dist/list-files.cjs +3 -4
  19. package/dist/list-files.d.cts +1 -1
  20. package/dist/list-files.d.mts +1 -1
  21. package/dist/list-files.mjs +1 -2
  22. package/dist/list-files.mjs.map +1 -1
  23. package/dist/package-fns.cjs +3 -3
  24. package/dist/package-fns.d.cts +4 -4
  25. package/dist/package-fns.d.cts.map +1 -1
  26. package/dist/package-fns.d.mts +4 -4
  27. package/dist/package-fns.d.mts.map +1 -1
  28. package/dist/package-fns.mjs +1 -1
  29. package/dist/semver-fns.cjs +6 -6
  30. package/dist/semver-fns.mjs +2 -2
  31. package/dist/tsconfig.cjs +1 -1
  32. package/dist/tsconfig.d.cts +1 -1
  33. package/dist/tsconfig.d.mts +1 -1
  34. package/dist/tsconfig.mjs +1 -1
  35. package/dist/tsconfig.mjs.map +1 -1
  36. package/package.json +10 -91
  37. package/dist/json/src/storm-json.cjs +0 -106
  38. package/dist/json/src/storm-json.mjs +0 -105
  39. package/dist/json/src/storm-json.mjs.map +0 -1
  40. package/dist/json/src/types.d.cts +0 -32
  41. package/dist/json/src/types.d.cts.map +0 -1
  42. package/dist/json/src/types.d.mts +0 -32
  43. package/dist/json/src/types.d.mts.map +0 -1
  44. package/dist/json/src/utils/code-frames.cjs +0 -77
  45. package/dist/json/src/utils/code-frames.mjs +0 -77
  46. package/dist/json/src/utils/code-frames.mjs.map +0 -1
  47. package/dist/json/src/utils/parse-error.cjs +0 -34
  48. package/dist/json/src/utils/parse-error.mjs +0 -34
  49. package/dist/json/src/utils/parse-error.mjs.map +0 -1
  50. package/dist/json/src/utils/parse.cjs +0 -45
  51. package/dist/json/src/utils/parse.mjs +0 -46
  52. package/dist/json/src/utils/parse.mjs.map +0 -1
  53. package/dist/json/src/utils/stringify.cjs +0 -33
  54. package/dist/json/src/utils/stringify.mjs +0 -34
  55. package/dist/json/src/utils/stringify.mjs.map +0 -1
  56. package/dist/json/src/utils/strip-comments.cjs +0 -85
  57. package/dist/json/src/utils/strip-comments.mjs +0 -85
  58. package/dist/json/src/utils/strip-comments.mjs.map +0 -1
  59. package/dist/type-checks/src/get-object-tag.cjs +0 -15
  60. package/dist/type-checks/src/get-object-tag.mjs +0 -15
  61. package/dist/type-checks/src/get-object-tag.mjs.map +0 -1
  62. package/dist/type-checks/src/index.cjs +0 -14
  63. package/dist/type-checks/src/index.mjs +0 -16
  64. package/dist/type-checks/src/is-buffer.cjs +0 -14
  65. package/dist/type-checks/src/is-buffer.mjs +0 -14
  66. package/dist/type-checks/src/is-buffer.mjs.map +0 -1
  67. package/dist/type-checks/src/is-collection.cjs +0 -1
  68. package/dist/type-checks/src/is-collection.mjs +0 -3
  69. package/dist/type-checks/src/is-empty.cjs +0 -20
  70. package/dist/type-checks/src/is-empty.mjs +0 -21
  71. package/dist/type-checks/src/is-empty.mjs.map +0 -1
  72. package/dist/type-checks/src/is-error.cjs +0 -29
  73. package/dist/type-checks/src/is-error.mjs +0 -30
  74. package/dist/type-checks/src/is-error.mjs.map +0 -1
  75. package/dist/type-checks/src/is-null.cjs +0 -12
  76. package/dist/type-checks/src/is-null.mjs +0 -12
  77. package/dist/type-checks/src/is-null.mjs.map +0 -1
  78. package/dist/type-checks/src/is-number.cjs +0 -18
  79. package/dist/type-checks/src/is-number.mjs +0 -18
  80. package/dist/type-checks/src/is-number.mjs.map +0 -1
  81. package/dist/type-checks/src/is-object.cjs +0 -19
  82. package/dist/type-checks/src/is-object.mjs +0 -20
  83. package/dist/type-checks/src/is-object.mjs.map +0 -1
  84. package/dist/type-checks/src/is-plain-object.cjs +0 -64
  85. package/dist/type-checks/src/is-plain-object.mjs +0 -64
  86. package/dist/type-checks/src/is-plain-object.mjs.map +0 -1
  87. package/dist/type-checks/src/is-set-string.cjs +0 -20
  88. package/dist/type-checks/src/is-set-string.mjs +0 -21
  89. package/dist/type-checks/src/is-set-string.mjs.map +0 -1
  90. package/dist/type-checks/src/is-set.cjs +0 -19
  91. package/dist/type-checks/src/is-set.mjs +0 -20
  92. package/dist/type-checks/src/is-set.mjs.map +0 -1
  93. package/dist/type-checks/src/is-string.cjs +0 -12
  94. package/dist/type-checks/src/is-string.mjs +0 -12
  95. package/dist/type-checks/src/is-string.mjs.map +0 -1
  96. package/dist/type-checks/src/is-undefined.cjs +0 -8
  97. package/dist/type-checks/src/is-undefined.mjs +0 -8
  98. package/dist/type-checks/src/is-undefined.mjs.map +0 -1
  99. package/dist/type-checks/src/type-detect.cjs +0 -15
  100. package/dist/type-checks/src/type-detect.mjs +0 -17
  101. package/dist/type-checks/src/type-detect.mjs.map +0 -1
  102. package/dist/types/src/file.d.cts +0 -31
  103. package/dist/types/src/file.d.cts.map +0 -1
  104. package/dist/types/src/file.d.mts +0 -31
  105. package/dist/types/src/file.d.mts.map +0 -1
  106. package/dist/types/src/package-json.d.cts +0 -261
  107. package/dist/types/src/package-json.d.cts.map +0 -1
  108. package/dist/types/src/package-json.d.mts +0 -261
  109. package/dist/types/src/package-json.d.mts.map +0 -1
  110. package/dist/types/src/package-manager.d.cts +0 -5
  111. package/dist/types/src/package-manager.d.cts.map +0 -1
  112. package/dist/types/src/package-manager.d.mts +0 -5
  113. package/dist/types/src/package-manager.d.mts.map +0 -1
  114. package/dist/types/src/tsconfig.d.cts +0 -803
  115. package/dist/types/src/tsconfig.d.cts.map +0 -1
  116. package/dist/types/src/tsconfig.d.mts +0 -803
  117. package/dist/types/src/tsconfig.d.mts.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"code-frames.mjs","names":[],"sources":["../../../../../json/src/utils/code-frames.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\ninterface Location {\n column: number;\n line: number;\n}\n\ninterface NodeLocation {\n end?: Location;\n start?: Location;\n}\n\n// Adapted from https://raw.githubusercontent.com/babel/babel/4108524/packages/babel-code-frame/src/index.js\n\n/**\n * RegExp to test for newlines in terminal.\n */\nconst NEWLINE = /\\r\\n|[\\n\\r\\u2028\\u2029]/;\n\n/**\n * Extract what lines should be marked and highlighted.\n */\nfunction getMarkerLines(\n loc: NodeLocation,\n source: string[],\n opts: { linesAbove?: number; linesBelow?: number } = {}\n): {\n start: number;\n end: number;\n markerLines: Record<number, boolean | [number, number]>;\n} {\n const startLoc: Location = {\n column: 0,\n line: -1,\n ...loc.start\n };\n const endLoc: Location = {\n ...startLoc,\n ...loc.end\n };\n const { linesAbove = 2, linesBelow = 3 } = opts || {};\n const startLine = startLoc.line;\n const startColumn = startLoc.column;\n const endLine = endLoc.line;\n const endColumn = endLoc.column;\n\n let start = Math.max(startLine - (linesAbove + 1), 0);\n let end = Math.min(source.length, endLine + linesBelow);\n\n if (startLine === -1) {\n start = 0;\n }\n\n if (endLine === -1) {\n end = source.length;\n }\n\n const lineDiff = endLine - startLine;\n const markerLines = {} as Record<number, boolean | [number, number]>;\n\n if (lineDiff) {\n for (let i = 0; i <= lineDiff; i++) {\n const lineNumber = i + startLine;\n\n if (!startColumn) {\n markerLines[lineNumber] = true;\n } else if (i === 0) {\n const sourceLength = source[lineNumber - 1]?.length ?? 0;\n\n markerLines[lineNumber] = [startColumn, sourceLength - startColumn + 1];\n } else if (i === lineDiff) {\n markerLines[lineNumber] = [0, endColumn];\n } else {\n const sourceLength = source[lineNumber - i]?.length ?? 0;\n\n markerLines[lineNumber] = [0, sourceLength];\n }\n }\n } else if (startColumn === endColumn) {\n markerLines[startLine] = startColumn ? [startColumn, 0] : true;\n } else {\n markerLines[startLine] = [startColumn, endColumn - startColumn];\n }\n\n return {\n start,\n end,\n markerLines\n };\n}\n\nexport function codeFrameColumns(\n rawLines: string,\n loc: NodeLocation,\n opts: {\n linesAbove?: number;\n linesBelow?: number;\n highlight?: (rawLines: string) => string;\n } = {}\n): string {\n const lines = rawLines.split(NEWLINE);\n const { start, end, markerLines } = getMarkerLines(loc, lines, opts);\n\n const numberMaxWidth = String(end).length;\n const highlightedLines = opts.highlight ? opts.highlight(rawLines) : rawLines;\n\n const frame = highlightedLines\n .split(NEWLINE)\n .slice(start, end)\n .map((line, index) => {\n const number = start + 1 + index;\n const paddedNumber = ` ${number}`.slice(-numberMaxWidth);\n const gutter = ` ${paddedNumber} | `;\n const hasMarker = Boolean(markerLines[number] ?? false);\n if (hasMarker) {\n let markerLine = \"\";\n if (Array.isArray(hasMarker)) {\n const markerSpacing = line\n .slice(0, Math.max(hasMarker[0] - 1, 0))\n .replace(/[^\\t]/g, \" \");\n const numberOfMarkers = hasMarker[1] || 1;\n\n markerLine = [\n \"\\n \",\n gutter.replace(/\\d/g, \" \"),\n markerSpacing,\n \"^\".repeat(numberOfMarkers)\n ].join(\"\");\n }\n return [\">\", gutter, line, markerLine].join(\"\");\n }\n return ` ${gutter}${line}`;\n })\n .join(\"\\n\");\n\n return frame;\n}\n"],"mappings":";;;;AAiCA,MAAM,UAAU;;;;AAKhB,SAAS,eACP,KACA,QACA,OAAqD,EAAE,EAKvD;CACA,MAAM,WAAqB;EACzB,QAAQ;EACR,MAAM;EACN,GAAG,IAAI;EACR;CACD,MAAM,SAAmB;EACvB,GAAG;EACH,GAAG,IAAI;EACR;CACD,MAAM,EAAE,aAAa,GAAG,aAAa,MAAM,QAAQ,EAAE;CACrD,MAAM,YAAY,SAAS;CAC3B,MAAM,cAAc,SAAS;CAC7B,MAAM,UAAU,OAAO;CACvB,MAAM,YAAY,OAAO;CAEzB,IAAI,QAAQ,KAAK,IAAI,aAAa,aAAa,IAAI,EAAE;CACrD,IAAI,MAAM,KAAK,IAAI,OAAO,QAAQ,UAAU,WAAW;AAEvD,KAAI,cAAc,GAChB,SAAQ;AAGV,KAAI,YAAY,GACd,OAAM,OAAO;CAGf,MAAM,WAAW,UAAU;CAC3B,MAAM,cAAc,EAAE;AAEtB,KAAI,SACF,MAAK,IAAI,IAAI,GAAG,KAAK,UAAU,KAAK;EAClC,MAAM,aAAa,IAAI;AAEvB,MAAI,CAAC,YACH,aAAY,cAAc;WACjB,MAAM,EAGf,aAAY,cAAc,CAAC,cAFN,OAAO,aAAa,IAAI,UAAU,KAEA,cAAc,EAAE;WAC9D,MAAM,SACf,aAAY,cAAc,CAAC,GAAG,UAAU;MAIxC,aAAY,cAAc,CAAC,GAFN,OAAO,aAAa,IAAI,UAAU,EAEZ;;UAGtC,gBAAgB,UACzB,aAAY,aAAa,cAAc,CAAC,aAAa,EAAE,GAAG;KAE1D,aAAY,aAAa,CAAC,aAAa,YAAY,YAAY;AAGjE,QAAO;EACL;EACA;EACA;EACD;;AAGH,SAAgB,iBACd,UACA,KACA,OAII,EAAE,EACE;CAER,MAAM,EAAE,OAAO,KAAK,gBAAgB,eAAe,KADrC,SAAS,MAAM,QACgC,EAAE,KAAK;CAEpE,MAAM,iBAAiB,OAAO,IAAI,CAAC;AAgCnC,SA/ByB,KAAK,YAAY,KAAK,UAAU,SAAS,GAAG,UAGlE,MAAM,QAAQ,CACd,MAAM,OAAO,IAAI,CACjB,KAAK,MAAM,UAAU;EACpB,MAAM,SAAS,QAAQ,IAAI;EAE3B,MAAM,SAAS,IADM,IAAI,SAAS,MAAM,CAAC,eACV,CAAC;EAChC,MAAM,YAAY,QAAQ,YAAY,WAAW,MAAM;AACvD,MAAI,WAAW;GACb,IAAI,aAAa;AACjB,OAAI,MAAM,QAAQ,UAAU,EAAE;IAC5B,MAAM,gBAAgB,KACnB,MAAM,GAAG,KAAK,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC,CACvC,QAAQ,UAAU,IAAI;IACzB,MAAM,kBAAkB,UAAU,MAAM;AAExC,iBAAa;KACX;KACA,OAAO,QAAQ,OAAO,IAAI;KAC1B;KACA,IAAI,OAAO,gBAAgB;KAC5B,CAAC,KAAK,GAAG;;AAEZ,UAAO;IAAC;IAAK;IAAQ;IAAM;IAAW,CAAC,KAAK,GAAG;;AAEjD,SAAO,IAAI,SAAS;GACpB,CACD,KAAK,KAEI"}
@@ -1,34 +0,0 @@
1
- const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
2
- const require_code_frames = require('./code-frames.cjs');
3
- let jsonc_parser = require("jsonc-parser");
4
- let lines_and_columns = require("lines-and-columns");
5
-
6
- //#region ../json/src/utils/parse-error.ts
7
- /**
8
- * Nicely formats a JSON error with context
9
- *
10
- * @param input - JSON content as string
11
- * @param parseError - jsonc ParseError
12
- * @returns Formatted error message with context
13
- */
14
- function formatParseError(input, parseError) {
15
- const { error, offset, length } = parseError;
16
- const result = new lines_and_columns.LinesAndColumns(input).locationForIndex(offset);
17
- let line = result?.line ?? 0;
18
- let column = result?.column ?? 0;
19
- line++;
20
- column++;
21
- return `${(0, jsonc_parser.printParseErrorCode)(error)} in JSON at ${line}:${column}\n${require_code_frames.codeFrameColumns(input, {
22
- start: {
23
- line,
24
- column
25
- },
26
- end: {
27
- line,
28
- column: column + length
29
- }
30
- })}\n`;
31
- }
32
-
33
- //#endregion
34
- exports.formatParseError = formatParseError;
@@ -1,34 +0,0 @@
1
- import { codeFrameColumns } from "./code-frames.mjs";
2
- import { printParseErrorCode } from "jsonc-parser";
3
- import { LinesAndColumns } from "lines-and-columns";
4
-
5
- //#region ../json/src/utils/parse-error.ts
6
- /**
7
- * Nicely formats a JSON error with context
8
- *
9
- * @param input - JSON content as string
10
- * @param parseError - jsonc ParseError
11
- * @returns Formatted error message with context
12
- */
13
- function formatParseError(input, parseError) {
14
- const { error, offset, length } = parseError;
15
- const result = new LinesAndColumns(input).locationForIndex(offset);
16
- let line = result?.line ?? 0;
17
- let column = result?.column ?? 0;
18
- line++;
19
- column++;
20
- return `${printParseErrorCode(error)} in JSON at ${line}:${column}\n${codeFrameColumns(input, {
21
- start: {
22
- line,
23
- column
24
- },
25
- end: {
26
- line,
27
- column: column + length
28
- }
29
- })}\n`;
30
- }
31
-
32
- //#endregion
33
- export { formatParseError };
34
- //# sourceMappingURL=parse-error.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse-error.mjs","names":[],"sources":["../../../../../json/src/utils/parse-error.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport type { ParseError } from \"jsonc-parser\";\nimport { printParseErrorCode } from \"jsonc-parser\";\nimport { LinesAndColumns } from \"lines-and-columns\";\nimport { codeFrameColumns } from \"./code-frames\";\n\n/**\n * Nicely formats a JSON error with context\n *\n * @param input - JSON content as string\n * @param parseError - jsonc ParseError\n * @returns Formatted error message with context\n */\nexport function formatParseError(input: string, parseError: ParseError) {\n const { error, offset, length } = parseError;\n const result = new LinesAndColumns(input).locationForIndex(offset);\n let line = result?.line ?? 0;\n let column = result?.column ?? 0;\n\n line++;\n column++;\n\n return `${printParseErrorCode(error)} in JSON at ${line}:${column}\\n${codeFrameColumns(\n input,\n {\n start: {\n line,\n column\n },\n end: {\n line,\n column: column + length\n }\n }\n )}\\n`;\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,SAAgB,iBAAiB,OAAe,YAAwB;CACtE,MAAM,EAAE,OAAO,QAAQ,WAAW;CAClC,MAAM,SAAS,IAAI,gBAAgB,MAAM,CAAC,iBAAiB,OAAO;CAClE,IAAI,OAAO,QAAQ,QAAQ;CAC3B,IAAI,SAAS,QAAQ,UAAU;AAE/B;AACA;AAEA,QAAO,GAAG,oBAAoB,MAAM,CAAC,cAAc,KAAK,GAAG,OAAO,IAAI,iBACpE,OACA;EACE,OAAO;GACL;GACA;GACD;EACD,KAAK;GACH;GACA,QAAQ,SAAS;GAClB;EACF,CACF,CAAC"}
@@ -1,45 +0,0 @@
1
- const require_strip_comments = require('./strip-comments.cjs');
2
-
3
- //#region ../json/src/utils/parse.ts
4
- const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
5
- const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
6
- const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;
7
- function jsonParseTransform(key, value) {
8
- if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
9
- console.warn(`Dropping "${key}" key to prevent prototype pollution.`);
10
- return;
11
- }
12
- return value;
13
- }
14
- function parse(value, options = {}) {
15
- if (typeof value !== "string") return value;
16
- let stripped = require_strip_comments.stripComments(value);
17
- if (stripped[0] === "\"" && stripped[stripped.length - 1] === "\"" && !stripped.includes("\\")) return stripped.slice(1, -1);
18
- stripped = stripped.trim();
19
- if (stripped.length <= 9) switch (stripped.toLowerCase()) {
20
- case "true": return true;
21
- case "false": return false;
22
- case "undefined": return;
23
- case "null": return null;
24
- case "nan": return NaN;
25
- case "infinity": return Number.POSITIVE_INFINITY;
26
- case "-infinity": return Number.NEGATIVE_INFINITY;
27
- }
28
- if (!JsonSigRx.test(stripped)) {
29
- if (options.strict) throw new Error("Invalid JSON");
30
- return stripped;
31
- }
32
- try {
33
- if (suspectProtoRx.test(stripped) || suspectConstructorRx.test(stripped)) {
34
- if (options.strict) throw new Error("Possible prototype pollution");
35
- return JSON.parse(stripped, jsonParseTransform);
36
- }
37
- return JSON.parse(stripped);
38
- } catch (error) {
39
- if (options.strict) throw error;
40
- return value;
41
- }
42
- }
43
-
44
- //#endregion
45
- exports.parse = parse;
@@ -1,46 +0,0 @@
1
- import { stripComments } from "./strip-comments.mjs";
2
-
3
- //#region ../json/src/utils/parse.ts
4
- const suspectProtoRx = /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/;
5
- const suspectConstructorRx = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
6
- const JsonSigRx = /^\s*["[{]|^\s*-?\d{1,16}(?:\.\d{1,17})?(?:E[+-]?\d+)?\s*$/i;
7
- function jsonParseTransform(key, value) {
8
- if (key === "__proto__" || key === "constructor" && value && typeof value === "object" && "prototype" in value) {
9
- console.warn(`Dropping "${key}" key to prevent prototype pollution.`);
10
- return;
11
- }
12
- return value;
13
- }
14
- function parse(value, options = {}) {
15
- if (typeof value !== "string") return value;
16
- let stripped = stripComments(value);
17
- if (stripped[0] === "\"" && stripped[stripped.length - 1] === "\"" && !stripped.includes("\\")) return stripped.slice(1, -1);
18
- stripped = stripped.trim();
19
- if (stripped.length <= 9) switch (stripped.toLowerCase()) {
20
- case "true": return true;
21
- case "false": return false;
22
- case "undefined": return;
23
- case "null": return null;
24
- case "nan": return NaN;
25
- case "infinity": return Number.POSITIVE_INFINITY;
26
- case "-infinity": return Number.NEGATIVE_INFINITY;
27
- }
28
- if (!JsonSigRx.test(stripped)) {
29
- if (options.strict) throw new Error("Invalid JSON");
30
- return stripped;
31
- }
32
- try {
33
- if (suspectProtoRx.test(stripped) || suspectConstructorRx.test(stripped)) {
34
- if (options.strict) throw new Error("Possible prototype pollution");
35
- return JSON.parse(stripped, jsonParseTransform);
36
- }
37
- return JSON.parse(stripped);
38
- } catch (error) {
39
- if (options.strict) throw error;
40
- return value;
41
- }
42
- }
43
-
44
- //#endregion
45
- export { parse };
46
- //# sourceMappingURL=parse.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse.mjs","names":[],"sources":["../../../../../json/src/utils/parse.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { stripComments } from \"./strip-comments\";\n\n// https://github.com/fastify/secure-json-parse\n// https://github.com/hapijs/bourne\nconst suspectProtoRx =\n /\"(?:_|\\\\u0{2}5[Ff]){2}(?:p|\\\\u0{2}70)(?:r|\\\\u0{2}72)(?:o|\\\\u0{2}6[Ff])(?:t|\\\\u0{2}74)(?:o|\\\\u0{2}6[Ff])(?:_|\\\\u0{2}5[Ff]){2}\"\\s*:/;\nconst suspectConstructorRx =\n /\"(?:c|\\\\u0063)(?:o|\\\\u006[Ff])(?:n|\\\\u006[Ee])(?:s|\\\\u0073)(?:t|\\\\u0074)(?:r|\\\\u0072)(?:u|\\\\u0075)(?:c|\\\\u0063)(?:t|\\\\u0074)(?:o|\\\\u006[Ff])(?:r|\\\\u0072)\"\\s*:/;\n\nconst JsonSigRx = /^\\s*[\"[{]|^\\s*-?\\d{1,16}(?:\\.\\d{1,17})?(?:E[+-]?\\d+)?\\s*$/i;\n\nfunction jsonParseTransform(key: string, value: any): any {\n if (\n key === \"__proto__\" ||\n (key === \"constructor\" &&\n value &&\n typeof value === \"object\" &&\n \"prototype\" in value)\n ) {\n // eslint-disable-next-line no-console\n console.warn(`Dropping \"${key}\" key to prevent prototype pollution.`);\n return;\n }\n return value;\n}\n\nexport interface Options {\n strict?: boolean;\n}\n\nexport function parse<T = unknown>(value: any, options: Options = {}): T {\n if (typeof value !== \"string\") {\n return value;\n }\n\n let stripped = stripComments(value);\n\n if (\n stripped[0] === '\"' &&\n stripped[stripped.length - 1] === '\"' &&\n !stripped.includes(\"\\\\\")\n ) {\n return stripped.slice(1, -1) as T;\n }\n\n stripped = stripped.trim();\n\n if (stripped.length <= 9) {\n switch (stripped.toLowerCase()) {\n case \"true\": {\n return true as T;\n }\n case \"false\": {\n return false as T;\n }\n case \"undefined\": {\n return undefined as T;\n }\n case \"null\": {\n return null as T;\n }\n case \"nan\": {\n return Number.NaN as T;\n }\n case \"infinity\": {\n return Number.POSITIVE_INFINITY as T;\n }\n case \"-infinity\": {\n return Number.NEGATIVE_INFINITY as T;\n }\n }\n }\n\n if (!JsonSigRx.test(stripped)) {\n if (options.strict) {\n throw new Error(\"Invalid JSON\");\n }\n return stripped as T;\n }\n\n try {\n if (suspectProtoRx.test(stripped) || suspectConstructorRx.test(stripped)) {\n if (options.strict) {\n throw new Error(\"Possible prototype pollution\");\n }\n return JSON.parse(stripped, jsonParseTransform);\n }\n\n return JSON.parse(stripped);\n } catch (error) {\n if (options.strict) {\n throw error;\n }\n return value as T;\n }\n}\n\nexport function safeParse<T = unknown>(value: any, options: Options = {}): T {\n return parse<T>(value, { ...options, strict: true });\n}\n"],"mappings":";;;AAsBA,MAAM,iBACJ;AACF,MAAM,uBACJ;AAEF,MAAM,YAAY;AAElB,SAAS,mBAAmB,KAAa,OAAiB;AACxD,KACE,QAAQ,eACP,QAAQ,iBACP,SACA,OAAO,UAAU,YACjB,eAAe,OACjB;AAEA,UAAQ,KAAK,aAAa,IAAI,uCAAuC;AACrE;;AAEF,QAAO;;AAOT,SAAgB,MAAmB,OAAY,UAAmB,EAAE,EAAK;AACvE,KAAI,OAAO,UAAU,SACnB,QAAO;CAGT,IAAI,WAAW,cAAc,MAAM;AAEnC,KACE,SAAS,OAAO,QAChB,SAAS,SAAS,SAAS,OAAO,QAClC,CAAC,SAAS,SAAS,KAAK,CAExB,QAAO,SAAS,MAAM,GAAG,GAAG;AAG9B,YAAW,SAAS,MAAM;AAE1B,KAAI,SAAS,UAAU,EACrB,SAAQ,SAAS,aAAa,EAA9B;EACE,KAAK,OACH,QAAO;EAET,KAAK,QACH,QAAO;EAET,KAAK,YACH;EAEF,KAAK,OACH,QAAO;EAET,KAAK,MACH,QAAO;EAET,KAAK,WACH,QAAO,OAAO;EAEhB,KAAK,YACH,QAAO,OAAO;;AAKpB,KAAI,CAAC,UAAU,KAAK,SAAS,EAAE;AAC7B,MAAI,QAAQ,OACV,OAAM,IAAI,MAAM,eAAe;AAEjC,SAAO;;AAGT,KAAI;AACF,MAAI,eAAe,KAAK,SAAS,IAAI,qBAAqB,KAAK,SAAS,EAAE;AACxE,OAAI,QAAQ,OACV,OAAM,IAAI,MAAM,+BAA+B;AAEjD,UAAO,KAAK,MAAM,UAAU,mBAAmB;;AAGjD,SAAO,KAAK,MAAM,SAAS;UACpB,OAAO;AACd,MAAI,QAAQ,OACV,OAAM;AAER,SAAO"}
@@ -1,33 +0,0 @@
1
- const require_is_number = require('../../../type-checks/src/is-number.cjs');
2
- const require_is_undefined = require('../../../type-checks/src/is-undefined.cjs');
3
-
4
- //#region ../json/src/utils/stringify.ts
5
- /**
6
- * Stringify a value to a JSON-like string.
7
- *
8
- * @param value - The value to stringify
9
- * @param spacing - The spacing to use for the stringification
10
- * @returns The stringified value
11
- */
12
- const stringify = (value, spacing = 2) => {
13
- const space = require_is_number.isNumber(spacing) ? " ".repeat(spacing) : spacing;
14
- switch (value) {
15
- case null: return "null";
16
- case void 0: return "\"undefined\"";
17
- case true: return "true";
18
- case false: return "false";
19
- case Number.POSITIVE_INFINITY: return "infinity";
20
- case Number.NEGATIVE_INFINITY: return "-infinity";
21
- }
22
- if (Array.isArray(value)) return `[${space}${value.map((v) => stringify(v, space)).join(`,${space}`)}${space}]`;
23
- if (value instanceof Uint8Array) return value.toString();
24
- switch (typeof value) {
25
- case "number": return `${value}`;
26
- case "string": return JSON.stringify(value);
27
- case "object": return `{${space}${Object.keys(value).filter((key) => !require_is_undefined.isUndefined(value[key])).map((key) => `"${key}": ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
28
- default: return "null";
29
- }
30
- };
31
-
32
- //#endregion
33
- exports.stringify = stringify;
@@ -1,34 +0,0 @@
1
- import { isNumber } from "../../../type-checks/src/is-number.mjs";
2
- import { isUndefined } from "../../../type-checks/src/is-undefined.mjs";
3
-
4
- //#region ../json/src/utils/stringify.ts
5
- /**
6
- * Stringify a value to a JSON-like string.
7
- *
8
- * @param value - The value to stringify
9
- * @param spacing - The spacing to use for the stringification
10
- * @returns The stringified value
11
- */
12
- const stringify = (value, spacing = 2) => {
13
- const space = isNumber(spacing) ? " ".repeat(spacing) : spacing;
14
- switch (value) {
15
- case null: return "null";
16
- case void 0: return "\"undefined\"";
17
- case true: return "true";
18
- case false: return "false";
19
- case Number.POSITIVE_INFINITY: return "infinity";
20
- case Number.NEGATIVE_INFINITY: return "-infinity";
21
- }
22
- if (Array.isArray(value)) return `[${space}${value.map((v) => stringify(v, space)).join(`,${space}`)}${space}]`;
23
- if (value instanceof Uint8Array) return value.toString();
24
- switch (typeof value) {
25
- case "number": return `${value}`;
26
- case "string": return JSON.stringify(value);
27
- case "object": return `{${space}${Object.keys(value).filter((key) => !isUndefined(value[key])).map((key) => `"${key}": ${space}${stringify(value[key], space)}`).join(`,${space}`)}${space}}`;
28
- default: return "null";
29
- }
30
- };
31
-
32
- //#endregion
33
- export { stringify };
34
- //# sourceMappingURL=stringify.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stringify.mjs","names":[],"sources":["../../../../../json/src/utils/stringify.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isNumber } from \"@stryke/type-checks/is-number\";\nimport { isUndefined } from \"@stryke/type-checks/is-undefined\";\n\nexport const invalidKeyChars = [\n \"@\",\n \"/\",\n \"#\",\n \"$\",\n \" \",\n \":\",\n \";\",\n \",\",\n \".\",\n \"!\",\n \"?\",\n \"&\",\n \"=\",\n \"+\",\n \"-\",\n \"*\",\n \"%\",\n \"^\",\n \"~\",\n \"|\",\n \"\\\\\",\n '\"',\n \"'\",\n \"`\",\n \"{\",\n \"}\",\n \"[\",\n \"]\",\n \"(\",\n \")\",\n \"<\",\n \">\"\n] as const;\n\n/**\n * Stringify a value to a JSON-like string.\n *\n * @param value - The value to stringify\n * @param spacing - The spacing to use for the stringification\n * @returns The stringified value\n */\nexport const stringify = (\n value: unknown,\n spacing: string | number = 2\n): string => {\n const space = isNumber(spacing) ? \" \".repeat(spacing) : spacing;\n\n switch (value) {\n case null: {\n return \"null\";\n }\n case undefined: {\n return '\"undefined\"';\n }\n case true: {\n return \"true\";\n }\n case false: {\n return \"false\";\n }\n case Number.POSITIVE_INFINITY: {\n return \"infinity\";\n }\n case Number.NEGATIVE_INFINITY: {\n return \"-infinity\";\n }\n }\n\n if (Array.isArray(value)) {\n return `[${space}${value.map(v => stringify(v, space)).join(`,${space}`)}${space}]`;\n }\n if (value instanceof Uint8Array) {\n return value.toString();\n }\n\n // eslint-disable-next-line ts/switch-exhaustiveness-check\n switch (typeof value) {\n case \"number\": {\n return `${value}`;\n }\n case \"string\": {\n return JSON.stringify(value);\n }\n case \"object\": {\n const keys = Object.keys(value as object).filter(\n key => !isUndefined((value as any)[key])\n );\n\n return `{${space}${keys\n .map(\n key => `\"${key}\": ${space}${stringify((value as any)[key], space)}`\n )\n .join(`,${space}`)}${space}}`;\n }\n default:\n return \"null\";\n }\n};\n"],"mappings":";;;;;;;;;;;AA+DA,MAAa,aACX,OACA,UAA2B,MAChB;CACX,MAAM,QAAQ,SAAS,QAAQ,GAAG,IAAI,OAAO,QAAQ,GAAG;AAExD,SAAQ,OAAR;EACE,KAAK,KACH,QAAO;EAET,KAAK,OACH,QAAO;EAET,KAAK,KACH,QAAO;EAET,KAAK,MACH,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;EAET,KAAK,OAAO,kBACV,QAAO;;AAIX,KAAI,MAAM,QAAQ,MAAM,CACtB,QAAO,IAAI,QAAQ,MAAM,KAAI,MAAK,UAAU,GAAG,MAAM,CAAC,CAAC,KAAK,IAAI,QAAQ,GAAG,MAAM;AAEnF,KAAI,iBAAiB,WACnB,QAAO,MAAM,UAAU;AAIzB,SAAQ,OAAO,OAAf;EACE,KAAK,SACH,QAAO,GAAG;EAEZ,KAAK,SACH,QAAO,KAAK,UAAU,MAAM;EAE9B,KAAK,SAKH,QAAO,IAAI,QAJE,OAAO,KAAK,MAAgB,CAAC,QACxC,QAAO,CAAC,YAAa,MAAc,KAAK,CAGnB,CACpB,KACC,QAAO,IAAI,IAAI,KAAK,QAAQ,UAAW,MAAc,MAAM,MAAM,GAClE,CACA,KAAK,IAAI,QAAQ,GAAG,MAAM;EAE/B,QACE,QAAO"}
@@ -1,85 +0,0 @@
1
-
2
- //#region ../json/src/utils/strip-comments.ts
3
- const singleComment = Symbol("singleComment");
4
- const multiComment = Symbol("multiComment");
5
- function stripWithoutWhitespace() {
6
- return "";
7
- }
8
- function stripWithWhitespace(value, start, end) {
9
- return value.slice(start, end).replace(/\S/g, " ");
10
- }
11
- function isEscaped(value, quotePosition) {
12
- let index = quotePosition - 1;
13
- let backslashCount = 0;
14
- while (value[index] === "\\") {
15
- index -= 1;
16
- backslashCount += 1;
17
- }
18
- return Boolean(backslashCount % 2);
19
- }
20
- function stripComments(value, { whitespace = true, trailingCommas = false } = {}) {
21
- if (typeof value !== "string") throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof value}\``);
22
- const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
23
- let isInsideString = false;
24
- let isInsideComment = false;
25
- let offset = 0;
26
- let buffer = "";
27
- let result = "";
28
- let commaIndex = -1;
29
- for (let index = 0; index < value.length; index++) {
30
- const currentCharacter = value[index];
31
- const nextCharacter = value[index + 1];
32
- if (!isInsideComment && currentCharacter === "\"") {
33
- if (!isEscaped(value, index)) isInsideString = !isInsideString;
34
- }
35
- if (isInsideString) continue;
36
- if (!isInsideComment && currentCharacter + (nextCharacter ?? "") === "//") {
37
- buffer += value.slice(offset, index);
38
- offset = index;
39
- isInsideComment = singleComment;
40
- index++;
41
- } else if (isInsideComment === singleComment && currentCharacter + (nextCharacter ?? "") === "\r\n") {
42
- index++;
43
- isInsideComment = false;
44
- buffer += strip(value, offset, index);
45
- offset = index;
46
- } else if (isInsideComment === singleComment && currentCharacter === "\n") {
47
- isInsideComment = false;
48
- buffer += strip(value, offset, index);
49
- offset = index;
50
- } else if (!isInsideComment && currentCharacter + (nextCharacter ?? "") === "/*") {
51
- buffer += value.slice(offset, index);
52
- offset = index;
53
- isInsideComment = multiComment;
54
- index++;
55
- } else if (isInsideComment === multiComment && currentCharacter + (nextCharacter ?? "") === "*/") {
56
- index++;
57
- isInsideComment = false;
58
- buffer += strip(value, offset, index + 1);
59
- offset = index + 1;
60
- } else if (trailingCommas && !isInsideComment) {
61
- if (commaIndex !== -1) {
62
- if (currentCharacter === "}" || currentCharacter === "]") {
63
- buffer += value.slice(offset, index);
64
- result += strip(buffer, 0, 1) + buffer.slice(1);
65
- buffer = "";
66
- offset = index;
67
- commaIndex = -1;
68
- } else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
69
- buffer += value.slice(offset, index);
70
- offset = index;
71
- commaIndex = -1;
72
- }
73
- } else if (currentCharacter === ",") {
74
- result += buffer + value.slice(offset, index);
75
- buffer = "";
76
- offset = index;
77
- commaIndex = index;
78
- }
79
- }
80
- }
81
- return result + buffer + (isInsideComment ? strip(value.slice(offset)) : value.slice(offset));
82
- }
83
-
84
- //#endregion
85
- exports.stripComments = stripComments;
@@ -1,85 +0,0 @@
1
- //#region ../json/src/utils/strip-comments.ts
2
- const singleComment = Symbol("singleComment");
3
- const multiComment = Symbol("multiComment");
4
- function stripWithoutWhitespace() {
5
- return "";
6
- }
7
- function stripWithWhitespace(value, start, end) {
8
- return value.slice(start, end).replace(/\S/g, " ");
9
- }
10
- function isEscaped(value, quotePosition) {
11
- let index = quotePosition - 1;
12
- let backslashCount = 0;
13
- while (value[index] === "\\") {
14
- index -= 1;
15
- backslashCount += 1;
16
- }
17
- return Boolean(backslashCount % 2);
18
- }
19
- function stripComments(value, { whitespace = true, trailingCommas = false } = {}) {
20
- if (typeof value !== "string") throw new TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof value}\``);
21
- const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;
22
- let isInsideString = false;
23
- let isInsideComment = false;
24
- let offset = 0;
25
- let buffer = "";
26
- let result = "";
27
- let commaIndex = -1;
28
- for (let index = 0; index < value.length; index++) {
29
- const currentCharacter = value[index];
30
- const nextCharacter = value[index + 1];
31
- if (!isInsideComment && currentCharacter === "\"") {
32
- if (!isEscaped(value, index)) isInsideString = !isInsideString;
33
- }
34
- if (isInsideString) continue;
35
- if (!isInsideComment && currentCharacter + (nextCharacter ?? "") === "//") {
36
- buffer += value.slice(offset, index);
37
- offset = index;
38
- isInsideComment = singleComment;
39
- index++;
40
- } else if (isInsideComment === singleComment && currentCharacter + (nextCharacter ?? "") === "\r\n") {
41
- index++;
42
- isInsideComment = false;
43
- buffer += strip(value, offset, index);
44
- offset = index;
45
- } else if (isInsideComment === singleComment && currentCharacter === "\n") {
46
- isInsideComment = false;
47
- buffer += strip(value, offset, index);
48
- offset = index;
49
- } else if (!isInsideComment && currentCharacter + (nextCharacter ?? "") === "/*") {
50
- buffer += value.slice(offset, index);
51
- offset = index;
52
- isInsideComment = multiComment;
53
- index++;
54
- } else if (isInsideComment === multiComment && currentCharacter + (nextCharacter ?? "") === "*/") {
55
- index++;
56
- isInsideComment = false;
57
- buffer += strip(value, offset, index + 1);
58
- offset = index + 1;
59
- } else if (trailingCommas && !isInsideComment) {
60
- if (commaIndex !== -1) {
61
- if (currentCharacter === "}" || currentCharacter === "]") {
62
- buffer += value.slice(offset, index);
63
- result += strip(buffer, 0, 1) + buffer.slice(1);
64
- buffer = "";
65
- offset = index;
66
- commaIndex = -1;
67
- } else if (currentCharacter !== " " && currentCharacter !== " " && currentCharacter !== "\r" && currentCharacter !== "\n") {
68
- buffer += value.slice(offset, index);
69
- offset = index;
70
- commaIndex = -1;
71
- }
72
- } else if (currentCharacter === ",") {
73
- result += buffer + value.slice(offset, index);
74
- buffer = "";
75
- offset = index;
76
- commaIndex = index;
77
- }
78
- }
79
- }
80
- return result + buffer + (isInsideComment ? strip(value.slice(offset)) : value.slice(offset));
81
- }
82
-
83
- //#endregion
84
- export { stripComments };
85
- //# sourceMappingURL=strip-comments.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strip-comments.mjs","names":[],"sources":["../../../../../json/src/utils/strip-comments.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { EMPTY_STRING } from \"@stryke/types/base\";\n\nconst singleComment = Symbol(\"singleComment\");\nconst multiComment = Symbol(\"multiComment\");\n\nfunction stripWithoutWhitespace() {\n return \"\";\n}\nfunction stripWithWhitespace(value: string, start?: number, end?: number) {\n return value.slice(start, end).replace(/\\S/g, \" \");\n}\n\nfunction isEscaped(value: string, quotePosition: number) {\n let index = quotePosition - 1;\n let backslashCount = 0;\n while (value[index] === \"\\\\\") {\n index -= 1;\n backslashCount += 1;\n }\n\n return Boolean(backslashCount % 2);\n}\n\nexport function stripComments(\n value: string,\n { whitespace = true, trailingCommas = false } = {}\n) {\n if (typeof value !== \"string\") {\n throw new TypeError(\n `Expected argument \\`jsonString\\` to be a \\`string\\`, got \\`${typeof value}\\``\n );\n }\n\n const strip = whitespace ? stripWithWhitespace : stripWithoutWhitespace;\n let isInsideString: boolean | symbol = false;\n let isInsideComment: boolean | symbol = false;\n let offset = 0;\n let buffer = \"\";\n let result = \"\";\n let commaIndex = -1;\n for (let index = 0; index < value.length; index++) {\n const currentCharacter = value[index];\n const nextCharacter = value[index + 1];\n if (!isInsideComment && currentCharacter === '\"') {\n const escaped = isEscaped(value, index);\n if (!escaped) {\n isInsideString = !isInsideString;\n }\n }\n if (isInsideString) {\n continue;\n }\n if (\n !isInsideComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"//\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n isInsideComment = singleComment;\n index++;\n } else if (\n isInsideComment === singleComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"\\r\\n\"\n ) {\n index++;\n isInsideComment = false;\n buffer += strip(value, offset, index);\n offset = index;\n } else if (isInsideComment === singleComment && currentCharacter === \"\\n\") {\n isInsideComment = false;\n buffer += strip(value, offset, index);\n offset = index;\n } else if (\n !isInsideComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"/*\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n isInsideComment = multiComment;\n index++;\n } else if (\n isInsideComment === multiComment &&\n currentCharacter + (nextCharacter ?? EMPTY_STRING) === \"*/\"\n ) {\n index++;\n isInsideComment = false;\n buffer += strip(value, offset, index + 1);\n offset = index + 1;\n } else if (trailingCommas && !isInsideComment) {\n if (commaIndex !== -1) {\n if (currentCharacter === \"}\" || currentCharacter === \"]\") {\n buffer += value.slice(offset, index);\n result += strip(buffer, 0, 1) + buffer.slice(1);\n buffer = \"\";\n offset = index;\n commaIndex = -1;\n } else if (\n currentCharacter !== \" \" &&\n currentCharacter !== \"\t\" &&\n currentCharacter !== \"\\r\" &&\n currentCharacter !== \"\\n\"\n ) {\n buffer += value.slice(offset, index);\n offset = index;\n commaIndex = -1;\n }\n } else if (currentCharacter === \",\") {\n result += buffer + value.slice(offset, index);\n buffer = \"\";\n offset = index;\n commaIndex = index;\n }\n }\n }\n\n return (\n result +\n buffer +\n (isInsideComment ? strip(value.slice(offset)) : value.slice(offset))\n );\n}\n"],"mappings":";AAoBA,MAAM,gBAAgB,OAAO,gBAAgB;AAC7C,MAAM,eAAe,OAAO,eAAe;AAE3C,SAAS,yBAAyB;AAChC,QAAO;;AAET,SAAS,oBAAoB,OAAe,OAAgB,KAAc;AACxE,QAAO,MAAM,MAAM,OAAO,IAAI,CAAC,QAAQ,OAAO,IAAI;;AAGpD,SAAS,UAAU,OAAe,eAAuB;CACvD,IAAI,QAAQ,gBAAgB;CAC5B,IAAI,iBAAiB;AACrB,QAAO,MAAM,WAAW,MAAM;AAC5B,WAAS;AACT,oBAAkB;;AAGpB,QAAO,QAAQ,iBAAiB,EAAE;;AAGpC,SAAgB,cACd,OACA,EAAE,aAAa,MAAM,iBAAiB,UAAU,EAAE,EAClD;AACA,KAAI,OAAO,UAAU,SACnB,OAAM,IAAI,UACR,8DAA8D,OAAO,MAAM,IAC5E;CAGH,MAAM,QAAQ,aAAa,sBAAsB;CACjD,IAAI,iBAAmC;CACvC,IAAI,kBAAoC;CACxC,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI,SAAS;CACb,IAAI,aAAa;AACjB,MAAK,IAAI,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;EACjD,MAAM,mBAAmB,MAAM;EAC/B,MAAM,gBAAgB,MAAM,QAAQ;AACpC,MAAI,CAAC,mBAAmB,qBAAqB,MAE3C;OAAI,CADY,UAAU,OAAO,MACrB,CACV,kBAAiB,CAAC;;AAGtB,MAAI,eACF;AAEF,MACE,CAAC,mBACD,oBAAoB,yBAAmC,MACvD;AACA,aAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,YAAS;AACT,qBAAkB;AAClB;aAEA,oBAAoB,iBACpB,oBAAoB,yBAAmC,QACvD;AACA;AACA,qBAAkB;AAClB,aAAU,MAAM,OAAO,QAAQ,MAAM;AACrC,YAAS;aACA,oBAAoB,iBAAiB,qBAAqB,MAAM;AACzE,qBAAkB;AAClB,aAAU,MAAM,OAAO,QAAQ,MAAM;AACrC,YAAS;aAET,CAAC,mBACD,oBAAoB,yBAAmC,MACvD;AACA,aAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,YAAS;AACT,qBAAkB;AAClB;aAEA,oBAAoB,gBACpB,oBAAoB,yBAAmC,MACvD;AACA;AACA,qBAAkB;AAClB,aAAU,MAAM,OAAO,QAAQ,QAAQ,EAAE;AACzC,YAAS,QAAQ;aACR,kBAAkB,CAAC,iBAC5B;OAAI,eAAe,IACjB;QAAI,qBAAqB,OAAO,qBAAqB,KAAK;AACxD,eAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,eAAU,MAAM,QAAQ,GAAG,EAAE,GAAG,OAAO,MAAM,EAAE;AAC/C,cAAS;AACT,cAAS;AACT,kBAAa;eAEb,qBAAqB,OACrB,qBAAqB,OACrB,qBAAqB,QACrB,qBAAqB,MACrB;AACA,eAAU,MAAM,MAAM,QAAQ,MAAM;AACpC,cAAS;AACT,kBAAa;;cAEN,qBAAqB,KAAK;AACnC,cAAU,SAAS,MAAM,MAAM,QAAQ,MAAM;AAC7C,aAAS;AACT,aAAS;AACT,iBAAa;;;;AAKnB,QACE,SACA,UACC,kBAAkB,MAAM,MAAM,MAAM,OAAO,CAAC,GAAG,MAAM,MAAM,OAAO"}
@@ -1,15 +0,0 @@
1
-
2
- //#region ../type-checks/src/get-object-tag.ts
3
- /**
4
- * Gets the `toStringTag` of `obj`.
5
- *
6
- * @param value - The obj to query.
7
- * @returns Returns the `toStringTag`.
8
- */
9
- const getObjectTag = (value) => {
10
- if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
11
- return Object.prototype.toString.call(value);
12
- };
13
-
14
- //#endregion
15
- exports.getObjectTag = getObjectTag;
@@ -1,15 +0,0 @@
1
- //#region ../type-checks/src/get-object-tag.ts
2
- /**
3
- * Gets the `toStringTag` of `obj`.
4
- *
5
- * @param value - The obj to query.
6
- * @returns Returns the `toStringTag`.
7
- */
8
- const getObjectTag = (value) => {
9
- if (value == null) return value === void 0 ? "[object Undefined]" : "[object Null]";
10
- return Object.prototype.toString.call(value);
11
- };
12
-
13
- //#endregion
14
- export { getObjectTag };
15
- //# sourceMappingURL=get-object-tag.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"get-object-tag.mjs","names":[],"sources":["../../../../type-checks/src/get-object-tag.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Gets the `toStringTag` of `obj`.\n *\n * @param value - The obj to query.\n * @returns Returns the `toStringTag`.\n */\nexport const getObjectTag = (value: unknown): string => {\n if (value == null) {\n return value === undefined ? \"[object Undefined]\" : \"[object Null]\";\n }\n return Object.prototype.toString.call(value);\n};\n"],"mappings":";;;;;;;AAwBA,MAAa,gBAAgB,UAA2B;AACtD,KAAI,SAAS,KACX,QAAO,UAAU,SAAY,uBAAuB;AAEtD,QAAO,OAAO,UAAU,SAAS,KAAK,MAAM"}
@@ -1,14 +0,0 @@
1
- const require_get_object_tag = require('./get-object-tag.cjs');
2
- const require_is_plain_object = require('./is-plain-object.cjs');
3
- const require_is_null = require('./is-null.cjs');
4
- const require_is_number = require('./is-number.cjs');
5
- const require_is_undefined = require('./is-undefined.cjs');
6
- const require_is_empty = require('./is-empty.cjs');
7
- const require_is_object = require('./is-object.cjs');
8
- const require_is_buffer = require('./is-buffer.cjs');
9
- require('./type-detect.cjs');
10
- require('./is-collection.cjs');
11
- const require_is_string = require('./is-string.cjs');
12
- const require_is_error = require('./is-error.cjs');
13
- const require_is_set = require('./is-set.cjs');
14
- const require_is_set_string = require('./is-set-string.cjs');
@@ -1,16 +0,0 @@
1
- import { getObjectTag } from "./get-object-tag.mjs";
2
- import { isObjectLike, isPlainObject } from "./is-plain-object.mjs";
3
- import { isNull } from "./is-null.mjs";
4
- import { isNumber } from "./is-number.mjs";
5
- import { isUndefined } from "./is-undefined.mjs";
6
- import { isEmpty } from "./is-empty.mjs";
7
- import { isObject } from "./is-object.mjs";
8
- import { isBufferExists } from "./is-buffer.mjs";
9
- import "./type-detect.mjs";
10
- import "./is-collection.mjs";
11
- import { isString } from "./is-string.mjs";
12
- import { isError } from "./is-error.mjs";
13
- import { isSet } from "./is-set.mjs";
14
- import { isSetString } from "./is-set-string.mjs";
15
-
16
- export { };
@@ -1,14 +0,0 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
- let node_buffer = require("node:buffer");
3
-
4
- //#region ../type-checks/src/is-buffer.ts
5
- const isBufferExists = typeof node_buffer.Buffer !== "undefined";
6
- /**
7
- * Check if the provided value's type is `Buffer`
8
- */
9
- const isBuffer = isBufferExists ? node_buffer.Buffer.isBuffer.bind(node_buffer.Buffer) : function isBuffer(_) {
10
- return false;
11
- };
12
-
13
- //#endregion
14
- exports.isBufferExists = isBufferExists;
@@ -1,14 +0,0 @@
1
- import { Buffer } from "node:buffer";
2
-
3
- //#region ../type-checks/src/is-buffer.ts
4
- const isBufferExists = typeof Buffer !== "undefined";
5
- /**
6
- * Check if the provided value's type is `Buffer`
7
- */
8
- const isBuffer = isBufferExists ? Buffer.isBuffer.bind(Buffer) : function isBuffer(_) {
9
- return false;
10
- };
11
-
12
- //#endregion
13
- export { isBufferExists };
14
- //# sourceMappingURL=is-buffer.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-buffer.mjs","names":[],"sources":["../../../../type-checks/src/is-buffer.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { Buffer } from \"node:buffer\";\n\nexport const isBufferExists = typeof Buffer !== \"undefined\";\n\n/**\n * Check if the provided value's type is `Buffer`\n */\nexport const isBuffer: typeof Buffer.isBuffer = isBufferExists\n ? Buffer.isBuffer.bind(Buffer)\n : /**\n * Check if the provided value's type is `Buffer`\n\n * @param _ - The value to type check\n * @returns An indicator specifying if the value provided is of type `Buffer`\n */\n function isBuffer(_: Parameters<typeof Buffer.isBuffer>[0]): _ is Buffer {\n return false;\n };\n"],"mappings":";;;AAoBA,MAAa,iBAAiB,OAAO,WAAW;;;;AAKhD,MAAa,WAAmC,iBAC5C,OAAO,SAAS,KAAK,OAAO,GAO5B,SAAS,SAAS,GAAuD;AACvE,QAAO"}
@@ -1 +0,0 @@
1
- require('./type-detect.cjs');
@@ -1,3 +0,0 @@
1
- import "./type-detect.mjs";
2
-
3
- export { };
@@ -1,20 +0,0 @@
1
- const require_is_null = require('./is-null.cjs');
2
- const require_is_undefined = require('./is-undefined.cjs');
3
-
4
- //#region ../type-checks/src/is-empty.ts
5
- /**
6
- * Check if the provided value's type is `null` or `undefined`
7
- *
8
- * @param value - The value to type check
9
- * @returns An indicator specifying if the value provided is of type `null` or `undefined`
10
- */
11
- const isEmpty = (value) => {
12
- try {
13
- return require_is_undefined.isUndefined(value) || require_is_null.isNull(value);
14
- } catch {
15
- return false;
16
- }
17
- };
18
-
19
- //#endregion
20
- exports.isEmpty = isEmpty;
@@ -1,21 +0,0 @@
1
- import { isNull } from "./is-null.mjs";
2
- import { isUndefined } from "./is-undefined.mjs";
3
-
4
- //#region ../type-checks/src/is-empty.ts
5
- /**
6
- * Check if the provided value's type is `null` or `undefined`
7
- *
8
- * @param value - The value to type check
9
- * @returns An indicator specifying if the value provided is of type `null` or `undefined`
10
- */
11
- const isEmpty = (value) => {
12
- try {
13
- return isUndefined(value) || isNull(value);
14
- } catch {
15
- return false;
16
- }
17
- };
18
-
19
- //#endregion
20
- export { isEmpty };
21
- //# sourceMappingURL=is-empty.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"is-empty.mjs","names":[],"sources":["../../../../type-checks/src/is-empty.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { isDate } from \"./is-date\";\nimport { isFunction } from \"./is-function\";\nimport { isNull } from \"./is-null\";\nimport { isNumber } from \"./is-number\";\nimport { isSymbol } from \"./is-symbol\";\nimport { isUndefined } from \"./is-undefined\";\n\n/**\n * Check if the provided value's type is `null` or `undefined`\n *\n * @param value - The value to type check\n * @returns An indicator specifying if the value provided is of type `null` or `undefined`\n */\nexport const isEmpty = (value: unknown) => {\n try {\n return isUndefined(value) || isNull(value);\n } catch {\n return false;\n }\n};\n\nexport const isEmptyAnything = (value: any) => {\n if (value === true || value === false) return true;\n if (value === null || value === undefined) return true;\n if (isNumber(value)) return value === 0;\n if (isDate(value)) return Number.isNaN(value.getTime());\n if (isFunction(value)) return false;\n if (isSymbol(value)) return false;\n const { length } = value;\n if (isNumber(length)) return length === 0;\n const { size } = value;\n if (isNumber(size)) return size === 0;\n const keys = Object.keys(value).length;\n\n return keys === 0;\n};\n"],"mappings":";;;;;;;;;;AA+BA,MAAa,WAAW,UAAmB;AACzC,KAAI;AACF,SAAO,YAAY,MAAM,IAAI,OAAO,MAAM;SACpC;AACN,SAAO"}