Skip to content

Commit

Permalink
squash: remove "named params" support
Browse files Browse the repository at this point in the history
This is going to be introduced separately
  • Loading branch information
LiviaMedeiros committed Apr 4, 2022
1 parent 037561c commit 847749f
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 232 deletions.
36 changes: 0 additions & 36 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -619,25 +619,6 @@ On Linux, positional writes do not work when the file is opened in append mode.
The kernel ignores the position argument and always appends the data to
the end of the file.
#### `filehandle.write(buffer, options)`
<!-- YAML
added: REPLACEME
-->
* `buffer` {Buffer|TypedArray|DataView}
* `options` {Object}
* `offset` {integer} **Default:** `0`
* `length` {integer} **Default:** `buffer.byteLength - offset`
* `position` {integer} **Default:** `null`
* Returns: {Promise}
Write `buffer` to the file.
Similar to the above `filehandle.write` function, this version takes an
optional `options` object. If no `options` object is specified, it will
default with the above values.
#### `filehandle.write(string[, position[, encoding]])`
<!-- YAML
Expand Down Expand Up @@ -5784,23 +5765,6 @@ changes:
For detailed information, see the documentation of the asynchronous version of
this API: [`fs.write(fd, buffer...)`][].
### `fs.writeSync(fd, buffer, options)`
<!-- YAML
added: REPLACEME
-->
* `fd` {integer}
* `buffer` {Buffer|TypedArray|DataView}
* `options` {Object}
* `offset` {integer} **Default:** `0`
* `length` {integer} **Default:** `buffer.byteLength - offset`
* `position` {integer} **Default:** `null`
* Returns: {number} The number of bytes written.
For detailed information, see the documentation of the asynchronous version of
this API: [`fs.write(fd, buffer...)`][].
### `fs.writeSync(fd, string[, position[, encoding]])`
<!-- YAML
Expand Down
17 changes: 3 additions & 14 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -854,26 +854,15 @@ ObjectDefineProperty(write, internalUtil.customPromisifyArgs,
* specified `fd` (file descriptor).
* @param {number} fd
* @param {Buffer | TypedArray | DataView | string} buffer
* @param {{
* offset?: number;
* length?: number;
* position?: number;
* }} [offset]
* @param {number} [offset]
* @param {number} [length]
* @param {number} [position]
* @returns {number}
*/
function writeSync(fd, buffer, offset, length, position) {
fd = getValidatedFd(fd);
const ctx = {};
let result;

if (typeof offset === 'object' && offset !== null) {
({
offset = 0,
length = buffer.byteLength - offset,
position = null
} = offset);
}

if (isArrayBufferView(buffer)) {
if (position === undefined)
position = null;
Expand Down
15 changes: 2 additions & 13 deletions lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,19 +560,8 @@ async function readv(handle, buffers, position) {
return { bytesRead, buffers };
}

async function write(handle, bufferOrOptions, offset, length, position) {
let buffer = bufferOrOptions;
if (!isArrayBufferView(buffer) && typeof buffer !== 'string') {
validateBuffer(bufferOrOptions?.buffer);
({
buffer,
offset = 0,
length = buffer.byteLength - offset,
position = null
} = bufferOrOptions);
}

if (buffer.byteLength === 0)
async function write(handle, buffer, offset, length, position) {
if (buffer?.byteLength === 0)
return { bytesWritten: 0, buffer };

if (isArrayBufferView(buffer)) {
Expand Down
87 changes: 0 additions & 87 deletions test/parallel/test-fs-promises-write-optional-params.js

This file was deleted.

82 changes: 0 additions & 82 deletions test/parallel/test-fs-write-sync-optional-params.js

This file was deleted.

0 comments on commit 847749f

Please sign in to comment.