Skip to content

Commit

Permalink
feat: add node-start
Browse files Browse the repository at this point in the history
  • Loading branch information
andreashuber69 committed Jun 2, 2024
1 parent 32b05a3 commit fa6124e
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 6 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,9 @@ cd kiss-worker-demo2
npm install
npm start
```

The above will run the example code in your browser. You can run it on node as follows:

```bash
npm run node-start
```
59 changes: 54 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
"private": true,
"scripts": {
"start": "vite --open",
"node-start": "tsx ./src/node-main.ts",
"build": "tsc -p './src' && vite build",
"preview": "vite preview --open",
"ci": "npm run build"
},
"devDependencies": {
"@tsconfig/node20": "^20.1.4",
"@tsconfig/strictest": "^2.0.5",
"kiss-worker": "^3.0.0",
"kiss-worker": "^3.1.0-alpha.0",
"tsx": "^4.11.0",
"typescript": "^5.4.5",
"vite": "^5.2.11"
}
Expand Down
11 changes: 11 additions & 0 deletions src/node-main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createCalculatorWorker } from "./createCalculatorWorker.ts";

const worker = await createCalculatorWorker();
let current = 2n;

for (let round = 0; round < 20; ++round) {
current = await worker.obj.multiply(current, current);
}

console.log(current);
worker.terminate();

0 comments on commit fa6124e

Please sign in to comment.