333
schangxiang@126.com
2025-09-19 18966e02fb573c7e2bb0c6426ed792b38b910940
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
34
35
36
37
38
39
40
41
42
43
44
45
46
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * Metadata args utility functions.
 */
var MetadataUtils = /** @class */ (function () {
    function MetadataUtils() {
    }
    /**
     * Gets given's entity all inherited classes.
     * Gives in order from parents to children.
     * For example Post extends ContentModel which extends Unit it will give
     * [Unit, ContentModel, Post]
     */
    MetadataUtils.getInheritanceTree = function (entity) {
        var tree = [entity];
        var getPrototypeOf = function (object) {
            var proto = Object.getPrototypeOf(object);
            if (proto && proto.name) {
                tree.push(proto);
                getPrototypeOf(proto);
            }
        };
        getPrototypeOf(entity);
        return tree;
    };
    /**
     * Checks if this table is inherited from another table.
     */
    MetadataUtils.isInherited = function (target1, target2) {
        return target1.prototype instanceof target2;
    };
    /**
     * Filters given array of targets by a given classes.
     * If classes are not given, then it returns array itself.
     */
    MetadataUtils.filterByTarget = function (array, classes) {
        if (!classes)
            return array;
        return array.filter(function (item) { return item.target && classes.indexOf(item.target) !== -1; });
    };
    return MetadataUtils;
}());
exports.MetadataUtils = MetadataUtils;
 
//# sourceMappingURL=MetadataUtils.js.map