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

Atomic File Writer

A utility for performing atomic file writes by generating unique temporary filenames, writing content to the temporary file, then renaming it to the target location.

Capabilities

Generates unique temporary filenames for atomic writes

  • When performing an atomic write, the system generates a temporary filename in the same directory as the target file with a .tmp extension @test
  • The generated temporary filename is unique and does not conflict with existing files @test

Supports configurable temporary filename patterns

  • When a custom prefix is provided (e.g., backup-), the temporary filename includes that prefix @test
  • When a custom extension is provided (e.g., .atomic), the temporary filename uses that extension instead of .tmp @test

Handles multiple atomic operations concurrently

  • When multiple atomic write operations are requested simultaneously, each generates a unique temporary filename @test

Implementation

@generates

API

/**
 * Performs an atomic file write by first writing to a temporary file,
 * then renaming it to the target path.
 *
 * @param {string} targetPath - The final path where the file should be written
 * @param {string} content - The content to write to the file
 * @param {Object} options - Optional configuration
 * @param {string} options.prefix - Prefix for the temporary filename (default: 'tmp-')
 * @param {string} options.postfix - Extension for the temporary filename (default: '.tmp')
 * @returns {Promise<string>} The path where the file was written
 */
async function atomicWrite(targetPath, content, options = {}) {
  // IMPLEMENTATION HERE
}

module.exports = { atomicWrite };

Dependencies { .dependencies }

tmp-promise { .dependency }

Provides temporary name generation support.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/npm-tmp-promise

tile.json