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-6/

Task Queue Processing System

A system for processing computational tasks using a background worker pool with convenient method access.

Requirements

Build a task processing system that offloads mathematical computations to background workers. The system should provide a simple interface for calling worker methods without manually managing task execution.

Worker Implementation

Create a worker file that exposes the following computational methods:

  • A method that calculates the factorial of a number (accepts a single number, returns the factorial)
  • A method that checks if a number is prime (accepts a single number, returns true/false)
  • A method that computes the Fibonacci number at a given position (accepts a single number, returns the Fibonacci value)

Main Application

Create a main application that:

  1. Initializes a background worker pool with the worker file
  2. Creates an interface that allows calling worker methods as if they were local functions
  3. Processes multiple tasks using the worker methods:
    • Calculate factorial of 10
    • Check if 17 is prime
    • Calculate the 15th Fibonacci number
  4. Prints the results of all computations
  5. Properly terminates the worker pool after all tasks complete

Test Cases

  • Factorial of 10 equals 3628800 @test
  • 17 is identified as a prime number @test
  • The 15th Fibonacci number equals 610 @test
  • Worker pool terminates successfully after processing all tasks @test

Implementation

@generates

API

/**
 * Main entry point that demonstrates worker proxy usage.
 * Initializes worker pool, processes tasks, and cleans up.
 * @returns {Promise<void>}
 */
async function main() {
  // Implementation here
}

module.exports = { main };

Dependencies { .dependencies }

workerpool { .dependency }

Provides worker pool management and task execution capabilities.

Install with Tessl CLI

npx tessl i tessl/npm-workerpool

tile.json