readable-web-to-node-stream
Advanced tools
Comparing version 3.0.2 to 3.0.3
@@ -19,5 +19,5 @@ import { Readable } from 'readable-stream'; | ||
* | ||
* @param stream ReadableStream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream | ||
* @param stream ReadableStream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream | ||
*/ | ||
constructor(stream: ReadableStream); | ||
constructor(stream: ReadableStream | ReadableStream<Uint8Array>); | ||
/** | ||
@@ -29,3 +29,3 @@ * Implementation of readable._read(size). | ||
*/ | ||
_read(): Promise<void>; | ||
_read(): void; | ||
/** | ||
@@ -32,0 +32,0 @@ * If there is no unresolved read call to Web-API ReadableStream immediately returns; |
@@ -14,3 +14,3 @@ "use strict"; | ||
* | ||
* @param stream ReadableStream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream | ||
* @param stream ReadableStream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream | ||
*/ | ||
@@ -29,3 +29,3 @@ constructor(stream) { | ||
*/ | ||
async _read() { | ||
_read() { | ||
// Should start pushing data into the queue | ||
@@ -37,13 +37,17 @@ // Read data from the underlying Web-API-readable-stream | ||
} | ||
this.pendingRead = this.reader.read(); | ||
const data = await this.pendingRead; | ||
// clear the promise before pushing pushing new data to the queue and allow sequential calls to _read() | ||
delete this.pendingRead; | ||
if (data.done || this.released) { | ||
this.push(null); // Signal EOF | ||
} | ||
else { | ||
this.bytesRead += data.value.length; | ||
this.push(data.value); // Push new data to the queue | ||
} | ||
this.pendingRead = this.reader | ||
.read() | ||
.then((data) => { | ||
delete this.pendingRead; | ||
if (data.done || this.released) { | ||
this.push(null); // Signal EOF | ||
} | ||
else { | ||
this.bytesRead += data.value.length; | ||
this.push(data.value); // Push new data to the queue | ||
} | ||
}) | ||
.catch((err) => { | ||
this.destroy(err); | ||
}); | ||
} | ||
@@ -50,0 +54,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.parseReadableStream = void 0; | ||
localStorage.debug = 'readable-web-to-node-stream'; | ||
const assert = require("assert"); | ||
const mmb = require("music-metadata-browser"); | ||
@@ -14,4 +12,4 @@ const index_1 = require("./index"); | ||
}); | ||
assert.ok(response.ok, `HTTP error status=${response.status}: ${response.statusText}`); | ||
assert.ok(response.body, 'HTTP-stream'); | ||
expect(response.ok).withContext(`HTTP error status=${response.status}: ${response.statusText}`); | ||
expect(response.body).withContext('HTTP-stream').toBeDefined(); | ||
return response; | ||
@@ -25,3 +23,2 @@ } | ||
} | ||
exports.parseReadableStream = parseReadableStream; | ||
const tiuqottigeloot_vol24_Tracks = [ | ||
@@ -138,6 +135,9 @@ { | ||
it(`track ${track.metaData.artist} - ${track.metaData.title}`, async () => { | ||
const url = 'https://raw.githubusercontent.com/Borewit/test-audio/958e057' + track.url; | ||
const url = `https://raw.githubusercontent.com/Borewit/test-audio/958e057${track.url}`; | ||
const response = await httpGetByUrl(url); | ||
const contentLength = response.headers.get('Content-Length'); | ||
expect(response.body).toBeDefined(); | ||
// @ts-ignore | ||
const metadata = await parseReadableStream(response.body, { | ||
size: parseInt(response.headers.get('Content-Length'), 10), | ||
size: contentLength ? Number.parseInt(contentLength, 10) : undefined, | ||
mimeType: response.headers.get('Content-Type') | ||
@@ -144,0 +144,0 @@ }); |
{ | ||
"name": "readable-web-to-node-stream", | ||
"version": "3.0.2", | ||
"version": "3.0.3", | ||
"description": "Converts a Web-API readable-stream into a Node readable-stream.", | ||
@@ -15,17 +15,14 @@ "main": "lib/index.js", | ||
"scripts": { | ||
"clean": "del-cli lib/**/*.js lib/**/*.js.map lib/**/*.d.ts coverage", | ||
"clean": "del-cli 'lib/**/*.js' 'lib/**/*.js.map' 'lib/**/*.d.ts' 'coverage'", | ||
"compile-lib": "tsc -p lib/tsconfig.json", | ||
"compile-test": "tsc -p lib/tsconfig.spec.json", | ||
"prepublishOnly": "yarn run build", | ||
"build": "npm run compile-lib && npm run compile-test", | ||
"tslint": "tslint 'lib/**/*.ts' --exclude 'lib/**/*.d.ts'", | ||
"eslint": "eslint karma.conf.js", | ||
"lint": "npm run tslint && npm run eslint", | ||
"build": "yarn run compile-lib && npm run compile-test", | ||
"lint-ts": "biome check", | ||
"lint": "yarn run biome check", | ||
"test": "karma start --single-run", | ||
"karma-headless": "karma start --single-run --reporters coverage-istanbul,spec,progress", | ||
"karma": "karma start", | ||
"karma-firefox": "karma start --browsers Firefox", | ||
"karma-once": "karma start --browsers Chrome --single-run", | ||
"travis-karma": "karma start --browsers Firefox --single-run --reporters coverage-istanbul,spec", | ||
"browserstack": "karma start --browsers bs_win_chrome,bs_win_firefox,bs_osx_safari --single-run --reporters coverage-istanbul,spec", | ||
"travis-karma-browserstack": "karma start --browsers bs_win_chrome,bs_win_firefox,bs_osx_safari --single-run --reporters coverage-istanbul,spec,BrowserStack", | ||
"post-coveralls": "coveralls < coverage/lcov.info", | ||
@@ -59,28 +56,32 @@ "post-codacy": " codacy-coverage < coverage/lcov.info" | ||
"dependencies": { | ||
"readable-stream": "^3.6.0" | ||
"process": "^0.11.10", | ||
"readable-stream": "^4.7.0" | ||
}, | ||
"devDependencies": { | ||
"@types/jasmine": "^3.8.1", | ||
"@types/node": "^16.3.1", | ||
"@types/readable-stream": "^2.3.9", | ||
"coveralls": "^3.1.0", | ||
"del-cli": "^3.0.1", | ||
"eslint": "^7.18.0", | ||
"@biomejs/biome": "^1.9.4", | ||
"@types/jasmine": "^5.1.5", | ||
"@types/node": "^22.13.0", | ||
"@types/readable-stream": "^4.0.18", | ||
"coveralls": "^3.1.1", | ||
"del-cli": "^6.0.0", | ||
"istanbul-instrumenter-loader": "^3.0.1", | ||
"jasmine-core": "^3.8.0", | ||
"karma": "^6.3.4", | ||
"karma-browserstack-launcher": "^1.6.0", | ||
"karma-chrome-launcher": "^3.1.0", | ||
"jasmine-core": "^5.5.0", | ||
"karma": "^6.4.4", | ||
"karma-chrome-launcher": "^3.2.0", | ||
"karma-coverage-istanbul-reporter": "^3.0.3", | ||
"karma-firefox-launcher": "^2.1.0", | ||
"karma-jasmine": "^4.0.1", | ||
"karma-jasmine-html-reporter": "^1.7.0", | ||
"karma-spec-reporter": "^0.0.32", | ||
"karma-webpack": "^5.0.0", | ||
"music-metadata-browser": "^2.2.7", | ||
"ts-loader": "^8.0.14", | ||
"tslint": "^6.1.3", | ||
"typescript": "^4.3.5", | ||
"webpack": "^4.46.0" | ||
} | ||
"karma-edge-launcher": "^0.4.2", | ||
"karma-firefox-launcher": "^2.1.3", | ||
"karma-jasmine": "^5.1.0", | ||
"karma-jasmine-html-reporter": "^2.1.0", | ||
"karma-safari-launcher": "^1.0.0", | ||
"karma-spec-reporter": "^0.0.36", | ||
"karma-webpack": "^5.0.1", | ||
"music-metadata-browser": "^2.5.11", | ||
"ts-loader": "^9.5.2", | ||
"typescript": "^5.7.3", | ||
"url": "^0.11.4", | ||
"webpack": "^5.94.0", | ||
"webpack-cli": "^6.0.1" | ||
}, | ||
"packageManager": "yarn@4.6.0" | ||
} |
@@ -1,5 +0,4 @@ | ||
![Karma CI](https://github.com/Borewit/readable-web-to-node-stream/workflows/Karma%20CI/badge.svg) | ||
[![CI browser tests](https://github.com/Borewit/readable-web-to-node-stream/actions/workflows/xvfb-ci.yml/badge.svg)](https://github.com/Borewit/readable-web-to-node-stream/actions/workflows/xvfb-ci.yml) | ||
[![NPM version](https://badge.fury.io/js/readable-web-to-node-stream.svg)](https://npmjs.org/package/readable-web-to-node-stream) | ||
[![npm downloads](http://img.shields.io/npm/dm/readable-web-to-node-stream.svg)](https://npmcharts.com/compare/readable-web-to-node-stream) | ||
[![dependencies Status](https://david-dm.org/Borewit/readable-web-to-node-stream/status.svg)](https://david-dm.org/Borewit/readable-web-to-node-stream) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/Borewit/readable-web-to-node-stream/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Borewit/readable-web-to-node-stream?targetFile=package.json) | ||
@@ -14,2 +13,5 @@ [![Codacy Badge](https://app.codacy.com/project/badge/Grade/d4b511481b3a4634b6ca5c0724407eb9)](https://www.codacy.com/gh/Borewit/peek-readable/dashboard?utm_source=github.com&utm_medium=referral&utm_content=Borewit/peek-readable&utm_campaign=Badge_Grade) | ||
To covert the other way around, from [Node.js readable stream](https://nodejs.org/api/stream.html#stream_readable_streams) to [Web-API readable stream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader), | ||
you may use [node-readable-to-web-readable-stream](https://github.com/Borewit/node-readable-to-web-readable-stream). | ||
## Installation | ||
@@ -21,3 +23,3 @@ Install via [npm](http://npmjs.org/): | ||
``` | ||
or or [yarn](https://yarnpkg.com/): | ||
or [yarn](https://yarnpkg.com/): | ||
```bash | ||
@@ -32,7 +34,4 @@ yarn add readable-web-to-node-stream | ||
Unit tests are performed on the following browsers: | ||
* Latest Google Chrome 74.0 | ||
* Google Chrome 74.0 | ||
* Firefox 68.0 | ||
* Safari 12.0 | ||
* Opera 60.0 | ||
@@ -39,0 +38,0 @@ ## Example |
16029
6
258
2
24
71
+ Addedprocess@^0.11.10
+ Addedabort-controller@3.0.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbuffer@6.0.3(transitive)
+ Addedevent-target-shim@5.0.1(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedprocess@0.11.10(transitive)
+ Addedreadable-stream@4.7.0(transitive)
- Removedinherits@2.0.4(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedutil-deprecate@1.0.2(transitive)
Updatedreadable-stream@^4.7.0