@arkyn/shared 1.3.149 → 1.3.150

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.
@@ -0,0 +1,3 @@
1
+ declare function formatJsonObject(obj: any, indentLevel: number): string;
2
+ export { formatJsonObject };
3
+ //# sourceMappingURL=formatJsonObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatJsonObject.d.ts","sourceRoot":"","sources":["../../src/formats/formatJsonObject.ts"],"names":[],"mappings":"AAAA,iBAAS,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CA6C/D;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,49 @@
1
+ function formatJsonObject(obj, indentLevel) {
2
+ const indent = " ".repeat(indentLevel);
3
+ let formattedString = "";
4
+ if (typeof obj === "object" && obj !== null) {
5
+ if (Array.isArray(obj)) {
6
+ formattedString += "[\n";
7
+ obj.forEach((item, index) => {
8
+ formattedString +=
9
+ indent + " " + formatJsonObject(item, indentLevel + 1);
10
+ if (index < obj.length - 1) {
11
+ formattedString += ",";
12
+ }
13
+ formattedString += "\n";
14
+ });
15
+ formattedString += indent + "]";
16
+ }
17
+ else {
18
+ formattedString += "{\n";
19
+ const keys = Object.keys(obj);
20
+ keys.forEach((key, index) => {
21
+ formattedString +=
22
+ indent +
23
+ ' "' +
24
+ key +
25
+ '": ' +
26
+ formatJsonObject(obj[key], indentLevel + 1);
27
+ if (index < keys.length - 1) {
28
+ formattedString += ",";
29
+ }
30
+ formattedString += "\n";
31
+ });
32
+ formattedString += indent + "}";
33
+ }
34
+ }
35
+ else if (typeof obj === "string") {
36
+ try {
37
+ const parsedObj = JSON.parse(obj);
38
+ formattedString += formatJsonObject(parsedObj, indentLevel);
39
+ }
40
+ catch {
41
+ formattedString += '"' + obj + '"';
42
+ }
43
+ }
44
+ else {
45
+ formattedString += obj;
46
+ }
47
+ return formattedString;
48
+ }
49
+ export { formatJsonObject };
@@ -0,0 +1,3 @@
1
+ declare function formatJsonString(jsonString: string): string;
2
+ export { formatJsonString };
3
+ //# sourceMappingURL=formatJsonString.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatJsonString.d.ts","sourceRoot":"","sources":["../../src/formats/formatJsonString.ts"],"names":[],"mappings":"AAEA,iBAAS,gBAAgB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { formatJsonObject } from "./formatJsonObject";
2
+ function formatJsonString(jsonString) {
3
+ try {
4
+ const jsonObject = JSON.parse(jsonString);
5
+ return formatJsonObject(jsonObject, 0);
6
+ }
7
+ catch (error) {
8
+ console.error("Invalid JSON string:", error);
9
+ return "";
10
+ }
11
+ }
12
+ export { formatJsonString };
@@ -0,0 +1,3 @@
1
+ declare function formatToEllipsis(text: string, size?: number): string;
2
+ export { formatToEllipsis };
3
+ //# sourceMappingURL=formatToEllipsis.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatToEllipsis.d.ts","sourceRoot":"","sources":["../../src/formats/formatToEllipsis.ts"],"names":[],"mappings":"AAAA,iBAAS,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,SAAK,GAAG,MAAM,CAEzD;AAED,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,4 @@
1
+ function formatToEllipsis(text, size = 40) {
2
+ return text.length > size ? `${text.substring(0, size)}...` : text;
3
+ }
4
+ export { formatToEllipsis };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  export { formatBrazilianDateToDate } from "./formats/formatBrazilianDateToDate";
2
2
  export { formatDateHour } from "./formats/formatDateHour";
3
+ export { formatJsonObject } from "./formats/formatJsonObject";
4
+ export { formatJsonString } from "./formats/formatJsonString";
3
5
  export { formatToBRL } from "./formats/formatToBRL";
4
6
  export { formatToCep } from "./formats/formatToCep";
5
7
  export { formatToCNPJ } from "./formats/formatToCNPJ";
6
8
  export { formatToCPF } from "./formats/formatToCPF";
7
9
  export { formatToCpfCnpj } from "./formats/formatToCpfCnpj";
10
+ export { formatToEllipsis } from "./formats/formatToEllipsis";
8
11
  export { formatToHiddenDigits } from "./formats/formatToHiddenDigits";
9
12
  export { formatToPhone } from "./formats/formatToPhone";
10
13
  export { generateColorByString } from "./generators/generateColorByString";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAGzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAC/E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,E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E,MAAM,gCAAgC,CAAC;AAGrE,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC"}
package/dist/index.js CHANGED
@@ -1,11 +1,14 @@
1
1
  // formats
2
2
  export { formatBrazilianDateToDate } from "./formats/formatBrazilianDateToDate";
3
3
  export { formatDateHour } from "./formats/formatDateHour";
4
+ export { formatJsonObject } from "./formats/formatJsonObject";
5
+ export { formatJsonString } from "./formats/formatJsonString";
4
6
  export { formatToBRL } from "./formats/formatToBRL";
5
7
  export { formatToCep } from "./formats/formatToCep";
6
8
  export { formatToCNPJ } from "./formats/formatToCNPJ";
7
9
  export { formatToCPF } from "./formats/formatToCPF";
8
10
  export { formatToCpfCnpj } from "./formats/formatToCpfCnpj";
11
+ export { formatToEllipsis } from "./formats/formatToEllipsis";
9
12
  export { formatToHiddenDigits } from "./formats/formatToHiddenDigits";
10
13
  export { formatToPhone } from "./formats/formatToPhone";
11
14
  // generators
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkyn/shared",
3
- "version": "1.3.149",
3
+ "version": "1.3.150",
4
4
  "main": "./dist/bundle.js",
5
5
  "module": "./src/index.ts",
6
6
  "type": "module",
@@ -0,0 +1,48 @@
1
+ function formatJsonObject(obj: any, indentLevel: number): string {
2
+ const indent = " ".repeat(indentLevel);
3
+ let formattedString = "";
4
+
5
+ if (typeof obj === "object" && obj !== null) {
6
+ if (Array.isArray(obj)) {
7
+ formattedString += "[\n";
8
+ obj.forEach((item, index) => {
9
+ formattedString +=
10
+ indent + " " + formatJsonObject(item, indentLevel + 1);
11
+ if (index < obj.length - 1) {
12
+ formattedString += ",";
13
+ }
14
+ formattedString += "\n";
15
+ });
16
+ formattedString += indent + "]";
17
+ } else {
18
+ formattedString += "{\n";
19
+ const keys = Object.keys(obj);
20
+ keys.forEach((key, index) => {
21
+ formattedString +=
22
+ indent +
23
+ ' "' +
24
+ key +
25
+ '": ' +
26
+ formatJsonObject(obj[key], indentLevel + 1);
27
+ if (index < keys.length - 1) {
28
+ formattedString += ",";
29
+ }
30
+ formattedString += "\n";
31
+ });
32
+ formattedString += indent + "}";
33
+ }
34
+ } else if (typeof obj === "string") {
35
+ try {
36
+ const parsedObj = JSON.parse(obj);
37
+ formattedString += formatJsonObject(parsedObj, indentLevel);
38
+ } catch {
39
+ formattedString += '"' + obj + '"';
40
+ }
41
+ } else {
42
+ formattedString += obj;
43
+ }
44
+
45
+ return formattedString;
46
+ }
47
+
48
+ export { formatJsonObject };
@@ -0,0 +1,13 @@
1
+ import { formatJsonObject } from "./formatJsonObject";
2
+
3
+ function formatJsonString(jsonString: string): string {
4
+ try {
5
+ const jsonObject = JSON.parse(jsonString);
6
+ return formatJsonObject(jsonObject, 0);
7
+ } catch (error) {
8
+ console.error("Invalid JSON string:", error);
9
+ return "";
10
+ }
11
+ }
12
+
13
+ export { formatJsonString };
@@ -0,0 +1,5 @@
1
+ function formatToEllipsis(text: string, size = 40): string {
2
+ return text.length > size ? `${text.substring(0, size)}...` : text;
3
+ }
4
+
5
+ export { formatToEllipsis };
package/src/index.ts CHANGED
@@ -1,11 +1,14 @@
1
1
  // formats
2
2
  export { formatBrazilianDateToDate } from "./formats/formatBrazilianDateToDate";
3
3
  export { formatDateHour } from "./formats/formatDateHour";
4
+ export { formatJsonObject } from "./formats/formatJsonObject";
5
+ export { formatJsonString } from "./formats/formatJsonString";
4
6
  export { formatToBRL } from "./formats/formatToBRL";
5
7
  export { formatToCep } from "./formats/formatToCep";
6
8
  export { formatToCNPJ } from "./formats/formatToCNPJ";
7
9
  export { formatToCPF } from "./formats/formatToCPF";
8
10
  export { formatToCpfCnpj } from "./formats/formatToCpfCnpj";
11
+ export { formatToEllipsis } from "./formats/formatToEllipsis";
9
12
  export { formatToHiddenDigits } from "./formats/formatToHiddenDigits";
10
13
  export { formatToPhone } from "./formats/formatToPhone";
11
14