Skip to content

Commit be4950d

Browse files
targosjasnell
authored andcommitted
util: add type check functions for BigInt arrays
Adds `isBigInt64Array` and `isBigUint64Array`. PR-URL: #19201 Reviewed-By: Ali Ijaz Sheikh <[email protected]> Reviewed-By: Myles Borins <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent 61f8783 commit be4950d

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

lib/internal/util/types.js

+11-1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,14 @@ function isFloat64Array(value) {
6161
return TypedArrayProto_toStringTag(value) === 'Float64Array';
6262
}
6363

64+
function isBigInt64Array(value) {
65+
return TypedArrayProto_toStringTag(value) === 'BigInt64Array';
66+
}
67+
68+
function isBigUint64Array(value) {
69+
return TypedArrayProto_toStringTag(value) === 'BigUint64Array';
70+
}
71+
6472
module.exports = {
6573
isArrayBufferView,
6674
isTypedArray,
@@ -72,5 +80,7 @@ module.exports = {
7280
isInt16Array,
7381
isInt32Array,
7482
isFloat32Array,
75-
isFloat64Array
83+
isFloat64Array,
84+
isBigInt64Array,
85+
isBigUint64Array
7686
};

test/.eslintrc.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ rules:
2121
# Global scoped methods and vars
2222
globals:
2323
WebAssembly: false
24+
BigInt64Array: false
25+
BigUint64Array: false

test/parallel/test-util-types.js

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Flags: --harmony-bigint
12
/* global SharedArrayBuffer */
23
'use strict';
34
const common = require('../common');
@@ -44,6 +45,8 @@ for (const [ value, _method ] of [
4445
[ new Int32Array() ],
4546
[ new Float32Array() ],
4647
[ new Float64Array() ],
48+
[ new BigInt64Array() ],
49+
[ new BigUint64Array() ],
4750
[ Object.defineProperty(new Uint8Array(),
4851
Symbol.toStringTag,
4952
{ value: 'foo' }) ],

0 commit comments

Comments
 (0)