object-flatten-referencing 6.0.6 → 6.0.7

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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name object-flatten-referencing
3
3
  * @fileoverview Flatten complex nested objects according to a reference objects
4
- * @version 6.0.6
4
+ * @version 6.0.7
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/object-flatten-referencing/}
@@ -134,7 +134,7 @@ function arrayiffyString(something) {
134
134
  return something;
135
135
  }
136
136
 
137
- var version$1 = "6.0.6";
137
+ var version$1 = "6.0.7";
138
138
 
139
139
  const version = version$1;
140
140
  function existy(x) {
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @name object-flatten-referencing
3
3
  * @fileoverview Flatten complex nested objects according to a reference objects
4
- * @version 6.0.6
4
+ * @version 6.0.7
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/object-flatten-referencing/}
@@ -11,8 +11,8 @@
11
11
  /**
12
12
  * @name str-indexes-of-plus
13
13
  * @fileoverview Like indexOf but returns array and counts per-grapheme
14
- * @version 4.0.6
14
+ * @version 4.0.7
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/str-indexes-of-plus/}
18
- */function o(t,e,r=0){if("string"!=typeof t)throw new TypeError("str-indexes-of-plus/strIndexesOfPlus(): first input argument must be a string! Currently it's: "+typeof t);if("string"!=typeof e)throw new TypeError("str-indexes-of-plus/strIndexesOfPlus(): second input argument must be a string! Currently it's: "+typeof e);if(isNaN(+r)||"string"==typeof r&&!/^\d*$/.test(r))throw new TypeError(`str-indexes-of-plus/strIndexesOfPlus(): third input argument must be a natural number! Currently it's: ${r}`);const n=Array.from(t),o=Array.from(e);if(0===n.length||0===o.length||null!=r&&+r>=n.length)return[];r||(r=0);const i=[];let a,c=!1;for(let t=r,e=n.length;t<e;t++)c&&(n[t]===o[t-+a]?t-+a+1===o.length&&i.push(+a):(a=null,c=!1)),c||n[t]===o[0]&&(1===o.length?i.push(t):(c=!0,a=t));return i}const i=new Map,a=(t,e)=>{if(!Array.isArray(t))switch(typeof t){case"string":t=[t];break;case"undefined":t=[];break;default:throw new TypeError(`Expected '${e}' to be a string or an array, but got a type of '${typeof t}'`)}return t.filter((t=>{if("string"!=typeof t){if(void 0===t)return!1;throw new TypeError(`Expected '${e}' to be an array of strings, but found a type of '${typeof t}' in the array`)}return!0}))},c=(t,e)=>{e={caseSensitive:!1,...e};const r=t+JSON.stringify(e);if(i.has(r))return i.get(r);const n="!"===t[0];n&&(t=t.slice(1)),t=function(t){if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(t).replace(/\\\*/g,"[\\s\\S]*");const o=new RegExp(`^${t}$`,e.caseSensitive?"":"i");return o.negated=n,i.set(r,o),o};function s(t,e,r){return((t,e,r,n)=>{if(t=a(t,"inputs"),0===(e=a(e,"patterns")).length)return[];e=e.map((t=>c(t,r)));const{allPatterns:o}=r||{},i=[];for(const r of t){let t;const a=[...e].fill(!1);for(const[n,o]of e.entries())if(o.test(r)&&(a[n]=!0,t=!o.negated,!t))break;if(!(!1===t||void 0===t&&e.some((t=>!t.negated))||o&&a.some(((t,r)=>!t&&!e[r].negated)))&&(i.push(r),n))break}return i})(t,e,r,!0).length>0}var u,f,l=Object.prototype,p=Function.prototype.toString,h=l.hasOwnProperty,y=p.call(Object),g=l.toString,d=(u=Object.getPrototypeOf,f=Object,function(t){return u(f(t))});var b=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=g.call(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=d(t);if(null===e)return!0;var r=h.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&p.call(r)==y};const _={wrapHeadsWith:"%%_",wrapTailsWith:"_%%",dontWrapKeys:[],dontWrapPaths:[],xhtml:!0,preventDoubleWrapping:!0,preventWrappingIfContains:[],objectKeyAndValueJoinChar:".",wrapGlobalFlipSwitch:!0,ignore:[],whatToDoWhenReferenceIsMissing:0,mergeArraysWithLineBreaks:!0,mergeWithoutTrailingBrIfLineContainsBr:!0,enforceStrictKeyset:!0};function v(t){return"string"==typeof t}function w(t,e){const r={..._,...e};if(0===arguments.length||0===Object.keys(t).length)return[];const o=n(t);let i=[];return b(o)&&Object.keys(o).forEach((t=>{b(o[t])&&(o[t]=w(o[t],r)),Array.isArray(o[t])&&(i=i.concat(o[t].map((e=>t+r.objectKeyAndValueJoinChar+e)))),v(o[t])&&i.push(t+r.objectKeyAndValueJoinChar+o[t])})),i}function j(t,e,r=!1,o=!1){const i={..._,...e};if(0===arguments.length||0===t.length)return"";const a=n(t);let c="";if(a.length>0)if(o){for(let t=0,e=a.length;t<e;t++)if(v(a[t])){let e;e="",i.mergeArraysWithLineBreaks&&t>0&&(!i.mergeWithoutTrailingBrIfLineContainsBr||"string"!=typeof a[t-1]||i.mergeWithoutTrailingBrIfLineContainsBr&&void 0!==a[t-1]&&!a[t-1].toLowerCase().includes("<br"))&&(e=`<br${i.xhtml?" /":""}>`),c+=e+(r?i.wrapHeadsWith:"")+a[t]+(r?i.wrapTailsWith:"")}else if(Array.isArray(a[t])&&a[t].length>0&&a[t].every(v)){let e="";i.mergeArraysWithLineBreaks&&c.length>0&&(e=`<br${i.xhtml?" /":""}>`),c=a[t].reduce(((t,n,o,a)=>{let c="";return o!==a.length-1&&(c=" "),t+(0===o?e:"")+(r?i.wrapHeadsWith:"")+n+(r?i.wrapTailsWith:"")+c}),c)}}else c=a.reduce(((t,e,n,o)=>{let a="";i.mergeArraysWithLineBreaks&&n>0&&(a=`<br${i.xhtml?" /":""}>`);let c="";return n!==o.length-1&&(c=" "),t+(0===n?a:"")+(r?i.wrapHeadsWith:"")+e+(r?i.wrapTailsWith:"")+c}),c);return c}function W(t){return v(t)?t.length>0?[t]:[]:t}function m(t){return null!=t}function A(t){return"string"==typeof t}t.arrayiffyString=W,t.defaults=_,t.flattenArr=j,t.flattenObject=w,t.flattenReferencing=function(t,e,r){if(0===arguments.length)throw new Error("object-flatten-referencing/ofr(): [THROW_ID_01] all inputs missing!");if(1===arguments.length)throw new Error("object-flatten-referencing/ofr(): [THROW_ID_02] reference object missing!");if(m(r)&&!b(r))throw new Error("object-flatten-referencing/ofr(): [THROW_ID_03] third input, options object must be a plain object. Currently it's: "+typeof r);const i={..._,...r};function a(t,e,r,i=!0,c=!0,u=""){let f=n(t);const l=n(e);return r.wrapGlobalFlipSwitch||(i=!1),b(f)?Object.keys(f).forEach((t=>{const e=u+(0===u.length?t:`.${t}`);if(0===r.ignore.length||!r.ignore.includes(t))if(r.wrapGlobalFlipSwitch&&(i=!0,r.dontWrapKeys.length>0&&(i=i&&!r.dontWrapKeys.some((e=>s(t,e,{caseSensitive:!0})))),r.dontWrapPaths.length>0&&(i=i&&!r.dontWrapPaths.some((t=>t===e))),r.preventWrappingIfContains.length>0&&"string"==typeof f[t]&&(i=i&&!r.preventWrappingIfContains.some((e=>f[t].includes(e))))),m(l[t])||!m(l[t])&&2===r.whatToDoWhenReferenceIsMissing)if(Array.isArray(f[t]))if(2===r.whatToDoWhenReferenceIsMissing||A(l[t]))f[t]=j(f[t],r,i,c);else{if(f[t].every((t=>"string"==typeof t||Array.isArray(t)))){let e=!0;f[t].forEach((t=>{Array.isArray(t)&&!t.every(A)&&(e=!1)})),e&&(c=!1)}f[t]=a(f[t],l[t],r,i,c,e)}else b(f[t])?f[t]=2===r.whatToDoWhenReferenceIsMissing||A(l[t])?j(w(f[t],r),r,i,c):a(f[t],l[t],i?r:{...r,wrapGlobalFlipSwitch:!1},i,c,e):A(f[t])&&(f[t]=a(f[t],l[t],r,i,c,e));else if(typeof f[t]!=typeof l[t]&&1===r.whatToDoWhenReferenceIsMissing)throw new Error(`object-flatten-referencing/ofr(): [THROW_ID_06] reference object does not have the key ${t} and we need it. TIP: Turn off throwing via opts.whatToDoWhenReferenceIsMissing.`)})):Array.isArray(f)?Array.isArray(l)?f.forEach(((t,e)=>{f[e]=m(f[e])&&m(l[e])?a(f[e],l[e],r,i,c,`${u}[${e}]`):a(f[e],l[0],r,i,c,`${u}[${e}]`)})):A(l)&&(f=j(f,r,i,c)):A(f)&&f.length>0&&(r.wrapHeadsWith||r.wrapTailsWith)&&(r.preventDoubleWrapping&&(""!==r.wrapHeadsWith&&o(f,r.wrapHeadsWith.trim()).length||""!==r.wrapTailsWith&&o(f,r.wrapTailsWith.trim()).length)||(f=(i?r.wrapHeadsWith:"")+f+(i?r.wrapTailsWith:""))),f}return i.dontWrapKeys=W(i.dontWrapKeys),i.preventWrappingIfContains=W(i.preventWrappingIfContains),i.dontWrapPaths=W(i.dontWrapPaths),i.ignore=W(i.ignore),"number"!=typeof i.whatToDoWhenReferenceIsMissing&&(i.whatToDoWhenReferenceIsMissing=+i.whatToDoWhenReferenceIsMissing||0),a(t,e,i)},t.version="6.0.6",Object.defineProperty(t,"__esModule",{value:!0})}));
18
+ */function o(t,e,r=0){if("string"!=typeof t)throw new TypeError("str-indexes-of-plus/strIndexesOfPlus(): first input argument must be a string! Currently it's: "+typeof t);if("string"!=typeof e)throw new TypeError("str-indexes-of-plus/strIndexesOfPlus(): second input argument must be a string! Currently it's: "+typeof e);if(isNaN(+r)||"string"==typeof r&&!/^\d*$/.test(r))throw new TypeError(`str-indexes-of-plus/strIndexesOfPlus(): third input argument must be a natural number! Currently it's: ${r}`);const n=Array.from(t),o=Array.from(e);if(0===n.length||0===o.length||null!=r&&+r>=n.length)return[];r||(r=0);const i=[];let a,c=!1;for(let t=r,e=n.length;t<e;t++)c&&(n[t]===o[t-+a]?t-+a+1===o.length&&i.push(+a):(a=null,c=!1)),c||n[t]===o[0]&&(1===o.length?i.push(t):(c=!0,a=t));return i}const i=new Map,a=(t,e)=>{if(!Array.isArray(t))switch(typeof t){case"string":t=[t];break;case"undefined":t=[];break;default:throw new TypeError(`Expected '${e}' to be a string or an array, but got a type of '${typeof t}'`)}return t.filter((t=>{if("string"!=typeof t){if(void 0===t)return!1;throw new TypeError(`Expected '${e}' to be an array of strings, but found a type of '${typeof t}' in the array`)}return!0}))},c=(t,e)=>{e={caseSensitive:!1,...e};const r=t+JSON.stringify(e);if(i.has(r))return i.get(r);const n="!"===t[0];n&&(t=t.slice(1)),t=function(t){if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(t).replace(/\\\*/g,"[\\s\\S]*");const o=new RegExp(`^${t}$`,e.caseSensitive?"":"i");return o.negated=n,i.set(r,o),o};function s(t,e,r){return((t,e,r,n)=>{if(t=a(t,"inputs"),0===(e=a(e,"patterns")).length)return[];e=e.map((t=>c(t,r)));const{allPatterns:o}=r||{},i=[];for(const r of t){let t;const a=[...e].fill(!1);for(const[n,o]of e.entries())if(o.test(r)&&(a[n]=!0,t=!o.negated,!t))break;if(!(!1===t||void 0===t&&e.some((t=>!t.negated))||o&&a.some(((t,r)=>!t&&!e[r].negated)))&&(i.push(r),n))break}return i})(t,e,r,!0).length>0}var u,f,l=Object.prototype,p=Function.prototype.toString,h=l.hasOwnProperty,y=p.call(Object),g=l.toString,d=(u=Object.getPrototypeOf,f=Object,function(t){return u(f(t))});var b=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=g.call(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=d(t);if(null===e)return!0;var r=h.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&p.call(r)==y};const _={wrapHeadsWith:"%%_",wrapTailsWith:"_%%",dontWrapKeys:[],dontWrapPaths:[],xhtml:!0,preventDoubleWrapping:!0,preventWrappingIfContains:[],objectKeyAndValueJoinChar:".",wrapGlobalFlipSwitch:!0,ignore:[],whatToDoWhenReferenceIsMissing:0,mergeArraysWithLineBreaks:!0,mergeWithoutTrailingBrIfLineContainsBr:!0,enforceStrictKeyset:!0};function v(t){return"string"==typeof t}function w(t,e){const r={..._,...e};if(0===arguments.length||0===Object.keys(t).length)return[];const o=n(t);let i=[];return b(o)&&Object.keys(o).forEach((t=>{b(o[t])&&(o[t]=w(o[t],r)),Array.isArray(o[t])&&(i=i.concat(o[t].map((e=>t+r.objectKeyAndValueJoinChar+e)))),v(o[t])&&i.push(t+r.objectKeyAndValueJoinChar+o[t])})),i}function j(t,e,r=!1,o=!1){const i={..._,...e};if(0===arguments.length||0===t.length)return"";const a=n(t);let c="";if(a.length>0)if(o){for(let t=0,e=a.length;t<e;t++)if(v(a[t])){let e;e="",i.mergeArraysWithLineBreaks&&t>0&&(!i.mergeWithoutTrailingBrIfLineContainsBr||"string"!=typeof a[t-1]||i.mergeWithoutTrailingBrIfLineContainsBr&&void 0!==a[t-1]&&!a[t-1].toLowerCase().includes("<br"))&&(e=`<br${i.xhtml?" /":""}>`),c+=e+(r?i.wrapHeadsWith:"")+a[t]+(r?i.wrapTailsWith:"")}else if(Array.isArray(a[t])&&a[t].length>0&&a[t].every(v)){let e="";i.mergeArraysWithLineBreaks&&c.length>0&&(e=`<br${i.xhtml?" /":""}>`),c=a[t].reduce(((t,n,o,a)=>{let c="";return o!==a.length-1&&(c=" "),t+(0===o?e:"")+(r?i.wrapHeadsWith:"")+n+(r?i.wrapTailsWith:"")+c}),c)}}else c=a.reduce(((t,e,n,o)=>{let a="";i.mergeArraysWithLineBreaks&&n>0&&(a=`<br${i.xhtml?" /":""}>`);let c="";return n!==o.length-1&&(c=" "),t+(0===n?a:"")+(r?i.wrapHeadsWith:"")+e+(r?i.wrapTailsWith:"")+c}),c);return c}function W(t){return v(t)?t.length>0?[t]:[]:t}function m(t){return null!=t}function A(t){return"string"==typeof t}t.arrayiffyString=W,t.defaults=_,t.flattenArr=j,t.flattenObject=w,t.flattenReferencing=function(t,e,r){if(0===arguments.length)throw new Error("object-flatten-referencing/ofr(): [THROW_ID_01] all inputs missing!");if(1===arguments.length)throw new Error("object-flatten-referencing/ofr(): [THROW_ID_02] reference object missing!");if(m(r)&&!b(r))throw new Error("object-flatten-referencing/ofr(): [THROW_ID_03] third input, options object must be a plain object. Currently it's: "+typeof r);const i={..._,...r};function a(t,e,r,i=!0,c=!0,u=""){let f=n(t);const l=n(e);return r.wrapGlobalFlipSwitch||(i=!1),b(f)?Object.keys(f).forEach((t=>{const e=u+(0===u.length?t:`.${t}`);if(0===r.ignore.length||!r.ignore.includes(t))if(r.wrapGlobalFlipSwitch&&(i=!0,r.dontWrapKeys.length>0&&(i=i&&!r.dontWrapKeys.some((e=>s(t,e,{caseSensitive:!0})))),r.dontWrapPaths.length>0&&(i=i&&!r.dontWrapPaths.some((t=>t===e))),r.preventWrappingIfContains.length>0&&"string"==typeof f[t]&&(i=i&&!r.preventWrappingIfContains.some((e=>f[t].includes(e))))),m(l[t])||!m(l[t])&&2===r.whatToDoWhenReferenceIsMissing)if(Array.isArray(f[t]))if(2===r.whatToDoWhenReferenceIsMissing||A(l[t]))f[t]=j(f[t],r,i,c);else{if(f[t].every((t=>"string"==typeof t||Array.isArray(t)))){let e=!0;f[t].forEach((t=>{Array.isArray(t)&&!t.every(A)&&(e=!1)})),e&&(c=!1)}f[t]=a(f[t],l[t],r,i,c,e)}else b(f[t])?f[t]=2===r.whatToDoWhenReferenceIsMissing||A(l[t])?j(w(f[t],r),r,i,c):a(f[t],l[t],i?r:{...r,wrapGlobalFlipSwitch:!1},i,c,e):A(f[t])&&(f[t]=a(f[t],l[t],r,i,c,e));else if(typeof f[t]!=typeof l[t]&&1===r.whatToDoWhenReferenceIsMissing)throw new Error(`object-flatten-referencing/ofr(): [THROW_ID_06] reference object does not have the key ${t} and we need it. TIP: Turn off throwing via opts.whatToDoWhenReferenceIsMissing.`)})):Array.isArray(f)?Array.isArray(l)?f.forEach(((t,e)=>{f[e]=m(f[e])&&m(l[e])?a(f[e],l[e],r,i,c,`${u}[${e}]`):a(f[e],l[0],r,i,c,`${u}[${e}]`)})):A(l)&&(f=j(f,r,i,c)):A(f)&&f.length>0&&(r.wrapHeadsWith||r.wrapTailsWith)&&(r.preventDoubleWrapping&&(""!==r.wrapHeadsWith&&o(f,r.wrapHeadsWith.trim()).length||""!==r.wrapTailsWith&&o(f,r.wrapTailsWith.trim()).length)||(f=(i?r.wrapHeadsWith:"")+f+(i?r.wrapTailsWith:""))),f}return i.dontWrapKeys=W(i.dontWrapKeys),i.preventWrappingIfContains=W(i.preventWrappingIfContains),i.dontWrapPaths=W(i.dontWrapPaths),i.ignore=W(i.ignore),"number"!=typeof i.whatToDoWhenReferenceIsMissing&&(i.whatToDoWhenReferenceIsMissing=+i.whatToDoWhenReferenceIsMissing||0),a(t,e,i)},t.version="6.0.7",Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "object-flatten-referencing",
3
- "version": "6.0.6",
3
+ "version": "6.0.7",
4
4
  "description": "Flatten complex nested objects according to a reference objects",
5
5
  "keywords": [
6
6
  "advanced",
@@ -82,7 +82,7 @@
82
82
  "lodash.clonedeep": "^4.5.0",
83
83
  "lodash.isplainobject": "^4.0.6",
84
84
  "matcher": "^5.0.0",
85
- "str-indexes-of-plus": "^4.0.6"
85
+ "str-indexes-of-plus": "^4.0.7"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@babel/cli": "^7.16.0",
@@ -106,21 +106,21 @@
106
106
  "@rollup/plugin-typescript": "^8.3.0",
107
107
  "@types/lodash.clonedeep": "^4.5.6",
108
108
  "@types/lodash.isplainobject": "^4.0.6",
109
- "@types/node": "^16.11.9",
109
+ "@types/node": "^16.11.10",
110
110
  "@types/tap": "^15.0.5",
111
- "@typescript-eslint/eslint-plugin": "^5.4.0",
112
- "@typescript-eslint/parser": "^5.4.0",
113
- "core-js": "^3.19.1",
111
+ "@typescript-eslint/eslint-plugin": "^5.5.0",
112
+ "@typescript-eslint/parser": "^5.5.0",
113
+ "core-js": "^3.19.2",
114
114
  "cross-env": "^7.0.3",
115
115
  "eslint": "^8.3.0",
116
- "lect": "^0.18.6",
117
- "rollup": "^2.60.0",
116
+ "lect": "^0.18.7",
117
+ "rollup": "^2.60.1",
118
118
  "rollup-plugin-ascii": "^0.0.3",
119
119
  "rollup-plugin-banner": "^0.2.1",
120
120
  "rollup-plugin-cleanup": "^3.2.1",
121
121
  "rollup-plugin-dts": "^4.0.1",
122
122
  "rollup-plugin-terser": "^7.0.2",
123
- "tap": "^15.1.2",
123
+ "tap": "^15.1.5",
124
124
  "tslib": "^2.3.1",
125
125
  "typescript": "^4.5.2"
126
126
  },