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 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 { indicies } = this;
4
- const existing = indicies.get(input);
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
- indicies.set(input, index);
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) => `${JSON.stringify(k)}:${flatten.call(this, obj[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":
@@ -1,4 +1,5 @@
1
1
  import { type DecodePlugin, type EncodePlugin } from "./utils.js";
2
+ export type { DecodePlugin, EncodePlugin };
2
3
  export declare function decode(readable: ReadableStream<Uint8Array>, plugins?: DecodePlugin[]): Promise<{
3
4
  done: Promise<undefined>;
4
5
  value: unknown;
@@ -105,7 +105,7 @@ export function encode(input, plugins) {
105
105
  const encoder = {
106
106
  deferred: {},
107
107
  index: 0,
108
- indicies: new Map(),
108
+ indices: new Map(),
109
109
  stringified: [],
110
110
  plugins,
111
111
  };
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
@@ -26,7 +26,7 @@ export interface ThisDecode {
26
26
  }
27
27
  export interface ThisEncode {
28
28
  index: number;
29
- indicies: Map<unknown, number>;
29
+ indices: Map<unknown, number>;
30
30
  stringified: string[];
31
31
  deferred: Record<number, Promise<unknown>>;
32
32
  plugins?: EncodePlugin[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbo-stream",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
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
  "type": "module",
6
6
  "files": [