uityu.shared 1.0.0 → 1.0.1

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/README.md CHANGED
@@ -109,6 +109,18 @@ const limit = clampLimit(undefined, { defaultValue: 10, max: 50, min: 5 });
109
109
  // -> 10
110
110
  ```
111
111
 
112
+ ### Normalización de texto genérica
113
+
114
+ ```ts
115
+ import { normalizeText } from 'uityu.shared/common/string';
116
+
117
+ const emailKey = normalizeText(' USER@domain.COM ');
118
+ // -> 'user@domain.com'
119
+
120
+ const keepCase = normalizeText(' Mixed Value ', { lowercase: false });
121
+ // -> 'Mixed Value'
122
+ ```
123
+
112
124
  ## Errores + HTTP (`uityu.shared/errors`, `uityu.shared/http`)
113
125
 
114
126
  ```ts
@@ -1,3 +1,4 @@
1
1
  export * from "./math/index.js";
2
2
  export * from "./logging/index.js";
3
+ export * from "./string/index.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
@@ -1,3 +1,4 @@
1
1
  export * from "./math/index.js";
2
2
  export * from "./logging/index.js";
3
+ export * from "./string/index.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./normalize-text.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from "./normalize-text.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,12 @@
1
+ export type NormalizeTextOptions = {
2
+ /** When false, keeps original casing */
3
+ lowercase?: boolean;
4
+ /** When false, preserves surrounding whitespace */
5
+ trim?: boolean;
6
+ };
7
+ /**
8
+ * Normalize arbitrary strings (emails, identifiers, etc.)
9
+ * by trimming and lowercasing by default.
10
+ */
11
+ export declare function normalizeText(value: string | null | undefined, options?: NormalizeTextOptions): string;
12
+ //# sourceMappingURL=normalize-text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-text.d.ts","sourceRoot":"","sources":["../../../src/common/string/normalize-text.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,wCAAwC;IACxC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,mDAAmD;IACnD,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AAOF;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,OAAO,GAAE,oBAAsC,GAC9C,MAAM,CAYR"}
@@ -0,0 +1,19 @@
1
+ const DEFAULT_OPTIONS = {
2
+ lowercase: true,
3
+ trim: true,
4
+ };
5
+ /**
6
+ * Normalize arbitrary strings (emails, identifiers, etc.)
7
+ * by trimming and lowercasing by default.
8
+ */
9
+ export function normalizeText(value, options = DEFAULT_OPTIONS) {
10
+ if (typeof value !== "string") {
11
+ return "";
12
+ }
13
+ let result = options.trim === false ? value : value.trim();
14
+ if (options.lowercase !== false) {
15
+ result = result.toLowerCase();
16
+ }
17
+ return result;
18
+ }
19
+ //# sourceMappingURL=normalize-text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-text.js","sourceRoot":"","sources":["../../../src/common/string/normalize-text.ts"],"names":[],"mappings":"AAOA,MAAM,eAAe,GAAmC;IACtD,SAAS,EAAE,IAAI;IACf,IAAI,EAAE,IAAI;CACX,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,KAAgC,EAChC,UAAgC,eAAe;IAE/C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,MAAM,GAAG,OAAO,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAE3D,IAAI,OAAO,CAAC,SAAS,KAAK,KAAK,EAAE,CAAC;QAChC,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uityu.shared",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Shared infrastructure toolkit for UITYU microservices (Cloud Functions, SSR, APIs).",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -22,6 +22,10 @@
22
22
  "import": "./dist/common/logging/index.js",
23
23
  "types": "./dist/common/logging/index.d.ts"
24
24
  },
25
+ "./common/string": {
26
+ "import": "./dist/common/string/index.js",
27
+ "types": "./dist/common/string/index.d.ts"
28
+ },
25
29
  "./errors": {
26
30
  "import": "./dist/errors/index.js",
27
31
  "types": "./dist/errors/index.d.ts"