github
730 of 1049 branches covered (69.59%)
1439 of 2000 new or added lines in 41 files covered. (71.95%)
6 existing lines in 1 file now uncovered.5196 of 7254 relevant lines covered (71.63%)
68.15 hits per line
| 1 |
import { Transform } from 'stream';
|
1✔ |
| 2 |
|
1✔ |
| 3 |
class CacheStream extends Transform { |
|
| 4 |
_cache: Buffer[];
|
23✔ |
| 5 |
|
23✔ |
| 6 |
constructor() {
|
|
| 7 |
super(); |
23✔ |
| 8 |
|
23✔ |
| 9 |
this._cache = [];
|
23✔ |
| 10 |
} |
23✔ |
| 11 |
|
23✔ |
| 12 |
_transform(chunk, enc, callback) {
|
|
| 13 |
const buf = chunk instanceof Buffer ? chunk : Buffer.from(chunk, enc);
|
|
| 14 |
this._cache.push(buf);
|
10✔ |
| 15 |
this.push(buf);
|
10✔ |
| 16 |
callback(); |
10✔ |
| 17 |
} |
10✔ |
| 18 |
|
23✔ |
| 19 |
getCache() {
|
|
| 20 |
return Buffer.concat(this._cache); |
12✔ |
| 21 |
} |
12✔ |
| 22 |
} |
23✔ |
| 23 |
|
1✔ |
|
|
|
1✔ |
|
|
// For ESM compatibility
|
1✔ |
|
|
export default CacheStream; |
1✔ |
|
|
// For CommonJS compatibility
|
1✔ |
|
|
if (typeof module !== 'undefined' && typeof module.exports === 'object' && module.exports !== null) { |
|
|
NEW
|
module.exports = CacheStream; |
× |
|
NEW
|
// For ESM compatibility
|
× |
|
NEW
|
module.exports.default = CacheStream;
|
× |
|
NEW
|
} |
× |