recital / packages / ext-common-commands / dist / lib / tools / fragment-tools.js
fragment-tools.js
Raw
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findFragment = exports.getSceneThatFragmentBelongsTo = void 0;
var getSceneThatFragmentBelongsTo = function (stageObjects, fragment) {
    var index = stageObjects.indexOf(fragment);
    if (index === -1) {
        return undefined;
    }
    for (var i = index; i >= 0; i--) {
        var pointer = stageObjects[i];
        if (pointer.type === 'scene') {
            return pointer;
        }
    }
    return undefined;
};
exports.getSceneThatFragmentBelongsTo = getSceneThatFragmentBelongsTo;
var findFragment = function (stageObjects, primary, title) {
    if (!primary && !title) {
        return undefined;
    }
    if (primary && title) {
        return stageObjects.find(function (val) {
            return val.type === 'fragment' && val.primary === primary && val.title === title;
        });
    }
    if (primary) {
        return stageObjects.find(function (val) {
            return val.type === 'fragment' && val.primary === primary;
        });
    }
    if (title) {
        return stageObjects.find(function (val) {
            return val.type === 'fragment' && val.title === title;
        });
    }
};
exports.findFragment = findFragment;
//# sourceMappingURL=fragment-tools.js.map