MCPcopy Index your code
hub / github.com/nodejs/node / truncate

Method truncate

lib/internal/vfs/file_system.js:904–915  ·  view source on GitHub ↗

* Truncates a file asynchronously. * @param {string} filePath The file path * @param {number|Function} [len] The new length or callback * @param {Function} [callback] Callback (err)

(filePath, len, callback)

Source from the content-addressed store, hash-verified

902 * @param {Function} [callback] Callback (err)
903 */
904 truncate(filePath, len, callback) {
905 if (typeof len === 'function') {
906 callback = len;
907 len = 0;
908 }
909 try {
910 this.truncateSync(filePath, len);
911 process.nextTick(callback, null);
912 } catch (err) {
913 process.nextTick(callback, err);
914 }
915 }
916
917 /**
918 * Truncates a file descriptor asynchronously.

Callers

nothing calls this directly

Calls 3

truncateSyncMethod · 0.95
openMethod · 0.65
closeMethod · 0.65

Tested by

no test coverage detected