turbo-stream 2.2.3 → 2.3.0

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 CHANGED
@@ -32,7 +32,7 @@ function stringify(input, index) {
32
32
  while (stack.length > 0) {
33
33
  const [input, index] = stack.pop();
34
34
  const partsForObj = (obj) => Object.keys(obj)
35
- .map((k) => `"${flatten.call(this, k)}":${flatten.call(this, obj[k])}`)
35
+ .map((k) => `"_${flatten.call(this, k)}":${flatten.call(this, obj[k])}`)
36
36
  .join(",");
37
37
  switch (typeof input) {
38
38
  case "boolean":
@@ -77,7 +77,7 @@ function stringify(input, index) {
77
77
  const stack = [[input, index]];
78
78
  while (stack.length > 0) {
79
79
  const [input2, index2] = stack.pop();
80
- const partsForObj = (obj) => Object.keys(obj).map((k) => `"${flatten.call(this, k)}":${flatten.call(this, obj[k])}`).join(",");
80
+ const partsForObj = (obj) => Object.keys(obj).map((k) => `"_${flatten.call(this, k)}":${flatten.call(this, obj[k])}`).join(",");
81
81
  switch (typeof input2) {
82
82
  case "boolean":
83
83
  case "number":
@@ -313,7 +313,7 @@ function hydrate(index) {
313
313
  case TYPE_NULL_OBJECT:
314
314
  const obj = /* @__PURE__ */ Object.create(null);
315
315
  hydrated[index2] = obj;
316
- for (const key in b) {
316
+ for (const key of Object.keys(b).reverse()) {
317
317
  const r = [];
318
318
  stack.push([
319
319
  b[key],
@@ -322,7 +322,7 @@ function hydrate(index) {
322
322
  }
323
323
  ]);
324
324
  stack.push([
325
- Number(key),
325
+ Number(key.slice(1)),
326
326
  (k) => {
327
327
  r[0] = k;
328
328
  }
@@ -398,7 +398,7 @@ function hydrate(index) {
398
398
  } else {
399
399
  const object = {};
400
400
  hydrated[index2] = object;
401
- for (const key in value) {
401
+ for (const key of Object.keys(value).reverse()) {
402
402
  const r = [];
403
403
  stack.push([
404
404
  value[key],
@@ -407,7 +407,7 @@ function hydrate(index) {
407
407
  }
408
408
  ]);
409
409
  stack.push([
410
- Number(key),
410
+ Number(key.slice(1)),
411
411
  (k) => {
412
412
  r[0] = k;
413
413
  }
package/dist/unflatten.js CHANGED
@@ -122,7 +122,7 @@ function hydrate(index) {
122
122
  case utils_js_1.TYPE_NULL_OBJECT:
123
123
  const obj = Object.create(null);
124
124
  hydrated[index] = obj;
125
- for (const key in b) {
125
+ for (const key of Object.keys(b).reverse()) {
126
126
  const r = [];
127
127
  stack.push([
128
128
  b[key],
@@ -131,7 +131,7 @@ function hydrate(index) {
131
131
  },
132
132
  ]);
133
133
  stack.push([
134
- Number(key),
134
+ Number(key.slice(1)),
135
135
  (k) => {
136
136
  r[0] = k;
137
137
  },
@@ -214,7 +214,7 @@ function hydrate(index) {
214
214
  else {
215
215
  const object = {};
216
216
  hydrated[index] = object;
217
- for (const key in value) {
217
+ for (const key of Object.keys(value).reverse()) {
218
218
  const r = [];
219
219
  stack.push([
220
220
  value[key],
@@ -223,7 +223,7 @@ function hydrate(index) {
223
223
  },
224
224
  ]);
225
225
  stack.push([
226
- Number(key),
226
+ Number(key.slice(1)),
227
227
  (k) => {
228
228
  r[0] = k;
229
229
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbo-stream",
3
- "version": "2.2.3",
3
+ "version": "2.3.0",
4
4
  "description": "A streaming data transport format that aims to support built-in features such as Promises, Dates, RegExps, Maps, Sets and more.",
5
5
  "files": [
6
6
  "dist",