diff --git a/package.json b/package.json index 549b5d0..1053451 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@intelligo.ai/object-to-schema", - "version": "2.2.11", + "version": "2.2.12", "description": "", "main": "dist/index.js", "types": "dist/index.d.ts", diff --git a/src/index.ts b/src/index.ts index 5e08866..d73c703 100644 --- a/src/index.ts +++ b/src/index.ts @@ -9,7 +9,7 @@ export { } // const aa = { -// "companyName": "BRIGADE CAPITAL MANAGEMENT, LP", +// "companyName": "", // "evictionId": 1836030810467466240.0, // "bridge": null, // "defendantNames": [ diff --git a/src/utils/predefinedTransformations.ts b/src/utils/predefinedTransformations.ts index d1d4bba..34ab4b7 100644 --- a/src/utils/predefinedTransformations.ts +++ b/src/utils/predefinedTransformations.ts @@ -6,16 +6,17 @@ const toUpperCase = applyToOneOrMany(str => str.toUpperCase()); const titleCase = applyToOneOrMany(titleCaseTransformer) const companyNameFormat = applyToOneOrMany(companyNameTransformer) -function titleCaseTransformer(str: string) { +function titleCaseTransformer(str) { if (!str) { return str; } return str.trim() - .split(/\s/) - .map(word => `${word[0].toUpperCase()}${word.slice(1).toLowerCase()}`) - .join(' ') + .toLowerCase() + .split(/\s+/) + .map(word => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' '); } const toDate = applyToOneOrMany(str => new Date(str).toISOString());