array-of-arrays-into-ast
Advanced tools
Comparing version
@@ -6,2 +6,8 @@ # Change Log | ||
## 2.0.15 (2021-04-11) | ||
### Reverts | ||
- Revert "chore: setup refresh" ([23cf206](https://github.com/codsen/codsen/commit/23cf206970a087ff0fa04e61f94d919f59ab3881)) | ||
## 2.0.1 (2021-01-28) | ||
@@ -8,0 +14,0 @@ |
/** | ||
* @name array-of-arrays-into-ast | ||
* @fileoverview Turns an array of arrays of data into a nested tree of plain objects | ||
* @version 2.0.14 | ||
* @version 2.0.15 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -25,3 +25,3 @@ * @license MIT | ||
var version$1 = "2.0.14"; | ||
var version$1 = "2.0.15"; | ||
@@ -28,0 +28,0 @@ var version = version$1; |
/** | ||
* @name array-of-arrays-into-ast | ||
* @fileoverview Turns an array of arrays of data into a nested tree of plain objects | ||
* @version 2.0.14 | ||
* @version 2.0.15 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -12,3 +12,3 @@ * @license MIT | ||
var version$1 = "2.0.14"; | ||
var version$1 = "2.0.15"; | ||
@@ -15,0 +15,0 @@ const version = version$1; |
/** | ||
* @name array-of-arrays-into-ast | ||
* @fileoverview Turns an array of arrays of data into a nested tree of plain objects | ||
* @version 2.0.14 | ||
* @version 2.0.15 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -14,3 +14,3 @@ * @license MIT | ||
* @fileoverview Like _.includes but with wildcards | ||
* @version 3.0.14 | ||
* @version 3.0.15 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -24,3 +24,3 @@ * @license MIT | ||
* @fileoverview Is the input (plain object, array, string or whatever) not empty? | ||
* @version 3.0.14 | ||
* @version 3.0.15 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -33,6 +33,6 @@ * @license MIT | ||
* @fileoverview Recursively, deeply merge of anything (objects, arrays, strings or nested thereof), which weighs contents by type hierarchy to ensure the maximum content is retained | ||
* @version 12.0.11 | ||
* @version 12.0.12 | ||
* @author Roy Revelt, Codsen Ltd | ||
* @license MIT | ||
* {@link https://codsen.com/os/object-merge-advanced/} | ||
*/function Kt(t){return"string"==typeof t}function Pt(t){return"boolean"==typeof t}const Bt=Array.isArray;function Ct(t){return!!t&&t.some((t=>"string"==typeof t))}function Nt(t,e){return 0===Object.keys(t).length||0===Object.keys(e).length||Object.keys(t).every((t=>Object.keys(e).includes(t)))||Object.keys(e).every((e=>Object.keys(t).includes(e)))}function Rt(t){return null===t?"null":St(t)?"date":mt(t)?"object":Bt(t)?"array":typeof t}const Dt={cb:null,mergeObjectsOnlyWhenKeysetMatches:!0,ignoreKeys:[],hardMergeKeys:[],hardArrayConcatKeys:[],mergeArraysContainingStringsToBeEmpty:!1,oneToManyArrayObjectMerge:!1,hardMergeEverything:!1,hardArrayConcat:!1,ignoreEverything:!1,concatInsteadOfMerging:!0,dedupeStringsInArrayValues:!1,mergeBoolsUsingOrNotAnd:!0,useNullAsExplicitFalse:!1};function Ut(t,e,n,o){const c={...Dt,...o};let u;if("string"==typeof c.ignoreKeys&&(c.ignoreKeys=[c.ignoreKeys]),"string"==typeof c.hardMergeKeys&&(c.hardMergeKeys=[c.hardMergeKeys]),c.hardMergeKeys.includes("*")&&(c.hardMergeEverything=!0),c.ignoreKeys.includes("*")&&(c.ignoreEverything=!0),c.useNullAsExplicitFalse&&(null===e||null===n))return"function"==typeof c.cb?c.cb(e,n,null,{path:t.path,key:t.key,type:t.type}):null;let i=Bt(e)||mt(e)?r(e):e;const a=Bt(n)||mt(n)?r(n):n;let f;c.ignoreEverything?f=i:c.hardMergeEverything&&(f=a);const s=c.hardMergeEverything||c.ignoreEverything;if(!Bt(i)){if(mt(i)){if(It(i)){if(Bt(a)){if(It(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}if(mt(a)){Object.keys(a).forEach((e=>{u=t.path&&t.path.length?`${t.path}.${e}`:`${e}`,i[e]=i.hasOwnProperty(e)?Ft(e,c.ignoreKeys)?Ut({path:u,key:e,type:[Rt(i),Rt(a)]},i[e],a[e],{...c,ignoreEverything:!0}):Ft(e,c.hardMergeKeys)?Ut({path:u,key:e,type:[Rt(i),Rt(a)]},i[e],a[e],{...c,hardMergeEverything:!0}):Ft(e,c.hardArrayConcatKeys)?Ut({path:u,key:e,type:[Rt(i),Rt(a)]},i[e],a[e],{...c,hardArrayConcat:!0}):Ut({path:u,key:e,type:[Rt(i[e]),Rt(a[e])]},i[e],a[e],c):a[e]}));const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):i}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(Bt(a)||mt(a)||It(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(St(i)){if(isFinite(i)){if(St(a)){if(isFinite(a)){const o=s?f:i>a?i:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:a||i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(St(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(Kt(i)){if(It(i)){if((Bt(a)||mt(a)||Kt(a))&&It(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(null!=a&&!Pt(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if("number"==typeof i){if(It(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(Pt(i)){if(Pt(a)){if(c.mergeBoolsUsingOrNotAnd){const o=s?f:i||a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i&&a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(null!=a){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(null===i){if(null!=a){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}{const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}}if(!It(i)){if(It(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}if(!Bt(a)||!It(a)){const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}{if(c.mergeArraysContainingStringsToBeEmpty&&(Ct(i)||Ct(a))){const o=s?f:[];return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}if(c.hardArrayConcat){const o=s?f:i.concat(a);return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}let o=[];for(let e=0,n=Math.max(i.length,a.length);e<n;e++)u=t.path&&t.path.length?`${t.path}.${e}`:`${e}`,mt(i[e])&&mt(a[e])&&(c.mergeObjectsOnlyWhenKeysetMatches&&Nt(i[e],a[e])||!c.mergeObjectsOnlyWhenKeysetMatches)?o.push(Ut({path:u,key:t.key,type:[Rt(i),Rt(a)]},i[e],a[e],c)):!c.oneToManyArrayObjectMerge||1!==i.length&&1!==a.length?c.concatInsteadOfMerging?(e<i.length&&o.push(i[e]),e<a.length&&o.push(a[e])):(e<i.length&&o.push(i[e]),e<a.length&&!B(i,a[e])&&o.push(a[e])):o.push(1===i.length?Ut({path:u,key:t.key,type:[Rt(i),Rt(a)]},i[0],a[e],c):Ut({path:u,key:t.key,type:[Rt(i),Rt(a)]},i[e],a[0],c));c.dedupeStringsInArrayValues&&o.every((t=>Kt(t)))&&(o=vt(o).sort()),i=r(o)}const y=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),y,{path:t.path,key:t.key,type:t.type}):y}const Wt={dedupe:!0};t.defaults=Wt,t.generateAst=function(t,e){if(!Array.isArray(t))throw new Error(`array-of-arrays-into-ast: [THROW_ID_01] input must be array. Currently it's of a type ${typeof t} equal to:\n${JSON.stringify(t,null,4)}`);if(0===t.length)return{};const n={...Wt,...e};let r={};return t.forEach((t=>{let e=null;for(let n=t.length;n--;)e={[t[n]]:[e]};r=function(t,e,n){if(!arguments.length)throw new TypeError("object-merge-advanced/mergeAdvanced(): [THROW_ID_01] Both inputs are missing");return Ut({key:null,path:"",type:[Rt(t),Rt(e)]},t,e,n)}(r,e,{concatInsteadOfMerging:!n.dedupe})})),o=r,Object.keys(o).sort().reduce(((t,e)=>(t[e]=o[e],t)),{});var o},t.version="2.0.14",Object.defineProperty(t,"__esModule",{value:!0})})); | ||
*/function Kt(t){return"string"==typeof t}function Pt(t){return"boolean"==typeof t}const Bt=Array.isArray;function Ct(t){return!!t&&t.some((t=>"string"==typeof t))}function Nt(t,e){return 0===Object.keys(t).length||0===Object.keys(e).length||Object.keys(t).every((t=>Object.keys(e).includes(t)))||Object.keys(e).every((e=>Object.keys(t).includes(e)))}function Rt(t){return null===t?"null":St(t)?"date":mt(t)?"object":Bt(t)?"array":typeof t}const Dt={cb:null,mergeObjectsOnlyWhenKeysetMatches:!0,ignoreKeys:[],hardMergeKeys:[],hardArrayConcatKeys:[],mergeArraysContainingStringsToBeEmpty:!1,oneToManyArrayObjectMerge:!1,hardMergeEverything:!1,hardArrayConcat:!1,ignoreEverything:!1,concatInsteadOfMerging:!0,dedupeStringsInArrayValues:!1,mergeBoolsUsingOrNotAnd:!0,useNullAsExplicitFalse:!1};function Ut(t,e,n,o){const c={...Dt,...o};let u;if("string"==typeof c.ignoreKeys&&(c.ignoreKeys=[c.ignoreKeys]),"string"==typeof c.hardMergeKeys&&(c.hardMergeKeys=[c.hardMergeKeys]),c.hardMergeKeys.includes("*")&&(c.hardMergeEverything=!0),c.ignoreKeys.includes("*")&&(c.ignoreEverything=!0),c.useNullAsExplicitFalse&&(null===e||null===n))return"function"==typeof c.cb?c.cb(e,n,null,{path:t.path,key:t.key,type:t.type}):null;let i=Bt(e)||mt(e)?r(e):e;const a=Bt(n)||mt(n)?r(n):n;let f;c.ignoreEverything?f=i:c.hardMergeEverything&&(f=a);const s=c.hardMergeEverything||c.ignoreEverything;if(!Bt(i)){if(mt(i)){if(It(i)){if(Bt(a)){if(It(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}if(mt(a)){Object.keys(a).forEach((e=>{u=t.path&&t.path.length?`${t.path}.${e}`:`${e}`,i[e]=i.hasOwnProperty(e)?Ft(e,c.ignoreKeys)?Ut({path:u,key:e,type:[Rt(i),Rt(a)]},i[e],a[e],{...c,ignoreEverything:!0}):Ft(e,c.hardMergeKeys)?Ut({path:u,key:e,type:[Rt(i),Rt(a)]},i[e],a[e],{...c,hardMergeEverything:!0}):Ft(e,c.hardArrayConcatKeys)?Ut({path:u,key:e,type:[Rt(i),Rt(a)]},i[e],a[e],{...c,hardArrayConcat:!0}):Ut({path:u,key:e,type:[Rt(i[e]),Rt(a[e])]},i[e],a[e],c):a[e]}));const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):i}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(Bt(a)||mt(a)||It(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(St(i)){if(isFinite(i)){if(St(a)){if(isFinite(a)){const o=s?f:i>a?i:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:a||i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(St(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(Kt(i)){if(It(i)){if((Bt(a)||mt(a)||Kt(a))&&It(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(null!=a&&!Pt(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if("number"==typeof i){if(It(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(Pt(i)){if(Pt(a)){if(c.mergeBoolsUsingOrNotAnd){const o=s?f:i||a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i&&a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(null!=a){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}if(null===i){if(null!=a){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}{const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:t.path,key:t.key,type:t.type}):o}}if(!It(i)){if(It(a)){const o=s?f:a;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}if(!Bt(a)||!It(a)){const o=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}{if(c.mergeArraysContainingStringsToBeEmpty&&(Ct(i)||Ct(a))){const o=s?f:[];return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}if(c.hardArrayConcat){const o=s?f:i.concat(a);return"function"==typeof c.cb?c.cb(r(e),r(n),o,{path:u,key:t.key,type:t.type}):o}let o=[];for(let e=0,n=Math.max(i.length,a.length);e<n;e++)u=t.path&&t.path.length?`${t.path}.${e}`:`${e}`,mt(i[e])&&mt(a[e])&&(c.mergeObjectsOnlyWhenKeysetMatches&&Nt(i[e],a[e])||!c.mergeObjectsOnlyWhenKeysetMatches)?o.push(Ut({path:u,key:t.key,type:[Rt(i),Rt(a)]},i[e],a[e],c)):!c.oneToManyArrayObjectMerge||1!==i.length&&1!==a.length?c.concatInsteadOfMerging?(e<i.length&&o.push(i[e]),e<a.length&&o.push(a[e])):(e<i.length&&o.push(i[e]),e<a.length&&!B(i,a[e])&&o.push(a[e])):o.push(1===i.length?Ut({path:u,key:t.key,type:[Rt(i),Rt(a)]},i[0],a[e],c):Ut({path:u,key:t.key,type:[Rt(i),Rt(a)]},i[e],a[0],c));c.dedupeStringsInArrayValues&&o.every((t=>Kt(t)))&&(o=vt(o).sort()),i=r(o)}const y=s?f:i;return"function"==typeof c.cb?c.cb(r(e),r(n),y,{path:t.path,key:t.key,type:t.type}):y}const Wt={dedupe:!0};t.defaults=Wt,t.generateAst=function(t,e){if(!Array.isArray(t))throw new Error(`array-of-arrays-into-ast: [THROW_ID_01] input must be array. Currently it's of a type ${typeof t} equal to:\n${JSON.stringify(t,null,4)}`);if(0===t.length)return{};const n={...Wt,...e};let r={};return t.forEach((t=>{let e=null;for(let n=t.length;n--;)e={[t[n]]:[e]};r=function(t,e,n){if(!arguments.length)throw new TypeError("object-merge-advanced/mergeAdvanced(): [THROW_ID_01] Both inputs are missing");return Ut({key:null,path:"",type:[Rt(t),Rt(e)]},t,e,n)}(r,e,{concatInsteadOfMerging:!n.dedupe})})),o=r,Object.keys(o).sort().reduce(((t,e)=>(t[e]=o[e],t)),{});var o},t.version="2.0.15",Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "array-of-arrays-into-ast", | ||
"version": "2.0.14", | ||
"version": "2.0.15", | ||
"description": "Turns an array of arrays of data into a nested tree of plain objects", | ||
@@ -79,4 +79,4 @@ "keywords": [ | ||
"@babel/runtime": "^7.13.10", | ||
"check-types-mini": "^6.0.14", | ||
"object-merge-advanced": "^12.0.11" | ||
"check-types-mini": "^6.0.15", | ||
"object-merge-advanced": "^12.0.12" | ||
}, | ||
@@ -110,3 +110,3 @@ "devDependencies": { | ||
"eslint": "^7.23.0", | ||
"lect": "^0.16.14", | ||
"lect": "^0.16.15", | ||
"rollup": "^2.44.0", | ||
@@ -113,0 +113,0 @@ "rollup-plugin-ascii": "^0.0.3", |
Sorry, the diff of this file is too big to display
156786
0.1%+ Added
- Removed
Updated