Skip to content

Instantly share code, notes, and snippets.

@Zodiase

Zodiase/main.js Secret

Created June 1, 2017 18:26
Show Gist options
  • Save Zodiase/3c8b9d9862ec3ac9c486ec75b99f341a to your computer and use it in GitHub Desktop.
Save Zodiase/3c8b9d9862ec3ac9c486ec75b99f341a to your computer and use it in GitHub Desktop.
Testing Hamsters
// Using hamsters.js@4.1.2
var hamsters = require('hamsters.js');
var startOptions = {
maxThreads: 3,
persistence: false,
Worker: require("webworker-threads").Worker,
};
hamsters.init(startOptions);
(function() {
var params = {'array':[0,1,2,3,4,5,6,7,8,9]};
hamsters.run(params, function() {
console.log('params.array', params.array, params.array.length);
var arr = params.array;
arr.forEach(function(item) {
console.log('run');
rtn.data.push((item * 120)/10);
});
}, function(output) {
console.log(output);
return output;
});
})();
{
"name": "test-hamsters",
"version": "1.0.0",
"description": "",
"main": "main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"hamsters.js": "^4.1.2",
"webworker-threads": "^0.7.11"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment