src/patch.js
function calc_patches_any(context, patches, path, value, tracker) {
	const valueType = value_type(value);
	if (valueType == ValueTypes.OBJECT) {
		if (value.propertyIsEnumerable("_")) {
			if (value["_"] == "$ref") {
				return patches.push([path, [PatchTypes.REFERENCE, value.path]]);
			}
			throw new Error("Underscore property is reserved");
		}

		calc_patches_object(context, patches, path, value, tracker);
	} else if (valueType == ValueTypes.ARRAY) {
		calc_patches_array(context, patches, path, value, tracker);
	} else {
		patches.push([path, value]);
	}
}
function calc_patches_any(context, patches, path, value, tracker) {
	const valueType = value_type(value);
	if (valueType == ValueTypes.OBJECT) {
		if (value.propertyIsEnumerable("_")) {
			if (value["_"] == "$ref") {
				return patches.push([path, [PatchTypes.REFERENCE, value.path]]);
			}
			throw new Error("Underscore property is reserved");
		}

		calc_patches_object(context, patches, path, value, tracker);
	} else if (valueType == ValueTypes.ARRAY) {
		calc_patches_array(context, patches, path, value, tracker);
	} else {
		patches.push([path, value]);
	}
}
function calc_patches_any ( context , patches , path , value , tracker ) { const valueType = value_type ( value ) ; if ( valueType == ValueTypes . OBJECT ) { if ( value . propertyIsEnumerable ( "_" ) ) { if ( value [ "_" ] == "$ref" ) { return patches . push ( [ path , [ PatchTypes . REFERENCE , value . path ] ] ) ; } throw new Error ( "Underscore property is reserved" ) ; } calc_patches_object ( context , patches , path , value , tracker ) ; } else if ( valueType == ValueTypes . ARRAY ) { calc_patches_array ( context , patches , path , value , tracker ) ; } else { patches . push ( [ path , value ] ) ; } }
Given path and value , calculate patches
@param {*} context
@param {*} patches
@param {*} path
@param {*} value
@param {*} tracker
Given path and value calculate patches