Skip to content

Tag (NodeJS)

Dmitry Kochin edited this page Jun 22, 2018 · 2 revisions

Tag is an utility class to represent Ties.DB EBML structure. The EBML structures can be returned in response to requests.

Creating Tag

let tag = new Tag(propertiesOrName);

Arguments

  • propertiesOrName - if it is string then it should be name of the tag to be created. The name should be valid for Ties.DB EBML schema. Otherwise it can be an object with the following keys:
{
    name: string, //Name of the tag from the Ties.DB EBML schema
    value: mixed,  //Javascript typed value of the tag
    data: Buffer  //binary representation of the value
}

name is obligatory, value and data are optional.


Getting subtags

let child = tag.getChild(name);

Gets one immediate child of the tag with the specified name

Arguments

  • name - name of the subtag to get

Returns

Tag or null if not found


Getting array of subtags

let children = tag.getChildren(name);

Gets all immediate children of the tag with the specified name

Arguments

  • name - name of the subtags to get

Returns

Array of Tag. The array will be empty if not found


Adding child tags

tag.addChild(name, value);
tag.addChild(tag);

Adds new child to the tag

Arguments

  • name - name of the subtag to add. Should be valid Ties.DB EBML schema name.
  • value - value of the subtag
  • tag - a Tag object to add as a subtag

Clone this wiki locally