Skip to content

Commit

Permalink
perf: use native JSON.stringify for gzipped data
Browse files Browse the repository at this point in the history
  • Loading branch information
JLHwung committed Nov 7, 2024
1 parent c97691c commit 89544f1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion scripts/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const gzipInline = function(data) {
if (data instanceof Map) {
return `new Map(${ gzipInline([...data]) })`;
}
const json = jsesc(data, { 'json': true });
const json = JSON.stringify(data);
const gzipBuffer = zlib.gzipSync(json);
const str = gzipBuffer.toString('base64');
return `JSON.parse(require('zlib').gunzipSync(Buffer.from('${ str }','base64')))`;
Expand Down

0 comments on commit 89544f1

Please sign in to comment.