All files / dist/src utils.js

0% Statements 0/21
0% Branches 0/8
0% Functions 0/3
0% Lines 0/20

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33                                                                 
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getPath(obj, path) {
    var keys = path.split('.');
    for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
        var key = keys_1[_i];
        if (obj == null) {
            return obj;
        }
        obj = obj[key];
    }
    return obj;
}
exports.getPath = getPath;
function inPath(node, ancestor, path) {
    if (path.length === 0) {
        return node === ancestor;
    }
    if (ancestor == null) {
        return false;
    }
    var first = path[0];
    var field = ancestor[first];
    var remainingPath = path.slice(1);
    if (Array.isArray(field)) {
        return field.some(function (item) { return inPath(node, item, remainingPath); });
    }
    else {
        return inPath(node, field, remainingPath);
    }
}
exports.inPath = inPath;
//# sourceMappingURL=utils.js.map