Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const requestQueue = new Queue((segment: Item, callback: () => void): void => {
let req = miniget(urlResolve(playlistURL, segment.url), requestOptions);
req.on('error', callback);
streamQueue.push(req, (err, size) => {
downloaded += +size;
stream.emit('progress', {
num: ++segmentNumber,
size: size,
duration: segment.duration,
url: segment.url,
}, requestQueue.total, downloaded);
callback();
});
}, { concurrency: chunkReadahead });
const refreshPlaylist = (): void => {
lastRefresh = Date.now();
currPlaylist = miniget(playlistURL, requestOptions);
currPlaylist.on('error', onError);
const parser = currPlaylist.pipe(new Parser(options.id));
parser.on('starttime', (a: number) => {
if (starttime) { return; }
starttime = a;
if (typeof options.begin === 'string' && begin >= 0) {
begin += starttime;
}
});
parser.on('endlist', () => { isStatic = true; });
parser.on('endearly', currPlaylist.unpipe.bind(currPlaylist, parser));
let addedItems: any[] = [];
let liveAddedItems: any[] = [];
const addItem = (item: TimedItem, isLive: boolean): void => {
if (item.seq <= lastSeq) { return; }