Skip to content

Instantly share code, notes, and snippets.

@rcombs
Created October 23, 2014 06:20
Show Gist options
  • Save rcombs/8b39fabf90dadf894dbd to your computer and use it in GitHub Desktop.
Save rcombs/8b39fabf90dadf894dbd to your computer and use it in GitHub Desktop.
module libjass {
export class ASSStream {
public ASS: ASS;
private buffer: string;
private state: boolean;
constructor() {
this.state = 0;
this.buffer = "";
}
append(raw: string): boolean {
var lines: string[] = raw.split("\n");
switch (this.ready) {
case false:
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
if (line == "[Events]") {
this.ready = 1;
}
this.buffer += line + "\n";
}
if (this.ready)
this.ASS = ASS.fromString(this.buffer);
break;
case true:
for (var i = 0; i < lines.length; i++) {
this.ASS.addEvent(lines[i]);
}
}
return this.ready;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment