Socket
Socket
Sign inDemoInstall

rfc6902

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rfc6902 - npm Package Compare versions

Comparing version 1.2.1 to 1.2.2

2

diff.js

@@ -165,3 +165,3 @@ import { compare } from './equal';

const padded_index = array_operation.index + 1 + padding;
const index_token = padded_index < input_length ? String(padded_index) : '-';
const index_token = padded_index < (input_length + padding) ? String(padded_index) : '-';
const operation = {

@@ -168,0 +168,0 @@ op: array_operation.op,

{
"name": "rfc6902",
"version": "1.2.1",
"version": "1.2.2",
"description": "Complete implementation of RFC6902 (patch and diff)",

@@ -5,0 +5,0 @@ "keywords": [

@@ -64,4 +64,6 @@ # rfc6902

Applying `json-patch` documents is way easier than generating them,
which might explain why there are more than five patch-applying RFC6902 implementations in NPM,
but only one (this one) that attempts to generate patch documents from two distinct objects (there's one that uses `Object.observe()`, which is cheating, and only works when you're the one making the changes).
which might explain why, when I started this project,
there were more than five patch-applying RFC6902 implementations in NPM,
but none for generating a patch from two distinct objects.
(There was one that used `Object.observe()`, which only works when you're the one making the changes, and only as long as `Object.observe()` hasn't been deprecated, which it has.)

@@ -68,0 +70,0 @@ So when comparing _your_ data objects, you'll want to ensure that the patches it generates meet your needs.

@@ -188,3 +188,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.rfc6902 = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

var padded_index = array_operation.index + 1 + padding;
var index_token = padded_index < input_length ? String(padded_index) : "-";
var index_token = padded_index < input_length + padding ? String(padded_index) : "-";
var operation = {

@@ -191,0 +191,0 @@ op: array_operation.op,

(function(p){"object"===typeof exports&&"undefined"!==typeof module?module.exports=p():"function"===typeof define&&define.amd?define([],p):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).rfc6902=p()})(function(){return function m(n,c,l){function g(a,b){if(!c[a]){if(!n[a]){var e="function"==typeof require&&require;if(!b&&e)return e(a,!0);if(k)return k(a,!0);e=Error("Cannot find module '"+a+"'");throw e.code="MODULE_NOT_FOUND",e;}e=c[a]={exports:{}};
n[a][0].call(e.exports,function(e){var b=n[a][1][e];return g(b?b:e)},e,e.exports,m,n,c,l)}return c[a].exports}for(var k="function"==typeof require&&require,h=0;h<l.length;h++)g(l[h]);return g}({1:[function(m,n,c){function l(a,e){var b={},d;for(d in a)b[d]=1;for(var f in e)delete b[f];return Object.keys(b)}function g(a){var e={};a.forEach(function(a){for(var b in a)e[b]=(e[b]||0)+1});a=a.length;for(var b in e)e[b]<a&&delete e[b];return Object.keys(e)}function k(a){return void 0===a?"undefined":null===
a?"null":Array.isArray(a)?"array":typeof a}function h(a,b,c){function h(e,d){var f=k[e+","+d];if(void 0===f){if(q(a[e-1],b[d-1]))f=h(e-1,d-1);else{f=[];if(0<e){var c=h(e-1,d);f.push({operations:c.operations.concat({op:"remove",index:e-1}),cost:c.cost+1})}0<d&&(c=h(e,d-1),f.push({operations:c.operations.concat({op:"add",index:e-1,value:b[d-1]}),cost:c.cost+1}));0<e&&0<d&&(c=h(e-1,d-1),f.push({operations:c.operations.concat({op:"replace",index:e-1,original:a[e-1],value:b[d-1]}),cost:c.cost+1}));f=f.sort(function(a,
e){return a.cost-e.cost})[0]}k[e+","+d]=f}return f}var k={"0,0":{operations:[],cost:0}},l=isNaN(a.length)||0>=a.length?0:a.length,g=isNaN(b.length)||0>=b.length?0:b.length,g=h(l,g).operations.reduce(function(a,b){var h=d(a,2),k=h[0],h=h[1];if("add"===b.op){var g=b.index+1+h,g={op:b.op,path:c.add(g<l?String(g):"-").toString(),value:b.value};return[k.concat(g),h+1]}if("remove"===b.op)return g={op:b.op,path:c.add(String(b.index+h)).toString()},[k.concat(g),h-1];g=c.add(String(b.index+h));g=e(b.original,
e){return a.cost-e.cost})[0]}k[e+","+d]=f}return f}var k={"0,0":{operations:[],cost:0}},l=isNaN(a.length)||0>=a.length?0:a.length,g=isNaN(b.length)||0>=b.length?0:b.length,g=h(l,g).operations.reduce(function(a,b){var h=d(a,2),k=h[0],h=h[1];if("add"===b.op){var g=b.index+1+h,g={op:b.op,path:c.add(g<l+h?String(g):"-").toString(),value:b.value};return[k.concat(g),h+1]}if("remove"===b.op)return g={op:b.op,path:c.add(String(b.index+h)).toString()},[k.concat(g),h-1];g=c.add(String(b.index+h));g=e(b.original,
b.value,g);return[k.concat.apply(k,f(g)),h]},[[],0]);return d(g,2)[0]}function a(a,b,d){var c=[];l(a,b).forEach(function(a){c.push({op:"remove",path:d.add(a).toString()})});l(b,a).forEach(function(a){c.push({op:"add",path:d.add(a).toString(),value:b[a]})});g([a,b]).forEach(function(h){c.push.apply(c,f(e(a[h],b[h],d.add(h))))});return c}function b(a,b,e){return q(a,b)?[]:[{op:"replace",path:e.toString(),value:b}]}function e(e,d,f){var c=k(e),g=k(d);return"array"==c&&"array"==g?h(e,d,f):"object"==c&&

@@ -6,0 +6,0 @@ "object"==g?a(e,d,f):b(e,d,f)}var d=function(a,e){if(Array.isArray(a))return a;if(Symbol.iterator in Object(a)){for(var b=[],d=a[Symbol.iterator](),f;!(f=d.next()).done&&(b.push(f.value),!e||b.length!==e););return b}throw new TypeError("Invalid attempt to destructure non-iterable instance");},f=function(a){if(Array.isArray(a)){for(var b=0,e=Array(a.length);b<a.length;b++)e[b]=a[b];return e}return Array.from(a)};c.subtract=l;c.intersection=g;c.objectType=k;c.diffArrays=h;c.diffObjects=a;c.diffValues=

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc