Socket
Socket
Sign inDemoInstall

json-ptr

Package Overview
Dependencies
Maintainers
1
Versions
91
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

json-ptr - npm Package Compare versions

Comparing version 3.1.2-dependabot-npm-and-yarn-json5-2-2-3.c209166 to 3.1.2-dependabot-npm-and-yarn-webpack-5-76-0.29bfad0

2

dist/json-ptr.min.js

@@ -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 s(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 f(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:()=>s,decodePointerSegments:()=>i,decodePtrInit:()=>b,decodeRelativePointer:()=>h,decodeUriFragmentIdentifier:()=>u,encodeFragmentSegments:()=>o,encodePointer:()=>f,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,s=e,f=r.length,u=r.length-1,p=-1;++p<f;){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(s)){if("-"===o&&p===u)return void s.push(t);if(a=l(s,o),s.length>a){if(p===u){i=s[a],s[a]=t;break}s=s[a]}else if(p===u&&a===s.length){if(n)return void s.push(t)}else n&&(s=s[a]=p===u?t:{})}else{if(void 0===s[o]){if(n){if(p===u)return void(s[o]=t);var c=Number(r[p+1]);if(Number.isInteger(c)&&-1!==l(s[o],c)){s=s[o]=[];continue}s=s[o]={};continue}return}if(p===u){i=s[o],s[o]=t;break}s=s[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,s=t.length-1,f=-1;++f<a;){if("string"!=typeof(r=t[f])&&"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(f===s){n=i[o],delete i[o];break}i=i[o]}else{if(void 0===i[r])return;if(f===s){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:s}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,s=i.path;if(t(r(s),a),A(a))if(n.set(a,new E(p(s))),Array.isArray(a)){var f=-1;for(h=a.length;++f<h;){var u=a[f];m(u)&&n.has(u)?o.push({obj:new O(n.get(u)),path:s.concat([f+""])}):o.push({obj:u,path:s.concat([f+""])})}}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:s.concat(c[l])}):o.push({obj:g,path:s.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:f)},e.listPointers=function(e){var t=[];return P(e,(function(e,r){t.push({pointer:e,value:r})}),f),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:f),r},e.map=function(e,t){void 0===t&&(t=!1);var r=new Map;return P(e,r.set.bind(r),t?p:f),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)),s=new e(a);if("#"==o[0][o[0].length-1]){var f=a[a.length-1],u=s.parent(t);return Array.isArray(u)?parseInt(f,10):f}return s.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]=f(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,(()=>(()=>{"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 s(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 f(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:()=>s,decodePointerSegments:()=>i,decodePtrInit:()=>b,decodeRelativePointer:()=>h,decodeUriFragmentIdentifier:()=>u,encodeFragmentSegments:()=>o,encodePointer:()=>f,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,s=e,f=r.length,u=r.length-1,p=-1;++p<f;){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(s)){if("-"===o&&p===u)return void s.push(t);if(a=l(s,o),s.length>a){if(p===u){i=s[a],s[a]=t;break}s=s[a]}else if(p===u&&a===s.length){if(n)return void s.push(t)}else n&&(s=s[a]=p===u?t:{})}else{if(void 0===s[o]){if(n){if(p===u)return void(s[o]=t);var c=Number(r[p+1]);if(Number.isInteger(c)&&-1!==l(s[o],c)){s=s[o]=[];continue}s=s[o]={};continue}return}if(p===u){i=s[o],s[o]=t;break}s=s[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,s=t.length-1,f=-1;++f<a;){if("string"!=typeof(r=t[f])&&"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(f===s){n=i[o],delete i[o];break}i=i[o]}else{if(void 0===i[r])return;if(f===s){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:s}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,s=i.path;if(t(r(s),a),A(a))if(n.set(a,new E(p(s))),Array.isArray(a)){var f=-1;for(h=a.length;++f<h;){var u=a[f];m(u)&&n.has(u)?o.push({obj:new O(n.get(u)),path:s.concat([f+""])}):o.push({obj:u,path:s.concat([f+""])})}}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:s.concat(c[l])}):o.push({obj:g,path:s.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:f)},e.listPointers=function(e){var t=[];return P(e,(function(e,r){t.push({pointer:e,value:r})}),f),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:f),r},e.map=function(e,t){void 0===t&&(t=!1);var r=new Map;return P(e,r.set.bind(r),t?p:f),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)),s=new e(a);if("#"==o[0][o[0].length-1]){var f=a[a.length-1],u=s.parent(t);return Array.isArray(u)?parseInt(f,10):f}return s.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]=f(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.1.2-dependabot-npm-and-yarn-json5-2-2-3.c209166",
"version": "3.1.2-dependabot-npm-and-yarn-webpack-5-76-0.29bfad0",
"author": "Phillip Clark <phillip@flitbit.com>",

@@ -5,0 +5,0 @@ "description": "A complete implementation of JSON Pointer (RFC 6901) for nodejs and modern browsers.",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc