File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -3502,6 +3502,24 @@ Truncates the file. No arguments other than a possible exception are
35023502given to the completion callback . A file descriptor can also be passed as the
35033503first argument . In this case, ` fs.ftruncate()` is called.
35043504
3505+ ` ` ` mjs
3506+ import { truncate } from 'fs';
3507+ // Assuming that 'path/file.txt' is a regular file.
3508+ truncate('path/file.txt', (err) => {
3509+ if (err) throw err;
3510+ console.log('path/file.txt was truncated');
3511+ });
3512+ ` ` `
3513+
3514+ ` ` ` cjs
3515+ const { truncate } = require('fs');
3516+ // Assuming that 'path/file.txt' is a regular file.
3517+ truncate('path/file.txt', (err) => {
3518+ if (err) throw err;
3519+ console.log('path/file.txt was truncated');
3520+ });
3521+ ` ` `
3522+
35053523Passing a file descriptor is deprecated and may result in an error being thrown
35063524in the future.
35073525
You can’t perform that action at this time.
0 commit comments