@anzerr/bcrypt.pool
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

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

npm install --save git+https://git@github.com/anzerr/bcrypt.pool.git
npm install --save @anzerr/bcrypt.pool

Example

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

/@anzerr/bcrypt.pool/

    Package Sidebar

    Install

    npm i @anzerr/bcrypt.pool

    Weekly Downloads

    227

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    7.98 kB

    Total Files

    7

    Last publish

    Collaborators

    • anzerr