Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions benchmark/util/type-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ const args = {
'false-primitive': true,
'false-object': int32Array,
},
DataView: {
'true': dataView,
'false-primitive': true,
'false-object': uint8Array,
},
};

const bench = common.createBenchmark(main, {
Expand Down
5 changes: 5 additions & 0 deletions lib/internal/util/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const {
TypedArrayPrototypeGetSymbolToStringTag,
} = primordials;

function isDataView(value) {
return ArrayBufferIsView(value) && TypedArrayPrototypeGetSymbolToStringTag(value) === undefined;
}

function isTypedArray(value) {
return TypedArrayPrototypeGetSymbolToStringTag(value) !== undefined;
}
Expand Down Expand Up @@ -61,6 +65,7 @@ function isBigUint64Array(value) {
module.exports = {
...internalBinding('types'),
isArrayBufferView: ArrayBufferIsView,
isDataView,
isTypedArray,
isUint8Array,
isUint8ClampedArray,
Expand Down
1 change: 0 additions & 1 deletion src/node_types.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace {
V(AsyncFunction) \
V(BigIntObject) \
V(BooleanObject) \
V(DataView) \
V(Date) \
V(External) \
V(GeneratorFunction) \
Expand Down
17 changes: 0 additions & 17 deletions test/parallel/test-util-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,23 +650,6 @@ for (const [ value, _method ] of [
}
}

{
function testIsDataView(input) {
return types.isDataView(input);
}

eval('%PrepareFunctionForOptimization(testIsDataView)');
testIsDataView(new DataView(new ArrayBuffer()));
eval('%OptimizeFunctionOnNextCall(testIsDataView)');
assert.strictEqual(testIsDataView(new DataView(new ArrayBuffer())), true);
assert.strictEqual(testIsDataView(Math.random()), false);

if (common.isDebug) {
const { getV8FastApiCallCount } = internalBinding('debug');
assert.strictEqual(getV8FastApiCallCount('types.isDataView'), 2);
}
}

{
function testIsSharedArrayBuffer(input) {
return types.isSharedArrayBuffer(input);
Expand Down
Loading