7865 lines
398 KiB
JSON
7865 lines
398 KiB
JSON
{
|
||
"type": "module",
|
||
"source": "doc/api/fs.md",
|
||
"modules": [
|
||
{
|
||
"textRaw": "File System",
|
||
"name": "fs",
|
||
"introduced_in": "v0.10.0",
|
||
"stability": 2,
|
||
"stabilityText": "Stable",
|
||
"desc": "<p>The <code>fs</code> module provides an API for interacting with the file system in a\nmanner closely modeled around standard POSIX functions.</p>\n<p>To use this module:</p>\n<pre><code class=\"language-js\">const fs = require('fs');\n</code></pre>\n<p>All file system operations have synchronous and asynchronous forms.</p>\n<p>The asynchronous form always takes a completion callback as its last argument.\nThe arguments passed to the completion callback depend on the method, but the\nfirst argument is always reserved for an exception. If the operation was\ncompleted successfully, then the first argument will be <code>null</code> or <code>undefined</code>.</p>\n<pre><code class=\"language-js\">const fs = require('fs');\n\nfs.unlink('/tmp/hello', (err) => {\n if (err) throw err;\n console.log('successfully deleted /tmp/hello');\n});\n</code></pre>\n<p>Exceptions that occur using synchronous operations are thrown immediately and\nmay be handled using <code>try…catch</code>, or may be allowed to bubble up.</p>\n<pre><code class=\"language-js\">const fs = require('fs');\n\ntry {\n fs.unlinkSync('/tmp/hello');\n console.log('successfully deleted /tmp/hello');\n} catch (err) {\n // handle the error\n}\n</code></pre>\n<p>There is no guaranteed ordering when using asynchronous methods. So the\nfollowing is prone to error because the <code>fs.stat()</code> operation may complete\nbefore the <code>fs.rename()</code> operation:</p>\n<pre><code class=\"language-js\">fs.rename('/tmp/hello', '/tmp/world', (err) => {\n if (err) throw err;\n console.log('renamed complete');\n});\nfs.stat('/tmp/world', (err, stats) => {\n if (err) throw err;\n console.log(`stats: ${JSON.stringify(stats)}`);\n});\n</code></pre>\n<p>To correctly order the operations, move the <code>fs.stat()</code> call into the callback\nof the <code>fs.rename()</code> operation:</p>\n<pre><code class=\"language-js\">fs.rename('/tmp/hello', '/tmp/world', (err) => {\n if (err) throw err;\n fs.stat('/tmp/world', (err, stats) => {\n if (err) throw err;\n console.log(`stats: ${JSON.stringify(stats)}`);\n });\n});\n</code></pre>\n<p>In busy processes, use the asynchronous versions of these calls. The synchronous\nversions will block the entire process until they complete, halting all\nconnections.</p>\n<p>While it is not recommended, most fs functions allow the callback argument to\nbe omitted, in which case a default callback is used that rethrows errors. To\nget a trace to the original call site, set the <code>NODE_DEBUG</code> environment\nvariable:</p>\n<p>Omitting the callback function on asynchronous fs functions is deprecated and\nmay result in an error being thrown in the future.</p>\n<pre><code class=\"language-console\">$ cat script.js\nfunction bad() {\n require('fs').readFile('/');\n}\nbad();\n\n$ env NODE_DEBUG=fs node script.js\nfs.js:88\n throw backtrace;\n ^\nError: EISDIR: illegal operation on a directory, read\n <stack trace.>\n</code></pre>",
|
||
"modules": [
|
||
{
|
||
"textRaw": "File paths",
|
||
"name": "file_paths",
|
||
"desc": "<p>Most <code>fs</code> operations accept filepaths that may be specified in the form of\na string, a <a href=\"buffer.html#buffer_buffer\"><code>Buffer</code></a>, or a <a href=\"url.html#url_the_whatwg_url_api\"><code>URL</code></a> object using the <code>file:</code> protocol.</p>\n<p>String form paths are interpreted as UTF-8 character sequences identifying\nthe absolute or relative filename. Relative paths will be resolved relative\nto the current working directory as specified by <code>process.cwd()</code>.</p>\n<p>Example using an absolute path on POSIX:</p>\n<pre><code class=\"language-js\">const fs = require('fs');\n\nfs.open('/open/some/file.txt', 'r', (err, fd) => {\n if (err) throw err;\n fs.close(fd, (err) => {\n if (err) throw err;\n });\n});\n</code></pre>\n<p>Example using a relative path on POSIX (relative to <code>process.cwd()</code>):</p>\n<pre><code class=\"language-js\">fs.open('file.txt', 'r', (err, fd) => {\n if (err) throw err;\n fs.close(fd, (err) => {\n if (err) throw err;\n });\n});\n</code></pre>\n<p>Paths specified using a <a href=\"buffer.html#buffer_buffer\"><code>Buffer</code></a> are useful primarily on certain POSIX\noperating systems that treat file paths as opaque byte sequences. On such\nsystems, it is possible for a single file path to contain sub-sequences that\nuse multiple character encodings. As with string paths, <code>Buffer</code> paths may\nbe relative or absolute:</p>\n<p>Example using an absolute path on POSIX:</p>\n<pre><code class=\"language-js\">fs.open(Buffer.from('/open/some/file.txt'), 'r', (err, fd) => {\n if (err) throw err;\n fs.close(fd, (err) => {\n if (err) throw err;\n });\n});\n</code></pre>\n<p>On Windows, Node.js follows the concept of per-drive working directory. This\nbehavior can be observed when using a drive path without a backslash. For\nexample <code>fs.readdirSync('C:\\\\')</code> can potentially return a different result than\n<code>fs.readdirSync('C:')</code>. For more information, see\n<a href=\"https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file#fully-qualified-vs-relative-paths\">this MSDN page</a>.</p>",
|
||
"modules": [
|
||
{
|
||
"textRaw": "URL object support",
|
||
"name": "url_object_support",
|
||
"meta": {
|
||
"added": [
|
||
"v7.6.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>For most <code>fs</code> module functions, the <code>path</code> or <code>filename</code> argument may be passed\nas a WHATWG <a href=\"url.html#url_the_whatwg_url_api\"><code>URL</code></a> object. Only <a href=\"url.html#url_the_whatwg_url_api\"><code>URL</code></a> objects using the <code>file:</code> protocol\nare supported.</p>\n<pre><code class=\"language-js\">const fs = require('fs');\nconst fileUrl = new URL('file:///tmp/hello');\n\nfs.readFileSync(fileUrl);\n</code></pre>\n<p><code>file:</code> URLs are always absolute paths.</p>\n<p>Using WHATWG <a href=\"url.html#url_the_whatwg_url_api\"><code>URL</code></a> objects might introduce platform-specific behaviors.</p>\n<p>On Windows, <code>file:</code> URLs with a host name convert to UNC paths, while <code>file:</code>\nURLs with drive letters convert to local absolute paths. <code>file:</code> URLs without a\nhost name nor a drive letter will result in a throw:</p>\n<pre><code class=\"language-js\">// On Windows :\n\n// - WHATWG file URLs with hostname convert to UNC path\n// file://hostname/p/a/t/h/file => \\\\hostname\\p\\a\\t\\h\\file\nfs.readFileSync(new URL('file://hostname/p/a/t/h/file'));\n\n// - WHATWG file URLs with drive letters convert to absolute path\n// file:///C:/tmp/hello => C:\\tmp\\hello\nfs.readFileSync(new URL('file:///C:/tmp/hello'));\n\n// - WHATWG file URLs without hostname must have a drive letters\nfs.readFileSync(new URL('file:///notdriveletter/p/a/t/h/file'));\nfs.readFileSync(new URL('file:///c/p/a/t/h/file'));\n// TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must be absolute\n</code></pre>\n<p><code>file:</code> URLs with drive letters must use <code>:</code> as a separator just after\nthe drive letter. Using another separator will result in a throw.</p>\n<p>On all other platforms, <code>file:</code> URLs with a host name are unsupported and will\nresult in a throw:</p>\n<pre><code class=\"language-js\">// On other platforms:\n\n// - WHATWG file URLs with hostname are unsupported\n// file://hostname/p/a/t/h/file => throw!\nfs.readFileSync(new URL('file://hostname/p/a/t/h/file'));\n// TypeError [ERR_INVALID_FILE_URL_PATH]: must be absolute\n\n// - WHATWG file URLs convert to absolute path\n// file:///tmp/hello => /tmp/hello\nfs.readFileSync(new URL('file:///tmp/hello'));\n</code></pre>\n<p>A <code>file:</code> URL having encoded slash characters will result in a throw on all\nplatforms:</p>\n<pre><code class=\"language-js\">// On Windows\nfs.readFileSync(new URL('file:///C:/p/a/t/h/%2F'));\nfs.readFileSync(new URL('file:///C:/p/a/t/h/%2f'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n\\ or / characters */\n\n// On POSIX\nfs.readFileSync(new URL('file:///p/a/t/h/%2F'));\nfs.readFileSync(new URL('file:///p/a/t/h/%2f'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n/ characters */\n</code></pre>\n<p>On Windows, <code>file:</code> URLs having encoded backslash will result in a throw:</p>\n<pre><code class=\"language-js\">// On Windows\nfs.readFileSync(new URL('file:///C:/path/%5C'));\nfs.readFileSync(new URL('file:///C:/path/%5c'));\n/* TypeError [ERR_INVALID_FILE_URL_PATH]: File URL path must not include encoded\n\\ or / characters */\n</code></pre>",
|
||
"type": "module",
|
||
"displayName": "URL object support"
|
||
}
|
||
],
|
||
"type": "module",
|
||
"displayName": "File paths"
|
||
},
|
||
{
|
||
"textRaw": "File Descriptors",
|
||
"name": "file_descriptors",
|
||
"desc": "<p>On POSIX systems, for every process, the kernel maintains a table of currently\nopen files and resources. Each open file is assigned a simple numeric\nidentifier called a <em>file descriptor</em>. At the system-level, all file system\noperations use these file descriptors to identify and track each specific\nfile. Windows systems use a different but conceptually similar mechanism for\ntracking resources. To simplify things for users, Node.js abstracts away the\nspecific differences between operating systems and assigns all open files a\nnumeric file descriptor.</p>\n<p>The <code>fs.open()</code> method is used to allocate a new file descriptor. Once\nallocated, the file descriptor may be used to read data from, write data to,\nor request information about the file.</p>\n<pre><code class=\"language-js\">fs.open('/open/some/file.txt', 'r', (err, fd) => {\n if (err) throw err;\n fs.fstat(fd, (err, stat) => {\n if (err) throw err;\n // use stat\n\n // always close the file descriptor!\n fs.close(fd, (err) => {\n if (err) throw err;\n });\n });\n});\n</code></pre>\n<p>Most operating systems limit the number of file descriptors that may be open\nat any given time so it is critical to close the descriptor when operations\nare completed. Failure to do so will result in a memory leak that will\neventually cause an application to crash.</p>",
|
||
"type": "module",
|
||
"displayName": "File Descriptors"
|
||
},
|
||
{
|
||
"textRaw": "Threadpool Usage",
|
||
"name": "threadpool_usage",
|
||
"desc": "<p>All file system APIs except <code>fs.FSWatcher()</code> and those that are explicitly\nsynchronous use libuv's threadpool, which can have surprising and negative\nperformance implications for some applications. See the\n<a href=\"cli.html#cli_uv_threadpool_size_size\"><code>UV_THREADPOOL_SIZE</code></a> documentation for more information.</p>",
|
||
"type": "module",
|
||
"displayName": "Threadpool Usage"
|
||
},
|
||
{
|
||
"textRaw": "Class `fs.Dir`",
|
||
"name": "class_`fs.dir`",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>A class representing a directory stream.</p>\n<p>Created by <a href=\"#fs_fs_opendir_path_options_callback\"><code>fs.opendir()</code></a>, <a href=\"#fs_fs_opendirsync_path_options\"><code>fs.opendirSync()</code></a>, or\n<a href=\"#fs_fspromises_opendir_path_options\"><code>fsPromises.opendir()</code></a>.</p>\n<pre><code class=\"language-js\">const fs = require('fs');\n\nasync function print(path) {\n const dir = await fs.promises.opendir(path);\n for await (const dirent of dir) {\n console.log(dirent.name);\n }\n}\nprint('./').catch(console.error);\n</code></pre>",
|
||
"methods": [
|
||
{
|
||
"textRaw": "`dir.close()`",
|
||
"type": "method",
|
||
"name": "close",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously close the directory's underlying resource handle.\nSubsequent reads will result in errors.</p>\n<p>A <code>Promise</code> is returned that will be resolved after the resource has been\nclosed.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dir.close(callback)`",
|
||
"type": "method",
|
||
"name": "close",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously close the directory's underlying resource handle.\nSubsequent reads will result in errors.</p>\n<p>The <code>callback</code> will be called after the resource handle has been closed.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dir.closeSync()`",
|
||
"type": "method",
|
||
"name": "closeSync",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Synchronously close the directory's underlying resource handle.\nSubsequent reads will result in errors.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dir.read()`",
|
||
"type": "method",
|
||
"name": "read",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise} containing {fs.Dirent|null}",
|
||
"name": "return",
|
||
"type": "Promise",
|
||
"desc": "containing {fs.Dirent|null}"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously read the next directory entry via <a href=\"http://man7.org/linux/man-pages/man3/readdir.3.html\"><code>readdir(3)</code></a> as an\n<a href=\"#fs_class_fs_dirent\"><code>fs.Dirent</code></a>.</p>\n<p>After the read is completed, a <code>Promise</code> is returned that will be resolved with\nan <a href=\"#fs_class_fs_dirent\"><code>fs.Dirent</code></a>, or <code>null</code> if there are no more directory entries to read.</p>\n<p>Directory entries returned by this function are in no particular order as\nprovided by the operating system's underlying directory mechanisms.\nEntries added or removed while iterating over the directory may or may not be\nincluded in the iteration results.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dir.read(callback)`",
|
||
"type": "method",
|
||
"name": "read",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`dirent` {fs.Dirent|null}",
|
||
"name": "dirent",
|
||
"type": "fs.Dirent|null"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously read the next directory entry via <a href=\"http://man7.org/linux/man-pages/man3/readdir.3.html\"><code>readdir(3)</code></a> as an\n<a href=\"#fs_class_fs_dirent\"><code>fs.Dirent</code></a>.</p>\n<p>After the read is completed, the <code>callback</code> will be called with an\n<a href=\"#fs_class_fs_dirent\"><code>fs.Dirent</code></a>, or <code>null</code> if there are no more directory entries to read.</p>\n<p>Directory entries returned by this function are in no particular order as\nprovided by the operating system's underlying directory mechanisms.\nEntries added or removed while iterating over the directory may or may not be\nincluded in the iteration results.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dir.readSync()`",
|
||
"type": "method",
|
||
"name": "readSync",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {fs.Dirent|null}",
|
||
"name": "return",
|
||
"type": "fs.Dirent|null"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Synchronously read the next directory entry via <a href=\"http://man7.org/linux/man-pages/man3/readdir.3.html\"><code>readdir(3)</code></a> as an\n<a href=\"#fs_class_fs_dirent\"><code>fs.Dirent</code></a>.</p>\n<p>If there are no more directory entries to read, <code>null</code> will be returned.</p>\n<p>Directory entries returned by this function are in no particular order as\nprovided by the operating system's underlying directory mechanisms.\nEntries added or removed while iterating over the directory may or may not be\nincluded in the iteration results.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dir[Symbol.asyncIterator]()`",
|
||
"type": "method",
|
||
"name": "[Symbol.asyncIterator]",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {AsyncIterator} of {fs.Dirent}",
|
||
"name": "return",
|
||
"type": "AsyncIterator",
|
||
"desc": "of {fs.Dirent}"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously iterates over the directory via <a href=\"http://man7.org/linux/man-pages/man3/readdir.3.html\"><code>readdir(3)</code></a> until all entries have\nbeen read.</p>\n<p>Entries returned by the async iterator are always an <a href=\"#fs_class_fs_dirent\"><code>fs.Dirent</code></a>.\nThe <code>null</code> case from <code>dir.read()</code> is handled internally.</p>\n<p>See <a href=\"#fs_class_fs_dir\"><code>fs.Dir</code></a> for an example.</p>\n<p>Directory entries returned by this iterator are in no particular order as\nprovided by the operating system's underlying directory mechanisms.\nEntries added or removed while iterating over the directory may or may not be\nincluded in the iteration results.</p>"
|
||
}
|
||
],
|
||
"properties": [
|
||
{
|
||
"textRaw": "`path` {string}",
|
||
"type": "string",
|
||
"name": "path",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The read-only path of this directory as was provided to <a href=\"#fs_fs_opendir_path_options_callback\"><code>fs.opendir()</code></a>,\n<a href=\"#fs_fs_opendirsync_path_options\"><code>fs.opendirSync()</code></a>, or <a href=\"#fs_fspromises_opendir_path_options\"><code>fsPromises.opendir()</code></a>.</p>"
|
||
}
|
||
],
|
||
"type": "module",
|
||
"displayName": "Class `fs.Dir`"
|
||
},
|
||
{
|
||
"textRaw": "`fs` Promises API",
|
||
"name": "`fs`_promises_api",
|
||
"desc": "<p>The <code>fs.promises</code> API provides an alternative set of asynchronous file system\nmethods that return <code>Promise</code> objects rather than using callbacks. The\nAPI is accessible via <code>require('fs').promises</code>.</p>",
|
||
"classes": [
|
||
{
|
||
"textRaw": "class: `FileHandle`",
|
||
"type": "class",
|
||
"name": "FileHandle",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>A <code>FileHandle</code> object is a wrapper for a numeric file descriptor.\nInstances of <code>FileHandle</code> are distinct from numeric file descriptors\nin that they provide an object oriented API for working with files.</p>\n<p>If a <code>FileHandle</code> is not closed using the\n<code>filehandle.close()</code> method, it might automatically close the file descriptor\nand will emit a process warning, thereby helping to prevent memory leaks.\nPlease do not rely on this behavior because it is unreliable and\nthe file may not be closed. Instead, always explicitly close <code>FileHandle</code>s.\nNode.js may change this behavior in the future.</p>\n<p>Instances of the <code>FileHandle</code> object are created internally by the\n<code>fsPromises.open()</code> method.</p>\n<p>Unlike the callback-based API (<code>fs.fstat()</code>, <code>fs.fchown()</code>, <code>fs.fchmod()</code>, and\nso on), a numeric file descriptor is not used by the promise-based API. Instead,\nthe promise-based API uses the <code>FileHandle</code> class in order to help avoid\naccidental leaking of unclosed file descriptors after a <code>Promise</code> is resolved or\nrejected.</p>",
|
||
"methods": [
|
||
{
|
||
"textRaw": "`filehandle.appendFile(data, options)`",
|
||
"type": "method",
|
||
"name": "appendFile",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`data` {string|Buffer}",
|
||
"name": "data",
|
||
"type": "string|Buffer"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Alias of <a href=\"#fs_filehandle_writefile_data_options\"><code>filehandle.writeFile()</code></a>.</p>\n<p>When operating on file handles, the mode cannot be changed from what it was set\nto with <a href=\"#fs_fspromises_open_path_flags_mode\"><code>fsPromises.open()</code></a>. Therefore, this is equivalent to\n<a href=\"#fs_filehandle_writefile_data_options\"><code>filehandle.writeFile()</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.chmod(mode)`",
|
||
"type": "method",
|
||
"name": "chmod",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`mode` {integer}",
|
||
"name": "mode",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Modifies the permissions on the file. The <code>Promise</code> is resolved with no\narguments upon success.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.chown(uid, gid)`",
|
||
"type": "method",
|
||
"name": "chown",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`uid` {integer}",
|
||
"name": "uid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`gid` {integer}",
|
||
"name": "gid",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Changes the ownership of the file then resolves the <code>Promise</code> with no arguments\nupon success.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.close()`",
|
||
"type": "method",
|
||
"name": "close",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise} A `Promise` that will be resolved once the underlying file descriptor is closed, or will be rejected if an error occurs while closing.",
|
||
"name": "return",
|
||
"type": "Promise",
|
||
"desc": "A `Promise` that will be resolved once the underlying file descriptor is closed, or will be rejected if an error occurs while closing."
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Closes the file descriptor.</p>\n<pre><code class=\"language-js\">const fsPromises = require('fs').promises;\nasync function openAndClose() {\n let filehandle;\n try {\n filehandle = await fsPromises.open('thefile.txt', 'r');\n } finally {\n if (filehandle !== undefined)\n await filehandle.close();\n }\n}\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.datasync()`",
|
||
"type": "method",
|
||
"name": "datasync",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/fdatasync.2.html\"><code>fdatasync(2)</code></a>. The <code>Promise</code> is resolved with no arguments upon\nsuccess.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.read(buffer, offset, length, position)`",
|
||
"type": "method",
|
||
"name": "read",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`buffer` {Buffer|Uint8Array}",
|
||
"name": "buffer",
|
||
"type": "Buffer|Uint8Array"
|
||
},
|
||
{
|
||
"textRaw": "`offset` {integer}",
|
||
"name": "offset",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`length` {integer}",
|
||
"name": "length",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Read data from the file.</p>\n<p><code>buffer</code> is the buffer that the data will be written to.</p>\n<p><code>offset</code> is the offset in the buffer to start writing at.</p>\n<p><code>length</code> is an integer specifying the number of bytes to read.</p>\n<p><code>position</code> is an argument specifying where to begin reading from in the file.\nIf <code>position</code> is <code>null</code>, data will be read from the current file position,\nand the file position will be updated.\nIf <code>position</code> is an integer, the file position will remain unchanged.</p>\n<p>Following successful read, the <code>Promise</code> is resolved with an object with a\n<code>bytesRead</code> property specifying the number of bytes read, and a <code>buffer</code>\nproperty that is a reference to the passed in <code>buffer</code> argument.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.read(options)`",
|
||
"type": "method",
|
||
"name": "read",
|
||
"meta": {
|
||
"added": [
|
||
"v12.17.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`buffer` {Buffer|Uint8Array} **Default:** `Buffer.alloc(16384)`",
|
||
"name": "buffer",
|
||
"type": "Buffer|Uint8Array",
|
||
"default": "`Buffer.alloc(16384)`"
|
||
},
|
||
{
|
||
"textRaw": "`offset` {integer} **Default:** `0`",
|
||
"name": "offset",
|
||
"type": "integer",
|
||
"default": "`0`"
|
||
},
|
||
{
|
||
"textRaw": "`length` {integer} **Default:** `buffer.length`",
|
||
"name": "length",
|
||
"type": "integer",
|
||
"default": "`buffer.length`"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer} **Default:** `null`",
|
||
"name": "position",
|
||
"type": "integer",
|
||
"default": "`null`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.readFile(options)`",
|
||
"type": "method",
|
||
"name": "readFile",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `null`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`null`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously reads the entire contents of a file.</p>\n<p>The <code>Promise</code> is resolved with the contents of the file. If no encoding is\nspecified (using <code>options.encoding</code>), the data is returned as a <code>Buffer</code>\nobject. Otherwise, the data will be a string.</p>\n<p>If <code>options</code> is a string, then it specifies the encoding.</p>\n<p>The <code>FileHandle</code> has to support reading.</p>\n<p>If one or more <code>filehandle.read()</code> calls are made on a file handle and then a\n<code>filehandle.readFile()</code> call is made, the data will be read from the current\nposition till the end of the file. It doesn't always read from the beginning\nof the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.readv(buffers[, position])`",
|
||
"type": "method",
|
||
"name": "readv",
|
||
"meta": {
|
||
"added": [
|
||
"v12.17.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`buffers` {ArrayBufferView[]}",
|
||
"name": "buffers",
|
||
"type": "ArrayBufferView[]"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Read from a file and write to an array of <code>ArrayBufferView</code>s</p>\n<p>The <code>Promise</code> is resolved with an object containing a <code>bytesRead</code> property\nidentifying the number of bytes read, and a <code>buffers</code> property containing\na reference to the <code>buffers</code> input.</p>\n<p><code>position</code> is the offset from the beginning of the file where this data\nshould be read from. If <code>typeof position !== 'number'</code>, the data will be read\nfrom the current position.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.stat([options])`",
|
||
"type": "method",
|
||
"name": "stat",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/20220",
|
||
"description": "Accepts an additional `options` object to specify whether the numeric values returned should be bigint."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`bigint` {boolean} Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`. **Default:** `false`.",
|
||
"name": "bigint",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Retrieves the <a href=\"#fs_class_fs_stats\"><code>fs.Stats</code></a> for the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.sync()`",
|
||
"type": "method",
|
||
"name": "sync",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/fsync.2.html\"><code>fsync(2)</code></a>. The <code>Promise</code> is resolved with no arguments upon\nsuccess.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.truncate(len)`",
|
||
"type": "method",
|
||
"name": "truncate",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`len` {integer} **Default:** `0`",
|
||
"name": "len",
|
||
"type": "integer",
|
||
"default": "`0`"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Truncates the file then resolves the <code>Promise</code> with no arguments upon success.</p>\n<p>If the file was larger than <code>len</code> bytes, only the first <code>len</code> bytes will be\nretained in the file.</p>\n<p>For example, the following program retains only the first four bytes of the\nfile:</p>\n<pre><code class=\"language-js\">const fs = require('fs');\nconst fsPromises = fs.promises;\n\nconsole.log(fs.readFileSync('temp.txt', 'utf8'));\n// Prints: Node.js\n\nasync function doTruncate() {\n let filehandle = null;\n try {\n filehandle = await fsPromises.open('temp.txt', 'r+');\n await filehandle.truncate(4);\n } finally {\n if (filehandle) {\n // Close the file if it is opened.\n await filehandle.close();\n }\n }\n console.log(fs.readFileSync('temp.txt', 'utf8')); // Prints: Node\n}\n\ndoTruncate().catch(console.error);\n</code></pre>\n<p>If the file previously was shorter than <code>len</code> bytes, it is extended, and the\nextended part is filled with null bytes (<code>'\\0'</code>):</p>\n<pre><code class=\"language-js\">const fs = require('fs');\nconst fsPromises = fs.promises;\n\nconsole.log(fs.readFileSync('temp.txt', 'utf8'));\n// Prints: Node.js\n\nasync function doTruncate() {\n let filehandle = null;\n try {\n filehandle = await fsPromises.open('temp.txt', 'r+');\n await filehandle.truncate(10);\n } finally {\n if (filehandle) {\n // Close the file if it is opened.\n await filehandle.close();\n }\n }\n console.log(fs.readFileSync('temp.txt', 'utf8')); // Prints Node.js\\0\\0\\0\n}\n\ndoTruncate().catch(console.error);\n</code></pre>\n<p>The last three bytes are null bytes (<code>'\\0'</code>), to compensate the over-truncation.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.utimes(atime, mtime)`",
|
||
"type": "method",
|
||
"name": "utimes",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`atime` {number|string|Date}",
|
||
"name": "atime",
|
||
"type": "number|string|Date"
|
||
},
|
||
{
|
||
"textRaw": "`mtime` {number|string|Date}",
|
||
"name": "mtime",
|
||
"type": "number|string|Date"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Change the file system timestamps of the object referenced by the <code>FileHandle</code>\nthen resolves the <code>Promise</code> with no arguments upon success.</p>\n<p>This function does not work on AIX versions before 7.1, it will resolve the\n<code>Promise</code> with an error using code <code>UV_ENOSYS</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.write(buffer[, offset[, length[, position]]])`",
|
||
"type": "method",
|
||
"name": "write",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`buffer` {Buffer|Uint8Array}",
|
||
"name": "buffer",
|
||
"type": "Buffer|Uint8Array"
|
||
},
|
||
{
|
||
"textRaw": "`offset` {integer}",
|
||
"name": "offset",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`length` {integer}",
|
||
"name": "length",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Write <code>buffer</code> to the file.</p>\n<p>The <code>Promise</code> is resolved with an object containing a <code>bytesWritten</code> property\nidentifying the number of bytes written, and a <code>buffer</code> property containing\na reference to the <code>buffer</code> written.</p>\n<p><code>offset</code> determines the part of the buffer to be written, and <code>length</code> is\nan integer specifying the number of bytes to write.</p>\n<p><code>position</code> refers to the offset from the beginning of the file where this data\nshould be written. If <code>typeof position !== 'number'</code>, the data will be written\nat the current position. See <a href=\"http://man7.org/linux/man-pages/man2/pwrite.2.html\"><code>pwrite(2)</code></a>.</p>\n<p>It is unsafe to use <code>filehandle.write()</code> multiple times on the same file\nwithout waiting for the <code>Promise</code> to be resolved (or rejected). For this\nscenario, use <a href=\"#fs_fs_createwritestream_path_options\"><code>fs.createWriteStream()</code></a>.</p>\n<p>On Linux, positional writes do not work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.write(string[, position[, encoding]])`",
|
||
"type": "method",
|
||
"name": "write",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`string` {string}",
|
||
"name": "string",
|
||
"type": "string"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Write <code>string</code> to the file. If <code>string</code> is not a string, then\nthe value will be coerced to one.</p>\n<p>The <code>Promise</code> is resolved with an object containing a <code>bytesWritten</code> property\nidentifying the number of bytes written, and a <code>buffer</code> property containing\na reference to the <code>string</code> written.</p>\n<p><code>position</code> refers to the offset from the beginning of the file where this data\nshould be written. If the type of <code>position</code> is not a <code>number</code> the data\nwill be written at the current position. See <a href=\"http://man7.org/linux/man-pages/man2/pwrite.2.html\"><code>pwrite(2)</code></a>.</p>\n<p><code>encoding</code> is the expected string encoding.</p>\n<p>It is unsafe to use <code>filehandle.write()</code> multiple times on the same file\nwithout waiting for the <code>Promise</code> to be resolved (or rejected). For this\nscenario, use <a href=\"#fs_fs_createwritestream_path_options\"><code>fs.createWriteStream()</code></a>.</p>\n<p>On Linux, positional writes do not work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.writeFile(data, options)`",
|
||
"type": "method",
|
||
"name": "writeFile",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`data` {string|Buffer|Uint8Array}",
|
||
"name": "data",
|
||
"type": "string|Buffer|Uint8Array"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously writes data to a file, replacing the file if it already exists.\n<code>data</code> can be a string or a buffer. The <code>Promise</code> will be resolved with no\narguments upon success.</p>\n<p>The <code>encoding</code> option is ignored if <code>data</code> is a buffer.</p>\n<p>If <code>options</code> is a string, then it specifies the encoding.</p>\n<p>The <code>FileHandle</code> has to support writing.</p>\n<p>It is unsafe to use <code>filehandle.writeFile()</code> multiple times on the same file\nwithout waiting for the <code>Promise</code> to be resolved (or rejected).</p>\n<p>If one or more <code>filehandle.write()</code> calls are made on a file handle and then a\n<code>filehandle.writeFile()</code> call is made, the data will be written from the\ncurrent position till the end of the file. It doesn't always write from the\nbeginning of the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`filehandle.writev(buffers[, position])`",
|
||
"type": "method",
|
||
"name": "writev",
|
||
"meta": {
|
||
"added": [
|
||
"v12.9.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`buffers` {ArrayBufferView[]}",
|
||
"name": "buffers",
|
||
"type": "ArrayBufferView[]"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Write an array of <code>ArrayBufferView</code>s to the file.</p>\n<p>The <code>Promise</code> is resolved with an object containing a <code>bytesWritten</code> property\nidentifying the number of bytes written, and a <code>buffers</code> property containing\na reference to the <code>buffers</code> input.</p>\n<p><code>position</code> is the offset from the beginning of the file where this data\nshould be written. If <code>typeof position !== 'number'</code>, the data will be written\nat the current position.</p>\n<p>It is unsafe to call <code>writev()</code> multiple times on the same file without waiting\nfor the previous operation to complete.</p>\n<p>On Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.</p>"
|
||
}
|
||
],
|
||
"properties": [
|
||
{
|
||
"textRaw": "`fd` {number} The numeric file descriptor managed by the `FileHandle` object.",
|
||
"type": "number",
|
||
"name": "fd",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "The numeric file descriptor managed by the `FileHandle` object."
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"methods": [
|
||
{
|
||
"textRaw": "`fsPromises.access(path[, mode])`",
|
||
"type": "method",
|
||
"name": "access",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `fs.constants.F_OK`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`fs.constants.F_OK`"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Tests a user's permissions for the file or directory specified by <code>path</code>.\nThe <code>mode</code> argument is an optional integer that specifies the accessibility\nchecks to be performed. Check <a href=\"#fs_file_access_constants\">File Access Constants</a> for possible values\nof <code>mode</code>. It is possible to create a mask consisting of the bitwise OR of\ntwo or more values (e.g. <code>fs.constants.W_OK | fs.constants.R_OK</code>).</p>\n<p>If the accessibility check is successful, the <code>Promise</code> is resolved with no\nvalue. If any of the accessibility checks fail, the <code>Promise</code> is rejected\nwith an <code>Error</code> object. The following example checks if the file\n<code>/etc/passwd</code> can be read and written by the current process.</p>\n<pre><code class=\"language-js\">const fs = require('fs');\nconst fsPromises = fs.promises;\n\nfsPromises.access('/etc/passwd', fs.constants.R_OK | fs.constants.W_OK)\n .then(() => console.log('can access'))\n .catch(() => console.error('cannot access'));\n</code></pre>\n<p>Using <code>fsPromises.access()</code> to check for the accessibility of a file before\ncalling <code>fsPromises.open()</code> is not recommended. Doing so introduces a race\ncondition, since other processes may change the file's state between the two\ncalls. Instead, user code should open/read/write the file directly and handle\nthe error raised if the file is not accessible.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.appendFile(path, data[, options])`",
|
||
"type": "method",
|
||
"name": "appendFile",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL|FileHandle} filename or `FileHandle`",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL|FileHandle",
|
||
"desc": "filename or `FileHandle`"
|
||
},
|
||
{
|
||
"textRaw": "`data` {string|Buffer}",
|
||
"name": "data",
|
||
"type": "string|Buffer"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `0o666`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`0o666`"
|
||
},
|
||
{
|
||
"textRaw": "`flag` {string} See [support of file system `flags`][]. **Default:** `'a'`.",
|
||
"name": "flag",
|
||
"type": "string",
|
||
"default": "`'a'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously append data to a file, creating the file if it does not yet\nexist. <code>data</code> can be a string or a <a href=\"buffer.html#buffer_buffer\"><code>Buffer</code></a>. The <code>Promise</code> will be\nresolved with no arguments upon success.</p>\n<p>If <code>options</code> is a string, then it specifies the encoding.</p>\n<p>The <code>path</code> may be specified as a <code>FileHandle</code> that has been opened\nfor appending (using <code>fsPromises.open()</code>).</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.chmod(path, mode)`",
|
||
"type": "method",
|
||
"name": "chmod",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer}",
|
||
"name": "mode",
|
||
"type": "string|integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Changes the permissions of a file then resolves the <code>Promise</code> with no\narguments upon succces.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.chown(path, uid, gid)`",
|
||
"type": "method",
|
||
"name": "chown",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`uid` {integer}",
|
||
"name": "uid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`gid` {integer}",
|
||
"name": "gid",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Changes the ownership of a file then resolves the <code>Promise</code> with no arguments\nupon success.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.copyFile(src, dest[, flags])`",
|
||
"type": "method",
|
||
"name": "copyFile",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`src` {string|Buffer|URL} source filename to copy",
|
||
"name": "src",
|
||
"type": "string|Buffer|URL",
|
||
"desc": "source filename to copy"
|
||
},
|
||
{
|
||
"textRaw": "`dest` {string|Buffer|URL} destination filename of the copy operation",
|
||
"name": "dest",
|
||
"type": "string|Buffer|URL",
|
||
"desc": "destination filename of the copy operation"
|
||
},
|
||
{
|
||
"textRaw": "`flags` {number} modifiers for copy operation. **Default:** `0`.",
|
||
"name": "flags",
|
||
"type": "number",
|
||
"default": "`0`",
|
||
"desc": "modifiers for copy operation."
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously copies <code>src</code> to <code>dest</code>. By default, <code>dest</code> is overwritten if it\nalready exists. The <code>Promise</code> will be resolved with no arguments upon success.</p>\n<p>Node.js makes no guarantees about the atomicity of the copy operation. If an\nerror occurs after the destination file has been opened for writing, Node.js\nwill attempt to remove the destination.</p>\n<p><code>flags</code> is an optional integer that specifies the behavior\nof the copy operation. It is possible to create a mask consisting of the bitwise\nOR of two or more values (e.g.\n<code>fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE</code>).</p>\n<ul>\n<li><code>fs.constants.COPYFILE_EXCL</code>: The copy operation will fail if <code>dest</code> already\nexists.</li>\n<li><code>fs.constants.COPYFILE_FICLONE</code>: The copy operation will attempt to create a\ncopy-on-write reflink. If the platform does not support copy-on-write, then a\nfallback copy mechanism is used.</li>\n<li><code>fs.constants.COPYFILE_FICLONE_FORCE</code>: The copy operation will attempt to\ncreate a copy-on-write reflink. If the platform does not support copy-on-write,\nthen the operation will fail.</li>\n</ul>\n<pre><code class=\"language-js\">const fsPromises = require('fs').promises;\n\n// destination.txt will be created or overwritten by default.\nfsPromises.copyFile('source.txt', 'destination.txt')\n .then(() => console.log('source.txt was copied to destination.txt'))\n .catch(() => console.log('The file could not be copied'));\n</code></pre>\n<p>If the third argument is a number, then it specifies <code>flags</code>:</p>\n<pre><code class=\"language-js\">const fs = require('fs');\nconst fsPromises = fs.promises;\nconst { COPYFILE_EXCL } = fs.constants;\n\n// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.\nfsPromises.copyFile('source.txt', 'destination.txt', COPYFILE_EXCL)\n .then(() => console.log('source.txt was copied to destination.txt'))\n .catch(() => console.log('The file could not be copied'));\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.lchmod(path, mode)`",
|
||
"type": "method",
|
||
"name": "lchmod",
|
||
"meta": {
|
||
"deprecated": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer}",
|
||
"name": "mode",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Changes the permissions on a symbolic link then resolves the <code>Promise</code> with\nno arguments upon success. This method is only implemented on macOS.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.lchown(path, uid, gid)`",
|
||
"type": "method",
|
||
"name": "lchown",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/21498",
|
||
"description": "This API is no longer deprecated."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`uid` {integer}",
|
||
"name": "uid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`gid` {integer}",
|
||
"name": "gid",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Changes the ownership on a symbolic link then resolves the <code>Promise</code> with\nno arguments upon success.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.link(existingPath, newPath)`",
|
||
"type": "method",
|
||
"name": "link",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`existingPath` {string|Buffer|URL}",
|
||
"name": "existingPath",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`newPath` {string|Buffer|URL}",
|
||
"name": "newPath",
|
||
"type": "string|Buffer|URL"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/link.2.html\"><code>link(2)</code></a>. The <code>Promise</code> is resolved with no arguments upon success.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.lstat(path[, options])`",
|
||
"type": "method",
|
||
"name": "lstat",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/20220",
|
||
"description": "Accepts an additional `options` object to specify whether the numeric values returned should be bigint."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`bigint` {boolean} Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`. **Default:** `false`.",
|
||
"name": "bigint",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/lstat.2.html\"><code>lstat(2)</code></a>. The <code>Promise</code> is resolved with the <a href=\"#fs_class_fs_stats\"><code>fs.Stats</code></a> object\nfor the given symbolic link <code>path</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.mkdir(path[, options])`",
|
||
"type": "method",
|
||
"name": "mkdir",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|integer}",
|
||
"name": "options",
|
||
"type": "Object|integer",
|
||
"options": [
|
||
{
|
||
"textRaw": "`recursive` {boolean} **Default:** `false`",
|
||
"name": "recursive",
|
||
"type": "boolean",
|
||
"default": "`false`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer} Not supported on Windows. **Default:** `0o777`.",
|
||
"name": "mode",
|
||
"type": "string|integer",
|
||
"default": "`0o777`",
|
||
"desc": "Not supported on Windows."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously creates a directory then resolves the <code>Promise</code> with either no\narguments, or the first directory path created if <code>recursive</code> is <code>true</code>.</p>\n<p>The optional <code>options</code> argument can be an integer specifying mode (permission\nand sticky bits), or an object with a <code>mode</code> property and a <code>recursive</code>\nproperty indicating whether parent directories should be created. Calling\n<code>fsPromises.mkdir()</code> when <code>path</code> is a directory that exists results in a\nrejection only when <code>recursive</code> is false.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.mkdtemp(prefix[, options])`",
|
||
"type": "method",
|
||
"name": "mkdtemp",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`prefix` {string}",
|
||
"name": "prefix",
|
||
"type": "string"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Creates a unique temporary directory and resolves the <code>Promise</code> with the created\ndirectory path. A unique directory name is generated by appending six random\ncharacters to the end of the provided <code>prefix</code>. Due to platform\ninconsistencies, avoid trailing <code>X</code> characters in <code>prefix</code>. Some platforms,\nnotably the BSDs, can return more than six random characters, and replace\ntrailing <code>X</code> characters in <code>prefix</code> with random characters.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use.</p>\n<pre><code class=\"language-js\">fsPromises.mkdtemp(path.join(os.tmpdir(), 'foo-'))\n .catch(console.error);\n</code></pre>\n<p>The <code>fsPromises.mkdtemp()</code> method will append the six randomly selected\ncharacters directly to the <code>prefix</code> string. For instance, given a directory\n<code>/tmp</code>, if the intention is to create a temporary directory <em>within</em> <code>/tmp</code>, the\n<code>prefix</code> must end with a trailing platform-specific path separator\n(<code>require('path').sep</code>).</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.open(path, flags[, mode])`",
|
||
"type": "method",
|
||
"name": "open",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v11.1.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/23767",
|
||
"description": "The `flags` argument is now optional and defaults to `'r'`."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`flags` {string|number} See [support of file system `flags`][]. **Default:** `'r'`.",
|
||
"name": "flags",
|
||
"type": "string|number",
|
||
"default": "`'r'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer} **Default:** `0o666` (readable and writable)",
|
||
"name": "mode",
|
||
"type": "string|integer",
|
||
"default": "`0o666` (readable and writable)"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous file open that returns a <code>Promise</code> that, when resolved, yields a\n<code>FileHandle</code> object. See <a href=\"http://man7.org/linux/man-pages/man2/open.2.html\"><code>open(2)</code></a>.</p>\n<p><code>mode</code> sets the file mode (permission and sticky bits), but only if the file was\ncreated.</p>\n<p>Some characters (<code>< > : \" / \\ | ? *</code>) are reserved under Windows as documented\nby <a href=\"https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file\">Naming Files, Paths, and Namespaces</a>. Under NTFS, if the filename contains\na colon, Node.js will open a file system stream, as described by\n<a href=\"https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams\">this MSDN page</a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.opendir(path[, options])`",
|
||
"type": "method",
|
||
"name": "opendir",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.16.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/30114",
|
||
"description": "The `bufferSize` option was introduced."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise} containing {fs.Dir}",
|
||
"name": "return",
|
||
"type": "Promise",
|
||
"desc": "containing {fs.Dir}"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`bufferSize` {number} Number of directory entries that are buffered internally when reading from the directory. Higher values lead to better performance but higher memory usage. **Default:** `32`",
|
||
"name": "bufferSize",
|
||
"type": "number",
|
||
"default": "`32`",
|
||
"desc": "Number of directory entries that are buffered internally when reading from the directory. Higher values lead to better performance but higher memory usage."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously open a directory. See <a href=\"http://man7.org/linux/man-pages/man3/opendir.3.html\"><code>opendir(3)</code></a>.</p>\n<p>Creates an <a href=\"#fs_class_fs_dir\"><code>fs.Dir</code></a>, which contains all further functions for reading from\nand cleaning up the directory.</p>\n<p>The <code>encoding</code> option sets the encoding for the <code>path</code> while opening the\ndirectory and subsequent read operations.</p>\n<p>Example using async iteration:</p>\n<pre><code class=\"language-js\">const fs = require('fs');\n\nasync function print(path) {\n const dir = await fs.promises.opendir(path);\n for await (const dirent of dir) {\n console.log(dirent.name);\n }\n}\nprint('./').catch(console.error);\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.readdir(path[, options])`",
|
||
"type": "method",
|
||
"name": "readdir",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.11.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/22020",
|
||
"description": "New option `withFileTypes` was added."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`withFileTypes` {boolean} **Default:** `false`",
|
||
"name": "withFileTypes",
|
||
"type": "boolean",
|
||
"default": "`false`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Reads the contents of a directory then resolves the <code>Promise</code> with an array\nof the names of the files in the directory excluding <code>'.'</code> and <code>'..'</code>.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe filenames. If the <code>encoding</code> is set to <code>'buffer'</code>, the filenames returned\nwill be passed as <code>Buffer</code> objects.</p>\n<p>If <code>options.withFileTypes</code> is set to <code>true</code>, the resolved array will contain\n<a href=\"#fs_class_fs_dirent\"><code>fs.Dirent</code></a> objects.</p>\n<pre><code class=\"language-js\">const fs = require('fs');\n\nasync function print(path) {\n const files = await fs.promises.readdir(path);\n for (const file of files) {\n console.log(file);\n }\n}\nprint('./').catch(console.error);\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.readFile(path[, options])`",
|
||
"type": "method",
|
||
"name": "readFile",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL|FileHandle} filename or `FileHandle`",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL|FileHandle",
|
||
"desc": "filename or `FileHandle`"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `null`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`null`"
|
||
},
|
||
{
|
||
"textRaw": "`flag` {string} See [support of file system `flags`][]. **Default:** `'r'`.",
|
||
"name": "flag",
|
||
"type": "string",
|
||
"default": "`'r'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously reads the entire contents of a file.</p>\n<p>The <code>Promise</code> is resolved with the contents of the file. If no encoding is\nspecified (using <code>options.encoding</code>), the data is returned as a <code>Buffer</code>\nobject. Otherwise, the data will be a string.</p>\n<p>If <code>options</code> is a string, then it specifies the encoding.</p>\n<p>When the <code>path</code> is a directory, the behavior of <code>fsPromises.readFile()</code> is\nplatform-specific. On macOS, Linux, and Windows, the promise will be rejected\nwith an error. On FreeBSD, a representation of the directory's contents will be\nreturned.</p>\n<p>Any specified <code>FileHandle</code> has to support reading.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.readlink(path[, options])`",
|
||
"type": "method",
|
||
"name": "readlink",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/readlink.2.html\"><code>readlink(2)</code></a>. The <code>Promise</code> is resolved with the <code>linkString</code> upon\nsuccess.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe link path returned. If the <code>encoding</code> is set to <code>'buffer'</code>, the link path\nreturned will be passed as a <code>Buffer</code> object.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.realpath(path[, options])`",
|
||
"type": "method",
|
||
"name": "realpath",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Determines the actual location of <code>path</code> using the same semantics as the\n<code>fs.realpath.native()</code> function then resolves the <code>Promise</code> with the resolved\npath.</p>\n<p>Only paths that can be converted to UTF8 strings are supported.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe path. If the <code>encoding</code> is set to <code>'buffer'</code>, the path returned will be\npassed as a <code>Buffer</code> object.</p>\n<p>On Linux, when Node.js is linked against musl libc, the procfs file system must\nbe mounted on <code>/proc</code> in order for this function to work. Glibc does not have\nthis restriction.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.rename(oldPath, newPath)`",
|
||
"type": "method",
|
||
"name": "rename",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`oldPath` {string|Buffer|URL}",
|
||
"name": "oldPath",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`newPath` {string|Buffer|URL}",
|
||
"name": "newPath",
|
||
"type": "string|Buffer|URL"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Renames <code>oldPath</code> to <code>newPath</code> and resolves the <code>Promise</code> with no arguments\nupon success.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.rmdir(path[, options])`",
|
||
"type": "method",
|
||
"name": "rmdir",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.16.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/30644",
|
||
"description": "The `maxBusyTries` option is renamed to `maxRetries`, and its default is 0. The `emfileWait` option has been removed, and `EMFILE` errors use the same retry logic as other errors. The `retryDelay` option is now supported. `ENFILE` errors are now retried."
|
||
},
|
||
{
|
||
"version": "v12.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/29168",
|
||
"description": "The `recursive`, `maxBusyTries`, and `emfileWait` options are now supported."
|
||
}
|
||
]
|
||
},
|
||
"stability": 1,
|
||
"stabilityText": "Recursive removal is experimental.",
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or `EPERM` error is encountered, Node.js will retry the operation with a linear backoff wait of `retryDelay` ms longer on each try. This option represents the number of retries. This option is ignored if the `recursive` option is not `true`. **Default:** `0`.",
|
||
"name": "maxRetries",
|
||
"type": "integer",
|
||
"default": "`0`",
|
||
"desc": "If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or `EPERM` error is encountered, Node.js will retry the operation with a linear backoff wait of `retryDelay` ms longer on each try. This option represents the number of retries. This option is ignored if the `recursive` option is not `true`."
|
||
},
|
||
{
|
||
"textRaw": "`recursive` {boolean} If `true`, perform a recursive directory removal. In recursive mode, errors are not reported if `path` does not exist, and operations are retried on failure. **Default:** `false`.",
|
||
"name": "recursive",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "If `true`, perform a recursive directory removal. In recursive mode, errors are not reported if `path` does not exist, and operations are retried on failure."
|
||
},
|
||
{
|
||
"textRaw": "`retryDelay` {integer} The amount of time in milliseconds to wait between retries. This option is ignored if the `recursive` option is not `true`. **Default:** `100`.",
|
||
"name": "retryDelay",
|
||
"type": "integer",
|
||
"default": "`100`",
|
||
"desc": "The amount of time in milliseconds to wait between retries. This option is ignored if the `recursive` option is not `true`."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Removes the directory identified by <code>path</code> then resolves the <code>Promise</code> with\nno arguments upon success.</p>\n<p>Using <code>fsPromises.rmdir()</code> on a file (not a directory) results in the\n<code>Promise</code> being rejected with an <code>ENOENT</code> error on Windows and an <code>ENOTDIR</code>\nerror on POSIX.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.stat(path[, options])`",
|
||
"type": "method",
|
||
"name": "stat",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/20220",
|
||
"description": "Accepts an additional `options` object to specify whether the numeric values returned should be bigint."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`bigint` {boolean} Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`. **Default:** `false`.",
|
||
"name": "bigint",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>The <code>Promise</code> is resolved with the <a href=\"#fs_class_fs_stats\"><code>fs.Stats</code></a> object for the given <code>path</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.symlink(target, path[, type])`",
|
||
"type": "method",
|
||
"name": "symlink",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`target` {string|Buffer|URL}",
|
||
"name": "target",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`type` {string} **Default:** `'file'`",
|
||
"name": "type",
|
||
"type": "string",
|
||
"default": "`'file'`"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Creates a symbolic link then resolves the <code>Promise</code> with no arguments upon\nsuccess.</p>\n<p>The <code>type</code> argument is only used on Windows platforms and can be one of <code>'dir'</code>,\n<code>'file'</code>, or <code>'junction'</code>. Windows junction points require the destination path\nto be absolute. When using <code>'junction'</code>, the <code>target</code> argument will\nautomatically be normalized to absolute path.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.truncate(path[, len])`",
|
||
"type": "method",
|
||
"name": "truncate",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`len` {integer} **Default:** `0`",
|
||
"name": "len",
|
||
"type": "integer",
|
||
"default": "`0`"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Truncates the <code>path</code> then resolves the <code>Promise</code> with no arguments upon\nsuccess. The <code>path</code> <em>must</em> be a string or <code>Buffer</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.unlink(path)`",
|
||
"type": "method",
|
||
"name": "unlink",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/unlink.2.html\"><code>unlink(2)</code></a>. The <code>Promise</code> is resolved with no arguments upon\nsuccess.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.utimes(path, atime, mtime)`",
|
||
"type": "method",
|
||
"name": "utimes",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`atime` {number|string|Date}",
|
||
"name": "atime",
|
||
"type": "number|string|Date"
|
||
},
|
||
{
|
||
"textRaw": "`mtime` {number|string|Date}",
|
||
"name": "mtime",
|
||
"type": "number|string|Date"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Change the file system timestamps of the object referenced by <code>path</code> then\nresolves the <code>Promise</code> with no arguments upon success.</p>\n<p>The <code>atime</code> and <code>mtime</code> arguments follow these rules:</p>\n<ul>\n<li>Values can be either numbers representing Unix epoch time, <code>Date</code>s, or a\nnumeric string like <code>'123456789.0'</code>.</li>\n<li>If the value can not be converted to a number, or is <code>NaN</code>, <code>Infinity</code> or\n<code>-Infinity</code>, an <code>Error</code> will be thrown.</li>\n</ul>"
|
||
},
|
||
{
|
||
"textRaw": "`fsPromises.writeFile(file, data[, options])`",
|
||
"type": "method",
|
||
"name": "writeFile",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {Promise}",
|
||
"name": "return",
|
||
"type": "Promise"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`file` {string|Buffer|URL|FileHandle} filename or `FileHandle`",
|
||
"name": "file",
|
||
"type": "string|Buffer|URL|FileHandle",
|
||
"desc": "filename or `FileHandle`"
|
||
},
|
||
{
|
||
"textRaw": "`data` {string|Buffer|Uint8Array}",
|
||
"name": "data",
|
||
"type": "string|Buffer|Uint8Array"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `0o666`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`0o666`"
|
||
},
|
||
{
|
||
"textRaw": "`flag` {string} See [support of file system `flags`][]. **Default:** `'w'`.",
|
||
"name": "flag",
|
||
"type": "string",
|
||
"default": "`'w'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously writes data to a file, replacing the file if it already exists.\n<code>data</code> can be a string or a buffer. The <code>Promise</code> will be resolved with no\narguments upon success.</p>\n<p>The <code>encoding</code> option is ignored if <code>data</code> is a buffer.</p>\n<p>If <code>options</code> is a string, then it specifies the encoding.</p>\n<p>Any specified <code>FileHandle</code> has to support writing.</p>\n<p>It is unsafe to use <code>fsPromises.writeFile()</code> multiple times on the same file\nwithout waiting for the <code>Promise</code> to be resolved (or rejected).</p>"
|
||
}
|
||
],
|
||
"type": "module",
|
||
"displayName": "`fs` Promises API"
|
||
},
|
||
{
|
||
"textRaw": "FS Constants",
|
||
"name": "fs_constants",
|
||
"desc": "<p>The following constants are exported by <code>fs.constants</code>.</p>\n<p>Not every constant will be available on every operating system.</p>\n<p>To use more than one constant, use the bitwise OR <code>|</code> operator.</p>\n<p>Example:</p>\n<pre><code class=\"language-js\">const fs = require('fs');\n\nconst {\n O_RDWR,\n O_CREAT,\n O_EXCL\n} = fs.constants;\n\nfs.open('/path/to/my/file', O_RDWR | O_CREAT | O_EXCL, (err, fd) => {\n // ...\n});\n</code></pre>",
|
||
"modules": [
|
||
{
|
||
"textRaw": "File Access Constants",
|
||
"name": "file_access_constants",
|
||
"desc": "<p>The following constants are meant for use with <a href=\"#fs_fs_access_path_mode_callback\"><code>fs.access()</code></a>.</p>\n<table>\n <tr>\n <th>Constant</th>\n <th>Description</th>\n </tr>\n <tr>\n <td><code>F_OK</code></td>\n <td>Flag indicating that the file is visible to the calling process.\n This is useful for determining if a file exists, but says nothing\n about <code>rwx</code> permissions. Default if no mode is specified.</td>\n </tr>\n <tr>\n <td><code>R_OK</code></td>\n <td>Flag indicating that the file can be read by the calling process.</td>\n </tr>\n <tr>\n <td><code>W_OK</code></td>\n <td>Flag indicating that the file can be written by the calling\n process.</td>\n </tr>\n <tr>\n <td><code>X_OK</code></td>\n <td>Flag indicating that the file can be executed by the calling\n process. This has no effect on Windows\n (will behave like <code>fs.constants.F_OK</code>).</td>\n </tr>\n</table>",
|
||
"type": "module",
|
||
"displayName": "File Access Constants"
|
||
},
|
||
{
|
||
"textRaw": "File Copy Constants",
|
||
"name": "file_copy_constants",
|
||
"desc": "<p>The following constants are meant for use with <a href=\"#fs_fs_copyfile_src_dest_flags_callback\"><code>fs.copyFile()</code></a>.</p>\n<table>\n <tr>\n <th>Constant</th>\n <th>Description</th>\n </tr>\n <tr>\n <td><code>COPYFILE_EXCL</code></td>\n <td>If present, the copy operation will fail with an error if the\n destination path already exists.</td>\n </tr>\n <tr>\n <td><code>COPYFILE_FICLONE</code></td>\n <td>If present, the copy operation will attempt to create a\n copy-on-write reflink. If the underlying platform does not support\n copy-on-write, then a fallback copy mechanism is used.</td>\n </tr>\n <tr>\n <td><code>COPYFILE_FICLONE_FORCE</code></td>\n <td>If present, the copy operation will attempt to create a\n copy-on-write reflink. If the underlying platform does not support\n copy-on-write, then the operation will fail with an error.</td>\n </tr>\n</table>",
|
||
"type": "module",
|
||
"displayName": "File Copy Constants"
|
||
},
|
||
{
|
||
"textRaw": "File Open Constants",
|
||
"name": "file_open_constants",
|
||
"desc": "<p>The following constants are meant for use with <code>fs.open()</code>.</p>\n<table>\n <tr>\n <th>Constant</th>\n <th>Description</th>\n </tr>\n <tr>\n <td><code>O_RDONLY</code></td>\n <td>Flag indicating to open a file for read-only access.</td>\n </tr>\n <tr>\n <td><code>O_WRONLY</code></td>\n <td>Flag indicating to open a file for write-only access.</td>\n </tr>\n <tr>\n <td><code>O_RDWR</code></td>\n <td>Flag indicating to open a file for read-write access.</td>\n </tr>\n <tr>\n <td><code>O_CREAT</code></td>\n <td>Flag indicating to create the file if it does not already exist.</td>\n </tr>\n <tr>\n <td><code>O_EXCL</code></td>\n <td>Flag indicating that opening a file should fail if the\n <code>O_CREAT</code> flag is set and the file already exists.</td>\n </tr>\n <tr>\n <td><code>O_NOCTTY</code></td>\n <td>Flag indicating that if path identifies a terminal device, opening the\n path shall not cause that terminal to become the controlling terminal for\n the process (if the process does not already have one).</td>\n </tr>\n <tr>\n <td><code>O_TRUNC</code></td>\n <td>Flag indicating that if the file exists and is a regular file, and the\n file is opened successfully for write access, its length shall be truncated\n to zero.</td>\n </tr>\n <tr>\n <td><code>O_APPEND</code></td>\n <td>Flag indicating that data will be appended to the end of the file.</td>\n </tr>\n <tr>\n <td><code>O_DIRECTORY</code></td>\n <td>Flag indicating that the open should fail if the path is not a\n directory.</td>\n </tr>\n <tr>\n <td><code>O_NOATIME</code></td>\n <td>Flag indicating reading accesses to the file system will no longer\n result in an update to the <code>atime</code> information associated with\n the file. This flag is available on Linux operating systems only.</td>\n </tr>\n <tr>\n <td><code>O_NOFOLLOW</code></td>\n <td>Flag indicating that the open should fail if the path is a symbolic\n link.</td>\n </tr>\n <tr>\n <td><code>O_SYNC</code></td>\n <td>Flag indicating that the file is opened for synchronized I/O with write\n operations waiting for file integrity.</td>\n </tr>\n <tr>\n <td><code>O_DSYNC</code></td>\n <td>Flag indicating that the file is opened for synchronized I/O with write\n operations waiting for data integrity.</td>\n </tr>\n <tr>\n <td><code>O_SYMLINK</code></td>\n <td>Flag indicating to open the symbolic link itself rather than the\n resource it is pointing to.</td>\n </tr>\n <tr>\n <td><code>O_DIRECT</code></td>\n <td>When set, an attempt will be made to minimize caching effects of file\n I/O.</td>\n </tr>\n <tr>\n <td><code>O_NONBLOCK</code></td>\n <td>Flag indicating to open the file in nonblocking mode when possible.</td>\n </tr>\n <tr>\n <td><code>UV_FS_O_FILEMAP</code></td>\n <td>When set, a memory file mapping is used to access the file. This flag\n is available on Windows operating systems only. On other operating systems,\n this flag is ignored.</td>\n </tr>\n</table>",
|
||
"type": "module",
|
||
"displayName": "File Open Constants"
|
||
},
|
||
{
|
||
"textRaw": "File Type Constants",
|
||
"name": "file_type_constants",
|
||
"desc": "<p>The following constants are meant for use with the <a href=\"#fs_class_fs_stats\"><code>fs.Stats</code></a> object's\n<code>mode</code> property for determining a file's type.</p>\n<table>\n <tr>\n <th>Constant</th>\n <th>Description</th>\n </tr>\n <tr>\n <td><code>S_IFMT</code></td>\n <td>Bit mask used to extract the file type code.</td>\n </tr>\n <tr>\n <td><code>S_IFREG</code></td>\n <td>File type constant for a regular file.</td>\n </tr>\n <tr>\n <td><code>S_IFDIR</code></td>\n <td>File type constant for a directory.</td>\n </tr>\n <tr>\n <td><code>S_IFCHR</code></td>\n <td>File type constant for a character-oriented device file.</td>\n </tr>\n <tr>\n <td><code>S_IFBLK</code></td>\n <td>File type constant for a block-oriented device file.</td>\n </tr>\n <tr>\n <td><code>S_IFIFO</code></td>\n <td>File type constant for a FIFO/pipe.</td>\n </tr>\n <tr>\n <td><code>S_IFLNK</code></td>\n <td>File type constant for a symbolic link.</td>\n </tr>\n <tr>\n <td><code>S_IFSOCK</code></td>\n <td>File type constant for a socket.</td>\n </tr>\n</table>",
|
||
"type": "module",
|
||
"displayName": "File Type Constants"
|
||
},
|
||
{
|
||
"textRaw": "File Mode Constants",
|
||
"name": "file_mode_constants",
|
||
"desc": "<p>The following constants are meant for use with the <a href=\"#fs_class_fs_stats\"><code>fs.Stats</code></a> object's\n<code>mode</code> property for determining the access permissions for a file.</p>\n<table>\n <tr>\n <th>Constant</th>\n <th>Description</th>\n </tr>\n <tr>\n <td><code>S_IRWXU</code></td>\n <td>File mode indicating readable, writable, and executable by owner.</td>\n </tr>\n <tr>\n <td><code>S_IRUSR</code></td>\n <td>File mode indicating readable by owner.</td>\n </tr>\n <tr>\n <td><code>S_IWUSR</code></td>\n <td>File mode indicating writable by owner.</td>\n </tr>\n <tr>\n <td><code>S_IXUSR</code></td>\n <td>File mode indicating executable by owner.</td>\n </tr>\n <tr>\n <td><code>S_IRWXG</code></td>\n <td>File mode indicating readable, writable, and executable by group.</td>\n </tr>\n <tr>\n <td><code>S_IRGRP</code></td>\n <td>File mode indicating readable by group.</td>\n </tr>\n <tr>\n <td><code>S_IWGRP</code></td>\n <td>File mode indicating writable by group.</td>\n </tr>\n <tr>\n <td><code>S_IXGRP</code></td>\n <td>File mode indicating executable by group.</td>\n </tr>\n <tr>\n <td><code>S_IRWXO</code></td>\n <td>File mode indicating readable, writable, and executable by others.</td>\n </tr>\n <tr>\n <td><code>S_IROTH</code></td>\n <td>File mode indicating readable by others.</td>\n </tr>\n <tr>\n <td><code>S_IWOTH</code></td>\n <td>File mode indicating writable by others.</td>\n </tr>\n <tr>\n <td><code>S_IXOTH</code></td>\n <td>File mode indicating executable by others.</td>\n </tr>\n</table>",
|
||
"type": "module",
|
||
"displayName": "File Mode Constants"
|
||
}
|
||
],
|
||
"type": "module",
|
||
"displayName": "FS Constants"
|
||
},
|
||
{
|
||
"textRaw": "File System Flags",
|
||
"name": "file_system_flags",
|
||
"desc": "<p>The following flags are available wherever the <code>flag</code> option takes a\nstring.</p>\n<ul>\n<li>\n<p><code>'a'</code>: Open file for appending.\nThe file is created if it does not exist.</p>\n</li>\n<li>\n<p><code>'ax'</code>: Like <code>'a'</code> but fails if the path exists.</p>\n</li>\n<li>\n<p><code>'a+'</code>: Open file for reading and appending.\nThe file is created if it does not exist.</p>\n</li>\n<li>\n<p><code>'ax+'</code>: Like <code>'a+'</code> but fails if the path exists.</p>\n</li>\n<li>\n<p><code>'as'</code>: Open file for appending in synchronous mode.\nThe file is created if it does not exist.</p>\n</li>\n<li>\n<p><code>'as+'</code>: Open file for reading and appending in synchronous mode.\nThe file is created if it does not exist.</p>\n</li>\n<li>\n<p><code>'r'</code>: Open file for reading.\nAn exception occurs if the file does not exist.</p>\n</li>\n<li>\n<p><code>'r+'</code>: Open file for reading and writing.\nAn exception occurs if the file does not exist.</p>\n</li>\n<li>\n<p><code>'rs+'</code>: Open file for reading and writing in synchronous mode. Instructs\nthe operating system to bypass the local file system cache.</p>\n<p>This is primarily useful for opening files on NFS mounts as it allows\nskipping the potentially stale local cache. It has a very real impact on\nI/O performance so using this flag is not recommended unless it is needed.</p>\n<p>This doesn't turn <code>fs.open()</code> or <code>fsPromises.open()</code> into a synchronous\nblocking call. If synchronous operation is desired, something like\n<code>fs.openSync()</code> should be used.</p>\n</li>\n<li>\n<p><code>'w'</code>: Open file for writing.\nThe file is created (if it does not exist) or truncated (if it exists).</p>\n</li>\n<li>\n<p><code>'wx'</code>: Like <code>'w'</code> but fails if the path exists.</p>\n</li>\n<li>\n<p><code>'w+'</code>: Open file for reading and writing.\nThe file is created (if it does not exist) or truncated (if it exists).</p>\n</li>\n<li>\n<p><code>'wx+'</code>: Like <code>'w+'</code> but fails if the path exists.</p>\n</li>\n</ul>\n<p><code>flag</code> can also be a number as documented by <a href=\"http://man7.org/linux/man-pages/man2/open.2.html\"><code>open(2)</code></a>; commonly used constants\nare available from <code>fs.constants</code>. On Windows, flags are translated to\ntheir equivalent ones where applicable, e.g. <code>O_WRONLY</code> to <code>FILE_GENERIC_WRITE</code>,\nor <code>O_EXCL|O_CREAT</code> to <code>CREATE_NEW</code>, as accepted by <code>CreateFileW</code>.</p>\n<p>The exclusive flag <code>'x'</code> (<code>O_EXCL</code> flag in <a href=\"http://man7.org/linux/man-pages/man2/open.2.html\"><code>open(2)</code></a>) ensures that path is newly\ncreated. On POSIX systems, path is considered to exist even if it is a symlink\nto a non-existent file. The exclusive flag may or may not work with network\nfile systems.</p>\n<p>On Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.</p>\n<p>Modifying a file rather than replacing it may require a flags mode of <code>'r+'</code>\nrather than the default mode <code>'w'</code>.</p>\n<p>The behavior of some flags are platform-specific. As such, opening a directory\non macOS and Linux with the <code>'a+'</code> flag, as in the example below, will return an\nerror. In contrast, on Windows and FreeBSD, a file descriptor or a <code>FileHandle</code>\nwill be returned.</p>\n<pre><code class=\"language-js\">// macOS and Linux\nfs.open('<directory>', 'a+', (err, fd) => {\n // => [Error: EISDIR: illegal operation on a directory, open <directory>]\n});\n\n// Windows and FreeBSD\nfs.open('<directory>', 'a+', (err, fd) => {\n // => null, <fd>\n});\n</code></pre>\n<p>On Windows, opening an existing hidden file using the <code>'w'</code> flag (either\nthrough <code>fs.open()</code> or <code>fs.writeFile()</code> or <code>fsPromises.open()</code>) will fail with\n<code>EPERM</code>. Existing hidden files can be opened for writing with the <code>'r+'</code> flag.</p>\n<p>A call to <code>fs.ftruncate()</code> or <code>filehandle.truncate()</code> can be used to reset\nthe file contents.</p>",
|
||
"type": "module",
|
||
"displayName": "File System Flags"
|
||
}
|
||
],
|
||
"classes": [
|
||
{
|
||
"textRaw": "Class: `fs.Dirent`",
|
||
"type": "class",
|
||
"name": "fs.Dirent",
|
||
"meta": {
|
||
"added": [
|
||
"v10.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>A representation of a directory entry, which can be a file or a subdirectory\nwithin the directory, as returned by reading from an <a href=\"#fs_class_fs_dir\"><code>fs.Dir</code></a>. The\ndirectory entry is a combination of the file name and file type pairs.</p>\n<p>Additionally, when <a href=\"#fs_fs_readdir_path_options_callback\"><code>fs.readdir()</code></a> or <a href=\"#fs_fs_readdirsync_path_options\"><code>fs.readdirSync()</code></a> is called with\nthe <code>withFileTypes</code> option set to <code>true</code>, the resulting array is filled with\n<code>fs.Dirent</code> objects, rather than strings or <code>Buffers</code>.</p>",
|
||
"methods": [
|
||
{
|
||
"textRaw": "`dirent.isBlockDevice()`",
|
||
"type": "method",
|
||
"name": "isBlockDevice",
|
||
"meta": {
|
||
"added": [
|
||
"v10.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Dirent</code> object describes a block device.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dirent.isCharacterDevice()`",
|
||
"type": "method",
|
||
"name": "isCharacterDevice",
|
||
"meta": {
|
||
"added": [
|
||
"v10.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Dirent</code> object describes a character device.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dirent.isDirectory()`",
|
||
"type": "method",
|
||
"name": "isDirectory",
|
||
"meta": {
|
||
"added": [
|
||
"v10.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Dirent</code> object describes a file system\ndirectory.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dirent.isFIFO()`",
|
||
"type": "method",
|
||
"name": "isFIFO",
|
||
"meta": {
|
||
"added": [
|
||
"v10.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Dirent</code> object describes a first-in-first-out\n(FIFO) pipe.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dirent.isFile()`",
|
||
"type": "method",
|
||
"name": "isFile",
|
||
"meta": {
|
||
"added": [
|
||
"v10.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Dirent</code> object describes a regular file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dirent.isSocket()`",
|
||
"type": "method",
|
||
"name": "isSocket",
|
||
"meta": {
|
||
"added": [
|
||
"v10.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Dirent</code> object describes a socket.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`dirent.isSymbolicLink()`",
|
||
"type": "method",
|
||
"name": "isSymbolicLink",
|
||
"meta": {
|
||
"added": [
|
||
"v10.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Dirent</code> object describes a symbolic link.</p>"
|
||
}
|
||
],
|
||
"properties": [
|
||
{
|
||
"textRaw": "`name` {string|Buffer}",
|
||
"type": "string|Buffer",
|
||
"name": "name",
|
||
"meta": {
|
||
"added": [
|
||
"v10.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The file name that this <code>fs.Dirent</code> object refers to. The type of this\nvalue is determined by the <code>options.encoding</code> passed to <a href=\"#fs_fs_readdir_path_options_callback\"><code>fs.readdir()</code></a> or\n<a href=\"#fs_fs_readdirsync_path_options\"><code>fs.readdirSync()</code></a>.</p>"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "Class: `fs.FSWatcher`",
|
||
"type": "class",
|
||
"name": "fs.FSWatcher",
|
||
"meta": {
|
||
"added": [
|
||
"v0.5.8"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<ul>\n<li>Extends <a href=\"events.html#events_class_eventemitter\" class=\"type\"><EventEmitter></a></li>\n</ul>\n<p>A successful call to <a href=\"#fs_fs_watch_filename_options_listener\"><code>fs.watch()</code></a> method will return a new <code>fs.FSWatcher</code>\nobject.</p>\n<p>All <code>fs.FSWatcher</code> objects emit a <code>'change'</code> event whenever a specific watched\nfile is modified.</p>",
|
||
"events": [
|
||
{
|
||
"textRaw": "Event: `'change'`",
|
||
"type": "event",
|
||
"name": "change",
|
||
"meta": {
|
||
"added": [
|
||
"v0.5.8"
|
||
],
|
||
"changes": []
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`eventType` {string} The type of change event that has occurred",
|
||
"name": "eventType",
|
||
"type": "string",
|
||
"desc": "The type of change event that has occurred"
|
||
},
|
||
{
|
||
"textRaw": "`filename` {string|Buffer} The filename that changed (if relevant/available)",
|
||
"name": "filename",
|
||
"type": "string|Buffer",
|
||
"desc": "The filename that changed (if relevant/available)"
|
||
}
|
||
],
|
||
"desc": "<p>Emitted when something changes in a watched directory or file.\nSee more details in <a href=\"#fs_fs_watch_filename_options_listener\"><code>fs.watch()</code></a>.</p>\n<p>The <code>filename</code> argument may not be provided depending on operating system\nsupport. If <code>filename</code> is provided, it will be provided as a <code>Buffer</code> if\n<code>fs.watch()</code> is called with its <code>encoding</code> option set to <code>'buffer'</code>, otherwise\n<code>filename</code> will be a UTF-8 string.</p>\n<pre><code class=\"language-js\">// Example when handled through fs.watch() listener\nfs.watch('./tmp', { encoding: 'buffer' }, (eventType, filename) => {\n if (filename) {\n console.log(filename);\n // Prints: <Buffer ...>\n }\n});\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "Event: `'close'`",
|
||
"type": "event",
|
||
"name": "close",
|
||
"meta": {
|
||
"added": [
|
||
"v10.0.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"params": [],
|
||
"desc": "<p>Emitted when the watcher stops watching for changes. The closed\n<code>fs.FSWatcher</code> object is no longer usable in the event handler.</p>"
|
||
},
|
||
{
|
||
"textRaw": "Event: `'error'`",
|
||
"type": "event",
|
||
"name": "error",
|
||
"meta": {
|
||
"added": [
|
||
"v0.5.8"
|
||
],
|
||
"changes": []
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`error` {Error}",
|
||
"name": "error",
|
||
"type": "Error"
|
||
}
|
||
],
|
||
"desc": "<p>Emitted when an error occurs while watching the file. The errored\n<code>fs.FSWatcher</code> object is no longer usable in the event handler.</p>"
|
||
}
|
||
],
|
||
"methods": [
|
||
{
|
||
"textRaw": "`watcher.close()`",
|
||
"type": "method",
|
||
"name": "close",
|
||
"meta": {
|
||
"added": [
|
||
"v0.5.8"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Stop watching for changes on the given <code>fs.FSWatcher</code>. Once stopped, the\n<code>fs.FSWatcher</code> object is no longer usable.</p>"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "Class: `fs.ReadStream`",
|
||
"type": "class",
|
||
"name": "fs.ReadStream",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.93"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<ul>\n<li>Extends: <a href=\"stream.html#stream_class_stream_readable\" class=\"type\"><stream.Readable></a></li>\n</ul>\n<p>A successful call to <code>fs.createReadStream()</code> will return a new <code>fs.ReadStream</code>\nobject.</p>",
|
||
"events": [
|
||
{
|
||
"textRaw": "Event: `'close'`",
|
||
"type": "event",
|
||
"name": "close",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.93"
|
||
],
|
||
"changes": []
|
||
},
|
||
"params": [],
|
||
"desc": "<p>Emitted when the <code>fs.ReadStream</code>'s underlying file descriptor has been closed.</p>"
|
||
},
|
||
{
|
||
"textRaw": "Event: `'open'`",
|
||
"type": "event",
|
||
"name": "open",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.93"
|
||
],
|
||
"changes": []
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer} Integer file descriptor used by the `ReadStream`.",
|
||
"name": "fd",
|
||
"type": "integer",
|
||
"desc": "Integer file descriptor used by the `ReadStream`."
|
||
}
|
||
],
|
||
"desc": "<p>Emitted when the <code>fs.ReadStream</code>'s file descriptor has been opened.</p>"
|
||
},
|
||
{
|
||
"textRaw": "Event: `'ready'`",
|
||
"type": "event",
|
||
"name": "ready",
|
||
"meta": {
|
||
"added": [
|
||
"v9.11.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"params": [],
|
||
"desc": "<p>Emitted when the <code>fs.ReadStream</code> is ready to be used.</p>\n<p>Fires immediately after <code>'open'</code>.</p>"
|
||
}
|
||
],
|
||
"properties": [
|
||
{
|
||
"textRaw": "`bytesRead` {number}",
|
||
"type": "number",
|
||
"name": "bytesRead",
|
||
"meta": {
|
||
"added": [
|
||
"v6.4.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The number of bytes that have been read so far.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`path` {string|Buffer}",
|
||
"type": "string|Buffer",
|
||
"name": "path",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.93"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The path to the file the stream is reading from as specified in the first\nargument to <code>fs.createReadStream()</code>. If <code>path</code> is passed as a string, then\n<code>readStream.path</code> will be a string. If <code>path</code> is passed as a <code>Buffer</code>, then\n<code>readStream.path</code> will be a <code>Buffer</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`pending` {boolean}",
|
||
"type": "boolean",
|
||
"name": "pending",
|
||
"meta": {
|
||
"added": [
|
||
"v11.2.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>This property is <code>true</code> if the underlying file has not been opened yet,\ni.e. before the <code>'ready'</code> event is emitted.</p>"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "Class: `fs.Stats`",
|
||
"type": "class",
|
||
"name": "fs.Stats",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v8.1.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/13173",
|
||
"description": "Added times as numbers."
|
||
}
|
||
]
|
||
},
|
||
"desc": "<p>A <code>fs.Stats</code> object provides information about a file.</p>\n<p>Objects returned from <a href=\"#fs_fs_stat_path_options_callback\"><code>fs.stat()</code></a>, <a href=\"#fs_fs_lstat_path_options_callback\"><code>fs.lstat()</code></a> and <a href=\"#fs_fs_fstat_fd_options_callback\"><code>fs.fstat()</code></a> and\ntheir synchronous counterparts are of this type.\nIf <code>bigint</code> in the <code>options</code> passed to those methods is true, the numeric values\nwill be <code>bigint</code> instead of <code>number</code>, and the object will contain additional\nnanosecond-precision properties suffixed with <code>Ns</code>.</p>\n<pre><code class=\"language-console\">Stats {\n dev: 2114,\n ino: 48064969,\n mode: 33188,\n nlink: 1,\n uid: 85,\n gid: 100,\n rdev: 0,\n size: 527,\n blksize: 4096,\n blocks: 8,\n atimeMs: 1318289051000.1,\n mtimeMs: 1318289051000.1,\n ctimeMs: 1318289051000.1,\n birthtimeMs: 1318289051000.1,\n atime: Mon, 10 Oct 2011 23:24:11 GMT,\n mtime: Mon, 10 Oct 2011 23:24:11 GMT,\n ctime: Mon, 10 Oct 2011 23:24:11 GMT,\n birthtime: Mon, 10 Oct 2011 23:24:11 GMT }\n</code></pre>\n<p><code>bigint</code> version:</p>\n<pre><code class=\"language-console\">BigIntStats {\n dev: 2114n,\n ino: 48064969n,\n mode: 33188n,\n nlink: 1n,\n uid: 85n,\n gid: 100n,\n rdev: 0n,\n size: 527n,\n blksize: 4096n,\n blocks: 8n,\n atimeMs: 1318289051000n,\n mtimeMs: 1318289051000n,\n ctimeMs: 1318289051000n,\n birthtimeMs: 1318289051000n,\n atimeNs: 1318289051000000000n,\n mtimeNs: 1318289051000000000n,\n ctimeNs: 1318289051000000000n,\n birthtimeNs: 1318289051000000000n,\n atime: Mon, 10 Oct 2011 23:24:11 GMT,\n mtime: Mon, 10 Oct 2011 23:24:11 GMT,\n ctime: Mon, 10 Oct 2011 23:24:11 GMT,\n birthtime: Mon, 10 Oct 2011 23:24:11 GMT }\n</code></pre>",
|
||
"methods": [
|
||
{
|
||
"textRaw": "`stats.isBlockDevice()`",
|
||
"type": "method",
|
||
"name": "isBlockDevice",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.10"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Stats</code> object describes a block device.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`stats.isCharacterDevice()`",
|
||
"type": "method",
|
||
"name": "isCharacterDevice",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.10"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Stats</code> object describes a character device.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`stats.isDirectory()`",
|
||
"type": "method",
|
||
"name": "isDirectory",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.10"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Stats</code> object describes a file system directory.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`stats.isFIFO()`",
|
||
"type": "method",
|
||
"name": "isFIFO",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.10"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Stats</code> object describes a first-in-first-out (FIFO)\npipe.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`stats.isFile()`",
|
||
"type": "method",
|
||
"name": "isFile",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.10"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Stats</code> object describes a regular file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`stats.isSocket()`",
|
||
"type": "method",
|
||
"name": "isSocket",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.10"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Stats</code> object describes a socket.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`stats.isSymbolicLink()`",
|
||
"type": "method",
|
||
"name": "isSymbolicLink",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.10"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": []
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the <code>fs.Stats</code> object describes a symbolic link.</p>\n<p>This method is only valid when using <a href=\"#fs_fs_lstat_path_options_callback\"><code>fs.lstat()</code></a>.</p>"
|
||
}
|
||
],
|
||
"properties": [
|
||
{
|
||
"textRaw": "`dev` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "dev",
|
||
"desc": "<p>The numeric identifier of the device containing the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`ino` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "ino",
|
||
"desc": "<p>The file system specific \"Inode\" number for the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "mode",
|
||
"desc": "<p>A bit-field describing the file type and mode.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`nlink` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "nlink",
|
||
"desc": "<p>The number of hard-links that exist for the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`uid` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "uid",
|
||
"desc": "<p>The numeric user identifier of the user that owns the file (POSIX).</p>"
|
||
},
|
||
{
|
||
"textRaw": "`gid` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "gid",
|
||
"desc": "<p>The numeric group identifier of the group that owns the file (POSIX).</p>"
|
||
},
|
||
{
|
||
"textRaw": "`rdev` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "rdev",
|
||
"desc": "<p>A numeric device identifier if the file is considered \"special\".</p>"
|
||
},
|
||
{
|
||
"textRaw": "`size` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "size",
|
||
"desc": "<p>The size of the file in bytes.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`blksize` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "blksize",
|
||
"desc": "<p>The file system block size for i/o operations.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`blocks` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "blocks",
|
||
"desc": "<p>The number of blocks allocated for this file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`atimeMs` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "atimeMs",
|
||
"meta": {
|
||
"added": [
|
||
"v8.1.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The timestamp indicating the last time this file was accessed expressed in\nmilliseconds since the POSIX Epoch.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`mtimeMs` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "mtimeMs",
|
||
"meta": {
|
||
"added": [
|
||
"v8.1.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The timestamp indicating the last time this file was modified expressed in\nmilliseconds since the POSIX Epoch.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`ctimeMs` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "ctimeMs",
|
||
"meta": {
|
||
"added": [
|
||
"v8.1.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The timestamp indicating the last time the file status was changed expressed\nin milliseconds since the POSIX Epoch.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`birthtimeMs` {number|bigint}",
|
||
"type": "number|bigint",
|
||
"name": "birthtimeMs",
|
||
"meta": {
|
||
"added": [
|
||
"v8.1.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The timestamp indicating the creation time of this file expressed in\nmilliseconds since the POSIX Epoch.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`atimeNs` {bigint}",
|
||
"type": "bigint",
|
||
"name": "atimeNs",
|
||
"meta": {
|
||
"added": [
|
||
"v12.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>Only present when <code>bigint: true</code> is passed into the method that generates\nthe object.\nThe timestamp indicating the last time this file was accessed expressed in\nnanoseconds since the POSIX Epoch.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`mtimeNs` {bigint}",
|
||
"type": "bigint",
|
||
"name": "mtimeNs",
|
||
"meta": {
|
||
"added": [
|
||
"v12.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>Only present when <code>bigint: true</code> is passed into the method that generates\nthe object.\nThe timestamp indicating the last time this file was modified expressed in\nnanoseconds since the POSIX Epoch.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`ctimeNs` {bigint}",
|
||
"type": "bigint",
|
||
"name": "ctimeNs",
|
||
"meta": {
|
||
"added": [
|
||
"v12.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>Only present when <code>bigint: true</code> is passed into the method that generates\nthe object.\nThe timestamp indicating the last time the file status was changed expressed\nin nanoseconds since the POSIX Epoch.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`birthtimeNs` {bigint}",
|
||
"type": "bigint",
|
||
"name": "birthtimeNs",
|
||
"meta": {
|
||
"added": [
|
||
"v12.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>Only present when <code>bigint: true</code> is passed into the method that generates\nthe object.\nThe timestamp indicating the creation time of this file expressed in\nnanoseconds since the POSIX Epoch.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`atime` {Date}",
|
||
"type": "Date",
|
||
"name": "atime",
|
||
"meta": {
|
||
"added": [
|
||
"v0.11.13"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The timestamp indicating the last time this file was accessed.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`mtime` {Date}",
|
||
"type": "Date",
|
||
"name": "mtime",
|
||
"meta": {
|
||
"added": [
|
||
"v0.11.13"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The timestamp indicating the last time this file was modified.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`ctime` {Date}",
|
||
"type": "Date",
|
||
"name": "ctime",
|
||
"meta": {
|
||
"added": [
|
||
"v0.11.13"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The timestamp indicating the last time the file status was changed.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`birthtime` {Date}",
|
||
"type": "Date",
|
||
"name": "birthtime",
|
||
"meta": {
|
||
"added": [
|
||
"v0.11.13"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The timestamp indicating the creation time of this file.</p>"
|
||
}
|
||
],
|
||
"modules": [
|
||
{
|
||
"textRaw": "Stat Time Values",
|
||
"name": "stat_time_values",
|
||
"desc": "<p>The <code>atimeMs</code>, <code>mtimeMs</code>, <code>ctimeMs</code>, <code>birthtimeMs</code> properties are\nnumeric values that hold the corresponding times in milliseconds. Their\nprecision is platform specific. When <code>bigint: true</code> is passed into the\nmethod that generates the object, the properties will be <a href=\"https://tc39.github.io/proposal-bigint\">bigints</a>,\notherwise they will be <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type\">numbers</a>.</p>\n<p>The <code>atimeNs</code>, <code>mtimeNs</code>, <code>ctimeNs</code>, <code>birthtimeNs</code> properties are\n<a href=\"https://tc39.github.io/proposal-bigint\">bigints</a> that hold the corresponding times in nanoseconds. They are\nonly present when <code>bigint: true</code> is passed into the method that generates\nthe object. Their precision is platform specific.</p>\n<p><code>atime</code>, <code>mtime</code>, <code>ctime</code>, and <code>birthtime</code> are\n<a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date\"><code>Date</code></a> object alternate representations of the various times. The\n<code>Date</code> and number values are not connected. Assigning a new number value, or\nmutating the <code>Date</code> value, will not be reflected in the corresponding alternate\nrepresentation.</p>\n<p>The times in the stat object have the following semantics:</p>\n<ul>\n<li><code>atime</code> \"Access Time\": Time when file data last accessed. Changed\nby the <a href=\"http://man7.org/linux/man-pages/man2/mknod.2.html\"><code>mknod(2)</code></a>, <a href=\"http://man7.org/linux/man-pages/man2/utimes.2.html\"><code>utimes(2)</code></a>, and <a href=\"http://man7.org/linux/man-pages/man2/read.2.html\"><code>read(2)</code></a> system calls.</li>\n<li><code>mtime</code> \"Modified Time\": Time when file data last modified.\nChanged by the <a href=\"http://man7.org/linux/man-pages/man2/mknod.2.html\"><code>mknod(2)</code></a>, <a href=\"http://man7.org/linux/man-pages/man2/utimes.2.html\"><code>utimes(2)</code></a>, and <a href=\"http://man7.org/linux/man-pages/man2/write.2.html\"><code>write(2)</code></a> system calls.</li>\n<li><code>ctime</code> \"Change Time\": Time when file status was last changed\n(inode data modification). Changed by the <a href=\"http://man7.org/linux/man-pages/man2/chmod.2.html\"><code>chmod(2)</code></a>, <a href=\"http://man7.org/linux/man-pages/man2/chown.2.html\"><code>chown(2)</code></a>,\n<a href=\"http://man7.org/linux/man-pages/man2/link.2.html\"><code>link(2)</code></a>, <a href=\"http://man7.org/linux/man-pages/man2/mknod.2.html\"><code>mknod(2)</code></a>, <a href=\"http://man7.org/linux/man-pages/man2/rename.2.html\"><code>rename(2)</code></a>, <a href=\"http://man7.org/linux/man-pages/man2/unlink.2.html\"><code>unlink(2)</code></a>, <a href=\"http://man7.org/linux/man-pages/man2/utimes.2.html\"><code>utimes(2)</code></a>,\n<a href=\"http://man7.org/linux/man-pages/man2/read.2.html\"><code>read(2)</code></a>, and <a href=\"http://man7.org/linux/man-pages/man2/write.2.html\"><code>write(2)</code></a> system calls.</li>\n<li><code>birthtime</code> \"Birth Time\": Time of file creation. Set once when the\nfile is created. On filesystems where birthtime is not available,\nthis field may instead hold either the <code>ctime</code> or\n<code>1970-01-01T00:00Z</code> (ie, Unix epoch timestamp <code>0</code>). This value may be greater\nthan <code>atime</code> or <code>mtime</code> in this case. On Darwin and other FreeBSD variants,\nalso set if the <code>atime</code> is explicitly set to an earlier value than the current\n<code>birthtime</code> using the <a href=\"http://man7.org/linux/man-pages/man2/utimes.2.html\"><code>utimes(2)</code></a> system call.</li>\n</ul>\n<p>Prior to Node.js 0.12, the <code>ctime</code> held the <code>birthtime</code> on Windows systems. As\nof 0.12, <code>ctime</code> is not \"creation time\", and on Unix systems, it never was.</p>",
|
||
"type": "module",
|
||
"displayName": "Stat Time Values"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "Class: `fs.WriteStream`",
|
||
"type": "class",
|
||
"name": "fs.WriteStream",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.93"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<ul>\n<li>Extends <a href=\"stream.html#stream_class_stream_writable\" class=\"type\"><stream.Writable></a></li>\n</ul>",
|
||
"events": [
|
||
{
|
||
"textRaw": "Event: `'close'`",
|
||
"type": "event",
|
||
"name": "close",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.93"
|
||
],
|
||
"changes": []
|
||
},
|
||
"params": [],
|
||
"desc": "<p>Emitted when the <code>WriteStream</code>'s underlying file descriptor has been closed.</p>"
|
||
},
|
||
{
|
||
"textRaw": "Event: `'open'`",
|
||
"type": "event",
|
||
"name": "open",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.93"
|
||
],
|
||
"changes": []
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer} Integer file descriptor used by the `WriteStream`.",
|
||
"name": "fd",
|
||
"type": "integer",
|
||
"desc": "Integer file descriptor used by the `WriteStream`."
|
||
}
|
||
],
|
||
"desc": "<p>Emitted when the <code>WriteStream</code>'s file is opened.</p>"
|
||
},
|
||
{
|
||
"textRaw": "Event: `'ready'`",
|
||
"type": "event",
|
||
"name": "ready",
|
||
"meta": {
|
||
"added": [
|
||
"v9.11.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"params": [],
|
||
"desc": "<p>Emitted when the <code>fs.WriteStream</code> is ready to be used.</p>\n<p>Fires immediately after <code>'open'</code>.</p>"
|
||
}
|
||
],
|
||
"properties": [
|
||
{
|
||
"textRaw": "`writeStream.bytesWritten`",
|
||
"name": "bytesWritten",
|
||
"meta": {
|
||
"added": [
|
||
"v0.4.7"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The number of bytes written so far. Does not include data that is still queued\nfor writing.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`writeStream.path`",
|
||
"name": "path",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.93"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>The path to the file the stream is writing to as specified in the first\nargument to <a href=\"#fs_fs_createwritestream_path_options\"><code>fs.createWriteStream()</code></a>. If <code>path</code> is passed as a string, then\n<code>writeStream.path</code> will be a string. If <code>path</code> is passed as a <code>Buffer</code>, then\n<code>writeStream.path</code> will be a <code>Buffer</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`pending` {boolean}",
|
||
"type": "boolean",
|
||
"name": "pending",
|
||
"meta": {
|
||
"added": [
|
||
"v11.2.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"desc": "<p>This property is <code>true</code> if the underlying file has not been opened yet,\ni.e. before the <code>'ready'</code> event is emitted.</p>"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"methods": [
|
||
{
|
||
"textRaw": "`fs.access(path[, mode], callback)`",
|
||
"type": "method",
|
||
"name": "access",
|
||
"meta": {
|
||
"added": [
|
||
"v0.11.15"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v6.3.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/6534",
|
||
"description": "The constants like `fs.R_OK`, etc which were present directly on `fs` were moved into `fs.constants` as a soft deprecation. Thus for Node.js `< v6.3.0` use `fs` to access those constants, or do something like `(fs.constants || fs).R_OK` to work with all versions."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `fs.constants.F_OK`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`fs.constants.F_OK`"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Tests a user's permissions for the file or directory specified by <code>path</code>.\nThe <code>mode</code> argument is an optional integer that specifies the accessibility\nchecks to be performed. Check <a href=\"#fs_file_access_constants\">File Access Constants</a> for possible values\nof <code>mode</code>. It is possible to create a mask consisting of the bitwise OR of\ntwo or more values (e.g. <code>fs.constants.W_OK | fs.constants.R_OK</code>).</p>\n<p>The final argument, <code>callback</code>, is a callback function that is invoked with\na possible error argument. If any of the accessibility checks fail, the error\nargument will be an <code>Error</code> object. The following examples check if\n<code>package.json</code> exists, and if it is readable or writable.</p>\n<pre><code class=\"language-js\">const file = 'package.json';\n\n// Check if the file exists in the current directory.\nfs.access(file, fs.constants.F_OK, (err) => {\n console.log(`${file} ${err ? 'does not exist' : 'exists'}`);\n});\n\n// Check if the file is readable.\nfs.access(file, fs.constants.R_OK, (err) => {\n console.log(`${file} ${err ? 'is not readable' : 'is readable'}`);\n});\n\n// Check if the file is writable.\nfs.access(file, fs.constants.W_OK, (err) => {\n console.log(`${file} ${err ? 'is not writable' : 'is writable'}`);\n});\n\n// Check if the file exists in the current directory, and if it is writable.\nfs.access(file, fs.constants.F_OK | fs.constants.W_OK, (err) => {\n if (err) {\n console.error(\n `${file} ${err.code === 'ENOENT' ? 'does not exist' : 'is read-only'}`);\n } else {\n console.log(`${file} exists, and it is writable`);\n }\n});\n</code></pre>\n<p>Using <code>fs.access()</code> to check for the accessibility of a file before calling\n<code>fs.open()</code>, <code>fs.readFile()</code> or <code>fs.writeFile()</code> is not recommended. Doing\nso introduces a race condition, since other processes may change the file's\nstate between the two calls. Instead, user code should open/read/write the\nfile directly and handle the error raised if the file is not accessible.</p>\n<p><strong>write (NOT RECOMMENDED)</strong></p>\n<pre><code class=\"language-js\">fs.access('myfile', (err) => {\n if (!err) {\n console.error('myfile already exists');\n return;\n }\n\n fs.open('myfile', 'wx', (err, fd) => {\n if (err) throw err;\n writeMyData(fd);\n });\n});\n</code></pre>\n<p><strong>write (RECOMMENDED)</strong></p>\n<pre><code class=\"language-js\">fs.open('myfile', 'wx', (err, fd) => {\n if (err) {\n if (err.code === 'EEXIST') {\n console.error('myfile already exists');\n return;\n }\n\n throw err;\n }\n\n writeMyData(fd);\n});\n</code></pre>\n<p><strong>read (NOT RECOMMENDED)</strong></p>\n<pre><code class=\"language-js\">fs.access('myfile', (err) => {\n if (err) {\n if (err.code === 'ENOENT') {\n console.error('myfile does not exist');\n return;\n }\n\n throw err;\n }\n\n fs.open('myfile', 'r', (err, fd) => {\n if (err) throw err;\n readMyData(fd);\n });\n});\n</code></pre>\n<p><strong>read (RECOMMENDED)</strong></p>\n<pre><code class=\"language-js\">fs.open('myfile', 'r', (err, fd) => {\n if (err) {\n if (err.code === 'ENOENT') {\n console.error('myfile does not exist');\n return;\n }\n\n throw err;\n }\n\n readMyData(fd);\n});\n</code></pre>\n<p>The \"not recommended\" examples above check for accessibility and then use the\nfile; the \"recommended\" examples are better because they use the file directly\nand handle the error, if any.</p>\n<p>In general, check for the accessibility of a file only if the file will not be\nused directly, for example when its accessibility is a signal from another\nprocess.</p>\n<p>On Windows, access-control policies (ACLs) on a directory may limit access to\na file or directory. The <code>fs.access()</code> function, however, does not check the\nACL and therefore may report that a path is accessible even if the ACL restricts\nthe user from reading or writing to it.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.accessSync(path[, mode])`",
|
||
"type": "method",
|
||
"name": "accessSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.11.15"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `fs.constants.F_OK`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`fs.constants.F_OK`"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronously tests a user's permissions for the file or directory specified\nby <code>path</code>. The <code>mode</code> argument is an optional integer that specifies the\naccessibility checks to be performed. Check <a href=\"#fs_file_access_constants\">File Access Constants</a> for\npossible values of <code>mode</code>. It is possible to create a mask consisting of\nthe bitwise OR of two or more values\n(e.g. <code>fs.constants.W_OK | fs.constants.R_OK</code>).</p>\n<p>If any of the accessibility checks fail, an <code>Error</code> will be thrown. Otherwise,\nthe method will return <code>undefined</code>.</p>\n<pre><code class=\"language-js\">try {\n fs.accessSync('etc/passwd', fs.constants.R_OK | fs.constants.W_OK);\n console.log('can read/write');\n} catch (err) {\n console.error('no access!');\n}\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.appendFile(path, data[, options], callback)`",
|
||
"type": "method",
|
||
"name": "appendFile",
|
||
"meta": {
|
||
"added": [
|
||
"v0.6.7"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7831",
|
||
"description": "The passed `options` object will never be modified."
|
||
},
|
||
{
|
||
"version": "v5.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/3163",
|
||
"description": "The `file` parameter can be a file descriptor now."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL|number} filename or file descriptor",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL|number",
|
||
"desc": "filename or file descriptor"
|
||
},
|
||
{
|
||
"textRaw": "`data` {string|Buffer}",
|
||
"name": "data",
|
||
"type": "string|Buffer"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `0o666`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`0o666`"
|
||
},
|
||
{
|
||
"textRaw": "`flag` {string} See [support of file system `flags`][]. **Default:** `'a'`.",
|
||
"name": "flag",
|
||
"type": "string",
|
||
"default": "`'a'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously append data to a file, creating the file if it does not yet\nexist. <code>data</code> can be a string or a <a href=\"buffer.html#buffer_buffer\"><code>Buffer</code></a>.</p>\n<pre><code class=\"language-js\">fs.appendFile('message.txt', 'data to append', (err) => {\n if (err) throw err;\n console.log('The \"data to append\" was appended to file!');\n});\n</code></pre>\n<p>If <code>options</code> is a string, then it specifies the encoding:</p>\n<pre><code class=\"language-js\">fs.appendFile('message.txt', 'data to append', 'utf8', callback);\n</code></pre>\n<p>The <code>path</code> may be specified as a numeric file descriptor that has been opened\nfor appending (using <code>fs.open()</code> or <code>fs.openSync()</code>). The file descriptor will\nnot be closed automatically.</p>\n<pre><code class=\"language-js\">fs.open('message.txt', 'a', (err, fd) => {\n if (err) throw err;\n fs.appendFile(fd, 'data to append', 'utf8', (err) => {\n fs.close(fd, (err) => {\n if (err) throw err;\n });\n if (err) throw err;\n });\n});\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.appendFileSync(path, data[, options])`",
|
||
"type": "method",
|
||
"name": "appendFileSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.6.7"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7831",
|
||
"description": "The passed `options` object will never be modified."
|
||
},
|
||
{
|
||
"version": "v5.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/3163",
|
||
"description": "The `file` parameter can be a file descriptor now."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL|number} filename or file descriptor",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL|number",
|
||
"desc": "filename or file descriptor"
|
||
},
|
||
{
|
||
"textRaw": "`data` {string|Buffer}",
|
||
"name": "data",
|
||
"type": "string|Buffer"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `0o666`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`0o666`"
|
||
},
|
||
{
|
||
"textRaw": "`flag` {string} See [support of file system `flags`][]. **Default:** `'a'`.",
|
||
"name": "flag",
|
||
"type": "string",
|
||
"default": "`'a'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronously append data to a file, creating the file if it does not yet\nexist. <code>data</code> can be a string or a <a href=\"buffer.html#buffer_buffer\"><code>Buffer</code></a>.</p>\n<pre><code class=\"language-js\">try {\n fs.appendFileSync('message.txt', 'data to append');\n console.log('The \"data to append\" was appended to file!');\n} catch (err) {\n /* Handle the error */\n}\n</code></pre>\n<p>If <code>options</code> is a string, then it specifies the encoding:</p>\n<pre><code class=\"language-js\">fs.appendFileSync('message.txt', 'data to append', 'utf8');\n</code></pre>\n<p>The <code>path</code> may be specified as a numeric file descriptor that has been opened\nfor appending (using <code>fs.open()</code> or <code>fs.openSync()</code>). The file descriptor will\nnot be closed automatically.</p>\n<pre><code class=\"language-js\">let fd;\n\ntry {\n fd = fs.openSync('message.txt', 'a');\n fs.appendFileSync(fd, 'data to append', 'utf8');\n} catch (err) {\n /* Handle the error */\n} finally {\n if (fd !== undefined)\n fs.closeSync(fd);\n}\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.chmod(path, mode, callback)`",
|
||
"type": "method",
|
||
"name": "chmod",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.30"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer}",
|
||
"name": "mode",
|
||
"type": "string|integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously changes the permissions of a file. No arguments other than a\npossible exception are given to the completion callback.</p>\n<p>See also: <a href=\"http://man7.org/linux/man-pages/man2/chmod.2.html\"><code>chmod(2)</code></a>.</p>\n<pre><code class=\"language-js\">fs.chmod('my_file.txt', 0o775, (err) => {\n if (err) throw err;\n console.log('The permissions for file \"my_file.txt\" have been changed!');\n});\n</code></pre>",
|
||
"modules": [
|
||
{
|
||
"textRaw": "File modes",
|
||
"name": "file_modes",
|
||
"desc": "<p>The <code>mode</code> argument used in both the <code>fs.chmod()</code> and <code>fs.chmodSync()</code>\nmethods is a numeric bitmask created using a logical OR of the following\nconstants:</p>\n<table>\n<thead>\n<tr>\n<th>Constant</th>\n<th>Octal</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>fs.constants.S_IRUSR</code></td>\n<td><code>0o400</code></td>\n<td>read by owner</td>\n</tr>\n<tr>\n<td><code>fs.constants.S_IWUSR</code></td>\n<td><code>0o200</code></td>\n<td>write by owner</td>\n</tr>\n<tr>\n<td><code>fs.constants.S_IXUSR</code></td>\n<td><code>0o100</code></td>\n<td>execute/search by owner</td>\n</tr>\n<tr>\n<td><code>fs.constants.S_IRGRP</code></td>\n<td><code>0o40</code></td>\n<td>read by group</td>\n</tr>\n<tr>\n<td><code>fs.constants.S_IWGRP</code></td>\n<td><code>0o20</code></td>\n<td>write by group</td>\n</tr>\n<tr>\n<td><code>fs.constants.S_IXGRP</code></td>\n<td><code>0o10</code></td>\n<td>execute/search by group</td>\n</tr>\n<tr>\n<td><code>fs.constants.S_IROTH</code></td>\n<td><code>0o4</code></td>\n<td>read by others</td>\n</tr>\n<tr>\n<td><code>fs.constants.S_IWOTH</code></td>\n<td><code>0o2</code></td>\n<td>write by others</td>\n</tr>\n<tr>\n<td><code>fs.constants.S_IXOTH</code></td>\n<td><code>0o1</code></td>\n<td>execute/search by others</td>\n</tr>\n</tbody>\n</table>\n<p>An easier method of constructing the <code>mode</code> is to use a sequence of three\noctal digits (e.g. <code>765</code>). The left-most digit (<code>7</code> in the example), specifies\nthe permissions for the file owner. The middle digit (<code>6</code> in the example),\nspecifies permissions for the group. The right-most digit (<code>5</code> in the example),\nspecifies the permissions for others.</p>\n<table>\n<thead>\n<tr>\n<th>Number</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>7</code></td>\n<td>read, write, and execute</td>\n</tr>\n<tr>\n<td><code>6</code></td>\n<td>read and write</td>\n</tr>\n<tr>\n<td><code>5</code></td>\n<td>read and execute</td>\n</tr>\n<tr>\n<td><code>4</code></td>\n<td>read only</td>\n</tr>\n<tr>\n<td><code>3</code></td>\n<td>write and execute</td>\n</tr>\n<tr>\n<td><code>2</code></td>\n<td>write only</td>\n</tr>\n<tr>\n<td><code>1</code></td>\n<td>execute only</td>\n</tr>\n<tr>\n<td><code>0</code></td>\n<td>no permission</td>\n</tr>\n</tbody>\n</table>\n<p>For example, the octal value <code>0o765</code> means:</p>\n<ul>\n<li>The owner may read, write and execute the file.</li>\n<li>The group may read and write the file.</li>\n<li>Others may read and execute the file.</li>\n</ul>\n<p>When using raw numbers where file modes are expected, any value larger than\n<code>0o777</code> may result in platform-specific behaviors that are not supported to work\nconsistently. Therefore constants like <code>S_ISVTX</code>, <code>S_ISGID</code> or <code>S_ISUID</code> are not\nexposed in <code>fs.constants</code>.</p>\n<p>Caveats: on Windows only the write permission can be changed, and the\ndistinction among the permissions of group, owner or others is not\nimplemented.</p>",
|
||
"type": "module",
|
||
"displayName": "File modes"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`fs.chmodSync(path, mode)`",
|
||
"type": "method",
|
||
"name": "chmodSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.6.7"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer}",
|
||
"name": "mode",
|
||
"type": "string|integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_chmod_path_mode_callback\"><code>fs.chmod()</code></a>.</p>\n<p>See also: <a href=\"http://man7.org/linux/man-pages/man2/chmod.2.html\"><code>chmod(2)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.chown(path, uid, gid, callback)`",
|
||
"type": "method",
|
||
"name": "chown",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.97"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`uid` {integer}",
|
||
"name": "uid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`gid` {integer}",
|
||
"name": "gid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously changes owner and group of a file. No arguments other than a\npossible exception are given to the completion callback.</p>\n<p>See also: <a href=\"http://man7.org/linux/man-pages/man2/chown.2.html\"><code>chown(2)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.chownSync(path, uid, gid)`",
|
||
"type": "method",
|
||
"name": "chownSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.97"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`uid` {integer}",
|
||
"name": "uid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`gid` {integer}",
|
||
"name": "gid",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronously changes owner and group of a file. Returns <code>undefined</code>.\nThis is the synchronous version of <a href=\"#fs_fs_chown_path_uid_gid_callback\"><code>fs.chown()</code></a>.</p>\n<p>See also: <a href=\"http://man7.org/linux/man-pages/man2/chown.2.html\"><code>chown(2)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.close(fd, callback)`",
|
||
"type": "method",
|
||
"name": "close",
|
||
"meta": {
|
||
"added": [
|
||
"v0.0.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/close.2.html\"><code>close(2)</code></a>. No arguments other than a possible exception are given\nto the completion callback.</p>\n<p>Calling <code>fs.close()</code> on any file descriptor (<code>fd</code>) that is currently in use\nthrough any other <code>fs</code> operation may lead to undefined behavior.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.closeSync(fd)`",
|
||
"type": "method",
|
||
"name": "closeSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/close.2.html\"><code>close(2)</code></a>. Returns <code>undefined</code>.</p>\n<p>Calling <code>fs.closeSync()</code> on any file descriptor (<code>fd</code>) that is currently in use\nthrough any other <code>fs</code> operation may lead to undefined behavior.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.copyFile(src, dest[, flags], callback)`",
|
||
"type": "method",
|
||
"name": "copyFile",
|
||
"meta": {
|
||
"added": [
|
||
"v8.5.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`src` {string|Buffer|URL} source filename to copy",
|
||
"name": "src",
|
||
"type": "string|Buffer|URL",
|
||
"desc": "source filename to copy"
|
||
},
|
||
{
|
||
"textRaw": "`dest` {string|Buffer|URL} destination filename of the copy operation",
|
||
"name": "dest",
|
||
"type": "string|Buffer|URL",
|
||
"desc": "destination filename of the copy operation"
|
||
},
|
||
{
|
||
"textRaw": "`flags` {number} modifiers for copy operation. **Default:** `0`.",
|
||
"name": "flags",
|
||
"type": "number",
|
||
"default": "`0`",
|
||
"desc": "modifiers for copy operation."
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously copies <code>src</code> to <code>dest</code>. By default, <code>dest</code> is overwritten if it\nalready exists. No arguments other than a possible exception are given to the\ncallback function. Node.js makes no guarantees about the atomicity of the copy\noperation. If an error occurs after the destination file has been opened for\nwriting, Node.js will attempt to remove the destination.</p>\n<p><code>flags</code> is an optional integer that specifies the behavior\nof the copy operation. It is possible to create a mask consisting of the bitwise\nOR of two or more values (e.g.\n<code>fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE</code>).</p>\n<ul>\n<li><code>fs.constants.COPYFILE_EXCL</code>: The copy operation will fail if <code>dest</code> already\nexists.</li>\n<li><code>fs.constants.COPYFILE_FICLONE</code>: The copy operation will attempt to create a\ncopy-on-write reflink. If the platform does not support copy-on-write, then a\nfallback copy mechanism is used.</li>\n<li><code>fs.constants.COPYFILE_FICLONE_FORCE</code>: The copy operation will attempt to\ncreate a copy-on-write reflink. If the platform does not support copy-on-write,\nthen the operation will fail.</li>\n</ul>\n<pre><code class=\"language-js\">const fs = require('fs');\n\n// destination.txt will be created or overwritten by default.\nfs.copyFile('source.txt', 'destination.txt', (err) => {\n if (err) throw err;\n console.log('source.txt was copied to destination.txt');\n});\n</code></pre>\n<p>If the third argument is a number, then it specifies <code>flags</code>:</p>\n<pre><code class=\"language-js\">const fs = require('fs');\nconst { COPYFILE_EXCL } = fs.constants;\n\n// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.\nfs.copyFile('source.txt', 'destination.txt', COPYFILE_EXCL, callback);\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.copyFileSync(src, dest[, flags])`",
|
||
"type": "method",
|
||
"name": "copyFileSync",
|
||
"meta": {
|
||
"added": [
|
||
"v8.5.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`src` {string|Buffer|URL} source filename to copy",
|
||
"name": "src",
|
||
"type": "string|Buffer|URL",
|
||
"desc": "source filename to copy"
|
||
},
|
||
{
|
||
"textRaw": "`dest` {string|Buffer|URL} destination filename of the copy operation",
|
||
"name": "dest",
|
||
"type": "string|Buffer|URL",
|
||
"desc": "destination filename of the copy operation"
|
||
},
|
||
{
|
||
"textRaw": "`flags` {number} modifiers for copy operation. **Default:** `0`.",
|
||
"name": "flags",
|
||
"type": "number",
|
||
"default": "`0`",
|
||
"desc": "modifiers for copy operation."
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronously copies <code>src</code> to <code>dest</code>. By default, <code>dest</code> is overwritten if it\nalready exists. Returns <code>undefined</code>. Node.js makes no guarantees about the\natomicity of the copy operation. If an error occurs after the destination file\nhas been opened for writing, Node.js will attempt to remove the destination.</p>\n<p><code>flags</code> is an optional integer that specifies the behavior\nof the copy operation. It is possible to create a mask consisting of the bitwise\nOR of two or more values (e.g.\n<code>fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE</code>).</p>\n<ul>\n<li><code>fs.constants.COPYFILE_EXCL</code>: The copy operation will fail if <code>dest</code> already\nexists.</li>\n<li><code>fs.constants.COPYFILE_FICLONE</code>: The copy operation will attempt to create a\ncopy-on-write reflink. If the platform does not support copy-on-write, then a\nfallback copy mechanism is used.</li>\n<li><code>fs.constants.COPYFILE_FICLONE_FORCE</code>: The copy operation will attempt to\ncreate a copy-on-write reflink. If the platform does not support copy-on-write,\nthen the operation will fail.</li>\n</ul>\n<pre><code class=\"language-js\">const fs = require('fs');\n\n// destination.txt will be created or overwritten by default.\nfs.copyFileSync('source.txt', 'destination.txt');\nconsole.log('source.txt was copied to destination.txt');\n</code></pre>\n<p>If the third argument is a number, then it specifies <code>flags</code>:</p>\n<pre><code class=\"language-js\">const fs = require('fs');\nconst { COPYFILE_EXCL } = fs.constants;\n\n// By using COPYFILE_EXCL, the operation will fail if destination.txt exists.\nfs.copyFileSync('source.txt', 'destination.txt', COPYFILE_EXCL);\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.createReadStream(path[, options])`",
|
||
"type": "method",
|
||
"name": "createReadStream",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/29212",
|
||
"description": "Enable `emitClose` option."
|
||
},
|
||
{
|
||
"version": "v11.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/19898",
|
||
"description": "Impose new restrictions on `start` and `end`, throwing more appropriate errors in cases when we cannot reasonably handle the input values."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7831",
|
||
"description": "The passed `options` object will never be modified."
|
||
},
|
||
{
|
||
"version": "v2.3.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/1845",
|
||
"description": "The passed `options` object can be a string now."
|
||
},
|
||
{
|
||
"version": "v12.17.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/29083",
|
||
"description": "The `fs` options allow overriding the used `fs` implementation."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {fs.ReadStream} See [Readable Stream][].",
|
||
"name": "return",
|
||
"type": "fs.ReadStream",
|
||
"desc": "See [Readable Stream][]."
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`flags` {string} See [support of file system `flags`][]. **Default:** `'r'`.",
|
||
"name": "flags",
|
||
"type": "string",
|
||
"default": "`'r'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
},
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `null`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`null`"
|
||
},
|
||
{
|
||
"textRaw": "`fd` {integer} **Default:** `null`",
|
||
"name": "fd",
|
||
"type": "integer",
|
||
"default": "`null`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `0o666`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`0o666`"
|
||
},
|
||
{
|
||
"textRaw": "`autoClose` {boolean} **Default:** `true`",
|
||
"name": "autoClose",
|
||
"type": "boolean",
|
||
"default": "`true`"
|
||
},
|
||
{
|
||
"textRaw": "`emitClose` {boolean} **Default:** `false`",
|
||
"name": "emitClose",
|
||
"type": "boolean",
|
||
"default": "`false`"
|
||
},
|
||
{
|
||
"textRaw": "`start` {integer}",
|
||
"name": "start",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`end` {integer} **Default:** `Infinity`",
|
||
"name": "end",
|
||
"type": "integer",
|
||
"default": "`Infinity`"
|
||
},
|
||
{
|
||
"textRaw": "`highWaterMark` {integer} **Default:** `64 * 1024`",
|
||
"name": "highWaterMark",
|
||
"type": "integer",
|
||
"default": "`64 * 1024`"
|
||
},
|
||
{
|
||
"textRaw": "`fs` {Object|null} **Default:** `null`",
|
||
"name": "fs",
|
||
"type": "Object|null",
|
||
"default": "`null`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Unlike the 16 kb default <code>highWaterMark</code> for a readable stream, the stream\nreturned by this method has a default <code>highWaterMark</code> of 64 kb.</p>\n<p><code>options</code> can include <code>start</code> and <code>end</code> values to read a range of bytes from\nthe file instead of the entire file. Both <code>start</code> and <code>end</code> are inclusive and\nstart counting at 0, allowed values are in the\n[0, <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER\"><code>Number.MAX_SAFE_INTEGER</code></a>] range. If <code>fd</code> is specified and <code>start</code> is\nomitted or <code>undefined</code>, <code>fs.createReadStream()</code> reads sequentially from the\ncurrent file position. The <code>encoding</code> can be any one of those accepted by\n<a href=\"buffer.html#buffer_buffer\"><code>Buffer</code></a>.</p>\n<p>If <code>fd</code> is specified, <code>ReadStream</code> will ignore the <code>path</code> argument and will use\nthe specified file descriptor. This means that no <code>'open'</code> event will be\nemitted. <code>fd</code> should be blocking; non-blocking <code>fd</code>s should be passed to\n<a href=\"net.html#net_class_net_socket\"><code>net.Socket</code></a>.</p>\n<p>If <code>fd</code> points to a character device that only supports blocking reads\n(such as keyboard or sound card), read operations do not finish until data is\navailable. This can prevent the process from exiting and the stream from\nclosing naturally.</p>\n<p>By default, the stream will not emit a <code>'close'</code> event after it has been\ndestroyed. This is the opposite of the default for other <code>Readable</code> streams.\nSet the <code>emitClose</code> option to <code>true</code> to change this behavior.</p>\n<p>By providing the <code>fs</code> option, it is possible to override the corresponding <code>fs</code>\nimplementations for <code>open</code>, <code>read</code>, and <code>close</code>. When providing the <code>fs</code> option,\noverrides for <code>open</code>, <code>read</code>, and <code>close</code> are required.</p>\n<pre><code class=\"language-js\">const fs = require('fs');\n// Create a stream from some character device.\nconst stream = fs.createReadStream('/dev/input/event0');\nsetTimeout(() => {\n stream.close(); // This may not close the stream.\n // Artificially marking end-of-stream, as if the underlying resource had\n // indicated end-of-file by itself, allows the stream to close.\n // This does not cancel pending read operations, and if there is such an\n // operation, the process may still not be able to exit successfully\n // until it finishes.\n stream.push(null);\n stream.read(0);\n}, 100);\n</code></pre>\n<p>If <code>autoClose</code> is false, then the file descriptor won't be closed, even if\nthere's an error. It is the application's responsibility to close it and make\nsure there's no file descriptor leak. If <code>autoClose</code> is set to true (default\nbehavior), on <code>'error'</code> or <code>'end'</code> the file descriptor will be closed\nautomatically.</p>\n<p><code>mode</code> sets the file mode (permission and sticky bits), but only if the\nfile was created.</p>\n<p>An example to read the last 10 bytes of a file which is 100 bytes long:</p>\n<pre><code class=\"language-js\">fs.createReadStream('sample.txt', { start: 90, end: 99 });\n</code></pre>\n<p>If <code>options</code> is a string, then it specifies the encoding.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.createWriteStream(path[, options])`",
|
||
"type": "method",
|
||
"name": "createWriteStream",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/29212",
|
||
"description": "Enable `emitClose` option."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7831",
|
||
"description": "The passed `options` object will never be modified."
|
||
},
|
||
{
|
||
"version": "v5.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/3679",
|
||
"description": "The `autoClose` option is supported now."
|
||
},
|
||
{
|
||
"version": "v2.3.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/1845",
|
||
"description": "The passed `options` object can be a string now."
|
||
},
|
||
{
|
||
"version": "v12.17.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/v12.17.0",
|
||
"description": "The `fs` options allow overriding the used `fs` implementation."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {fs.WriteStream} See [Writable Stream][].",
|
||
"name": "return",
|
||
"type": "fs.WriteStream",
|
||
"desc": "See [Writable Stream][]."
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`flags` {string} See [support of file system `flags`][]. **Default:** `'w'`.",
|
||
"name": "flags",
|
||
"type": "string",
|
||
"default": "`'w'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
},
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`fd` {integer} **Default:** `null`",
|
||
"name": "fd",
|
||
"type": "integer",
|
||
"default": "`null`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `0o666`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`0o666`"
|
||
},
|
||
{
|
||
"textRaw": "`autoClose` {boolean} **Default:** `true`",
|
||
"name": "autoClose",
|
||
"type": "boolean",
|
||
"default": "`true`"
|
||
},
|
||
{
|
||
"textRaw": "`emitClose` {boolean} **Default:** `false`",
|
||
"name": "emitClose",
|
||
"type": "boolean",
|
||
"default": "`false`"
|
||
},
|
||
{
|
||
"textRaw": "`start` {integer}",
|
||
"name": "start",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`fs` {Object|null} **Default:** `null`",
|
||
"name": "fs",
|
||
"type": "Object|null",
|
||
"default": "`null`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p><code>options</code> may also include a <code>start</code> option to allow writing data at\nsome position past the beginning of the file, allowed values are in the\n[0, <a href=\"https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/MAX_SAFE_INTEGER\"><code>Number.MAX_SAFE_INTEGER</code></a>] range. Modifying a file rather\nthan replacing it may require a <code>flags</code> mode of <code>r+</code> rather than the\ndefault mode <code>w</code>. The <code>encoding</code> can be any one of those accepted by\n<a href=\"buffer.html#buffer_buffer\"><code>Buffer</code></a>.</p>\n<p>If <code>autoClose</code> is set to true (default behavior) on <code>'error'</code> or <code>'finish'</code>\nthe file descriptor will be closed automatically. If <code>autoClose</code> is false,\nthen the file descriptor won't be closed, even if there's an error.\nIt is the application's responsibility to close it and make sure there's no\nfile descriptor leak.</p>\n<p>By default, the stream will not emit a <code>'close'</code> event after it has been\ndestroyed. This is the opposite of the default for other <code>Writable</code> streams.\nSet the <code>emitClose</code> option to <code>true</code> to change this behavior.</p>\n<p>By providing the <code>fs</code> option it is possible to override the corresponding <code>fs</code>\nimplementations for <code>open</code>, <code>write</code>, <code>writev</code> and <code>close</code>. Overriding <code>write()</code>\nwithout <code>writev()</code> can reduce performance as some optimizations (<code>_writev()</code>)\nwill be disabled. When providing the <code>fs</code> option, overrides for <code>open</code>,\n<code>close</code>, and at least one of <code>write</code> and <code>writev</code> are required.</p>\n<p>Like <a href=\"#fs_class_fs_readstream\"><code>ReadStream</code></a>, if <code>fd</code> is specified, <a href=\"#fs_class_fs_writestream\"><code>WriteStream</code></a> will ignore the\n<code>path</code> argument and will use the specified file descriptor. This means that no\n<code>'open'</code> event will be emitted. <code>fd</code> should be blocking; non-blocking <code>fd</code>s\nshould be passed to <a href=\"net.html#net_class_net_socket\"><code>net.Socket</code></a>.</p>\n<p>If <code>options</code> is a string, then it specifies the encoding.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.exists(path, callback)`",
|
||
"type": "method",
|
||
"name": "exists",
|
||
"meta": {
|
||
"added": [
|
||
"v0.0.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
],
|
||
"deprecated": [
|
||
"v1.0.0"
|
||
]
|
||
},
|
||
"stability": 0,
|
||
"stabilityText": "Deprecated: Use [`fs.stat()`][] or [`fs.access()`][] instead.",
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`exists` {boolean}",
|
||
"name": "exists",
|
||
"type": "boolean"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Test whether or not the given path exists by checking with the file system.\nThen call the <code>callback</code> argument with either true or false:</p>\n<pre><code class=\"language-js\">fs.exists('/etc/passwd', (exists) => {\n console.log(exists ? 'it\\'s there' : 'no passwd!');\n});\n</code></pre>\n<p><strong>The parameters for this callback are not consistent with other Node.js\ncallbacks.</strong> Normally, the first parameter to a Node.js callback is an <code>err</code>\nparameter, optionally followed by other parameters. The <code>fs.exists()</code> callback\nhas only one boolean parameter. This is one reason <code>fs.access()</code> is recommended\ninstead of <code>fs.exists()</code>.</p>\n<p>Using <code>fs.exists()</code> to check for the existence of a file before calling\n<code>fs.open()</code>, <code>fs.readFile()</code> or <code>fs.writeFile()</code> is not recommended. Doing\nso introduces a race condition, since other processes may change the file's\nstate between the two calls. Instead, user code should open/read/write the\nfile directly and handle the error raised if the file does not exist.</p>\n<p><strong>write (NOT RECOMMENDED)</strong></p>\n<pre><code class=\"language-js\">fs.exists('myfile', (exists) => {\n if (exists) {\n console.error('myfile already exists');\n } else {\n fs.open('myfile', 'wx', (err, fd) => {\n if (err) throw err;\n writeMyData(fd);\n });\n }\n});\n</code></pre>\n<p><strong>write (RECOMMENDED)</strong></p>\n<pre><code class=\"language-js\">fs.open('myfile', 'wx', (err, fd) => {\n if (err) {\n if (err.code === 'EEXIST') {\n console.error('myfile already exists');\n return;\n }\n\n throw err;\n }\n\n writeMyData(fd);\n});\n</code></pre>\n<p><strong>read (NOT RECOMMENDED)</strong></p>\n<pre><code class=\"language-js\">fs.exists('myfile', (exists) => {\n if (exists) {\n fs.open('myfile', 'r', (err, fd) => {\n if (err) throw err;\n readMyData(fd);\n });\n } else {\n console.error('myfile does not exist');\n }\n});\n</code></pre>\n<p><strong>read (RECOMMENDED)</strong></p>\n<pre><code class=\"language-js\">fs.open('myfile', 'r', (err, fd) => {\n if (err) {\n if (err.code === 'ENOENT') {\n console.error('myfile does not exist');\n return;\n }\n\n throw err;\n }\n\n readMyData(fd);\n});\n</code></pre>\n<p>The \"not recommended\" examples above check for existence and then use the\nfile; the \"recommended\" examples are better because they use the file directly\nand handle the error, if any.</p>\n<p>In general, check for the existence of a file only if the file won’t be\nused directly, for example when its existence is a signal from another\nprocess.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.existsSync(path)`",
|
||
"type": "method",
|
||
"name": "existsSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {boolean}",
|
||
"name": "return",
|
||
"type": "boolean"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>true</code> if the path exists, <code>false</code> otherwise.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"fs.html#fs_fs_exists_path_callback\"><code>fs.exists()</code></a>.</p>\n<p><code>fs.exists()</code> is deprecated, but <code>fs.existsSync()</code> is not. The <code>callback</code>\nparameter to <code>fs.exists()</code> accepts parameters that are inconsistent with other\nNode.js callbacks. <code>fs.existsSync()</code> does not use a callback.</p>\n<pre><code class=\"language-js\">if (fs.existsSync('/etc/passwd')) {\n console.log('The path exists.');\n}\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.fchmod(fd, mode, callback)`",
|
||
"type": "method",
|
||
"name": "fchmod",
|
||
"meta": {
|
||
"added": [
|
||
"v0.4.7"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer}",
|
||
"name": "mode",
|
||
"type": "string|integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/fchmod.2.html\"><code>fchmod(2)</code></a>. No arguments other than a possible exception\nare given to the completion callback.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.fchmodSync(fd, mode)`",
|
||
"type": "method",
|
||
"name": "fchmodSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.4.7"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer}",
|
||
"name": "mode",
|
||
"type": "string|integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/fchmod.2.html\"><code>fchmod(2)</code></a>. Returns <code>undefined</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.fchown(fd, uid, gid, callback)`",
|
||
"type": "method",
|
||
"name": "fchown",
|
||
"meta": {
|
||
"added": [
|
||
"v0.4.7"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`uid` {integer}",
|
||
"name": "uid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`gid` {integer}",
|
||
"name": "gid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/fchown.2.html\"><code>fchown(2)</code></a>. No arguments other than a possible exception are given\nto the completion callback.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.fchownSync(fd, uid, gid)`",
|
||
"type": "method",
|
||
"name": "fchownSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.4.7"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`uid` {integer}",
|
||
"name": "uid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`gid` {integer}",
|
||
"name": "gid",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/fchown.2.html\"><code>fchown(2)</code></a>. Returns <code>undefined</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.fdatasync(fd, callback)`",
|
||
"type": "method",
|
||
"name": "fdatasync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.96"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/fdatasync.2.html\"><code>fdatasync(2)</code></a>. No arguments other than a possible exception are\ngiven to the completion callback.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.fdatasyncSync(fd)`",
|
||
"type": "method",
|
||
"name": "fdatasyncSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.96"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/fdatasync.2.html\"><code>fdatasync(2)</code></a>. Returns <code>undefined</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.fstat(fd[, options], callback)`",
|
||
"type": "method",
|
||
"name": "fstat",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.95"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v10.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/20220",
|
||
"description": "Accepts an additional `options` object to specify whether the numeric values returned should be bigint."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`bigint` {boolean} Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`. **Default:** `false`.",
|
||
"name": "bigint",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`."
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`stats` {fs.Stats}",
|
||
"name": "stats",
|
||
"type": "fs.Stats"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/fstat.2.html\"><code>fstat(2)</code></a>. The callback gets two arguments <code>(err, stats)</code> where\n<code>stats</code> is an <a href=\"#fs_class_fs_stats\"><code>fs.Stats</code></a> object. <code>fstat()</code> is identical to <a href=\"fs.html#fs_fs_stat_path_options_callback\"><code>stat()</code></a>,\nexcept that the file to be stat-ed is specified by the file descriptor <code>fd</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.fstatSync(fd[, options])`",
|
||
"type": "method",
|
||
"name": "fstatSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.95"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/20220",
|
||
"description": "Accepts an additional `options` object to specify whether the numeric values returned should be bigint."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {fs.Stats}",
|
||
"name": "return",
|
||
"type": "fs.Stats"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`bigint` {boolean} Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`. **Default:** `false`.",
|
||
"name": "bigint",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/fstat.2.html\"><code>fstat(2)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.fsync(fd, callback)`",
|
||
"type": "method",
|
||
"name": "fsync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.96"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/fsync.2.html\"><code>fsync(2)</code></a>. No arguments other than a possible exception are given\nto the completion callback.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.fsyncSync(fd)`",
|
||
"type": "method",
|
||
"name": "fsyncSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.96"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/fsync.2.html\"><code>fsync(2)</code></a>. Returns <code>undefined</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.ftruncate(fd[, len], callback)`",
|
||
"type": "method",
|
||
"name": "ftruncate",
|
||
"meta": {
|
||
"added": [
|
||
"v0.8.6"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`len` {integer} **Default:** `0`",
|
||
"name": "len",
|
||
"type": "integer",
|
||
"default": "`0`"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/ftruncate.2.html\"><code>ftruncate(2)</code></a>. No arguments other than a possible exception are\ngiven to the completion callback.</p>\n<p>If the file referred to by the file descriptor was larger than <code>len</code> bytes, only\nthe first <code>len</code> bytes will be retained in the file.</p>\n<p>For example, the following program retains only the first four bytes of the\nfile:</p>\n<pre><code class=\"language-js\">console.log(fs.readFileSync('temp.txt', 'utf8'));\n// Prints: Node.js\n\n// get the file descriptor of the file to be truncated\nconst fd = fs.openSync('temp.txt', 'r+');\n\n// Truncate the file to first four bytes\nfs.ftruncate(fd, 4, (err) => {\n assert.ifError(err);\n console.log(fs.readFileSync('temp.txt', 'utf8'));\n});\n// Prints: Node\n</code></pre>\n<p>If the file previously was shorter than <code>len</code> bytes, it is extended, and the\nextended part is filled with null bytes (<code>'\\0'</code>):</p>\n<pre><code class=\"language-js\">console.log(fs.readFileSync('temp.txt', 'utf8'));\n// Prints: Node.js\n\n// get the file descriptor of the file to be truncated\nconst fd = fs.openSync('temp.txt', 'r+');\n\n// Truncate the file to 10 bytes, whereas the actual size is 7 bytes\nfs.ftruncate(fd, 10, (err) => {\n assert.ifError(err);\n console.log(fs.readFileSync('temp.txt'));\n});\n// Prints: <Buffer 4e 6f 64 65 2e 6a 73 00 00 00>\n// ('Node.js\\0\\0\\0' in UTF8)\n</code></pre>\n<p>The last three bytes are null bytes (<code>'\\0'</code>), to compensate the over-truncation.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.ftruncateSync(fd[, len])`",
|
||
"type": "method",
|
||
"name": "ftruncateSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.8.6"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`len` {integer} **Default:** `0`",
|
||
"name": "len",
|
||
"type": "integer",
|
||
"default": "`0`"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>undefined</code>.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_ftruncate_fd_len_callback\"><code>fs.ftruncate()</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.futimes(fd, atime, mtime, callback)`",
|
||
"type": "method",
|
||
"name": "futimes",
|
||
"meta": {
|
||
"added": [
|
||
"v0.4.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v4.1.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/2387",
|
||
"description": "Numeric strings, `NaN` and `Infinity` are now allowed time specifiers."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`atime` {number|string|Date}",
|
||
"name": "atime",
|
||
"type": "number|string|Date"
|
||
},
|
||
{
|
||
"textRaw": "`mtime` {number|string|Date}",
|
||
"name": "mtime",
|
||
"type": "number|string|Date"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Change the file system timestamps of the object referenced by the supplied file\ndescriptor. See <a href=\"#fs_fs_utimes_path_atime_mtime_callback\"><code>fs.utimes()</code></a>.</p>\n<p>This function does not work on AIX versions before 7.1, it will return the\nerror <code>UV_ENOSYS</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.futimesSync(fd, atime, mtime)`",
|
||
"type": "method",
|
||
"name": "futimesSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.4.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v4.1.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/2387",
|
||
"description": "Numeric strings, `NaN` and `Infinity` are now allowed time specifiers."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`atime` {number|string|Date}",
|
||
"name": "atime",
|
||
"type": "number|string|Date"
|
||
},
|
||
{
|
||
"textRaw": "`mtime` {number|string|Date}",
|
||
"name": "mtime",
|
||
"type": "number|string|Date"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous version of <a href=\"#fs_fs_futimes_fd_atime_mtime_callback\"><code>fs.futimes()</code></a>. Returns <code>undefined</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.lchmod(path, mode, callback)`",
|
||
"type": "method",
|
||
"name": "lchmod",
|
||
"meta": {
|
||
"deprecated": [
|
||
"v0.4.7"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer}",
|
||
"name": "mode",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2\"><code>lchmod(2)</code></a>. No arguments other than a possible exception\nare given to the completion callback.</p>\n<p>Only available on macOS.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.lchmodSync(path, mode)`",
|
||
"type": "method",
|
||
"name": "lchmodSync",
|
||
"meta": {
|
||
"deprecated": [
|
||
"v0.4.7"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer}",
|
||
"name": "mode",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"https://www.freebsd.org/cgi/man.cgi?query=lchmod&sektion=2\"><code>lchmod(2)</code></a>. Returns <code>undefined</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.lchown(path, uid, gid, callback)`",
|
||
"type": "method",
|
||
"name": "lchown",
|
||
"meta": {
|
||
"changes": [
|
||
{
|
||
"version": "v10.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/21498",
|
||
"description": "This API is no longer deprecated."
|
||
},
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`uid` {integer}",
|
||
"name": "uid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`gid` {integer}",
|
||
"name": "gid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/lchown.2.html\"><code>lchown(2)</code></a>. No arguments other than a possible exception are given\nto the completion callback.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.lchownSync(path, uid, gid)`",
|
||
"type": "method",
|
||
"name": "lchownSync",
|
||
"meta": {
|
||
"changes": [
|
||
{
|
||
"version": "v10.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/21498",
|
||
"description": "This API is no longer deprecated."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`uid` {integer}",
|
||
"name": "uid",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`gid` {integer}",
|
||
"name": "gid",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/lchown.2.html\"><code>lchown(2)</code></a>. Returns <code>undefined</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.link(existingPath, newPath, callback)`",
|
||
"type": "method",
|
||
"name": "link",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `existingPath` and `newPath` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`existingPath` {string|Buffer|URL}",
|
||
"name": "existingPath",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`newPath` {string|Buffer|URL}",
|
||
"name": "newPath",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/link.2.html\"><code>link(2)</code></a>. No arguments other than a possible exception are given to\nthe completion callback.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.linkSync(existingPath, newPath)`",
|
||
"type": "method",
|
||
"name": "linkSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `existingPath` and `newPath` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`existingPath` {string|Buffer|URL}",
|
||
"name": "existingPath",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`newPath` {string|Buffer|URL}",
|
||
"name": "newPath",
|
||
"type": "string|Buffer|URL"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/link.2.html\"><code>link(2)</code></a>. Returns <code>undefined</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.lstat(path[, options], callback)`",
|
||
"type": "method",
|
||
"name": "lstat",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.30"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v10.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/20220",
|
||
"description": "Accepts an additional `options` object to specify whether the numeric values returned should be bigint."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`bigint` {boolean} Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`. **Default:** `false`.",
|
||
"name": "bigint",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`."
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`stats` {fs.Stats}",
|
||
"name": "stats",
|
||
"type": "fs.Stats"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/lstat.2.html\"><code>lstat(2)</code></a>. The callback gets two arguments <code>(err, stats)</code> where\n<code>stats</code> is a <a href=\"#fs_class_fs_stats\"><code>fs.Stats</code></a> object. <code>lstat()</code> is identical to <code>stat()</code>,\nexcept that if <code>path</code> is a symbolic link, then the link itself is stat-ed,\nnot the file that it refers to.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.lstatSync(path[, options])`",
|
||
"type": "method",
|
||
"name": "lstatSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.30"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v10.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/20220",
|
||
"description": "Accepts an additional `options` object to specify whether the numeric values returned should be bigint."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {fs.Stats}",
|
||
"name": "return",
|
||
"type": "fs.Stats"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`bigint` {boolean} Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`. **Default:** `false`.",
|
||
"name": "bigint",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/lstat.2.html\"><code>lstat(2)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.mkdir(path[, options], callback)`",
|
||
"type": "method",
|
||
"name": "mkdir",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.8"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.17.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/31530",
|
||
"description": "In `recursive` mode, the callback now receives the first created path as an argument."
|
||
},
|
||
{
|
||
"version": "v10.12.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/21875",
|
||
"description": "The second argument can now be an `options` object with `recursive` and `mode` properties."
|
||
},
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|integer}",
|
||
"name": "options",
|
||
"type": "Object|integer",
|
||
"options": [
|
||
{
|
||
"textRaw": "`recursive` {boolean} **Default:** `false`",
|
||
"name": "recursive",
|
||
"type": "boolean",
|
||
"default": "`false`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer} Not supported on Windows. **Default:** `0o777`.",
|
||
"name": "mode",
|
||
"type": "string|integer",
|
||
"default": "`0o777`",
|
||
"desc": "Not supported on Windows."
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously creates a directory.</p>\n<p>The callback is given a possible exception and, if <code>recursive</code> is <code>true</code>, the\nfirst directory path created, <code>(err, [path])</code>.</p>\n<p>The optional <code>options</code> argument can be an integer specifying mode (permission\nand sticky bits), or an object with a <code>mode</code> property and a <code>recursive</code>\nproperty indicating whether parent directories should be created. Calling\n<code>fs.mkdir()</code> when <code>path</code> is a directory that exists results in an error only\nwhen <code>recursive</code> is false.</p>\n<pre><code class=\"language-js\">// Creates /tmp/a/apple, regardless of whether `/tmp` and /tmp/a exist.\nfs.mkdir('/tmp/a/apple', { recursive: true }, (err) => {\n if (err) throw err;\n});\n</code></pre>\n<p>On Windows, using <code>fs.mkdir()</code> on the root directory even with recursion will\nresult in an error:</p>\n<pre><code class=\"language-js\">fs.mkdir('/', { recursive: true }, (err) => {\n // => [Error: EPERM: operation not permitted, mkdir 'C:\\']\n});\n</code></pre>\n<p>See also: <a href=\"http://man7.org/linux/man-pages/man2/mkdir.2.html\"><code>mkdir(2)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.mkdirSync(path[, options])`",
|
||
"type": "method",
|
||
"name": "mkdirSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.17.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/31530",
|
||
"description": "In `recursive` mode, the first created path is returned now."
|
||
},
|
||
{
|
||
"version": "v10.12.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/21875",
|
||
"description": "The second argument can now be an `options` object with `recursive` and `mode` properties."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {string|undefined}",
|
||
"name": "return",
|
||
"type": "string|undefined"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|integer}",
|
||
"name": "options",
|
||
"type": "Object|integer",
|
||
"options": [
|
||
{
|
||
"textRaw": "`recursive` {boolean} **Default:** `false`",
|
||
"name": "recursive",
|
||
"type": "boolean",
|
||
"default": "`false`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer} Not supported on Windows. **Default:** `0o777`.",
|
||
"name": "mode",
|
||
"type": "string|integer",
|
||
"default": "`0o777`",
|
||
"desc": "Not supported on Windows."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronously creates a directory. Returns <code>undefined</code>, or if <code>recursive</code> is\n<code>true</code>, the first directory path created.\nThis is the synchronous version of <a href=\"#fs_fs_mkdir_path_options_callback\"><code>fs.mkdir()</code></a>.</p>\n<p>See also: <a href=\"http://man7.org/linux/man-pages/man2/mkdir.2.html\"><code>mkdir(2)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.mkdtemp(prefix[, options], callback)`",
|
||
"type": "method",
|
||
"name": "mkdtemp",
|
||
"meta": {
|
||
"added": [
|
||
"v5.10.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v6.2.1",
|
||
"pr-url": "https://github.com/nodejs/node/pull/6828",
|
||
"description": "The `callback` parameter is optional now."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`prefix` {string}",
|
||
"name": "prefix",
|
||
"type": "string"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`directory` {string}",
|
||
"name": "directory",
|
||
"type": "string"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Creates a unique temporary directory.</p>\n<p>Generates six random characters to be appended behind a required\n<code>prefix</code> to create a unique temporary directory. Due to platform\ninconsistencies, avoid trailing <code>X</code> characters in <code>prefix</code>. Some platforms,\nnotably the BSDs, can return more than six random characters, and replace\ntrailing <code>X</code> characters in <code>prefix</code> with random characters.</p>\n<p>The created directory path is passed as a string to the callback's second\nparameter.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use.</p>\n<pre><code class=\"language-js\">fs.mkdtemp(path.join(os.tmpdir(), 'foo-'), (err, directory) => {\n if (err) throw err;\n console.log(directory);\n // Prints: /tmp/foo-itXde2 or C:\\Users\\...\\AppData\\Local\\Temp\\foo-itXde2\n});\n</code></pre>\n<p>The <code>fs.mkdtemp()</code> method will append the six randomly selected characters\ndirectly to the <code>prefix</code> string. For instance, given a directory <code>/tmp</code>, if the\nintention is to create a temporary directory <em>within</em> <code>/tmp</code>, the <code>prefix</code>\nmust end with a trailing platform-specific path separator\n(<code>require('path').sep</code>).</p>\n<pre><code class=\"language-js\">// The parent directory for the new temporary directory\nconst tmpDir = os.tmpdir();\n\n// This method is *INCORRECT*:\nfs.mkdtemp(tmpDir, (err, directory) => {\n if (err) throw err;\n console.log(directory);\n // Will print something similar to `/tmpabc123`.\n // A new temporary directory is created at the file system root\n // rather than *within* the /tmp directory.\n});\n\n// This method is *CORRECT*:\nconst { sep } = require('path');\nfs.mkdtemp(`${tmpDir}${sep}`, (err, directory) => {\n if (err) throw err;\n console.log(directory);\n // Will print something similar to `/tmp/abc123`.\n // A new temporary directory is created within\n // the /tmp directory.\n});\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.mkdtempSync(prefix[, options])`",
|
||
"type": "method",
|
||
"name": "mkdtempSync",
|
||
"meta": {
|
||
"added": [
|
||
"v5.10.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {string}",
|
||
"name": "return",
|
||
"type": "string"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`prefix` {string}",
|
||
"name": "prefix",
|
||
"type": "string"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns the created directory path.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_mkdtemp_prefix_options_callback\"><code>fs.mkdtemp()</code></a>.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.open(path[, flags[, mode]], callback)`",
|
||
"type": "method",
|
||
"name": "open",
|
||
"meta": {
|
||
"added": [
|
||
"v0.0.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v11.1.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/23767",
|
||
"description": "The `flags` argument is now optional and defaults to `'r'`."
|
||
},
|
||
{
|
||
"version": "v9.9.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/18801",
|
||
"description": "The `as` and `as+` modes are supported now."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`flags` {string|number} See [support of file system `flags`][]. **Default:** `'r'`.",
|
||
"name": "flags",
|
||
"type": "string|number",
|
||
"default": "`'r'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer} **Default:** `0o666` (readable and writable)",
|
||
"name": "mode",
|
||
"type": "string|integer",
|
||
"default": "`0o666` (readable and writable)"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous file open. See <a href=\"http://man7.org/linux/man-pages/man2/open.2.html\"><code>open(2)</code></a>.</p>\n<p><code>mode</code> sets the file mode (permission and sticky bits), but only if the file was\ncreated. On Windows, only the write permission can be manipulated; see\n<a href=\"#fs_fs_chmod_path_mode_callback\"><code>fs.chmod()</code></a>.</p>\n<p>The callback gets two arguments <code>(err, fd)</code>.</p>\n<p>Some characters (<code>< > : \" / \\ | ? *</code>) are reserved under Windows as documented\nby <a href=\"https://docs.microsoft.com/en-us/windows/desktop/FileIO/naming-a-file\">Naming Files, Paths, and Namespaces</a>. Under NTFS, if the filename contains\na colon, Node.js will open a file system stream, as described by\n<a href=\"https://docs.microsoft.com/en-us/windows/desktop/FileIO/using-streams\">this MSDN page</a>.</p>\n<p>Functions based on <code>fs.open()</code> exhibit this behavior as well:\n<code>fs.writeFile()</code>, <code>fs.readFile()</code>, etc.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.opendir(path[, options], callback)`",
|
||
"type": "method",
|
||
"name": "opendir",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.16.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/30114",
|
||
"description": "The `bufferSize` option was introduced."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`bufferSize` {number} Number of directory entries that are buffered internally when reading from the directory. Higher values lead to better performance but higher memory usage. **Default:** `32`",
|
||
"name": "bufferSize",
|
||
"type": "number",
|
||
"default": "`32`",
|
||
"desc": "Number of directory entries that are buffered internally when reading from the directory. Higher values lead to better performance but higher memory usage."
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`dir` {fs.Dir}",
|
||
"name": "dir",
|
||
"type": "fs.Dir"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously open a directory. See <a href=\"http://man7.org/linux/man-pages/man3/opendir.3.html\"><code>opendir(3)</code></a>.</p>\n<p>Creates an <a href=\"#fs_class_fs_dir\"><code>fs.Dir</code></a>, which contains all further functions for reading from\nand cleaning up the directory.</p>\n<p>The <code>encoding</code> option sets the encoding for the <code>path</code> while opening the\ndirectory and subsequent read operations.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.opendirSync(path[, options])`",
|
||
"type": "method",
|
||
"name": "opendirSync",
|
||
"meta": {
|
||
"added": [
|
||
"v12.12.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.16.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/30114",
|
||
"description": "The `bufferSize` option was introduced."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {fs.Dir}",
|
||
"name": "return",
|
||
"type": "fs.Dir"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`bufferSize` {number} Number of directory entries that are buffered internally when reading from the directory. Higher values lead to better performance but higher memory usage. **Default:** `32`",
|
||
"name": "bufferSize",
|
||
"type": "number",
|
||
"default": "`32`",
|
||
"desc": "Number of directory entries that are buffered internally when reading from the directory. Higher values lead to better performance but higher memory usage."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronously open a directory. See <a href=\"http://man7.org/linux/man-pages/man3/opendir.3.html\"><code>opendir(3)</code></a>.</p>\n<p>Creates an <a href=\"#fs_class_fs_dir\"><code>fs.Dir</code></a>, which contains all further functions for reading from\nand cleaning up the directory.</p>\n<p>The <code>encoding</code> option sets the encoding for the <code>path</code> while opening the\ndirectory and subsequent read operations.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.openSync(path[, flags, mode])`",
|
||
"type": "method",
|
||
"name": "openSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v11.1.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/23767",
|
||
"description": "The `flags` argument is now optional and defaults to `'r'`."
|
||
},
|
||
{
|
||
"version": "v9.9.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/18801",
|
||
"description": "The `as` and `as+` modes are supported now."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {number}",
|
||
"name": "return",
|
||
"type": "number"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`flags` {string|number} **Default:** `'r'`. See [support of file system `flags`][].",
|
||
"name": "flags",
|
||
"type": "string|number",
|
||
"default": "`'r'`. See [support of file system `flags`][]"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {string|integer} **Default:** `0o666`",
|
||
"name": "mode",
|
||
"type": "string|integer",
|
||
"default": "`0o666`"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns an integer representing the file descriptor.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_open_path_flags_mode_callback\"><code>fs.open()</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.read(fd, buffer, offset, length, position, callback)`",
|
||
"type": "method",
|
||
"name": "read",
|
||
"meta": {
|
||
"added": [
|
||
"v0.0.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/22150",
|
||
"description": "The `buffer` parameter can now be any `TypedArray`, or a `DataView`."
|
||
},
|
||
{
|
||
"version": "v7.4.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10382",
|
||
"description": "The `buffer` parameter can now be a `Uint8Array`."
|
||
},
|
||
{
|
||
"version": "v6.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/4518",
|
||
"description": "The `length` parameter can now be `0`."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffer` {Buffer|TypedArray|DataView}",
|
||
"name": "buffer",
|
||
"type": "Buffer|TypedArray|DataView"
|
||
},
|
||
{
|
||
"textRaw": "`offset` {integer}",
|
||
"name": "offset",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`length` {integer}",
|
||
"name": "length",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`bytesRead` {integer}",
|
||
"name": "bytesRead",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffer` {Buffer}",
|
||
"name": "buffer",
|
||
"type": "Buffer"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Read data from the file specified by <code>fd</code>.</p>\n<p><code>buffer</code> is the buffer that the data (read from the fd) will be written to.</p>\n<p><code>offset</code> is the offset in the buffer to start writing at.</p>\n<p><code>length</code> is an integer specifying the number of bytes to read.</p>\n<p><code>position</code> is an argument specifying where to begin reading from in the file.\nIf <code>position</code> is <code>null</code>, data will be read from the current file position,\nand the file position will be updated.\nIf <code>position</code> is an integer, the file position will remain unchanged.</p>\n<p>The callback is given the three arguments, <code>(err, bytesRead, buffer)</code>.</p>\n<p>If this method is invoked as its <a href=\"util.html#util_util_promisify_original\"><code>util.promisify()</code></a>ed version, it returns\na <code>Promise</code> for an <code>Object</code> with <code>bytesRead</code> and <code>buffer</code> properties.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.read(fd, [options,] callback)`",
|
||
"type": "method",
|
||
"name": "read",
|
||
"meta": {
|
||
"added": [
|
||
"v12.17.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.17.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/31402",
|
||
"description": "Options object can be passed in to make Buffer, offset, length and position optional"
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`buffer` {Buffer|TypedArray|DataView} **Default:** `Buffer.alloc(16384)`",
|
||
"name": "buffer",
|
||
"type": "Buffer|TypedArray|DataView",
|
||
"default": "`Buffer.alloc(16384)`"
|
||
},
|
||
{
|
||
"textRaw": "`offset` {integer} **Default:** `0`",
|
||
"name": "offset",
|
||
"type": "integer",
|
||
"default": "`0`"
|
||
},
|
||
{
|
||
"textRaw": "`length` {integer} **Default:** `buffer.length`",
|
||
"name": "length",
|
||
"type": "integer",
|
||
"default": "`buffer.length`"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer} **Default:** `null`",
|
||
"name": "position",
|
||
"type": "integer",
|
||
"default": "`null`"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`bytesRead` {integer}",
|
||
"name": "bytesRead",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffer` {Buffer}",
|
||
"name": "buffer",
|
||
"type": "Buffer"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Similar to the above <code>fs.read</code> function, this version takes an optional <code>options</code> object.\nIf no <code>options</code> object is specified, it will default with the above values.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.readdir(path[, options], callback)`",
|
||
"type": "method",
|
||
"name": "readdir",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.8"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/22020",
|
||
"description": "New option `withFileTypes` was added."
|
||
},
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v6.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/5616",
|
||
"description": "The `options` parameter was added."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`withFileTypes` {boolean} **Default:** `false`",
|
||
"name": "withFileTypes",
|
||
"type": "boolean",
|
||
"default": "`false`"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`files` {string[]|Buffer[]|fs.Dirent[]}",
|
||
"name": "files",
|
||
"type": "string[]|Buffer[]|fs.Dirent[]"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man3/readdir.3.html\"><code>readdir(3)</code></a>. Reads the contents of a directory.\nThe callback gets two arguments <code>(err, files)</code> where <code>files</code> is an array of\nthe names of the files in the directory excluding <code>'.'</code> and <code>'..'</code>.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe filenames passed to the callback. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe filenames returned will be passed as <code>Buffer</code> objects.</p>\n<p>If <code>options.withFileTypes</code> is set to <code>true</code>, the <code>files</code> array will contain\n<a href=\"#fs_class_fs_dirent\"><code>fs.Dirent</code></a> objects.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.readdirSync(path[, options])`",
|
||
"type": "method",
|
||
"name": "readdirSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/22020",
|
||
"description": "New option `withFileTypes` was added."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {string[]|Buffer[]|fs.Dirent[]}",
|
||
"name": "return",
|
||
"type": "string[]|Buffer[]|fs.Dirent[]"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`withFileTypes` {boolean} **Default:** `false`",
|
||
"name": "withFileTypes",
|
||
"type": "boolean",
|
||
"default": "`false`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man3/readdir.3.html\"><code>readdir(3)</code></a>.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe filenames returned. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe filenames returned will be passed as <code>Buffer</code> objects.</p>\n<p>If <code>options.withFileTypes</code> is set to <code>true</code>, the result will contain\n<a href=\"#fs_class_fs_dirent\"><code>fs.Dirent</code></a> objects.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.readFile(path[, options], callback)`",
|
||
"type": "method",
|
||
"name": "readFile",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.29"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v5.1.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/3740",
|
||
"description": "The `callback` will always be called with `null` as the `error` parameter in case of success."
|
||
},
|
||
{
|
||
"version": "v5.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/3163",
|
||
"description": "The `path` parameter can be a file descriptor now."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL|integer} filename or file descriptor",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL|integer",
|
||
"desc": "filename or file descriptor"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `null`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`null`"
|
||
},
|
||
{
|
||
"textRaw": "`flag` {string} See [support of file system `flags`][]. **Default:** `'r'`.",
|
||
"name": "flag",
|
||
"type": "string",
|
||
"default": "`'r'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`data` {string|Buffer}",
|
||
"name": "data",
|
||
"type": "string|Buffer"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously reads the entire contents of a file.</p>\n<pre><code class=\"language-js\">fs.readFile('/etc/passwd', (err, data) => {\n if (err) throw err;\n console.log(data);\n});\n</code></pre>\n<p>The callback is passed two arguments <code>(err, data)</code>, where <code>data</code> is the\ncontents of the file.</p>\n<p>If no encoding is specified, then the raw buffer is returned.</p>\n<p>If <code>options</code> is a string, then it specifies the encoding:</p>\n<pre><code class=\"language-js\">fs.readFile('/etc/passwd', 'utf8', callback);\n</code></pre>\n<p>When the path is a directory, the behavior of <code>fs.readFile()</code> and\n<a href=\"#fs_fs_readfilesync_path_options\"><code>fs.readFileSync()</code></a> is platform-specific. On macOS, Linux, and Windows, an\nerror will be returned. On FreeBSD, a representation of the directory's contents\nwill be returned.</p>\n<pre><code class=\"language-js\">// macOS, Linux, and Windows\nfs.readFile('<directory>', (err, data) => {\n // => [Error: EISDIR: illegal operation on a directory, read <directory>]\n});\n\n// FreeBSD\nfs.readFile('<directory>', (err, data) => {\n // => null, <data>\n});\n</code></pre>\n<p>The <code>fs.readFile()</code> function buffers the entire file. To minimize memory costs,\nwhen possible prefer streaming via <code>fs.createReadStream()</code>.</p>",
|
||
"modules": [
|
||
{
|
||
"textRaw": "File Descriptors",
|
||
"name": "file_descriptors",
|
||
"desc": "<ol>\n<li>Any specified file descriptor has to support reading.</li>\n<li>If a file descriptor is specified as the <code>path</code>, it will not be closed\nautomatically.</li>\n<li>The reading will begin at the current position. For example, if the file\nalready had <code>'Hello World</code>' and six bytes are read with the file descriptor,\nthe call to <code>fs.readFile()</code> with the same file descriptor, would give\n<code>'World'</code>, rather than <code>'Hello World'</code>.</li>\n</ol>",
|
||
"type": "module",
|
||
"displayName": "File Descriptors"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`fs.readFileSync(path[, options])`",
|
||
"type": "method",
|
||
"name": "readFileSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.8"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v5.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/3163",
|
||
"description": "The `path` parameter can be a file descriptor now."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {string|Buffer}",
|
||
"name": "return",
|
||
"type": "string|Buffer"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL|integer} filename or file descriptor",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL|integer",
|
||
"desc": "filename or file descriptor"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `null`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`null`"
|
||
},
|
||
{
|
||
"textRaw": "`flag` {string} See [support of file system `flags`][]. **Default:** `'r'`.",
|
||
"name": "flag",
|
||
"type": "string",
|
||
"default": "`'r'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns the contents of the <code>path</code>.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_readfile_path_options_callback\"><code>fs.readFile()</code></a>.</p>\n<p>If the <code>encoding</code> option is specified then this function returns a\nstring. Otherwise it returns a buffer.</p>\n<p>Similar to <a href=\"#fs_fs_readfile_path_options_callback\"><code>fs.readFile()</code></a>, when the path is a directory, the behavior of\n<code>fs.readFileSync()</code> is platform-specific.</p>\n<pre><code class=\"language-js\">// macOS, Linux, and Windows\nfs.readFileSync('<directory>');\n// => [Error: EISDIR: illegal operation on a directory, read <directory>]\n\n// FreeBSD\nfs.readFileSync('<directory>'); // => <data>\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.readlink(path[, options], callback)`",
|
||
"type": "method",
|
||
"name": "readlink",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`linkString` {string|Buffer}",
|
||
"name": "linkString",
|
||
"type": "string|Buffer"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/readlink.2.html\"><code>readlink(2)</code></a>. The callback gets two arguments <code>(err, linkString)</code>.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe link path passed to the callback. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe link path returned will be passed as a <code>Buffer</code> object.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.readlinkSync(path[, options])`",
|
||
"type": "method",
|
||
"name": "readlinkSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {string|Buffer}",
|
||
"name": "return",
|
||
"type": "string|Buffer"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/readlink.2.html\"><code>readlink(2)</code></a>. Returns the symbolic link's string value.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe link path returned. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe link path returned will be passed as a <code>Buffer</code> object.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.readSync(fd, buffer, offset, length, position)`",
|
||
"type": "method",
|
||
"name": "readSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/22150",
|
||
"description": "The `buffer` parameter can now be any `TypedArray` or a `DataView`."
|
||
},
|
||
{
|
||
"version": "v6.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/4518",
|
||
"description": "The `length` parameter can now be `0`."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {number}",
|
||
"name": "return",
|
||
"type": "number"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffer` {Buffer|TypedArray|DataView}",
|
||
"name": "buffer",
|
||
"type": "Buffer|TypedArray|DataView"
|
||
},
|
||
{
|
||
"textRaw": "`offset` {integer}",
|
||
"name": "offset",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`length` {integer}",
|
||
"name": "length",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns the number of <code>bytesRead</code>.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_read_fd_buffer_offset_length_position_callback\"><code>fs.read()</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.readSync(fd, buffer, [options])`",
|
||
"type": "method",
|
||
"name": "readSync",
|
||
"meta": {
|
||
"added": [
|
||
"v12.17.0"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.17.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/32460",
|
||
"description": "Options object can be passed in to make offset, length and position optional"
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {number}",
|
||
"name": "return",
|
||
"type": "number"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffer` {Buffer|TypedArray|DataView}",
|
||
"name": "buffer",
|
||
"type": "Buffer|TypedArray|DataView"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`offset` {integer} **Default:** `0`",
|
||
"name": "offset",
|
||
"type": "integer",
|
||
"default": "`0`"
|
||
},
|
||
{
|
||
"textRaw": "`length` {integer} **Default:** `buffer.length`",
|
||
"name": "length",
|
||
"type": "integer",
|
||
"default": "`buffer.length`"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer} **Default:** `null`",
|
||
"name": "position",
|
||
"type": "integer",
|
||
"default": "`null`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns the number of <code>bytesRead</code>.</p>\n<p>Similar to the above <code>fs.readSync</code> function, this version takes an optional <code>options</code> object.\nIf no <code>options</code> object is specified, it will default with the above values.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_read_fd_buffer_offset_length_position_callback\"><code>fs.read()</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.readv(fd, buffers[, position], callback)`",
|
||
"type": "method",
|
||
"name": "readv",
|
||
"meta": {
|
||
"added": [
|
||
"v12.17.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffers` {ArrayBufferView[]}",
|
||
"name": "buffers",
|
||
"type": "ArrayBufferView[]"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`bytesRead` {integer}",
|
||
"name": "bytesRead",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffers` {ArrayBufferView[]}",
|
||
"name": "buffers",
|
||
"type": "ArrayBufferView[]"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Read from a file specified by <code>fd</code> and write to an array of <code>ArrayBufferView</code>s\nusing <code>readv()</code>.</p>\n<p><code>position</code> is the offset from the beginning of the file from where data\nshould be read. If <code>typeof position !== 'number'</code>, the data will be read\nfrom the current position.</p>\n<p>The callback will be given three arguments: <code>err</code>, <code>bytesRead</code>, and\n<code>buffers</code>. <code>bytesRead</code> is how many bytes were read from the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.readvSync(fd, buffers[, position])`",
|
||
"type": "method",
|
||
"name": "readvSync",
|
||
"meta": {
|
||
"added": [
|
||
"v12.17.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {number} The number of bytes read.",
|
||
"name": "return",
|
||
"type": "number",
|
||
"desc": "The number of bytes read."
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffers` {ArrayBufferView[]}",
|
||
"name": "buffers",
|
||
"type": "ArrayBufferView[]"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_readv_fd_buffers_position_callback\"><code>fs.readv()</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.realpath(path[, options], callback)`",
|
||
"type": "method",
|
||
"name": "realpath",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v8.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/13028",
|
||
"description": "Pipe/Socket resolve support was added."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v6.4.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7899",
|
||
"description": "Calling `realpath` now works again for various edge cases on Windows."
|
||
},
|
||
{
|
||
"version": "v6.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/3594",
|
||
"description": "The `cache` parameter was removed."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`resolvedPath` {string|Buffer}",
|
||
"name": "resolvedPath",
|
||
"type": "string|Buffer"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously computes the canonical pathname by resolving <code>.</code>, <code>..</code> and\nsymbolic links.</p>\n<p>A canonical pathname is not necessarily unique. Hard links and bind mounts can\nexpose a file system entity through many pathnames.</p>\n<p>This function behaves like <a href=\"http://man7.org/linux/man-pages/man3/realpath.3.html\"><code>realpath(3)</code></a>, with some exceptions:</p>\n<ol>\n<li>\n<p>No case conversion is performed on case-insensitive file systems.</p>\n</li>\n<li>\n<p>The maximum number of symbolic links is platform-independent and generally\n(much) higher than what the native <a href=\"http://man7.org/linux/man-pages/man3/realpath.3.html\"><code>realpath(3)</code></a> implementation supports.</p>\n</li>\n</ol>\n<p>The <code>callback</code> gets two arguments <code>(err, resolvedPath)</code>. May use <code>process.cwd</code>\nto resolve relative paths.</p>\n<p>Only paths that can be converted to UTF8 strings are supported.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe path passed to the callback. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe path returned will be passed as a <code>Buffer</code> object.</p>\n<p>If <code>path</code> resolves to a socket or a pipe, the function will return a system\ndependent name for that object.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.realpath.native(path[, options], callback)`",
|
||
"type": "method",
|
||
"name": "native",
|
||
"meta": {
|
||
"added": [
|
||
"v9.2.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`resolvedPath` {string|Buffer}",
|
||
"name": "resolvedPath",
|
||
"type": "string|Buffer"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man3/realpath.3.html\"><code>realpath(3)</code></a>.</p>\n<p>The <code>callback</code> gets two arguments <code>(err, resolvedPath)</code>.</p>\n<p>Only paths that can be converted to UTF8 strings are supported.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe path passed to the callback. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe path returned will be passed as a <code>Buffer</code> object.</p>\n<p>On Linux, when Node.js is linked against musl libc, the procfs file system must\nbe mounted on <code>/proc</code> in order for this function to work. Glibc does not have\nthis restriction.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.realpathSync(path[, options])`",
|
||
"type": "method",
|
||
"name": "realpathSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v8.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/13028",
|
||
"description": "Pipe/Socket resolve support was added."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v6.4.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7899",
|
||
"description": "Calling `realpathSync` now works again for various edge cases on Windows."
|
||
},
|
||
{
|
||
"version": "v6.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/3594",
|
||
"description": "The `cache` parameter was removed."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {string|Buffer}",
|
||
"name": "return",
|
||
"type": "string|Buffer"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns the resolved pathname.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_realpath_path_options_callback\"><code>fs.realpath()</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.realpathSync.native(path[, options])`",
|
||
"type": "method",
|
||
"name": "native",
|
||
"meta": {
|
||
"added": [
|
||
"v9.2.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {string|Buffer}",
|
||
"name": "return",
|
||
"type": "string|Buffer"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man3/realpath.3.html\"><code>realpath(3)</code></a>.</p>\n<p>Only paths that can be converted to UTF8 strings are supported.</p>\n<p>The optional <code>options</code> argument can be a string specifying an encoding, or an\nobject with an <code>encoding</code> property specifying the character encoding to use for\nthe path returned. If the <code>encoding</code> is set to <code>'buffer'</code>,\nthe path returned will be passed as a <code>Buffer</code> object.</p>\n<p>On Linux, when Node.js is linked against musl libc, the procfs file system must\nbe mounted on <code>/proc</code> in order for this function to work. Glibc does not have\nthis restriction.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.rename(oldPath, newPath, callback)`",
|
||
"type": "method",
|
||
"name": "rename",
|
||
"meta": {
|
||
"added": [
|
||
"v0.0.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `oldPath` and `newPath` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`oldPath` {string|Buffer|URL}",
|
||
"name": "oldPath",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`newPath` {string|Buffer|URL}",
|
||
"name": "newPath",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously rename file at <code>oldPath</code> to the pathname provided\nas <code>newPath</code>. In the case that <code>newPath</code> already exists, it will\nbe overwritten. If there is a directory at <code>newPath</code>, an error will\nbe raised instead. No arguments other than a possible exception are\ngiven to the completion callback.</p>\n<p>See also: <a href=\"http://man7.org/linux/man-pages/man2/rename.2.html\"><code>rename(2)</code></a>.</p>\n<pre><code class=\"language-js\">fs.rename('oldFile.txt', 'newFile.txt', (err) => {\n if (err) throw err;\n console.log('Rename complete!');\n});\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.renameSync(oldPath, newPath)`",
|
||
"type": "method",
|
||
"name": "renameSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `oldPath` and `newPath` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`oldPath` {string|Buffer|URL}",
|
||
"name": "oldPath",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`newPath` {string|Buffer|URL}",
|
||
"name": "newPath",
|
||
"type": "string|Buffer|URL"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/rename.2.html\"><code>rename(2)</code></a>. Returns <code>undefined</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.rmdir(path[, options], callback)`",
|
||
"type": "method",
|
||
"name": "rmdir",
|
||
"meta": {
|
||
"added": [
|
||
"v0.0.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.16.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/30644",
|
||
"description": "The `maxBusyTries` option is renamed to `maxRetries`, and its default is 0. The `emfileWait` option has been removed, and `EMFILE` errors use the same retry logic as other errors. The `retryDelay` option is now supported. `ENFILE` errors are now retried."
|
||
},
|
||
{
|
||
"version": "v12.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/29168",
|
||
"description": "The `recursive`, `maxBusyTries`, and `emfileWait` options are now supported."
|
||
},
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameters can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"stability": 1,
|
||
"stabilityText": "Recursive removal is experimental.",
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or `EPERM` error is encountered, Node.js will retry the operation with a linear backoff wait of `retryDelay` ms longer on each try. This option represents the number of retries. This option is ignored if the `recursive` option is not `true`. **Default:** `0`.",
|
||
"name": "maxRetries",
|
||
"type": "integer",
|
||
"default": "`0`",
|
||
"desc": "If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or `EPERM` error is encountered, Node.js will retry the operation with a linear backoff wait of `retryDelay` ms longer on each try. This option represents the number of retries. This option is ignored if the `recursive` option is not `true`."
|
||
},
|
||
{
|
||
"textRaw": "`recursive` {boolean} If `true`, perform a recursive directory removal. In recursive mode, errors are not reported if `path` does not exist, and operations are retried on failure. **Default:** `false`.",
|
||
"name": "recursive",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "If `true`, perform a recursive directory removal. In recursive mode, errors are not reported if `path` does not exist, and operations are retried on failure."
|
||
},
|
||
{
|
||
"textRaw": "`retryDelay` {integer} The amount of time in milliseconds to wait between retries. This option is ignored if the `recursive` option is not `true`. **Default:** `100`.",
|
||
"name": "retryDelay",
|
||
"type": "integer",
|
||
"default": "`100`",
|
||
"desc": "The amount of time in milliseconds to wait between retries. This option is ignored if the `recursive` option is not `true`."
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/rmdir.2.html\"><code>rmdir(2)</code></a>. No arguments other than a possible exception are given\nto the completion callback.</p>\n<p>Using <code>fs.rmdir()</code> on a file (not a directory) results in an <code>ENOENT</code> error on\nWindows and an <code>ENOTDIR</code> error on POSIX.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.rmdirSync(path[, options])`",
|
||
"type": "method",
|
||
"name": "rmdirSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v12.16.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/30644",
|
||
"description": "The `maxBusyTries` option is renamed to `maxRetries`, and its default is 0. The `emfileWait` option has been removed, and `EMFILE` errors use the same retry logic as other errors. The `retryDelay` option is now supported. `ENFILE` errors are now retried."
|
||
},
|
||
{
|
||
"version": "v12.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/29168",
|
||
"description": "The `recursive`, `maxBusyTries`, and `emfileWait` options are now supported."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameters can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"stability": 1,
|
||
"stabilityText": "Recursive removal is experimental.",
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`maxRetries` {integer} If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or `EPERM` error is encountered, Node.js will retry the operation with a linear backoff wait of `retryDelay` ms longer on each try. This option represents the number of retries. This option is ignored if the `recursive` option is not `true`. **Default:** `0`.",
|
||
"name": "maxRetries",
|
||
"type": "integer",
|
||
"default": "`0`",
|
||
"desc": "If an `EBUSY`, `EMFILE`, `ENFILE`, `ENOTEMPTY`, or `EPERM` error is encountered, Node.js will retry the operation with a linear backoff wait of `retryDelay` ms longer on each try. This option represents the number of retries. This option is ignored if the `recursive` option is not `true`."
|
||
},
|
||
{
|
||
"textRaw": "`recursive` {boolean} If `true`, perform a recursive directory removal. In recursive mode, errors are not reported if `path` does not exist, and operations are retried on failure. **Default:** `false`.",
|
||
"name": "recursive",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "If `true`, perform a recursive directory removal. In recursive mode, errors are not reported if `path` does not exist, and operations are retried on failure."
|
||
},
|
||
{
|
||
"textRaw": "`retryDelay` {integer} The amount of time in milliseconds to wait between retries. This option is ignored if the `recursive` option is not `true`. **Default:** `100`.",
|
||
"name": "retryDelay",
|
||
"type": "integer",
|
||
"default": "`100`",
|
||
"desc": "The amount of time in milliseconds to wait between retries. This option is ignored if the `recursive` option is not `true`."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/rmdir.2.html\"><code>rmdir(2)</code></a>. Returns <code>undefined</code>.</p>\n<p>Using <code>fs.rmdirSync()</code> on a file (not a directory) results in an <code>ENOENT</code> error\non Windows and an <code>ENOTDIR</code> error on POSIX.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.stat(path[, options], callback)`",
|
||
"type": "method",
|
||
"name": "stat",
|
||
"meta": {
|
||
"added": [
|
||
"v0.0.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v10.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/20220",
|
||
"description": "Accepts an additional `options` object to specify whether the numeric values returned should be bigint."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`bigint` {boolean} Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`. **Default:** `false`.",
|
||
"name": "bigint",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`."
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`stats` {fs.Stats}",
|
||
"name": "stats",
|
||
"type": "fs.Stats"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/stat.2.html\"><code>stat(2)</code></a>. The callback gets two arguments <code>(err, stats)</code> where\n<code>stats</code> is an <a href=\"#fs_class_fs_stats\"><code>fs.Stats</code></a> object.</p>\n<p>In case of an error, the <code>err.code</code> will be one of <a href=\"errors.html#errors_common_system_errors\">Common System Errors</a>.</p>\n<p>Using <code>fs.stat()</code> to check for the existence of a file before calling\n<code>fs.open()</code>, <code>fs.readFile()</code> or <code>fs.writeFile()</code> is not recommended.\nInstead, user code should open/read/write the file directly and handle the\nerror raised if the file is not available.</p>\n<p>To check if a file exists without manipulating it afterwards, <a href=\"#fs_fs_access_path_mode_callback\"><code>fs.access()</code></a>\nis recommended.</p>\n<p>For example, given the following directory structure:</p>\n<pre><code class=\"language-fundamental\">- txtDir\n-- file.txt\n- app.js\n</code></pre>\n<p>The next program will check for the stats of the given paths:</p>\n<pre><code class=\"language-js\">const fs = require('fs');\n\nconst pathsToCheck = ['./txtDir', './txtDir/file.txt'];\n\nfor (let i = 0; i < pathsToCheck.length; i++) {\n fs.stat(pathsToCheck[i], function(err, stats) {\n console.log(stats.isDirectory());\n console.log(stats);\n });\n}\n</code></pre>\n<p>The resulting output will resemble:</p>\n<pre><code class=\"language-console\">true\nStats {\n dev: 16777220,\n mode: 16877,\n nlink: 3,\n uid: 501,\n gid: 20,\n rdev: 0,\n blksize: 4096,\n ino: 14214262,\n size: 96,\n blocks: 0,\n atimeMs: 1561174653071.963,\n mtimeMs: 1561174614583.3518,\n ctimeMs: 1561174626623.5366,\n birthtimeMs: 1561174126937.2893,\n atime: 2019-06-22T03:37:33.072Z,\n mtime: 2019-06-22T03:36:54.583Z,\n ctime: 2019-06-22T03:37:06.624Z,\n birthtime: 2019-06-22T03:28:46.937Z\n}\nfalse\nStats {\n dev: 16777220,\n mode: 33188,\n nlink: 1,\n uid: 501,\n gid: 20,\n rdev: 0,\n blksize: 4096,\n ino: 14214074,\n size: 8,\n blocks: 8,\n atimeMs: 1561174616618.8555,\n mtimeMs: 1561174614584,\n ctimeMs: 1561174614583.8145,\n birthtimeMs: 1561174007710.7478,\n atime: 2019-06-22T03:36:56.619Z,\n mtime: 2019-06-22T03:36:54.584Z,\n ctime: 2019-06-22T03:36:54.584Z,\n birthtime: 2019-06-22T03:26:47.711Z\n}\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.statSync(path[, options])`",
|
||
"type": "method",
|
||
"name": "statSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v10.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/20220",
|
||
"description": "Accepts an additional `options` object to specify whether the numeric values returned should be bigint."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {fs.Stats}",
|
||
"name": "return",
|
||
"type": "fs.Stats"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`bigint` {boolean} Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`. **Default:** `false`.",
|
||
"name": "bigint",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "Whether the numeric values in the returned [`fs.Stats`][] object should be `bigint`."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/stat.2.html\"><code>stat(2)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.symlink(target, path[, type], callback)`",
|
||
"type": "method",
|
||
"name": "symlink",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `target` and `path` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v12.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/23724",
|
||
"description": "If the `type` argument is left undefined, Node will autodetect `target` type and automatically select `dir` or `file`"
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`target` {string|Buffer|URL}",
|
||
"name": "target",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`type` {string}",
|
||
"name": "type",
|
||
"type": "string"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/symlink.2.html\"><code>symlink(2)</code></a> which creates the link called <code>path</code> pointing to\n<code>target</code>. No arguments other than a possible exception are given to the\ncompletion callback.</p>\n<p>The <code>type</code> argument is only available on Windows and ignored on other platforms.\nIt can be set to <code>'dir'</code>, <code>'file'</code>, or <code>'junction'</code>. If the <code>type</code> argument is\nnot set, Node.js will autodetect <code>target</code> type and use <code>'file'</code> or <code>'dir'</code>. If\nthe <code>target</code> does not exist, <code>'file'</code> will be used. Windows junction points\nrequire the destination path to be absolute. When using <code>'junction'</code>, the\n<code>target</code> argument will automatically be normalized to absolute path.</p>\n<p>Relative targets are relative to the link’s parent directory.</p>\n<pre><code class=\"language-js\">fs.symlink('./mew', './example/mewtwo', callback);\n</code></pre>\n<p>The above example creates a symbolic link <code>mewtwo</code> in the <code>example</code> which points\nto <code>mew</code> in the same directory:</p>\n<pre><code class=\"language-bash\">$ tree example/\nexample/\n├── mew\n└── mewtwo -> ./mew\n</code></pre>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.symlinkSync(target, path[, type])`",
|
||
"type": "method",
|
||
"name": "symlinkSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `target` and `path` parameters can be WHATWG `URL` objects using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v12.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/23724",
|
||
"description": "If the `type` argument is left undefined, Node will autodetect `target` type and automatically select `dir` or `file`"
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`target` {string|Buffer|URL}",
|
||
"name": "target",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`type` {string}",
|
||
"name": "type",
|
||
"type": "string"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>undefined</code>.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_symlink_target_path_type_callback\"><code>fs.symlink()</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.truncate(path[, len], callback)`",
|
||
"type": "method",
|
||
"name": "truncate",
|
||
"meta": {
|
||
"added": [
|
||
"v0.8.6"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`len` {integer} **Default:** `0`",
|
||
"name": "len",
|
||
"type": "integer",
|
||
"default": "`0`"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronous <a href=\"http://man7.org/linux/man-pages/man2/truncate.2.html\"><code>truncate(2)</code></a>. No arguments other than a possible exception are\ngiven to the completion callback. A file descriptor can also be passed as the\nfirst argument. In this case, <code>fs.ftruncate()</code> is called.</p>\n<p>Passing a file descriptor is deprecated and may result in an error being thrown\nin the future.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.truncateSync(path[, len])`",
|
||
"type": "method",
|
||
"name": "truncateSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.8.6"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`len` {integer} **Default:** `0`",
|
||
"name": "len",
|
||
"type": "integer",
|
||
"default": "`0`"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/truncate.2.html\"><code>truncate(2)</code></a>. Returns <code>undefined</code>. A file descriptor can also be\npassed as the first argument. In this case, <code>fs.ftruncateSync()</code> is called.</p>\n<p>Passing a file descriptor is deprecated and may result in an error being thrown\nin the future.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.unlink(path, callback)`",
|
||
"type": "method",
|
||
"name": "unlink",
|
||
"meta": {
|
||
"added": [
|
||
"v0.0.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Asynchronously removes a file or symbolic link. No arguments other than a\npossible exception are given to the completion callback.</p>\n<pre><code class=\"language-js\">// Assuming that 'path/file.txt' is a regular file.\nfs.unlink('path/file.txt', (err) => {\n if (err) throw err;\n console.log('path/file.txt was deleted');\n});\n</code></pre>\n<p><code>fs.unlink()</code> will not work on a directory, empty or otherwise. To remove a\ndirectory, use <a href=\"#fs_fs_rmdir_path_options_callback\"><code>fs.rmdir()</code></a>.</p>\n<p>See also: <a href=\"http://man7.org/linux/man-pages/man2/unlink.2.html\"><code>unlink(2)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.unlinkSync(path)`",
|
||
"type": "method",
|
||
"name": "unlinkSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Synchronous <a href=\"http://man7.org/linux/man-pages/man2/unlink.2.html\"><code>unlink(2)</code></a>. Returns <code>undefined</code>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.unwatchFile(filename[, listener])`",
|
||
"type": "method",
|
||
"name": "unwatchFile",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`filename` {string|Buffer|URL}",
|
||
"name": "filename",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`listener` {Function} Optional, a listener previously attached using `fs.watchFile()`",
|
||
"name": "listener",
|
||
"type": "Function",
|
||
"desc": "Optional, a listener previously attached using `fs.watchFile()`"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Stop watching for changes on <code>filename</code>. If <code>listener</code> is specified, only that\nparticular listener is removed. Otherwise, <em>all</em> listeners are removed,\neffectively stopping watching of <code>filename</code>.</p>\n<p>Calling <code>fs.unwatchFile()</code> with a filename that is not being watched is a\nno-op, not an error.</p>\n<p>Using <a href=\"#fs_fs_watch_filename_options_listener\"><code>fs.watch()</code></a> is more efficient than <code>fs.watchFile()</code> and\n<code>fs.unwatchFile()</code>. <code>fs.watch()</code> should be used instead of <code>fs.watchFile()</code>\nand <code>fs.unwatchFile()</code> when possible.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.utimes(path, atime, mtime, callback)`",
|
||
"type": "method",
|
||
"name": "utimes",
|
||
"meta": {
|
||
"added": [
|
||
"v0.4.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v8.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/11919",
|
||
"description": "`NaN`, `Infinity`, and `-Infinity` are no longer valid time specifiers."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v4.1.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/2387",
|
||
"description": "Numeric strings, `NaN` and `Infinity` are now allowed time specifiers."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`atime` {number|string|Date}",
|
||
"name": "atime",
|
||
"type": "number|string|Date"
|
||
},
|
||
{
|
||
"textRaw": "`mtime` {number|string|Date}",
|
||
"name": "mtime",
|
||
"type": "number|string|Date"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Change the file system timestamps of the object referenced by <code>path</code>.</p>\n<p>The <code>atime</code> and <code>mtime</code> arguments follow these rules:</p>\n<ul>\n<li>Values can be either numbers representing Unix epoch time in seconds,\n<code>Date</code>s, or a numeric string like <code>'123456789.0'</code>.</li>\n<li>If the value can not be converted to a number, or is <code>NaN</code>, <code>Infinity</code> or\n<code>-Infinity</code>, an <code>Error</code> will be thrown.</li>\n</ul>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.utimesSync(path, atime, mtime)`",
|
||
"type": "method",
|
||
"name": "utimesSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.4.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v8.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/11919",
|
||
"description": "`NaN`, `Infinity`, and `-Infinity` are no longer valid time specifiers."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `path` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v4.1.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/2387",
|
||
"description": "Numeric strings, `NaN` and `Infinity` are now allowed time specifiers."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`path` {string|Buffer|URL}",
|
||
"name": "path",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`atime` {number|string|Date}",
|
||
"name": "atime",
|
||
"type": "number|string|Date"
|
||
},
|
||
{
|
||
"textRaw": "`mtime` {number|string|Date}",
|
||
"name": "mtime",
|
||
"type": "number|string|Date"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>undefined</code>.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_utimes_path_atime_mtime_callback\"><code>fs.utimes()</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.watch(filename[, options][, listener])`",
|
||
"type": "method",
|
||
"name": "watch",
|
||
"meta": {
|
||
"added": [
|
||
"v0.5.10"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `filename` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7831",
|
||
"description": "The passed `options` object will never be modified."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {fs.FSWatcher}",
|
||
"name": "return",
|
||
"type": "fs.FSWatcher"
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`filename` {string|Buffer|URL}",
|
||
"name": "filename",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {string|Object}",
|
||
"name": "options",
|
||
"type": "string|Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`persistent` {boolean} Indicates whether the process should continue to run as long as files are being watched. **Default:** `true`.",
|
||
"name": "persistent",
|
||
"type": "boolean",
|
||
"default": "`true`",
|
||
"desc": "Indicates whether the process should continue to run as long as files are being watched."
|
||
},
|
||
{
|
||
"textRaw": "`recursive` {boolean} Indicates whether all subdirectories should be watched, or only the current directory. This applies when a directory is specified, and only on supported platforms (See [Caveats][]). **Default:** `false`.",
|
||
"name": "recursive",
|
||
"type": "boolean",
|
||
"default": "`false`",
|
||
"desc": "Indicates whether all subdirectories should be watched, or only the current directory. This applies when a directory is specified, and only on supported platforms (See [Caveats][])."
|
||
},
|
||
{
|
||
"textRaw": "`encoding` {string} Specifies the character encoding to be used for the filename passed to the listener. **Default:** `'utf8'`.",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`",
|
||
"desc": "Specifies the character encoding to be used for the filename passed to the listener."
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`listener` {Function|undefined} **Default:** `undefined`",
|
||
"name": "listener",
|
||
"type": "Function|undefined",
|
||
"default": "`undefined`",
|
||
"options": [
|
||
{
|
||
"textRaw": "`eventType` {string}",
|
||
"name": "eventType",
|
||
"type": "string"
|
||
},
|
||
{
|
||
"textRaw": "`filename` {string|Buffer}",
|
||
"name": "filename",
|
||
"type": "string|Buffer"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Watch for changes on <code>filename</code>, where <code>filename</code> is either a file or a\ndirectory.</p>\n<p>The second argument is optional. If <code>options</code> is provided as a string, it\nspecifies the <code>encoding</code>. Otherwise <code>options</code> should be passed as an object.</p>\n<p>The listener callback gets two arguments <code>(eventType, filename)</code>. <code>eventType</code>\nis either <code>'rename'</code> or <code>'change'</code>, and <code>filename</code> is the name of the file\nwhich triggered the event.</p>\n<p>On most platforms, <code>'rename'</code> is emitted whenever a filename appears or\ndisappears in the directory.</p>\n<p>The listener callback is attached to the <code>'change'</code> event fired by\n<a href=\"#fs_class_fs_fswatcher\"><code>fs.FSWatcher</code></a>, but it is not the same thing as the <code>'change'</code> value of\n<code>eventType</code>.</p>",
|
||
"miscs": [
|
||
{
|
||
"textRaw": "Caveats",
|
||
"name": "Caveats",
|
||
"type": "misc",
|
||
"desc": "<p>The <code>fs.watch</code> API is not 100% consistent across platforms, and is\nunavailable in some situations.</p>\n<p>The recursive option is only supported on macOS and Windows.</p>\n<p>On Windows, no events will be emitted if the watched directory is moved or\nrenamed. An <code>EPERM</code> error is reported when the watched directory is deleted.</p>",
|
||
"miscs": [
|
||
{
|
||
"textRaw": "Availability",
|
||
"name": "Availability",
|
||
"type": "misc",
|
||
"desc": "<p>This feature depends on the underlying operating system providing a way\nto be notified of filesystem changes.</p>\n<ul>\n<li>On Linux systems, this uses <a href=\"http://man7.org/linux/man-pages/man7/inotify.7.html\"><code>inotify(7)</code></a>.</li>\n<li>On BSD systems, this uses <a href=\"https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2\"><code>kqueue(2)</code></a>.</li>\n<li>On macOS, this uses <a href=\"https://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2\"><code>kqueue(2)</code></a> for files and <a href=\"https://developer.apple.com/documentation/coreservices/file_system_events\"><code>FSEvents</code></a> for\ndirectories.</li>\n<li>On SunOS systems (including Solaris and SmartOS), this uses <a href=\"https://illumos.org/man/port_create\"><code>event ports</code></a>.</li>\n<li>On Windows systems, this feature depends on <a href=\"https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-readdirectorychangesw\"><code>ReadDirectoryChangesW</code></a>.</li>\n<li>On Aix systems, this feature depends on <a href=\"https://www.ibm.com/developerworks/aix/library/au-aix_event_infrastructure/\"><code>AHAFS</code></a>, which must be enabled.</li>\n</ul>\n<p>If the underlying functionality is not available for some reason, then\n<code>fs.watch()</code> will not be able to function and may thrown an exception.\nFor example, watching files or directories can be unreliable, and in some\ncases impossible, on network file systems (NFS, SMB, etc) or host file systems\nwhen using virtualization software such as Vagrant or Docker.</p>\n<p>It is still possible to use <code>fs.watchFile()</code>, which uses stat polling, but\nthis method is slower and less reliable.</p>"
|
||
},
|
||
{
|
||
"textRaw": "Inodes",
|
||
"name": "Inodes",
|
||
"type": "misc",
|
||
"desc": "<p>On Linux and macOS systems, <code>fs.watch()</code> resolves the path to an <a href=\"https://en.wikipedia.org/wiki/Inode\">inode</a> and\nwatches the inode. If the watched path is deleted and recreated, it is assigned\na new inode. The watch will emit an event for the delete but will continue\nwatching the <em>original</em> inode. Events for the new inode will not be emitted.\nThis is expected behavior.</p>\n<p>AIX files retain the same inode for the lifetime of a file. Saving and closing a\nwatched file on AIX will result in two notifications (one for adding new\ncontent, and one for truncation).</p>"
|
||
},
|
||
{
|
||
"textRaw": "Filename Argument",
|
||
"name": "Filename Argument",
|
||
"type": "misc",
|
||
"desc": "<p>Providing <code>filename</code> argument in the callback is only supported on Linux,\nmacOS, Windows, and AIX. Even on supported platforms, <code>filename</code> is not always\nguaranteed to be provided. Therefore, don't assume that <code>filename</code> argument is\nalways provided in the callback, and have some fallback logic if it is <code>null</code>.</p>\n<pre><code class=\"language-js\">fs.watch('somedir', (eventType, filename) => {\n console.log(`event type is: ${eventType}`);\n if (filename) {\n console.log(`filename provided: ${filename}`);\n } else {\n console.log('filename not provided');\n }\n});\n</code></pre>"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`fs.watchFile(filename[, options], listener)`",
|
||
"type": "method",
|
||
"name": "watchFile",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.31"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.5.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/20220",
|
||
"description": "The `bigint` option is now supported."
|
||
},
|
||
{
|
||
"version": "v7.6.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10739",
|
||
"description": "The `filename` parameter can be a WHATWG `URL` object using `file:` protocol. Support is currently still *experimental*."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`filename` {string|Buffer|URL}",
|
||
"name": "filename",
|
||
"type": "string|Buffer|URL"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object}",
|
||
"name": "options",
|
||
"type": "Object",
|
||
"options": [
|
||
{
|
||
"textRaw": "`bigint` {boolean} **Default:** `false`",
|
||
"name": "bigint",
|
||
"type": "boolean",
|
||
"default": "`false`"
|
||
},
|
||
{
|
||
"textRaw": "`persistent` {boolean} **Default:** `true`",
|
||
"name": "persistent",
|
||
"type": "boolean",
|
||
"default": "`true`"
|
||
},
|
||
{
|
||
"textRaw": "`interval` {integer} **Default:** `5007`",
|
||
"name": "interval",
|
||
"type": "integer",
|
||
"default": "`5007`"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`listener` {Function}",
|
||
"name": "listener",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`current` {fs.Stats}",
|
||
"name": "current",
|
||
"type": "fs.Stats"
|
||
},
|
||
{
|
||
"textRaw": "`previous` {fs.Stats}",
|
||
"name": "previous",
|
||
"type": "fs.Stats"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Watch for changes on <code>filename</code>. The callback <code>listener</code> will be called each\ntime the file is accessed.</p>\n<p>The <code>options</code> argument may be omitted. If provided, it should be an object. The\n<code>options</code> object may contain a boolean named <code>persistent</code> that indicates\nwhether the process should continue to run as long as files are being watched.\nThe <code>options</code> object may specify an <code>interval</code> property indicating how often the\ntarget should be polled in milliseconds.</p>\n<p>The <code>listener</code> gets two arguments the current stat object and the previous\nstat object:</p>\n<pre><code class=\"language-js\">fs.watchFile('message.text', (curr, prev) => {\n console.log(`the current mtime is: ${curr.mtime}`);\n console.log(`the previous mtime was: ${prev.mtime}`);\n});\n</code></pre>\n<p>These stat objects are instances of <code>fs.Stat</code>. If the <code>bigint</code> option is <code>true</code>,\nthe numeric values in these objects are specified as <code>BigInt</code>s.</p>\n<p>To be notified when the file was modified, not just accessed, it is necessary\nto compare <code>curr.mtime</code> and <code>prev.mtime</code>.</p>\n<p>When an <code>fs.watchFile</code> operation results in an <code>ENOENT</code> error, it\nwill invoke the listener once, with all the fields zeroed (or, for dates, the\nUnix Epoch). If the file is created later on, the listener will be called\nagain, with the latest stat objects. This is a change in functionality since\nv0.10.</p>\n<p>Using <a href=\"#fs_fs_watch_filename_options_listener\"><code>fs.watch()</code></a> is more efficient than <code>fs.watchFile</code> and\n<code>fs.unwatchFile</code>. <code>fs.watch</code> should be used instead of <code>fs.watchFile</code> and\n<code>fs.unwatchFile</code> when possible.</p>\n<p>When a file being watched by <code>fs.watchFile()</code> disappears and reappears,\nthen the <code>previousStat</code> reported in the second callback event (the file's\nreappearance) will be the same as the <code>previousStat</code> of the first callback\nevent (its disappearance).</p>\n<p>This happens when:</p>\n<ul>\n<li>the file is deleted, followed by a restore</li>\n<li>the file is renamed and then renamed a second time back to its original name</li>\n</ul>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.write(fd, buffer[, offset[, length[, position]]], callback)`",
|
||
"type": "method",
|
||
"name": "write",
|
||
"meta": {
|
||
"added": [
|
||
"v0.0.2"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/22150",
|
||
"description": "The `buffer` parameter can now be any `TypedArray` or a `DataView`"
|
||
},
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.4.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10382",
|
||
"description": "The `buffer` parameter can now be a `Uint8Array`."
|
||
},
|
||
{
|
||
"version": "v7.2.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7856",
|
||
"description": "The `offset` and `length` parameters are optional now."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffer` {Buffer|TypedArray|DataView}",
|
||
"name": "buffer",
|
||
"type": "Buffer|TypedArray|DataView"
|
||
},
|
||
{
|
||
"textRaw": "`offset` {integer}",
|
||
"name": "offset",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`length` {integer}",
|
||
"name": "length",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`bytesWritten` {integer}",
|
||
"name": "bytesWritten",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffer` {Buffer|TypedArray|DataView}",
|
||
"name": "buffer",
|
||
"type": "Buffer|TypedArray|DataView"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Write <code>buffer</code> to the file specified by <code>fd</code>.</p>\n<p><code>offset</code> determines the part of the buffer to be written, and <code>length</code> is\nan integer specifying the number of bytes to write.</p>\n<p><code>position</code> refers to the offset from the beginning of the file where this data\nshould be written. If <code>typeof position !== 'number'</code>, the data will be written\nat the current position. See <a href=\"http://man7.org/linux/man-pages/man2/pwrite.2.html\"><code>pwrite(2)</code></a>.</p>\n<p>The callback will be given three arguments <code>(err, bytesWritten, buffer)</code> where\n<code>bytesWritten</code> specifies how many <em>bytes</em> were written from <code>buffer</code>.</p>\n<p>If this method is invoked as its <a href=\"util.html#util_util_promisify_original\"><code>util.promisify()</code></a>ed version, it returns\na <code>Promise</code> for an <code>Object</code> with <code>bytesWritten</code> and <code>buffer</code> properties.</p>\n<p>It is unsafe to use <code>fs.write()</code> multiple times on the same file without waiting\nfor the callback. For this scenario, <a href=\"#fs_fs_createwritestream_path_options\"><code>fs.createWriteStream()</code></a> is\nrecommended.</p>\n<p>On Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.write(fd, string[, position[, encoding]], callback)`",
|
||
"type": "method",
|
||
"name": "write",
|
||
"meta": {
|
||
"added": [
|
||
"v0.11.5"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.2.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7856",
|
||
"description": "The `position` parameter is optional now."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`string` {string}",
|
||
"name": "string",
|
||
"type": "string"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`encoding` {string} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`written` {integer}",
|
||
"name": "written",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`string` {string}",
|
||
"name": "string",
|
||
"type": "string"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Write <code>string</code> to the file specified by <code>fd</code>. If <code>string</code> is not a string, then\nthe value will be coerced to one.</p>\n<p><code>position</code> refers to the offset from the beginning of the file where this data\nshould be written. If <code>typeof position !== 'number'</code> the data will be written at\nthe current position. See <a href=\"http://man7.org/linux/man-pages/man2/pwrite.2.html\"><code>pwrite(2)</code></a>.</p>\n<p><code>encoding</code> is the expected string encoding.</p>\n<p>The callback will receive the arguments <code>(err, written, string)</code> where <code>written</code>\nspecifies how many <em>bytes</em> the passed string required to be written. Bytes\nwritten is not necessarily the same as string characters written. See\n<a href=\"buffer.html#buffer_class_method_buffer_bytelength_string_encoding\"><code>Buffer.byteLength</code></a>.</p>\n<p>It is unsafe to use <code>fs.write()</code> multiple times on the same file without waiting\nfor the callback. For this scenario, <a href=\"#fs_fs_createwritestream_path_options\"><code>fs.createWriteStream()</code></a> is\nrecommended.</p>\n<p>On Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.</p>\n<p>On Windows, if the file descriptor is connected to the console (e.g. <code>fd == 1</code>\nor <code>stdout</code>) a string containing non-ASCII characters will not be rendered\nproperly by default, regardless of the encoding used.\nIt is possible to configure the console to render UTF-8 properly by changing the\nactive codepage with the <code>chcp 65001</code> command. See the <a href=\"https://ss64.com/nt/chcp.html\">chcp</a> docs for more\ndetails.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.writeFile(file, data[, options], callback)`",
|
||
"type": "method",
|
||
"name": "writeFile",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.29"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/22150",
|
||
"description": "The `data` parameter can now be any `TypedArray` or a `DataView`."
|
||
},
|
||
{
|
||
"version": "v10.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/12562",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will throw a `TypeError` at runtime."
|
||
},
|
||
{
|
||
"version": "v7.4.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10382",
|
||
"description": "The `data` parameter can now be a `Uint8Array`."
|
||
},
|
||
{
|
||
"version": "v7.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7897",
|
||
"description": "The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning with id DEP0013."
|
||
},
|
||
{
|
||
"version": "v5.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/3163",
|
||
"description": "The `file` parameter can be a file descriptor now."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`file` {string|Buffer|URL|integer} filename or file descriptor",
|
||
"name": "file",
|
||
"type": "string|Buffer|URL|integer",
|
||
"desc": "filename or file descriptor"
|
||
},
|
||
{
|
||
"textRaw": "`data` {string|Buffer|TypedArray|DataView}",
|
||
"name": "data",
|
||
"type": "string|Buffer|TypedArray|DataView"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `0o666`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`0o666`"
|
||
},
|
||
{
|
||
"textRaw": "`flag` {string} See [support of file system `flags`][]. **Default:** `'w'`.",
|
||
"name": "flag",
|
||
"type": "string",
|
||
"default": "`'w'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>When <code>file</code> is a filename, asynchronously writes data to the file, replacing the\nfile if it already exists. <code>data</code> can be a string or a buffer.</p>\n<p>When <code>file</code> is a file descriptor, the behavior is similar to calling\n<code>fs.write()</code> directly (which is recommended). See the notes below on using\na file descriptor.</p>\n<p>The <code>encoding</code> option is ignored if <code>data</code> is a buffer.</p>\n<pre><code class=\"language-js\">const data = new Uint8Array(Buffer.from('Hello Node.js'));\nfs.writeFile('message.txt', data, (err) => {\n if (err) throw err;\n console.log('The file has been saved!');\n});\n</code></pre>\n<p>If <code>options</code> is a string, then it specifies the encoding:</p>\n<pre><code class=\"language-js\">fs.writeFile('message.txt', 'Hello Node.js', 'utf8', callback);\n</code></pre>\n<p>It is unsafe to use <code>fs.writeFile()</code> multiple times on the same file without\nwaiting for the callback. For this scenario, <a href=\"#fs_fs_createwritestream_path_options\"><code>fs.createWriteStream()</code></a> is\nrecommended.</p>",
|
||
"modules": [
|
||
{
|
||
"textRaw": "Using `fs.writeFile()` with File Descriptors",
|
||
"name": "using_`fs.writefile()`_with_file_descriptors",
|
||
"desc": "<p>When <code>file</code> is a file descriptor, the behavior is almost identical to directly\ncalling <code>fs.write()</code> like:</p>\n<pre><code class=\"language-javascript\">fs.write(fd, Buffer.from(data, options.encoding), callback);\n</code></pre>\n<p>The difference from directly calling <code>fs.write()</code> is that under some unusual\nconditions, <code>fs.write()</code> may write only part of the buffer and will need to be\nretried to write the remaining data, whereas <code>fs.writeFile()</code> will retry until\nthe data is entirely written (or an error occurs).</p>\n<p>The implications of this are a common source of confusion. In\nthe file descriptor case, the file is not replaced! The data is not necessarily\nwritten to the beginning of the file, and the file's original data may remain\nbefore and/or after the newly written data.</p>\n<p>For example, if <code>fs.writeFile()</code> is called twice in a row, first to write the\nstring <code>'Hello'</code>, then to write the string <code>', World'</code>, the file would contain\n<code>'Hello, World'</code>, and might contain some of the file's original data (depending\non the size of the original file, and the position of the file descriptor). If\na file name had been used instead of a descriptor, the file would be guaranteed\nto contain only <code>', World'</code>.</p>",
|
||
"type": "module",
|
||
"displayName": "Using `fs.writeFile()` with File Descriptors"
|
||
}
|
||
]
|
||
},
|
||
{
|
||
"textRaw": "`fs.writeFileSync(file, data[, options])`",
|
||
"type": "method",
|
||
"name": "writeFileSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.29"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/22150",
|
||
"description": "The `data` parameter can now be any `TypedArray` or a `DataView`."
|
||
},
|
||
{
|
||
"version": "v7.4.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10382",
|
||
"description": "The `data` parameter can now be a `Uint8Array`."
|
||
},
|
||
{
|
||
"version": "v5.0.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/3163",
|
||
"description": "The `file` parameter can be a file descriptor now."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`file` {string|Buffer|URL|integer} filename or file descriptor",
|
||
"name": "file",
|
||
"type": "string|Buffer|URL|integer",
|
||
"desc": "filename or file descriptor"
|
||
},
|
||
{
|
||
"textRaw": "`data` {string|Buffer|TypedArray|DataView}",
|
||
"name": "data",
|
||
"type": "string|Buffer|TypedArray|DataView"
|
||
},
|
||
{
|
||
"textRaw": "`options` {Object|string}",
|
||
"name": "options",
|
||
"type": "Object|string",
|
||
"options": [
|
||
{
|
||
"textRaw": "`encoding` {string|null} **Default:** `'utf8'`",
|
||
"name": "encoding",
|
||
"type": "string|null",
|
||
"default": "`'utf8'`"
|
||
},
|
||
{
|
||
"textRaw": "`mode` {integer} **Default:** `0o666`",
|
||
"name": "mode",
|
||
"type": "integer",
|
||
"default": "`0o666`"
|
||
},
|
||
{
|
||
"textRaw": "`flag` {string} See [support of file system `flags`][]. **Default:** `'w'`.",
|
||
"name": "flag",
|
||
"type": "string",
|
||
"default": "`'w'`",
|
||
"desc": "See [support of file system `flags`][]."
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Returns <code>undefined</code>.</p>\n<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_writefile_file_data_options_callback\"><code>fs.writeFile()</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.writeSync(fd, buffer[, offset[, length[, position]]])`",
|
||
"type": "method",
|
||
"name": "writeSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.1.21"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v10.10.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/22150",
|
||
"description": "The `buffer` parameter can now be any `TypedArray` or a `DataView`."
|
||
},
|
||
{
|
||
"version": "v7.4.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/10382",
|
||
"description": "The `buffer` parameter can now be a `Uint8Array`."
|
||
},
|
||
{
|
||
"version": "v7.2.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7856",
|
||
"description": "The `offset` and `length` parameters are optional now."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {number} The number of bytes written.",
|
||
"name": "return",
|
||
"type": "number",
|
||
"desc": "The number of bytes written."
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffer` {Buffer|TypedArray|DataView}",
|
||
"name": "buffer",
|
||
"type": "Buffer|TypedArray|DataView"
|
||
},
|
||
{
|
||
"textRaw": "`offset` {integer}",
|
||
"name": "offset",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`length` {integer}",
|
||
"name": "length",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_write_fd_buffer_offset_length_position_callback\"><code>fs.write(fd, buffer...)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.writeSync(fd, string[, position[, encoding]])`",
|
||
"type": "method",
|
||
"name": "writeSync",
|
||
"meta": {
|
||
"added": [
|
||
"v0.11.5"
|
||
],
|
||
"changes": [
|
||
{
|
||
"version": "v7.2.0",
|
||
"pr-url": "https://github.com/nodejs/node/pull/7856",
|
||
"description": "The `position` parameter is optional now."
|
||
}
|
||
]
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {number} The number of bytes written.",
|
||
"name": "return",
|
||
"type": "number",
|
||
"desc": "The number of bytes written."
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`string` {string}",
|
||
"name": "string",
|
||
"type": "string"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`encoding` {string}",
|
||
"name": "encoding",
|
||
"type": "string"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_write_fd_string_position_encoding_callback\"><code>fs.write(fd, string...)</code></a>.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.writev(fd, buffers[, position], callback)`",
|
||
"type": "method",
|
||
"name": "writev",
|
||
"meta": {
|
||
"added": [
|
||
"v12.9.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffers` {ArrayBufferView[]}",
|
||
"name": "buffers",
|
||
"type": "ArrayBufferView[]"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`callback` {Function}",
|
||
"name": "callback",
|
||
"type": "Function",
|
||
"options": [
|
||
{
|
||
"textRaw": "`err` {Error}",
|
||
"name": "err",
|
||
"type": "Error"
|
||
},
|
||
{
|
||
"textRaw": "`bytesWritten` {integer}",
|
||
"name": "bytesWritten",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffers` {ArrayBufferView[]}",
|
||
"name": "buffers",
|
||
"type": "ArrayBufferView[]"
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>Write an array of <code>ArrayBufferView</code>s to the file specified by <code>fd</code> using\n<code>writev()</code>.</p>\n<p><code>position</code> is the offset from the beginning of the file where this data\nshould be written. If <code>typeof position !== 'number'</code>, the data will be written\nat the current position.</p>\n<p>The callback will be given three arguments: <code>err</code>, <code>bytesWritten</code>, and\n<code>buffers</code>. <code>bytesWritten</code> is how many bytes were written from <code>buffers</code>.</p>\n<p>If this method is <a href=\"util.html#util_util_promisify_original\"><code>util.promisify()</code></a>ed, it returns a <code>Promise</code> for an\n<code>Object</code> with <code>bytesWritten</code> and <code>buffers</code> properties.</p>\n<p>It is unsafe to use <code>fs.writev()</code> multiple times on the same file without\nwaiting for the callback. For this scenario, use <a href=\"#fs_fs_createwritestream_path_options\"><code>fs.createWriteStream()</code></a>.</p>\n<p>On Linux, positional writes don't work when the file is opened in append mode.\nThe kernel ignores the position argument and always appends the data to\nthe end of the file.</p>"
|
||
},
|
||
{
|
||
"textRaw": "`fs.writevSync(fd, buffers[, position])`",
|
||
"type": "method",
|
||
"name": "writevSync",
|
||
"meta": {
|
||
"added": [
|
||
"v12.9.0"
|
||
],
|
||
"changes": []
|
||
},
|
||
"signatures": [
|
||
{
|
||
"return": {
|
||
"textRaw": "Returns: {number} The number of bytes written.",
|
||
"name": "return",
|
||
"type": "number",
|
||
"desc": "The number of bytes written."
|
||
},
|
||
"params": [
|
||
{
|
||
"textRaw": "`fd` {integer}",
|
||
"name": "fd",
|
||
"type": "integer"
|
||
},
|
||
{
|
||
"textRaw": "`buffers` {ArrayBufferView[]}",
|
||
"name": "buffers",
|
||
"type": "ArrayBufferView[]"
|
||
},
|
||
{
|
||
"textRaw": "`position` {integer}",
|
||
"name": "position",
|
||
"type": "integer"
|
||
}
|
||
]
|
||
}
|
||
],
|
||
"desc": "<p>For detailed information, see the documentation of the asynchronous version of\nthis API: <a href=\"#fs_fs_writev_fd_buffers_position_callback\"><code>fs.writev()</code></a>.</p>"
|
||
}
|
||
],
|
||
"properties": [
|
||
{
|
||
"textRaw": "`constants` {Object}",
|
||
"type": "Object",
|
||
"name": "constants",
|
||
"desc": "<p>Returns an object containing commonly used constants for file system\noperations. The specific constants currently defined are described in\n<a href=\"#fs_fs_constants_1\">FS Constants</a>.</p>"
|
||
}
|
||
],
|
||
"type": "module",
|
||
"displayName": "fs"
|
||
}
|
||
]
|
||
} |