Skip to content

Commit

Permalink
fix input validation for some Jest environments
Browse files Browse the repository at this point in the history
Closes #62.
  • Loading branch information
mourner committed Jun 10, 2019
1 parent 197e8e2 commit 05fac18
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ function pixelmatch(img1, img2, output, width, height, options) {
}

function isPixelData(arr) {
return arr instanceof Uint8Array || arr instanceof Uint8ClampedArray;
// work around instanceof Uint8Array not working properly in some Jest environments
return ArrayBuffer.isView(arr) && arr.constructor.BYTES_PER_ELEMENT === 1;
}

// check if a pixel is likely a part of anti-aliasing;
Expand Down

0 comments on commit 05fac18

Please sign in to comment.