immutable-json-patch
Advanced tools
Comparing version 5.1.1 to 5.1.2
@@ -17,5 +17,8 @@ "use strict"; | ||
var _utils = require("./utils.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); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
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); } | ||
/** | ||
@@ -22,0 +25,0 @@ * Shallow clone of an Object, Array, or value |
@@ -0,4 +1,7 @@ | ||
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); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
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); } | ||
/** | ||
@@ -5,0 +8,0 @@ * Immutability helpers |
(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'; | ||
function _typeof$1(obj) { "@babel/helpers - typeof"; return _typeof$1 = "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$1(obj); } | ||
function _typeof$2(obj) { "@babel/helpers - typeof"; return _typeof$2 = "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$2(obj); } | ||
function isJSONArray(value) { | ||
@@ -12,3 +12,3 @@ return Array.isArray(value); | ||
function isJSONObject(value) { | ||
return value !== null && _typeof$1(value) === 'object' && value.constructor === Object // do not match on classes or Array | ||
return value !== null && _typeof$2(value) === 'object' && value.constructor === Object // do not match on classes or Array | ||
; | ||
@@ -20,3 +20,3 @@ } | ||
// @ts-ignore | ||
return value && _typeof$1(value) === 'object' ? typeof value.op === 'string' : false; | ||
return value && _typeof$2(value) === 'object' ? typeof value.op === 'string' : false; | ||
} | ||
@@ -26,3 +26,3 @@ function isJSONPatchAdd(value) { | ||
// @ts-ignore | ||
return value && _typeof$1(value) === 'object' ? value.op === 'add' : false; | ||
return value && _typeof$2(value) === 'object' ? value.op === 'add' : false; | ||
} | ||
@@ -32,3 +32,3 @@ function isJSONPatchRemove(value) { | ||
// @ts-ignore | ||
return value && _typeof$1(value) === 'object' ? value.op === 'remove' : false; | ||
return value && _typeof$2(value) === 'object' ? value.op === 'remove' : false; | ||
} | ||
@@ -38,3 +38,3 @@ function isJSONPatchReplace(value) { | ||
// @ts-ignore | ||
return value && _typeof$1(value) === 'object' ? value.op === 'replace' : false; | ||
return value && _typeof$2(value) === 'object' ? value.op === 'replace' : false; | ||
} | ||
@@ -44,3 +44,3 @@ function isJSONPatchCopy(value) { | ||
// @ts-ignore | ||
return value && _typeof$1(value) === 'object' ? value.op === 'copy' : false; | ||
return value && _typeof$2(value) === 'object' ? value.op === 'copy' : false; | ||
} | ||
@@ -50,3 +50,3 @@ function isJSONPatchMove(value) { | ||
// @ts-ignore | ||
return value && _typeof$1(value) === 'object' ? value.op === 'move' : false; | ||
return value && _typeof$2(value) === 'object' ? value.op === 'move' : false; | ||
} | ||
@@ -56,6 +56,6 @@ function isJSONPatchTest(value) { | ||
// @ts-ignore | ||
return value && _typeof$1(value) === 'object' ? value.op === 'test' : false; | ||
return value && _typeof$2(value) === 'object' ? value.op === 'test' : false; | ||
} | ||
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); } | ||
function _typeof$1(obj) { "@babel/helpers - typeof"; return _typeof$1 = "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$1(obj); } | ||
/** | ||
@@ -118,8 +118,11 @@ * Test deep equality of two JSON values, objects, or arrays | ||
function isObjectOrArray(value) { | ||
return _typeof(value) === 'object' && value !== null; | ||
return _typeof$1(value) === 'object' && value !== null; | ||
} | ||
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); } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
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); } | ||
@@ -733,5 +736,3 @@ /** | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
})); | ||
//# sourceMappingURL=immutableJSONPatch.js.map |
@@ -1,1 +0,1 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).immutableJSONPatch={})}(this,function(e){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function y(e){return Array.isArray(e)}function h(e){return null!==e&&"object"===t(e)&&e.constructor===Object}function r(e){return(r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function f(e,t){return e===t}function n(e){return e.slice(0,e.length-1)}function o(e){return"object"===r(e)&&null!==e}function i(t,e){var r,n=Object.keys(t);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(t),e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)),n}function c(n){for(var e=1;e<arguments.length;e++){var o=null!=arguments[e]?arguments[e]:{};e%2?i(Object(o),!0).forEach(function(e){var t,r;t=n,r=o[e=e],e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(o)):i(Object(o)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(o,e))})}return n}function d(t){var r,n;return y(t)?(r=t.slice(),Object.getOwnPropertySymbols(t).forEach(function(e){r[e]=t[e]}),r):h(t)?(n=c({},t),Object.getOwnPropertySymbols(t).forEach(function(e){n[e]=t[e]}),n):t}function a(e,t,r){return e[t]===r?e:((e=d(e))[t]=r,e)}function b(e,t){for(var r=e,n=0;n<t.length;)r=h(r)?r[t[n]]:y(r)?r[parseInt(t[n])]:void 0,n++;return r}function m(e,t,r){var n=3<arguments.length&&void 0!==arguments[3]&&arguments[3];if(0===t.length)return r;var o=t[0],t=m(e?e[o]:void 0,t.slice(1),r,n);if(h(e)||y(e))return a(e,o,t);if(n)return(r=u.test(o)?[]:{})[o]=t,r;throw new Error("Path does not exist")}var u=/^\d+$/;function p(e,t,r){if(0===t.length)return r(e);var n;if(o(e))return a(e,n=t[0],p(e[n],t.slice(1),r));throw new Error("Path doesn't exist")}function g(e,t){if(0===t.length)return e;var r,n;if(o(e))return 1===t.length?(n=t[0])in e?(y(r=d(e))&&r.splice(parseInt(n),1),h(r)&&delete r[n],r):e:a(e,n=t[0],g(e[n],t.slice(1)));throw new Error("Path does not exist")}function O(e,t,r){var n=t.slice(0,t.length-1),o=t[t.length-1];return p(e,n,function(e){if(Array.isArray(e))return(e=d(e)).splice(parseInt(o),0,r),e;throw new TypeError("Array expected at path "+JSON.stringify(n))})}function S(e,t){return void 0!==e&&(0===t.length||null!==e&&S(e[t[0]],t.slice(1)))}function l(e){e=e.split("/");return e.shift(),e.map(function(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")})}function w(e){return e.map(s).join("")}function s(e){return"/"+String(e).replace(/~/g,"~0").replace(/\//g,"~1")}function v(e,t,r){for(var n,o,i,c,f,a,u=e,p=0;p<t.length;p++){l=void 0;var l=t[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=t[p];if(r&&r.before){var s=r.before(u,l);if(void 0!==s){if(void 0!==s.document&&(u=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=u,y=P(u,l.path);if("add"===l.op)c=u,f=y,a=l.value,u=(j(c,f)?O:m)(c,f,a);else if("remove"===l.op)u=g(u,y);else if("replace"===l.op)c=u,f=l.value,u=m(c,y,f);else if("copy"===l.op)a=u,n=y,o=J(l.from),i=void 0,i=b(a,o),u=j(a,n)?O(a,n,i):(i=b(a,o),m(a,n,i));else if("move"===l.op)o=u,n=y,i=J(l.from),h=void 0,h=b(o,i),u=(j(o=g(o,i),n)?O:m)(o,n,h);else{if("test"!==l.op)throw new Error("Unknown JSONPatch operation "+JSON.stringify(l));v=d=h=void 0;var h=u,d=y,v=l.value;if(void 0===v)throw new Error('Test failed: no value provided (path: "'.concat(w(d),'")'));if(!S(h,d))throw new Error('Test failed: path not found (path: "'.concat(w(d),'")'));if(!function(e,t){return JSON.stringify(e)===JSON.stringify(t)}(b(h,d),v))throw new Error('Test failed, value differs (path: "'.concat(w(d),'")'))}r&&r.after&&void 0!==(y=r.after(u,l,s))&&(u=y)}return u}function j(e,t){if(0!==t.length)return e=b(e,n(t)),Array.isArray(e)}function P(e,t){return e=e,"-"!==(t=l(t))[t.length-1]?t:(t=b(e,e=n(t)),e.concat(t.length))}function J(e){return l(e)}function N(e){return function(e){if(Array.isArray(e))return E(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){var r;if(e)return"string"==typeof e?E(e,t):"Map"===(r="Object"===(r=Object.prototype.toString.call(e).slice(8,-1))&&e.constructor?e.constructor.name:r)||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?E(e,t):void 0}(e)||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 E(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function A(e,t){return[{op:"replace",path:w(t),value:b(e,t)}]}function I(e,t){return[{op:"add",path:w(t),value:b(e,t)}]}function T(e,t){return j(e,t)||!S(e,t)?[{op:"remove",path:w(t)}]:A(e,t)}e.appendToJSONPointer=function(e,t){return e+s(t)},e.compileJSONPointer=w,e.compileJSONPointerProp=s,e.deleteIn=g,e.existsIn=S,e.getIn=b,e.immutableJSONPatch=v,e.insertAt=O,e.isJSONArray=y,e.isJSONObject=h,e.isJSONPatchAdd=function(e){return!(!e||"object"!==t(e))&&"add"===e.op},e.isJSONPatchCopy=function(e){return!(!e||"object"!==t(e))&&"copy"===e.op},e.isJSONPatchMove=function(e){return!(!e||"object"!==t(e))&&"move"===e.op},e.isJSONPatchOperation=function(e){return!(!e||"object"!==t(e))&&"string"==typeof e.op},e.isJSONPatchRemove=function(e){return!(!e||"object"!==t(e))&&"remove"===e.op},e.isJSONPatchReplace=function(e){return!(!e||"object"!==t(e))&&"replace"===e.op},e.isJSONPatchTest=function(e){return!(!e||"object"!==t(e))&&"test"===e.op},e.parseFrom=J,e.parseJSONPointer=l,e.parsePath=P,e.revertJSONPatch=function(e,t,i){var c=[];return v(e,t,{before:function(e,t){var r,n,o=P(e,t.path);if("add"===t.op)r=T(e,o);else if("remove"===t.op)r=I(e,o);else if("replace"===t.op)r=A(e,o);else if("copy"===t.op)r=T(e,o);else if("move"===t.op)r=function(e,t,r){if(t.length<r.length&&function(e,t,r){var n=2<arguments.length&&void 0!==r?r:f;if(!(e.length<t.length)){for(var o=0;o<t.length;o++)if(!n(e[o],t[o]))return;return 1}}(r,t))return[{op:"replace",path:w(t),value:e}];r={op:"move",from:w(t),path:w(r)};return!j(e,t)&&S(e,t)?[r].concat(N(I(e,t))):[r]}(e,o,J(t.from));else{if("test"!==t.op)throw new Error("Unknown JSONPatch operation "+JSON.stringify(t));r=[]}if(i&&i.before){o=i.before(e,t,r);if(o&&o.revertOperations&&(r=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=r.concat(c),void 0!==n)return{document:n}}}),c},e.setIn=m,e.startsWithJSONPointer=function(e,t){return e.startsWith(t)&&(e.length===t.length||"/"===e[t.length])},e.transform=function e(t,r){var n,o,i,c,f=2<arguments.length&&void 0!==arguments[2]?arguments[2]:[],a=r(t,f);if(y(a)){for(var u,p=0;p<a.length;p++){var l=a[p],s=e(l,r,f.concat(p+""));s!==l&&((u=u||d(a))[p]=s)}return u||a}if(h(a)){for(o in a)Object.hasOwnProperty.call(a,o)&&(c=e(i=a[o],r,f.concat(o)))!==i&&((n=n||d(a))[o]=c);return n||a}return a},e.updateIn=p,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!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}); |
The ISC License | ||
Copyright (c) 2020-2022 by Jos de Jong | ||
Copyright (c) 2020-2023 by Jos de Jong | ||
@@ -5,0 +5,0 @@ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. |
{ | ||
"name": "immutable-json-patch", | ||
"version": "5.1.1", | ||
"version": "5.1.2", | ||
"description": "Immutable JSON patch with support for reverting operations", | ||
@@ -14,2 +14,10 @@ "repository": { | ||
"types": "lib/types/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./lib/esm/index.js", | ||
"require": "./lib/umd/immutableJSONPatch.js", | ||
"browser": "./lib/umd/immutableJSONPatch.js", | ||
"types": "./lib/types/index.d.ts" | ||
} | ||
}, | ||
"sideEffects": false, | ||
@@ -45,26 +53,26 @@ "keywords": [ | ||
"devDependencies": { | ||
"@babel/cli": "7.19.3", | ||
"@babel/core": "7.20.2", | ||
"@babel/plugin-transform-typescript": "7.20.2", | ||
"@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", | ||
"@types/mocha": "10.0.0", | ||
"@types/node": "18.11.9", | ||
"@typescript-eslint/eslint-plugin": "5.43.0", | ||
"@typescript-eslint/parser": "5.43.0", | ||
"@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", | ||
"del-cli": "5.0.0", | ||
"eslint": "8.27.0", | ||
"eslint": "8.31.0", | ||
"eslint-config-standard": "17.0.0", | ||
"eslint-plugin-import": "2.26.0", | ||
"eslint-plugin-n": "15.5.1", | ||
"eslint-plugin-import": "2.27.4", | ||
"eslint-plugin-n": "15.6.1", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-promise": "6.1.1", | ||
"mocha": "10.1.0", | ||
"mocha": "10.2.0", | ||
"npm-run-all": "4.1.5", | ||
"rollup": "2.79.1", | ||
"rollup": "3.10.0", | ||
"ts-node": "10.9.1", | ||
"typescript": "4.9.3", | ||
"typescript": "4.9.4", | ||
"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
281604
2483