@sagold/json-pointer
Advanced tools
Comparing version
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("jsonPointer",[],e):"object"==typeof exports?exports.jsonPointer=e():t.jsonPointer=e()}("undefined"!=typeof self?self:this,(()=>(()=>{"use strict";var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function n(t){return"#"===t||""===t||Array.isArray(t)&&0===t.length||!1}t.r(e),t.d(e,{default:()=>_,get:()=>s,isRoot:()=>n,join:()=>P,remove:()=>m,removeUndefinedItems:()=>v,set:()=>g,split:()=>f,splitLast:()=>O});const o=/~1/g,r=/~0/g,i=/(^#?\/?)/g;function l(t){return t.replace(o,"/").replace(r,"~")}function u(t){return l(decodeURIComponent(t))}function f(t){if(null==t||"string"!=typeof t||n(t))return Array.isArray(t)?t:[];const e=t.indexOf("#")>=0?u:l,o=(t=t.replace(i,"")).split("/");for(let t=0,n=o.length;t<n;t+=1)o[t]=e(o[t]);return o}function s(t,e,o=void 0){if(null==e||null==t)return o;if(n(e))return t;const r=c(t,f(e));return void 0===r?o:r}function c(t,e){const n=e.shift();if(void 0!==t)return void 0!==n?c(t[n],e):t}const p=/^\[.*\]$/,d=/^[[{](.+)[\]}]$/;function a(t,e){return"__proto__"===t||"constructor"==t&&e.length>0&&"prototype"==e[0]}function g(t,e,n){if(null==e)return t;const o=f(e);if(0===o.length)return t;null==t&&(t=p.test(o[0])?[]:{});let r,i,l=t;for(;o.length>1;)r=o.shift(),i=p.test(o[0])||`${parseInt(o[0])}`===o[0],a(r,o)||(l=h(l,r,i));return r=o.pop(),y(l,r,n),t}function y(t,e,n){var o,r;const i=null!==(r=null===(o=e.match(d))||void 0===o?void 0:o.pop())&&void 0!==r?r:e;"[]"===e&&Array.isArray(t)?t.push(n):a(i,t)||(t[i]=n)}function h(t,e,n){var o,r;const i=null!==(r=null===(o=e.match(d))||void 0===o?void 0:o.pop())&&void 0!==r?r:e;if(null!=t[i])return t[i];const l=n?[]:{};return y(t,e,l),l}function v(t){let e=0,n=0;for(;e+n<t.length;)void 0===t[e+n]&&(n+=1),t[e]=t[e+n],e+=1;return t.length=t.length-n,t}function m(t,e,n){const o=f(e),r=o.pop(),i=s(t,o);return i&&delete i[r],Array.isArray(i)&&!0!==n&&v(i),t}const j=/~/g,b=/\//g;function A(t,e){if(0===t.length)return e?"#":"";for(let n=0,o=t.length;n<o;n+=1)t[n]=t[n].replace(j,"~0").replace(b,"~1"),e&&(t[n]=encodeURIComponent(t[n]));return(e?"#/":"/")+t.join("/")}function P(t,...e){const n=[];if(Array.isArray(t))return A(t,!0===arguments[1]);const o=arguments[arguments.length-1],r="boolean"==typeof o?o:t&&"#"===t[0];for(let t=0,e=arguments.length;t<e;t+=1)n.push.apply(n,f(arguments[t]));const i=[];for(let t=0,e=n.length;t<e;t+=1)if(".."===n[t]){if(0===i.length)return r?"#":"";i.pop()}else i.push(n[t]);return A(i,r)}function O(t){const e=f(t);if(0===e.length)return"string"==typeof t&&"#"===t[0]?["#",e[0]]:["",void 0];if(1===e.length)return"#"===t[0]?["#",e[0]]:["",e[0]];const n=e.pop();return[P(e,"#"===t[0]),n]}const _={get:s,set:g,remove:m,join:P,split:f,splitLast:O,isRoot:n,removeUndefinedItems:v};return e})())); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("jsonPointer",[],e):"object"==typeof exports?exports.jsonPointer=e():t.jsonPointer=e()}("undefined"!=typeof self?self:this,()=>(()=>{"use strict";var t={d:(e,n)=>{for(var o in n)t.o(n,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:n[o]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};function n(t){return"#"===t||""===t||Array.isArray(t)&&0===t.length||!1}t.r(e),t.d(e,{default:()=>_,get:()=>s,isRoot:()=>n,join:()=>P,remove:()=>m,removeUndefinedItems:()=>v,set:()=>g,split:()=>f,splitLast:()=>O});const o=/~1/g,r=/~0/g,i=/(^#?\/?)/g;function l(t){return t.replace(o,"/").replace(r,"~")}function u(t){return l(decodeURIComponent(t))}function f(t){if(null==t||"string"!=typeof t||n(t))return Array.isArray(t)?t.slice():[];const e=t.indexOf("#")>=0?u:l,o=(t=t.replace(i,"")).split("/");for(let t=0,n=o.length;t<n;t+=1)o[t]=e(o[t]);return o}function s(t,e,o=void 0){if(null==e||null==t)return o;if(n(e))return t;const r=c(t,f(e));return void 0===r?o:r}function c(t,e){const n=e.shift();if(void 0!==t)return void 0!==n?c(t[n],e):t}const p=/^\[.*\]$/,d=/^[[{](.+)[\]}]$/;function a(t,e){return"__proto__"===t||"constructor"==t&&e.length>0&&"prototype"==e[0]}function g(t,e,n){if(null==e)return t;const o=f(e);if(0===o.length)return t;null==t&&(t=p.test(o[0])?[]:{});let r,i,l=t;for(;o.length>1;)r=o.shift(),i=p.test(o[0])||`${parseInt(o[0])}`===o[0],a(r,o)||(l=h(l,r,i));return r=o.pop(),y(l,r,n),t}function y(t,e,n){var o,r;const i=null!==(r=null===(o=e.match(d))||void 0===o?void 0:o.pop())&&void 0!==r?r:e;"[]"===e&&Array.isArray(t)?t.push(n):a(i,t)||(t[i]=n)}function h(t,e,n){var o,r;const i=null!==(r=null===(o=e.match(d))||void 0===o?void 0:o.pop())&&void 0!==r?r:e;if(null!=t[i])return t[i];const l=n?[]:{};return y(t,e,l),l}function v(t){let e=0,n=0;for(;e+n<t.length;)void 0===t[e+n]&&(n+=1),t[e]=t[e+n],e+=1;return t.length=t.length-n,t}function m(t,e,n){const o=f(e),r=o.pop(),i=s(t,o);return i&&delete i[r],Array.isArray(i)&&!0!==n&&v(i),t}const j=/~/g,b=/\//g;function A(t,e){if(0===t.length)return e?"#":"";for(let n=0,o=t.length;n<o;n+=1)t[n]=t[n].replace(j,"~0").replace(b,"~1"),e&&(t[n]=encodeURIComponent(t[n]));return(e?"#/":"/")+t.join("/")}function P(t,...e){const n=[];if(Array.isArray(t))return A(t,!0===arguments[1]);const o=arguments[arguments.length-1],r="boolean"==typeof o?o:t&&"#"===t[0];for(let t=0,e=arguments.length;t<e;t+=1)n.push.apply(n,f(arguments[t]));const i=[];for(let t=0,e=n.length;t<e;t+=1)if(".."===n[t]){if(0===i.length)return r?"#":"";i.pop()}else i.push(n[t]);return A(i,r)}function O(t){const e=f(t);if(0===e.length)return"string"==typeof t&&"#"===t[0]?["#",e[0]]:["",void 0];if(1===e.length)return"#"===t[0]?["#",e[0]]:["",e[0]];const n=e.pop();return[P(e,"#"===t[0]),n]}const _={get:s,set:g,remove:m,join:P,split:f,splitLast:O,isRoot:n,removeUndefinedItems:v};return e})()); |
@@ -22,3 +22,3 @@ import { isRoot } from "./isRoot"; | ||
if (pointer == null || typeof pointer !== "string" || isRoot(pointer)) { | ||
return Array.isArray(pointer) ? pointer : []; | ||
return Array.isArray(pointer) ? pointer.slice() : []; | ||
} | ||
@@ -25,0 +25,0 @@ const sanitize = |
{ | ||
"name": "@sagold/json-pointer", | ||
"version": "7.1.1", | ||
"version": "7.1.2", | ||
"description": "json pointer - failsafe data retrieval from js and json objects", | ||
@@ -32,8 +32,6 @@ "main": "dist/jsonPointer.js", | ||
"devDependencies": { | ||
"@eslint/js": "^9.20.0", | ||
"eslint": "^9.20.1", | ||
"typescript": "^5.7.3", | ||
"typescript-eslint": "^8.24.0", | ||
"@eslint/js": "^9.30.1", | ||
"@types/mocha": "^10.0.6", | ||
"@types/node": "^22.10.6", | ||
"eslint": "^9.30.1", | ||
"mocha": "^11.1.0", | ||
@@ -44,2 +42,4 @@ "nyc": "^17.1.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.7.3", | ||
"typescript-eslint": "^8.35.1", | ||
"webpack": "^5.97.1", | ||
@@ -46,0 +46,0 @@ "webpack-cli": "^6.0.1" |
28710
0.05%