VYI

VYI

new VYI(pVyiDataopt)

Initializes this module with the information from the VYI passed.
Source:
Parameters:
Name Type Attributes Description
pVyiData Object <optional>
A JSON / Javascript object containing the vyi information.this.ogger

Members

version

The version of the module.
Source:

Methods

addIcon(pIconData) → {Icon|undefined}

Adds an icon to this VYI.
Source:
Parameters:
Name Type Description
pIconData Icon | Array The icon data to use.
Returns:
Type:
Icon | undefined
- The Icon added or undefined.

export(pCompressedopt) → {Object|string}

Exports this VYI into VYI format.
Source:
Parameters:
Name Type Attributes Description
pCompressed boolean <optional>
Whether the data will be compressed.
Returns:
Type:
Object | string
Returns the vyi data in either a binary string or an object.

getIcon(pName) → {Icon|undefined}

Gets the icon that has the name pName. The LAST defined icon that has the passed name will be returned.
Source:
Parameters:
Name Type Description
pName string The name of the icon to get.
Returns:
Type:
Icon | undefined
The icon that has the name pName or undefined.

getIconById(pId) → {Icon}

Gets an icon by the id provided.
Source:
Parameters:
Name Type Description
pId string The id of the icon.
Returns:
Type:
Icon
The icon that has the id that was passed.

getIconCount() → {number}

Gets the number of icons this vyi has.
Source:
Returns:
Type:
number
The amount of icons this vyi has.

getIconNames() → {Array}

Returns all the icon names in this vyi.
Source:
Returns:
Type:
Array
An array of icon names in this vyi.

getIcons() → {Array.<Icon>}

Gets all the icons in this vyi.
Source:
Returns:
Type:
Array.<Icon>

getName() → {string}

Gets the name of the vyi.
Source:
Returns:
Type:
string
The name of the vyi.

(async) parse(pVyiData) → {Promise.<void>}

Parses the provided VYI data (either a URL, a JSON object, or binary data) and processes it. If the data is a URL (string), it fetches/reads the data and parses it as JSON. If the data is binary, it attempts to inflate it using pako or decode it as plain text.
Source:
Parameters:
Name Type Description
pVyiData string | Object | Uint8Array | ArrayBuffer The VYI data to parse. Or a path to a VYI file.
Throws:
- Throws an error if fetching, inflating, or decoding fails.
Type
Error
Returns:
Type:
Promise.<void>
- A promise that resolves when the parsing is completed.

readFile(pVyiData) → {Promise.<VYI>}

Read the file from a binary string.
Source:
Parameters:
Name Type Description
pVyiData string The compressed binary string representing the vyi data.
Returns:
Type:
Promise.<VYI>
- An vyi that was compressed in the file.

removeIcon(pIcon)

Removes the icon passed.
Source:
Parameters:
Name Type Description
pIcon Icon The icon to remove from this vyi.

removeIconById(pName)

Removes the icon via it's id.
Source:
Parameters:
Name Type Description
pName string The id to use to find the icon.

removeIconByName(pName)

Removes the icon via it's name. The LAST defined icon that has the passed name will be removed. As names are not unique.
Source:
Parameters:
Name Type Description
pName string The name to use to find the icon.

rename(pName)

Renames the vyi.
Source:
Parameters:
Name Type Description
pName string The name to give this vyi.