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 1.1.0 to 1.1.1

6

.vscode/launch.json

@@ -8,2 +8,8 @@ {

{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}/examples/issues/issue-13.js"
},
{
"name": "Run mocha",

@@ -10,0 +16,0 @@ "type": "node",

2

dist/json-ptr.min.js

@@ -1,1 +0,1 @@

!function(e,n){"function"==typeof define&&define.amd?define([],n):"object"==typeof module&&module.exports?module.exports=n():e.returnExports=n()}("undefined"!=typeof self?self:this,function(){var e=this,n=this.JsonPointer;function r(e,n,r){for(var t=e.toString(),i="",o=t,u=0,f=-1;(f=o.indexOf(n))>-1;)i+=t.substring(u,u+f)+r,o=o.substring(f+n.length,o.length),u+=f+n.length;return o.length>0&&(i+=t.substring(t.length-o.length,t.length)),i}function t(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 function(e){for(var n=-1,t=e.length,i=new Array(t);++n<t;)i[n]=r(r(e[n],"~1","/"),"~0","~");return i}(e.substring(1).split("/"))}function i(e){if(e&&!Array.isArray(e))throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"":"/".concat(function(e){for(var n=-1,t=e.length,i=new Array(t);++n<t;)"string"==typeof e[n]?i[n]=r(r(e[n],"~","~0"),"/","~1"):i[n]=e[n];return i}(e).join("/"))}function o(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 idetifiers must begin with a hash.");if(1===e.length)return[];if("/"!==e[1])throw new ReferenceError("Invalid JSON Pointer syntax.");return function(e){for(var n=-1,t=e.length,i=new Array(t);++n<t;)i[n]=r(r(decodeURIComponent(""+e[n]),"~1","/"),"~0","~");return i}(e.substring(2).split("/"))}function u(e){if(e&&!Array.isArray(e))throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"#":"#/".concat(function(e){for(var n=-1,t=e.length,i=new Array(t);++n<t;)"string"==typeof e[n]?i[n]=encodeURIComponent(r(r(e[n],"~","~0"),"/","~1")):i[n]=e[n];return i}(e).join("/"))}function f(e,n){var r=n.length,t=0;if(1===r&&"-"===n[0])return Array.isArray(e)?e.length:0;if(0===r||r>1&&"0"===n[0]||!isFinite(n))return-1;for(;++t<r;)if(n[t]<"0"||n[t]>"9")return-1;return parseInt(n,10)}function a(e,n,r,t){var i,o,u,a,s,l,c,g;if(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");if(i=e,o=r.length,u=r.length-1,a=-1,o)for(;++a<o;)if(s=r[a],Array.isArray(i)){if(l=f(i,s),i.length>l){if(a===u)return c=i[l],i[l]=n,c;i=i[l]}else if(i.length===l){if(a===u)return i.push(n),g;t&&(i=i[l]={})}}else{if(void 0===i[s]){if(t){if(a===u)return i[s]=n,g;if(-1!==f(i[s],r[a+1])){i=i[s]=[];continue}i=i[s]={};continue}return g}if(a===u)return c=i[s],i[s]=n,c;i=i[s]}return i}function s(e){return(n=e)&&n.length&&"#"===n[0]?o:t;var n}function l(e){var n,t,o,f,l=Array.isArray(e)?e.slice(0):e=s(e)(e),c=Array.isArray(e)?i(l):e,g=(f="if (typeof(obj) !== 'undefined'",0===(o=l).length?function(e){return e}:(f=o.reduce(function(e,n,t){return e+" && \n\ttypeof((obj = obj['"+r(o[t],"\\","\\\\")+"'])) !== 'undefined'"},"if (typeof(obj) !== 'undefined'"),f+=") {\n\treturn obj;\n }",new Function(["obj"],f)));Object.defineProperties(this,{get:{enumerable:!0,value:g},set:{enumerable:!0,value:function(e,n,r){return a(e,n,l,r)}},has:{enumerable:!0,value:function(e){return void 0!==g(e)}},path:{enumerable:!0,get:function(){return l.slice(0)}},pointer:{enumerable:!0,get:function(){return n||(n=i(l)),n}},uriFragmentIdentifier:{enumerable:!0,get:function(){return t||(t=u(l)),t}},toString:{enumerable:!0,configurable:!0,writable:!0,value:function(){return c}}})}function c(e){var n="string"==typeof e||Array.isArray(e)?new l(e):e;Object.defineProperties(this,{$ref:{enumerable:!0,value:n.uriFragmentIdentifier},resolve:{enumerable:!0,value:function(e){return n.get(e)}},toString:{enumerable:!0,writable:!0,configurable:!0,value:function(){return n.uriFragmentIdentifier}}})}function g(e,n,r){var t,o,f,a,s,g,h,y,d,p=[],b=0;for(p.push({obj:e,path:[]}),r&&(d=Object.create(null)),n(i([]),e);b<p.length;)if("object"===typeof(y=p[b++]).obj&&null!==y.obj)if(Array.isArray(y.obj))for(a=-1,s=y.obj.length;++a<s;){if(g=y.obj[a],h=y.path.concat(a),"object"==typeof g&&null!==g){if(r&&d[g]){n(i(h),new c(d[g]));continue}p.push({obj:g,path:h}),r&&(d[g]=new l(u(h)))}n(i(h),g)}else for(f=(t=Object.keys(y.obj)).length,o=-1;++o<f;){if(g=y.obj[t[o]],h=y.path.concat(t[o]),"object"==typeof g&&null!==g){if(r&&d[g]){n(i(h),new c(d[g]));continue}p.push({obj:g,path:h}),r&&(d[g]=new l(u(h)))}n(i(h),g)}}return c.isReference=function(e){return e&&e instanceof c||"string"==typeof e.$ref&&"function"==typeof e.resolve},l.create=function(e){return new l(e)},l.has=function(e,n){return function(e,n){var r,t,i,o,u;if(void 0!==e){if(r=e,i=-1,t=n.length)for(;++i<t&&r;)if(o=n[i],Array.isArray(r)){if(isNaN(o)||!isFinite(o))break;if(u=f(r,o),!(r.length>u))break;r=r[u]}else r=r[o];return i===t&&void 0!==r}return!1}(e,s(n)(n))},l.get=function(e,n){return function(e,n){var r,t,i,o,u,a;if(void 0!==e){if(r=e,i=-1,t=n.length)for(;++i<t&&r;)if(o=n[i],Array.isArray(r)){if(isNaN(o)||!isFinite(o))return a;if(u=f(r,o),!(r.length>u))return a;r=r[u]}else r=r[o];return r}return a}(e,s(n)(n))},l.set=function(e,n,r,t){return a(e,r,s(n)(n),t)},l.list=function(e,n){var r=[];return g(e,n?function(e,n){r.push({fragmentId:u(t(e)),value:n})}:function(e,n){r.push({pointer:e,value:n})}),r},l.flatten=function(e,n){var r={};return g(e,n?function(e,n){r[u(t(e))]=n}:function(e,n){r[e]=n}),r},l.map=function(e,n){var r=[];return g(e,n?function(e,n){r.push({key:u(t(e)),value:n})}:r.set.bind(r)),r},l.visit=g,l.decode=function(e){return s(e)(e)},l.decodePointer=t,l.encodePointer=i,l.decodeUriFragmentIdentifier=o,l.encodeUriFragmentIdentifier=u,l.JsonPointer=l,l.JsonReference=c,l.isReference=c.isReference,l.noConflict=function(){return e.JsonPointer=n,l},e.JsonPointer=l,l});
!function(e,n){"function"==typeof define&&define.amd?define([],n):"object"==typeof module&&module.exports?module.exports=n():e.returnExports=n()}("undefined"!=typeof self?self:this,function(){var e=this,n=this.JsonPointer;function a(e,n,r){for(var t=e.toString(),i="",o=t,u=0,f=-1;-1<(f=o.indexOf(n));)i+=t.substring(u,u+f)+r,o=o.substring(f+n.length,o.length),u+=f+n.length;return 0<o.length&&(i+=t.substring(t.length-o.length,t.length)),i}function t(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 function(e){for(var n=-1,r=e.length,t=new Array(r);++n<r;)t[n]=a(a(e[n],"~1","/"),"~0","~");return t}(e.substring(1).split("/"))}function y(e){if(e&&!Array.isArray(e))throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"":"/".concat(function(e){for(var n=-1,r=e.length,t=new Array(r);++n<r;)"string"==typeof e[n]?t[n]=a(a(e[n],"~","~0"),"/","~1"):t[n]=e[n];return t}(e).join("/"))}function r(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 idetifiers must begin with a hash.");if(1===e.length)return[];if("/"!==e[1])throw new ReferenceError("Invalid JSON Pointer syntax.");return function(e){for(var n=-1,r=e.length,t=new Array(r);++n<r;)t[n]=a(a(decodeURIComponent(""+e[n]),"~1","/"),"~0","~");return t}(e.substring(2).split("/"))}function d(e){if(e&&!Array.isArray(e))throw new TypeError("Invalid type: path must be an array of segments.");return 0===e.length?"#":"#/".concat(function(e){for(var n=-1,r=e.length,t=new Array(r);++n<r;)"string"==typeof e[n]?t[n]=encodeURIComponent(a(a(e[n],"~","~0"),"/","~1")):t[n]=e[n];return t}(e).join("/"))}function g(e,n){var r=n.length,t=0;if(1===r&&"-"===n[0])return Array.isArray(e)?e.length:0;if(0===r||1<r&&"0"===n[0]||!isFinite(n))return-1;for(;++t<r;)if(n[t]<"0"||"9"<n[t])return-1;return parseInt(n,10)}function s(e,n,r,t){var i,o,u,f,a,s,c,l;if(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");if(i=e,o=r.length,u=r.length-1,f=-1,o)for(;++f<o;)if(a=r[f],Array.isArray(i)){if(s=g(i,a),i.length>s){if(f===u)return c=i[s],i[s]=n,c;i=i[s]}else if(i.length===s){if(f===u)return i.push(n),l;t&&(i=i[s]={})}}else{if(void 0===i[a]){if(t){if(f===u)return i[a]=n,l;if(-1!==g(i[a],r[f+1])){i=i[a]=[];continue}i=i[a]={};continue}return l}if(f===u)return c=i[a],i[a]=n,c;i=i[a]}return i}function c(e){return(n=e)&&n.length&&"#"===n[0]?r:t;var n}function p(e){var n,r,t,i,o=Array.isArray(e)?e.slice(0):e=c(e)(e),u=Array.isArray(e)?y(o):e,f=(i="if (typeof(obj) !== 'undefined'",0===(t=o).length?function(e){return e}:(i=t.reduce(function(e,n,r){return e+" && \n\ttypeof((obj = obj['"+a(t[r],"\\","\\\\")+"'])) !== 'undefined'"},"if (typeof(obj) !== 'undefined'"),i+=") {\n\treturn obj;\n }",new Function(["obj"],i)));Object.defineProperties(this,{get:{enumerable:!0,value:f},set:{enumerable:!0,value:function(e,n,r){return s(e,n,o,r)}},has:{enumerable:!0,value:function(e){return void 0!==f(e)}},path:{enumerable:!0,get:function(){return o.slice(0)}},pointer:{enumerable:!0,get:function(){return n||(n=y(o)),n}},uriFragmentIdentifier:{enumerable:!0,get:function(){return r||(r=d(o)),r}},toString:{enumerable:!0,configurable:!0,writable:!0,value:function(){return u}}})}function b(e){var n="string"==typeof e||Array.isArray(e)?new p(e):e;Object.defineProperties(this,{$ref:{enumerable:!0,value:n.uriFragmentIdentifier},resolve:{enumerable:!0,value:function(e){return n.get(e)}},toString:{enumerable:!0,writable:!0,configurable:!0,value:function(){return n.uriFragmentIdentifier}}})}function i(e,n,r){var t,i,o,u,f,a,s,c,l,g=[],h=0;for(g.push({obj:e,path:[]}),r&&(l=Object.create(null)),n(y([]),e);h<g.length;)if("object"===typeof(c=g[h++]).obj&&null!==c.obj)if(Array.isArray(c.obj))for(u=-1,f=c.obj.length;++u<f;){if(a=c.obj[u],s=c.path.concat(u),"object"==typeof a&&null!==a){if(r&&l[a]){n(y(s),new b(l[a]));continue}g.push({obj:a,path:s}),r&&(l[a]=new p(d(s)))}n(y(s),a)}else for(o=(t=Object.keys(c.obj)).length,i=-1;++i<o;){if(a=c.obj[t[i]],s=c.path.concat(t[i]),"object"==typeof a&&null!==a){if(r&&l[a]){n(y(s),new b(l[a]));continue}g.push({obj:a,path:s}),r&&(l[a]=new p(d(s)))}n(y(s),a)}}return b.isReference=function(e){return e&&e instanceof b||"string"==typeof e.$ref&&"function"==typeof e.resolve},p.create=function(e){return new p(e)},p.has=function(e,n){return function(e,n){var r,t,i,o,u;if(void 0===e)return!1;if(r=e,i=-1,t=n.length)for(;++i<t&&r;)if(o=n[i],Array.isArray(r)){if(isNaN(o)||!isFinite(o)){r=r[o];continue}if(u=g(r,o),!(r.length>u))break;r=r[u]}else r=r[o];return i===t&&void 0!==r}(e,c(n)(n))},p.get=function(e,n){return function(e,n){var r,t,i,o,u;if(void 0!==e){if(r=e,i=-1,t=n.length)for(;++i<t&&r;)if(o=n[i],Array.isArray(r)){if(isNaN(o)||!isFinite(o)){r=r[o];continue}if(u=g(r,o),!(r.length>u))return;r=r[u]}else r=r[o];return r}}(e,c(n)(n))},p.set=function(e,n,r,t){return s(e,r,c(n)(n),t)},p.list=function(e,n){var r=[];return i(e,n?function(e,n){r.push({fragmentId:d(t(e)),value:n})}:function(e,n){r.push({pointer:e,value:n})}),r},p.flatten=function(e,n){var r={};return i(e,n?function(e,n){r[d(t(e))]=n}:function(e,n){r[e]=n}),r},p.map=function(e,n){var r=[];return i(e,n?function(e,n){r.push({key:d(t(e)),value:n})}:r.set.bind(r)),r},p.visit=i,p.decode=function(e){return c(e)(e)},p.decodePointer=t,p.encodePointer=y,p.decodeUriFragmentIdentifier=r,p.encodeUriFragmentIdentifier=d,(p.JsonPointer=p).JsonReference=b,p.isReference=b.isReference,p.noConflict=function(){return e.JsonPointer=n,p},e.JsonPointer=p});

@@ -165,3 +165,4 @@ (function (root, factory) {

if (isNaN(step) || !isFinite(step)) {
break;
it = it[step];
continue;
}

@@ -200,3 +201,4 @@ p = toArrayIndexReference(it, step);

if (isNaN(step) || !isFinite(step)) {
return nonexistent;
it = it[step];
continue;
}

@@ -203,0 +205,0 @@ p = toArrayIndexReference(it, step);

{
"name": "json-ptr",
"version": "1.1.0",
"version": "1.1.1",
"author": "Phillip Clark <phillip@flitbit.com>",

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

"ci": "mocha --reporter mocha-junit-reporter test/**/*.js",
"lint": "eslint src test"
"lint": "eslint index.js test"
},
"devDependencies": {
"bluebird": "^3.5.1",
"eslint": "^4.18.1",
"eslint-plugin-mocha": "^4.11.0",
"bluebird": "^3.5.2",
"eslint": "^5.7.0",
"eslint-plugin-mocha": "^5.2.0",
"expect.js": "^0.3.1",
"json": "^9.0.6",
"mocha": "^5.0.1",
"mocha-junit-reporter": "^1.17.0",
"nodemon": "^1.15.1",
"mocha": "^5.2.0",
"mocha-junit-reporter": "^1.18.0",
"nodemon": "^1.18.4",
"rimraf": "^2.6.2",
"uglify-js": "^3.3.12"
"uglify-js": "^3.4.9"
}
}

@@ -33,3 +33,3 @@ # json-ptr

```html
<script src="https://cdn.jsdelivr.net/gh/flitbit/json-ptr@1/dist/json-ptr.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/json-ptr@1/dist/json-ptr.min.js"></script>
<!-- exports an object named JsonPointer -->

@@ -36,0 +36,0 @@ <script>var ptr = JsonPointer.noConflict()</script>

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