

import deepAssign from "./DeepAssign";
import {JsObject} from "./DeepAssign";

export class HasDescriptor<Desc extends JsObject , UDesc extends JsObject>{

    constructor(protected desc : Desc){}

    updateInPlace(updateDescriptor : UDesc) : this {
        this.desc = Object.assign(this.desc, updateDescriptor) as Desc;
        return this;
    }

    copy(updateDescriptor : UDesc) : this {
        const newDescriptor = deepAssign(this.desc, updateDescriptor);
        const constructWith = this.constructor;
        return constructWith(newDescriptor) as this;
    }
}