@mxfb/tools 0.1.1 → 0.2.3

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.
Files changed (184) hide show
  1. package/agnostic/index.d.ts +1 -23
  2. package/agnostic/misc/elo/index.d.ts +31 -0
  3. package/agnostic/misc/elo/index.js +6 -0
  4. package/agnostic/misc/index.d.ts +4 -20
  5. package/agnostic/misc/index.js +6 -35
  6. package/agnostic/misc/tennis/index.d.ts +60 -0
  7. package/agnostic/misc/tennis/index.js +6 -0
  8. package/chunks/chunk-TTZHPIH7.js +237 -0
  9. package/chunks/chunk-ZC5RZBNY.js +33 -0
  10. package/components/index.d.ts +1 -4
  11. package/node/index.d.ts +2 -6
  12. package/package.json +15 -15
  13. package/shared/errors/index.d.ts +132 -8
  14. package/agnostic/arrays/index.d.ts +0 -11
  15. package/agnostic/arrays/is-array-of/index.d.ts +0 -5
  16. package/agnostic/arrays/is-array-of/index.js +0 -23
  17. package/agnostic/async/index.d.ts +0 -8
  18. package/agnostic/async/index.js +0 -20
  19. package/agnostic/async/timeout-call/index.d.ts +0 -1
  20. package/agnostic/async/timeout-call/index.js +0 -6
  21. package/agnostic/async/transitions/index.d.ts +0 -41
  22. package/agnostic/async/transitions/index.js +0 -7
  23. package/agnostic/async/wait/index.d.ts +0 -1
  24. package/agnostic/async/wait/index.js +0 -6
  25. package/agnostic/booleans/index.d.ts +0 -8
  26. package/agnostic/booleans/index.js +0 -17
  27. package/agnostic/booleans/is-falsy/index.d.ts +0 -7
  28. package/agnostic/booleans/is-falsy/index.js +0 -11
  29. package/agnostic/css/bem/BEM.d.ts +0 -29
  30. package/agnostic/css/bem/getNamesArr.d.ts +0 -2
  31. package/agnostic/css/bem/index.d.ts +0 -7
  32. package/agnostic/css/bem/index.js +0 -9
  33. package/agnostic/css/generate-nice-color/index.d.ts +0 -2
  34. package/agnostic/css/generate-nice-color/index.js +0 -8
  35. package/agnostic/css/index.d.ts +0 -14
  36. package/agnostic/css/index.js +0 -177
  37. package/agnostic/css/is-valid-css-class-name/index.d.ts +0 -2
  38. package/agnostic/css/is-valid-css-class-name/index.js +0 -8
  39. package/agnostic/css/styles-set/index.d.ts +0 -37
  40. package/agnostic/errors/index.d.ts +0 -30
  41. package/agnostic/errors/index.js +0 -6
  42. package/agnostic/html/get-node-ancestors/index.d.ts +0 -1
  43. package/agnostic/html/get-node-ancestors/index.js +0 -6
  44. package/agnostic/html/get-position-inside-parent/index.d.ts +0 -1
  45. package/agnostic/html/get-position-inside-parent/index.js +0 -6
  46. package/agnostic/html/index.d.ts +0 -17
  47. package/agnostic/html/index.js +0 -39
  48. package/agnostic/html/insert-node/index.d.ts +0 -2
  49. package/agnostic/html/insert-node/index.js +0 -6
  50. package/agnostic/html/placeholders/index.d.ts +0 -9
  51. package/agnostic/html/placeholders/index.js +0 -6
  52. package/agnostic/html/sanitize/index.d.ts +0 -24
  53. package/agnostic/html/sanitize/index.js +0 -9
  54. package/agnostic/html/selector-to-element/index.d.ts +0 -1
  55. package/agnostic/html/selector-to-element/index.js +0 -9
  56. package/agnostic/html/string-to-nodes/index.d.ts +0 -7
  57. package/agnostic/html/string-to-nodes/index.js +0 -10
  58. package/agnostic/misc/assert/index.d.ts +0 -5
  59. package/agnostic/misc/assert/index.js +0 -6
  60. package/agnostic/misc/cast/index.d.ts +0 -9
  61. package/agnostic/misc/cast/index.js +0 -8
  62. package/agnostic/misc/crossenv/index.d.ts +0 -13
  63. package/agnostic/misc/crossenv/index.js +0 -6
  64. package/agnostic/misc/get-current-downlink/index.d.ts +0 -1
  65. package/agnostic/misc/get-current-downlink/index.js +0 -6
  66. package/agnostic/misc/is-constructor-function/index.d.ts +0 -2
  67. package/agnostic/misc/is-constructor-function/index.js +0 -6
  68. package/agnostic/misc/is-nullish/index.d.ts +0 -4
  69. package/agnostic/misc/is-nullish/index.js +0 -10
  70. package/agnostic/misc/logs/index.d.ts +0 -55
  71. package/agnostic/misc/logs/index.js +0 -6
  72. package/agnostic/misc/random/index.d.ts +0 -10
  73. package/agnostic/misc/random/index.js +0 -6
  74. package/agnostic/numbers/absolute-modulo/index.d.ts +0 -1
  75. package/agnostic/numbers/absolute-modulo/index.js +0 -6
  76. package/agnostic/numbers/clamp/index.d.ts +0 -1
  77. package/agnostic/numbers/clamp/index.js +0 -6
  78. package/agnostic/numbers/index.d.ts +0 -13
  79. package/agnostic/numbers/index.js +0 -30
  80. package/agnostic/numbers/interpolate/index.d.ts +0 -1
  81. package/agnostic/numbers/interpolate/index.js +0 -6
  82. package/agnostic/numbers/responsive-harmonics/index.d.ts +0 -10
  83. package/agnostic/numbers/responsive-harmonics/index.js +0 -9
  84. package/agnostic/numbers/round/index.d.ts +0 -1
  85. package/agnostic/numbers/round/index.js +0 -6
  86. package/agnostic/objects/enums/index.d.ts +0 -4
  87. package/agnostic/objects/enums/index.js +0 -7
  88. package/agnostic/objects/enums/is-in-enum/index.d.ts +0 -1
  89. package/agnostic/objects/enums/is-in-enum/index.js +0 -6
  90. package/agnostic/objects/flatten-getters/index.d.ts +0 -1
  91. package/agnostic/objects/flatten-getters/index.js +0 -9
  92. package/agnostic/objects/index.d.ts +0 -12
  93. package/agnostic/objects/index.js +0 -32
  94. package/agnostic/objects/is-object/index.d.ts +0 -1
  95. package/agnostic/objects/is-object/index.js +0 -6
  96. package/agnostic/objects/is-record/index.d.ts +0 -1
  97. package/agnostic/objects/is-record/index.js +0 -6
  98. package/agnostic/objects/record-format/index.d.ts +0 -11
  99. package/agnostic/objects/record-format/index.js +0 -16
  100. package/agnostic/objects/validation/index.d.ts +0 -3
  101. package/agnostic/objects/validation/index.js +0 -6
  102. package/agnostic/optim/index.d.ts +0 -7
  103. package/agnostic/optim/index.js +0 -18
  104. package/agnostic/optim/memoize/index.d.ts +0 -3
  105. package/agnostic/optim/memoize/index.js +0 -6
  106. package/agnostic/optim/throttle-debounce/index.d.ts +0 -30
  107. package/agnostic/optim/throttle-debounce/index.js +0 -8
  108. package/agnostic/optim/throttle-debounce/types.d.ts +0 -2
  109. package/agnostic/regexps/index.d.ts +0 -23
  110. package/agnostic/regexps/index.js +0 -89
  111. package/agnostic/strings/char-codes/index.d.ts +0 -17
  112. package/agnostic/strings/char-codes/index.js +0 -6
  113. package/agnostic/strings/index.d.ts +0 -14
  114. package/agnostic/strings/index.js +0 -32
  115. package/agnostic/strings/matches/index.d.ts +0 -3
  116. package/agnostic/strings/matches/index.js +0 -10
  117. package/agnostic/strings/normalize-indent/index.d.ts +0 -1
  118. package/agnostic/strings/normalize-indent/index.js +0 -6
  119. package/agnostic/strings/replace-all/index.d.ts +0 -1
  120. package/agnostic/strings/replace-all/index.js +0 -6
  121. package/agnostic/strings/to-alphanum/index.d.ts +0 -1
  122. package/agnostic/strings/to-alphanum/index.js +0 -6
  123. package/chunks/chunk-32IRF4OP.js +0 -9
  124. package/chunks/chunk-34U4HX4V.js +0 -73
  125. package/chunks/chunk-4GDNHUCZ.js +0 -162
  126. package/chunks/chunk-4QQBKBYH.js +0 -59
  127. package/chunks/chunk-4VC5PT5T.js +0 -13
  128. package/chunks/chunk-5LNUCDQ6.js +0 -132
  129. package/chunks/chunk-7AWTHZLY.js +0 -12
  130. package/chunks/chunk-7DBNMU6N.js +0 -14
  131. package/chunks/chunk-7YW5HL6N.js +0 -168
  132. package/chunks/chunk-COVPTTAD.js +0 -10
  133. package/chunks/chunk-DNIOWD7K.js +0 -8
  134. package/chunks/chunk-DQNJQBC6.js +0 -10
  135. package/chunks/chunk-E6MSDKON.js +0 -13
  136. package/chunks/chunk-EDVNAV3G.js +0 -72
  137. package/chunks/chunk-EW46EXFB.js +0 -8
  138. package/chunks/chunk-FPEW3A27.js +0 -14
  139. package/chunks/chunk-GJOU3UAL.js +0 -36
  140. package/chunks/chunk-HC6ZOHCS.js +0 -14
  141. package/chunks/chunk-HGCG2J77.js +0 -122
  142. package/chunks/chunk-IFD7GSGK.js +0 -130
  143. package/chunks/chunk-JQXNEJAP.js +0 -18
  144. package/chunks/chunk-JWBDZPQG.js +0 -18
  145. package/chunks/chunk-K37RALUX.js +0 -8
  146. package/chunks/chunk-KQT5CTGF.js +0 -21
  147. package/chunks/chunk-LEXQ6E6L.js +0 -31
  148. package/chunks/chunk-LQFKUNVQ.js +0 -19
  149. package/chunks/chunk-MF56TTC5.js +0 -15
  150. package/chunks/chunk-MT74WIQR.js +0 -41
  151. package/chunks/chunk-NRITRUZW.js +0 -10
  152. package/chunks/chunk-NRJQKVQV.js +0 -31
  153. package/chunks/chunk-OSAXBA7G.js +0 -10
  154. package/chunks/chunk-PO3V3I57.js +0 -23
  155. package/chunks/chunk-QXAJXTXV.js +0 -19
  156. package/chunks/chunk-RCO57B6F.js +0 -9
  157. package/chunks/chunk-SQZGZ3VT.js +0 -15
  158. package/chunks/chunk-UYTXXUU7.js +0 -54
  159. package/chunks/chunk-VTPRO4NJ.js +0 -10
  160. package/chunks/chunk-VYW4IADX.js +0 -35
  161. package/chunks/chunk-VZDUZTW6.js +0 -113
  162. package/chunks/chunk-W5A2TON3.js +0 -10
  163. package/chunks/chunk-W7YBGJ4H.js +0 -28
  164. package/chunks/chunk-WLL3FNVL.js +0 -40
  165. package/chunks/chunk-WOAYU6LB.js +0 -13
  166. package/chunks/chunk-XA4HVHJ4.js +0 -18
  167. package/chunks/chunk-XN3PZIVL.js +0 -38
  168. package/chunks/chunk-YDIBNEGA.js +0 -9
  169. package/components/Comp/index.d.ts +0 -1
  170. package/index.d.ts +0 -3
  171. package/node/files/index.d.ts +0 -9
  172. package/node/files/index.js +0 -21
  173. package/node/files/is-in-directory/index.d.ts +0 -1
  174. package/node/files/is-in-directory/index.js +0 -6
  175. package/node/files/read-write/index.d.ts +0 -9
  176. package/node/files/read-write/index.js +0 -6
  177. package/node/files/subpaths/index.d.ts +0 -34
  178. package/node/files/subpaths/index.js +0 -7
  179. package/node/image/index.d.ts +0 -9
  180. package/node/image/index.js +0 -74
  181. package/node/process/index.d.ts +0 -8
  182. package/node/process/index.js +0 -20
  183. package/node/process/on-exit/index.d.ts +0 -5
  184. package/node/process/on-exit/index.js +0 -14
@@ -1,26 +1,4 @@
1
- import { Arrays as ArraysNamespace } from './arrays';
2
- import { Async as AsyncNamespace } from './async';
3
- import { Booleans as BooleansNamespace } from './booleans';
4
- import { Css as CssNamespace } from './css';
5
- import { Errors as ErrorsNamespace } from './errors';
6
- import { Html as HtmlNamespace } from './html';
7
- import { Misc as MiscNamespace } from './misc';
8
- import { Numbers as NumbersNamespace } from './numbers';
9
- import { Objects as ObjectsNamespace } from './objects';
10
- import { Optim as OptimNamespace } from './optim';
11
- import { Regexps as RegexpsNamespace } from './regexps';
12
- import { Strings as StringsNamespace } from './strings';
1
+ import * as MiscNamespace from './misc';
13
2
  export declare namespace Agnostic {
14
- export import Arrays = ArraysNamespace;
15
- export import Async = AsyncNamespace;
16
- export import Booleans = BooleansNamespace;
17
- export import Css = CssNamespace;
18
- export import Errors = ErrorsNamespace;
19
- export import Html = HtmlNamespace;
20
3
  export import Misc = MiscNamespace;
21
- export import Numbers = NumbersNamespace;
22
- export import Objects = ObjectsNamespace;
23
- export import Optim = OptimNamespace;
24
- export import Regexps = RegexpsNamespace;
25
- export import Strings = StringsNamespace;
26
4
  }
@@ -0,0 +1,31 @@
1
+ export declare namespace Elo {
2
+ const K_FACTOR = 32;
3
+ /**
4
+ * Calcule la probabilité de gain de A en fonction des scores Elo de A et B.
5
+ * @param eloA Le score Elo du joueur A.
6
+ * @param eloB Le score Elo du joueur B.
7
+ * @returns La probabilité que le joueur A gagne contre le joueur B.
8
+ */
9
+ function getWinProbability(eloA: number, eloB: number): number;
10
+ /**
11
+ * Calcule les nouveaux classements Elo pour les scénarios de victoire de A, de B et de match nul.
12
+ * @param eloA Le score Elo actuel du joueur A.
13
+ * @param eloB Le score Elo actuel du joueur B.
14
+ * @param kFactor Facteur K pour les calculs Elo (facultatif, valeur par défaut = 32).
15
+ * @returns Un objet contenant les nouveaux classements Elo pour chaque scénario de résultat.
16
+ */
17
+ function getOutcome(eloA: number, eloB: number, kFactor?: number): {
18
+ aWins: {
19
+ eloA: number;
20
+ eloB: number;
21
+ };
22
+ bWins: {
23
+ eloA: number;
24
+ eloB: number;
25
+ };
26
+ null: {
27
+ eloA: number;
28
+ eloB: number;
29
+ };
30
+ };
31
+ }
@@ -0,0 +1,6 @@
1
+ import {
2
+ Elo
3
+ } from "../../../chunks/chunk-ZC5RZBNY.js";
4
+ export {
5
+ Elo
6
+ };
@@ -1,22 +1,6 @@
1
- import { Assert as AssertNamespace } from './assert';
2
- import { Cast as CastNamespace } from './cast';
3
- import { Crossenv as CrossenvNamespace } from './crossenv';
4
- import { getCurrentDownlink as getCurrentDownlinkFunc } from './get-current-downlink';
5
- import { ConstructorFunction as ConstructorFunctionType, isConstructorFunction as isConstructorFunctionFunc } from './is-constructor-function';
6
- import { Nullish as NullishType, isNullish as isNullishFunc, isNotNullish as isNotNullishFunc } from './is-nullish';
7
- import { Logs as LogsNamespace } from './logs';
8
- import { Random as RandomNamespace } from './random';
1
+ import { Elo as EloNamespace } from './elo';
2
+ import { Tennis as TennisNamespace } from './tennis';
9
3
  export declare namespace Misc {
10
- export import Assert = AssertNamespace;
11
- export import Cast = CastNamespace;
12
- export import Crossenv = CrossenvNamespace;
13
- const getCurrentDownlink: typeof getCurrentDownlinkFunc;
14
- type ConstructorFunction = ConstructorFunctionType;
15
- const isConstructorFunction: typeof isConstructorFunctionFunc;
16
- const nullishValues: (null | undefined)[];
17
- type Nullish = NullishType;
18
- const isNullish: typeof isNullishFunc;
19
- const isNotNullish: typeof isNotNullishFunc;
20
- export import Logs = LogsNamespace;
21
- export import Random = RandomNamespace;
4
+ export import Elo = EloNamespace;
5
+ export import Tennis = TennisNamespace;
22
6
  }
@@ -1,44 +1,15 @@
1
1
  import {
2
- Cast
3
- } from "../../chunks/chunk-4QQBKBYH.js";
2
+ Elo
3
+ } from "../../chunks/chunk-ZC5RZBNY.js";
4
4
  import {
5
- getCurrentDownlink
6
- } from "../../chunks/chunk-7AWTHZLY.js";
7
- import {
8
- Logs
9
- } from "../../chunks/chunk-5LNUCDQ6.js";
10
- import {
11
- Assert
12
- } from "../../chunks/chunk-W7YBGJ4H.js";
13
- import {
14
- Random
15
- } from "../../chunks/chunk-WLL3FNVL.js";
16
- import "../../chunks/chunk-QXAJXTXV.js";
17
- import {
18
- isNotNullish,
19
- isNullish,
20
- nullishValues
21
- } from "../../chunks/chunk-HC6ZOHCS.js";
22
- import {
23
- Crossenv
24
- } from "../../chunks/chunk-GJOU3UAL.js";
25
- import {
26
- isConstructorFunction
27
- } from "../../chunks/chunk-RCO57B6F.js";
5
+ Tennis
6
+ } from "../../chunks/chunk-TTZHPIH7.js";
28
7
 
29
8
  // src/agnostic/misc/index.ts
30
9
  var Misc;
31
10
  ((Misc2) => {
32
- Misc2.Assert = Assert;
33
- Misc2.Cast = Cast;
34
- Misc2.Crossenv = Crossenv;
35
- Misc2.getCurrentDownlink = getCurrentDownlink;
36
- Misc2.isConstructorFunction = isConstructorFunction;
37
- Misc2.nullishValues = nullishValues;
38
- Misc2.isNullish = isNullish;
39
- Misc2.isNotNullish = isNotNullish;
40
- Misc2.Logs = Logs;
41
- Misc2.Random = Random;
11
+ Misc2.Elo = Elo;
12
+ Misc2.Tennis = Tennis;
42
13
  })(Misc || (Misc = {}));
43
14
  export {
44
15
  Misc
@@ -0,0 +1,60 @@
1
+ export declare namespace Tennis {
2
+ namespace Score {
3
+ type PointDescriptor = boolean;
4
+ type GameFormat = {
5
+ upTo: number;
6
+ diffToWin: number;
7
+ };
8
+ class Game {
9
+ private format;
10
+ private pointsSequence;
11
+ constructor(format: GameFormat);
12
+ add(point: PointDescriptor): this;
13
+ getNumericScore(): [number, number];
14
+ static numericToStringScoreValue(numScore: [number, number]): string;
15
+ getScore(): string;
16
+ isFinished(): boolean;
17
+ getWinner(): boolean | null;
18
+ }
19
+ type SetFormat = {
20
+ upTo: number;
21
+ diffToWin: number;
22
+ gamesFormat: GameFormat;
23
+ tieBreakAt: number | null;
24
+ tieBreakFormat: GameFormat;
25
+ };
26
+ class Set {
27
+ private format;
28
+ private pointsSequence;
29
+ constructor(format: SetFormat);
30
+ add(point: PointDescriptor): void;
31
+ getGames(): Game[];
32
+ getNumericScore(): {
33
+ games: [number, number];
34
+ currentGame?: [number, number];
35
+ };
36
+ getScore(): string;
37
+ isFinished(): boolean;
38
+ getWinner(): boolean | null;
39
+ }
40
+ type MatchFormat = {
41
+ upTo: number;
42
+ setsFormat: SetFormat;
43
+ lastSetFormat: SetFormat;
44
+ };
45
+ class Match {
46
+ private format;
47
+ private pointsSequence;
48
+ constructor(format: MatchFormat);
49
+ add(point: PointDescriptor): void;
50
+ getSets(): Set[];
51
+ getNumericScore(): {
52
+ sets: [number, number][];
53
+ currentGame?: [number, number];
54
+ };
55
+ getScore(): string;
56
+ isFinished(): boolean;
57
+ getWinner(): boolean | null;
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,6 @@
1
+ import {
2
+ Tennis
3
+ } from "../../../chunks/chunk-TTZHPIH7.js";
4
+ export {
5
+ Tennis
6
+ };
@@ -0,0 +1,237 @@
1
+ // src/agnostic/misc/tennis/index.ts
2
+ var Tennis;
3
+ ((Tennis2) => {
4
+ let Score;
5
+ ((Score2) => {
6
+ class Game {
7
+ format;
8
+ pointsSequence = [];
9
+ constructor(format) {
10
+ this.format = format;
11
+ }
12
+ add(point) {
13
+ if (!this.isFinished()) this.pointsSequence.push(point);
14
+ return this;
15
+ }
16
+ getNumericScore() {
17
+ const { pointsSequence, format } = this;
18
+ const { upTo, diffToWin } = format;
19
+ return pointsSequence.reduce((reduced, point) => {
20
+ const [aScore, bScore] = reduced;
21
+ const aWon = aScore >= upTo && aScore - bScore >= diffToWin;
22
+ const bWon = bScore >= upTo && bScore - aScore >= diffToWin;
23
+ if (aWon || bWon) return reduced;
24
+ return point ? [aScore + 1, bScore] : [aScore, bScore + 1];
25
+ }, [0, 0]);
26
+ }
27
+ static numericToStringScoreValue(numScore) {
28
+ const [aScore, bScore] = numScore;
29
+ if (aScore >= 3 && bScore >= 3) {
30
+ if (aScore === bScore) return "deuce";
31
+ if (aScore < bScore) return "Ad/40";
32
+ return "40/Ad";
33
+ }
34
+ const strScoresList = ["0", "15", "30", "40"];
35
+ return `${strScoresList.at(aScore) ?? "?"}/${strScoresList.at(bScore) ?? "?"}`;
36
+ }
37
+ getScore() {
38
+ return Game.numericToStringScoreValue(this.getNumericScore());
39
+ }
40
+ isFinished() {
41
+ const { format } = this;
42
+ const { upTo, diffToWin } = format;
43
+ const [aScore, bScore] = this.getNumericScore();
44
+ const maxScoreReached = Math.max(aScore, bScore) >= upTo;
45
+ const diffReached = Math.abs(aScore - bScore) >= diffToWin;
46
+ if (maxScoreReached && diffReached) return true;
47
+ return false;
48
+ }
49
+ getWinner() {
50
+ if (!this.isFinished()) return null;
51
+ const [aScore, bScore] = this.getNumericScore();
52
+ return aScore > bScore;
53
+ }
54
+ }
55
+ Score2.Game = Game;
56
+ class Set {
57
+ format;
58
+ pointsSequence = [];
59
+ constructor(format) {
60
+ this.format = format;
61
+ }
62
+ add(point) {
63
+ this.pointsSequence.push(point);
64
+ }
65
+ getGames() {
66
+ const { format } = this;
67
+ const { upTo, diffToWin, gamesFormat, tieBreakFormat, tieBreakAt } = format;
68
+ let aGames = 0;
69
+ let bGames = 0;
70
+ const games = [];
71
+ const { pointsSequence } = this;
72
+ pointsSequence.forEach((point) => {
73
+ const maxGamesReached = Math.max(aGames, bGames) >= upTo;
74
+ const diffReached = Math.abs(aGames - bGames) >= diffToWin;
75
+ if (maxGamesReached && diffReached) return;
76
+ const lastGameInList = games.at(-1);
77
+ const lastGameIsFinished = lastGameInList?.isFinished();
78
+ if (lastGameInList === void 0 || lastGameIsFinished === true) {
79
+ const isTiebreak = aGames === bGames && aGames === tieBreakAt;
80
+ if (isTiebreak) games.push(new Game(tieBreakFormat));
81
+ else games.push(new Game(gamesFormat));
82
+ }
83
+ const currentGame = games.at(-1);
84
+ if (currentGame === void 0) throw "Something went wrong, this should't be undefined";
85
+ currentGame.add(point);
86
+ const currentGameWinner = currentGame.getWinner();
87
+ if (currentGameWinner === true) {
88
+ aGames += 1;
89
+ }
90
+ if (currentGameWinner === false) {
91
+ bGames += 1;
92
+ }
93
+ });
94
+ return games;
95
+ }
96
+ getNumericScore() {
97
+ const games = this.getGames();
98
+ let aScore = 0;
99
+ let bScore = 0;
100
+ games.forEach((game) => {
101
+ const winner = game.getWinner();
102
+ if (winner === true) {
103
+ aScore++;
104
+ }
105
+ if (winner === false) {
106
+ bScore++;
107
+ }
108
+ });
109
+ const lastGame = games.at(-1);
110
+ if (lastGame === void 0) return { games: [aScore, bScore] };
111
+ if (lastGame.isFinished() === false) return {
112
+ games: [aScore, bScore],
113
+ currentGame: lastGame.getNumericScore()
114
+ };
115
+ return { games: [aScore, bScore] };
116
+ }
117
+ getScore() {
118
+ const numericScore = this.getNumericScore();
119
+ const { games, currentGame } = numericScore;
120
+ if (currentGame === void 0) return `${games.join("/")}`;
121
+ return `${games.join("/")} ${Game.numericToStringScoreValue(currentGame)}`;
122
+ }
123
+ isFinished() {
124
+ const { format } = this;
125
+ const { upTo, diffToWin, tieBreakAt } = format;
126
+ const [aScore, bScore] = this.getNumericScore().games;
127
+ const maxGamesReached = Math.max(aScore, bScore) >= upTo;
128
+ const diffReached = Math.abs(aScore - bScore) >= diffToWin;
129
+ const tieBreakBeenPlayed = tieBreakAt !== null && Math.max(aScore, bScore) > tieBreakAt;
130
+ return tieBreakBeenPlayed || maxGamesReached && diffReached;
131
+ }
132
+ getWinner() {
133
+ if (!this.isFinished()) return null;
134
+ const [aScore, bScore] = this.getNumericScore().games;
135
+ return aScore > bScore;
136
+ }
137
+ }
138
+ Score2.Set = Set;
139
+ class Match {
140
+ format;
141
+ pointsSequence = [];
142
+ constructor(format) {
143
+ this.format = format;
144
+ }
145
+ add(point) {
146
+ this.pointsSequence.push(point);
147
+ }
148
+ getSets() {
149
+ const { format } = this;
150
+ const { upTo, setsFormat, lastSetFormat } = format;
151
+ let aSets = 0;
152
+ let bSets = 0;
153
+ const sets = [];
154
+ const { pointsSequence } = this;
155
+ pointsSequence.forEach((point) => {
156
+ const maxSetsReached = Math.max(aSets, bSets) >= upTo;
157
+ if (maxSetsReached) return;
158
+ const lastSetInList = sets.at(-1);
159
+ const lastSetIsFinished = lastSetInList?.isFinished();
160
+ if (lastSetInList === void 0 || lastSetIsFinished === true) {
161
+ const isLastSet = aSets === bSets && aSets === upTo - 1;
162
+ if (isLastSet) sets.push(new Set(lastSetFormat));
163
+ else sets.push(new Set(setsFormat));
164
+ }
165
+ const currentSet = sets.at(-1);
166
+ if (currentSet === void 0) throw "Something went wrong, this should't be undefined";
167
+ currentSet.add(point);
168
+ const currentSetWinner = currentSet.getWinner();
169
+ if (currentSetWinner === true) {
170
+ aSets += 1;
171
+ }
172
+ if (currentSetWinner === false) {
173
+ bSets += 1;
174
+ }
175
+ });
176
+ return sets;
177
+ }
178
+ getNumericScore() {
179
+ const sets = this.getSets();
180
+ const numericScore = {
181
+ sets: [],
182
+ currentGame: void 0
183
+ };
184
+ sets.forEach((set) => {
185
+ const setNumericScore = set.getNumericScore();
186
+ const { games, currentGame } = setNumericScore;
187
+ numericScore.sets.push(games);
188
+ if (currentGame !== void 0) {
189
+ numericScore.currentGame = currentGame;
190
+ }
191
+ });
192
+ return numericScore;
193
+ }
194
+ getScore() {
195
+ return this.getSets().map((set) => set.getScore()).join(" ");
196
+ }
197
+ isFinished() {
198
+ const { format } = this;
199
+ const { upTo } = format;
200
+ const sets = this.getSets();
201
+ let aSets = 0;
202
+ let bSets = 0;
203
+ sets.forEach((set) => {
204
+ const winner = set.getWinner();
205
+ if (winner === true) {
206
+ aSets++;
207
+ }
208
+ if (winner === false) {
209
+ bSets++;
210
+ }
211
+ });
212
+ return Math.max(aSets, bSets) >= upTo;
213
+ }
214
+ getWinner() {
215
+ if (!this.isFinished()) return null;
216
+ const sets = this.getSets();
217
+ let aSets = 0;
218
+ let bSets = 0;
219
+ sets.forEach((set) => {
220
+ const winner = set.getWinner();
221
+ if (winner === true) {
222
+ aSets++;
223
+ }
224
+ if (winner === false) {
225
+ bSets++;
226
+ }
227
+ });
228
+ return aSets > bSets;
229
+ }
230
+ }
231
+ Score2.Match = Match;
232
+ })(Score = Tennis2.Score || (Tennis2.Score = {}));
233
+ })(Tennis || (Tennis = {}));
234
+
235
+ export {
236
+ Tennis
237
+ };
@@ -0,0 +1,33 @@
1
+ // src/agnostic/misc/elo/index.ts
2
+ var Elo;
3
+ ((Elo2) => {
4
+ Elo2.K_FACTOR = 32;
5
+ function getWinProbability(eloA, eloB) {
6
+ const exponent = (eloB - eloA) / 400;
7
+ return 1 / (1 + Math.pow(10, exponent));
8
+ }
9
+ Elo2.getWinProbability = getWinProbability;
10
+ function getOutcome(eloA, eloB, kFactor = Elo2.K_FACTOR) {
11
+ const probA = getWinProbability(eloA, eloB);
12
+ const probB = 1 - probA;
13
+ return {
14
+ aWins: {
15
+ eloA: Math.round(eloA + kFactor * (1 - probA)),
16
+ eloB: Math.round(eloB + kFactor * (0 - probB))
17
+ },
18
+ bWins: {
19
+ eloA: Math.round(eloA + kFactor * (0 - probA)),
20
+ eloB: Math.round(eloB + kFactor * (1 - probB))
21
+ },
22
+ null: {
23
+ eloA: Math.round(eloA + kFactor * (0.5 - probA)),
24
+ eloB: Math.round(eloB + kFactor * (0.5 - probB))
25
+ }
26
+ };
27
+ }
28
+ Elo2.getOutcome = getOutcome;
29
+ })(Elo || (Elo = {}));
30
+
31
+ export {
32
+ Elo
33
+ };
@@ -1,4 +1 @@
1
- import CompClass from './Comp';
2
- export declare namespace Components {
3
- const Comp: typeof CompClass;
4
- }
1
+ export declare namespace Components { }
package/node/index.d.ts CHANGED
@@ -1,6 +1,2 @@
1
- import { Files as FilesNamespace } from './files';
2
- import { Process as ProcessNamespace } from './process';
3
- export declare namespace Node {
4
- export import Files = FilesNamespace;
5
- export import Process = ProcessNamespace;
6
- }
1
+ import * as MxfbCliConfig from './mxfb-cli-config';
2
+ export { MxfbCliConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mxfb/tools",
3
- "version": "0.1.1",
3
+ "version": "0.2.3",
4
4
  "description": "",
5
5
  "author": "Maxime Fabas",
6
6
  "license": "ISC",
@@ -12,9 +12,9 @@
12
12
  "main": "index.js",
13
13
  "module": "index.js",
14
14
  "peerDependencies": {
15
+ "@design-edito/tools": "^0.1.73",
15
16
  "chalk": "^5.3.0",
16
17
  "fs-extra": "^11.2.0",
17
- "get-image-colors": "^4.0.1",
18
18
  "jsdom": "^24.1.1",
19
19
  "node-fetch": "^3.3.2",
20
20
  "react": "^18.3.1",
@@ -22,20 +22,20 @@
22
22
  "sharp": "^0.33.3"
23
23
  },
24
24
  "devDependencies": {
25
- "@types/chalk": "^2.2.0",
26
- "@types/fs-extra": "^11.0.4",
27
- "@types/get-image-colors": "^4.0.5",
28
- "@types/jsdom": "^21.1.7",
29
- "@types/node": "^22.1.0",
25
+ "@types/node": "^22.15.21",
30
26
  "@types/prompts": "^2.4.9",
31
- "@types/react": "^18.3.3",
32
- "@types/react-dom": "^18.3.0",
33
- "@types/semver": "^7.5.8",
34
- "camelcase": "^8.0.0",
35
- "esbuild": "^0.23.0",
27
+ "@types/semver": "^7.7.0",
28
+ "chalk": "^5.4.1",
29
+ "chokidar-cli": "^3.0.0",
30
+ "concurrently": "^9.1.2",
31
+ "esbuild": "^0.25.5",
36
32
  "prompts": "^2.4.2",
37
- "semver": "^7.6.3",
38
- "simple-git": "^3.25.0",
39
- "typescript": "^5.5.4"
33
+ "puppeteer": "^24.9.0",
34
+ "react": "^19.1.0",
35
+ "react-dom": "^19.1.0",
36
+ "semver": "^7.7.2",
37
+ "sharp": "^0.34.2",
38
+ "simple-git": "^3.27.0",
39
+ "typescript": "^5.8.3"
40
40
  }
41
41
  }