Add support for Uint8(Clamped)Array input (#2511)

This commit is contained in:
Leon Radley
2021-01-06 10:49:24 +01:00
committed by GitHub
parent bf1b326988
commit 4821a11223
8 changed files with 141 additions and 33 deletions

View File

@@ -48,6 +48,15 @@ const buffer = function (val) {
return val instanceof Buffer;
};
/**
* Is this value a Uint8Array or Uint8ClampedArray object?
* @private
*/
const uint8Array = function (val) {
// allow both since Uint8ClampedArray simply clamps the values between 0-255
return val instanceof Uint8Array || val instanceof Uint8ClampedArray;
};
/**
* Is this value a non-empty string?
* @private
@@ -110,6 +119,7 @@ module.exports = {
fn: fn,
bool: bool,
buffer: buffer,
uint8Array: uint8Array,
string: string,
number: number,
integer: integer,