Comparing version 5.0.0 to 5.0.1
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.diffAny = exports.diffObjects = exports.diffArrays = exports.intersection = exports.subtract = exports.isDestructive = void 0; | ||
var pointer_1 = require("./pointer"); // we only need this for type inference | ||
var util_1 = require("./util"); | ||
@@ -136,3 +135,3 @@ function isDestructive(_a) { | ||
// TODO: this !diff(...).length usage could/should be lazy | ||
if (i > 0 && j > 0 && !diff(input[i - 1], output[j - 1], new pointer_1.Pointer()).length) { | ||
if (i > 0 && j > 0 && !diff(input[i - 1], output[j - 1], ptr.add(String(i - 1))).length) { | ||
// equal (no operations => no cost) | ||
@@ -139,0 +138,0 @@ memoized = dist(i - 1, j - 1); |
@@ -293,3 +293,3 @@ (function (global, factory) { | ||
// TODO: this !diff(...).length usage could/should be lazy | ||
if (i > 0 && j > 0 && !diff(input[i - 1], output[j - 1], new Pointer()).length) { | ||
if (i > 0 && j > 0 && !diff(input[i - 1], output[j - 1], ptr.add(String(i - 1))).length) { | ||
// equal (no operations => no cost) | ||
@@ -296,0 +296,0 @@ memoized = dist(i - 1, j - 1); |
(function(p,r){"object"===typeof exports&&"undefined"!==typeof module?r(exports):"function"===typeof define&&define.amd?define(["exports"],r):(p="undefined"!==typeof globalThis?globalThis:p||self,r(p.rfc6902={}))})(this,function(p){function r(a){return a.replace(/~1/g,"/").replace(/~0/g,"~")}function E(a){return a.replace(/~/g,"~0").replace(/\//g,"~1")}function z(a){return void 0===a?"undefined":null===a?"null":Array.isArray(a)?"array":typeof a}function v(a){if(null==a||"object"!=typeof a)return a; | ||
if(a.constructor==Array){var b=a.length,c=Array(b);for(let d=0;d<b;d++)c[d]=v(a[d]);return c}if(a.constructor==Date)return new Date(+a);b={};for(c in a)w.call(a,c)&&(b[c]=v(a[c]));return b}function F({op:a}){return"remove"===a||"replace"===a||"copy"===a||"move"===a}function A(a,b){const c={};for(const d in a)w.call(a,d)&&void 0!==a[d]&&(c[d]=1);for(const d in b)w.call(b,d)&&void 0!==b[d]&&delete c[d];return Object.keys(c)}function G(a){const b=a.length,c={};for(let d=0;d<b;d++){const e=a[d];for(const f in e)w.call(e, | ||
f)&&void 0!==e[f]&&(c[f]=(c[f]||0)+1)}for(const d in c)c[d]<b&&delete c[d];return Object.keys(c)}function x(a,b){return{operations:a.operations.concat(b),cost:a.cost+1}}function H(a,b,c,d=q){function e(k,g){const h=`${k},${g}`;var l=f[h];if(void 0===l){if(0<k&&0<g&&!d(a[k-1],b[g-1],new m).length)l=e(k-1,g-1);else{l=[];if(0<k){var t=e(k-1,g);l.push(x(t,{op:"remove",index:k-1}))}0<g&&(t=e(k,g-1),l.push(x(t,{op:"add",index:k-1,value:b[g-1]})));0<k&&0<g&&(t=e(k-1,g-1),l.push(x(t,{op:"replace",index:k- | ||
1,original:a[k-1],value:b[g-1]})));l=l.sort((I,J)=>I.cost-J.cost)[0]}f[h]=l}return l}const f={"0,0":{operations:[],cost:0}},B=isNaN(a.length)||0>=a.length?0:a.length;var u=isNaN(b.length)||0>=b.length?0:b.length;u=e(B,u).operations;[u]=u.reduce(([k,g],h)=>{if("add"===h.op){var l=h.index+1+g;h={op:h.op,path:c.add(l<B+g?String(l):"-").toString(),value:h.value};return[k.concat(h),g+1]}if("remove"===h.op)return h={op:h.op,path:c.add(String(h.index+g)).toString()},[k.concat(h),g-1];l=c.add(String(h.index+ | ||
f)&&void 0!==e[f]&&(c[f]=(c[f]||0)+1)}for(const d in c)c[d]<b&&delete c[d];return Object.keys(c)}function x(a,b){return{operations:a.operations.concat(b),cost:a.cost+1}}function H(a,b,c,d=q){function e(k,g){const h=`${k},${g}`;var l=f[h];if(void 0===l){if(0<k&&0<g&&!d(a[k-1],b[g-1],c.add(String(k-1))).length)l=e(k-1,g-1);else{l=[];if(0<k){var t=e(k-1,g);l.push(x(t,{op:"remove",index:k-1}))}0<g&&(t=e(k,g-1),l.push(x(t,{op:"add",index:k-1,value:b[g-1]})));0<k&&0<g&&(t=e(k-1,g-1),l.push(x(t,{op:"replace", | ||
index:k-1,original:a[k-1],value:b[g-1]})));l=l.sort((I,J)=>I.cost-J.cost)[0]}f[h]=l}return l}const f={"0,0":{operations:[],cost:0}},B=isNaN(a.length)||0>=a.length?0:a.length;var u=isNaN(b.length)||0>=b.length?0:b.length;u=e(B,u).operations;[u]=u.reduce(([k,g],h)=>{if("add"===h.op){var l=h.index+1+g;h={op:h.op,path:c.add(l<B+g?String(l):"-").toString(),value:h.value};return[k.concat(h),g+1]}if("remove"===h.op)return h={op:h.op,path:c.add(String(h.index+g)).toString()},[k.concat(h),g-1];l=c.add(String(h.index+ | ||
g));h=d(h.original,h.value,l);return[k.concat(...h),g]},[[],0]);return u}function K(a,b,c,d=q){const e=[];A(a,b).forEach(f=>{e.push({op:"remove",path:c.add(f).toString()})});A(b,a).forEach(f=>{e.push({op:"add",path:c.add(f).toString(),value:b[f]})});G([a,b]).forEach(f=>{e.push(...d(a[f],b[f],c.add(f)))});return e}function q(a,b,c,d=q){if(a===b)return[];const e=z(a),f=z(b);return"array"==e&&"array"==f?H(a,b,c,d):"object"==e&&"object"==f?K(a,b,c,d):[{op:"replace",path:c.toString(),value:b}]}function y(a, | ||
@@ -6,0 +6,0 @@ b,c){Array.isArray(a)?"-"==b?a.push(c):(b=parseInt(b,10),a.splice(b,0,c)):a[b]=c}function C(a,b){Array.isArray(a)?(b=parseInt(b,10),a.splice(b,1)):delete a[b]}function L(a,b){a=m.fromJSON(b.path).evaluate(a);if(null===a.parent)return new n(b.path);if(Array.isArray(a.parent)){if(parseInt(a.key,10)>=a.parent.length)return new n(b.path)}else if(void 0===a.value)return new n(b.path);a.parent[a.key]=b.value;return null}function M(a,b){switch(b.op){case "add":return a=m.fromJSON(b.path).evaluate(a),void 0=== |
{ | ||
"name": "rfc6902", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "Complete implementation of RFC6902 (patch and diff)", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
91759
1754