• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const {
4  ArrayBufferIsView,
5  ObjectDefineProperties,
6  TypedArrayPrototypeGetSymbolToStringTag,
7} = primordials;
8
9function isTypedArray(value) {
10  return TypedArrayPrototypeGetSymbolToStringTag(value) !== undefined;
11}
12
13function isUint8Array(value) {
14  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint8Array';
15}
16
17function isUint8ClampedArray(value) {
18  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint8ClampedArray';
19}
20
21function isUint16Array(value) {
22  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint16Array';
23}
24
25function isUint32Array(value) {
26  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Uint32Array';
27}
28
29function isInt8Array(value) {
30  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Int8Array';
31}
32
33function isInt16Array(value) {
34  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Int16Array';
35}
36
37function isInt32Array(value) {
38  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Int32Array';
39}
40
41function isFloat32Array(value) {
42  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Float32Array';
43}
44
45function isFloat64Array(value) {
46  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'Float64Array';
47}
48
49function isBigInt64Array(value) {
50  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'BigInt64Array';
51}
52
53function isBigUint64Array(value) {
54  return TypedArrayPrototypeGetSymbolToStringTag(value) === 'BigUint64Array';
55}
56
57module.exports = {
58  ...internalBinding('types'),
59  isArrayBufferView: ArrayBufferIsView,
60  isTypedArray,
61  isUint8Array,
62  isUint8ClampedArray,
63  isUint16Array,
64  isUint32Array,
65  isInt8Array,
66  isInt16Array,
67  isInt32Array,
68  isFloat32Array,
69  isFloat64Array,
70  isBigInt64Array,
71  isBigUint64Array,
72};
73
74let isCryptoKey;
75let isKeyObject;
76
77ObjectDefineProperties(module.exports, {
78  isKeyObject: {
79    __proto__: null,
80    configurable: false,
81    enumerable: true,
82    value(obj) {
83      if (!process.versions.openssl) {
84        return false;
85      }
86
87      if (!isKeyObject) {
88        ({ isKeyObject } = require('internal/crypto/keys'));
89      }
90
91      return isKeyObject(obj);
92    },
93  },
94  isCryptoKey: {
95    __proto__: null,
96    configurable: false,
97    enumerable: true,
98    value(obj) {
99      if (!process.versions.openssl) {
100        return false;
101      }
102
103      if (!isCryptoKey) {
104        ({ isCryptoKey } = require('internal/crypto/keys'));
105      }
106
107      return isCryptoKey(obj);
108    },
109  },
110});
111