How to use the fast-json-patch.apply function in fast-json-patch

To help you get started, we’ve selected a few fast-json-patch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yahoo / elide-js / lib / datastores / memorydatastore.js View on Github external
this._updateSimpleProps(model, toCreate, state);

      // we link objects by applying patches after we determine that the operation
      // will succeed, so we need to create a copy so that we can insert the unlinked
      // version into our store and return the linked version to the client
      toReturn = clone(toCreate);

      [
        relationPatches,
        willReject,
        withReason
      ] = this._updateLinkProperties(model, toReturn, state, true, 'create');

      if (!willReject) {
        this._setData(model, toCreate);
        jsonpatch.apply(this._data, relationPatches);
      } else {
        return this._promise.reject(new Error(withReason));
      }
    }

    return this._promise.resolve(toReturn);
  }
github rjanicek / bos / scripts / bos-core.js View on Github external
parser.on('root', function (patches) {
			if (!jsonpatch.apply(object, patches)) {
				stream.unpipe();
				returnErrorAndObject('error applying patches ' + me.stringifyPatches(patches));
			}
		});
		stream.on('error', function (error) {
github microsoft / refreshing-config / index.js View on Github external
return this.refreshIfNeeded().then(() => {
      const newValues = extend(true, {}, this.values);
      patch.apply(newValues, patches);
      const affected = this._getAffectedProperties(patches);
      const oldKeys = Object.getOwnPropertyNames(this.values);
      return Q.all(affected.map(key => {
        if (newValues[key] !== undefined) {
          return this.set(key, newValues[key]);
        }
        if (oldKeys.includes(key)) {
          return this.delete(key);
        }
        return Q();
      }));
    });
  }
github WebediaGaming / react-nexus / dist / R.utils.js View on Github external
patch: function patch(prev, next) {
            return jsonpatch.apply(prev, next);
        },
        /**
github rjanicek / bos / scripts / index.js View on Github external
parser.on('root', function (patches) {
			if (!jsonpatch.apply(object, patches)) {
				stream.unpipe();
				returnErrorAndObject('error applying patches ' + stringifyPatches(patches));
			}
		});
		stream.on('error', function (error) {