Skip to content

Commit

Permalink
Added jest & value synchronization
Browse files Browse the repository at this point in the history
  • Loading branch information
W4G1 committed Dec 18, 2023
1 parent 7f4d00d commit 6fb61d3
Show file tree
Hide file tree
Showing 16 changed files with 5,445 additions and 899 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<a href="https://github.com/W4G1/multithreading">![Multithreading logo](https://github.com/W4G1/multithreading/assets/38042257/2069b810-c630-42a8-9312-d86990e8f7ad)

<div align="center">

<a href="https://multithreading.io">![Multithreading Banner](https://github.com/W4G1/multithreading/assets/38042257/33d76244-5605-4f0f-8bd8-e752ce1c8175)</a>

<a href="https://github.com/W4G1/multithreading/blob/main/LICENSE.md">![License](https://img.shields.io/github/license/W4G1/multithreading)</a>
<a href="https://www.npmjs.com/package/multithreading">![Downloads](https://img.shields.io/npm/dw/multithreading?color=%238956FF)</a>
<a href="https://www.npmjs.com/package/multithreading?activeTab=versions">![NPM version](https://img.shields.io/npm/v/multithreading)</a>
<a href="https://github.com/W4G1/multithreading">![GitHub Repo stars](https://img.shields.io/github/stars/W4G1/multithreading?logo=github&label=Star&labelColor=rgb(26%2C%2030%2C%2035)&color=rgb(13%2C%2017%2C%2023))</a>

</div>

Expand All @@ -14,7 +15,7 @@ Multithreading is a tiny runtime that allows you to execute functions on separat

With a minified size of only 3.8kb, it has first class support for [Node.js](https://nodejs.org/), [Deno](https://deno.com/) and the [browser](https://caniuse.com/webworkers/). It can also be used with any framework or library such as [React](https://react.dev/), [Vue](https://vuejs.org/) or [Svelte](https://svelte.dev/).

Depending on the environment, it uses [Worker Threads](https://nodejs.org/api/worker_threads.html) or [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API). In addition to [ES6 generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) to make multithreading as simple as possible.
Depending on the environment, it uses [Worker Threads](https://nodejs.org/api/worker_threads.html) or [Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Worker). In addition to [ES6 generators](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*) to make multithreading as simple as possible.

## Installation

Expand Down Expand Up @@ -42,7 +43,7 @@ const add = threaded(function* (a, b) {

console.log(await add(5, 10)); // 15
```
The `add` function is executed on a separate thread, and the result is returned to the main thread when the function is done executing. Multiple invocations will automatically be executed in parallel on separate threads.
The `add` function is executed on a separate thread, and the result is returned to the main thread when the function is done executing. Consecutive invocations will be automatically executed in parallel on separate threads.

#### Example with shared state

Expand Down
5 changes: 5 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('jest').Config} */
module.exports = {
// verbose: true,
rootDir: "./test",
};
2 changes: 1 addition & 1 deletion nodemon.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"watch": ["."],
"ext": "js,ts,json",
"ignore": [".temp", "dist", ".rollup.cache"],
"exec": "rollup -c rollup.config.worker.dev.js --configPlugin @rollup/plugin-typescript && rollup -c rollup.config.dev.js --configPlugin @rollup/plugin-typescript && node ./test/node_test.js"
"exec": "rollup -c rollup.config.worker.dev.js --configPlugin @rollup/plugin-typescript && rollup -c rollup.config.dev.js --configPlugin @rollup/plugin-typescript && node ./node_test.js"
}
Loading

0 comments on commit 6fb61d3

Please sign in to comment.