ziko 1.1.0 → 1.1.1

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/dist/ziko.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Thu Jun 04 2026 14:34:29 GMT+0100 (UTC+01:00)
5
+ Date : Tue Jul 28 2026 17:04:51 GMT+0100 (UTC+01:00)
6
6
  Git-Repo : https://github.com/zakarialaoui10/ziko.js
7
7
  Git-Wiki : https://github.com/zakarialaoui10/ziko.js/wiki
8
8
  Released under MIT License
@@ -13,18 +13,18 @@ const EPSILON=Number.EPSILON;
13
13
 
14
14
  const is_primitive = value => typeof value !== 'object' && typeof value !== 'function' || value === null;
15
15
 
16
- const mapfun=(fun,...X)=>{
16
+ const mapfun$1=(fun,...X)=>{
17
17
  const Y=X.map(x=>{
18
18
  if(is_primitive(x) || x?.__mapfun__) return fun(x)
19
- if(x instanceof Array) return x.map(n=>mapfun(fun,n));
19
+ if(x instanceof Array) return x.map(n=>mapfun$1(fun,n));
20
20
  if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
21
- if(x instanceof Set) return new Set(mapfun(fun,...[...x]));
22
- if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
23
- if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun(x.arr.flat(1)))
21
+ if(x instanceof Set) return new Set(mapfun$1(fun,...[...x]));
22
+ if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun$1(fun,n[1])]));
23
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun$1(x.arr.flat(1)))
24
24
  else if(x instanceof Object){
25
25
  return Object.fromEntries(
26
26
  Object.entries(x).map(
27
- n=>n=[n[0],mapfun(fun,n[1])]
27
+ n=>n=[n[0],mapfun$1(fun,n[1])]
28
28
  )
29
29
  )
30
30
  }
@@ -42,7 +42,7 @@ const apply_fun = (x, fn) => {
42
42
  x.cols,
43
43
  x.arr.flat(1).map(fn)
44
44
  )
45
- if (x instanceof Array) mapfun(fn, ...x);
45
+ if (x instanceof Array) mapfun$1(fn, ...x);
46
46
  return fn(x)
47
47
  };
48
48
 
@@ -525,7 +525,7 @@ const complex=(a,b)=>{
525
525
 
526
526
  const PRECESION = 8;
527
527
 
528
- const abs = (...x) => mapfun(
528
+ const abs = (...x) => mapfun$1(
529
529
  x =>{
530
530
  if(x.isComplex?.()) return x.z;
531
531
  return Math.abs(x)
@@ -535,7 +535,7 @@ const abs = (...x) => mapfun(
535
535
 
536
536
  const pow$1 = (...x) => {
537
537
  const n = x.pop();
538
- return mapfun(
538
+ return mapfun$1(
539
539
  x => {
540
540
  if(x.isComplex?.()) {
541
541
  if(n.isComplex?.()) return new x.constructor({
@@ -554,7 +554,7 @@ const pow$1 = (...x) => {
554
554
  )
555
555
  };
556
556
 
557
- const sqrt$2 = (...x) => mapfun(
557
+ const sqrt$2 = (...x) => mapfun$1(
558
558
  x=>{
559
559
  if(x.isComplex?.())
560
560
  return new x.constructor({z: x.z**(1/2), phi: x.phi/2});
@@ -564,7 +564,7 @@ const sqrt$2 = (...x) => mapfun(
564
564
  ...x
565
565
  );
566
566
 
567
- const cbrt = (...x) => mapfun(
567
+ const cbrt = (...x) => mapfun$1(
568
568
  x=>{
569
569
  if(x.isComplex?.())
570
570
  return new x.constructor({z: x.z**(1/3), phi: x.phi/3}).toFixed(PRECESION)
@@ -576,7 +576,7 @@ const cbrt = (...x) => mapfun(
576
576
  const nthr = (...x) => {
577
577
  const n = x.pop();
578
578
  if(typeof n !== 'number') throw Error('nthr expects a real number n');
579
- return mapfun(
579
+ return mapfun$1(
580
580
  x => {
581
581
  if(x.isComplex?.()) return new x.constructor({z: x.z ** (1/n), phi: x.phi / n});
582
582
  if(x<0) return n %2 ===2
@@ -591,7 +591,7 @@ const nthr = (...x) => {
591
591
  const croot = (...x) =>{
592
592
  const c = x.pop();
593
593
  if(!c.isComplex?.()) throw Error('croot expect Complex number as root')
594
- return mapfun(
594
+ return mapfun$1(
595
595
  x => {
596
596
  if(typeof x === 'number') x = new c.constructor(x, 0);
597
597
  const {a : c_a, b : c_b} = c;
@@ -608,7 +608,7 @@ const croot = (...x) =>{
608
608
  )
609
609
  };
610
610
 
611
- const exp$1 = (...x) => mapfun(
611
+ const exp$1 = (...x) => mapfun$1(
612
612
  x => {
613
613
  if(x.isComplex?.()) return new x.constructor(
614
614
  Math.exp(x.a) * Math.cos(x.b),
@@ -619,7 +619,7 @@ const exp$1 = (...x) => mapfun(
619
619
  ,...x
620
620
  );
621
621
 
622
- const ln = (...x) => mapfun(
622
+ const ln = (...x) => mapfun$1(
623
623
  x => {
624
624
  if(x.isComplex?.()) return new x.constructor(
625
625
  Math.log(x.z),
@@ -630,7 +630,7 @@ const ln = (...x) => mapfun(
630
630
  ,...x
631
631
  );
632
632
 
633
- const sign = (...x) => mapfun(
633
+ const sign = (...x) => mapfun$1(
634
634
  x => {
635
635
  if(x.isComplex?.()){
636
636
  const {z, phi} = x;
@@ -642,7 +642,7 @@ const sign = (...x) => mapfun(
642
642
  ,...x
643
643
  );
644
644
 
645
- const floor = (...x) => mapfun(
645
+ const floor = (...x) => mapfun$1(
646
646
  x => {
647
647
  if(x.isComplex?.()) return new x.constructor(
648
648
  Math.floor(x.a),
@@ -652,7 +652,7 @@ const floor = (...x) => mapfun(
652
652
  },
653
653
  ...x
654
654
  );
655
- const ceil = (...x) => mapfun(
655
+ const ceil = (...x) => mapfun$1(
656
656
  x => {
657
657
  if(x.isComplex?.()) return new x.constructor(
658
658
  Math.ceil(x.a),
@@ -662,7 +662,7 @@ const ceil = (...x) => mapfun(
662
662
  },
663
663
  ...x
664
664
  );
665
- const round = (...x) => mapfun(
665
+ const round = (...x) => mapfun$1(
666
666
  x => {
667
667
  if(x.isComplex?.()) return new x.constructor(
668
668
  Math.round(x.a),
@@ -673,7 +673,7 @@ const round = (...x) => mapfun(
673
673
  ...x
674
674
  );
675
675
 
676
- const trunc = (...x) => mapfun(
676
+ const trunc = (...x) => mapfun$1(
677
677
  x => {
678
678
  if(x.isComplex?.()) return new x.constructor(
679
679
  Math.trunc(x.a),
@@ -684,7 +684,7 @@ const trunc = (...x) => mapfun(
684
684
  ...x
685
685
  );
686
686
 
687
- const fract = (...x) => mapfun(
687
+ const fract = (...x) => mapfun$1(
688
688
  x => {
689
689
  if(x.isComplex?.()) return new x.constructor(
690
690
  x.a - Math.trunc(x.a),
@@ -695,7 +695,7 @@ const fract = (...x) => mapfun(
695
695
  ...x
696
696
  );
697
697
 
698
- const cos$3 = (...x) => mapfun(
698
+ const cos$3 = (...x) => mapfun$1(
699
699
  x => {
700
700
  if(x.isComplex?.()) return new x.constructor(
701
701
  Math.cos(x.a) * Math.cosh(x.b),
@@ -706,7 +706,7 @@ const cos$3 = (...x) => mapfun(
706
706
  ,...x
707
707
  );
708
708
 
709
- const sin$3 = (...x) => mapfun(
709
+ const sin$3 = (...x) => mapfun$1(
710
710
  x =>{
711
711
  if(x?.isComplex) return new x.constructor(
712
712
  Math.sin(x.a) * Math.cosh(x.b),
@@ -717,7 +717,7 @@ const sin$3 = (...x) => mapfun(
717
717
  , ...x
718
718
  );
719
719
 
720
- const tan = (...x) => mapfun(
720
+ const tan = (...x) => mapfun$1(
721
721
  x =>{
722
722
  if(x?.isComplex){
723
723
  const D = Math.cos(2*x.a) + Math.cosh(2*x.b);
@@ -731,7 +731,7 @@ const tan = (...x) => mapfun(
731
731
  ...x
732
732
  );
733
733
 
734
- const sec = (...x) => mapfun(
734
+ const sec = (...x) => mapfun$1(
735
735
  x => {
736
736
  if(x.isComplex?.()) ;
737
737
  return + (1 / Math.cos(x)).toFixed(PRECESION)
@@ -739,7 +739,7 @@ const sec = (...x) => mapfun(
739
739
  ,...x
740
740
  );
741
741
 
742
- const acos$1 = (...x) => mapfun(
742
+ const acos$1 = (...x) => mapfun$1(
743
743
  x =>{
744
744
  if(x?.isComplex){
745
745
  const { a, b } = x;
@@ -757,7 +757,7 @@ const acos$1 = (...x) => mapfun(
757
757
  ...x
758
758
  );
759
759
 
760
- const asin = (...x) => mapfun(
760
+ const asin = (...x) => mapfun$1(
761
761
  x => {
762
762
  if(x?.isComplex){
763
763
  const { a, b } = x;
@@ -773,7 +773,7 @@ const asin = (...x) => mapfun(
773
773
  ...x
774
774
  );
775
775
 
776
- const atan = (...x) => mapfun(
776
+ const atan = (...x) => mapfun$1(
777
777
  x => {
778
778
  if(x?.isComplex){
779
779
  const { a, b } = x;
@@ -787,7 +787,7 @@ const atan = (...x) => mapfun(
787
787
  ...x
788
788
  );
789
789
 
790
- const acot = (...x) => mapfun(
790
+ const acot = (...x) => mapfun$1(
791
791
  x => {
792
792
  if(x?.isComplex){
793
793
  const { a, b } = x;
@@ -802,7 +802,7 @@ const acot = (...x) => mapfun(
802
802
  );
803
803
 
804
804
 
805
- const cosh$2 = (...x) => mapfun(
805
+ const cosh$2 = (...x) => mapfun$1(
806
806
  x =>{
807
807
  if(x?.isComplex) return new x.constructor(
808
808
  Math.cosh(x.a) * Math.cos(x.b),
@@ -812,7 +812,7 @@ const cosh$2 = (...x) => mapfun(
812
812
  },
813
813
  ...x
814
814
  );
815
- const sinh$1 = (...x) => mapfun(
815
+ const sinh$1 = (...x) => mapfun$1(
816
816
  x =>{
817
817
  if(x?.isComplex) return new x.constructor(
818
818
  Math.sinh(x.a) * Math.cos(x.b),
@@ -822,7 +822,7 @@ const sinh$1 = (...x) => mapfun(
822
822
  },
823
823
  ...x
824
824
  );
825
- const tanh = (...x) => mapfun(
825
+ const tanh = (...x) => mapfun$1(
826
826
  x =>{
827
827
  if(x?.isComplex){
828
828
  const D = Math.cosh(2*a) + Math.cos(2*b);
@@ -836,7 +836,7 @@ const tanh = (...x) => mapfun(
836
836
  ...x
837
837
  );
838
838
 
839
- const coth = (...x) => mapfun(
839
+ const coth = (...x) => mapfun$1(
840
840
  x =>{
841
841
  if(x?.isComplex){
842
842
  const {a, b} = x;
@@ -851,7 +851,7 @@ const coth = (...x) => mapfun(
851
851
  ...x
852
852
  );
853
853
 
854
- const acosh = (...x) => mapfun(
854
+ const acosh = (...x) => mapfun$1(
855
855
  x =>{
856
856
  if(x?.isComplex){
857
857
  return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).sub(1))))
@@ -861,7 +861,7 @@ const acosh = (...x) => mapfun(
861
861
  ...x
862
862
  );
863
863
 
864
- const asinh = (...x) => mapfun(
864
+ const asinh = (...x) => mapfun$1(
865
865
  x =>{
866
866
  if(x?.isComplex){
867
867
  return ln(x.clone().add(sqrt$2(x.clone().mul(x.clone()).add(1))))
@@ -871,7 +871,7 @@ const asinh = (...x) => mapfun(
871
871
  ...x
872
872
  );
873
873
 
874
- const atanh = (...x) => mapfun(
874
+ const atanh = (...x) => mapfun$1(
875
875
  x =>{
876
876
  if(x?.isComplex);
877
877
  return + Math.atanh(x).toFixed(PRECESION)
@@ -879,7 +879,7 @@ const atanh = (...x) => mapfun(
879
879
  ...x
880
880
  );
881
881
 
882
- const sig = (...x) => mapfun(
882
+ const sig = (...x) => mapfun$1(
883
883
  x =>{
884
884
  if(x?.isComplex);
885
885
  return 1/(1 + Math.exp(-x)).toFixed(PRECESION)
@@ -887,8 +887,8 @@ const sig = (...x) => mapfun(
887
887
  ...x
888
888
  );
889
889
 
890
- const deg2rad = (...deg) => mapfun(x => x * Math.PI / 180, ...deg);
891
- const rad2deg = (...rad) => mapfun(x => x / Math.PI * 180, ...rad);
890
+ const deg2rad = (...deg) => mapfun$1(x => x * Math.PI / 180, ...deg);
891
+ const rad2deg = (...rad) => mapfun$1(x => x / Math.PI * 180, ...rad);
892
892
 
893
893
  const norm = (x, min, max) => apply_fun(
894
894
  x,
@@ -919,10 +919,10 @@ const hypot = (...x) => {
919
919
 
920
920
  const atan2 = (y, x, rad = true) => {
921
921
  if (y instanceof Array && !(x instanceof Array))
922
- return mapfun(n => atan2(n, x, rad), ...y);
922
+ return mapfun$1(n => atan2(n, x, rad), ...y);
923
923
 
924
924
  if (x instanceof Array && !(y instanceof Array))
925
- return mapfun(n => atan2(y, n, rad), ...x);
925
+ return mapfun$1(n => atan2(y, n, rad), ...x);
926
926
 
927
927
  if (y instanceof Array && x instanceof Array)
928
928
  return y.map((v, i) => atan2(v, x[i], rad));
@@ -1159,7 +1159,7 @@ class Matrix{
1159
1159
  return new Matrix(this.rows, this.cols, this.arr.flat(1));
1160
1160
  }
1161
1161
  toComplex(){
1162
- this.arr = mapfun(
1162
+ this.arr = mapfun$1(
1163
1163
  x => x?.isComplex?.() ? x : new Complex(x, 0),
1164
1164
  ...this.arr
1165
1165
  );
@@ -1623,7 +1623,7 @@ class Matrix{
1623
1623
  return new Matrix(v.length, 1, v);
1624
1624
  }
1625
1625
  serialize() {
1626
- const arr = mapfun(x => x.serialize?.() || x, ...this.arr);
1626
+ const arr = mapfun$1(x => x.serialize?.() || x, ...this.arr);
1627
1627
  return JSON.stringify({
1628
1628
  type : 'matrix',
1629
1629
  data : {
@@ -1638,7 +1638,7 @@ class Matrix{
1638
1638
  const {type, data} = json;
1639
1639
  if(type !== 'matrix') return TypeError('Not a valid Matrix')
1640
1640
  let {arr} = data;
1641
- arr = mapfun(x => {
1641
+ arr = mapfun$1(x => {
1642
1642
  if(typeof x === 'string') {
1643
1643
  const x_obj = JSON.parse(x);
1644
1644
  const {type} = x_obj;
@@ -1669,186 +1669,6 @@ const matrix2=(...element)=>new Matrix(2, 2, element);
1669
1669
  const matrix3=(...element)=>new Matrix(3, 3, element);
1670
1670
  const matrix4=(...element)=>new Matrix(4, 4, element);
1671
1671
 
1672
- const zeros=(n)=>new Array(n).fill(0);
1673
- const ones=(n)=>new Array(n).fill(1);
1674
- const nums=(num,n)=>new Array(n).fill(num);
1675
-
1676
- const arange=(a, b, step , include = false)=>{
1677
- let tab = [];
1678
- if(a<b){
1679
- for (let i = a; include?i<=b:i<b; i += step) tab.push((i * 10) / 10);
1680
- }
1681
- else {
1682
- for(let i = a; include?i>=b:i>b; i -= step) tab.push((i * 10) / 10);
1683
- }
1684
- return tab;
1685
- };
1686
- const linspace=(a,b,n=abs(b-a)+1,endpoint=true)=>{
1687
- if(Math.floor(n)!==n)return;
1688
- if([a,b].every(n=>typeof n==="number")){
1689
- const [max,min]=[a,b].sort((a,b)=>b-a);
1690
- var Y = [];
1691
- let step ;
1692
- endpoint ? step = (max - min) / (n - 1) : step = (max - min) / n;
1693
- for (var i = 0; i < n; i++) {
1694
- a<b?Y.push(min+step*i):Y.push(max-step*i);
1695
- }
1696
- return Y
1697
- }
1698
-
1699
- if([a,b].some(n=>n.isComplex?.())){
1700
- const z1 = new n.constructor(a);
1701
- const z2 = new n.constructor(b);
1702
- n=n||Math.abs(z1.a-z2.a)+1;
1703
- const X=linspace(z1.a,z2.a,n,endpoint);
1704
- const Y=linspace(z1.b,z2.b,n,endpoint);
1705
- let Z=new Array(n).fill(null);
1706
- Z=Z.map((n,i)=> new n.constructor(X[i],Y[i]));
1707
- return Z;
1708
- }
1709
- };
1710
- const logspace=(a,b,n=b-a+1,base=E,endpoint=true)=>{
1711
- return linspace(a,b,n,endpoint).map(n=>pow$1(base,n))
1712
- };
1713
- const geomspace=(a,b,n=abs(b-a)+1,endpoint=true)=>{
1714
- if(Math.floor(n)!==n)return;
1715
- if([a,b].every(n=>typeof n==="number")){
1716
- const [max,min]=[a,b].sort((a,b)=>b-a);
1717
- let base;
1718
- endpoint ? base = nthr(max/min,n-1) : base = nthr(max/min,n) ;
1719
- const Y = [min];
1720
- for (let i = 1; i < n; i++) {
1721
- Y.push(Y[i-1]*base);
1722
- }
1723
- return a<b?Y:Y.reverse()
1724
- }
1725
-
1726
- if([a,b].some(n=>n.isComplex?.())){
1727
- const z1 = new n.constructor(a);
1728
- const z2 = new n.constructor(b);
1729
- n=n||Math.abs(z1.a-z2.a)+1;
1730
- let base;
1731
- endpoint ? base = nthr(z2.div(z1),n-1) : base = nthr(z2.div(z1),n) ;
1732
- const Y = [z1];
1733
- for (let i = 1; i < n; i++) {
1734
- Y.push(mul(Y[i-1],base));
1735
- }
1736
- return Y;
1737
- }
1738
- };
1739
-
1740
- /** @module Math */
1741
- /**
1742
- * Checks if a value is within the specified range.
1743
- * @function
1744
- * @param {number} x - The value to check.
1745
- * @param {number} a - The start of the range.
1746
- * @param {number} b - The end of the range.
1747
- * @returns {boolean} Returns true if the value is within the range [a, b], otherwise false.
1748
- */
1749
- const inRange = (x, a, b) => {
1750
- const [min, max] = [Math.min(a, b), Math.max(a, b)];
1751
- return x >= min && x <= max;
1752
- };
1753
-
1754
- /**
1755
- * Checks if two numbers are approximately equal within a given error margin.
1756
- * @param {number} a - The first number.
1757
- * @param {number} b - The second number.
1758
- * @param {number} [Err=0.0001] - The maximum acceptable difference between the two numbers.
1759
- * @returns {boolean} Returns true if the two numbers are approximately equal within the specified error margin, otherwise false.
1760
- */
1761
- const isApproximatlyEqual = (a, b, Err = 0.0001) => {
1762
- return Math.abs(a - b) <= Err;
1763
- };
1764
-
1765
- /** @module Math */
1766
-
1767
- /**
1768
- * Computes the cartesian product of two arrays.
1769
- * @param {Array} a - The first array.
1770
- * @param {Array} b - The second array.
1771
- * @returns {Array} Returns an array representing the cartesian product of the input arrays.
1772
- */
1773
- const cartesianProduct = (a, b) => a.reduce((p, x) => [...p, ...b.map((y) => [x, y])], []);
1774
-
1775
- /**
1776
- * Computes the greatest common divisor (GCD) of two numbers.
1777
- * @param {number} n1 - The first number.
1778
- * @param {number} n2 - The second number.
1779
- * @returns {number} Returns the greatest common divisor of the two input numbers.
1780
- */
1781
- const pgcd = (n1, n2) => {
1782
- let i,
1783
- pgcd = 1;
1784
- if (n1 == floor(n1) && n2 == floor(n2)) {
1785
- for (i = 2; i <= n1 && i <= n2; ++i) {
1786
- if (n1 % i == 0 && n2 % i == 0) pgcd = i;
1787
- }
1788
- return pgcd;
1789
- } else console.log("error");
1790
- };
1791
-
1792
- /**
1793
- * Computes the least common multiple (LCM) of two numbers.
1794
- * @param {number} n1 - The first number.
1795
- * @param {number} n2 - The second number.
1796
- * @returns {number} Returns the least common multiple of the two input numbers.
1797
- */
1798
- const ppcm = (n1, n2) => {
1799
- let ppcm;
1800
- if (n1 == floor(n1) && n2 == floor(n2)) {
1801
- ppcm = n1 > n2 ? n1 : n2;
1802
- while (true) {
1803
- if (ppcm % n1 == 0 && ppcm % n2 == 0) break;
1804
- ++ppcm;
1805
- }
1806
- return ppcm;
1807
- } else console.log("error");
1808
- };
1809
-
1810
- // import { mapfun } from "../mapfun/index.js";
1811
- // import {
1812
- // add,
1813
- // sub,
1814
- // mul,
1815
- // div,
1816
- // modulo
1817
- // } from "./arithmetic.js";
1818
- const Utils={
1819
- // add,
1820
- // sub,
1821
- // mul,
1822
- // div,
1823
- // modulo,
1824
-
1825
- zeros,
1826
- ones,
1827
- nums,
1828
- // norm,
1829
- // lerp,
1830
- // map,
1831
- // clamp,
1832
- arange,
1833
- linspace,
1834
- logspace,
1835
- geomspace,
1836
-
1837
- // sum,
1838
- // prod,
1839
- // accum,
1840
-
1841
- cartesianProduct,
1842
- ppcm,
1843
- pgcd,
1844
-
1845
- // deg2rad,
1846
- // rad2deg,
1847
-
1848
- inRange,
1849
- isApproximatlyEqual
1850
- };
1851
-
1852
1672
  class UINode {
1853
1673
  constructor(node){
1854
1674
  this.cache = {
@@ -4316,110 +4136,6 @@ const svg2ascii=svg=>btoa(svg2str(svg));
4316
4136
  const svg2imgUrl=svg=>'data:image/svg+xml;base64,'+svg2ascii(svg);
4317
4137
  const svg2img=(svg,render=true)=>tags.img(svg2imgUrl(svg)).mount(render);
4318
4138
 
4319
- // const obj2str=(object)=>{
4320
- // const recursiveToString = (obj) => {
4321
- // if (Array.isArray(obj)) return arr2str(obj);
4322
- // if (typeof obj === 'object' && obj !== null) {
4323
- // return `{ ${Object.entries(obj)
4324
- // .map(([key, value]) => `${key}:${recursiveToString(value)}`)
4325
- // .join(" , ")} }`;
4326
- // }
4327
- // return String(obj);
4328
- // };
4329
- // return recursiveToString(object);
4330
- // };
4331
- // const obj2str = (object) => {
4332
- // const recursiveToString = (obj, indentLevel = 0) => {
4333
- // const indent = ' '.repeat(indentLevel);
4334
- // const nextIndent = ' '.repeat(indentLevel + 1);
4335
- // if(Array.isArray(obj)) return arr2str(obj, indentLevel);
4336
- // if(obj instanceof Complex || obj instanceof Matrix) return obj.toString();
4337
- // if (typeof obj === 'object' && obj !== null) {
4338
- // const entries = Object.entries(obj)
4339
- // .map(([key, value]) => `${nextIndent}${key}: ${recursiveToString(value, indentLevel + 1)}`)
4340
- // .join(",\n");
4341
-
4342
- // return `{\n${entries}\n${indent}}`;
4343
- // }
4344
-
4345
- // return String(obj);
4346
- // };
4347
-
4348
- // return recursiveToString(object);
4349
- // };
4350
- // const obj2str = (object, useIndentation = true, indentLevel = 0) => {
4351
- // const recursiveToString = (obj, level = 0) => {
4352
- // const indent = useIndentation ? ' '.repeat(level) : '';
4353
- // const nextIndent = useIndentation ? ' '.repeat(level + 1) : '';
4354
- // if (Array.isArray(obj)) return arr2str(obj, false, level);
4355
- // if(obj instanceof Complex || obj instanceof Matrix) return obj.toString();
4356
- // if (typeof obj === 'object' && obj !== null) {
4357
- // const entries = Object.entries(obj)
4358
- // .map(([key, value]) => useIndentation
4359
- // ? `${nextIndent}${key}: ${recursiveToString(value, level + 1)}`
4360
- // : `${key}: ${recursiveToString(value, level + 1)}`
4361
- // ).join(useIndentation ? ",\n" : ", ");
4362
-
4363
- // return useIndentation
4364
- // ? `{\n${entries}\n${indent}}`
4365
- // : `{${entries}}`;
4366
- // }
4367
-
4368
- // return String(obj);
4369
- // };
4370
-
4371
- // return recursiveToString(object, indentLevel);
4372
- // };
4373
-
4374
- const obj2str=(obj)=>JSON.stringify(
4375
- mapfun(n=>{
4376
- if(["number","string","boolean","bigint"].includes(typeof n)) return String(n);
4377
- if(n instanceof Complex || n instanceof Matrix) return n.toString();
4378
- if(n instanceof Array) return arr2str(n)
4379
- },
4380
- obj), null, " ")
4381
- .replace(/"([^"]+)":/g, '$1:') // Remove Quotes from Keys
4382
- .replace(/: "([^"]+)"/g, ': $1'); // Remove Quotes from str values
4383
-
4384
- const getMaxDepth = arr=> {
4385
- if (!Array.isArray(arr)) return 0;
4386
- let maxDepth = 1;
4387
- for (const element of arr) {
4388
- if (Array.isArray(element)) {
4389
- const depth = getMaxDepth(element);
4390
- if (depth + 1 > maxDepth) {
4391
- maxDepth = depth + 1;
4392
- }
4393
- }
4394
- }
4395
- return maxDepth;
4396
- };
4397
- const arr2str = (arr) => {
4398
- let level = 0;
4399
- function arrStringify(arr) {
4400
- let max = getMaxDepth(arr);
4401
- let useIdentation = 0;
4402
- if (arr.some((n) => Array.isArray(n))) {
4403
- level++;
4404
- useIdentation = 1;
4405
- }
4406
- return (
4407
- "[" +
4408
- arr.map((n, i) => {
4409
- if (["number", "string", "boolean", "bigint"].includes(typeof n))
4410
- return String(n);
4411
- if (n instanceof Complex) return n.toString();
4412
- if (n instanceof Array) {
4413
- return `\n${" ".repeat(level)}${arrStringify(n)}${i === arr.length - 1 ? "\n" : ""}`;
4414
- }
4415
- if( n instanceof Object) return obj2str(n);
4416
- })
4417
- + `${" ".repeat((max+level+1) * useIdentation)}]`
4418
- );
4419
- }
4420
- return arrStringify(arr);
4421
- };
4422
-
4423
4139
  const json2css=(json, indentLevel = 0)=>{
4424
4140
  json = trimKeys(json);
4425
4141
  let cssText = '';
@@ -4692,6 +4408,49 @@ function useDerived(deriveFn, sources) {
4692
4408
  })
4693
4409
  }
4694
4410
 
4411
+ const mapfun=(fun,...X)=>{
4412
+ const Y=X.map(x=>{
4413
+ if(
4414
+ x===null||
4415
+ ["number","string","boolean","bigint","undefined"].includes(typeof x)||
4416
+ x?.__mapfun__
4417
+ ) return fun(x)
4418
+ if(x instanceof Array) return x.map(n=>mapfun(fun,n));
4419
+ if(ArrayBuffer.isView(x)) return x.map(n=>fun(n));
4420
+ if(x instanceof Set) return new Set(mapfun(fun,...[...x]));
4421
+ if(x instanceof Map) return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
4422
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, mapfun(x.arr.flat(1)))
4423
+ // if(x.isComplex?.()){
4424
+ // const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
4425
+ // switch(fun){
4426
+ // // Moved to Fixed to avoid Circular Dep
4427
+ // // case Math.log: return new x.constructor(ln(z),phi); // Done
4428
+ // // case Math.exp: return new x.constructor(e(a)*cos(b),e(a)*sin(b)); // Done
4429
+ // // case Math.abs: return z; // Done
4430
+ // // case Math.sqrt: return new x.constructor(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2)); // Done
4431
+ // // case Fixed.cos: return new x.constructor(cos(a)*cosh(b),-(sin(a)*sinh(b)));
4432
+ // // case Fixed.sin: return new x.constructor(sin(a)*cosh(b),cos(a)*sinh(b));
4433
+ // // case Fixed.tan:{
4434
+ // // const DEN = cos(2*a)+cosh(2*b);
4435
+ // // return new x.constructor(sin(2*a)/DEN,sinh(2*b)/DEN);
4436
+ // // }
4437
+ // // case Fixed.cosh:return new x.constructor(cosh(a)*cos(b),sinh(a)*sin(b));
4438
+ // // case Fixed.sinh:return new x.constructor(sinh(a)*cos(b),cosh(a)*sin(b));
4439
+ // // case Fixed.tanh:{
4440
+ // // const DEN=cosh(2*a)+cos(2*b);
4441
+ // // return new x.constructor(sinh(2*a)/DEN,sin(2*b)/DEN)
4442
+ // // }
4443
+ // default : return fun(x)
4444
+ // }
4445
+ // }
4446
+ else if(x instanceof Object){
4447
+ return Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
4448
+ // return fun(Object) || Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
4449
+ }
4450
+ });
4451
+ return Y.length==1? Y[0]: Y;
4452
+ };
4453
+
4695
4454
  const useReactive = (nested_value) => mapfun(
4696
4455
  n => {
4697
4456
  const state = useState(n);
@@ -5125,4 +4884,4 @@ if(globalThis?.document){
5125
4884
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5126
4885
  }
5127
4886
 
5128
- export { App, ClickAwayEvent, ClickListeners, Clock, CloneElement, Complex, E, EPSILON, EventController, FileBasedRouting, Flex, HTMLWrapper, KeyListeners, Matrix, PI$1 as PI, PtrListeners, Random, SPA, SVGWrapper, Scheduler, Suspense, SwipeEvent, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIFlex, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, UseThread, Utils, View, ViewEvent, ViewListeners, ZikoApp, ZikoSPA, ZikoUISuspense, ZikoUIText, abs, accum_prod, accum_sum, acos$1 as acos, acosh, acot, add, add_class, add_vendor_prefix, and, animation, apply_fun, arange, arc, arr2str, asin, asinh, atan, atan2, atanh, back, binomial, call_with_optional_props, cartesianProduct, cbrt, ceil, clamp, clock, cloneUI, complex, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, exp$1 as exp, floor, fract, geomspace, hypot, inRange, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, isApproximatlyEqual, isPrimitive, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linkStyle, linspace, ln, logspace, loop, map$1 as map, mapfun, matrix, matrix2, matrix3, matrix4, max, mean, median, min, modulo, mul, nand, nor, norm, normalize_css_value, nthr, nums, obj2str, ones, or, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, percentile, pgcd, pow$1 as pow, ppcm, rad2deg, register_click_away_event, register_swipe_event, register_view_event, remove_class, round, script, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sqrt$2 as sqrt, std, step, step_fps, style, sub, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, trunc, useDerived, useEventEmitter, useIPC, useLocaleStorage, useMediaQuery, useQueryParams, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitElm, waitForUIElm, waitForUIElmSync, watchQueryParams, xnor, xor, zeros };
4887
+ export { App, ClickAwayEvent, ClickListeners, Clock, CloneElement, Complex, E, EPSILON, EventController, FileBasedRouting, Flex, HTMLWrapper, KeyListeners, Matrix, PI$1 as PI, PtrListeners, Random, SPA, SVGWrapper, Scheduler, Suspense, SwipeEvent, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIFlex, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, UseThread, View, ViewEvent, ViewListeners, ZikoApp, ZikoSPA, ZikoUISuspense, ZikoUIText, abs, accum_prod, accum_sum, acos$1 as acos, acosh, acot, add, add_class, add_vendor_prefix, and, animation, apply_fun, arc, asin, asinh, atan, atan2, atanh, back, binomial, call_with_optional_props, cbrt, ceil, clamp, clock, cloneUI, complex, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, exp$1 as exp, floor, fract, hypot, in_back, in_bounce, in_circ, in_cubic, in_elastic, in_expo, in_out_back, in_out_bounce, in_out_circ, in_out_cubic, in_out_elastic, in_out_expo, in_out_quad, in_out_quart, in_out_quint, in_out_sin, in_quad, in_quart, in_quint, in_sin, isPrimitive, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linkStyle, ln, loop, map$1 as map, mapfun$1 as mapfun, matrix, matrix2, matrix3, matrix4, max, mean, median, min, modulo, mul, nand, nor, norm, normalize_css_value, nthr, or, out_back, out_bounce, out_circ, out_cubic, out_elastic, out_expo, out_quad, out_quart, out_quint, out_sin, percentile, pow$1 as pow, rad2deg, register_click_away_event, register_swipe_event, register_view_event, remove_class, round, script, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sqrt$2 as sqrt, std, step, step_fps, style, sub, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, trunc, useDerived, useEventEmitter, useIPC, useLocaleStorage, useMediaQuery, useQueryParams, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitElm, waitForUIElm, waitForUIElmSync, watchQueryParams, xnor, xor };