Namespace libjass

Properties

debugMode
Getter
Debug mode. When true, libjass logs some debug messages.
var result = libjass.debugMode;
boolean
Setter
Debug mode. When true, libjass logs some debug messages.
libjass.debugMode = value;
value
boolean
Map
Getter

Set to the global implementation of Map if the environment has one, else set to ./utility/map.SimpleMap

Set it to null to force ./utility/map.SimpleMap to be used even if a global Map is present.

var result = libjass.Map;
function(new:Map, !Array.<!Array.<*>>=)
Setter

Set to the global implementation of Map if the environment has one, else set to ./utility/map.SimpleMap

Set it to null to force ./utility/map.SimpleMap to be used even if a global Map is present.

libjass.Map = value;
value
function(new:Map, !Array.<!Array.<*>>=)
Promise
Getter

Set to the global implementation of Promise if the environment has one, else set to ./utility/promise.SimplePromise

Set it to null to force ./utility/promise.SimplePromise to be used even if a global Promise is present.

var result = libjass.Promise;
function(new:Promise)
Setter

Set to the global implementation of Promise if the environment has one, else set to ./utility/promise.SimplePromise

Set it to null to force ./utility/promise.SimplePromise to be used even if a global Promise is present.

libjass.Promise = value;
value
function(new:Promise)
Set
Getter

Set to the global implementation of Set if the environment has one, else set to ./utility/set.SimpleSet

Set it to null to force ./utility/set.SimpleSet to be used even if a global Set is present.

var result = libjass.Set;
function(new:Set, !Array.<T>=)
Setter

Set to the global implementation of Set if the environment has one, else set to ./utility/set.SimpleSet

Set it to null to force ./utility/set.SimpleSet to be used even if a global Set is present.

libjass.Set = value;
value
function(new:Set, !Array.<T>=)
verboseMode
Getter
Verbose debug mode. When true, libjass logs some more debug messages. This setting is independent of libjass.debugMode
var result = libjass.verboseMode;
boolean
Setter
Verbose debug mode. When true, libjass logs some more debug messages. This setting is independent of libjass.debugMode
libjass.verboseMode = value;
value
boolean

Classes

class ASS
This class represents an ASS script. It contains the libjass.ScriptProperties, an array of libjass.Styles, and an array of libjass.Dialogues.
var ass = new libjass.ASS();
dialogues
Getter
The dialogues in this script.
var result = ass.dialogues;
!Array.<!libjass.Dialogue>
dialoguesFormatSpecifier
Getter
The format specifier for the styles section.
var result = ass.dialoguesFormatSpecifier;
!Array.<string>
Setter
The format specifier for the events section.
ass.dialoguesFormatSpecifier = value;
value
!Array.<string>
properties
Getter
The properties of this script.
var result = ass.properties;
!libjass.ScriptProperties
styles
Getter
The styles in this script.
var result = ass.styles;
!Map.<string, !libjass.Style>
stylesFormatSpecifier
Getter
The format specifier for the styles section.
var result = ass.stylesFormatSpecifier;
!Array.<string>
Setter
The format specifier for the events section.
ass.stylesFormatSpecifier = value;
value
!Array.<string>
addEvent
Add an event to this ASS script.
ass.addEvent(line);
line
string
The line from the script that contains the new event.
addStyle
Add a style to this ASS script.
ass.addStyle(line);
line
string
The line from the script that contains the new style.
fromReadableStream
Creates an ASS object from the given ReadableStream.
var result = libjass.ASS.fromReadableStream(stream, encoding, type);
stream
!ReadableStream
encoding
string="utf-8"
type
number=0
The type of the script. One of the libjass.Format constants.
Returns
!Promise.<!libjass.ASS>
A promise that will be resolved with the ASS object when it has been fully parsed
fromStream
Creates an ASS object from the given libjass.parser.Stream.
var result = libjass.ASS.fromStream(stream, type);
stream
!libjass.parser.Stream
The stream to parse the script from
type
number=0
The type of the script. One of the libjass.Format constants.
Returns
!Promise.<!libjass.ASS>
A promise that will be resolved with the ASS object when it has been fully parsed
fromString
Creates an ASS object from the raw text of an ASS script.
var result = libjass.ASS.fromString(raw, type);
raw
string
The raw text of the script.
type
number=0
The type of the script. One of the libjass.Format constants.
Returns
!Promise.<!libjass.ASS>
fromUrl
Creates an ASS object from the given URL.
var result = libjass.ASS.fromUrl(url, type);
url
string
The URL of the script.
type
number=0
The type of the script. One of the libjass.Format constants.
Returns
!Promise.<!libjass.ASS>
A promise that will be resolved with the ASS object when it has been fully parsed
class DeferredPromise.<T>
A deferred promise.
var deferredPromise = new libjass.DeferredPromise();
promise
Getter
var result = deferredPromise.promise;
!Promise.<T>
reject
deferredPromise.reject(reason);
reason
*
resolve
deferredPromise.resolve(value);
value
T
class Dialogue
This class represents a dialogue in a libjass.ASS script.
var dialogue = new libjass.Dialogue(template, ass);
template
!Map.<string, string>
The template object that contains the dialogue's properties. It is a map of the string values read from the ASS file.
"Style"
string
The name of the default style of this dialogue
"Start"
string
The start time
"End"
string
The end time
"Layer"
string
The layer number
"Text"
string
The text of this dialogue
ass
ASS
The ASS object to which this dialogue belongs
alignment
Getter
The alignment number of this dialogue.
var result = dialogue.alignment;
number
end
Getter
The end time of this dialogue.
var result = dialogue.end;
number
id
Getter
The unique ID of this dialogue. Auto-generated.
var result = dialogue.id;
number
layer
Getter
The layer number of this dialogue.
var result = dialogue.layer;
number
parts
Getter
The libjass.parts of this dialogue.
var result = dialogue.parts;
!Array.<!libjass.parts.Part>
start
Getter
The start time of this dialogue.
var result = dialogue.start;
number
style
Getter
The default style of this dialogue.
var result = dialogue.style;
!libjass.Style
toString
var result = dialogue.toString();
Returns
string
A simple representation of this dialogue's properties and parts.
_parsePartsString
Parses this dialogue's parts from the raw parts string.
dialogue._parsePartsString();
_toTime
Converts this string into the number of seconds it represents. This string must be in the form of hh:mm:ss.MMM
var result = libjass.Dialogue._toTime(str);
str
string
Returns
number
class ScriptProperties
This class represents the properties of a libjass.ASS script.
var scriptProperties = new libjass.ScriptProperties();
resolutionX
Getter
The horizontal script resolution.
var result = scriptProperties.resolutionX;
number
Setter
The horizontal script resolution.
scriptProperties.resolutionX = value;
value
number
resolutionY
Getter
The vertical script resolution.
var result = scriptProperties.resolutionY;
number
Setter
The vertical script resolution.
scriptProperties.resolutionY = value;
value
number
scaleBorderAndShadow
Getter
Whether to scale outline widths and shadow depths from script resolution to video resolution or not. If true, widths and depths are scaled.
var result = scriptProperties.scaleBorderAndShadow;
boolean
Setter
Whether to scale outline widths and shadow depths from script resolution to video resolution or not. If true, widths and depths are scaled.
scriptProperties.scaleBorderAndShadow = value;
value
boolean
wrappingStyle
Getter
The wrap style. One of the libjass.WrappingStyle constants.
var result = scriptProperties.wrappingStyle;
number
Setter
The wrap style. One of the libjass.WrappingStyle constants.
scriptProperties.wrappingStyle = value;
value
number
class Style
This class represents a single global style declaration in a libjass.ASS script. The styles can be obtained via the libjass.ASS.styles property.
var style = new libjass.Style(template);
template
!Map.<string, string>
The template object that contains the style's properties. It is a map of the string values read from the ASS file.
"Name"
string
The name of the style
"Italic"
string
-1 if the style is italicized
"Bold"
string
-1 if the style is bold
"Underline"
string
-1 if the style is underlined
"StrikeOut"
string
-1 if the style is struck-through
"Fontname"
string
The name of the font
"Fontsize"
string
The size of the font
"ScaleX"
string
The horizontal scaling of the font
"ScaleY"
string
The vertical scaling of the font
"Spacing"
string
The letter spacing of the font
"PrimaryColour"
string
The primary color
"OutlineColour"
string
The outline color
"BackColour"
string
The shadow color
"Outline"
string
The outline thickness
"Shadow"
string
The shadow depth
"Alignment"
string
The alignment number
"MarginL"
string
The left margin
"MarginR"
string
The right margin
"MarginV"
string
The vertical margin
alignment
Getter
The alignment of dialogues of this style.
var result = style.alignment;
number
bold
Getter
Whether this style is bold or not.
var result = style.bold;
boolean
borderStyle
Getter
The border style of this style.
var result = style.borderStyle;
number
fontName
Getter
The name of this style's font.
var result = style.fontName;
string
fontScaleX
Getter
The horizontal scaling of this style's font.
var result = style.fontScaleX;
number
fontScaleY
Getter
The vertical scaling of this style's font.
var result = style.fontScaleY;
number
fontSize
Getter
The size of this style's font.
var result = style.fontSize;
number
italic
Getter
Whether this style is italicized or not.
var result = style.italic;
string
letterSpacing
Getter
The letter spacing scaling of this style's font.
var result = style.letterSpacing;
number
marginLeft
Getter
The left margin of dialogues of this style.
var result = style.marginLeft;
number
marginRight
Getter
The right margin of dialogues of this style.
var result = style.marginRight;
number
marginVertical
Getter
The vertical margin of dialogues of this style.
var result = style.marginVertical;
number
name
Getter
The name of this style.
var result = style.name;
string
outlineColor
Getter
The color of this style's outline.
var result = style.outlineColor;
!libjass.parts.Color
outlineThickness
Getter
The thickness of this style's outline.
var result = style.outlineThickness;
number
primaryColor
Getter
The color of this style's font.
var result = style.primaryColor;
!libjass.parts.Color
rotationZ
Getter
The default Z-rotation of this style.
var result = style.rotationZ;
number
secondaryColor
Getter
The alternate color of this style's font, used in karaoke.
var result = style.secondaryColor;
!libjass.parts.Color
shadowColor
Getter
The color of this style's shadow.
var result = style.shadowColor;
!libjass.parts.Color
shadowDepth
Getter
The depth of this style's shadow.
var result = style.shadowDepth;
number
strikeThrough
Getter
Whether this style is struck-through or not.
var result = style.strikeThrough;
boolean
underline
Getter
Whether this style is underlined or not.
var result = style.underline;
boolean

Enums

enum BorderStyle
The border style defined in the libjass.Style properties.
Outline = 1
OpaqueBox = 3
enum Format
The format of the string passed to libjass.ASS.fromString
ASS = 0
SRT = 1
enum WrappingStyle
The wrapping style defined in the libjass.ScriptProperties
SmartWrappingWithWiderTopLine = 0
SmartWrappingWithWiderBottomLine = 3
EndOfLineWrapping = 1
NoLineWrapping = 2

Namespace libjass.parser

Free functions

parse
Parses a given string with the specified rule.
var result = libjass.parser.parse(input, rule);
input
string
The string to be parsed.
rule
string
The rule to parse the string with
Returns
*
The value returned depends on the rule used.

Interfaces

interface Stream
An interface for a stream.
nextLine
var result = stream.nextLine();
Returns
!Promise.<?string>
A promise that will be resolved with the next line, or null if the stream is exhausted.

Classes

class BrowserReadableStream implements Stream
A libjass.parser.Stream that reads from a ReadableStream object.
var browserReadableStream = new libjass.parser.BrowserReadableStream(stream, encoding);
stream
!ReadableStream
encoding
string
nextLine
var result = browserReadableStream.nextLine();
Returns
!Promise.<?string>
A promise that will be resolved with the next line, or null if the stream is exhausted.
_tryResolveNextLine
browserReadableStream._tryResolveNextLine();
class SrtStreamParser
A parser that parses an libjass.ASS object from a libjass.parser.Stream of an SRT script.
var srtStreamParser = new libjass.parser.SrtStreamParser(stream);
stream
!libjass.parser.Stream
The libjass.parser.Stream to parse
ass
Getter
var result = srtStreamParser.ass;
!Promise.<!libjass.ASS>
_onNextLine
srtStreamParser._onNextLine(line);
line
string
class StreamParser
A parser that parses an libjass.ASS object from a libjass.parser.Stream.
var streamParser = new libjass.parser.StreamParser(stream);
stream
!libjass.parser.Stream
The libjass.parser.Stream to parse
ass
Getter
var result = streamParser.ass;
!Promise.<!libjass.ASS>
minimalASS
Getter
parsed at the point this promise becomes resolved.
var result = streamParser.minimalASS;
!Promise.<!libjass.ASS>
_onNextLine
streamParser._onNextLine(line);
line
string
class StringStream implements Stream
A libjass.parser.Stream that reads from a string in memory.
var stringStream = new libjass.parser.StringStream(str);
str
string
The string
nextLine
var result = stringStream.nextLine();
Returns
!Promise.<?string>
A promise that will be resolved with the next line, or null if the string has been completely read.
class XhrStream implements Stream
A libjass.parser.Stream that reads from an XMLHttpRequest object.
var xhrStream = new libjass.parser.XhrStream(xhr);
xhr
!XMLHttpRequest
The XMLHttpRequest object. Make sure to not call .open() on this object before passing it in here, since event handlers cannot be registered after open() has been called.
nextLine
var result = xhrStream.nextLine();
Returns
!Promise.<?string>
A promise that will be resolved with the next line, or null if the stream is exhausted.
_onXhrLoadEnd
xhrStream._onXhrLoadEnd(event);
event
!ProgressEvent
_onXhrProgress
xhrStream._onXhrProgress(event);
event
!ProgressEvent
_tryResolveNextLine
xhrStream._tryResolveNextLine();

Namespace libjass.parts

Interfaces

interface Part
The base interface of the ASS tag classes.

Classes

class Alignment
An alignment tag {\an} or {\a}
var alignment = new libjass.parts.Alignment(value);
value
number
{\an###} -> alignment (number)
value
Getter
The value of this alignment tag.
var result = alignment.value;
?number
class Alpha
An alpha tag {\alpha}
var alpha = new libjass.parts.Alpha(value);
value
?number
{\alpha###} -> alpha (number), {\alpha} -> null
value
Getter
The value of this alpha tag.
var result = alpha.value;
?number
class Blur
A blur tag {\be}
var blur = new libjass.parts.Blur(value);
value
?number
{\be###} -> strength (number), {\be} -> null
value
Getter
The value of this blur tag.
var result = blur.value;
?number
class Bold
A bold tag {\b}
var bold = new libjass.parts.Bold(value);
value
*
{\b1} -> true, {\b0} -> false, {\b###} -> weight of the bold (number), {\b} -> null
value
Getter
The value of this bold tag.
var result = bold.value;
?boolean|?number
class Border
A border tag {\bord}
var border = new libjass.parts.Border(value);
value
?number
{\bord###} -> width (number), {\bord} -> null
value
Getter
The value of this border tag.
var result = border.value;
?number
class BorderX
A horizontal border tag {\xbord}
var borderX = new libjass.parts.BorderX(value);
value
?number
{\xbord###} -> width (number), {\xbord} -> null
value
Getter
The value of this horizontal border tag.
var result = borderX.value;
?number
class BorderY
A vertical border tag {\ybord}
var borderY = new libjass.parts.BorderY(value);
value
?number
{\ybord###} -> height (number), {\ybord} -> null
value
Getter
The value of this vertical border tag.
var result = borderY.value;
?number
class Color

Represents a CSS color with red, green, blue and alpha components.

Instances of this class are immutable.

var color = new libjass.parts.Color(red, green, blue, alpha);
red
number
green
number
blue
number
alpha
number=1
alpha
Getter
The alpha component of this color as a number between 0 and 1, where 0 means transparent and 1 means opaque.
var result = color.alpha;
number
blue
Getter
The blue component of this color as a number between 0 and 255.
var result = color.blue;
number
green
Getter
The green component of this color as a number between 0 and 255.
var result = color.green;
number
red
Getter
The red component of this color as a number between 0 and 255.
var result = color.red;
number
toString
var result = color.toString();
Returns
string
The CSS representation "rgba(...)" of this color.
withAlpha
var result = color.withAlpha(value);
value
?number
The new alpha. If null, the existing alpha is used.
Returns
!libjass.parts.Color
Returns a new Color instance with the same color but the provided alpha.
class ColorKaraoke
A color karaoke tag {\k}
var colorKaraoke = new libjass.parts.ColorKaraoke(duration);
duration
number
{\k###} -> duration (number)
duration
Getter
The duration of this color karaoke tag.
var result = colorKaraoke.duration;
number
class Comment
A comment, i.e., any text enclosed in {} that is not understood as an ASS tag.
var comment = new libjass.parts.Comment(value);
value
string
The text of this comment
value
Getter
The value of this comment.
var result = comment.value;
string
class ComplexFade
A complex fade tag {\fade}
var complexFade = new libjass.parts.ComplexFade(a1, a2, a3, t1, t2, t3, t4);
a1
number
a2
number
a3
number
t1
number
t2
number
t3
number
t4
number
a1
Getter
The alpha value of this complex fade tag at time t2.
var result = complexFade.a1;
number
a2
Getter
The alpha value of this complex fade tag at time t3.
var result = complexFade.a2;
number
a3
Getter
The alpha value of this complex fade tag at time t4.
var result = complexFade.a3;
number
t1
Getter
The starting time of this complex fade tag.
var result = complexFade.t1;
number
t2
Getter
The first intermediate time of this complex fade tag.
var result = complexFade.t2;
number
t3
Getter
The second intermediate time of this complex fade tag.
var result = complexFade.t3;
number
t4
Getter
The ending time of this complex fade tag.
var result = complexFade.t4;
number
class DrawingBaselineOffset
A drawing mode baseline offset tag {\pbo}
var drawingBaselineOffset = new libjass.parts.DrawingBaselineOffset(value);
value
number
value
Getter
The value of this drawing mode baseline offset tag.
var result = drawingBaselineOffset.value;
number
class DrawingInstructions
A pseudo-part representing text interpreted as drawing instructions
var drawingInstructions = new libjass.parts.DrawingInstructions(instructions);
instructions
!Array.<!libjass.parts.drawing.Instruction>
instructions
Getter
The instructions contained in this drawing instructions part.
var result = drawingInstructions.instructions;
!Array.<!libjass.parts.drawing.Instruction>
class DrawingMode
A drawing mode tag {\p}
var drawingMode = new libjass.parts.DrawingMode(scale);
scale
number
scale
Getter
The scale of this drawing mode tag.
var result = drawingMode.scale;
number
class Fade
A simple fade tag {\fad}
var fade = new libjass.parts.Fade(start, end);
start
number
end
number
end
Getter
The end time of this fade tag.
var result = fade.end;
number
start
Getter
The start time of this fade tag.
var result = fade.start;
number
class FontName
A font name tag {\fn}
var fontName = new libjass.parts.FontName(value);
value
?string
{\fn###} -> name (string), {\fn} -> null
value
Getter
The value of this font name tag.
var result = fontName.value;
?string
class FontScaleX
A horizontal font scaling tag {\fscx}
var fontScaleX = new libjass.parts.FontScaleX(value);
value
?number
{\fscx###} -> scale (number), {\fscx} -> null
value
Getter
The value of this horizontal font scaling tag.
var result = fontScaleX.value;
?number
class FontScaleY
A vertical font scaling tag {\fscy}
var fontScaleY = new libjass.parts.FontScaleY(value);
value
?number
{\fscy###} -> scale (number), {\fscy} -> null
value
Getter
The value of this vertical font scaling tag.
var result = fontScaleY.value;
?number
class FontSize
A font size tag {\fs}
var fontSize = new libjass.parts.FontSize(value);
value
?number
{\fs###} -> size (number), {\fs} -> null
value
Getter
The value of this font size tag.
var result = fontSize.value;
?number
class FontSizeMinus
A font size decrease tag {\fs-}
var fontSizeMinus = new libjass.parts.FontSizeMinus(value);
value
?number
{\fs-###} -> difference (number)
value
Getter
The value of this font size decrease tag.
var result = fontSizeMinus.value;
?number
class FontSizePlus
A font size increase tag {\fs+}
var fontSizePlus = new libjass.parts.FontSizePlus(value);
value
?number
{\fs+###} -> difference (number)
value
Getter
The value of this font size increase tag.
var result = fontSizePlus.value;
?number
class GaussianBlur
A Gaussian blur tag {\blur}
var gaussianBlur = new libjass.parts.GaussianBlur(value);
value
?number
{\blur###} -> strength (number), {\blur} -> null
value
Getter
The value of this Gaussian blur tag.
var result = gaussianBlur.value;
?number
class Italic
An italic tag {\i}
var italic = new libjass.parts.Italic(value);
value
?boolean
{\i1} -> true, {\i0} -> false, {\i} -> null
value
Getter
The value of this italic tag.
var result = italic.value;
?boolean
class LetterSpacing
A letter-spacing tag {\fsp}
var letterSpacing = new libjass.parts.LetterSpacing(value);
value
?number
{\fsp###} -> spacing (number), {\fsp} -> null
value
Getter
The value of this letter-spacing tag.
var result = letterSpacing.value;
?number
class Move
A movement tag {\move}
var move = new libjass.parts.Move(x1, y1, x2, y2, t1, t2);
x1
number
y1
number
x2
number
y2
number
t1
number
t2
number
t1
Getter
The start time of this move tag.
var result = move.t1;
number
t2
Getter
The end time value of this move tag.
var result = move.t2;
number
x1
Getter
The starting x value of this move tag.
var result = move.x1;
number
x2
Getter
The ending x value of this move tag.
var result = move.x2;
number
y1
Getter
The starting y value of this move tag.
var result = move.y1;
number
y2
Getter
The ending y value of this move tag.
var result = move.y2;
number
class NewLine
A newline character \N.
var newLine = new libjass.parts.NewLine();
class OutlineAlpha
An outline alpha tag {\3a}
var outlineAlpha = new libjass.parts.OutlineAlpha(value);
value
?number
{\3a###} -> alpha (number), {\3a} -> null
value
Getter
The value of this outline alpha tag.
var result = outlineAlpha.value;
?number
class OutlineColor
An outline color tag {\3c}
var outlineColor = new libjass.parts.OutlineColor(value);
value
libjass.parts.Color
{\3c###} -> color (Color), {\3c} -> null
value
Getter
The value of this outline color tag.
var result = outlineColor.value;
libjass.parts.Color
class OutlineKaraoke
An outline karaoke tag {\ko}
var outlineKaraoke = new libjass.parts.OutlineKaraoke(duration);
duration
number
{\ko###} -> duration (number)
duration
Getter
The duration of this outline karaoke tag.
var result = outlineKaraoke.duration;
number
class Position
A position tag {\pos}
var position = new libjass.parts.Position(x, y);
x
number
y
number
x
Getter
The x value of this position tag.
var result = position.x;
number
y
Getter
The y value of this position tag.
var result = position.y;
number
class PrimaryAlpha
A primary alpha tag {\1a}
var primaryAlpha = new libjass.parts.PrimaryAlpha(value);
value
?number
{\1a###} -> alpha (number), {\1a} -> null
value
Getter
The value of this primary alpha tag.
var result = primaryAlpha.value;
?number
class PrimaryColor
A primary color tag {\c} or {\1c}
var primaryColor = new libjass.parts.PrimaryColor(value);
value
libjass.parts.Color
{\1c###} -> color (Color), {\1c} -> null
value
Getter
The value of this primary color tag.
var result = primaryColor.value;
libjass.parts.Color
class RectangularClip
A rectangular clip tag {\clip} or {\iclip}
var rectangularClip = new libjass.parts.RectangularClip(x1, y1, x2, y2, inside);
x1
number
y1
number
x2
number
y2
number
inside
boolean
inside
Getter
Whether this rectangular clip tag clips the region it encloses or the region it excludes.
var result = rectangularClip.inside;
boolean
x1
Getter
The X coordinate of the starting position of this rectangular clip tag.
var result = rectangularClip.x1;
number
x2
Getter
The X coordinate of the ending position of this rectangular clip tag.
var result = rectangularClip.x2;
number
y1
Getter
The Y coordinate of the starting position of this rectangular clip tag.
var result = rectangularClip.y1;
number
y2
Getter
The Y coordinate of the ending position of this rectangular clip tag.
var result = rectangularClip.y2;
number
class Reset
A style reset tag {\r}
var reset = new libjass.parts.Reset(value);
value
?string
{\r###} -> style name (string), {\r} -> null
value
Getter
The value of this style reset tag.
var result = reset.value;
?string
class RotateX
An X-axis rotation tag {\frx}
var rotateX = new libjass.parts.RotateX(value);
value
?number
{\frx###} -> angle (number), {\frx} -> null
value
Getter
The value of this X-axis rotation tag.
var result = rotateX.value;
?number
class RotateY
A Y-axis rotation tag {\fry}
var rotateY = new libjass.parts.RotateY(value);
value
?number
{\fry###} -> angle (number), {\fry} -> null
value
Getter
The value of this Y-axis rotation tag.
var result = rotateY.value;
?number
class RotateZ
A Z-axis rotation tag {\fr} or {\frz}
var rotateZ = new libjass.parts.RotateZ(value);
value
?number
{\frz###} -> angle (number), {\frz} -> null
value
Getter
The value of this Z-axis rotation tag.
var result = rotateZ.value;
?number
class RotationOrigin
A rotation origin tag {\org}
var rotationOrigin = new libjass.parts.RotationOrigin(x, y);
x
number
y
number
x
Getter
The x value of this rotation origin tag.
var result = rotationOrigin.x;
number
y
Getter
The y value of this rotation origin tag.
var result = rotationOrigin.y;
number
class SecondaryAlpha
A secondary alpha tag {\2a}
var secondaryAlpha = new libjass.parts.SecondaryAlpha(value);
value
?number
{\2a###} -> alpha (number), {\2a} -> null
value
Getter
The value of this secondary alpha tag.
var result = secondaryAlpha.value;
?number
class SecondaryColor
A secondary color tag {\2c}
var secondaryColor = new libjass.parts.SecondaryColor(value);
value
libjass.parts.Color
{\2c###} -> color (Color), {\2c} -> null
value
Getter
The value of this secondary color tag.
var result = secondaryColor.value;
libjass.parts.Color
class Shadow
A shadow tag {\shad}
var shadow = new libjass.parts.Shadow(value);
value
?number
{\shad###} -> depth (number), {\shad} -> null
value
Getter
The value of this shadow tag.
var result = shadow.value;
?number
class ShadowAlpha
A shadow alpha tag {\4a}
var shadowAlpha = new libjass.parts.ShadowAlpha(value);
value
?number
{\4a###} -> alpha (number), {\4a} -> null
value
Getter
The value of this shadow alpha tag.
var result = shadowAlpha.value;
?number
class ShadowColor
A shadow color tag {\4c}
var shadowColor = new libjass.parts.ShadowColor(value);
value
libjass.parts.Color
{\4c###} -> color (Color), {\4c} -> null
value
Getter
The value of this shadow color tag.
var result = shadowColor.value;
libjass.parts.Color
class ShadowX
A horizontal shadow tag {\xshad}
var shadowX = new libjass.parts.ShadowX(value);
value
?number
{\xshad###} -> depth (number), {\xshad} -> null
value
Getter
The value of this horizontal shadow tag.
var result = shadowX.value;
?number
class ShadowY
A vertical shadow tag {\yshad}
var shadowY = new libjass.parts.ShadowY(value);
value
?number
{\yshad###} -> depth (number), {\yshad} -> null
value
Getter
The value of this vertical shadow tag.
var result = shadowY.value;
?number
class SkewX
An X-axis shearing tag {\fax}
var skewX = new libjass.parts.SkewX(value);
value
?number
{\fax###} -> angle (number), {\fax} -> null
value
Getter
The value of this X-axis shearing tag.
var result = skewX.value;
?number
class SkewY
A Y-axis shearing tag {\fay}
var skewY = new libjass.parts.SkewY(value);
value
?number
{\fay###} -> angle (number), {\fay} -> null
value
Getter
The value of this Y-axis shearing tag.
var result = skewY.value;
?number
class StrikeThrough
A strike-through tag {\s}
var strikeThrough = new libjass.parts.StrikeThrough(value);
value
?boolean
{\s1} -> true, {\s0} -> false, {\s} -> null
value
Getter
The value of this strike-through tag.
var result = strikeThrough.value;
?boolean
class SweepingColorKaraoke
A sweeping color karaoke tag {\K} or {\kf}
var sweepingColorKaraoke = new libjass.parts.SweepingColorKaraoke(duration);
duration
number
{\kf###} -> duration (number)
duration
Getter
The duration of this sweeping color karaoke tag.
var result = sweepingColorKaraoke.duration;
number
class Text
A block of text, i.e., any text not enclosed in {}. Also includes \h.
var text = new libjass.parts.Text(value);
value
string
The content of this block of text
value
Getter
The value of this text part.
var result = text.value;
string
toString
var result = text.toString();
Returns
string
class Transform
A transform tag {\t}
var transform = new libjass.parts.Transform(start, end, accel, tags);
start
number
end
number
accel
number
tags
!Array.<!libjass.parts.Tag>
accel
Getter
The acceleration of this transform tag.
var result = transform.accel;
number
end
Getter
The ending time of this transform tag.
var result = transform.end;
number
start
Getter
The starting time of this transform tag.
var result = transform.start;
number
tags
Getter
The tags animated by this transform tag.
var result = transform.tags;
!Array.<!libjass.parts.Tag>
class Underline
An underline tag {\u}
var underline = new libjass.parts.Underline(value);
value
?boolean
{\u1} -> true, {\u0} -> false, {\u} -> null
value
Getter
The value of this underline tag.
var result = underline.value;
?boolean
class VectorClip
A vector clip tag {\clip} or {\iclip}
var vectorClip = new libjass.parts.VectorClip(scale, instructions, inside);
scale
number
instructions
!Array.<!libjass.parts.drawing.Instruction>
inside
boolean
inside
Getter
Whether this vector clip tag clips the region it encloses or the region it excludes.
var result = vectorClip.inside;
boolean
instructions
Getter
The clip commands of this vector clip tag.
var result = vectorClip.instructions;
string
scale
Getter
The scale of this vector clip tag.
var result = vectorClip.scale;
number
class WrappingStyle
A wrapping style tag {\q}
var wrappingStyle = new libjass.parts.WrappingStyle(value);
value
number
{\q###} -> style (number)
value
Getter
The value of this wrapping style tag.
var result = wrappingStyle.value;
number

Namespace libjass.parts.drawing

Interfaces

interface Instruction
The base interface of the drawing instructions.

Classes

class CubicBezierCurveInstruction implements Instruction
An instruction to draw a cubic bezier curve to a particular position, with two given control points.
var cubicBezierCurveInstruction = new libjass.parts.drawing.CubicBezierCurveInstruction(x1, y1, x2, y2, x3, y3);
x1
number
y1
number
x2
number
y2
number
x3
number
y3
number
x1
Getter
The X position of the first control point of this cubic bezier curve instruction.
var result = cubicBezierCurveInstruction.x1;
number
x2
Getter
The X position of the second control point of this cubic bezier curve instruction.
var result = cubicBezierCurveInstruction.x2;
number
x3
Getter
The ending X position of this cubic bezier curve instruction.
var result = cubicBezierCurveInstruction.x3;
number
y1
Getter
The Y position of the first control point of this cubic bezier curve instruction.
var result = cubicBezierCurveInstruction.y1;
number
y2
Getter
The Y position of the second control point of this cubic bezier curve instruction.
var result = cubicBezierCurveInstruction.y2;
number
y3
Getter
The ending Y position of this cubic bezier curve instruction.
var result = cubicBezierCurveInstruction.y3;
number
class LineInstruction implements Instruction
An instruction to draw a line to a particular position.
var lineInstruction = new libjass.parts.drawing.LineInstruction(x, y);
x
number
y
number
x
Getter
The X position of this line instruction.
var result = lineInstruction.x;
number
y
Getter
The Y position of this line instruction.
var result = lineInstruction.y;
number
class MoveInstruction implements Instruction
An instruction to move to a particular position.
var moveInstruction = new libjass.parts.drawing.MoveInstruction(x, y);
x
number
y
number
x
Getter
The X position of this move instruction.
var result = moveInstruction.x;
number
y
Getter
The Y position of this move instruction.
var result = moveInstruction.y;
number

Namespace libjass.renderers

Interfaces

interface Clock
The clock interface. A clock is used by a renderer as a source of libjass.renderers.ClockEvents.
currentTime
Getter
var result = clock.currentTime;
number
Setter
clock.currentTime = value;
value
number
enabled
Getter
var result = clock.enabled;
boolean
Setter
clock.enabled = value;
value
boolean
paused
Getter
var result = clock.paused;
boolean
Setter
clock.paused = value;
value
boolean
rate
Getter
Gets the rate of the clock - how fast the clock ticks compared to real time.
var result = clock.rate;
number
Setter
Gets the rate of the clock - how fast the clock ticks compared to real time.
clock.rate = value;
value
number
addEventListener
clock.addEventListener(type, listener);
type
number
listener
!Function
disable
Disable the clock.
var result = clock.disable();
Returns
boolean
True if the clock is now disabled, false if it was already disabled.
enable
Enable the clock.
var result = clock.enable();
Returns
boolean
True if the clock is now enabled, false if it was already enabled.
setEnabled
Enable or disable the clock.
var result = clock.setEnabled(enabled);
enabled
boolean
If true, the clock is enabled, otherwise it's disabled.
Returns
boolean
True if the clock is now in the given state, false if it was already in that state.
toggle
Toggle the clock.
clock.toggle();

Classes

class AutoClock implements Clock

An implementation of libjass.renderers.Clock that automatically ticks and generates libjass.renderers.ClockEvents according to the state of an external driver.

For example, if you're using libjass to render subtitles on a canvas with your own video controls, these video controls will function as the driver to this AutoClock. It would call libjass.renderers.AutoClock.play, libjass.renderers.AutoClock.pause, etc. when the user pressed the corresponding video controls.

The difference from ManualClock is that AutoClock does not require the driver to call something like libjass.renderers.ManualClock.tick. Instead it keeps its own time with a high-resolution requestAnimationFrame-based timer.

If using libjass with a <video> element, consider using libjass.renderers.VideoClock that uses the video element as a driver.

var autoClock = new libjass.renderers.AutoClock(getCurrentTime, autoPauseAfter);
getCurrentTime
function():number
A callback that will be invoked to get the current time of the external driver.
autoPauseAfter
number
If two calls to getCurrentTime are more than autoPauseAfter milliseconds apart but return the same time, then the external driver will be considered to have paused.
currentTime
Getter
var result = autoClock.currentTime;
number
enabled
Getter
var result = autoClock.enabled;
boolean
paused
Getter
var result = autoClock.paused;
boolean
rate
Getter
Gets the rate of the clock - how fast the clock ticks compared to real time.
var result = autoClock.rate;
number
addEventListener
autoClock.addEventListener(type, listener);
type
number
listener
!Function
disable
Disable the clock.
var result = autoClock.disable();
Returns
boolean
True if the clock is now disabled, false if it was already disabled.
enable
Enable the clock.
var result = autoClock.enable();
Returns
boolean
True if the clock is now enabled, false if it was already enabled.
pause
Tells the clock to pause.
autoClock.pause();
play
Tells the clock to start generating ticks.
autoClock.play();
seeking
Tells the clock that the external driver is seeking.
autoClock.seeking();
setEnabled
Enable or disable the clock.
var result = autoClock.setEnabled(enabled);
enabled
boolean
If true, the clock is enabled, otherwise it's disabled.
Returns
boolean
True if the clock is now in the given state, false if it was already in that state.
setRate
Sets the rate of the clock - how fast the clock ticks compared to real time.
autoClock.setRate(rate);
rate
number
The new rate of the clock.
toggle
Toggle the clock.
autoClock.toggle();
_onTimerTick
autoClock._onTimerTick(timeStamp);
timeStamp
number
_startTicking
autoClock._startTicking();
_stopTicking
autoClock._stopTicking();
class DefaultRenderer extends WebRenderer
A default renderer implementation.
var defaultRenderer = new libjass.renderers.DefaultRenderer(video, ass, settings);
video
!HTMLVideoElement
ass
!libjass.ASS
settings
libjass.renderers.RendererSettings
resizeVideo
@deprecated
defaultRenderer.resizeVideo(width, height);
width
number
height
number
_ready
defaultRenderer._ready();
_onFullScreenChange
defaultRenderer._onFullScreenChange(fullScreenElement);
fullScreenElement
!Element
class EventSource.<T>
A mixin class that represents an event source.
var eventSource = new libjass.renderers.EventSource();
_eventListeners
Getter
A map from event type to an array of all the listeners registered for that event type.
var result = eventSource._eventListeners;
!Map.<T, !Array.<Function>>
Setter
A map from event type to an array of all the listeners registered for that event type.
eventSource._eventListeners = value;
value
!Map.<T, !Array.<Function>>
_dispatchEvent
Calls all listeners registered for the given event type.
eventSource._dispatchEvent(type, args);
type
!T
The type of event to dispatch
args
!Array.<*>
Arguments for the listeners of the event
addEventListener
Add a listener for the given event.
eventSource.addEventListener(type, listener);
type
!T
The type of event to attach the listener for
listener
!Function
The listener
class ManualClock implements Clock, EventSource.<ClockEvent>
An implementation of libjass.renderers.Clock that allows user script to manually trigger libjass.renderers.ClockEvents.
var manualClock = new libjass.renderers.ManualClock();
_dispatchEvent
Getter
var result = manualClock._dispatchEvent;
function(number, Array.<*>)
Setter
manualClock._dispatchEvent = value;
value
function(number, Array.<*>)
_eventListeners
Getter
var result = manualClock._eventListeners;
!Map.<T, !Array.<Function>>
Setter
manualClock._eventListeners = value;
value
!Map.<T, !Array.<Function>>
addEventListener
Getter
var result = manualClock.addEventListener;
function(number, !Function)
Setter
manualClock.addEventListener = value;
value
function(number, !Function)
currentTime
Getter
var result = manualClock.currentTime;
number
enabled
Getter
var result = manualClock.enabled;
boolean
paused
Getter
var result = manualClock.paused;
boolean
rate
Getter
Gets the rate of the clock - how fast the clock ticks compared to real time.
var result = manualClock.rate;
number
disable
Disable the clock.
var result = manualClock.disable();
Returns
boolean
True if the clock is now disabled, false if it was already disabled.
enable
Enable the clock.
var result = manualClock.enable();
Returns
boolean
True if the clock is now enabled, false if it was already enabled.
pause
Trigger a libjass.renderers.ClockEvent.Pause
manualClock.pause();
play
Trigger a libjass.renderers.ClockEvent.Play
manualClock.play();
seek
Seek to the given time. Unlike libjass.renderers.ManualClock.tick this is used to represent a discontinuous jump, such as the user seeking via the video element's position bar.
manualClock.seek(time);
time
number
setEnabled
Enable or disable the clock.
var result = manualClock.setEnabled(enabled);
enabled
boolean
If true, the clock is enabled, otherwise it's disabled.
Returns
boolean
True if the clock is now in the given state, false if it was already in that state.
setRate
Sets the rate of the clock - how fast the clock ticks compared to real time.
manualClock.setRate(rate);
rate
number
The new rate of the clock.
stop
Trigger a libjass.renderers.ClockEvent.Stop
manualClock.stop();
tick
Trigger a libjass.renderers.ClockEvent.Tick with the given time.
manualClock.tick(currentTime);
currentTime
number
toggle
Toggle the clock.
manualClock.toggle();
class NullRenderer
A renderer implementation that doesn't output anything.
var nullRenderer = new libjass.renderers.NullRenderer(ass, clock, settings);
ass
!libjass.ASS
clock
!libjass.renderers.Clock
settings
libjass.renderers.RendererSettings
ass
Getter
var result = nullRenderer.ass;
!libjass.ASS
clock
Getter
var result = nullRenderer.clock;
!libjass.renderers.Clock
enabled
Getter
var result = nullRenderer.enabled;
boolean
id
Getter
The unique ID of this renderer. Auto-generated.
var result = nullRenderer.id;
number
settings
Getter
var result = nullRenderer.settings;
!libjass.renderers.RendererSettings
disable
Disable the renderer.
var result = nullRenderer.disable();
Returns
boolean
True if the renderer is now disabled, false if it was already disabled.
draw
Draw a dialogue. This is a no-op for this type.
nullRenderer.draw(dialogue);
dialogue
!libjass.Dialogue
enable
Enable the renderer.
var result = nullRenderer.enable();
Returns
boolean
True if the renderer is now enabled, false if it was already enabled.
preRender
Pre-render a dialogue. This is a no-op for this type.
nullRenderer.preRender(dialogue);
dialogue
!libjass.Dialogue
setEnabled
Enable or disable the renderer.
var result = nullRenderer.setEnabled(enabled);
enabled
boolean
If true, the renderer is enabled, otherwise it's disabled.
Returns
boolean
True if the renderer is now in the given state, false if it was already in that state.
toggle
Toggle the renderer.
nullRenderer.toggle();
_onClockPause
Runs when the clock is paused.
nullRenderer._onClockPause();
_onClockPlay
Runs when the clock is enabled, or starts playing, or is resumed from pause.
nullRenderer._onClockPlay();
_onClockRateChange
Runs when the clock changes its rate.
nullRenderer._onClockRateChange();
_onClockStop
Runs when the clock is disabled.
nullRenderer._onClockStop();
_onClockTick
Runs when the clock's current time changed. This might be a result of either regular playback or seeking.
nullRenderer._onClockTick();
class RendererSettings
Settings for the renderer.
var rendererSettings = new libjass.renderers.RendererSettings();
enableSvg
Getter

Outlines and blur are implemented using SVG filters by default. When false, they will be rendered using alternative means.

IE 11 and below do not support SVG filters on HTML elements so this should be set to false there. See http://caniuse.com/svg-html for details.

Defaults to true.

var result = rendererSettings.enableSvg;
boolean
Setter

Outlines and blur are implemented using SVG filters by default. When false, they will be rendered using alternative means.

IE 11 and below do not support SVG filters on HTML elements so this should be set to false there. See http://caniuse.com/svg-html for details.

Defaults to true.

rendererSettings.enableSvg = value;
value
boolean
fontMap
Getter

A map of font name to one or more URLs of that font. If provided, the fonts in this map are pre-loaded by the WebRenderer when it's created.

If you have a <style> or <link> element on the page containing @font-face rules, you can use the libjass.renderers.RendererSettings.makeFontMapFromStyleElement convenience method to create a font map.

var result = rendererSettings.fontMap;
!Map.<string, !Array.<string>>
Setter

A map of font name to one or more URLs of that font. If provided, the fonts in this map are pre-loaded by the WebRenderer when it's created.

If you have a <style> or <link> element on the page containing @font-face rules, you can use the libjass.renderers.RendererSettings.makeFontMapFromStyleElement convenience method to create a font map.

rendererSettings.fontMap = value;
value
!Map.<string, !Array.<string>>
preciseOutlines
Getter

Subtitle outlines will be rendered in full detail. When false, the value of blur is used to draw less outlines for better performance and (hopefully) similar output.

Defaults to false.

var result = rendererSettings.preciseOutlines;
boolean
Setter

Subtitle outlines will be rendered in full detail. When false, the value of blur is used to draw less outlines for better performance and (hopefully) similar output.

Defaults to false.

rendererSettings.preciseOutlines = value;
value
boolean
preRenderTime
Getter

Subtitles will be pre-rendered for this amount of time (seconds).

Defaults to 5.

var result = rendererSettings.preRenderTime;
number
Setter

Subtitles will be pre-rendered for this amount of time (seconds).

Defaults to 5.

rendererSettings.preRenderTime = value;
value
number
from
Converts an arbitrary object into a libjass.renderers.RendererSettings object.
var result = libjass.renderers.RendererSettings.from(object);
object
*
Returns
!libjass.renderers.RendererSettings
makeFontMapFromStyleElement

A convenience method to create a font map from a <style> or <link> element that contains @font-face rules. There should be one @font-face rule for each font name, mapping to a font file URL.

For example:

@font-face {
    font-family: "Helvetica";
    src: url("/fonts/helvetica.ttf");
}

var result = libjass.renderers.RendererSettings.makeFontMapFromStyleElement(linkStyle);
linkStyle
!LinkStyle
Returns
!Map.<string, !Array.<string>>
_stripQuotes
var result = libjass.renderers.RendererSettings._stripQuotes(str);
str
string
Returns
string
class VideoClock implements Clock
An implementation of libjass.renderers.Clock that generates libjass.renderers.ClockEvents according to the state of a <video> element.
var videoClock = new libjass.renderers.VideoClock(video);
video
!HTMLVideoElement
currentTime
Getter
var result = videoClock.currentTime;
number
enabled
Getter
var result = videoClock.enabled;
boolean
paused
Getter
var result = videoClock.paused;
boolean
rate
Getter
Gets the rate of the clock - how fast the clock ticks compared to real time.
var result = videoClock.rate;
number
addEventListener
videoClock.addEventListener(type, listener);
type
number
listener
!Function
disable
Disable the clock.
var result = videoClock.disable();
Returns
boolean
True if the clock is now disabled, false if it was already disabled.
enable
Enable the clock.
var result = videoClock.enable();
Returns
boolean
True if the clock is now enabled, false if it was already enabled.
setEnabled
Enable or disable the clock.
var result = videoClock.setEnabled(enabled);
enabled
boolean
If true, the clock is enabled, otherwise it's disabled.
Returns
boolean
True if the clock is now in the given state, false if it was already in that state.
toggle
Toggle the clock.
videoClock.toggle();
class WebRenderer extends NullRenderer implements EventSource.<string>
A renderer implementation that draws subtitles to the given <div>
var webRenderer = new libjass.renderers.WebRenderer(ass, clock, libjassSubsWrapper, settings);
ass
!libjass.ASS
clock
!libjass.renderers.Clock
libjassSubsWrapper
!HTMLDivElement
Subtitles will be rendered to this <div>
settings
!libjass.renderers.RendererSettings
_dispatchEvent
Getter
var result = webRenderer._dispatchEvent;
function(number, Array.<*>)
Setter
webRenderer._dispatchEvent = value;
value
function(number, Array.<*>)
_eventListeners
Getter
var result = webRenderer._eventListeners;
!Map.<T, !Array.<Function>>
Setter
webRenderer._eventListeners = value;
value
!Map.<T, !Array.<Function>>
addEventListener
Getter
var result = webRenderer.addEventListener;
function(number, !Function)
Setter
webRenderer.addEventListener = value;
value
function(number, !Function)
libjassSubsWrapper
Getter
var result = webRenderer.libjassSubsWrapper;
!HTMLDivElement
draw
Returns the subtitle div for display. The libjass.renderers.Clock.currentTime of the libjass.renderers.NullRenderer.clock is used to shift the animations appropriately, so that at the time the div is inserted into the DOM and the animations begin, they are in sync with the clock time.
webRenderer.draw(dialogue);
dialogue
!libjass.Dialogue
preRender
The magic happens here. The subtitle div is rendered and stored. Call libjass.renderers.WebRenderer.draw to get a clone of the div to display.
webRenderer.preRender(dialogue);
dialogue
!libjass.Dialogue
resize
Resize the subtitles to the given new dimensions.
webRenderer.resize(width, height);
width
number
height
number
_onClockPause
webRenderer._onClockPause();
_onClockPlay
webRenderer._onClockPlay();
_onClockRateChange
webRenderer._onClockRateChange();
_onClockStop
webRenderer._onClockStop();
_onClockTick
webRenderer._onClockTick();
_ready
webRenderer._ready();
_removeAllSubs
webRenderer._removeAllSubs();
_removeSub
webRenderer._removeSub(sub);
sub
!HTMLDivElement

Enums

enum ClockEvent
The type of clock event.
Play = 0
Tick = 1
Pause = 2
Stop = 3
RateChange = 4

Namespace libjass.webworker

Properties

supported
Getter
Indicates whether web workers are supposed in this environment or not.
var result = libjass.webworker.supported;
boolean
Setter
Indicates whether web workers are supposed in this environment or not.
libjass.webworker.supported = value;
value
boolean

Free functions

createWorker
Create a new web worker and returns a libjass.webworker.WorkerChannel to it.
var result = libjass.webworker.createWorker(scriptPath);
scriptPath
string=
The path to libjass.js to be loaded in the web worker. If the browser supports document.currentScript, the parameter is optional and, if not provided, the path will be determined from the src attribute of the <script> element that contains the currently running copy of libjass.js
Returns
!libjass.webworker.WorkerChannel
A communication channel to the new web worker.

Interfaces

interface WorkerChannel
Represents a communication channel between the host and the web worker. An instance of this class is created by calling libjass.webworker.createWorker
request
Sends a request to the other side to execute the given command with the given parameters.
var result = workerChannel.request(command, parameters);
command
number
parameters
*
Returns
!Promise.<*>
A promise that will get resolved when the other side computes the result

Enums

enum WorkerCommands
The commands that can be sent to or from a web worker.
Response = 0
Parse = 1
Ping = 2

Module ./parser/misc

Free functions

parseLineIntoProperty
Parses a line into a ./types/misc.Property.
var result = parseLineIntoProperty(line);
line
string
Returns
!Property
parseLineIntoTypedTemplate
Parses a line into a ./types/misc.TypedTemplate according to the given format specifier.
var result = parseLineIntoTypedTemplate(line, formatSpecifier);
line
string
formatSpecifier
!Array.<string>
Returns
!TypedTemplate

Module ./parser/parse

Free functions

makeTagParserFunction
Constructs a simple tag parser function and sets it on the prototype of the ./parser/parse.ParserRun class.
makeTagParserFunction(tagName, tagConstructor, valueParser, required);
tagName
string
The name of the tag to generate the parser function for
tagConstructor
function(new: !libjass.parts.Part, *)
The type of tag to be returned by the generated parser function
valueParser
function(!ParseNode): ParseNode
The parser for the tag's value
required
boolean
Whether the tag's value is required or optional

Classes

class ParseNode
This class represents a single parse node. It has a start and end position, and an optional value object.
var parseNode = new ParseNode(parent, value);
parent
ParseNode
The parent of this parse node.
value
*=null
If provided, it is assigned as the value of the node.
children
Getter
var result = parseNode.children;
!Array.<!ParseNode>
end
Getter
The end position of this parse node.
var result = parseNode.end;
number
parent
Getter
var result = parseNode.parent;
ParseNode
start
Getter
The start position of this parse node.
var result = parseNode.start;
number
value
Getter
An optional object associated with this parse node.
var result = parseNode.value;
*
Setter

An optional object associated with this parse node.

If the value is a string, then the end property is updated to be the length of the string.

parseNode.value = value;
value
*
pop
Removes the last child of this node and updates the end position to be end position of the new last child.
parseNode.pop();
_setEnd
Updates the end property of this node and its parent recursively to the root node.
parseNode._setEnd(newEnd);
newEnd
number
class ParserRun
This class represents a single run of the parser.
var parserRun = new ParserRun(input, rule);
input
string
rule
string
result
Getter
var result = parserRun.result;
ParseNode
parse_alpha
var result = parserRun.parse_alpha(parent);
parent
!ParseNode
Returns
ParseNode
parse_color
var result = parserRun.parse_color(parent);
parent
!ParseNode
Returns
ParseNode
parse_colorWithAlpha
var result = parserRun.parse_colorWithAlpha(parent);
parent
!ParseNode
Returns
ParseNode
parse_comment
var result = parserRun.parse_comment(parent);
parent
!ParseNode
Returns
ParseNode
parse_decimal
var result = parserRun.parse_decimal(parent);
parent
!ParseNode
Returns
ParseNode
parse_decimalInt32
var result = parserRun.parse_decimalInt32(parent);
parent
!ParseNode
Returns
ParseNode
parse_decimalOrHexInt32
var result = parserRun.parse_decimalOrHexInt32(parent);
parent
!ParseNode
Returns
ParseNode
parse_dialogueParts
var result = parserRun.parse_dialogueParts(parent);
parent
!ParseNode
Returns
ParseNode
parse_drawingInstructionCubicBezierCurve
var result = parserRun.parse_drawingInstructionCubicBezierCurve(parent);
parent
!ParseNode
Returns
ParseNode
parse_drawingInstructionLine
var result = parserRun.parse_drawingInstructionLine(parent);
parent
!ParseNode
Returns
ParseNode
parse_drawingInstructionMove
var result = parserRun.parse_drawingInstructionMove(parent);
parent
!ParseNode
Returns
ParseNode
parse_drawingInstructions
var result = parserRun.parse_drawingInstructions(parent);
parent
!ParseNode
Returns
ParseNode
parse_enableDisable
var result = parserRun.parse_enableDisable(parent);
parent
!ParseNode
Returns
ParseNode
parse_enclosedTags
var result = parserRun.parse_enclosedTags(parent);
parent
!ParseNode
Returns
ParseNode
parse_hardspace
var result = parserRun.parse_hardspace(parent);
parent
!ParseNode
Returns
ParseNode
parse_hexInt32
var result = parserRun.parse_hexInt32(parent);
parent
!ParseNode
Returns
ParseNode
parse_newline
var result = parserRun.parse_newline(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_1a
var result = parserRun.parse_tag_1a(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_1c
var result = parserRun.parse_tag_1c(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_2a
var result = parserRun.parse_tag_2a(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_2c
var result = parserRun.parse_tag_2c(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_3a
var result = parserRun.parse_tag_3a(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_3c
var result = parserRun.parse_tag_3c(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_4a
var result = parserRun.parse_tag_4a(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_4c
var result = parserRun.parse_tag_4c(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_a
var result = parserRun.parse_tag_a(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_alpha
var result = parserRun.parse_tag_alpha(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_an
var result = parserRun.parse_tag_an(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_b
var result = parserRun.parse_tag_b(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_be
var result = parserRun.parse_tag_be(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_blur
var result = parserRun.parse_tag_blur(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_bord
var result = parserRun.parse_tag_bord(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_c
var result = parserRun.parse_tag_c(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_clip
var result = parserRun.parse_tag_clip(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fad
var result = parserRun.parse_tag_fad(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fade
var result = parserRun.parse_tag_fade(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fax
var result = parserRun.parse_tag_fax(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fay
var result = parserRun.parse_tag_fay(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fn
var result = parserRun.parse_tag_fn(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fr
var result = parserRun.parse_tag_fr(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_frx
var result = parserRun.parse_tag_frx(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fry
var result = parserRun.parse_tag_fry(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_frz
var result = parserRun.parse_tag_frz(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fs
var result = parserRun.parse_tag_fs(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fscx
var result = parserRun.parse_tag_fscx(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fscy
var result = parserRun.parse_tag_fscy(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fsminus
var result = parserRun.parse_tag_fsminus(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fsp
var result = parserRun.parse_tag_fsp(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_fsplus
var result = parserRun.parse_tag_fsplus(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_i
var result = parserRun.parse_tag_i(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_iclip
var result = parserRun.parse_tag_iclip(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_k
var result = parserRun.parse_tag_k(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_K
var result = parserRun.parse_tag_K(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_kf
var result = parserRun.parse_tag_kf(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_ko
var result = parserRun.parse_tag_ko(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_move
var result = parserRun.parse_tag_move(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_org
var result = parserRun.parse_tag_org(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_p
var result = parserRun.parse_tag_p(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_pbo
var result = parserRun.parse_tag_pbo(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_pos
var result = parserRun.parse_tag_pos(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_q
var result = parserRun.parse_tag_q(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_r
var result = parserRun.parse_tag_r(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_s
var result = parserRun.parse_tag_s(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_shad
var result = parserRun.parse_tag_shad(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_t
var result = parserRun.parse_tag_t(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_u
var result = parserRun.parse_tag_u(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_xbord
var result = parserRun.parse_tag_xbord(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_xshad
var result = parserRun.parse_tag_xshad(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_ybord
var result = parserRun.parse_tag_ybord(parent);
parent
!ParseNode
Returns
ParseNode
parse_tag_yshad
var result = parserRun.parse_tag_yshad(parent);
parent
!ParseNode
Returns
ParseNode
parse_text
var result = parserRun.parse_text(parent);
parent
!ParseNode
Returns
ParseNode
parse_unsignedDecimal
var result = parserRun.parse_unsignedDecimal(parent);
parent
!ParseNode
Returns
ParseNode
read
var result = parserRun.read(parent, next);
parent
!ParseNode
next
string
Returns
ParseNode
_haveMore
var result = parserRun._haveMore();
Returns
boolean
_parse_tag_clip_or_iclip
var result = parserRun._parse_tag_clip_or_iclip(tagName, parent);
tagName
string
One of "clip" and "iclip"
parent
!ParseNode
Returns
ParseNode
_peek
var result = parserRun._peek(count);
count
number=1
Returns
string

Module ./parser/streams

Interfaces

interface ReadableStream
getReader
var result = readableStream.getReader();
Returns
!ReadableStreamReader
interface TextDecoder
decode
var result = textDecoder.decode(input, options);
input
!ArrayBuffer|!ArrayBufferView
options
{ stream: boolean }
Returns
string
interface TextDecoderConstructor
prototype
Getter
var result = textDecoderConstructor.prototype;
!TextDecoder
Setter
textDecoderConstructor.prototype = value;
value
!TextDecoder
interface ReadableStreamReader
read
var result = readableStreamReader.read();
Returns
!Promise.<{ value?: Uint8Array, done: boolean }>

Module ./renderers/web/animation-collection

Classes

class AnimationCollection
This class represents a collection of animations. Each animation contains one or more keyframes. The collection can then be converted to a CSS3 representation.
var animationCollection = new AnimationCollection(renderer);
renderer
!libjass.renderers.NullRenderer
The renderer that this collection is associated with
animationDelays
Getter
This array should be used to set the "animation-delay" CSS property of the target element.
var result = animationCollection.animationDelays;
!Array.<number>
animationStyle
Getter
This string should be set as the "animation" CSS property of the target element.
var result = animationCollection.animationStyle;
string
cssText
Getter
This string contains the animation definitions and should be inserted into a <style> element.
var result = animationCollection.cssText;
string
add
Add an animation to this collection. The given keyframes together make one animation.
animationCollection.add(timingFunction, keyframes);
timingFunction
string
One of the acceptable values for the "animation-timing-function" CSS property
keyframes
!Array.<!libjass.renderers.Keyframe>

Module ./renderers/web/dom-parser

Properties

domParser
Getter
var result = domParser;
!DomParser
Setter
domParser = value;
value
!DomParser

Module ./renderers/web/drawing-styles

Classes

class DrawingStyles
This class represents an ASS drawing - a set of drawing instructions between {\p} tags.
var drawingStyles = new DrawingStyles(outputScaleX, outputScaleY);
outputScaleX
number
outputScaleY
number
baselineOffset
Setter
drawingStyles.baselineOffset = value;
value
number
scale
Setter
drawingStyles.scale = value;
value
number
toSVG
Converts this drawing to an <svg> element.
var result = drawingStyles.toSVG(drawingInstructions, fillColor);
drawingInstructions
!libjass.parts.DrawingInstructions
fillColor
!libjass.parts.Color
Returns
!SVGSVGElement

Module ./renderers/web/keyframe

Classes

class Keyframe
This class represents a single keyframe. It has a list of CSS properties (names and values) associated with a point in time. Multiple keyframes make up an animation.
var keyframe = new Keyframe(time, properties);
time
number
properties
!Map.<string, string>
properties
Getter
var result = keyframe.properties;
!Map.<string, string>
time
Getter
var result = keyframe.time;
number

Module ./renderers/web/renderer

Interfaces

interface PreRenderedSub
animationDelays
Getter
var result = preRenderedSub.animationDelays;
!Map.<string, number>
Setter
preRenderedSub.animationDelays = value;
value
!Map.<string, number>
sub
Getter
var result = preRenderedSub.sub;
!HTMLDivElement
Setter
preRenderedSub.sub = value;
value
!HTMLDivElement

Module ./renderers/web/span-styles

Free functions

fontSizeForLineHeight
Uses linear interpolation to calculate the CSS font size that would give the specified line height for the specified font family.
var result = fontSizeForLineHeight(fontFamily, lineHeight, fontSizeElement);
fontFamily
string
lineHeight
number
fontSizeElement
!HTMLDivElement
Returns
number
lineHeightForFontSize
var result = lineHeightForFontSize(fontFamily, fontSize, fontSizeElement);
fontFamily
string
fontSize
number
fontSizeElement
!HTMLDivElement
Returns
number

Classes

class SpanStyles
This class represents the style attribute of a span. As a Dialogue's div is rendered, individual parts are added to span's, and this class is used to maintain the style attribute of those.
var spanStyles = new SpanStyles(renderer, dialogue, scaleX, scaleY, settings, fontSizeElement, svgDefsElement);
renderer
!libjass.renderers.NullRenderer
The renderer that this set of styles is associated with
dialogue
!libjass.Dialogue
The Dialogue that this set of styles is associated with
scaleX
number
The horizontal scaling of the subtitles
scaleY
number
The vertical scaling of the subtitles
settings
!libjass.renderers.RendererSettings
The renderer settings
fontSizeElement
!HTMLDivElement
A <div> element to measure font sizes with
svgDefsElement
!SVGDefsElement
An SVG <defs> element to append filter definitions to
blur
Setter
Sets the blur property. null defaults it to 0.
spanStyles.blur = value;
value
?number
bold
Setter
Sets the bold property. null defaults it to the default style's value.
spanStyles.bold = value;
value
(?number|?boolean)
fontName
Setter
Sets the font name property. null defaults it to the default style's value.
spanStyles.fontName = value;
value
?string
fontScaleX
Setter
Sets the horizontal font scaling property. null defaults it to the default style's value.
spanStyles.fontScaleX = value;
value
?number
fontScaleY
Setter
Sets the vertical font scaling property. null defaults it to the default style's value.
spanStyles.fontScaleY = value;
value
?number
fontSize
Setter
Sets the font size property. null defaults it to the default style's value.
spanStyles.fontSize = value;
value
?number
gaussianBlur
Setter
Sets the Gaussian blur property. null defaults it to 0.
spanStyles.gaussianBlur = value;
value
?number
italic
Setter
Sets the italic property. null defaults it to the default style's value.
spanStyles.italic = value;
value
?boolean
letterSpacing
Setter
Sets the letter spacing property. null defaults it to the default style's value.
spanStyles.letterSpacing = value;
value
?number
outlineAlpha
Setter
Sets the outline alpha property.
spanStyles.outlineAlpha = value;
value
?number
outlineColor
Setter
Sets the outline color property. null defaults it to the default style's value.
spanStyles.outlineColor = value;
value
libjass.Color
outlineHeight
Setter
Sets the outline height property. null defaults it to the style's original outline height value.
spanStyles.outlineHeight = value;
value
?number
outlineWidth
Setter
Sets the outline width property. null defaults it to the style's original outline width value.
spanStyles.outlineWidth = value;
value
?number
primaryAlpha
Getter
Gets the primary alpha property.
var result = spanStyles.primaryAlpha;
?number
Setter
Sets the primary alpha property.
spanStyles.primaryAlpha = value;
value
?number
primaryColor
Getter
Gets the primary color property.
var result = spanStyles.primaryColor;
!libjass.Color
Setter
Sets the primary color property. null defaults it to the default style's value.
spanStyles.primaryColor = value;
value
libjass.Color
rotationX
Setter
Sets the X-axis rotation property.
spanStyles.rotationX = value;
value
?number
rotationY
Setter
Sets the Y-axis rotation property.
spanStyles.rotationY = value;
value
?number
rotationZ
Setter
Sets the Z-axis rotation property.
spanStyles.rotationZ = value;
value
?number
secondaryAlpha
Getter
Gets the secondary alpha property.
var result = spanStyles.secondaryAlpha;
?number
Setter
Sets the secondary alpha property.
spanStyles.secondaryAlpha = value;
value
?number
secondaryColor
Getter
Gets the secondary color property.
var result = spanStyles.secondaryColor;
!libjass.Color
Setter
Sets the secondary color property. null defaults it to the default style's value.
spanStyles.secondaryColor = value;
value
libjass.Color
shadowAlpha
Setter
Sets the shadow alpha property.
spanStyles.shadowAlpha = value;
value
?number
shadowColor
Setter
Sets the shadow color property. null defaults it to the default style's value.
spanStyles.shadowColor = value;
value
libjass.Color
shadowDepthX
Setter
Sets the outline width property. null defaults it to the style's original shadow depth X value.
spanStyles.shadowDepthX = value;
value
?number
shadowDepthY
Setter
Sets the shadow height property. null defaults it to the style's original shadow depth Y value.
spanStyles.shadowDepthY = value;
value
?number
skewX
Setter
Sets the X-axis skew property.
spanStyles.skewX = value;
value
?number
skewY
Setter
Sets the Y-axis skew property.
spanStyles.skewY = value;
value
?number
strikeThrough
Setter
Sets the strike-through property. null defaults it to the default style's value.
spanStyles.strikeThrough = value;
value
?boolean
underline
Setter
Sets the underline property. null defaults it to the default style's value.
spanStyles.underline = value;
value
?boolean
makeNewLine
var result = spanStyles.makeNewLine();
Returns
!HTMLBRElement
reset
Resets the styles to the defaults provided by the argument.
spanStyles.reset(newStyle);
newStyle
libjass.Style
The new defaults to reset the style to. If null, the styles are reset to the default style of the Dialogue.
setStylesOnSpan
Sets the style attribute on the given span element.
var result = spanStyles.setStylesOnSpan(span, animationCollection, animationStyleElement);
span
!HTMLSpanElement
animationCollection
!AnimationCollection
animationStyleElement
!HTMLStyleElement
Returns
!HTMLSpanElement
The resulting <span> with the CSS styles applied. This may be a wrapper around the input <span> if the styles were applied using SVG filters.

Module ./settings

Free functions

setDebugMode
Sets the debug mode.
setDebugMode(value);
value
boolean
setVerboseMode
Sets the verbose debug mode.
setVerboseMode(value);
value
boolean

Module ./types/misc

Free functions

valueOrDefault.<T>
var result = valueOrDefault(template, key, converter, validator, defaultValue);
template
!Map.<string, string>
key
string
converter
function(string):T
validator
?function(T):boolean
defaultValue
T
Returns
T

Interfaces

interface Property
A property.
name
Getter
var result = property.name;
string
Setter
property.name = value;
value
string
value
Getter
var result = property.value;
string
Setter
property.value = value;
value
string
interface TypedTemplate
A template object with a particular type.
template
Getter
var result = typedTemplate.template;
!Map.<string, string>
Setter
typedTemplate.template = value;
value
!Map.<string, string>
type
Getter
var result = typedTemplate.type;
string
Setter
typedTemplate.type = value;
value
string

Module ./utility/extends

Free functions

___extends
Class inheritance shim.
___extends(derived, base);
derived
!Function
base
!Function

Module ./utility/map

Free functions

setImplementation
Sets the Map implementation used by libjass to the provided one. If null, ./utility/map.SimpleMap is used.
setImplementation(value);
value
?function(new:Map, !Array.<!Array.<*>>=)

Classes

class SimpleMap.<K, V>

Map implementation for browsers that don't support it. Only supports keys which are of Number or String type, or which have a property called "id".

Keys and values are stored as properties of an object, with property names derived from the key type.

var simpleMap = new SimpleMap(iterable);
iterable
!Array.<!Array.<*>>=
Only an array of elements (where each element is a 2-tuple of key and value) is supported.
size
Getter
var result = simpleMap.size;
number
clear
simpleMap.clear();
delete
var result = simpleMap.delete(key);
key
K
Returns
boolean
true if the key was present before being deleted, false otherwise
forEach
simpleMap.forEach(callbackfn, thisArg);
callbackfn
function(V, K, libjass.Map.<K, V>)
A function that is called with each key and value in the map.
thisArg
*
get
var result = simpleMap.get(key);
key
K
Returns
V
has
var result = simpleMap.has(key);
key
K
Returns
boolean
set
var result = simpleMap.set(key, value);
key
K
value
V
Returns
libjass.Map.<K, V>
This map
_keyToProperty
Converts the given key into a property name for the internal map.
var result = simpleMap._keyToProperty(key);
key
K
Returns
string

Module ./utility/mixin

Free functions

mixin
Adds properties of the given mixins' prototypes to the given class's prototype.
mixin(clazz, mixins);
clazz
!*
mixins
!Array.<*>

Module ./utility/promise

Free functions

setImplementation
Sets the Promise implementation used by libjass to the provided one. If null, ./utility/promise.SimplePromise is used.
setImplementation(value);
value
?function(new:Promise)

Classes

class SimplePromise.<T>
Promise implementation for browsers that don't support it.
var simplePromise = new SimplePromise(resolver);
resolver
function(function(T), function(*))
all.<T>
var result = SimplePromise.all(values);
values
!Array.<T|!Promise.<T>>
Returns
!Promise.<!Array.<T>>
catch
var result = simplePromise.catch(rejectedHandler);
rejectedHandler
function(*):(T|Promise.<T>)
Returns
!Promise.<T>
isFulfilled
var result = simplePromise.isFulfilled();
Returns
boolean
isPending
var result = simplePromise.isPending();
Returns
boolean
isRejected
var result = simplePromise.isRejected();
Returns
boolean
reason
var result = simplePromise.reason();
Returns
*
resolve.<T>
var result = SimplePromise.resolve(value);
value
T|!Promise.<T>
Returns
!Promise.<T>
then.<U>
var result = simplePromise.then(fulfilledHandler, rejectedHandler);
fulfilledHandler
?function(T):(U|Promise.<U>)
rejectedHandler
?function(*):(U|Promise.<U>)
Returns
!Promise.<U>
value
var result = simplePromise.value();
Returns
T
_fulfill
simplePromise._fulfill(value);
value
T
_getThenMethod.<T>
var result = SimplePromise._getThenMethod(obj);
obj
!*
Returns
?function(function(T):(T|!Promise.<T>), function(*):(T|!Promise.<T>)):!Promise.<T>
_propagateResolution
Propagates the result of the current promise to all its children.
simplePromise._propagateResolution();
_reject
simplePromise._reject(reason);
reason
*
_resolve
simplePromise._resolve(value);
value
T|!Promise.<T>

Enums

enum SimplePromiseState
The state of the ./utility/promise.SimplePromise
PENDING = 0
FULFILLED = 1
REJECTED = 2

Module ./utility/set

Free functions

setImplementation
Sets the Set implementation used by libjass to the provided one. If null, ./utility/set.SimpleSet is used.
setImplementation(value);
value
?function(new:Set, !Array.<T>=)

Classes

class SimpleSet.<T>

Set implementation for browsers that don't support it. Only supports Number and String elements.

Elements are stored as properties of an object, with names derived from their type.

var simpleSet = new SimpleSet(iterable);
iterable
!Array.<T>=
Only an array of values is supported.
size
Getter
var result = simpleSet.size;
number
add
var result = simpleSet.add(value);
value
T
Returns
libjass.Set.<T>
This set
clear
simpleSet.clear();
forEach
simpleSet.forEach(callbackfn, thisArg);
callbackfn
function(T, T, libjass.Set.<T>)
A function that is called with each value in the set.
thisArg
*
has
var result = simpleSet.has(value);
value
T
Returns
boolean
_toProperty
Converts the given value into a property name for the internal map.
var result = simpleSet._toProperty(value);
value
T
Returns
string

Module ./webworker/channel

Interfaces

interface WorkerCommandHandler
The signature of a handler registered to handle a particular command in libjass.webworker.WorkerCommands
interface WorkerCommunication
The interface implemented by a communication channel to the other side.
addEventListener
workerCommunication.addEventListener(type, listener, useCapture);
type
string
listener
!EventListener
useCapture
?boolean
postMessage
workerCommunication.postMessage(message);
message
*
interface WorkerRequestMessage
The interface implemented by a request sent to the other side of the communication channel.
command
Getter
The command type of this request.
var result = workerRequestMessage.command;
number
Setter
The command type of this request.
workerRequestMessage.command = value;
value
number
parameters
Getter
Any parameters serialized with this request.
var result = workerRequestMessage.parameters;
*
Setter
Any parameters serialized with this request.
workerRequestMessage.parameters = value;
value
*
requestId
Getter
An internal identifier for this request. Used to connect responses to their corresponding requests.
var result = workerRequestMessage.requestId;
number
Setter
An internal identifier for this request. Used to connect responses to their corresponding requests.
workerRequestMessage.requestId = value;
value
number
interface WorkerResponseMessage
The interface implemented by a response received from the other side of the communication channel.
error
Getter
Set if the computation of this response resulted in an error.
var result = workerResponseMessage.error;
*
Setter
Set if the computation of this response resulted in an error.
workerResponseMessage.error = value;
value
*
requestId
Getter
An internal identifier for this response. Used to connect responses to their corresponding requests.
var result = workerResponseMessage.requestId;
number
Setter
An internal identifier for this response. Used to connect responses to their corresponding requests.
workerResponseMessage.requestId = value;
value
number
result
Getter
The result of computing this response.
var result = workerResponseMessage.result;
*
Setter
The result of computing this response.
workerResponseMessage.result = value;
value
*

Classes

class WorkerChannelImpl implements WorkerChannel
Internal implementation of libjass.webworker.WorkerChannel
var workerChannelImpl = new WorkerChannelImpl(comm);
comm
!*
The object used to talk to the other side of the channel. When created by the main thread, this is the Worker object. When created by the web worker, this is its global object.
cancelRequest
workerChannelImpl.cancelRequest(requestId);
requestId
number
request
var result = workerChannelImpl.request(command, parameters);
command
number
parameters
*
Returns
!Promise.<*>
_onMessage
workerChannelImpl._onMessage(rawMessage);
rawMessage
string
_respond
workerChannelImpl._respond(message);
message
!WorkerResponseMessage

Module ./webworker/misc

Free functions

deserialize
var result = deserialize(str);
str
string
Returns
*
getWorkerCommandHandler
Gets the handler for the given worker command.
var result = getWorkerCommandHandler(command);
command
number
Returns
?function(*, function(*, *))
registerClassPrototype
Registers a prototype as a deserializable type.
registerClassPrototype(prototype);
prototype
!*
registerWorkerCommand
Registers a handler for the given worker command.
registerWorkerCommand(command, handler);
command
number
The command that this handler will handle. One of the libjass.webworker.WorkerCommands constants.
handler
function(*, function(*, *))
The handler. A function of the form (parameters: *, response: function(error: *, result: *): void): void
serialize
var result = serialize(obj);
obj
*
Returns
string