lib/record-patch-builder.js
function buildMerge(recordTypes, recordTypeName, mergePatch) {

	// only object merge patches are supported
	if (((typeof mergePatch) !== 'object') || (mergePatch === null))
		throw new common.X2SyntaxError('Merge patch must be an object.');

	// build JSON patch
	const jsonPatch = new Array();
	buildMergeLevel('', mergePatch, jsonPatch);

	// build and return the record patch
	return build(recordTypes, recordTypeName, jsonPatch);
}
function buildMerge(recordTypes, recordTypeName, mergePatch) {

	// only object merge patches are supported
	if (((typeof mergePatch) !== 'object') || (mergePatch === null))
		throw new common.X2SyntaxError('Merge patch must be an object.');

	// build JSON patch
	const jsonPatch = new Array();
	buildMergeLevel('', mergePatch, jsonPatch);

	// build and return the record patch
	return build(recordTypes, recordTypeName, jsonPatch);
}
function buildMerge ( recordTypes , recordTypeName , mergePatch ) { // only object merge patches are supported if ( ( ( typeof mergePatch ) !== 'object' ) || ( mergePatch === null ) ) throw new common . X2SyntaxError ( 'Merge patch must be an object.' ) ; // build JSON patch const jsonPatch = new Array ( ) ; buildMergeLevel ( '' , mergePatch , jsonPatch ) ; // build and return the record patch return build ( recordTypes , recordTypeName , jsonPatch ) ; }
Build record patch object from Merge Patch specification.

@function module:x2node-patches.buildMerge
@param {module:x2node-records~RecordTypesLibrary} recordTypes Record types
library.
@param {string} recordTypeName Name of the record type, against records of
which the patch will be applied.
@param {Object} mergePatch RFC 7396 merge patch specification.
@returns {module:x2node-patches~RecordPatch} The patch object that can be used
to apply the patch to records.
@throws {module:x2node-common.X2UsageError} If the provided record type name
is invalid.
@throws {module:x2node-common.X2SyntaxError} If the provided patch
specification is invalid.
Build record patch object from Merge Patch specification .