| 541 | // see https://github.com/promises-aplus/promises-spec/issues/179 |
| 542 | return new Promise(function (resolve, reject) { |
| 543 | var readNextChunk = function () { |
| 544 | reader.read().then(function (result) { |
| 545 | if (result.done) { |
| 546 | //Note: bytes in textDecoder are ignored |
| 547 | resolve(undefined); |
| 548 | } else { |
| 549 | var chunk = textDecoder.decode(result.value, {stream: true}); |
| 550 | onProgressCallback(chunk); |
| 551 | readNextChunk(); |
| 552 | } |
| 553 | })["catch"](function (error) { |
| 554 | reject(error); |
| 555 | }); |
| 556 | }; |
| 557 | readNextChunk(); |
| 558 | }); |
| 559 | })["catch"](function (error) { |