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 @@ -3452,6 +3452,24 @@ Truncates the file. No arguments other than a possible exception are
34523452given to the completion callback . A file descriptor can also be passed as the
34533453first argument . In this case, ` fs.ftruncate()` is called.
34543454
3455+ ` ` ` mjs
3456+ import { truncate } from 'fs';
3457+ // Assuming that 'path/file.txt' is a regular file.
3458+ truncate('path/file.txt', (err) => {
3459+ if (err) throw err;
3460+ console.log('path/file.txt was truncated');
3461+ });
3462+ ` ` `
3463+
3464+ ` ` ` cjs
3465+ const { truncate } = require('fs');
3466+ // Assuming that 'path/file.txt' is a regular file.
3467+ truncate('path/file.txt', (err) => {
3468+ if (err) throw err;
3469+ console.log('path/file.txt was truncated');
3470+ });
3471+ ` ` `
3472+
34553473Passing a file descriptor is deprecated and may result in an error being thrown
34563474in the future.
34573475
You can’t perform that action at this time.
0 commit comments