1.1.0 ā€¢ Published 2 years ago

nodejs-threads v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

A very simple function based implementation of node.js worker threads

šŸ  Homepage

āœØ Demo

Install

npm install nodejs-threads

Basic Usage

// No need to create a separate file for the worker thread.

const { runInWorker } = require('nodejs-threads');
// OR
import { runInWorker } from 'nodejs-threads';

// Assume this is the CPU intensive task
const { calculateScore } = './users.service';

async function main() {
    try {
        // Spawn a worker thread like this:
        // Does not block the main thread
        const result = await runInWorker('./users.service', 'calculateScore', { name: 'Karan' });
        console.log('[PRIMARY] : WORKER EXECUTED WITH ...', result);
    } catch (error) {
        console.log('[PRIMARY] : ERROR', error);
    }
}

API Guide

For complete usage guide, refer our API.md file

Run tests

npm run test

Author

šŸ‘¤ Karan Raina karanraina1996@gmail.com

šŸ¤ Contributing

Contributions, issues and feature requests are welcome!Feel free to check issues page. You can also take a look at the contributing guide.

Show your support

Give a ā­ļø if this project helped you!

šŸ“ License

Copyright Ā© 2021 Karan Raina <karanraina1996@gmail.com>. This project is MIT licensed.


This README was generated with ā¤ļø by readme-md-generator

1.1.0

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago