z-schema 12.1.1 → 12.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.
Files changed (110) hide show
  1. package/README.md +2 -2
  2. package/bin/z-schema +4 -5
  3. package/cjs/{index.js → index.cjs} +696 -687
  4. package/cjs/{index.d.ts → index.d.cts} +47 -26
  5. package/dist/{errors.d.mts → errors.d.ts} +2 -2
  6. package/dist/{errors.mjs → errors.js} +1 -2
  7. package/dist/{format-validators.mjs → format-validators.js} +43 -36
  8. package/dist/{index.d.mts → index.d.ts} +9 -9
  9. package/dist/{index.mjs → index.js} +3 -3
  10. package/dist/{json-schema-versions.d.mts → json-schema-versions.d.ts} +34 -3
  11. package/dist/{json-schema.d.mts → json-schema.d.ts} +7 -7
  12. package/dist/{json-schema.mjs → json-schema.js} +7 -12
  13. package/dist/{json-validation.mjs → json-validation.js} +143 -127
  14. package/dist/{report.d.mts → report.d.ts} +7 -8
  15. package/dist/{report.mjs → report.js} +28 -31
  16. package/dist/{schema-cache.d.mts → schema-cache.d.ts} +4 -4
  17. package/dist/{schema-cache.mjs → schema-cache.js} +10 -11
  18. package/dist/{schema-compiler.d.mts → schema-compiler.d.ts} +4 -4
  19. package/dist/{schema-compiler.mjs → schema-compiler.js} +95 -77
  20. package/dist/{schema-validator.d.mts → schema-validator.d.ts} +5 -5
  21. package/dist/{schema-validator.mjs → schema-validator.js} +138 -166
  22. package/dist/utils/{array.mjs → array.js} +4 -3
  23. package/dist/utils/{base64.mjs → base64.js} +3 -2
  24. package/dist/utils/{clone.mjs → clone.js} +18 -20
  25. package/dist/utils/{hostname.mjs → hostname.js} +19 -22
  26. package/dist/utils/{json.mjs → json.js} +11 -7
  27. package/dist/utils/{schema-regex.mjs → schema-regex.js} +5 -5
  28. package/dist/utils/{time.mjs → time.js} +5 -5
  29. package/dist/utils/unicode.js +22 -0
  30. package/dist/utils/{what-is.mjs → what-is.js} +1 -2
  31. package/dist/validation/{array.mjs → array.js} +18 -20
  32. package/dist/validation/{combinators.mjs → combinators.js} +16 -16
  33. package/dist/validation/{numeric.mjs → numeric.js} +11 -11
  34. package/dist/validation/{object.mjs → object.js} +35 -34
  35. package/dist/validation/{ref.mjs → ref.js} +4 -4
  36. package/dist/validation/{shared.mjs → shared.js} +12 -11
  37. package/dist/validation/{string.mjs → string.js} +32 -32
  38. package/dist/validation/type.js +34 -0
  39. package/dist/{z-schema-base.d.mts → z-schema-base.d.ts} +11 -12
  40. package/dist/{z-schema-base.mjs → z-schema-base.js} +45 -40
  41. package/dist/{z-schema-options.d.mts → z-schema-options.d.ts} +3 -3
  42. package/dist/{z-schema-options.mjs → z-schema-options.js} +4 -4
  43. package/dist/{z-schema-reader.d.mts → z-schema-reader.d.ts} +1 -1
  44. package/dist/{z-schema-versions.mjs → z-schema-versions.js} +21 -21
  45. package/dist/{z-schema.d.mts → z-schema.d.ts} +5 -13
  46. package/dist/{z-schema.mjs → z-schema.js} +37 -47
  47. package/package.json +25 -23
  48. package/src/errors.ts +1 -2
  49. package/src/format-validators.ts +139 -59
  50. package/src/json-schema-versions.ts +56 -2
  51. package/src/json-schema.ts +10 -9
  52. package/src/json-validation.ts +189 -146
  53. package/src/report.ts +37 -49
  54. package/src/schema-cache.ts +13 -13
  55. package/src/schema-compiler.ts +170 -117
  56. package/src/schema-validator.ts +239 -238
  57. package/src/utils/array.ts +9 -6
  58. package/src/utils/base64.ts +13 -2
  59. package/src/utils/clone.ts +28 -30
  60. package/src/utils/date.ts +6 -3
  61. package/src/utils/hostname.ts +27 -27
  62. package/src/utils/json.ts +16 -9
  63. package/src/utils/properties.ts +2 -2
  64. package/src/utils/schema-regex.ts +4 -4
  65. package/src/utils/time.ts +5 -5
  66. package/src/utils/unicode.ts +12 -5
  67. package/src/utils/what-is.ts +1 -5
  68. package/src/validation/array.ts +24 -22
  69. package/src/validation/combinators.ts +14 -14
  70. package/src/validation/numeric.ts +14 -28
  71. package/src/validation/object.ts +32 -36
  72. package/src/validation/ref.ts +5 -6
  73. package/src/validation/shared.ts +22 -21
  74. package/src/validation/string.ts +29 -39
  75. package/src/validation/type.ts +17 -17
  76. package/src/z-schema-base.ts +49 -38
  77. package/src/z-schema-options.ts +4 -3
  78. package/src/z-schema.ts +35 -45
  79. package/umd/ZSchema.js +723 -697
  80. package/umd/ZSchema.min.js +2 -2
  81. package/umd/package.json +3 -0
  82. package/dist/utils/unicode.mjs +0 -12
  83. package/dist/validation/type.mjs +0 -32
  84. /package/dist/{format-validators.d.mts → format-validators.d.ts} +0 -0
  85. /package/dist/{json-schema-versions.mjs → json-schema-versions.js} +0 -0
  86. /package/dist/schemas/{draft-04-schema.mjs → draft-04-schema.js} +0 -0
  87. /package/dist/schemas/{draft-06-schema.mjs → draft-06-schema.js} +0 -0
  88. /package/dist/schemas/{draft-07-schema.mjs → draft-07-schema.js} +0 -0
  89. /package/dist/schemas/{draft-2019-09-meta-applicator.mjs → draft-2019-09-meta-applicator.js} +0 -0
  90. /package/dist/schemas/{draft-2019-09-meta-content.mjs → draft-2019-09-meta-content.js} +0 -0
  91. /package/dist/schemas/{draft-2019-09-meta-core.mjs → draft-2019-09-meta-core.js} +0 -0
  92. /package/dist/schemas/{draft-2019-09-meta-format.mjs → draft-2019-09-meta-format.js} +0 -0
  93. /package/dist/schemas/{draft-2019-09-meta-meta-data.mjs → draft-2019-09-meta-meta-data.js} +0 -0
  94. /package/dist/schemas/{draft-2019-09-meta-validation.mjs → draft-2019-09-meta-validation.js} +0 -0
  95. /package/dist/schemas/{draft-2019-09-schema.mjs → draft-2019-09-schema.js} +0 -0
  96. /package/dist/schemas/{draft-2020-12-meta-applicator.mjs → draft-2020-12-meta-applicator.js} +0 -0
  97. /package/dist/schemas/{draft-2020-12-meta-content.mjs → draft-2020-12-meta-content.js} +0 -0
  98. /package/dist/schemas/{draft-2020-12-meta-core.mjs → draft-2020-12-meta-core.js} +0 -0
  99. /package/dist/schemas/{draft-2020-12-meta-format-annotation.mjs → draft-2020-12-meta-format-annotation.js} +0 -0
  100. /package/dist/schemas/{draft-2020-12-meta-format-assertion.mjs → draft-2020-12-meta-format-assertion.js} +0 -0
  101. /package/dist/schemas/{draft-2020-12-meta-meta-data.mjs → draft-2020-12-meta-meta-data.js} +0 -0
  102. /package/dist/schemas/{draft-2020-12-meta-unevaluated.mjs → draft-2020-12-meta-unevaluated.js} +0 -0
  103. /package/dist/schemas/{draft-2020-12-meta-validation.mjs → draft-2020-12-meta-validation.js} +0 -0
  104. /package/dist/schemas/{draft-2020-12-schema.mjs → draft-2020-12-schema.js} +0 -0
  105. /package/dist/utils/{constants.mjs → constants.js} +0 -0
  106. /package/dist/utils/{date.mjs → date.js} +0 -0
  107. /package/dist/utils/{properties.mjs → properties.js} +0 -0
  108. /package/dist/utils/{symbols.mjs → symbols.js} +0 -0
  109. /package/dist/utils/{uri.mjs → uri.js} +0 -0
  110. /package/dist/{z-schema-reader.mjs → z-schema-reader.js} +0 -0
@@ -1,13 +1,16 @@
1
1
  import isIPModule from "validator/lib/isIP.js";
2
2
  import punycode from "punycode/punycode.js";
3
3
  //#region src/utils/hostname.ts
4
- const IDN_SEPARATOR_REGEX = /[\u3002\uff0e\uff61]/g;
5
- const IDN_SEPARATOR_TEST_REGEX = /[\u3002\uff0e\uff61]/;
4
+ const IDN_SEPARATOR_REGEX = /[\u3002\uFF0E\uFF61]/g;
5
+ const IDN_SEPARATOR_TEST_REGEX = /[\u3002\uFF0E\uFF61]/;
6
6
  const splitHostnameLabels = (hostname) => {
7
7
  if (hostname.length === 0 || hostname.length > 255) return null;
8
8
  if (hostname.startsWith(".") || hostname.endsWith(".")) return null;
9
9
  const labels = hostname.split(".");
10
- if (labels.some((label) => label.length === 0 || label.length > 63)) return null;
10
+ for (let i = 0; i < labels.length; i++) {
11
+ const len = labels[i].length;
12
+ if (len === 0 || len > 63) return null;
13
+ }
11
14
  return labels;
12
15
  };
13
16
  const isAsciiHostnameLabel = (label) => /^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i.test(label);
@@ -18,7 +21,7 @@ const toUnicodeLabel = (label) => {
18
21
  if (!/^xn--/i.test(label)) return label;
19
22
  try {
20
23
  return punycode.toUnicode(label.toLowerCase());
21
- } catch (_e) {
24
+ } catch {
22
25
  return null;
23
26
  }
24
27
  };
@@ -26,34 +29,27 @@ const isValidIdnUnicodeLabel = (label) => {
26
29
  if (label.startsWith("-") || label.endsWith("-")) return false;
27
30
  if (label.length >= 4 && label[2] === "-" && label[3] === "-" && !/^xn--/i.test(label)) return false;
28
31
  if (/^\p{M}/u.test(label)) return false;
29
- if (/[\u302e\u302f\u0640\u07fa]/u.test(label)) return false;
32
+ if (/[\u302E\u302F\u0640\u07FA]/u.test(label)) return false;
30
33
  for (let idx = 0; idx < label.length; idx++) {
31
34
  const char = label[idx];
32
- if (char === "·") {
33
- if (idx === 0 || idx === label.length - 1 || label[idx - 1] !== "l" || label[idx + 1] !== "l") return false;
34
- }
35
- if (char === "͵") {
36
- if (idx === label.length - 1 || !isGreek(label[idx + 1])) return false;
37
- }
38
- if (char === "׳" || char === "״") {
39
- if (idx === 0 || !isHebrew(label[idx - 1])) return false;
40
- }
41
- if (char === "‍") {
42
- if (idx === 0 || label[idx - 1] !== "्") return false;
43
- }
35
+ if (char === "·" && (idx === 0 || idx === label.length - 1 || label[idx - 1] !== "l" || label[idx + 1] !== "l")) return false;
36
+ if (char === "͵" && (idx === label.length - 1 || !isGreek(label[idx + 1]))) return false;
37
+ if ((char === "׳" || char === "״") && (idx === 0 || !isHebrew(label[idx - 1]))) return false;
38
+ if (char === "" && (idx === 0 || label[idx - 1] !== "्")) return false;
44
39
  }
45
- if (label.includes("・") && !hasCjkKanaOrHan(label.replace(/\u30fb/g, ""))) return false;
40
+ if (label.includes("・") && !hasCjkKanaOrHan(label.replaceAll("・", ""))) return false;
46
41
  const hasArabicIndic = /[\u0660-\u0669]/.test(label);
47
- const hasExtendedArabicIndic = /[\u06f0-\u06f9]/.test(label);
42
+ const hasExtendedArabicIndic = /[\u06F0-\u06F9]/.test(label);
48
43
  if (hasArabicIndic && hasExtendedArabicIndic) return false;
49
44
  return true;
50
45
  };
51
46
  const isValidHostname = (hostname) => {
52
- if (IDN_SEPARATOR_TEST_REGEX.test(hostname) || /[^\x00-\x7F]/.test(hostname)) return false;
47
+ if (IDN_SEPARATOR_TEST_REGEX.test(hostname) || /[^\u0000-\u007F]/.test(hostname)) return false;
53
48
  if (isIPModule.default(hostname, 4)) return false;
54
49
  const labels = splitHostnameLabels(hostname);
55
50
  if (labels === null) return false;
56
- for (const label of labels) {
51
+ for (let i = 0; i < labels.length; i++) {
52
+ const label = labels[i];
57
53
  if (!isAsciiHostnameLabel(label)) return false;
58
54
  if (/^xn--/i.test(label)) {
59
55
  const unicodeLabel = toUnicodeLabel(label);
@@ -65,7 +61,8 @@ const isValidHostname = (hostname) => {
65
61
  const isValidIdnHostname = (hostname) => {
66
62
  const labels = splitHostnameLabels(hostname.replace(IDN_SEPARATOR_REGEX, "."));
67
63
  if (labels === null) return false;
68
- for (const label of labels) {
64
+ for (let i = 0; i < labels.length; i++) {
65
+ const label = labels[i];
69
66
  const unicodeLabel = toUnicodeLabel(label);
70
67
  if (unicodeLabel === null || !isValidIdnUnicodeLabel(unicodeLabel)) return false;
71
68
  }
@@ -1,10 +1,11 @@
1
- import { isObject } from "./what-is.mjs";
1
+ import { isObject } from "./what-is.js";
2
2
  //#region src/utils/json.ts
3
+ const sortedKeys = (obj) => Object.keys(obj).sort();
3
4
  const areEqual = (json1, json2, options, _depth = 0) => {
4
5
  const caseInsensitiveComparison = options?.caseInsensitiveComparison || false;
5
6
  const maxDepth = options?.maxDepth ?? 100;
6
7
  if (json1 === json2) return true;
7
- if (caseInsensitiveComparison === true && typeof json1 === "string" && typeof json2 === "string" && json1.toUpperCase() === json2.toUpperCase()) return true;
8
+ if (caseInsensitiveComparison && typeof json1 === "string" && typeof json2 === "string" && json1.toUpperCase() === json2.toUpperCase()) return true;
8
9
  if (_depth >= maxDepth) throw new Error(`Maximum recursion depth (${maxDepth}) exceeded in areEqual. If your data is deeply nested and valid, increase the maxRecursionDepth option.`);
9
10
  let i, len;
10
11
  if (Array.isArray(json1) && Array.isArray(json2)) {
@@ -22,13 +23,16 @@ const areEqual = (json1, json2, options, _depth = 0) => {
22
23
  }
23
24
  return false;
24
25
  };
25
- const decodeJSONPointer = (str) => {
26
- return decodeURIComponent(str).replace(/~[0-1]/g, (x) => x === "~1" ? "/" : "~");
27
- };
28
- const sortedKeys = (obj) => Object.keys(obj).sort();
26
+ const decodeJSONPointer = (str) => decodeURIComponent(str).replaceAll(/~[0-1]/g, (x) => x === "~1" ? "/" : "~");
29
27
  const get = (obj, path) => {
30
28
  if (typeof path === "string") path = path.split(".");
31
- return path.reduce((acc, key) => acc && acc[key] !== void 0 ? acc[key] : void 0, obj);
29
+ let acc = obj;
30
+ for (let i = 0; i < path.length; i++) {
31
+ const key = path[i];
32
+ if (acc && acc[key] !== void 0) acc = acc[key];
33
+ else return;
34
+ }
35
+ return acc;
32
36
  };
33
37
  //#endregion
34
38
  export { areEqual, decodeJSONPointer, get, sortedKeys };
@@ -1,4 +1,4 @@
1
- import { MAX_SCHEMA_REGEX_LENGTH } from "./constants.mjs";
1
+ import { MAX_SCHEMA_REGEX_LENGTH } from "./constants.js";
2
2
  import isSafeRegex from "safe-regex2";
3
3
  //#region src/utils/schema-regex.ts
4
4
  function compileSchemaRegex(pattern) {
@@ -21,12 +21,12 @@ function compileSchemaRegex(pattern) {
21
21
  ok: true,
22
22
  value: new RegExp(pattern, "u")
23
23
  };
24
- } catch (e) {
24
+ } catch (error) {
25
25
  return {
26
26
  ok: false,
27
27
  error: {
28
28
  pattern,
29
- message: e && e.message ? e.message : "Invalid regular expression"
29
+ message: error instanceof Error ? error.message : "Invalid regular expression"
30
30
  }
31
31
  };
32
32
  }
@@ -35,12 +35,12 @@ function compileSchemaRegex(pattern) {
35
35
  ok: true,
36
36
  value: new RegExp(pattern)
37
37
  };
38
- } catch (e) {
38
+ } catch (error) {
39
39
  return {
40
40
  ok: false,
41
41
  error: {
42
42
  pattern,
43
- message: e && e.message ? e.message : "Invalid regular expression"
43
+ message: error instanceof Error ? error.message : "Invalid regular expression"
44
44
  }
45
45
  };
46
46
  }
@@ -12,9 +12,9 @@ const RFC3339_TIME_REGEX = /^([0-9]{2}):([0-9]{2}):([0-9]{2})(\.[0-9]+)?(z|([+-]
12
12
  const parseRfc3339Time = (time) => {
13
13
  const matches = RFC3339_TIME_REGEX.exec(time);
14
14
  if (matches === null) return null;
15
- const hour = parseInt(matches[1], 10);
16
- const minute = parseInt(matches[2], 10);
17
- const second = parseInt(matches[3], 10);
15
+ const hour = Number.parseInt(matches[1], 10);
16
+ const minute = Number.parseInt(matches[2], 10);
17
+ const second = Number.parseInt(matches[3], 10);
18
18
  if (hour > 23 || minute > 59 || second > 60) return null;
19
19
  let utcHour = hour;
20
20
  let utcMinute = minute;
@@ -22,8 +22,8 @@ const parseRfc3339Time = (time) => {
22
22
  const offsetMatches = /^([+-])([0-9]{2}):([0-9]{2})$/.exec(matches[5]);
23
23
  if (offsetMatches === null) return null;
24
24
  const offsetSign = offsetMatches[1];
25
- const offsetHour = parseInt(offsetMatches[2], 10);
26
- const offsetMinute = parseInt(offsetMatches[3], 10);
25
+ const offsetHour = Number.parseInt(offsetMatches[2], 10);
26
+ const offsetMinute = Number.parseInt(offsetMatches[3], 10);
27
27
  if (offsetHour > 23 || offsetMinute > 59) return null;
28
28
  const utc = toUtcTime(hour, minute, offsetSign, offsetHour, offsetMinute);
29
29
  utcHour = utc.hour;
@@ -0,0 +1,22 @@
1
+ //#region src/utils/unicode.ts
2
+ /**
3
+ * Returns the number of Unicode code points in the string.
4
+ * Uses a surrogate-aware charCodeAt scan (equivalent to the string iterator)
5
+ * that counts a surrogate pair as one code point and lone surrogates as one each.
6
+ */
7
+ function unicodeLength(str) {
8
+ let count = str.length;
9
+ for (let i = 0; i < str.length - 1; i++) {
10
+ const hi = str.charCodeAt(i);
11
+ if (hi >= 55296 && hi <= 56319) {
12
+ const lo = str.charCodeAt(i + 1);
13
+ if (lo >= 56320 && lo <= 57343) {
14
+ count--;
15
+ i++;
16
+ }
17
+ }
18
+ }
19
+ return count;
20
+ }
21
+ //#endregion
22
+ export { unicodeLength };
@@ -6,8 +6,7 @@ const whatIs = (what) => {
6
6
  return "object";
7
7
  }
8
8
  if (typeof what === "number") {
9
- if (Number.isFinite(what)) if (what % 1 === 0) return "integer";
10
- else return "number";
9
+ if (Number.isFinite(what)) return what % 1 === 0 ? "integer" : "number";
11
10
  if (Number.isNaN(what)) return "not-a-number";
12
11
  return "unknown-number";
13
12
  }
@@ -1,35 +1,33 @@
1
- import { isUniqueArray } from "../utils/array.mjs";
2
- import { cacheValidationResult, deferOrRunSync, shouldSkipValidate } from "./shared.mjs";
1
+ import { isUniqueArray } from "../utils/array.js";
2
+ import { cacheValidationResult, deferOrRunSync, shouldSkipValidate } from "./shared.js";
3
3
  //#region src/validation/array.ts
4
- function additionalItemsValidator(report, schema, json) {
5
- if (shouldSkipValidate(this.validateOptions, ["ARRAY_ADDITIONAL_ITEMS"])) return;
4
+ function additionalItemsValidator(ctx, report, schema, json) {
5
+ if (shouldSkipValidate(ctx.validateOptions, ["ARRAY_ADDITIONAL_ITEMS"])) return;
6
6
  if (!Array.isArray(json)) return;
7
- if (schema.additionalItems === false && Array.isArray(schema.items)) {
8
- if (json.length > schema.items.length) report.addError("ARRAY_ADDITIONAL_ITEMS", void 0, void 0, schema, "additionalItems");
9
- }
7
+ if (schema.additionalItems === false && Array.isArray(schema.items) && json.length > schema.items.length) report.addError("ARRAY_ADDITIONAL_ITEMS", void 0, void 0, schema, "additionalItems");
10
8
  }
11
9
  function itemsValidator() {}
12
10
  function prefixItemsValidator() {}
13
- function maxItemsValidator(report, schema, json) {
14
- if (shouldSkipValidate(this.validateOptions, ["ARRAY_LENGTH_LONG"])) return;
11
+ function maxItemsValidator(ctx, report, schema, json) {
12
+ if (shouldSkipValidate(ctx.validateOptions, ["ARRAY_LENGTH_LONG"])) return;
15
13
  if (!Array.isArray(json)) return;
16
14
  if (json.length > schema.maxItems) report.addError("ARRAY_LENGTH_LONG", [json.length, schema.maxItems], void 0, schema, "maxItems");
17
15
  }
18
- function minItemsValidator(report, schema, json) {
19
- if (shouldSkipValidate(this.validateOptions, ["ARRAY_LENGTH_SHORT"])) return;
16
+ function minItemsValidator(ctx, report, schema, json) {
17
+ if (shouldSkipValidate(ctx.validateOptions, ["ARRAY_LENGTH_SHORT"])) return;
20
18
  if (!Array.isArray(json)) return;
21
19
  if (json.length < schema.minItems) report.addError("ARRAY_LENGTH_SHORT", [json.length, schema.minItems], void 0, schema, "minItems");
22
20
  }
23
- function uniqueItemsValidator(report, schema, json) {
24
- if (shouldSkipValidate(this.validateOptions, ["ARRAY_UNIQUE"])) return;
21
+ function uniqueItemsValidator(ctx, report, schema, json) {
22
+ if (shouldSkipValidate(ctx.validateOptions, ["ARRAY_UNIQUE"])) return;
25
23
  if (!Array.isArray(json)) return;
26
24
  if (schema.uniqueItems === true) {
27
25
  const matches = [];
28
- if (isUniqueArray(json, matches, this.options.maxRecursionDepth) === false) report.addError("ARRAY_UNIQUE", matches, void 0, schema, "uniqueItems");
26
+ if (!isUniqueArray(json, matches, ctx.options.maxRecursionDepth)) report.addError("ARRAY_UNIQUE", matches, void 0, schema, "uniqueItems");
29
27
  }
30
28
  }
31
- function containsValidator(report, schema, json) {
32
- if (shouldSkipValidate(this.validateOptions, ["CONTAINS"])) return;
29
+ function containsValidator(ctx, report, schema, json) {
30
+ if (shouldSkipValidate(ctx.validateOptions, ["CONTAINS"])) return;
33
31
  if (!Array.isArray(json)) return;
34
32
  const containsSchema = schema.contains;
35
33
  if (containsSchema === void 0) return;
@@ -38,16 +36,16 @@ function containsValidator(report, schema, json) {
38
36
  for (let idx = 0; idx < json.length; idx++) {
39
37
  const subReport = new Report_(report);
40
38
  subReports.push(subReport);
41
- this._jsonValidate(subReport, containsSchema, json[idx]);
39
+ ctx._jsonValidate(subReport, containsSchema, json[idx]);
42
40
  cacheValidationResult(report, containsSchema, json[idx], subReport.errors.length === 0);
43
41
  }
44
42
  const addContainsErrorIfNeeded = () => {
45
43
  let matchingItems = 0;
46
- for (const subReport of subReports) if (subReport.errors.length === 0) matchingItems += 1;
47
- const supportsContainsBounds = this.options.version === "draft2019-09" || this.options.version === "draft2020-12";
44
+ for (let i = 0; i < subReports.length; i++) if (subReports[i].errors.length === 0) matchingItems += 1;
45
+ const supportsContainsBounds = ctx.options.version === "draft2019-09" || ctx.options.version === "draft2020-12";
48
46
  const minContains = supportsContainsBounds && typeof schema.minContains === "number" ? schema.minContains ?? 1 : 1;
49
47
  const maxContains = supportsContainsBounds && typeof schema.maxContains === "number" ? schema.maxContains : void 0;
50
- if (!(matchingItems >= minContains) || !(maxContains === void 0 || matchingItems <= maxContains)) report.addError("CONTAINS", void 0, subReports, schema, void 0);
48
+ if (!(matchingItems >= minContains) || !(maxContains === void 0 || matchingItems <= maxContains)) report.addError("CONTAINS", void 0, subReports, schema);
51
49
  };
52
50
  deferOrRunSync(report, subReports, addContainsErrorIfNeeded);
53
51
  }
@@ -1,18 +1,18 @@
1
- import { Report } from "../report.mjs";
2
- import { cacheValidationResult, deferOrRunSync } from "./shared.mjs";
1
+ import { Report } from "../report.js";
2
+ import { cacheValidationResult, deferOrRunSync } from "./shared.js";
3
3
  //#region src/validation/combinators.ts
4
- function allOfValidator(report, schema, json) {
4
+ function allOfValidator(ctx, report, schema, json) {
5
5
  for (let i = 0; i < schema.allOf.length; i++) {
6
- const validateResult = this._jsonValidate(report, schema.allOf[i], json);
7
- if (this.options.breakOnFirstError && validateResult === false) break;
6
+ const validateResult = ctx._jsonValidate(report, schema.allOf[i], json);
7
+ if (ctx.options.breakOnFirstError && !validateResult) break;
8
8
  }
9
9
  }
10
- function anyOfValidator(report, schema, json) {
10
+ function anyOfValidator(ctx, report, schema, json) {
11
11
  const subReports = [];
12
12
  for (let i = 0; i < schema.anyOf.length; i++) {
13
13
  const subReport = new Report(report);
14
14
  subReports.push(subReport);
15
- this._jsonValidate(subReport, schema.anyOf[i], json);
15
+ ctx._jsonValidate(subReport, schema.anyOf[i], json);
16
16
  cacheValidationResult(report, schema.anyOf[i], json, subReport.errors.length === 0);
17
17
  }
18
18
  deferOrRunSync(report, subReports, () => {
@@ -21,15 +21,15 @@ function anyOfValidator(report, schema, json) {
21
21
  passed = true;
22
22
  break;
23
23
  }
24
- if (passed === false) report.addError("ANY_OF_MISSING", void 0, subReports, schema, "anyOf");
24
+ if (!passed) report.addError("ANY_OF_MISSING", void 0, subReports, schema, "anyOf");
25
25
  });
26
26
  }
27
- function oneOfValidator(report, schema, json) {
27
+ function oneOfValidator(ctx, report, schema, json) {
28
28
  const subReports = [];
29
29
  for (let i = 0; i < schema.oneOf.length; i++) {
30
30
  const subReport = new Report(report);
31
31
  subReports.push(subReport);
32
- this._jsonValidate(subReport, schema.oneOf[i], json);
32
+ ctx._jsonValidate(subReport, schema.oneOf[i], json);
33
33
  cacheValidationResult(report, schema.oneOf[i], json, subReport.errors.length === 0);
34
34
  }
35
35
  deferOrRunSync(report, subReports, () => {
@@ -39,22 +39,22 @@ function oneOfValidator(report, schema, json) {
39
39
  else if (passes > 1) report.addError("ONE_OF_MULTIPLE", void 0, void 0, schema, "oneOf");
40
40
  });
41
41
  }
42
- function notValidator(report, schema, json) {
42
+ function notValidator(ctx, report, schema, json) {
43
43
  const subReport = new Report(report);
44
- if (this._jsonValidate(subReport, schema.not, json) === true) report.addError("NOT_PASSED", void 0, void 0, schema, "not");
44
+ if (ctx._jsonValidate(subReport, schema.not, json)) report.addError("NOT_PASSED", void 0, void 0, schema, "not");
45
45
  }
46
- function ifValidator(report, schema, json) {
47
- if (this.options.version === "draft-04" || this.options.version === "draft-06") return;
46
+ function ifValidator(ctx, report, schema, json) {
47
+ if (ctx.options.version === "draft-04" || ctx.options.version === "draft-06") return;
48
48
  const conditionSchema = schema.if;
49
49
  const thenSchema = schema.then;
50
50
  const elseSchema = schema.else;
51
51
  if (conditionSchema === void 0 || thenSchema === void 0 && elseSchema === void 0) return;
52
52
  const conditionReport = new Report(report);
53
- this._jsonValidate(conditionReport, conditionSchema, json);
53
+ ctx._jsonValidate(conditionReport, conditionSchema, json);
54
54
  cacheValidationResult(report, conditionSchema, json, conditionReport.errors.length === 0);
55
55
  const branchSchema = conditionReport.errors.length === 0 ? thenSchema : elseSchema;
56
56
  if (branchSchema === void 0) return;
57
- this._jsonValidate(report, branchSchema, json);
57
+ ctx._jsonValidate(report, branchSchema, json);
58
58
  }
59
59
  function thenValidator() {}
60
60
  function elseValidator() {}
@@ -1,35 +1,35 @@
1
- import { shouldSkipValidate } from "./shared.mjs";
1
+ import { shouldSkipValidate } from "./shared.js";
2
2
  //#region src/validation/numeric.ts
3
- function multipleOfValidator(report, schema, json) {
4
- if (shouldSkipValidate(this.validateOptions, ["MULTIPLE_OF"])) return;
3
+ function multipleOfValidator(ctx, report, schema, json) {
4
+ if (shouldSkipValidate(ctx.validateOptions, ["MULTIPLE_OF"])) return;
5
5
  if (typeof json !== "number") return;
6
6
  const result = json / schema.multipleOf;
7
7
  if (!Number.isFinite(result) || Math.abs(result - Math.round(result)) >= 1e-10) report.addError("MULTIPLE_OF", [json, schema.multipleOf], void 0, schema, "multipleOf");
8
8
  }
9
- function maximumValidator(report, schema, json) {
10
- if (shouldSkipValidate(this.validateOptions, ["MAXIMUM", "MAXIMUM_EXCLUSIVE"])) return;
9
+ function maximumValidator(ctx, report, schema, json) {
10
+ if (shouldSkipValidate(ctx.validateOptions, ["MAXIMUM", "MAXIMUM_EXCLUSIVE"])) return;
11
11
  if (typeof json !== "number") return;
12
12
  if (schema.exclusiveMaximum !== true) {
13
13
  if (json > schema.maximum) report.addError("MAXIMUM", [json, schema.maximum], void 0, schema, "maximum");
14
14
  } else if (json >= schema.maximum) report.addError("MAXIMUM_EXCLUSIVE", [json, schema.maximum], void 0, schema, "maximum");
15
15
  }
16
- function exclusiveMaximumValidator(report, schema, json) {
16
+ function exclusiveMaximumValidator(ctx, report, schema, json) {
17
17
  if (typeof schema.exclusiveMaximum === "number") {
18
- if (shouldSkipValidate(this.validateOptions, ["MAXIMUM_EXCLUSIVE"])) return;
18
+ if (shouldSkipValidate(ctx.validateOptions, ["MAXIMUM_EXCLUSIVE"])) return;
19
19
  if (typeof json !== "number") return;
20
20
  if (json >= schema.exclusiveMaximum) report.addError("MAXIMUM_EXCLUSIVE", [json, schema.exclusiveMaximum], void 0, schema, "exclusiveMaximum");
21
21
  }
22
22
  }
23
- function minimumValidator(report, schema, json) {
24
- if (shouldSkipValidate(this.validateOptions, ["MINIMUM", "MINIMUM_EXCLUSIVE"])) return;
23
+ function minimumValidator(ctx, report, schema, json) {
24
+ if (shouldSkipValidate(ctx.validateOptions, ["MINIMUM", "MINIMUM_EXCLUSIVE"])) return;
25
25
  if (typeof json !== "number") return;
26
26
  if (schema.exclusiveMinimum !== true) {
27
27
  if (json < schema.minimum) report.addError("MINIMUM", [json, schema.minimum], void 0, schema, "minimum");
28
28
  } else if (json <= schema.minimum) report.addError("MINIMUM_EXCLUSIVE", [json, schema.minimum], void 0, schema, "minimum");
29
29
  }
30
- function exclusiveMinimumValidator(report, schema, json) {
30
+ function exclusiveMinimumValidator(ctx, report, schema, json) {
31
31
  if (typeof schema.exclusiveMinimum === "number") {
32
- if (shouldSkipValidate(this.validateOptions, ["MINIMUM_EXCLUSIVE"])) return;
32
+ if (shouldSkipValidate(ctx.validateOptions, ["MINIMUM_EXCLUSIVE"])) return;
33
33
  if (typeof json !== "number") return;
34
34
  if (json <= schema.exclusiveMinimum) report.addError("MINIMUM_EXCLUSIVE", [json, schema.exclusiveMinimum], void 0, schema, "exclusiveMinimum");
35
35
  }
@@ -1,22 +1,22 @@
1
- import { isObject } from "../utils/what-is.mjs";
2
- import { compileSchemaRegex } from "../utils/schema-regex.mjs";
3
- import { difference } from "../utils/array.mjs";
4
- import { deferOrRunSync, shouldSkipValidate, supportsDependentKeywords } from "./shared.mjs";
1
+ import { isObject } from "../utils/what-is.js";
2
+ import { compileSchemaRegex } from "../utils/schema-regex.js";
3
+ import { difference } from "../utils/array.js";
4
+ import { deferOrRunSync, shouldSkipValidate, supportsDependentKeywords } from "./shared.js";
5
5
  //#region src/validation/object.ts
6
- function maxPropertiesValidator(report, schema, json) {
7
- if (shouldSkipValidate(this.validateOptions, ["OBJECT_PROPERTIES_MAXIMUM"])) return;
6
+ function maxPropertiesValidator(ctx, report, schema, json) {
7
+ if (shouldSkipValidate(ctx.validateOptions, ["OBJECT_PROPERTIES_MAXIMUM"])) return;
8
8
  if (!isObject(json)) return;
9
9
  const keysCount = Object.keys(json).length;
10
10
  if (keysCount > schema.maxProperties) report.addError("OBJECT_PROPERTIES_MAXIMUM", [keysCount, schema.maxProperties], void 0, schema, "maxProperties");
11
11
  }
12
- function minPropertiesValidator(report, schema, json) {
13
- if (shouldSkipValidate(this.validateOptions, ["OBJECT_PROPERTIES_MINIMUM"])) return;
12
+ function minPropertiesValidator(ctx, report, schema, json) {
13
+ if (shouldSkipValidate(ctx.validateOptions, ["OBJECT_PROPERTIES_MINIMUM"])) return;
14
14
  if (!isObject(json)) return;
15
15
  const keysCount = Object.keys(json).length;
16
16
  if (keysCount < schema.minProperties) report.addError("OBJECT_PROPERTIES_MINIMUM", [keysCount, schema.minProperties], void 0, schema, "minProperties");
17
17
  }
18
- function requiredValidator(report, schema, json) {
19
- if (shouldSkipValidate(this.validateOptions, ["OBJECT_MISSING_REQUIRED_PROPERTY"])) return;
18
+ function requiredValidator(ctx, report, schema, json) {
19
+ if (shouldSkipValidate(ctx.validateOptions, ["OBJECT_MISSING_REQUIRED_PROPERTY"])) return;
20
20
  if (!isObject(json)) return;
21
21
  const idx = schema.required.length;
22
22
  for (let i = 0; i < idx; i++) {
@@ -24,30 +24,31 @@ function requiredValidator(report, schema, json) {
24
24
  if (!Object.hasOwn(json, requiredPropertyName)) report.addError("OBJECT_MISSING_REQUIRED_PROPERTY", [requiredPropertyName], void 0, schema, "required");
25
25
  }
26
26
  }
27
- function additionalPropertiesValidator(report, schema, json) {
28
- if (schema.properties === void 0 && schema.patternProperties === void 0) return propertiesValidator.call(this, report, schema, json);
27
+ function additionalPropertiesValidator(ctx, report, schema, json) {
28
+ if (schema.properties === void 0 && schema.patternProperties === void 0) propertiesValidator(ctx, report, schema, json);
29
29
  }
30
- function patternPropertiesValidator(report, schema, json) {
31
- if (schema.properties === void 0) return propertiesValidator.call(this, report, schema, json);
30
+ function patternPropertiesValidator(ctx, report, schema, json) {
31
+ if (schema.properties === void 0) propertiesValidator(ctx, report, schema, json);
32
32
  }
33
- function propertiesValidator(report, schema, json) {
34
- if (shouldSkipValidate(this.validateOptions, ["OBJECT_ADDITIONAL_PROPERTIES"])) return;
33
+ function propertiesValidator(ctx, report, schema, json) {
34
+ if (shouldSkipValidate(ctx.validateOptions, ["OBJECT_ADDITIONAL_PROPERTIES"])) return;
35
35
  if (!isObject(json)) return;
36
- const properties = schema.properties !== void 0 ? schema.properties : {};
37
- const patternProperties = schema.patternProperties !== void 0 ? schema.patternProperties : {};
36
+ const properties = schema.properties === void 0 ? {} : schema.properties;
37
+ const patternProperties = schema.patternProperties === void 0 ? {} : schema.patternProperties;
38
38
  if (schema.additionalProperties === false) {
39
39
  let s = Object.keys(json);
40
40
  const p = Object.keys(properties);
41
41
  const pp = Object.keys(patternProperties);
42
42
  s = difference(s, p);
43
- for (const ppKey of pp) {
43
+ for (let i = 0; i < pp.length; i++) {
44
+ const ppKey = pp[i];
44
45
  const result = compileSchemaRegex(ppKey);
45
46
  if (!result.ok) continue;
46
47
  const regExp = result.value;
47
- for (let idx2 = s.length - 1; idx2 >= 0; idx2--) if (regExp.test(s[idx2]) === true) s.splice(idx2, 1);
48
+ for (let idx2 = s.length - 1; idx2 >= 0; idx2--) if (regExp.test(s[idx2])) s.splice(idx2, 1);
48
49
  }
49
50
  if (s.length > 0) {
50
- if (Array.isArray(this.options.assumeAdditional)) for (const allowed of this.options.assumeAdditional) {
51
+ if (Array.isArray(ctx.options.assumeAdditional)) for (const allowed of ctx.options.assumeAdditional) {
51
52
  const io = s.indexOf(allowed);
52
53
  if (io !== -1) s.splice(io, 1);
53
54
  }
@@ -55,29 +56,29 @@ function propertiesValidator(report, schema, json) {
55
56
  }
56
57
  }
57
58
  }
58
- function dependenciesValidator(report, schema, json) {
59
- if (shouldSkipValidate(this.validateOptions, ["OBJECT_DEPENDENCY_KEY"])) return;
59
+ function dependenciesValidator(ctx, report, schema, json) {
60
+ if (shouldSkipValidate(ctx.validateOptions, ["OBJECT_DEPENDENCY_KEY"])) return;
60
61
  if (!isObject(json)) return;
61
62
  const keys = Object.keys(schema.dependencies);
62
63
  for (const dependencyName of keys) if (Object.hasOwn(json, dependencyName)) {
63
64
  const dependencyDefinition = schema.dependencies[dependencyName];
64
65
  if (Array.isArray(dependencyDefinition)) {
65
66
  for (const requiredPropertyName of dependencyDefinition) if (!Object.hasOwn(json, requiredPropertyName)) report.addError("OBJECT_DEPENDENCY_KEY", [requiredPropertyName, dependencyName], void 0, schema, "dependencies");
66
- } else this._jsonValidate(report, dependencyDefinition, json);
67
+ } else ctx._jsonValidate(report, dependencyDefinition, json);
67
68
  }
68
69
  }
69
- function dependentSchemasValidator(report, schema, json) {
70
- if (!supportsDependentKeywords(schema, this.options.version)) return;
70
+ function dependentSchemasValidator(ctx, report, schema, json) {
71
+ if (!supportsDependentKeywords(schema, ctx.options.version)) return;
71
72
  if (!isObject(json) || !isObject(schema.dependentSchemas)) return;
72
73
  const keys = Object.keys(schema.dependentSchemas);
73
74
  for (const dependencyName of keys) if (Object.hasOwn(json, dependencyName)) {
74
75
  const dependencySchema = schema.dependentSchemas[dependencyName];
75
- this._jsonValidate(report, dependencySchema, json);
76
+ ctx._jsonValidate(report, dependencySchema, json);
76
77
  }
77
78
  }
78
- function dependentRequiredValidator(report, schema, json) {
79
- if (!supportsDependentKeywords(schema, this.options.version)) return;
80
- if (shouldSkipValidate(this.validateOptions, ["OBJECT_DEPENDENCY_KEY"])) return;
79
+ function dependentRequiredValidator(ctx, report, schema, json) {
80
+ if (!supportsDependentKeywords(schema, ctx.options.version)) return;
81
+ if (shouldSkipValidate(ctx.validateOptions, ["OBJECT_DEPENDENCY_KEY"])) return;
81
82
  if (!isObject(json) || !isObject(schema.dependentRequired)) return;
82
83
  const keys = Object.keys(schema.dependentRequired);
83
84
  for (const dependencyName of keys) {
@@ -87,8 +88,8 @@ function dependentRequiredValidator(report, schema, json) {
87
88
  for (const requiredPropertyName of requiredProperties) if (!Object.hasOwn(json, requiredPropertyName)) report.addError("OBJECT_DEPENDENCY_KEY", [requiredPropertyName, dependencyName], void 0, schema, "dependentRequired");
88
89
  }
89
90
  }
90
- function propertyNamesValidator(report, schema, json) {
91
- if (shouldSkipValidate(this.validateOptions, ["PROPERTY_NAMES"])) return;
91
+ function propertyNamesValidator(ctx, report, schema, json) {
92
+ if (shouldSkipValidate(ctx.validateOptions, ["PROPERTY_NAMES"])) return;
92
93
  if (!isObject(json)) return;
93
94
  const propertyNamesSchema = schema.propertyNames;
94
95
  if (propertyNamesSchema === void 0) return;
@@ -98,10 +99,10 @@ function propertyNamesValidator(report, schema, json) {
98
99
  for (const key of keys) {
99
100
  const subReport = new Report_(report);
100
101
  subReports.push(subReport);
101
- this._jsonValidate(subReport, propertyNamesSchema, key);
102
+ ctx._jsonValidate(subReport, propertyNamesSchema, key);
102
103
  }
103
104
  const addPropertyNameErrors = () => {
104
- for (let idx = 0; idx < keys.length; idx++) if (subReports[idx].errors.length > 0) report.addError("PROPERTY_NAMES", [keys[idx]], subReports[idx], schema, void 0);
105
+ for (let idx = 0; idx < keys.length; idx++) if (subReports[idx].errors.length > 0) report.addError("PROPERTY_NAMES", [keys[idx]], subReports[idx], schema);
105
106
  };
106
107
  deferOrRunSync(report, subReports, addPropertyNameErrors);
107
108
  }
@@ -1,11 +1,11 @@
1
- import { getRemotePath } from "../utils/uri.mjs";
2
- import { findId, getId } from "../json-schema.mjs";
1
+ import { getRemotePath } from "../utils/uri.js";
2
+ import { findId, getId } from "../json-schema.js";
3
3
  //#region src/validation/ref.ts
4
4
  const getDynamicRefAnchorName = (dynamicRef) => {
5
5
  const hashIdx = dynamicRef.indexOf("#");
6
6
  if (hashIdx === -1) return;
7
7
  const fragment = dynamicRef.slice(hashIdx + 1);
8
- if (!fragment || fragment[0] === "/") return;
8
+ if (!fragment || fragment.startsWith("/")) return;
9
9
  return fragment;
10
10
  };
11
11
  const findDynamicAnchorInScope = (scopeSchema, anchorName) => {
@@ -32,7 +32,7 @@ const resolveRecursiveRef = (schema, recursiveAnchorStack) => {
32
32
  */
33
33
  const resolveDynamicRef = (schema, dynamicScopeStack) => {
34
34
  const resolved = schema.__$dynamicRefResolved;
35
- if (typeof resolved === "undefined" || !schema.$dynamicRef) return resolved;
35
+ if (resolved === void 0 || !schema.$dynamicRef) return resolved;
36
36
  let target = resolved;
37
37
  const anchorName = getDynamicRefAnchorName(schema.$dynamicRef);
38
38
  if (anchorName && typeof target === "object" && target.$dynamicAnchor === anchorName) for (let scopeIdx = 0; scopeIdx < dynamicScopeStack.length; scopeIdx++) {
@@ -1,10 +1,6 @@
1
- import { isObject } from "../utils/what-is.mjs";
1
+ import { isObject } from "../utils/what-is.js";
2
2
  //#region src/validation/shared.ts
3
- const shouldSkipValidate = function(options, errors) {
4
- return options && Array.isArray(options.includeErrors) && options.includeErrors.length > 0 && !errors.some(function(err) {
5
- return options.includeErrors.includes(err);
6
- });
7
- };
3
+ const shouldSkipValidate = (options, errors) => options && Array.isArray(options.includeErrors) && options.includeErrors.length > 0 && !errors.some((err) => options.includeErrors.includes(err));
8
4
  const supportsDependentKeywords = (schema, version) => {
9
5
  if (typeof schema.$schema === "string") return !/draft-04|draft-06|draft-07/.test(schema.$schema);
10
6
  return !(version === "draft-04" || version === "draft-06" || version === "draft-07");
@@ -44,7 +40,7 @@ const isValidationVocabularyEnabled = (schema, report, version) => {
44
40
  const metaSchema = currentSchemaMeta || rootSchemaMeta;
45
41
  if (!metaSchema || typeof metaSchema !== "object" || !isObject(metaSchema.$vocabulary)) return true;
46
42
  const vocabulary = metaSchema.$vocabulary;
47
- if (Object.hasOwn(vocabulary, VOCAB_VALIDATION_2019_09) || Object.hasOwn(vocabulary, VOCAB_VALIDATION_2020_12)) return vocabulary[VOCAB_VALIDATION_2019_09] === true || vocabulary[VOCAB_VALIDATION_2020_12] === true;
43
+ if (Object.hasOwn(vocabulary, VOCAB_VALIDATION_2019_09) || Object.hasOwn(vocabulary, VOCAB_VALIDATION_2020_12)) return vocabulary[VOCAB_VALIDATION_2019_09] || vocabulary[VOCAB_VALIDATION_2020_12];
48
44
  return false;
49
45
  };
50
46
  /**
@@ -60,8 +56,8 @@ const isFormatAssertionVocabEnabled = (schema, report, version) => {
60
56
  const metaSchema = currentSchemaMeta || rootSchemaMeta;
61
57
  if (!metaSchema || typeof metaSchema !== "object" || !isObject(metaSchema.$vocabulary)) return false;
62
58
  const vocabulary = metaSchema.$vocabulary;
63
- if (Object.hasOwn(vocabulary, VOCAB_FORMAT_ASSERTION_2020_12)) return vocabulary[VOCAB_FORMAT_ASSERTION_2020_12] === true;
64
- if (Object.hasOwn(vocabulary, VOCAB_FORMAT_2019_09)) return vocabulary[VOCAB_FORMAT_2019_09] === true;
59
+ if (Object.hasOwn(vocabulary, VOCAB_FORMAT_ASSERTION_2020_12)) return vocabulary[VOCAB_FORMAT_ASSERTION_2020_12];
60
+ if (Object.hasOwn(vocabulary, VOCAB_FORMAT_2019_09)) return vocabulary[VOCAB_FORMAT_2019_09];
65
61
  return false;
66
62
  };
67
63
  function cacheValidationResult(report, schema, json, passed) {
@@ -85,9 +81,14 @@ function getCachedValidationResult(report, schema, json) {
85
81
  */
86
82
  function deferOrRunSync(report, subReports, decisionFn) {
87
83
  const asyncTasksBefore = report.asyncTasks.length;
88
- for (const subReport of subReports) report.asyncTasks.push(...subReport.asyncTasks);
84
+ for (let i = 0; i < subReports.length; i++) {
85
+ const tasks = subReports[i].asyncTasks;
86
+ for (let j = 0; j < tasks.length; j++) report.asyncTasks.push(tasks[j]);
87
+ }
89
88
  if (report.asyncTasks.length > asyncTasksBefore) report.addAsyncTaskWithPath((callback) => {
90
- setTimeout(() => callback(null), 0);
89
+ setTimeout(() => {
90
+ callback(null);
91
+ }, 0);
91
92
  }, [], () => {
92
93
  decisionFn();
93
94
  });