turbo-stream 0.0.7 → 0.0.8

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,4 +1,4 @@
1
- import { HOLE, NAN, NEGATIVE_INFINITY, NEGATIVE_ZERO, POSITIVE_INFINITY, TYPE_BIGINT, TYPE_DATE, TYPE_ERROR, TYPE_MAP, TYPE_PROMISE, TYPE_REGEXP, TYPE_SET, TYPE_SYMBOL, UNDEFINED, } from "./utils.js";
1
+ import { HOLE, NAN, NEGATIVE_INFINITY, NEGATIVE_ZERO, POSITIVE_INFINITY, TYPE_BIGINT, TYPE_DATE, TYPE_ERROR, TYPE_MAP, TYPE_NULL_OBJECT, TYPE_PROMISE, TYPE_REGEXP, TYPE_SET, TYPE_SYMBOL, UNDEFINED, } from "./utils.js";
2
2
  export function flatten(input) {
3
3
  const existing = this.indicies.get(input);
4
4
  if (existing)
@@ -74,6 +74,13 @@ function stringify(input, index) {
74
74
  }
75
75
  str[index] += "]";
76
76
  }
77
+ else if (Object.getPrototypeOf(input) === null) {
78
+ str[index] = `["${TYPE_NULL_OBJECT}"`;
79
+ const parts = [];
80
+ for (const key in input)
81
+ parts.push(`${JSON.stringify(key)}:${flatten.call(this, input[key])}`);
82
+ str[index] += ",{" + parts.join(",") + "}]";
83
+ }
77
84
  else if (isPlainObject(input)) {
78
85
  const parts = [];
79
86
  for (const key in input)
package/dist/unflatten.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Deferred, HOLE, NAN, NEGATIVE_INFINITY, NEGATIVE_ZERO, POSITIVE_INFINITY, TYPE_BIGINT, TYPE_DATE, TYPE_MAP, TYPE_PROMISE, TYPE_REGEXP, TYPE_SET, TYPE_SYMBOL, UNDEFINED, TYPE_ERROR, } from "./utils.js";
1
+ import { Deferred, HOLE, NAN, NEGATIVE_INFINITY, NEGATIVE_ZERO, POSITIVE_INFINITY, TYPE_BIGINT, TYPE_DATE, TYPE_MAP, TYPE_PROMISE, TYPE_REGEXP, TYPE_SET, TYPE_SYMBOL, UNDEFINED, TYPE_ERROR, TYPE_NULL_OBJECT, } from "./utils.js";
2
2
  const globalObj = (typeof window !== "undefined"
3
3
  ? window
4
4
  : typeof globalThis !== "undefined"
@@ -57,6 +57,13 @@ function hydrate(index) {
57
57
  map.set(hydrate.call(this, value[i]), hydrate.call(this, value[i + 1]));
58
58
  }
59
59
  return map;
60
+ case TYPE_NULL_OBJECT:
61
+ console.log({ value });
62
+ const obj = Object.create(null);
63
+ hydrated[index] = obj;
64
+ for (const key in value[1])
65
+ obj[key] = hydrate.call(this, value[1][key]);
66
+ return obj;
60
67
  case TYPE_PROMISE:
61
68
  if (hydrated[value[1]]) {
62
69
  return (hydrated[index] = hydrated[value[1]]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "turbo-stream",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
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": [