fast-readable-async-iterator
Advanced tools
Comparing version 1.1.2 to 2.0.0
51
index.js
@@ -1,25 +0,34 @@ | ||
if (typeof ReadableStream !== 'undefined' && !ReadableStream.prototype[Symbol.asyncIterator]) { | ||
ReadableStream.prototype[Symbol.asyncIterator] = function () { | ||
const reader = this.getReader() | ||
let last = reader.read() | ||
return { | ||
next () { | ||
const temp = last | ||
last = reader.read() | ||
return temp | ||
}, | ||
async return (value) { | ||
await last | ||
reader.releaseLock() | ||
return { done: true, value } | ||
}, | ||
async throw (err) { | ||
await this.return() | ||
throw err | ||
}, | ||
[Symbol.asyncIterator] () { | ||
return this | ||
if (typeof ReadableStream !== 'undefined') { | ||
if (!ReadableStream.prototype[Symbol.asyncIterator]) { | ||
ReadableStream.prototype[Symbol.asyncIterator] = function ({ preventCancel } = {}) { | ||
const reader = this.getReader() | ||
const stream = this | ||
let last = reader.read() | ||
return { | ||
next () { | ||
const temp = last | ||
last = reader.read() | ||
return temp | ||
}, | ||
async return (value) { | ||
await last | ||
reader.releaseLock() | ||
if (!preventCancel) stream.cancel() | ||
return { done: true, value } | ||
}, | ||
async throw (err) { | ||
await this.return() | ||
throw err | ||
}, | ||
[Symbol.asyncIterator] () { | ||
return this | ||
} | ||
} | ||
} | ||
} | ||
if (!ReadableStream.prototype.getIterator) { | ||
ReadableStream.prototype.getIterator = function ({ preventCancel } = {}) { | ||
return this[Symbol.asyncIterator]({ preventCancel }) | ||
} | ||
} | ||
} |
{ | ||
"name": "fast-readable-async-iterator", | ||
"version": "1.1.2", | ||
"version": "2.0.0", | ||
"description": "Fast Async Iterator for browser Readable Streams.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1855
34