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

Temporary File Processor with Error Recovery

Build a file processing utility that handles temporary files with robust error handling and recovery mechanisms.

Capabilities

Handles invalid directory paths

  • When the parent directory doesn't exist, the error is caught and a helpful message is logged @test
  • When the parent directory path is invalid, the operation fails gracefully without crashing @test

Handles permission errors

  • When lacking write permissions, the error is caught and handled appropriately @test
  • When permission errors occur during cleanup, they are caught and reported @test

Recovers from file creation failures

  • When temp file creation fails, the error is caught and a fallback approach is used @test

Ensures cleanup in error scenarios

  • When an error occurs during file processing, cleanup still executes @test
  • When processing throws an exception, temporary resources are properly released @test

Implementation

@generates

API

/**
 * Processes data by writing it to a temporary file and performing operations on it.
 * Handles errors gracefully and ensures cleanup in all scenarios.
 *
 * @param {string} data - The data to process
 * @param {Object} options - Processing options
 * @param {string} [options.dir] - Directory for temporary file (may be invalid)
 * @param {Function} [options.onError] - Error handler callback
 * @returns {Promise<Object>} Result object with success status and message
 */
async function processWithTempFile(data, options = {}) {
  // Implementation here
}

/**
 * Attempts file creation with fallback strategies when errors occur.
 * Tries multiple approaches to ensure robustness.
 *
 * @param {Object} options - Creation options
 * @returns {Promise<Object>} File info with path and cleanup function
 */
async function createTempFileWithRetry(options = {}) {
  // Implementation here
}

module.exports = {
  processWithTempFile,
  createTempFileWithRetry
};

Dependencies { .dependencies }

tmp-promise { .dependency }

Provides temporary file creation and management with promise-based API.

Install with Tessl CLI

npx tessl i tessl/npm-tmp-promise

tile.json