All files / lib/internal/util types.js

100% Statements 81/81
100% Branches 12/12
100% Functions 12/12
100% Lines 81/81

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 821x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2729x 2729x 2729x 1x 244595x 244595x 244595x 1x 119x 119x 119x 1x 135x 135x 135x 1x 200x 200x 200x 1x 117x 117x 117x 1x 110x 110x 110x 1x 107x 107x 107x 1x 151x 151x 151x 1x 137x 137x 137x 1x 94x 94x 94x 1x 36359x 36359x 36359x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
'use strict';
 
const {
  ArrayBufferIsView,
  ObjectGetOwnPropertyDescriptor,
  ObjectGetPrototypeOf,
  SymbolToStringTag,
  uncurryThis,
} = primordials;
 
const TypedArrayPrototype = ObjectGetPrototypeOf(Uint8Array.prototype);
 
const TypedArrayProto_toStringTag =
    uncurryThis(
      ObjectGetOwnPropertyDescriptor(TypedArrayPrototype,
                                     SymbolToStringTag).get);
 
function isTypedArray(value) {
  return TypedArrayProto_toStringTag(value) !== undefined;
}
 
function isUint8Array(value) {
  return TypedArrayProto_toStringTag(value) === 'Uint8Array';
}
 
function isUint8ClampedArray(value) {
  return TypedArrayProto_toStringTag(value) === 'Uint8ClampedArray';
}
 
function isUint16Array(value) {
  return TypedArrayProto_toStringTag(value) === 'Uint16Array';
}
 
function isUint32Array(value) {
  return TypedArrayProto_toStringTag(value) === 'Uint32Array';
}
 
function isInt8Array(value) {
  return TypedArrayProto_toStringTag(value) === 'Int8Array';
}
 
function isInt16Array(value) {
  return TypedArrayProto_toStringTag(value) === 'Int16Array';
}
 
function isInt32Array(value) {
  return TypedArrayProto_toStringTag(value) === 'Int32Array';
}
 
function isFloat32Array(value) {
  return TypedArrayProto_toStringTag(value) === 'Float32Array';
}
 
function isFloat64Array(value) {
  return TypedArrayProto_toStringTag(value) === 'Float64Array';
}
 
function isBigInt64Array(value) {
  return TypedArrayProto_toStringTag(value) === 'BigInt64Array';
}
 
function isBigUint64Array(value) {
  return TypedArrayProto_toStringTag(value) === 'BigUint64Array';
}
 
module.exports = {
  ...internalBinding('types'),
  isArrayBufferView: ArrayBufferIsView,
  isTypedArray,
  isUint8Array,
  isUint8ClampedArray,
  isUint16Array,
  isUint32Array,
  isInt8Array,
  isInt16Array,
  isInt32Array,
  isFloat32Array,
  isFloat64Array,
  isBigInt64Array,
  isBigUint64Array
};