Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as mm from 'music-metadata/lib/core';
import { ReadableWebToNodeStream } from 'readable-web-to-node-stream';
import * as toBuffer from 'typedarray-to-buffer';
const debug = initDebug('music-metadata-browser:main');
export { IPicture, IAudioMetadata, IOptions, ITag, INativeTagDict, IChapter } from 'music-metadata/lib/type';
/**
* Parse audio Stream
* @param stream
* @param {string} contentType MIME-Type
* @param {IOptions} options Parsing options
* @returns {Promise}
*/
export const parseNodeStream = mm.parseStream;
/**
* Parse Web API ReadableStream: https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream
* @param {ReadableStream} stream ReadableStream
* @param {string} contentType MIME-Type
* @param {IOptions} options Parsing options
* @returns {Promise}
*/
export async function parseReadableStream(stream: ReadableStream, contentType, options?: IOptions): Promise {
const ns = new ReadableWebToNodeStream(stream);
const res = await parseNodeStream(ns, contentType, options);
debug(`Completed parsing from stream bytesRead=${ns.bytesRead} / fileSize=${options && options.fileSize ? options.fileSize : '?'}`);
await ns.close();
return res;
}