CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-workerpool

Offload tasks to a pool of workers on node.js and in the browser

Overall
score

95%

Overview
Eval results
Files

task.mdevals/scenario-8/

Data Processor

Build a data processing utility that offloads CPU-intensive operations to worker threads. The utility should handle multiple types of data transformations efficiently using a worker pool.

Capabilities

Process numeric data

  • Given an array [1, 2, 3, 4, 5], the processNumbers function returns [2, 4, 6, 8, 10] (each number doubled) @test
  • Given an empty array [], the processNumbers function returns [] @test

Process text data

  • Given the string "hello world", the processText function returns "HELLO WORLD" (uppercase transformation) @test
  • Given an empty string "", the processText function returns "" @test

Handle computation errors

  • When an error occurs during numeric processing, the promise rejects with the error @test

Clean up resources

  • After processing is complete, resources are properly released @test

Implementation

@generates

API

/**
 * Processes an array of numbers by doubling each value.
 * Offloads the computation to worker threads.
 *
 * @param {number[]} numbers - Array of numbers to process
 * @returns {Promise<number[]>} Promise resolving to array of doubled numbers
 */
async function processNumbers(numbers) {
  // IMPLEMENTATION HERE
}

/**
 * Processes a text string by converting it to uppercase.
 * Offloads the computation to worker threads.
 *
 * @param {string} text - Text to process
 * @returns {Promise<string>} Promise resolving to uppercase text
 */
async function processText(text) {
  // IMPLEMENTATION HERE
}

/**
 * Releases all worker pool resources.
 *
 * @returns {Promise<void>} Promise that resolves when cleanup is complete
 */
async function cleanup() {
  // IMPLEMENTATION HERE
}

module.exports = {
  processNumbers,
  processText,
  cleanup
};

Dependencies { .dependencies }

workerpool { .dependency }

Provides worker pool management for offloading computational tasks.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-workerpool

tile.json