Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
W4G1 committed Dec 19, 2023
1 parent b1b8ec8 commit 0149b6b
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,9 @@ Depending on the environment, it uses [Worker Threads](https://nodejs.org/api/wo
npm install multithreading
```

#### Node.js
To use the `multithreading` package with Node.js, and to keep the bundle size as small as possible, it is necessary to install the [web-worker](https://www.npmjs.com/package/web-worker) package separately because Node.js does not support web workers by default.

```bash
npm install web-worker
```

## Usage

#### Minimal example
#### Basic example

```js
import { threaded } from "multithreading";
Expand Down Expand Up @@ -112,7 +105,7 @@ await Promise.all([

console.log(user.balance); // 15
```
In this example, the `addBalance` function integrates the external `add` function into a multithreaded environment. The `yield` statement is used to declare external dependencies, ensuring that the required functions and data are available to the threaded function.
In this example, the `add` function is used within the multithreaded `addBalance` function. The `yield` statement is used to declare external dependencies, ensuring that the required functions and data are available to the threaded function.

As with previous examples, the shared state is managed using `$claim` and `$unclaim` to guarantee proper synchronization and prevent data conflicts.

Expand Down

0 comments on commit 0149b6b

Please sign in to comment.