The tmp package with promises support and disposers.
93
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.
.tmp extension @testbackup-), the temporary filename includes that prefix @test.atomic), the temporary filename uses that extension instead of .tmp @test@generates
/**
* 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 };Provides temporary name generation support.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-tmp-promisedocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10