@@ -3800,128 +3800,6 @@ fsPromises.copyFile('source.txt', 'destination.txt', COPYFILE_EXCL)
38003800 .catch (() => console .log (' The file could not be copied' ));
38013801```
38023802
3803- ### fsPromises.fchmod(filehandle, mode)
3804- <!-- YAML
3805- added: v10.0.0
3806- -->
3807-
3808- * ` filehandle ` {FileHandle}
3809- * ` mode ` {integer}
3810- * Returns: {Promise}
3811-
3812- Asynchronous fchmod(2). The ` Promise ` is resolved with no arguments upon
3813- success.
3814-
3815- ### fsPromises.fchown(filehandle, uid, gid)
3816- <!-- YAML
3817- added: v10.0.0
3818- -->
3819-
3820- * ` filehandle ` {FileHandle}
3821- * ` uid ` {integer}
3822- * ` gid ` {integer}
3823- * Returns: {Promise}
3824-
3825- Changes the ownership of the file represented by ` filehandle ` then resolves
3826- the ` Promise ` with no arguments upon success.
3827-
3828- ### fsPromises.fdatasync(filehandle)
3829- <!-- YAML
3830- added: v10.0.0
3831- -->
3832-
3833- * ` filehandle ` {FileHandle}
3834- * Returns: {Promise}
3835-
3836- Asynchronous fdatasync(2). The ` Promise ` is resolved with no arguments upon
3837- success.
3838-
3839- ### fsPromises.fstat(filehandle)
3840- <!-- YAML
3841- added: v10.0.0
3842- -->
3843-
3844- * ` filehandle ` {FileHandle}
3845- * Returns: {Promise}
3846-
3847- Retrieves the [ ` fs.Stats ` ] [ ] for the given ` filehandle ` .
3848-
3849- ### fsPromises.fsync(filehandle)
3850- <!-- YAML
3851- added: v10.0.0
3852- -->
3853-
3854- * ` filehandle ` {FileHandle}
3855- * Returns: {Promise}
3856-
3857- Asynchronous fsync(2). The ` Promise ` is resolved with no arguments upon
3858- success.
3859-
3860- ### fsPromises.ftruncate(filehandle[ , len] )
3861- <!-- YAML
3862- added: v10.0.0
3863- -->
3864-
3865- * ` filehandle ` {FileHandle}
3866- * ` len ` {integer} ** Default:** ` 0 `
3867- * Returns: {Promise}
3868-
3869- Truncates the file represented by ` filehandle ` then resolves the ` Promise `
3870- with no arguments upon success.
3871-
3872- If the file referred to by the ` FileHandle ` was larger than ` len ` bytes, only
3873- the first ` len ` bytes will be retained in the file.
3874-
3875- For example, the following program retains only the first four bytes of the
3876- file:
3877-
3878- ``` js
3879- console .log (fs .readFileSync (' temp.txt' , ' utf8' ));
3880- // Prints: Node.js
3881-
3882- async function doTruncate () {
3883- const fd = await fsPromises .open (' temp.txt' , ' r+' );
3884- await fsPromises .ftruncate (fd, 4 );
3885- console .log (fs .readFileSync (' temp.txt' , ' utf8' )); // Prints: Node
3886- }
3887-
3888- doTruncate ().catch (console .error );
3889- ```
3890-
3891- If the file previously was shorter than ` len ` bytes, it is extended, and the
3892- extended part is filled with null bytes (` '\0' ` ). For example,
3893-
3894- ``` js
3895- console .log (fs .readFileSync (' temp.txt' , ' utf8' ));
3896- // Prints: Node.js
3897-
3898- async function doTruncate () {
3899- const fd = await fsPromises .open (' temp.txt' , ' r+' );
3900- await fsPromises .ftruncate (fd, 10 );
3901- console .log (fs .readFileSync (' temp.txt' , ' utf8' )); // Prints Node.js\0\0\0
3902- }
3903-
3904- doTruncate ().catch (console .error );
3905- ```
3906-
3907- The last three bytes are null bytes (` '\0' ` ), to compensate the over-truncation.
3908-
3909- ### fsPromises.futimes(filehandle, atime, mtime)
3910- <!-- YAML
3911- added: v10.0.0
3912- -->
3913-
3914- * ` filehandle ` {FileHandle}
3915- * ` atime ` {number|string|Date}
3916- * ` mtime ` {number|string|Date}
3917- * Returns: {Promise}
3918-
3919- Change the file system timestamps of the object referenced by the supplied
3920- ` FileHandle ` then resolves the ` Promise ` with no arguments upon success.
3921-
3922- This function does not work on AIX versions before 7.1, it will resolve the
3923- ` Promise ` with an error using code ` UV_ENOSYS ` .
3924-
39253803### fsPromises.lchmod(path, mode)
39263804<!-- YAML
39273805deprecated: v10.0.0
@@ -4030,35 +3908,6 @@ by [Naming Files, Paths, and Namespaces][]. Under NTFS, if the filename contains
40303908a colon, Node.js will open a file system stream, as described by
40313909[ this MSDN page] [ MSDN-Using-Streams ] .
40323910
4033- ### fsPromises.read(filehandle, buffer, offset, length, position)
4034- <!-- YAML
4035- added: v10.0.0
4036- -->
4037-
4038- * ` filehandle ` {FileHandle}
4039- * ` buffer ` {Buffer|Uint8Array}
4040- * ` offset ` {integer}
4041- * ` length ` {integer}
4042- * ` position ` {integer}
4043- * Returns: {Promise}
4044-
4045- Read data from the file specified by ` filehandle ` .
4046-
4047- ` buffer ` is the buffer that the data will be written to.
4048-
4049- ` offset ` is the offset in the buffer to start writing at.
4050-
4051- ` length ` is an integer specifying the number of bytes to read.
4052-
4053- ` position ` is an argument specifying where to begin reading from in the file.
4054- If ` position ` is ` null ` , data will be read from the current file position,
4055- and the file position will be updated.
4056- If ` position ` is an integer, the file position will remain unchanged.
4057-
4058- Following successful read, the ` Promise ` is resolved with an object with a
4059- ` bytesRead ` property specifying the number of bytes read, and a ` buffer `
4060- property that is a reference to the passed in ` buffer ` argument.
4061-
40623911### fsPromises.readdir(path[ , options] )
40633912<!-- YAML
40643913added: v10.0.0
@@ -4243,39 +4092,6 @@ The `atime` and `mtime` arguments follow these rules:
42434092- If the value can not be converted to a number, or is ` NaN ` , ` Infinity ` or
42444093 ` -Infinity ` , an ` Error ` will be thrown.
42454094
4246- ### fsPromises.write(filehandle, buffer[ , offset[ , length[ , position]]] )
4247- <!-- YAML
4248- added: v10.0.0
4249- -->
4250-
4251- * ` filehandle ` {FileHandle}
4252- * ` buffer ` {Buffer|Uint8Array}
4253- * ` offset ` {integer}
4254- * ` length ` {integer}
4255- * ` position ` {integer}
4256- * Returns: {Promise}
4257-
4258- Write ` buffer ` to the file specified by ` filehandle ` .
4259-
4260- The ` Promise ` is resolved with an object containing a ` bytesWritten ` property
4261- identifying the number of bytes written, and a ` buffer ` property containing
4262- a reference to the ` buffer ` written.
4263-
4264- ` offset ` determines the part of the buffer to be written, and ` length ` is
4265- an integer specifying the number of bytes to write.
4266-
4267- ` position ` refers to the offset from the beginning of the file where this data
4268- should be written. If ` typeof position !== 'number' ` , the data will be written
4269- at the current position. See pwrite(2).
4270-
4271- It is unsafe to use ` fsPromises.write() ` multiple times on the same file
4272- without waiting for the ` Promise ` to be resolved (or rejected). For this
4273- scenario, ` fs.createWriteStream ` is strongly recommended.
4274-
4275- On Linux, positional writes do not work when the file is opened in append mode.
4276- The kernel ignores the position argument and always appends the data to
4277- the end of the file.
4278-
42794095### fsPromises.writeFile(file, data[ , options] )
42804096<!-- YAML
42814097added: v10.0.0
0 commit comments