lib/index.js
/*
	* params: options.userOld, options.userNew, options.db, options.ignore

	* options.userOld: the old version of the object which will be updated
	* options.userNew: the new version of the object with changes which will be used to patch the old version
	* options.db: the version of the old document as it exists in the database
	* options.ignore: a regex which can be provided to skip patching specific patch paths

	* Compares the flattened old and new objects, generates a diff, applies the diff
	* and unflattens the result of applying the diff to the db/original object.
	 
	* Returns a patched object.
	*/
options.userOld, options.userNew, options.db, options.ignore
options.userOld: the old version of the object which will be updated
options.userNew: the new version of the object with changes which will be used to patch the old version
options.db: the version of the old document as it exists in the database
options.ignore: a regex which can be provided to skip patching specific patch paths

Compares the flattened old and new objects, generates a diff, applies the diff
and unflattens the result of applying the diff to the db/original object.

Returns a patched object.
options . userOld options . userNew options . db options . ignore options . userOld : the old version of the object which will be updated options . userNew : the new version of the object with changes which will be used to patch the old version options . db : the version of the old document as it exists in the database options . ignore : a regex which can be provided to skip patching specific patch paths Compares the flattened old and new objects generates a diff applies the diff and unflattens the result of applying the diff to the db / original object . Returns a patched object .
apply(options) {
		var userOld = options.userOld
		var userNew = options.userNew
		var db      = options.db || userOld
		var ignore  = options.ignore
		var userDiff = this.compare({
			oldObj: hoek.clone(userOld), 
			newObj: hoek.clone(userNew) 
		})
		if(ignore){
			userDiff = userDiff.filter(patch => {
				return !patch.path.match(ignore)
			})
		}
		var flatDb = this.flatten({
			obj: hoek.clone(db)
		})
		jsonPatch.apply(flatDb, userDiff)
		return this.unflatten({
			obj: flatDb
		})
	}
apply ( options ) { var userOld = options . userOld var userNew = options . userNew var db = options . db || userOld var ignore = options . ignore var userDiff = this . compare ( { oldObj : hoek . clone ( userOld ) , newObj : hoek . clone ( userNew ) } ) if ( ignore ) { userDiff = userDiff . filter ( patch => { return ! patch . path . match ( ignore ) } ) } var flatDb = this . flatten ( { obj : hoek . clone ( db ) } ) jsonPatch . apply ( flatDb , userDiff ) return this . unflatten ( { obj : flatDb } ) }
params: options.userOld, options.userNew, options.db, options.ignore
 options.userOld: the old version of the object which will be updated
 options.userNew: the new version of the object with changes which will be used to patch the old version
 options.db: the version of the old document as it exists in the database
 options.ignore: a regex which can be provided to skip patching specific patch paths
params : options . userOld options . userNew options . db options . ignore options . userOld : the old version of the object which will be updated options . userNew : the new version of the object with changes which will be used to patch the old version options . db : the version of the old document as it exists in the database options . ignore : a regex which can be provided to skip patching specific patch paths