seroval 0.2.1 → 0.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/README.md CHANGED
@@ -58,25 +58,25 @@ const result = serialize(object);
58
58
  Output (as a string):
59
59
 
60
60
  ```js
61
- ((h,j,k,m)=>(h={number:[0.5906513825027921,-0,NaN,Infinity,-Infinity],string:["hello world","\x3Cscript>Hello World\x3C/script>"],boolean:[!0,!1],null:null,undefined:void 0,bigint:BigInt("9007199254740991"),array:j=[,,,,k=new Map([["hello","world"],["mutual",m=new Set(["hello","world"])]])],regexp:/[a-z0-9]+/i,date:new Date("2023-02-06T06:16:00.384Z"),map:k,set:m},j[3]=j,h.self=h,k.set("self",k),m.add(m).add(j),h))()
61
+ ((h,j,k,m)=>(m={number:[0.4178420745429774,-0,NaN,1/0,-1/0],string:["hello world","\x3Cscript>Hello World\x3C/script>"],boolean:[!0,!1],null:null,undefined:void 0,bigint:9007199254740991n,array:h=[,,,,j=new Map([["hello","world"],["mutual",k=new Set(["hello","world"])]])],regexp:/[a-z0-9]+/i,date:new Date("2023-03-13T00:52:11.335Z"),map:j,set:k},h[3]=h,j.set("self",j),k.add(k).add(h),m.self=m,m))()
62
62
 
63
63
  // Formatted for readability
64
- ((h, j, k, m) => (h = {
65
- number: [0.5906513825027921, -0, NaN, Infinity, -Infinity],
64
+ ((h, j, k, m) => (m = {
65
+ number: [0.4178420745429774, -0, NaN, 1/0, -1/0],
66
66
  string: ["hello world", "\x3Cscript>Hello World\x3C/script>"],
67
67
  boolean: [!0, !1],
68
68
  null: null,
69
69
  undefined: void 0,
70
- bigint: BigInt("9007199254740991"),
71
- array: j = [, , , , k = new Map([
70
+ bigint: 9007199254740991n,
71
+ array: h = [, , , , j = new Map([
72
72
  ["hello", "world"],
73
- ["mutual", m = new Set(["hello", "world"])]
73
+ ["mutual", k = new Set(["hello", "world"])]
74
74
  ])],
75
75
  regexp: /[a-z0-9]+/i,
76
- date: new Date("2023-02-06T06:16:00.384Z"),
77
- map: k,
78
- set: m
79
- }, j[3] = j, h.self = h, k.set("self", k), m.add(m).add(j), h))()
76
+ date: new Date("2023-03-13T00:52:11.335Z"),
77
+ map: j,
78
+ set: k
79
+ }, h[3] = h, j.set("self", j), k.add(k).add(h), m.self = m, m))()
80
80
  ```
81
81
 
82
82
  ### Mutual cyclic example
@@ -102,7 +102,7 @@ const result = serialize({ a, b, c, d });
102
102
  Output (as a string):
103
103
 
104
104
  ```js
105
- ((h,j,k,m,o,q)=>(q={a:h=new Map([["name","a"],["children",[j=new Map([["name","c"],["right",k=new Map([["name","b"],["children",o=[,m=new Map([["name","d"]])]]])]]),m]]]),b:k,c:j,d:m},o[0]=j,j.set("left",h),m.set("left",h).set("right",k),q))()
105
+ ((h,j,k,m,o,q)=>(q={a:h=new Map([["name","a"],["children",[j=new Map([["name","c"],["right",o=new Map([["name","b"],["children",k=[,m=new Map([["name","d"]])]]])]]),m]]]),b:o,c:j,d:m},j.set("left",h),k[0]=j,m.set("left",h).set("right",o),q))()
106
106
 
107
107
  // Formatted
108
108
  ((h, j, k, m, o, q) => (q = {
@@ -110,18 +110,18 @@ Output (as a string):
110
110
  ["name", "a"],
111
111
  ["children", [j = new Map([
112
112
  ["name", "c"],
113
- ["right", k = new Map([
113
+ ["right", o = new Map([
114
114
  ["name", "b"],
115
- ["children", o = [, m = new Map([
115
+ ["children", k = [, m = new Map([
116
116
  ["name", "d"]
117
117
  ])]]
118
118
  ])]
119
119
  ]), m]]
120
120
  ]),
121
- b: k,
121
+ b: o,
122
122
  c: j,
123
123
  d: m
124
- }, o[0] = j, j.set("left", h), m.set("left", h).set("right", k), q))()
124
+ }, j.set("left", h), k[0] = j, m.set("left", h).set("right", o), q))()
125
125
  ```
126
126
 
127
127
  ## Deserialization
@@ -172,7 +172,28 @@ The following values are the only values accepted by `seroval`:
172
172
  - `Date`
173
173
  - `Map`
174
174
  - `Set`
175
+ - `TypedArray`
176
+ - `Int8Array`
177
+ - `Int16Array`
178
+ - `Int32Array`
179
+ - `Uint8Array`
180
+ - `Uint16Array`
181
+ - `Uint32Array`
182
+ - `Uint8ClampedArray`
183
+ - `Float32Array`
184
+ - `Float64Array`
185
+ - `BigInt64Array`
186
+ - `BigUint64Array`
187
+ - `Error`
188
+ - `AggregateError`
189
+ - `EvalError`
190
+ - `RangeError`
191
+ - `ReferenceError`
192
+ - `SyntaxError`
193
+ - `TypeError`
194
+ - `URIError`
175
195
  - `Promise` (with `serializeAsync`)
196
+ - [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol)
176
197
  - Cyclic references (both self and mutual)
177
198
 
178
199
  ## Sponsors