diff options
author | Minteck <freeziv.ytb@gmail.com> | 2021-03-07 18:29:17 +0100 |
---|---|---|
committer | Minteck <freeziv.ytb@gmail.com> | 2021-03-07 18:29:17 +0100 |
commit | 0f79e708bf07721b73ea41e5d341be08e8ea4dce (patch) | |
tree | f3c63cd6a9f4ef0b26f95eec6a031600232e80c8 /node_modules/readable-web-to-node-stream | |
download | electrode-0f79e708bf07721b73ea41e5d341be08e8ea4dce.tar.gz electrode-0f79e708bf07721b73ea41e5d341be08e8ea4dce.tar.bz2 electrode-0f79e708bf07721b73ea41e5d341be08e8ea4dce.zip |
Initial commit
Diffstat (limited to 'node_modules/readable-web-to-node-stream')
5 files changed, 438 insertions, 0 deletions
diff --git a/node_modules/readable-web-to-node-stream/README.md b/node_modules/readable-web-to-node-stream/README.md new file mode 100644 index 0000000..69a30dd --- /dev/null +++ b/node_modules/readable-web-to-node-stream/README.md @@ -0,0 +1,70 @@ +![Karma CI](https://github.com/Borewit/readable-web-to-node-stream/workflows/Karma%20CI/badge.svg)[![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) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b48f9601e0984734b1962913f70432a6)](https://www.codacy.com/app/Borewit/readable-web-to-node-stream?utm_source=github.com&utm_medium=referral&utm_content=Borewit/readable-web-to-node-stream&utm_campaign=Badge_Grade) +[![Coverage Status](https://coveralls.io/repos/github/Borewit/readable-web-to-node-stream/badge.svg?branch=master)](https://coveralls.io/github/Borewit/readable-web-to-node-stream?branch=master) +[![Minified size](https://badgen.net/bundlephobia/min/readable-web-to-node-stream)](https://bundlephobia.com/result?p=readable-web-to-node-stream) + +# readable-web-stream-to-node + +Converts a [Web-API readable stream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader) into a [Node.js readable stream](https://nodejs.org/api/stream.html#stream_readable_streams). + +## Installation +Install via [npm](http://npmjs.org/): + +```bash +npm install readable-web-to-node-stream +``` +or or [yarn](https://yarnpkg.com/): +```bash +yarn add readable-web-to-node-stream +``` + +## Compatibility + +Source is written in TypeScript and compiled to ECMAScript 2017 (ES8). + +Unit tests are performed on the following browsers: + +* Google Chrome 74.0 +* Firefox 68.0 +* Safari 12.0 +* Opera 60.0 + +## Example + +Import readable-web-stream-to-node in JavaScript: +```js +const {ReadableWebToNodeStream} = require('readable-web-to-node-stream'); + +async function download(url) { + const response = await fetch(url); + const readableWebStream = response.body; + const nodeStream = new ReadableWebToNodeStream(readableWebStream); +} +``` + +## API + +**constructor(stream: ReadableStream): Promise<void>** + +`stream: ReadableStream`: the [Web-API readable stream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader). + +**close(): Promise<void>** +Will cancel close the Readable-node stream, and will release Web-API-readable-stream. + +**waitForReadToComplete(): Promise<void>** +If there is no unresolved read call to Web-API ReadableStream immediately returns, otherwise it will wait until the read is resolved. + +## Licence + +(The MIT License) + +Copyright (c) 2019 Borewit + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/readable-web-to-node-stream/lib/index.d.ts b/node_modules/readable-web-to-node-stream/lib/index.d.ts new file mode 100644 index 0000000..7d7145b --- /dev/null +++ b/node_modules/readable-web-to-node-stream/lib/index.d.ts @@ -0,0 +1,39 @@ +import { Readable } from 'readable-stream'; +/** + * Converts a Web-API stream into Node stream.Readable class + * Node stream readable: https://nodejs.org/api/stream.html#stream_readable_streams + * Web API readable-stream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream + * Node readable stream: https://nodejs.org/api/stream.html#stream_readable_streams + */ +export declare class ReadableWebToNodeStream extends Readable { + bytesRead: number; + released: boolean; + /** + * Default web API stream reader + * https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader + */ + private reader; + private pendingRead; + /** + * + * @param stream ReadableStream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream + */ + constructor(stream: ReadableStream); + /** + * Implementation of readable._read(size). + * When readable._read() is called, if data is available from the resource, + * the implementation should begin pushing that data into the read queue + * https://nodejs.org/api/stream.html#stream_readable_read_size_1 + */ + _read(): Promise<void>; + /** + * If there is no unresolved read call to Web-API ReadableStream immediately returns; + * otherwise will wait until the read is resolved. + */ + waitForReadToComplete(): Promise<void>; + /** + * Close wrapper + */ + close(): Promise<void>; + private syncAndRelease; +} diff --git a/node_modules/readable-web-to-node-stream/lib/index.js b/node_modules/readable-web-to-node-stream/lib/index.js new file mode 100644 index 0000000..1efaea1 --- /dev/null +++ b/node_modules/readable-web-to-node-stream/lib/index.js @@ -0,0 +1,69 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.ReadableWebToNodeStream = void 0; +const readable_stream_1 = require("readable-stream"); +/** + * Converts a Web-API stream into Node stream.Readable class + * Node stream readable: https://nodejs.org/api/stream.html#stream_readable_streams + * Web API readable-stream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream + * Node readable stream: https://nodejs.org/api/stream.html#stream_readable_streams + */ +class ReadableWebToNodeStream extends readable_stream_1.Readable { + /** + * + * @param stream ReadableStream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream + */ + constructor(stream) { + super(); + this.bytesRead = 0; + this.released = false; + this.reader = stream.getReader(); + } + /** + * Implementation of readable._read(size). + * When readable._read() is called, if data is available from the resource, + * the implementation should begin pushing that data into the read queue + * https://nodejs.org/api/stream.html#stream_readable_read_size_1 + */ + async _read() { + // Should start pushing data into the queue + // Read data from the underlying Web-API-readable-stream + if (this.released) { + this.push(null); // Signal EOF + return; + } + 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 + } + } + /** + * If there is no unresolved read call to Web-API ReadableStream immediately returns; + * otherwise will wait until the read is resolved. + */ + async waitForReadToComplete() { + if (this.pendingRead) { + await this.pendingRead; + } + } + /** + * Close wrapper + */ + async close() { + await this.syncAndRelease(); + } + async syncAndRelease() { + this.released = true; + await this.waitForReadToComplete(); + await this.reader.releaseLock(); + } +} +exports.ReadableWebToNodeStream = ReadableWebToNodeStream; +//# sourceMappingURL=index.js.map
\ No newline at end of file diff --git a/node_modules/readable-web-to-node-stream/lib/index.spec.js b/node_modules/readable-web-to-node-stream/lib/index.spec.js new file mode 100644 index 0000000..98ddd4e --- /dev/null +++ b/node_modules/readable-web-to-node-stream/lib/index.spec.js @@ -0,0 +1,147 @@ +"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"); +const index_1 = require("./index"); +async function httpGetByUrl(url) { + const response = await fetch(url); + const headers = []; + response.headers.forEach(header => { + headers.push(header); + }); + assert.ok(response.ok, `HTTP error status=${response.status}: ${response.statusText}`); + assert.ok(response.body, 'HTTP-stream'); + return response; +} +async function parseReadableStream(stream, fileInfo, options) { + const ns = new index_1.ReadableWebToNodeStream(stream); + const res = await mmb.parseNodeStream(ns, fileInfo, options); + await ns.close(); + return res; +} +exports.parseReadableStream = parseReadableStream; +const tiuqottigeloot_vol24_Tracks = [ + { + url: '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/01%20-%20Diablo%20Swing%20Orchestra%20-%20Heroines.mp3', + duration: 322.612245, + metaData: { + title: 'Heroines', + artist: 'Diablo Swing Orchestra' + } + }, + { + url: '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/02%20-%20Eclectek%20-%20We%20Are%20Going%20To%20Eclecfunk%20Your%20Ass.mp3', + duration: 190.093061, + metaData: { + title: 'We Are Going to Eclecfunk Your Ass', + artist: 'Eclectek' + } + } /* , + { + url: + '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/03%20-%20Auto-Pilot%20-%20Seventeen.mp3', + duration: 214.622041, + metaData: { + title: 'Seventeen', + artist: 'Auto-Pilot' + } + }, + { + url: + '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/04%20-%20Muha%20-%20Microphone.mp3', + duration: 181.838367, + metaData: { + title: 'Microphone', + artist: 'Muha' + } + }, + { + url: + '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/05%20-%20Just%20Plain%20Ant%20-%20Stumble.mp3', + duration: 86.047347, + metaData: { + title: 'Stumble', + artist: 'Just Plain Ant' + } + }, + { + url: + '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/06%20-%20Sleaze%20-%20God%20Damn.mp3', + duration: 226.795102, + metaData: { + title: 'God Damn', + artist: 'Sleaze' + } + }, + { + url: + '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/07%20-%20Juanitos%20-%20Hola%20Hola%20Bossa%20Nova.mp3', + duration: 207.072653, + metaData: { + title: 'Hola Hola Bossa Nova', + artist: 'Juanitos' + } + }, + { + url: + '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/08%20-%20Entertainment%20For%20The%20Braindead%20-%20Resolutions%20(Chris%20Summer%20Remix).mp3', + duration: 314.331429, + metaData: { + title: 'Resolutions (Chris Summer remix)', + artist: 'Entertainment for the Braindead' + } + }, + { + url: + '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/09%20-%20Nobara%20Hayakawa%20-%20Trail.mp3', + duration: 204.042449, + metaData: { + title: 'Trail', + artist: 'Nobara Hayakawa' + } + }, + { + url: + '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/10%20-%20Paper%20Navy%20-%20Tongue%20Tied.mp3', + duration: 201.116735, + metaData: { + title: 'Tongue Tied', + artist: 'Paper Navy' + } + }, + { + url: + '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/11%20-%2060%20Tigres%20-%20Garage.mp3', + duration: 245.394286, + metaData: { + title: 'Garage', + artist: '60 Tigres' + } + }, + { + url: + '/Various%20Artists%20-%202009%20-%20netBloc%20Vol%2024_%20tiuqottigeloot%20%5BMP3-V2%5D/12%20-%20CM%20aka%20Creative%20-%20The%20Cycle%20(Featuring%20Mista%20Mista).mp3', + duration: 221.44, + metaData: { + title: 'The Cycle (feat. Mista Mista)', + artist: 'CM aka Creative' + } + } */ +]; +describe('Parse WebAmp tracks', () => { + tiuqottigeloot_vol24_Tracks.forEach(track => { + it(`track ${track.metaData.artist} - ${track.metaData.title}`, async () => { + const url = 'https://raw.githubusercontent.com/Borewit/test-audio/958e057' + track.url; + const response = await httpGetByUrl(url); + const metadata = await parseReadableStream(response.body, { + size: parseInt(response.headers.get('Content-Length'), 10), + mimeType: response.headers.get('Content-Type') + }); + expect(metadata.common.artist).toEqual(track.metaData.artist); + expect(metadata.common.title).toEqual(track.metaData.title); + }, 20000); + }); +}); +//# sourceMappingURL=index.spec.js.map
\ No newline at end of file diff --git a/node_modules/readable-web-to-node-stream/package.json b/node_modules/readable-web-to-node-stream/package.json new file mode 100644 index 0000000..1ea7926 --- /dev/null +++ b/node_modules/readable-web-to-node-stream/package.json @@ -0,0 +1,113 @@ +{ + "_from": "readable-web-to-node-stream@^3.0.0", + "_id": "readable-web-to-node-stream@3.0.1", + "_inBundle": false, + "_integrity": "sha512-4zDC6CvjUyusN7V0QLsXVB7pJCD9+vtrM9bYDRv6uBQ+SKfx36rp5AFNPRgh9auKRul/a1iFZJYXcCbwRL+SaA==", + "_location": "/readable-web-to-node-stream", + "_phantomChildren": {}, + "_requested": { + "type": "range", + "registry": true, + "raw": "readable-web-to-node-stream@^3.0.0", + "name": "readable-web-to-node-stream", + "escapedName": "readable-web-to-node-stream", + "rawSpec": "^3.0.0", + "saveSpec": null, + "fetchSpec": "^3.0.0" + }, + "_requiredBy": [ + "/file-type" + ], + "_resolved": "https://registry.npmjs.org/readable-web-to-node-stream/-/readable-web-to-node-stream-3.0.1.tgz", + "_shasum": "3f619b1bc5dd73a4cfe5c5f9b4f6faba55dff845", + "_spec": "readable-web-to-node-stream@^3.0.0", + "_where": "/data/dev/Projets/FNS Electrode/Projets/FNS Electrode/node_modules/file-type", + "author": { + "name": "Borewit", + "url": "https://github.com/Borewit" + }, + "bugs": { + "url": "https://github.com/Borewit/readable-web-to-node-stream/issues" + }, + "bundleDependencies": false, + "dependencies": { + "@types/readable-stream": "^2.3.9", + "readable-stream": "^3.6.0" + }, + "deprecated": false, + "description": "Converts a Web-API readable-stream into a Node readable-stream.", + "devDependencies": { + "@types/jasmine": "^3.6.2", + "@types/node": "^14.14.17", + "coveralls": "^3.1.0", + "del-cli": "^3.0.1", + "eslint": "^7.16.0", + "istanbul-instrumenter-loader": "^3.0.1", + "jasmine-core": "^3.6.0", + "karma": "^5.2.3", + "karma-browserstack-launcher": "^1.6.0", + "karma-chrome-launcher": "^3.1.0", + "karma-coverage-istanbul-reporter": "^3.0.3", + "karma-firefox-launcher": "^2.1.0", + "karma-jasmine": "^4.0.1", + "karma-jasmine-html-reporter": "^1.5.4", + "karma-spec-reporter": "^0.0.32", + "karma-webpack": "^4.0.2", + "music-metadata-browser": "^2.1.6", + "ts-loader": "^8.0.13", + "tslint": "^6.1.3", + "typescript": "^4.1.2", + "webpack": "^4.44.2" + }, + "engines": { + "node": ">=8" + }, + "files": [ + "lib/**/*.js", + "lib/**/*.d.ts" + ], + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Borewit" + }, + "homepage": "https://github.com/Borewit/readable-web-to-node-stream#readme", + "keywords": [ + "stream.readable", + "web", + "node", + "browser", + "stream", + "covert", + "coverter", + "readable", + "readablestream" + ], + "license": "MIT", + "main": "lib/index.js", + "name": "readable-web-to-node-stream", + "repository": { + "type": "git", + "url": "git+https://github.com/Borewit/readable-web-to-node-stream.git" + }, + "scripts": { + "browserstack": "karma start --browsers bs_win_chrome,bs_win_firefox,bs_osx_safari --single-run --reporters coverage-istanbul,spec", + "build": "npm run compile-lib && npm run compile-test", + "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", + "eslint": "eslint karma.conf.js", + "karma": "karma start", + "karma-firefox": "karma start --browsers Firefox", + "karma-once": "karma start --browsers Chrome --single-run", + "lint": "npm run tslint && npm run eslint", + "post-codacy": " codacy-coverage < coverage/lcov.info", + "post-coveralls": "coveralls < coverage/lcov.info", + "prepublishOnly": "yarn run build", + "test": "karma start --single-run", + "travis-karma": "karma start --browsers Firefox --single-run --reporters coverage-istanbul,spec", + "travis-karma-browserstack": "karma start --browsers bs_win_chrome,bs_win_firefox,bs_osx_safari,bs_win_opera --single-run --reporters coverage-istanbul,spec,BrowserStack", + "tslint": "tslint 'lib/**/*.ts' --exclude 'lib/**/*.d.ts'" + }, + "types": "lib/index.d.ts", + "version": "3.0.1" +} |