ziko 0.54.3 → 0.54.5

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.js CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Fri Dec 12 2025 14:53:26 GMT+0100 (UTC+01:00)
5
+ Date : Fri Dec 12 2025 17:18:59 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
@@ -131,7 +131,7 @@
131
131
  static Zero() {
132
132
  return new Complex(0, 0);
133
133
  }
134
- static Twidlle(N, K){
134
+ static Twiddle(N, K){
135
135
  const phi = -2 * Math.PI * K / N;
136
136
  return new Complex(
137
137
  Math.cos(phi),
@@ -864,6 +864,60 @@
864
864
 
865
865
  const median = X => percentile(X, 50);
866
866
 
867
+ const not = x => {
868
+ if(x.isComplex?.()) return new x.constructor(not(x.a), not(x.b))
869
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, x.arr.flat(1).map(not))
870
+ return + !x;
871
+ };
872
+ const handle_complex_and_matrix = (x, operation) => {
873
+ if (x.every(n => n.isComplex?.())) {
874
+ const Re = x.map(n => n.a);
875
+ const Im = x.map(n => n.b);
876
+ return new x[0].constructor(
877
+ operation(...Re),
878
+ operation(...Im)
879
+ );
880
+ }
881
+
882
+ if (x.every(n => n.isMatrix?.())) {
883
+ if (!x.every(mat => mat.rows === x[0].rows && mat.cols === x[0].cols)) {
884
+ return TypeError('All matrices must have the same shape');
885
+ }
886
+
887
+ const { rows, cols } = x[0];
888
+ const Y = Array.from({ length: rows }, (_, i) =>
889
+ Array.from({ length: cols }, (_, j) =>
890
+ operation(...x.map(mat => mat.arr[i][j]))
891
+ )
892
+ );
893
+ return new x[0].constructor(Y);
894
+ }
895
+
896
+ return null; // Return null if no Complex or Matrix found
897
+ };
898
+
899
+ const and = (...x) => {
900
+ const result = handle_complex_and_matrix(x, and);
901
+ if (result !== null) return result;
902
+ return x.reduce((n, m) => (n &= m), 1);
903
+ };
904
+
905
+ const or = (...x) => {
906
+ const result = handle_complex_and_matrix(x, or);
907
+ if (result !== null) return result;
908
+ return x.reduce((n, m) => (n |= m), 0);
909
+ };
910
+
911
+ const xor = (...x) => {
912
+ const result = handle_complex_and_matrix(x, xor);
913
+ if (result !== null) return result;
914
+ return x.reduce((n, m) => (n ^= m), 0);
915
+ };
916
+
917
+ const nand = (...x) => not(and(...x));
918
+ const nor = (...x) => not(or(...x));
919
+ const xnor = (...x) => not(xor(...x));
920
+
867
921
  const preload=(url)=>{
868
922
  const xhr = new XMLHttpRequest();
869
923
  xhr.open("GET", url, false);
@@ -4321,50 +4375,6 @@
4321
4375
  }
4322
4376
  };
4323
4377
 
4324
- const Logic$1={
4325
- _mode:Number,
4326
- _map:function(func,a,b){
4327
- if (a instanceof Matrix)
4328
- return new Matrix(
4329
- a.rows,
4330
- a.cols,
4331
- a.arr.flat(1).map((n) => func(n, b))
4332
- );
4333
- else if (a instanceof Complex) return new Complex(func(a.a, b), func(a.b, b));
4334
- else if (a instanceof Array) return a.map((n) => func(n, b));
4335
- },
4336
- not:function(input){
4337
- if(["number","boolean"].includes(typeof input)) return Logic$1._mode(!input);
4338
- else return this._map(this.not,input)
4339
- },
4340
- and:function(a, ...b){
4341
- if(["number","boolean"].includes(typeof a))return Logic$1._mode(b.reduce((n, m) => (n &= m), a));
4342
- else return this._map(this.and,a,b)
4343
- },
4344
- or:function(a, ...b) {
4345
- if(["number","boolean"].includes(typeof a)) return Logic$1._mode(b.reduce((n, m) => (n |= m), a));
4346
- else return this._map(this.or,a,b);
4347
- },
4348
- nand:function(a, ...b) {
4349
- return this.not(this.and(a, b));
4350
- },
4351
- nor:function(a, ...b) {
4352
- return this.not(this.or(a, b));
4353
- },
4354
- xor:function(a,...b){
4355
- let arr=[a,...b];
4356
- if(["number","boolean"].includes(typeof a))return this._mode(arr.reduce((length,cur)=>{
4357
- if(+cur===1)length+=1;
4358
- return length;
4359
- },0)===1);
4360
- else return this._map(this.xor,a,b);
4361
- },
4362
- xnor:function(a,...b){
4363
- return Logic$1.not(Logic$1.xor(a,b))
4364
- }
4365
-
4366
- };
4367
-
4368
4378
  class Permutation {
4369
4379
  static withDiscount(arr, l = arr.length) {
4370
4380
  if (l === 1) return arr.map((n) => [n]);
@@ -5759,7 +5769,6 @@
5759
5769
  exports.FileBasedRouting = FileBasedRouting;
5760
5770
  exports.Flex = Flex;
5761
5771
  exports.HTMLWrapper = HTMLWrapper;
5762
- exports.Logic = Logic$1;
5763
5772
  exports.Matrix = Matrix;
5764
5773
  exports.PI = PI$1;
5765
5774
  exports.Permutation = Permutation;
@@ -5797,6 +5806,7 @@
5797
5806
  exports.acosh = acosh;
5798
5807
  exports.acot = acot;
5799
5808
  exports.add = add;
5809
+ exports.and = and;
5800
5810
  exports.animation = animation;
5801
5811
  exports.apply_fun = apply_fun;
5802
5812
  exports.arange = arange;
@@ -5898,11 +5908,14 @@
5898
5908
  exports.min = min$1;
5899
5909
  exports.modulo = modulo;
5900
5910
  exports.mul = mul;
5911
+ exports.nand = nand;
5912
+ exports.nor = nor;
5901
5913
  exports.norm = norm;
5902
5914
  exports.nthr = nthr;
5903
5915
  exports.nums = nums;
5904
5916
  exports.obj2str = obj2str;
5905
5917
  exports.ones = ones;
5918
+ exports.or = or;
5906
5919
  exports.out_back = out_back;
5907
5920
  exports.out_bounce = out_bounce;
5908
5921
  exports.out_circ = out_circ;
@@ -5965,6 +5978,8 @@
5965
5978
  exports.wait = wait;
5966
5979
  exports.waitForUIElm = waitForUIElm;
5967
5980
  exports.waitForUIElmSync = waitForUIElmSync;
5981
+ exports.xnor = xnor;
5982
+ exports.xor = xor;
5968
5983
  exports.zeros = zeros;
5969
5984
 
5970
5985
  }));
package/dist/ziko.mjs CHANGED
@@ -2,7 +2,7 @@
2
2
  /*
3
3
  Project: ziko.js
4
4
  Author: Zakaria Elalaoui
5
- Date : Fri Dec 12 2025 14:53:26 GMT+0100 (UTC+01:00)
5
+ Date : Fri Dec 12 2025 17:18:59 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
@@ -125,7 +125,7 @@ class Complex{
125
125
  static Zero() {
126
126
  return new Complex(0, 0);
127
127
  }
128
- static Twidlle(N, K){
128
+ static Twiddle(N, K){
129
129
  const phi = -2 * Math.PI * K / N;
130
130
  return new Complex(
131
131
  Math.cos(phi),
@@ -858,6 +858,60 @@ const percentile = (X, p) => {
858
858
 
859
859
  const median = X => percentile(X, 50);
860
860
 
861
+ const not = x => {
862
+ if(x.isComplex?.()) return new x.constructor(not(x.a), not(x.b))
863
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, x.arr.flat(1).map(not))
864
+ return + !x;
865
+ };
866
+ const handle_complex_and_matrix = (x, operation) => {
867
+ if (x.every(n => n.isComplex?.())) {
868
+ const Re = x.map(n => n.a);
869
+ const Im = x.map(n => n.b);
870
+ return new x[0].constructor(
871
+ operation(...Re),
872
+ operation(...Im)
873
+ );
874
+ }
875
+
876
+ if (x.every(n => n.isMatrix?.())) {
877
+ if (!x.every(mat => mat.rows === x[0].rows && mat.cols === x[0].cols)) {
878
+ return TypeError('All matrices must have the same shape');
879
+ }
880
+
881
+ const { rows, cols } = x[0];
882
+ const Y = Array.from({ length: rows }, (_, i) =>
883
+ Array.from({ length: cols }, (_, j) =>
884
+ operation(...x.map(mat => mat.arr[i][j]))
885
+ )
886
+ );
887
+ return new x[0].constructor(Y);
888
+ }
889
+
890
+ return null; // Return null if no Complex or Matrix found
891
+ };
892
+
893
+ const and = (...x) => {
894
+ const result = handle_complex_and_matrix(x, and);
895
+ if (result !== null) return result;
896
+ return x.reduce((n, m) => (n &= m), 1);
897
+ };
898
+
899
+ const or = (...x) => {
900
+ const result = handle_complex_and_matrix(x, or);
901
+ if (result !== null) return result;
902
+ return x.reduce((n, m) => (n |= m), 0);
903
+ };
904
+
905
+ const xor = (...x) => {
906
+ const result = handle_complex_and_matrix(x, xor);
907
+ if (result !== null) return result;
908
+ return x.reduce((n, m) => (n ^= m), 0);
909
+ };
910
+
911
+ const nand = (...x) => not(and(...x));
912
+ const nor = (...x) => not(or(...x));
913
+ const xnor = (...x) => not(xor(...x));
914
+
861
915
  const preload=(url)=>{
862
916
  const xhr = new XMLHttpRequest();
863
917
  xhr.open("GET", url, false);
@@ -4315,50 +4369,6 @@ const Base={
4315
4369
  }
4316
4370
  };
4317
4371
 
4318
- const Logic$1={
4319
- _mode:Number,
4320
- _map:function(func,a,b){
4321
- if (a instanceof Matrix)
4322
- return new Matrix(
4323
- a.rows,
4324
- a.cols,
4325
- a.arr.flat(1).map((n) => func(n, b))
4326
- );
4327
- else if (a instanceof Complex) return new Complex(func(a.a, b), func(a.b, b));
4328
- else if (a instanceof Array) return a.map((n) => func(n, b));
4329
- },
4330
- not:function(input){
4331
- if(["number","boolean"].includes(typeof input)) return Logic$1._mode(!input);
4332
- else return this._map(this.not,input)
4333
- },
4334
- and:function(a, ...b){
4335
- if(["number","boolean"].includes(typeof a))return Logic$1._mode(b.reduce((n, m) => (n &= m), a));
4336
- else return this._map(this.and,a,b)
4337
- },
4338
- or:function(a, ...b) {
4339
- if(["number","boolean"].includes(typeof a)) return Logic$1._mode(b.reduce((n, m) => (n |= m), a));
4340
- else return this._map(this.or,a,b);
4341
- },
4342
- nand:function(a, ...b) {
4343
- return this.not(this.and(a, b));
4344
- },
4345
- nor:function(a, ...b) {
4346
- return this.not(this.or(a, b));
4347
- },
4348
- xor:function(a,...b){
4349
- let arr=[a,...b];
4350
- if(["number","boolean"].includes(typeof a))return this._mode(arr.reduce((length,cur)=>{
4351
- if(+cur===1)length+=1;
4352
- return length;
4353
- },0)===1);
4354
- else return this._map(this.xor,a,b);
4355
- },
4356
- xnor:function(a,...b){
4357
- return Logic$1.not(Logic$1.xor(a,b))
4358
- }
4359
-
4360
- };
4361
-
4362
4372
  class Permutation {
4363
4373
  static withDiscount(arr, l = arr.length) {
4364
4374
  if (l === 1) return arr.map((n) => [n]);
@@ -5743,4 +5753,4 @@ if(globalThis?.document){
5743
5753
  document?.addEventListener("DOMContentLoaded", __Ziko__.__Config__.init());
5744
5754
  }
5745
5755
 
5746
- export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Logic$1 as Logic, Matrix, PI$1 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, UseThread, Utils, View, ZikoApp, ZikoEvent, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, abs, accum, accum_prod, accum_sum, acos$1 as acos, acosh, acot, add, animation, apply_fun, arange, arc, arr2str, asin, asinh, atan, atan2, atanh, back, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_swipe_event, bind_touch_event, bind_view_event, bind_wheel_event, cartesianProduct, cbrt, ceil, clamp, clock, combinaison, complex, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, event_controller, exp$1 as exp, floor, fract, geomspace, getEvent, 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, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linspace, ln, logspace, loop, map$1 as map, mapfun, matrix, matrix2, matrix3, matrix4, max$1 as max, mean, median, min$1 as min, modulo, mul, norm, nthr, nums, obj2str, ones, 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, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sqrt$2 as sqrt, std, step, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, toggle_event_listener, trunc, useDerived, useEventEmitter, useIPC, useLocaleStorage, useMediaQuery, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitForUIElm, waitForUIElmSync, zeros };
5756
+ export { App, Base, Clock, Combinaison, Complex, E, EPSILON, FileBasedRouting, Flex, HTMLWrapper, Matrix, PI$1 as PI, Permutation, Random, SPA, SVGWrapper, Scheduler, Suspense, Switch, Tick, TimeAnimation, TimeLoop, TimeScheduler, UIElement$1 as UIElement, UIHTMLWrapper, UINode, UISVGWrapper, UISwitch, UIView, UseRoot, UseThread, Utils, View, ZikoApp, ZikoEvent, ZikoSPA, ZikoUIFlex, ZikoUISuspense, ZikoUIText, abs, accum, accum_prod, accum_sum, acos$1 as acos, acosh, acot, add, and, animation, apply_fun, arange, arc, arr2str, asin, asinh, atan, atan2, atanh, back, bind_click_event, bind_clipboard_event, bind_drag_event, bind_focus_event, bind_key_event, bind_mouse_event, bind_pointer_event, bind_swipe_event, bind_touch_event, bind_view_event, bind_wheel_event, cartesianProduct, cbrt, ceil, clamp, clock, combinaison, complex, cos$3 as cos, cosh$2 as cosh, coth, croot, csv2arr, csv2json, csv2matrix, csv2object, csv2sql, debounce, defineParamsGetter, define_wc, deg2rad, discret, div, elastic, event_controller, exp$1 as exp, floor, fract, geomspace, getEvent, 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, isStateGetter, json2arr, json2css, json2csv, json2csvFile, json2xml, json2xmlFile, json2yml, json2ymlFile, lerp, linear, linspace, ln, logspace, loop, map$1 as map, mapfun, matrix, matrix2, matrix3, matrix4, max$1 as max, mean, median, min$1 as min, modulo, mul, nand, nor, norm, 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, powerSet, ppcm, preload, prod, rad2deg, round, sec, sig, sign, sin$3 as sin, sinh$1 as sinh, sleep, sqrt$2 as sqrt, std, step, step_fps, sub, subSet, sum, svg2ascii, svg2img, svg2imgUrl, svg2str, tags, tan, tanh, text, throttle, tick, timeTaken, time_memory_Taken, timeout, toggle_event_listener, trunc, useDerived, useEventEmitter, useIPC, useLocaleStorage, useMediaQuery, useReactive, useRoot, useSessionStorage, useState, useThread, useTitle, variance, wait, waitForUIElm, waitForUIElmSync, xnor, xor, zeros };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ziko",
3
- "version": "0.54.3",
3
+ "version": "0.54.5",
4
4
  "description": "A versatile JavaScript library offering a rich set of Hyperscript Based UI components, advanced mathematical utilities, interactivity ,animations, client side routing and more ...",
5
5
  "keywords": [
6
6
  "front-end",
@@ -77,7 +77,7 @@ class Complex{
77
77
  static Zero() {
78
78
  return new Complex(0, 0);
79
79
  }
80
- static Twidlle(N, K){
80
+ static Twiddle(N, K){
81
81
  const phi = -2 * Math.PI * K / N;
82
82
  return new Complex(
83
83
  Math.cos(phi),
@@ -1,6 +1,5 @@
1
1
  import { powerSet , subSet } from "./Set/index.js";
2
2
  import { Base } from "./Conversion/index.js";
3
- import { Logic } from "./Logic/index.js";
4
3
  import {
5
4
  Permutation,
6
5
  } from "./Permutation/index.js"
@@ -9,4 +8,5 @@ import {
9
8
  combinaison,
10
9
  } from "./Combinaison/index.js"
11
10
 
12
- export{Logic,Base,Permutation,Combinaison,combinaison,powerSet,subSet}
11
+ export{
12
+ Base,Permutation,Combinaison,combinaison,powerSet,subSet}
@@ -3,6 +3,7 @@ export * from './nested/index.js'
3
3
  export * from './arithmetic/index.js'
4
4
  export * from './utils/index.js'
5
5
  export * from './stats/index.js'
6
+ export * from './logic/index.js'
6
7
  // export const atan2=(x,y,rad=true)=>{
7
8
  // if(typeof x === "number"){
8
9
  // if(typeof y === "number")return rad?Math.atan2(x,y):Math.atan2(x,y)*180/Math.PI;
@@ -0,0 +1,54 @@
1
+ const not = x => {
2
+ if(x.isComplex?.()) return new x.constructor(not(x.a), not(x.b))
3
+ if(x.isMatrix?.()) return new x.constructor(x.rows, x.cols, x.arr.flat(1).map(not))
4
+ return + !x;
5
+ }
6
+ const handle_complex_and_matrix = (x, operation) => {
7
+ if (x.every(n => n.isComplex?.())) {
8
+ const Re = x.map(n => n.a);
9
+ const Im = x.map(n => n.b);
10
+ return new x[0].constructor(
11
+ operation(...Re),
12
+ operation(...Im)
13
+ );
14
+ }
15
+
16
+ if (x.every(n => n.isMatrix?.())) {
17
+ if (!x.every(mat => mat.rows === x[0].rows && mat.cols === x[0].cols)) {
18
+ return TypeError('All matrices must have the same shape');
19
+ }
20
+
21
+ const { rows, cols } = x[0];
22
+ const Y = Array.from({ length: rows }, (_, i) =>
23
+ Array.from({ length: cols }, (_, j) =>
24
+ operation(...x.map(mat => mat.arr[i][j]))
25
+ )
26
+ );
27
+ return new x[0].constructor(Y);
28
+ }
29
+
30
+ return null; // Return null if no Complex or Matrix found
31
+ };
32
+
33
+ export const and = (...x) => {
34
+ const result = handle_complex_and_matrix(x, and);
35
+ if (result !== null) return result;
36
+ return x.reduce((n, m) => (n &= m), 1);
37
+ };
38
+
39
+ export const or = (...x) => {
40
+ const result = handle_complex_and_matrix(x, or);
41
+ if (result !== null) return result;
42
+ return x.reduce((n, m) => (n |= m), 0);
43
+ };
44
+
45
+ export const xor = (...x) => {
46
+ const result = handle_complex_and_matrix(x, xor);
47
+ if (result !== null) return result;
48
+ return x.reduce((n, m) => (n ^= m), 0);
49
+ };
50
+
51
+ export const nand = (...x) => not(and(...x));
52
+ export const nor = (...x) => not(or(...x));
53
+ export const xnor = (...x) => not(xor(...x));
54
+
@@ -38,7 +38,7 @@ export declare class Complex {
38
38
  nrth(n?: number): Complex;
39
39
 
40
40
  static Zero(): Complex;
41
- static Twuddle(N : number, K : number): Complex;
41
+ static Twiddle(N : number, K : number): Complex;
42
42
  static fromExpo(z: number, phi: number): Complex;
43
43
  static add(c: Complex, ...z: (number | Complex)[]): Complex;
44
44
  static sub(c: Complex, ...z: (number | Complex)[]): Complex;
@@ -0,0 +1,11 @@
1
+ import type { Complex } from "../../complex/index.d.ts";
2
+ // import type { Matrix } from "../../matrix/index.d.ts";
3
+ import { Matrix } from '../../../../src/math/matrix/index.js'
4
+
5
+ export declare const not: (x: 0 | 1 | Complex | Matrix) => 0 | 1 | Complex | Matrix;
6
+ export declare const and: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
7
+ export declare const or: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
8
+ export declare const xor: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
9
+ export declare const nand: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
10
+ export declare const nor: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
11
+ export declare const xnor: (...x: (0 | 1 | Complex | Matrix)[]) => 0 | 1 | Complex | Matrix;
@@ -1,46 +0,0 @@
1
- import { Complex } from "../../complex/index.js";
2
- import { Matrix } from "../../matrix/index.js";
3
- const Logic={
4
- _mode:Number,
5
- _map:function(func,a,b){
6
- if (a instanceof Matrix)
7
- return new Matrix(
8
- a.rows,
9
- a.cols,
10
- a.arr.flat(1).map((n) => func(n, b))
11
- );
12
- else if (a instanceof Complex) return new Complex(func(a.a, b), func(a.b, b));
13
- else if (a instanceof Array) return a.map((n) => func(n, b));
14
- },
15
- not:function(input){
16
- if(["number","boolean"].includes(typeof input)) return Logic._mode(!input);
17
- else return this._map(this.not,input)
18
- },
19
- and:function(a, ...b){
20
- if(["number","boolean"].includes(typeof a))return Logic._mode(b.reduce((n, m) => (n &= m), a));
21
- else return this._map(this.and,a,b)
22
- },
23
- or:function(a, ...b) {
24
- if(["number","boolean"].includes(typeof a)) return Logic._mode(b.reduce((n, m) => (n |= m), a));
25
- else return this._map(this.or,a,b);
26
- },
27
- nand:function(a, ...b) {
28
- return this.not(this.and(a, b));
29
- },
30
- nor:function(a, ...b) {
31
- return this.not(this.or(a, b));
32
- },
33
- xor:function(a,...b){
34
- let arr=[a,...b]
35
- if(["number","boolean"].includes(typeof a))return this._mode(arr.reduce((length,cur)=>{
36
- if(+cur===1)length+=1;
37
- return length;
38
- },0)===1);
39
- else return this._map(this.xor,a,b);
40
- },
41
- xnor:function(a,...b){
42
- return Logic.not(Logic.xor(a,b))
43
- }
44
-
45
- }
46
- export{Logic}