constructor()

in src/canvastools/ts/CanvasTools/Core/TagsDescriptor.ts [74:104]


    constructor(arg1?: Tag|Tag[], arg2: Tag[] = []) {
        // empty TagsDescriptor
        if (arg1 === undefined) {
            this.primaryTag = null;
            this.allTags = [];
        } else if (arg1 instanceof Tag) {
            // arg1 = primaryTag, arg2 = secondaryTag
            if (arg2 instanceof Array) {
                this.allTags = new Array<Tag>(arg1, ...arg2);
            } else {
                this.allTags = [arg1];
            }
            this.primaryTag = arg1;
        } else if (arg1 instanceof Array) {
            // arg1 = tags, ignore arg2
            this.allTags = arg1.map((tag) => tag.copy());
            if (arg1.length > 0) {
                this.primaryTag = arg1[0];
            } else {
                this.primaryTag = null;
            }
        } else if (arg1 === null) {
            // arg1 = null | undefined, ignore
            if (arg2 instanceof Array) {
                this.allTags = arg2.map((tag) => tag.copy());
            } else {
                this.allTags = [];
            }
            this.primaryTag = null;
        }
    }