From 13d50cb4bd1472faae5134345d279bfc9964cdd8 Mon Sep 17 00:00:00 2001 From: ihasq Date: Mon, 15 Jan 2024 00:24:41 +0900 Subject: [PATCH] work in progress --- example/example.js | 0 example/main.js | 3 +++ package.json | 5 +++-- src/Fn.js | 20 -------------------- src/Workio.js | 19 +++++++++++++++++++ src/function.js | 0 src/lib.js | 6 ------ src/object.js | 0 src/worker.js | 5 +++++ 9 files changed, 30 insertions(+), 28 deletions(-) create mode 100644 example/example.js create mode 100644 example/main.js delete mode 100644 src/Fn.js create mode 100644 src/function.js delete mode 100644 src/lib.js create mode 100644 src/object.js create mode 100644 src/worker.js diff --git a/example/example.js b/example/example.js new file mode 100644 index 0000000..e69de29 diff --git a/example/main.js b/example/main.js new file mode 100644 index 0000000..468d154 --- /dev/null +++ b/example/main.js @@ -0,0 +1,3 @@ +import { Workio } from "../src/Workio.js" + +await new Workio((name) => `Hello, ${name} from Workio!`, { type: Function })() \ No newline at end of file diff --git a/package.json b/package.json index 87626db..0d50171 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,8 @@ "test": "test" }, "scripts": { - "test": "npx standard && node ./test/standard.js" + "test": "npx standard && node ./test/standard.js", + "example": "node ./example/example.js" }, "repository": { "type": "git", @@ -22,4 +23,4 @@ "url": "https://github.com/workio-js/workio/issues" }, "homepage": "https://github.com/workio-js/workio#readme" -} +} \ No newline at end of file diff --git a/src/Fn.js b/src/Fn.js deleted file mode 100644 index 0a50a4b..0000000 --- a/src/Fn.js +++ /dev/null @@ -1,20 +0,0 @@ - -export class Fn { - - /** - * @param { Function } workerFn - * @param { Object } [config] - * @param { Boolean } [config.async] - */ - - constructor(workerFn, config) { - super() - if(!workerFn instanceof Function) { - throw new TypeError("workerFn is not a type of function") - }; - const workerFnDescriber = { - type: workerFn.constructor.name - } - - } -} \ No newline at end of file diff --git a/src/Workio.js b/src/Workio.js index dbe6d7b..307d7a7 100644 --- a/src/Workio.js +++ b/src/Workio.js @@ -1,5 +1,6 @@ import { ScriptURL, UniversalWorker } from "./util/lib.js"; import { AM_I_NODE } from "./constants/lib.js"; +import { WorkioWorker } from "./worker.js" export class Workio { @@ -14,6 +15,17 @@ export class Workio { if(!workerFn instanceof Function) { throw new TypeError("workerFn is not a type of function") }; + switch(config.type) { + case Worker: + case undefined: + return; + + case Function: + return + + case Object: + return + } const compiledScriptURL = new ScriptURL(` (async () => { @@ -65,4 +77,11 @@ export class Workio { } + /** + * @param { Object } functionList + */ + static public(functionList, options) { + + } + }; \ No newline at end of file diff --git a/src/function.js b/src/function.js new file mode 100644 index 0000000..e69de29 diff --git a/src/lib.js b/src/lib.js deleted file mode 100644 index 4fa84cb..0000000 --- a/src/lib.js +++ /dev/null @@ -1,6 +0,0 @@ -import { Workio } from "./Workio.js"; -import { Fn } from "./Fn.js" - -Object.assign(Workio, { Fn }) - -export { Workio }; \ No newline at end of file diff --git a/src/object.js b/src/object.js new file mode 100644 index 0000000..e69de29 diff --git a/src/worker.js b/src/worker.js new file mode 100644 index 0000000..11861db --- /dev/null +++ b/src/worker.js @@ -0,0 +1,5 @@ +export class WorkioWorker { + constructor() { + + } +} \ No newline at end of file