Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Fall back on Blob
return this.parseBlob(await response.blob(), options);
}
} else {
throw new Error(`HTTP error status=${response.status}: ${response.statusText}`);
}
}
/**
* Parse audio from ITokenizer source
* @param {strtok3.ITokenizer} Audio source implementing the tokenizer interface
* @param {string} mimeType Content specification MIME-type, e.g.: 'audio/mpeg'
* @param {IOptions} options Parsing options
* @returns {Promise}
*/
export const parseFromTokenizer = mm.parseFromTokenizer;
/**
* Convert Web API File to Node Buffer
* @param {Blob} blob Web API Blob
* @returns {Promise}
*/
function convertBlobToBuffer(blob: Blob): Promise {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onloadend = event => {
let data = (event.target as any).result;
if (data instanceof ArrayBuffer) {
data = toBuffer(new Uint8Array((event.target as any).result));
}
resolve(data);