Skip to content

Commit

Permalink
util: add type check functions for BigInt arrays
Browse files Browse the repository at this point in the history
Adds `isBigInt64Array` and `isBigUint64Array`.

PR-URL: #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>
  • Loading branch information
targos authored and jasnell committed Apr 16, 2018
1 parent 61f8783 commit be4950d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/internal/util/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -72,5 +80,7 @@ module.exports = {
isInt16Array,
isInt32Array,
isFloat32Array,
isFloat64Array
isFloat64Array,
isBigInt64Array,
isBigUint64Array
};
2 changes: 2 additions & 0 deletions test/.eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ rules:
# Global scoped methods and vars
globals:
WebAssembly: false
BigInt64Array: false
BigUint64Array: false
3 changes: 3 additions & 0 deletions test/parallel/test-util-types.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// Flags: --harmony-bigint
/* global SharedArrayBuffer */
'use strict';
const common = require('../common');
Expand Down Expand Up @@ -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' }) ],
Expand Down

0 comments on commit be4950d

Please sign in to comment.