@antv/g2
Version:
the Grammar of Graphics in Javascript
16 lines (13 loc) • 362 B
text/typescript
export function createWorker(f: any) {
if (typeof window === "undefined") return;
let blob;
try {
blob = new Blob([f.toString()], { type: 'application/javascript' });
} catch (e) {
// @ts-ignore
blob = new window.BlobBuilder();
blob.append(f.toString());
blob = blob.getBlob();
}
return new Worker(URL.createObjectURL(blob));
}