Skip to content

Commit

Permalink
Pull out new throws
Browse files Browse the repository at this point in the history
  • Loading branch information
jasnell committed Mar 23, 2016
1 parent ad5e145 commit c04c7bd
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,8 @@ function alignPool() {

function Buffer(arg, encodingOrOffset, length) {
// Common case.
if (typeof arg === 'number') {
if (typeof encodingOrOffset === 'string') {
throw new Error(
'If encoding is specified then the first argument must be a string'
);
}
if (typeof arg === 'number')
return Buffer.allocUnsafe(arg);
}
return Buffer.from(arg, encodingOrOffset, length);
}

Expand Down Expand Up @@ -155,9 +149,6 @@ function fromString(string, encoding) {
if (typeof encoding !== 'string' || encoding === '')
encoding = 'utf8';

if (!Buffer.isEncoding(encoding))
throw new TypeError('"encoding" must be a valid string encoding');

var length = byteLength(string, encoding);
if (length >= (Buffer.poolSize >>> 1))
return binding.createFromString(string, encoding);
Expand Down

0 comments on commit c04c7bd

Please sign in to comment.