UNPKG

@n1ru4l/graphql-live-query-patch-jsondiffpatch

Version:

[![npm version](https://img.shields.io/npm/v/@n1ru4l/graphql-live-query-patch-jsondiffpatch.svg)](https://www.npmjs.com/package/@n1ru4l/graphql-live-query-patch-jsondiffpatch) [![npm downloads](https://img.shields.io/npm/dm/@n1ru4l/graphql-live-query-patc

36 lines (27 loc) 1.37 kB
'use strict'; 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