@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.
- package/@tool-box/utils/datatypes/boolean-utils.d.ts +7 -0
- package/@tool-box/utils/datatypes/boolean-utils.js +146 -4
- package/@tool-box/utils/datatypes/string-utils.d.ts +20 -4
- package/@tool-box/utils/datatypes/string-utils.js +300 -14
- package/@tool-box/utils/ducts/common.d.ts +49 -0
- package/@tool-box/utils/ducts/common.js +36 -3
- package/@tool-box/utils/ducts/optional-type.d.ts +85 -0
- package/@tool-box/utils/ducts/optional-type.js +79 -0
- package/@tool-box/utils/ducts/return-type.d.ts +17 -17
- package/@tool-box/utils/ducts/return-type.js +14 -4
- package/@tool-box/utils/http-provider/http-provider.d.ts +6 -0
- package/@tool-box/utils/http-provider/http-provider.js +43 -14
- package/@tool-box/utils/map/map.abstract.d.ts +39 -0
- package/@tool-box/utils/map/map.abstract.js +70 -6
- package/@tool-box/utils/random/random.d.ts +168 -0
- package/@tool-box/utils/random/random.js +235 -0
- package/@tool-box/utils/type-guard/guardian.d.ts +450 -7
- package/@tool-box/utils/type-guard/guardian.js +539 -35
- package/objects/@common/edges/cron-expression.edge.d.ts +30 -2
- package/objects/@common/edges/cron-expression.edge.js +77 -5
- package/objects/@common/edges/email.edge.d.ts +39 -1
- package/objects/@common/edges/email.edge.js +80 -2
- package/objects/@common/edges/ulid.sketch.edge.d.ts +48 -1
- package/objects/@common/edges/ulid.sketch.edge.js +75 -4
- package/objects/@common/edges/url.edge.d.ts +182 -0
- package/objects/@common/edges/url.edge.js +249 -0
- package/objects/@common/edges/username.edge.d.ts +9 -0
- package/objects/@common/edges/username.edge.js +34 -0
- package/objects/@common/edges/uuid.sketch.edge.d.ts +97 -1
- package/objects/@common/edges/uuid.sketch.edge.js +127 -6
- package/objects/amount/amount-value.edge.d.ts +39 -0
- package/objects/amount/amount-value.edge.js +69 -0
- package/objects/amount/amount.edge.d.ts +378 -2
- package/objects/amount/amount.edge.js +493 -4
- package/objects/datetime/edges/datetime.edge.d.ts +422 -4
- package/objects/datetime/edges/datetime.edge.js +538 -33
- package/objects/password/password.edge.d.ts +90 -0
- package/objects/password/password.edge.js +140 -6
- package/objects/primitives/boolean.edge.sketch.d.ts +105 -3
- package/objects/primitives/boolean.edge.sketch.js +132 -6
- package/objects/primitives/number.edge.sketch.d.ts +236 -0
- package/objects/primitives/number.edge.sketch.js +310 -24
- package/objects/primitives/string.edge.sketch.d.ts +148 -0
- package/objects/primitives/string.edge.sketch.js +191 -7
- package/objects/schedule/schedule.edge.d.ts +194 -0
- package/objects/schedule/schedule.edge.js +269 -2
- package/objects/time/time.edge.d.ts +285 -2
- package/objects/time/time.edge.js +385 -6
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -1,29 +1,472 @@
|
|
|
1
|
+
import { Newable } from "../datatypes/generic-types";
|
|
1
2
|
import { PrimitiveType } from "./guardian.type";
|
|
2
3
|
declare class Guardian {
|
|
4
|
+
/**
|
|
5
|
+
* Verifica se todos os valores booleanos passados são verdadeiros.
|
|
6
|
+
* @param args - Valores booleanos a serem verificados
|
|
7
|
+
* @returns true se todos os valores são true, false caso contrário
|
|
8
|
+
* @example
|
|
9
|
+
* Guardian.and(true, true, true) // true
|
|
10
|
+
* Guardian.and(true, false, true) // false
|
|
11
|
+
*/
|
|
3
12
|
static and(...args: boolean[]): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Verifica se pelo menos um dos valores booleanos passados é verdadeiro.
|
|
15
|
+
* @param args - Valores booleanos a serem verificados
|
|
16
|
+
* @returns true se pelo menos um valor é true, false caso contrário
|
|
17
|
+
* @example
|
|
18
|
+
* Guardian.or(false, false, true) // true
|
|
19
|
+
* Guardian.or(false, false, false) // false
|
|
20
|
+
*/
|
|
4
21
|
static or(...args: boolean[]): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Retorna um valor baseado em uma condição booleana (ternário).
|
|
24
|
+
* @template TTrue - Tipo do valor a retornar se a condição for verdadeira
|
|
25
|
+
* @template TFalse - Tipo do valor a retornar se a condição for falsa
|
|
26
|
+
* @param condition - Condição a ser avaliada
|
|
27
|
+
* @param returnIfTrue - Valor retornado quando a condição é true
|
|
28
|
+
* @param returnIfFalse - Valor retornado quando a condição é false
|
|
29
|
+
* @returns O valor correspondente à condição
|
|
30
|
+
* @example
|
|
31
|
+
* Guardian.ternaryCondition(5 > 3, "maior", "menor") // "maior"
|
|
32
|
+
*/
|
|
33
|
+
static ternaryCondition<TTrue, TFalse>(condition: boolean, returnIfTrue: TTrue, returnIfFalse: TFalse): TTrue | TFalse;
|
|
34
|
+
/**
|
|
35
|
+
* Verifica se um número é maior que uma referência.
|
|
36
|
+
* @param value - Valor a ser comparado
|
|
37
|
+
* @param reference - Valor de referência para comparação
|
|
38
|
+
* @returns true se value > reference, false caso contrário
|
|
39
|
+
* @example
|
|
40
|
+
* Guardian.greaterThan(10, 5) // true
|
|
41
|
+
*/
|
|
5
42
|
static greaterThan(value: number, reference: number): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Verifica se um número é menor que uma referência.
|
|
45
|
+
* @param value - Valor a ser comparado
|
|
46
|
+
* @param reference - Valor de referência para comparação
|
|
47
|
+
* @returns true se value < reference, false caso contrário
|
|
48
|
+
* @example
|
|
49
|
+
* Guardian.lessThan(3, 5) // true
|
|
50
|
+
*/
|
|
6
51
|
static lessThan(value: number, reference: number): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Verifica se um número é maior ou igual a uma referência.
|
|
54
|
+
* @param value - Valor a ser comparado
|
|
55
|
+
* @param reference - Valor de referência para comparação
|
|
56
|
+
* @returns true se value >= reference, false caso contrário
|
|
57
|
+
* @example
|
|
58
|
+
* Guardian.greaterThanOrEqual(5, 5) // true
|
|
59
|
+
*/
|
|
60
|
+
static greaterThanOrEqual(value: number, reference: number): boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Verifica se um número é menor ou igual a uma referência.
|
|
63
|
+
* @param value - Valor a ser comparado
|
|
64
|
+
* @param reference - Valor de referência para comparação
|
|
65
|
+
* @returns true se value <= reference, false caso contrário
|
|
66
|
+
* @example
|
|
67
|
+
* Guardian.lessThanOrEqual(5, 5) // true
|
|
68
|
+
*/
|
|
69
|
+
static lessThanOrEqual(value: number, reference: number): boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Verifica se um valor numérico está entre um mínimo e máximo (inclusive).
|
|
72
|
+
* @param value - Valor numérico ou string a ser verificado
|
|
73
|
+
* @param min - Valor mínimo da faixa
|
|
74
|
+
* @param max - Valor máximo da faixa
|
|
75
|
+
* @returns true se value está entre min e max, false caso contrário
|
|
76
|
+
* @throws {GuardianException} Se min > max ou se value está vazio
|
|
77
|
+
* @example
|
|
78
|
+
* Guardian.isBetween(5, 1, 10) // true
|
|
79
|
+
* Guardian.isBetween("5", 1, 10) // true
|
|
80
|
+
*/
|
|
81
|
+
static isBetween(value: number | string, min: number, max: number): boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Verifica se um número é positivo (maior que zero).
|
|
84
|
+
* @param value - Número a ser verificado
|
|
85
|
+
* @returns true se value > 0, false caso contrário
|
|
86
|
+
* @example
|
|
87
|
+
* Guardian.isPositive(5) // true
|
|
88
|
+
* Guardian.isPositive(-5) // false
|
|
89
|
+
*/
|
|
90
|
+
static isPositive(value: number): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Verifica se um número é negativo (menor que zero).
|
|
93
|
+
* @param value - Número a ser verificado
|
|
94
|
+
* @returns true se value < 0, false caso contrário
|
|
95
|
+
* @example
|
|
96
|
+
* Guardian.isNegative(-5) // true
|
|
97
|
+
* Guardian.isNegative(5) // false
|
|
98
|
+
*/
|
|
99
|
+
static isNegative(value: number): boolean;
|
|
100
|
+
/**
|
|
101
|
+
* Verifica se um número é zero.
|
|
102
|
+
* @param value - Número a ser verificado
|
|
103
|
+
* @returns true se value === 0, false caso contrário
|
|
104
|
+
* @example
|
|
105
|
+
* Guardian.isZero(0) // true
|
|
106
|
+
* Guardian.isZero(5) // false
|
|
107
|
+
*/
|
|
108
|
+
static isZero(value: number): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Verifica se um valor é um número inteiro.
|
|
111
|
+
* @param value - Valor a ser verificado
|
|
112
|
+
* @returns true se value é um número inteiro, false caso contrário
|
|
113
|
+
* @example
|
|
114
|
+
* Guardian.isInteger(5) // true
|
|
115
|
+
* Guardian.isInteger(5.5) // false
|
|
116
|
+
*/
|
|
117
|
+
static isInteger(value: unknown): value is number;
|
|
118
|
+
/**
|
|
119
|
+
* Verifica se um valor é um número decimal (ponto flutuante).
|
|
120
|
+
* @param value - Valor a ser verificado
|
|
121
|
+
* @returns true se value é um número decimal, false caso contrário
|
|
122
|
+
* @example
|
|
123
|
+
* Guardian.isFloat(5.5) // true
|
|
124
|
+
* Guardian.isFloat(5) // false
|
|
125
|
+
*/
|
|
126
|
+
static isFloat(value: unknown): value is number;
|
|
127
|
+
/**
|
|
128
|
+
* Verifica se um valor está vazio (null, undefined, string vazia, array vazio, objeto vazio).
|
|
129
|
+
* @param value - Valor a ser verificado
|
|
130
|
+
* @returns true se value está vazio, false caso contrário
|
|
131
|
+
* @example
|
|
132
|
+
* Guardian.isEmpty(null) // true
|
|
133
|
+
* Guardian.isEmpty("") // true
|
|
134
|
+
* Guardian.isEmpty([]) // true
|
|
135
|
+
* Guardian.isEmpty({}) // true
|
|
136
|
+
* Guardian.isEmpty("texto") // false
|
|
137
|
+
*/
|
|
138
|
+
static isEmpty(value: unknown): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Verifica se um valor não está vazio.
|
|
141
|
+
* @param value - Valor a ser verificado
|
|
142
|
+
* @returns true se value não está vazio, false caso contrário
|
|
143
|
+
* @example
|
|
144
|
+
* Guardian.isNotEmpty("texto") // true
|
|
145
|
+
* Guardian.isNotEmpty("") // false
|
|
146
|
+
*/
|
|
147
|
+
static isNotEmpty(value: unknown): boolean;
|
|
148
|
+
/**
|
|
149
|
+
* Verifica se um array está vazio.
|
|
150
|
+
* @template T - Tipo dos elementos do array
|
|
151
|
+
* @param value - Array a ser verificado
|
|
152
|
+
* @returns true se o array está vazio, false caso contrário
|
|
153
|
+
* @throws {GuardianException} Se value não for um array
|
|
154
|
+
* @example
|
|
155
|
+
* Guardian.isEmptyArray([]) // true
|
|
156
|
+
* Guardian.isEmptyArray([1, 2]) // false
|
|
157
|
+
*/
|
|
7
158
|
static isEmptyArray<T>(value: T[] | null | undefined): value is T[];
|
|
159
|
+
/**
|
|
160
|
+
* Verifica se um array possui elementos (não está vazio).
|
|
161
|
+
* @template T - Tipo dos elementos do array
|
|
162
|
+
* @param value - Array a ser verificado
|
|
163
|
+
* @returns true se o array possui elementos, false caso contrário
|
|
164
|
+
* @throws {GuardianException} Se value não for um array
|
|
165
|
+
* @example
|
|
166
|
+
* Guardian.isFilledArray([1, 2]) // true
|
|
167
|
+
* Guardian.isFilledArray([]) // false
|
|
168
|
+
*/
|
|
8
169
|
static isFilledArray<T>(value: T[] | null | undefined): value is T[];
|
|
170
|
+
/**
|
|
171
|
+
* Verifica se um array possui exatamente um comprimento específico.
|
|
172
|
+
* @template T - Tipo dos elementos do array
|
|
173
|
+
* @param value - Array a ser verificado
|
|
174
|
+
* @param reference - Comprimento esperado do array
|
|
175
|
+
* @returns true se o array possui exatamente o comprimento especificado, false caso contrário
|
|
176
|
+
* @throws {GuardianException} Se value não for um array
|
|
177
|
+
* @example
|
|
178
|
+
* Guardian.isLengthArray([1, 2, 3], 3) // true
|
|
179
|
+
* Guardian.isLengthArray([1, 2], 3) // false
|
|
180
|
+
*/
|
|
9
181
|
static isLengthArray<T>(value: T[] | null | undefined, reference: number): value is T[];
|
|
10
|
-
|
|
182
|
+
/**
|
|
183
|
+
* Verifica se um valor é undefined.
|
|
184
|
+
* @param value - Valor a ser verificado
|
|
185
|
+
* @returns true se value é undefined, false caso contrário
|
|
186
|
+
* @example
|
|
187
|
+
* Guardian.isUndefined(undefined) // true
|
|
188
|
+
* Guardian.isUndefined(null) // false
|
|
189
|
+
*/
|
|
11
190
|
static isUndefined(value: unknown): value is undefined;
|
|
191
|
+
/**
|
|
192
|
+
* Verifica se um valor não é undefined.
|
|
193
|
+
* @param value - Valor a ser verificado
|
|
194
|
+
* @returns true se value não é undefined, false caso contrário
|
|
195
|
+
* @example
|
|
196
|
+
* Guardian.isNotUndefined(null) // true
|
|
197
|
+
* Guardian.isNotUndefined(undefined) // false
|
|
198
|
+
*/
|
|
12
199
|
static isNotUndefined(value: unknown): value is boolean;
|
|
200
|
+
/**
|
|
201
|
+
* Verifica se um valor é null.
|
|
202
|
+
* @param value - Valor a ser verificado
|
|
203
|
+
* @returns true se value é null, false caso contrário
|
|
204
|
+
* @example
|
|
205
|
+
* Guardian.isNull(null) // true
|
|
206
|
+
* Guardian.isNull(undefined) // false
|
|
207
|
+
*/
|
|
13
208
|
static isNull(value: unknown): value is null;
|
|
209
|
+
/**
|
|
210
|
+
* Verifica se um valor não é null.
|
|
211
|
+
* @param value - Valor a ser verificado
|
|
212
|
+
* @returns true se value não é null, false caso contrário
|
|
213
|
+
* @example
|
|
214
|
+
* Guardian.isNotNull(undefined) // true
|
|
215
|
+
* Guardian.isNotNull(null) // false
|
|
216
|
+
*/
|
|
14
217
|
static isNotNull(value: unknown): value is boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Verifica se um valor é null ou undefined.
|
|
220
|
+
* @param value - Valor a ser verificado
|
|
221
|
+
* @returns true se value é null ou undefined, false caso contrário
|
|
222
|
+
* @example
|
|
223
|
+
* Guardian.isNullOrUndefined(null) // true
|
|
224
|
+
* Guardian.isNullOrUndefined(undefined) // true
|
|
225
|
+
* Guardian.isNullOrUndefined("") // false
|
|
226
|
+
*/
|
|
227
|
+
static isNullOrUndefined(value: unknown): value is null | undefined;
|
|
228
|
+
/**
|
|
229
|
+
* Verifica se um valor não é null e não é undefined.
|
|
230
|
+
* @param value - Valor a ser verificado
|
|
231
|
+
* @returns true se value não é null e não é undefined, false caso contrário
|
|
232
|
+
* @example
|
|
233
|
+
* Guardian.isNotNullOrUndefined("texto") // true
|
|
234
|
+
* Guardian.isNotNullOrUndefined(null) // false
|
|
235
|
+
*/
|
|
236
|
+
static isNotNullOrUndefined(value: unknown): value is boolean;
|
|
237
|
+
/**
|
|
238
|
+
* Verifica se dois valores são iguais usando comparação estrita (===).
|
|
239
|
+
* @param valueA - Primeiro valor a ser comparado
|
|
240
|
+
* @param valueB - Segundo valor a ser comparado
|
|
241
|
+
* @returns true se valueA === valueB, false caso contrário
|
|
242
|
+
* @example
|
|
243
|
+
* Guardian.isEqual(5, 5) // true
|
|
244
|
+
* Guardian.isEqual(5, "5") // false
|
|
245
|
+
*/
|
|
15
246
|
static isEqual(valueA: unknown, valueB: unknown): boolean;
|
|
247
|
+
/**
|
|
248
|
+
* Verifica se dois valores são diferentes usando comparação estrita (!==).
|
|
249
|
+
* @param valueA - Primeiro valor a ser comparado
|
|
250
|
+
* @param valueB - Segundo valor a ser comparado
|
|
251
|
+
* @returns true se valueA !== valueB, false caso contrário
|
|
252
|
+
* @example
|
|
253
|
+
* Guardian.isDifferent(5, "5") // true
|
|
254
|
+
* Guardian.isDifferent(5, 5) // false
|
|
255
|
+
*/
|
|
16
256
|
static isDifferent(valueA: unknown, valueB: unknown): boolean;
|
|
257
|
+
/**
|
|
258
|
+
* Verifica se todos os valores de um array são iguais.
|
|
259
|
+
* @template T - Tipo dos valores no array
|
|
260
|
+
* @param values - Array de valores a ser verificado
|
|
261
|
+
* @returns true se todos os valores são iguais, false caso contrário
|
|
262
|
+
* @example
|
|
263
|
+
* Guardian.allEqual([5, 5, 5]) // true
|
|
264
|
+
* Guardian.allEqual([5, 5, 3]) // false
|
|
265
|
+
*/
|
|
266
|
+
static allEqual<T>(values: T[]): boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Verifica se um valor específico existe em uma coleção de valores.
|
|
269
|
+
* @param reference - Valor a ser procurado
|
|
270
|
+
* @param anyValues - Array de valores onde procurar
|
|
271
|
+
* @returns true se reference existe em anyValues, false caso contrário
|
|
272
|
+
* @example
|
|
273
|
+
* Guardian.isAnyOf(3, [1, 2, 3, 4]) // true
|
|
274
|
+
* Guardian.isAnyOf(5, [1, 2, 3, 4]) // false
|
|
275
|
+
*/
|
|
17
276
|
static isAnyOf(reference: unknown, anyValues: unknown[]): boolean;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
277
|
+
/**
|
|
278
|
+
* Verifica se uma string é um endereço de email válido.
|
|
279
|
+
* @param value - String a ser validada como email
|
|
280
|
+
* @returns true se value é um email válido, false caso contrário
|
|
281
|
+
* @example
|
|
282
|
+
* Guardian.isEmail("user@example.com") // true
|
|
283
|
+
* Guardian.isEmail("invalid-email") // false
|
|
284
|
+
*/
|
|
285
|
+
static isEmail(value: string): boolean;
|
|
286
|
+
/**
|
|
287
|
+
* Verifica se uma string é uma URL válida.
|
|
288
|
+
* @param value - String a ser validada como URL
|
|
289
|
+
* @returns true se value é uma URL válida, false caso contrário
|
|
290
|
+
* @example
|
|
291
|
+
* Guardian.isURL("https://example.com") // true
|
|
292
|
+
* Guardian.isURL("not a url") // false
|
|
293
|
+
*/
|
|
294
|
+
static isURL(value: string): boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Verifica se uma string é um UUID (Universally Unique Identifier) válido.
|
|
297
|
+
* @param value - String a ser validada como UUID
|
|
298
|
+
* @returns true se value é um UUID válido, false caso contrário
|
|
299
|
+
* @example
|
|
300
|
+
* Guardian.isUUID("550e8400-e29b-41d4-a716-446655440000") // true
|
|
301
|
+
* Guardian.isUUID("invalid-uuid") // false
|
|
302
|
+
*/
|
|
303
|
+
static isUUID(value: string): boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Verifica se um valor é do tipo booleano.
|
|
306
|
+
* @param value - Valor a ser verificado
|
|
307
|
+
* @returns true se value é um booleano, false caso contrário
|
|
308
|
+
* @example
|
|
309
|
+
* Guardian.isBoolean(true) // true
|
|
310
|
+
* Guardian.isBoolean(1) // false
|
|
311
|
+
*/
|
|
312
|
+
static isBoolean(value: unknown): value is boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Verifica se um valor é uma função.
|
|
315
|
+
* @param value - Valor a ser verificado
|
|
316
|
+
* @returns true se value é uma função, false caso contrário
|
|
317
|
+
* @example
|
|
318
|
+
* Guardian.isFunction(() => {}) // true
|
|
319
|
+
* Guardian.isFunction("função") // false
|
|
320
|
+
*/
|
|
321
|
+
static isFunction(value: unknown): value is Function;
|
|
322
|
+
/**
|
|
323
|
+
* Verifica se um valor é um objeto Date válido.
|
|
324
|
+
* @param value - Valor a ser verificado
|
|
325
|
+
* @returns true se value é uma data válida, false caso contrário
|
|
326
|
+
* @example
|
|
327
|
+
* Guardian.isDate(new Date()) // true
|
|
328
|
+
* Guardian.isDate(new Date("invalid")) // false
|
|
329
|
+
* Guardian.isDate("2024-01-01") // false
|
|
330
|
+
*/
|
|
331
|
+
static isDate(value: unknown): value is Date;
|
|
332
|
+
/**
|
|
333
|
+
* Verifica se todos os elementos de um array satisfazem um predicado.
|
|
334
|
+
* @template T - Tipo dos elementos do array
|
|
335
|
+
* @param array - Array a ser verificado
|
|
336
|
+
* @param predicate - Função que retorna true/false para cada elemento
|
|
337
|
+
* @returns true se todos os elementos satisfazem o predicado, false caso contrário
|
|
338
|
+
* @example
|
|
339
|
+
* Guardian.isEveryOf([2, 4, 6], x => x % 2 === 0) // true
|
|
340
|
+
* Guardian.isEveryOf([2, 3, 6], x => x % 2 === 0) // false
|
|
341
|
+
*/
|
|
342
|
+
static isEveryOf<T>(array: T[], predicate: (item: T) => boolean): boolean;
|
|
343
|
+
/**
|
|
344
|
+
* Verifica se pelo menos um elemento de um array satisfaz um predicado.
|
|
345
|
+
* @template T - Tipo dos elementos do array
|
|
346
|
+
* @param array - Array a ser verificado
|
|
347
|
+
* @param predicate - Função que retorna true/false para cada elemento
|
|
348
|
+
* @returns true se pelo menos um elemento satisfaz o predicado, false caso contrário
|
|
349
|
+
* @example
|
|
350
|
+
* Guardian.isSomeOf([1, 2, 4], x => x % 2 === 0) // true
|
|
351
|
+
* Guardian.isSomeOf([1, 3, 5], x => x % 2 === 0) // false
|
|
352
|
+
*/
|
|
353
|
+
static isSomeOf<T>(array: T[], predicate: (item: T) => boolean): boolean;
|
|
354
|
+
/**
|
|
355
|
+
* Verifica se um valor que possui propriedade length tem exatamente o comprimento específico.
|
|
356
|
+
* @template T - Tipo do valor com propriedade length
|
|
357
|
+
* @param value - Valor a ser verificado
|
|
358
|
+
* @param length - Comprimento esperado
|
|
359
|
+
* @returns true se o comprimento é exatamente o especificado, false caso contrário
|
|
360
|
+
* @example
|
|
361
|
+
* Guardian.hasLength("hello", 5) // true
|
|
362
|
+
* Guardian.hasLength([1, 2, 3], 3) // true
|
|
363
|
+
* Guardian.hasLength([1, 2], 3) // false
|
|
364
|
+
*/
|
|
365
|
+
static hasLength<T extends {
|
|
366
|
+
length: number;
|
|
367
|
+
}>(value: T, length: number): boolean;
|
|
368
|
+
/**
|
|
369
|
+
* Verifica se um valor existe dentro de uma coleção.
|
|
370
|
+
* @template T - Tipo dos valores
|
|
371
|
+
* @param value - Valor a ser procurado
|
|
372
|
+
* @param collection - Coleção onde procurar
|
|
373
|
+
* @returns true se value está na coleção, false caso contrário
|
|
374
|
+
* @example
|
|
375
|
+
* Guardian.isWithin(3, [1, 2, 3, 4]) // true
|
|
376
|
+
* Guardian.isWithin(5, [1, 2, 3, 4]) // false
|
|
377
|
+
*/
|
|
378
|
+
static isWithin<T>(value: T, collection: T[]): boolean;
|
|
379
|
+
/**
|
|
380
|
+
* Verifica se um valor não existe dentro de uma coleção.
|
|
381
|
+
* @template T - Tipo dos valores
|
|
382
|
+
* @param value - Valor a ser procurado
|
|
383
|
+
* @param collection - Coleção onde procurar
|
|
384
|
+
* @returns true se value não está na coleção, false caso contrário
|
|
385
|
+
* @example
|
|
386
|
+
* Guardian.isNotWithin(5, [1, 2, 3, 4]) // true
|
|
387
|
+
* Guardian.isNotWithin(3, [1, 2, 3, 4]) // false
|
|
388
|
+
*/
|
|
389
|
+
static isNotWithin<T>(value: T, collection: T[]): boolean;
|
|
390
|
+
/**
|
|
391
|
+
* Verifica se um objeto possui uma propriedade específica (própria ou herdada).
|
|
392
|
+
* @template T - Tipo do objeto
|
|
393
|
+
* @param value - Objeto a ser verificado
|
|
394
|
+
* @param property - Nome da propriedade a procurar
|
|
395
|
+
* @returns true se o objeto possui a propriedade, false caso contrário
|
|
396
|
+
* @example
|
|
397
|
+
* Guardian.hasProperty({ name: "João" }, "name") // true
|
|
398
|
+
* Guardian.hasProperty({ name: "João" }, "age") // false
|
|
399
|
+
*/
|
|
400
|
+
static hasProperty<T extends object>(value: T, property: PropertyKey): property is keyof T;
|
|
401
|
+
/**
|
|
402
|
+
* Verifica se um objeto possui uma propriedade própria (não herdada).
|
|
403
|
+
* @template T - Tipo do objeto
|
|
404
|
+
* @param value - Objeto a ser verificado
|
|
405
|
+
* @param property - Nome da propriedade a procurar
|
|
406
|
+
* @returns true se o objeto possui a propriedade própria, false caso contrário
|
|
407
|
+
* @example
|
|
408
|
+
* Guardian.hasOwnProperty({ name: "João" }, "name") // true
|
|
409
|
+
* Guardian.hasOwnProperty({ name: "João" }, "toString") // false
|
|
410
|
+
*/
|
|
411
|
+
static hasOwnProperty<T extends object>(value: T, property: PropertyKey): property is keyof T;
|
|
412
|
+
/**
|
|
413
|
+
* Verifica se um valor é do tipo primitivo especificado.
|
|
414
|
+
* @template T - Tipo esperado do valor
|
|
415
|
+
* @param value - Valor a ser verificado
|
|
416
|
+
* @param type - Tipo primitivo esperado (string, number, boolean, etc)
|
|
417
|
+
* @returns true se value é do tipo especificado, false caso contrário
|
|
418
|
+
* @example
|
|
419
|
+
* Guardian.isTypeOf("hello", "string") // true
|
|
420
|
+
* Guardian.isTypeOf(42, "number") // true
|
|
421
|
+
* Guardian.isTypeOf(42, "string") // false
|
|
422
|
+
*/
|
|
423
|
+
static isTypeOf<T>(value: unknown, type: PrimitiveType): value is T;
|
|
424
|
+
/**
|
|
425
|
+
* Verifica se um valor não é do tipo primitivo especificado.
|
|
426
|
+
* @template T - Tipo esperado do valor
|
|
427
|
+
* @param value - Valor a ser verificado
|
|
428
|
+
* @param type - Tipo primitivo a ser descartado
|
|
429
|
+
* @returns true se value não é do tipo especificado, false caso contrário
|
|
430
|
+
* @example
|
|
431
|
+
* Guardian.isNotTypeOf(42, "string") // true
|
|
432
|
+
* Guardian.isNotTypeOf("hello", "string") // false
|
|
433
|
+
*/
|
|
434
|
+
static isNotTypeOf<T>(value: unknown, type: PrimitiveType): value is T;
|
|
435
|
+
/**
|
|
436
|
+
* Verifica se um valor é uma instância de uma classe/construtor específico.
|
|
437
|
+
* @template T - Tipo esperado da instância
|
|
438
|
+
* @param value - Valor a ser verificado
|
|
439
|
+
* @param instance - Construtor/classe a ser verificado
|
|
440
|
+
* @returns true se value é uma instância de instance, false caso contrário
|
|
441
|
+
* @example
|
|
442
|
+
* Guardian.isInstanceOf(new Date(), Date) // true
|
|
443
|
+
* Guardian.isInstanceOf(new Date(), Array) // false
|
|
444
|
+
* Guardian.isInstanceOf(new User(), User) // true
|
|
445
|
+
*/
|
|
446
|
+
static isInstanceOf<T>(value: unknown, instance: Newable<T>): value is T;
|
|
447
|
+
/**
|
|
448
|
+
* Verifica se um valor é do tipo numérico.
|
|
449
|
+
* @param value - Valor a ser verificado
|
|
450
|
+
* @returns true se value é um número, false caso contrário
|
|
451
|
+
*/
|
|
22
452
|
private static isNumber;
|
|
453
|
+
/**
|
|
454
|
+
* Verifica se um valor é do tipo string.
|
|
455
|
+
* @param value - Valor a ser verificado
|
|
456
|
+
* @returns true se value é uma string, false caso contrário
|
|
457
|
+
*/
|
|
23
458
|
private static isString;
|
|
459
|
+
/**
|
|
460
|
+
* Verifica se um valor é um array.
|
|
461
|
+
* @param value - Valor a ser verificado
|
|
462
|
+
* @returns true se value é um array, false caso contrário
|
|
463
|
+
*/
|
|
24
464
|
private static isArray;
|
|
465
|
+
/**
|
|
466
|
+
* Verifica se um valor é um objeto.
|
|
467
|
+
* @param value - Valor a ser verificado
|
|
468
|
+
* @returns true se value é um objeto, false caso contrário
|
|
469
|
+
*/
|
|
25
470
|
private static isObject;
|
|
26
|
-
static isTypeOf<T>(value: unknown, type: PrimitiveType): value is T;
|
|
27
|
-
static isNotTypeOf<T>(value: unknown, type: PrimitiveType): value is T;
|
|
28
471
|
}
|
|
29
472
|
export { Guardian as _ };
|