Use npm to install hamsters.js npm install --save hamsters.js
Import the library into your app.js file like below
<!-- Add Hamsters.js -->
let hamsters = require('hamsters.js');
If you are using Node.js version 9 or lower it does not ship with a native Worker Thread implementation out of the box to resolve this you will need to make use of a third party worker implementation, there are several of these on npm and github, the library should work with any implementation that adheres to the worker specifications.
<!-- Add Third Party Worker Library -->
const Worker = require('ThirdParyWorkerLibrary');
If you are using Node.js version 10 or higher it does come with a Worker Thread implementation out of the box you will need to include the Worker object as defined below. You will also need to pass --experimental in your package.json npm start to make use of the built in Worker Thread implementation.
If you do not include the Worker object the library will therefore make use of the legacy fallback mode allowing you to still write your logic and validate it works with the library but will not provide the performance benefits of multiple threads.
Once you've installed a worker implementation simply pass the Worker object as an argument in the library initialization start options. If you are using Node's native worker implementation, also pass parentPort as a start option.
<!-- Initialize Hamsters.js Node Version 9.0 and lower -->
<!-- Initialize Hamsters.js Node Version 10 and higher -->
Once you've downloaded and added the library to your project you should have a variable named hamsters available, this variable is the core of the library. Do not create any globally scoped variables with the same name or you will risk causing compatibility issues. Now that you've successfully added the library to your project, continue reading to begin using the library.