# @anzerr/thread.node

> Test to understand how the new 'worker_threads' works with SharedArrayBuffer.

Latest version **1.0.11** (published 2022-02-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @anzerr/thread.node
pnpm add @anzerr/thread.node
yarn add @anzerr/thread.node
bun add @anzerr/thread.node
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2022-02-17 |
| First published | 2019-08-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 0.10.0 |
| Dependencies | 0 |
| Unpacked size | 8.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | anzerr |
| Maintainers | anzerr |

## Links

- npm: https://www.npmjs.com/package/@anzerr/thread.node
- Repository: https://github.com/anzerr/worker_threads.node
- Homepage: https://github.com/anzerr/worker_threads.node#readme
- Issues: https://github.com/anzerr/worker_threads.node/issues
- npm.io page: https://npm.io/package/@anzerr/thread.node

## Recent versions

- 1.0.11 (latest) — 2022-02-17
- 1.0.1 (old) — 2019-08-07
- 1.0.10 — 2022-01-21
- 1.0.9 — 2021-07-23
- 1.0.8 — 2021-06-25
- 1.0.7 — 2020-08-28
- 1.0.6 — 2020-07-23
- 1.0.5 — 2020-06-05
- 1.0.2 — 2019-08-07

## README

### `Intro`
Test to understand how the new 'worker_threads' works with SharedArrayBuffer.

#### `Install`
``` bash
npm install --save git+https://github.com/anzerr/worker_threads.node.git
npm install --save @anzerr/thread.node
```

### `Example`

``` javascript
const {Executors} = require('@anzerr/thread.node');

let pool = Executors.singleThreadPool();

const buffer = new SharedArrayBuffer(16);

pool.submit(async (d) => {
	new Int32Array(d)[0] = 42;
	return {'cat': 10};
}, buffer).then((res) => {
	console.log('sumbit1', res);
	return Promise.all([
		pool.submit(async (d) => {
			const b = Buffer.from(d);
			const path = require('path');
			b.write(path.resolve(process.cwd()));
		}, buffer).then((result) => console.log('1', result)),
		pool.submit(async (d) => {
			return Buffer.from(d)[0];
		}, buffer).then((result) => console.log('2', result)),
		pool.submit(async (d) => {
			return d.data.toString();
		}, {data: 'egg'}).then((result) => console.log('3', result))
	]);
}).then(() => {
	return pool.close();
}).catch((e) => {
	console.log(e);
	return pool.close();
}).then(() => {
	console.log('done', Buffer.from(buffer).toString());

```

---
_Source: https://npm.io/package/@anzerr/thread.node · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
