Skip to content

Commit 49c0185

Browse files
committed
Update theory.js
1 parent 302ed32 commit 49c0185

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

packages/seroval/theory.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,28 @@
1-
import { serialize } from './dist/esm/development/index.mjs';
1+
import { toCrossJSONStream, fromCrossJSON, crossSerializeStream } from "./dist/esm/development/index.mjs";
22

3-
const example = {};
3+
const delay = (delay, value) => new Promise((resolve) => {
4+
setTimeout(() => resolve(value), delay)
5+
})
46

5-
example[NaN] = example;
7+
const bla = {
8+
a: 'Hello',
9+
b: delay(1000, "World"),
10+
c: delay(2000, "Bla"),
11+
d: delay(3000, {
12+
e: 2500
13+
})
14+
}
615

7-
console.log(serialize(example));
16+
const refs = new Map();
17+
18+
toCrossJSONStream(bla, {
19+
onParse(node, initial) {
20+
console.log(fromCrossJSON(node, { refs }))
21+
}
22+
});
23+
24+
// crossSerializeStream(bla, {
25+
// onSerialize(node) {
26+
// console.log(node);
27+
// }
28+
// })

0 commit comments

Comments
 (0)