lib/ison: Use setTimeout instead of setImmediate. Allows the use of indexDB in browsers (#1226)

This commit is contained in:
George Shammas 2022-05-05 20:13:18 +00:00 committed by GitHub
parent e3eaf5e268
commit 440bbffb73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -278,7 +278,7 @@ let stringifyWrapper = (value, replacer, space, intensity, callback) => {
let g = rs.next();
let yieldCPU = () => {
setImmediate(() => {
setTimeout(() => {
g = rs.next();
if (g && g.done === true) {
// Reinitializing the values at the end of API call
@ -291,7 +291,7 @@ let stringifyWrapper = (value, replacer, space, intensity, callback) => {
return callback(null, yielding);
}
yieldCPU();
});
}, 0);
};
return yieldCPU();
};
@ -592,7 +592,7 @@ let parseWrapper = (text, reviver, intensity, cb) => {
// Main yield control logic.
let yieldCPU = () => {
setImmediate(() => {
setTimeout(() => {
gen = rs.next();
if (gen && gen.done === true) {
@ -618,7 +618,7 @@ let parseWrapper = (text, reviver, intensity, cb) => {
}
}
yieldCPU();
});
}), 0;
};
return yieldCPU();
};
@ -700,4 +700,4 @@ if(typeof JSON != ''+u){
JSON.stringifyAsync = yson.stringifyAsync;
}
}());
}());