{"size": 1101, "ext": "js", "max_stars_repo_path": "templates/ui/maker/YAMLMake.js", "max_stars_repo_name": "realkotob/phaser3-rex-notes", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "templates/ui/maker/YAMLMake.js", "max_issues_repo_name": "realkotob/phaser3-rex-notes", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "templates/ui/maker/YAMLMake.js", "max_forks_repo_name": "realkotob/phaser3-rex-notes", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.4571428571, "max_line_length": 83, "alphanum_fraction": 0.5821980018}
import ParseYAML from './utils/ParseYAML.js';
import Make from './Make.js';

var YAMLMake = function (scene, data, view, styles, customBuilders) {
    data = ParseYAML(data);
    if (Array.isArray(data)) {
        // Parsing result of YAML data might be an array, 
        // Only last item will be used to create game object, others are references
        data = data[data.length - 1];
    } else if (data.$root) {
        // Parsing result of YAML data might be an object, with $root key, 
        // data.$root will be used to create game object, others are default styles
        var defaultStyles = data;
        data = data.$root;
        delete defaultStyles.$root;

        if (styles === undefined) {
            styles = defaultStyles;
        } else {
            for (var key in defaultStyles) {
                if (!styles[key]) {
                    styles[key] = defaultStyles[key];
                }
            }
        }
    }

    styles = ParseYAML(styles);

    var gameObject = Make(scene, data, view, styles, customBuilders);

    return gameObject;
}

export default YAMLMake;