turbo-stream 2.2.2 → 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":
@@ -206,7 +206,9 @@ function unflatten(parsed) {
206
206
  if (!Array.isArray(parsed) || !parsed.length)
207
207
  throw new SyntaxError();
208
208
  const startIndex = values.length;
209
- values.push(...parsed);
209
+ for (const value of parsed) {
210
+ values.push(value);
211
+ }
210
212
  hydrated.length = values.length;
211
213
  return hydrate.call(this, startIndex);
212
214
  }
@@ -311,7 +313,7 @@ function hydrate(index) {
311
313
  case TYPE_NULL_OBJECT:
312
314
  const obj = /* @__PURE__ */ Object.create(null);
313
315
  hydrated[index2] = obj;
314
- for (const key in b) {
316
+ for (const key of Object.keys(b).reverse()) {
315
317
  const r = [];
316
318
  stack.push([
317
319
  b[key],
@@ -320,7 +322,7 @@ function hydrate(index) {
320
322
  }
321
323
  ]);
322
324
  stack.push([
323
- Number(key),
325
+ Number(key.slice(1)),
324
326
  (k) => {
325
327
  r[0] = k;
326
328
  }
@@ -396,7 +398,7 @@ function hydrate(index) {
396
398
  } else {
397
399
  const object = {};
398
400
  hydrated[index2] = object;
399
- for (const key in value) {
401
+ for (const key of Object.keys(value).reverse()) {
400
402
  const r = [];
401
403
  stack.push([
402
404
  value[key],
@@ -405,7 +407,7 @@ function hydrate(index) {
405
407
  }
406
408
  ]);
407
409
  stack.push([
408
- Number(key),
410
+ Number(key.slice(1)),
409
411
  (k) => {
410
412
  r[0] = k;
411
413
  }
package/dist/unflatten.js CHANGED
@@ -14,7 +14,9 @@ function unflatten(parsed) {
14
14
  if (!Array.isArray(parsed) || !parsed.length)
15
15
  throw new SyntaxError();
16
16
  const startIndex = values.length;
17
- values.push(...parsed);
17
+ for (const value of parsed) {
18
+ values.push(value);
19
+ }
18
20
  hydrated.length = values.length;
19
21
  return hydrate.call(this, startIndex);
20
22
  }
@@ -120,7 +122,7 @@ function hydrate(index) {
120
122
  case utils_js_1.TYPE_NULL_OBJECT:
121
123
  const obj = Object.create(null);
122
124
  hydrated[index] = obj;
123
- for (const key in b) {
125
+ for (const key of Object.keys(b).reverse()) {
124
126
  const r = [];
125
127
  stack.push([
126
128
  b[key],
@@ -129,7 +131,7 @@ function hydrate(index) {
129
131
  },
130
132
  ]);
131
133
  stack.push([
132
- Number(key),
134
+ Number(key.slice(1)),
133
135
  (k) => {
134
136
  r[0] = k;
135
137
  },
@@ -212,7 +214,7 @@ function hydrate(index) {
212
214
  else {
213
215
  const object = {};
214
216
  hydrated[index] = object;
215
- for (const key in value) {
217
+ for (const key of Object.keys(value).reverse()) {
216
218
  const r = [];
217
219
  stack.push([
218
220
  value[key],
@@ -221,7 +223,7 @@ function hydrate(index) {
221
223
  },
222
224
  ]);
223
225
  stack.push([
224
- Number(key),
226
+ Number(key.slice(1)),
225
227
  (k) => {
226
228
  r[0] = k;
227
229
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbo-stream",
3
- "version": "2.2.2",
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",