{"size": 1355, "ext": "js", "max_stars_repo_path": "source/JsMaterialX/test/testHelpers.js", "max_stars_repo_name": "kohakukun/MaterialX", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "source/JsMaterialX/test/testHelpers.js", "max_issues_repo_name": "kohakukun/MaterialX", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "source/JsMaterialX/test/testHelpers.js", "max_forks_repo_name": "kohakukun/MaterialX", "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": 33.0487804878, "max_line_length": 107, "alphanum_fraction": 0.6546125461}
import Module from './_build/JsMaterialX.js';
// import Module from './_build/JsMaterialX-1.37.1.js'; // uncomment to load the versioned JsMaterialX file
import regeneratorRuntime from 'regenerator-runtime'; // This is required for the async/awaits
var fs = require('fs');
var path = require('path');
/**
 * Returns a promise that resolves the MaterialX namespace
 */
export function initMaterialX() {
    return new Promise(function (resolve) {
        // Note: Module is not a promise.
        // The then function is defined by emscripten.
        Module().then((module) => {
            resolve(module.getMaterialX());
        });
    });
}

/**
 * Helper function used to traverse a tree or a graph
 * @param {MaterialX.TreeIterator|MaterialX.GraphIterator} elements - iterator
 * @param {function} elemCb - callback called on each element. The element is passed to the callback.
 */
export function traverse(elements, elemCb) {
    var elem = elements.next();
    while (elem) {
        elemCb && elemCb(elem);
        elem = elements.next();
    }
}

export function getMtlxStrings(fileNames, subPath) {
    const mtlxStrs = [];
    for (let i = 0; i < fileNames.length; i++) {
        const p = path.resolve(subPath, fileNames[parseInt(i, 10)]);
        const t = fs.readFileSync(p, 'utf8');
        mtlxStrs.push(t);
    }
    return mtlxStrs;
}
