# wpoll

> Worker Poll With Timeout

Latest version **1.0.3** (published 2021-07-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install wpoll
pnpm add wpoll
yarn add wpoll
bun add wpoll
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-07-06 |
| First published | 2021-05-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | le-ar |
| Maintainers | le-ar |
| Keywords | worker threads, poll, node, thread poll |

## Links

- npm: https://www.npmjs.com/package/wpoll
- Repository: https://github.com/le-ar/wpoll
- npm.io page: https://npm.io/package/wpoll

## Alternatives

- [apollo-link-http-common](https://npm.io/package/apollo-link-http-common.md) — 879.0K weekly downloads
- [react-relay](https://npm.io/package/react-relay.md) — 336.8K weekly downloads
- [relay-test-utils](https://npm.io/package/relay-test-utils.md) — 181.6K weekly downloads
- [@vendure/core](https://npm.io/package/@vendure/core.md) — 14.8K weekly downloads
- [@pnpm/deps.graph-sequencer](https://npm.io/package/@pnpm/deps.graph-sequencer.md) — 13.4K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-07-06
- 1.0.2 — 2021-05-10
- 1.0.1 — 2021-05-10
- 1.0.0 — 2021-05-10

## README

# WPoll

![Lines of code](https://img.shields.io/tokei/lines/github/le-ar/wpoll)
![GitHub top language](https://img.shields.io/github/languages/top/le-ar/wpoll)
![NPM](https://img.shields.io/npm/l/wpoll)
![GitHub last commit](https://img.shields.io/github/last-commit/le-ar/wpoll)

### Worker poll use worker_threads

## Example

- main.ts
```typescript
import { WPoll } from 'wpoll';
import path from 'path';

let wpoll = new WPoll<number>(path.resolve(__dirname, './worker.js'));
wpoll.init();

(async () => {
    console.log(await wpoll.exec(100));
})();
```

- worker.ts
```typescript
import { WWorker } from 'wpoll';

new WWorker(async (message) => {
    console.log(message);
    return 5;
});
```

## Types
### ```WPoll<T = void, P = void>```

|Name|Parameter|Type|Description|
|---|---|---|---|
|Constructor||WPoll&lt;T, P>|
||workerFile|string|Path to worker file (absolute path preferred)|
||props|WPollProps|Init Parameters
|init|-|-|Init Workers. Must be called once|
|exec|T|P|Execute with parameters T and return P

### ```WWorker<T = void, P = void>```

|Name|Parameter|Type|Description|
|---|---|---|---|
|Constructor||WWorker&lt;T,P>
||onMessage|(message: T) => Promise&lt;P> &#124; P| callback on message received

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