Skip to content

Commit

Permalink
Replace instanceof with Buffer.isBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
refi93 committed Apr 28, 2021
1 parent 79fbb0c commit 043dfc8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -1765,7 +1765,7 @@ class Union extends Layout {
*/
getVariant(vb, offset) {
let variant = vb;
if (vb instanceof Buffer) {
if (Buffer.isBuffer(vb)) {
if (undefined === offset) {
offset = 0;
}
Expand Down Expand Up @@ -2325,7 +2325,7 @@ class Blob extends Layout {
if (this.length instanceof ExternalLayout) {
span = src.length;
}
if (!((src instanceof Buffer)
if (!(Buffer.isBuffer(src)
&& (span === src.length))) {
throw new TypeError(nameWithProperty('Blob.encode', this)
+ ' requires (length ' + span + ') Buffer as src');
Expand Down Expand Up @@ -2361,7 +2361,7 @@ class CString extends Layout {

/** @override */
getSpan(b, offset) {
if (!(b instanceof Buffer)) {
if (!Buffer.isBuffer(b)) {
throw new TypeError('b must be a Buffer');
}
if (undefined === offset) {
Expand Down Expand Up @@ -2452,7 +2452,7 @@ class UTF8 extends Layout {

/** @override */
getSpan(b, offset) {
if (!(b instanceof Buffer)) {
if (!Buffer.isBuffer(b)) {
throw new TypeError('b must be a Buffer');
}
if (undefined === offset) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "buffer-layout",
"version": "1.2.0",
"version": "1.2.1",
"description": "Translation between JavaScript values and Buffers",
"keywords": [
"Buffer",
Expand Down

0 comments on commit 043dfc8

Please sign in to comment.