mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
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:
4 files changed
+10
-18
No files matched your search
@@ -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, {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -19,7 +19,6 @@ namespace {
|
||||
V(AsyncFunction) \
|
||||
V(BigIntObject) \
|
||||
V(BooleanObject) \
|
||||
V(DataView) \
|
||||
V(Date) \
|
||||
V(External) \
|
||||
V(GeneratorFunction) \
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user