json-variables 11.0.10 → 11.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +2 -6
- package/dist/json-variables.esm.js +7 -7
- package/dist/json-variables.umd.js +16 -16
- package/package.json +12 -10
- package/types/index.d.ts +17 -17
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -26,14 +26,12 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `10.1.0`.
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i json-variables
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 10.1.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
@@ -69,8 +67,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
69
67
|
|
|
70
68
|
MIT License
|
|
71
69
|
|
|
72
|
-
Copyright (c) 2010-
|
|
73
|
-
|
|
70
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
74
71
|
|
|
75
72
|
<img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
|
|
76
|
-
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name json-variables
|
|
3
3
|
* @fileoverview Resolves custom-marked, cross-referenced paths in parsed JSON
|
|
4
|
-
* @version 11.0.
|
|
4
|
+
* @version 11.0.11
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/json-variables/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import{traverse as k}from"ast-monkey-traverse";import{isMatch as x}from"matcher";import d from"object-path";import{arrayiffy as F}from"arrayiffy-if-string";import{strFindHeadsTails as I}from"string-find-heads-tails";import{getByKey as _}from"ast-get-values-by-key";import{Ranges as B}from"ranges-push";import{rApply as S}from"ranges-apply";import{remDup as L}from"string-remove-duplicate-heads-tails";import{matchLeftIncl as U,matchRightIncl as M}from"string-match-left-right";var j="11.0.
|
|
11
|
-
`;c=i.reduce((D,b,O)=>D+(O===0?"":m)+(b===
|
|
10
|
+
import{traverse as k}from"ast-monkey-traverse";import{isMatch as x}from"matcher";import d from"object-path";import{arrayiffy as F}from"arrayiffy-if-string";import{strFindHeadsTails as I}from"string-find-heads-tails";import{getByKey as _}from"ast-get-values-by-key";import{Ranges as B}from"ranges-push";import{rApply as S}from"ranges-apply";import{remDup as L}from"string-remove-duplicate-heads-tails";import{matchLeftIncl as U,matchRightIncl as M}from"string-match-left-right";var j="11.0.11";var de=j,q=Object.prototype.hasOwnProperty,K={heads:"%%_",tails:"_%%",headsNoWrap:"%%-",tailsNoWrap:"-%%",lookForDataContainers:!0,dataContainerIdentifierTails:"_data",wrapHeadsWith:"",wrapTailsWith:"",dontWrapVars:[],preventDoubleWrapping:!0,wrapGlobalFlipSwitch:!0,noSingleMarkers:!1,resolveToBoolIfAnyValuesContainBool:!0,resolveToFalseIfAnyValuesContainBool:!0,throwWhenNonStringInsertedInString:!1,allowUnresolved:!1};function u(e){return typeof e=="string"}function G(e){return typeof e=="number"}function A(e){return typeof e=="boolean"}function E(e){return e===null}function w(e){return e&&typeof e=="object"&&!Array.isArray(e)}function z(e){return e!=null}function g(e){return u(e)?e.trim():e}function Y(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let r=0,t=e.length;r<t;r++)if(e[r]===".")return e.slice(0,r)}return e}function Q(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let r=0,t=e.length;r<t;r++)if(e[r]===".")return e.slice(r+1)}return e}function P(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let r=e.length;r--;)if(e[r]===".")return e.slice(0,r)}return e}function H(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let r=e.length;r--;)if(e[r]===".")return e.slice(r+1)}return e}function T(e,r){return typeof e!="string"||!e.trim()?!1:!!(e.includes(r.heads)||e.includes(r.tails)||u(r.headsNoWrap)&&r.headsNoWrap.length>0&&e.includes(r.headsNoWrap)||u(r.tailsNoWrap)&&r.tailsNoWrap.length>0&&e.includes(r.tailsNoWrap))}function X(e,r,t){let l,i;return typeof e=="string"&&e.length>0&&M(e,0,r,{trimBeforeMatching:!0,cb:(n,a,o)=>(l=o,!0)})&&U(e,e.length-1,t,{trimBeforeMatching:!0,cb:(n,a,o)=>(i=+o+1,!0)})?e.slice(l,i):e}function J(e,r,t=!1,l,i,n){if(r.wrapHeadsWith||(r.wrapHeadsWith=""),r.wrapTailsWith||(r.wrapTailsWith=""),u(e)&&!t&&r.wrapGlobalFlipSwitch&&!r.dontWrapVars.some(a=>x(n,a))&&(!r.preventDoubleWrapping||r.preventDoubleWrapping&&u(e)&&!e.includes(r.wrapHeadsWith)&&!e.includes(r.wrapTailsWith)))return`${r.wrapHeadsWith}${e}${r.wrapTailsWith}`;if(t){if(!u(e))return e;let a=L(e,{heads:r.wrapHeadsWith,tails:r.wrapTailsWith});return u(a)?X(a,r.wrapHeadsWith,r.wrapTailsWith):a}return e}function Z(e,r,t,l){let i;if(t.indexOf(".")!==-1){let n=t,a=!0;if(l.lookForDataContainers&&typeof l.dataContainerIdentifierTails=="string"&&l.dataContainerIdentifierTails.length>0&&!n.endsWith(l.dataContainerIdentifierTails)){let o=d.get(e,n+l.dataContainerIdentifierTails);w(o)&&d.get(o,r)&&(i=d.get(o,r),a=!1)}for(;a&&n.indexOf(".")!==-1;){if(n=P(n),H(n)===r)throw new Error(`json-variables/findValues(): [THROW_ID_20] While trying to resolve: "${r}" at path "${t}", we encountered a closed loop. The parent key "${H(n)}" is called the same as the variable "${r}" we're looking for.`);if(l.lookForDataContainers&&typeof l.dataContainerIdentifierTails=="string"&&l.dataContainerIdentifierTails.length>0&&!n.endsWith(l.dataContainerIdentifierTails)){let o=d.get(e,n+l.dataContainerIdentifierTails);w(o)&&d.get(o,r)&&(i=d.get(o,r),a=!1)}if(i===void 0){let o=d.get(e,n);w(o)&&d.get(o,r)&&(i=d.get(o,r),a=!1)}}}if(i===void 0){let n=d.get(e,r);n!==void 0&&(i=n)}if(i===void 0)if(r.indexOf(".")===-1){let n=_(e,r);if(n.length>0){for(let a=0,o=n.length;a<o;a++)if(u(n[a].val)||A(n[a].val)||E(n[a].val)){i=n[a].val;break}else if(G(n[a].val)){i=String(n[a].val);break}else if(Array.isArray(n[a].val)){i=n[a].val.join("");break}}}else{let n=_(e,Y(r));if(n.length>0)for(let a=0,o=n.length;a<o;a++){let y=d.get(n[a].val,Q(r));y&&u(y)&&(i=y)}}return i}function R(e,r,t,l,i=[]){if(i.includes(t)){let c="";if(i.length>1){let m=` \u2192
|
|
11
|
+
`;c=i.reduce((D,b,O)=>D+(O===0?"":m)+(b===t?"\u{1F4A5} ":" ")+b,` Here's the path we travelled up until we hit the recursion:
|
|
12
12
|
|
|
13
|
-
`),c+=`${m}\u{1F4A5} ${
|
|
14
|
-
${c}`)}let
|
|
15
|
-
${c}`)}h.length===1&&S(r,[[h[0].headsStartAt,h[0].tailsEndAt]]).trim()===""&&(
|
|
16
|
-
Please check the following key: ${a}`);if(o!==void 0?
|
|
13
|
+
`),c+=`${m}\u{1F4A5} ${t}`}throw new Error(`json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "${r}" at path "${t}", we encountered a closed loop, the key is referencing itself."${c}`)}let n={},a=Array.from(i);a.push(t);let o=new B;function y(c,m,D){for(let b=0,O=c.length;b<O;b++){let f=c[b],p=r.slice(f.headsEndAt,f.tailsStartAt);if(p.length===0)o.push(f.headsStartAt,f.tailsEndAt);else if(q.call(n,p)&&u(n[p]))o.push(f.headsStartAt,f.tailsEndAt,n[p]);else{let s=Z(e,p.trim(),t,l);if(s===void 0)if(l.allowUnresolved===!0)s="";else if(typeof l.allowUnresolved=="string")s=l.allowUnresolved;else throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ${r.slice(f.headsEndAt,f.tailsStartAt)}. We're at path: "${t}".`);if(!D&&l.throwWhenNonStringInsertedInString&&!u(s))throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ${r.slice(f.headsEndAt,f.tailsStartAt)} at path ${t}, it resolved into a non-string value, ${JSON.stringify(s,null,4)}. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").`);if(A(s)){if(l.resolveToBoolIfAnyValuesContainBool)return o.wipe(),l.resolveToFalseIfAnyValuesContainBool?!1:s;s=""}else{if(E(s)&&D)return o.wipe(),s;Array.isArray(s)?s=String(s.join("")):E(s)?s="":s=String(s)}let N=t.includes(".")?`${P(t)}.${p}`:p;if(T(s,l)){let V=J(R(e,s,N,l,a),l,m,a,N,p.trim());typeof V=="string"&&o.push(f.headsStartAt,f.tailsEndAt,V)}else{n[p]=s;let V=J(s,l,m,a,N,p.trim());typeof V=="string"&&o.push(f.headsStartAt,f.tailsEndAt,V)}}}}let h;try{h=I(r,l.heads,l.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(c){throw new Error(`json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "${r}" at path ${t}, something wrong with heads and tails was detected! Here's the internal error message:
|
|
14
|
+
${c}`)}let W=!1;h.length===1&&S(r,[[h[0].headsStartAt,h[0].tailsEndAt]]).trim()===""&&(W=!0);let $=y(h,!1,W);if(typeof $=="boolean"||$===null)return $;try{h=I(r,l.headsNoWrap,l.tailsNoWrap,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(c){throw new Error(`json-variables/resolveString(): [THROW_ID_22] While trying to resolve string: "${r}" at path ${t}, something wrong with no-wrap heads and no-wrap tails was detected! Here's the internal error message:
|
|
15
|
+
${c}`)}h.length===1&&S(r,[[h[0].headsStartAt,h[0].tailsEndAt]]).trim()===""&&(W=!0);let v=y(h,!0,W);return A(v)||E(v)?v:o?.current()?S(r,o.current()):r}function he(e,r){if(!arguments.length)throw new Error("json-variables/jVar(): [THROW_ID_01] Alas! Inputs are missing!");if(!w(e))throw new TypeError(`json-variables/jVar(): [THROW_ID_02] Alas! The input must be a plain object! Currently it's: ${Array.isArray(e)?"array":typeof e}`);if(r&&!w(r))throw new TypeError(`json-variables/jVar(): [THROW_ID_03] Alas! An Optional Options Object must be a plain object! Currently it's: ${Array.isArray(r)?"array":typeof r}`);let t={...K,...r};t.dontWrapVars?Array.isArray(t.dontWrapVars)||(t.dontWrapVars=F(t.dontWrapVars)):t.dontWrapVars=[];let l,i;if(t.dontWrapVars.length>0&&!t.dontWrapVars.every((a,o)=>u(a)?!0:(l=a,i=o,!1)))throw new Error(`json-variables/jVar(): [THROW_ID_05] Alas! All variable names set in opts.dontWrapVars should be of a string type. Computer detected a value "${l}" at index ${i}, which is not string but ${Array.isArray(l)?"array":typeof l}!`);if(t.heads==="")throw new Error("json-variables/jVar(): [THROW_ID_06] Alas! opts.heads are empty!");if(t.tails==="")throw new Error("json-variables/jVar(): [THROW_ID_07] Alas! opts.tails are empty!");if(t.lookForDataContainers&&t.dataContainerIdentifierTails==="")throw new Error("json-variables/jVar(): [THROW_ID_08] Alas! opts.dataContainerIdentifierTails is empty!");if(t.heads===t.tails)throw new Error("json-variables/jVar(): [THROW_ID_09] Alas! opts.heads and opts.tails can't be equal!");if(t.heads===t.headsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_10] Alas! opts.heads and opts.headsNoWrap can't be equal!");if(t.tails===t.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_11] Alas! opts.tails and opts.tailsNoWrap can't be equal!");if(t.headsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_12] Alas! opts.headsNoWrap is an empty string!");if(t.tailsNoWrap==="")throw new Error("json-variables/jVar(): [THROW_ID_13] Alas! opts.tailsNoWrap is an empty string!");if(t.headsNoWrap===t.tailsNoWrap)throw new Error("json-variables/jVar(): [THROW_ID_14] Alas! opts.headsNoWrap and opts.tailsNoWrap can't be equal!");let n;return k(e,(a,o,y)=>{if(z(o)&&T(a,t))throw new Error(`json-variables/jVar(): [THROW_ID_15] Alas! Object keys can't contain variables!
|
|
16
|
+
Please check the following key: ${a}`);if(o!==void 0?n=o:n=a,n==="")return n;if(t.heads.length!==0&&g(n)===g(t.heads)||t.tails.length!==0&&g(n)===g(t.tails)||t.headsNoWrap.length!==0&&g(n)===g(t.headsNoWrap)||t.tailsNoWrap.length!==0&&g(n)===g(t.tailsNoWrap)){if(!t.noSingleMarkers)return n;throw new Error(`json-variables/jVar(): [THROW_ID_16] Alas! While processing the input, we stumbled upon ${g(n)} which is equal to ${g(n)===g(t.heads)?"heads":""}${g(n)===g(t.tails)?"tails":""}${u(t.headsNoWrap)&&g(n)===g(t.headsNoWrap)?"headsNoWrap":""}${u(t.tailsNoWrap)&&g(n)===g(t.tailsNoWrap)?"tailsNoWrap":""}. If you wouldn't have set opts.noSingleMarkers to "true" this error would not happen and computer would have left the current element (${g(n)}) alone`)}return u(n)&&T(n,t)?R(e,n,y.path,t):n})}export{K as defaults,he as jVar,de as version};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name json-variables
|
|
3
3
|
* @fileoverview Resolves custom-marked, cross-referenced paths in parsed JSON
|
|
4
|
-
* @version 11.0.
|
|
4
|
+
* @version 11.0.11
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/json-variables/}
|
|
@@ -24,7 +24,7 @@ We're talking about the area of the code:
|
|
|
24
24
|
|
|
25
25
|
--------------------------------------starts
|
|
26
26
|
${e.slice(Math.max(u-200,0),u)}
|
|
27
|
-
${
|
|
27
|
+
${`\x1B[${33}m------->\x1B[${39}m`} ${`\x1B[${31}m${e.slice(u,u+f.length)}\x1B[${39}m`} \x1B[${33}m<-------\x1B[${39}m
|
|
28
28
|
${e.slice(u+f.length,Math.min(y,u+200))}
|
|
29
29
|
--------------------------------------ends
|
|
30
30
|
|
|
@@ -37,7 +37,7 @@ ${JSON.stringify(t,null,4)} (type ${typeof t})`);else i=$({},zt);let o=e.filter(
|
|
|
37
37
|
${JSON.stringify(r,null,4)}`);if(C(this.ranges)&&Array.isArray(this.last())&&i===this.last()[1]){if(this.last()[1]=o,this.last()[2],this.last()[2]!==null&&C(r)){let n=this.last()[2]&&this.last()[2].length>0&&(!this.opts||!this.opts.mergeType||this.opts.mergeType===1)?`${this.last()[2]}${r}`:r;this.opts.limitToBeAddedWhitespace&&(n=pe(n,this.opts.limitLinebreaksCount)),X(n)&&!n.length||(this.last()[2]=n)}}else{this.ranges||(this.ranges=[]);let n=r!==void 0&&!(X(r)&&!r.length)?[i,o,r&&this.opts.limitToBeAddedWhitespace?pe(r,this.opts.limitLinebreaksCount):r]:[i,o];this.ranges.push(n)}}else throw V(i)&&i>=0?new TypeError(`ranges-push/Ranges/add(): [THROW_ID_10] "to" value, the second input argument, must be a natural number or zero! Currently it's of a type "${typeof o}" equal to: ${JSON.stringify(o,null,4)}`):new TypeError(`ranges-push/Ranges/add(): [THROW_ID_09] "from" value, the first input argument, must be a natural number or zero! Currently it's of a type "${typeof i}" equal to: ${JSON.stringify(i,null,4)}`)}push(e,t,r){this.add(e,t,r)}current(){return Array.isArray(this.ranges)&&this.ranges.length?(this.ranges=oi(this.ranges,{mergeType:this.opts.mergeType}),this.ranges&&this.opts.limitToBeAddedWhitespace?this.ranges.map(e=>C(e[2])?[e[0],e[1],pe(e[2],this.opts.limitLinebreaksCount)]:e):this.ranges):null}wipe(){this.ranges=[]}replace(e){if(Array.isArray(e)&&e.length)if(Array.isArray(e[0])&&V(e[0][0]))this.ranges=Array.from(e);else throw new Error(`ranges-push/Ranges/replace(): [THROW_ID_11] Single range was given but we expected array of arrays! The first element, ${JSON.stringify(e[0],null,4)} should be an array and its first element should be an integer, a string index.`);else this.ranges=[]}last(){return Array.isArray(this.ranges)&&this.ranges.length?this.ranges[this.ranges.length-1]:null}};var fi={strictlyTwoElementsInRangeArrays:!1,progressFn:null};function Fe(e,t){if(!Array.isArray(e)||!e.length)return e;let r=$($({},fi),t),i,o;if(r.strictlyTwoElementsInRangeArrays&&!e.every((s,h)=>!Array.isArray(s)||s.length!==2?(i=h,o=s.length,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_03] The first argument should be an array and must consist of arrays which are natural number indexes representing TWO string index ranges. However, ${i}th range (${JSON.stringify(e[i],null,4)}) has not two but ${o} elements!`);if(!e.every((s,h)=>!Array.isArray(s)||!Number.isInteger(s[0])||s[0]<0||!Number.isInteger(s[1])||s[1]<0?(i=h,!1):!0))throw new TypeError(`ranges-sort: [THROW_ID_04] The first argument should be an array and must consist of arrays which are natural number indexes representing string index ranges. However, ${i}th range (${JSON.stringify(e[i],null,4)}) does not consist of only natural numbers!`);let n=e.length**2,l=0;return Array.from(e).sort((s,h)=>(r.progressFn&&(l+=1,r.progressFn(Math.floor(l*100/n))),s[0]===h[0]?s[1]<h[1]?-1:s[1]>h[1]?1:0:s[0]<h[0]?-1:1))}var Yt={mergeType:1,progressFn:null,joinRangesThatTouchEdges:!0};function Xt(e,t){function r(a){return a&&typeof a=="object"&&!Array.isArray(a)}if(!Array.isArray(e)||!e.length)return null;let i;if(t)if(r(t)){if(i=$($({},Yt),t),i.progressFn&&r(i.progressFn)&&!Object.keys(i.progressFn).length)i.progressFn=null;else if(i.progressFn&&typeof i.progressFn!="function")throw new Error(`ranges-merge: [THROW_ID_01] opts.progressFn must be a function! It was given of a type: "${typeof i.progressFn}", equal to ${JSON.stringify(i.progressFn,null,4)}`);if(![1,2,"1","2"].includes(i.mergeType))throw new Error(`ranges-merge: [THROW_ID_02] opts.mergeType was customised to a wrong thing! It was given of a type: "${typeof i.mergeType}", equal to ${JSON.stringify(i.mergeType,null,4)}`);if(typeof i.joinRangesThatTouchEdges!="boolean")throw new Error(`ranges-merge: [THROW_ID_04] opts.joinRangesThatTouchEdges was customised to a wrong thing! It was given of a type: "${typeof i.joinRangesThatTouchEdges}", equal to ${JSON.stringify(i.joinRangesThatTouchEdges,null,4)}`)}else throw new Error(`emlint: [THROW_ID_03] the second input argument must be a plain object. It was given as:
|
|
38
38
|
${JSON.stringify(t,null,4)} (type ${typeof t})`);else i=$({},Yt);let o=e.filter(a=>Array.isArray(a)).map(a=>[...a]).filter(a=>a[2]!==void 0||a[0]!==a[1]),n,l,s;i.progressFn?n=Fe(o,{progressFn:a=>{s=Math.floor(a/5),s!==l&&(l=s,i.progressFn(s))}}):n=Fe(o);let h=n.length-1;for(let a=h;a>0;a--)i.progressFn&&(s=Math.floor((1-a/h)*78)+21,s!==l&&s>l&&(l=s,i.progressFn(s))),(n[a][0]<=n[a-1][0]||!i.joinRangesThatTouchEdges&&n[a][0]<n[a-1][1]||i.joinRangesThatTouchEdges&&n[a][0]<=n[a-1][1])&&(n[a-1][0]=Math.min(n[a][0],n[a-1][0]),n[a-1][1]=Math.max(n[a][1],n[a-1][1]),n[a][2]!==void 0&&(n[a-1][0]>=n[a][0]||n[a-1][1]<=n[a][1])&&n[a-1][2]!==null&&(n[a][2]===null&&n[a-1][2]!==null?n[a-1][2]=null:n[a-1][2]!=null?+i.mergeType==2&&n[a-1][0]===n[a][0]?n[a-1][2]=n[a][2]:n[a-1][2]+=n[a][2]:n[a-1][2]=n[a][2]),n.splice(a,1),a=n.length);return n.length?n:null}var ui=!0,ke="Invariant failed";function Zt(e,t){if(!e){if(ui)throw new Error(ke);var r=typeof t=="function"?t():t,i=r?ke+": "+r:ke;throw new Error(i)}}function L(e,t,r){let i=0,o=0;if(arguments.length===0)throw new Error("ranges-apply: [THROW_ID_01] inputs missing!");if(typeof e!="string")throw new TypeError(`ranges-apply: [THROW_ID_02] first input argument must be a string! Currently it's: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(t&&!Array.isArray(t))throw new TypeError(`ranges-apply: [THROW_ID_03] second input argument must be an array (or null)! Currently it's: ${typeof t}, equal to: ${JSON.stringify(t,null,4)}`);if(r&&typeof r!="function")throw new TypeError(`ranges-apply: [THROW_ID_04] the third input argument must be a function (or falsey)! Currently it's: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(!t||!t.filter(g=>g).length)return e;let n;Array.isArray(t)&&Number.isInteger(t[0])&&Number.isInteger(t[1])?n=[Array.from(t)]:n=Array.from(t);let l=n.length,s=0;n.filter(g=>g).forEach((g,c)=>{if(r&&(i=Math.floor(s/l*10),i!==o&&(o=i,r(i))),!Array.isArray(g))throw new TypeError(`ranges-apply: [THROW_ID_05] ranges array, second input arg., has ${c}th element not an array: ${JSON.stringify(g,null,4)}, which is ${typeof g}`);if(!Number.isInteger(g[0])){if(!Number.isInteger(+g[0])||+g[0]<0)throw new TypeError(`ranges-apply: [THROW_ID_06] ranges array, second input arg. has ${c}th element, array ${JSON.stringify(g,null,0)}. Its first element is not an integer, string index, but ${typeof g[0]}, equal to: ${JSON.stringify(g[0],null,4)}.`);n[c][0]=+n[c][0]}if(!Number.isInteger(g[1])){if(!Number.isInteger(+g[1])||+g[1]<0)throw new TypeError(`ranges-apply: [THROW_ID_07] ranges array, second input arg. has ${c}th element, array ${JSON.stringify(g,null,0)}. Its second element is not an integer, string index, but ${typeof g[1]}, equal to: ${JSON.stringify(g[1],null,4)}.`);n[c][1]=+n[c][1]}s+=1});let h=Xt(n,{progressFn:g=>{r&&(i=10+Math.floor(g/10),i!==o&&(o=i,r(i)))}});Zt(h);let a=h.length;if(a>0){let g=e.slice(h[a-1][1]);e=h.reduce((c,T,m,u)=>{r&&(i=20+Math.floor(m/a*80),i!==o&&(o=i,r(i)));let y=m===0?0:u[m-1][1],d=u[m][0];return`${c}${e.slice(y,d)}${u[m][2]||""}`},""),e+=g}return e}var Qt=U(Ve(),1);var gi={classicTrim:!1,cr:!1,lf:!1,tab:!1,space:!0,nbsp:!1};function Q(e,t){if(typeof e!="string")throw new Error(`string-trim-spaces-only: [THROW_ID_01] input must be string! It was given as ${typeof e}, equal to:
|
|
39
39
|
${JSON.stringify(e,null,4)}`);let r=$($({},gi),t);function i(l){return r.classicTrim&&!l.trim()||!r.classicTrim&&(r.space&&l===" "||r.cr&&l==="\r"||r.lf&&l===`
|
|
40
|
-
`||r.tab&&l===" "||r.nbsp&&l==="\xA0")}let o,n;if(e.length){if(i(e[0]))for(let l=0,s=e.length;l<s;l++){if(!i(e[l])){o=l;break}if(l===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(i(e[e.length-1])){for(let l=e.length;l--;)if(!i(e[l])){n=l+1;break}}return o?n?{res:e.slice(o,n),ranges:[[0,o],[n,e.length]]}:{res:e.slice(o),ranges:[[0,o]]}:n?{res:e.slice(0,n),ranges:[[n,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}}var ci={heads:["{{"],tails:["}}"]};function er(e,t){let r=Object.prototype.hasOwnProperty;if(e===void 0)throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_01] The input is missing!");if(typeof e!="string")return e;if(t&&!(0,Qt.default)(t))throw new Error(`string-remove-duplicate-heads-tails: [THROW_ID_03] The given options are not a plain object but ${typeof t}!`);let i=$({},t);if(i&&r.call(i,"heads"))if(I(i.heads).every(y=>typeof y=="string"||Array.isArray(y)))typeof i.heads=="string"&&(i.heads=I(i.heads));else throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_04] The opts.heads contains elements which are not string-type!");if(i&&r.call(i,"tails"))if(I(i.tails).every(y=>typeof y=="string"||Array.isArray(y)))typeof i.tails=="string"&&(i.tails=I(i.tails));else throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_05] The opts.tails contains elements which are not string-type!");let o=Q(e).res;if(o.length===0)return e;e=o;let n=$($({},ci),i);n.heads=n.heads.map(y=>y.trim()),n.tails=n.tails.map(y=>y.trim());let l=!1,s=!1,h=new Z({limitToBeAddedWhitespace:!0}),a=new Z({limitToBeAddedWhitespace:!0}),g=!0,c=!0,T="";function m(y,d){let f;return W(y,0,d.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})&&W(y,f,d.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})?y.slice(f):y}for(;e!==m(e,n);)e=Q(m(e,n)).res;function u(y,d){let f;return!k(y,y.length-1,d.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})||!f?y:k(y,f,d.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})?y.slice(0,f+1):y}for(;e!==u(e,n);)e=Q(u(e,n)).res;if(!n.heads.length||!W(e,0,n.heads,{trimBeforeMatching:!0})||!n.tails.length||!k(e,e.length-1,n.tails,{trimBeforeMatching:!0}))return Q(e).res;for(let y=0,d=e.length;y<d;y++)if(e[y].trim()!==""){let f;if(W(e,y,n.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})&&f){c=!0,g&&(g=!0);let p;W(e,f,n.tails,{trimBeforeMatching:!0,cb:(w,b,O)=>(p=O,!0)})&&h.push(y,p),a.current()&&l&&T!=="tails"&&h.push(a.current()),l||a.current()&&(h.push(a.current()),a.wipe()),a.push(y,f),T="heads",y=f-1;continue}if(W(e,y,n.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=Number.isInteger(b)?b:e.length,!0)})&&f){c=!0,g?(T==="heads"&&a.wipe(),g=!1):a.push(y,f),T="tails",y=f-1;continue}g&&(g=!0),c&&!l?(l=!0,c=!1):c&&!s?(s=!0,g=!0,c=!1,T==="heads"&&a.wipe()):c&&s&&a.wipe()}return a.current()&&h.push(a.current()),h.current()?L(e,h.current()).trim():e.trim()}var tr="11.0.
|
|
40
|
+
`||r.tab&&l===" "||r.nbsp&&l==="\xA0")}let o,n;if(e.length){if(i(e[0]))for(let l=0,s=e.length;l<s;l++){if(!i(e[l])){o=l;break}if(l===e.length-1)return{res:"",ranges:[[0,e.length]]}}if(i(e[e.length-1])){for(let l=e.length;l--;)if(!i(e[l])){n=l+1;break}}return o?n?{res:e.slice(o,n),ranges:[[0,o],[n,e.length]]}:{res:e.slice(o),ranges:[[0,o]]}:n?{res:e.slice(0,n),ranges:[[n,e.length]]}:{res:e,ranges:[]}}return{res:"",ranges:[]}}var ci={heads:["{{"],tails:["}}"]};function er(e,t){let r=Object.prototype.hasOwnProperty;if(e===void 0)throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_01] The input is missing!");if(typeof e!="string")return e;if(t&&!(0,Qt.default)(t))throw new Error(`string-remove-duplicate-heads-tails: [THROW_ID_03] The given options are not a plain object but ${typeof t}!`);let i=$({},t);if(i&&r.call(i,"heads"))if(I(i.heads).every(y=>typeof y=="string"||Array.isArray(y)))typeof i.heads=="string"&&(i.heads=I(i.heads));else throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_04] The opts.heads contains elements which are not string-type!");if(i&&r.call(i,"tails"))if(I(i.tails).every(y=>typeof y=="string"||Array.isArray(y)))typeof i.tails=="string"&&(i.tails=I(i.tails));else throw new Error("string-remove-duplicate-heads-tails: [THROW_ID_05] The opts.tails contains elements which are not string-type!");let o=Q(e).res;if(o.length===0)return e;e=o;let n=$($({},ci),i);n.heads=n.heads.map(y=>y.trim()),n.tails=n.tails.map(y=>y.trim());let l=!1,s=!1,h=new Z({limitToBeAddedWhitespace:!0}),a=new Z({limitToBeAddedWhitespace:!0}),g=!0,c=!0,T="";function m(y,d){let f;return W(y,0,d.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})&&W(y,f,d.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})?y.slice(f):y}for(;e!==m(e,n);)e=Q(m(e,n)).res;function u(y,d){let f;return!k(y,y.length-1,d.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})||!f?y:k(y,f,d.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})?y.slice(0,f+1):y}for(;e!==u(e,n);)e=Q(u(e,n)).res;if(!n.heads.length||!W(e,0,n.heads,{trimBeforeMatching:!0})||!n.tails.length||!k(e,e.length-1,n.tails,{trimBeforeMatching:!0}))return Q(e).res;for(let y=0,d=e.length;y<d;y++)if(e[y].trim()!==""){let f;if(W(e,y,n.heads,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=b,!0)})&&f){c=!0,g&&(g=!0);let p;W(e,f,n.tails,{trimBeforeMatching:!0,cb:(w,b,O)=>(p=O,!0)})&&h.push(y,p),a.current()&&l&&T!=="tails"&&h.push(a.current()),l||a.current()&&(h.push(a.current()),a.wipe()),a.push(y,f),T="heads",y=f-1;continue}if(W(e,y,n.tails,{trimBeforeMatching:!0,cb:(p,w,b)=>(f=Number.isInteger(b)?b:e.length,!0)})&&f){c=!0,g?(T==="heads"&&a.wipe(),g=!1):a.push(y,f),T="tails",y=f-1;continue}g&&(g=!0),c&&!l?(l=!0,c=!1):c&&!s?(s=!0,g=!0,c=!1,T==="heads"&&a.wipe()):c&&s&&a.wipe()}return a.current()&&h.push(a.current()),h.current()?L(e,h.current()).trim():e.trim()}var tr="11.0.11";var pi=tr,di=Object.prototype.hasOwnProperty,rr={heads:"%%_",tails:"_%%",headsNoWrap:"%%-",tailsNoWrap:"-%%",lookForDataContainers:!0,dataContainerIdentifierTails:"_data",wrapHeadsWith:"",wrapTailsWith:"",dontWrapVars:[],preventDoubleWrapping:!0,wrapGlobalFlipSwitch:!0,noSingleMarkers:!1,resolveToBoolIfAnyValuesContainBool:!0,resolveToFalseIfAnyValuesContainBool:!0,throwWhenNonStringInsertedInString:!1,allowUnresolved:!1};function A(e){return typeof e=="string"}function yi(e){return typeof e=="number"}function Le(e){return typeof e=="boolean"}function de(e){return e===null}function ee(e){return e&&typeof e=="object"&&!Array.isArray(e)}function mi(e){return e!=null}function _(e){return A(e)?e.trim():e}function wi(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let t=0,r=e.length;t<r;t++)if(e[t]===".")return e.slice(0,t)}return e}function bi(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let t=0,r=e.length;t<r;t++)if(e[t]===".")return e.slice(t+1)}return e}function nr(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let t=e.length;t--;)if(e[t]===".")return e.slice(0,t)}return e}function ir(e){if(typeof e=="string"&&e.length>0&&e.indexOf(".")!==-1){for(let t=e.length;t--;)if(e[t]===".")return e.slice(t+1)}return e}function qe(e,t){return typeof e!="string"||!e.trim()?!1:!!(e.includes(t.heads)||e.includes(t.tails)||A(t.headsNoWrap)&&t.headsNoWrap.length>0&&e.includes(t.headsNoWrap)||A(t.tailsNoWrap)&&t.tailsNoWrap.length>0&&e.includes(t.tailsNoWrap))}function Ti(e,t,r){let i,o;return typeof e=="string"&&e.length>0&&W(e,0,t,{trimBeforeMatching:!0,cb:(n,l,s)=>(i=s,!0)})&&k(e,e.length-1,r,{trimBeforeMatching:!0,cb:(n,l,s)=>(o=+s+1,!0)})?e.slice(i,o):e}function sr(e,t,r=!1,i,o,n){if(t.wrapHeadsWith||(t.wrapHeadsWith=""),t.wrapTailsWith||(t.wrapTailsWith=""),A(e)&&!r&&t.wrapGlobalFlipSwitch&&!t.dontWrapVars.some(l=>ge(n,l))&&(!t.preventDoubleWrapping||t.preventDoubleWrapping&&A(e)&&!e.includes(t.wrapHeadsWith)&&!e.includes(t.wrapTailsWith)))return`${t.wrapHeadsWith}${e}${t.wrapTailsWith}`;if(r){if(!A(e))return e;let l=er(e,{heads:t.wrapHeadsWith,tails:t.wrapTailsWith});return A(l)?Ti(l,t.wrapHeadsWith,t.wrapTailsWith):l}return e}function $i(e,t,r,i){let o;if(r.indexOf(".")!==-1){let n=r,l=!0;if(i.lookForDataContainers&&typeof i.dataContainerIdentifierTails=="string"&&i.dataContainerIdentifierTails.length>0&&!n.endsWith(i.dataContainerIdentifierTails)){let s=D.default.get(e,n+i.dataContainerIdentifierTails);ee(s)&&D.default.get(s,t)&&(o=D.default.get(s,t),l=!1)}for(;l&&n.indexOf(".")!==-1;){if(n=nr(n),ir(n)===t)throw new Error(`json-variables/findValues(): [THROW_ID_20] While trying to resolve: "${t}" at path "${r}", we encountered a closed loop. The parent key "${ir(n)}" is called the same as the variable "${t}" we're looking for.`);if(i.lookForDataContainers&&typeof i.dataContainerIdentifierTails=="string"&&i.dataContainerIdentifierTails.length>0&&!n.endsWith(i.dataContainerIdentifierTails)){let s=D.default.get(e,n+i.dataContainerIdentifierTails);ee(s)&&D.default.get(s,t)&&(o=D.default.get(s,t),l=!1)}if(o===void 0){let s=D.default.get(e,n);ee(s)&&D.default.get(s,t)&&(o=D.default.get(s,t),l=!1)}}}if(o===void 0){let n=D.default.get(e,t);n!==void 0&&(o=n)}if(o===void 0)if(t.indexOf(".")===-1){let n=Be(e,t);if(n.length>0){for(let l=0,s=n.length;l<s;l++)if(A(n[l].val)||Le(n[l].val)||de(n[l].val)){o=n[l].val;break}else if(yi(n[l].val)){o=String(n[l].val);break}else if(Array.isArray(n[l].val)){o=n[l].val.join("");break}}}else{let n=Be(e,wi(t));if(n.length>0)for(let l=0,s=n.length;l<s;l++){let h=D.default.get(n[l].val,bi(t));h&&A(h)&&(o=h)}}return o}function ar(e,t,r,i,o=[]){if(o.includes(r)){let m="";if(o.length>1){let u=` \u2192
|
|
41
41
|
`;m=o.reduce((y,d,f)=>y+(f===0?"":u)+(d===r?"\u{1F4A5} ":" ")+d,` Here's the path we travelled up until we hit the recursion:
|
|
42
42
|
|
|
43
43
|
`),m+=`${u}\u{1F4A5} ${r}`}throw new Error(`json-variables/resolveString(): [THROW_ID_19] While trying to resolve: "${t}" at path "${r}", we encountered a closed loop, the key is referencing itself."${m}`)}let n={},l=Array.from(o);l.push(r);let s=new Z;function h(m,u,y){for(let d=0,f=m.length;d<f;d++){let p=m[d],w=t.slice(p.headsEndAt,p.tailsStartAt);if(w.length===0)s.push(p.headsStartAt,p.tailsEndAt);else if(di.call(n,w)&&A(n[w]))s.push(p.headsStartAt,p.tailsEndAt,n[w]);else{let b=$i(e,w.trim(),r,i);if(b===void 0)if(i.allowUnresolved===!0)b="";else if(typeof i.allowUnresolved=="string")b=i.allowUnresolved;else throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_18] We couldn't find the value to resolve the variable ${t.slice(p.headsEndAt,p.tailsStartAt)}. We're at path: "${r}".`);if(!y&&i.throwWhenNonStringInsertedInString&&!A(b))throw new Error(`json-variables/processHeadsAndTails(): [THROW_ID_23] While resolving the variable ${t.slice(p.headsEndAt,p.tailsStartAt)} at path ${r}, it resolved into a non-string value, ${JSON.stringify(b,null,4)}. This is happening because options setting "throwWhenNonStringInsertedInString" is active (set to "true").`);if(Le(b)){if(i.resolveToBoolIfAnyValuesContainBool)return s.wipe(),i.resolveToFalseIfAnyValuesContainBool?!1:b;b=""}else{if(de(b)&&y)return s.wipe(),b;Array.isArray(b)?b=String(b.join("")):de(b)?b="":b=String(b)}let O=r.includes(".")?`${nr(r)}.${w}`:w;if(qe(b,i)){let E=sr(ar(e,b,O,i,l),i,u,l,O,w.trim());typeof E=="string"&&s.push(p.headsStartAt,p.tailsEndAt,E)}else{n[w]=b;let E=sr(b,i,u,l,O,w.trim());typeof E=="string"&&s.push(p.headsStartAt,p.tailsEndAt,E)}}}}let a;try{a=Pe(t,i.heads,i.tails,{source:"",throwWhenSomethingWrongIsDetected:!1})}catch(m){throw new Error(`json-variables/resolveString(): [THROW_ID_17] While trying to resolve string: "${t}" at path ${r}, something wrong with heads and tails was detected! Here's the internal error message:
|
|
@@ -47,7 +47,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
47
47
|
/**
|
|
48
48
|
* @name arrayiffy-if-string
|
|
49
49
|
* @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
|
|
50
|
-
* @version 4.0.
|
|
50
|
+
* @version 4.0.11
|
|
51
51
|
* @author Roy Revelt, Codsen Ltd
|
|
52
52
|
* @license MIT
|
|
53
53
|
* {@link https://codsen.com/os/arrayiffy-if-string/}
|
|
@@ -55,7 +55,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
55
55
|
/**
|
|
56
56
|
* @name ast-get-values-by-key
|
|
57
57
|
* @fileoverview Extract values and paths from AST by keys OR set them by keys
|
|
58
|
-
* @version 4.0.
|
|
58
|
+
* @version 4.0.11
|
|
59
59
|
* @author Roy Revelt, Codsen Ltd
|
|
60
60
|
* @license MIT
|
|
61
61
|
* {@link https://codsen.com/os/ast-get-values-by-key/}
|
|
@@ -63,7 +63,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
63
63
|
/**
|
|
64
64
|
* @name ast-monkey-traverse
|
|
65
65
|
* @fileoverview Utility library to traverse AST
|
|
66
|
-
* @version 3.0.
|
|
66
|
+
* @version 3.0.11
|
|
67
67
|
* @author Roy Revelt, Codsen Ltd
|
|
68
68
|
* @license MIT
|
|
69
69
|
* {@link https://codsen.com/os/ast-monkey-traverse/}
|
|
@@ -71,7 +71,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
71
71
|
/**
|
|
72
72
|
* @name ast-monkey-util
|
|
73
73
|
* @fileoverview Utility library of AST helper functions
|
|
74
|
-
* @version 2.0.
|
|
74
|
+
* @version 2.0.11
|
|
75
75
|
* @author Roy Revelt, Codsen Ltd
|
|
76
76
|
* @license MIT
|
|
77
77
|
* {@link https://codsen.com/os/ast-monkey-util/}
|
|
@@ -79,7 +79,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
79
79
|
/**
|
|
80
80
|
* @name ranges-apply
|
|
81
81
|
* @fileoverview Take an array of string index ranges, delete/replace the string according to them
|
|
82
|
-
* @version 6.0.
|
|
82
|
+
* @version 6.0.11
|
|
83
83
|
* @author Roy Revelt, Codsen Ltd
|
|
84
84
|
* @license MIT
|
|
85
85
|
* {@link https://codsen.com/os/ranges-apply/}
|
|
@@ -87,7 +87,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
87
87
|
/**
|
|
88
88
|
* @name ranges-merge
|
|
89
89
|
* @fileoverview Merge and sort string index ranges
|
|
90
|
-
* @version 8.0.
|
|
90
|
+
* @version 8.0.11
|
|
91
91
|
* @author Roy Revelt, Codsen Ltd
|
|
92
92
|
* @license MIT
|
|
93
93
|
* {@link https://codsen.com/os/ranges-merge/}
|
|
@@ -95,7 +95,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
95
95
|
/**
|
|
96
96
|
* @name ranges-push
|
|
97
97
|
* @fileoverview Gather string index ranges
|
|
98
|
-
* @version 6.0.
|
|
98
|
+
* @version 6.0.11
|
|
99
99
|
* @author Roy Revelt, Codsen Ltd
|
|
100
100
|
* @license MIT
|
|
101
101
|
* {@link https://codsen.com/os/ranges-push/}
|
|
@@ -103,7 +103,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
103
103
|
/**
|
|
104
104
|
* @name ranges-sort
|
|
105
105
|
* @fileoverview Sort string index ranges
|
|
106
|
-
* @version 5.0.
|
|
106
|
+
* @version 5.0.11
|
|
107
107
|
* @author Roy Revelt, Codsen Ltd
|
|
108
108
|
* @license MIT
|
|
109
109
|
* {@link https://codsen.com/os/ranges-sort/}
|
|
@@ -111,7 +111,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
111
111
|
/**
|
|
112
112
|
* @name string-collapse-leading-whitespace
|
|
113
113
|
* @fileoverview Collapse the leading and trailing whitespace of a string
|
|
114
|
-
* @version 6.0.
|
|
114
|
+
* @version 6.0.11
|
|
115
115
|
* @author Roy Revelt, Codsen Ltd
|
|
116
116
|
* @license MIT
|
|
117
117
|
* {@link https://codsen.com/os/string-collapse-leading-whitespace/}
|
|
@@ -119,7 +119,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
119
119
|
/**
|
|
120
120
|
* @name string-find-heads-tails
|
|
121
121
|
* @fileoverview Finds where are arbitrary templating marker heads and tails located
|
|
122
|
-
* @version 5.0.
|
|
122
|
+
* @version 5.0.11
|
|
123
123
|
* @author Roy Revelt, Codsen Ltd
|
|
124
124
|
* @license MIT
|
|
125
125
|
* {@link https://codsen.com/os/string-find-heads-tails/}
|
|
@@ -127,7 +127,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
127
127
|
/**
|
|
128
128
|
* @name string-match-left-right
|
|
129
129
|
* @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
|
|
130
|
-
* @version 8.0.
|
|
130
|
+
* @version 8.0.11
|
|
131
131
|
* @author Roy Revelt, Codsen Ltd
|
|
132
132
|
* @license MIT
|
|
133
133
|
* {@link https://codsen.com/os/string-match-left-right/}
|
|
@@ -135,7 +135,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
135
135
|
/**
|
|
136
136
|
* @name string-remove-duplicate-heads-tails
|
|
137
137
|
* @fileoverview Detect and (recursively) remove head and tail wrappings around the input string
|
|
138
|
-
* @version 6.0.
|
|
138
|
+
* @version 6.0.11
|
|
139
139
|
* @author Roy Revelt, Codsen Ltd
|
|
140
140
|
* @license MIT
|
|
141
141
|
* {@link https://codsen.com/os/string-remove-duplicate-heads-tails/}
|
|
@@ -143,7 +143,7 @@ Please check the following key: ${l}`);if(s!==void 0?n=s:n=l,n==="")return n;if(
|
|
|
143
143
|
/**
|
|
144
144
|
* @name string-trim-spaces-only
|
|
145
145
|
* @fileoverview Like String.trim() but you can choose granularly what to trim
|
|
146
|
-
* @version 4.0.
|
|
146
|
+
* @version 4.0.11
|
|
147
147
|
* @author Roy Revelt, Codsen Ltd
|
|
148
148
|
* @license MIT
|
|
149
149
|
* {@link https://codsen.com/os/string-trim-spaces-only/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "json-variables",
|
|
3
|
-
"version": "11.0.
|
|
3
|
+
"version": "11.0.11",
|
|
4
4
|
"description": "Resolves custom-marked, cross-referenced paths in parsed JSON",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"comb",
|
|
@@ -42,13 +42,15 @@
|
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
44
44
|
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
45
|
-
"dts": "rollup -c",
|
|
45
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
46
46
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
47
47
|
"lect": "node '../../ops/lect/lect.js'",
|
|
48
48
|
"letspublish": "yarn publish || :",
|
|
49
49
|
"lint": "eslint . --fix",
|
|
50
50
|
"perf": "node perf/check.js",
|
|
51
51
|
"prepare": "echo 'ready'",
|
|
52
|
+
"prettier": "prettier",
|
|
53
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
52
54
|
"pretest": "yarn run lect && yarn run build",
|
|
53
55
|
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
54
56
|
"unit": "uvu test"
|
|
@@ -72,15 +74,15 @@
|
|
|
72
74
|
"various": {}
|
|
73
75
|
},
|
|
74
76
|
"dependencies": {
|
|
75
|
-
"arrayiffy-if-string": "^4.0.
|
|
76
|
-
"ast-get-values-by-key": "^4.0.
|
|
77
|
-
"ast-monkey-traverse": "^3.0.
|
|
77
|
+
"arrayiffy-if-string": "^4.0.11",
|
|
78
|
+
"ast-get-values-by-key": "^4.0.11",
|
|
79
|
+
"ast-monkey-traverse": "^3.0.11",
|
|
78
80
|
"matcher": "^5.0.0",
|
|
79
81
|
"object-path": "^0.11.8",
|
|
80
|
-
"ranges-apply": "^6.0.
|
|
81
|
-
"ranges-push": "^6.0.
|
|
82
|
-
"string-find-heads-tails": "^5.0.
|
|
83
|
-
"string-match-left-right": "^8.0.
|
|
84
|
-
"string-remove-duplicate-heads-tails": "^6.0.
|
|
82
|
+
"ranges-apply": "^6.0.11",
|
|
83
|
+
"ranges-push": "^6.0.11",
|
|
84
|
+
"string-find-heads-tails": "^5.0.11",
|
|
85
|
+
"string-match-left-right": "^8.0.11",
|
|
86
|
+
"string-remove-duplicate-heads-tails": "^6.0.11"
|
|
85
87
|
}
|
|
86
88
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
declare const version: string;
|
|
2
2
|
interface Obj {
|
|
3
|
-
|
|
3
|
+
[key: string]: any;
|
|
4
4
|
}
|
|
5
5
|
interface Opts {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
6
|
+
heads: string;
|
|
7
|
+
tails: string;
|
|
8
|
+
headsNoWrap: string;
|
|
9
|
+
tailsNoWrap: string;
|
|
10
|
+
lookForDataContainers: boolean;
|
|
11
|
+
dataContainerIdentifierTails: string;
|
|
12
|
+
wrapHeadsWith: string | string[];
|
|
13
|
+
wrapTailsWith: string | string[];
|
|
14
|
+
dontWrapVars: string[];
|
|
15
|
+
preventDoubleWrapping: boolean;
|
|
16
|
+
wrapGlobalFlipSwitch: boolean;
|
|
17
|
+
noSingleMarkers: boolean;
|
|
18
|
+
resolveToBoolIfAnyValuesContainBool: boolean;
|
|
19
|
+
resolveToFalseIfAnyValuesContainBool: boolean;
|
|
20
|
+
throwWhenNonStringInsertedInString: boolean;
|
|
21
|
+
allowUnresolved: boolean | string;
|
|
22
22
|
}
|
|
23
23
|
declare const defaults: Opts;
|
|
24
24
|
/**
|