Skip to content

Commit 81283c1

Browse files
committed
[Refactor] use SafeBuffer.isBuffer instead of instanceof
1 parent 07afa81 commit 81283c1

1 file changed

Lines changed: 1 addition & 5 deletions

File tree

index.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ var useArrayBuffer = typeof ArrayBuffer !== 'undefined'
1919
var useFromArrayBuffer = useArrayBuffer && (Buffer.prototype instanceof Uint8Array || Buffer.TYPED_ARRAY_SUPPORT);
2020

2121
module.exports = function toBuffer(data, encoding) {
22-
/*
23-
* No need to do anything for exact instance
24-
* This is only valid when safe-buffer.Buffer === buffer.Buffer, i.e. when Buffer.from/Buffer.alloc existed
25-
*/
26-
if (data instanceof Buffer) {
22+
if (Buffer.isBuffer(data)) {
2723
return data;
2824
}
2925

0 commit comments

Comments
 (0)