class Holder {
constructor(init) {
Holder.internalAssign(this, init);
}
static has(instance, property) {
return Object.prototype.hasOwnProperty.call(instance, property);
}
static internalAssign(target, source) {
if (Holder.has(source, "a"))
target.a = source.a;
if (Holder.has(source, "b"))
target.b = source.b;
if (Holder.has(source, "c"))
target.c = source.c;
}
clone() {
return new Holder(this);
}
cloneWith(props) {
const cloned = this.clone();
Holder.internalAssign(cloned, props);
return cloned;
}
cloneWith2(props) {
const cloned = this.clone();
Object.assign(this, props);
return cloned;
}
mutate(mutation) {
const cloned = this.clone();
mutation(cloned);
return cloned;
}
}
var initHolder = new Holder({
a: "value of a",
b: "value of b",
c: 1
});