@atlantjs/arch 13.2.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 (52) hide show
  1. package/@tool-box/utils/convert-units/convert-units.d.ts +14 -5
  2. package/@tool-box/utils/convert-units/convert-units.js +100 -8
  3. package/@tool-box/utils/datatypes/boolean-utils.d.ts +7 -0
  4. package/@tool-box/utils/datatypes/boolean-utils.js +146 -4
  5. package/@tool-box/utils/datatypes/string-utils.d.ts +20 -4
  6. package/@tool-box/utils/datatypes/string-utils.js +300 -14
  7. package/@tool-box/utils/ducts/common.d.ts +49 -0
  8. package/@tool-box/utils/ducts/common.js +36 -3
  9. package/@tool-box/utils/ducts/optional-type.d.ts +85 -0
  10. package/@tool-box/utils/ducts/optional-type.js +79 -0
  11. package/@tool-box/utils/ducts/return-type.d.ts +17 -17
  12. package/@tool-box/utils/ducts/return-type.js +14 -4
  13. package/@tool-box/utils/http-provider/http-provider.d.ts +6 -0
  14. package/@tool-box/utils/http-provider/http-provider.js +43 -14
  15. package/@tool-box/utils/map/map.abstract.d.ts +39 -0
  16. package/@tool-box/utils/map/map.abstract.js +70 -6
  17. package/@tool-box/utils/random/random.d.ts +168 -0
  18. package/@tool-box/utils/random/random.js +235 -0
  19. package/@tool-box/utils/type-guard/guardian.d.ts +450 -7
  20. package/@tool-box/utils/type-guard/guardian.js +539 -35
  21. package/objects/@common/edges/cron-expression.edge.d.ts +30 -2
  22. package/objects/@common/edges/cron-expression.edge.js +77 -5
  23. package/objects/@common/edges/email.edge.d.ts +39 -1
  24. package/objects/@common/edges/email.edge.js +80 -2
  25. package/objects/@common/edges/ulid.sketch.edge.d.ts +48 -1
  26. package/objects/@common/edges/ulid.sketch.edge.js +75 -4
  27. package/objects/@common/edges/url.edge.d.ts +182 -0
  28. package/objects/@common/edges/url.edge.js +249 -0
  29. package/objects/@common/edges/username.edge.d.ts +9 -0
  30. package/objects/@common/edges/username.edge.js +34 -0
  31. package/objects/@common/edges/uuid.sketch.edge.d.ts +97 -1
  32. package/objects/@common/edges/uuid.sketch.edge.js +127 -6
  33. package/objects/amount/amount-value.edge.d.ts +42 -0
  34. package/objects/amount/amount-value.edge.js +76 -0
  35. package/objects/amount/amount.edge.d.ts +389 -11
  36. package/objects/amount/amount.edge.js +543 -4
  37. package/objects/datetime/edges/datetime.edge.d.ts +422 -4
  38. package/objects/datetime/edges/datetime.edge.js +538 -33
  39. package/objects/password/password.edge.d.ts +90 -0
  40. package/objects/password/password.edge.js +140 -6
  41. package/objects/primitives/boolean.edge.sketch.d.ts +105 -3
  42. package/objects/primitives/boolean.edge.sketch.js +132 -6
  43. package/objects/primitives/number.edge.sketch.d.ts +236 -0
  44. package/objects/primitives/number.edge.sketch.js +310 -24
  45. package/objects/primitives/string.edge.sketch.d.ts +148 -0
  46. package/objects/primitives/string.edge.sketch.js +191 -7
  47. package/objects/schedule/schedule.edge.d.ts +194 -0
  48. package/objects/schedule/schedule.edge.js +269 -2
  49. package/objects/time/time.edge.d.ts +285 -2
  50. package/objects/time/time.edge.js +385 -6
  51. package/package.json +1 -1
  52. package/tsconfig.tsbuildinfo +1 -1
@@ -1,11 +1,20 @@
1
1
  import { AmountEdge } from "../../../objects/amount/amount.edge";
2
+ import { EnergyUnitPoint } from "../../../objects/amount/points/energy-unit.point";
2
3
  import { LengthUnitPoint } from "../../../objects/amount/points/length-unit.point";
3
4
  import { MassUnitPoint } from "../../../objects/amount/points/mass-unit.point";
4
5
  import { VolumeUnitPoint } from "../../../objects/amount/points/volume-unit.point";
5
6
  export declare class ConvertUnit {
6
- static toKg(value: AmountEdge<MassUnitPoint>): number;
7
- static toCm(value: AmountEdge<LengthUnitPoint>): number;
8
- static toM(value: AmountEdge<LengthUnitPoint>): number;
9
- static toL(value: AmountEdge<VolumeUnitPoint>): number;
10
- static toMl(value: AmountEdge<VolumeUnitPoint>): number;
7
+ static toKilogram(value: AmountEdge<MassUnitPoint>): number;
8
+ static toGram(value: AmountEdge<MassUnitPoint>): number;
9
+ static toMilligram(value: AmountEdge<MassUnitPoint>): number;
10
+ static toMicrogram(value: AmountEdge<MassUnitPoint>): number;
11
+ static toKilometer(value: AmountEdge<LengthUnitPoint>): number;
12
+ static toCentimeter(value: AmountEdge<LengthUnitPoint>): number;
13
+ static toMeter(value: AmountEdge<LengthUnitPoint>): number;
14
+ static toMillimeter(value: AmountEdge<LengthUnitPoint>): number;
15
+ static toLiter(value: AmountEdge<VolumeUnitPoint>): number;
16
+ static toMilliliter(value: AmountEdge<VolumeUnitPoint>): number;
17
+ static toKilocalorie(value: AmountEdge<EnergyUnitPoint>): number;
18
+ static toCalorie(value: AmountEdge<EnergyUnitPoint>): number;
19
+ static toJoule(value: AmountEdge<EnergyUnitPoint>): number;
11
20
  }
@@ -4,13 +4,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ConvertUnit = void 0;
7
+ const convert_units_1 = __importDefault(require("convert-units"));
7
8
  const guardian_1 = require("../type-guard/guardian");
9
+ const energy_unit_point_1 = require("../../../objects/amount/points/energy-unit.point");
8
10
  const length_unit_point_1 = require("../../../objects/amount/points/length-unit.point");
9
11
  const mass_unit_point_1 = require("../../../objects/amount/points/mass-unit.point");
10
12
  const volume_unit_point_1 = require("../../../objects/amount/points/volume-unit.point");
11
- const convert_units_1 = __importDefault(require("convert-units"));
12
13
  class ConvertUnit {
13
- static toKg(value) {
14
+ // Mass
15
+ static toKilogram(value) {
14
16
  if (guardian_1._.isEqual(value.unit, mass_unit_point_1.MassUnitPoint.gram)) {
15
17
  return (0, convert_units_1.default)(value.value).from("g").to("kg");
16
18
  }
@@ -22,9 +24,58 @@ class ConvertUnit {
22
24
  }
23
25
  return value.value;
24
26
  }
25
- static toCm(value) {
27
+ static toGram(value) {
28
+ if (guardian_1._.isEqual(value.unit, mass_unit_point_1.MassUnitPoint.kilogram)) {
29
+ return (0, convert_units_1.default)(value.value).from("kg").to("g");
30
+ }
31
+ if (guardian_1._.isEqual(value.unit, mass_unit_point_1.MassUnitPoint.micrograma)) {
32
+ return (0, convert_units_1.default)(value.value).from("mcg").to("g");
33
+ }
34
+ if (guardian_1._.isEqual(value.unit, mass_unit_point_1.MassUnitPoint.milligram)) {
35
+ return (0, convert_units_1.default)(value.value).from("mg").to("g");
36
+ }
37
+ return value.value;
38
+ }
39
+ static toMilligram(value) {
40
+ if (guardian_1._.isEqual(value.unit, mass_unit_point_1.MassUnitPoint.kilogram)) {
41
+ return (0, convert_units_1.default)(value.value).from("kg").to("mg");
42
+ }
43
+ if (guardian_1._.isEqual(value.unit, mass_unit_point_1.MassUnitPoint.micrograma)) {
44
+ return (0, convert_units_1.default)(value.value).from("mcg").to("mg");
45
+ }
46
+ if (guardian_1._.isEqual(value.unit, mass_unit_point_1.MassUnitPoint.gram)) {
47
+ return (0, convert_units_1.default)(value.value).from("g").to("mg");
48
+ }
49
+ return value.value;
50
+ }
51
+ static toMicrogram(value) {
52
+ if (guardian_1._.isEqual(value.unit, mass_unit_point_1.MassUnitPoint.kilogram)) {
53
+ return (0, convert_units_1.default)(value.value).from("kg").to("mcg");
54
+ }
55
+ if (guardian_1._.isEqual(value.unit, mass_unit_point_1.MassUnitPoint.milligram)) {
56
+ return (0, convert_units_1.default)(value.value).from("mg").to("mcg");
57
+ }
58
+ if (guardian_1._.isEqual(value.unit, mass_unit_point_1.MassUnitPoint.gram)) {
59
+ return (0, convert_units_1.default)(value.value).from("g").to("mcg");
60
+ }
61
+ return value.value;
62
+ }
63
+ // Length
64
+ static toKilometer(value) {
26
65
  if (guardian_1._.isEqual(value.unit, length_unit_point_1.LengthUnitPoint.millimeter)) {
27
- return (0, convert_units_1.default)(value.value).from("ml").to("cm");
66
+ return (0, convert_units_1.default)(value.value).from("mm").to("km");
67
+ }
68
+ if (guardian_1._.isEqual(value.unit, length_unit_point_1.LengthUnitPoint.centimeter)) {
69
+ return (0, convert_units_1.default)(value.value).from("cm").to("km");
70
+ }
71
+ if (guardian_1._.isEqual(value.unit, length_unit_point_1.LengthUnitPoint.meter)) {
72
+ return (0, convert_units_1.default)(value.value).from("m").to("km");
73
+ }
74
+ return value.value;
75
+ }
76
+ static toCentimeter(value) {
77
+ if (guardian_1._.isEqual(value.unit, length_unit_point_1.LengthUnitPoint.millimeter)) {
78
+ return (0, convert_units_1.default)(value.value).from("mm").to("cm");
28
79
  }
29
80
  if (guardian_1._.isEqual(value.unit, length_unit_point_1.LengthUnitPoint.kilometer)) {
30
81
  return (0, convert_units_1.default)(value.value).from("km").to("cm");
@@ -34,9 +85,9 @@ class ConvertUnit {
34
85
  }
35
86
  return value.value;
36
87
  }
37
- static toM(value) {
88
+ static toMeter(value) {
38
89
  if (guardian_1._.isEqual(value.unit, length_unit_point_1.LengthUnitPoint.millimeter)) {
39
- return (0, convert_units_1.default)(value.value).from("ml").to("m");
90
+ return (0, convert_units_1.default)(value.value).from("mm").to("m");
40
91
  }
41
92
  if (guardian_1._.isEqual(value.unit, length_unit_point_1.LengthUnitPoint.kilometer)) {
42
93
  return (0, convert_units_1.default)(value.value).from("km").to("m");
@@ -46,17 +97,58 @@ class ConvertUnit {
46
97
  }
47
98
  return value.value;
48
99
  }
49
- static toL(value) {
100
+ static toMillimeter(value) {
101
+ if (guardian_1._.isEqual(value.unit, length_unit_point_1.LengthUnitPoint.meter)) {
102
+ return (0, convert_units_1.default)(value.value).from("m").to("mm");
103
+ }
104
+ if (guardian_1._.isEqual(value.unit, length_unit_point_1.LengthUnitPoint.kilometer)) {
105
+ return (0, convert_units_1.default)(value.value).from("km").to("mm");
106
+ }
107
+ if (guardian_1._.isEqual(value.unit, length_unit_point_1.LengthUnitPoint.centimeter)) {
108
+ return (0, convert_units_1.default)(value.value).from("cm").to("mm");
109
+ }
110
+ return value.value;
111
+ }
112
+ // Volume
113
+ static toLiter(value) {
50
114
  if (guardian_1._.isEqual(value.unit, volume_unit_point_1.VolumeUnitPoint.milliliter)) {
51
115
  return (0, convert_units_1.default)(value.value).from("ml").to("l");
52
116
  }
53
117
  return value.value;
54
118
  }
55
- static toMl(value) {
119
+ static toMilliliter(value) {
56
120
  if (guardian_1._.isEqual(value.unit, volume_unit_point_1.VolumeUnitPoint.liter)) {
57
121
  return (0, convert_units_1.default)(value.value).from("l").to("ml");
58
122
  }
59
123
  return value.value;
60
124
  }
125
+ // Energy
126
+ static toKilocalorie(value) {
127
+ if (guardian_1._.isEqual(value.unit, energy_unit_point_1.EnergyUnitPoint.calorie)) {
128
+ return value.value / 1000;
129
+ }
130
+ if (guardian_1._.isEqual(value.unit, energy_unit_point_1.EnergyUnitPoint.joule)) {
131
+ return value.value / 4184;
132
+ }
133
+ return value.value;
134
+ }
135
+ static toCalorie(value) {
136
+ if (guardian_1._.isEqual(value.unit, energy_unit_point_1.EnergyUnitPoint.kilocalorie)) {
137
+ return value.value * 1000;
138
+ }
139
+ if (guardian_1._.isEqual(value.unit, energy_unit_point_1.EnergyUnitPoint.joule)) {
140
+ return value.value / 4.184;
141
+ }
142
+ return value.value;
143
+ }
144
+ static toJoule(value) {
145
+ if (guardian_1._.isEqual(value.unit, energy_unit_point_1.EnergyUnitPoint.kilocalorie)) {
146
+ return value.value * 4184;
147
+ }
148
+ if (guardian_1._.isEqual(value.unit, energy_unit_point_1.EnergyUnitPoint.calorie)) {
149
+ return value.value * 4.184;
150
+ }
151
+ return value.value;
152
+ }
61
153
  }
62
154
  exports.ConvertUnit = ConvertUnit;
@@ -6,4 +6,11 @@ interface Boolean {
6
6
  not(): boolean;
7
7
  and(value: boolean): boolean;
8
8
  or(value: boolean): boolean;
9
+ xor(value: boolean): boolean;
10
+ nand(value: boolean): boolean;
11
+ nor(value: boolean): boolean;
12
+ implies(value: boolean): boolean;
13
+ toNumber(): number;
14
+ toString(): string;
15
+ toggle(): boolean;
9
16
  }
@@ -1,22 +1,164 @@
1
1
  "use strict";
2
+ /**
3
+ * Verifica se o valor booleano é verdadeiro (true).
4
+ * @returns true se o valor é true, false caso contrário
5
+ * @example
6
+ * (true).truthy() // true
7
+ * (false).truthy() // false
8
+ */
2
9
  Boolean.prototype.truthy = function () {
3
- return this === true;
10
+ return this.valueOf() === true;
4
11
  };
12
+ /**
13
+ * Verifica se o valor booleano é falso (false ou undefined).
14
+ * @returns true se o valor é false ou undefined, false caso contrário
15
+ * @example
16
+ * (false).falsy() // true
17
+ * (true).falsy() // false
18
+ */
5
19
  Boolean.prototype.falsy = function () {
6
- return this === false || this === undefined;
20
+ return this.valueOf() === false || this.valueOf() === undefined;
7
21
  };
22
+ /**
23
+ * Retorna o valor booleano negado (inversão lógica).
24
+ * @returns true se o valor é false, false se o valor é true
25
+ * @example
26
+ * (true).not() // false
27
+ * (false).not() // true
28
+ */
8
29
  Boolean.prototype.not = function () {
9
30
  return !this.valueOf();
10
31
  };
32
+ /**
33
+ * Realiza a operação lógica AND (E) entre este valor e outro.
34
+ * Retorna true somente se ambos os valores forem true.
35
+ * @param value - Segundo operando booleano
36
+ * @returns true se ambos são true, false caso contrário
37
+ * @example
38
+ * (true).and(true) // true
39
+ * (true).and(false) // false
40
+ * (false).and(true) // false
41
+ */
11
42
  Boolean.prototype.and = function (value) {
12
43
  return this.valueOf() === true && value === true;
13
44
  };
45
+ /**
46
+ * Realiza a operação lógica OR (OU) entre este valor e outro.
47
+ * Retorna true se pelo menos um dos valores for true.
48
+ * @param value - Segundo operando booleano
49
+ * @returns true se pelo menos um é true, false caso contrário
50
+ * @example
51
+ * (true).or(false) // true
52
+ * (false).or(false) // false
53
+ * (false).or(true) // true
54
+ */
14
55
  Boolean.prototype.or = function (value) {
15
56
  return this.valueOf() === true || value === true;
16
57
  };
58
+ /**
59
+ * Verifica se este valor booleano é igual a outro.
60
+ * @param value - Valor booleano para comparação
61
+ * @returns true se os valores são iguais, false caso contrário
62
+ * @example
63
+ * (true).equal(true) // true
64
+ * (true).equal(false) // false
65
+ */
17
66
  Boolean.prototype.equal = function (value) {
18
- return this === value;
67
+ return this.valueOf() === value;
19
68
  };
69
+ /**
70
+ * Verifica se este valor booleano é diferente de outro.
71
+ * @param value - Valor booleano para comparação
72
+ * @returns true se os valores são diferentes, false caso contrário
73
+ * @example
74
+ * (true).different(false) // true
75
+ * (true).different(true) // false
76
+ */
20
77
  Boolean.prototype.different = function (value) {
21
- return this !== value;
78
+ return this.valueOf() !== value;
79
+ };
80
+ /**
81
+ * Realiza a operação lógica XOR (OU exclusivo) entre este valor e outro.
82
+ * Retorna true somente se exatamente um dos valores for true.
83
+ * @param value - Segundo operando booleano
84
+ * @returns true se exatamente um é true, false caso contrário
85
+ * @example
86
+ * (true).xor(false) // true
87
+ * (true).xor(true) // false
88
+ * (false).xor(false) // false
89
+ */
90
+ Boolean.prototype.xor = function (value) {
91
+ return this.valueOf() !== value;
92
+ };
93
+ /**
94
+ * Realiza a operação lógica NAND (NÃO-E) entre este valor e outro.
95
+ * Retorna false somente se ambos os valores forem true.
96
+ * @param value - Segundo operando booleano
97
+ * @returns false se ambos são true, true caso contrário
98
+ * @example
99
+ * (true).nand(true) // false
100
+ * (true).nand(false) // true
101
+ * (false).nand(false) // true
102
+ */
103
+ Boolean.prototype.nand = function (value) {
104
+ return !(this.valueOf() === true && value === true);
105
+ };
106
+ /**
107
+ * Realiza a operação lógica NOR (NÃO-OU) entre este valor e outro.
108
+ * Retorna true somente se ambos os valores forem false.
109
+ * @param value - Segundo operando booleano
110
+ * @returns true se ambos são false, false caso contrário
111
+ * @example
112
+ * (false).nor(false) // true
113
+ * (true).nor(false) // false
114
+ * (true).nor(true) // false
115
+ */
116
+ Boolean.prototype.nor = function (value) {
117
+ return !(this.valueOf() === true || value === true);
118
+ };
119
+ /**
120
+ * Realiza a operação lógica de implicação (→) entre este valor e outro.
121
+ * Retorna false somente se este valor é true e o outro é false.
122
+ * @param value - Consequente da implicação
123
+ * @returns false se this é true e value é false, true caso contrário
124
+ * @example
125
+ * (true).implies(true) // true
126
+ * (true).implies(false) // false
127
+ * (false).implies(true) // true
128
+ * (false).implies(false) // true
129
+ */
130
+ Boolean.prototype.implies = function (value) {
131
+ return !this.valueOf() || value;
132
+ };
133
+ /**
134
+ * Converte o valor booleano para número.
135
+ * true é convertido para 1, false para 0.
136
+ * @returns 1 se o valor é true, 0 se o valor é false
137
+ * @example
138
+ * (true).toNumber() // 1
139
+ * (false).toNumber() // 0
140
+ */
141
+ Boolean.prototype.toNumber = function () {
142
+ return this.valueOf() ? 1 : 0;
143
+ };
144
+ /**
145
+ * Converte o valor booleano para string.
146
+ * @returns "true" se o valor é true, "false" se o valor é false
147
+ * @example
148
+ * (true).toString() // "true"
149
+ * (false).toString() // "false"
150
+ */
151
+ Boolean.prototype.toString = function () {
152
+ return this.valueOf() ? "true" : "false";
153
+ };
154
+ /**
155
+ * Retorna o valor booleano invertido sem alterar o original.
156
+ * Equivalente a `.not()`, porém semânticamente indica alternância de estado.
157
+ * @returns true se o valor é false, false se o valor é true
158
+ * @example
159
+ * (true).toggle() // false
160
+ * (false).toggle() // true
161
+ */
162
+ Boolean.prototype.toggle = function () {
163
+ return !this.valueOf();
22
164
  };
@@ -1,14 +1,30 @@
1
1
  interface String {
2
2
  toKebabCase(): string;
3
3
  toSnakeCase(): string;
4
+ toCamelCase(): string;
4
5
  toPascalCase(): string;
5
- sanitize(): string;
6
- capitalize(): string;
7
6
  toTitleCase(): string;
8
- contains(substring: string): boolean;
9
- truncate(length: number): String;
7
+ capitalize(): string;
8
+ sanitize(): string;
9
+ truncate(length: number): string;
10
10
  removeWhitespace(): string;
11
+ contains(substring: string): boolean;
12
+ startsWith(substring: string): boolean;
13
+ endsWith(substring: string): boolean;
11
14
  isEmpty(): boolean;
12
15
  isFilled(): boolean;
16
+ isPalindrome(): boolean;
17
+ isNumeric(): boolean;
18
+ isEmail(): boolean;
19
+ isURL(): boolean;
20
+ isUUID(): boolean;
21
+ countOccurrences(substring: string): number;
22
+ toBase64(): string;
13
23
  fromBase64(): string;
24
+ reverse(): string;
25
+ repeat(times: number): string;
26
+ padStart(length: number, char?: string): string;
27
+ padEnd(length: number, char?: string): string;
28
+ replaceAll(search: string | RegExp, replacement: string | ((substring: string, ...args: any[]) => string)): string;
14
29
  }
30
+ declare function escapeRegExp(value: string): string;