Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e21b873

Browse filesBrowse files
Renegade334aduh95
authored andcommitted
lib: use js-only implementation of isDataView()
PR-URL: #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>
1 parent 2b12bca commit e21b873
Copy full SHA for e21b873

4 files changed

+10-18Lines changed: 10 additions & 18 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎benchmark/util/type-check.js‎

Copy file name to clipboardExpand all lines: benchmark/util/type-check.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ const args = {
2323
'false-primitive': true,
2424
'false-object': int32Array,
2525
},
26+
DataView: {
27+
'true': dataView,
28+
'false-primitive': true,
29+
'false-object': uint8Array,
30+
},
2631
};
2732

2833
const bench = common.createBenchmark(main, {
Collapse file

‎lib/internal/util/types.js‎

Copy file name to clipboardExpand all lines: lib/internal/util/types.js
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ const {
66
TypedArrayPrototypeGetSymbolToStringTag,
77
} = primordials;
88

9+
function isDataView(value) {
10+
return ArrayBufferIsView(value) && TypedArrayPrototypeGetSymbolToStringTag(value) === undefined;
11+
}
12+
913
function isTypedArray(value) {
1014
return TypedArrayPrototypeGetSymbolToStringTag(value) !== undefined;
1115
}
@@ -61,6 +65,7 @@ function isBigUint64Array(value) {
6165
module.exports = {
6266
...internalBinding('types'),
6367
isArrayBufferView: ArrayBufferIsView,
68+
isDataView,
6469
isTypedArray,
6570
isUint8Array,
6671
isUint8ClampedArray,
Collapse file

‎src/node_types.cc‎

Copy file name to clipboardExpand all lines: src/node_types.cc
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ namespace {
1919
V(AsyncFunction) \
2020
V(BigIntObject) \
2121
V(BooleanObject) \
22-
V(DataView) \
2322
V(Date) \
2423
V(External) \
2524
V(GeneratorFunction) \
Collapse file

‎test/parallel/test-util-types.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-util-types.js
-17Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -650,23 +650,6 @@ for (const [ value, _method ] of [
650650
}
651651
}
652652

653-
{
654-
function testIsDataView(input) {
655-
return types.isDataView(input);
656-
}
657-
658-
eval('%PrepareFunctionForOptimization(testIsDataView)');
659-
testIsDataView(new DataView(new ArrayBuffer()));
660-
eval('%OptimizeFunctionOnNextCall(testIsDataView)');
661-
assert.strictEqual(testIsDataView(new DataView(new ArrayBuffer())), true);
662-
assert.strictEqual(testIsDataView(Math.random()), false);
663-
664-
if (common.isDebug) {
665-
const { getV8FastApiCallCount } = internalBinding('debug');
666-
assert.strictEqual(getV8FastApiCallCount('types.isDataView'), 2);
667-
}
668-
}
669-
670653
{
671654
function testIsSharedArrayBuffer(input) {
672655
return types.isSharedArrayBuffer(input);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.