fflate
Version:
High performance (de)compression in an 8kB package
21 lines (20 loc) • 792 B
JavaScript
var ch2 = {};
var durl = function (c) { return URL.createObjectURL(new Blob([c], { type: 'text/javascript' })); };
var cwk = function (u) { return new Worker(u); };
try {
URL.revokeObjectURL(durl(''));
}
catch (e) {
// We're in Deno or a very old browser
durl = function (c) { return 'data:application/javascript;charset=UTF-8,' + encodeURI(c); };
// If Deno, this is necessary; if not, this changes nothing
cwk = function (u) { return new Worker(u, { type: 'module' }); };
}
exports["default"] = (function (c, id, msg, transfer, cb) {
var w = cwk(ch2[id] || (ch2[id] = durl(c)));
w.onerror = function (e) { return cb(e.error, null); };
w.onmessage = function (e) { return cb(null, e.data); };
w.postMessage(msg, transfer);
return w;
});
;