@sankhyalabs/core 1.0.25 → 1.0.26

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.
@@ -9,4 +9,10 @@ export declare class StringUtils {
9
9
  * @param value String para ser validada.
10
10
  */
11
11
  static isEmpty(value: any): Boolean;
12
+ /**
13
+ * Remove acentos de vogais, substitui Ç por c e retorna a string em caixa alta.
14
+ *
15
+ * @param value String para ser transformada.
16
+ */
17
+ static replaceAccentuatedChars(text: string): string;
12
18
  }
@@ -19,5 +19,36 @@ export class StringUtils {
19
19
  }
20
20
  return false;
21
21
  }
22
+ /**
23
+ * Remove acentos de vogais, substitui Ç por c e retorna a string em caixa alta.
24
+ *
25
+ * @param value String para ser transformada.
26
+ */
27
+ static replaceAccentuatedChars(text) {
28
+ text = text.toUpperCase();
29
+ text = text.replace(/[À]/, "A");
30
+ text = text.replace(/[Á]/, "A");
31
+ text = text.replace(/[Â]/, "A");
32
+ text = text.replace(/[Ã]/, "A");
33
+ text = text.replace(/[Ä]/, "A");
34
+ text = text.replace(/[È]/, "E");
35
+ text = text.replace(/[É]/, "E");
36
+ text = text.replace(/[Ê]/, "E");
37
+ text = text.replace(/[Ë]/, "E");
38
+ text = text.replace(/[Ì]/, "I");
39
+ text = text.replace(/[Í]/, "I");
40
+ text = text.replace(/[Î]/, "I");
41
+ text = text.replace(/[Ï]/, "I");
42
+ text = text.replace(/[Ò]/, "O");
43
+ text = text.replace(/[Ó]/, "O");
44
+ text = text.replace(/[Ô]/, "O");
45
+ text = text.replace(/[Ö]/, "O");
46
+ text = text.replace(/[Ù]/, "U");
47
+ text = text.replace(/[Ú]/, "U");
48
+ text = text.replace(/[Û]/, "U");
49
+ text = text.replace(/[Ü]/, "U");
50
+ text = text.replace(/[Ç]/, "C");
51
+ return text.replace(/[^a-z0-9]/gi, '');
52
+ }
22
53
  }
23
54
  //# sourceMappingURL=StringUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StringUtils.js","sourceRoot":"","sources":["../../src/utils/StringUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,WAAW;IAEpB;;;;;MAKE;IACF,MAAM,CAAC,OAAO,CAAC,KAAS;QAEpB,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;YACtC,OAAO,IAAI,CAAC;SACf;QAED,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QACzB,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAErB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACpB,OAAO,IAAI,CAAC;SACf;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;CAEJ"}
1
+ {"version":3,"file":"StringUtils.js","sourceRoot":"","sources":["../../src/utils/StringUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,WAAW;IAEpB;;;;;MAKE;IACF,MAAM,CAAC,OAAO,CAAC,KAAU;QAErB,IAAI,KAAK,IAAI,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;YACtC,OAAO,IAAI,CAAC;SACf;QAED,KAAK,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;QACzB,KAAK,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;QAErB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE;YACpB,OAAO,IAAI,CAAC;SACf;QAED,OAAO,KAAK,CAAC;IACjB,CAAC;IAGD;;;;MAIE;IACF,MAAM,CAAC,uBAAuB,CAAC,IAAY;QACvC,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAC1B,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACh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AI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,EAAE,EAAE,CAAC,CAAC;IAC3C,CAAC;CAEJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sankhyalabs/core",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
4
4
  "description": "Modulo core JavaScript da Sankhya.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Classe com utiliários comuns para Strings.
3
3
  */
4
- export class StringUtils{
4
+ export class StringUtils {
5
5
 
6
6
  /**
7
7
  * Verifica se a string está vazia.
@@ -9,8 +9,8 @@ export class StringUtils{
9
9
  *
10
10
  * @param value String para ser validada.
11
11
  */
12
- static isEmpty(value:any):Boolean {
13
-
12
+ static isEmpty(value: any): Boolean {
13
+
14
14
  if (value == undefined || value === null) {
15
15
  return true;
16
16
  }
@@ -25,4 +25,37 @@ export class StringUtils{
25
25
  return false;
26
26
  }
27
27
 
28
+
29
+ /**
30
+ * Remove acentos de vogais, substitui Ç por c e retorna a string em caixa alta.
31
+ *
32
+ * @param value String para ser transformada.
33
+ */
34
+ static replaceAccentuatedChars(text: string): string {
35
+ text = text.toUpperCase();
36
+ text = text.replace(/[À]/, "A");
37
+ text = text.replace(/[Á]/, "A");
38
+ text = text.replace(/[Â]/, "A");
39
+ text = text.replace(/[Ã]/, "A");
40
+ text = text.replace(/[Ä]/, "A");
41
+ text = text.replace(/[È]/, "E");
42
+ text = text.replace(/[É]/, "E");
43
+ text = text.replace(/[Ê]/, "E");
44
+ text = text.replace(/[Ë]/, "E");
45
+ text = text.replace(/[Ì]/, "I");
46
+ text = text.replace(/[Í]/, "I");
47
+ text = text.replace(/[Î]/, "I");
48
+ text = text.replace(/[Ï]/, "I");
49
+ text = text.replace(/[Ò]/, "O");
50
+ text = text.replace(/[Ó]/, "O");
51
+ text = text.replace(/[Ô]/, "O");
52
+ text = text.replace(/[Ö]/, "O");
53
+ text = text.replace(/[Ù]/, "U");
54
+ text = text.replace(/[Ú]/, "U");
55
+ text = text.replace(/[Û]/, "U");
56
+ text = text.replace(/[Ü]/, "U");
57
+ text = text.replace(/[Ç]/, "C");
58
+ return text.replace(/[^a-z0-9]/gi, '');
59
+ }
60
+
28
61
  }
@@ -1,35 +1,44 @@
1
- import {StringUtils} from '../../src/utils/StringUtils';
2
-
3
- describe('StringUtils', function() {
4
-
5
- it('valor vazio', function() {
6
- let result = StringUtils.isEmpty('');
7
- expect(result).toBe(true);
8
- });
9
-
10
- it('valor em branco', function() {
11
- let result = StringUtils.isEmpty(' ');
12
- expect(result).toBe(true);
13
- });
14
-
15
- it('valor null', function() {
16
- let result = StringUtils.isEmpty(null);
17
- expect(result).toBe(true);
18
- });
19
-
20
- it('valor undefined', function() {
21
- let result = StringUtils.isEmpty(undefined);
22
- expect(result).toBe(true);
23
- });
24
-
25
- it('valor 0', function() {
26
- let result = StringUtils.isEmpty('0');
27
- expect(result).toBe(false);
28
- });
29
-
30
- it('com valor', function() {
31
- let result = StringUtils.isEmpty('ab');
32
- expect(result).toBe(false);
33
- });
1
+ import { StringUtils } from '../../src/utils/StringUtils';
2
+
3
+ describe('StringUtils', function () {
4
+
5
+ it('valor vazio', function () {
6
+ let result = StringUtils.isEmpty('');
7
+ expect(result).toBe(true);
8
+ });
9
+
10
+ it('valor em branco', function () {
11
+ let result = StringUtils.isEmpty(' ');
12
+ expect(result).toBe(true);
13
+ });
14
+
15
+ it('valor null', function () {
16
+ let result = StringUtils.isEmpty(null);
17
+ expect(result).toBe(true);
18
+ });
19
+
20
+ it('valor undefined', function () {
21
+ let result = StringUtils.isEmpty(undefined);
22
+ expect(result).toBe(true);
23
+ });
24
+
25
+ it('valor 0', function () {
26
+ let result = StringUtils.isEmpty('0');
27
+ expect(result).toBe(false);
28
+ });
29
+
30
+ it('com valor', function () {
31
+ let result = StringUtils.isEmpty('ab');
32
+ expect(result).toBe(false);
33
+ });
34
+
35
+ it('substitui vogais com acento por sem acento', function () {
36
+ let resultadoInputMaiusculo = StringUtils.replaceAccentuatedChars('ÁÀÂÃÄ');
37
+ expect(resultadoInputMaiusculo).toBe('AAAAA');
38
+ let resultInputMinusculo = StringUtils.replaceAccentuatedChars('áàâãä');
39
+ expect(resultInputMinusculo).toBe('AAAAA');
40
+ let resultInputCedilha = StringUtils.replaceAccentuatedChars('ç');
41
+ expect(resultInputCedilha).toBe('C');
42
+ });
34
43
 
35
44
  });