@n1ru4l/graphql-live-query-patch-jsondiffpatch
Version:
[](https://www.npmjs.com/package/@n1ru4l/graphql-live-query-patch-jsondiffpatch) [ • 1.37 kB
JavaScript
;
Object.defineProperty(exports, '__esModule', { value: true });
const jsondiffpatch = require('jsondiffpatch');
const graphqlLiveQueryPatch = require('@n1ru4l/graphql-live-query-patch');
const applyJSONDiffPatch = (previous, patch) => {
const patcher = jsondiffpatch.create();
// @ts-ignore
const result = patcher.patch(previous, patch);
return result;
};
const applyLiveQueryJSONDiffPatch = graphqlLiveQueryPatch.createApplyLiveQueryPatch(applyJSONDiffPatch);
const generateJSONDiffPatch = (previous, current) => {
const patcher = jsondiffpatch.create();
const patch = patcher.diff(previous, current);
if (patch === undefined) {
return graphqlLiveQueryPatch.noDiffSymbol;
}
return patch;
};
const applyLiveQueryJSONDiffPatchGenerator = graphqlLiveQueryPatch.createApplyLiveQueryPatchGenerator(generateJSONDiffPatch);
const liveQueryJSONDiffPatchGenerator = graphqlLiveQueryPatch.createLiveQueryPatchGenerator(generateJSONDiffPatch);
exports.applyJSONDiffPatch = applyJSONDiffPatch;
exports.applyLiveQueryJSONDiffPatch = applyLiveQueryJSONDiffPatch;
exports.applyLiveQueryJSONDiffPatchGenerator = applyLiveQueryJSONDiffPatchGenerator;
exports.generateJSONDiffPatch = generateJSONDiffPatch;
exports.liveQueryJSONDiffPatchGenerator = liveQueryJSONDiffPatchGenerator;
//# sourceMappingURL=index.cjs.js.map