Update the immutable object using JSON Patch
operations.

@param {object} object
@param {array|object} ops
@returns {object}
973313
function patch(object, ops) {
  ops = Array.isArray(ops) ? ops : [ops];
  object = ops.reduce(function (ob, op) {
    op = (0, _parse2['default'])(op, ob);
    return operators[op.op].call(ob, op);
  }, object);
  // Re-convert the returned object into an
  // immutable structure, in case the entire
  // object was replaced with a POJO
  return _immutable2['default'].fromJS(object);
}
1006852
function do_update(self, ObjType, obj, orig_data) {
	return nr_fcall("nopg:do_update", function() {
		var query, params, data, where = {};

		if(obj.$id) {
			where.$id = obj.$id;
		} else if(obj.$name) {
			where.$name = obj.$name;
		} else {
			throw new TypeError("Cannot know what to update!");
		}

		if(orig_data === undefined) {
			// FIXME: Check that `obj` is an ORM object
			data = obj.valueOf();
		} else {
			data = (new ObjType(obj)).update(orig_data).valueOf();
		}

		//debug.log('data = ', data);

		// Select only keys that start with $
		var keys = ARRAY(ObjType.meta.keys)
			// Remove leading '$' character from keys
			.filter(first_letter_is_dollar)
			.map( parse_keyword_name )
			// Ignore keys that aren't going to be changed
			.filter(function(key) {
				return data.hasOwnProperty(key);
			// Ignore keys that were not changed
			}).filter(function(key) {
				return json_cmp(data[key], obj['$'+key]) ? false : true;
			});

		//debug.log('keys = ', keys.valueOf());

		// Return with the current object if there is no keys to update
		if(keys.valueOf().length === 0) {
			return do_select(self, ObjType, where);
		}

		// FIXME: Implement binary content support
		query = "UPDATE " + (ObjType.meta.table) + " SET "+ keys.map(function(k, i) { return k + ' = $' + (i+1); }).join(', ') +" WHERE ";

		if(where.$id) {
			query += "id = $"+ (keys.valueOf().length+1);
		} else if(where.$name) {
			query += "name = $"+ (keys.valueOf().length+1);
		} else {
			throw new TypeError("Cannot know what to update!");
		}

		query += " RETURNING *";

		params = keys.map(function(key) {
			return data[key];
		}).valueOf();

		if(where.$id) {
			params.push(where.$id);
		} else if(where.$name){
			params.push(where.$name);
		}

		return do_query(self, query, params);
	});
}
533574
@SuppressWarnings("unchecked")
    public void setOps(final DBObject ops) {
        this.ops = (Map<String, Map<String, Object>>) ops;
    }
707516
protected void update(JSONObject data)
    {
        api.get().getClient().send(new JSONObject()
            .put("d", data)
            .put("op", WebSocketCode.PRESENCE).toString());
    }
836089
public void addOperations(final Map<MemcachedNode, Operation> ops) {
    for (Map.Entry<MemcachedNode, Operation> me : ops.entrySet()) {
      addOperation(me.getKey(), me.getValue());
    }
  }
21042
def get_patch_op(self, keypath, value, op='replace'):
        
        if isinstance(value, bool):
            value = str(value).lower()
        return {'op': op, 'path': '/*/*/{}'.format(keypath), 'value': value}
7115
def json_expand(json_op):
    
    if type(json_op) == dict and 'json' in json_op:
        return update_in(json_op, ['json'], safe_json_loads)

    return json_op
455784
function __toJSONSafe(obj, replacer) {
  if (obj !== Object(obj)) return obj; // primitive value
  if (obj._$visited) return undefined;
  replacer = replacer || __safeReplacer;
  if (obj.toJSON) {
    var newObj = obj.toJSON();
    if (newObj !== Object(newObj)) return newObj; // primitive value
    if (newObj !== obj) return __toJSONSafe(newObj, replacer);
    // toJSON returned the object unchanged.
    obj = newObj;
  }
  obj._$visited = true;
  var result;
  if (obj instanceof Array) {
    result = obj.map(function (o) {
      return __toJSONSafe(o, replacer);
    });
  } else if (typeof (obj) === "function") {
    result = undefined;
  } else {
    result = {};
    for (var prop in obj) {
      if (prop === "_$visited") continue;
      var val = obj[prop];
      if (replacer) {
        val = replacer(prop, val);
        if (val === undefined) continue;
      }
      val = __toJSONSafe(val, replacer);
      if (val === undefined) continue;
      result[prop] = val;
    }
  }
  delete obj._$visited;
  return result;
}
88328
function compile(patch) {
  var code = "";
  patch.forEach(function(op) {
    var o = "";
    switch (op.op) {
      case "remove":
        o += "delete " + pathToStatement(op.path);
        break;
      case "add":
        o += pathToStatement(op.path) + " = " + JSON.stringify(op.value);
        break;
      case "replace":
        o += pathToStatement(op.path) + " = " + JSON.stringify(op.value);
        break;
      case "move":
        var from = pathToStatement(op.from);
        o += pathToStatement(op.path) + " = " + from + ";\n";
        o += "delete " + from;
        break;
      case "copy":
        o += pathToStatement(op.path) + " = " + from;
        break;
      case "test":
        o +=
          "if (!oo.equal(" +
          pathToStatement(op.path) +
          ", " +
          JSON.stringify(op.value) +
          ") throw new Error()";
        break;
    }
    code += o + ";\n";
  });
  return code;
}
542983
void update(JsonObject jsonObject) {
        for (JsonObject.Member member : jsonObject) {
            if (member.getValue().isNull()) {
                continue;
            }

            this.parseJSONMember(member);
        }

        this.clearPendingChanges();
    }
662841
public static <T> T updateObject(T object)
    {
        return SqlClosure.sqlExecute(c -> OrmElf.updateObject(c, object));
    }
405594
function makeImmutableObject(obj) {
    if (!globalConfig.use_static) {
      addPropertyTo(obj, "merge", merge);
      addPropertyTo(obj, "replace", objectReplace);
      addPropertyTo(obj, "without", without);
      addPropertyTo(obj, "asMutable", asMutableObject);
      addPropertyTo(obj, "set", objectSet);
      addPropertyTo(obj, "setIn", objectSetIn);
      addPropertyTo(obj, "update", update);
      addPropertyTo(obj, "updateIn", updateIn);
      addPropertyTo(obj, "getIn", getIn);
    }

    return makeImmutable(obj, mutatingObjectMethods);
  }
310731
function patch(obj, method, optionsArgIndex) {
    var orig = obj[method];
    if (!orig) return;
    obj[method] = function () {
      var opts = arguments[optionsArgIndex];
      var file = null;
      if (opts) {
        file = typeof opts == 'string' ? opts : opts.filename;
      }
      if (file) callback(file);
      return orig.apply(this, arguments);
    };
  }
1307879
def _update_dict(self, initial: JSON, other: Mapping) -> JSON:
        
        for key, value in other.items():
            if isinstance(value, collections.Mapping):
                r = self._update_dict(initial.get(key, {}), value)
                initial[key] = r
            else:
                initial[key] = other[key]
        return initial
452390
function checkForAtomicOperators(update) {
  const keys = Object.keys(update);

  // same errors as the server would give for update doc lacking atomic operators
  if (keys.length === 0) {
    return toError('The update operation document must contain at least one atomic operator.');
  }

  if (keys[0][0] !== '$') {
    return toError('the update operation document must contain atomic operators.');
  }
}
96553
function _immutable (obj, seen) {
    if (seen.indexOf(obj) === -1) {
        seen.push(Object.freeze(obj));

        forEach(Object.getOwnPropertyNames(obj), function (key) {
            var value = obj[key];

            if (typeof value === "object" && !isNull(value)) {
                _immutable(value, seen);
            }
        });
    }

    return obj;
}
1198165
function JSONTransform(options) {
  // allow use without new
  if (!(this instanceof JSONTransform)) {
    return new JSONTransform(options);
  }

  this.isFirst = true;

  if (options.objectMode !== true) {
    // assume that if they're not giving us objects, this will be an array of strings
    this.isArray = true;
  } else {
    // otherwise they either tell us, or we're assuming they want the smallest form of this data, which is an object.
    this.isArray = options.isArray || false;
  }

  this.options = options;
  this.keyProperty = options.keyProperty || 'key';
  this.valueProperty = options.valueProperty || 'value';

  // init Transform
  Transform.call(this, options);
}