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

28 lines (21 loc) 1.07 kB
import { create } from 'jsondiffpatch'; import { createApplyLiveQueryPatch, noDiffSymbol, createApplyLiveQueryPatchGenerator, createLiveQueryPatchGenerator } from '@n1ru4l/graphql-live-query-patch'; const applyJSONDiffPatch = (previous, patch) => { const patcher = create(); // @ts-ignore const result = patcher.patch(previous, patch); return result; }; const applyLiveQueryJSONDiffPatch = createApplyLiveQueryPatch(applyJSONDiffPatch); const generateJSONDiffPatch = (previous, current) => { const patcher = create(); const patch = patcher.diff(previous, current); if (patch === undefined) { return noDiffSymbol; } return patch; }; const applyLiveQueryJSONDiffPatchGenerator = createApplyLiveQueryPatchGenerator(generateJSONDiffPatch); const liveQueryJSONDiffPatchGenerator = createLiveQueryPatchGenerator(generateJSONDiffPatch); export { applyJSONDiffPatch, applyLiveQueryJSONDiffPatch, applyLiveQueryJSONDiffPatchGenerator, generateJSONDiffPatch, liveQueryJSONDiffPatchGenerator }; //# sourceMappingURL=index.esm.js.map