Comparing version 3.0.1-master.55c1dd5 to 3.0.1-master.cb11e0b
@@ -312,3 +312,3 @@ 'use strict'; | ||
function looksLikeFragment(ptr) { | ||
return ptr?.length > 0 && ptr[0] === '#'; | ||
return typeof ptr === 'string' && ptr.length > 0 && ptr[0] === '#'; | ||
} | ||
@@ -504,9 +504,10 @@ function pickDecoder(ptr) { | ||
class JsonPointer { | ||
/** @hidden */ | ||
[$ptr]; | ||
/** @hidden */ | ||
[$frg]; | ||
/** @hidden */ | ||
[$get]; | ||
/** | ||
* Creates a new instance. | ||
* @param ptr a string representation of a JSON Pointer, or a decoded array of path segments. | ||
*/ | ||
constructor(ptr) { | ||
this.path = decodePtrInit(ptr); | ||
} | ||
/** | ||
* Factory function that creates a JsonPointer instance. | ||
@@ -715,13 +716,2 @@ * | ||
/** | ||
* The pointer's decoded path segments. | ||
*/ | ||
path; | ||
/** | ||
* Creates a new instance. | ||
* @param ptr a string representation of a JSON Pointer, or a decoded array of path segments. | ||
*/ | ||
constructor(ptr) { | ||
this.path = decodePtrInit(ptr); | ||
} | ||
/** | ||
* Gets the target object's value at the pointer's location. | ||
@@ -862,2 +852,11 @@ * @param target the target of the operation | ||
/** | ||
* Creates a new instance. | ||
* @param pointer a JSON Pointer for the reference. | ||
*/ | ||
constructor(pointer) { | ||
this[$pointer] = | ||
pointer instanceof JsonPointer ? pointer : new JsonPointer(pointer); | ||
this.$ref = this[$pointer].uriFragmentIdentifier; | ||
} | ||
/** | ||
* Determines if the specified `candidate` is a JsonReference. | ||
@@ -872,18 +871,3 @@ * @param candidate the candidate | ||
} | ||
/** @hidden */ | ||
[$pointer]; | ||
/** | ||
* A reference to a position if an object graph. | ||
*/ | ||
$ref; | ||
/** | ||
* Creates a new instance. | ||
* @param pointer a JSON Pointer for the reference. | ||
*/ | ||
constructor(pointer) { | ||
this[$pointer] = | ||
pointer instanceof JsonPointer ? pointer : new JsonPointer(pointer); | ||
this.$ref = this[$pointer].uriFragmentIdentifier; | ||
} | ||
/** | ||
* Resolves the reference against the `target` object, returning the value at | ||
@@ -890,0 +874,0 @@ * the referenced pointer's location. |
@@ -308,3 +308,3 @@ function replace(source, find, repl) { | ||
function looksLikeFragment(ptr) { | ||
return ptr?.length > 0 && ptr[0] === '#'; | ||
return typeof ptr === 'string' && ptr.length > 0 && ptr[0] === '#'; | ||
} | ||
@@ -500,9 +500,10 @@ function pickDecoder(ptr) { | ||
class JsonPointer { | ||
/** @hidden */ | ||
[$ptr]; | ||
/** @hidden */ | ||
[$frg]; | ||
/** @hidden */ | ||
[$get]; | ||
/** | ||
* Creates a new instance. | ||
* @param ptr a string representation of a JSON Pointer, or a decoded array of path segments. | ||
*/ | ||
constructor(ptr) { | ||
this.path = decodePtrInit(ptr); | ||
} | ||
/** | ||
* Factory function that creates a JsonPointer instance. | ||
@@ -711,13 +712,2 @@ * | ||
/** | ||
* The pointer's decoded path segments. | ||
*/ | ||
path; | ||
/** | ||
* Creates a new instance. | ||
* @param ptr a string representation of a JSON Pointer, or a decoded array of path segments. | ||
*/ | ||
constructor(ptr) { | ||
this.path = decodePtrInit(ptr); | ||
} | ||
/** | ||
* Gets the target object's value at the pointer's location. | ||
@@ -858,2 +848,11 @@ * @param target the target of the operation | ||
/** | ||
* Creates a new instance. | ||
* @param pointer a JSON Pointer for the reference. | ||
*/ | ||
constructor(pointer) { | ||
this[$pointer] = | ||
pointer instanceof JsonPointer ? pointer : new JsonPointer(pointer); | ||
this.$ref = this[$pointer].uriFragmentIdentifier; | ||
} | ||
/** | ||
* Determines if the specified `candidate` is a JsonReference. | ||
@@ -868,18 +867,3 @@ * @param candidate the candidate | ||
} | ||
/** @hidden */ | ||
[$pointer]; | ||
/** | ||
* A reference to a position if an object graph. | ||
*/ | ||
$ref; | ||
/** | ||
* Creates a new instance. | ||
* @param pointer a JSON Pointer for the reference. | ||
*/ | ||
constructor(pointer) { | ||
this[$pointer] = | ||
pointer instanceof JsonPointer ? pointer : new JsonPointer(pointer); | ||
this.$ref = this[$pointer].uriFragmentIdentifier; | ||
} | ||
/** | ||
* Resolves the reference against the `target` object, returning the value at | ||
@@ -886,0 +870,0 @@ * the referenced pointer's location. |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("JsonPointer",[],t):"object"==typeof exports?exports.JsonPointer=t():e.JsonPointer=t()}(self,(function(){return(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e,t,r){for(var n="",o=e,i=0,a=-1;(a=o.indexOf(t))>-1;)n+=e.substring(i,i+a)+r,o=o.substring(a+t.length,o.length),i+=a+t.length;return o.length>0&&(n+=e.substring(e.length-o.length,e.length)),n}function n(e){for(var t=-1,n=e.length,o=new Array(n);++t<n;)"string"==typeof e[t]?o[t]=r(r(decodeURIComponent(e[t]),"~1","/"),"~0","~"):o[t]=e[t];return o}function o(e){for(var t=-1,n=e.length,o=new Array(n);++t<n;)"string"==typeof e[t]?o[t]=encodeURIComponent(r(r(e[t],"~","~0"),"/","~1")):o[t]=e[t];return o}function i(e){for(var t=-1,n=e.length,o=new Array(n);++t<n;)"string"==typeof e[t]?o[t]=r(r(e[t],"~1","/"),"~0","~"):o[t]=e[t];return o}function a(e){for(var t=-1,n=e.length,o=new Array(n);++t<n;)"string"==typeof e[t]?o[t]=r(r(e[t],"~","~0"),"/","~1"):o[t]=e[t];return o}function f(e){if("string"!=typeof e)throw new TypeError("Invalid type: JSON Pointers are represented as strings.");if(0===e.length)return[];if("/"!==e[0])throw new ReferenceError("Invalid JSON Pointer syntax. Non-empty pointer must begin with a solidus `/`.");return i(e.substring(1).split("/"))}function s(e){if(!e||e&&!Array.isArray(e))throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"":"/".concat(a(e).join("/"))}function u(e){if("string"!=typeof e)throw new TypeError("Invalid type: JSON Pointers are represented as strings.");if(0===e.length||"#"!==e[0])throw new ReferenceError("Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.");if(1===e.length)return[];if("/"!==e[1])throw new ReferenceError("Invalid JSON Pointer syntax.");return n(e.substring(2).split("/"))}function p(e){if(!e||e&&!Array.isArray(e))throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"#":"#/".concat(o(e).join("/"))}e.r(t),e.d(t,{JsonPointer:()=>E,JsonReference:()=>O,compilePointerDereference:()=>g,decodeFragmentSegments:()=>n,decodePointer:()=>f,decodePointerSegments:()=>i,decodePtrInit:()=>b,decodeRelativePointer:()=>h,decodeUriFragmentIdentifier:()=>u,encodeFragmentSegments:()=>o,encodePointer:()=>s,encodePointerSegments:()=>a,encodeUriFragmentIdentifier:()=>p,looksLikeFragment:()=>v,pickDecoder:()=>w,replace:()=>r,setValueAtPath:()=>y,toArrayIndexReference:()=>l,unsetValueAtPath:()=>d});var c="Invalid Relative JSON Pointer syntax. Relative pointer must begin with a non-negative integer, followed by either the number sign (#), or a JSON Pointer.";function h(e){if("string"!=typeof e)throw new TypeError("Invalid type: Relative JSON Pointers are represented as strings.");if(0===e.length)throw new ReferenceError(c);var t=e.split("/"),r=t[0];if("#"==r[r.length-1]){if(t.length>1)throw new ReferenceError(c);r=r.substr(0,r.length-1)}for(var n=-1,o=r.length;++n<o;)if(r[n]<"0"||r[n]>"9")throw new ReferenceError(c);var a=i(t.slice(1));return a.unshift(t[0]),a}function l(e,t){if("number"==typeof t)return t;var r=t.length;if(!r)return-1;var n=0;if(1===r&&"-"===t[0])return Array.isArray(e)?e.length:0;for(;++n<r;)if(t[n]<"0"||t[n]>"9")return-1;return parseInt(t,10)}function g(e){var t="if (typeof(it) !== 'undefined'";return 0===e.length?function(e){return e}:(t=e.reduce((function(t,n,o){return t+"\n\t&& it !== null && typeof((it = it['"+r(r(e[o]+"","\\","\\\\"),"'","\\'")+"'])) !== 'undefined'"}),"if (typeof(it) !== 'undefined'"),t+=") {\n\treturn it;\n }",new Function("it",t))}function y(e,t,r,n){if(void 0===n&&(n=!1),0===r.length)throw new Error("Cannot set the root object; assign it directly.");if(void 0===e)throw new TypeError("Cannot set values on undefined");for(var o,i,a,f=e,s=r.length,u=r.length-1,p=-1;++p<s;){if("string"!=typeof(o=r[p])&&"number"!=typeof o)throw new TypeError("PathSegments must be a string or a number.");if("__proto__"===o||"constructor"===o||"prototype"===o)throw new Error("Attempted prototype pollution disallowed.");if(Array.isArray(f)){if("-"===o&&p===u)return void f.push(t);if(a=l(f,o),f.length>a){if(p===u){i=f[a],f[a]=t;break}f=f[a]}else if(p===u&&a===f.length){if(n)return void f.push(t)}else n&&(f=f[a]=p===u?t:{})}else{if(void 0===f[o]){if(n){if(p===u)return void(f[o]=t);if(-1!==l(f[o],r[p+1])){f=f[o]=[];continue}f=f[o]={};continue}return}if(p===u){i=f[o],f[o]=t;break}f=f[o]}}return i}function d(e,t){if(0===t.length)throw new Error("Cannot unset the root object; assign it directly.");if(void 0===e)throw new TypeError("Cannot unset values on undefined");for(var r,n,o,i=e,a=t.length,f=t.length-1,s=-1;++s<a;){if("string"!=typeof(r=t[s])&&"number"!=typeof r)throw new TypeError("PathSegments must be a string or a number.");if("__proto__"===r||"constructor"===r||"prototype"===r)throw new Error("Attempted prototype pollution disallowed.");if(Array.isArray(i)){if((o=l(i,r))>=i.length)return;if(s===f){n=i[o],delete i[o];break}i=i[o]}else{if(void 0===i[r])return;if(s===f){n=i[r],delete i[r];break}i=i[r]}}return n}function v(e){return(null==e?void 0:e.length)>0&&"#"===e[0]}function w(e){return v(e)?u:f}function b(e){return Array.isArray(e)?e.slice(0):w(e)(e)}function m(e){return"object"==typeof e&&null!==e}function A(e){return m(e)&&!O.isReference(e)}function P(e,t,r){for(var n=new Map,o=[{obj:e,path:[]}];o.length;){var i=o.shift(),a=i.obj,f=i.path;if(t(r(f),a),A(a))if(n.set(a,new E(p(f))),Array.isArray(a)){var s=-1;for(h=a.length;++s<h;){var u=a[s];m(u)&&n.has(u)?o.push({obj:new O(n.get(u)),path:f.concat([s+""])}):o.push({obj:u,path:f.concat([s+""])})}}else for(var c=Object.keys(a),h=c.length,l=-1;++l<h;){var g=a[c[l]];m(g)&&n.has(g)?o.push({obj:new O(n.get(g)),path:f.concat(c[l])}):o.push({obj:g,path:f.concat(c[l])})}}}var I=Symbol("pointer"),S=Symbol("fragmentId"),j=Symbol("getter"),E=function(){function e(e){this.path=b(e)}return e.create=function(t){return new e(t)},e.has=function(t,r){return("string"==typeof r||Array.isArray(r))&&(r=new e(r)),r.has(t)},e.get=function(t,r){return("string"==typeof r||Array.isArray(r))&&(r=new e(r)),r.get(t)},e.set=function(t,r,n,o){return void 0===o&&(o=!1),("string"==typeof r||Array.isArray(r))&&(r=new e(r)),r.set(t,n,o)},e.unset=function(t,r){return("string"==typeof r||Array.isArray(r))&&(r=new e(r)),r.unset(t)},e.decode=function(e){return w(e)(e)},e.visit=function(e,t,r){void 0===r&&(r=!1),P(e,t,r?p:s)},e.listPointers=function(e){var t=[];return P(e,(function(e,r){t.push({pointer:e,value:r})}),s),t},e.listFragmentIds=function(e){var t=[];return P(e,(function(e,r){t.push({fragmentId:e,value:r})}),p),t},e.flatten=function(e,t){void 0===t&&(t=!1);var r={};return P(e,(function(e,t){r[e]=t}),t?p:s),r},e.map=function(e,t){void 0===t&&(t=!1);var r=new Map;return P(e,r.set.bind(r),t?p:s),r},e.prototype.get=function(e){return this[j]||(this[j]=g(this.path)),this[j](e)},e.prototype.set=function(e,t,r){return void 0===r&&(r=!1),y(e,t,this.path,r)},e.prototype.unset=function(e){return d(e,this.path)},e.prototype.has=function(e){return void 0!==this.get(e)},e.prototype.parent=function(t){var r=this.path;if(1!=r.length)return new e(r.slice(0,r.length-1)).get(t)},e.prototype.relative=function(t){var r=this.path,n=h(t),o=parseInt(n[0]);if(o>r.length)throw new Error("Relative location does not exist.");var i=r.slice(0,r.length-o).concat(n.slice(1));if("#"==n[0][n[0].length-1]){var a=i[i.length-1];throw new Error("We won't compile a pointer that will always return '"+a+"'. Use JsonPointer.rel(target, ptr) instead.")}return new e(i)},e.prototype.rel=function(t,r){var n=this.path,o=h(r),i=parseInt(o[0]);if(!(i>n.length)){var a=n.slice(0,n.length-i).concat(o.slice(1)),f=new e(a);if("#"==o[0][o[0].length-1]){var s=a[a.length-1],u=f.parent(t);return Array.isArray(u)?parseInt(s,10):s}return f.get(t)}},e.prototype.concat=function(t){return new e(this.path.concat(t instanceof e?t.path:b(t)))},Object.defineProperty(e.prototype,"pointer",{get:function(){return void 0===this[I]&&(this[I]=s(this.path)),this[I]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uriFragmentIdentifier",{get:function(){return this[S]||(this[S]=p(this.path)),this[S]},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.pointer},e}(),R=Symbol("pointer"),O=function(){function e(e){this[R]=e instanceof E?e:new E(e),this.$ref=this[R].uriFragmentIdentifier}return e.isReference=function(e){if(!e)return!1;var t=e;return"string"==typeof t.$ref&&"function"==typeof t.resolve},e.prototype.resolve=function(e){return this[R].get(e)},e.prototype.pointer=function(){return this[R]},e.prototype.toString=function(){return this.$ref},e}();return t})()})); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("JsonPointer",[],t):"object"==typeof exports?exports.JsonPointer=t():e.JsonPointer=t()}(self,(function(){return(()=>{"use strict";var e={d:(t,r)=>{for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function r(e,t,r){for(var n="",o=e,i=0,a=-1;(a=o.indexOf(t))>-1;)n+=e.substring(i,i+a)+r,o=o.substring(a+t.length,o.length),i+=a+t.length;return o.length>0&&(n+=e.substring(e.length-o.length,e.length)),n}function n(e){for(var t=-1,n=e.length,o=new Array(n);++t<n;)"string"==typeof e[t]?o[t]=r(r(decodeURIComponent(e[t]),"~1","/"),"~0","~"):o[t]=e[t];return o}function o(e){for(var t=-1,n=e.length,o=new Array(n);++t<n;)"string"==typeof e[t]?o[t]=encodeURIComponent(r(r(e[t],"~","~0"),"/","~1")):o[t]=e[t];return o}function i(e){for(var t=-1,n=e.length,o=new Array(n);++t<n;)"string"==typeof e[t]?o[t]=r(r(e[t],"~1","/"),"~0","~"):o[t]=e[t];return o}function a(e){for(var t=-1,n=e.length,o=new Array(n);++t<n;)"string"==typeof e[t]?o[t]=r(r(e[t],"~","~0"),"/","~1"):o[t]=e[t];return o}function f(e){if("string"!=typeof e)throw new TypeError("Invalid type: JSON Pointers are represented as strings.");if(0===e.length)return[];if("/"!==e[0])throw new ReferenceError("Invalid JSON Pointer syntax. Non-empty pointer must begin with a solidus `/`.");return i(e.substring(1).split("/"))}function s(e){if(!e||e&&!Array.isArray(e))throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"":"/".concat(a(e).join("/"))}function u(e){if("string"!=typeof e)throw new TypeError("Invalid type: JSON Pointers are represented as strings.");if(0===e.length||"#"!==e[0])throw new ReferenceError("Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.");if(1===e.length)return[];if("/"!==e[1])throw new ReferenceError("Invalid JSON Pointer syntax.");return n(e.substring(2).split("/"))}function p(e){if(!e||e&&!Array.isArray(e))throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"#":"#/".concat(o(e).join("/"))}e.r(t),e.d(t,{JsonPointer:()=>E,JsonReference:()=>O,compilePointerDereference:()=>g,decodeFragmentSegments:()=>n,decodePointer:()=>f,decodePointerSegments:()=>i,decodePtrInit:()=>b,decodeRelativePointer:()=>h,decodeUriFragmentIdentifier:()=>u,encodeFragmentSegments:()=>o,encodePointer:()=>s,encodePointerSegments:()=>a,encodeUriFragmentIdentifier:()=>p,looksLikeFragment:()=>v,pickDecoder:()=>w,replace:()=>r,setValueAtPath:()=>y,toArrayIndexReference:()=>l,unsetValueAtPath:()=>d});var c="Invalid Relative JSON Pointer syntax. Relative pointer must begin with a non-negative integer, followed by either the number sign (#), or a JSON Pointer.";function h(e){if("string"!=typeof e)throw new TypeError("Invalid type: Relative JSON Pointers are represented as strings.");if(0===e.length)throw new ReferenceError(c);var t=e.split("/"),r=t[0];if("#"==r[r.length-1]){if(t.length>1)throw new ReferenceError(c);r=r.substr(0,r.length-1)}for(var n=-1,o=r.length;++n<o;)if(r[n]<"0"||r[n]>"9")throw new ReferenceError(c);var a=i(t.slice(1));return a.unshift(t[0]),a}function l(e,t){if("number"==typeof t)return t;var r=t.length;if(!r)return-1;var n=0;if(1===r&&"-"===t[0])return Array.isArray(e)?e.length:0;for(;++n<r;)if(t[n]<"0"||t[n]>"9")return-1;return parseInt(t,10)}function g(e){var t="if (typeof(it) !== 'undefined'";return 0===e.length?function(e){return e}:(t=e.reduce((function(t,n,o){return t+"\n\t&& it !== null && typeof((it = it['"+r(r(e[o]+"","\\","\\\\"),"'","\\'")+"'])) !== 'undefined'"}),"if (typeof(it) !== 'undefined'"),t+=") {\n\treturn it;\n }",new Function("it",t))}function y(e,t,r,n){if(void 0===n&&(n=!1),0===r.length)throw new Error("Cannot set the root object; assign it directly.");if(void 0===e)throw new TypeError("Cannot set values on undefined");for(var o,i,a,f=e,s=r.length,u=r.length-1,p=-1;++p<s;){if("string"!=typeof(o=r[p])&&"number"!=typeof o)throw new TypeError("PathSegments must be a string or a number.");if("__proto__"===o||"constructor"===o||"prototype"===o)throw new Error("Attempted prototype pollution disallowed.");if(Array.isArray(f)){if("-"===o&&p===u)return void f.push(t);if(a=l(f,o),f.length>a){if(p===u){i=f[a],f[a]=t;break}f=f[a]}else if(p===u&&a===f.length){if(n)return void f.push(t)}else n&&(f=f[a]=p===u?t:{})}else{if(void 0===f[o]){if(n){if(p===u)return void(f[o]=t);if(-1!==l(f[o],r[p+1])){f=f[o]=[];continue}f=f[o]={};continue}return}if(p===u){i=f[o],f[o]=t;break}f=f[o]}}return i}function d(e,t){if(0===t.length)throw new Error("Cannot unset the root object; assign it directly.");if(void 0===e)throw new TypeError("Cannot unset values on undefined");for(var r,n,o,i=e,a=t.length,f=t.length-1,s=-1;++s<a;){if("string"!=typeof(r=t[s])&&"number"!=typeof r)throw new TypeError("PathSegments must be a string or a number.");if("__proto__"===r||"constructor"===r||"prototype"===r)throw new Error("Attempted prototype pollution disallowed.");if(Array.isArray(i)){if((o=l(i,r))>=i.length)return;if(s===f){n=i[o],delete i[o];break}i=i[o]}else{if(void 0===i[r])return;if(s===f){n=i[r],delete i[r];break}i=i[r]}}return n}function v(e){return"string"==typeof e&&e.length>0&&"#"===e[0]}function w(e){return v(e)?u:f}function b(e){return Array.isArray(e)?e.slice(0):w(e)(e)}function m(e){return"object"==typeof e&&null!==e}function A(e){return m(e)&&!O.isReference(e)}function P(e,t,r){for(var n=new Map,o=[{obj:e,path:[]}];o.length;){var i=o.shift(),a=i.obj,f=i.path;if(t(r(f),a),A(a))if(n.set(a,new E(p(f))),Array.isArray(a)){var s=-1;for(h=a.length;++s<h;){var u=a[s];m(u)&&n.has(u)?o.push({obj:new O(n.get(u)),path:f.concat([s+""])}):o.push({obj:u,path:f.concat([s+""])})}}else for(var c=Object.keys(a),h=c.length,l=-1;++l<h;){var g=a[c[l]];m(g)&&n.has(g)?o.push({obj:new O(n.get(g)),path:f.concat(c[l])}):o.push({obj:g,path:f.concat(c[l])})}}}var I=Symbol("pointer"),S=Symbol("fragmentId"),j=Symbol("getter"),E=function(){function e(e){this.path=b(e)}return e.create=function(t){return new e(t)},e.has=function(t,r){return("string"==typeof r||Array.isArray(r))&&(r=new e(r)),r.has(t)},e.get=function(t,r){return("string"==typeof r||Array.isArray(r))&&(r=new e(r)),r.get(t)},e.set=function(t,r,n,o){return void 0===o&&(o=!1),("string"==typeof r||Array.isArray(r))&&(r=new e(r)),r.set(t,n,o)},e.unset=function(t,r){return("string"==typeof r||Array.isArray(r))&&(r=new e(r)),r.unset(t)},e.decode=function(e){return w(e)(e)},e.visit=function(e,t,r){void 0===r&&(r=!1),P(e,t,r?p:s)},e.listPointers=function(e){var t=[];return P(e,(function(e,r){t.push({pointer:e,value:r})}),s),t},e.listFragmentIds=function(e){var t=[];return P(e,(function(e,r){t.push({fragmentId:e,value:r})}),p),t},e.flatten=function(e,t){void 0===t&&(t=!1);var r={};return P(e,(function(e,t){r[e]=t}),t?p:s),r},e.map=function(e,t){void 0===t&&(t=!1);var r=new Map;return P(e,r.set.bind(r),t?p:s),r},e.prototype.get=function(e){return this[j]||(this[j]=g(this.path)),this[j](e)},e.prototype.set=function(e,t,r){return void 0===r&&(r=!1),y(e,t,this.path,r)},e.prototype.unset=function(e){return d(e,this.path)},e.prototype.has=function(e){return void 0!==this.get(e)},e.prototype.parent=function(t){var r=this.path;if(1!=r.length)return new e(r.slice(0,r.length-1)).get(t)},e.prototype.relative=function(t){var r=this.path,n=h(t),o=parseInt(n[0]);if(o>r.length)throw new Error("Relative location does not exist.");var i=r.slice(0,r.length-o).concat(n.slice(1));if("#"==n[0][n[0].length-1]){var a=i[i.length-1];throw new Error("We won't compile a pointer that will always return '".concat(a,"'. Use JsonPointer.rel(target, ptr) instead."))}return new e(i)},e.prototype.rel=function(t,r){var n=this.path,o=h(r),i=parseInt(o[0]);if(!(i>n.length)){var a=n.slice(0,n.length-i).concat(o.slice(1)),f=new e(a);if("#"==o[0][o[0].length-1]){var s=a[a.length-1],u=f.parent(t);return Array.isArray(u)?parseInt(s,10):s}return f.get(t)}},e.prototype.concat=function(t){return new e(this.path.concat(t instanceof e?t.path:b(t)))},Object.defineProperty(e.prototype,"pointer",{get:function(){return void 0===this[I]&&(this[I]=s(this.path)),this[I]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uriFragmentIdentifier",{get:function(){return this[S]||(this[S]=p(this.path)),this[S]},enumerable:!1,configurable:!0}),e.prototype.toString=function(){return this.pointer},e}(),R=Symbol("pointer"),O=function(){function e(e){this[R]=e instanceof E?e:new E(e),this.$ref=this[R].uriFragmentIdentifier}return e.isReference=function(e){if(!e)return!1;var t=e;return"string"==typeof t.$ref&&"function"==typeof t.resolve},e.prototype.resolve=function(e){return this[R].get(e)},e.prototype.pointer=function(){return this[R]},e.prototype.toString=function(){return this.$ref},e}();return t})()})); | ||
//# sourceMappingURL=json-ptr.min.js.map |
{ | ||
"name": "json-ptr", | ||
"version": "3.0.1-master.55c1dd5", | ||
"version": "3.0.1-master.cb11e0b", | ||
"author": "Phillip Clark <phillip@flitbit.com>", | ||
@@ -56,2 +56,3 @@ "description": "A complete implementation of JSON Pointer (RFC 6901) for nodejs and modern browsers.", | ||
"@rollup/plugin-node-resolve": "^13.0.6", | ||
"@rollup/plugin-typescript": "^8.3.0", | ||
"@types/assert-plus": "^1.0.4", | ||
@@ -58,0 +59,0 @@ "@types/bent": "^7.3.2", |
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 too big to display
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
1500907
38
16956