File tree Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Original file line number Diff line number Diff line change 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' ) ;
@@ -238,6 +237,9 @@ function WriteStream(path, options) {
238
237
239
238
options = copyObject ( getOptions ( options , { } ) ) ;
240
239
240
+ // Only buffers are supported.
241
+ options . decodeStrings = true ;
242
+
241
243
// For backwards compat do not emit close on destroy.
242
244
if ( options . emitClose === undefined ) {
243
245
options . emitClose = false ;
@@ -298,11 +300,6 @@ WriteStream.prototype.open = function() {
298
300
299
301
300
302
WriteStream . prototype . _write = function ( data , encoding , cb ) {
301
- if ( ! ( data instanceof Buffer ) ) {
302
- const err = new ERR_INVALID_ARG_TYPE ( 'data' , 'Buffer' , data ) ;
303
- return this . emit ( 'error' , err ) ;
304
- }
305
-
306
303
if ( typeof this . fd !== 'number' ) {
307
304
return this . once ( 'open' , function ( ) {
308
305
this . _write ( data , encoding , cb ) ;
Original file line number Diff line number Diff line change 20
20
// USE OR OTHER DEALINGS IN THE SOFTWARE.
21
21
22
22
'use strict' ;
23
- const common = require ( '../common' ) ;
23
+ require ( '../common' ) ;
24
24
const assert = require ( 'assert' ) ;
25
25
const path = require ( 'path' ) ;
26
26
const fs = require ( 'fs' ) ;
@@ -52,16 +52,3 @@ tmpdir.refresh();
52
52
} ) ;
53
53
stream . destroy ( ) ;
54
54
}
55
-
56
- // Throws if data is not of type Buffer.
57
- {
58
- const stream = fs . createWriteStream ( file ) ;
59
- common . expectsError ( ( ) => {
60
- stream . _write ( 42 , null , function ( ) { } ) ;
61
- } , {
62
- code : 'ERR_INVALID_ARG_TYPE' ,
63
- type : TypeError ,
64
- message : 'The "data" argument must be of type Buffer. Received type number'
65
- } ) ;
66
- stream . destroy ( ) ;
67
- }
You can’t perform that action at this time.
0 commit comments