code: function shallowCopy(t) {
    if (Array.isArray(t)) {
      return [...t];
    } else if (t && typeof t === 'object') {
      return Object.assign(new t.constructor(), t);
    }
    return t;
  }
docs: TODO support all mongodb update operators TODO invariant checks