object-flatten-referencing 5.0.16 → 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/CHANGELOG.md +22 -0
- package/README.md +4 -0
- package/dist/object-flatten-referencing.esm.js +2 -2
- package/dist/object-flatten-referencing.umd.js +4 -4
- package/package.json +46 -39
- package/dist/object-flatten-referencing.cjs.js +0 -264
- package/dist/object-flatten-referencing.dev.umd.js +0 -2399
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 6.0.1 (2021-09-13)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
|
|
11
|
+
|
|
12
|
+
## 6.0.0 (2021-09-09)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- migrate to ES Modules ([8c9d95d](https://github.com/codsen/codsen/commit/8c9d95d5dea0b769c2f070397141918a4893d575))
|
|
17
|
+
|
|
18
|
+
### BREAKING CHANGES
|
|
19
|
+
|
|
20
|
+
- programs now are in ES Modules and won't work with Common JS require()
|
|
21
|
+
|
|
22
|
+
## 5.1.0 (2021-05-24)
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
- config file based major bump blacklisting ([e15f9bb](https://github.com/codsen/codsen/commit/e15f9bba1c4fd5f847ac28b3f38fa6ee633f5dca))
|
|
27
|
+
|
|
6
28
|
## 5.0.15 (2021-04-11)
|
|
7
29
|
|
|
8
30
|
### Reverts
|
package/README.md
CHANGED
|
@@ -26,10 +26,14 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
+
This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
|
|
30
|
+
|
|
29
31
|
```bash
|
|
30
32
|
npm i object-flatten-referencing
|
|
31
33
|
```
|
|
32
34
|
|
|
35
|
+
If you need a legacy version which works with `require`, use version 5.1.0
|
|
36
|
+
|
|
33
37
|
## Quick Take
|
|
34
38
|
|
|
35
39
|
```js
|
|
@@ -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
|
|
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 = "
|
|
119
|
+
var version$1 = "6.0.2";
|
|
120
120
|
|
|
121
121
|
const version = version$1;
|
|
122
122
|
function existy(x) {
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name object-flatten-referencing
|
|
3
3
|
* @fileoverview Flatten complex nested objects according to a reference objects
|
|
4
|
-
* @version
|
|
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/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).objectFlattenReferencing={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{}
|
|
10
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).objectFlattenReferencing={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",o=9007199254740991,i="[object Arguments]",a="[object Boolean]",s="[object Date]",c="[object Function]",u="[object GeneratorFunction]",f="[object Map]",l="[object Number]",p="[object Object]",h="[object Promise]",y="[object RegExp]",g="[object Set]",d="[object String]",b="[object Symbol]",_="[object WeakMap]",v="[object ArrayBuffer]",w="[object DataView]",j="[object Float32Array]",W="[object Float64Array]",m="[object Int8Array]",A="[object Int16Array]",O="[object Int32Array]",T="[object Uint8Array]",x="[object Uint8ClampedArray]",I="[object Uint16Array]",$="[object Uint32Array]",E=/\w*$/,S=/^\[object .+?Constructor\]$/,P=/^(?:0|[1-9]\d*)$/,R={};R[i]=R["[object Array]"]=R[v]=R[w]=R[a]=R[s]=R[j]=R[W]=R[m]=R[A]=R[O]=R[f]=R[l]=R[p]=R[y]=R[g]=R[d]=R[b]=R[T]=R[x]=R[I]=R[$]=!0,R["[object Error]"]=R[c]=R[_]=!1;var C="object"==typeof self&&self&&self.Object===Object&&self,D="object"==typeof e&&e&&e.Object===Object&&e||C||Function("return this")(),M=r&&!r.nodeType&&r,k=M&&t&&!t.nodeType&&t,B=k&&k.exports===M;function F(t,e){return t.set(e[0],e[1]),t}function H(t,e){return t.add(e),t}function L(t,e,r,n){var o=-1,i=t?t.length:0;for(n&&i&&(r=t[++o]);++o<i;)r=e(r,t[o],o,t);return r}function K(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function G(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function U(t,e){return function(r){return t(e(r))}}function V(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var J,N=Array.prototype,z=Function.prototype,q=Object.prototype,Q=D["__core-js_shared__"],X=(J=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+J:"",Y=z.toString,Z=q.hasOwnProperty,tt=q.toString,et=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=B?D.Buffer:void 0,nt=D.Symbol,ot=D.Uint8Array,it=U(Object.getPrototypeOf,Object),at=Object.create,st=q.propertyIsEnumerable,ct=N.splice,ut=Object.getOwnPropertySymbols,ft=rt?rt.isBuffer:void 0,lt=U(Object.keys,Object),pt=kt(D,"DataView"),ht=kt(D,"Map"),yt=kt(D,"Promise"),gt=kt(D,"Set"),dt=kt(D,"WeakMap"),bt=kt(Object,"create"),_t=Kt(pt),vt=Kt(ht),wt=Kt(yt),jt=Kt(gt),Wt=Kt(dt),mt=nt?nt.prototype:void 0,At=mt?mt.valueOf:void 0;function Ot(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Tt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function xt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function It(t){this.__data__=new Tt(t)}function $t(t,e){var r=Ut(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Vt(t)}(t)&&Z.call(t,"callee")&&(!st.call(t,"callee")||tt.call(t)==i)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,o=!!n;for(var a in t)!e&&!Z.call(t,a)||o&&("length"==a||Ht(a,n))||r.push(a);return r}function Et(t,e,r){var n=t[e];Z.call(t,e)&&Gt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function St(t,e){for(var r=t.length;r--;)if(Gt(t[r][0],e))return r;return-1}function Pt(t,e,r,n,o,h,_){var S;if(n&&(S=h?n(t,o,h,_):n(t)),void 0!==S)return S;if(!zt(t))return t;var P=Ut(t);if(P){if(S=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&Z.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!e)return function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(t,S)}else{var C=Ft(t),D=C==c||C==u;if(Jt(t))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(t,e);if(C==p||C==i||D&&!h){if(K(t))return h?t:{};if(S=function(t){return"function"!=typeof t.constructor||Lt(t)?{}:(e=it(t),zt(e)?at(e):{});var e}(D?{}:t),!e)return function(t,e){return Dt(t,Bt(t),e)}(t,function(t,e){return t&&Dt(e,qt(e),t)}(S,t))}else{if(!R[C])return h?t:{};S=function(t,e,r,n){var o=t.constructor;switch(e){case v:return Ct(t);case a:case s:return new o(+t);case w:return function(t,e){var r=e?Ct(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case j:case W:case m:case A:case O:case T:case x:case I:case $:return function(t,e){var r=e?Ct(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case f:return function(t,e,r){return L(e?r(G(t),!0):G(t),F,new t.constructor)}(t,n,r);case l:case d:return new o(t);case y:return function(t){var e=new t.constructor(t.source,E.exec(t));return e.lastIndex=t.lastIndex,e}(t);case g:return function(t,e,r){return L(e?r(V(t),!0):V(t),H,new t.constructor)}(t,n,r);case b:return i=t,At?Object(At.call(i)):{}}var i}(t,C,Pt,e)}}_||(_=new It);var M=_.get(t);if(M)return M;if(_.set(t,S),!P)var k=r?function(t){return function(t,e,r){var n=e(t);return Ut(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,qt,Bt)}(t):qt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(k||t,(function(o,i){k&&(o=t[i=o]),Et(S,i,Pt(o,e,r,n,i,t,_))})),S}function Rt(t){return!(!zt(t)||(e=t,X&&X in e))&&(Nt(t)||K(t)?et:S).test(Kt(t));var e}function Ct(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Dt(t,e,r,n){r||(r={});for(var o=-1,i=e.length;++o<i;){var a=e[o],s=n?n(r[a],t[a],a,r,t):void 0;Et(r,a,void 0===s?t[a]:s)}return r}function Mt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function kt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Rt(r)?r:void 0}Ot.prototype.clear=function(){this.__data__=bt?bt(null):{}},Ot.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},Ot.prototype.get=function(t){var e=this.__data__;if(bt){var r=e[t];return r===n?void 0:r}return Z.call(e,t)?e[t]:void 0},Ot.prototype.has=function(t){var e=this.__data__;return bt?void 0!==e[t]:Z.call(e,t)},Ot.prototype.set=function(t,e){return this.__data__[t]=bt&&void 0===e?n:e,this},Tt.prototype.clear=function(){this.__data__=[]},Tt.prototype.delete=function(t){var e=this.__data__,r=St(e,t);return!(r<0)&&(r==e.length-1?e.pop():ct.call(e,r,1),!0)},Tt.prototype.get=function(t){var e=this.__data__,r=St(e,t);return r<0?void 0:e[r][1]},Tt.prototype.has=function(t){return St(this.__data__,t)>-1},Tt.prototype.set=function(t,e){var r=this.__data__,n=St(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},xt.prototype.clear=function(){this.__data__={hash:new Ot,map:new(ht||Tt),string:new Ot}},xt.prototype.delete=function(t){return Mt(this,t).delete(t)},xt.prototype.get=function(t){return Mt(this,t).get(t)},xt.prototype.has=function(t){return Mt(this,t).has(t)},xt.prototype.set=function(t,e){return Mt(this,t).set(t,e),this},It.prototype.clear=function(){this.__data__=new Tt},It.prototype.delete=function(t){return this.__data__.delete(t)},It.prototype.get=function(t){return this.__data__.get(t)},It.prototype.has=function(t){return this.__data__.has(t)},It.prototype.set=function(t,e){var r=this.__data__;if(r instanceof Tt){var n=r.__data__;if(!ht||n.length<199)return n.push([t,e]),this;r=this.__data__=new xt(n)}return r.set(t,e),this};var Bt=ut?U(ut,Object):function(){return[]},Ft=function(t){return tt.call(t)};function Ht(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||P.test(t))&&t>-1&&t%1==0&&t<e}function Lt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||q)}function Kt(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Gt(t,e){return t===e||t!=t&&e!=e}(pt&&Ft(new pt(new ArrayBuffer(1)))!=w||ht&&Ft(new ht)!=f||yt&&Ft(yt.resolve())!=h||gt&&Ft(new gt)!=g||dt&&Ft(new dt)!=_)&&(Ft=function(t){var e=tt.call(t),r=e==p?t.constructor:void 0,n=r?Kt(r):void 0;if(n)switch(n){case _t:return w;case vt:return f;case wt:return h;case jt:return g;case Wt:return _}return e});var Ut=Array.isArray;function Vt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!Nt(t)}var Jt=ft||function(){return!1};function Nt(t){var e=zt(t)?tt.call(t):"";return e==c||e==u}function zt(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function qt(t){return Vt(t)?$t(t):function(t){if(!Lt(t))return lt(t);var e=[];for(var r in Object(t))Z.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Pt(t,!0,!0)}}(r,r.exports);var n=r.exports;
|
|
11
11
|
/**
|
|
12
12
|
* @name str-indexes-of-plus
|
|
13
13
|
* @fileoverview Like indexOf but returns array and counts per-grapheme
|
|
14
|
-
* @version
|
|
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
|
|
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": "
|
|
3
|
+
"version": "6.0.2",
|
|
4
4
|
"description": "Flatten complex nested objects according to a reference objects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"advanced",
|
|
@@ -26,9 +26,11 @@
|
|
|
26
26
|
"email": "roy@codsen.com",
|
|
27
27
|
"url": "https://codsen.com"
|
|
28
28
|
},
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
|
|
29
|
+
"type": "module",
|
|
30
|
+
"exports": {
|
|
31
|
+
"script": "./dist/object-flatten-referencing.umd.js",
|
|
32
|
+
"default": "./dist/object-flatten-referencing.esm.js"
|
|
33
|
+
},
|
|
32
34
|
"types": "types/index.d.ts",
|
|
33
35
|
"scripts": {
|
|
34
36
|
"build": "rollup -c",
|
|
@@ -48,18 +50,20 @@
|
|
|
48
50
|
"pretest": "npm run build",
|
|
49
51
|
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
50
52
|
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
51
|
-
"unittest": "
|
|
53
|
+
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
|
|
52
54
|
"clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
|
|
53
55
|
"clean_types": "../../scripts/cleanTypes.js"
|
|
54
56
|
},
|
|
55
57
|
"tap": {
|
|
58
|
+
"check-coverage": false,
|
|
56
59
|
"coverage-report": [
|
|
57
60
|
"json-summary",
|
|
58
61
|
"text"
|
|
59
62
|
],
|
|
60
|
-
"
|
|
61
|
-
"--
|
|
62
|
-
"--
|
|
63
|
+
"node-arg": [
|
|
64
|
+
"--no-warnings",
|
|
65
|
+
"--experimental-loader",
|
|
66
|
+
"@istanbuljs/esm-loader-hook"
|
|
63
67
|
],
|
|
64
68
|
"timeout": 0
|
|
65
69
|
},
|
|
@@ -78,50 +82,53 @@
|
|
|
78
82
|
}
|
|
79
83
|
},
|
|
80
84
|
"dependencies": {
|
|
81
|
-
"@babel/runtime": "^7.
|
|
85
|
+
"@babel/runtime": "^7.15.4",
|
|
82
86
|
"lodash.clonedeep": "^4.5.0",
|
|
83
87
|
"lodash.isplainobject": "^4.0.6",
|
|
84
88
|
"matcher": "^4.0.0",
|
|
85
|
-
"str-indexes-of-plus": "^
|
|
89
|
+
"str-indexes-of-plus": "^4.0.2"
|
|
86
90
|
},
|
|
87
91
|
"devDependencies": {
|
|
88
|
-
"@babel/cli": "^7.
|
|
89
|
-
"@babel/core": "^7.
|
|
90
|
-
"@babel/node": "^7.
|
|
91
|
-
"@babel/plugin-external-helpers": "^7.
|
|
92
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
93
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.
|
|
94
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
95
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
96
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
97
|
-
"@babel/preset-env": "^7.
|
|
98
|
-
"@babel/preset-typescript": "^7.
|
|
99
|
-
"@babel/register": "^7.
|
|
92
|
+
"@babel/cli": "^7.15.4",
|
|
93
|
+
"@babel/core": "^7.15.5",
|
|
94
|
+
"@babel/node": "^7.15.4",
|
|
95
|
+
"@babel/plugin-external-helpers": "^7.14.5",
|
|
96
|
+
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
|
97
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
|
|
98
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.15.6",
|
|
99
|
+
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
|
|
100
|
+
"@babel/plugin-transform-runtime": "^7.15.0",
|
|
101
|
+
"@babel/preset-env": "^7.15.6",
|
|
102
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
103
|
+
"@babel/register": "^7.15.3",
|
|
104
|
+
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
100
105
|
"@rollup/plugin-babel": "^5.3.0",
|
|
101
|
-
"@rollup/plugin-commonjs": "^
|
|
106
|
+
"@rollup/plugin-commonjs": "^20.0.0",
|
|
102
107
|
"@rollup/plugin-json": "^4.1.0",
|
|
103
|
-
"@rollup/plugin-node-resolve": "^
|
|
104
|
-
"@rollup/plugin-
|
|
105
|
-
"@rollup/plugin-
|
|
106
|
-
"@rollup/plugin-typescript": "^8.2.1",
|
|
108
|
+
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
109
|
+
"@rollup/plugin-strip": "^2.1.0",
|
|
110
|
+
"@rollup/plugin-typescript": "^8.2.5",
|
|
107
111
|
"@types/lodash.clonedeep": "^4.5.6",
|
|
108
112
|
"@types/lodash.isplainobject": "^4.0.6",
|
|
109
|
-
"@types/node": "^
|
|
110
|
-
"@types/tap": "^
|
|
111
|
-
"@typescript-eslint/eslint-plugin": "^4.
|
|
112
|
-
"@typescript-eslint/parser": "^4.
|
|
113
|
-
"core-js": "^3.
|
|
113
|
+
"@types/node": "^16.9.1",
|
|
114
|
+
"@types/tap": "^15.0.5",
|
|
115
|
+
"@typescript-eslint/eslint-plugin": "^4.31.0",
|
|
116
|
+
"@typescript-eslint/parser": "^4.31.0",
|
|
117
|
+
"core-js": "^3.17.3",
|
|
114
118
|
"cross-env": "^7.0.3",
|
|
115
|
-
"eslint": "^7.
|
|
116
|
-
"lect": "^0.
|
|
117
|
-
"rollup": "^2.
|
|
119
|
+
"eslint": "^7.32.0",
|
|
120
|
+
"lect": "^0.18.2",
|
|
121
|
+
"rollup": "^2.56.3",
|
|
118
122
|
"rollup-plugin-ascii": "^0.0.3",
|
|
119
123
|
"rollup-plugin-banner": "^0.2.1",
|
|
120
124
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
121
|
-
"rollup-plugin-dts": "^
|
|
125
|
+
"rollup-plugin-dts": "^4.0.0",
|
|
122
126
|
"rollup-plugin-terser": "^7.0.2",
|
|
123
|
-
"tap": "^
|
|
124
|
-
"tslib": "^2.1
|
|
125
|
-
"typescript": "^4.
|
|
127
|
+
"tap": "^15.0.9",
|
|
128
|
+
"tslib": "^2.3.1",
|
|
129
|
+
"typescript": "^4.4.3"
|
|
130
|
+
},
|
|
131
|
+
"engines": {
|
|
132
|
+
"node": ">=12"
|
|
126
133
|
}
|
|
127
134
|
}
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name object-flatten-referencing
|
|
3
|
-
* @fileoverview Flatten complex nested objects according to a reference objects
|
|
4
|
-
* @version 5.0.16
|
|
5
|
-
* @author Roy Revelt, Codsen Ltd
|
|
6
|
-
* @license MIT
|
|
7
|
-
* {@link https://codsen.com/os/object-flatten-referencing/}
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
13
|
-
|
|
14
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
15
|
-
var _typeof = require('@babel/runtime/helpers/typeof');
|
|
16
|
-
var clone = require('lodash.clonedeep');
|
|
17
|
-
var strIndexesOfPlus = require('str-indexes-of-plus');
|
|
18
|
-
var matcher = require('matcher');
|
|
19
|
-
var isObj = require('lodash.isplainobject');
|
|
20
|
-
|
|
21
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
22
|
-
|
|
23
|
-
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
24
|
-
var _typeof__default = /*#__PURE__*/_interopDefaultLegacy(_typeof);
|
|
25
|
-
var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
|
|
26
|
-
var matcher__default = /*#__PURE__*/_interopDefaultLegacy(matcher);
|
|
27
|
-
var isObj__default = /*#__PURE__*/_interopDefaultLegacy(isObj);
|
|
28
|
-
|
|
29
|
-
var defaults = {
|
|
30
|
-
wrapHeadsWith: "%%_",
|
|
31
|
-
wrapTailsWith: "_%%",
|
|
32
|
-
dontWrapKeys: [],
|
|
33
|
-
dontWrapPaths: [],
|
|
34
|
-
xhtml: true,
|
|
35
|
-
preventDoubleWrapping: true,
|
|
36
|
-
preventWrappingIfContains: [],
|
|
37
|
-
objectKeyAndValueJoinChar: ".",
|
|
38
|
-
wrapGlobalFlipSwitch: true,
|
|
39
|
-
ignore: [],
|
|
40
|
-
whatToDoWhenReferenceIsMissing: 0,
|
|
41
|
-
mergeArraysWithLineBreaks: true,
|
|
42
|
-
mergeWithoutTrailingBrIfLineContainsBr: true,
|
|
43
|
-
enforceStrictKeyset: true
|
|
44
|
-
};
|
|
45
|
-
function isStr$1(something) {
|
|
46
|
-
return typeof something === "string";
|
|
47
|
-
}
|
|
48
|
-
function flattenObject(objOrig, originalOpts) {
|
|
49
|
-
var opts = _objectSpread__default['default'](_objectSpread__default['default']({}, defaults), originalOpts);
|
|
50
|
-
if (arguments.length === 0 || Object.keys(objOrig).length === 0) {
|
|
51
|
-
return [];
|
|
52
|
-
}
|
|
53
|
-
var obj = clone__default['default'](objOrig);
|
|
54
|
-
var res = [];
|
|
55
|
-
if (isObj__default['default'](obj)) {
|
|
56
|
-
Object.keys(obj).forEach(function (key) {
|
|
57
|
-
if (isObj__default['default'](obj[key])) {
|
|
58
|
-
obj[key] = flattenObject(obj[key], opts);
|
|
59
|
-
}
|
|
60
|
-
if (Array.isArray(obj[key])) {
|
|
61
|
-
res = res.concat(obj[key].map(function (el) {
|
|
62
|
-
return key + opts.objectKeyAndValueJoinChar + el;
|
|
63
|
-
}));
|
|
64
|
-
}
|
|
65
|
-
if (isStr$1(obj[key])) {
|
|
66
|
-
res.push(key + opts.objectKeyAndValueJoinChar + obj[key]);
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
return res;
|
|
71
|
-
}
|
|
72
|
-
function flattenArr(arrOrig, originalOpts) {
|
|
73
|
-
var wrap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
74
|
-
var joinArraysUsingBrs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
75
|
-
var opts = _objectSpread__default['default'](_objectSpread__default['default']({}, defaults), originalOpts);
|
|
76
|
-
if (arguments.length === 0 || arrOrig.length === 0) {
|
|
77
|
-
return "";
|
|
78
|
-
}
|
|
79
|
-
var arr = clone__default['default'](arrOrig);
|
|
80
|
-
var res = "";
|
|
81
|
-
if (arr.length > 0) {
|
|
82
|
-
if (joinArraysUsingBrs) {
|
|
83
|
-
for (var i = 0, len = arr.length; i < len; i++) {
|
|
84
|
-
if (isStr$1(arr[i])) {
|
|
85
|
-
var lineBreak = void 0;
|
|
86
|
-
lineBreak = "";
|
|
87
|
-
if (opts.mergeArraysWithLineBreaks && i > 0 && (!opts.mergeWithoutTrailingBrIfLineContainsBr || typeof arr[i - 1] !== "string" || opts.mergeWithoutTrailingBrIfLineContainsBr && arr[i - 1] !== undefined && !arr[i - 1].toLowerCase().includes("<br"))) {
|
|
88
|
-
lineBreak = "<br".concat(opts.xhtml ? " /" : "", ">");
|
|
89
|
-
}
|
|
90
|
-
res += lineBreak + (wrap ? opts.wrapHeadsWith : "") + arr[i] + (wrap ? opts.wrapTailsWith : "");
|
|
91
|
-
} else if (Array.isArray(arr[i])) {
|
|
92
|
-
if (arr[i].length > 0 && arr[i].every(isStr$1)) {
|
|
93
|
-
(function () {
|
|
94
|
-
var lineBreak = "";
|
|
95
|
-
if (opts.mergeArraysWithLineBreaks && res.length > 0) {
|
|
96
|
-
lineBreak = "<br".concat(opts.xhtml ? " /" : "", ">");
|
|
97
|
-
}
|
|
98
|
-
res = arr[i].reduce(function (acc, val, i2, arr2) {
|
|
99
|
-
var trailingSpace = "";
|
|
100
|
-
if (i2 !== arr2.length - 1) {
|
|
101
|
-
trailingSpace = " ";
|
|
102
|
-
}
|
|
103
|
-
return acc + (i2 === 0 ? lineBreak : "") + (wrap ? opts.wrapHeadsWith : "") + val + (wrap ? opts.wrapTailsWith : "") + trailingSpace;
|
|
104
|
-
}, res);
|
|
105
|
-
})();
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
} else {
|
|
110
|
-
res = arr.reduce(function (acc, val, i, arr2) {
|
|
111
|
-
var lineBreak = "";
|
|
112
|
-
if (opts.mergeArraysWithLineBreaks && i > 0) {
|
|
113
|
-
lineBreak = "<br".concat(opts.xhtml ? " /" : "", ">");
|
|
114
|
-
}
|
|
115
|
-
var trailingSpace = "";
|
|
116
|
-
if (i !== arr2.length - 1) {
|
|
117
|
-
trailingSpace = " ";
|
|
118
|
-
}
|
|
119
|
-
return acc + (i === 0 ? lineBreak : "") + (wrap ? opts.wrapHeadsWith : "") + val + (wrap ? opts.wrapTailsWith : "") + trailingSpace;
|
|
120
|
-
}, res);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return res;
|
|
124
|
-
}
|
|
125
|
-
function arrayiffyString(something) {
|
|
126
|
-
if (isStr$1(something)) {
|
|
127
|
-
if (something.length > 0) {
|
|
128
|
-
return [something];
|
|
129
|
-
}
|
|
130
|
-
return [];
|
|
131
|
-
}
|
|
132
|
-
return something;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
var version$1 = "5.0.16";
|
|
136
|
-
|
|
137
|
-
var version = version$1;
|
|
138
|
-
function existy(x) {
|
|
139
|
-
return x != null;
|
|
140
|
-
}
|
|
141
|
-
function isStr(something) {
|
|
142
|
-
return typeof something === "string";
|
|
143
|
-
}
|
|
144
|
-
function flattenReferencing(originalInput1, originalReference1, opts1) {
|
|
145
|
-
if (arguments.length === 0) {
|
|
146
|
-
throw new Error("object-flatten-referencing/ofr(): [THROW_ID_01] all inputs missing!");
|
|
147
|
-
}
|
|
148
|
-
if (arguments.length === 1) {
|
|
149
|
-
throw new Error("object-flatten-referencing/ofr(): [THROW_ID_02] reference object missing!");
|
|
150
|
-
}
|
|
151
|
-
if (existy(opts1) && !isObj__default['default'](opts1)) {
|
|
152
|
-
throw new Error("object-flatten-referencing/ofr(): [THROW_ID_03] third input, options object must be a plain object. Currently it's: ".concat(_typeof__default['default'](opts1)));
|
|
153
|
-
}
|
|
154
|
-
var originalOpts = _objectSpread__default['default'](_objectSpread__default['default']({}, defaults), opts1);
|
|
155
|
-
originalOpts.dontWrapKeys = arrayiffyString(originalOpts.dontWrapKeys);
|
|
156
|
-
originalOpts.preventWrappingIfContains = arrayiffyString(originalOpts.preventWrappingIfContains);
|
|
157
|
-
originalOpts.dontWrapPaths = arrayiffyString(originalOpts.dontWrapPaths);
|
|
158
|
-
originalOpts.ignore = arrayiffyString(originalOpts.ignore);
|
|
159
|
-
if (typeof originalOpts.whatToDoWhenReferenceIsMissing !== "number") {
|
|
160
|
-
originalOpts.whatToDoWhenReferenceIsMissing = +originalOpts.whatToDoWhenReferenceIsMissing || 0;
|
|
161
|
-
}
|
|
162
|
-
function ofr(originalInput, originalReference, opts) {
|
|
163
|
-
var wrap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
164
|
-
var joinArraysUsingBrs = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
|
|
165
|
-
var currentRoot = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : "";
|
|
166
|
-
var input = clone__default['default'](originalInput);
|
|
167
|
-
var reference = clone__default['default'](originalReference);
|
|
168
|
-
if (!opts.wrapGlobalFlipSwitch) {
|
|
169
|
-
wrap = false;
|
|
170
|
-
}
|
|
171
|
-
if (isObj__default['default'](input)) {
|
|
172
|
-
Object.keys(input).forEach(function (key) {
|
|
173
|
-
var currentPath = currentRoot + (currentRoot.length === 0 ? key : ".".concat(key));
|
|
174
|
-
if (opts.ignore.length === 0 || !opts.ignore.includes(key)) {
|
|
175
|
-
if (opts.wrapGlobalFlipSwitch) {
|
|
176
|
-
wrap = true;
|
|
177
|
-
if (opts.dontWrapKeys.length > 0) {
|
|
178
|
-
wrap = wrap && !opts.dontWrapKeys.some(function (elem) {
|
|
179
|
-
return matcher__default['default'].isMatch(key, elem, {
|
|
180
|
-
caseSensitive: true
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
if (opts.dontWrapPaths.length > 0) {
|
|
185
|
-
wrap = wrap && !opts.dontWrapPaths.some(function (elem) {
|
|
186
|
-
return elem === currentPath;
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
if (opts.preventWrappingIfContains.length > 0 && typeof input[key] === "string") {
|
|
190
|
-
wrap = wrap && !opts.preventWrappingIfContains.some(function (elem) {
|
|
191
|
-
return input[key].includes(elem);
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
if (existy(reference[key]) || !existy(reference[key]) && opts.whatToDoWhenReferenceIsMissing === 2) {
|
|
196
|
-
if (Array.isArray(input[key])) {
|
|
197
|
-
if (opts.whatToDoWhenReferenceIsMissing === 2 || isStr(reference[key])) {
|
|
198
|
-
input[key] = flattenArr(input[key], opts, wrap, joinArraysUsingBrs);
|
|
199
|
-
} else {
|
|
200
|
-
if (input[key].every(function (el) {
|
|
201
|
-
return typeof el === "string" || Array.isArray(el);
|
|
202
|
-
})) {
|
|
203
|
-
var allOK = true;
|
|
204
|
-
input[key].forEach(function (oneOfElements) {
|
|
205
|
-
if (Array.isArray(oneOfElements) && !oneOfElements.every(isStr)) {
|
|
206
|
-
allOK = false;
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
if (allOK) {
|
|
210
|
-
joinArraysUsingBrs = false;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
input[key] = ofr(input[key], reference[key], opts, wrap, joinArraysUsingBrs, currentPath);
|
|
214
|
-
}
|
|
215
|
-
} else if (isObj__default['default'](input[key])) {
|
|
216
|
-
if (opts.whatToDoWhenReferenceIsMissing === 2 || isStr(reference[key])) {
|
|
217
|
-
input[key] = flattenArr(flattenObject(input[key], opts), opts, wrap, joinArraysUsingBrs);
|
|
218
|
-
} else if (!wrap) {
|
|
219
|
-
input[key] = ofr(input[key], reference[key], _objectSpread__default['default'](_objectSpread__default['default']({}, opts), {}, {
|
|
220
|
-
wrapGlobalFlipSwitch: false
|
|
221
|
-
}), wrap, joinArraysUsingBrs, currentPath);
|
|
222
|
-
} else {
|
|
223
|
-
input[key] = ofr(input[key], reference[key], opts, wrap, joinArraysUsingBrs, currentPath);
|
|
224
|
-
}
|
|
225
|
-
} else if (isStr(input[key])) {
|
|
226
|
-
input[key] = ofr(input[key], reference[key], opts, wrap, joinArraysUsingBrs, currentPath);
|
|
227
|
-
}
|
|
228
|
-
} else if (_typeof__default['default'](input[key]) !== _typeof__default['default'](reference[key])) {
|
|
229
|
-
if (opts.whatToDoWhenReferenceIsMissing === 1) {
|
|
230
|
-
throw new Error("object-flatten-referencing/ofr(): [THROW_ID_06] reference object does not have the key ".concat(key, " and we need it. TIP: Turn off throwing via opts.whatToDoWhenReferenceIsMissing."));
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
});
|
|
235
|
-
} else if (Array.isArray(input)) {
|
|
236
|
-
if (Array.isArray(reference)) {
|
|
237
|
-
input.forEach(function (_el, i) {
|
|
238
|
-
if (existy(input[i]) && existy(reference[i])) {
|
|
239
|
-
input[i] = ofr(input[i], reference[i], opts, wrap, joinArraysUsingBrs, "".concat(currentRoot, "[").concat(i, "]"));
|
|
240
|
-
} else {
|
|
241
|
-
input[i] = ofr(input[i], reference[0], opts, wrap, joinArraysUsingBrs, "".concat(currentRoot, "[").concat(i, "]"));
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
} else if (isStr(reference)) {
|
|
245
|
-
input = flattenArr(input, opts, wrap, joinArraysUsingBrs);
|
|
246
|
-
}
|
|
247
|
-
} else if (isStr(input)) {
|
|
248
|
-
if (input.length > 0 && (opts.wrapHeadsWith || opts.wrapTailsWith)) {
|
|
249
|
-
if (!opts.preventDoubleWrapping || (opts.wrapHeadsWith === "" || !strIndexesOfPlus.strIndexesOfPlus(input, opts.wrapHeadsWith.trim()).length) && (opts.wrapTailsWith === "" || !strIndexesOfPlus.strIndexesOfPlus(input, opts.wrapTailsWith.trim()).length)) {
|
|
250
|
-
input = (wrap ? opts.wrapHeadsWith : "") + input + (wrap ? opts.wrapTailsWith : "");
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
return input;
|
|
255
|
-
}
|
|
256
|
-
return ofr(originalInput1, originalReference1, originalOpts);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
exports.arrayiffyString = arrayiffyString;
|
|
260
|
-
exports.defaults = defaults;
|
|
261
|
-
exports.flattenArr = flattenArr;
|
|
262
|
-
exports.flattenObject = flattenObject;
|
|
263
|
-
exports.flattenReferencing = flattenReferencing;
|
|
264
|
-
exports.version = version;
|