Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fs & util docs #18775

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,7 @@ changes:
* `start` {integer}
* `end` {integer}
* `highWaterMark` {integer}
* Returns: {ReadStream}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be {stream.Readable}
See type-parser.js#L81-L84

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your kind pointing out!


Returns a new [`ReadStream`][] object. (See [Readable Streams][]).

Expand Down Expand Up @@ -1285,6 +1286,7 @@ changes:
* `mode` {integer}
* `autoClose` {boolean}
* `start` {integer}
* Returns: {WriteStream}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be {stream.Writable}
See type-parser.js#L81-L84


Returns a new [`WriteStream`][] object. (See [Writable Stream][]).

Expand Down Expand Up @@ -1442,6 +1444,7 @@ changes:
-->

* `path` {string|Buffer|URL}
* Returns: {boolean}

Synchronous version of [`fs.exists()`][].
Returns `true` if the path exists, `false` otherwise.
Expand Down Expand Up @@ -1560,6 +1563,7 @@ added: v0.1.95
-->

* `fd` {integer}
* Returns: {fs.Stats}

Synchronous fstat(2). Returns an instance of [`fs.Stats`][].

Expand Down Expand Up @@ -1834,6 +1838,7 @@ changes:
-->

* `path` {string|Buffer|URL}
* Returns: {fs.Stats}

Synchronous lstat(2). Returns an instance of [`fs.Stats`][].

Expand Down Expand Up @@ -1959,6 +1964,7 @@ added: v5.10.0
* `prefix` {string}
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* Returns: {string}

The synchronous version of [`fs.mkdtemp()`][]. Returns the created
folder path.
Expand Down Expand Up @@ -2083,6 +2089,7 @@ changes:
* `path` {string|Buffer|URL}
* `flags` {string|number}
* `mode` {integer} **Default:** `0o666`
* Returns: {number}

Synchronous version of [`fs.open()`][]. Returns an integer representing the file
descriptor.
Expand Down Expand Up @@ -2173,6 +2180,7 @@ changes:
* `path` {string|Buffer|URL}
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* Returns: {Array} An array of filenames

Synchronous readdir(3). Returns an array of filenames excluding `'.'` and
`'..'`.
Expand Down Expand Up @@ -2273,6 +2281,7 @@ changes:
* `options` {Object|string}
* `encoding` {string|null} **Default:** `null`
* `flag` {string} **Default:** `'r'`
* Returns: {string|Buffer}

Synchronous version of [`fs.readFile()`][]. Returns the contents of the `path`.

Expand Down Expand Up @@ -2333,6 +2342,7 @@ changes:
* `path` {string|Buffer|URL}
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* Returns: {string|Buffer}

Synchronous readlink(2). Returns the symbolic link's string value.

Expand All @@ -2355,6 +2365,7 @@ changes:
* `offset` {integer}
* `length` {integer}
* `position` {integer}
* Returns: {number}

Synchronous version of [`fs.read()`][]. Returns the number of `bytesRead`.

Expand Down Expand Up @@ -2465,6 +2476,7 @@ changes:
* `path` {string|Buffer|URL}
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* Returns: {string|Buffer}

Synchronously computes the canonical pathname by resolving `.`, `..` and
symbolic links.
Expand Down Expand Up @@ -2495,6 +2507,7 @@ added: v9.2.0
* `path` {string|Buffer|URL}
* `options` {string|Object}
* `encoding` {string} **Default:** `'utf8'`
* Returns: {string|Buffer}

Synchronous realpath(3).

Expand Down Expand Up @@ -2632,6 +2645,7 @@ changes:
-->

* `path` {string|Buffer|URL}
* Returns: {fs.Stats}

Synchronous stat(2). Returns an instance of [`fs.Stats`][].

Expand Down Expand Up @@ -3197,6 +3211,7 @@ changes:
* `offset` {integer}
* `length` {integer}
* `position` {integer}
* Returns: {number}

## fs.writeSync(fd, string[, position[, encoding]])
<!-- YAML
Expand All @@ -3211,6 +3226,7 @@ changes:
* `string` {string}
* `position` {integer}
* `encoding` {string}
* Returns: {number}

Synchronous versions of [`fs.write()`][]. Returns the number of bytes written.

Expand Down
19 changes: 18 additions & 1 deletion doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ contains circular references.
object formatting. Similar to `util.inspect()` without options. This will show
the full object not including non-enumerable properties and proxies.
* `%%` - single percent sign (`'%'`). This does not consume an argument.
* Returns: {string} The formatted string

If the placeholder does not have a corresponding argument, the placeholder is
not replaced.
Expand Down Expand Up @@ -397,6 +398,7 @@ changes:
This is useful to minimize the inspection output for large complicated
objects. To make it recurse indefinitely pass `null` or `Infinity`. Defaults
to `Infinity`.
* Returns: {string} The representation of passed object

The `util.inspect()` method returns a string representation of `object` that is
intended for debugging. The output of `util.inspect` may change at any time
Expand Down Expand Up @@ -627,7 +629,7 @@ added: v9.0.0
* `val2` {any}
* Returns: {boolean}

Returns `true` if there is deep strict equality between `val` and `val2`.
Returns `true` if there is deep strict equality between `val1` and `val2`.
Otherwise, returns `false`.

See [`assert.deepStrictEqual()`][] for more information about deep strict
Expand Down Expand Up @@ -944,6 +946,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Internal alias for [`Array.isArray`][].

Expand All @@ -969,6 +972,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is a `Boolean`. Otherwise, returns `false`.

Expand All @@ -992,6 +996,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated: Use [`Buffer.isBuffer()`][] instead.

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is a `Buffer`. Otherwise, returns `false`.

Expand All @@ -1015,6 +1020,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is a `Date`. Otherwise, returns `false`.

Expand All @@ -1038,6 +1044,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is an [`Error`][]. Otherwise, returns
`false`.
Expand Down Expand Up @@ -1077,6 +1084,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is a `Function`. Otherwise, returns
`false`.
Expand Down Expand Up @@ -1104,6 +1112,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is strictly `null`. Otherwise, returns
`false`.
Expand All @@ -1128,6 +1137,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is `null` or `undefined`. Otherwise,
returns `false`.
Expand All @@ -1152,6 +1162,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is a `Number`. Otherwise, returns `false`.

Expand All @@ -1177,6 +1188,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is strictly an `Object` **and** not a
`Function`. Otherwise, returns `false`.
Expand All @@ -1203,6 +1215,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is a primitive type. Otherwise, returns
`false`.
Expand Down Expand Up @@ -1239,6 +1252,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is a `RegExp`. Otherwise, returns `false`.

Expand All @@ -1262,6 +1276,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is a `string`. Otherwise, returns `false`.

Expand All @@ -1287,6 +1302,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is a `Symbol`. Otherwise, returns `false`.

Expand All @@ -1310,6 +1326,7 @@ deprecated: v4.0.0
> Stability: 0 - Deprecated

* `object` {any}
* Returns: {boolean}

Returns `true` if the given `object` is `undefined`. Otherwise, returns `false`.

Expand Down