@hyperjump/json-pointer
Advanced tools
Comparing version 0.9.4 to 0.9.5
@@ -1,2 +0,2 @@ | ||
define(function () { 'use strict'; | ||
define((function () { 'use strict'; | ||
@@ -77,4 +77,11 @@ var justCurryIt = curry$1; | ||
} else if (pointer.length > 1) { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
if (Array.isArray(subject)) { | ||
const index = pointer.shift(); | ||
const clonedSubject = [...subject]; | ||
clonedSubject[index] = _set(pointer, applySegment(subject, index, cursor), value, append(index, cursor)); | ||
return clonedSubject; | ||
} else { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
} | ||
} else if (Array.isArray(subject)) { | ||
@@ -181,3 +188,3 @@ const clonedSubject = [...subject]; | ||
}); | ||
})); | ||
//# sourceMappingURL=json-pointer-amd.js.map |
@@ -1,2 +0,2 @@ | ||
define((function(){"use strict";const e=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}},t=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(u)},r=(e,t,n,i)=>{if(0===e.length)return n;if(e.length>1){const o=e.shift();return{...t,[o]:r(e,c(t,o,i),n,l(o,i))}}if(Array.isArray(t)){const r=[...t];return r[a(t,e[0])]=n,r}return"object"==typeof t&&null!==t?{...t,[e[0]]:n}:c(t,e[0],i)},n=(e,t,r,i)=>{if(0!==e.length)if(1!==e.length||f(t)){const o=e.shift();n(e,c(t,o,i),r,l(o,i))}else{t[a(t,e[0])]=r}},i=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=c(t,n,r);return{...t,[n]:i(e,o,l(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return c(t,e[0],r)}},o=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),i=c(t,n,r);o(e,i,l(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:c(t,e[0],r)},l=e(((e,t)=>t+"/"+s(e))),s=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),u=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),a=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,c=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(f(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[a(e,t)]},f=e=>null===e||"object"!=typeof e;return{nil:"",append:l,get:(e,r)=>{const n=t(e),i=e=>n.reduce((([e,t],r)=>[c(e,r,t),l(r,t)]),[e,""])[0];return void 0===r?i:i(r)},set:(n,i,o)=>{const l=t(n),s=e(((e,t)=>r(l,e,t,"")));return void 0===i?s:s(i,o)},assign:(r,i,o)=>{const l=t(r),s=e(((e,t)=>n(l,e,t,"")));return void 0===i?s:s(i,o)},unset:(e,r)=>{const n=t(e),o=e=>i(n,e,"");return void 0===r?o:o(r)},remove:(e,r)=>{const n=t(e),i=e=>o(n,e,"");return void 0===r?i:i(r)}}})); | ||
define((function(){"use strict";var r=function(r,t){return function e(){null==t&&(t=r.length);var n=[].slice.call(arguments);return n.length>=t?r.apply(this,n):function(){return e.apply(this,n.concat([].slice.call(arguments)))}}};const t=r,e=r=>{if(r.length>0&&"/"!==r[0])throw Error("Invalid JSON Pointer");return r.split("/").slice(1).map(u)},n=(r,t,e,i)=>{if(0===r.length)return e;if(r.length>1){if(Array.isArray(t)){const o=r.shift(),l=[...t];return l[o]=n(r,f(t,o,i),e,s(o,i)),l}{const o=r.shift();return{...t,[o]:n(r,f(t,o,i),e,s(o,i))}}}if(Array.isArray(t)){const n=[...t];return n[c(t,r[0])]=e,n}return"object"==typeof t&&null!==t?{...t,[r[0]]:e}:f(t,r[0],i)},i=(r,t,e,n)=>{if(0!==r.length)if(1!==r.length||p(t)){const o=r.shift();i(r,f(t,o,n),e,s(o,n))}else{t[c(t,r[0])]=e}},o=(r,t,e)=>{if(0!=r.length){if(r.length>1){const n=r.shift(),i=f(t,n,e);return{...t,[n]:o(r,i,s(n,e))}}if(Array.isArray(t))return t.filter(((t,e)=>e!=r[0]));if("object"==typeof t&&null!==t){const{[r[0]]:e,...n}=t;return n}return f(t,r[0],e)}},l=(r,t,e)=>{if(0!==r.length)if(r.length>1){const n=r.shift(),i=f(t,n,e);l(r,i,s(n,e))}else Array.isArray(t)?t.splice(r[0],1):"object"==typeof t&&null!==t?delete t[r[0]]:f(t,r[0],e)},s=t(((r,t)=>t+"/"+a(r))),a=r=>r.toString().replace(/~/g,"~0").replace(/\//g,"~1"),u=r=>r.toString().replace(/~1/g,"/").replace(/~0/g,"~"),c=(r,t)=>Array.isArray(r)&&"-"===t?r.length:t,f=(r,t,e="")=>{if(void 0===r)throw TypeError(`Value at '${e}' is undefined and does not have property '${t}'`);if(null===r)throw TypeError(`Value at '${e}' is null and does not have property '${t}'`);if(p(r))throw TypeError(`Value at '${e}' is a ${typeof r} and does not have property '${t}'`);return r[c(r,t)]},p=r=>null===r||"object"!=typeof r;return{nil:"",append:s,get:(r,t)=>{const n=e(r),i=r=>n.reduce((([r,t],e)=>[f(r,e,t),s(e,t)]),[r,""])[0];return void 0===t?i:i(t)},set:(r,i,o)=>{const l=e(r),s=t(((r,t)=>n(l,r,t,"")));return void 0===i?s:s(i,o)},assign:(r,n,o)=>{const l=e(r),s=t(((r,t)=>i(l,r,t,"")));return void 0===n?s:s(n,o)},unset:(r,t)=>{const n=e(r),i=r=>o(n,r,"");return void 0===t?i:i(t)},remove:(r,t)=>{const n=e(r),i=r=>l(n,r,"");return void 0===t?i:i(t)}}})); | ||
//# sourceMappingURL=json-pointer-amd.min.js.map |
@@ -77,4 +77,11 @@ 'use strict'; | ||
} else if (pointer.length > 1) { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
if (Array.isArray(subject)) { | ||
const index = pointer.shift(); | ||
const clonedSubject = [...subject]; | ||
clonedSubject[index] = _set(pointer, applySegment(subject, index, cursor), value, append(index, cursor)); | ||
return clonedSubject; | ||
} else { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
} | ||
} else if (Array.isArray(subject)) { | ||
@@ -81,0 +88,0 @@ const clonedSubject = [...subject]; |
@@ -1,2 +0,2 @@ | ||
"use strict";const e=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.apply(this,n.concat([].slice.call(arguments)))}}},r=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(a)},t=(e,r,n,o)=>{if(0===e.length)return n;if(e.length>1){const i=e.shift();return{...r,[i]:t(e,c(r,i,o),n,l(i,o))}}if(Array.isArray(r)){const t=[...r];return t[u(r,e[0])]=n,t}return"object"==typeof r&&null!==r?{...r,[e[0]]:n}:c(r,e[0],o)},n=(e,r,t,o)=>{if(0!==e.length)if(1!==e.length||f(r)){const i=e.shift();n(e,c(r,i,o),t,l(i,o))}else{r[u(r,e[0])]=t}},o=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),i=c(r,n,t);return{...r,[n]:o(e,i,l(n,t))}}if(Array.isArray(r))return r.filter(((r,t)=>t!=e[0]));if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return c(r,e[0],t)}},i=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=c(r,n,t);i(e,o,l(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:c(r,e[0],t)},l=e(((e,r)=>r+"/"+s(e))),s=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),a=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),u=(e,r)=>Array.isArray(e)&&"-"===r?e.length:r,c=(e,r,t="")=>{if(void 0===e)throw TypeError(`Value at '${t}' is undefined and does not have property '${r}'`);if(null===e)throw TypeError(`Value at '${t}' is null and does not have property '${r}'`);if(f(e))throw TypeError(`Value at '${t}' is a ${typeof e} and does not have property '${r}'`);return e[u(e,r)]},f=e=>null===e||"object"!=typeof e;var p={nil:"",append:l,get:(e,t)=>{const n=r(e),o=e=>n.reduce((([e,r],t)=>[c(e,t,r),l(t,r)]),[e,""])[0];return void 0===t?o:o(t)},set:(n,o,i)=>{const l=r(n),s=e(((e,r)=>t(l,e,r,"")));return void 0===o?s:s(o,i)},assign:(t,o,i)=>{const l=r(t),s=e(((e,r)=>n(l,e,r,"")));return void 0===o?s:s(o,i)},unset:(e,t)=>{const n=r(e),i=e=>o(n,e,"");return void 0===t?i:i(t)},remove:(e,t)=>{const n=r(e),o=e=>i(n,e,"");return void 0===t?o:o(t)}};module.exports=p; | ||
"use strict";const r=function(r,t){return function e(){null==t&&(t=r.length);var n=[].slice.call(arguments);return n.length>=t?r.apply(this,n):function(){return e.apply(this,n.concat([].slice.call(arguments)))}}},t=r=>{if(r.length>0&&"/"!==r[0])throw Error("Invalid JSON Pointer");return r.split("/").slice(1).map(a)},e=(r,t,n,o)=>{if(0===r.length)return n;if(r.length>1){if(Array.isArray(t)){const i=r.shift(),s=[...t];return s[i]=e(r,c(t,i,o),n,l(i,o)),s}{const i=r.shift();return{...t,[i]:e(r,c(t,i,o),n,l(i,o))}}}if(Array.isArray(t)){const e=[...t];return e[u(t,r[0])]=n,e}return"object"==typeof t&&null!==t?{...t,[r[0]]:n}:c(t,r[0],o)},n=(r,t,e,o)=>{if(0!==r.length)if(1!==r.length||f(t)){const i=r.shift();n(r,c(t,i,o),e,l(i,o))}else{t[u(t,r[0])]=e}},o=(r,t,e)=>{if(0!=r.length){if(r.length>1){const n=r.shift(),i=c(t,n,e);return{...t,[n]:o(r,i,l(n,e))}}if(Array.isArray(t))return t.filter(((t,e)=>e!=r[0]));if("object"==typeof t&&null!==t){const{[r[0]]:e,...n}=t;return n}return c(t,r[0],e)}},i=(r,t,e)=>{if(0!==r.length)if(r.length>1){const n=r.shift(),o=c(t,n,e);i(r,o,l(n,e))}else Array.isArray(t)?t.splice(r[0],1):"object"==typeof t&&null!==t?delete t[r[0]]:c(t,r[0],e)},l=r(((r,t)=>t+"/"+s(r))),s=r=>r.toString().replace(/~/g,"~0").replace(/\//g,"~1"),a=r=>r.toString().replace(/~1/g,"/").replace(/~0/g,"~"),u=(r,t)=>Array.isArray(r)&&"-"===t?r.length:t,c=(r,t,e="")=>{if(void 0===r)throw TypeError(`Value at '${e}' is undefined and does not have property '${t}'`);if(null===r)throw TypeError(`Value at '${e}' is null and does not have property '${t}'`);if(f(r))throw TypeError(`Value at '${e}' is a ${typeof r} and does not have property '${t}'`);return r[u(r,t)]},f=r=>null===r||"object"!=typeof r;var p={nil:"",append:l,get:(r,e)=>{const n=t(r),o=r=>n.reduce((([r,t],e)=>[c(r,e,t),l(e,t)]),[r,""])[0];return void 0===e?o:o(e)},set:(n,o,i)=>{const l=t(n),s=r(((r,t)=>e(l,r,t,"")));return void 0===o?s:s(o,i)},assign:(e,o,i)=>{const l=t(e),s=r(((r,t)=>n(l,r,t,"")));return void 0===o?s:s(o,i)},unset:(r,e)=>{const n=t(r),i=r=>o(n,r,"");return void 0===e?i:i(e)},remove:(r,e)=>{const n=t(r),o=r=>i(n,r,"");return void 0===e?o:o(e)}};module.exports=p; | ||
//# sourceMappingURL=json-pointer-cjs.min.js.map |
@@ -75,4 +75,11 @@ var justCurryIt = curry$1; | ||
} else if (pointer.length > 1) { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
if (Array.isArray(subject)) { | ||
const index = pointer.shift(); | ||
const clonedSubject = [...subject]; | ||
clonedSubject[index] = _set(pointer, applySegment(subject, index, cursor), value, append(index, cursor)); | ||
return clonedSubject; | ||
} else { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
} | ||
} else if (Array.isArray(subject)) { | ||
@@ -79,0 +86,0 @@ const clonedSubject = [...subject]; |
@@ -1,2 +0,2 @@ | ||
const e=function(e,r){return function t(){null==r&&(r=e.length);var n=[].slice.call(arguments);return n.length>=r?e.apply(this,n):function(){return t.apply(this,n.concat([].slice.call(arguments)))}}},r=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(a)},t=(e,r,n,o)=>{if(0===e.length)return n;if(e.length>1){const l=e.shift();return{...r,[l]:t(e,c(r,l,o),n,i(l,o))}}if(Array.isArray(r)){const t=[...r];return t[u(r,e[0])]=n,t}return"object"==typeof r&&null!==r?{...r,[e[0]]:n}:c(r,e[0],o)},n=(e,r,t,o)=>{if(0!==e.length)if(1!==e.length||f(r)){const l=e.shift();n(e,c(r,l,o),t,i(l,o))}else{r[u(r,e[0])]=t}},o=(e,r,t)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),l=c(r,n,t);return{...r,[n]:o(e,l,i(n,t))}}if(Array.isArray(r))return r.filter(((r,t)=>t!=e[0]));if("object"==typeof r&&null!==r){const{[e[0]]:t,...n}=r;return n}return c(r,e[0],t)}},l=(e,r,t)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=c(r,n,t);l(e,o,i(n,t))}else Array.isArray(r)?r.splice(e[0],1):"object"==typeof r&&null!==r?delete r[e[0]]:c(r,e[0],t)},i=e(((e,r)=>r+"/"+s(e))),s=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),a=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),u=(e,r)=>Array.isArray(e)&&"-"===r?e.length:r,c=(e,r,t="")=>{if(void 0===e)throw TypeError(`Value at '${t}' is undefined and does not have property '${r}'`);if(null===e)throw TypeError(`Value at '${t}' is null and does not have property '${r}'`);if(f(e))throw TypeError(`Value at '${t}' is a ${typeof e} and does not have property '${r}'`);return e[u(e,r)]},f=e=>null===e||"object"!=typeof e;var p={nil:"",append:i,get:(e,t)=>{const n=r(e),o=e=>n.reduce((([e,r],t)=>[c(e,t,r),i(t,r)]),[e,""])[0];return void 0===t?o:o(t)},set:(n,o,l)=>{const i=r(n),s=e(((e,r)=>t(i,e,r,"")));return void 0===o?s:s(o,l)},assign:(t,o,l)=>{const i=r(t),s=e(((e,r)=>n(i,e,r,"")));return void 0===o?s:s(o,l)},unset:(e,t)=>{const n=r(e),l=e=>o(n,e,"");return void 0===t?l:l(t)},remove:(e,t)=>{const n=r(e),o=e=>l(n,e,"");return void 0===t?o:o(t)}};export{p as default}; | ||
const r=function(r,t){return function e(){null==t&&(t=r.length);var n=[].slice.call(arguments);return n.length>=t?r.apply(this,n):function(){return e.apply(this,n.concat([].slice.call(arguments)))}}},t=r=>{if(r.length>0&&"/"!==r[0])throw Error("Invalid JSON Pointer");return r.split("/").slice(1).map(a)},e=(r,t,n,o)=>{if(0===r.length)return n;if(r.length>1){if(Array.isArray(t)){const i=r.shift(),s=[...t];return s[i]=e(r,c(t,i,o),n,l(i,o)),s}{const i=r.shift();return{...t,[i]:e(r,c(t,i,o),n,l(i,o))}}}if(Array.isArray(t)){const e=[...t];return e[u(t,r[0])]=n,e}return"object"==typeof t&&null!==t?{...t,[r[0]]:n}:c(t,r[0],o)},n=(r,t,e,o)=>{if(0!==r.length)if(1!==r.length||f(t)){const i=r.shift();n(r,c(t,i,o),e,l(i,o))}else{t[u(t,r[0])]=e}},o=(r,t,e)=>{if(0!=r.length){if(r.length>1){const n=r.shift(),i=c(t,n,e);return{...t,[n]:o(r,i,l(n,e))}}if(Array.isArray(t))return t.filter(((t,e)=>e!=r[0]));if("object"==typeof t&&null!==t){const{[r[0]]:e,...n}=t;return n}return c(t,r[0],e)}},i=(r,t,e)=>{if(0!==r.length)if(r.length>1){const n=r.shift(),o=c(t,n,e);i(r,o,l(n,e))}else Array.isArray(t)?t.splice(r[0],1):"object"==typeof t&&null!==t?delete t[r[0]]:c(t,r[0],e)},l=r(((r,t)=>t+"/"+s(r))),s=r=>r.toString().replace(/~/g,"~0").replace(/\//g,"~1"),a=r=>r.toString().replace(/~1/g,"/").replace(/~0/g,"~"),u=(r,t)=>Array.isArray(r)&&"-"===t?r.length:t,c=(r,t,e="")=>{if(void 0===r)throw TypeError(`Value at '${e}' is undefined and does not have property '${t}'`);if(null===r)throw TypeError(`Value at '${e}' is null and does not have property '${t}'`);if(f(r))throw TypeError(`Value at '${e}' is a ${typeof r} and does not have property '${t}'`);return r[u(r,t)]},f=r=>null===r||"object"!=typeof r;var p={nil:"",append:l,get:(r,e)=>{const n=t(r),o=r=>n.reduce((([r,t],e)=>[c(r,e,t),l(e,t)]),[r,""])[0];return void 0===e?o:o(e)},set:(n,o,i)=>{const l=t(n),s=r(((r,t)=>e(l,r,t,"")));return void 0===o?s:s(o,i)},assign:(e,o,i)=>{const l=t(e),s=r(((r,t)=>n(l,r,t,"")));return void 0===o?s:s(o,i)},unset:(r,e)=>{const n=t(r),i=r=>o(n,r,"");return void 0===e?i:i(e)},remove:(r,e)=>{const n=t(r),o=r=>i(n,r,"");return void 0===e?o:o(e)}};export{p as default}; | ||
//# sourceMappingURL=json-pointer-esm.min.js.map |
@@ -78,4 +78,11 @@ var JsonPointer = (function () { | ||
} else if (pointer.length > 1) { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
if (Array.isArray(subject)) { | ||
const index = pointer.shift(); | ||
const clonedSubject = [...subject]; | ||
clonedSubject[index] = _set(pointer, applySegment(subject, index, cursor), value, append(index, cursor)); | ||
return clonedSubject; | ||
} else { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
} | ||
} else if (Array.isArray(subject)) { | ||
@@ -182,3 +189,3 @@ const clonedSubject = [...subject]; | ||
}()); | ||
})(); | ||
//# sourceMappingURL=json-pointer-iife.js.map |
@@ -1,2 +0,2 @@ | ||
var JsonPointer=function(){"use strict";const r=function(r,t){return function e(){null==t&&(t=r.length);var n=[].slice.call(arguments);return n.length>=t?r.apply(this,n):function(){return e.apply(this,n.concat([].slice.call(arguments)))}}},t=r=>{if(r.length>0&&"/"!==r[0])throw Error("Invalid JSON Pointer");return r.split("/").slice(1).map(u)},e=(r,t,n,o)=>{if(0===r.length)return n;if(r.length>1){const i=r.shift();return{...t,[i]:e(r,c(t,i,o),n,l(i,o))}}if(Array.isArray(t)){const e=[...t];return e[a(t,r[0])]=n,e}return"object"==typeof t&&null!==t?{...t,[r[0]]:n}:c(t,r[0],o)},n=(r,t,e,o)=>{if(0!==r.length)if(1!==r.length||f(t)){const i=r.shift();n(r,c(t,i,o),e,l(i,o))}else{t[a(t,r[0])]=e}},o=(r,t,e)=>{if(0!=r.length){if(r.length>1){const n=r.shift(),i=c(t,n,e);return{...t,[n]:o(r,i,l(n,e))}}if(Array.isArray(t))return t.filter(((t,e)=>e!=r[0]));if("object"==typeof t&&null!==t){const{[r[0]]:e,...n}=t;return n}return c(t,r[0],e)}},i=(r,t,e)=>{if(0!==r.length)if(r.length>1){const n=r.shift(),o=c(t,n,e);i(r,o,l(n,e))}else Array.isArray(t)?t.splice(r[0],1):"object"==typeof t&&null!==t?delete t[r[0]]:c(t,r[0],e)},l=r(((r,t)=>t+"/"+s(r))),s=r=>r.toString().replace(/~/g,"~0").replace(/\//g,"~1"),u=r=>r.toString().replace(/~1/g,"/").replace(/~0/g,"~"),a=(r,t)=>Array.isArray(r)&&"-"===t?r.length:t,c=(r,t,e="")=>{if(void 0===r)throw TypeError(`Value at '${e}' is undefined and does not have property '${t}'`);if(null===r)throw TypeError(`Value at '${e}' is null and does not have property '${t}'`);if(f(r))throw TypeError(`Value at '${e}' is a ${typeof r} and does not have property '${t}'`);return r[a(r,t)]},f=r=>null===r||"object"!=typeof r;return{nil:"",append:l,get:(r,e)=>{const n=t(r),o=r=>n.reduce((([r,t],e)=>[c(r,e,t),l(e,t)]),[r,""])[0];return void 0===e?o:o(e)},set:(n,o,i)=>{const l=t(n),s=r(((r,t)=>e(l,r,t,"")));return void 0===o?s:s(o,i)},assign:(e,o,i)=>{const l=t(e),s=r(((r,t)=>n(l,r,t,"")));return void 0===o?s:s(o,i)},unset:(r,e)=>{const n=t(r),i=r=>o(n,r,"");return void 0===e?i:i(e)},remove:(r,e)=>{const n=t(r),o=r=>i(n,r,"");return void 0===e?o:o(e)}}}(); | ||
var JsonPointer=function(){"use strict";var r=function(r,t){return function e(){null==t&&(t=r.length);var n=[].slice.call(arguments);return n.length>=t?r.apply(this,n):function(){return e.apply(this,n.concat([].slice.call(arguments)))}}};const t=r,e=r=>{if(r.length>0&&"/"!==r[0])throw Error("Invalid JSON Pointer");return r.split("/").slice(1).map(u)},n=(r,t,e,i)=>{if(0===r.length)return e;if(r.length>1){if(Array.isArray(t)){const o=r.shift(),l=[...t];return l[o]=n(r,f(t,o,i),e,s(o,i)),l}{const o=r.shift();return{...t,[o]:n(r,f(t,o,i),e,s(o,i))}}}if(Array.isArray(t)){const n=[...t];return n[c(t,r[0])]=e,n}return"object"==typeof t&&null!==t?{...t,[r[0]]:e}:f(t,r[0],i)},i=(r,t,e,n)=>{if(0!==r.length)if(1!==r.length||p(t)){const o=r.shift();i(r,f(t,o,n),e,s(o,n))}else{t[c(t,r[0])]=e}},o=(r,t,e)=>{if(0!=r.length){if(r.length>1){const n=r.shift(),i=f(t,n,e);return{...t,[n]:o(r,i,s(n,e))}}if(Array.isArray(t))return t.filter(((t,e)=>e!=r[0]));if("object"==typeof t&&null!==t){const{[r[0]]:e,...n}=t;return n}return f(t,r[0],e)}},l=(r,t,e)=>{if(0!==r.length)if(r.length>1){const n=r.shift(),i=f(t,n,e);l(r,i,s(n,e))}else Array.isArray(t)?t.splice(r[0],1):"object"==typeof t&&null!==t?delete t[r[0]]:f(t,r[0],e)},s=t(((r,t)=>t+"/"+a(r))),a=r=>r.toString().replace(/~/g,"~0").replace(/\//g,"~1"),u=r=>r.toString().replace(/~1/g,"/").replace(/~0/g,"~"),c=(r,t)=>Array.isArray(r)&&"-"===t?r.length:t,f=(r,t,e="")=>{if(void 0===r)throw TypeError(`Value at '${e}' is undefined and does not have property '${t}'`);if(null===r)throw TypeError(`Value at '${e}' is null and does not have property '${t}'`);if(p(r))throw TypeError(`Value at '${e}' is a ${typeof r} and does not have property '${t}'`);return r[c(r,t)]},p=r=>null===r||"object"!=typeof r;return{nil:"",append:s,get:(r,t)=>{const n=e(r),i=r=>n.reduce((([r,t],e)=>[f(r,e,t),s(e,t)]),[r,""])[0];return void 0===t?i:i(t)},set:(r,i,o)=>{const l=e(r),s=t(((r,t)=>n(l,r,t,"")));return void 0===i?s:s(i,o)},assign:(r,n,o)=>{const l=e(r),s=t(((r,t)=>i(l,r,t,"")));return void 0===n?s:s(n,o)},unset:(r,t)=>{const n=e(r),i=r=>o(n,r,"");return void 0===t?i:i(t)},remove:(r,t)=>{const n=e(r),i=r=>l(n,r,"");return void 0===t?i:i(t)}}}(); | ||
//# sourceMappingURL=json-pointer-iife.min.js.map |
@@ -1,5 +0,5 @@ | ||
System.register('JsonPointer', [], function (exports) { | ||
System.register('JsonPointer', [], (function (exports) { | ||
'use strict'; | ||
return { | ||
execute: function () { | ||
execute: (function () { | ||
@@ -80,4 +80,11 @@ var justCurryIt = curry$1; | ||
} else if (pointer.length > 1) { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
if (Array.isArray(subject)) { | ||
const index = pointer.shift(); | ||
const clonedSubject = [...subject]; | ||
clonedSubject[index] = _set(pointer, applySegment(subject, index, cursor), value, append(index, cursor)); | ||
return clonedSubject; | ||
} else { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
} | ||
} else if (Array.isArray(subject)) { | ||
@@ -182,5 +189,5 @@ const clonedSubject = [...subject]; | ||
} | ||
}) | ||
}; | ||
}); | ||
})); | ||
//# sourceMappingURL=json-pointer-system.js.map |
@@ -1,2 +0,2 @@ | ||
System.register("JsonPointer",[],(function(e){"use strict";return{execute:function(){const t=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}},r=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(a)},n=(e,t,r,o)=>{if(0===e.length)return r;if(e.length>1){const i=e.shift();return{...t,[i]:n(e,f(t,i,o),r,s(i,o))}}if(Array.isArray(t)){const n=[...t];return n[c(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:f(t,e[0],o)},o=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const i=e.shift();o(e,f(t,i,n),r,s(i,n))}else{t[c(t,e[0])]=r}},i=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=f(t,n,r);return{...t,[n]:i(e,o,s(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return f(t,e[0],r)}},l=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=f(t,n,r);l(e,o,s(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:f(t,e[0],r)},s=t(((e,t)=>t+"/"+u(e))),u=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),a=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),c=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,f=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[c(e,t)]},p=e=>null===e||"object"!=typeof e;e("default",{nil:"",append:s,get:(e,t)=>{const n=r(e),o=e=>n.reduce((([e,t],r)=>[f(e,r,t),s(r,t)]),[e,""])[0];return void 0===t?o:o(t)},set:(e,o,i)=>{const l=r(e),s=t(((e,t)=>n(l,e,t,"")));return void 0===o?s:s(o,i)},assign:(e,n,i)=>{const l=r(e),s=t(((e,t)=>o(l,e,t,"")));return void 0===n?s:s(n,i)},unset:(e,t)=>{const n=r(e),o=e=>i(n,e,"");return void 0===t?o:o(t)},remove:(e,t)=>{const n=r(e),o=e=>l(n,e,"");return void 0===t?o:o(t)}})}}})); | ||
System.register("JsonPointer",[],(function(r){"use strict";return{execute:function(){var t=function(r,t){return function e(){null==t&&(t=r.length);var n=[].slice.call(arguments);return n.length>=t?r.apply(this,n):function(){return e.apply(this,n.concat([].slice.call(arguments)))}}};const e=t,n=r=>{if(r.length>0&&"/"!==r[0])throw Error("Invalid JSON Pointer");return r.split("/").slice(1).map(c)},i=(r,t,e,n)=>{if(0===r.length)return e;if(r.length>1){if(Array.isArray(t)){const o=r.shift(),l=[...t];return l[o]=i(r,p(t,o,n),e,u(o,n)),l}{const o=r.shift();return{...t,[o]:i(r,p(t,o,n),e,u(o,n))}}}if(Array.isArray(t)){const n=[...t];return n[f(t,r[0])]=e,n}return"object"==typeof t&&null!==t?{...t,[r[0]]:e}:p(t,r[0],n)},o=(r,t,e,n)=>{if(0!==r.length)if(1!==r.length||h(t)){const i=r.shift();o(r,p(t,i,n),e,u(i,n))}else{t[f(t,r[0])]=e}},l=(r,t,e)=>{if(0!=r.length){if(r.length>1){const n=r.shift(),i=p(t,n,e);return{...t,[n]:l(r,i,u(n,e))}}if(Array.isArray(t))return t.filter(((t,e)=>e!=r[0]));if("object"==typeof t&&null!==t){const{[r[0]]:e,...n}=t;return n}return p(t,r[0],e)}},s=(r,t,e)=>{if(0!==r.length)if(r.length>1){const n=r.shift(),i=p(t,n,e);s(r,i,u(n,e))}else Array.isArray(t)?t.splice(r[0],1):"object"==typeof t&&null!==t?delete t[r[0]]:p(t,r[0],e)},u=e(((r,t)=>t+"/"+a(r))),a=r=>r.toString().replace(/~/g,"~0").replace(/\//g,"~1"),c=r=>r.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(r,t)=>Array.isArray(r)&&"-"===t?r.length:t,p=(r,t,e="")=>{if(void 0===r)throw TypeError(`Value at '${e}' is undefined and does not have property '${t}'`);if(null===r)throw TypeError(`Value at '${e}' is null and does not have property '${t}'`);if(h(r))throw TypeError(`Value at '${e}' is a ${typeof r} and does not have property '${t}'`);return r[f(r,t)]},h=r=>null===r||"object"!=typeof r;r("default",{nil:"",append:u,get:(r,t)=>{const e=n(r),i=r=>e.reduce((([r,t],e)=>[p(r,e,t),u(e,t)]),[r,""])[0];return void 0===t?i:i(t)},set:(r,t,o)=>{const l=n(r),s=e(((r,t)=>i(l,r,t,"")));return void 0===t?s:s(t,o)},assign:(r,t,i)=>{const l=n(r),s=e(((r,t)=>o(l,r,t,"")));return void 0===t?s:s(t,i)},unset:(r,t)=>{const e=n(r),i=r=>l(e,r,"");return void 0===t?i:i(t)},remove:(r,t)=>{const e=n(r),i=r=>s(e,r,"");return void 0===t?i:i(t)}})}}})); | ||
//# sourceMappingURL=json-pointer-system.min.js.map |
@@ -5,3 +5,3 @@ (function (global, factory) { | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.JsonPointer = factory()); | ||
}(this, (function () { 'use strict'; | ||
})(this, (function () { 'use strict'; | ||
@@ -82,4 +82,11 @@ var justCurryIt = curry$1; | ||
} else if (pointer.length > 1) { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
if (Array.isArray(subject)) { | ||
const index = pointer.shift(); | ||
const clonedSubject = [...subject]; | ||
clonedSubject[index] = _set(pointer, applySegment(subject, index, cursor), value, append(index, cursor)); | ||
return clonedSubject; | ||
} else { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
} | ||
} else if (Array.isArray(subject)) { | ||
@@ -186,3 +193,3 @@ const clonedSubject = [...subject]; | ||
}))); | ||
})); | ||
//# sourceMappingURL=json-pointer-umd.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).JsonPointer=t()}(this,(function(){"use strict";const e=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}},t=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(u)},r=(e,t,n,o)=>{if(0===e.length)return n;if(e.length>1){const i=e.shift();return{...t,[i]:r(e,a(t,i,o),n,l(i,o))}}if(Array.isArray(t)){const r=[...t];return r[f(t,e[0])]=n,r}return"object"==typeof t&&null!==t?{...t,[e[0]]:n}:a(t,e[0],o)},n=(e,t,r,o)=>{if(0!==e.length)if(1!==e.length||c(t)){const i=e.shift();n(e,a(t,i,o),r,l(i,o))}else{t[f(t,e[0])]=r}},o=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),i=a(t,n,r);return{...t,[n]:o(e,i,l(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return a(t,e[0],r)}},i=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=a(t,n,r);i(e,o,l(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:a(t,e[0],r)},l=e(((e,t)=>t+"/"+s(e))),s=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),u=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),f=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,a=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(c(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[f(e,t)]},c=e=>null===e||"object"!=typeof e;return{nil:"",append:l,get:(e,r)=>{const n=t(e),o=e=>n.reduce((([e,t],r)=>[a(e,r,t),l(r,t)]),[e,""])[0];return void 0===r?o:o(r)},set:(n,o,i)=>{const l=t(n),s=e(((e,t)=>r(l,e,t,"")));return void 0===o?s:s(o,i)},assign:(r,o,i)=>{const l=t(r),s=e(((e,t)=>n(l,e,t,"")));return void 0===o?s:s(o,i)},unset:(e,r)=>{const n=t(e),i=e=>o(n,e,"");return void 0===r?i:i(r)},remove:(e,r)=>{const n=t(e),o=e=>i(n,e,"");return void 0===r?o:o(r)}}})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).JsonPointer=t()}(this,(function(){"use strict";var e=function(e,t){return function r(){null==t&&(t=e.length);var n=[].slice.call(arguments);return n.length>=t?e.apply(this,n):function(){return r.apply(this,n.concat([].slice.call(arguments)))}}};const t=e,r=e=>{if(e.length>0&&"/"!==e[0])throw Error("Invalid JSON Pointer");return e.split("/").slice(1).map(u)},n=(e,t,r,o)=>{if(0===e.length)return r;if(e.length>1){if(Array.isArray(t)){const i=e.shift(),l=[...t];return l[i]=n(e,c(t,i,o),r,s(i,o)),l}{const i=e.shift();return{...t,[i]:n(e,c(t,i,o),r,s(i,o))}}}if(Array.isArray(t)){const n=[...t];return n[a(t,e[0])]=r,n}return"object"==typeof t&&null!==t?{...t,[e[0]]:r}:c(t,e[0],o)},o=(e,t,r,n)=>{if(0!==e.length)if(1!==e.length||p(t)){const i=e.shift();o(e,c(t,i,n),r,s(i,n))}else{t[a(t,e[0])]=r}},i=(e,t,r)=>{if(0!=e.length){if(e.length>1){const n=e.shift(),o=c(t,n,r);return{...t,[n]:i(e,o,s(n,r))}}if(Array.isArray(t))return t.filter(((t,r)=>r!=e[0]));if("object"==typeof t&&null!==t){const{[e[0]]:r,...n}=t;return n}return c(t,e[0],r)}},l=(e,t,r)=>{if(0!==e.length)if(e.length>1){const n=e.shift(),o=c(t,n,r);l(e,o,s(n,r))}else Array.isArray(t)?t.splice(e[0],1):"object"==typeof t&&null!==t?delete t[e[0]]:c(t,e[0],r)},s=t(((e,t)=>t+"/"+f(e))),f=e=>e.toString().replace(/~/g,"~0").replace(/\//g,"~1"),u=e=>e.toString().replace(/~1/g,"/").replace(/~0/g,"~"),a=(e,t)=>Array.isArray(e)&&"-"===t?e.length:t,c=(e,t,r="")=>{if(void 0===e)throw TypeError(`Value at '${r}' is undefined and does not have property '${t}'`);if(null===e)throw TypeError(`Value at '${r}' is null and does not have property '${t}'`);if(p(e))throw TypeError(`Value at '${r}' is a ${typeof e} and does not have property '${t}'`);return e[a(e,t)]},p=e=>null===e||"object"!=typeof e;return{nil:"",append:s,get:(e,t)=>{const n=r(e),o=e=>n.reduce((([e,t],r)=>[c(e,r,t),s(r,t)]),[e,""])[0];return void 0===t?o:o(t)},set:(e,o,i)=>{const l=r(e),s=t(((e,t)=>n(l,e,t,"")));return void 0===o?s:s(o,i)},assign:(e,n,i)=>{const l=r(e),s=t(((e,t)=>o(l,e,t,"")));return void 0===n?s:s(n,i)},unset:(e,t)=>{const n=r(e),o=e=>i(n,e,"");return void 0===t?o:o(t)},remove:(e,t)=>{const n=r(e),o=e=>l(n,e,"");return void 0===t?o:o(t)}}})); | ||
//# sourceMappingURL=json-pointer-umd.min.js.map |
@@ -34,4 +34,11 @@ const curry = require("just-curry-it"); | ||
} else if (pointer.length > 1) { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
if (Array.isArray(subject)) { | ||
const index = pointer.shift(); | ||
const clonedSubject = [...subject]; | ||
clonedSubject[index] = _set(pointer, applySegment(subject, index, cursor), value, append(index, cursor)); | ||
return clonedSubject; | ||
} else { | ||
const segment = pointer.shift(); | ||
return { ...subject, [segment]: _set(pointer, applySegment(subject, segment, cursor), value, append(segment, cursor)) }; | ||
} | ||
} else if (Array.isArray(subject)) { | ||
@@ -38,0 +45,0 @@ const clonedSubject = [...subject]; |
{ | ||
"name": "@hyperjump/json-pointer", | ||
"version": "0.9.4", | ||
"version": "0.9.5", | ||
"description": "An RFC-6901 JSON Pointer implementation", | ||
@@ -30,23 +30,23 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@rollup/plugin-commonjs": "^20.0.0", | ||
"@rollup/plugin-node-resolve": "^13.0.4", | ||
"@types/chai": "^4.2.21", | ||
"@types/mocha": "^9.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.29.3", | ||
"@typescript-eslint/parser": "^4.29.3", | ||
"chai": "^4.3.4", | ||
"eslint": "^7.32.0", | ||
"eslint-import-resolver-node": "^0.3.6", | ||
"eslint-import-resolver-typescript": "^2.4.0", | ||
"eslint-plugin-import": "^2.24.2", | ||
"mocha": "^9.1.1", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.56.3", | ||
"rollup-plugin-terser": "^7.0.2", | ||
"ts-node": "^10.2.1", | ||
"typescript": "^4.4.2" | ||
"@rollup/plugin-commonjs": "*", | ||
"@rollup/plugin-node-resolve": "*", | ||
"@types/chai": "*", | ||
"@types/mocha": "*", | ||
"@typescript-eslint/eslint-plugin": "*", | ||
"@typescript-eslint/parser": "*", | ||
"chai": "*", | ||
"eslint": "*", | ||
"eslint-import-resolver-node": "*", | ||
"eslint-import-resolver-typescript": "*", | ||
"eslint-plugin-import": "*", | ||
"mocha": "*", | ||
"rimraf": "*", | ||
"rollup": "*", | ||
"rollup-plugin-terser": "*", | ||
"ts-node": "*", | ||
"typescript": "*" | ||
}, | ||
"dependencies": { | ||
"just-curry-it": "^3.2.1" | ||
"just-curry-it": "^5.2.1" | ||
} | ||
} |
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
206889
1213
+ Addedjust-curry-it@5.3.0(transitive)
- Removedjust-curry-it@3.2.1(transitive)
Updatedjust-curry-it@^5.2.1