teptris 0.3.24 → 0.3.26
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.
- package/dist/teptris.wasm +0 -0
- package/package.json +1 -1
- package/src/index.js +16 -4
package/dist/teptris.wasm
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teptris",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.26",
|
|
4
4
|
"description": "TOML for JavaScript/TypeScript at libteptris speed (WebAssembly, no fallback) - version tracks the engine ({engine}.{iteration}; npm semver is 3-part)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
package/src/index.js
CHANGED
|
@@ -427,13 +427,25 @@ export function initApi(mod) {
|
|
|
427
427
|
}
|
|
428
428
|
try {
|
|
429
429
|
const keys = Object.keys(o);
|
|
430
|
+
// ONE pass: scalars emit immediately (canonical order - scalar
|
|
431
|
+
// ops precede table ops per table); container keys collect and
|
|
432
|
+
// walk after. The inlined type test replaces the per-key
|
|
433
|
+
// isScalar closure call x2 the two-pass structure paid.
|
|
434
|
+
const containers = [];
|
|
430
435
|
for (let i = 0; i < keys.length; i++) {
|
|
431
436
|
const k = keys[i], v = o[k];
|
|
432
|
-
|
|
437
|
+
const tv = typeof v;
|
|
438
|
+
if (v instanceof Date ||
|
|
439
|
+
(v !== null && (tv === "string" || tv === "number" ||
|
|
440
|
+
tv === "boolean" || tv === "bigint"))) {
|
|
441
|
+
scalar(k, v);
|
|
442
|
+
} else {
|
|
443
|
+
containers.push(k);
|
|
444
|
+
}
|
|
433
445
|
}
|
|
434
|
-
for (let i = 0; i <
|
|
435
|
-
const k =
|
|
436
|
-
|
|
446
|
+
for (let i = 0; i < containers.length; i++) {
|
|
447
|
+
const k = containers[i];
|
|
448
|
+
const v = o[k];
|
|
437
449
|
if (v === null || v === undefined) {
|
|
438
450
|
throw new Error("null/undefined cannot round-trip through TOML (nan/inf parse to null in loads() and cannot re-enter)");
|
|
439
451
|
}
|