All files / lib/internal/util types.js

96.3% Statements 104/108
89.47% Branches 17/19
100% Functions 14/14
96.3% Lines 104/108

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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 10922x 22x 22x 22x 22x 22x 22x 22x 4082x 4082x 4082x 22x 291797x 291797x 291797x 22x 85x 85x 85x 22x 85x 85x 85x 22x 85x 85x 85x 22x 85x 85x 85x 22x 85x 85x 85x 22x 85x 85x 85x 22x 139x 139x 139x 22x 134x 134x 134x 22x 108x 108x 108x 22x 16619x 16619x 16619x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 22x 79x     79x 79x 2x 2x 79x 79x 79x 22x 22x 22x 22x 22x 107x     107x 107x 2x 2x 107x 107x 107x 22x 22x  
'use strict';
 
const {
  ArrayBufferIsView,
  ObjectDefineProperties,
  TypedArrayPrototypeGetSymbolToStringTag,
} = primordials;
 
function isTypedArray(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) !== undefined;
}
 
function isUint8Array(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint8Array';
}
 
function isUint8ClampedArray(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint8ClampedArray';
}
 
function isUint16Array(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint16Array';
}
 
function isUint32Array(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint32Array';
}
 
function isInt8Array(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Int8Array';
}
 
function isInt16Array(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Int16Array';
}
 
function isInt32Array(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Int32Array';
}
 
function isFloat32Array(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Float32Array';
}
 
function isFloat64Array(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Float64Array';
}
 
function isBigInt64Array(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'BigInt64Array';
}
 
function isBigUint64Array(value) {
  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'BigUint64Array';
}
 
module.exports = {
  ...internalBinding('types'),
  isArrayBufferView: ArrayBufferIsView,
  isTypedArray,
  isUint8Array,
  isUint8ClampedArray,
  isUint16Array,
  isUint32Array,
  isInt8Array,
  isInt16Array,
  isInt32Array,
  isFloat32Array,
  isFloat64Array,
  isBigInt64Array,
  isBigUint64Array
};
 
let isCryptoKey;
let isKeyObject;
 
ObjectDefineProperties(module.exports, {
  isKeyObject: {
    configurable: false,
    enumerable: true,
    value(obj) {
      if (!process.versions.openssl) {
        return false;
      }
 
      if (!isKeyObject) {
        ({ isKeyObject } = require('internal/crypto/keys'));
      }
 
      return isKeyObject(obj);
    }
  },
  isCryptoKey: {
    configurable: false,
    enumerable: true,
    value(obj) {
      if (!process.versions.openssl) {
        return false;
      }
 
      if (!isCryptoKey) {
        ({ isCryptoKey } = require('internal/crypto/keys'));
      }
 
      return isCryptoKey(obj);
    }
  }
});