object-flatten-referencing 6.0.1 → 6.0.2
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/README.md
CHANGED
|
@@ -32,7 +32,7 @@ This package is ESM only: Node 12+ is needed to use it and it must be imported i
|
|
|
32
32
|
npm i object-flatten-referencing
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with require
|
|
35
|
+
If you need a legacy version which works with `require`, use version 5.1.0
|
|
36
36
|
|
|
37
37
|
## Quick Take
|
|
38
38
|
|
|
@@ -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.
|
|
4
|
+
* @version 6.0.2
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/object-flatten-referencing/}
|
|
@@ -116,7 +116,7 @@ function arrayiffyString(something) {
|
|
|
116
116
|
return something;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
var version$1 = "6.0.
|
|
119
|
+
var version$1 = "6.0.2";
|
|
120
120
|
|
|
121
121
|
const version = version$1;
|
|
122
122
|
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.
|
|
4
|
+
* @version 6.0.2
|
|
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.
|
|
14
|
+
* @version 4.0.2
|
|
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,s=!1;for(let t=r,e=n.length;t<e;t++)s&&(n[t]===o[t-+a]?t-+a+1===o.length&&i.push(+a):(a=null,s=!1)),s||n[t]===o[0]&&(1===o.length?i.push(t):(s=!0,a=t));return i}var i={exports:{}};const a=t=>{if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")},s=new Map;function c(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}))}function u(t,e){e={caseSensitive:!1,...e};const r=t+JSON.stringify(e);if(s.has(r))return s.get(r);const n="!"===t[0];n&&(t=t.slice(1)),t=a(t).replace(/\\\*/g,"[\\s\\S]*");const o=new RegExp(`^${t}$`,e.caseSensitive?"":"i");return o.negated=n,s.set(r,o),o}i.exports=(t,e,r)=>{if(t=c(t,"inputs"),0===(e=c(e,"patterns")).length)return[];const n="!"===e[0][0];e=e.map((t=>u(t,r)));const o=[];for(const r of t){let t=n;for(const n of e)n.test(r)&&(t=!n.negated);t&&o.push(r)}return o},i.exports.isMatch=(t,e,r)=>(t=c(t,"inputs"),0!==(e=c(e,"patterns")).length&&t.some((t=>e.every((e=>{const n=u(e,r),o=n.test(t);return n.negated?!o:o})))));var f=i.exports;var l,p,h=Object.prototype,y=Function.prototype.toString,g=h.hasOwnProperty,d=y.call(Object),b=h.toString,_=(l=Object.getPrototypeOf,p=Object,function(t){return l(p(t))});var v=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=b.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=_(t);if(null===e)return!0;var r=g.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&y.call(r)==d};const w={wrapHeadsWith:"%%_",wrapTailsWith:"_%%",dontWrapKeys:[],dontWrapPaths:[],xhtml:!0,preventDoubleWrapping:!0,preventWrappingIfContains:[],objectKeyAndValueJoinChar:".",wrapGlobalFlipSwitch:!0,ignore:[],whatToDoWhenReferenceIsMissing:0,mergeArraysWithLineBreaks:!0,mergeWithoutTrailingBrIfLineContainsBr:!0,enforceStrictKeyset:!0};function j(t){return"string"==typeof t}function W(t,e){const r={...w,...e};if(0===arguments.length||0===Object.keys(t).length)return[];const o=n(t);let i=[];return v(o)&&Object.keys(o).forEach((t=>{v(o[t])&&(o[t]=W(o[t],r)),Array.isArray(o[t])&&(i=i.concat(o[t].map((e=>t+r.objectKeyAndValueJoinChar+e)))),j(o[t])&&i.push(t+r.objectKeyAndValueJoinChar+o[t])})),i}function m(t,e,r=!1,o=!1){const i={...w,...e};if(0===arguments.length||0===t.length)return"";const a=n(t);let s="";if(a.length>0)if(o){for(let t=0,e=a.length;t<e;t++)if(j(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?" /":""}>`),s+=e+(r?i.wrapHeadsWith:"")+a[t]+(r?i.wrapTailsWith:"")}else if(Array.isArray(a[t])&&a[t].length>0&&a[t].every(j)){let e="";i.mergeArraysWithLineBreaks&&s.length>0&&(e=`<br${i.xhtml?" /":""}>`),s=a[t].reduce(((t,n,o,a)=>{let s="";return o!==a.length-1&&(s=" "),t+(0===o?e:"")+(r?i.wrapHeadsWith:"")+n+(r?i.wrapTailsWith:"")+s}),s)}}else s=a.reduce(((t,e,n,o)=>{let a="";i.mergeArraysWithLineBreaks&&n>0&&(a=`<br${i.xhtml?" /":""}>`);let s="";return n!==o.length-1&&(s=" "),t+(0===n?a:"")+(r?i.wrapHeadsWith:"")+e+(r?i.wrapTailsWith:"")+s}),s);return s}function A(t){return j(t)?t.length>0?[t]:[]:t}function O(t){return null!=t}function T(t){return"string"==typeof t}t.arrayiffyString=A,t.defaults=w,t.flattenArr=m,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(O(r)&&!v(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={...w,...r};function a(t,e,r,i=!0,s=!0,c=""){let u=n(t);const l=n(e);return r.wrapGlobalFlipSwitch||(i=!1),v(u)?Object.keys(u).forEach((t=>{const e=c+(0===c.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=>f.isMatch(t,e,{caseSensitive:!0})))),r.dontWrapPaths.length>0&&(i=i&&!r.dontWrapPaths.some((t=>t===e))),r.preventWrappingIfContains.length>0&&"string"==typeof u[t]&&(i=i&&!r.preventWrappingIfContains.some((e=>u[t].includes(e))))),O(l[t])||!O(l[t])&&2===r.whatToDoWhenReferenceIsMissing)if(Array.isArray(u[t]))if(2===r.whatToDoWhenReferenceIsMissing||T(l[t]))u[t]=m(u[t],r,i,s);else{if(u[t].every((t=>"string"==typeof t||Array.isArray(t)))){let e=!0;u[t].forEach((t=>{Array.isArray(t)&&!t.every(T)&&(e=!1)})),e&&(s=!1)}u[t]=a(u[t],l[t],r,i,s,e)}else v(u[t])?u[t]=2===r.whatToDoWhenReferenceIsMissing||T(l[t])?m(W(u[t],r),r,i,s):a(u[t],l[t],i?r:{...r,wrapGlobalFlipSwitch:!1},i,s,e):T(u[t])&&(u[t]=a(u[t],l[t],r,i,s,e));else if(typeof u[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(u)?Array.isArray(l)?u.forEach(((t,e)=>{u[e]=O(u[e])&&O(l[e])?a(u[e],l[e],r,i,s,`${c}[${e}]`):a(u[e],l[0],r,i,s,`${c}[${e}]`)})):T(l)&&(u=m(u,r,i,s)):T(u)&&u.length>0&&(r.wrapHeadsWith||r.wrapTailsWith)&&(r.preventDoubleWrapping&&(""!==r.wrapHeadsWith&&o(u,r.wrapHeadsWith.trim()).length||""!==r.wrapTailsWith&&o(u,r.wrapTailsWith.trim()).length)||(u=(i?r.wrapHeadsWith:"")+u+(i?r.wrapTailsWith:""))),u}return i.dontWrapKeys=A(i.dontWrapKeys),i.preventWrappingIfContains=A(i.preventWrappingIfContains),i.dontWrapPaths=A(i.dontWrapPaths),i.ignore=A(i.ignore),"number"!=typeof i.whatToDoWhenReferenceIsMissing&&(i.whatToDoWhenReferenceIsMissing=+i.whatToDoWhenReferenceIsMissing||0),a(t,e,i)},t.version="6.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,s=!1;for(let t=r,e=n.length;t<e;t++)s&&(n[t]===o[t-+a]?t-+a+1===o.length&&i.push(+a):(a=null,s=!1)),s||n[t]===o[0]&&(1===o.length?i.push(t):(s=!0,a=t));return i}var i={exports:{}};const a=t=>{if("string"!=typeof t)throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")},s=new Map;function c(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}))}function u(t,e){e={caseSensitive:!1,...e};const r=t+JSON.stringify(e);if(s.has(r))return s.get(r);const n="!"===t[0];n&&(t=t.slice(1)),t=a(t).replace(/\\\*/g,"[\\s\\S]*");const o=new RegExp(`^${t}$`,e.caseSensitive?"":"i");return o.negated=n,s.set(r,o),o}i.exports=(t,e,r)=>{if(t=c(t,"inputs"),0===(e=c(e,"patterns")).length)return[];const n="!"===e[0][0];e=e.map((t=>u(t,r)));const o=[];for(const r of t){let t=n;for(const n of e)n.test(r)&&(t=!n.negated);t&&o.push(r)}return o},i.exports.isMatch=(t,e,r)=>(t=c(t,"inputs"),0!==(e=c(e,"patterns")).length&&t.some((t=>e.every((e=>{const n=u(e,r),o=n.test(t);return n.negated?!o:o})))));var f=i.exports;var l,p,h=Object.prototype,y=Function.prototype.toString,g=h.hasOwnProperty,d=y.call(Object),b=h.toString,_=(l=Object.getPrototypeOf,p=Object,function(t){return l(p(t))});var v=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=b.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=_(t);if(null===e)return!0;var r=g.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&y.call(r)==d};const w={wrapHeadsWith:"%%_",wrapTailsWith:"_%%",dontWrapKeys:[],dontWrapPaths:[],xhtml:!0,preventDoubleWrapping:!0,preventWrappingIfContains:[],objectKeyAndValueJoinChar:".",wrapGlobalFlipSwitch:!0,ignore:[],whatToDoWhenReferenceIsMissing:0,mergeArraysWithLineBreaks:!0,mergeWithoutTrailingBrIfLineContainsBr:!0,enforceStrictKeyset:!0};function j(t){return"string"==typeof t}function W(t,e){const r={...w,...e};if(0===arguments.length||0===Object.keys(t).length)return[];const o=n(t);let i=[];return v(o)&&Object.keys(o).forEach((t=>{v(o[t])&&(o[t]=W(o[t],r)),Array.isArray(o[t])&&(i=i.concat(o[t].map((e=>t+r.objectKeyAndValueJoinChar+e)))),j(o[t])&&i.push(t+r.objectKeyAndValueJoinChar+o[t])})),i}function m(t,e,r=!1,o=!1){const i={...w,...e};if(0===arguments.length||0===t.length)return"";const a=n(t);let s="";if(a.length>0)if(o){for(let t=0,e=a.length;t<e;t++)if(j(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?" /":""}>`),s+=e+(r?i.wrapHeadsWith:"")+a[t]+(r?i.wrapTailsWith:"")}else if(Array.isArray(a[t])&&a[t].length>0&&a[t].every(j)){let e="";i.mergeArraysWithLineBreaks&&s.length>0&&(e=`<br${i.xhtml?" /":""}>`),s=a[t].reduce(((t,n,o,a)=>{let s="";return o!==a.length-1&&(s=" "),t+(0===o?e:"")+(r?i.wrapHeadsWith:"")+n+(r?i.wrapTailsWith:"")+s}),s)}}else s=a.reduce(((t,e,n,o)=>{let a="";i.mergeArraysWithLineBreaks&&n>0&&(a=`<br${i.xhtml?" /":""}>`);let s="";return n!==o.length-1&&(s=" "),t+(0===n?a:"")+(r?i.wrapHeadsWith:"")+e+(r?i.wrapTailsWith:"")+s}),s);return s}function A(t){return j(t)?t.length>0?[t]:[]:t}function O(t){return null!=t}function T(t){return"string"==typeof t}t.arrayiffyString=A,t.defaults=w,t.flattenArr=m,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(O(r)&&!v(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={...w,...r};function a(t,e,r,i=!0,s=!0,c=""){let u=n(t);const l=n(e);return r.wrapGlobalFlipSwitch||(i=!1),v(u)?Object.keys(u).forEach((t=>{const e=c+(0===c.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=>f.isMatch(t,e,{caseSensitive:!0})))),r.dontWrapPaths.length>0&&(i=i&&!r.dontWrapPaths.some((t=>t===e))),r.preventWrappingIfContains.length>0&&"string"==typeof u[t]&&(i=i&&!r.preventWrappingIfContains.some((e=>u[t].includes(e))))),O(l[t])||!O(l[t])&&2===r.whatToDoWhenReferenceIsMissing)if(Array.isArray(u[t]))if(2===r.whatToDoWhenReferenceIsMissing||T(l[t]))u[t]=m(u[t],r,i,s);else{if(u[t].every((t=>"string"==typeof t||Array.isArray(t)))){let e=!0;u[t].forEach((t=>{Array.isArray(t)&&!t.every(T)&&(e=!1)})),e&&(s=!1)}u[t]=a(u[t],l[t],r,i,s,e)}else v(u[t])?u[t]=2===r.whatToDoWhenReferenceIsMissing||T(l[t])?m(W(u[t],r),r,i,s):a(u[t],l[t],i?r:{...r,wrapGlobalFlipSwitch:!1},i,s,e):T(u[t])&&(u[t]=a(u[t],l[t],r,i,s,e));else if(typeof u[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(u)?Array.isArray(l)?u.forEach(((t,e)=>{u[e]=O(u[e])&&O(l[e])?a(u[e],l[e],r,i,s,`${c}[${e}]`):a(u[e],l[0],r,i,s,`${c}[${e}]`)})):T(l)&&(u=m(u,r,i,s)):T(u)&&u.length>0&&(r.wrapHeadsWith||r.wrapTailsWith)&&(r.preventDoubleWrapping&&(""!==r.wrapHeadsWith&&o(u,r.wrapHeadsWith.trim()).length||""!==r.wrapTailsWith&&o(u,r.wrapTailsWith.trim()).length)||(u=(i?r.wrapHeadsWith:"")+u+(i?r.wrapTailsWith:""))),u}return i.dontWrapKeys=A(i.dontWrapKeys),i.preventWrappingIfContains=A(i.preventWrappingIfContains),i.dontWrapPaths=A(i.dontWrapPaths),i.ignore=A(i.ignore),"number"!=typeof i.whatToDoWhenReferenceIsMissing&&(i.whatToDoWhenReferenceIsMissing=+i.whatToDoWhenReferenceIsMissing||0),a(t,e,i)},t.version="6.0.2",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.
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"description": "Flatten complex nested objects according to a reference objects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"advanced",
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"lodash.clonedeep": "^4.5.0",
|
|
87
87
|
"lodash.isplainobject": "^4.0.6",
|
|
88
88
|
"matcher": "^4.0.0",
|
|
89
|
-
"str-indexes-of-plus": "^4.0.
|
|
89
|
+
"str-indexes-of-plus": "^4.0.2"
|
|
90
90
|
},
|
|
91
91
|
"devDependencies": {
|
|
92
92
|
"@babel/cli": "^7.15.4",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"core-js": "^3.17.3",
|
|
118
118
|
"cross-env": "^7.0.3",
|
|
119
119
|
"eslint": "^7.32.0",
|
|
120
|
-
"lect": "^0.18.
|
|
120
|
+
"lect": "^0.18.2",
|
|
121
121
|
"rollup": "^2.56.3",
|
|
122
122
|
"rollup-plugin-ascii": "^0.0.3",
|
|
123
123
|
"rollup-plugin-banner": "^0.2.1",
|