| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b43d2dd commit 67f5de9
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,7 +3,6 @@ | |||
| 3 | 3 | const { Math, Object } = primordials; | |
| 4 | 4 | ||
| 5 | 5 | const { | |
| 6 | - ERR_INVALID_ARG_TYPE, | ||
| 7 | 6 | ERR_OUT_OF_RANGE | |
| 8 | 7 | } = require('internal/errors').codes; | |
| 9 | 8 | const { validateNumber } = require('internal/validators'); | |
@@ -235,6 +234,9 @@ function WriteStream(path, options) { | |||
| 235 | 234 | ||
| 236 | 235 | options = copyObject(getOptions(options, {})); | |
| 237 | 236 | ||
| 237 | + // Only buffers are supported. | ||
| 238 | + options.decodeStrings = true; | ||
| 239 | + | ||
| 238 | 240 | // For backwards compat do not emit close on destroy. | |
| 239 | 241 | if (options.emitClose === undefined) { | |
| 240 | 242 | options.emitClose = false; | |
@@ -295,11 +297,6 @@ WriteStream.prototype.open = function() { | |||
| 295 | 297 | ||
| 296 | 298 | ||
| 297 | 299 | WriteStream.prototype._write = function(data, encoding, cb) { | |
| 298 | - if (!(data instanceof Buffer)) { | ||
| 299 | - const err = new ERR_INVALID_ARG_TYPE('data', 'Buffer', data); | ||
| 300 | - return this.emit('error', err); | ||
| 301 | - } | ||
| 302 | - | ||
| 303 | 300 | if (typeof this.fd !== 'number') { | |
| 304 | 301 | return this.once('open', function() { | |
| 305 | 302 | this._write(data, encoding, cb); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -55,12 +55,13 @@ tmpdir.refresh(); | |||
| 55 | 55 | // Throws if data is not of type Buffer. | |
| 56 | 56 | { | |
| 57 | 57 | const stream = fs.createWriteStream(file); | |
| 58 | - common.expectsError(() => { | ||
| 59 | - stream._write(42, null, function() {}); | ||
| 60 | - }, { | ||
| 58 | + stream.on('error', common.expectsError({ | ||
| 61 | 59 | code: 'ERR_INVALID_ARG_TYPE', | |
| 62 | - type: TypeError, | ||
| 63 | - message: 'The "data" argument must be of type Buffer. Received type number' | ||
| 64 | - }); | ||
| 60 | + type: TypeError | ||
| 61 | + })); | ||
| 62 | + stream.write(42, null, common.expectsError({ | ||
| 63 | + code: 'ERR_INVALID_ARG_TYPE', | ||
| 64 | + type: TypeError | ||
| 65 | + })); | ||
| 65 | 66 | stream.destroy(); | |
| 66 | 67 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments