function isNumberArray(arr, len) {
  if (Array.isArray(arr)) {
    return (
      (len === null || arr.length === len) &&
      arr.every(x => typeof x === "number")
    );
  }

  // This check allows us to have typed arrays but not the
  // BigInt64Array/BigUint64Array types (their elements aren't "number").
  return (
    ArrayBuffer.isView(arr) &&
    !(arr instanceof BigInt64Array || arr instanceof BigUint64Array) &&
    (len === null || arr.length === len)
  );
}
Checks if something is an Array containing only numbers,
and (optionally) checks its length.
@param {any} arr
@param {number | null} len
@returns {boolean}