You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could use sync-rpc to render transforms that only support async, synchronously. It would be relatively slow, but if you need it then at least it would work.
The code would look something like:
worker.js
constjstransformer=require('./');functioninit(transformName){constt=jstransformer(require('jstransformer-'+transformName));returnfunctionrender({str, options, locals}){// sync-rpc converts this promise into a synchronous resultreturnt.renderAsync(str,options,locals);}}module.exports=init;
index.js
constsyncRPC=require('sync-rpc');// ...Transformer.prototype.render=function(str,options,locals){if(!this.can('render')&&this.can('renderAsync')){if(!this._syncWorker){this._syncWorker=syncRPC(require.resolve('./worker.js'),this.name);}returnthis._syncWorker({str, options, locals});}// ... normal sync implementation here ...}// ...
The text was updated successfully, but these errors were encountered:
We could use sync-rpc to render transforms that only support async, synchronously. It would be relatively slow, but if you need it then at least it would work.
The code would look something like:
worker.js
index.js
The text was updated successfully, but these errors were encountered: