Async builds (serializes) on JSON in javascript

In my answer-based application, I need to compress (serialize) large objects and not block js thread - an asynchronous api that uses other threads, something like this:

JSON.stringifyAsync({ foo: "bar" }).then(x => console.log(x));

Please do not offer to wrap JSON.stringify in Promise, it just postpones js thread lock.

+4
source share
2 answers

I do not think this is currently possible. This is a problem for node.js (here here , here and here ), and I do not think that the situation is better for web browsers or other JS engines.

EcmaScript (. ), JSON.parseAsync JSON.stringifyAsync. . : " ". , , () , .

+5

, .

- :

async.eachOf(obj,function(value,key,callback){
  async.setImmediate(function(){

    // do something

  });
}, function(err,reply){

});
0

Source: https://habr.com/ru/post/1659557/


All Articles