1- const TypedArrayProto : { at ?: typeof arrayLikeAt } = Reflect . getPrototypeOf ( Int8Array ) || { }
1+ const TypedArray = Reflect . getPrototypeOf ( Int8Array ) as Int8ArrayConstructor | null
22
33export function arrayLikeAt < T > ( this : ArrayLike < T > , i : number ) : T | void {
44 const l = this . length
@@ -14,21 +14,27 @@ export function isSupported(): boolean {
1414 typeof Array . prototype . at === 'function' &&
1515 'at' in String . prototype &&
1616 typeof String . prototype . at === 'function' &&
17- 'at' in TypedArrayProto &&
18- typeof TypedArrayProto . at === 'function'
17+ typeof TypedArray === 'function' &&
18+ 'at' in TypedArray . prototype &&
19+ typeof TypedArray . prototype . at === 'function'
1920 )
2021}
2122
2223/*#__PURE__*/
2324export function isPolyfilled ( ) : boolean {
24- return Array . prototype . at === arrayLikeAt && String . prototype . at === arrayLikeAt && TypedArrayProto . at === arrayLikeAt
25+ return (
26+ Array . prototype . at === arrayLikeAt &&
27+ String . prototype . at === arrayLikeAt &&
28+ typeof TypedArray === 'function' &&
29+ TypedArray . prototype . at === arrayLikeAt
30+ )
2531}
2632
2733export function apply ( ) : void {
2834 if ( ! isSupported ( ) ) {
2935 const defn = { value : arrayLikeAt , writable : true , configurable : true }
3036 Object . defineProperty ( Array . prototype , 'at' , defn )
3137 Object . defineProperty ( String . prototype , 'at' , defn )
32- Object . defineProperty ( TypedArrayProto , 'at' , defn )
38+ Object . defineProperty ( TypedArray , 'at' , defn )
3339 }
3440}
0 commit comments