docs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
Build a utility function that manages file sizes in a memory filesystem by implementing truncation operations.
Your task is to create a function resizeFile that takes a filesystem instance, a file path, and a target size, and resizes the file to exactly that size. The function should:
/**
* Resizes a file to the specified target size.
*
* @param {Object} fs - The filesystem instance (metro-memory-fs)
* @param {string} filePath - The path to the file to resize
* @param {number} targetSize - The desired size in bytes
* @returns {number} The new size of the file
* @throws {Error} If the file doesn't exist
*/
function resizeFile(fs, filePath, targetSize) {
// Implementation here
}
module.exports = { resizeFile };Provides in-memory filesystem operations for testing.