y-ary 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +186 -0
- package/dist/index.cjs +261 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +247 -0
- package/dist/index.d.ts +247 -0
- package/dist/index.js +228 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interprets a mathematical formula by replacing variables with their values
|
|
3
|
+
* @param formula - Mathematical formula as a string (e.g., 'x/1 + y')
|
|
4
|
+
* @param where - Object mapping variable names to their numeric values (e.g., {x: 4, y: 6})
|
|
5
|
+
* @returns The evaluated result of the formula
|
|
6
|
+
*/
|
|
7
|
+
declare const formulaInterpreter: (formula: string, where: {
|
|
8
|
+
[key: string]: number;
|
|
9
|
+
}) => number;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Generates an array or matrix by randomly selecting numbers from a bank with occurrence limits.
|
|
13
|
+
*
|
|
14
|
+
* @param bankNums - Object where keys are the numbers to use and values are the maximum
|
|
15
|
+
* number of times each number can appear in the array.
|
|
16
|
+
* Example: { 1: 3, 2: 3, 3: 3 } means number 1 can appear up to 3 times,
|
|
17
|
+
* number 2 can appear up to 3 times, etc.
|
|
18
|
+
*
|
|
19
|
+
* @param dims - Array dimensions:
|
|
20
|
+
* - [length]: Creates a 1D array with the specified length
|
|
21
|
+
* - [rows, cols]: Creates a 2D array (matrix) with the specified rows and columns
|
|
22
|
+
*
|
|
23
|
+
* @param extraRules - Optional validation callback that receives:
|
|
24
|
+
* - candidateNum: The number being considered for addition
|
|
25
|
+
* - currentArray: The flattened array built so far (for 2D arrays, this is all elements)
|
|
26
|
+
* Returns true to allow the number, false to reject it and try another.
|
|
27
|
+
*
|
|
28
|
+
* @returns A 1D array or 2D array (matrix) of numbers randomly selected from bankNums,
|
|
29
|
+
* respecting occurrence limits and any extra validation rules.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Generate 1D array of length 5
|
|
33
|
+
* const result1D = arrayWithBankNums(
|
|
34
|
+
* { 1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3, 7: 3, 8: 3, 9: 3, 10: 3 },
|
|
35
|
+
* [5]
|
|
36
|
+
* );
|
|
37
|
+
* // Possible result: [3, 7, 1, 9, 2]
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Generate 2D array (matrix) of 3 rows x 4 columns
|
|
41
|
+
* const result2D = arrayWithBankNums(
|
|
42
|
+
* { 1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3 },
|
|
43
|
+
* [3, 4]
|
|
44
|
+
* );
|
|
45
|
+
* // Possible result: [[1, 3, 2, 5], [4, 1, 6, 3], [2, 5, 4, 6]]
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // With extraRules: only allow even numbers
|
|
49
|
+
* const result = arrayWithBankNums(
|
|
50
|
+
* { 1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3 },
|
|
51
|
+
* [4],
|
|
52
|
+
* (num, arr) => num % 2 === 0
|
|
53
|
+
* );
|
|
54
|
+
* // Possible result: [2, 4, 6, 2]
|
|
55
|
+
*/
|
|
56
|
+
declare const arrayWithBankNums: (bankNums: {
|
|
57
|
+
[n: number]: number;
|
|
58
|
+
}, dims: number[], extraRules?: (candidateNum: number, currentArray: number[]) => boolean) => number[] | number[][];
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Array Rules - Colección de funciones de validación para usar con arrayWithBankNums
|
|
62
|
+
*
|
|
63
|
+
* Estas funciones pueden ser usadas como el parámetro `extraRules` en arrayWithBankNums
|
|
64
|
+
* para aplicar restricciones adicionales durante la generación del array.
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* Type definition for array rule functions
|
|
68
|
+
*/
|
|
69
|
+
type ArrayRule = (candidateNum: number, currentArray: number[]) => boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Solo permite números pares
|
|
72
|
+
* @example arrayWithBankNums(bankNums, [5], onlyEven)
|
|
73
|
+
*/
|
|
74
|
+
declare const onlyEven: ArrayRule;
|
|
75
|
+
/**
|
|
76
|
+
* Solo permite números impares
|
|
77
|
+
* @example arrayWithBankNums(bankNums, [5], onlyOdd)
|
|
78
|
+
*/
|
|
79
|
+
declare const onlyOdd: ArrayRule;
|
|
80
|
+
/**
|
|
81
|
+
* Crea una regla que solo permite números dentro de un rango específico
|
|
82
|
+
* @param min - Valor mínimo (inclusivo)
|
|
83
|
+
* @param max - Valor máximo (inclusivo)
|
|
84
|
+
* @example arrayWithBankNums(bankNums, [5], inRange(1, 5))
|
|
85
|
+
*/
|
|
86
|
+
declare const inRange: (min: number, max: number) => ArrayRule;
|
|
87
|
+
/**
|
|
88
|
+
* Crea una regla que excluye números dentro de un rango específico
|
|
89
|
+
* @param min - Valor mínimo a excluir (inclusivo)
|
|
90
|
+
* @param max - Valor máximo a excluir (inclusivo)
|
|
91
|
+
* @example arrayWithBankNums(bankNums, [5], notInRange(3, 7))
|
|
92
|
+
*/
|
|
93
|
+
declare const notInRange: (min: number, max: number) => ArrayRule;
|
|
94
|
+
/**
|
|
95
|
+
* No permite números consecutivos repetidos
|
|
96
|
+
* @example arrayWithBankNums(bankNums, [5], noConsecutiveRepeats)
|
|
97
|
+
*/
|
|
98
|
+
declare const noConsecutiveRepeats: ArrayRule;
|
|
99
|
+
/**
|
|
100
|
+
* No permite que un número aparezca más de N veces en el array
|
|
101
|
+
* @param maxCount - Número máximo de veces que puede aparecer
|
|
102
|
+
* @example arrayWithBankNums(bankNums, [10], maxOccurrences(2))
|
|
103
|
+
*/
|
|
104
|
+
declare const maxOccurrences: (maxCount: number) => ArrayRule;
|
|
105
|
+
/**
|
|
106
|
+
* No permite duplicados en el array (cada número solo puede aparecer una vez)
|
|
107
|
+
* @example arrayWithBankNums(bankNums, [5], noDuplicates)
|
|
108
|
+
*/
|
|
109
|
+
declare const noDuplicates: ArrayRule;
|
|
110
|
+
/**
|
|
111
|
+
* No permite que el mismo número aparezca en las últimas N posiciones
|
|
112
|
+
* @param positions - Número de posiciones a verificar
|
|
113
|
+
* @example arrayWithBankNums(bankNums, [10], noRepeatInLast(3))
|
|
114
|
+
*/
|
|
115
|
+
declare const noRepeatInLast: (positions: number) => ArrayRule;
|
|
116
|
+
/**
|
|
117
|
+
* Solo permite números que mantengan la suma total por debajo de un límite
|
|
118
|
+
* @param maxSum - Suma máxima permitida
|
|
119
|
+
* @example arrayWithBankNums(bankNums, [5], sumLessThan(20))
|
|
120
|
+
*/
|
|
121
|
+
declare const sumLessThan: (maxSum: number) => ArrayRule;
|
|
122
|
+
/**
|
|
123
|
+
* Solo permite números que mantengan la suma total por encima de un límite
|
|
124
|
+
* @param minSum - Suma mínima requerida
|
|
125
|
+
* @example arrayWithBankNums(bankNums, [5], sumGreaterThan(10))
|
|
126
|
+
*/
|
|
127
|
+
declare const sumGreaterThan: (minSum: number) => ArrayRule;
|
|
128
|
+
/**
|
|
129
|
+
* Solo permite números que mantengan el promedio dentro de un rango
|
|
130
|
+
* @param min - Promedio mínimo
|
|
131
|
+
* @param max - Promedio máximo
|
|
132
|
+
* @example arrayWithBankNums(bankNums, [5], averageInRange(3, 7))
|
|
133
|
+
*/
|
|
134
|
+
declare const averageInRange: (min: number, max: number) => ArrayRule;
|
|
135
|
+
/**
|
|
136
|
+
* Solo permite números que sean mayores que el último número en el array (orden ascendente)
|
|
137
|
+
* @example arrayWithBankNums(bankNums, [5], ascending)
|
|
138
|
+
*/
|
|
139
|
+
declare const ascending: ArrayRule;
|
|
140
|
+
/**
|
|
141
|
+
* Solo permite números que sean menores que el último número en el array (orden descendente)
|
|
142
|
+
* @example arrayWithBankNums(bankNums, [5], descending)
|
|
143
|
+
*/
|
|
144
|
+
declare const descending: ArrayRule;
|
|
145
|
+
/**
|
|
146
|
+
* Solo permite números que sean diferentes del último número (no estrictamente ascendente/descendente)
|
|
147
|
+
* @example arrayWithBankNums(bankNums, [5], different)
|
|
148
|
+
*/
|
|
149
|
+
declare const different: ArrayRule;
|
|
150
|
+
/**
|
|
151
|
+
* Alterna entre números pares e impares
|
|
152
|
+
* @example arrayWithBankNums(bankNums, [6], alternateEvenOdd)
|
|
153
|
+
*/
|
|
154
|
+
declare const alternateEvenOdd: ArrayRule;
|
|
155
|
+
/**
|
|
156
|
+
* Solo permite números divisibles por un divisor específico
|
|
157
|
+
* @param divisor - El divisor
|
|
158
|
+
* @example arrayWithBankNums(bankNums, [5], divisibleBy(3))
|
|
159
|
+
*/
|
|
160
|
+
declare const divisibleBy: (divisor: number) => ArrayRule;
|
|
161
|
+
/**
|
|
162
|
+
* Solo permite números que NO sean divisibles por un divisor específico
|
|
163
|
+
* @param divisor - El divisor
|
|
164
|
+
* @example arrayWithBankNums(bankNums, [5], notDivisibleBy(5))
|
|
165
|
+
*/
|
|
166
|
+
declare const notDivisibleBy: (divisor: number) => ArrayRule;
|
|
167
|
+
/**
|
|
168
|
+
* Aplica diferentes reglas según la posición en el array
|
|
169
|
+
* @param rules - Objeto que mapea índices a reglas
|
|
170
|
+
* @example arrayWithBankNums(bankNums, [5], byPosition({ 0: onlyEven, 1: onlyOdd }))
|
|
171
|
+
*/
|
|
172
|
+
declare const byPosition: (rules: {
|
|
173
|
+
[index: number]: ArrayRule;
|
|
174
|
+
}) => ArrayRule;
|
|
175
|
+
/**
|
|
176
|
+
* Aplica una regla solo en posiciones pares (0, 2, 4, ...)
|
|
177
|
+
* @param rule - La regla a aplicar
|
|
178
|
+
* @example arrayWithBankNums(bankNums, [6], onEvenPositions(onlyEven))
|
|
179
|
+
*/
|
|
180
|
+
declare const onEvenPositions: (rule: ArrayRule) => ArrayRule;
|
|
181
|
+
/**
|
|
182
|
+
* Aplica una regla solo en posiciones impares (1, 3, 5, ...)
|
|
183
|
+
* @param rule - La regla a aplicar
|
|
184
|
+
* @example arrayWithBankNums(bankNums, [6], onOddPositions(onlyOdd))
|
|
185
|
+
*/
|
|
186
|
+
declare const onOddPositions: (rule: ArrayRule) => ArrayRule;
|
|
187
|
+
/**
|
|
188
|
+
* Combina múltiples reglas con AND (todas deben cumplirse)
|
|
189
|
+
* @param rules - Array de reglas a combinar
|
|
190
|
+
* @example arrayWithBankNums(bankNums, [5], and([onlyEven, inRange(2, 8)]))
|
|
191
|
+
*/
|
|
192
|
+
declare const and: (rules: ArrayRule[]) => ArrayRule;
|
|
193
|
+
/**
|
|
194
|
+
* Combina múltiples reglas con OR (al menos una debe cumplirse)
|
|
195
|
+
* @param rules - Array de reglas a combinar
|
|
196
|
+
* @example arrayWithBankNums(bankNums, [5], or([onlyEven, divisibleBy(3)]))
|
|
197
|
+
*/
|
|
198
|
+
declare const or: (rules: ArrayRule[]) => ArrayRule;
|
|
199
|
+
/**
|
|
200
|
+
* Invierte una regla (NOT)
|
|
201
|
+
* @param rule - La regla a invertir
|
|
202
|
+
* @example arrayWithBankNums(bankNums, [5], not(onlyEven)) // Solo impares
|
|
203
|
+
*/
|
|
204
|
+
declare const not: (rule: ArrayRule) => ArrayRule;
|
|
205
|
+
/**
|
|
206
|
+
* Solo permite números primos
|
|
207
|
+
* @example arrayWithBankNums(bankNums, [5], onlyPrimes)
|
|
208
|
+
*/
|
|
209
|
+
declare const onlyPrimes: ArrayRule;
|
|
210
|
+
/**
|
|
211
|
+
* Solo permite números que sean cuadrados perfectos
|
|
212
|
+
* @example arrayWithBankNums(bankNums, [5], onlySquares)
|
|
213
|
+
*/
|
|
214
|
+
declare const onlySquares: ArrayRule;
|
|
215
|
+
/**
|
|
216
|
+
* Asegura que la diferencia entre números consecutivos no exceda un límite
|
|
217
|
+
* @param maxDiff - Diferencia máxima permitida
|
|
218
|
+
* @example arrayWithBankNums(bankNums, [5], maxDifference(3))
|
|
219
|
+
*/
|
|
220
|
+
declare const maxDifference: (maxDiff: number) => ArrayRule;
|
|
221
|
+
/**
|
|
222
|
+
* Asegura que la diferencia entre números consecutivos sea al menos un mínimo
|
|
223
|
+
* @param minDiff - Diferencia mínima requerida
|
|
224
|
+
* @example arrayWithBankNums(bankNums, [5], minDifference(2))
|
|
225
|
+
*/
|
|
226
|
+
declare const minDifference: (minDiff: number) => ArrayRule;
|
|
227
|
+
/**
|
|
228
|
+
* Mantiene un balance entre números pares e impares
|
|
229
|
+
* @param maxImbalance - Diferencia máxima permitida entre cantidad de pares e impares
|
|
230
|
+
* @example arrayWithBankNums(bankNums, [10], balanceEvenOdd(2))
|
|
231
|
+
*/
|
|
232
|
+
declare const balanceEvenOdd: (maxImbalance?: number) => ArrayRule;
|
|
233
|
+
/**
|
|
234
|
+
* Solo permite números en posiciones específicas del array
|
|
235
|
+
* @param allowedPositions - Array de posiciones permitidas (0-indexed)
|
|
236
|
+
* @param value - El valor que solo puede aparecer en esas posiciones
|
|
237
|
+
* @example arrayWithBankNums(bankNums, [5], valueAtPositions([0, 2, 4], 7))
|
|
238
|
+
*/
|
|
239
|
+
declare const valueAtPositions: (allowedPositions: number[], value: number) => ArrayRule;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Y-ary package entry point
|
|
243
|
+
* Export your public API here
|
|
244
|
+
*/
|
|
245
|
+
declare function hello(name: string): string;
|
|
246
|
+
|
|
247
|
+
export { type ArrayRule, alternateEvenOdd, and, arrayWithBankNums, ascending, averageInRange, balanceEvenOdd, byPosition, descending, different, divisibleBy, formulaInterpreter, hello, inRange, maxDifference, maxOccurrences, minDifference, noConsecutiveRepeats, noDuplicates, noRepeatInLast, not, notDivisibleBy, notInRange, onEvenPositions, onOddPositions, onlyEven, onlyOdd, onlyPrimes, onlySquares, or, sumGreaterThan, sumLessThan, valueAtPositions };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interprets a mathematical formula by replacing variables with their values
|
|
3
|
+
* @param formula - Mathematical formula as a string (e.g., 'x/1 + y')
|
|
4
|
+
* @param where - Object mapping variable names to their numeric values (e.g., {x: 4, y: 6})
|
|
5
|
+
* @returns The evaluated result of the formula
|
|
6
|
+
*/
|
|
7
|
+
declare const formulaInterpreter: (formula: string, where: {
|
|
8
|
+
[key: string]: number;
|
|
9
|
+
}) => number;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Generates an array or matrix by randomly selecting numbers from a bank with occurrence limits.
|
|
13
|
+
*
|
|
14
|
+
* @param bankNums - Object where keys are the numbers to use and values are the maximum
|
|
15
|
+
* number of times each number can appear in the array.
|
|
16
|
+
* Example: { 1: 3, 2: 3, 3: 3 } means number 1 can appear up to 3 times,
|
|
17
|
+
* number 2 can appear up to 3 times, etc.
|
|
18
|
+
*
|
|
19
|
+
* @param dims - Array dimensions:
|
|
20
|
+
* - [length]: Creates a 1D array with the specified length
|
|
21
|
+
* - [rows, cols]: Creates a 2D array (matrix) with the specified rows and columns
|
|
22
|
+
*
|
|
23
|
+
* @param extraRules - Optional validation callback that receives:
|
|
24
|
+
* - candidateNum: The number being considered for addition
|
|
25
|
+
* - currentArray: The flattened array built so far (for 2D arrays, this is all elements)
|
|
26
|
+
* Returns true to allow the number, false to reject it and try another.
|
|
27
|
+
*
|
|
28
|
+
* @returns A 1D array or 2D array (matrix) of numbers randomly selected from bankNums,
|
|
29
|
+
* respecting occurrence limits and any extra validation rules.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* // Generate 1D array of length 5
|
|
33
|
+
* const result1D = arrayWithBankNums(
|
|
34
|
+
* { 1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3, 7: 3, 8: 3, 9: 3, 10: 3 },
|
|
35
|
+
* [5]
|
|
36
|
+
* );
|
|
37
|
+
* // Possible result: [3, 7, 1, 9, 2]
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* // Generate 2D array (matrix) of 3 rows x 4 columns
|
|
41
|
+
* const result2D = arrayWithBankNums(
|
|
42
|
+
* { 1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3 },
|
|
43
|
+
* [3, 4]
|
|
44
|
+
* );
|
|
45
|
+
* // Possible result: [[1, 3, 2, 5], [4, 1, 6, 3], [2, 5, 4, 6]]
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* // With extraRules: only allow even numbers
|
|
49
|
+
* const result = arrayWithBankNums(
|
|
50
|
+
* { 1: 3, 2: 3, 3: 3, 4: 3, 5: 3, 6: 3 },
|
|
51
|
+
* [4],
|
|
52
|
+
* (num, arr) => num % 2 === 0
|
|
53
|
+
* );
|
|
54
|
+
* // Possible result: [2, 4, 6, 2]
|
|
55
|
+
*/
|
|
56
|
+
declare const arrayWithBankNums: (bankNums: {
|
|
57
|
+
[n: number]: number;
|
|
58
|
+
}, dims: number[], extraRules?: (candidateNum: number, currentArray: number[]) => boolean) => number[] | number[][];
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Array Rules - Colección de funciones de validación para usar con arrayWithBankNums
|
|
62
|
+
*
|
|
63
|
+
* Estas funciones pueden ser usadas como el parámetro `extraRules` en arrayWithBankNums
|
|
64
|
+
* para aplicar restricciones adicionales durante la generación del array.
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
* Type definition for array rule functions
|
|
68
|
+
*/
|
|
69
|
+
type ArrayRule = (candidateNum: number, currentArray: number[]) => boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Solo permite números pares
|
|
72
|
+
* @example arrayWithBankNums(bankNums, [5], onlyEven)
|
|
73
|
+
*/
|
|
74
|
+
declare const onlyEven: ArrayRule;
|
|
75
|
+
/**
|
|
76
|
+
* Solo permite números impares
|
|
77
|
+
* @example arrayWithBankNums(bankNums, [5], onlyOdd)
|
|
78
|
+
*/
|
|
79
|
+
declare const onlyOdd: ArrayRule;
|
|
80
|
+
/**
|
|
81
|
+
* Crea una regla que solo permite números dentro de un rango específico
|
|
82
|
+
* @param min - Valor mínimo (inclusivo)
|
|
83
|
+
* @param max - Valor máximo (inclusivo)
|
|
84
|
+
* @example arrayWithBankNums(bankNums, [5], inRange(1, 5))
|
|
85
|
+
*/
|
|
86
|
+
declare const inRange: (min: number, max: number) => ArrayRule;
|
|
87
|
+
/**
|
|
88
|
+
* Crea una regla que excluye números dentro de un rango específico
|
|
89
|
+
* @param min - Valor mínimo a excluir (inclusivo)
|
|
90
|
+
* @param max - Valor máximo a excluir (inclusivo)
|
|
91
|
+
* @example arrayWithBankNums(bankNums, [5], notInRange(3, 7))
|
|
92
|
+
*/
|
|
93
|
+
declare const notInRange: (min: number, max: number) => ArrayRule;
|
|
94
|
+
/**
|
|
95
|
+
* No permite números consecutivos repetidos
|
|
96
|
+
* @example arrayWithBankNums(bankNums, [5], noConsecutiveRepeats)
|
|
97
|
+
*/
|
|
98
|
+
declare const noConsecutiveRepeats: ArrayRule;
|
|
99
|
+
/**
|
|
100
|
+
* No permite que un número aparezca más de N veces en el array
|
|
101
|
+
* @param maxCount - Número máximo de veces que puede aparecer
|
|
102
|
+
* @example arrayWithBankNums(bankNums, [10], maxOccurrences(2))
|
|
103
|
+
*/
|
|
104
|
+
declare const maxOccurrences: (maxCount: number) => ArrayRule;
|
|
105
|
+
/**
|
|
106
|
+
* No permite duplicados en el array (cada número solo puede aparecer una vez)
|
|
107
|
+
* @example arrayWithBankNums(bankNums, [5], noDuplicates)
|
|
108
|
+
*/
|
|
109
|
+
declare const noDuplicates: ArrayRule;
|
|
110
|
+
/**
|
|
111
|
+
* No permite que el mismo número aparezca en las últimas N posiciones
|
|
112
|
+
* @param positions - Número de posiciones a verificar
|
|
113
|
+
* @example arrayWithBankNums(bankNums, [10], noRepeatInLast(3))
|
|
114
|
+
*/
|
|
115
|
+
declare const noRepeatInLast: (positions: number) => ArrayRule;
|
|
116
|
+
/**
|
|
117
|
+
* Solo permite números que mantengan la suma total por debajo de un límite
|
|
118
|
+
* @param maxSum - Suma máxima permitida
|
|
119
|
+
* @example arrayWithBankNums(bankNums, [5], sumLessThan(20))
|
|
120
|
+
*/
|
|
121
|
+
declare const sumLessThan: (maxSum: number) => ArrayRule;
|
|
122
|
+
/**
|
|
123
|
+
* Solo permite números que mantengan la suma total por encima de un límite
|
|
124
|
+
* @param minSum - Suma mínima requerida
|
|
125
|
+
* @example arrayWithBankNums(bankNums, [5], sumGreaterThan(10))
|
|
126
|
+
*/
|
|
127
|
+
declare const sumGreaterThan: (minSum: number) => ArrayRule;
|
|
128
|
+
/**
|
|
129
|
+
* Solo permite números que mantengan el promedio dentro de un rango
|
|
130
|
+
* @param min - Promedio mínimo
|
|
131
|
+
* @param max - Promedio máximo
|
|
132
|
+
* @example arrayWithBankNums(bankNums, [5], averageInRange(3, 7))
|
|
133
|
+
*/
|
|
134
|
+
declare const averageInRange: (min: number, max: number) => ArrayRule;
|
|
135
|
+
/**
|
|
136
|
+
* Solo permite números que sean mayores que el último número en el array (orden ascendente)
|
|
137
|
+
* @example arrayWithBankNums(bankNums, [5], ascending)
|
|
138
|
+
*/
|
|
139
|
+
declare const ascending: ArrayRule;
|
|
140
|
+
/**
|
|
141
|
+
* Solo permite números que sean menores que el último número en el array (orden descendente)
|
|
142
|
+
* @example arrayWithBankNums(bankNums, [5], descending)
|
|
143
|
+
*/
|
|
144
|
+
declare const descending: ArrayRule;
|
|
145
|
+
/**
|
|
146
|
+
* Solo permite números que sean diferentes del último número (no estrictamente ascendente/descendente)
|
|
147
|
+
* @example arrayWithBankNums(bankNums, [5], different)
|
|
148
|
+
*/
|
|
149
|
+
declare const different: ArrayRule;
|
|
150
|
+
/**
|
|
151
|
+
* Alterna entre números pares e impares
|
|
152
|
+
* @example arrayWithBankNums(bankNums, [6], alternateEvenOdd)
|
|
153
|
+
*/
|
|
154
|
+
declare const alternateEvenOdd: ArrayRule;
|
|
155
|
+
/**
|
|
156
|
+
* Solo permite números divisibles por un divisor específico
|
|
157
|
+
* @param divisor - El divisor
|
|
158
|
+
* @example arrayWithBankNums(bankNums, [5], divisibleBy(3))
|
|
159
|
+
*/
|
|
160
|
+
declare const divisibleBy: (divisor: number) => ArrayRule;
|
|
161
|
+
/**
|
|
162
|
+
* Solo permite números que NO sean divisibles por un divisor específico
|
|
163
|
+
* @param divisor - El divisor
|
|
164
|
+
* @example arrayWithBankNums(bankNums, [5], notDivisibleBy(5))
|
|
165
|
+
*/
|
|
166
|
+
declare const notDivisibleBy: (divisor: number) => ArrayRule;
|
|
167
|
+
/**
|
|
168
|
+
* Aplica diferentes reglas según la posición en el array
|
|
169
|
+
* @param rules - Objeto que mapea índices a reglas
|
|
170
|
+
* @example arrayWithBankNums(bankNums, [5], byPosition({ 0: onlyEven, 1: onlyOdd }))
|
|
171
|
+
*/
|
|
172
|
+
declare const byPosition: (rules: {
|
|
173
|
+
[index: number]: ArrayRule;
|
|
174
|
+
}) => ArrayRule;
|
|
175
|
+
/**
|
|
176
|
+
* Aplica una regla solo en posiciones pares (0, 2, 4, ...)
|
|
177
|
+
* @param rule - La regla a aplicar
|
|
178
|
+
* @example arrayWithBankNums(bankNums, [6], onEvenPositions(onlyEven))
|
|
179
|
+
*/
|
|
180
|
+
declare const onEvenPositions: (rule: ArrayRule) => ArrayRule;
|
|
181
|
+
/**
|
|
182
|
+
* Aplica una regla solo en posiciones impares (1, 3, 5, ...)
|
|
183
|
+
* @param rule - La regla a aplicar
|
|
184
|
+
* @example arrayWithBankNums(bankNums, [6], onOddPositions(onlyOdd))
|
|
185
|
+
*/
|
|
186
|
+
declare const onOddPositions: (rule: ArrayRule) => ArrayRule;
|
|
187
|
+
/**
|
|
188
|
+
* Combina múltiples reglas con AND (todas deben cumplirse)
|
|
189
|
+
* @param rules - Array de reglas a combinar
|
|
190
|
+
* @example arrayWithBankNums(bankNums, [5], and([onlyEven, inRange(2, 8)]))
|
|
191
|
+
*/
|
|
192
|
+
declare const and: (rules: ArrayRule[]) => ArrayRule;
|
|
193
|
+
/**
|
|
194
|
+
* Combina múltiples reglas con OR (al menos una debe cumplirse)
|
|
195
|
+
* @param rules - Array de reglas a combinar
|
|
196
|
+
* @example arrayWithBankNums(bankNums, [5], or([onlyEven, divisibleBy(3)]))
|
|
197
|
+
*/
|
|
198
|
+
declare const or: (rules: ArrayRule[]) => ArrayRule;
|
|
199
|
+
/**
|
|
200
|
+
* Invierte una regla (NOT)
|
|
201
|
+
* @param rule - La regla a invertir
|
|
202
|
+
* @example arrayWithBankNums(bankNums, [5], not(onlyEven)) // Solo impares
|
|
203
|
+
*/
|
|
204
|
+
declare const not: (rule: ArrayRule) => ArrayRule;
|
|
205
|
+
/**
|
|
206
|
+
* Solo permite números primos
|
|
207
|
+
* @example arrayWithBankNums(bankNums, [5], onlyPrimes)
|
|
208
|
+
*/
|
|
209
|
+
declare const onlyPrimes: ArrayRule;
|
|
210
|
+
/**
|
|
211
|
+
* Solo permite números que sean cuadrados perfectos
|
|
212
|
+
* @example arrayWithBankNums(bankNums, [5], onlySquares)
|
|
213
|
+
*/
|
|
214
|
+
declare const onlySquares: ArrayRule;
|
|
215
|
+
/**
|
|
216
|
+
* Asegura que la diferencia entre números consecutivos no exceda un límite
|
|
217
|
+
* @param maxDiff - Diferencia máxima permitida
|
|
218
|
+
* @example arrayWithBankNums(bankNums, [5], maxDifference(3))
|
|
219
|
+
*/
|
|
220
|
+
declare const maxDifference: (maxDiff: number) => ArrayRule;
|
|
221
|
+
/**
|
|
222
|
+
* Asegura que la diferencia entre números consecutivos sea al menos un mínimo
|
|
223
|
+
* @param minDiff - Diferencia mínima requerida
|
|
224
|
+
* @example arrayWithBankNums(bankNums, [5], minDifference(2))
|
|
225
|
+
*/
|
|
226
|
+
declare const minDifference: (minDiff: number) => ArrayRule;
|
|
227
|
+
/**
|
|
228
|
+
* Mantiene un balance entre números pares e impares
|
|
229
|
+
* @param maxImbalance - Diferencia máxima permitida entre cantidad de pares e impares
|
|
230
|
+
* @example arrayWithBankNums(bankNums, [10], balanceEvenOdd(2))
|
|
231
|
+
*/
|
|
232
|
+
declare const balanceEvenOdd: (maxImbalance?: number) => ArrayRule;
|
|
233
|
+
/**
|
|
234
|
+
* Solo permite números en posiciones específicas del array
|
|
235
|
+
* @param allowedPositions - Array de posiciones permitidas (0-indexed)
|
|
236
|
+
* @param value - El valor que solo puede aparecer en esas posiciones
|
|
237
|
+
* @example arrayWithBankNums(bankNums, [5], valueAtPositions([0, 2, 4], 7))
|
|
238
|
+
*/
|
|
239
|
+
declare const valueAtPositions: (allowedPositions: number[], value: number) => ArrayRule;
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Y-ary package entry point
|
|
243
|
+
* Export your public API here
|
|
244
|
+
*/
|
|
245
|
+
declare function hello(name: string): string;
|
|
246
|
+
|
|
247
|
+
export { type ArrayRule, alternateEvenOdd, and, arrayWithBankNums, ascending, averageInRange, balanceEvenOdd, byPosition, descending, different, divisibleBy, formulaInterpreter, hello, inRange, maxDifference, maxOccurrences, minDifference, noConsecutiveRepeats, noDuplicates, noRepeatInLast, not, notDivisibleBy, notInRange, onEvenPositions, onOddPositions, onlyEven, onlyOdd, onlyPrimes, onlySquares, or, sumGreaterThan, sumLessThan, valueAtPositions };
|