You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

15 lines
318 B

6 months ago
  1. const {asyncIterator} = Symbol;
  2. const readBlob = async function* (blob) {
  3. if (blob.stream) {
  4. yield* blob.stream()
  5. } else if (blob.arrayBuffer) {
  6. yield await blob.arrayBuffer()
  7. } else if (blob[asyncIterator]) {
  8. yield* blob[asyncIterator]();
  9. } else {
  10. yield blob;
  11. }
  12. }
  13. export default readBlob;