@fluixi/utils 1.0.0-alpha.53
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 +21 -0
- package/README.md +73 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/lib/array/advanced.cjs +1 -0
- package/dist/lib/array/advanced.d.ts +1116 -0
- package/dist/lib/array/advanced.d.ts.map +1 -0
- package/dist/lib/array/advanced.js +2429 -0
- package/dist/lib/array/advanced.mjs +1 -0
- package/dist/lib/array/array.cjs +1 -0
- package/dist/lib/array/array.d.ts +6 -0
- package/dist/lib/array/array.d.ts.map +1 -0
- package/dist/lib/array/array.js +31 -0
- package/dist/lib/array/array.mjs +1 -0
- package/dist/lib/array/index.cjs +1 -0
- package/dist/lib/array/index.d.ts +4 -0
- package/dist/lib/array/index.d.ts.map +1 -0
- package/dist/lib/array/index.js +3 -0
- package/dist/lib/array/index.mjs +1 -0
- package/dist/lib/array/utils.cjs +1 -0
- package/dist/lib/array/utils.d.ts +100 -0
- package/dist/lib/array/utils.d.ts.map +1 -0
- package/dist/lib/array/utils.js +165 -0
- package/dist/lib/array/utils.mjs +1 -0
- package/dist/lib/color/color.cjs +1 -0
- package/dist/lib/color/color.d.ts +366 -0
- package/dist/lib/color/color.d.ts.map +1 -0
- package/dist/lib/color/color.js +722 -0
- package/dist/lib/color/color.mjs +1 -0
- package/dist/lib/color/constants.cjs +1 -0
- package/dist/lib/color/constants.d.ts +361 -0
- package/dist/lib/color/constants.d.ts.map +1 -0
- package/dist/lib/color/constants.js +358 -0
- package/dist/lib/color/constants.mjs +1 -0
- package/dist/lib/color/conversions.cjs +1 -0
- package/dist/lib/color/conversions.d.ts +166 -0
- package/dist/lib/color/conversions.d.ts.map +1 -0
- package/dist/lib/color/conversions.js +766 -0
- package/dist/lib/color/conversions.mjs +1 -0
- package/dist/lib/color/helpers.cjs +1 -0
- package/dist/lib/color/helpers.d.ts +75 -0
- package/dist/lib/color/helpers.d.ts.map +1 -0
- package/dist/lib/color/helpers.js +419 -0
- package/dist/lib/color/helpers.mjs +1 -0
- package/dist/lib/color/index.cjs +1 -0
- package/dist/lib/color/index.d.ts +12 -0
- package/dist/lib/color/index.d.ts.map +1 -0
- package/dist/lib/color/index.js +15 -0
- package/dist/lib/color/index.mjs +1 -0
- package/dist/lib/color/types.cjs +1 -0
- package/dist/lib/color/types.d.ts +179 -0
- package/dist/lib/color/types.d.ts.map +1 -0
- package/dist/lib/color/types.js +1 -0
- package/dist/lib/color/types.mjs +0 -0
- package/dist/lib/color/utils.cjs +1 -0
- package/dist/lib/color/utils.d.ts +199 -0
- package/dist/lib/color/utils.d.ts.map +1 -0
- package/dist/lib/color/utils.js +858 -0
- package/dist/lib/color/utils.mjs +1 -0
- package/dist/lib/compare/comparators.cjs +1 -0
- package/dist/lib/compare/comparators.d.ts +65 -0
- package/dist/lib/compare/comparators.d.ts.map +1 -0
- package/dist/lib/compare/comparators.js +210 -0
- package/dist/lib/compare/comparators.mjs +1 -0
- package/dist/lib/compare/index.cjs +1 -0
- package/dist/lib/compare/index.d.ts +2 -0
- package/dist/lib/compare/index.d.ts.map +1 -0
- package/dist/lib/compare/index.js +1 -0
- package/dist/lib/compare/index.mjs +1 -0
- package/dist/lib/crypto/hash.cjs +1 -0
- package/dist/lib/crypto/hash.d.ts +6 -0
- package/dist/lib/crypto/hash.d.ts.map +1 -0
- package/dist/lib/crypto/hash.js +53 -0
- package/dist/lib/crypto/hash.mjs +1 -0
- package/dist/lib/crypto/index.cjs +1 -0
- package/dist/lib/crypto/index.d.ts +2 -0
- package/dist/lib/crypto/index.d.ts.map +1 -0
- package/dist/lib/crypto/index.js +1 -0
- package/dist/lib/crypto/index.mjs +1 -0
- package/dist/lib/dom/events.cjs +1 -0
- package/dist/lib/dom/events.d.ts +159 -0
- package/dist/lib/dom/events.d.ts.map +1 -0
- package/dist/lib/dom/events.js +50 -0
- package/dist/lib/dom/events.mjs +1 -0
- package/dist/lib/dom/index.cjs +1 -0
- package/dist/lib/dom/index.d.ts +3 -0
- package/dist/lib/dom/index.d.ts.map +1 -0
- package/dist/lib/dom/index.js +2 -0
- package/dist/lib/dom/index.mjs +1 -0
- package/dist/lib/dom/utils.cjs +1 -0
- package/dist/lib/dom/utils.d.ts +6 -0
- package/dist/lib/dom/utils.d.ts.map +1 -0
- package/dist/lib/dom/utils.js +37 -0
- package/dist/lib/dom/utils.mjs +1 -0
- package/dist/lib/functions/functions.cjs +1 -0
- package/dist/lib/functions/functions.d.ts +329 -0
- package/dist/lib/functions/functions.d.ts.map +1 -0
- package/dist/lib/functions/functions.js +585 -0
- package/dist/lib/functions/functions.mjs +1 -0
- package/dist/lib/functions/index.cjs +1 -0
- package/dist/lib/functions/index.d.ts +3 -0
- package/dist/lib/functions/index.d.ts.map +1 -0
- package/dist/lib/functions/index.js +1 -0
- package/dist/lib/functions/index.mjs +1 -0
- package/dist/lib/functions/types.cjs +1 -0
- package/dist/lib/functions/types.d.ts +2 -0
- package/dist/lib/functions/types.d.ts.map +1 -0
- package/dist/lib/functions/types.js +1 -0
- package/dist/lib/functions/types.mjs +0 -0
- package/dist/lib/helpers.cjs +1 -0
- package/dist/lib/helpers.d.ts +13 -0
- package/dist/lib/helpers.d.ts.map +1 -0
- package/dist/lib/helpers.js +66 -0
- package/dist/lib/helpers.mjs +1 -0
- package/dist/lib/index.cjs +1 -0
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.d.ts.map +1 -0
- package/dist/lib/index.js +8 -0
- package/dist/lib/index.mjs +1 -0
- package/dist/lib/maths/constants.cjs +1 -0
- package/dist/lib/maths/constants.d.ts +84 -0
- package/dist/lib/maths/constants.d.ts.map +1 -0
- package/dist/lib/maths/constants.js +79 -0
- package/dist/lib/maths/constants.mjs +1 -0
- package/dist/lib/maths/fn/advanced.cjs +1 -0
- package/dist/lib/maths/fn/advanced.d.ts +149 -0
- package/dist/lib/maths/fn/advanced.d.ts.map +1 -0
- package/dist/lib/maths/fn/advanced.js +264 -0
- package/dist/lib/maths/fn/advanced.mjs +1 -0
- package/dist/lib/maths/fn/basic.cjs +1 -0
- package/dist/lib/maths/fn/basic.d.ts +182 -0
- package/dist/lib/maths/fn/basic.d.ts.map +1 -0
- package/dist/lib/maths/fn/basic.js +343 -0
- package/dist/lib/maths/fn/basic.mjs +1 -0
- package/dist/lib/maths/fn/complex.cjs +1 -0
- package/dist/lib/maths/fn/complex.d.ts +153 -0
- package/dist/lib/maths/fn/complex.d.ts.map +1 -0
- package/dist/lib/maths/fn/complex.js +383 -0
- package/dist/lib/maths/fn/complex.mjs +1 -0
- package/dist/lib/maths/fn/index.cjs +1 -0
- package/dist/lib/maths/fn/index.d.ts +10 -0
- package/dist/lib/maths/fn/index.d.ts.map +1 -0
- package/dist/lib/maths/fn/index.js +9 -0
- package/dist/lib/maths/fn/index.mjs +1 -0
- package/dist/lib/maths/fn/trigo.cjs +1 -0
- package/dist/lib/maths/fn/trigo.d.ts +147 -0
- package/dist/lib/maths/fn/trigo.d.ts.map +1 -0
- package/dist/lib/maths/fn/trigo.js +227 -0
- package/dist/lib/maths/fn/trigo.mjs +1 -0
- package/dist/lib/maths/fn/vector.cjs +1 -0
- package/dist/lib/maths/fn/vector.d.ts +512 -0
- package/dist/lib/maths/fn/vector.d.ts.map +1 -0
- package/dist/lib/maths/fn/vector.js +1136 -0
- package/dist/lib/maths/fn/vector.mjs +1 -0
- package/dist/lib/maths/formatter.cjs +1 -0
- package/dist/lib/maths/formatter.d.ts +35 -0
- package/dist/lib/maths/formatter.d.ts.map +1 -0
- package/dist/lib/maths/formatter.js +56 -0
- package/dist/lib/maths/formatter.mjs +1 -0
- package/dist/lib/maths/guards.cjs +1 -0
- package/dist/lib/maths/guards.d.ts +166 -0
- package/dist/lib/maths/guards.d.ts.map +1 -0
- package/dist/lib/maths/guards.js +315 -0
- package/dist/lib/maths/guards.mjs +1 -0
- package/dist/lib/maths/index.cjs +1 -0
- package/dist/lib/maths/index.d.ts +24 -0
- package/dist/lib/maths/index.d.ts.map +1 -0
- package/dist/lib/maths/index.js +29 -0
- package/dist/lib/maths/index.mjs +1 -0
- package/dist/lib/maths/parser.cjs +1 -0
- package/dist/lib/maths/parser.d.ts +20 -0
- package/dist/lib/maths/parser.d.ts.map +1 -0
- package/dist/lib/maths/parser.js +78 -0
- package/dist/lib/maths/parser.mjs +1 -0
- package/dist/lib/maths/random.cjs +1 -0
- package/dist/lib/maths/random.d.ts +27 -0
- package/dist/lib/maths/random.d.ts.map +1 -0
- package/dist/lib/maths/random.js +49 -0
- package/dist/lib/maths/random.mjs +1 -0
- package/dist/lib/maths/types/advanced.cjs +1 -0
- package/dist/lib/maths/types/advanced.d.ts +357 -0
- package/dist/lib/maths/types/advanced.d.ts.map +1 -0
- package/dist/lib/maths/types/advanced.js +5 -0
- package/dist/lib/maths/types/advanced.mjs +0 -0
- package/dist/lib/maths/types/basic.cjs +1 -0
- package/dist/lib/maths/types/basic.d.ts +95 -0
- package/dist/lib/maths/types/basic.d.ts.map +1 -0
- package/dist/lib/maths/types/basic.js +5 -0
- package/dist/lib/maths/types/basic.mjs +0 -0
- package/dist/lib/maths/types/index.cjs +1 -0
- package/dist/lib/maths/types/index.d.ts +4 -0
- package/dist/lib/maths/types/index.d.ts.map +1 -0
- package/dist/lib/maths/types/index.js +3 -0
- package/dist/lib/maths/types/index.mjs +0 -0
- package/dist/lib/maths/types/negative.cjs +1 -0
- package/dist/lib/maths/types/negative.d.ts +51 -0
- package/dist/lib/maths/types/negative.d.ts.map +1 -0
- package/dist/lib/maths/types/negative.js +5 -0
- package/dist/lib/maths/types/negative.mjs +0 -0
- package/dist/lib/maths/types/operations.cjs +1 -0
- package/dist/lib/maths/types/operations.d.ts +188 -0
- package/dist/lib/maths/types/operations.d.ts.map +1 -0
- package/dist/lib/maths/types/operations.js +6 -0
- package/dist/lib/maths/types/operations.mjs +0 -0
- package/dist/lib/object/clone.cjs +1 -0
- package/dist/lib/object/clone.d.ts +46 -0
- package/dist/lib/object/clone.d.ts.map +1 -0
- package/dist/lib/object/clone.js +104 -0
- package/dist/lib/object/clone.mjs +1 -0
- package/dist/lib/object/diff.cjs +1 -0
- package/dist/lib/object/diff.d.ts +203 -0
- package/dist/lib/object/diff.d.ts.map +1 -0
- package/dist/lib/object/diff.js +805 -0
- package/dist/lib/object/diff.mjs +1 -0
- package/dist/lib/object/getter-setter.cjs +1 -0
- package/dist/lib/object/getter-setter.d.ts +361 -0
- package/dist/lib/object/getter-setter.d.ts.map +1 -0
- package/dist/lib/object/getter-setter.js +1771 -0
- package/dist/lib/object/getter-setter.mjs +1 -0
- package/dist/lib/object/index.cjs +6 -0
- package/dist/lib/object/index.d.ts +13 -0
- package/dist/lib/object/index.d.ts.map +1 -0
- package/dist/lib/object/index.js +12 -0
- package/dist/lib/object/index.mjs +6 -0
- package/dist/lib/object/merge.cjs +1 -0
- package/dist/lib/object/merge.d.ts +93 -0
- package/dist/lib/object/merge.d.ts.map +1 -0
- package/dist/lib/object/merge.js +474 -0
- package/dist/lib/object/merge.mjs +1 -0
- package/dist/lib/object/object.cjs +1 -0
- package/dist/lib/object/object.d.ts +128 -0
- package/dist/lib/object/object.d.ts.map +1 -0
- package/dist/lib/object/object.js +432 -0
- package/dist/lib/object/object.mjs +1 -0
- package/dist/lib/object/omit.cjs +1 -0
- package/dist/lib/object/omit.d.ts +351 -0
- package/dist/lib/object/omit.d.ts.map +1 -0
- package/dist/lib/object/omit.js +656 -0
- package/dist/lib/object/omit.mjs +1 -0
- package/dist/lib/object/reconcile.cjs +1 -0
- package/dist/lib/object/reconcile.d.ts +7 -0
- package/dist/lib/object/reconcile.d.ts.map +1 -0
- package/dist/lib/object/reconcile.js +122 -0
- package/dist/lib/object/reconcile.mjs +1 -0
- package/dist/lib/object/selector.cjs +1 -0
- package/dist/lib/object/selector.d.ts +50 -0
- package/dist/lib/object/selector.d.ts.map +1 -0
- package/dist/lib/object/selector.js +371 -0
- package/dist/lib/object/selector.mjs +1 -0
- package/dist/lib/object/sort.cjs +1 -0
- package/dist/lib/object/sort.d.ts +149 -0
- package/dist/lib/object/sort.d.ts.map +1 -0
- package/dist/lib/object/sort.js +298 -0
- package/dist/lib/object/sort.mjs +1 -0
- package/dist/lib/object/transform.cjs +1 -0
- package/dist/lib/object/transform.d.ts +620 -0
- package/dist/lib/object/transform.d.ts.map +1 -0
- package/dist/lib/object/transform.js +1058 -0
- package/dist/lib/object/transform.mjs +1 -0
- package/dist/lib/object/types.cjs +1 -0
- package/dist/lib/object/types.d.ts +250 -0
- package/dist/lib/object/types.d.ts.map +1 -0
- package/dist/lib/object/types.js +1 -0
- package/dist/lib/object/types.mjs +0 -0
- package/dist/lib/object/utils.cjs +6 -0
- package/dist/lib/object/utils.d.ts +165 -0
- package/dist/lib/object/utils.d.ts.map +1 -0
- package/dist/lib/object/utils.js +444 -0
- package/dist/lib/object/utils.mjs +6 -0
- package/dist/lib/primitive/boolean/boolean.cjs +1 -0
- package/dist/lib/primitive/boolean/boolean.d.ts +276 -0
- package/dist/lib/primitive/boolean/boolean.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/boolean.js +615 -0
- package/dist/lib/primitive/boolean/boolean.mjs +1 -0
- package/dist/lib/primitive/boolean/index.cjs +1 -0
- package/dist/lib/primitive/boolean/index.d.ts +3 -0
- package/dist/lib/primitive/boolean/index.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/index.js +2 -0
- package/dist/lib/primitive/boolean/index.mjs +1 -0
- package/dist/lib/primitive/boolean/types.cjs +1 -0
- package/dist/lib/primitive/boolean/types.d.ts +14 -0
- package/dist/lib/primitive/boolean/types.d.ts.map +1 -0
- package/dist/lib/primitive/boolean/types.js +1 -0
- package/dist/lib/primitive/boolean/types.mjs +0 -0
- package/dist/lib/primitive/date/date.cjs +1 -0
- package/dist/lib/primitive/date/date.d.ts +641 -0
- package/dist/lib/primitive/date/date.d.ts.map +1 -0
- package/dist/lib/primitive/date/date.js +1998 -0
- package/dist/lib/primitive/date/date.mjs +1 -0
- package/dist/lib/primitive/date/index.cjs +1 -0
- package/dist/lib/primitive/date/index.d.ts +3 -0
- package/dist/lib/primitive/date/index.d.ts.map +1 -0
- package/dist/lib/primitive/date/index.js +2 -0
- package/dist/lib/primitive/date/index.mjs +1 -0
- package/dist/lib/primitive/date/types.cjs +1 -0
- package/dist/lib/primitive/date/types.d.ts +205 -0
- package/dist/lib/primitive/date/types.d.ts.map +1 -0
- package/dist/lib/primitive/date/types.js +7 -0
- package/dist/lib/primitive/date/types.mjs +0 -0
- package/dist/lib/primitive/index.cjs +5 -0
- package/dist/lib/primitive/index.d.ts +5 -0
- package/dist/lib/primitive/index.d.ts.map +1 -0
- package/dist/lib/primitive/index.js +4 -0
- package/dist/lib/primitive/index.mjs +5 -0
- package/dist/lib/primitive/string/index.cjs +5 -0
- package/dist/lib/primitive/string/index.d.ts +3 -0
- package/dist/lib/primitive/string/index.d.ts.map +1 -0
- package/dist/lib/primitive/string/index.js +2 -0
- package/dist/lib/primitive/string/index.mjs +5 -0
- package/dist/lib/primitive/string/parser-2.cjs +8 -0
- package/dist/lib/primitive/string/parser-2.d.ts +17 -0
- package/dist/lib/primitive/string/parser-2.d.ts.map +1 -0
- package/dist/lib/primitive/string/parser-2.js +656 -0
- package/dist/lib/primitive/string/parser-2.mjs +8 -0
- package/dist/lib/primitive/string/parser.cjs +3 -0
- package/dist/lib/primitive/string/parser.d.ts +9 -0
- package/dist/lib/primitive/string/parser.d.ts.map +1 -0
- package/dist/lib/primitive/string/parser.js +775 -0
- package/dist/lib/primitive/string/parser.mjs +3 -0
- package/dist/lib/primitive/string/string.cjs +5 -0
- package/dist/lib/primitive/string/string.d.ts +535 -0
- package/dist/lib/primitive/string/string.d.ts.map +1 -0
- package/dist/lib/primitive/string/string.js +1301 -0
- package/dist/lib/primitive/string/string.mjs +5 -0
- package/dist/lib/primitive/string/types.cjs +1 -0
- package/dist/lib/primitive/string/types.d.ts +318 -0
- package/dist/lib/primitive/string/types.d.ts.map +1 -0
- package/dist/lib/primitive/string/types.js +5 -0
- package/dist/lib/primitive/string/types.mjs +0 -0
- package/dist/lib/primitive/types.cjs +1 -0
- package/dist/lib/primitive/types.d.ts +27 -0
- package/dist/lib/primitive/types.d.ts.map +1 -0
- package/dist/lib/primitive/types.js +1 -0
- package/dist/lib/primitive/types.mjs +0 -0
- package/dist/lib/url/index.cjs +1 -0
- package/dist/lib/url/index.d.ts +3 -0
- package/dist/lib/url/index.d.ts.map +1 -0
- package/dist/lib/url/index.js +2 -0
- package/dist/lib/url/index.mjs +1 -0
- package/dist/lib/url/parser.cjs +1 -0
- package/dist/lib/url/parser.d.ts +216 -0
- package/dist/lib/url/parser.d.ts.map +1 -0
- package/dist/lib/url/parser.js +488 -0
- package/dist/lib/url/parser.mjs +1 -0
- package/dist/lib/url/types.cjs +1 -0
- package/dist/lib/url/types.d.ts +18 -0
- package/dist/lib/url/types.d.ts.map +1 -0
- package/dist/lib/url/types.js +1 -0
- package/dist/lib/url/types.mjs +0 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -0
- package/package.json +150 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var A=e=>e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object";var h=(e,t,n,r)=>{if(n>r)return;if(t.length===0)return e;let i=t[0],s=t.slice(1);if(i.type==="descendant"){let u=h(e,s,n+1,r);if(u!==void 0)return u;if(e&&typeof e=="object")if(Array.isArray(e)){let o=[];for(let a=0;a<e.length;a++){let f=h(e[a],t,n+1,r);f!==void 0&&(o[a]=f)}return o.length>0?o:void 0}else{let o={};for(let a in e)if(e.hasOwnProperty(a)){let f=h(e[a],t,n+1,r);f!==void 0&&(o[a]=f)}return Object.keys(o).length>0?o:void 0}return}switch(i.type){case"property":if(A(e)&&i.value&&String(i.value)in e){let u=e[String(i.value)],o=h(u,s,n+1,r);if(o!==void 0)return{[String(i.value)]:o}}break;case"index":if(Array.isArray(e)){let u=i.value;if(u>=0&&u<e.length){let o=h(e[u],s,n+1,r);if(o!==void 0){let a=new Array(e.length).filter(f=>f!==void 0);return a[u]=o,a}}}else if(e&&typeof e=="object"){let u=String(i.value);if(u in e){let o=h(e[u],s,n+1,r);if(o!==void 0)return{[u]:o}}}break;case"wildcard":if(e&&typeof e=="object")if(Array.isArray(e)){let u=[],o=!1;for(let a=0;a<e.length;a++){let f=h(e[a],s,n+1,r);f!==void 0&&(u[a]=f,o=!0)}return o?u:void 0}else{let u={},o=!1;for(let a in e)if(e.hasOwnProperty(a)){let f=h(e[a],s,n+1,r);f!==void 0&&(u[a]=f,o=!0)}return o?u:void 0}break;case"slice":if(Array.isArray(e)){let[u,o]=i.value,a=Math.max(0,u),f=Math.min(e.length,o===1/0?e.length:o),y=[],g=!1;for(let p=a;p<f;p++){let b=h(e[p],s,n+1,r);b!==void 0&&(y[p]=b,g=!0)}return g?y:void 0}break;case"union":if(Array.isArray(e)){let u=i.value,o=[],a=!1;for(let f of u)if(f>=0&&f<e.length){let y=h(e[f],s,n+1,r);y!==void 0&&(o[f]=y,a=!0)}return a?o:void 0}break;case"filter":if(Array.isArray(e)){let u=i.value,o=[],a=!1;for(let f=0;f<e.length;f++)if(u(e[f])){let y=h(e[f],s,n+1,r);y!==void 0&&(o[f]=y,a=!0)}return a?o:void 0}break}};var S=(e,t)=>{if(e==null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){let n=new Map;return e.forEach((r,i)=>{(!t||!t.some(s=>s.toString()===i.toString()))&&n.set(i,S(r))}),n}if(e instanceof Set){let n=new Set;return e.forEach(r=>{n.add(S(r))}),n}if(Array.isArray(e))return Array.from(e).map(n=>S(n));if(A(e)){let n={};for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(!t||!t.some(s=>s.toString()===i.toString()))&&(n[i]=S(e[i]));let r=Object.getOwnPropertySymbols(e);for(let i of r)(!t||!t.some(s=>s.toString()===i.toString()))&&(n[i]=S(e[i]));return n}return e};var K=(e,t={})=>{let{type:n="auto",throwOnError:r=!1}=t;if(!e||typeof e!="string")return[];let i=[],s="",u=!1,o=!1,a="",f="",y=0,p=n==="auto"?(c=>c.includes("..")?"descendant":c.includes("[?(")?"filter":c.includes("[:")||c.includes("[0:")?"slice":c.includes("[,")||c.includes("[0,1]")?"union":c.includes("[*]")||c.includes(".*.")?"wildcard":c.includes("[]")?"array-wildcard":c.includes("[")&&c.includes("]")?"bracket":"dot")(e):n,b=c=>{let l=c.trim();if(l==="*"||l==="")return{type:"wildcard",value:l===""?"[]":"*",raw:l===""?"[]":c};if(l==="[]")return{type:"wildcard",value:"[]",raw:c};if(/^-?\d+$/.test(l))return{type:"index",value:parseInt(l,10),raw:c};if(l.includes(":")){let T=l.split(":").map(k=>k.trim()),m=T[0]===""?0:parseInt(T[0],10),x=T[1]===""?1/0:parseInt(T[1],10);if(isNaN(m)||isNaN(x)){if(r)throw new Error(`Invalid slice notation: ${c}`);return{type:"wildcard",value:"*",raw:c}}return{type:"slice",value:[m,x],raw:c}}if(l.includes(",")){let T=l.split(",").map(m=>{let x=parseInt(m.trim(),10);return isNaN(x)?-1:x}).filter(m=>m>=0);if(T.length===0){if(r)throw new Error(`Invalid union notation: ${c}`);return{type:"wildcard",value:"*",raw:c}}return{type:"union",value:T,raw:c}}if(l.startsWith("?(")&&l.endsWith(")")){let T=l.slice(2,-1);try{return{type:"filter",value:V(T),raw:c}}catch(m){if(r)throw m;return{type:"wildcard",value:"*",raw:c}}}return l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'")?{type:"property",value:l.slice(1,-1),raw:c}:{type:"property",value:l,raw:c}};for(let c=0;c<e.length;c++){let l=e[c],T=e[c+1];if((l==='"'||l==="'")&&!o){o=!0,a=l;continue}else if(l===a&&o){o=!1,a="",l==='"'||l==="'"||(u?f+=l:s+=l);continue}if(o){u?f+=l:s+=l;continue}if(l==="["&&!u){s&&(i.push({type:"property",value:s,raw:s}),s=""),u=!0,f="";continue}if(l==="]"&&u&&!o){u=!1;let x=b(f);i.push(x);continue}let m=i.length>0?i[i.length-1]:null;if(l==="."&&!u&&!o){if(T==="."){let x=e.split("..")[0];i.push({type:"property",value:x,raw:x}),i.push({type:"descendant",value:"..",raw:".."}),c++}else s&&(s==="*"?i.push({type:"wildcard",value:s,raw:s}):i.push({type:"property",value:s,raw:s}),s="");continue}if(u)f+=l;else if(m&&m.type!=="descendant")s+=l;else{let x=e.split(m?.raw)[1];x!==void 0?s=x:s+=l}}return s&&i.push({type:"property",value:s,raw:s}),i.map(c=>{if(c.type==="property"&&typeof c.value=="string"&&/^-?\d+$/.test(c.value)){let l=parseInt(c.value,10);if(!isNaN(l))return{...c,type:"index",value:l}}return c})},V=e=>{let t=e.replace(/@\.([a-zA-Z_$][\w$]*)/g,(n,r)=>`item.${r}`).replace(/@/g,"item");try{return new Function("item",`return ${t}`)}catch{throw new Error(`Invalid filter expression: ${e}`)}};var I=(e,t,n)=>{let r=K(t),i=e;for(let s=0;s<r.length;s++){let u=r[s],o=s===r.length-1;switch(u.type){case"property":if(o)i[String(u.value)]=n;else{if(!i[String(u.value)]){let f=r[s+1];i[String(u.value)]=f.type==="index"||f.type==="slice"||f.type==="union"||f.type==="wildcard"?[]:{}}i=i[String(u.value)]}break;case"index":Array.isArray(i)||(i=[]);let a=u.value;if(o){if(a>=i.length)for(let f=i.length;f<=a;f++)i.push(void 0);i[a]=n}else{if(!i[a]){let f=r[s+1];i[a]=f.type==="index"||f.type==="slice"||f.type==="union"||f.type==="wildcard"?[]:{}}i=i[a]}break;case"wildcard":if(Array.isArray(i))if(o)for(let f=0;f<i.length;f++)i[f]=n;else{let f=r[s+1];for(let y=0;y<i.length;y++)i[y]||(i[y]=f.type==="index"||f.type==="slice"||f.type==="union"||f.type==="wildcard"?[]:{});i.length>0&&(i=i[0])}break}}};function d(e,t,n={}){let{preserveStructure:r,multiple:i,throwOnError:s=!1,defaultValue:u,maxDepth:o=20}=n;if(!e||typeof e!="object")return u;if(!t)return e;if(Array.isArray(t))if(r){let y={};for(let g of t){let p=d(e,g,{...n,preserveStructure:!1});p!==void 0&&I(y,g,p)}return y}else return t.map(y=>d(e,y,{...n,preserveStructure:!1}));let a=K(t,{...n,throwOnError:s});if(a.length===0)return e;if(typeof r>"u"||r===!1){let y=R(e,t);return i===!1&&Array.isArray(y)?y[0]:y===void 0&&u!==void 0?u:y}let f=h(e,a,0,o);return f===void 0&&u!==void 0?u:f}function R(e,t,n={}){let{createMissing:r=!1,add:i=!1,debug:s=!1}=n,u=K(t),o=e,a=!1,f="",y=t;if(typeof o=="object"&&!Array.isArray(o)&&y.length>0&&o[y])return o=o[y],o;for(let g=0;g<u.length;g++){let p=u[g],b=u.length>1?g===u.length-1:!1;if(o===null&&!r)return;let c=u[g+1];switch(p.type){case"property":if(o&&typeof o=="object")if(Array.isArray(o)){if(typeof p.value=="number"){let l=p.value;if(r&&l>=o.length)for(let T=o.length;T<=l;T++)o.push(void 0);if(r&&(o[l]===null||o[l]===void 0)&&(!b||a)&&(c?o[l]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"?[]:{}:o[l]=null,a=!1),o=o[l],c){a=!0;continue}}else i?o.push({[String(p.value)]:null}):o=o.map(l=>l[String(p.value)]);if(c)continue;return F(o)}else{if(o[f]&&f.split(".").length>=2){o=o[f];continue}if(r&&(o[String(p.value)]===null||o[String(p.value)]===void 0)&&(!b||a)&&(c?o[String(p.value)]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"?[]:{}:o[String(p.value)]=null,a=!1,o=o[String(p.value)],c)){a=!0;continue}if(o?(!o[String(p.value)]&&r&&(o[String(p.value)]=null),o=o[String(p.value)]):o={[String(p.value)]:null},c)continue}else if(r)o={},o[String(p.value)]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"||n.type==="array"?[]:{},o=o[String(p.value)];else return;break;case"index":case"wildcard":if(Array.isArray(o)){if(p.type==="index"){let l=p.value;if(l<0){o=o[o.length-Math.abs(l)];continue}if(r&&(l>=o.length||o[l]==null||o[l]==null)&&!b){for(let T=o.length;T<=l;T++)o.push(void 0);c&&(o[l]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"?[]:{})}o=o[l]}else if(!b)continue}else if(r){let l=u[g+1];o=[];let T=p.value;for(let m=0;m<=T;m++)o.push(void 0);o[T]=l.type==="index"||l.type==="slice"||l.type==="union"||l.type==="wildcard"||n.type==="array"?[]:{},o=o[T]}else{if(p.type==="index"&&typeof o=="object"&&o&&o[String(p.value)]!==void 0){o=o[String(p.value)];continue}if(typeof o=="object"){o=Object.values(o);continue}return}break;default:return}}return F(o)}function F(e){return Array.isArray(e)?e.filter(t=>typeof t<"u"):e}function v(e,t){if(!Array.isArray(e)||t<1)return[];let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function se(e){return e.reduce((t,n)=>t.concat(n),[])}function $(e,t=1/0){return t<1?e.slice():e.reduce((n,r)=>(Array.isArray(r)?n.push(...$(r,t-1)):n.push(r),n),[])}function O(e,t){if(!Array.isArray(e))return[];if(!t)return[...new Set(e)];let n=new Set;return e.filter(r=>{let i=typeof t=="function"?t(r):A(r)?d(r,t):r;return n.has(i)?!1:(n.add(i),!0)})}function oe(e,t){return Array.isArray(e)?e.reduce((n,r)=>{let i;return typeof t=="function"?i=String(t(r)):i=String(A(r)?d(r,t):r),n[i]||(n[i]=[]),n[i].push(r),n},{}):{}}function ue(e,t){return Array.isArray(e)?e.reduce((n,r)=>{let i;return typeof t=="function"?i=String(t(r)):t?i=String(A(r)?d(r,t):r):i=String(r),n[i]=(n[i]||0)+1,n},{}):{}}function ae(e,t,n){return Array.isArray(e)?e.reduce((r,i)=>{let s;typeof t=="function"?s=String(t(i)):s=String(A(i)?d(i,t):i);let u;return n?typeof n=="function"?u=n(i):u=d(i,n):u=i,r[s]=u,r},{}):{}}function fe(e,t){if(!Array.isArray(e)||e.length===0)return[];let n=[...e],i=(Array.isArray(t)?t:[t]).map(s=>typeof s=="object"&&"key"in s?{key:s.key,dir:s.dir||"asc"}:{key:s,dir:"asc"});return n.sort((s,u)=>{for(let{key:o,dir:a}of i){let f=A(s)?d(s,o):s,y=A(u)?d(u,o):u;if(f===y)continue;let g=f<y?-1:1;return a==="asc"?g:-g}return 0}),n}function le(e,t,n){if(!Array.isArray(e))return[];if(!Array.isArray(t))return e;if(!n){let i=new Set(t);return e.filter(s=>!i.has(s))}let r=new Set(t.map(i=>A(i)?d(i,n):i));return e.filter(i=>{let s=A(i)?d(i,n):i;return!r.has(s)})}function ce(e,t,n){if(!Array.isArray(e)||!Array.isArray(t))return[];if(!n){let i=new Set(t);return e.filter(s=>i.has(s))}let r=new Set(t.map(i=>A(i)?d(i,n):i));return e.filter(i=>{let s=A(i)?d(i,n):i;return r.has(s)})}function ye(e,t,n){return!Array.isArray(e)&&!Array.isArray(t)?[]:Array.isArray(e)?Array.isArray(t)?O([...e,...t],n):O(e,n):O(t,n)}function pe(e,t){return Array.isArray(e)?e.reduce((n,r,i)=>(n[t(r,i)?0:1].push(r),n),[[],[]]):[[],[]]}function de(e,t){return!Array.isArray(e)||t<=0?[]:e.slice(0,t)}function Te(e,t){return!Array.isArray(e)||t<=0?[]:e.slice(-t)}function Ae(e,t){if(!Array.isArray(e))return[];let n=[];for(let r=0;r<e.length&&t(e[r],r);r++)n.push(e[r]);return n}function ge(e,t){return!Array.isArray(e)||t<=0?e?[...e]:[]:e.slice(t)}function me(e,t){if(!Array.isArray(e))return[];let n=0;for(;n<e.length&&t(e[n],n);)n++;return e.slice(n)}function xe(e){return Array.isArray(e)?e.filter(Boolean):[]}function he(...e){if(e.length===0)return[];let t=Math.max(...e.map(r=>Array.isArray(r)?r.length:0)),n=[];for(let r=0;r<t;r++){let i=[];for(let s of e)i.push(Array.isArray(s)?s[r]:void 0);n.push(i)}return n}function be(e){if(!Array.isArray(e)||e.length===0)return[];let t=Math.max(...e.map(r=>Array.isArray(r)?r.length:0)),n=[];for(let r=0;r<t;r++){let i=[];for(let s of e)Array.isArray(s)&&i.push(s[r]);n.push(i)}return n}function C(e){if(!Array.isArray(e))return[];let t=[...e];for(let n=t.length-1;n>0;n--){let r=Math.floor(Math.random()*(n+1));[t[n],t[r]]=[t[r],t[n]]}return t}function Se(e){if(!(!Array.isArray(e)||e.length===0))return e[Math.floor(Math.random()*e.length)]}function Ke(e,t){return!Array.isArray(e)||t<=0?[]:C(e).slice(0,Math.min(t,e.length))}function we(e,t,n=0){if(!Array.isArray(e))return-1;for(let r=n;r<e.length;r++)if(t(e[r],r))return r;return-1}function ve(e,t,n){if(!Array.isArray(e))return-1;let r=n!==void 0?n:e.length-1;for(let i=r;i>=0;i--)if(t(e[i],i))return i;return-1}function Oe(e,t){return Array.isArray(e)?e.map(n=>d(n,t)):[]}function Pe(e,t){return!Array.isArray(e)||!Array.isArray(t)?[]:e.map(n=>{let r={};for(let i of t)i in n&&(r[i]=n[i]);return r})}function Ie(e,t){return!Array.isArray(e)||!Array.isArray(t)?[]:e.map(n=>{let r={...n};for(let i of t)delete r[i];return r})}function Fe(e,t){return Array.isArray(e)?e.reduce((n,r,i)=>{let s=t(r,i);return n.concat(s)},[]):[]}function je(e,t,n){if(!Array.isArray(e))return n;let r=n;for(let i=e.length-1;i>=0;i--)r=t(r,e[i],i);return r}function ke(e,t,n=1){if(n===0)return[];let r=[];if(n>0)for(let i=e;i<t;i+=n)r.push(i);else for(let i=e;i>t;i+=n)r.push(i);return r}function Ve(e,t,n=0,r){if(!Array.isArray(e))return[];let i=[...e],s=r===void 0?i.length:r;for(let u=n;u<s&&u<i.length;u++)i[u]=t;return i}function Re(e){return Array.isArray(e)?S(e):[]}function $e(e,t,...n){let r,i;if(typeof t=="string")r=t,i=[e];else{let u=n[n.length-1];typeof u=="string"?(r=u,i=[e,t,...n.slice(0,-1).filter(Array.isArray)]):(r="id",i=[e,t,...n.filter(Array.isArray)])}if(i.length===0)return[];let s=new Map;for(let u of i)if(Array.isArray(u))for(let o of u){let a=A(o)?d(o,r):void 0;if(a!==void 0){let f=s.get(a);s.set(a,f?{...f,...o}:o)}}return Array.from(s.values())}function Ce(e,t,n){if(!Array.isArray(e)||t===n)return e?[...e]:[];let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r}function Me(e,t){if(!Array.isArray(e)||e.length===0||t===0)return e?[...e]:[];let n=e.length,r=(t%n+n)%n;return[...e.slice(-r),...e.slice(0,-r)]}function Ue(e,t,...n){if(!Array.isArray(e))return n;let r=[...e];return r.splice(t,0,...n),r}function Ee(e,t,n=1){if(!Array.isArray(e))return[];let r=[...e];return r.splice(t,n),r}function We(e,t,n){if(!Array.isArray(e))return[];let r=[...e];return r[t]=n,r}function qe(e,t){if(!Array.isArray(e))return[];let n=e.filter(r=>r!=null);return t?n.filter(t):n}function Be(...e){return e.length===0?[[]]:e.length===1?e[0].map(t=>[t]):e.reduce((t,n)=>t.flatMap(r=>n.map(i=>[...r,i])),[[]])}function Ne(e,t){if(!Array.isArray(e))return[];let n=[];for(let r=0;r<e.length;r++)t(e[r],r)&&n.push(r);return n}function Le(e,t,n=!0){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(n&&A(e[r])&&A(t[r])){if(JSON.stringify(e[r])!==JSON.stringify(t[r]))return!1}else if(e[r]!==t[r])return!1;return!0}function _e(e,t){if(!Array.isArray(e)||e.length===0)return[];let n=[],r=[e[0]],i=t(e[0],0);for(let s=1;s<e.length;s++){let u=t(e[s],s);u===i?r.push(e[s]):(n.push(r),r=[e[s]],i=u)}return n.push(r),n}function ze(e,t,n,r){if(!Array.isArray(e))return[];let i=typeof t=="function",s=i?n:r;return e.map(u=>{let o=!1;return i?o=t(u):o=(A(u)?d(u,t):u)===n,o?{...u,...s}:u})}function Je(e,t){if(!Array.isArray(e))return{unique:[],duplicates:[]};let n=new Set,r=[],i=[];for(let s of e){let u=t&&A(s)?d(s,t):s;n.has(u)?i.push(s):(n.add(u),r.push(s))}return{unique:r,duplicates:i}}function M(e){return Array.isArray(e)?e:e==null?[]:[e]}function De(e){return M(e)}function Qe(e,t,n=1){if(!Array.isArray(e)||t<1||n<1)return[];let r=[];for(let i=0;i<=e.length-t;i+=n)r.push(e.slice(i,i+t));return r}function Ze(e,t){if(!Array.isArray(e)||e.length===0)return;let n=e[0],r=typeof t=="function"?t(n):d(n,t);for(let i=1;i<e.length;i++){let s=e[i],u=typeof t=="function"?t(s):d(s,t);u<r&&(r=u,n=s)}return n}function Ge(e,t){if(!Array.isArray(e)||e.length===0)return;let n=e[0],r=typeof t=="function"?t(n):d(n,t);for(let i=1;i<e.length;i++){let s=e[i],u=typeof t=="function"?t(s):d(s,t);u>r&&(r=u,n=s)}return n}function U(e,t){if(!Array.isArray(e)||e.length===0)return 0;let n=0;for(let r of e){let i=typeof t=="function"?t(r):d(r,t);typeof i=="number"&&!isNaN(i)&&(n+=i)}return n}function He(e,t){return!Array.isArray(e)||e.length===0?0:U(e,t)/e.length}function w(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e)t.set(n,(t.get(n)||0)+1);return t}function E(e,t=1){if(!Array.isArray(e)||e.length===0||t<1)return[];let n=w(e);return Array.from(n.entries()).sort((i,s)=>s[1]-i[1]).slice(0,t).map(([i])=>i)}function Xe(e,t=1){if(!Array.isArray(e)||e.length===0||t<1)return[];let n=w(e);return Array.from(n.entries()).sort((i,s)=>i[1]-s[1]).slice(0,t).map(([i])=>i)}async function Ye(e,t,n){if(!Array.isArray(e)||t<1)return;let r=v(e,t);for(let i=0;i<r.length;i++)await n(r[i],i)}async function en(e,t,n,r){if(!Array.isArray(e)||t<1||n<1)return;let i=v(e,t),s=v(i.map((u,o)=>({batch:u,index:o})),n);for(let u of s)await Promise.all(u.map(({batch:o,index:a})=>r(o,a)))}function nn(e){if(!Array.isArray(e)||e.length===0)return[];let t=Math.max(...e.map(r=>r.length)),n=[];for(let r=0;r<t;r++){let i=[];for(let s=0;s<e.length;s++)r<e[s].length&&i.push(e[s][r]);n.push(i)}return n}function tn(e,t){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function rn(e,t){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;let n=w(e),r=w(t);if(n.size!==r.size)return!1;for(let[i,s]of n)if(r.get(i)!==s)return!1;return!0}function W(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;let n=new Set(t);return e.every(r=>n.has(r))}function sn(e,t){return W(t,e)}function on(...e){if(e.length===0)return[];let t=Math.max(...e.map(r=>r.length)),n=[];for(let r=0;r<t;r++)for(let i of e)r<i.length&&n.push(i[r]);return n}function un(e,t){let n=[],r=[];if(!Array.isArray(e))return{pass:n,fail:r};for(let i=0;i<e.length;i++)t(e[i],i)?n.push(e[i]):r.push(e[i]);return{pass:n,fail:r}}function an(e,t){if(e<0)return[];let n=[];for(let r=0;r<e;r++)n.push(t(r));return n}function fn(e,t){if(!Array.isArray(e)||t<0)return[];let n=[];for(let r=0;r<t;r++)n.push(...e);return n}function ln(e){if(!Array.isArray(e)||e.length===0)return;let t=[...e].sort((r,i)=>r-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function cn(e){let t=E(e,1);return t.length>0?t[0]:void 0}function yn(e,...t){if(!Array.isArray(e))return[];let n=new Set(t);return e.filter(r=>!n.has(r))}function pn(e,...t){if(!Array.isArray(e))return[];let n=new Set(t.flat());return e.filter(r=>!n.has(r))}function dn(e){if(!Array.isArray(e)||e.length===0)return[];let t=[],n=[e[0]];for(let r=1;r<e.length;r++)e[r]===e[r-1]?n.push(e[r]):(t.push(n),n=[e[r]]);return t.push(n),t}function Tn(e){if(!Array.isArray(e)||e.length===0)return[];let t=[e[0]];for(let n=1;n<e.length;n++)e[n]!==e[n-1]&&t.push(e[n]);return t}function An(e,t="standard"){if(!Array.isArray(e)||e.length===0)return[];let n=e.map((i,s)=>({value:i,index:s}));n.sort((i,s)=>i.value-s.value);let r=new Array(e.length);if(t==="ordinal")for(let i=0;i<n.length;i++)r[n[i].index]=i+1;else if(t==="dense"){let i=1;r[n[0].index]=i;for(let s=1;s<n.length;s++)n[s].value!==n[s-1].value&&i++,r[n[s].index]=i}else{let i=0;for(;i<n.length;){let s=i;for(;s<n.length&&n[s].value===n[i].value;)s++;let u=i+1;for(let o=i;o<s;o++)r[n[o].index]=u;i=s}}return r}function P(e,t){if(!Array.isArray(e)||e.length===0||t<0||t>100)return;let n=[...e].sort((o,a)=>o-a),r=t/100*(n.length-1),i=Math.floor(r),s=Math.ceil(r),u=r-i;return i===s?n[i]:n[i]*(1-u)+n[s]*u}function gn(e){if(!Array.isArray(e)||e.length===0)return;let t=P(e,25),n=P(e,50),r=P(e,75);return{q1:t,q2:n,q3:r,iqr:r-t}}function j(e,t=!1){if(!Array.isArray(e)||e.length===0||t&&e.length===1)return;let n=e.reduce((s,u)=>s+u,0)/e.length,i=e.map(s=>Math.pow(s-n,2)).reduce((s,u)=>s+u,0)/(t?e.length-1:e.length);return Math.sqrt(i)}function mn(e,t=!1){let n=j(e,t);return n!==void 0?Math.pow(n,2):void 0}function xn(e){if(!Array.isArray(e)||e.length===0)return[];let t=Math.min(...e),r=Math.max(...e)-t;return r===0?e.map(()=>0):e.map(i=>(i-t)/r)}function hn(e){if(!Array.isArray(e)||e.length===0)return[];let t=e.reduce((r,i)=>r+i,0)/e.length,n=j(e);return n===void 0||n===0?e.map(()=>0):e.map(r=>(r-t)/n)}function q(e,t,n){if(!Array.isArray(e))return[];let r=[],i=n;for(let s=0;s<e.length;s++)i=t(i,e[s],s),r.push(i);return r}function bn(e){return q(e,(t,n)=>t+n,0)}function Sn(e){if(!Array.isArray(e)||e.length<2)return[];let t=[];for(let n=1;n<e.length;n++)t.push(e[n]-e[n-1]);return t}function Kn(e,t,n,r="end"){if(!Array.isArray(e)||t<=e.length)return[...e];let i=new Array(t-e.length).fill(n);return r==="start"?[...i,...e]:[...e,...i]}function wn(e,t){if(!Array.isArray(e)||e.length===0)return[];let n=0,r=e.length-1;for(;n<=r&&t(e[n]);)n++;for(;r>=n&&t(e[r]);)r--;return e.slice(n,r+1)}function vn(e){if(!Array.isArray(e)||e.length<2)return[];let t=[];for(let n=0;n<e.length-1;n++)t.push([e[n],e[n+1]]);return t}function On(e){return Array.isArray(e)?e.map((t,n)=>[n,t]):[]}function Pn(e,t){return Array.isArray(e)?e.map((n,r)=>{let i=t[r%t.length];return i(n)}):[]}function B(e,t=1){if(!Array.isArray(e)||e.length===0)return[];let n=e.length,r=(t%n+n)%n;return[...e.slice(r),...e.slice(0,r)]}function In(e,t=1){return B(e,-t)}function Fn(e,t,n){if(!Array.isArray(e)||t<0||n<0||t>=e.length||n>=e.length)return[...e];let r=[...e];return[r[t],r[n]]=[r[n],r[t]],r}function jn(e,t,n){if(!Array.isArray(e)||t<0||n>=e.length||t>=n)return[...e];let r=[...e],i=r.slice(t,n+1).reverse();return r.splice(t,n-t+1,...i),r}function kn(e,t){if(!Array.isArray(e)||e.length<=1)return!0;let n=t||((r,i)=>r<i?-1:r>i?1:0);for(let r=1;r<e.length;r++)if(n(e[r-1],e[r])>0)return!1;return!0}function Vn(e){return Array.isArray(e)?new Set(e).size!==e.length:!1}function Rn(e,t){return Array.isArray(e)?e.map(n=>{let r={};for(let i of t)i in n&&(r[i]=n[i]);return r}):[]}function N(e,t,n){if(!Array.isArray(e))return{};let r={};for(let i=0;i<e.length;i++){let s=t(e[i],i),u=n?n(e[i],i):e[i];r[s]=u}return r}async function $n(e,t){if(!Array.isArray(e))return[];let n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r));return n}async function Cn(e,t){return Array.isArray(e)?Promise.all(e.map((n,r)=>t(n,r))):[]}async function Mn(e,t){if(!Array.isArray(e))return[];let n=[];for(let r=0;r<e.length;r++)await t(e[r],r)&&n.push(e[r]);return n}async function Un(e,t,n){if(!Array.isArray(e))return n;let r=n;for(let i=0;i<e.length;i++)r=await t(r,e[i],i);return r}async function En(e,t){if(Array.isArray(e)){for(let n=0;n<e.length;n++)if(await t(e[n],n))return e[n]}}async function Wn(e,t){if(!Array.isArray(e))return!1;for(let n=0;n<e.length;n++)if(await t(e[n],n))return!0;return!1}async function qn(e,t){if(!Array.isArray(e))return!0;for(let n=0;n<e.length;n++)if(!await t(e[n],n))return!1;return!0}function Bn(e,t,n){if(!Array.isArray(e)||e.length===0)return 0;let r=0,i=0;for(let s of e){let u=typeof t=="function"?t(s):d(s,t),o=typeof n=="function"?n(s):d(s,n);typeof u=="number"&&typeof o=="number"&&(i+=u*o,r+=o)}return r===0?0:i/r}function Nn(e,t,n=1){if(!Array.isArray(e)||e.length===0||n<1)return[];let r=[],i=0;for(let u of e){let o=typeof t=="function"?t(u):d(u,t);i+=typeof o=="number"&&o>0?o:0,r.push(i)}if(i===0)return[];let s=[];for(let u=0;u<n;u++){let o=Math.random()*i,a=r.findIndex(f=>o<f);a!==-1&&s.push(e[a])}return s}function Ln(e,t){if(!Array.isArray(e)||!Array.isArray(t))return[];let n=[],r=0;for(let i of t){if(r>=e.length)break;n.push(e.slice(r,r+i)),r+=i}return n}function _n(e,t){if(!Array.isArray(e)||t<1)return[];let n=w(e),r=[];for(let i of e)n.get(i)===t&&r.push(i);return r}function zn(e,t,n){if(!Array.isArray(e)||t<1)return[];let r=[],i=0,s=[];for(let u of e)n(u)?(i++,s.push(u),i>=t&&r.push(...s.splice(0,s.length-t+1))):(i=0,s.length=0);return i>=t&&r.push(...s),r}function Jn(e,t,n){if(!Array.isArray(e))return[];let r=[],i=n;for(let s=0;s<e.length;s++){let{value:u,newContext:o}=t(e[s],i,s);r.push(u),i=o}return r}function Dn(e,t){return v(e,t)}function Qn(e,t,n){if(!Array.isArray(e)||!Array.isArray(t))return[];let r=Math.min(e.length,t.length),i=[];for(let s=0;s<r;s++)i.push(n(e[s],t[s]));return i}function Zn(e,t,n="last"){if(!Array.isArray(e)||e.length===0)return[];let r=new Map;for(let s of e)if(Array.isArray(s))for(let u of s){let o=d(u,t);if(n==="first")r.has(o)||r.set(o,u);else if(n==="last")r.set(o,u);else if(n==="concat"){let a=r.get(o);Array.isArray(a)?a.push(u):a?r.set(o,[a,u]):r.set(o,u)}else if(typeof n=="function"){let a=r.get(o);a&&!Array.isArray(a)?r.set(o,n(a,u)):r.set(o,u)}}let i=[];for(let s of r.values())Array.isArray(s)&&n==="concat"?i.push(...s):Array.isArray(s)||i.push(s);return i}function Gn(e,t){return N(e,n=>String(d(n,t)))}function Hn(e,t,n){if(!Array.isArray(e)||e.length===0)return-1;let r=n||((u,o)=>u<o?-1:u>o?1:0),i=0,s=e.length-1;for(;i<=s;){let u=Math.floor((i+s)/2),o=r(e[u],t);if(o===0)return u;o<0?i=u+1:s=u-1}return-1}function Xn(e,t,n){if(!Array.isArray(e))return[t];let r=n||((u,o)=>u<o?-1:u>o?1:0),i=[...e],s=0;for(;s<i.length&&r(i[s],t)<0;)s++;return i.splice(s,0,t),i}export{Pn as applyByIndex,He as avgBy,Dn as batch,Ye as batchProcess,en as batchProcessParallel,un as bifurcate,Hn as binarySearch,Be as cartesian,v as chunk,_e as chunkBy,xe as compact,ue as countBy,bn as cumulativeSum,Tn as dedupeConsecutive,Re as deepCloneArray,Sn as diff,le as difference,pn as differenceWith,ge as drop,me as dropWhile,M as ensureArray,On as enumerate,qn as everyAsync,Ve as fill,Mn as filterAsync,qe as filterCompact,zn as filterConsecutive,Ne as findAllIndices,En as findAsync,we as findIndex,ve as findLastIndex,Fe as flatMap,se as flatten,$ as flattenDeep,w as frequencies,an as generate,oe as groupBy,dn as groupConsecutive,Vn as hasDuplicates,rn as hasSameElements,Gn as indexBy,Ue as insert,Xn as insertSorted,on as interleave,ce as intersection,tn as isArrayEqual,Le as isEqual,kn as isSorted,W as isSubset,sn as isSuperset,ae as keyBy,Xe as leastCommon,$n as mapAsync,Cn as mapAsyncParallel,Jn as mapWithContext,Ge as maxBy,ln as median,Zn as mergeArraysByKey,$e as mergeByKey,Ze as minBy,cn as mode,E as mostCommon,Ce as move,xn as normalize,Ie as omit,Kn as pad,vn as pairwise,pe as partition,P as percentile,Pe as pick,Rn as pickMany,Oe as pluck,gn as quartiles,ke as range,An as rank,Un as reduceAsync,je as reduceRight,Ee as remove,fn as repeat,We as replace,jn as reverseSegment,Me as rotate,B as rotateLeft,In as rotateRight,Se as sample,Ke as sampleSize,q as scan,Ln as segment,_n as selectByCount,C as shuffle,Qe as slidingWindow,Wn as someAsync,fe as sortBy,Je as splitDuplicates,j as standardDeviation,hn as standardize,U as sumBy,Fn as swap,de as take,Te as takeLast,Ae as takeWhile,N as toObject,nn as transpose,wn as trim,ye as union,O as unique,be as unzip,ze as updateBy,mn as variance,Bn as weightedAverage,Nn as weightedSample,yn as without,De as wrap,he as zip,Qn as zipWith};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var f=(r,t)=>{for(var n in t)i(r,n,{get:t[n],enumerable:!0})},A=(r,t,n,y)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of o(t))!a.call(r,e)&&e!==n&&i(r,e,{get:()=>t[e],enumerable:!(y=s(t,e))||y.enumerable});return r};var p=r=>A(i({},"__esModule",{value:!0}),r);var x={};f(x,{isArrayOfBoolean:()=>b,isArrayOfNumber:()=>g,isArrayOfObject:()=>O,isArrayOfString:()=>u,toArrayString:()=>c});module.exports=p(x);var c=r=>{if(Array.isArray(r))return r;if(typeof r=="string")if(r.startsWith("[")&&r.endsWith("]"))try{return JSON.parse(r)}catch{return[]}else return[r];return[]};function u(r){return Array.isArray(r)&&r.every(t=>typeof t=="string")}function g(r){return Array.isArray(r)&&r.every(t=>typeof t=="number")}function b(r){return Array.isArray(r)&&r.every(t=>typeof t=="boolean")}function O(r){return Array.isArray(r)&&r.every(t=>typeof t=="object")}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const toArrayString: (value: string | string[]) => string[];
|
|
2
|
+
export declare function isArrayOfString(value: any): value is string[];
|
|
3
|
+
export declare function isArrayOfNumber(value: any): value is number[];
|
|
4
|
+
export declare function isArrayOfBoolean(value: any): value is boolean[];
|
|
5
|
+
export declare function isArrayOfObject(value: any): value is object[];
|
|
6
|
+
//# sourceMappingURL=array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../../src/lib/array/array.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,GAAI,OAAO,MAAM,GAAG,MAAM,EAAE,KAAG,MAAM,EAe9D,CAAC;AAEF,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,EAAE,CAI7D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,EAAE,CAI7D;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,OAAO,EAAE,CAI/D;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,EAAE,CAI7D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const toArrayString = (value) => {
|
|
2
|
+
if (Array.isArray(value)) {
|
|
3
|
+
return value;
|
|
4
|
+
}
|
|
5
|
+
else if (typeof value === 'string') {
|
|
6
|
+
if (value.startsWith('[') && value.endsWith(']')) {
|
|
7
|
+
try {
|
|
8
|
+
return JSON.parse(value);
|
|
9
|
+
}
|
|
10
|
+
catch (err) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
return [value];
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return [];
|
|
19
|
+
};
|
|
20
|
+
export function isArrayOfString(value) {
|
|
21
|
+
return (Array.isArray(value) && value.every((item) => typeof item === 'string'));
|
|
22
|
+
}
|
|
23
|
+
export function isArrayOfNumber(value) {
|
|
24
|
+
return (Array.isArray(value) && value.every((item) => typeof item === 'number'));
|
|
25
|
+
}
|
|
26
|
+
export function isArrayOfBoolean(value) {
|
|
27
|
+
return (Array.isArray(value) && value.every((item) => typeof item === 'boolean'));
|
|
28
|
+
}
|
|
29
|
+
export function isArrayOfObject(value) {
|
|
30
|
+
return (Array.isArray(value) && value.every((item) => typeof item === 'object'));
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=r=>{if(Array.isArray(r))return r;if(typeof r=="string")if(r.startsWith("[")&&r.endsWith("]"))try{return JSON.parse(r)}catch{return[]}else return[r];return[]};function n(r){return Array.isArray(r)&&r.every(t=>typeof t=="string")}function i(r){return Array.isArray(r)&&r.every(t=>typeof t=="number")}function y(r){return Array.isArray(r)&&r.every(t=>typeof t=="boolean")}function s(r){return Array.isArray(r)&&r.every(t=>typeof t=="object")}export{y as isArrayOfBoolean,i as isArrayOfNumber,s as isArrayOfObject,n as isArrayOfString,e as toArrayString};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var P=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var J=(e,n)=>{for(var t in n)P(e,t,{get:n[t],enumerable:!0})},Q=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of z(n))!D.call(e,i)&&i!==t&&P(e,i,{get:()=>n[i],enumerable:!(r=_(n,i))||r.enumerable});return e};var Z=e=>Q(P({},"__esModule",{value:!0}),e);var yt={};J(yt,{applyByIndex:()=>Bn,at:()=>Te,avgBy:()=>cn,batch:()=>ot,batchProcess:()=>pn,batchProcessParallel:()=>dn,bifurcate:()=>hn,binarySearch:()=>lt,cartesian:()=>en,chunk:()=>O,chunkBy:()=>rn,compact:()=>Ve,countBy:()=>he,cumulativeSum:()=>$n,dedupeConsecutive:()=>Pn,deepCloneArray:()=>De,diff:()=>Cn,difference:()=>Ke,differenceWith:()=>vn,drop:()=>je,dropWhile:()=>Fe,ensureArray:()=>M,enumerate:()=>Wn,everyAsync:()=>Yn,fill:()=>ze,filterAsync:()=>Zn,filterCompact:()=>Ye,filterConsecutive:()=>it,findAllIndices:()=>nn,findAsync:()=>Hn,findIndex:()=>Ue,findLastIndex:()=>Ee,first:()=>ce,flatMap:()=>Ne,flatten:()=>me,flattenArray:()=>de,flattenDeep:()=>$,frequencies:()=>K,generate:()=>bn,groupArrayBy:()=>pe,groupBy:()=>xe,groupConsecutive:()=>In,hasDuplicates:()=>zn,hasSameElements:()=>gn,indexBy:()=>ft,insert:()=>Ge,insertSorted:()=>ct,interleave:()=>xn,intersection:()=>we,isArray:()=>te,isArrayEqual:()=>An,isArrayLike:()=>se,isArrayOfBoolean:()=>Y,isArrayOfNumber:()=>X,isArrayOfObject:()=>ee,isArrayOfString:()=>H,isDoubleArray:()=>ie,isEmptyArray:()=>oe,isEqual:()=>tn,isIterable:()=>F,isNonEmptyArray:()=>ae,isObjectArray:()=>ne,isReadonlyArray:()=>fe,isSorted:()=>_n,isStaticArray:()=>re,isSubset:()=>W,isSuperset:()=>mn,isTypedArray:()=>ue,keyBy:()=>be,last:()=>le,leastCommon:()=>yn,mapAsync:()=>Jn,mapAsyncParallel:()=>Qn,mapWithContext:()=>st,maxBy:()=>ln,median:()=>Kn,mergeArraysByKey:()=>ut,mergeByKey:()=>Je,minBy:()=>fn,mode:()=>wn,mostCommon:()=>E,move:()=>Qe,normalize:()=>Vn,omit:()=>qe,pad:()=>Mn,pairwise:()=>En,partition:()=>ve,percentile:()=>I,pick:()=>Be,pickMany:()=>Dn,pluck:()=>We,quartiles:()=>jn,range:()=>_e,rank:()=>kn,reduceAsync:()=>Gn,reduceRight:()=>Le,remove:()=>He,repeat:()=>Sn,replace:()=>Xe,reverseSegment:()=>Ln,rotate:()=>Ze,rotateLeft:()=>q,rotateRight:()=>qn,sample:()=>Ce,sampleSize:()=>Me,scan:()=>B,segment:()=>tt,selectByCount:()=>rt,shuffle:()=>C,slidingWindow:()=>un,someAsync:()=>Xn,sortBy:()=>Se,splitDuplicates:()=>on,standardDeviation:()=>k,standardize:()=>Rn,sumBy:()=>U,swap:()=>Nn,take:()=>Ie,takeLast:()=>Pe,takeWhile:()=>ke,toArray:()=>ye,toArrayString:()=>G,toObject:()=>N,transpose:()=>Tn,trim:()=>Un,union:()=>Oe,unique:()=>v,unzip:()=>$e,updateBy:()=>sn,variance:()=>Fn,weightedAverage:()=>et,weightedSample:()=>nt,without:()=>On,wrap:()=>an,zip:()=>Re,zipWith:()=>at});module.exports=Z(yt);var G=e=>{if(Array.isArray(e))return e;if(typeof e=="string")if(e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch{return[]}else return[e];return[]};function H(e){return Array.isArray(e)&&e.every(n=>typeof n=="string")}function X(e){return Array.isArray(e)&&e.every(n=>typeof n=="number")}function Y(e){return Array.isArray(e)&&e.every(n=>typeof n=="boolean")}function ee(e){return Array.isArray(e)&&e.every(n=>typeof n=="object")}var j=require("@fluixi/utils/object"),ne=e=>Array.isArray(e)&&e.every(n=>(0,j.isObject)(n));function te(e){return Array.isArray(e)}function re(e){return Array.isArray(e)}function ie(e){return Array.isArray(e)&&e.every(n=>Array.isArray(n)&&n.length===2)}function F(e){return e!=null&&typeof e[Symbol.iterator]=="function"}function se(e){return e!=null&&typeof e=="object"&&"length"in e&&typeof e.length=="number"&&e.length>=0&&(e.length===0||e.length-1 in e)}function oe(e){return Array.isArray(e)&&e.length===0}function ae(e){return Array.isArray(e)&&e.length>0}function ue(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function fe(e){return Array.isArray(e)}function le(e){return e.length>0?e[e.length-1]:void 0}function ce(e){return e.length>0?e[0]:void 0}function ye(e){return Array.isArray(e)?[...e]:F(e)?[...e]:Array.from(e)}function pe(e,n){return e.reduce((t,r)=>{let i=n(r);return t[i]||(t[i]=[]),t[i].push(r),t},{})}function de(e){return e.flat()}function Te(e,n){let t=n<0?e.length+n:n;return e[t]}var A=e=>e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object";var h=(e,n,t,r)=>{if(t>r)return;if(n.length===0)return e;let i=n[0],s=n.slice(1);if(i.type==="descendant"){let a=h(e,s,t+1,r);if(a!==void 0)return a;if(e&&typeof e=="object")if(Array.isArray(e)){let o=[];for(let u=0;u<e.length;u++){let f=h(e[u],n,t+1,r);f!==void 0&&(o[u]=f)}return o.length>0?o:void 0}else{let o={};for(let u in e)if(e.hasOwnProperty(u)){let f=h(e[u],n,t+1,r);f!==void 0&&(o[u]=f)}return Object.keys(o).length>0?o:void 0}return}switch(i.type){case"property":if(A(e)&&i.value&&String(i.value)in e){let a=e[String(i.value)],o=h(a,s,t+1,r);if(o!==void 0)return{[String(i.value)]:o}}break;case"index":if(Array.isArray(e)){let a=i.value;if(a>=0&&a<e.length){let o=h(e[a],s,t+1,r);if(o!==void 0){let u=new Array(e.length).filter(f=>f!==void 0);return u[a]=o,u}}}else if(e&&typeof e=="object"){let a=String(i.value);if(a in e){let o=h(e[a],s,t+1,r);if(o!==void 0)return{[a]:o}}}break;case"wildcard":if(e&&typeof e=="object")if(Array.isArray(e)){let a=[],o=!1;for(let u=0;u<e.length;u++){let f=h(e[u],s,t+1,r);f!==void 0&&(a[u]=f,o=!0)}return o?a:void 0}else{let a={},o=!1;for(let u in e)if(e.hasOwnProperty(u)){let f=h(e[u],s,t+1,r);f!==void 0&&(a[u]=f,o=!0)}return o?a:void 0}break;case"slice":if(Array.isArray(e)){let[a,o]=i.value,u=Math.max(0,a),f=Math.min(e.length,o===1/0?e.length:o),y=[],g=!1;for(let p=u;p<f;p++){let b=h(e[p],s,t+1,r);b!==void 0&&(y[p]=b,g=!0)}return g?y:void 0}break;case"union":if(Array.isArray(e)){let a=i.value,o=[],u=!1;for(let f of a)if(f>=0&&f<e.length){let y=h(e[f],s,t+1,r);y!==void 0&&(o[f]=y,u=!0)}return u?o:void 0}break;case"filter":if(Array.isArray(e)){let a=i.value,o=[],u=!1;for(let f=0;f<e.length;f++)if(a(e[f])){let y=h(e[f],s,t+1,r);y!==void 0&&(o[f]=y,u=!0)}return u?o:void 0}break}};var S=(e,n)=>{if(e==null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){let t=new Map;return e.forEach((r,i)=>{(!n||!n.some(s=>s.toString()===i.toString()))&&t.set(i,S(r))}),t}if(e instanceof Set){let t=new Set;return e.forEach(r=>{t.add(S(r))}),t}if(Array.isArray(e))return Array.from(e).map(t=>S(t));if(A(e)){let t={};for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(!n||!n.some(s=>s.toString()===i.toString()))&&(t[i]=S(e[i]));let r=Object.getOwnPropertySymbols(e);for(let i of r)(!n||!n.some(s=>s.toString()===i.toString()))&&(t[i]=S(e[i]));return t}return e};var w=(e,n={})=>{let{type:t="auto",throwOnError:r=!1}=n;if(!e||typeof e!="string")return[];let i=[],s="",a=!1,o=!1,u="",f="",y=0,p=t==="auto"?(c=>c.includes("..")?"descendant":c.includes("[?(")?"filter":c.includes("[:")||c.includes("[0:")?"slice":c.includes("[,")||c.includes("[0,1]")?"union":c.includes("[*]")||c.includes(".*.")?"wildcard":c.includes("[]")?"array-wildcard":c.includes("[")&&c.includes("]")?"bracket":"dot")(e):t,b=c=>{let l=c.trim();if(l==="*"||l==="")return{type:"wildcard",value:l===""?"[]":"*",raw:l===""?"[]":c};if(l==="[]")return{type:"wildcard",value:"[]",raw:c};if(/^-?\d+$/.test(l))return{type:"index",value:parseInt(l,10),raw:c};if(l.includes(":")){let T=l.split(":").map(L=>L.trim()),m=T[0]===""?0:parseInt(T[0],10),x=T[1]===""?1/0:parseInt(T[1],10);if(isNaN(m)||isNaN(x)){if(r)throw new Error(`Invalid slice notation: ${c}`);return{type:"wildcard",value:"*",raw:c}}return{type:"slice",value:[m,x],raw:c}}if(l.includes(",")){let T=l.split(",").map(m=>{let x=parseInt(m.trim(),10);return isNaN(x)?-1:x}).filter(m=>m>=0);if(T.length===0){if(r)throw new Error(`Invalid union notation: ${c}`);return{type:"wildcard",value:"*",raw:c}}return{type:"union",value:T,raw:c}}if(l.startsWith("?(")&&l.endsWith(")")){let T=l.slice(2,-1);try{return{type:"filter",value:Ae(T),raw:c}}catch(m){if(r)throw m;return{type:"wildcard",value:"*",raw:c}}}return l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'")?{type:"property",value:l.slice(1,-1),raw:c}:{type:"property",value:l,raw:c}};for(let c=0;c<e.length;c++){let l=e[c],T=e[c+1];if((l==='"'||l==="'")&&!o){o=!0,u=l;continue}else if(l===u&&o){o=!1,u="",l==='"'||l==="'"||(a?f+=l:s+=l);continue}if(o){a?f+=l:s+=l;continue}if(l==="["&&!a){s&&(i.push({type:"property",value:s,raw:s}),s=""),a=!0,f="";continue}if(l==="]"&&a&&!o){a=!1;let x=b(f);i.push(x);continue}let m=i.length>0?i[i.length-1]:null;if(l==="."&&!a&&!o){if(T==="."){let x=e.split("..")[0];i.push({type:"property",value:x,raw:x}),i.push({type:"descendant",value:"..",raw:".."}),c++}else s&&(s==="*"?i.push({type:"wildcard",value:s,raw:s}):i.push({type:"property",value:s,raw:s}),s="");continue}if(a)f+=l;else if(m&&m.type!=="descendant")s+=l;else{let x=e.split(m?.raw)[1];x!==void 0?s=x:s+=l}}return s&&i.push({type:"property",value:s,raw:s}),i.map(c=>{if(c.type==="property"&&typeof c.value=="string"&&/^-?\d+$/.test(c.value)){let l=parseInt(c.value,10);if(!isNaN(l))return{...c,type:"index",value:l}}return c})},Ae=e=>{let n=e.replace(/@\.([a-zA-Z_$][\w$]*)/g,(t,r)=>`item.${r}`).replace(/@/g,"item");try{return new Function("item",`return ${n}`)}catch{throw new Error(`Invalid filter expression: ${e}`)}};var V=(e,n,t)=>{let r=w(n),i=e;for(let s=0;s<r.length;s++){let a=r[s],o=s===r.length-1;switch(a.type){case"property":if(o)i[String(a.value)]=t;else{if(!i[String(a.value)]){let f=r[s+1];i[String(a.value)]=f.type==="index"||f.type==="slice"||f.type==="union"||f.type==="wildcard"?[]:{}}i=i[String(a.value)]}break;case"index":Array.isArray(i)||(i=[]);let u=a.value;if(o){if(u>=i.length)for(let f=i.length;f<=u;f++)i.push(void 0);i[u]=t}else{if(!i[u]){let f=r[s+1];i[u]=f.type==="index"||f.type==="slice"||f.type==="union"||f.type==="wildcard"?[]:{}}i=i[u]}break;case"wildcard":if(Array.isArray(i))if(o)for(let f=0;f<i.length;f++)i[f]=t;else{let f=r[s+1];for(let y=0;y<i.length;y++)i[y]||(i[y]=f.type==="index"||f.type==="slice"||f.type==="union"||f.type==="wildcard"?[]:{});i.length>0&&(i=i[0])}break}}};function d(e,n,t={}){let{preserveStructure:r,multiple:i,throwOnError:s=!1,defaultValue:a,maxDepth:o=20}=t;if(!e||typeof e!="object")return a;if(!n)return e;if(Array.isArray(n))if(r){let y={};for(let g of n){let p=d(e,g,{...t,preserveStructure:!1});p!==void 0&&V(y,g,p)}return y}else return n.map(y=>d(e,y,{...t,preserveStructure:!1}));let u=w(n,{...t,throwOnError:s});if(u.length===0)return e;if(typeof r>"u"||r===!1){let y=ge(e,n);return i===!1&&Array.isArray(y)?y[0]:y===void 0&&a!==void 0?a:y}let f=h(e,u,0,o);return f===void 0&&a!==void 0?a:f}function ge(e,n,t={}){let{createMissing:r=!1,add:i=!1,debug:s=!1}=t,a=w(n),o=e,u=!1,f="",y=n;if(typeof o=="object"&&!Array.isArray(o)&&y.length>0&&o[y])return o=o[y],o;for(let g=0;g<a.length;g++){let p=a[g],b=a.length>1?g===a.length-1:!1;if(o===null&&!r)return;let c=a[g+1];switch(p.type){case"property":if(o&&typeof o=="object")if(Array.isArray(o)){if(typeof p.value=="number"){let l=p.value;if(r&&l>=o.length)for(let T=o.length;T<=l;T++)o.push(void 0);if(r&&(o[l]===null||o[l]===void 0)&&(!b||u)&&(c?o[l]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"?[]:{}:o[l]=null,u=!1),o=o[l],c){u=!0;continue}}else i?o.push({[String(p.value)]:null}):o=o.map(l=>l[String(p.value)]);if(c)continue;return R(o)}else{if(o[f]&&f.split(".").length>=2){o=o[f];continue}if(r&&(o[String(p.value)]===null||o[String(p.value)]===void 0)&&(!b||u)&&(c?o[String(p.value)]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"?[]:{}:o[String(p.value)]=null,u=!1,o=o[String(p.value)],c)){u=!0;continue}if(o?(!o[String(p.value)]&&r&&(o[String(p.value)]=null),o=o[String(p.value)]):o={[String(p.value)]:null},c)continue}else if(r)o={},o[String(p.value)]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"||t.type==="array"?[]:{},o=o[String(p.value)];else return;break;case"index":case"wildcard":if(Array.isArray(o)){if(p.type==="index"){let l=p.value;if(l<0){o=o[o.length-Math.abs(l)];continue}if(r&&(l>=o.length||o[l]==null||o[l]==null)&&!b){for(let T=o.length;T<=l;T++)o.push(void 0);c&&(o[l]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"?[]:{})}o=o[l]}else if(!b)continue}else if(r){let l=a[g+1];o=[];let T=p.value;for(let m=0;m<=T;m++)o.push(void 0);o[T]=l.type==="index"||l.type==="slice"||l.type==="union"||l.type==="wildcard"||t.type==="array"?[]:{},o=o[T]}else{if(p.type==="index"&&typeof o=="object"&&o&&o[String(p.value)]!==void 0){o=o[String(p.value)];continue}if(typeof o=="object"){o=Object.values(o);continue}return}break;default:return}}return R(o)}function R(e){return Array.isArray(e)?e.filter(n=>typeof n<"u"):e}function O(e,n){if(!Array.isArray(e)||n<1)return[];let t=[];for(let r=0;r<e.length;r+=n)t.push(e.slice(r,r+n));return t}function me(e){return e.reduce((n,t)=>n.concat(t),[])}function $(e,n=1/0){return n<1?e.slice():e.reduce((t,r)=>(Array.isArray(r)?t.push(...$(r,n-1)):t.push(r),t),[])}function v(e,n){if(!Array.isArray(e))return[];if(!n)return[...new Set(e)];let t=new Set;return e.filter(r=>{let i=typeof n=="function"?n(r):A(r)?d(r,n):r;return t.has(i)?!1:(t.add(i),!0)})}function xe(e,n){return Array.isArray(e)?e.reduce((t,r)=>{let i;return typeof n=="function"?i=String(n(r)):i=String(A(r)?d(r,n):r),t[i]||(t[i]=[]),t[i].push(r),t},{}):{}}function he(e,n){return Array.isArray(e)?e.reduce((t,r)=>{let i;return typeof n=="function"?i=String(n(r)):n?i=String(A(r)?d(r,n):r):i=String(r),t[i]=(t[i]||0)+1,t},{}):{}}function be(e,n,t){return Array.isArray(e)?e.reduce((r,i)=>{let s;typeof n=="function"?s=String(n(i)):s=String(A(i)?d(i,n):i);let a;return t?typeof t=="function"?a=t(i):a=d(i,t):a=i,r[s]=a,r},{}):{}}function Se(e,n){if(!Array.isArray(e)||e.length===0)return[];let t=[...e],i=(Array.isArray(n)?n:[n]).map(s=>typeof s=="object"&&"key"in s?{key:s.key,dir:s.dir||"asc"}:{key:s,dir:"asc"});return t.sort((s,a)=>{for(let{key:o,dir:u}of i){let f=A(s)?d(s,o):s,y=A(a)?d(a,o):a;if(f===y)continue;let g=f<y?-1:1;return u==="asc"?g:-g}return 0}),t}function Ke(e,n,t){if(!Array.isArray(e))return[];if(!Array.isArray(n))return e;if(!t){let i=new Set(n);return e.filter(s=>!i.has(s))}let r=new Set(n.map(i=>A(i)?d(i,t):i));return e.filter(i=>{let s=A(i)?d(i,t):i;return!r.has(s)})}function we(e,n,t){if(!Array.isArray(e)||!Array.isArray(n))return[];if(!t){let i=new Set(n);return e.filter(s=>i.has(s))}let r=new Set(n.map(i=>A(i)?d(i,t):i));return e.filter(i=>{let s=A(i)?d(i,t):i;return r.has(s)})}function Oe(e,n,t){return!Array.isArray(e)&&!Array.isArray(n)?[]:Array.isArray(e)?Array.isArray(n)?v([...e,...n],t):v(e,t):v(n,t)}function ve(e,n){return Array.isArray(e)?e.reduce((t,r,i)=>(t[n(r,i)?0:1].push(r),t),[[],[]]):[[],[]]}function Ie(e,n){return!Array.isArray(e)||n<=0?[]:e.slice(0,n)}function Pe(e,n){return!Array.isArray(e)||n<=0?[]:e.slice(-n)}function ke(e,n){if(!Array.isArray(e))return[];let t=[];for(let r=0;r<e.length&&n(e[r],r);r++)t.push(e[r]);return t}function je(e,n){return!Array.isArray(e)||n<=0?e?[...e]:[]:e.slice(n)}function Fe(e,n){if(!Array.isArray(e))return[];let t=0;for(;t<e.length&&n(e[t],t);)t++;return e.slice(t)}function Ve(e){return Array.isArray(e)?e.filter(Boolean):[]}function Re(...e){if(e.length===0)return[];let n=Math.max(...e.map(r=>Array.isArray(r)?r.length:0)),t=[];for(let r=0;r<n;r++){let i=[];for(let s of e)i.push(Array.isArray(s)?s[r]:void 0);t.push(i)}return t}function $e(e){if(!Array.isArray(e)||e.length===0)return[];let n=Math.max(...e.map(r=>Array.isArray(r)?r.length:0)),t=[];for(let r=0;r<n;r++){let i=[];for(let s of e)Array.isArray(s)&&i.push(s[r]);t.push(i)}return t}function C(e){if(!Array.isArray(e))return[];let n=[...e];for(let t=n.length-1;t>0;t--){let r=Math.floor(Math.random()*(t+1));[n[t],n[r]]=[n[r],n[t]]}return n}function Ce(e){if(!(!Array.isArray(e)||e.length===0))return e[Math.floor(Math.random()*e.length)]}function Me(e,n){return!Array.isArray(e)||n<=0?[]:C(e).slice(0,Math.min(n,e.length))}function Ue(e,n,t=0){if(!Array.isArray(e))return-1;for(let r=t;r<e.length;r++)if(n(e[r],r))return r;return-1}function Ee(e,n,t){if(!Array.isArray(e))return-1;let r=t!==void 0?t:e.length-1;for(let i=r;i>=0;i--)if(n(e[i],i))return i;return-1}function We(e,n){return Array.isArray(e)?e.map(t=>d(t,n)):[]}function Be(e,n){return!Array.isArray(e)||!Array.isArray(n)?[]:e.map(t=>{let r={};for(let i of n)i in t&&(r[i]=t[i]);return r})}function qe(e,n){return!Array.isArray(e)||!Array.isArray(n)?[]:e.map(t=>{let r={...t};for(let i of n)delete r[i];return r})}function Ne(e,n){return Array.isArray(e)?e.reduce((t,r,i)=>{let s=n(r,i);return t.concat(s)},[]):[]}function Le(e,n,t){if(!Array.isArray(e))return t;let r=t;for(let i=e.length-1;i>=0;i--)r=n(r,e[i],i);return r}function _e(e,n,t=1){if(t===0)return[];let r=[];if(t>0)for(let i=e;i<n;i+=t)r.push(i);else for(let i=e;i>n;i+=t)r.push(i);return r}function ze(e,n,t=0,r){if(!Array.isArray(e))return[];let i=[...e],s=r===void 0?i.length:r;for(let a=t;a<s&&a<i.length;a++)i[a]=n;return i}function De(e){return Array.isArray(e)?S(e):[]}function Je(e,n,...t){let r,i;if(typeof n=="string")r=n,i=[e];else{let a=t[t.length-1];typeof a=="string"?(r=a,i=[e,n,...t.slice(0,-1).filter(Array.isArray)]):(r="id",i=[e,n,...t.filter(Array.isArray)])}if(i.length===0)return[];let s=new Map;for(let a of i)if(Array.isArray(a))for(let o of a){let u=A(o)?d(o,r):void 0;if(u!==void 0){let f=s.get(u);s.set(u,f?{...f,...o}:o)}}return Array.from(s.values())}function Qe(e,n,t){if(!Array.isArray(e)||n===t)return e?[...e]:[];let r=[...e],[i]=r.splice(n,1);return r.splice(t,0,i),r}function Ze(e,n){if(!Array.isArray(e)||e.length===0||n===0)return e?[...e]:[];let t=e.length,r=(n%t+t)%t;return[...e.slice(-r),...e.slice(0,-r)]}function Ge(e,n,...t){if(!Array.isArray(e))return t;let r=[...e];return r.splice(n,0,...t),r}function He(e,n,t=1){if(!Array.isArray(e))return[];let r=[...e];return r.splice(n,t),r}function Xe(e,n,t){if(!Array.isArray(e))return[];let r=[...e];return r[n]=t,r}function Ye(e,n){if(!Array.isArray(e))return[];let t=e.filter(r=>r!=null);return n?t.filter(n):t}function en(...e){return e.length===0?[[]]:e.length===1?e[0].map(n=>[n]):e.reduce((n,t)=>n.flatMap(r=>t.map(i=>[...r,i])),[[]])}function nn(e,n){if(!Array.isArray(e))return[];let t=[];for(let r=0;r<e.length;r++)n(e[r],r)&&t.push(r);return t}function tn(e,n,t=!0){if(!Array.isArray(e)||!Array.isArray(n)||e.length!==n.length)return!1;for(let r=0;r<e.length;r++)if(t&&A(e[r])&&A(n[r])){if(JSON.stringify(e[r])!==JSON.stringify(n[r]))return!1}else if(e[r]!==n[r])return!1;return!0}function rn(e,n){if(!Array.isArray(e)||e.length===0)return[];let t=[],r=[e[0]],i=n(e[0],0);for(let s=1;s<e.length;s++){let a=n(e[s],s);a===i?r.push(e[s]):(t.push(r),r=[e[s]],i=a)}return t.push(r),t}function sn(e,n,t,r){if(!Array.isArray(e))return[];let i=typeof n=="function",s=i?t:r;return e.map(a=>{let o=!1;return i?o=n(a):o=(A(a)?d(a,n):a)===t,o?{...a,...s}:a})}function on(e,n){if(!Array.isArray(e))return{unique:[],duplicates:[]};let t=new Set,r=[],i=[];for(let s of e){let a=n&&A(s)?d(s,n):s;t.has(a)?i.push(s):(t.add(a),r.push(s))}return{unique:r,duplicates:i}}function M(e){return Array.isArray(e)?e:e==null?[]:[e]}function an(e){return M(e)}function un(e,n,t=1){if(!Array.isArray(e)||n<1||t<1)return[];let r=[];for(let i=0;i<=e.length-n;i+=t)r.push(e.slice(i,i+n));return r}function fn(e,n){if(!Array.isArray(e)||e.length===0)return;let t=e[0],r=typeof n=="function"?n(t):d(t,n);for(let i=1;i<e.length;i++){let s=e[i],a=typeof n=="function"?n(s):d(s,n);a<r&&(r=a,t=s)}return t}function ln(e,n){if(!Array.isArray(e)||e.length===0)return;let t=e[0],r=typeof n=="function"?n(t):d(t,n);for(let i=1;i<e.length;i++){let s=e[i],a=typeof n=="function"?n(s):d(s,n);a>r&&(r=a,t=s)}return t}function U(e,n){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(let r of e){let i=typeof n=="function"?n(r):d(r,n);typeof i=="number"&&!isNaN(i)&&(t+=i)}return t}function cn(e,n){return!Array.isArray(e)||e.length===0?0:U(e,n)/e.length}function K(e){let n=new Map;if(!Array.isArray(e))return n;for(let t of e)n.set(t,(n.get(t)||0)+1);return n}function E(e,n=1){if(!Array.isArray(e)||e.length===0||n<1)return[];let t=K(e);return Array.from(t.entries()).sort((i,s)=>s[1]-i[1]).slice(0,n).map(([i])=>i)}function yn(e,n=1){if(!Array.isArray(e)||e.length===0||n<1)return[];let t=K(e);return Array.from(t.entries()).sort((i,s)=>i[1]-s[1]).slice(0,n).map(([i])=>i)}async function pn(e,n,t){if(!Array.isArray(e)||n<1)return;let r=O(e,n);for(let i=0;i<r.length;i++)await t(r[i],i)}async function dn(e,n,t,r){if(!Array.isArray(e)||n<1||t<1)return;let i=O(e,n),s=O(i.map((a,o)=>({batch:a,index:o})),t);for(let a of s)await Promise.all(a.map(({batch:o,index:u})=>r(o,u)))}function Tn(e){if(!Array.isArray(e)||e.length===0)return[];let n=Math.max(...e.map(r=>r.length)),t=[];for(let r=0;r<n;r++){let i=[];for(let s=0;s<e.length;s++)r<e[s].length&&i.push(e[s][r]);t.push(i)}return t}function An(e,n){if(!Array.isArray(e)||!Array.isArray(n)||e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}function gn(e,n){if(!Array.isArray(e)||!Array.isArray(n)||e.length!==n.length)return!1;let t=K(e),r=K(n);if(t.size!==r.size)return!1;for(let[i,s]of t)if(r.get(i)!==s)return!1;return!0}function W(e,n){if(!Array.isArray(e)||!Array.isArray(n))return!1;let t=new Set(n);return e.every(r=>t.has(r))}function mn(e,n){return W(n,e)}function xn(...e){if(e.length===0)return[];let n=Math.max(...e.map(r=>r.length)),t=[];for(let r=0;r<n;r++)for(let i of e)r<i.length&&t.push(i[r]);return t}function hn(e,n){let t=[],r=[];if(!Array.isArray(e))return{pass:t,fail:r};for(let i=0;i<e.length;i++)n(e[i],i)?t.push(e[i]):r.push(e[i]);return{pass:t,fail:r}}function bn(e,n){if(e<0)return[];let t=[];for(let r=0;r<e;r++)t.push(n(r));return t}function Sn(e,n){if(!Array.isArray(e)||n<0)return[];let t=[];for(let r=0;r<n;r++)t.push(...e);return t}function Kn(e){if(!Array.isArray(e)||e.length===0)return;let n=[...e].sort((r,i)=>r-i),t=Math.floor(n.length/2);return n.length%2===0?(n[t-1]+n[t])/2:n[t]}function wn(e){let n=E(e,1);return n.length>0?n[0]:void 0}function On(e,...n){if(!Array.isArray(e))return[];let t=new Set(n);return e.filter(r=>!t.has(r))}function vn(e,...n){if(!Array.isArray(e))return[];let t=new Set(n.flat());return e.filter(r=>!t.has(r))}function In(e){if(!Array.isArray(e)||e.length===0)return[];let n=[],t=[e[0]];for(let r=1;r<e.length;r++)e[r]===e[r-1]?t.push(e[r]):(n.push(t),t=[e[r]]);return n.push(t),n}function Pn(e){if(!Array.isArray(e)||e.length===0)return[];let n=[e[0]];for(let t=1;t<e.length;t++)e[t]!==e[t-1]&&n.push(e[t]);return n}function kn(e,n="standard"){if(!Array.isArray(e)||e.length===0)return[];let t=e.map((i,s)=>({value:i,index:s}));t.sort((i,s)=>i.value-s.value);let r=new Array(e.length);if(n==="ordinal")for(let i=0;i<t.length;i++)r[t[i].index]=i+1;else if(n==="dense"){let i=1;r[t[0].index]=i;for(let s=1;s<t.length;s++)t[s].value!==t[s-1].value&&i++,r[t[s].index]=i}else{let i=0;for(;i<t.length;){let s=i;for(;s<t.length&&t[s].value===t[i].value;)s++;let a=i+1;for(let o=i;o<s;o++)r[t[o].index]=a;i=s}}return r}function I(e,n){if(!Array.isArray(e)||e.length===0||n<0||n>100)return;let t=[...e].sort((o,u)=>o-u),r=n/100*(t.length-1),i=Math.floor(r),s=Math.ceil(r),a=r-i;return i===s?t[i]:t[i]*(1-a)+t[s]*a}function jn(e){if(!Array.isArray(e)||e.length===0)return;let n=I(e,25),t=I(e,50),r=I(e,75);return{q1:n,q2:t,q3:r,iqr:r-n}}function k(e,n=!1){if(!Array.isArray(e)||e.length===0||n&&e.length===1)return;let t=e.reduce((s,a)=>s+a,0)/e.length,i=e.map(s=>Math.pow(s-t,2)).reduce((s,a)=>s+a,0)/(n?e.length-1:e.length);return Math.sqrt(i)}function Fn(e,n=!1){let t=k(e,n);return t!==void 0?Math.pow(t,2):void 0}function Vn(e){if(!Array.isArray(e)||e.length===0)return[];let n=Math.min(...e),r=Math.max(...e)-n;return r===0?e.map(()=>0):e.map(i=>(i-n)/r)}function Rn(e){if(!Array.isArray(e)||e.length===0)return[];let n=e.reduce((r,i)=>r+i,0)/e.length,t=k(e);return t===void 0||t===0?e.map(()=>0):e.map(r=>(r-n)/t)}function B(e,n,t){if(!Array.isArray(e))return[];let r=[],i=t;for(let s=0;s<e.length;s++)i=n(i,e[s],s),r.push(i);return r}function $n(e){return B(e,(n,t)=>n+t,0)}function Cn(e){if(!Array.isArray(e)||e.length<2)return[];let n=[];for(let t=1;t<e.length;t++)n.push(e[t]-e[t-1]);return n}function Mn(e,n,t,r="end"){if(!Array.isArray(e)||n<=e.length)return[...e];let i=new Array(n-e.length).fill(t);return r==="start"?[...i,...e]:[...e,...i]}function Un(e,n){if(!Array.isArray(e)||e.length===0)return[];let t=0,r=e.length-1;for(;t<=r&&n(e[t]);)t++;for(;r>=t&&n(e[r]);)r--;return e.slice(t,r+1)}function En(e){if(!Array.isArray(e)||e.length<2)return[];let n=[];for(let t=0;t<e.length-1;t++)n.push([e[t],e[t+1]]);return n}function Wn(e){return Array.isArray(e)?e.map((n,t)=>[t,n]):[]}function Bn(e,n){return Array.isArray(e)?e.map((t,r)=>{let i=n[r%n.length];return i(t)}):[]}function q(e,n=1){if(!Array.isArray(e)||e.length===0)return[];let t=e.length,r=(n%t+t)%t;return[...e.slice(r),...e.slice(0,r)]}function qn(e,n=1){return q(e,-n)}function Nn(e,n,t){if(!Array.isArray(e)||n<0||t<0||n>=e.length||t>=e.length)return[...e];let r=[...e];return[r[n],r[t]]=[r[t],r[n]],r}function Ln(e,n,t){if(!Array.isArray(e)||n<0||t>=e.length||n>=t)return[...e];let r=[...e],i=r.slice(n,t+1).reverse();return r.splice(n,t-n+1,...i),r}function _n(e,n){if(!Array.isArray(e)||e.length<=1)return!0;let t=n||((r,i)=>r<i?-1:r>i?1:0);for(let r=1;r<e.length;r++)if(t(e[r-1],e[r])>0)return!1;return!0}function zn(e){return Array.isArray(e)?new Set(e).size!==e.length:!1}function Dn(e,n){return Array.isArray(e)?e.map(t=>{let r={};for(let i of n)i in t&&(r[i]=t[i]);return r}):[]}function N(e,n,t){if(!Array.isArray(e))return{};let r={};for(let i=0;i<e.length;i++){let s=n(e[i],i),a=t?t(e[i],i):e[i];r[s]=a}return r}async function Jn(e,n){if(!Array.isArray(e))return[];let t=[];for(let r=0;r<e.length;r++)t.push(await n(e[r],r));return t}async function Qn(e,n){return Array.isArray(e)?Promise.all(e.map((t,r)=>n(t,r))):[]}async function Zn(e,n){if(!Array.isArray(e))return[];let t=[];for(let r=0;r<e.length;r++)await n(e[r],r)&&t.push(e[r]);return t}async function Gn(e,n,t){if(!Array.isArray(e))return t;let r=t;for(let i=0;i<e.length;i++)r=await n(r,e[i],i);return r}async function Hn(e,n){if(Array.isArray(e)){for(let t=0;t<e.length;t++)if(await n(e[t],t))return e[t]}}async function Xn(e,n){if(!Array.isArray(e))return!1;for(let t=0;t<e.length;t++)if(await n(e[t],t))return!0;return!1}async function Yn(e,n){if(!Array.isArray(e))return!0;for(let t=0;t<e.length;t++)if(!await n(e[t],t))return!1;return!0}function et(e,n,t){if(!Array.isArray(e)||e.length===0)return 0;let r=0,i=0;for(let s of e){let a=typeof n=="function"?n(s):d(s,n),o=typeof t=="function"?t(s):d(s,t);typeof a=="number"&&typeof o=="number"&&(i+=a*o,r+=o)}return r===0?0:i/r}function nt(e,n,t=1){if(!Array.isArray(e)||e.length===0||t<1)return[];let r=[],i=0;for(let a of e){let o=typeof n=="function"?n(a):d(a,n);i+=typeof o=="number"&&o>0?o:0,r.push(i)}if(i===0)return[];let s=[];for(let a=0;a<t;a++){let o=Math.random()*i,u=r.findIndex(f=>o<f);u!==-1&&s.push(e[u])}return s}function tt(e,n){if(!Array.isArray(e)||!Array.isArray(n))return[];let t=[],r=0;for(let i of n){if(r>=e.length)break;t.push(e.slice(r,r+i)),r+=i}return t}function rt(e,n){if(!Array.isArray(e)||n<1)return[];let t=K(e),r=[];for(let i of e)t.get(i)===n&&r.push(i);return r}function it(e,n,t){if(!Array.isArray(e)||n<1)return[];let r=[],i=0,s=[];for(let a of e)t(a)?(i++,s.push(a),i>=n&&r.push(...s.splice(0,s.length-n+1))):(i=0,s.length=0);return i>=n&&r.push(...s),r}function st(e,n,t){if(!Array.isArray(e))return[];let r=[],i=t;for(let s=0;s<e.length;s++){let{value:a,newContext:o}=n(e[s],i,s);r.push(a),i=o}return r}function ot(e,n){return O(e,n)}function at(e,n,t){if(!Array.isArray(e)||!Array.isArray(n))return[];let r=Math.min(e.length,n.length),i=[];for(let s=0;s<r;s++)i.push(t(e[s],n[s]));return i}function ut(e,n,t="last"){if(!Array.isArray(e)||e.length===0)return[];let r=new Map;for(let s of e)if(Array.isArray(s))for(let a of s){let o=d(a,n);if(t==="first")r.has(o)||r.set(o,a);else if(t==="last")r.set(o,a);else if(t==="concat"){let u=r.get(o);Array.isArray(u)?u.push(a):u?r.set(o,[u,a]):r.set(o,a)}else if(typeof t=="function"){let u=r.get(o);u&&!Array.isArray(u)?r.set(o,t(u,a)):r.set(o,a)}}let i=[];for(let s of r.values())Array.isArray(s)&&t==="concat"?i.push(...s):Array.isArray(s)||i.push(s);return i}function ft(e,n){return N(e,t=>String(d(t,n)))}function lt(e,n,t){if(!Array.isArray(e)||e.length===0)return-1;let r=t||((a,o)=>a<o?-1:a>o?1:0),i=0,s=e.length-1;for(;i<=s;){let a=Math.floor((i+s)/2),o=r(e[a],n);if(o===0)return a;o<0?i=a+1:s=a-1}return-1}function ct(e,n,t){if(!Array.isArray(e))return[n];let r=t||((a,o)=>a<o?-1:a>o?1:0),i=[...e],s=0;for(;s<i.length&&r(i[s],n)<0;)s++;return i.splice(s,0,n),i}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/array/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var z=e=>{if(Array.isArray(e))return e;if(typeof e=="string")if(e.startsWith("[")&&e.endsWith("]"))try{return JSON.parse(e)}catch{return[]}else return[e];return[]};function D(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function J(e){return Array.isArray(e)&&e.every(t=>typeof t=="number")}function Q(e){return Array.isArray(e)&&e.every(t=>typeof t=="boolean")}function Z(e){return Array.isArray(e)&&e.every(t=>typeof t=="object")}import{isObject as V}from"@fluixi/utils/object";var X=e=>Array.isArray(e)&&e.every(t=>V(t));function Y(e){return Array.isArray(e)}function ee(e){return Array.isArray(e)}function ne(e){return Array.isArray(e)&&e.every(t=>Array.isArray(t)&&t.length===2)}function R(e){return e!=null&&typeof e[Symbol.iterator]=="function"}function te(e){return e!=null&&typeof e=="object"&&"length"in e&&typeof e.length=="number"&&e.length>=0&&(e.length===0||e.length-1 in e)}function re(e){return Array.isArray(e)&&e.length===0}function ie(e){return Array.isArray(e)&&e.length>0}function se(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function oe(e){return Array.isArray(e)}function ae(e){return e.length>0?e[e.length-1]:void 0}function ue(e){return e.length>0?e[0]:void 0}function fe(e){return Array.isArray(e)?[...e]:R(e)?[...e]:Array.from(e)}function le(e,t){return e.reduce((n,r)=>{let i=t(r);return n[i]||(n[i]=[]),n[i].push(r),n},{})}function ce(e){return e.flat()}function ye(e,t){let n=t<0?e.length+t:t;return e[n]}var A=e=>e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object";var h=(e,t,n,r)=>{if(n>r)return;if(t.length===0)return e;let i=t[0],s=t.slice(1);if(i.type==="descendant"){let a=h(e,s,n+1,r);if(a!==void 0)return a;if(e&&typeof e=="object")if(Array.isArray(e)){let o=[];for(let u=0;u<e.length;u++){let f=h(e[u],t,n+1,r);f!==void 0&&(o[u]=f)}return o.length>0?o:void 0}else{let o={};for(let u in e)if(e.hasOwnProperty(u)){let f=h(e[u],t,n+1,r);f!==void 0&&(o[u]=f)}return Object.keys(o).length>0?o:void 0}return}switch(i.type){case"property":if(A(e)&&i.value&&String(i.value)in e){let a=e[String(i.value)],o=h(a,s,n+1,r);if(o!==void 0)return{[String(i.value)]:o}}break;case"index":if(Array.isArray(e)){let a=i.value;if(a>=0&&a<e.length){let o=h(e[a],s,n+1,r);if(o!==void 0){let u=new Array(e.length).filter(f=>f!==void 0);return u[a]=o,u}}}else if(e&&typeof e=="object"){let a=String(i.value);if(a in e){let o=h(e[a],s,n+1,r);if(o!==void 0)return{[a]:o}}}break;case"wildcard":if(e&&typeof e=="object")if(Array.isArray(e)){let a=[],o=!1;for(let u=0;u<e.length;u++){let f=h(e[u],s,n+1,r);f!==void 0&&(a[u]=f,o=!0)}return o?a:void 0}else{let a={},o=!1;for(let u in e)if(e.hasOwnProperty(u)){let f=h(e[u],s,n+1,r);f!==void 0&&(a[u]=f,o=!0)}return o?a:void 0}break;case"slice":if(Array.isArray(e)){let[a,o]=i.value,u=Math.max(0,a),f=Math.min(e.length,o===1/0?e.length:o),y=[],g=!1;for(let p=u;p<f;p++){let b=h(e[p],s,n+1,r);b!==void 0&&(y[p]=b,g=!0)}return g?y:void 0}break;case"union":if(Array.isArray(e)){let a=i.value,o=[],u=!1;for(let f of a)if(f>=0&&f<e.length){let y=h(e[f],s,n+1,r);y!==void 0&&(o[f]=y,u=!0)}return u?o:void 0}break;case"filter":if(Array.isArray(e)){let a=i.value,o=[],u=!1;for(let f=0;f<e.length;f++)if(a(e[f])){let y=h(e[f],s,n+1,r);y!==void 0&&(o[f]=y,u=!0)}return u?o:void 0}break}};var S=(e,t)=>{if(e==null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp)return new RegExp(e.source,e.flags);if(e instanceof Map){let n=new Map;return e.forEach((r,i)=>{(!t||!t.some(s=>s.toString()===i.toString()))&&n.set(i,S(r))}),n}if(e instanceof Set){let n=new Set;return e.forEach(r=>{n.add(S(r))}),n}if(Array.isArray(e))return Array.from(e).map(n=>S(n));if(A(e)){let n={};for(let i in e)Object.prototype.hasOwnProperty.call(e,i)&&(!t||!t.some(s=>s.toString()===i.toString()))&&(n[i]=S(e[i]));let r=Object.getOwnPropertySymbols(e);for(let i of r)(!t||!t.some(s=>s.toString()===i.toString()))&&(n[i]=S(e[i]));return n}return e};var K=(e,t={})=>{let{type:n="auto",throwOnError:r=!1}=t;if(!e||typeof e!="string")return[];let i=[],s="",a=!1,o=!1,u="",f="",y=0,p=n==="auto"?(c=>c.includes("..")?"descendant":c.includes("[?(")?"filter":c.includes("[:")||c.includes("[0:")?"slice":c.includes("[,")||c.includes("[0,1]")?"union":c.includes("[*]")||c.includes(".*.")?"wildcard":c.includes("[]")?"array-wildcard":c.includes("[")&&c.includes("]")?"bracket":"dot")(e):n,b=c=>{let l=c.trim();if(l==="*"||l==="")return{type:"wildcard",value:l===""?"[]":"*",raw:l===""?"[]":c};if(l==="[]")return{type:"wildcard",value:"[]",raw:c};if(/^-?\d+$/.test(l))return{type:"index",value:parseInt(l,10),raw:c};if(l.includes(":")){let T=l.split(":").map(F=>F.trim()),m=T[0]===""?0:parseInt(T[0],10),x=T[1]===""?1/0:parseInt(T[1],10);if(isNaN(m)||isNaN(x)){if(r)throw new Error(`Invalid slice notation: ${c}`);return{type:"wildcard",value:"*",raw:c}}return{type:"slice",value:[m,x],raw:c}}if(l.includes(",")){let T=l.split(",").map(m=>{let x=parseInt(m.trim(),10);return isNaN(x)?-1:x}).filter(m=>m>=0);if(T.length===0){if(r)throw new Error(`Invalid union notation: ${c}`);return{type:"wildcard",value:"*",raw:c}}return{type:"union",value:T,raw:c}}if(l.startsWith("?(")&&l.endsWith(")")){let T=l.slice(2,-1);try{return{type:"filter",value:$(T),raw:c}}catch(m){if(r)throw m;return{type:"wildcard",value:"*",raw:c}}}return l.startsWith('"')&&l.endsWith('"')||l.startsWith("'")&&l.endsWith("'")?{type:"property",value:l.slice(1,-1),raw:c}:{type:"property",value:l,raw:c}};for(let c=0;c<e.length;c++){let l=e[c],T=e[c+1];if((l==='"'||l==="'")&&!o){o=!0,u=l;continue}else if(l===u&&o){o=!1,u="",l==='"'||l==="'"||(a?f+=l:s+=l);continue}if(o){a?f+=l:s+=l;continue}if(l==="["&&!a){s&&(i.push({type:"property",value:s,raw:s}),s=""),a=!0,f="";continue}if(l==="]"&&a&&!o){a=!1;let x=b(f);i.push(x);continue}let m=i.length>0?i[i.length-1]:null;if(l==="."&&!a&&!o){if(T==="."){let x=e.split("..")[0];i.push({type:"property",value:x,raw:x}),i.push({type:"descendant",value:"..",raw:".."}),c++}else s&&(s==="*"?i.push({type:"wildcard",value:s,raw:s}):i.push({type:"property",value:s,raw:s}),s="");continue}if(a)f+=l;else if(m&&m.type!=="descendant")s+=l;else{let x=e.split(m?.raw)[1];x!==void 0?s=x:s+=l}}return s&&i.push({type:"property",value:s,raw:s}),i.map(c=>{if(c.type==="property"&&typeof c.value=="string"&&/^-?\d+$/.test(c.value)){let l=parseInt(c.value,10);if(!isNaN(l))return{...c,type:"index",value:l}}return c})},$=e=>{let t=e.replace(/@\.([a-zA-Z_$][\w$]*)/g,(n,r)=>`item.${r}`).replace(/@/g,"item");try{return new Function("item",`return ${t}`)}catch{throw new Error(`Invalid filter expression: ${e}`)}};var P=(e,t,n)=>{let r=K(t),i=e;for(let s=0;s<r.length;s++){let a=r[s],o=s===r.length-1;switch(a.type){case"property":if(o)i[String(a.value)]=n;else{if(!i[String(a.value)]){let f=r[s+1];i[String(a.value)]=f.type==="index"||f.type==="slice"||f.type==="union"||f.type==="wildcard"?[]:{}}i=i[String(a.value)]}break;case"index":Array.isArray(i)||(i=[]);let u=a.value;if(o){if(u>=i.length)for(let f=i.length;f<=u;f++)i.push(void 0);i[u]=n}else{if(!i[u]){let f=r[s+1];i[u]=f.type==="index"||f.type==="slice"||f.type==="union"||f.type==="wildcard"?[]:{}}i=i[u]}break;case"wildcard":if(Array.isArray(i))if(o)for(let f=0;f<i.length;f++)i[f]=n;else{let f=r[s+1];for(let y=0;y<i.length;y++)i[y]||(i[y]=f.type==="index"||f.type==="slice"||f.type==="union"||f.type==="wildcard"?[]:{});i.length>0&&(i=i[0])}break}}};function d(e,t,n={}){let{preserveStructure:r,multiple:i,throwOnError:s=!1,defaultValue:a,maxDepth:o=20}=n;if(!e||typeof e!="object")return a;if(!t)return e;if(Array.isArray(t))if(r){let y={};for(let g of t){let p=d(e,g,{...n,preserveStructure:!1});p!==void 0&&P(y,g,p)}return y}else return t.map(y=>d(e,y,{...n,preserveStructure:!1}));let u=K(t,{...n,throwOnError:s});if(u.length===0)return e;if(typeof r>"u"||r===!1){let y=C(e,t);return i===!1&&Array.isArray(y)?y[0]:y===void 0&&a!==void 0?a:y}let f=h(e,u,0,o);return f===void 0&&a!==void 0?a:f}function C(e,t,n={}){let{createMissing:r=!1,add:i=!1,debug:s=!1}=n,a=K(t),o=e,u=!1,f="",y=t;if(typeof o=="object"&&!Array.isArray(o)&&y.length>0&&o[y])return o=o[y],o;for(let g=0;g<a.length;g++){let p=a[g],b=a.length>1?g===a.length-1:!1;if(o===null&&!r)return;let c=a[g+1];switch(p.type){case"property":if(o&&typeof o=="object")if(Array.isArray(o)){if(typeof p.value=="number"){let l=p.value;if(r&&l>=o.length)for(let T=o.length;T<=l;T++)o.push(void 0);if(r&&(o[l]===null||o[l]===void 0)&&(!b||u)&&(c?o[l]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"?[]:{}:o[l]=null,u=!1),o=o[l],c){u=!0;continue}}else i?o.push({[String(p.value)]:null}):o=o.map(l=>l[String(p.value)]);if(c)continue;return k(o)}else{if(o[f]&&f.split(".").length>=2){o=o[f];continue}if(r&&(o[String(p.value)]===null||o[String(p.value)]===void 0)&&(!b||u)&&(c?o[String(p.value)]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"?[]:{}:o[String(p.value)]=null,u=!1,o=o[String(p.value)],c)){u=!0;continue}if(o?(!o[String(p.value)]&&r&&(o[String(p.value)]=null),o=o[String(p.value)]):o={[String(p.value)]:null},c)continue}else if(r)o={},o[String(p.value)]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"||n.type==="array"?[]:{},o=o[String(p.value)];else return;break;case"index":case"wildcard":if(Array.isArray(o)){if(p.type==="index"){let l=p.value;if(l<0){o=o[o.length-Math.abs(l)];continue}if(r&&(l>=o.length||o[l]==null||o[l]==null)&&!b){for(let T=o.length;T<=l;T++)o.push(void 0);c&&(o[l]=c.type==="index"||c.type==="slice"||c.type==="union"||c.type==="wildcard"?[]:{})}o=o[l]}else if(!b)continue}else if(r){let l=a[g+1];o=[];let T=p.value;for(let m=0;m<=T;m++)o.push(void 0);o[T]=l.type==="index"||l.type==="slice"||l.type==="union"||l.type==="wildcard"||n.type==="array"?[]:{},o=o[T]}else{if(p.type==="index"&&typeof o=="object"&&o&&o[String(p.value)]!==void 0){o=o[String(p.value)];continue}if(typeof o=="object"){o=Object.values(o);continue}return}break;default:return}}return k(o)}function k(e){return Array.isArray(e)?e.filter(t=>typeof t<"u"):e}function O(e,t){if(!Array.isArray(e)||t<1)return[];let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}function je(e){return e.reduce((t,n)=>t.concat(n),[])}function M(e,t=1/0){return t<1?e.slice():e.reduce((n,r)=>(Array.isArray(r)?n.push(...M(r,t-1)):n.push(r),n),[])}function v(e,t){if(!Array.isArray(e))return[];if(!t)return[...new Set(e)];let n=new Set;return e.filter(r=>{let i=typeof t=="function"?t(r):A(r)?d(r,t):r;return n.has(i)?!1:(n.add(i),!0)})}function Fe(e,t){return Array.isArray(e)?e.reduce((n,r)=>{let i;return typeof t=="function"?i=String(t(r)):i=String(A(r)?d(r,t):r),n[i]||(n[i]=[]),n[i].push(r),n},{}):{}}function Ve(e,t){return Array.isArray(e)?e.reduce((n,r)=>{let i;return typeof t=="function"?i=String(t(r)):t?i=String(A(r)?d(r,t):r):i=String(r),n[i]=(n[i]||0)+1,n},{}):{}}function Re(e,t,n){return Array.isArray(e)?e.reduce((r,i)=>{let s;typeof t=="function"?s=String(t(i)):s=String(A(i)?d(i,t):i);let a;return n?typeof n=="function"?a=n(i):a=d(i,n):a=i,r[s]=a,r},{}):{}}function $e(e,t){if(!Array.isArray(e)||e.length===0)return[];let n=[...e],i=(Array.isArray(t)?t:[t]).map(s=>typeof s=="object"&&"key"in s?{key:s.key,dir:s.dir||"asc"}:{key:s,dir:"asc"});return n.sort((s,a)=>{for(let{key:o,dir:u}of i){let f=A(s)?d(s,o):s,y=A(a)?d(a,o):a;if(f===y)continue;let g=f<y?-1:1;return u==="asc"?g:-g}return 0}),n}function Ce(e,t,n){if(!Array.isArray(e))return[];if(!Array.isArray(t))return e;if(!n){let i=new Set(t);return e.filter(s=>!i.has(s))}let r=new Set(t.map(i=>A(i)?d(i,n):i));return e.filter(i=>{let s=A(i)?d(i,n):i;return!r.has(s)})}function Me(e,t,n){if(!Array.isArray(e)||!Array.isArray(t))return[];if(!n){let i=new Set(t);return e.filter(s=>i.has(s))}let r=new Set(t.map(i=>A(i)?d(i,n):i));return e.filter(i=>{let s=A(i)?d(i,n):i;return r.has(s)})}function Ue(e,t,n){return!Array.isArray(e)&&!Array.isArray(t)?[]:Array.isArray(e)?Array.isArray(t)?v([...e,...t],n):v(e,n):v(t,n)}function Ee(e,t){return Array.isArray(e)?e.reduce((n,r,i)=>(n[t(r,i)?0:1].push(r),n),[[],[]]):[[],[]]}function We(e,t){return!Array.isArray(e)||t<=0?[]:e.slice(0,t)}function Be(e,t){return!Array.isArray(e)||t<=0?[]:e.slice(-t)}function qe(e,t){if(!Array.isArray(e))return[];let n=[];for(let r=0;r<e.length&&t(e[r],r);r++)n.push(e[r]);return n}function Ne(e,t){return!Array.isArray(e)||t<=0?e?[...e]:[]:e.slice(t)}function Le(e,t){if(!Array.isArray(e))return[];let n=0;for(;n<e.length&&t(e[n],n);)n++;return e.slice(n)}function _e(e){return Array.isArray(e)?e.filter(Boolean):[]}function ze(...e){if(e.length===0)return[];let t=Math.max(...e.map(r=>Array.isArray(r)?r.length:0)),n=[];for(let r=0;r<t;r++){let i=[];for(let s of e)i.push(Array.isArray(s)?s[r]:void 0);n.push(i)}return n}function De(e){if(!Array.isArray(e)||e.length===0)return[];let t=Math.max(...e.map(r=>Array.isArray(r)?r.length:0)),n=[];for(let r=0;r<t;r++){let i=[];for(let s of e)Array.isArray(s)&&i.push(s[r]);n.push(i)}return n}function U(e){if(!Array.isArray(e))return[];let t=[...e];for(let n=t.length-1;n>0;n--){let r=Math.floor(Math.random()*(n+1));[t[n],t[r]]=[t[r],t[n]]}return t}function Je(e){if(!(!Array.isArray(e)||e.length===0))return e[Math.floor(Math.random()*e.length)]}function Qe(e,t){return!Array.isArray(e)||t<=0?[]:U(e).slice(0,Math.min(t,e.length))}function Ze(e,t,n=0){if(!Array.isArray(e))return-1;for(let r=n;r<e.length;r++)if(t(e[r],r))return r;return-1}function Ge(e,t,n){if(!Array.isArray(e))return-1;let r=n!==void 0?n:e.length-1;for(let i=r;i>=0;i--)if(t(e[i],i))return i;return-1}function He(e,t){return Array.isArray(e)?e.map(n=>d(n,t)):[]}function Xe(e,t){return!Array.isArray(e)||!Array.isArray(t)?[]:e.map(n=>{let r={};for(let i of t)i in n&&(r[i]=n[i]);return r})}function Ye(e,t){return!Array.isArray(e)||!Array.isArray(t)?[]:e.map(n=>{let r={...n};for(let i of t)delete r[i];return r})}function en(e,t){return Array.isArray(e)?e.reduce((n,r,i)=>{let s=t(r,i);return n.concat(s)},[]):[]}function nn(e,t,n){if(!Array.isArray(e))return n;let r=n;for(let i=e.length-1;i>=0;i--)r=t(r,e[i],i);return r}function tn(e,t,n=1){if(n===0)return[];let r=[];if(n>0)for(let i=e;i<t;i+=n)r.push(i);else for(let i=e;i>t;i+=n)r.push(i);return r}function rn(e,t,n=0,r){if(!Array.isArray(e))return[];let i=[...e],s=r===void 0?i.length:r;for(let a=n;a<s&&a<i.length;a++)i[a]=t;return i}function sn(e){return Array.isArray(e)?S(e):[]}function on(e,t,...n){let r,i;if(typeof t=="string")r=t,i=[e];else{let a=n[n.length-1];typeof a=="string"?(r=a,i=[e,t,...n.slice(0,-1).filter(Array.isArray)]):(r="id",i=[e,t,...n.filter(Array.isArray)])}if(i.length===0)return[];let s=new Map;for(let a of i)if(Array.isArray(a))for(let o of a){let u=A(o)?d(o,r):void 0;if(u!==void 0){let f=s.get(u);s.set(u,f?{...f,...o}:o)}}return Array.from(s.values())}function an(e,t,n){if(!Array.isArray(e)||t===n)return e?[...e]:[];let r=[...e],[i]=r.splice(t,1);return r.splice(n,0,i),r}function un(e,t){if(!Array.isArray(e)||e.length===0||t===0)return e?[...e]:[];let n=e.length,r=(t%n+n)%n;return[...e.slice(-r),...e.slice(0,-r)]}function fn(e,t,...n){if(!Array.isArray(e))return n;let r=[...e];return r.splice(t,0,...n),r}function ln(e,t,n=1){if(!Array.isArray(e))return[];let r=[...e];return r.splice(t,n),r}function cn(e,t,n){if(!Array.isArray(e))return[];let r=[...e];return r[t]=n,r}function yn(e,t){if(!Array.isArray(e))return[];let n=e.filter(r=>r!=null);return t?n.filter(t):n}function pn(...e){return e.length===0?[[]]:e.length===1?e[0].map(t=>[t]):e.reduce((t,n)=>t.flatMap(r=>n.map(i=>[...r,i])),[[]])}function dn(e,t){if(!Array.isArray(e))return[];let n=[];for(let r=0;r<e.length;r++)t(e[r],r)&&n.push(r);return n}function Tn(e,t,n=!0){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(n&&A(e[r])&&A(t[r])){if(JSON.stringify(e[r])!==JSON.stringify(t[r]))return!1}else if(e[r]!==t[r])return!1;return!0}function An(e,t){if(!Array.isArray(e)||e.length===0)return[];let n=[],r=[e[0]],i=t(e[0],0);for(let s=1;s<e.length;s++){let a=t(e[s],s);a===i?r.push(e[s]):(n.push(r),r=[e[s]],i=a)}return n.push(r),n}function gn(e,t,n,r){if(!Array.isArray(e))return[];let i=typeof t=="function",s=i?n:r;return e.map(a=>{let o=!1;return i?o=t(a):o=(A(a)?d(a,t):a)===n,o?{...a,...s}:a})}function mn(e,t){if(!Array.isArray(e))return{unique:[],duplicates:[]};let n=new Set,r=[],i=[];for(let s of e){let a=t&&A(s)?d(s,t):s;n.has(a)?i.push(s):(n.add(a),r.push(s))}return{unique:r,duplicates:i}}function E(e){return Array.isArray(e)?e:e==null?[]:[e]}function xn(e){return E(e)}function hn(e,t,n=1){if(!Array.isArray(e)||t<1||n<1)return[];let r=[];for(let i=0;i<=e.length-t;i+=n)r.push(e.slice(i,i+t));return r}function bn(e,t){if(!Array.isArray(e)||e.length===0)return;let n=e[0],r=typeof t=="function"?t(n):d(n,t);for(let i=1;i<e.length;i++){let s=e[i],a=typeof t=="function"?t(s):d(s,t);a<r&&(r=a,n=s)}return n}function Sn(e,t){if(!Array.isArray(e)||e.length===0)return;let n=e[0],r=typeof t=="function"?t(n):d(n,t);for(let i=1;i<e.length;i++){let s=e[i],a=typeof t=="function"?t(s):d(s,t);a>r&&(r=a,n=s)}return n}function W(e,t){if(!Array.isArray(e)||e.length===0)return 0;let n=0;for(let r of e){let i=typeof t=="function"?t(r):d(r,t);typeof i=="number"&&!isNaN(i)&&(n+=i)}return n}function Kn(e,t){return!Array.isArray(e)||e.length===0?0:W(e,t)/e.length}function w(e){let t=new Map;if(!Array.isArray(e))return t;for(let n of e)t.set(n,(t.get(n)||0)+1);return t}function B(e,t=1){if(!Array.isArray(e)||e.length===0||t<1)return[];let n=w(e);return Array.from(n.entries()).sort((i,s)=>s[1]-i[1]).slice(0,t).map(([i])=>i)}function wn(e,t=1){if(!Array.isArray(e)||e.length===0||t<1)return[];let n=w(e);return Array.from(n.entries()).sort((i,s)=>i[1]-s[1]).slice(0,t).map(([i])=>i)}async function On(e,t,n){if(!Array.isArray(e)||t<1)return;let r=O(e,t);for(let i=0;i<r.length;i++)await n(r[i],i)}async function vn(e,t,n,r){if(!Array.isArray(e)||t<1||n<1)return;let i=O(e,t),s=O(i.map((a,o)=>({batch:a,index:o})),n);for(let a of s)await Promise.all(a.map(({batch:o,index:u})=>r(o,u)))}function In(e){if(!Array.isArray(e)||e.length===0)return[];let t=Math.max(...e.map(r=>r.length)),n=[];for(let r=0;r<t;r++){let i=[];for(let s=0;s<e.length;s++)r<e[s].length&&i.push(e[s][r]);n.push(i)}return n}function Pn(e,t){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function kn(e,t){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;let n=w(e),r=w(t);if(n.size!==r.size)return!1;for(let[i,s]of n)if(r.get(i)!==s)return!1;return!0}function q(e,t){if(!Array.isArray(e)||!Array.isArray(t))return!1;let n=new Set(t);return e.every(r=>n.has(r))}function jn(e,t){return q(t,e)}function Fn(...e){if(e.length===0)return[];let t=Math.max(...e.map(r=>r.length)),n=[];for(let r=0;r<t;r++)for(let i of e)r<i.length&&n.push(i[r]);return n}function Vn(e,t){let n=[],r=[];if(!Array.isArray(e))return{pass:n,fail:r};for(let i=0;i<e.length;i++)t(e[i],i)?n.push(e[i]):r.push(e[i]);return{pass:n,fail:r}}function Rn(e,t){if(e<0)return[];let n=[];for(let r=0;r<e;r++)n.push(t(r));return n}function $n(e,t){if(!Array.isArray(e)||t<0)return[];let n=[];for(let r=0;r<t;r++)n.push(...e);return n}function Cn(e){if(!Array.isArray(e)||e.length===0)return;let t=[...e].sort((r,i)=>r-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function Mn(e){let t=B(e,1);return t.length>0?t[0]:void 0}function Un(e,...t){if(!Array.isArray(e))return[];let n=new Set(t);return e.filter(r=>!n.has(r))}function En(e,...t){if(!Array.isArray(e))return[];let n=new Set(t.flat());return e.filter(r=>!n.has(r))}function Wn(e){if(!Array.isArray(e)||e.length===0)return[];let t=[],n=[e[0]];for(let r=1;r<e.length;r++)e[r]===e[r-1]?n.push(e[r]):(t.push(n),n=[e[r]]);return t.push(n),t}function Bn(e){if(!Array.isArray(e)||e.length===0)return[];let t=[e[0]];for(let n=1;n<e.length;n++)e[n]!==e[n-1]&&t.push(e[n]);return t}function qn(e,t="standard"){if(!Array.isArray(e)||e.length===0)return[];let n=e.map((i,s)=>({value:i,index:s}));n.sort((i,s)=>i.value-s.value);let r=new Array(e.length);if(t==="ordinal")for(let i=0;i<n.length;i++)r[n[i].index]=i+1;else if(t==="dense"){let i=1;r[n[0].index]=i;for(let s=1;s<n.length;s++)n[s].value!==n[s-1].value&&i++,r[n[s].index]=i}else{let i=0;for(;i<n.length;){let s=i;for(;s<n.length&&n[s].value===n[i].value;)s++;let a=i+1;for(let o=i;o<s;o++)r[n[o].index]=a;i=s}}return r}function I(e,t){if(!Array.isArray(e)||e.length===0||t<0||t>100)return;let n=[...e].sort((o,u)=>o-u),r=t/100*(n.length-1),i=Math.floor(r),s=Math.ceil(r),a=r-i;return i===s?n[i]:n[i]*(1-a)+n[s]*a}function Nn(e){if(!Array.isArray(e)||e.length===0)return;let t=I(e,25),n=I(e,50),r=I(e,75);return{q1:t,q2:n,q3:r,iqr:r-t}}function j(e,t=!1){if(!Array.isArray(e)||e.length===0||t&&e.length===1)return;let n=e.reduce((s,a)=>s+a,0)/e.length,i=e.map(s=>Math.pow(s-n,2)).reduce((s,a)=>s+a,0)/(t?e.length-1:e.length);return Math.sqrt(i)}function Ln(e,t=!1){let n=j(e,t);return n!==void 0?Math.pow(n,2):void 0}function _n(e){if(!Array.isArray(e)||e.length===0)return[];let t=Math.min(...e),r=Math.max(...e)-t;return r===0?e.map(()=>0):e.map(i=>(i-t)/r)}function zn(e){if(!Array.isArray(e)||e.length===0)return[];let t=e.reduce((r,i)=>r+i,0)/e.length,n=j(e);return n===void 0||n===0?e.map(()=>0):e.map(r=>(r-t)/n)}function N(e,t,n){if(!Array.isArray(e))return[];let r=[],i=n;for(let s=0;s<e.length;s++)i=t(i,e[s],s),r.push(i);return r}function Dn(e){return N(e,(t,n)=>t+n,0)}function Jn(e){if(!Array.isArray(e)||e.length<2)return[];let t=[];for(let n=1;n<e.length;n++)t.push(e[n]-e[n-1]);return t}function Qn(e,t,n,r="end"){if(!Array.isArray(e)||t<=e.length)return[...e];let i=new Array(t-e.length).fill(n);return r==="start"?[...i,...e]:[...e,...i]}function Zn(e,t){if(!Array.isArray(e)||e.length===0)return[];let n=0,r=e.length-1;for(;n<=r&&t(e[n]);)n++;for(;r>=n&&t(e[r]);)r--;return e.slice(n,r+1)}function Gn(e){if(!Array.isArray(e)||e.length<2)return[];let t=[];for(let n=0;n<e.length-1;n++)t.push([e[n],e[n+1]]);return t}function Hn(e){return Array.isArray(e)?e.map((t,n)=>[n,t]):[]}function Xn(e,t){return Array.isArray(e)?e.map((n,r)=>{let i=t[r%t.length];return i(n)}):[]}function L(e,t=1){if(!Array.isArray(e)||e.length===0)return[];let n=e.length,r=(t%n+n)%n;return[...e.slice(r),...e.slice(0,r)]}function Yn(e,t=1){return L(e,-t)}function et(e,t,n){if(!Array.isArray(e)||t<0||n<0||t>=e.length||n>=e.length)return[...e];let r=[...e];return[r[t],r[n]]=[r[n],r[t]],r}function nt(e,t,n){if(!Array.isArray(e)||t<0||n>=e.length||t>=n)return[...e];let r=[...e],i=r.slice(t,n+1).reverse();return r.splice(t,n-t+1,...i),r}function tt(e,t){if(!Array.isArray(e)||e.length<=1)return!0;let n=t||((r,i)=>r<i?-1:r>i?1:0);for(let r=1;r<e.length;r++)if(n(e[r-1],e[r])>0)return!1;return!0}function rt(e){return Array.isArray(e)?new Set(e).size!==e.length:!1}function it(e,t){return Array.isArray(e)?e.map(n=>{let r={};for(let i of t)i in n&&(r[i]=n[i]);return r}):[]}function _(e,t,n){if(!Array.isArray(e))return{};let r={};for(let i=0;i<e.length;i++){let s=t(e[i],i),a=n?n(e[i],i):e[i];r[s]=a}return r}async function st(e,t){if(!Array.isArray(e))return[];let n=[];for(let r=0;r<e.length;r++)n.push(await t(e[r],r));return n}async function ot(e,t){return Array.isArray(e)?Promise.all(e.map((n,r)=>t(n,r))):[]}async function at(e,t){if(!Array.isArray(e))return[];let n=[];for(let r=0;r<e.length;r++)await t(e[r],r)&&n.push(e[r]);return n}async function ut(e,t,n){if(!Array.isArray(e))return n;let r=n;for(let i=0;i<e.length;i++)r=await t(r,e[i],i);return r}async function ft(e,t){if(Array.isArray(e)){for(let n=0;n<e.length;n++)if(await t(e[n],n))return e[n]}}async function lt(e,t){if(!Array.isArray(e))return!1;for(let n=0;n<e.length;n++)if(await t(e[n],n))return!0;return!1}async function ct(e,t){if(!Array.isArray(e))return!0;for(let n=0;n<e.length;n++)if(!await t(e[n],n))return!1;return!0}function yt(e,t,n){if(!Array.isArray(e)||e.length===0)return 0;let r=0,i=0;for(let s of e){let a=typeof t=="function"?t(s):d(s,t),o=typeof n=="function"?n(s):d(s,n);typeof a=="number"&&typeof o=="number"&&(i+=a*o,r+=o)}return r===0?0:i/r}function pt(e,t,n=1){if(!Array.isArray(e)||e.length===0||n<1)return[];let r=[],i=0;for(let a of e){let o=typeof t=="function"?t(a):d(a,t);i+=typeof o=="number"&&o>0?o:0,r.push(i)}if(i===0)return[];let s=[];for(let a=0;a<n;a++){let o=Math.random()*i,u=r.findIndex(f=>o<f);u!==-1&&s.push(e[u])}return s}function dt(e,t){if(!Array.isArray(e)||!Array.isArray(t))return[];let n=[],r=0;for(let i of t){if(r>=e.length)break;n.push(e.slice(r,r+i)),r+=i}return n}function Tt(e,t){if(!Array.isArray(e)||t<1)return[];let n=w(e),r=[];for(let i of e)n.get(i)===t&&r.push(i);return r}function At(e,t,n){if(!Array.isArray(e)||t<1)return[];let r=[],i=0,s=[];for(let a of e)n(a)?(i++,s.push(a),i>=t&&r.push(...s.splice(0,s.length-t+1))):(i=0,s.length=0);return i>=t&&r.push(...s),r}function gt(e,t,n){if(!Array.isArray(e))return[];let r=[],i=n;for(let s=0;s<e.length;s++){let{value:a,newContext:o}=t(e[s],i,s);r.push(a),i=o}return r}function mt(e,t){return O(e,t)}function xt(e,t,n){if(!Array.isArray(e)||!Array.isArray(t))return[];let r=Math.min(e.length,t.length),i=[];for(let s=0;s<r;s++)i.push(n(e[s],t[s]));return i}function ht(e,t,n="last"){if(!Array.isArray(e)||e.length===0)return[];let r=new Map;for(let s of e)if(Array.isArray(s))for(let a of s){let o=d(a,t);if(n==="first")r.has(o)||r.set(o,a);else if(n==="last")r.set(o,a);else if(n==="concat"){let u=r.get(o);Array.isArray(u)?u.push(a):u?r.set(o,[u,a]):r.set(o,a)}else if(typeof n=="function"){let u=r.get(o);u&&!Array.isArray(u)?r.set(o,n(u,a)):r.set(o,a)}}let i=[];for(let s of r.values())Array.isArray(s)&&n==="concat"?i.push(...s):Array.isArray(s)||i.push(s);return i}function bt(e,t){return _(e,n=>String(d(n,t)))}function St(e,t,n){if(!Array.isArray(e)||e.length===0)return-1;let r=n||((a,o)=>a<o?-1:a>o?1:0),i=0,s=e.length-1;for(;i<=s;){let a=Math.floor((i+s)/2),o=r(e[a],t);if(o===0)return a;o<0?i=a+1:s=a-1}return-1}function Kt(e,t,n){if(!Array.isArray(e))return[t];let r=n||((a,o)=>a<o?-1:a>o?1:0),i=[...e],s=0;for(;s<i.length&&r(i[s],t)<0;)s++;return i.splice(s,0,t),i}export{Xn as applyByIndex,ye as at,Kn as avgBy,mt as batch,On as batchProcess,vn as batchProcessParallel,Vn as bifurcate,St as binarySearch,pn as cartesian,O as chunk,An as chunkBy,_e as compact,Ve as countBy,Dn as cumulativeSum,Bn as dedupeConsecutive,sn as deepCloneArray,Jn as diff,Ce as difference,En as differenceWith,Ne as drop,Le as dropWhile,E as ensureArray,Hn as enumerate,ct as everyAsync,rn as fill,at as filterAsync,yn as filterCompact,At as filterConsecutive,dn as findAllIndices,ft as findAsync,Ze as findIndex,Ge as findLastIndex,ue as first,en as flatMap,je as flatten,ce as flattenArray,M as flattenDeep,w as frequencies,Rn as generate,le as groupArrayBy,Fe as groupBy,Wn as groupConsecutive,rt as hasDuplicates,kn as hasSameElements,bt as indexBy,fn as insert,Kt as insertSorted,Fn as interleave,Me as intersection,Y as isArray,Pn as isArrayEqual,te as isArrayLike,Q as isArrayOfBoolean,J as isArrayOfNumber,Z as isArrayOfObject,D as isArrayOfString,ne as isDoubleArray,re as isEmptyArray,Tn as isEqual,R as isIterable,ie as isNonEmptyArray,X as isObjectArray,oe as isReadonlyArray,tt as isSorted,ee as isStaticArray,q as isSubset,jn as isSuperset,se as isTypedArray,Re as keyBy,ae as last,wn as leastCommon,st as mapAsync,ot as mapAsyncParallel,gt as mapWithContext,Sn as maxBy,Cn as median,ht as mergeArraysByKey,on as mergeByKey,bn as minBy,Mn as mode,B as mostCommon,an as move,_n as normalize,Ye as omit,Qn as pad,Gn as pairwise,Ee as partition,I as percentile,Xe as pick,it as pickMany,He as pluck,Nn as quartiles,tn as range,qn as rank,ut as reduceAsync,nn as reduceRight,ln as remove,$n as repeat,cn as replace,nt as reverseSegment,un as rotate,L as rotateLeft,Yn as rotateRight,Je as sample,Qe as sampleSize,N as scan,dt as segment,Tt as selectByCount,U as shuffle,hn as slidingWindow,lt as someAsync,$e as sortBy,mn as splitDuplicates,j as standardDeviation,zn as standardize,W as sumBy,et as swap,We as take,Be as takeLast,qe as takeWhile,fe as toArray,z as toArrayString,_ as toObject,In as transpose,Zn as trim,Ue as union,v as unique,De as unzip,gn as updateBy,Ln as variance,yt as weightedAverage,pt as weightedSample,Un as without,xn as wrap,ze as zip,xt as zipWith};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var y=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var f=(r,n)=>{for(var t in n)y(r,t,{get:n[t],enumerable:!0})},T=(r,n,t,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of A(n))!s.call(r,e)&&e!==t&&y(r,e,{get:()=>n[e],enumerable:!(a=u(n,e))||a.enumerable});return r};var c=r=>T(y({},"__esModule",{value:!0}),r);var O={};f(O,{at:()=>K,first:()=>U,flattenArray:()=>B,groupArrayBy:()=>j,isArray:()=>p,isArrayLike:()=>k,isDoubleArray:()=>x,isEmptyArray:()=>g,isIterable:()=>o,isNonEmptyArray:()=>h,isObjectArray:()=>l,isReadonlyArray:()=>b,isStaticArray:()=>d,isTypedArray:()=>w,last:()=>m,toArray:()=>I});module.exports=c(O);var i=require("@fluixi/utils/object"),l=r=>Array.isArray(r)&&r.every(n=>(0,i.isObject)(n));function p(r){return Array.isArray(r)}function d(r){return Array.isArray(r)}function x(r){return Array.isArray(r)&&r.every(n=>Array.isArray(n)&&n.length===2)}function o(r){return r!=null&&typeof r[Symbol.iterator]=="function"}function k(r){return r!=null&&typeof r=="object"&&"length"in r&&typeof r.length=="number"&&r.length>=0&&(r.length===0||r.length-1 in r)}function g(r){return Array.isArray(r)&&r.length===0}function h(r){return Array.isArray(r)&&r.length>0}function w(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function b(r){return Array.isArray(r)}function m(r){return r.length>0?r[r.length-1]:void 0}function U(r){return r.length>0?r[0]:void 0}function I(r){return Array.isArray(r)?[...r]:o(r)?[...r]:Array.from(r)}function j(r,n){return r.reduce((t,a)=>{let e=n(a);return t[e]||(t[e]=[]),t[e].push(a),t},{})}function B(r){return r.flat()}function K(r,n){let t=n<0?r.length+n:n;return r[t]}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { type AnyObject } from '@fluixi/utils/object';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value is an object array
|
|
4
|
+
* @param value - Value to check
|
|
5
|
+
* @returns True if value is an object array
|
|
6
|
+
*/
|
|
7
|
+
export declare const isObjectArray: (value: any) => value is AnyObject[];
|
|
8
|
+
/**
|
|
9
|
+
* Type guard to check if a value is an array
|
|
10
|
+
* @param v - Value to check
|
|
11
|
+
* @returns True if value is an array
|
|
12
|
+
*/
|
|
13
|
+
export declare function isArray<T = any>(v: unknown): v is T[];
|
|
14
|
+
/**
|
|
15
|
+
* Type guard to check if a value is a static array
|
|
16
|
+
* @param v - Value to check
|
|
17
|
+
* @returns True if value is a static array
|
|
18
|
+
*/
|
|
19
|
+
export declare function isStaticArray<T = any, U = any>(v: unknown): v is [T, U];
|
|
20
|
+
/**
|
|
21
|
+
* Type guard to check if a value is an array of 2-item tuples: [T, U][]
|
|
22
|
+
* @param v - Value to check
|
|
23
|
+
* @returns True if value is an array of 2-item tuples
|
|
24
|
+
*/
|
|
25
|
+
export declare function isDoubleArray<T = any, U = any>(v: unknown): v is [T, U][];
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is iterable
|
|
28
|
+
* @param v - Value to check
|
|
29
|
+
* @returns True if value is iterable
|
|
30
|
+
*/
|
|
31
|
+
export declare function isIterable(v: unknown): v is Iterable<unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Type guard to check if a value is array-like
|
|
34
|
+
* @param v - Value to check
|
|
35
|
+
* @returns True if value is array-like
|
|
36
|
+
*/
|
|
37
|
+
export declare function isArrayLike(v: unknown): v is ArrayLike<unknown>;
|
|
38
|
+
/**
|
|
39
|
+
* Type guard to check if an array is empty
|
|
40
|
+
* @param v - Array to check
|
|
41
|
+
* @returns True if array is empty
|
|
42
|
+
*/
|
|
43
|
+
export declare function isEmptyArray<T>(v: T[]): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Type guard to check if a value is a non-empty array
|
|
46
|
+
* @param v - Value to check
|
|
47
|
+
* @returns True if value is a non-empty array
|
|
48
|
+
*/
|
|
49
|
+
export declare function isNonEmptyArray<T>(v: unknown): v is [T, ...T[]];
|
|
50
|
+
/**
|
|
51
|
+
* Type guard to check if a value is a typed array
|
|
52
|
+
* @param v - Value to check
|
|
53
|
+
* @returns True if value is a typed array (Int8Array, Uint8Array, etc.)
|
|
54
|
+
*/
|
|
55
|
+
export declare function isTypedArray(v: unknown): v is Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array;
|
|
56
|
+
/**
|
|
57
|
+
* Type guard to check if a value is a readonly array
|
|
58
|
+
* @param v - Value to check
|
|
59
|
+
* @returns True if value is a readonly array
|
|
60
|
+
*/
|
|
61
|
+
export declare function isReadonlyArray<T = any>(v: unknown): v is readonly T[];
|
|
62
|
+
/**
|
|
63
|
+
* Safely get the last element of an array
|
|
64
|
+
* @param arr - Array to get last element from
|
|
65
|
+
* @returns Last element or undefined if array is empty
|
|
66
|
+
*/
|
|
67
|
+
export declare function last<T>(arr: T[]): T | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Safely get the first element of an array
|
|
70
|
+
* @param arr - Array to get first element from
|
|
71
|
+
* @returns First element or undefined if array is empty
|
|
72
|
+
*/
|
|
73
|
+
export declare function first<T>(arr: T[]): T | undefined;
|
|
74
|
+
/**
|
|
75
|
+
* Create an array from an iterable or array-like object with type safety
|
|
76
|
+
* @param iterable - Iterable or array-like object
|
|
77
|
+
* @returns Array from the iterable
|
|
78
|
+
*/
|
|
79
|
+
export declare function toArray<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
80
|
+
/**
|
|
81
|
+
* Group array items by a key
|
|
82
|
+
* @param arr - Array to group
|
|
83
|
+
* @param keyFn - Function to extract group key
|
|
84
|
+
* @returns Object with keys mapping to arrays of items
|
|
85
|
+
*/
|
|
86
|
+
export declare function groupArrayBy<T, K extends string | number | symbol>(arr: T[], keyFn: (item: T) => K): Record<K, T[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Flatten an array of arrays
|
|
89
|
+
* @param arr - Array of arrays to flatten
|
|
90
|
+
* @returns Flattened array
|
|
91
|
+
*/
|
|
92
|
+
export declare function flattenArray<T>(arr: T[][]): T[];
|
|
93
|
+
/**
|
|
94
|
+
* Get array element by index with support for negative indices
|
|
95
|
+
* @param arr - Array to get element from
|
|
96
|
+
* @param index - Index (negative counts from end)
|
|
97
|
+
* @returns Element at index or undefined if out of bounds
|
|
98
|
+
*/
|
|
99
|
+
export declare function at<T>(arr: T[], index: number): T | undefined;
|
|
100
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/array/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,aAAa,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,SAAS,EAE5D,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,CAAC,EAAE,CAErD;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAEvE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAKzE;AAED;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,QAAQ,CAAC,OAAO,CAAC,CAE7D;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,SAAS,CAAC,OAAO,CAAC,CAS/D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,CAE/D;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,CAAC,EAAE,OAAO,GACT,CAAC,IACA,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,UAAU,GACV,WAAW,GACX,UAAU,GACV,WAAW,GACX,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,cAAc,CAEjB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,SAAS,CAAC,EAAE,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAE/C;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,CAAC,GAAG,SAAS,CAEhD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAQpE;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,GAAG,MAAM,GAAG,MAAM,EAChE,GAAG,EAAE,CAAC,EAAE,EACR,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GACpB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAShB;AAkBD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,GAAG,CAAC,EAAE,CAE/C;AAED;;;;;GAKG;AACH,wBAAgB,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAG5D"}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { isObject } from '@fluixi/utils/object';
|
|
2
|
+
/**
|
|
3
|
+
* Type guard to check if a value is an object array
|
|
4
|
+
* @param value - Value to check
|
|
5
|
+
* @returns True if value is an object array
|
|
6
|
+
*/
|
|
7
|
+
export const isObjectArray = (value) => {
|
|
8
|
+
return Array.isArray(value) && value.every((item) => isObject(item));
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Type guard to check if a value is an array
|
|
12
|
+
* @param v - Value to check
|
|
13
|
+
* @returns True if value is an array
|
|
14
|
+
*/
|
|
15
|
+
export function isArray(v) {
|
|
16
|
+
return Array.isArray(v);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Type guard to check if a value is a static array
|
|
20
|
+
* @param v - Value to check
|
|
21
|
+
* @returns True if value is a static array
|
|
22
|
+
*/
|
|
23
|
+
export function isStaticArray(v) {
|
|
24
|
+
return Array.isArray(v);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Type guard to check if a value is an array of 2-item tuples: [T, U][]
|
|
28
|
+
* @param v - Value to check
|
|
29
|
+
* @returns True if value is an array of 2-item tuples
|
|
30
|
+
*/
|
|
31
|
+
export function isDoubleArray(v) {
|
|
32
|
+
return (Array.isArray(v) &&
|
|
33
|
+
v.every((item) => Array.isArray(item) && item.length === 2));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Type guard to check if a value is iterable
|
|
37
|
+
* @param v - Value to check
|
|
38
|
+
* @returns True if value is iterable
|
|
39
|
+
*/
|
|
40
|
+
export function isIterable(v) {
|
|
41
|
+
return v != null && typeof v[Symbol.iterator] === 'function';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Type guard to check if a value is array-like
|
|
45
|
+
* @param v - Value to check
|
|
46
|
+
* @returns True if value is array-like
|
|
47
|
+
*/
|
|
48
|
+
export function isArrayLike(v) {
|
|
49
|
+
return (v != null &&
|
|
50
|
+
typeof v === 'object' &&
|
|
51
|
+
'length' in v &&
|
|
52
|
+
typeof v.length === 'number' &&
|
|
53
|
+
v.length >= 0 &&
|
|
54
|
+
(v.length === 0 || v.length - 1 in v));
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Type guard to check if an array is empty
|
|
58
|
+
* @param v - Array to check
|
|
59
|
+
* @returns True if array is empty
|
|
60
|
+
*/
|
|
61
|
+
export function isEmptyArray(v) {
|
|
62
|
+
return Array.isArray(v) && v.length === 0;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Type guard to check if a value is a non-empty array
|
|
66
|
+
* @param v - Value to check
|
|
67
|
+
* @returns True if value is a non-empty array
|
|
68
|
+
*/
|
|
69
|
+
export function isNonEmptyArray(v) {
|
|
70
|
+
return Array.isArray(v) && v.length > 0;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Type guard to check if a value is a typed array
|
|
74
|
+
* @param v - Value to check
|
|
75
|
+
* @returns True if value is a typed array (Int8Array, Uint8Array, etc.)
|
|
76
|
+
*/
|
|
77
|
+
export function isTypedArray(v) {
|
|
78
|
+
return ArrayBuffer.isView(v) && !(v instanceof DataView);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Type guard to check if a value is a readonly array
|
|
82
|
+
* @param v - Value to check
|
|
83
|
+
* @returns True if value is a readonly array
|
|
84
|
+
*/
|
|
85
|
+
export function isReadonlyArray(v) {
|
|
86
|
+
return Array.isArray(v);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Safely get the last element of an array
|
|
90
|
+
* @param arr - Array to get last element from
|
|
91
|
+
* @returns Last element or undefined if array is empty
|
|
92
|
+
*/
|
|
93
|
+
export function last(arr) {
|
|
94
|
+
return arr.length > 0 ? arr[arr.length - 1] : undefined;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Safely get the first element of an array
|
|
98
|
+
* @param arr - Array to get first element from
|
|
99
|
+
* @returns First element or undefined if array is empty
|
|
100
|
+
*/
|
|
101
|
+
export function first(arr) {
|
|
102
|
+
return arr.length > 0 ? arr[0] : undefined;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Create an array from an iterable or array-like object with type safety
|
|
106
|
+
* @param iterable - Iterable or array-like object
|
|
107
|
+
* @returns Array from the iterable
|
|
108
|
+
*/
|
|
109
|
+
export function toArray(iterable) {
|
|
110
|
+
if (Array.isArray(iterable)) {
|
|
111
|
+
return [...iterable];
|
|
112
|
+
}
|
|
113
|
+
if (isIterable(iterable)) {
|
|
114
|
+
return [...iterable];
|
|
115
|
+
}
|
|
116
|
+
return Array.from(iterable);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Group array items by a key
|
|
120
|
+
* @param arr - Array to group
|
|
121
|
+
* @param keyFn - Function to extract group key
|
|
122
|
+
* @returns Object with keys mapping to arrays of items
|
|
123
|
+
*/
|
|
124
|
+
export function groupArrayBy(arr, keyFn) {
|
|
125
|
+
return arr.reduce((groups, item) => {
|
|
126
|
+
const key = keyFn(item);
|
|
127
|
+
if (!groups[key]) {
|
|
128
|
+
groups[key] = [];
|
|
129
|
+
}
|
|
130
|
+
groups[key].push(item);
|
|
131
|
+
return groups;
|
|
132
|
+
}, {});
|
|
133
|
+
}
|
|
134
|
+
// /**
|
|
135
|
+
// * Chunk an array into smaller arrays of specified size
|
|
136
|
+
// * @param arr - Array to chunk
|
|
137
|
+
// * @param size - Size of each chunk
|
|
138
|
+
// * @returns Array of chunks
|
|
139
|
+
// */
|
|
140
|
+
// export function chunk<T>(arr: T[], size: number): T[][] {
|
|
141
|
+
// if (size <= 0) return [];
|
|
142
|
+
// const chunks: T[][] = [];
|
|
143
|
+
// for (let i = 0; i < arr.length; i += size) {
|
|
144
|
+
// chunks.push(arr.slice(i, i + size));
|
|
145
|
+
// }
|
|
146
|
+
// return chunks;
|
|
147
|
+
// }
|
|
148
|
+
/**
|
|
149
|
+
* Flatten an array of arrays
|
|
150
|
+
* @param arr - Array of arrays to flatten
|
|
151
|
+
* @returns Flattened array
|
|
152
|
+
*/
|
|
153
|
+
export function flattenArray(arr) {
|
|
154
|
+
return arr.flat();
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Get array element by index with support for negative indices
|
|
158
|
+
* @param arr - Array to get element from
|
|
159
|
+
* @param index - Index (negative counts from end)
|
|
160
|
+
* @returns Element at index or undefined if out of bounds
|
|
161
|
+
*/
|
|
162
|
+
export function at(arr, index) {
|
|
163
|
+
const normalizedIndex = index < 0 ? arr.length + index : index;
|
|
164
|
+
return arr[normalizedIndex];
|
|
165
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isObject as y}from"@fluixi/utils/object";var u=r=>Array.isArray(r)&&r.every(n=>y(n));function A(r){return Array.isArray(r)}function s(r){return Array.isArray(r)}function f(r){return Array.isArray(r)&&r.every(n=>Array.isArray(n)&&n.length===2)}function i(r){return r!=null&&typeof r[Symbol.iterator]=="function"}function T(r){return r!=null&&typeof r=="object"&&"length"in r&&typeof r.length=="number"&&r.length>=0&&(r.length===0||r.length-1 in r)}function c(r){return Array.isArray(r)&&r.length===0}function l(r){return Array.isArray(r)&&r.length>0}function p(r){return ArrayBuffer.isView(r)&&!(r instanceof DataView)}function d(r){return Array.isArray(r)}function x(r){return r.length>0?r[r.length-1]:void 0}function k(r){return r.length>0?r[0]:void 0}function g(r){return Array.isArray(r)?[...r]:i(r)?[...r]:Array.from(r)}function h(r,n){return r.reduce((t,a)=>{let e=n(a);return t[e]||(t[e]=[]),t[e].push(a),t},{})}function w(r){return r.flat()}function b(r,n){let t=n<0?r.length+n:n;return r[t]}export{b as at,k as first,w as flattenArray,h as groupArrayBy,A as isArray,T as isArrayLike,f as isDoubleArray,c as isEmptyArray,i as isIterable,l as isNonEmptyArray,u as isObjectArray,d as isReadonlyArray,s as isStaticArray,p as isTypedArray,x as last,g as toArray};
|