close
Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

README.md

DEP0081: fs.truncate() using a file descriptor

This recipe transforms the usage of fs.truncate() to fs.ftruncateSync() when a file descriptor is used.

See DEP0081.

Example

- const { truncate, open, close } = require('node:fs');
+ const { ftruncate, open, close } = require('node:fs');

  open('file.txt', 'w', (err, fd) => {
    if (err) throw err;
-   truncate(fd, 10, (err) => {
+   ftruncate(fd, 10, (err) => {
      if (err) throw err;
      close(fd, () => {});
    });
  });