util: add type check functions for BigInt arrays

Adds `isBigInt64Array` and `isBigUint64Array`.

PR-URL: https://github.com/nodejs/node/pull/19201
Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
Michaël Zasso 2018-03-07 17:05:01 +01:00 committed by Myles Borins
parent 24ec79627d
commit 01c9575ad5
No known key found for this signature in database
GPG Key ID: 933B01F40B5CA946
3 changed files with 16 additions and 1 deletions

View File

@ -61,6 +61,14 @@ 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 = {
isArrayBufferView,
isTypedArray,
@ -72,5 +80,7 @@ module.exports = {
isInt16Array,
isInt32Array,
isFloat32Array,
isFloat64Array
isFloat64Array,
isBigInt64Array,
isBigUint64Array
};

View File

@ -21,3 +21,5 @@ rules:
# Global scoped methods and vars
globals:
WebAssembly: false
BigInt64Array: false
BigUint64Array: false

View File

@ -1,3 +1,4 @@
// Flags: --harmony-bigint
/* global SharedArrayBuffer */
'use strict';
const common = require('../common');
@ -44,6 +45,8 @@ for (const [ value, _method ] of [
[ new Int32Array() ],
[ new Float32Array() ],
[ new Float64Array() ],
[ new BigInt64Array() ],
[ new BigUint64Array() ],
[ Object.defineProperty(new Uint8Array(),
Symbol.toStringTag,
{ value: 'foo' }) ],