CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-tmp-promise

The tmp package with promises support and disposers.

93

1.78x
Overview
Eval results
Files

task.mdevals/scenario-2/

Text File Processor

Build a text file processor that processes multiple text contents by writing them to temporary files, applying transformations, and collecting results. The processor should use a temporary workspace with automatic cleanup.

Requirements

The processor should:

  • Accept an array of text contents and corresponding processing functions
  • Create a temporary directory for the workspace
  • Write each text content to a separate file in the temporary directory
  • Read back each file and apply the specified processing function
  • Collect all processed results
  • Automatically clean up the temporary directory when done, even if errors occur

The implementation must guarantee cleanup in all scenarios, including exceptions during processing.

Interface

interface TextTask {
  content: string;
  processor: (text: string) => string;
}

interface ProcessingResult {
  success: boolean;
  output?: string;
  error?: string;
}

/**
 * Processes multiple text contents in a temporary workspace with automatic cleanup.
 *
 * @param tasks - Array of text tasks to process
 * @returns Promise resolving to array of processing results
 */
export async function processTexts(tasks: TextTask[]): Promise<ProcessingResult[]>;

@generates

Test Cases

  • Given a single task with content "hello world" and an uppercase processor, the result should indicate success with output "HELLO WORLD" @test

  • Given two tasks with different processors (uppercase and reverse), both results should indicate success with their respective processed outputs @test

  • Given three tasks where the second processor throws an error, the first and third should succeed, the second should have success=false with an error message @test

Dependencies { .dependencies }

tmp-promise { .dependency }

Provides temporary file and directory management with automatic cleanup support.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-tmp-promise

tile.json