ziko 0.0.12 → 0.0.14
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.cjs +3069 -2463
- package/dist/ziko.js +2993 -2329
- package/dist/ziko.min.js +2 -2
- package/dist/ziko.mjs +2984 -2328
- package/package.json +39 -12
- package/src/__helpers__/index.js +41 -0
- package/src/app/accessibility/index.js +0 -0
- package/src/app/app.js +46 -0
- package/src/app/component/index.js +38 -0
- package/src/app/globals/index.js +20 -0
- package/src/app/index.js +12 -0
- package/src/app/params/index.js +40 -0
- package/src/app/router/index.js +67 -0
- package/src/app/seo/index.js +43 -0
- package/src/app/themes/dark.js +885 -0
- package/src/app/themes/index.js +11 -0
- package/src/app/themes/light.js +255 -0
- package/src/data/api/fetchdom.js +14 -0
- package/src/data/api/index.js +4 -0
- package/src/data/api/preload.js +11 -0
- package/src/data/converter/adoc.js +130 -0
- package/src/data/converter/array.js +43 -0
- package/src/data/converter/canvas.js +25 -0
- package/src/data/converter/csv.js +33 -0
- package/src/data/converter/idea.txt +10 -0
- package/src/data/converter/index.js +34 -0
- package/src/data/converter/json.js +80 -0
- package/src/data/converter/markdown.js +95 -0
- package/src/data/converter/object.js +70 -0
- package/src/data/converter/svg.js +11 -0
- package/src/data/decorators.js +0 -0
- package/src/data/index.js +74 -0
- package/src/data/parser/markdown.js +0 -0
- package/src/data/parser/xml.js +47 -0
- package/src/data/string/index.js +1 -0
- package/src/data/string/patterns.js +12 -0
- package/src/data/string/string.js +170 -0
- package/src/graphics/canvas/_canvas_offscreen +0 -0
- package/src/graphics/canvas/canvas.js +189 -0
- package/src/graphics/canvas/elements/Basic/arc.js +43 -0
- package/src/graphics/canvas/elements/Basic/image.js +0 -0
- package/src/graphics/canvas/elements/Basic/line.js +26 -0
- package/src/graphics/canvas/elements/Basic/path.js +0 -0
- package/src/graphics/canvas/elements/Basic/points.js +48 -0
- package/src/graphics/canvas/elements/Basic/polygon.js +7 -0
- package/src/graphics/canvas/elements/Basic/polyline.js +0 -0
- package/src/graphics/canvas/elements/Basic/rect.js +46 -0
- package/src/graphics/canvas/elements/Basic/text.js +0 -0
- package/src/graphics/canvas/elements/Chart/histogram.js +0 -0
- package/src/graphics/canvas/elements/Chart/plot.js +0 -0
- package/src/graphics/canvas/elements/Chart/scatter.js +2 -0
- package/src/graphics/canvas/elements/Chart/stem.js +0 -0
- package/src/graphics/canvas/elements/Element.js +115 -0
- package/src/graphics/canvas/elements/Groupe.js +0 -0
- package/src/graphics/canvas/elements/grid.js +0 -0
- package/src/graphics/canvas/elements/index.js +13 -0
- package/src/graphics/canvas/filter/index.js +0 -0
- package/src/graphics/canvas/index.js +15 -0
- package/src/graphics/canvas/paint/index.js +0 -0
- package/src/graphics/canvas/utils/color.js +8 -0
- package/src/graphics/canvas/utils/floodFill.js +58 -0
- package/src/graphics/index.js +69 -0
- package/src/graphics/svg/Elements/Basic/circle.js +26 -0
- package/src/graphics/svg/Elements/Basic/ellipse.js +21 -0
- package/src/graphics/svg/Elements/Basic/foreignObject.js +33 -0
- package/src/graphics/svg/Elements/Basic/groupe.js +29 -0
- package/src/graphics/svg/Elements/Basic/image.js +33 -0
- package/src/graphics/svg/Elements/Basic/line.js +29 -0
- package/src/graphics/svg/Elements/Basic/link.js +30 -0
- package/src/graphics/svg/Elements/Basic/path.js +59 -0
- package/src/graphics/svg/Elements/Basic/polygon.js +32 -0
- package/src/graphics/svg/Elements/Basic/polyline.js +4 -0
- package/src/graphics/svg/Elements/Basic/rect.js +43 -0
- package/src/graphics/svg/Elements/Basic/text.js +26 -0
- package/src/graphics/svg/Elements/Derived/grid.js +9 -0
- package/src/graphics/svg/Elements/ZikoSvgElement.js +46 -0
- package/src/graphics/svg/Elements/index.js +14 -0
- package/src/graphics/svg/index.js +2 -0
- package/src/graphics/svg/svg.js +115 -0
- package/src/index.js +88 -0
- package/src/math/absract.js +1 -0
- package/src/math/calculus/index.js +1 -0
- package/src/math/calculus/special-functions/bessel.js +31 -0
- package/src/math/calculus/special-functions/beta.js +38 -0
- package/src/math/calculus/special-functions/gamma.js +30 -0
- package/src/math/calculus/special-functions/index.js +4 -0
- package/src/math/complex/Fractals/julia.js +0 -0
- package/src/math/complex/index.js +203 -0
- package/src/math/const.js +3 -0
- package/src/math/discret/Combinaison/index.js +34 -0
- package/src/math/discret/Conversion/index.js +86 -0
- package/src/math/discret/Logic/index.js +46 -0
- package/src/math/discret/Permutation/index.js +31 -0
- package/src/math/discret/Set/index.js +2 -0
- package/src/math/discret/Set/power-set.js +15 -0
- package/src/math/discret/Set/sub-set.js +10 -0
- package/src/math/discret/index.js +23 -0
- package/src/math/functions/index.js +182 -0
- package/src/math/index.js +189 -0
- package/src/math/matrix/Decomposition.js +90 -0
- package/src/math/matrix/LinearSystem.js +10 -0
- package/src/math/matrix/Matrix.js +717 -0
- package/src/math/matrix/index.js +3 -0
- package/src/math/numeric/index.js +0 -0
- package/src/math/random/index.js +173 -0
- package/src/math/signal/__np.py.txt +40 -0
- package/src/math/signal/conv.js +175 -0
- package/src/math/signal/fft.js +55 -0
- package/src/math/signal/filter.js +39 -0
- package/src/math/signal/functions.js +146 -0
- package/src/math/signal/index.js +110 -0
- package/src/math/statistics/Functions/index.js +100 -0
- package/src/math/statistics/index.js +16 -0
- package/src/math/utils/arithmetic.js +139 -0
- package/src/math/utils/checkers.js +29 -0
- package/src/math/utils/comparaison.js +1 -0
- package/src/math/utils/conversions.js +19 -0
- package/src/math/utils/discret.js +51 -0
- package/src/math/utils/index.js +102 -0
- package/src/math/utils/mapfun.js +50 -0
- package/src/reactivity/events/Global/Click.js +56 -0
- package/src/reactivity/events/Global/Clipboard.js +84 -0
- package/src/reactivity/events/Global/CustomEvent.js +53 -0
- package/src/reactivity/events/Global/Drag.js +137 -0
- package/src/reactivity/events/Global/Focus.js +56 -0
- package/src/reactivity/events/Global/Key.js +104 -0
- package/src/reactivity/events/Global/Mouse.js +230 -0
- package/src/reactivity/events/Global/Pointer.js +234 -0
- package/src/reactivity/events/Global/Swipe.js +147 -0
- package/src/reactivity/events/Global/Touch.js +0 -0
- package/src/reactivity/events/Global/Wheel.js +44 -0
- package/src/reactivity/events/Partiel/Hash.js +44 -0
- package/src/reactivity/events/Partiel/Input.js +59 -0
- package/src/reactivity/events/Partiel/Media.js +1 -0
- package/src/reactivity/events/ZikoEvent.js +91 -0
- package/src/reactivity/events/index.js +63 -0
- package/src/reactivity/hooks/Contexte/index.js +1 -0
- package/src/reactivity/hooks/Contexte/useSuccesifKeys.js +14 -0
- package/src/reactivity/hooks/Decorators/index.js +6 -0
- package/src/reactivity/hooks/Decorators/time.js +17 -0
- package/src/reactivity/hooks/Decorators/type.js +88 -0
- package/src/reactivity/hooks/Interactions/index.js +4 -0
- package/src/reactivity/hooks/Interactions/useBluetooth.js +48 -0
- package/src/reactivity/hooks/Interactions/useChannel.js +50 -0
- package/src/reactivity/hooks/Interactions/useEventEmmiter.js +64 -0
- package/src/reactivity/hooks/Interactions/useSerial.js +0 -0
- package/src/reactivity/hooks/Interactions/useThread.js +44 -0
- package/src/reactivity/hooks/Interactions/useUsb.js +0 -0
- package/src/reactivity/hooks/Sensors/index.js +2 -0
- package/src/reactivity/hooks/Sensors/useBattery.js +36 -0
- package/src/reactivity/hooks/Sensors/useCamera.js +0 -0
- package/src/reactivity/hooks/Sensors/useGeolocation.js +17 -0
- package/src/reactivity/hooks/Sensors/useMicro.js +0 -0
- package/src/reactivity/hooks/Sensors/useOrientation.js +0 -0
- package/src/reactivity/hooks/Storage/index.js +1 -0
- package/src/reactivity/hooks/Storage/useCookie.js +0 -0
- package/src/reactivity/hooks/Storage/useIndexedDb.js +0 -0
- package/src/reactivity/hooks/Storage/useStorage.js +73 -0
- package/src/reactivity/hooks/UI/index.js +5 -0
- package/src/reactivity/hooks/UI/useCssLink.js +0 -0
- package/src/reactivity/hooks/UI/useCssText.js +21 -0
- package/src/reactivity/hooks/UI/useFavIcon.js +38 -0
- package/src/reactivity/hooks/UI/useLinearGradient.js +0 -0
- package/src/reactivity/hooks/UI/useMediaQuery.js +43 -0
- package/src/reactivity/hooks/UI/useRadialGradient.js +0 -0
- package/src/reactivity/hooks/UI/useStyle.js +79 -0
- package/src/reactivity/hooks/UI/useTheme.js +62 -0
- package/src/reactivity/hooks/UI/useTitle.js +30 -0
- package/src/reactivity/hooks/index.js +85 -0
- package/src/reactivity/hooks/todo.md +26 -0
- package/src/reactivity/idea +2 -0
- package/src/reactivity/index.js +22 -0
- package/src/reactivity/observer/attributes.js +28 -0
- package/src/reactivity/observer/children.js +37 -0
- package/src/reactivity/observer/index.js +44 -0
- package/src/reactivity/observer/intersection.js +44 -0
- package/src/reactivity/observer/mutation.js +113 -0
- package/src/reactivity/observer/resize.js +47 -0
- package/src/reactivity/observer/screen.js +45 -0
- package/src/reactivity/observer/screen.js.txt +84 -0
- package/src/reactivity/observer/screen.txt +13 -0
- package/src/time/animation.js +76 -0
- package/src/time/index.js +54 -0
- package/src/time/loop.js +87 -0
- package/src/time/utils/decorators.js +17 -0
- package/src/time/utils/ease.js +144 -0
- package/src/time/utils/index.js +18 -0
- package/src/time/utils/performance.js +16 -0
- package/src/time/utils/ui.js +26 -0
- package/src/types.js +71 -0
- package/src/user-interface/elements/derived/Flex.js +103 -0
- package/src/user-interface/elements/derived/Grid.js +33 -0
- package/src/user-interface/elements/derived/elements/Notification.js +0 -0
- package/src/user-interface/elements/derived/elements/Popover.js +0 -0
- package/src/user-interface/elements/derived/elements/Popup.js +0 -0
- package/src/user-interface/elements/derived/elements/Swipper.js +4 -0
- package/src/user-interface/elements/derived/elements/Timeline.js +0 -0
- package/src/user-interface/elements/derived/elements/Toast.js +0 -0
- package/src/user-interface/elements/derived/elements/Treeview.js +0 -0
- package/src/user-interface/elements/derived/elements/accordion/accordion.js +45 -0
- package/src/user-interface/elements/derived/elements/accordion/collapsible.js +82 -0
- package/src/user-interface/elements/derived/elements/accordion/index.js +2 -0
- package/src/user-interface/elements/derived/elements/alert/alert.js +80 -0
- package/src/user-interface/elements/derived/elements/alert/index.js +1 -0
- package/src/user-interface/elements/derived/elements/alert/palette.js +52 -0
- package/src/user-interface/elements/derived/elements/carousel/index.js +51 -0
- package/src/user-interface/elements/derived/elements/code-note/SubElements.js.txt +105 -0
- package/src/user-interface/elements/derived/elements/code-note/code-cell.js +195 -0
- package/src/user-interface/elements/derived/elements/code-note/code-note.js +72 -0
- package/src/user-interface/elements/derived/elements/code-note/index.js +2 -0
- package/src/user-interface/elements/derived/elements/code-note/sub-elements.js +67 -0
- package/src/user-interface/elements/derived/elements/columns.js +1 -0
- package/src/user-interface/elements/derived/elements/fab.js +0 -0
- package/src/user-interface/elements/derived/elements/index.js +9 -0
- package/src/user-interface/elements/derived/elements/menu/index.js +1 -0
- package/src/user-interface/elements/derived/elements/menu/menu3d.js +260 -0
- package/src/user-interface/elements/derived/elements/modal/index.js +92 -0
- package/src/user-interface/elements/derived/elements/pagination/breadcrumbs.js +54 -0
- package/src/user-interface/elements/derived/elements/pagination/index.js +1 -0
- package/src/user-interface/elements/derived/elements/splitter/__ZikoUISplitter__.js +62 -0
- package/src/user-interface/elements/derived/elements/splitter/hsplitter.js +40 -0
- package/src/user-interface/elements/derived/elements/splitter/index.js +2 -0
- package/src/user-interface/elements/derived/elements/splitter/vsplitter.js +40 -0
- package/src/user-interface/elements/derived/elements/tabs/index.js +180 -0
- package/src/user-interface/elements/derived/index.js +3 -0
- package/src/user-interface/elements/primitives/ZikoUIContainerElement.js +127 -0
- package/src/user-interface/elements/primitives/ZikoUIElement.js +480 -0
- package/src/user-interface/elements/primitives/embaded/html.js +21 -0
- package/src/user-interface/elements/primitives/embaded/index.js +3 -0
- package/src/user-interface/elements/primitives/embaded/pdf.js +18 -0
- package/src/user-interface/elements/primitives/embaded/youtube.js +26 -0
- package/src/user-interface/elements/primitives/index.js +8 -0
- package/src/user-interface/elements/primitives/io/Form/index.js +42 -0
- package/src/user-interface/elements/primitives/io/Form/index.js.txt +104 -0
- package/src/user-interface/elements/primitives/io/Inputs/__helpers__.js +52 -0
- package/src/user-interface/elements/primitives/io/Inputs/index.js +12 -0
- package/src/user-interface/elements/primitives/io/Inputs/input/index.js +99 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-camera/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-checkbox/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-color/index.js +16 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/index.js +3 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-date-time.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-date.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-date-time/input-time.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/index.js +2 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/input-email.js +15 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-email-password/input-password.js +14 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/index.js +1 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/input-file.js +0 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-file/input-image.js +43 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-number/index.js +37 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-radio/index.js +26 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-search/index.js +45 -0
- package/src/user-interface/elements/primitives/io/Inputs/input-slider/index.js +34 -0
- package/src/user-interface/elements/primitives/io/Select/index.js +20 -0
- package/src/user-interface/elements/primitives/io/Textarea/index.js +18 -0
- package/src/user-interface/elements/primitives/io/index.js +4 -0
- package/src/user-interface/elements/primitives/list/elements.js +0 -0
- package/src/user-interface/elements/primitives/list/index.js +139 -0
- package/src/user-interface/elements/primitives/media/Audio/index.js +17 -0
- package/src/user-interface/elements/primitives/media/Image/figure.js +19 -0
- package/src/user-interface/elements/primitives/media/Image/image.js +37 -0
- package/src/user-interface/elements/primitives/media/Image/index.js +2 -0
- package/src/user-interface/elements/primitives/media/Video/index.js +27 -0
- package/src/user-interface/elements/primitives/media/__ZikoUIDynamicMediaELement__.js +47 -0
- package/src/user-interface/elements/primitives/media/index.js +3 -0
- package/src/user-interface/elements/primitives/misc/index.js +100 -0
- package/src/user-interface/elements/primitives/semantic/index.js +82 -0
- package/src/user-interface/elements/primitives/table/elements.js +94 -0
- package/src/user-interface/elements/primitives/table/index.js +3 -0
- package/src/user-interface/elements/primitives/table/table.js +115 -0
- package/src/user-interface/elements/primitives/table/utils.js +12 -0
- package/src/user-interface/elements/primitives/text/__ZikoUIText__.js +71 -0
- package/src/user-interface/elements/primitives/text/heading.js +36 -0
- package/src/user-interface/elements/primitives/text/index.js +3 -0
- package/src/user-interface/elements/primitives/text/p.js +26 -0
- package/src/user-interface/elements/primitives/text/pre.js +0 -0
- package/src/user-interface/elements/primitives/text/text.js +81 -0
- package/src/user-interface/index.js +190 -0
- package/src/user-interface/style/index.js +510 -0
- package/src/user-interface/utils/index.js +70 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { mapfun } from "../utils/index.js";
|
|
2
|
+
import { abs , sinc , sign , sin } from "../functions/index.js"
|
|
3
|
+
import { Random } from "../random/index.js";
|
|
4
|
+
import {
|
|
5
|
+
zeros,
|
|
6
|
+
ones,
|
|
7
|
+
nums,
|
|
8
|
+
arange,
|
|
9
|
+
linspace,
|
|
10
|
+
logspace,
|
|
11
|
+
geomspace,
|
|
12
|
+
map,
|
|
13
|
+
norm,
|
|
14
|
+
lerp,
|
|
15
|
+
clamp,
|
|
16
|
+
} from "./functions.js";
|
|
17
|
+
import{
|
|
18
|
+
fft,
|
|
19
|
+
ifft
|
|
20
|
+
} from "./fft.js"
|
|
21
|
+
import {
|
|
22
|
+
conv,
|
|
23
|
+
conv1d,
|
|
24
|
+
conv2d,
|
|
25
|
+
circularConv,
|
|
26
|
+
linearConv,
|
|
27
|
+
circularConv1d,
|
|
28
|
+
linearConv1d,
|
|
29
|
+
circularConv2d,
|
|
30
|
+
linearConv2d
|
|
31
|
+
} from "./conv.js";
|
|
32
|
+
import {
|
|
33
|
+
filter
|
|
34
|
+
} from "./filter.js";
|
|
35
|
+
//import { Matrix } from "../Matrix/index.js";
|
|
36
|
+
const Signal={
|
|
37
|
+
zeros,
|
|
38
|
+
ones,
|
|
39
|
+
nums,
|
|
40
|
+
arange,
|
|
41
|
+
linspace,
|
|
42
|
+
logspace,
|
|
43
|
+
geomspace,
|
|
44
|
+
map,
|
|
45
|
+
norm,
|
|
46
|
+
lerp,
|
|
47
|
+
clamp,
|
|
48
|
+
noise(n,min = 0,max = 1){
|
|
49
|
+
return Random.floats(n,min,max);
|
|
50
|
+
},
|
|
51
|
+
echelon(t,t0 = 0 , A = 1){
|
|
52
|
+
if(!(t instanceof Array))t=[t];
|
|
53
|
+
const Y = mapfun(n=>n>=t0?1:0,...t);
|
|
54
|
+
return Y instanceof Array ? Y.map(n=>n*A) : Y*A
|
|
55
|
+
},
|
|
56
|
+
rampe(t,t0 = 0 , A = 1){
|
|
57
|
+
if(!(t instanceof Array))t=[t]
|
|
58
|
+
const Y = mapfun(n=>n>=t0?n-t0:0,...t);
|
|
59
|
+
return Y instanceof Array ? Y.map(n=>n*A) : Y*A
|
|
60
|
+
},
|
|
61
|
+
sign(t,t0 = 0 , A = 1){
|
|
62
|
+
if(!(t instanceof Array))t=[t]
|
|
63
|
+
const Y = mapfun(n=>Math.sign(n-t0),...t);
|
|
64
|
+
return Y instanceof Array ? Y.map(n=>n*A) : Y*A
|
|
65
|
+
},
|
|
66
|
+
rect(t,T,t0 = 0, A = 1){
|
|
67
|
+
if(!(t instanceof Array))t=[t];
|
|
68
|
+
const Y = mapfun(n=>((t0-T/2 < n) && (t0+T/2 > n)? 1 - 2 * abs(n/T) : 0),...t)
|
|
69
|
+
return Y instanceof Array ? Y.map(n=>n*A) : Y*A
|
|
70
|
+
},
|
|
71
|
+
tri(t,T,t0 = 0 , A = 1){
|
|
72
|
+
if(!(t instanceof Array))t=[t]
|
|
73
|
+
const Y = mapfun(n=>((t0-T/2 < n) && (t0+T/2 > n)? 1 - 2 * abs(n/T) : 0),...t)
|
|
74
|
+
return Y instanceof Array ? Y.map(n=>n*A) : Y*A;
|
|
75
|
+
},
|
|
76
|
+
dirac(t,t0){
|
|
77
|
+
return mapfun(n=>n===t0?Infinity:0,...t);
|
|
78
|
+
},
|
|
79
|
+
lorentz(t , t0 = 0 , A = 1){
|
|
80
|
+
if(!(t instanceof Array))t=[t]
|
|
81
|
+
const Y = mapfun(n => 1/(1+(n-t0)**2),...t);
|
|
82
|
+
return Y instanceof Array ? Y.map(n=>n*A) : Y*A;
|
|
83
|
+
},
|
|
84
|
+
sinc(t , t0 , A = 1){
|
|
85
|
+
if(!(t instanceof Array))t=[t]
|
|
86
|
+
const Y = mapfun(n=>sinc(n-t0),...t);
|
|
87
|
+
return Y instanceof Array ? Y.map(n=>n*A) : Y*A;
|
|
88
|
+
},
|
|
89
|
+
square(t,T=1,A=1){
|
|
90
|
+
if(!(t instanceof Array))t=[t]
|
|
91
|
+
const Y = mapfun(n=>sign(sin(n*2*Math.PI/T)),...t);
|
|
92
|
+
return Y instanceof Array ? Y.map(n=>n*A) : Y*A;
|
|
93
|
+
},
|
|
94
|
+
sawtooth(){
|
|
95
|
+
|
|
96
|
+
},
|
|
97
|
+
conv,
|
|
98
|
+
conv1d,
|
|
99
|
+
conv2d,
|
|
100
|
+
circularConv,
|
|
101
|
+
linearConv,
|
|
102
|
+
circularConv1d,
|
|
103
|
+
linearConv1d,
|
|
104
|
+
circularConv2d,
|
|
105
|
+
linearConv2d,
|
|
106
|
+
fft,
|
|
107
|
+
ifft,
|
|
108
|
+
filter,
|
|
109
|
+
}
|
|
110
|
+
export{Signal}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Mixed calcul
|
|
2
|
+
const sum=(...x)=>{
|
|
3
|
+
if(x.every(n=>typeof n==="number")){
|
|
4
|
+
let s = x[0];
|
|
5
|
+
for (let i = 1; i < x.length; i++) s += x[i];
|
|
6
|
+
return s;
|
|
7
|
+
}
|
|
8
|
+
const Y=[];
|
|
9
|
+
for(let i=0;i<x.length;i++){
|
|
10
|
+
if(x[i] instanceof Array)Y.push(sum(...x[i]));
|
|
11
|
+
else if(x[i] instanceof Object){
|
|
12
|
+
Y.push(sum(...Object.values(x[i])))
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
return Y.length===1?Y[0]:Y;
|
|
16
|
+
}
|
|
17
|
+
const prod=(...x)=>{
|
|
18
|
+
if(x.every(n=>typeof n==="number")){
|
|
19
|
+
let p = x[0];
|
|
20
|
+
for (let i = 1; i < x.length; i++) p *= x[i];
|
|
21
|
+
return p;
|
|
22
|
+
}
|
|
23
|
+
const Y=[];
|
|
24
|
+
for(let i=0;i<x.length;i++){
|
|
25
|
+
if(x[i] instanceof Array)Y.push(prod(...x[i]));
|
|
26
|
+
else if(x[i] instanceof Object){
|
|
27
|
+
Y.push(prod(...Object.values(x[i])))
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return Y.length===1?Y[0]:Y;
|
|
31
|
+
}
|
|
32
|
+
const min=(...num)=>{
|
|
33
|
+
if(num.every(n=>typeof n==="number"))return Math.min(...num);
|
|
34
|
+
const Y=[];
|
|
35
|
+
for(let i=0;i<num.length;i++){
|
|
36
|
+
if(num[i] instanceof Array)Y.push(min(...num[i]));
|
|
37
|
+
else if(num[i] instanceof Object){
|
|
38
|
+
Y.push(
|
|
39
|
+
Object.fromEntries(
|
|
40
|
+
[Object.entries(num[i]).sort((a,b)=>a[1]-b[1])[0]]
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return Y.length===1?Y[0]:Y;
|
|
46
|
+
}
|
|
47
|
+
const max=(...num)=>{
|
|
48
|
+
if(num.every(n=>typeof n==="number"))return Math.max(...num);
|
|
49
|
+
const Y=[];
|
|
50
|
+
for(let i=0;i<num.length;i++){
|
|
51
|
+
if(num[i] instanceof Array)Y.push(min(...num[i]));
|
|
52
|
+
else if(num[i] instanceof Object){
|
|
53
|
+
Y.push(
|
|
54
|
+
Object.fromEntries(
|
|
55
|
+
[Object.entries(num[i]).sort((a,b)=>b[1]-a[1])[0]]
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return Y.length===1?Y[0]:Y;
|
|
61
|
+
}
|
|
62
|
+
const accum=(...num)=>{
|
|
63
|
+
if(num.every(n=>typeof n==="number")){
|
|
64
|
+
let acc = num.reduce((x, y) => [...x, x[x.length - 1] + y], [0]);
|
|
65
|
+
acc.shift();
|
|
66
|
+
return acc;
|
|
67
|
+
}
|
|
68
|
+
const Y=[];
|
|
69
|
+
for(let i=0;i<num.length;i++){
|
|
70
|
+
if(num[i] instanceof Array)Y.push(accum(...num[i]));
|
|
71
|
+
else if(num[i] instanceof Object){
|
|
72
|
+
Y.push(null
|
|
73
|
+
// Object.fromEntries(
|
|
74
|
+
// [Object.entries(num[i]).sort((a,b)=>b[1]-a[1])[0]]
|
|
75
|
+
// )
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return Y.length===1?Y[0]:Y;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// sort
|
|
83
|
+
|
|
84
|
+
export{
|
|
85
|
+
sum,
|
|
86
|
+
prod,
|
|
87
|
+
min,
|
|
88
|
+
max,
|
|
89
|
+
accum
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
//moy
|
|
93
|
+
//med
|
|
94
|
+
//variance
|
|
95
|
+
//std
|
|
96
|
+
//mode
|
|
97
|
+
//acccum
|
|
98
|
+
//min2max
|
|
99
|
+
//max2min
|
|
100
|
+
//percentile
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { Complex,complex} from "../complex/index.js";
|
|
2
|
+
import { Matrix } from "../matrix/index.js";
|
|
3
|
+
const _add=(a,b)=>{
|
|
4
|
+
if(typeof(a)==="number"){
|
|
5
|
+
if (typeof b == "number") return a + b;
|
|
6
|
+
else if (b instanceof Complex)return complex(a + b.a, b.b);
|
|
7
|
+
else if (b instanceof Matrix) return Matrix.nums(b.rows, b.cols, a).add(b);
|
|
8
|
+
else if (b instanceof Array)return b.map(n=>add(n,a));
|
|
9
|
+
}
|
|
10
|
+
else if(a instanceof Complex||a instanceof Matrix){
|
|
11
|
+
if(b instanceof Array)return b.map(n=>a.clone.add(n));
|
|
12
|
+
return a.clone.add(b);
|
|
13
|
+
}
|
|
14
|
+
else if(a instanceof Array){
|
|
15
|
+
if(b instanceof Array){
|
|
16
|
+
if(a.length === b.length)return a.map((n,i)=>add(n,b[i]))
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
return a.map(n=>add(n,b));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const _sub=(a,b)=>{
|
|
24
|
+
if(typeof(a)==="number"){
|
|
25
|
+
if (typeof b == "number") return a - b;
|
|
26
|
+
else if (b instanceof Complex)return complex(a - b.a, -b.b);
|
|
27
|
+
else if (b instanceof Matrix) return Matrix.nums(b.rows, b.cols, a).sub(b);
|
|
28
|
+
else if (b instanceof Array)return b.map(n=>sub(n,a));
|
|
29
|
+
}
|
|
30
|
+
else if(a instanceof Complex||a instanceof Matrix){
|
|
31
|
+
if(b instanceof Array)return b.map(n=>a.clone.sub(n));
|
|
32
|
+
return a.clone.sub(b);
|
|
33
|
+
}
|
|
34
|
+
else if(a instanceof Array){
|
|
35
|
+
if(b instanceof Array){
|
|
36
|
+
if(b instanceof Array){
|
|
37
|
+
if(a.length === b.length)return a.map((n,i)=>sub(n,b[i]))
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return a.map(n=>sub(n,b));
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
const _mul=(a,b)=>{
|
|
46
|
+
if(typeof(a)==="number"){
|
|
47
|
+
if (typeof b == "number") return a * b;
|
|
48
|
+
else if (b instanceof Complex)return complex(a * b.a,a * b.b);
|
|
49
|
+
else if (b instanceof Matrix) return Matrix.nums(b.rows, b.cols, a).mul(b);
|
|
50
|
+
else if (b instanceof Array)return b.map(n=>mul(a,n));
|
|
51
|
+
}
|
|
52
|
+
else if(a instanceof Complex||a instanceof Matrix){
|
|
53
|
+
if(b instanceof Array)return b.map(n=>a.clone.mul(n));
|
|
54
|
+
return a.clone.mul(b);
|
|
55
|
+
}
|
|
56
|
+
else if(a instanceof Array){
|
|
57
|
+
if(b instanceof Array){
|
|
58
|
+
if(b instanceof Array){
|
|
59
|
+
if(a.length === b.length)return a.map((n,i)=>mul(n,b[i]))
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
return a.map(n=>mul(n,b));
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const _div=(a,b)=>{
|
|
68
|
+
if(typeof(a)==="number"){
|
|
69
|
+
if (typeof b == "number") return a / b;
|
|
70
|
+
else if (b instanceof Complex)return complex(a / b.a,a / b.b);
|
|
71
|
+
else if (b instanceof Matrix) return Matrix.nums(b.rows, b.cols, a).div(b);
|
|
72
|
+
else if (b instanceof Array)return b.map(n=>div(a,n));
|
|
73
|
+
}
|
|
74
|
+
else if(a instanceof Complex||a instanceof Matrix){
|
|
75
|
+
if(b instanceof Array)return b.map(n=>a.clone.div(n));
|
|
76
|
+
return a.clone.div(b);
|
|
77
|
+
}
|
|
78
|
+
else if(a instanceof Array){
|
|
79
|
+
if(b instanceof Array){
|
|
80
|
+
if(b instanceof Array){
|
|
81
|
+
if(a.length === b.length)return a.map((n,i)=>div(n,b[i]))
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
return a.map(n=>div(n,b));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
const _modulo=(a,b)=>{
|
|
90
|
+
if(typeof(a)==="number"){
|
|
91
|
+
if (typeof b == "number") return a % b;
|
|
92
|
+
else if (b instanceof Complex)return complex(a % b.a,a % b.b);
|
|
93
|
+
else if (b instanceof Matrix) return Matrix.nums(b.rows, b.cols, a).modulo(b);
|
|
94
|
+
else if (b instanceof Array)return b.map(n=>div(a,n));
|
|
95
|
+
}
|
|
96
|
+
else if(a instanceof Complex||a instanceof Matrix){
|
|
97
|
+
if(b instanceof Array)return b.map(n=>a.clone.div(n));
|
|
98
|
+
return a.clone.div(b);
|
|
99
|
+
}
|
|
100
|
+
else if(a instanceof Array){
|
|
101
|
+
if(b instanceof Array){
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return a.map(n=>add(n,b));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
const add=(a,...b)=>{
|
|
109
|
+
var res=a;
|
|
110
|
+
for(let i=0;i<b.length;i++)res=_add(res,b[i])
|
|
111
|
+
return res;
|
|
112
|
+
}
|
|
113
|
+
const sub=(a,...b)=>{
|
|
114
|
+
var res=a;
|
|
115
|
+
for(let i=0;i<b.length;i++)res=_sub(res,b[i])
|
|
116
|
+
return res;
|
|
117
|
+
}
|
|
118
|
+
const mul=(a,...b)=>{
|
|
119
|
+
var res=a;
|
|
120
|
+
for(let i=0;i<b.length;i++)res=_mul(res,b[i])
|
|
121
|
+
return res;
|
|
122
|
+
}
|
|
123
|
+
const div=(a,...b)=>{
|
|
124
|
+
var res=a;
|
|
125
|
+
for(let i=0;i<b.length;i++)res=_div(res,b[i])
|
|
126
|
+
return res;
|
|
127
|
+
}
|
|
128
|
+
const modulo=(a,...b)=>{
|
|
129
|
+
var res=a;
|
|
130
|
+
for(let i=0;i<b.length;i++)res=_modulo(res,b[i])
|
|
131
|
+
return res;
|
|
132
|
+
}
|
|
133
|
+
export{
|
|
134
|
+
add,
|
|
135
|
+
sub,
|
|
136
|
+
mul,
|
|
137
|
+
div,
|
|
138
|
+
modulo
|
|
139
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/** @module Math */
|
|
2
|
+
/**
|
|
3
|
+
* Checks if a value is within the specified range.
|
|
4
|
+
* @function
|
|
5
|
+
* @param {number} x - The value to check.
|
|
6
|
+
* @param {number} a - The start of the range.
|
|
7
|
+
* @param {number} b - The end of the range.
|
|
8
|
+
* @returns {boolean} Returns true if the value is within the range [a, b], otherwise false.
|
|
9
|
+
*/
|
|
10
|
+
const inRange = (x, a, b) => {
|
|
11
|
+
const [min, max] = [Math.min(a, b), Math.max(a, b)];
|
|
12
|
+
return x >= min && x <= max;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Checks if two numbers are approximately equal within a given error margin.
|
|
17
|
+
* @param {number} a - The first number.
|
|
18
|
+
* @param {number} b - The second number.
|
|
19
|
+
* @param {number} [Err=0.0001] - The maximum acceptable difference between the two numbers.
|
|
20
|
+
* @returns {boolean} Returns true if the two numbers are approximately equal within the specified error margin, otherwise false.
|
|
21
|
+
*/
|
|
22
|
+
const isApproximatlyEqual = (a, b, Err = 0.0001) => {
|
|
23
|
+
return Math.abs(a - b) <= Err;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
inRange,
|
|
28
|
+
isApproximatlyEqual
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// approximatly equal
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** @module Math */
|
|
2
|
+
/**
|
|
3
|
+
* Converts degrees to radians.
|
|
4
|
+
* @param {...number} deg - Degrees to convert.
|
|
5
|
+
* @returns {number|number[]} Returns an array of radians corresponding to the input degrees.
|
|
6
|
+
*/
|
|
7
|
+
const deg2rad = (...deg) => mapfun(x => x * Math.PI / 180, ...deg);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Converts radians to degrees.
|
|
11
|
+
* @param {...number} rad - Radians to convert.
|
|
12
|
+
* @returns {number|number[]} Returns an array of degrees corresponding to the input radians.
|
|
13
|
+
*/
|
|
14
|
+
const rad2deg = (...rad) => mapfun(x => x / Math.PI * 180, ...rad);
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
deg2rad,
|
|
18
|
+
rad2deg
|
|
19
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** @module Math */
|
|
2
|
+
import { floor } from "../functions/index.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Computes the cartesian product of two arrays.
|
|
6
|
+
* @param {Array} a - The first array.
|
|
7
|
+
* @param {Array} b - The second array.
|
|
8
|
+
* @returns {Array} Returns an array representing the cartesian product of the input arrays.
|
|
9
|
+
*/
|
|
10
|
+
const cartesianProduct = (a, b) => a.reduce((p, x) => [...p, ...b.map((y) => [x, y])], []);
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Computes the greatest common divisor (GCD) of two numbers.
|
|
14
|
+
* @param {number} n1 - The first number.
|
|
15
|
+
* @param {number} n2 - The second number.
|
|
16
|
+
* @returns {number} Returns the greatest common divisor of the two input numbers.
|
|
17
|
+
*/
|
|
18
|
+
const pgcd = (n1, n2) => {
|
|
19
|
+
let i,
|
|
20
|
+
pgcd = 1;
|
|
21
|
+
if (n1 == floor(n1) && n2 == floor(n2)) {
|
|
22
|
+
for (i = 2; i <= n1 && i <= n2; ++i) {
|
|
23
|
+
if (n1 % i == 0 && n2 % i == 0) pgcd = i;
|
|
24
|
+
}
|
|
25
|
+
return pgcd;
|
|
26
|
+
} else console.log("error");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Computes the least common multiple (LCM) of two numbers.
|
|
31
|
+
* @param {number} n1 - The first number.
|
|
32
|
+
* @param {number} n2 - The second number.
|
|
33
|
+
* @returns {number} Returns the least common multiple of the two input numbers.
|
|
34
|
+
*/
|
|
35
|
+
const ppcm = (n1, n2) => {
|
|
36
|
+
let ppcm;
|
|
37
|
+
if (n1 == floor(n1) && n2 == floor(n2)) {
|
|
38
|
+
ppcm = n1 > n2 ? n1 : n2;
|
|
39
|
+
while (true) {
|
|
40
|
+
if (ppcm % n1 == 0 && ppcm % n2 == 0) break;
|
|
41
|
+
++ppcm;
|
|
42
|
+
}
|
|
43
|
+
return ppcm;
|
|
44
|
+
} else console.log("error");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
cartesianProduct,
|
|
49
|
+
ppcm,
|
|
50
|
+
pgcd
|
|
51
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { mapfun } from "./mapfun.js";
|
|
2
|
+
import {
|
|
3
|
+
add,
|
|
4
|
+
sub,
|
|
5
|
+
mul,
|
|
6
|
+
div,
|
|
7
|
+
modulo
|
|
8
|
+
} from "./arithmetic.js";
|
|
9
|
+
import {
|
|
10
|
+
zeros,
|
|
11
|
+
ones,
|
|
12
|
+
nums,
|
|
13
|
+
norm,
|
|
14
|
+
lerp,
|
|
15
|
+
map,
|
|
16
|
+
clamp,
|
|
17
|
+
arange,
|
|
18
|
+
linspace,
|
|
19
|
+
logspace,
|
|
20
|
+
geomspace
|
|
21
|
+
} from "../signal/functions.js"
|
|
22
|
+
import {
|
|
23
|
+
deg2rad,
|
|
24
|
+
rad2deg
|
|
25
|
+
} from "./conversions.js"
|
|
26
|
+
import{
|
|
27
|
+
sum,
|
|
28
|
+
prod,
|
|
29
|
+
accum
|
|
30
|
+
} from "../statistics/index.js"
|
|
31
|
+
import{
|
|
32
|
+
inRange,
|
|
33
|
+
isApproximatlyEqual
|
|
34
|
+
} from "./checkers.js"
|
|
35
|
+
import{
|
|
36
|
+
cartesianProduct,
|
|
37
|
+
ppcm,
|
|
38
|
+
pgcd
|
|
39
|
+
} from "./discret.js"
|
|
40
|
+
const Utils={
|
|
41
|
+
add,
|
|
42
|
+
sub,
|
|
43
|
+
mul,
|
|
44
|
+
div,
|
|
45
|
+
modulo,
|
|
46
|
+
|
|
47
|
+
zeros,
|
|
48
|
+
ones,
|
|
49
|
+
nums,
|
|
50
|
+
norm,
|
|
51
|
+
lerp,
|
|
52
|
+
map,
|
|
53
|
+
clamp,
|
|
54
|
+
arange,
|
|
55
|
+
linspace,
|
|
56
|
+
logspace,
|
|
57
|
+
geomspace,
|
|
58
|
+
|
|
59
|
+
sum,
|
|
60
|
+
prod,
|
|
61
|
+
accum,
|
|
62
|
+
|
|
63
|
+
cartesianProduct,
|
|
64
|
+
ppcm,
|
|
65
|
+
pgcd,
|
|
66
|
+
|
|
67
|
+
deg2rad,
|
|
68
|
+
rad2deg,
|
|
69
|
+
|
|
70
|
+
inRange,
|
|
71
|
+
isApproximatlyEqual
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
mapfun,
|
|
75
|
+
Utils,
|
|
76
|
+
zeros,
|
|
77
|
+
ones,
|
|
78
|
+
nums,
|
|
79
|
+
sum,
|
|
80
|
+
prod,
|
|
81
|
+
add,
|
|
82
|
+
mul,
|
|
83
|
+
sub,
|
|
84
|
+
div,
|
|
85
|
+
modulo,
|
|
86
|
+
rad2deg,
|
|
87
|
+
deg2rad,
|
|
88
|
+
arange,
|
|
89
|
+
linspace,
|
|
90
|
+
logspace,
|
|
91
|
+
geomspace,
|
|
92
|
+
norm,
|
|
93
|
+
lerp,
|
|
94
|
+
map,
|
|
95
|
+
clamp,
|
|
96
|
+
pgcd,
|
|
97
|
+
ppcm,
|
|
98
|
+
isApproximatlyEqual,
|
|
99
|
+
inRange,
|
|
100
|
+
cartesianProduct,
|
|
101
|
+
};
|
|
102
|
+
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** @module Math */
|
|
2
|
+
import { Matrix } from "../matrix/index.js";
|
|
3
|
+
import { Complex , complex } from "../complex/index.js";
|
|
4
|
+
import {ln,e,cos,sin,sqrt,cosh,sinh} from "../functions/index.js";
|
|
5
|
+
import { Fixed } from "../functions/index.js";
|
|
6
|
+
/**
|
|
7
|
+
* map a function to ...X
|
|
8
|
+
* @param {function} fun
|
|
9
|
+
* @param {...any} X
|
|
10
|
+
* @returns {any|any[]}
|
|
11
|
+
*/
|
|
12
|
+
const mapfun=(fun,...X)=>{
|
|
13
|
+
const Y=X.map(x=>{
|
|
14
|
+
if(x===null)return fun(null);
|
|
15
|
+
if(["number","string","boolean","bigint","undefined"].includes(typeof x))return fun(x);
|
|
16
|
+
if(x instanceof Array)return x.map(n=>mapfun(fun,n));
|
|
17
|
+
if(ArrayBuffer.isView(x))return x.map(n=>fun(n));
|
|
18
|
+
if(x instanceof Set)return new Set(mapfun(fun,...[...x]));
|
|
19
|
+
if(x instanceof Map)return new Map([...x].map(n=>[n[0],mapfun(fun,n[1])]));
|
|
20
|
+
if(x instanceof Matrix){
|
|
21
|
+
return new Matrix(x.rows,x.cols,mapfun(x.arr.flat(1)))
|
|
22
|
+
}
|
|
23
|
+
if(x instanceof Complex){
|
|
24
|
+
const [a,b,z,phi]=[x.a,x.b,x.z,x.phi];
|
|
25
|
+
switch(fun){
|
|
26
|
+
case Math.log:return complex(ln(z),phi); // Done
|
|
27
|
+
case Math.exp:return complex(e(a)*cos(b),e(a)*sin(b)); // Done
|
|
28
|
+
case Math.abs:return z; // Done
|
|
29
|
+
case Math.sqrt:return complex(sqrt(z)*cos(phi/2),sqrt(z)*sin(phi/2)); // Done
|
|
30
|
+
case Fixed.cos:return complex(cos(a)*cosh(b),-(sin(a)*sinh(b)));
|
|
31
|
+
case Fixed.sin:return complex(sin(a)*cosh(b),cos(a)*sinh(b));
|
|
32
|
+
case Fixed.tan:{
|
|
33
|
+
const DEN=cos(2*a)+cosh(2*b);
|
|
34
|
+
return complex(sin(2*a)/DEN,sinh(2*b)/DEN);
|
|
35
|
+
}
|
|
36
|
+
case Fixed.cosh:return complex(cosh(a)*cos(b),sinh(a)*sin(b));
|
|
37
|
+
case Fixed.sinh:return complex(sinh(a)*cos(b),cosh(a)*sin(b));
|
|
38
|
+
case Fixed.tanh:{
|
|
39
|
+
const DEN=cosh(2*a)+cos(2*b);
|
|
40
|
+
return complex(sinh(2*a)/DEN,sin(2*b)/DEN)
|
|
41
|
+
}
|
|
42
|
+
default : return fun(x)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else if(x instanceof Object)return Object.fromEntries(Object.entries(x).map(n=>n=[n[0],mapfun(fun,n[1])]))
|
|
46
|
+
|
|
47
|
+
});
|
|
48
|
+
return Y.length==1?Y[0]:Y;
|
|
49
|
+
}
|
|
50
|
+
export {mapfun}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ZikoEvent , EVENT_CONTROLLER } from "../ZikoEvent.js";
|
|
2
|
+
function click_controller(e){
|
|
3
|
+
EVENT_CONTROLLER.call(this,e,"click",null,null)
|
|
4
|
+
}
|
|
5
|
+
function dbclick_controller(e){
|
|
6
|
+
EVENT_CONTROLLER.call(this,e,"dbclick",null,null)
|
|
7
|
+
}
|
|
8
|
+
class ZikoEventClick extends ZikoEvent{
|
|
9
|
+
constructor(target){
|
|
10
|
+
super(target);
|
|
11
|
+
this.event=null;
|
|
12
|
+
this.cache={
|
|
13
|
+
prefixe:"",
|
|
14
|
+
preventDefault:{
|
|
15
|
+
click:false,
|
|
16
|
+
dbclick:false,
|
|
17
|
+
},
|
|
18
|
+
paused:{
|
|
19
|
+
click:false,
|
|
20
|
+
dbclick:false,
|
|
21
|
+
},
|
|
22
|
+
stream:{
|
|
23
|
+
enabled:{
|
|
24
|
+
click:false,
|
|
25
|
+
dbclick:false,
|
|
26
|
+
},
|
|
27
|
+
clear:{
|
|
28
|
+
click:false,
|
|
29
|
+
dbclick:false,
|
|
30
|
+
},
|
|
31
|
+
history:{
|
|
32
|
+
click:[],
|
|
33
|
+
dbclick:[],
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
callbacks:{
|
|
37
|
+
click:[],
|
|
38
|
+
dbclick:[],
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
this.__controller={
|
|
42
|
+
click:click_controller.bind(this),
|
|
43
|
+
dbclick:dbclick_controller.bind(this),
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
onClick(...callbacks){
|
|
47
|
+
this.__onEvent("click",{},...callbacks)
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
onDbClick(...callbacks){
|
|
51
|
+
this.__onEvent("dbclick",{},...callbacks)
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const useClickEvent=target=>new ZikoEventClick(target);
|
|
56
|
+
export default useClickEvent;
|