@@ -4163,6 +4163,10 @@ This happens when:
4163
4163
<!-- YAML
4164
4164
added: v0.0.2
4165
4165
changes:
4166
+ - version: REPLACEME
4167
+ pr-url: https://github.com/nodejs/node/pull/34993
4168
+ description: The `buffer` parameter will stringify an object with an
4169
+ explicit `toString` function.
4166
4170
- version: v14.0.0
4167
4171
pr-url: https://github.com/nodejs/node/pull/31030
4168
4172
description: The `buffer` parameter won't coerce unsupported input to
@@ -4188,7 +4192,7 @@ changes:
4188
4192
-->
4189
4193
4190
4194
* ` fd ` {integer}
4191
- * ` buffer ` {Buffer|TypedArray|DataView}
4195
+ * ` buffer ` {Buffer|TypedArray|DataView|string|Object }
4192
4196
* ` offset ` {integer}
4193
4197
* ` length ` {integer}
4194
4198
* ` position ` {integer}
@@ -4197,7 +4201,8 @@ changes:
4197
4201
* ` bytesWritten ` {integer}
4198
4202
* ` buffer ` {Buffer|TypedArray|DataView}
4199
4203
4200
- Write ` buffer ` to the file specified by ` fd ` .
4204
+ Write ` buffer ` to the file specified by ` fd ` . If ` buffer ` is a normal object, it
4205
+ must have an own ` toString ` function property.
4201
4206
4202
4207
` offset ` determines the part of the buffer to be written, and ` length ` is
4203
4208
an integer specifying the number of bytes to write.
@@ -4224,6 +4229,10 @@ the end of the file.
4224
4229
<!-- YAML
4225
4230
added: v0.11.5
4226
4231
changes:
4232
+ - version: REPLACEME
4233
+ pr-url: https://github.com/nodejs/node/pull/34993
4234
+ description: The `string` parameter will stringify an object with an
4235
+ explicit `toString` function.
4227
4236
- version: v14.0.0
4228
4237
pr-url: https://github.com/nodejs/node/pull/31030
4229
4238
description: The `string` parameter won't coerce unsupported input to
@@ -4242,16 +4251,16 @@ changes:
4242
4251
-->
4243
4252
4244
4253
* ` fd ` {integer}
4245
- * ` string ` {string}
4254
+ * ` string ` {string|Object }
4246
4255
* ` position ` {integer}
4247
4256
* ` encoding ` {string} ** Default:** ` 'utf8' `
4248
4257
* ` callback ` {Function}
4249
4258
* ` err ` {Error}
4250
4259
* ` written ` {integer}
4251
4260
* ` string ` {string}
4252
4261
4253
- Write ` string ` to the file specified by ` fd ` . If ` string ` is not a string, then
4254
- an exception will be thrown.
4262
+ Write ` string ` to the file specified by ` fd ` . If ` string ` is not a string, or an
4263
+ object with an own ` toString ` function property, then an exception is thrown.
4255
4264
4256
4265
` position ` refers to the offset from the beginning of the file where this data
4257
4266
should be written. If ` typeof position !== 'number' ` the data will be written at
@@ -4283,6 +4292,10 @@ details.
4283
4292
<!-- YAML
4284
4293
added: v0.1.29
4285
4294
changes:
4295
+ - version: REPLACEME
4296
+ pr-url: https://github.com/nodejs/node/pull/34993
4297
+ description: The `data` parameter will stringify an object with an
4298
+ explicit `toString` function.
4286
4299
- version: v14.0.0
4287
4300
pr-url: https://github.com/nodejs/node/pull/31030
4288
4301
description: The `data` parameter won't coerce unsupported input to
@@ -4308,7 +4321,7 @@ changes:
4308
4321
-->
4309
4322
4310
4323
* ` file ` {string|Buffer|URL|integer} filename or file descriptor
4311
- * ` data ` {string|Buffer|TypedArray|DataView}
4324
+ * ` data ` {string|Buffer|TypedArray|DataView|Object }
4312
4325
* ` options ` {Object|string}
4313
4326
* ` encoding ` {string|null} ** Default:** ` 'utf8' `
4314
4327
* ` mode ` {integer} ** Default:** ` 0o666 `
@@ -4324,6 +4337,7 @@ When `file` is a file descriptor, the behavior is similar to calling
4324
4337
a file descriptor.
4325
4338
4326
4339
The ` encoding ` option is ignored if ` data ` is a buffer.
4340
+ If ` data ` is a normal object, it must have an own ` toString ` function property.
4327
4341
4328
4342
``` js
4329
4343
const data = new Uint8Array (Buffer .from (' Hello Node.js' ));
@@ -4373,6 +4387,10 @@ to contain only `', World'`.
4373
4387
<!-- YAML
4374
4388
added: v0.1.29
4375
4389
changes:
4390
+ - version: REPLACEME
4391
+ pr-url: https://github.com/nodejs/node/pull/34993
4392
+ description: The `data` parameter will stringify an object with an
4393
+ explicit `toString` function.
4376
4394
- version: v14.0.0
4377
4395
pr-url: https://github.com/nodejs/node/pull/31030
4378
4396
description: The `data` parameter won't coerce unsupported input to
@@ -4390,7 +4408,7 @@ changes:
4390
4408
-->
4391
4409
4392
4410
* ` file ` {string|Buffer|URL|integer} filename or file descriptor
4393
- * ` data ` {string|Buffer|TypedArray|DataView}
4411
+ * ` data ` {string|Buffer|TypedArray|DataView|Object }
4394
4412
* ` options ` {Object|string}
4395
4413
* ` encoding ` {string|null} ** Default:** ` 'utf8' `
4396
4414
* ` mode ` {integer} ** Default:** ` 0o666 `
@@ -4405,6 +4423,10 @@ this API: [`fs.writeFile()`][].
4405
4423
<!-- YAML
4406
4424
added: v0.1.21
4407
4425
changes:
4426
+ - version: REPLACEME
4427
+ pr-url: https://github.com/nodejs/node/pull/34993
4428
+ description: The `buffer` parameter will stringify an object with an
4429
+ explicit `toString` function.
4408
4430
- version: v14.0.0
4409
4431
pr-url: https://github.com/nodejs/node/pull/31030
4410
4432
description: The `buffer` parameter won't coerce unsupported input to
@@ -4422,7 +4444,7 @@ changes:
4422
4444
-->
4423
4445
4424
4446
* ` fd ` {integer}
4425
- * ` buffer ` {Buffer|TypedArray|DataView}
4447
+ * ` buffer ` {Buffer|TypedArray|DataView|string|Object }
4426
4448
* ` offset ` {integer}
4427
4449
* ` length ` {integer}
4428
4450
* ` position ` {integer}
@@ -4435,6 +4457,10 @@ this API: [`fs.write(fd, buffer...)`][].
4435
4457
<!-- YAML
4436
4458
added: v0.11.5
4437
4459
changes:
4460
+ - version: REPLACEME
4461
+ pr-url: https://github.com/nodejs/node/pull/34993
4462
+ description: The `string` parameter will stringify an object with an
4463
+ explicit `toString` function.
4438
4464
- version: v14.0.0
4439
4465
pr-url: https://github.com/nodejs/node/pull/31030
4440
4466
description: The `string` parameter won't coerce unsupported input to
@@ -4445,7 +4471,7 @@ changes:
4445
4471
-->
4446
4472
4447
4473
* ` fd ` {integer}
4448
- * ` string ` {string}
4474
+ * ` string ` {string|Object }
4449
4475
* ` position ` {integer}
4450
4476
* ` encoding ` {string}
4451
4477
* Returns: {number} The number of bytes written.
@@ -4812,13 +4838,17 @@ This function does not work on AIX versions before 7.1, it will resolve the
4812
4838
<!-- YAML
4813
4839
added: v10.0.0
4814
4840
changes:
4841
+ - version: REPLACEME
4842
+ pr-url: https://github.com/nodejs/node/pull/34993
4843
+ description: The `buffer` parameter will stringify an object with an
4844
+ explicit `toString` function.
4815
4845
- version: v14.0.0
4816
4846
pr-url: https://github.com/nodejs/node/pull/31030
4817
4847
description: The `buffer` parameter won't coerce unsupported input to
4818
4848
buffers anymore.
4819
4849
-->
4820
4850
4821
- * ` buffer ` {Buffer|Uint8Array}
4851
+ * ` buffer ` {Buffer|Uint8Array|string|Object }
4822
4852
* ` offset ` {integer}
4823
4853
* ` length ` {integer}
4824
4854
* ` position ` {integer}
@@ -4849,19 +4879,23 @@ the end of the file.
4849
4879
<!-- YAML
4850
4880
added: v10.0.0
4851
4881
changes:
4882
+ - version: REPLACEME
4883
+ pr-url: https://github.com/nodejs/node/pull/34993
4884
+ description: The `string` parameter will stringify an object with an
4885
+ explicit `toString` function.
4852
4886
- version: v14.0.0
4853
4887
pr-url: https://github.com/nodejs/node/pull/31030
4854
4888
description: The `string` parameter won't coerce unsupported input to
4855
4889
strings anymore.
4856
4890
-->
4857
4891
4858
- * ` string ` {string}
4892
+ * ` string ` {string|Object }
4859
4893
* ` position ` {integer}
4860
4894
* ` encoding ` {string} ** Default:** ` 'utf8' `
4861
4895
* Returns: {Promise}
4862
4896
4863
- Write ` string ` to the file. If ` string ` is not a string, then
4864
- an exception will be thrown.
4897
+ Write ` string ` to the file. If ` string ` is not a string, or an
4898
+ object with an own ` toString ` function property, then an exception is thrown.
4865
4899
4866
4900
The ` Promise ` is resolved with an object containing a ` bytesWritten ` property
4867
4901
identifying the number of bytes written, and a ` buffer ` property containing
@@ -4885,20 +4919,24 @@ the end of the file.
4885
4919
<!-- YAML
4886
4920
added: v10.0.0
4887
4921
changes:
4922
+ - version: REPLACEME
4923
+ pr-url: https://github.com/nodejs/node/pull/34993
4924
+ description: The `data` parameter will stringify an object with an
4925
+ explicit `toString` function.
4888
4926
- version: v14.0.0
4889
4927
pr-url: https://github.com/nodejs/node/pull/31030
4890
4928
description: The `data` parameter won't coerce unsupported input to
4891
4929
strings anymore.
4892
4930
-->
4893
4931
4894
- * ` data ` {string|Buffer|Uint8Array}
4932
+ * ` data ` {string|Buffer|Uint8Array|Object }
4895
4933
* ` options ` {Object|string}
4896
4934
* ` encoding ` {string|null} ** Default:** ` 'utf8' `
4897
4935
* Returns: {Promise}
4898
4936
4899
4937
Asynchronously writes data to a file, replacing the file if it already exists.
4900
- ` data ` can be a string or a buffer. The ` Promise ` will be resolved with no
4901
- arguments upon success.
4938
+ ` data ` can be a string, a buffer, or an object with an own ` toString ` function
4939
+ property. The ` Promise ` is resolved with no arguments upon success.
4902
4940
4903
4941
The ` encoding ` option is ignored if ` data ` is a buffer.
4904
4942
@@ -5516,23 +5554,27 @@ The `atime` and `mtime` arguments follow these rules:
5516
5554
<!-- YAML
5517
5555
added: v10.0.0
5518
5556
changes:
5557
+ - version: REPLACEME
5558
+ pr-url: https://github.com/nodejs/node/pull/34993
5559
+ description: The `data` parameter will stringify an object with an
5560
+ explicit `toString` function.
5519
5561
- version: v14.0.0
5520
5562
pr-url: https://github.com/nodejs/node/pull/31030
5521
5563
description: The `data` parameter won't coerce unsupported input to
5522
5564
strings anymore.
5523
5565
-->
5524
5566
5525
5567
* ` file ` {string|Buffer|URL|FileHandle} filename or ` FileHandle `
5526
- * ` data ` {string|Buffer|Uint8Array}
5568
+ * ` data ` {string|Buffer|Uint8Array|Object }
5527
5569
* ` options ` {Object|string}
5528
5570
* ` encoding ` {string|null} ** Default:** ` 'utf8' `
5529
5571
* ` mode ` {integer} ** Default:** ` 0o666 `
5530
5572
* ` flag ` {string} See [ support of file system ` flags ` ] [ ] . ** Default:** ` 'w' ` .
5531
5573
* Returns: {Promise}
5532
5574
5533
5575
Asynchronously writes data to a file, replacing the file if it already exists.
5534
- ` data ` can be a string or a buffer. The ` Promise ` will be resolved with no
5535
- arguments upon success.
5576
+ ` data ` can be a string, a buffer, or an object with an own ` toString ` function
5577
+ property. The ` Promise ` is resolved with no arguments upon success.
5536
5578
5537
5579
The ` encoding ` option is ignored if ` data ` is a buffer.
5538
5580
0 commit comments