* getRandomData creates a random data used for testing the upload bandwidth. * @param size - creates a blob of the given size. * @returns {*}
(size)
| 376 | * @returns {*} |
| 377 | */ |
| 378 | function getRandomData(size) { |
| 379 | function getData() { |
| 380 | return Math.random().toString(); |
| 381 | } |
| 382 | |
| 383 | var count = size / 2; |
| 384 | var result = getData(); |
| 385 | |
| 386 | while (result.length <= count) { |
| 387 | result += getData(); |
| 388 | } |
| 389 | |
| 390 | result = result + result.substring(0, size - result.length); |
| 391 | var blob; |
| 392 | try { |
| 393 | blob = new Blob([result], { |
| 394 | type: "application/octet-stream" |
| 395 | }); |
| 396 | } catch (e) { |
| 397 | var bb = new BlobBuilder; // jshint ignore:line |
| 398 | bb.append(result); |
| 399 | blob = bb.getBlob("application/octet-stream"); |
| 400 | } |
| 401 | console.log(blob.size); |
| 402 | return blob; |
| 403 | } |
| 404 | |
| 405 | //TODO will be moved to a seperate file |
| 406 | function slicing(data, start, end) { |
no test coverage detected