lib: use js-only implementation of isDataView()

PR-URL: https://github.com/nodejs/node/pull/62780
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jordan Harband <ljharb@gmail.com>
Reviewed-By: Xuguang Mei <meixuguang@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Edy Silva <edigleyssonsilva@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>
This commit is contained in:
René authored and GitHub committed 2026-04-18 20:04:06 +00:00
1 parent ad44dc429c
commit 1bc6394601
4 files changed
+10 -18

No files matched your search

+5
View File
@@ -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, {
+5
View File
@@ -6,6 +6,10 @@ const {
TypedArrayPrototypeGetSymbolToStringTag,
} = primordials;
function isDataView(value) {
return ArrayBufferIsView(value) && TypedArrayPrototypeGetSymbolToStringTag(value) === undefined;
}
function isTypedArray(value) {
return TypedArrayPrototypeGetSymbolToStringTag(value) !== undefined;
}
@@ -61,6 +65,7 @@ function isBigUint64Array(value) {
module.exports = {
...internalBinding('types'),
isArrayBufferView: ArrayBufferIsView,
isDataView,
isTypedArray,
isUint8Array,
isUint8ClampedArray,
-1
View File
@@ -19,7 +19,6 @@ namespace {
V(AsyncFunction) \
V(BigIntObject) \
V(BooleanObject) \
V(DataView) \
V(Date) \
V(External) \
V(GeneratorFunction) \
-17
View File
@@ -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);