Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public parse(tokenizer: strtok3.ITokenizer, options: IOptions): Promise {
this.tokenizer = tokenizer;
this.vorbisParser = new VorbisParser();
this.vorbisStream = new VorbisStream();
return strtok3.fromStream(this.vorbisStream).then((vorbisTokenizer) => {
// ToDo: should be provided with level-2 tokenizer
const vorbis = this.vorbisParser.parse(vorbisTokenizer, options).then((metadata) => {
if (metadata.format.sampleRate) {
// Calculate duration
metadata.format.duration = this.header.absoluteGranulePosition / metadata.format.sampleRate;
}
return metadata;
});
const ogg = this.parsePage().catch((err) => {
if (err === StreamReader.EndOfStream) {
// console.log("EndOfStream: ogg");
this.vorbisStream.append(null);
} else throw err;
export async function parseStream(stream: Stream.Readable, mimeType?: string, options: IOptions = {}): Promise {
const tokenizer = await strtok3.fromStream(stream);
return Core.parseFromTokenizer(tokenizer, mimeType, options);
}