Skip to content

Commit 3a79448

Browse files
chore(temp): temp
1 parent 14f854e commit 3a79448

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

packages/node_modules/non-blocking-json/src/index.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,34 @@ const IS_ARRAY_END = Symbol("IS_ARRAY_END");
44
const IS_OBJECT_START = Symbol("IS_OBJECT_START");
55
const IS_OBJECT_END = Symbol("IS_OBJECT_END");
66

7+
let QUEUE_BATCH_COUNT = 10
78
let ASYNC_BATCH_COUNT = 3000;
89
let TRACK_PERF = false;
910

10-
export const tweak = (batchCount, trackPerf) => {
11+
export const tweak = (queueBatchCount, batchCount, trackPerf) => {
12+
QUEUE_BATCH_COUNT = queueBatchCount
1113
ASYNC_BATCH_COUNT = batchCount;
1214
TRACK_PERF = Boolean(trackPerf);
1315
};
1416

15-
const next = (typeof window !== 'undefined' && window.requestAnimationFrame) || setTimeout;
17+
const tick = (typeof window !== 'undefined' && window.requestAnimationFrame) || setTimeout;
18+
const queue = (() => {
19+
let pending = []
20+
function pick() {
21+
const picked = pending.splice(0, QUEUE_BATCH_COUNT)
22+
picked.forEach(cb => cb())
23+
if (pending.length) {
24+
tick(pick)
25+
}
26+
}
27+
return (cb) => {
28+
pending.push(cb)
29+
30+
if (pending.length === 1) {
31+
pick()
32+
}
33+
}
34+
})()
1635

1736
/*
1837
This function takes a value which results in a Map of
@@ -65,7 +84,7 @@ function isRef(ref) {
6584
*/
6685
export function stringify(value, replacer?) {
6786
return new Promise<string>(resolve => {
68-
next(async () => {
87+
queue(async () => {
6988
const paths = getPaths(value, new Map(), replacer ? replacer.bind(global || window) : replacer);
7089
const structs = [];
7190
let prevKey = [];
@@ -85,7 +104,7 @@ export function stringify(value, replacer?) {
85104
console.log("PERF - ", end - start)
86105
start = end
87106
}
88-
await new Promise(resolve => next(resolve));
107+
await new Promise(resolve => queue(resolve));
89108
}
90109

91110
x++;
@@ -168,7 +187,7 @@ export async function parse(value) {
168187
console.log("PERF - ", end - start)
169188
start = end
170189
}
171-
await new Promise(resolve => next(resolve));
190+
await new Promise(resolve => queue(resolve));
172191
}
173192

174193
if (value[charIndex] === '"' && value[charIndex - 1] !== '\\') {
@@ -218,7 +237,7 @@ export async function parse(value) {
218237
const keys = Object.keys(parsedValue);
219238

220239
if (i && i % ASYNC_BATCH_COUNT === 0) {
221-
await new Promise(resolve => next(resolve));
240+
await new Promise(resolve => queue(resolve));
222241
}
223242

224243
return Promise.all(

packages/node_modules/overmind/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ export class Overmind<ThisConfig extends IConfiguration>
662662

663663
let pendingFlush
664664
mutationTree.onMutation((mutation) => {
665+
console.log("WTF?", mutation)
665666
if (pendingFlush) {
666667
clearTimeout(pendingFlush)
667668
}

0 commit comments

Comments
 (0)