First release
This commit is contained in:
commit
fa6c85266e
2339 changed files with 761050 additions and 0 deletions
35
node_modules/m3u8-parser/src/line-stream.js
generated
vendored
Normal file
35
node_modules/m3u8-parser/src/line-stream.js
generated
vendored
Normal file
|
@ -0,0 +1,35 @@
|
|||
/**
|
||||
* @file m3u8/line-stream.js
|
||||
*/
|
||||
import Stream from '@videojs/vhs-utils/es/stream.js';
|
||||
|
||||
/**
|
||||
* A stream that buffers string input and generates a `data` event for each
|
||||
* line.
|
||||
*
|
||||
* @class LineStream
|
||||
* @extends Stream
|
||||
*/
|
||||
export default class LineStream extends Stream {
|
||||
constructor() {
|
||||
super();
|
||||
this.buffer = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new data to be parsed.
|
||||
*
|
||||
* @param {string} data the text to process
|
||||
*/
|
||||
push(data) {
|
||||
let nextNewline;
|
||||
|
||||
this.buffer += data;
|
||||
nextNewline = this.buffer.indexOf('\n');
|
||||
|
||||
for (; nextNewline > -1; nextNewline = this.buffer.indexOf('\n')) {
|
||||
this.trigger('data', this.buffer.substring(0, nextNewline));
|
||||
this.buffer = this.buffer.substring(nextNewline + 1);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue