An open API service indexing awesome lists of open source software.

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

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);
});
```