(thing)
| 267 | } |
| 268 | |
| 269 | function convertToUint8Array(thing) { |
| 270 | return new Promise(function(resolve, reject) { |
| 271 | if (thing instanceof Uint8Array) { |
| 272 | resolve(thing); |
| 273 | } else if (thing instanceof ArrayBuffer || ArrayBuffer.isView(thing)) { |
| 274 | resolve(new Uint8Array(thing)); |
| 275 | } else if (thing instanceof Blob) { |
| 276 | resolve(readBlobAsBuffer(thing).then(function(buffer) { |
| 277 | return new Uint8Array(buffer); |
| 278 | })); |
| 279 | } else { |
| 280 | // Assume that Blob will know how to read this thing |
| 281 | resolve(readBlobAsBuffer(new Blob([thing])).then(function(buffer) { |
| 282 | return new Uint8Array(buffer); |
| 283 | })); |
| 284 | } |
| 285 | }); |
| 286 | } |
| 287 | |
| 288 | function measureData(data) { |
| 289 | let result = data.byteLength || data.length || data.size; |
no test coverage detected