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