@@ -9,14 +9,13 @@ function uncurryThis(f) {
9
9
return f . call . bind ( f ) ;
10
10
}
11
11
12
- var supported = {
13
- BigInt : typeof BigInt !== 'undefined' ,
14
- Symbol : typeof Symbol !== 'undefined' ,
15
- Uint8Array : typeof Uint8Array !== 'undefined' ,
16
- ArrayBuffer : typeof ArrayBuffer !== 'undefined'
17
- } ;
12
+ var BigIntSupported = typeof BigInt !== 'undefined' ;
13
+ var SymbolSupported = typeof Symbol !== 'undefined' ;
14
+ var SymbolToStringTagSupported = SymbolSupported && typeof Symbol . toStringTag !== 'undefined' ;
15
+ var Uint8ArraySupported = typeof Uint8Array !== 'undefined' ;
16
+ var ArrayBufferSupported = typeof ArrayBuffer !== 'undefined' ;
18
17
19
- if ( supported . Uint8Array ) {
18
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
20
19
var TypedArrayPrototype = Object . getPrototypeOf ( Uint8Array . prototype ) ;
21
20
22
21
var TypedArrayProto_toStringTag =
@@ -32,11 +31,11 @@ var numberValue = uncurryThis(Number.prototype.valueOf);
32
31
var stringValue = uncurryThis ( String . prototype . valueOf ) ;
33
32
var booleanValue = uncurryThis ( Boolean . prototype . valueOf ) ;
34
33
35
- if ( supported . BigInt ) {
34
+ if ( BigIntSupported ) {
36
35
var bigIntValue = uncurryThis ( BigInt . prototype . valueOf ) ;
37
36
}
38
37
39
- if ( supported . Symbol ) {
38
+ if ( SymbolSupported ) {
40
39
var symbolValue = uncurryThis ( Symbol . prototype . valueOf ) ;
41
40
}
42
41
@@ -60,79 +59,127 @@ var methods = [
60
59
{
61
60
name : 'isArrayBufferView' ,
62
61
function : function isArrayBufferView ( value ) {
63
- return supported . ArrayBuffer && ArrayBuffer . isView ( value ) ;
62
+ return ArrayBufferSupported && ArrayBuffer . isView ( value ) ;
64
63
} ,
65
64
} ,
66
65
{
67
66
name : 'isTypedArray' ,
68
67
function : function isTypedArray ( value ) {
69
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) !== undefined ;
68
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
69
+ return TypedArrayProto_toStringTag ( value ) !== undefined ;
70
+ } else {
71
+ return ObjectToString ( value ) === '[object TypedArray]' ;
72
+ }
70
73
}
71
74
} ,
72
75
{
73
76
name : 'isUint8Array' ,
74
77
function : function isUint8Array ( value ) {
75
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'Uint8Array' ;
78
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
79
+ return TypedArrayProto_toStringTag ( value ) === 'Uint8Array' ;
80
+ } else {
81
+ return ObjectToString ( value ) === '[object Uint8Array]' ;
82
+ }
76
83
}
77
84
} ,
78
85
{
79
86
name : 'isUint8ClampedArray' ,
80
87
function : function isUint8ClampedArray ( value ) {
81
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'Uint8ClampedArray' ;
88
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
89
+ return TypedArrayProto_toStringTag ( value ) === 'Uint8ClampedArray' ;
90
+ } else {
91
+ return ObjectToString ( value ) === '[object Uint8ClampedArray]' ;
92
+ }
82
93
}
83
94
} ,
84
95
{
85
96
name : 'isUint16Array' ,
86
97
function : function isUint16Array ( value ) {
87
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'Uint16Array' ;
98
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
99
+ return TypedArrayProto_toStringTag ( value ) === 'Uint16Array' ;
100
+ } else {
101
+ return ObjectToString ( value ) === '[object Uint16Array]' ;
102
+ }
88
103
}
89
104
} ,
90
105
{
91
106
name : 'isUint32Array' ,
92
107
function : function isUint32Array ( value ) {
93
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'Uint32Array' ;
108
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
109
+ return TypedArrayProto_toStringTag ( value ) === 'Uint32Array' ;
110
+ } else {
111
+ return ObjectToString ( value ) === '[object Uint32Array]' ;
112
+ }
94
113
}
95
114
} ,
96
115
{
97
116
name : 'isInt8Array' ,
98
117
function : function isInt8Array ( value ) {
99
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'Int8Array' ;
118
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
119
+ return TypedArrayProto_toStringTag ( value ) === 'Int8Array' ;
120
+ } else {
121
+ return ObjectToString ( value ) === '[object Int8Array]' ;
122
+ }
100
123
}
101
124
} ,
102
125
{
103
126
name : 'isInt16Array' ,
104
127
function : function isInt16Array ( value ) {
105
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'Int16Array' ;
128
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
129
+ return TypedArrayProto_toStringTag ( value ) === 'Int16Array' ;
130
+ } else {
131
+ return ObjectToString ( value ) === '[object Int16Array]' ;
132
+ }
106
133
}
107
134
} ,
108
135
{
109
136
name : 'isInt32Array' ,
110
137
function : function isInt32Array ( value ) {
111
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'Int32Array' ;
138
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
139
+ return TypedArrayProto_toStringTag ( value ) === 'Int32Array' ;
140
+ } else {
141
+ return ObjectToString ( value ) === '[object Int32Array]' ;
142
+ }
112
143
}
113
144
} ,
114
145
{
115
146
name : 'isFloat32Array' ,
116
147
function : function isFloat32Array ( value ) {
117
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'Float32Array' ;
148
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
149
+ return TypedArrayProto_toStringTag ( value ) === 'Float32Array' ;
150
+ } else {
151
+ return ObjectToString ( value ) === '[object Float32Array]' ;
152
+ }
118
153
}
119
154
} ,
120
155
{
121
156
name : 'isFloat64Array' ,
122
157
function : function isFloat64Array ( value ) {
123
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'Float64Array' ;
158
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
159
+ return TypedArrayProto_toStringTag ( value ) === 'Float64Array' ;
160
+ } else {
161
+ return ObjectToString ( value ) === '[object Float64Array]' ;
162
+ }
124
163
}
125
164
} ,
126
165
{
127
166
name : 'isBigInt64Array' ,
128
167
function : function isBigInt64Array ( value ) {
129
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'BigInt64Array' ;
168
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
169
+ return TypedArrayProto_toStringTag ( value ) === 'BigInt64Array' ;
170
+ } else {
171
+ return ObjectToString ( value ) === '[object BigInt64Array]' ;
172
+ }
130
173
}
131
174
} ,
132
175
{
133
176
name : 'isBigUint64Array' ,
134
177
function : function isBigUint64Array ( value ) {
135
- return supported . Uint8Array && TypedArrayProto_toStringTag ( value ) === 'BigUint64Array' ;
178
+ if ( Uint8ArraySupported && SymbolToStringTagSupported ) {
179
+ return TypedArrayProto_toStringTag ( value ) === 'BigUint64Array' ;
180
+ } else {
181
+ return ObjectToString ( value ) === '[object BigUint64Array]' ;
182
+ }
136
183
}
137
184
} ,
138
185
{
@@ -240,13 +287,13 @@ var methods = [
240
287
{
241
288
name : 'isBigIntObject' ,
242
289
function : function isBigIntObject ( value ) {
243
- return supported . BigInt && checkBoxedPrimitive ( value , bigIntValue ) ;
290
+ return BigIntSupported && checkBoxedPrimitive ( value , bigIntValue ) ;
244
291
}
245
292
} ,
246
293
{
247
294
name : 'isSymbolObject' ,
248
295
function : function isSymbolObject ( value ) {
249
- return supported . Symbol && checkBoxedPrimitive ( value , symbolValue ) ;
296
+ return SymbolSupported && checkBoxedPrimitive ( value , symbolValue ) ;
250
297
}
251
298
} ,
252
299
{
@@ -264,7 +311,7 @@ var methods = [
264
311
{
265
312
name : 'isAnyArrayBuffer' ,
266
313
function : function isAnyArrayBuffer ( value ) {
267
- return supported . Uint8Array && (
314
+ return Uint8ArraySupported && (
268
315
exports . isArrayBuffer ( value ) ||
269
316
exports . isSharedArrayBuffer ( value )
270
317
) ;
0 commit comments