mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
refactor(ext/webidl): use TypedArrayPrototypeGetSymbolToStringTag
(#17602)
This commit is contained in:
parent
717daf4748
commit
8da235adce
1 changed files with 1 additions and 9 deletions
|
@ -486,14 +486,6 @@ converters.DataView = (V, opts = {}) => {
|
|||
return V;
|
||||
};
|
||||
|
||||
// Returns the unforgeable `TypedArray` constructor name or `undefined`,
|
||||
// if the `this` value isn't a valid `TypedArray` object.
|
||||
//
|
||||
// https://tc39.es/ecma262/#sec-get-%typedarray%.prototype-@@tostringtag
|
||||
const typedArrayNameGetter = ObjectGetOwnPropertyDescriptor(
|
||||
ObjectGetPrototypeOf(Uint8Array).prototype,
|
||||
SymbolToStringTag,
|
||||
).get;
|
||||
ArrayPrototypeForEach(
|
||||
[
|
||||
Int8Array,
|
||||
|
@ -510,7 +502,7 @@ ArrayPrototypeForEach(
|
|||
const name = func.name;
|
||||
const article = RegExpPrototypeTest(/^[AEIOU]/, name) ? "an" : "a";
|
||||
converters[name] = (V, opts = {}) => {
|
||||
if (!ArrayBufferIsView(V) || typedArrayNameGetter.call(V) !== name) {
|
||||
if (TypedArrayPrototypeGetSymbolToStringTag(V) !== name) {
|
||||
throw makeException(
|
||||
TypeError,
|
||||
`is not ${article} ${name} object`,
|
||||
|
|
Loading…
Reference in a new issue