File tree Expand file tree Collapse file tree 1 file changed +1
-10
lines changed Expand file tree Collapse file tree 1 file changed +1
-10
lines changed Original file line number Diff line number Diff line change @@ -47,14 +47,8 @@ function alignPool() {
47
47
48
48
function Buffer ( arg , encodingOrOffset , length ) {
49
49
// Common case.
50
- if ( typeof arg === 'number' ) {
51
- if ( typeof encodingOrOffset === 'string' ) {
52
- throw new Error (
53
- 'If encoding is specified then the first argument must be a string'
54
- ) ;
55
- }
50
+ if ( typeof arg === 'number' )
56
51
return Buffer . allocUnsafe ( arg ) ;
57
- }
58
52
return Buffer . from ( arg , encodingOrOffset , length ) ;
59
53
}
60
54
@@ -155,9 +149,6 @@ function fromString(string, encoding) {
155
149
if ( typeof encoding !== 'string' || encoding === '' )
156
150
encoding = 'utf8' ;
157
151
158
- if ( ! Buffer . isEncoding ( encoding ) )
159
- throw new TypeError ( '"encoding" must be a valid string encoding' ) ;
160
-
161
152
var length = byteLength ( string , encoding ) ;
162
153
if ( length >= ( Buffer . poolSize >>> 1 ) )
163
154
return binding . createFromString ( string , encoding ) ;
You can’t perform that action at this time.
0 commit comments