Skip to content

Commit 950a441

Browse files
fs: remove coercion to string in writing methods
Moves DEP0162 to End-of-Life. PR-URL: #42796 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 047cd61 commit 950a441

7 files changed

Lines changed: 51 additions & 91 deletions

File tree

doc/api/deprecations.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3131,6 +3131,9 @@ resources and not the actual references.
31313131

31323132
<!-- YAML
31333133
changes:
3134+
- version: REPLACEME
3135+
pr-url: https://github.com/nodejs/node/pull/42796
3136+
description: End-of-Life.
31343137
- version: v18.0.0
31353138
pr-url: https://github.com/nodejs/node/pull/42607
31363139
description: Runtime deprecation.
@@ -3141,7 +3144,7 @@ changes:
31413144
description: Documentation-only deprecation.
31423145
-->
31433146

3144-
Type: Runtime
3147+
Type: End-of-Life
31453148

31463149
Implicit coercion of objects with own `toString` property, passed as second
31473150
parameter in [`fs.write()`][], [`fs.writeFile()`][], [`fs.appendFile()`][],

doc/api/fs.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4534,6 +4534,10 @@ default with the above values.
45344534
<!-- YAML
45354535
added: v0.11.5
45364536
changes:
4537+
- version: REPLACEME
4538+
pr-url: https://github.com/nodejs/node/pull/42796
4539+
description: Passing to the `string` parameter an object with an own
4540+
`toString` function is no longer supported.
45374541
- version: v17.8.0
45384542
pr-url: https://github.com/nodejs/node/pull/42149
45394543
description: Passing to the `string` parameter an object with an own
@@ -4560,16 +4564,16 @@ changes:
45604564
-->
45614565

45624566
* `fd` {integer}
4563-
* `string` {string|Object}
4567+
* `string` {string}
45644568
* `position` {integer|null} **Default:** `null`
45654569
* `encoding` {string} **Default:** `'utf8'`
45664570
* `callback` {Function}
45674571
* `err` {Error}
45684572
* `written` {integer}
45694573
* `string` {string}
45704574

4571-
Write `string` to the file specified by `fd`. If `string` is not a string, or an
4572-
object with an own `toString` function property, then an exception is thrown.
4575+
Write `string` to the file specified by `fd`. If `string` is not a string,
4576+
an exception is thrown.
45734577

45744578
`position` refers to the offset from the beginning of the file where this data
45754579
should be written. If `typeof position !== 'number'` the data will be written at
@@ -4602,6 +4606,10 @@ details.
46024606
<!-- YAML
46034607
added: v0.1.29
46044608
changes:
4609+
- version: REPLACEME
4610+
pr-url: https://github.com/nodejs/node/pull/42796
4611+
description: Passing to the `string` parameter an object with an own
4612+
`toString` function is no longer supported.
46054613
- version: v18.0.0
46064614
pr-url: https://github.com/nodejs/node/pull/41678
46074615
description: Passing an invalid callback to the `callback` argument
@@ -4650,7 +4658,7 @@ changes:
46504658
-->
46514659

46524660
* `file` {string|Buffer|URL|integer} filename or file descriptor
4653-
* `data` {string|Buffer|TypedArray|DataView|Object}
4661+
* `data` {string|Buffer|TypedArray|DataView}
46544662
* `options` {Object|string}
46554663
* `encoding` {string|null} **Default:** `'utf8'`
46564664
* `mode` {integer} **Default:** `0o666`
@@ -5840,6 +5848,10 @@ this API: [`fs.utimes()`][].
58405848
<!-- YAML
58415849
added: v0.1.29
58425850
changes:
5851+
- version: REPLACEME
5852+
pr-url: https://github.com/nodejs/node/pull/42796
5853+
description: Passing to the `data` parameter an object with an own
5854+
`toString` function is no longer supported.
58435855
- version: v17.8.0
58445856
pr-url: https://github.com/nodejs/node/pull/42149
58455857
description: Passing to the `data` parameter an object with an own
@@ -5865,7 +5877,7 @@ changes:
58655877
-->
58665878

58675879
* `file` {string|Buffer|URL|integer} filename or file descriptor
5868-
* `data` {string|Buffer|TypedArray|DataView|Object}
5880+
* `data` {string|Buffer|TypedArray|DataView}
58695881
* `options` {Object|string}
58705882
* `encoding` {string|null} **Default:** `'utf8'`
58715883
* `mode` {integer} **Default:** `0o666`