Namespace: fsn/fs

fsn/fs

Properties:
Name Type Description
constants Object Identical to fs.constants.
Properties
Name Type Description
F_OK number Flag indicating that the file is visible to the calling process.
R_OK number Flag indicating that the file can be read by the calling process.
W_OK number Flag indicating that the file can be written by the calling process.
X_OK number Flag indicating that the file can be executed by the calling process.
O_RDONLY number Flag indicating to open a file for read-only access.
O_WRONLY number Flag indicating to open a file for write-only access.
O_RDWR number Flag indicating to open a file for read-write access.
O_CREAT number Flag indicating to create the file if it does not already exist.
O_EXCL number Flag indicating that opening a file should fail if the O_CREAT flag is set and the file already exists.
O_NOCTTY number Flag indicating that if path identifies a terminal device, opening the path shall not cause that terminal to become the controlling terminal for the process (if the process does not already have one).
O_TRUNC number Flag indicating that if the file exists and is a regular file, and the file is opened successfully for write access, its length shall be truncated to zero.
O_APPEND number Flag indicating that data will be appended to the end of the file.
O_DIRECTORY number Flag indicating that the open should fail if the path is not a directory.
O_NOATIME number Flag indicating reading accesses to the file system will no longer result in an update to the atime information associated with the file. This flag is available on Linux operating systems only.
O_NOFOLLOW number Flag indicating that the open should fail if the path is a symbolic link.
O_SYNC number Flag indicating that the file is opened for synchronous I/O.
O_SYMLINK number Flag indicating to open the symbolic link itself rather than the resource it is pointing to.
O_DIRECT number When set, an attempt will be made to minimize caching effects of file I/O.
O_NONBLOCK number Flag indicating to open the file in nonblocking mode when possible.
S_IFMT number Bit mask used to extract the file type code.
S_IFREG number File type constant for a regular file.
S_IFDIR number File type constant for a directory.
S_IFCHR number File type constant for a character-oriented device file.
S_IFBLK number File type constant for a block-oriented device file.
S_IFIFO number File type constant for a FIFO/pipe.
S_IFLNK number File type constant for a symbolic link.
S_IFSOCK number File type constant for a socket.
S_IRWXU number File mode indicating readable, writable and executable by owner.
S_IRUSR number File mode indicating readable by owner.
S_IWUSR number File mode indicating writable by owner.
S_IXUSR number File mode indicating executable by owner.
S_IRWXG number File mode indicating readable, writable and executable by group.
S_IRGRP number File mode indicating readable by group.
S_IWGRP number File mode indicating writable by group.
S_IXGRP number File mode indicating executable by group.
S_IRWXO number File mode indicating readable, writable and executable by others.
S_IROTH number File mode indicating readable by others.
S_IWOTH number File mode indicating writable by others.
S_IXOTH number File mode indicating executable by others.
Source:
fs.js#L21

Methods


<static> access(path [, mode])

Identical to fs.access but returns a promise instead.
Parameters:
Name Type Argument Description
path string | Buffer | URL The path to be checked
mode number <optional>
The accessibility checks to be performed
Source:
fs.js#L206
Returns:
Type
Promise.<void>

<static> appendFile(file, data [, options])

Identical to fs.appendFile but returns a promise instead.
Parameters:
Name Type Argument Description
file string | Buffer | number Filename or file descriptor
data string | Buffer The data to be written
options AppendFileOptions | string <optional>
Options for the append, or the encoding.
Source:
fs.js#L223
Returns:
Type
Promise.<void>

<static> chmod(path, mode)

Identical to fs.chmod but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer | URL File or directory path
mode number The chmod to be applied
Source:
fs.js#L233
Returns:
Type
Promise.<void>

<static> chown(path, uid, gid)

Identical to fs.chown but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer | URL File or directory path
uid number The new owner id
gid number The new group id
Source:
fs.js#L242
Returns:
Type
Promise.<void>

<static> close(fd)

Identical to fs.close but returns a promise instead.
Parameters:
Name Type Description
fd number The file descriptor
Source:
fs.js#L252
Returns:
Type
Promise.<void>

<static> copyFile(src, dest [, flags])

Identical to fs.copyFile but returns a promise instead.
Parameters:
Name Type Argument Default Description
src string | Buffer | URL File path to copy
dest string | Buffer | URL Destination to copy to
flags number <optional>
0 modifiers for copy operation.
Source:
fs.js#L65
Returns:
Type
Promise.<void>

<static> createReadStream(path [, options])

Identical to fs.createReadStream.
Parameters:
Name Type Argument Description
path string | Buffer | URL File or directory path
options ReadStreamOptions | string <optional>
The stream options or the encoding
Source:
fs.js#L272
Returns:
Type
ReadStream

<static> createWriteStream(path [, options])

Identical to fs.createWriteStream.
Parameters:
Name Type Argument Description
path string | Buffer | URL File or directory path
options WriteStreamOptions | string <optional>
The stream options or the encoding
Source:
fs.js#L292
Returns:
Type
WriteStream

<static> exists(path)

Identical to fs.exists but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer | URL The file or directory path
Deprecated:
Source:
fs.js#L301
Returns:
Type
Promise.<boolean>

<static> fchmod(fd, mode)

Identical to fs.fchmod but returns a promise instead.
Parameters:
Name Type Description
fd number The file descriptor id
mode number The chmod to be applied
Source:
fs.js#L310
Returns:
Type
Promise.<void>

<static> fchown(fd, uid, gid)

Identical to fs.fchown but returns a promise instead.
Parameters:
Name Type Description
fd number The file descriptor id
uid number The new owner id
gid number The new group id
Source:
fs.js#L319
Returns:
Type
Promise.<void>

<static> fdatasync(fd)

Identical to fs.fdatasync but returns a promise instead.
Parameters:
Name Type Description
fd number The file descriptor id
Source:
fs.js#L329
Returns:
Type
Promise.<void>

<static> fstat(fd)

Identical to fs.fstat but returns a promise instead.
Parameters:
Name Type Description
fd number The file descriptor id
Source:
fs.js#L337
Returns:
Type
Promise.<Stats>

<static> fsync(fd)

Identical to fs.fsync but returns a promise instead.
Parameters:
Name Type Description
fd number The file descriptor id
Source:
fs.js#L345
Returns:
Type
Promise.<void>

<static> ftruncate(fd, len)

Identical to fs.ftruncate but returns a promise instead.
Parameters:
Name Type Description
fd number The file descriptor id
len number The length in bytes to truncate to
Source:
fs.js#L353
Returns:
Type
Promise.<void>

<static> futimes(fd, atime, mtime)

Identical to fs.futimes but returns a promise instead.
Parameters:
Name Type Description
fd number The file descriptor id
atime number The atime
mtime number The mtime
Source:
fs.js#L362
Returns:
Type
Promise.<void>

<static> lchmod(path, mode)

Identical to fs.lchmod but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer The file path
mode number The chmod
Source:
fs.js#L372
Returns:
Type
Promise.<void>

<static> lchown(path, uid, gid)

Identical to fs.lchown but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer The file path
uid number The new owner id
gid number The new group id
Source:
fs.js#L381
Returns:
Type
Promise.<void>

Identical to fs.link but returns a promise instead.
Parameters:
Name Type Description
existingPath string | Buffer | URL The existing file path
newPath string | Buffer | URL The new file path
Source:
fs.js#L391
Returns:
Type
Promise.<void>

<static> lstat(path)

Identical to fs.lstat but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer | URL The file path
Source:
fs.js#L400
Returns:
Type
Promise.<Stats>

<static> mkdir(path [, mode])

Identical to fs.mkdir but returns a promise instead.
Parameters:
Name Type Argument Default Description
path string | Buffer | URL The file path
mode number <optional>
0o777 The chmod
Source:
fs.js#L408
Returns:
Type
Promise.<void>

<static> mkdtemp(prefix [, options])

Identical to fs.mkdtemp but returns a promise instead.
Parameters:
Name Type Argument Default Description
prefix string The prefix of the temporary folder to create
options EncodingOptions | string <optional>
'utf8' The temporary directory options, or encoding
Source:
fs.js#L423
Returns:
The folder path
Type
Promise.<string>

<static> open(path, flags [, mode])

Identical to fs.open but returns a promise instead.
Parameters:
Name Type Argument Default Description
path string | Buffer | URL The file path
flags string | number The flags for opening the file.
mode number <optional>
0o666 The chmod
Source:
fs.js#L432
Returns:
The file descriptor
Type
Promise.<integer>

<static> read(fd, buffer, offset, length, position)

Identical to fs.read but returns a promise instead.
Parameters:
Name Type Description
fd number The file descriptor
buffer Buffer | Uint8Array The buffer that he data will be written to.
offset number The offset in the buffer to start writing at
length number The the number of bytes to read
position number The the postilion to begin reading from the file
Source:
fs.js#L449
Returns:
Type
Promise.<ReadObject>

<static> readdir(path [, options])

Identical to fs.readdir but returns a promise instead.
Parameters:
Name Type Argument Default Description
path string | Buffer | URL The file path
options EncodingOptions | string <optional>
'utf8' The encoding options
Source:
fs.js#L461
Returns:
The files and directories
Type
Promise.<(Array.<string>|Buffer)>

<static> readFile(path [, options])

Identical to fs.readFile but returns a promise instead.
Parameters:
Name Type Argument Default Description
path string | Buffer | URL | integer The file path or file descriptor
options EncodingOptions | string <optional>
{encoding: null, flag: 'r'} The encoding options
Source:
fs.js#L470
Returns:
The file contents
Type
Promise.<(string|Buffer)>

Identical to fs.readlink but returns a promise instead.
Parameters:
Name Type Argument Default Description
path string | Buffer | URL The file path
options EncodingOptions | string <optional>
'utf8' The encoding options
Source:
fs.js#L479
Returns:
The linkString
Type
Promise.<(string|Buffer)>

<static> realpath(path [, options])

Identical to fs.realpath but returns a promise instead.
Parameters:
Name Type Argument Default Description
path string | Buffer | URL The file path
options EncodingOptions | string <optional>
'utf8' The encoding options
Source:
fs.js#L488
Returns:
The resolvedPath
Type
Promise.<(string|Buffer)>

<static> rename(oldPath, newPath)

Identical to fs.rename but returns a promise instead.
Parameters:
Name Type Description
oldPath string | Buffer | URL The old file path
newPath string | Buffer | URL The new file path
Source:
fs.js#L497
Returns:
Type
Promise.<void>

<static> rmdir(path)

Identical to fs.rmdir but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer | URL The directory path
Source:
fs.js#L506
Returns:
Type
Promise.<void>

<static> stat(path)

Identical to fs.stat but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer | URL The file path
Source:
fs.js#L514
Returns:
Type
Promise.<Stats>

Identical to fs.symlink but returns a promise instead.
Parameters:
Name Type Description
target string | Buffer | URL The path to link from
path string | Buffer | URL The path to link to
type string `dir`, `file`, or `junction` windows only
Source:
fs.js#L522
Returns:
Type
Promise.<void>

<static> truncate(path, len)

Identical to fs.truncate but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer The file path
len number The number of bytes to truncate to
Source:
fs.js#L532
Returns:
Type
Promise.<void>

Identical to fs.unlink but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer | URL The file path
Source:
fs.js#L541
Returns:
Type
Promise.<void>

<static> unwatchFile(path [, listener])

Identical to fs.unwatchFile.
Parameters:
Name Type Argument Description
path string | Buffer The file path
listener function <optional>
The listener function
Source:
fs.js#L549
Returns:
Type
Promise.<void>

<static> utimes(path, atime, mtime)

Identical to fs.utimes but returns a promise instead.
Parameters:
Name Type Description
path string | Buffer | URL The file path
atime number The atime
mtime number The mtime
Source:
fs.js#L558
Returns:
Type
Promise.<void>

<static> watch(path [, options], listener)

Identical to fs.watch.
Parameters:
Name Type Argument Description
path string | Buffer The file path
options WatchOptions <optional>
The watch options
listener function The listener function
Source:
fs.js#L576
Returns:
Type
FSWatcher

<static> watchFile(path [, options], listener)

Identical to fs.watchFile.
Parameters:
Name Type Argument Description
path string | Buffer | URL The file path
options WatchOptions <optional>
The watch options
listener function The listener function
Source:
fs.js#L586
Returns:
Type
FSWatcher

<static> write(fd, buffer [, offset] [, length] [, position])

Identical to fs.write but returns a promise instead.
Parameters:
Name Type Argument Description
fd number The file descriptor id
buffer Buffer | Uint8Array The buffer to write to file
offset number <optional>
The offset in the buffer to start reading at
length number <optional>
The the number of bytes to write
position number <optional>
The the position to begin writing to the file
Source:
fs.js#L596
Returns:
Type
Promise.<void>

<static> writeFile(file, data [, options])

Identical to fs.writeFile but returns a promise instead.
Parameters:
Name Type Argument Description
file string | Buffer | integer The filename or file descriptor
data string | Buffer | Uint8Array The data to write to file
options WriteOptions <optional>
The write options
Source:
fs.js#L616
Returns:
Type
Promise.<void>

Type Definitions


AppendFileOptions

Properties:
Name Type Argument Default Description
encoding string <optional>
'utf8' The file encoding
mode number <optional>
0o666 The chmod
flag string <optional>
'a' The flag
Source:
fs.js#L215

EncodingOptions

Type:
  • Object
Properties:
Name Type Argument Default Description
encoding string <optional>
'utf8' The encoding for the temporary directory
Source:
fs.js#L417

ReadObject

Type:
  • Object
Properties:
Name Type Description
bytesRead number The number of bytes read
buffer Buffer | Uint8Array The buffer containing the data read
Source:
fs.js#L442

ReadStreamOptions

Properties:
Name Type Argument Default Description
flags string <optional>
'r' The flags to use
defaultEncoding string <optional>
null The encoding to use
fd number <optional>
null The file descriptor
mode number <optional>
0o666 The chmod to use
autoClose boolean <optional>
true If the stream should auto close
start number <optional>
The starting spot
end number <optional>
The ending spot
Source:
fs.js#L260

WatchOptions

Properties:
Name Type Argument Default Description
persistent boolean <optional>
true Indicates whether the process should continue to run as long as files are being watched.
recursive boolean <optional>
false Indicates whether all subdirectories should be watched, or only the current directory.
encoding string <optional>
'utf8' Specifies the character encoding to be used for the filename passed to the listener.
Source:
fs.js#L568

WriteOptions

Properties:
Name Type Argument Default Description
encoding string <optional>
'utf8' The file encoding
mode number <optional>
0o666 The chmod
flag string <optional>
'w' The flag
Source:
fs.js#L608

WriteStreamOptions

Properties:
Name Type Argument Default Description
flags string <optional>
'w' The flags to use
defaultEncoding string <optional>
'utf8' The encoding to use
fd number <optional>
null The file descriptor
mode number <optional>
0o666 The chmod to use
autoClose boolean <optional>
true If the stream should auto close
start number <optional>
The starting spot
Source:
fs.js#L281