const debug = false
-function taskFunction (data) {
+const taskFunction = data => {
data = data || {}
data.function = data.function || TaskFunctions.jsonIntegerSerialization
const res = executeTaskFunction(data)
const debug = false
-function taskFunction (data) {
+const taskFunction = data => {
data = data || {}
data.function = data.function || TaskFunctions.jsonIntegerSerialization
const res = executeTaskFunction(data)
* @param {*} data The worker data.
* @returns {*} The result.
*/
-module.exports = function functionToBench (data) {
+const functionToBench = data => {
const crypto = require('crypto')
const fs = require('fs')
const TaskTypes = {
throw new Error(`Unknown task type: ${data.taskType}`)
}
}
+
+module.exports = functionToBench
import workerpool from 'workerpool'
import functionToBench from '../../functions/function-to-bench.js'
-function wrapperFunctionToBench (testName, taskType, taskSize) {
+const functionToBenchWrapper = (testName, taskType, taskSize) => {
return functionToBench({
test: testName,
taskType,
}
workerpool.worker({
- functionToBench: wrapperFunctionToBench
+ functionToBench: functionToBenchWrapper
})
* @returns The names of the worker's task functions.
*/
public listTaskFunctions (): string[] {
- return Array.from(this.taskFunctions.keys())
+ return [...this.taskFunctions.keys()]
}
/**
describe('Cluster worker test suite', () => {
let numberOfMessagesSent = 0
- const send = function () {
+ const send = () => {
++numberOfMessagesSent
}
class SpyWorker extends ClusterWorker {
describe('Thread worker test suite', () => {
let numberOfMessagesPosted = 0
- const postMessage = function () {
+ const postMessage = () => {
++numberOfMessagesPosted
}
class SpyWorker extends ThreadWorker {