We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8d628e8 commit fc61005Copy full SHA for fc61005
lib/to-buffer.js
@@ -5,11 +5,12 @@ var Buffer = require('safe-buffer').Buffer;
5
module.exports = function (thing, encoding, name) {
6
if (Buffer.isBuffer(thing)) {
7
return thing;
8
- } else if (typeof thing === 'string') {
+ }
9
+ if (typeof thing === 'string') {
10
return Buffer.from(thing, encoding);
- } else if (ArrayBuffer.isView(thing)) {
11
12
+ if (ArrayBuffer.isView(thing)) {
13
return Buffer.from(thing.buffer);
14
}
15
throw new TypeError(name + ' must be a string, a Buffer, a typed array or a DataView');
-
16
};
0 commit comments