/** Create a copy of an object by merging it with a subset of its properties. */ export function merge(obj: T, subset: Pick): T { const copy = Object.assign({}, obj); for (const k in subset) { if (subset[k]) { copy[k] = subset[k]; } } return copy; }