turbo-stream 1.1.0 → 1.1.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.
- package/dist/flatten.js +4 -4
- package/dist/turbo-stream.d.ts +1 -0
- package/dist/turbo-stream.js +1 -1
- package/dist/unflatten.js +4 -4
- package/dist/utils.d.ts +1 -1
- package/package.json +1 -1
package/dist/flatten.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HOLE, NAN, NEGATIVE_INFINITY, NEGATIVE_ZERO, POSITIVE_INFINITY, UNDEFINED, TYPE_BIGINT, TYPE_DATE, TYPE_ERROR, TYPE_MAP, TYPE_NULL_OBJECT, TYPE_PROMISE, TYPE_REGEXP, TYPE_SET, TYPE_SYMBOL, TYPE_URL, } from "./utils.js";
|
|
2
2
|
export function flatten(input) {
|
|
3
|
-
const {
|
|
4
|
-
const existing =
|
|
3
|
+
const { indices } = this;
|
|
4
|
+
const existing = indices.get(input);
|
|
5
5
|
if (existing)
|
|
6
6
|
return existing;
|
|
7
7
|
if (input === undefined)
|
|
@@ -15,7 +15,7 @@ export function flatten(input) {
|
|
|
15
15
|
if (input === 0 && 1 / input < 0)
|
|
16
16
|
return NEGATIVE_ZERO;
|
|
17
17
|
const index = this.index++;
|
|
18
|
-
|
|
18
|
+
indices.set(input, index);
|
|
19
19
|
stringify.call(this, input, index);
|
|
20
20
|
return index;
|
|
21
21
|
}
|
|
@@ -23,7 +23,7 @@ function stringify(input, index) {
|
|
|
23
23
|
const { deferred, plugins } = this;
|
|
24
24
|
const str = this.stringified;
|
|
25
25
|
const partsForObj = (obj) => Object.keys(obj)
|
|
26
|
-
.map((k) =>
|
|
26
|
+
.map((k) => `"${flatten.call(this, k)}":${flatten.call(this, obj[k])}`)
|
|
27
27
|
.join(",");
|
|
28
28
|
switch (typeof input) {
|
|
29
29
|
case "boolean":
|
package/dist/turbo-stream.d.ts
CHANGED
package/dist/turbo-stream.js
CHANGED
package/dist/unflatten.js
CHANGED
|
@@ -70,11 +70,10 @@ function hydrate(index) {
|
|
|
70
70
|
}
|
|
71
71
|
return map;
|
|
72
72
|
case TYPE_NULL_OBJECT:
|
|
73
|
-
console.log({ value });
|
|
74
73
|
const obj = Object.create(null);
|
|
75
74
|
hydrated[index] = obj;
|
|
76
75
|
for (const key in b)
|
|
77
|
-
obj[key] = hydrate.call(this, b[key]);
|
|
76
|
+
obj[hydrate.call(this, Number(key))] = hydrate.call(this, b[key]);
|
|
78
77
|
return obj;
|
|
79
78
|
case TYPE_PROMISE:
|
|
80
79
|
if (hydrated[b]) {
|
|
@@ -110,8 +109,9 @@ function hydrate(index) {
|
|
|
110
109
|
else {
|
|
111
110
|
const object = {};
|
|
112
111
|
hydrated[index] = object;
|
|
113
|
-
for (const key in value)
|
|
114
|
-
object[key] = hydrate.call(this, value[key]);
|
|
112
|
+
for (const key in value) {
|
|
113
|
+
object[hydrate.call(this, Number(key))] = hydrate.call(this, value[key]);
|
|
114
|
+
}
|
|
115
115
|
return object;
|
|
116
116
|
}
|
|
117
117
|
}
|
package/dist/utils.d.ts
CHANGED
package/package.json
CHANGED