@node-core/utils 7.1.0 → 7.2.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 (232) hide show
  1. package/components/metadata.js +2 -1
  2. package/lib/ci/build-types/test_build.js +3 -3
  3. package/lib/ci/failure_aggregator.js +2 -2
  4. package/lib/ci/run_ci.js +3 -2
  5. package/lib/cli.js +6 -6
  6. package/lib/figures.js +6 -6
  7. package/lib/prepare_security.js +20 -21
  8. package/lib/request.js +1 -1
  9. package/lib/update-v8/backport.js +3 -4
  10. package/lib/utils.js +4 -2
  11. package/lib/verbosity.js +2 -4
  12. package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/README.md +4 -4
  13. package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.d.mts +21 -0
  14. package/node_modules/@listr2/prompt-adapter-inquirer/dist/index.mjs +46 -0
  15. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/LICENSE +22 -0
  16. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.d.ts +2 -0
  17. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/index.js +2 -0
  18. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.d.ts +35 -0
  19. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/inquirer.js +1 -0
  20. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.d.ts +34 -0
  21. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/dist/utils.js +2 -0
  22. package/node_modules/@listr2/prompt-adapter-inquirer/node_modules/@inquirer/type/package.json +88 -0
  23. package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/package.json +25 -20
  24. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.d.ts +48 -3
  25. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/base.js +58 -19
  26. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/package.json +1 -1
  27. package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/readme.md +36 -1
  28. package/node_modules/ansi-regex/index.js +9 -4
  29. package/node_modules/ansi-regex/package.json +1 -1
  30. package/node_modules/ansi-regex/readme.md +6 -0
  31. package/node_modules/ansi-styles/index.d.ts +12 -12
  32. package/node_modules/ansi-styles/index.js +3 -3
  33. package/node_modules/ansi-styles/package.json +4 -4
  34. package/node_modules/cli-truncate/index.d.ts +3 -3
  35. package/node_modules/cli-truncate/index.js +40 -14
  36. package/node_modules/cli-truncate/node_modules/string-width/index.js +133 -15
  37. package/node_modules/cli-truncate/node_modules/string-width/package.json +4 -4
  38. package/node_modules/cli-truncate/node_modules/string-width/readme.md +1 -1
  39. package/node_modules/cli-truncate/package.json +7 -7
  40. package/node_modules/cli-truncate/readme.md +2 -3
  41. package/node_modules/ghauth/.github/dependabot.yml +11 -3
  42. package/node_modules/ghauth/.github/workflows/depsound.yml +33 -0
  43. package/node_modules/ghauth/.github/workflows/test-and-release.yml +4 -4
  44. package/node_modules/ghauth/CHANGELOG.md +60 -0
  45. package/node_modules/ghauth/package.json +30 -6
  46. package/node_modules/js-yaml/README.md +20 -187
  47. package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs +1008 -946
  48. package/node_modules/js-yaml/dist/browser/js-yaml.esm.min.mjs.map +1 -1
  49. package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js +29 -23
  50. package/node_modules/js-yaml/dist/browser/js-yaml.umd.min.js.map +1 -1
  51. package/node_modules/js-yaml/dist/js-yaml.cjs.js +1043 -583
  52. package/node_modules/js-yaml/dist/js-yaml.cjs.js.map +1 -1
  53. package/node_modules/js-yaml/dist/js-yaml.d.ts +877 -133
  54. package/node_modules/js-yaml/dist/js-yaml.mjs +995 -556
  55. package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -1
  56. package/node_modules/js-yaml/package.json +8 -7
  57. package/node_modules/listr2/dist/{index.d.cts → index.d.mts} +90 -60
  58. package/node_modules/listr2/dist/{index.js → index.mjs} +496 -373
  59. package/node_modules/listr2/node_modules/string-width/index.d.ts +39 -0
  60. package/node_modules/listr2/node_modules/string-width/index.js +207 -0
  61. package/node_modules/listr2/node_modules/string-width/package.json +65 -0
  62. package/node_modules/listr2/node_modules/string-width/readme.md +66 -0
  63. package/node_modules/listr2/node_modules/wrap-ansi/index.d.ts +1 -1
  64. package/node_modules/listr2/node_modules/wrap-ansi/index.js +544 -116
  65. package/node_modules/listr2/node_modules/wrap-ansi/package.json +10 -13
  66. package/node_modules/listr2/node_modules/wrap-ansi/readme.md +2 -0
  67. package/node_modules/listr2/package.json +16 -19
  68. package/node_modules/log-update/index.d.ts +64 -1
  69. package/node_modules/log-update/index.js +268 -18
  70. package/node_modules/log-update/node_modules/string-width/index.d.ts +39 -0
  71. package/node_modules/log-update/node_modules/string-width/index.js +207 -0
  72. package/node_modules/log-update/node_modules/string-width/package.json +65 -0
  73. package/node_modules/log-update/node_modules/string-width/readme.md +66 -0
  74. package/node_modules/log-update/node_modules/wrap-ansi/index.d.ts +1 -1
  75. package/node_modules/log-update/node_modules/wrap-ansi/index.js +544 -116
  76. package/node_modules/log-update/node_modules/wrap-ansi/package.json +10 -13
  77. package/node_modules/log-update/node_modules/wrap-ansi/readme.md +2 -0
  78. package/node_modules/log-update/package.json +14 -12
  79. package/node_modules/log-update/readme.md +61 -0
  80. package/node_modules/slice-ansi/index.d.ts +2 -2
  81. package/node_modules/slice-ansi/index.js +260 -112
  82. package/node_modules/slice-ansi/package.json +10 -9
  83. package/node_modules/slice-ansi/readme.md +3 -2
  84. package/node_modules/slice-ansi/tokenize-ansi.js +752 -0
  85. package/node_modules/smol-toml/README.md +205 -191
  86. package/node_modules/smol-toml/dist/date.d.ts +0 -1
  87. package/node_modules/smol-toml/dist/date.js +0 -1
  88. package/node_modules/smol-toml/dist/error.d.ts +0 -1
  89. package/node_modules/smol-toml/dist/error.js +0 -1
  90. package/node_modules/smol-toml/dist/extract.js +32 -65
  91. package/node_modules/smol-toml/dist/index.cjs +302 -288
  92. package/node_modules/smol-toml/dist/index.d.ts +0 -1
  93. package/node_modules/smol-toml/dist/index.js +0 -1
  94. package/node_modules/smol-toml/dist/parse.d.ts +1 -3
  95. package/node_modules/smol-toml/dist/parse.js +22 -21
  96. package/node_modules/smol-toml/dist/primitive.js +75 -76
  97. package/node_modules/smol-toml/dist/stringify.d.ts +0 -1
  98. package/node_modules/smol-toml/dist/stringify.js +43 -30
  99. package/node_modules/smol-toml/dist/struct.js +90 -93
  100. package/node_modules/smol-toml/dist/util.d.ts +1 -1
  101. package/node_modules/smol-toml/dist/util.js +36 -39
  102. package/node_modules/smol-toml/package.json +6 -6
  103. package/node_modules/strip-ansi/index.js +5 -0
  104. package/node_modules/strip-ansi/package.json +5 -5
  105. package/package.json +3 -9
  106. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.cjs +0 -127
  107. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.cts +0 -152
  108. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.d.ts +0 -152
  109. package/node_modules/@listr2/prompt-adapter-enquirer/dist/index.js +0 -92
  110. package/node_modules/chalk/package.json +0 -92
  111. package/node_modules/chalk/readme.md +0 -331
  112. package/node_modules/chalk/source/index.d.ts +0 -437
  113. package/node_modules/chalk/source/index.js +0 -261
  114. package/node_modules/chalk/source/utilities.js +0 -33
  115. package/node_modules/chalk/source/vendor/ansi-styles/index.d.ts +0 -299
  116. package/node_modules/chalk/source/vendor/ansi-styles/index.js +0 -261
  117. package/node_modules/chalk/source/vendor/supports-color/browser.d.ts +0 -1
  118. package/node_modules/chalk/source/vendor/supports-color/browser.js +0 -32
  119. package/node_modules/chalk/source/vendor/supports-color/index.d.ts +0 -55
  120. package/node_modules/chalk/source/vendor/supports-color/index.js +0 -206
  121. package/node_modules/colorette/LICENSE.md +0 -7
  122. package/node_modules/colorette/README.md +0 -134
  123. package/node_modules/colorette/index.cjs +0 -218
  124. package/node_modules/colorette/index.d.ts +0 -93
  125. package/node_modules/colorette/index.js +0 -150
  126. package/node_modules/colorette/package.json +0 -40
  127. package/node_modules/eventemitter3/LICENSE +0 -21
  128. package/node_modules/eventemitter3/README.md +0 -94
  129. package/node_modules/eventemitter3/dist/eventemitter3.esm.js +0 -347
  130. package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js +0 -1
  131. package/node_modules/eventemitter3/dist/eventemitter3.esm.min.js.map +0 -1
  132. package/node_modules/eventemitter3/dist/eventemitter3.umd.js +0 -355
  133. package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js +0 -1
  134. package/node_modules/eventemitter3/dist/eventemitter3.umd.min.js.map +0 -1
  135. package/node_modules/eventemitter3/index.d.ts +0 -135
  136. package/node_modules/eventemitter3/index.js +0 -336
  137. package/node_modules/eventemitter3/index.mjs +0 -4
  138. package/node_modules/eventemitter3/package.json +0 -67
  139. package/node_modules/figures/index.d.ts +0 -279
  140. package/node_modules/figures/index.js +0 -292
  141. package/node_modules/figures/package.json +0 -49
  142. package/node_modules/figures/readme.md +0 -337
  143. package/node_modules/isexe/LICENSE.md +0 -55
  144. package/node_modules/isexe/README.md +0 -80
  145. package/node_modules/isexe/dist/commonjs/index.d.ts +0 -14
  146. package/node_modules/isexe/dist/commonjs/index.d.ts.map +0 -1
  147. package/node_modules/isexe/dist/commonjs/index.js +0 -56
  148. package/node_modules/isexe/dist/commonjs/index.js.map +0 -1
  149. package/node_modules/isexe/dist/commonjs/index.min.js +0 -2
  150. package/node_modules/isexe/dist/commonjs/index.min.js.map +0 -7
  151. package/node_modules/isexe/dist/commonjs/options.d.ts +0 -32
  152. package/node_modules/isexe/dist/commonjs/options.d.ts.map +0 -1
  153. package/node_modules/isexe/dist/commonjs/options.js +0 -3
  154. package/node_modules/isexe/dist/commonjs/options.js.map +0 -1
  155. package/node_modules/isexe/dist/commonjs/package.json +0 -3
  156. package/node_modules/isexe/dist/commonjs/posix.d.ts +0 -18
  157. package/node_modules/isexe/dist/commonjs/posix.d.ts.map +0 -1
  158. package/node_modules/isexe/dist/commonjs/posix.js +0 -67
  159. package/node_modules/isexe/dist/commonjs/posix.js.map +0 -1
  160. package/node_modules/isexe/dist/commonjs/win32.d.ts +0 -18
  161. package/node_modules/isexe/dist/commonjs/win32.d.ts.map +0 -1
  162. package/node_modules/isexe/dist/commonjs/win32.js +0 -63
  163. package/node_modules/isexe/dist/commonjs/win32.js.map +0 -1
  164. package/node_modules/isexe/dist/esm/index.d.ts +0 -14
  165. package/node_modules/isexe/dist/esm/index.d.ts.map +0 -1
  166. package/node_modules/isexe/dist/esm/index.js +0 -16
  167. package/node_modules/isexe/dist/esm/index.js.map +0 -1
  168. package/node_modules/isexe/dist/esm/index.min.js +0 -2
  169. package/node_modules/isexe/dist/esm/index.min.js.map +0 -7
  170. package/node_modules/isexe/dist/esm/options.d.ts +0 -32
  171. package/node_modules/isexe/dist/esm/options.d.ts.map +0 -1
  172. package/node_modules/isexe/dist/esm/options.js +0 -2
  173. package/node_modules/isexe/dist/esm/options.js.map +0 -1
  174. package/node_modules/isexe/dist/esm/package.json +0 -3
  175. package/node_modules/isexe/dist/esm/posix.d.ts +0 -18
  176. package/node_modules/isexe/dist/esm/posix.d.ts.map +0 -1
  177. package/node_modules/isexe/dist/esm/posix.js +0 -62
  178. package/node_modules/isexe/dist/esm/posix.js.map +0 -1
  179. package/node_modules/isexe/dist/esm/win32.d.ts +0 -18
  180. package/node_modules/isexe/dist/esm/win32.d.ts.map +0 -1
  181. package/node_modules/isexe/dist/esm/win32.js +0 -58
  182. package/node_modules/isexe/dist/esm/win32.js.map +0 -1
  183. package/node_modules/isexe/package.json +0 -78
  184. package/node_modules/listr2/dist/index.cjs +0 -2189
  185. package/node_modules/listr2/dist/index.d.ts +0 -1528
  186. package/node_modules/rfdc/.github/workflows/ci.yml +0 -21
  187. package/node_modules/rfdc/LICENSE +0 -15
  188. package/node_modules/rfdc/default.js +0 -3
  189. package/node_modules/rfdc/index.d.ts +0 -13
  190. package/node_modules/rfdc/index.js +0 -198
  191. package/node_modules/rfdc/index.test-d.ts +0 -13
  192. package/node_modules/rfdc/package.json +0 -73
  193. package/node_modules/rfdc/readme.md +0 -181
  194. package/node_modules/rfdc/test/index.js +0 -306
  195. package/node_modules/smol-toml/dist/date.d.ts.map +0 -1
  196. package/node_modules/smol-toml/dist/date.js.map +0 -1
  197. package/node_modules/smol-toml/dist/error.d.ts.map +0 -1
  198. package/node_modules/smol-toml/dist/error.js.map +0 -1
  199. package/node_modules/smol-toml/dist/extract.js.map +0 -1
  200. package/node_modules/smol-toml/dist/index.cjs.map +0 -1
  201. package/node_modules/smol-toml/dist/index.d.ts.map +0 -1
  202. package/node_modules/smol-toml/dist/index.js.map +0 -1
  203. package/node_modules/smol-toml/dist/parse.d.ts.map +0 -1
  204. package/node_modules/smol-toml/dist/parse.js.map +0 -1
  205. package/node_modules/smol-toml/dist/primitive.d.ts +0 -29
  206. package/node_modules/smol-toml/dist/primitive.d.ts.map +0 -1
  207. package/node_modules/smol-toml/dist/primitive.js.map +0 -1
  208. package/node_modules/smol-toml/dist/stringify.d.ts.map +0 -1
  209. package/node_modules/smol-toml/dist/stringify.js.map +0 -1
  210. package/node_modules/smol-toml/dist/struct.js.map +0 -1
  211. package/node_modules/smol-toml/dist/util.d.ts.map +0 -1
  212. package/node_modules/smol-toml/dist/util.js.map +0 -1
  213. package/node_modules/smol-toml/src/date.ts +0 -152
  214. package/node_modules/smol-toml/src/error.ts +0 -77
  215. package/node_modules/smol-toml/src/extract.ts +0 -113
  216. package/node_modules/smol-toml/src/index.ts +0 -42
  217. package/node_modules/smol-toml/src/parse.ts +0 -184
  218. package/node_modules/smol-toml/src/primitive.ts +0 -249
  219. package/node_modules/smol-toml/src/stringify.ts +0 -191
  220. package/node_modules/smol-toml/src/struct.ts +0 -202
  221. package/node_modules/smol-toml/src/util.ts +0 -106
  222. package/node_modules/which/LICENSE +0 -15
  223. package/node_modules/which/README.md +0 -51
  224. package/node_modules/which/bin/which.js +0 -52
  225. package/node_modules/which/lib/index.js +0 -111
  226. package/node_modules/which/package.json +0 -52
  227. /package/node_modules/@listr2/{prompt-adapter-enquirer → prompt-adapter-inquirer}/LICENSE +0 -0
  228. /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.d.ts +0 -0
  229. /package/node_modules/{log-update/node_modules/ansi-escapes → ansi-escapes}/index.js +0 -0
  230. /package/node_modules/{chalk → ansi-escapes}/license +0 -0
  231. /package/node_modules/{figures → listr2/node_modules/string-width}/license +0 -0
  232. /package/node_modules/log-update/node_modules/{ansi-escapes → string-width}/license +0 -0
@@ -150,304 +150,301 @@ var TomlError = class extends Error {
150
150
  }
151
151
  };
152
152
  //#endregion
153
+ //#region src/util.ts
154
+ /** @internal */
155
+ function indexOfNewline(str, start = 0) {
156
+ let idx = str.indexOf("\n", start);
157
+ if (str.charCodeAt(idx - 1) === 13) idx--;
158
+ return idx;
159
+ }
160
+ /** @internal */
161
+ function skipComment(ctx) {
162
+ for (; ctx.p < ctx.s.length; ctx.p++) {
163
+ let c = ctx.s.charCodeAt(ctx.p);
164
+ if (c === 10) break;
165
+ if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) {
166
+ ctx.p++;
167
+ break;
168
+ }
169
+ if (c < 32 && c !== 9 || c === 127) throw new TomlError("control characters are not allowed in comments", {
170
+ toml: ctx.s,
171
+ ptr: ctx.p
172
+ });
173
+ }
174
+ }
175
+ /** @internal */
176
+ function skipVoid(ctx, banNewLines, banComments) {
177
+ let c;
178
+ while (1) {
179
+ while ((c = ctx.s.charCodeAt(ctx.p)) === 32 || c === 9 || !banNewLines && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) ctx.p++;
180
+ if (banComments || c !== 35) break;
181
+ skipComment(ctx);
182
+ }
183
+ }
184
+ /** @internal */
185
+ function skipUntil(ctx, sep, end) {
186
+ let ptr = ctx.p;
187
+ if (!end) {
188
+ ptr = indexOfNewline(ctx.s, ptr);
189
+ ctx.p = ptr < 0 ? ctx.s.length : ptr;
190
+ return;
191
+ }
192
+ for (; ctx.p < ctx.s.length; ctx.p++) {
193
+ let c = ctx.s.charCodeAt(ctx.p);
194
+ if (c === 35) skipComment(ctx);
195
+ else if (c === end || c === sep) return;
196
+ }
197
+ throw new TomlError("cannot find end of structure", {
198
+ toml: ctx.s,
199
+ ptr
200
+ });
201
+ }
202
+ //#endregion
153
203
  //#region src/primitive.ts
154
204
  let INT_REGEX = /^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/;
155
205
  let FLOAT_REGEX = /^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/;
156
206
  let LEADING_ZERO = /^[+-]?0[0-9_]/;
157
207
  /** @internal */
158
- function parseString(str, ptr) {
159
- let c = str[ptr++];
208
+ function parseString(ctx) {
209
+ let start = ctx.p;
210
+ let c = ctx.s.charCodeAt(ctx.p++);
160
211
  let first = c;
161
- let isLiteral = c === "'";
162
- let isMultiline = c === str[ptr] && c === str[ptr + 1];
212
+ let isLiteral = c === 39;
213
+ let isMultiline = c === ctx.s.charCodeAt(ctx.p) && c === ctx.s.charCodeAt(ctx.p + 1);
163
214
  if (isMultiline) {
164
- if (str[ptr += 2] === "\n") ptr++;
165
- else if (str[ptr] === "\r" && str[ptr + 1] === "\n") ptr += 2;
215
+ if ((c = ctx.s.charCodeAt(ctx.p += 2)) === 10) ctx.p++;
216
+ else if (c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10) ctx.p += 2;
166
217
  }
167
218
  let parsed = "";
168
- let sliceStart = ptr;
219
+ let sliceStart = ctx.p;
169
220
  let state = 0;
170
- for (let i = ptr; i < str.length; i++) {
171
- c = str[i];
172
- if (isMultiline && (c === "\n" || c === "\r" && str[i + 1] === "\n")) state = state && 3;
173
- else if (c < " " && c !== " " || c === "") throw new TomlError("control characters are not allowed in strings", {
174
- toml: str,
175
- ptr: i
221
+ for (; ctx.p < ctx.s.length; ctx.p++) {
222
+ c = ctx.s.charCodeAt(ctx.p);
223
+ if (isMultiline && (c === 10 || c === 13 && ctx.s.charCodeAt(ctx.p + 1) === 10)) state = state && 3;
224
+ else if (c < 32 && c !== 9 || c === 127) throw new TomlError("control characters are not allowed in strings", {
225
+ toml: ctx.s,
226
+ ptr: ctx.p
176
227
  });
177
- else if ((!state || state === 3) && c === first && (!isMultiline || str[i + 1] === first && str[i + 2] === first)) {
228
+ else if ((!state || state === 3) && c === first && (!isMultiline || ctx.s.charCodeAt(ctx.p + 1) === first && ctx.s.charCodeAt(ctx.p + 2) === first)) {
178
229
  if (isMultiline) {
179
- if (str[i + 3] === first) i++;
180
- if (str[i + 3] === first) i++;
230
+ if (ctx.s.charCodeAt(ctx.p + 3) === first) ctx.p++;
231
+ if (ctx.s.charCodeAt(ctx.p + 3) === first) ctx.p++;
181
232
  }
182
- return [state ? parsed : parsed + str.slice(sliceStart, i), i + (isMultiline ? 3 : 1)];
233
+ if (!state) parsed += ctx.s.slice(sliceStart, ctx.p);
234
+ ctx.p += isMultiline ? 3 : 1;
235
+ return parsed;
183
236
  } else if (!state) {
184
- if (!isLiteral && c === "\\") {
185
- parsed += str.slice(sliceStart, sliceStart = i);
237
+ if (!isLiteral && c === 92) {
238
+ parsed += ctx.s.slice(sliceStart, sliceStart = ctx.p);
186
239
  state = 1;
187
240
  }
188
- } else if (state === 1) if (c === "x" || c === "u" || c === "U") {
189
- let value = 0;
190
- let len = c === "x" ? 2 : c === "u" ? 4 : 8;
191
- for (let j = 0; j < len; j++, i++) {
192
- let hex = str.charCodeAt(i + 1);
193
- let digit = hex >= 48 && hex <= 57 ? hex - 48 : hex >= 65 && hex <= 70 ? hex - 65 + 10 : hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1;
194
- if (digit < 0) throw new TomlError("invalid non-hex character in unicode escape", {
195
- toml: str,
196
- ptr: i + 1
241
+ } else if (state === 1) {
242
+ if (c === 120 || c === 117 || c === 85) {
243
+ let value = 0;
244
+ let len = c === 120 ? 2 : c === 117 ? 4 : 8;
245
+ for (let j = 0; j < len; j++, ctx.p++) {
246
+ let hex = ctx.s.charCodeAt(ctx.p + 1);
247
+ let digit = hex >= 48 && hex <= 57 ? hex - 48 : hex >= 65 && hex <= 70 ? hex - 65 + 10 : hex >= 97 && hex <= 102 ? hex - 97 + 10 : -1;
248
+ if (digit < 0) throw new TomlError("invalid non-hex character in unicode escape", {
249
+ toml: ctx.s,
250
+ ptr: ctx.p + 1
251
+ });
252
+ value = value << 4 | digit;
253
+ }
254
+ if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) throw new TomlError("invalid unicode escape", {
255
+ toml: ctx.s,
256
+ ptr: ctx.p
257
+ });
258
+ parsed += String.fromCodePoint(value);
259
+ sliceStart = ctx.p + 1;
260
+ state = 0;
261
+ } else if (c === 32 || c === 9) state = 2;
262
+ else {
263
+ if (c === 98) parsed += "\b";
264
+ else if (c === 116) parsed += " ";
265
+ else if (c === 110) parsed += "\n";
266
+ else if (c === 102) parsed += "\f";
267
+ else if (c === 114) parsed += "\r";
268
+ else if (c === 101) parsed += "\x1B";
269
+ else if (c === 34) parsed += "\"";
270
+ else if (c === 92) parsed += "\\";
271
+ else throw new TomlError("unrecognized escape sequence", {
272
+ toml: ctx.s,
273
+ ptr: ctx.p
197
274
  });
198
- value = value << 4 | digit;
275
+ sliceStart = ctx.p + 1;
276
+ state = 0;
199
277
  }
200
- if (value < 0 || value > 1114111 || value >= 55296 && value <= 57343) throw new TomlError("invalid unicode escape", {
201
- toml: str,
202
- ptr: i
203
- });
204
- parsed += String.fromCodePoint(value);
205
- sliceStart = i + 1;
206
- state = 0;
207
- } else if (c === " " || c === " ") state = 2;
208
- else {
209
- if (c === "b") parsed += "\b";
210
- else if (c === "t") parsed += " ";
211
- else if (c === "n") parsed += "\n";
212
- else if (c === "f") parsed += "\f";
213
- else if (c === "r") parsed += "\r";
214
- else if (c === "e") parsed += "\x1B";
215
- else if (c === "\"") parsed += "\"";
216
- else if (c === "\\") parsed += "\\";
217
- else throw new TomlError("unrecognized escape sequence", {
218
- toml: str,
219
- ptr: i
220
- });
221
- sliceStart = i + 1;
222
- state = 0;
223
- }
224
- else if (c !== " " && c !== " ") {
278
+ } else if (c !== 32 && c !== 9) {
225
279
  if (state === 2) throw new TomlError("invalid escape: only line-ending whitespace may be escaped", {
226
- toml: str,
280
+ toml: ctx.s,
227
281
  ptr: sliceStart
228
282
  });
229
- state = !isLiteral && c === "\\" ? 1 : 0;
230
- sliceStart = i;
283
+ state = !isLiteral && c === 92 ? 1 : 0;
284
+ sliceStart = ctx.p;
231
285
  }
232
286
  }
233
287
  throw new TomlError("unfinished string", {
234
- toml: str,
235
- ptr
288
+ toml: ctx.s,
289
+ ptr: start
236
290
  });
237
291
  }
292
+ function sliceAndTrimEndOf(ctx, start, end) {
293
+ let value = ctx.s.slice(start, end);
294
+ let commentIdx = value.indexOf("#");
295
+ if (commentIdx > 0) {
296
+ skipComment({
297
+ s: value,
298
+ p: commentIdx,
299
+ d: 0
300
+ });
301
+ value = value.slice(0, commentIdx);
302
+ }
303
+ return value.trimEnd();
304
+ }
238
305
  /** @internal */
239
- function parseValue(value, toml, ptr, integersAsBigInt) {
240
- if (value === "true") return true;
241
- if (value === "false") return false;
306
+ function parseValue(ctx, integersAsBigInt, end) {
307
+ let ptr = ctx.p;
308
+ let err = {
309
+ toml: ctx.s,
310
+ ptr
311
+ };
312
+ skipUntil(ctx, 44, end);
313
+ let value = sliceAndTrimEndOf(ctx, ptr, ctx.p);
314
+ if (!value) throw new TomlError("incomplete declaration: value expected", err);
242
315
  if (value === "-inf") return -Infinity;
243
316
  if (value === "inf" || value === "+inf") return Infinity;
244
317
  if (value === "nan" || value === "+nan" || value === "-nan") return NaN;
245
318
  if (value === "-0") return integersAsBigInt ? 0n : 0;
246
319
  let isInt = INT_REGEX.test(value);
247
320
  if (isInt || FLOAT_REGEX.test(value)) {
248
- if (LEADING_ZERO.test(value)) throw new TomlError("leading zeroes are not allowed", {
249
- toml,
250
- ptr
251
- });
321
+ if (LEADING_ZERO.test(value)) throw new TomlError("leading zeroes are not allowed", err);
252
322
  value = value.replace(/_/g, "");
253
323
  let numeric = +value;
254
- if (isNaN(numeric)) throw new TomlError("invalid number", {
255
- toml,
256
- ptr
257
- });
324
+ if (isNaN(numeric)) throw new TomlError("invalid number", err);
258
325
  if (isInt) {
259
- if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) throw new TomlError("integer value cannot be represented losslessly", {
260
- toml,
261
- ptr
262
- });
326
+ if ((isInt = !Number.isSafeInteger(numeric)) && !integersAsBigInt) throw new TomlError("integer value cannot be represented losslessly", err);
263
327
  if (isInt || integersAsBigInt === true) numeric = BigInt(value);
264
328
  }
265
329
  return numeric;
266
330
  }
267
331
  const date = new TomlDate(value);
268
- if (!date.isValid()) throw new TomlError("invalid value", {
269
- toml,
270
- ptr
271
- });
332
+ if (!date.isValid()) throw new TomlError("invalid value", err);
272
333
  return date;
273
334
  }
274
335
  //#endregion
275
- //#region src/util.ts
276
- /** @internal */
277
- function indexOfNewline(str, start = 0, end = str.length) {
278
- let idx = str.indexOf("\n", start);
279
- if (str[idx - 1] === "\r") idx--;
280
- return idx <= end ? idx : -1;
281
- }
336
+ //#region src/extract.ts
282
337
  /** @internal */
283
- function skipComment(str, ptr) {
284
- for (let i = ptr; i < str.length; i++) {
285
- let c = str[i];
286
- if (c === "\n") return i;
287
- if (c === "\r" && str[i + 1] === "\n") return i + 1;
288
- if (c < " " && c !== " " || c === "") throw new TomlError("control characters are not allowed in comments", {
289
- toml: str,
338
+ function extractValue(ctx, end, integersAsBigInt) {
339
+ let ptr = ctx.p;
340
+ let c = ctx.s.charCodeAt(ptr);
341
+ if (c === 91 || c === 123) {
342
+ if (!ctx.d--) throw new TomlError("document contains excessively nested structures. aborting.", {
343
+ toml: ctx.s,
290
344
  ptr
291
345
  });
346
+ let value = c === 91 ? parseArray(ctx, integersAsBigInt) : parseInlineTable(ctx, integersAsBigInt);
347
+ ctx.d++;
348
+ return value;
349
+ }
350
+ if (c === 34 || c === 39) return parseString(ctx);
351
+ if (c === 116) {
352
+ if (ctx.s.charCodeAt(++ctx.p) !== 114 || ctx.s.charCodeAt(++ctx.p) !== 117 || ctx.s.charCodeAt(++ctx.p) !== 101) throw new TomlError("invalid value", {
353
+ toml: ctx.s,
354
+ ptr
355
+ });
356
+ ctx.p++;
357
+ return true;
292
358
  }
293
- return str.length;
294
- }
295
- /** @internal */
296
- function skipVoid(str, ptr, banNewLines, banComments) {
297
- let c;
298
- while (1) {
299
- while ((c = str[ptr]) === " " || c === " " || !banNewLines && (c === "\n" || c === "\r" && str[ptr + 1] === "\n")) ptr++;
300
- if (banComments || c !== "#") break;
301
- ptr = skipComment(str, ptr);
302
- }
303
- return ptr;
304
- }
305
- /** @internal */
306
- function skipUntil(str, ptr, sep, end, banNewLines = false) {
307
- if (!end) {
308
- ptr = indexOfNewline(str, ptr);
309
- return ptr < 0 ? str.length : ptr;
310
- }
311
- for (let i = ptr; i < str.length; i++) {
312
- let c = str[i];
313
- if (c === "#") {
314
- i = indexOfNewline(str, i);
315
- if (i < 0) break;
316
- } else if (c === sep) return i + 1;
317
- else if (c === end || banNewLines && (c === "\n" || c === "\r" && str[i + 1] === "\n")) return i;
318
- }
319
- throw new TomlError("cannot find end of structure", {
320
- toml: str,
321
- ptr
322
- });
323
- }
324
- //#endregion
325
- //#region src/extract.ts
326
- function sliceAndTrimEndOf(str, startPtr, endPtr) {
327
- let value = str.slice(startPtr, endPtr);
328
- let commentIdx = value.indexOf("#");
329
- if (commentIdx > -1) {
330
- skipComment(str, commentIdx);
331
- value = value.slice(0, commentIdx);
332
- }
333
- return [value.trimEnd(), commentIdx];
334
- }
335
- /** @internal */
336
- function extractValue(str, ptr, end, depth, integersAsBigInt) {
337
- if (depth === 0) throw new TomlError("document contains excessively nested structures. aborting.", {
338
- toml: str,
339
- ptr
340
- });
341
- let c = str[ptr];
342
- if (c === "[" || c === "{") {
343
- let [value, endPtr] = c === "[" ? parseArray(str, ptr, depth, integersAsBigInt) : parseInlineTable(str, ptr, depth, integersAsBigInt);
344
- if (end) {
345
- endPtr = skipVoid(str, endPtr);
346
- if (str[endPtr] === ",") endPtr++;
347
- else if (str[endPtr] !== end) throw new TomlError("expected comma or end of structure", {
348
- toml: str,
349
- ptr: endPtr
350
- });
351
- }
352
- return [value, endPtr];
353
- }
354
- if (c === "\"" || c === "'") {
355
- let [parsed, endPtr] = parseString(str, ptr);
356
- if (end) {
357
- endPtr = skipVoid(str, endPtr);
358
- if (str[endPtr] && str[endPtr] !== "," && str[endPtr] !== end && str[endPtr] !== "\n" && str[endPtr] !== "\r") throw new TomlError("unexpected character encountered", {
359
- toml: str,
360
- ptr: endPtr
361
- });
362
- if (str[endPtr] === ",") endPtr++;
363
- }
364
- return [parsed, endPtr];
365
- }
366
- let endPtr = skipUntil(str, ptr, ",", end);
367
- let slice = sliceAndTrimEndOf(str, ptr, endPtr - (str[endPtr - 1] === "," ? 1 : 0));
368
- if (!slice[0]) throw new TomlError("incomplete key-value declaration: no value specified", {
369
- toml: str,
370
- ptr
371
- });
372
- if (end && slice[1] > -1) {
373
- endPtr = skipVoid(str, ptr + slice[1]);
374
- if (str[endPtr] === ",") endPtr++;
359
+ if (c === 102) {
360
+ if (ctx.s.charCodeAt(++ctx.p) !== 97 || ctx.s.charCodeAt(++ctx.p) !== 108 || ctx.s.charCodeAt(++ctx.p) !== 115 || ctx.s.charCodeAt(++ctx.p) !== 101) throw new TomlError("invalid value", {
361
+ toml: ctx.s,
362
+ ptr
363
+ });
364
+ ctx.p++;
365
+ return false;
375
366
  }
376
- return [parseValue(slice[0], str, ptr, integersAsBigInt), endPtr];
367
+ return parseValue(ctx, integersAsBigInt, end);
377
368
  }
378
369
  //#endregion
379
370
  //#region src/struct.ts
380
371
  let KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
381
372
  /** @internal */
382
- function parseKey(str, ptr, end = "=") {
383
- let dot = ptr - 1;
373
+ function parseKey(ctx, end = "=") {
374
+ let start = ctx.p;
375
+ let dot = start - 1;
384
376
  let parsed = [];
385
- let endPtr = str.indexOf(end, ptr);
377
+ let endPtr = ctx.s.indexOf(end, start);
386
378
  if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
387
- toml: str,
388
- ptr
379
+ toml: ctx.s,
380
+ ptr: start
389
381
  });
390
382
  do {
391
- let c = str[ptr = ++dot];
392
- if (c !== " " && c !== " ") if (c === "\"" || c === "'") {
393
- if (c === str[ptr + 1] && c === str[ptr + 2]) throw new TomlError("multiline strings are not allowed in keys", {
394
- toml: str,
395
- ptr
396
- });
397
- let [part, eos] = parseString(str, ptr);
398
- dot = str.indexOf(".", eos);
399
- let strEnd = str.slice(eos, dot < 0 || dot > endPtr ? endPtr : dot);
400
- let newLine = indexOfNewline(strEnd);
401
- if (newLine > -1) throw new TomlError("newlines are not allowed in keys", {
402
- toml: str,
403
- ptr: ptr + dot + newLine
404
- });
405
- if (strEnd.trimStart()) throw new TomlError("found extra tokens after the string part", {
406
- toml: str,
407
- ptr: eos
408
- });
409
- if (endPtr < eos) {
410
- endPtr = str.indexOf(end, eos);
411
- if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
412
- toml: str,
413
- ptr
383
+ let c = ctx.s.charCodeAt(ctx.p = ++dot);
384
+ if (c !== 32 && c !== 9) {
385
+ if (c === 34 || c === 39) {
386
+ if (c === ctx.s.charCodeAt(ctx.p + 1) && c === ctx.s.charCodeAt(ctx.p + 2)) throw new TomlError("multiline strings are not allowed in keys", {
387
+ toml: ctx.s,
388
+ ptr: ctx.p
389
+ });
390
+ let part = parseString(ctx);
391
+ dot = ctx.s.indexOf(".", ctx.p);
392
+ let strEnd = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
393
+ let newLine = indexOfNewline(strEnd);
394
+ if (newLine > -1) throw new TomlError("newlines are not allowed in keys", {
395
+ toml: ctx.s,
396
+ ptr: newLine
414
397
  });
398
+ if (strEnd.trimStart()) throw new TomlError("found extra tokens after the string part", {
399
+ toml: ctx.s,
400
+ ptr: ctx.p
401
+ });
402
+ if (endPtr < ctx.p) {
403
+ endPtr = ctx.s.indexOf(end, ctx.p);
404
+ if (endPtr < 0) throw new TomlError("incomplete key-value: cannot find end of key", {
405
+ toml: ctx.s,
406
+ ptr: start
407
+ });
408
+ }
409
+ parsed.push(part);
410
+ } else {
411
+ dot = ctx.s.indexOf(".", ctx.p);
412
+ let part = ctx.s.slice(ctx.p, dot < 0 || dot > endPtr ? endPtr : dot);
413
+ if (!KEY_PART_RE.test(part)) throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
414
+ toml: ctx.s,
415
+ ptr: ctx.p
416
+ });
417
+ parsed.push(part.trimEnd());
415
418
  }
416
- parsed.push(part);
417
- } else {
418
- dot = str.indexOf(".", ptr);
419
- let part = str.slice(ptr, dot < 0 || dot > endPtr ? endPtr : dot);
420
- if (!KEY_PART_RE.test(part)) throw new TomlError("only letter, numbers, dashes and underscores are allowed in keys", {
421
- toml: str,
422
- ptr
423
- });
424
- parsed.push(part.trimEnd());
425
419
  }
426
420
  } while (dot + 1 && dot < endPtr);
427
- return [parsed, skipVoid(str, endPtr + 1, true, true)];
421
+ ctx.p = endPtr + 1;
422
+ skipVoid(ctx, true, true);
423
+ return parsed;
428
424
  }
429
425
  /** @internal */
430
- function parseInlineTable(str, ptr, depth, integersAsBigInt) {
426
+ function parseInlineTable(ctx, integersAsBigInt) {
431
427
  let res = {};
432
428
  let seen = /* @__PURE__ */ new Set();
433
429
  let c;
434
- ptr++;
435
- while ((c = str[ptr++]) !== "}" && c) if (c === ",") throw new TomlError("expected value, found comma", {
436
- toml: str,
437
- ptr: ptr - 1
438
- });
439
- else if (c === "#") ptr = skipComment(str, ptr);
440
- else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
430
+ ctx.p++;
431
+ while (ctx.p < ctx.s.length) {
432
+ skipVoid(ctx);
433
+ if ((c = ctx.s.charCodeAt(ctx.p)) === 125) {
434
+ ctx.p++;
435
+ return res;
436
+ }
441
437
  let k;
442
438
  let t = res;
443
439
  let hasOwn = false;
444
- let [key, keyEndPtr] = parseKey(str, ptr - 1);
440
+ let p = ctx.p;
441
+ let key = parseKey(ctx);
445
442
  for (let i = 0; i < key.length; i++) {
446
443
  if (i) t = hasOwn ? t[k] : t[k] = {};
447
444
  k = key[i];
448
445
  if ((hasOwn = Object.hasOwn(t, k)) && (typeof t[k] !== "object" || seen.has(t[k]))) throw new TomlError("trying to redefine an already defined value", {
449
- toml: str,
450
- ptr
446
+ toml: ctx.s,
447
+ ptr: p
451
448
  });
452
449
  if (!hasOwn && k === "__proto__") Object.defineProperty(t, k, {
453
450
  enumerable: true,
@@ -456,40 +453,46 @@ function parseInlineTable(str, ptr, depth, integersAsBigInt) {
456
453
  });
457
454
  }
458
455
  if (hasOwn) throw new TomlError("trying to redefine an already defined value", {
459
- toml: str,
460
- ptr
456
+ toml: ctx.s,
457
+ ptr: ctx.p
458
+ });
459
+ let value = extractValue(ctx, 125, integersAsBigInt);
460
+ seen.add(t[k] = value);
461
+ skipVoid(ctx);
462
+ if ((c = ctx.s.charCodeAt(ctx.p++)) === 125) return res;
463
+ if (c !== 44) throw new TomlError("expected comma or end of structure", {
464
+ toml: ctx.s,
465
+ ptr: ctx.p - 1
461
466
  });
462
- let [value, valueEndPtr] = extractValue(str, keyEndPtr, "}", depth - 1, integersAsBigInt);
463
- seen.add(value);
464
- t[k] = value;
465
- ptr = valueEndPtr;
466
467
  }
467
- if (!c) throw new TomlError("unfinished table encountered", {
468
- toml: str,
469
- ptr
468
+ throw new TomlError("unfinished table encountered", {
469
+ toml: ctx.s,
470
+ ptr: ctx.p
470
471
  });
471
- return [res, ptr];
472
472
  }
473
473
  /** @internal */
474
- function parseArray(str, ptr, depth, integersAsBigInt) {
474
+ function parseArray(ctx, integersAsBigInt) {
475
475
  let res = [];
476
476
  let c;
477
- ptr++;
478
- while ((c = str[ptr++]) !== "]" && c) if (c === ",") throw new TomlError("expected value, found comma", {
479
- toml: str,
480
- ptr: ptr - 1
481
- });
482
- else if (c === "#") ptr = skipComment(str, ptr);
483
- else if (c !== " " && c !== " " && c !== "\n" && c !== "\r") {
484
- let e = extractValue(str, ptr - 1, "]", depth - 1, integersAsBigInt);
485
- res.push(e[0]);
486
- ptr = e[1];
487
- }
488
- if (!c) throw new TomlError("unfinished array encountered", {
489
- toml: str,
490
- ptr
477
+ ctx.p++;
478
+ while (ctx.p < ctx.s.length) {
479
+ skipVoid(ctx);
480
+ if ((c = ctx.s.charCodeAt(ctx.p)) === 93) {
481
+ ctx.p++;
482
+ return res;
483
+ }
484
+ res.push(extractValue(ctx, 93, integersAsBigInt));
485
+ skipVoid(ctx);
486
+ if ((c = ctx.s.charCodeAt(ctx.p++)) === 93) return res;
487
+ if (c !== 44) throw new TomlError("expected comma or end of structure", {
488
+ toml: ctx.s,
489
+ ptr: ctx.p - 1
490
+ });
491
+ }
492
+ throw new TomlError("unfinished array encountered", {
493
+ toml: ctx.s,
494
+ ptr: ctx.p
491
495
  });
492
- return [res, ptr];
493
496
  }
494
497
  //#endregion
495
498
  //#region src/parse.ts
@@ -559,46 +562,51 @@ function peekTable(key, table, meta, type) {
559
562
  ];
560
563
  }
561
564
  function parse(toml, { maxDepth = 1e3, integersAsBigInt } = {}) {
565
+ let ctx = {
566
+ s: toml,
567
+ p: 0,
568
+ d: maxDepth
569
+ };
562
570
  let res = {};
563
571
  let meta = {};
572
+ let tmp;
564
573
  let tbl = res;
565
574
  let m = meta;
566
- for (let ptr = skipVoid(toml, 0); ptr < toml.length;) {
567
- if (toml[ptr] === "[") {
568
- let isTableArray = toml[++ptr] === "[";
569
- let k = parseKey(toml, ptr += +isTableArray, "]");
575
+ skipVoid(ctx);
576
+ while (ctx.p < toml.length) {
577
+ if (toml.charCodeAt(ctx.p) === 91) {
578
+ let isTableArray = toml.charCodeAt(++ctx.p) === 91;
579
+ tmp = ctx.p += +isTableArray;
580
+ let k = parseKey(ctx, "]");
570
581
  if (isTableArray) {
571
- if (toml[k[1] - 1] !== "]") throw new TomlError("expected end of table declaration", {
582
+ if (toml.charCodeAt(ctx.p - 1) !== 93) throw new TomlError("expected end of table declaration", {
572
583
  toml,
573
- ptr: k[1] - 1
584
+ ptr: ctx.p - 1
574
585
  });
575
- k[1]++;
586
+ ctx.p++;
576
587
  }
577
- let p = peekTable(k[0], res, meta, isTableArray ? 2 : 1);
588
+ let p = peekTable(k, res, meta, isTableArray ? 2 : 1);
578
589
  if (!p) throw new TomlError("trying to redefine an already defined table or value", {
579
590
  toml,
580
- ptr
591
+ ptr: tmp
581
592
  });
582
593
  m = p[2];
583
594
  tbl = p[1];
584
- ptr = k[1];
585
595
  } else {
586
- let k = parseKey(toml, ptr);
587
- let p = peekTable(k[0], tbl, m, 0);
596
+ tmp = ctx.p;
597
+ let p = peekTable(parseKey(ctx), tbl, m, 0);
588
598
  if (!p) throw new TomlError("trying to redefine an already defined table or value", {
589
599
  toml,
590
- ptr
600
+ ptr: tmp
591
601
  });
592
- let v = extractValue(toml, k[1], void 0, maxDepth, integersAsBigInt);
593
- p[1][p[0]] = v[0];
594
- ptr = v[1];
602
+ p[1][p[0]] = extractValue(ctx, void 0, integersAsBigInt);
595
603
  }
596
- ptr = skipVoid(toml, ptr, true);
597
- if (toml[ptr] && toml[ptr] !== "\n" && toml[ptr] !== "\r") throw new TomlError("each key-value declaration must be followed by an end-of-line", {
604
+ skipVoid(ctx, true);
605
+ if (ctx.p < toml.length && (tmp = toml.charCodeAt(ctx.p)) !== 10 && tmp !== 13) throw new TomlError("each key-value declaration must be followed by an end-of-line", {
598
606
  toml,
599
- ptr
607
+ ptr: ctx.p
600
608
  });
601
- ptr = skipVoid(toml, ptr);
609
+ skipVoid(ctx);
602
610
  }
603
611
  return res;
604
612
  }
@@ -609,7 +617,8 @@ function extendedTypeOf(obj) {
609
617
  let type = typeof obj;
610
618
  if (type === "object") {
611
619
  if (Array.isArray(obj)) return "array";
612
- if (obj instanceof Date) return "date";
620
+ if (typeof obj?.getUTCDate === "function" && obj instanceof Date) return "date";
621
+ if (globalThis.Temporal && typeof obj?.since === "function" && (obj instanceof Temporal.Instant || obj instanceof Temporal.PlainDate || obj instanceof Temporal.PlainDateTime || obj instanceof Temporal.PlainTime || obj instanceof Temporal.ZonedDateTime)) return "temporal";
613
622
  }
614
623
  return type;
615
624
  }
@@ -620,23 +629,30 @@ function isArrayOfTables(obj) {
620
629
  function formatString(s) {
621
630
  return JSON.stringify(s).replace(/\x7f/g, "\\u007f");
622
631
  }
632
+ function stringifyTemporal(temporal) {
633
+ return temporal.toString({
634
+ calendarName: "never",
635
+ timeZoneName: "never"
636
+ });
637
+ }
623
638
  function stringifyValue(val, type, depth, numberAsFloat) {
624
639
  if (depth === 0) throw new Error("Could not stringify the object: maximum object depth exceeded");
625
- if (type === "number") {
626
- if (isNaN(val)) return "nan";
627
- if (val === Infinity) return "inf";
628
- if (val === -Infinity) return "-inf";
629
- if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val))) return val.toFixed(1);
630
- return val.toString();
631
- }
632
- if (type === "bigint" || type === "boolean") return val.toString();
633
- if (type === "string") return formatString(val);
634
- if (type === "date") {
635
- if (isNaN(val.getTime())) throw new TypeError("cannot serialize invalid date");
636
- return val.toISOString();
637
- }
638
- if (type === "object") return stringifyInlineTable(val, depth, numberAsFloat);
639
- if (type === "array") return stringifyArray(val, depth, numberAsFloat);
640
+ switch (type) {
641
+ case "number":
642
+ if (isNaN(val)) return "nan";
643
+ if (val === Infinity) return "inf";
644
+ if (val === -Infinity) return "-inf";
645
+ if (Number.isInteger(val) && (numberAsFloat || !Number.isSafeInteger(val))) return val.toFixed(1);
646
+ case "bigint":
647
+ case "boolean": return val.toString();
648
+ case "string": return formatString(val);
649
+ case "date":
650
+ if (isNaN(val.getTime())) throw new TypeError("cannot serialize invalid date");
651
+ return val.toISOString();
652
+ case "object": return stringifyInlineTable(val, depth, numberAsFloat);
653
+ case "array": return stringifyArray(val, depth, numberAsFloat);
654
+ case "temporal": return stringifyTemporal(val);
655
+ }
640
656
  }
641
657
  function stringifyInlineTable(obj, depth, numberAsFloat) {
642
658
  let keys = Object.keys(obj);
@@ -716,5 +732,3 @@ exports.TomlError = TomlError;
716
732
  exports.default = src_default;
717
733
  exports.parse = parse;
718
734
  exports.stringify = stringify;
719
-
720
- //# sourceMappingURL=index.cjs.map