0.9.7 • Published 10 months ago

threadosaurus v0.9.7

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

threadosaurus

npm version Build Status codecov

install

npm i threadosaurus

Usage

Here's a quick example of how to use Threadosaurus:

import { CreateThreadosaurus } from 'threadosaurus';
import SampleWorkerThreadClass from './SampleWorkerThreadClass';

const worker = CreateThreadosaurus(SampleWorkerThreadClass);
console.log(await worker.greet('LJ and NJ'));

In SampleWorkerThreadClass.ts:

import { Threadosaurus } from 'threadosaurus';

export default class SampleWorkerThreadClass implements Threadosaurus {
    async greet(name: string): Promise<string> {
        return Promise.resolve(`Hello ${name} from worker thread!`);
    }

    get__filename(): string {
        return __filename;
    }
}

Restrictions

When using Threadosaurus, please keep the following limitations in mind:

  • The worker class must implement the Threadosaurus interface.
  • The worker class must be the default export.
  • The worker class cannot accept constructor arguments.
  • The worker class will not retain member variables across method calls from the main thread.
  • All methods in the worker class must be asynchronous.
  • All method arguments in the worker class must be worker threads compatible types. More here.
  • It is recommended to design your class methods as pure functions for better predictability.

License

MIT

0.9.7

10 months ago

0.9.6

10 months ago

0.9.4

11 months ago

0.9.3

11 months ago

0.9.2

11 months ago

0.9.1

11 months ago