The tmp package with promises support and disposers.
93
Build a file processing utility that handles temporary files with robust error handling and recovery mechanisms.
@generates
/**
* 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
};Provides temporary file creation and management with promise-based API.
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