From 440bbffb736ab7c39d0e35dbcb096ff6d82d8d54 Mon Sep 17 00:00:00 2001 From: George Shammas Date: Thu, 5 May 2022 20:13:18 +0000 Subject: [PATCH] lib/ison: Use setTimeout instead of setImmediate. Allows the use of indexDB in browsers (#1226) --- lib/ison.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/ison.js b/lib/ison.js index 38aee2e6..67997ea8 100644 --- a/lib/ison.js +++ b/lib/ison.js @@ -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; } -}()); \ No newline at end of file +}());