@atlantjs/arch 13.3.0 → 14.0.0

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 (50) hide show
  1. package/@tool-box/utils/datatypes/boolean-utils.d.ts +7 -0
  2. package/@tool-box/utils/datatypes/boolean-utils.js +146 -4
  3. package/@tool-box/utils/datatypes/string-utils.d.ts +20 -4
  4. package/@tool-box/utils/datatypes/string-utils.js +300 -14
  5. package/@tool-box/utils/ducts/common.d.ts +49 -0
  6. package/@tool-box/utils/ducts/common.js +36 -3
  7. package/@tool-box/utils/ducts/optional-type.d.ts +85 -0
  8. package/@tool-box/utils/ducts/optional-type.js +79 -0
  9. package/@tool-box/utils/ducts/return-type.d.ts +17 -17
  10. package/@tool-box/utils/ducts/return-type.js +14 -4
  11. package/@tool-box/utils/http-provider/http-provider.d.ts +6 -0
  12. package/@tool-box/utils/http-provider/http-provider.js +43 -14
  13. package/@tool-box/utils/map/map.abstract.d.ts +39 -0
  14. package/@tool-box/utils/map/map.abstract.js +70 -6
  15. package/@tool-box/utils/random/random.d.ts +168 -0
  16. package/@tool-box/utils/random/random.js +235 -0
  17. package/@tool-box/utils/type-guard/guardian.d.ts +450 -7
  18. package/@tool-box/utils/type-guard/guardian.js +539 -35
  19. package/objects/@common/edges/cron-expression.edge.d.ts +30 -2
  20. package/objects/@common/edges/cron-expression.edge.js +77 -5
  21. package/objects/@common/edges/email.edge.d.ts +39 -1
  22. package/objects/@common/edges/email.edge.js +80 -2
  23. package/objects/@common/edges/ulid.sketch.edge.d.ts +48 -1
  24. package/objects/@common/edges/ulid.sketch.edge.js +75 -4
  25. package/objects/@common/edges/url.edge.d.ts +182 -0
  26. package/objects/@common/edges/url.edge.js +249 -0
  27. package/objects/@common/edges/username.edge.d.ts +9 -0
  28. package/objects/@common/edges/username.edge.js +34 -0
  29. package/objects/@common/edges/uuid.sketch.edge.d.ts +97 -1
  30. package/objects/@common/edges/uuid.sketch.edge.js +127 -6
  31. package/objects/amount/amount-value.edge.d.ts +39 -0
  32. package/objects/amount/amount-value.edge.js +69 -0
  33. package/objects/amount/amount.edge.d.ts +378 -2
  34. package/objects/amount/amount.edge.js +493 -4
  35. package/objects/datetime/edges/datetime.edge.d.ts +422 -4
  36. package/objects/datetime/edges/datetime.edge.js +538 -33
  37. package/objects/password/password.edge.d.ts +90 -0
  38. package/objects/password/password.edge.js +140 -6
  39. package/objects/primitives/boolean.edge.sketch.d.ts +105 -3
  40. package/objects/primitives/boolean.edge.sketch.js +132 -6
  41. package/objects/primitives/number.edge.sketch.d.ts +236 -0
  42. package/objects/primitives/number.edge.sketch.js +310 -24
  43. package/objects/primitives/string.edge.sketch.d.ts +148 -0
  44. package/objects/primitives/string.edge.sketch.js +191 -7
  45. package/objects/schedule/schedule.edge.d.ts +194 -0
  46. package/objects/schedule/schedule.edge.js +269 -2
  47. package/objects/time/time.edge.d.ts +285 -2
  48. package/objects/time/time.edge.js +385 -6
  49. package/package.json +1 -1
  50. package/tsconfig.tsbuildinfo +1 -1
@@ -1,5 +1,173 @@
1
1
  export declare class Random {
2
+ /**
3
+ * Gera um número inteiro aleatório dentro de um intervalo (inclusivo).
4
+ * @param min - Valor mínimo do intervalo
5
+ * @param max - Valor máximo do intervalo
6
+ * @returns Número inteiro aleatório entre min e max
7
+ * @example
8
+ * Random.number(1, 10) // pode retornar qualquer inteiro entre 1 e 10
9
+ */
2
10
  static number(min: number, max: number): number;
11
+ /**
12
+ * Gera um número decimal (float) aleatório dentro de um intervalo.
13
+ * @param min - Valor mínimo do intervalo
14
+ * @param max - Valor máximo do intervalo
15
+ * @param precision - Número de casas decimais (padrão: 2)
16
+ * @returns Número decimal aleatório entre min e max
17
+ * @example
18
+ * Random.float(1, 10) // pode retornar algo como 4.73
19
+ * Random.float(1, 10, 4) // pode retornar algo como 4.7312
20
+ */
21
+ static float(min: number, max: number, precision?: number): number;
22
+ /**
23
+ * Gera um número inteiro positivo aleatório até um valor máximo.
24
+ * @param max - Valor máximo do intervalo (padrão: 100)
25
+ * @returns Número inteiro positivo aleatório entre 1 e max
26
+ * @example
27
+ * Random.positiveNumber() // pode retornar qualquer inteiro entre 1 e 100
28
+ * Random.positiveNumber(50) // pode retornar qualquer inteiro entre 1 e 50
29
+ */
30
+ static positiveNumber(max?: number): number;
31
+ /**
32
+ * Gera um número inteiro negativo aleatório até um valor mínimo.
33
+ * @param min - Valor mínimo do intervalo (padrão: -100)
34
+ * @returns Número inteiro negativo aleatório entre min e -1
35
+ * @example
36
+ * Random.negativeNumber() // pode retornar qualquer inteiro entre -100 e -1
37
+ * Random.negativeNumber(-50) // pode retornar qualquer inteiro entre -50 e -1
38
+ */
39
+ static negativeNumber(min?: number): number;
40
+ /**
41
+ * Retorna um valor aleatório de um enum.
42
+ * @template T - Tipo do enum
43
+ * @param anEnum - Enum do qual será selecionado o valor aleatório
44
+ * @returns Um valor aleatório do enum
45
+ * @example
46
+ * enum Color { Red, Green, Blue }
47
+ * Random.enum(Color) // pode retornar Color.Red, Color.Green ou Color.Blue
48
+ */
3
49
  static enum<T extends Record<string, unknown>>(anEnum: T): T[keyof T];
50
+ /**
51
+ * Retorna um valor aleatório de um enum, excluindo valores específicos.
52
+ * @template T - Tipo do enum
53
+ * @param anEnum - Enum do qual será selecionado o valor aleatório
54
+ * @param excepts - Array de valores do enum que devem ser excluídos da seleção
55
+ * @returns Um valor aleatório do enum que não está nos excepts
56
+ * @throws {Error} Se não houver valores válidos após aplicar as exclusões
57
+ * @example
58
+ * enum Color { Red, Green, Blue }
59
+ * Random.enumExcluding(Color, [Color.Red]) // retorna Green ou Blue
60
+ */
4
61
  static enumExcluding<T extends Record<string, unknown>>(anEnum: T, excepts: Array<T[keyof T]>): T[keyof T];
62
+ /**
63
+ * Gera uma string aleatória de caracteres alfanuméricos.
64
+ * @param length - Comprimento da string a ser gerada (padrão: 8)
65
+ * @returns String aleatória com o comprimento especificado
66
+ * @example
67
+ * Random.string() // pode retornar "aB3xKp9z"
68
+ * Random.string(4) // pode retornar "kR2m"
69
+ */
70
+ static string(length?: number): string;
71
+ /**
72
+ * Gera uma string aleatória contendo apenas letras (sem números).
73
+ * @param length - Comprimento da string a ser gerada (padrão: 8)
74
+ * @returns String aleatória com apenas letras
75
+ * @example
76
+ * Random.letters() // pode retornar "AbCdEfGh"
77
+ * Random.letters(4) // pode retornar "kRmZ"
78
+ */
79
+ static letters(length?: number): string;
80
+ /**
81
+ * Gera um UUID v4 aleatório no formato padrão.
82
+ * @returns UUID no formato xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
83
+ * @example
84
+ * Random.uuid() // pode retornar "550e8400-e29b-41d4-a716-446655440000"
85
+ */
86
+ static uuid(): string;
87
+ /**
88
+ * Gera um valor booleano aleatório (true ou false).
89
+ * @returns true ou false aleatoriamente
90
+ * @example
91
+ * Random.boolean() // pode retornar true ou false
92
+ */
93
+ static boolean(): boolean;
94
+ /**
95
+ * Gera um valor booleano aleatório com uma probabilidade específica de ser true.
96
+ * @param probability - Probabilidade de retornar true (0 a 1, padrão: 0.5)
97
+ * @returns true com a probabilidade fornecida, false caso contrário
98
+ * @example
99
+ * Random.booleanWithProbability(0.8) // 80% de chance de retornar true
100
+ * Random.booleanWithProbability(0.2) // 20% de chance de retornar true
101
+ */
102
+ static booleanWithProbability(probability?: number): boolean;
103
+ /**
104
+ * Retorna um elemento aleatório de um array.
105
+ * @template T - Tipo dos elementos do array
106
+ * @param array - Array do qual será selecionado um elemento
107
+ * @returns Um elemento aleatório do array
108
+ * @throws {Error} Se o array estiver vazio
109
+ * @example
110
+ * Random.arrayElement([1, 2, 3, 4]) // pode retornar 1, 2, 3 ou 4
111
+ * Random.arrayElement(["a", "b", "c"]) // pode retornar "a", "b" ou "c"
112
+ */
113
+ static arrayElement<T>(array: T[]): T;
114
+ /**
115
+ * Retorna um elemento aleatório de um array, excluindo valores específicos.
116
+ * @template T - Tipo dos elementos do array
117
+ * @param array - Array do qual será selecionado um elemento
118
+ * @param excepts - Array de valores que devem ser excluídos da seleção
119
+ * @returns Um elemento aleatório do array que não está nos excepts
120
+ * @throws {Error} Se não houver elementos válidos após aplicar as exclusões
121
+ * @example
122
+ * Random.arrayElementExcluding([1, 2, 3, 4], [2, 4]) // pode retornar 1 ou 3
123
+ */
124
+ static arrayElementExcluding<T>(array: T[], excepts: T[]): T;
125
+ /**
126
+ * Retorna múltiplos elementos aleatórios únicos de um array.
127
+ * @template T - Tipo dos elementos do array
128
+ * @param array - Array do qual serão selecionados os elementos
129
+ * @param count - Quantidade de elementos a retornar
130
+ * @returns Array com elementos aleatórios únicos
131
+ * @throws {Error} Se count for maior que o tamanho do array
132
+ * @example
133
+ * Random.arrayElements([1, 2, 3, 4, 5], 3) // pode retornar [3, 1, 5]
134
+ */
135
+ static arrayElements<T>(array: T[], count: number): T[];
136
+ /**
137
+ * Retorna uma cópia do array com a ordem dos elementos embaralhada.
138
+ * @template T - Tipo dos elementos do array
139
+ * @param array - Array a ser embaralhado
140
+ * @returns Novo array com os mesmos elementos em ordem aleatória
141
+ * @example
142
+ * Random.shuffle([1, 2, 3, 4]) // pode retornar [3, 1, 4, 2]
143
+ */
144
+ static shuffle<T>(array: T[]): T[];
145
+ /**
146
+ * Gera uma data aleatória dentro de um intervalo.
147
+ * @param start - Data inicial do intervalo
148
+ * @param end - Data final do intervalo
149
+ * @returns Data aleatória entre start e end
150
+ * @example
151
+ * Random.date(new Date("2020-01-01"), new Date("2024-12-31"))
152
+ * // pode retornar qualquer data entre 2020 e 2024
153
+ */
154
+ static date(start: Date, end: Date): Date;
155
+ /**
156
+ * Gera uma data aleatória no passado a partir da data atual.
157
+ * @param daysAgo - Quantidade máxima de dias no passado (padrão: 365)
158
+ * @returns Data aleatória entre daysAgo dias atrás e hoje
159
+ * @example
160
+ * Random.pastDate() // data aleatória no último ano
161
+ * Random.pastDate(30) // data aleatória nos últimos 30 dias
162
+ */
163
+ static pastDate(daysAgo?: number): Date;
164
+ /**
165
+ * Gera uma data aleatória no futuro a partir da data atual.
166
+ * @param daysAhead - Quantidade máxima de dias no futuro (padrão: 365)
167
+ * @returns Data aleatória entre hoje e daysAhead dias à frente
168
+ * @example
169
+ * Random.futureDate() // data aleatória no próximo ano
170
+ * Random.futureDate(30) // data aleatória nos próximos 30 dias
171
+ */
172
+ static futureDate(daysAhead?: number): Date;
5
173
  }
@@ -2,15 +2,81 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Random = void 0;
4
4
  class Random {
5
+ // ==================== Números ====================
6
+ /**
7
+ * Gera um número inteiro aleatório dentro de um intervalo (inclusivo).
8
+ * @param min - Valor mínimo do intervalo
9
+ * @param max - Valor máximo do intervalo
10
+ * @returns Número inteiro aleatório entre min e max
11
+ * @example
12
+ * Random.number(1, 10) // pode retornar qualquer inteiro entre 1 e 10
13
+ */
5
14
  static number(min, max) {
6
15
  return Math.floor(Math.random() * (max - min + 1)) + min;
7
16
  }
17
+ /**
18
+ * Gera um número decimal (float) aleatório dentro de um intervalo.
19
+ * @param min - Valor mínimo do intervalo
20
+ * @param max - Valor máximo do intervalo
21
+ * @param precision - Número de casas decimais (padrão: 2)
22
+ * @returns Número decimal aleatório entre min e max
23
+ * @example
24
+ * Random.float(1, 10) // pode retornar algo como 4.73
25
+ * Random.float(1, 10, 4) // pode retornar algo como 4.7312
26
+ */
27
+ static float(min, max, precision = 2) {
28
+ const value = Math.random() * (max - min) + min;
29
+ return Number(value.toFixed(precision));
30
+ }
31
+ /**
32
+ * Gera um número inteiro positivo aleatório até um valor máximo.
33
+ * @param max - Valor máximo do intervalo (padrão: 100)
34
+ * @returns Número inteiro positivo aleatório entre 1 e max
35
+ * @example
36
+ * Random.positiveNumber() // pode retornar qualquer inteiro entre 1 e 100
37
+ * Random.positiveNumber(50) // pode retornar qualquer inteiro entre 1 e 50
38
+ */
39
+ static positiveNumber(max = 100) {
40
+ return Random.number(1, max);
41
+ }
42
+ /**
43
+ * Gera um número inteiro negativo aleatório até um valor mínimo.
44
+ * @param min - Valor mínimo do intervalo (padrão: -100)
45
+ * @returns Número inteiro negativo aleatório entre min e -1
46
+ * @example
47
+ * Random.negativeNumber() // pode retornar qualquer inteiro entre -100 e -1
48
+ * Random.negativeNumber(-50) // pode retornar qualquer inteiro entre -50 e -1
49
+ */
50
+ static negativeNumber(min = -100) {
51
+ return Random.number(min, -1);
52
+ }
53
+ // ==================== Enums ====================
54
+ /**
55
+ * Retorna um valor aleatório de um enum.
56
+ * @template T - Tipo do enum
57
+ * @param anEnum - Enum do qual será selecionado o valor aleatório
58
+ * @returns Um valor aleatório do enum
59
+ * @example
60
+ * enum Color { Red, Green, Blue }
61
+ * Random.enum(Color) // pode retornar Color.Red, Color.Green ou Color.Blue
62
+ */
8
63
  static enum(anEnum) {
9
64
  const keys = Object.keys(anEnum).filter((x) => Number.isNaN(Number(x)));
10
65
  const randomKeyIndex = Math.floor(Math.random() * keys.length);
11
66
  const randomKey = keys[randomKeyIndex];
12
67
  return anEnum[randomKey];
13
68
  }
69
+ /**
70
+ * Retorna um valor aleatório de um enum, excluindo valores específicos.
71
+ * @template T - Tipo do enum
72
+ * @param anEnum - Enum do qual será selecionado o valor aleatório
73
+ * @param excepts - Array de valores do enum que devem ser excluídos da seleção
74
+ * @returns Um valor aleatório do enum que não está nos excepts
75
+ * @throws {Error} Se não houver valores válidos após aplicar as exclusões
76
+ * @example
77
+ * enum Color { Red, Green, Blue }
78
+ * Random.enumExcluding(Color, [Color.Red]) // retorna Green ou Blue
79
+ */
14
80
  static enumExcluding(anEnum, excepts) {
15
81
  const exceptKeys = excepts.map((value) => Object.keys(anEnum).find((key) => anEnum[key] === value));
16
82
  const validKeys = Object.keys(anEnum).filter((key) => Number.isNaN(Number(key)) && !exceptKeys.includes(key));
@@ -21,5 +87,174 @@ class Random {
21
87
  const randomKey = validKeys[randomKeyIndex];
22
88
  return anEnum[randomKey];
23
89
  }
90
+ // ==================== Strings ====================
91
+ /**
92
+ * Gera uma string aleatória de caracteres alfanuméricos.
93
+ * @param length - Comprimento da string a ser gerada (padrão: 8)
94
+ * @returns String aleatória com o comprimento especificado
95
+ * @example
96
+ * Random.string() // pode retornar "aB3xKp9z"
97
+ * Random.string(4) // pode retornar "kR2m"
98
+ */
99
+ static string(length = 8) {
100
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
101
+ return Array.from({ length }, () => chars.charAt(Math.floor(Math.random() * chars.length))).join("");
102
+ }
103
+ /**
104
+ * Gera uma string aleatória contendo apenas letras (sem números).
105
+ * @param length - Comprimento da string a ser gerada (padrão: 8)
106
+ * @returns String aleatória com apenas letras
107
+ * @example
108
+ * Random.letters() // pode retornar "AbCdEfGh"
109
+ * Random.letters(4) // pode retornar "kRmZ"
110
+ */
111
+ static letters(length = 8) {
112
+ const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
113
+ return Array.from({ length }, () => chars.charAt(Math.floor(Math.random() * chars.length))).join("");
114
+ }
115
+ /**
116
+ * Gera um UUID v4 aleatório no formato padrão.
117
+ * @returns UUID no formato xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
118
+ * @example
119
+ * Random.uuid() // pode retornar "550e8400-e29b-41d4-a716-446655440000"
120
+ */
121
+ static uuid() {
122
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (char) => {
123
+ const random = (Math.random() * 16) | 0;
124
+ const value = char === "x" ? random : (random & 0x3) | 0x8;
125
+ return value.toString(16);
126
+ });
127
+ }
128
+ // ==================== Booleanos ====================
129
+ /**
130
+ * Gera um valor booleano aleatório (true ou false).
131
+ * @returns true ou false aleatoriamente
132
+ * @example
133
+ * Random.boolean() // pode retornar true ou false
134
+ */
135
+ static boolean() {
136
+ return Math.random() < 0.5;
137
+ }
138
+ /**
139
+ * Gera um valor booleano aleatório com uma probabilidade específica de ser true.
140
+ * @param probability - Probabilidade de retornar true (0 a 1, padrão: 0.5)
141
+ * @returns true com a probabilidade fornecida, false caso contrário
142
+ * @example
143
+ * Random.booleanWithProbability(0.8) // 80% de chance de retornar true
144
+ * Random.booleanWithProbability(0.2) // 20% de chance de retornar true
145
+ */
146
+ static booleanWithProbability(probability = 0.5) {
147
+ return Math.random() < probability;
148
+ }
149
+ // ==================== Arrays ====================
150
+ /**
151
+ * Retorna um elemento aleatório de um array.
152
+ * @template T - Tipo dos elementos do array
153
+ * @param array - Array do qual será selecionado um elemento
154
+ * @returns Um elemento aleatório do array
155
+ * @throws {Error} Se o array estiver vazio
156
+ * @example
157
+ * Random.arrayElement([1, 2, 3, 4]) // pode retornar 1, 2, 3 ou 4
158
+ * Random.arrayElement(["a", "b", "c"]) // pode retornar "a", "b" ou "c"
159
+ */
160
+ static arrayElement(array) {
161
+ if (array.length === 0) {
162
+ throw new Error("Cannot get a random element from an empty array.");
163
+ }
164
+ return array[Math.floor(Math.random() * array.length)];
165
+ }
166
+ /**
167
+ * Retorna um elemento aleatório de um array, excluindo valores específicos.
168
+ * @template T - Tipo dos elementos do array
169
+ * @param array - Array do qual será selecionado um elemento
170
+ * @param excepts - Array de valores que devem ser excluídos da seleção
171
+ * @returns Um elemento aleatório do array que não está nos excepts
172
+ * @throws {Error} Se não houver elementos válidos após aplicar as exclusões
173
+ * @example
174
+ * Random.arrayElementExcluding([1, 2, 3, 4], [2, 4]) // pode retornar 1 ou 3
175
+ */
176
+ static arrayElementExcluding(array, excepts) {
177
+ const validElements = array.filter((item) => !excepts.includes(item));
178
+ if (validElements.length === 0) {
179
+ throw new Error("No valid elements available after excluding 'excepts'.");
180
+ }
181
+ return Random.arrayElement(validElements);
182
+ }
183
+ /**
184
+ * Retorna múltiplos elementos aleatórios únicos de um array.
185
+ * @template T - Tipo dos elementos do array
186
+ * @param array - Array do qual serão selecionados os elementos
187
+ * @param count - Quantidade de elementos a retornar
188
+ * @returns Array com elementos aleatórios únicos
189
+ * @throws {Error} Se count for maior que o tamanho do array
190
+ * @example
191
+ * Random.arrayElements([1, 2, 3, 4, 5], 3) // pode retornar [3, 1, 5]
192
+ */
193
+ static arrayElements(array, count) {
194
+ if (count > array.length) {
195
+ throw new Error(`Cannot pick ${count} elements from an array of ${array.length}.`);
196
+ }
197
+ const shuffled = [...array].sort(() => Math.random() - 0.5);
198
+ return shuffled.slice(0, count);
199
+ }
200
+ /**
201
+ * Retorna uma cópia do array com a ordem dos elementos embaralhada.
202
+ * @template T - Tipo dos elementos do array
203
+ * @param array - Array a ser embaralhado
204
+ * @returns Novo array com os mesmos elementos em ordem aleatória
205
+ * @example
206
+ * Random.shuffle([1, 2, 3, 4]) // pode retornar [3, 1, 4, 2]
207
+ */
208
+ static shuffle(array) {
209
+ const shuffled = [...array];
210
+ for (let i = shuffled.length - 1; i > 0; i--) {
211
+ const j = Math.floor(Math.random() * (i + 1));
212
+ [shuffled[i], shuffled[j]] = [shuffled[j], shuffled[i]];
213
+ }
214
+ return shuffled;
215
+ }
216
+ // ==================== Datas ====================
217
+ /**
218
+ * Gera uma data aleatória dentro de um intervalo.
219
+ * @param start - Data inicial do intervalo
220
+ * @param end - Data final do intervalo
221
+ * @returns Data aleatória entre start e end
222
+ * @example
223
+ * Random.date(new Date("2020-01-01"), new Date("2024-12-31"))
224
+ * // pode retornar qualquer data entre 2020 e 2024
225
+ */
226
+ static date(start, end) {
227
+ const startTime = start.getTime();
228
+ const endTime = end.getTime();
229
+ return new Date(startTime + Math.random() * (endTime - startTime));
230
+ }
231
+ /**
232
+ * Gera uma data aleatória no passado a partir da data atual.
233
+ * @param daysAgo - Quantidade máxima de dias no passado (padrão: 365)
234
+ * @returns Data aleatória entre daysAgo dias atrás e hoje
235
+ * @example
236
+ * Random.pastDate() // data aleatória no último ano
237
+ * Random.pastDate(30) // data aleatória nos últimos 30 dias
238
+ */
239
+ static pastDate(daysAgo = 365) {
240
+ const now = new Date();
241
+ const past = new Date();
242
+ past.setDate(past.getDate() - daysAgo);
243
+ return Random.date(past, now);
244
+ }
245
+ /**
246
+ * Gera uma data aleatória no futuro a partir da data atual.
247
+ * @param daysAhead - Quantidade máxima de dias no futuro (padrão: 365)
248
+ * @returns Data aleatória entre hoje e daysAhead dias à frente
249
+ * @example
250
+ * Random.futureDate() // data aleatória no próximo ano
251
+ * Random.futureDate(30) // data aleatória nos próximos 30 dias
252
+ */
253
+ static futureDate(daysAhead = 365) {
254
+ const now = new Date();
255
+ const future = new Date();
256
+ future.setDate(future.getDate() + daysAhead);
257
+ return Random.date(now, future);
258
+ }
24
259
  }
25
260
  exports.Random = Random;