Socket
Socket
Sign inDemoInstall

webvtt-parser

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.2 to 2.2.0

4

package.json
{
"name": "webvtt-parser",
"version": "2.1.2",
"version": "2.2.0",
"description": "WebVTT parser and validator",

@@ -19,3 +19,3 @@ "main": "parser.js",

"contributors": [],
"license": "CC0",
"license": "CC0-1.0",
"bugs": {

@@ -22,0 +22,0 @@ "url": "https://github.com/w3c/webvtt.js/issues"

@@ -38,2 +38,3 @@ // Any copyright is dedicated to the Public Domain.

alreadyCollected = false,
styles = [],
cues = [],

@@ -125,2 +126,25 @@ errors = []

/* STYLES */
if(/^STYLE($|[ \t])/.test(cue.id)) {
var style = []
var invalid = false
linePos++
while(lines[linePos] != "" && lines[linePos] != undefined) {
if(lines[linePos].indexOf("-->") != -1) {
err("Cannot have timestamp in a style block.")
invalid = true
}
style.push(lines[linePos])
linePos++
}
if(cues.length) {
err("Style blocks cannot appear after the first cue.")
continue
}
if (!invalid) {
styles.push(style.join('\n'))
}
continue
}
linePos++

@@ -179,3 +203,3 @@

/* CUE TEXT PROCESSING */
var cuetextparser = new WebVTTCueTextParser(cue.text, err, mode, this.entities)
var cuetextparser = new WebVTTCueTextParser(cue.text, err, mode, entities)
cue.tree = cuetextparser.parse(cue.startTime, cue.endTime)

@@ -196,3 +220,3 @@ cues.push(cue)

/* END */
return {cues:cues, errors:errors, time:Date.now()-startTime}
return {cues:cues, errors:errors, time:Date.now()-startTime, styles: styles}
}

@@ -778,3 +802,3 @@ }

function serializeTimestamp(seconds) {
const ms = ("" + (seconds - Math.floor(seconds)).toFixed(3)*1000).padEnd(3, "0");
const ms = ("00" + (seconds - Math.floor(seconds)).toFixed(3)*1000).slice(-3);
let h = 0, m = 0, s = 0;

@@ -837,3 +861,3 @@ if (seconds >= 3600) {

function serializeCue(cue) {
return (cue.id ? cue.id + "\n" : "")
return (cue.id !== undefined ? cue.id + "\n" : "")
+ serializeTimestamp(cue.startTime)

@@ -845,4 +869,12 @@ + " --> "

}
this.serialize = function(cues) {
function serializeStyle(style) {
return "STYLE\n" + style + "\n\n"
}
this.serialize = function(cues, styles) {
var result = "WEBVTT\n\n"
if (styles) {
for(var i=0;i<styles.length;i++) {
result += serializeStyle(styles[i])
}
}
for(var i=0;i<cues.length;i++) {

@@ -849,0 +881,0 @@ result += serializeCue(cues[i])

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc