Module: services/optionDataLoader

Loads the data related to options and option groups defined in the metadata.

Source:

(require("services/optionDataLoader"))(optionGroups, imageDirectory, imageExtension) → {Object}

Creates the loader using the passed configuration.

Parameters:
Name Type Description
optionGroups Array.<OptionGroup>

All option groups

imageDirectory string

Image directory to find resources for options

imageExtension string

Image filename extension for option resources

Source:
Throws:

when there is a problem with passed parameters

Type
Error
Returns:
Type
Object

Methods

createOptionGroupsMap() → {Object.<string, OptionGroup>}

Creates a map to access option groups by id.

Please note that keys of the returned map are string, not integers.

Source:
Returns:
Type
Object.<string, OptionGroup>

createOptionImagesMap() → {Object.<string, OptionImageMapValueItem>}

Creates a map to access images of the options by id.

If option doesn't have any color, then value in the map will be the image. Otherwise, fetched value will be again a map. But this time a map of .

Please note that reading the images into memory for all options with their colors are quite a big thing. Don't call this method more than once!

Source:
Returns:
Type
Object.<string, OptionImageMapValueItem>

createOptionsMap() → {Object.<string, Option>}

Creates a map to access options by id.

Source:
Returns:
Type
Object.<string, Option>

(private, inner) getFilePath(option, color) → {string}

Get the file path for the option w/ given optional color.

Parameters:
Name Type Description
option
color
Source:
Returns:

the file path

Type
string
Examples
// returns "/some/path/skin.png"
getFilePath({resource:"skin"}, color:undefined)
// returns "/some/path/skin_FF00FF.png"
getFilePath({resource:"skin"}, color:"FF00FF")