@@ -120,39 +120,147 @@ for (const [ value, _method ] of [
120
120
{
121
121
const primitive = true ;
122
122
const arrayBuffer = new ArrayBuffer ( ) ;
123
+ const buffer = Buffer . from ( arrayBuffer ) ;
123
124
const dataView = new DataView ( arrayBuffer ) ;
124
- const int32Array = new Int32Array ( arrayBuffer ) ;
125
125
const uint8Array = new Uint8Array ( arrayBuffer ) ;
126
- const buffer = Buffer . from ( arrayBuffer ) ;
126
+ const uint8ClampedArray = new Uint8ClampedArray ( arrayBuffer ) ;
127
+ const uint16Array = new Uint16Array ( arrayBuffer ) ;
128
+ const uint32Array = new Uint32Array ( arrayBuffer ) ;
129
+ const int8Array = new Int8Array ( arrayBuffer ) ;
130
+ const int16Array = new Int16Array ( arrayBuffer ) ;
131
+ const int32Array = new Int32Array ( arrayBuffer ) ;
132
+ const float32Array = new Float32Array ( arrayBuffer ) ;
133
+ const float64Array = new Float64Array ( arrayBuffer ) ;
134
+ const bigInt64Array = new BigInt64Array ( arrayBuffer ) ;
135
+ const bigUint64Array = new BigUint64Array ( arrayBuffer ) ;
127
136
137
+ const fakeBuffer = Object . create ( Buffer . prototype ) ;
128
138
const fakeDataView = Object . create ( DataView . prototype ) ;
129
- const fakeInt32Array = Object . create ( Int32Array . prototype ) ;
130
139
const fakeUint8Array = Object . create ( Uint8Array . prototype ) ;
131
- const fakeBuffer = Object . create ( Buffer . prototype ) ;
140
+ const fakeUint8ClampedArray = Object . create ( Uint8ClampedArray . prototype ) ;
141
+ const fakeUint16Array = Object . create ( Uint16Array . prototype ) ;
142
+ const fakeUint32Array = Object . create ( Uint32Array . prototype ) ;
143
+ const fakeInt8Array = Object . create ( Int8Array . prototype ) ;
144
+ const fakeInt16Array = Object . create ( Int16Array . prototype ) ;
145
+ const fakeInt32Array = Object . create ( Int32Array . prototype ) ;
146
+ const fakeFloat32Array = Object . create ( Float32Array . prototype ) ;
147
+ const fakeFloat64Array = Object . create ( Float64Array . prototype ) ;
148
+ const fakeBigInt64Array = Object . create ( BigInt64Array . prototype ) ;
149
+ const fakeBigUint64Array = Object . create ( BigUint64Array . prototype ) ;
132
150
133
151
const stealthyDataView =
134
- Object . setPrototypeOf ( new DataView ( arrayBuffer ) , Uint8Array . prototype ) ;
135
- const stealthyInt32Array =
136
- Object . setPrototypeOf ( new Int32Array ( arrayBuffer ) , uint8Array ) ;
152
+ Object . setPrototypeOf ( new DataView ( arrayBuffer ) , Uint8Array . prototype ) ;
137
153
const stealthyUint8Array =
138
- Object . setPrototypeOf ( new Uint8Array ( arrayBuffer ) , ArrayBuffer . prototype ) ;
154
+ Object . setPrototypeOf ( new Uint8Array ( arrayBuffer ) , ArrayBuffer . prototype ) ;
155
+ const stealthyUint8ClampedArray =
156
+ Object . setPrototypeOf (
157
+ new Uint8ClampedArray ( arrayBuffer ) , ArrayBuffer . prototype
158
+ ) ;
159
+ const stealthyUint16Array =
160
+ Object . setPrototypeOf ( new Uint16Array ( arrayBuffer ) , Uint16Array . prototype ) ;
161
+ const stealthyUint32Array =
162
+ Object . setPrototypeOf ( new Uint32Array ( arrayBuffer ) , Uint32Array . prototype ) ;
163
+ const stealthyInt8Array =
164
+ Object . setPrototypeOf ( new Int8Array ( arrayBuffer ) , Int8Array . prototype ) ;
165
+ const stealthyInt16Array =
166
+ Object . setPrototypeOf ( new Int16Array ( arrayBuffer ) , Int16Array . prototype ) ;
167
+ const stealthyInt32Array =
168
+ Object . setPrototypeOf ( new Int32Array ( arrayBuffer ) , Int32Array . prototype ) ;
169
+ const stealthyFloat32Array =
170
+ Object . setPrototypeOf (
171
+ new Float32Array ( arrayBuffer ) , Float32Array . prototype
172
+ ) ;
173
+ const stealthyFloat64Array =
174
+ Object . setPrototypeOf (
175
+ new Float64Array ( arrayBuffer ) , Float64Array . prototype
176
+ ) ;
177
+ const stealthyBigInt64Array =
178
+ Object . setPrototypeOf (
179
+ new BigInt64Array ( arrayBuffer ) , BigInt64Array . prototype
180
+ ) ;
181
+ const stealthyBigUint64Array =
182
+ Object . setPrototypeOf (
183
+ new BigUint64Array ( arrayBuffer ) , BigUint64Array . prototype
184
+ ) ;
139
185
140
186
const all = [
141
- primitive , arrayBuffer , dataView , int32Array , uint8Array , buffer ,
142
- fakeDataView , fakeInt32Array , fakeUint8Array , fakeBuffer ,
143
- stealthyDataView , stealthyInt32Array , stealthyUint8Array
187
+ primitive , arrayBuffer , buffer , fakeBuffer ,
188
+ dataView , fakeDataView , stealthyDataView ,
189
+ uint8Array , fakeUint8Array , stealthyUint8Array ,
190
+ uint8ClampedArray , fakeUint8ClampedArray , stealthyUint8ClampedArray ,
191
+ uint16Array , fakeUint16Array , stealthyUint16Array ,
192
+ uint32Array , fakeUint32Array , stealthyUint32Array ,
193
+ int8Array , fakeInt8Array , stealthyInt8Array ,
194
+ int16Array , fakeInt16Array , stealthyInt16Array ,
195
+ int32Array , fakeInt32Array , stealthyInt32Array ,
196
+ float32Array , fakeFloat32Array , stealthyFloat32Array ,
197
+ float64Array , fakeFloat64Array , stealthyFloat64Array ,
198
+ bigInt64Array , fakeBigInt64Array , stealthyBigInt64Array ,
199
+ bigUint64Array , fakeBigUint64Array , stealthyBigUint64Array
144
200
] ;
145
201
146
202
const expected = {
147
203
isArrayBufferView : [
148
- dataView , int32Array , uint8Array , buffer ,
149
- stealthyDataView , stealthyInt32Array , stealthyUint8Array
204
+ buffer ,
205
+ dataView , stealthyDataView ,
206
+ uint8Array , stealthyUint8Array ,
207
+ uint8ClampedArray , stealthyUint8ClampedArray ,
208
+ uint16Array , stealthyUint16Array ,
209
+ uint32Array , stealthyUint32Array ,
210
+ int8Array , stealthyInt8Array ,
211
+ int16Array , stealthyInt16Array ,
212
+ int32Array , stealthyInt32Array ,
213
+ float32Array , stealthyFloat32Array ,
214
+ float64Array , stealthyFloat64Array ,
215
+ bigInt64Array , stealthyBigInt64Array ,
216
+ bigUint64Array , stealthyBigUint64Array
150
217
] ,
151
218
isTypedArray : [
152
- int32Array , uint8Array , buffer , stealthyInt32Array , stealthyUint8Array
219
+ buffer ,
220
+ uint8Array , stealthyUint8Array ,
221
+ uint8ClampedArray , stealthyUint8ClampedArray ,
222
+ uint16Array , stealthyUint16Array ,
223
+ uint32Array , stealthyUint32Array ,
224
+ int8Array , stealthyInt8Array ,
225
+ int16Array , stealthyInt16Array ,
226
+ int32Array , stealthyInt32Array ,
227
+ float32Array , stealthyFloat32Array ,
228
+ float64Array , stealthyFloat64Array ,
229
+ bigInt64Array , stealthyBigInt64Array ,
230
+ bigUint64Array , stealthyBigUint64Array
153
231
] ,
154
232
isUint8Array : [
155
- uint8Array , buffer , stealthyUint8Array
233
+ buffer , uint8Array , stealthyUint8Array
234
+ ] ,
235
+ isUint8ClampedArray : [
236
+ uint8ClampedArray , stealthyUint8ClampedArray
237
+ ] ,
238
+ isUint16Array : [
239
+ uint16Array , stealthyUint16Array
240
+ ] ,
241
+ isUint32Array : [
242
+ uint32Array , stealthyUint32Array
243
+ ] ,
244
+ isInt8Array : [
245
+ int8Array , stealthyInt8Array
246
+ ] ,
247
+ isInt16Array : [
248
+ int16Array , stealthyInt16Array
249
+ ] ,
250
+ isInt32Array : [
251
+ int32Array , stealthyInt32Array
252
+ ] ,
253
+ isFloat32Array : [
254
+ float32Array , stealthyFloat32Array
255
+ ] ,
256
+ isFloat64Array : [
257
+ float64Array , stealthyFloat64Array
258
+ ] ,
259
+ isBigInt64Array : [
260
+ bigInt64Array , stealthyBigInt64Array
261
+ ] ,
262
+ isBigUint64Array : [
263
+ bigUint64Array , stealthyBigUint64Array
156
264
]
157
265
} ;
158
266
0 commit comments