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

Temporary File Manager

Build a utility that creates temporary files for processing user-uploaded data with automatic cleanup.

Requirements

Create a module that provides functionality to process user data by:

  1. Creating a temporary file to store the user data
  2. Writing the data to the file
  3. Reading and processing the data from the file
  4. Returning the processed result
  5. Ensuring the temporary file is cleaned up after processing, even if errors occur

The module should export a function processUserData that:

  • Takes a string of user data as input
  • Creates a temporary file with a .txt extension
  • Writes the data to the temporary file
  • Reads back the data and returns it in uppercase
  • Properly cleans up the temporary file afterward
  • Handles errors gracefully

Test Cases

  • Given the input string "hello world", the function returns "HELLO WORLD" @test
  • Given the input string "testing 123", the function returns "TESTING 123" @test
  • The temporary file is removed after successful processing @test
  • The temporary file is removed even when an error occurs during processing @test

Implementation

@generates

API

/**
 * Processes user data by writing it to a temporary file,
 * reading it back, converting to uppercase, and cleaning up.
 *
 * @param {string} data - The user data to process
 * @returns {Promise<string>} The processed data in uppercase
 * @throws {Error} If data processing fails
 */
async function processUserData(data) {
  // IMPLEMENTATION HERE
}

module.exports = {
  processUserData
};

Dependencies { .dependencies }

tmp-promise { .dependency }

Provides temporary file creation and management with Promise support.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-tmp-promise

tile.json