https://github.com/anzerr/bcrypt.pool
util for creating worker pools to run bcryptjs
https://github.com/anzerr/bcrypt.pool
bcrypt fork lib nodejs pool sharedarraybuffer threads util
Last synced: 10 months ago
JSON representation
util for creating worker pools to run bcryptjs
- Host: GitHub
- URL: https://github.com/anzerr/bcrypt.pool
- Owner: anzerr
- License: mit
- Created: 2020-06-05T20:34:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2022-01-21T16:26:57.000Z (almost 4 years ago)
- Last Synced: 2025-02-07T07:46:48.052Z (11 months ago)
- Topics: bcrypt, fork, lib, nodejs, pool, sharedarraybuffer, threads, util
- Language: JavaScript
- Homepage:
- Size: 45.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
### `Intro`
Create a pool of forked workers that will run hash/compare instead of the main thread useful for api to not block the event loop. This uses bcryptjs so should work everywhere without needing to compile.
#### `Install`
``` bash
npm install --save git+https://git@github.com/anzerr/bcrypt.pool.git
npm install --save @anzerr/bcrypt.pool
```
### `Example`
``` javascript
const BcryptPool = require('bcrypt.pool');
const p = new BcryptPool(4, 12); // will creat 4 workers with 12 hash rounds
Promise.all([
p.hash('test'),
p.hash('test'),
p.hash('test'),
p.hash('test')
]).then((a) => {
return Promise.all([
p.compare('test', a[0]),
p.compare('test', a[1]),
p.compare('test', a[2]),
p.compare('test', a[3])
]);
}).then((res) => {
console.log(res);
});
```