immutable-json-patch
Advanced tools
Comparing version 5.1.2 to 5.1.3
@@ -22,3 +22,12 @@ "use strict"; | ||
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } | ||
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); } /** | ||
* Immutability helpers | ||
* | ||
* inspiration: | ||
* | ||
* https://www.npmjs.com/package/seamless-immutable | ||
* https://www.npmjs.com/package/ih | ||
* https://www.npmjs.com/package/mutatis | ||
* https://github.com/mariocasciaro/object-path-immutable | ||
*/ | ||
/** | ||
@@ -25,0 +34,0 @@ * Shallow clone of an Object, Array, or value |
@@ -16,3 +16,3 @@ "use strict"; | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
/** | ||
@@ -19,0 +19,0 @@ * Create the inverse of a set of json patch operations |
@@ -6,3 +6,3 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
import { existsIn, getIn } from './immutabilityHelpers.js'; | ||
@@ -9,0 +9,0 @@ import { immutableJSONPatch, isArrayItem, parseFrom, parsePath } from './immutableJSONPatch.js'; |
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); } | ||
/** | ||
* Test deep equality of two JSON values, objects, or arrays | ||
*/ | ||
// TODO: write unit tests | ||
*/ // TODO: write unit tests | ||
export function isEqual(a, b) { | ||
@@ -7,0 +6,0 @@ // FIXME: this function will return false for two objects with the same keys |
@@ -0,0 +0,0 @@ import type { JSONArray, JSONValue, JSONObject, JSONPath } from './types'; |
@@ -0,0 +0,0 @@ import { JSONArray, JSONValue, JSONObject, JSONPatchDocument, JSONPatchOperation, JSONPatchOptions, JSONPath, JSONPointer } from './types'; |
@@ -0,0 +0,0 @@ export { immutableJSONPatch, parsePath, parseFrom } from './immutableJSONPatch.js'; |
@@ -0,0 +0,0 @@ import type { JSONPath, JSONPointer } from './types'; |
@@ -0,0 +0,0 @@ import type { JSONValue, JSONPatchDocument, RevertJSONPatchOptions } from './types.js'; |
@@ -0,0 +0,0 @@ import { JSONArray, JSONObject, JSONPatchAdd, JSONPatchCopy, JSONPatchMove, JSONPatchOperation, JSONPatchRemove, JSONPatchReplace, JSONPatchTest } from './types'; |
@@ -0,0 +0,0 @@ export type JSONPointer = string; |
@@ -0,0 +0,0 @@ import type { JSONValue } from './types'; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
typeof define === 'function' && define.amd ? define(['exports'], factory) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["'immutableJSONPatch'"] = {})); | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.immutableJSONPatch = {})); | ||
})(this, (function (exports) { 'use strict'; | ||
@@ -55,4 +55,3 @@ | ||
* Test deep equality of two JSON values, objects, or arrays | ||
*/ | ||
// TODO: write unit tests | ||
*/ // TODO: write unit tests | ||
function isEqual(a, b) { | ||
@@ -597,3 +596,3 @@ // FIXME: this function will return false for two objects with the same keys | ||
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } | ||
@@ -600,0 +599,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self)["'immutableJSONPatch'"]={})}(this,function(t){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function y(t){return Array.isArray(t)}function h(t){return null!==t&&"object"===r(t)&&t.constructor===Object}function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,r){return t===r}function n(t){return t.slice(0,t.length-1)}function o(t){return"object"===e(t)&&null!==t}function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function c(r,t){var e,n=Object.keys(r);return Object.getOwnPropertySymbols&&(e=Object.getOwnPropertySymbols(r),t&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),n.push.apply(n,e)),n}function f(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?c(Object(o),!0).forEach(function(t){var r,e;r=n,e=o[t=t],(t=function(t){t=function(t,r){if("object"!==i(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===r?String:Number)(t);e=e.call(t,r||"default");if("object"!==i(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===i(t)?t:String(t)}(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):c(Object(o)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(o,t))})}return n}function m(r){var e,n;return y(r)?(e=r.slice(),Object.getOwnPropertySymbols(r).forEach(function(t){e[t]=r[t]}),e):h(r)?(n=f({},r),Object.getOwnPropertySymbols(r).forEach(function(t){n[t]=r[t]}),n):r}function a(t,r,e){return t[r]===e?t:((t=m(t))[r]=e,t)}function d(t,r){for(var e=t,n=0;n<r.length;)e=h(e)?e[r[n]]:y(e)?e[parseInt(r[n])]:void 0,n++;return e}function v(t,r,e){var n=3<arguments.length&&void 0!==arguments[3]&&arguments[3];if(0===r.length)return e;var o=r[0],r=v(t?t[o]:void 0,r.slice(1),e,n);if(h(t)||y(t))return a(t,o,r);if(n)return(e=p.test(o)?[]:{})[o]=r,e;throw new Error("Path does not exist")}var p=/^\d+$/;function l(t,r,e){if(0===r.length)return e(t);var n;if(o(t))return a(t,n=r[0],l(t[n],r.slice(1),e));throw new Error("Path doesn't exist")}function g(t,r){if(0===r.length)return t;var e,n;if(o(t))return 1===r.length?(n=r[0])in t?(y(e=m(t))&&e.splice(parseInt(n),1),h(e)&&delete e[n],e):t:a(t,n=r[0],g(t[n],r.slice(1)));throw new Error("Path does not exist")}function O(t,r,e){var n=r.slice(0,r.length-1),o=r[r.length-1];return l(t,n,function(t){if(Array.isArray(t))return(t=m(t)).splice(parseInt(o),0,e),t;throw new TypeError("Array expected at path "+JSON.stringify(n))})}function S(t,r){return void 0!==t&&(0===r.length||null!==t&&S(t[r[0]],r.slice(1)))}function s(t){t=t.split("/");return t.shift(),t.map(function(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")})}function w(t){return t.map(b).join("")}function b(t){return"/"+String(t).replace(/~/g,"~0").replace(/\//g,"~1")}function j(t,r,e){for(var n,o,i,c,u,f,a=t,p=0;p<r.length;p++){l=void 0;var l=r[p];if(!["add","remove","replace","copy","move","test"].includes(l.op))throw new Error("Unknown JSONPatch op "+JSON.stringify(l.op));if("string"!=typeof l.path)throw new Error('Required property "path" missing or not a string in operation '+JSON.stringify(l));if(("copy"===l.op||"move"===l.op)&&"string"!=typeof l.from)throw new Error('Required property "from" missing or not a string in operation '+JSON.stringify(l));l=r[p];if(e&&e.before){var s=e.before(a,l);if(void 0!==s){if(void 0!==s.document&&(a=s.document),void 0!==s.json)throw new Error('Deprecation warning: returned object property ".json" has been renamed to ".document"');void 0!==s.operation&&(l=s.operation)}}var s=a,y=N(a,l.path);if("add"===l.op)c=a,u=y,f=l.value,a=(P(c,u)?O:v)(c,u,f);else if("remove"===l.op)a=g(a,y);else if("replace"===l.op)c=a,u=l.value,a=v(c,y,u);else if("copy"===l.op)f=a,n=y,o=J(l.from),i=void 0,i=d(f,o),a=P(f,n)?O(f,n,i):(i=d(f,o),v(f,n,i));else if("move"===l.op)o=a,n=y,i=J(l.from),h=void 0,h=d(o,i),a=(P(o=g(o,i),n)?O:v)(o,n,h);else{if("test"!==l.op)throw new Error("Unknown JSONPatch operation "+JSON.stringify(l));b=m=h=void 0;var h=a,m=y,b=l.value;if(void 0===b)throw new Error('Test failed: no value provided (path: "'.concat(w(m),'")'));if(!S(h,m))throw new Error('Test failed: path not found (path: "'.concat(w(m),'")'));if(!function(t,r){return JSON.stringify(t)===JSON.stringify(r)}(d(h,m),b))throw new Error('Test failed, value differs (path: "'.concat(w(m),'")'))}e&&e.after&&void 0!==(y=e.after(a,l,s))&&(a=y)}return a}function P(t,r){if(0!==r.length)return t=d(t,n(r)),Array.isArray(t)}function N(t,r){return t=t,"-"!==(r=s(r))[r.length-1]?r:(r=d(t,t=n(r)),t.concat(r.length))}function J(t){return s(t)}function E(t){return function(t){if(Array.isArray(t))return A(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){var e;if(t)return"string"==typeof t?A(t,r):"Map"===(e="Object"===(e=Object.prototype.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?A(t,r):void 0}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function I(t,r){return[{op:"replace",path:w(r),value:d(t,r)}]}function T(t,r){return[{op:"add",path:w(r),value:d(t,r)}]}function x(t,r){return P(t,r)||!S(t,r)?[{op:"remove",path:w(r)}]:I(t,r)}t.appendToJSONPointer=function(t,r){return t+b(r)},t.compileJSONPointer=w,t.compileJSONPointerProp=b,t.deleteIn=g,t.existsIn=S,t.getIn=d,t.immutableJSONPatch=j,t.insertAt=O,t.isJSONArray=y,t.isJSONObject=h,t.isJSONPatchAdd=function(t){return!(!t||"object"!==r(t))&&"add"===t.op},t.isJSONPatchCopy=function(t){return!(!t||"object"!==r(t))&&"copy"===t.op},t.isJSONPatchMove=function(t){return!(!t||"object"!==r(t))&&"move"===t.op},t.isJSONPatchOperation=function(t){return!(!t||"object"!==r(t))&&"string"==typeof t.op},t.isJSONPatchRemove=function(t){return!(!t||"object"!==r(t))&&"remove"===t.op},t.isJSONPatchReplace=function(t){return!(!t||"object"!==r(t))&&"replace"===t.op},t.isJSONPatchTest=function(t){return!(!t||"object"!==r(t))&&"test"===t.op},t.parseFrom=J,t.parseJSONPointer=s,t.parsePath=N,t.revertJSONPatch=function(t,r,i){var c=[];return j(t,r,{before:function(t,r){var e,n,o=N(t,r.path);if("add"===r.op)e=x(t,o);else if("remove"===r.op)e=T(t,o);else if("replace"===r.op)e=I(t,o);else if("copy"===r.op)e=x(t,o);else if("move"===r.op)e=function(t,r,e){if(r.length<e.length&&function(t,r,e){var n=2<arguments.length&&void 0!==e?e:u;if(!(t.length<r.length)){for(var o=0;o<r.length;o++)if(!n(t[o],r[o]))return;return 1}}(e,r))return[{op:"replace",path:w(r),value:t}];e={op:"move",from:w(r),path:w(e)};return!P(t,r)&&S(t,r)?[e].concat(E(T(t,r))):[e]}(t,o,J(r.from));else{if("test"!==r.op)throw new Error("Unknown JSONPatch operation "+JSON.stringify(r));e=[]}if(i&&i.before){o=i.before(t,r,e);if(o&&o.revertOperations&&(e=o.revertOperations),o&&o.document&&(n=o.document),o&&o.json)throw new Error('Deprecation warning: returned object property ".json" has been renamed to ".document"')}if(c=e.concat(c),void 0!==n)return{document:n}}}),c},t.setIn=v,t.startsWithJSONPointer=function(t,r){return t.startsWith(r)&&(t.length===r.length||"/"===t[r.length])},t.transform=function t(r,e){var n,o,i,c,u=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],f=e(r,u);if(y(f)){for(var a,p=0;p<f.length;p++){var l=f[p],s=t(l,e,u.concat(p+""));s!==l&&((a=a||m(f))[p]=s)}return a||f}if(h(f)){for(o in f)Object.hasOwnProperty.call(f,o)&&(c=t(i=f[o],e,u.concat(o)))!==i&&((n=n||m(f))[o]=c);return n||f}return f},t.updateIn=l}); | ||
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).immutableJSONPatch={})}(this,function(t){"use strict";function r(t){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function y(t){return Array.isArray(t)}function h(t){return null!==t&&"object"===r(t)&&t.constructor===Object}function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,r){return t===r}function n(t){return t.slice(0,t.length-1)}function o(t){return"object"===e(t)&&null!==t}function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function c(r,t){var e,n=Object.keys(r);return Object.getOwnPropertySymbols&&(e=Object.getOwnPropertySymbols(r),t&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),n.push.apply(n,e)),n}function f(n){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?c(Object(o),!0).forEach(function(t){var r,e;r=n,e=o[t=t],(t=function(t){t=function(t,r){if("object"!==i(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0===e)return("string"===r?String:Number)(t);e=e.call(t,r||"default");if("object"!==i(e))return e;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"===i(t)?t:String(t)}(t))in r?Object.defineProperty(r,t,{value:e,enumerable:!0,configurable:!0,writable:!0}):r[t]=e}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):c(Object(o)).forEach(function(t){Object.defineProperty(n,t,Object.getOwnPropertyDescriptor(o,t))})}return n}function m(r){var e,n;return y(r)?(e=r.slice(),Object.getOwnPropertySymbols(r).forEach(function(t){e[t]=r[t]}),e):h(r)?(n=f({},r),Object.getOwnPropertySymbols(r).forEach(function(t){n[t]=r[t]}),n):r}function a(t,r,e){return t[r]===e?t:((t=m(t))[r]=e,t)}function d(t,r){for(var e=t,n=0;n<r.length;)e=h(e)?e[r[n]]:y(e)?e[parseInt(r[n])]:void 0,n++;return e}function v(t,r,e){var n=3<arguments.length&&void 0!==arguments[3]&&arguments[3];if(0===r.length)return e;var o=r[0],r=v(t?t[o]:void 0,r.slice(1),e,n);if(h(t)||y(t))return a(t,o,r);if(n)return(e=p.test(o)?[]:{})[o]=r,e;throw new Error("Path does not exist")}var p=/^\d+$/;function l(t,r,e){if(0===r.length)return e(t);var n;if(o(t))return a(t,n=r[0],l(t[n],r.slice(1),e));throw new Error("Path doesn't exist")}function g(t,r){if(0===r.length)return t;var e,n;if(o(t))return 1===r.length?(n=r[0])in t?(y(e=m(t))&&e.splice(parseInt(n),1),h(e)&&delete e[n],e):t:a(t,n=r[0],g(t[n],r.slice(1)));throw new Error("Path does not exist")}function O(t,r,e){var n=r.slice(0,r.length-1),o=r[r.length-1];return l(t,n,function(t){if(Array.isArray(t))return(t=m(t)).splice(parseInt(o),0,e),t;throw new TypeError("Array expected at path "+JSON.stringify(n))})}function S(t,r){return void 0!==t&&(0===r.length||null!==t&&S(t[r[0]],r.slice(1)))}function s(t){t=t.split("/");return t.shift(),t.map(function(t){return t.replace(/~1/g,"/").replace(/~0/g,"~")})}function w(t){return t.map(b).join("")}function b(t){return"/"+String(t).replace(/~/g,"~0").replace(/\//g,"~1")}function j(t,r,e){for(var n,o,i,c,u,f,a=t,p=0;p<r.length;p++){l=void 0;var l=r[p];if(!["add","remove","replace","copy","move","test"].includes(l.op))throw new Error("Unknown JSONPatch op "+JSON.stringify(l.op));if("string"!=typeof l.path)throw new Error('Required property "path" missing or not a string in operation '+JSON.stringify(l));if(("copy"===l.op||"move"===l.op)&&"string"!=typeof l.from)throw new Error('Required property "from" missing or not a string in operation '+JSON.stringify(l));l=r[p];if(e&&e.before){var s=e.before(a,l);if(void 0!==s){if(void 0!==s.document&&(a=s.document),void 0!==s.json)throw new Error('Deprecation warning: returned object property ".json" has been renamed to ".document"');void 0!==s.operation&&(l=s.operation)}}var s=a,y=N(a,l.path);if("add"===l.op)c=a,u=y,f=l.value,a=(P(c,u)?O:v)(c,u,f);else if("remove"===l.op)a=g(a,y);else if("replace"===l.op)c=a,u=l.value,a=v(c,y,u);else if("copy"===l.op)f=a,n=y,o=J(l.from),i=void 0,i=d(f,o),a=P(f,n)?O(f,n,i):(i=d(f,o),v(f,n,i));else if("move"===l.op)o=a,n=y,i=J(l.from),h=void 0,h=d(o,i),a=(P(o=g(o,i),n)?O:v)(o,n,h);else{if("test"!==l.op)throw new Error("Unknown JSONPatch operation "+JSON.stringify(l));b=m=h=void 0;var h=a,m=y,b=l.value;if(void 0===b)throw new Error('Test failed: no value provided (path: "'.concat(w(m),'")'));if(!S(h,m))throw new Error('Test failed: path not found (path: "'.concat(w(m),'")'));if(!function(t,r){return JSON.stringify(t)===JSON.stringify(r)}(d(h,m),b))throw new Error('Test failed, value differs (path: "'.concat(w(m),'")'))}e&&e.after&&void 0!==(y=e.after(a,l,s))&&(a=y)}return a}function P(t,r){if(0!==r.length)return t=d(t,n(r)),Array.isArray(t)}function N(t,r){return t=t,"-"!==(r=s(r))[r.length-1]?r:(r=d(t,t=n(r)),t.concat(r.length))}function J(t){return s(t)}function E(t){return function(t){if(Array.isArray(t))return A(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,r){var e;if(t)return"string"==typeof t?A(t,r):"Map"===(e="Object"===(e=Object.prototype.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:e)||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?A(t,r):void 0}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function A(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function I(t,r){return[{op:"replace",path:w(r),value:d(t,r)}]}function T(t,r){return[{op:"add",path:w(r),value:d(t,r)}]}function x(t,r){return P(t,r)||!S(t,r)?[{op:"remove",path:w(r)}]:I(t,r)}t.appendToJSONPointer=function(t,r){return t+b(r)},t.compileJSONPointer=w,t.compileJSONPointerProp=b,t.deleteIn=g,t.existsIn=S,t.getIn=d,t.immutableJSONPatch=j,t.insertAt=O,t.isJSONArray=y,t.isJSONObject=h,t.isJSONPatchAdd=function(t){return!(!t||"object"!==r(t))&&"add"===t.op},t.isJSONPatchCopy=function(t){return!(!t||"object"!==r(t))&&"copy"===t.op},t.isJSONPatchMove=function(t){return!(!t||"object"!==r(t))&&"move"===t.op},t.isJSONPatchOperation=function(t){return!(!t||"object"!==r(t))&&"string"==typeof t.op},t.isJSONPatchRemove=function(t){return!(!t||"object"!==r(t))&&"remove"===t.op},t.isJSONPatchReplace=function(t){return!(!t||"object"!==r(t))&&"replace"===t.op},t.isJSONPatchTest=function(t){return!(!t||"object"!==r(t))&&"test"===t.op},t.parseFrom=J,t.parseJSONPointer=s,t.parsePath=N,t.revertJSONPatch=function(t,r,i){var c=[];return j(t,r,{before:function(t,r){var e,n,o=N(t,r.path);if("add"===r.op)e=x(t,o);else if("remove"===r.op)e=T(t,o);else if("replace"===r.op)e=I(t,o);else if("copy"===r.op)e=x(t,o);else if("move"===r.op)e=function(t,r,e){if(r.length<e.length&&function(t,r,e){var n=2<arguments.length&&void 0!==e?e:u;if(!(t.length<r.length)){for(var o=0;o<r.length;o++)if(!n(t[o],r[o]))return;return 1}}(e,r))return[{op:"replace",path:w(r),value:t}];e={op:"move",from:w(r),path:w(e)};return!P(t,r)&&S(t,r)?[e].concat(E(T(t,r))):[e]}(t,o,J(r.from));else{if("test"!==r.op)throw new Error("Unknown JSONPatch operation "+JSON.stringify(r));e=[]}if(i&&i.before){o=i.before(t,r,e);if(o&&o.revertOperations&&(e=o.revertOperations),o&&o.document&&(n=o.document),o&&o.json)throw new Error('Deprecation warning: returned object property ".json" has been renamed to ".document"')}if(c=e.concat(c),void 0!==n)return{document:n}}}),c},t.setIn=v,t.startsWithJSONPointer=function(t,r){return t.startsWith(r)&&(t.length===r.length||"/"===t[r.length])},t.transform=function t(r,e){var n,o,i,c,u=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],f=e(r,u);if(y(f)){for(var a,p=0;p<f.length;p++){var l=f[p],s=t(l,e,u.concat(p+""));s!==l&&((a=a||m(f))[p]=s)}return a||f}if(h(f)){for(o in f)Object.hasOwnProperty.call(f,o)&&(c=t(i=f[o],e,u.concat(o)))!==i&&((n=n||m(f))[o]=c);return n||f}return f},t.updateIn=l}); |
{ | ||
"name": "immutable-json-patch", | ||
"version": "5.1.2", | ||
"version": "5.1.3", | ||
"description": "Immutable JSON patch with support for reverting operations", | ||
@@ -10,3 +10,3 @@ "repository": { | ||
"type": "module", | ||
"main": "lib/esm/index.js", | ||
"main": "lib/umd/immutableJSONPatch.js", | ||
"module": "lib/esm/index.js", | ||
@@ -38,3 +38,3 @@ "browser": "lib/umd/immutableJSONPatch.js", | ||
"build:cjs": "babel src --out-dir lib/cjs --extensions \".ts\" --source-maps --config-file ./babel-cjs.config.json && cpy tools/cjs/package.json lib/cjs --flat", | ||
"build:umd": "rollup lib/esm/index.js --format umd --name 'immutableJSONPatch' --sourcemap --output.file lib/umd/immutableJSONPatch.js && cpy tools/cjs/package.json lib/umd --flat", | ||
"build:umd": "rollup lib/esm/index.js --format umd --name immutableJSONPatch --sourcemap --output.file lib/umd/immutableJSONPatch.js && cpy tools/cjs/package.json lib/umd --flat", | ||
"build:umd:min": "uglifyjs --compress --mangle --source-map --comments --output lib/umd/immutableJSONPatch.min.js -- lib/umd/immutableJSONPatch.js", | ||
@@ -54,17 +54,17 @@ "build:types": "tsc --project tsconfig-types.json", | ||
"devDependencies": { | ||
"@babel/cli": "7.20.7", | ||
"@babel/core": "7.20.12", | ||
"@babel/plugin-transform-typescript": "7.20.7", | ||
"@babel/preset-env": "7.20.2", | ||
"@babel/preset-typescript": "7.18.6", | ||
"@babel/cli": "7.22.6", | ||
"@babel/core": "7.22.8", | ||
"@babel/plugin-transform-typescript": "7.22.5", | ||
"@babel/preset-env": "7.22.7", | ||
"@babel/preset-typescript": "7.22.5", | ||
"@types/mocha": "10.0.1", | ||
"@types/node": "18.11.18", | ||
"@typescript-eslint/eslint-plugin": "5.48.1", | ||
"@typescript-eslint/parser": "5.48.1", | ||
"cpy-cli": "4.2.0", | ||
"@types/node": "20.4.0", | ||
"@typescript-eslint/eslint-plugin": "5.61.0", | ||
"@typescript-eslint/parser": "5.61.0", | ||
"cpy-cli": "5.0.0", | ||
"del-cli": "5.0.0", | ||
"eslint": "8.31.0", | ||
"eslint-config-standard": "17.0.0", | ||
"eslint-plugin-import": "2.27.4", | ||
"eslint-plugin-n": "15.6.1", | ||
"eslint": "8.44.0", | ||
"eslint-config-standard": "17.1.0", | ||
"eslint-plugin-import": "2.27.5", | ||
"eslint-plugin-n": "16.0.1", | ||
"eslint-plugin-node": "11.1.0", | ||
@@ -74,7 +74,7 @@ "eslint-plugin-promise": "6.1.1", | ||
"npm-run-all": "4.1.5", | ||
"rollup": "3.10.0", | ||
"rollup": "3.26.2", | ||
"ts-node": "10.9.1", | ||
"typescript": "4.9.4", | ||
"typescript": "5.1.6", | ||
"uglify-js": "3.17.4" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
290999
2490