Comparing version 2.0.0 to 2.1.0
@@ -1,2 +0,2 @@ | ||
declare const _default: "var o=class{constructor(){this.methods={};addEventListener(\"message\",this.message.bind(this))}exec(t,e){let n=this.methods[t],a=new Promise(s=>s(n.apply(void 0,e))),c=s=>{try{postMessage({type:\"result\",value:s})}catch(i){r(i)}},r=s=>{s=s instanceof Error?s:typeof s==\"string\"?new Error(s):new Error;let{message:i,name:d,stack:g}=s;postMessage({type:\"result\",error:{message:i,name:d,stack:g}})};a.then(c,r)}init(t){this.register(t),postMessage({type:\"ready\"})}message(t){if(t.data.type===\"init\")return this.init(t.data.methods);if(t.data.type===\"exec\")return this.exec(t.data.method,t.data.args)}register(t){if(typeof t==\"string\"){let e=new Function(t)();for(let n in e)this.methods[n]=e[n]}else for(let e in t){let n=new Function(`return (${t[e]})`)();this.methods[e]=n}}};new o;"; | ||
declare const _default: "var u=new Function(\"url\",\"return import ( url );\"),a=u;var i=class{constructor(){this.methods={};addEventListener(\"message\",this.message.bind(this))}exec(t,s){let n=this.methods[t],c=new Promise(e=>e(n.apply({import:a},s))),d=e=>{try{postMessage({type:\"result\",value:e})}catch(o){r(o)}},r=e=>{e=e instanceof Error?e:typeof e==\"string\"?new Error(e):new Error;let{message:o,name:p,stack:g}=e;postMessage({type:\"result\",error:{message:o,name:p,stack:g}})};c.then(d,r)}init(t){this.register(t),postMessage({type:\"ready\"})}message(t){if(t.data.type===\"init\")return this.init(t.data.methods);if(t.data.type===\"exec\")return this.exec(t.data.method,t.data.args)}register(t){if(typeof t==\"string\"){let s=new Function(t)();for(let n in s)this.methods[n]=s[n]}else for(let s in t){let n=new Function(`return (${t[s]})`)();this.methods[s]=n}}};new i;"; | ||
export default _default; |
@@ -1,1 +0,1 @@ | ||
export default 'var o=class{constructor(){this.methods={};addEventListener("message",this.message.bind(this))}exec(t,e){let n=this.methods[t],a=new Promise(s=>s(n.apply(void 0,e))),c=s=>{try{postMessage({type:"result",value:s})}catch(i){r(i)}},r=s=>{s=s instanceof Error?s:typeof s=="string"?new Error(s):new Error;let{message:i,name:d,stack:g}=s;postMessage({type:"result",error:{message:i,name:d,stack:g}})};a.then(c,r)}init(t){this.register(t),postMessage({type:"ready"})}message(t){if(t.data.type==="init")return this.init(t.data.methods);if(t.data.type==="exec")return this.exec(t.data.method,t.data.args)}register(t){if(typeof t=="string"){let e=new Function(t)();for(let n in e)this.methods[n]=e[n]}else for(let e in t){let n=new Function(`return (${t[e]})`)();this.methods[e]=n}}};new o;'; | ||
export default 'var u=new Function("url","return import ( url );"),a=u;var i=class{constructor(){this.methods={};addEventListener("message",this.message.bind(this))}exec(t,s){let n=this.methods[t],c=new Promise(e=>e(n.apply({import:a},s))),d=e=>{try{postMessage({type:"result",value:e})}catch(o){r(o)}},r=e=>{e=e instanceof Error?e:typeof e=="string"?new Error(e):new Error;let{message:o,name:p,stack:g}=e;postMessage({type:"result",error:{message:o,name:p,stack:g}})};c.then(d,r)}init(t){this.register(t),postMessage({type:"ready"})}message(t){if(t.data.type==="init")return this.init(t.data.methods);if(t.data.type==="exec")return this.exec(t.data.method,t.data.args)}register(t){if(typeof t=="string"){let s=new Function(t)();for(let n in s)this.methods[n]=s[n]}else for(let s in t){let n=new Function(`return (${t[s]})`)();this.methods[s]=n}}};new i;'; |
/* IMPORT */ | ||
import importFool from 'import-fool-webpack'; | ||
/* MAIN */ | ||
@@ -13,3 +14,3 @@ class WorkerBackend { | ||
const fn = this.methods[method]; | ||
const result = new Promise(resolve => resolve(fn.apply(undefined, args))); | ||
const result = new Promise(resolve => resolve(fn.apply({ import: importFool }, args))); | ||
const onSuccess = (value) => { | ||
@@ -57,2 +58,1 @@ try { | ||
new WorkerBackend(); | ||
export {}; |
@@ -5,3 +5,3 @@ { | ||
"description": "A simple isomorphic library for executing functions inside WebWorkers or Node Threads pools.", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"type": "module", | ||
@@ -32,2 +32,3 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"import-fool-webpack": "^1.0.0", | ||
"promise-make-naked": "^2.0.0", | ||
@@ -34,0 +35,0 @@ "web-worker": "1.2.0" |
@@ -40,3 +40,3 @@ # WorkTank | ||
sum: function ( a: number, b: number ): Promise<number> { | ||
const {default: math} = await import ( 'math' ); | ||
const {default: math} = await this.import ( 'math' ); // Use `this.import` rather than the regular `import` inside functions that need to load a dependency if you are using a bundler, or pre-bundle the functions that get sent to worker threads | ||
return math.sum ( a + b ); | ||
@@ -43,0 +43,0 @@ }, |
@@ -1,1 +0,1 @@ | ||
export default 'var o=class{constructor(){this.methods={};addEventListener("message",this.message.bind(this))}exec(t,e){let n=this.methods[t],a=new Promise(s=>s(n.apply(void 0,e))),c=s=>{try{postMessage({type:"result",value:s})}catch(i){r(i)}},r=s=>{s=s instanceof Error?s:typeof s=="string"?new Error(s):new Error;let{message:i,name:d,stack:g}=s;postMessage({type:"result",error:{message:i,name:d,stack:g}})};a.then(c,r)}init(t){this.register(t),postMessage({type:"ready"})}message(t){if(t.data.type==="init")return this.init(t.data.methods);if(t.data.type==="exec")return this.exec(t.data.method,t.data.args)}register(t){if(typeof t=="string"){let e=new Function(t)();for(let n in e)this.methods[n]=e[n]}else for(let e in t){let n=new Function(`return (${t[e]})`)();this.methods[e]=n}}};new o;'; | ||
export default 'var u=new Function("url","return import ( url );"),a=u;var i=class{constructor(){this.methods={};addEventListener("message",this.message.bind(this))}exec(t,s){let n=this.methods[t],c=new Promise(e=>e(n.apply({import:a},s))),d=e=>{try{postMessage({type:"result",value:e})}catch(o){r(o)}},r=e=>{e=e instanceof Error?e:typeof e=="string"?new Error(e):new Error;let{message:o,name:p,stack:g}=e;postMessage({type:"result",error:{message:o,name:p,stack:g}})};c.then(d,r)}init(t){this.register(t),postMessage({type:"ready"})}message(t){if(t.data.type==="init")return this.init(t.data.methods);if(t.data.type==="exec")return this.exec(t.data.method,t.data.args)}register(t){if(typeof t=="string"){let s=new Function(t)();for(let n in s)this.methods[n]=s[n]}else for(let s in t){let n=new Function(`return (${t[s]})`)();this.methods[s]=n}}};new i;'; |
/* IMPORT */ | ||
import importFool from 'import-fool-webpack'; | ||
import type {Message} from '../types'; | ||
@@ -27,3 +28,3 @@ | ||
const fn = this.methods[method]; | ||
const result = new Promise ( resolve => resolve ( fn.apply ( undefined, args ) ) ); | ||
const result = new Promise ( resolve => resolve ( fn.apply ( { import: importFool }, args ) ) ); | ||
@@ -30,0 +31,0 @@ const onSuccess = ( value: any ): void => { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35355
765
3
2
+ Addedimport-fool-webpack@^1.0.0
+ Addedimport-fool-webpack@1.0.0(transitive)