summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRobert Nagy <ronagy@icloud.com>2019-08-08 11:18:39 +0200
committerRich Trott <rtrott@gmail.com>2019-09-22 16:23:02 -0700
commit95d6ad67bfc9ef3e2f4705c81c88e32c5b1cea51 (patch)
treef376f48d677cd9eb6b4806d7064844416dbaf8a6 /lib
parenta861b84d5d260d580243741b8e2f1c2b7330a6a2 (diff)
downloadandroid-node-v8-95d6ad67bfc9ef3e2f4705c81c88e32c5b1cea51.tar.gz
android-node-v8-95d6ad67bfc9ef3e2f4705c81c88e32c5b1cea51.tar.bz2
android-node-v8-95d6ad67bfc9ef3e2f4705c81c88e32c5b1cea51.zip
fs: remove unnecessary argument check
Writable already assures that only Buffer's are passed to _write. Also this is not the "correct" way to handle errors inside _write. PR-URL: https://github.com/nodejs/node/pull/29043 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/internal/fs/streams.js9
1 files changed, 3 insertions, 6 deletions
diff --git a/lib/internal/fs/streams.js b/lib/internal/fs/streams.js
index b0c4224893..110ad11493 100644
--- a/lib/internal/fs/streams.js
+++ b/lib/internal/fs/streams.js
@@ -3,7 +3,6 @@
const { Math, Object } = primordials;
const {
- ERR_INVALID_ARG_TYPE,
ERR_OUT_OF_RANGE
} = require('internal/errors').codes;
const { validateNumber } = require('internal/validators');
@@ -235,6 +234,9 @@ function WriteStream(path, options) {
options = copyObject(getOptions(options, {}));
+ // Only buffers are supported.
+ options.decodeStrings = true;
+
// For backwards compat do not emit close on destroy.
if (options.emitClose === undefined) {
options.emitClose = false;
@@ -295,11 +297,6 @@ WriteStream.prototype.open = function() {
WriteStream.prototype._write = function(data, encoding, cb) {
- if (!(data instanceof Buffer)) {
- const err = new ERR_INVALID_ARG_TYPE('data', 'Buffer', data);
- return this.emit('error', err);
- }
-
if (typeof this.fd !== 'number') {
return this.once('open', function() {
this._write(data, encoding, cb);