dce-reactkit 3.2.4 → 3.2.5

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/dist/cjs/index.js CHANGED
@@ -3027,8 +3027,45 @@ const genHumanReadableName = (machineReadableName) => {
3027
3027
  }
3028
3028
  humanReadableName += char;
3029
3029
  });
3030
- // Trim and return
3031
- return humanReadableName.trim();
3030
+ const words = (humanReadableName
3031
+ .trim()
3032
+ // Split into words
3033
+ .split(' ')
3034
+ // Filter out whitespace
3035
+ .filter((word) => {
3036
+ return (word.length > 0);
3037
+ })
3038
+ // Capitalize first letter
3039
+ .map((word) => {
3040
+ if (word.length <= 1) {
3041
+ return word;
3042
+ }
3043
+ return `${word.substring(0, 1).toUpperCase()}${word.substring(1)}`;
3044
+ }));
3045
+ // Handle acronyms by piling words together
3046
+ const consolidatedWords = [];
3047
+ let acronym = '';
3048
+ words.forEach((word) => {
3049
+ if (word.length === 1) {
3050
+ // Add on to acronym
3051
+ acronym += word;
3052
+ }
3053
+ else {
3054
+ // Wrap up acronym
3055
+ if (acronym.length > 0) {
3056
+ consolidatedWords.push(acronym);
3057
+ acronym = '';
3058
+ }
3059
+ // Full word. Just add it
3060
+ consolidatedWords.push(word);
3061
+ }
3062
+ });
3063
+ // Add trailing acronym
3064
+ if (acronym.length > 0) {
3065
+ consolidatedWords.push(acronym);
3066
+ }
3067
+ // Return
3068
+ return consolidatedWords.join(' ');
3032
3069
  };
3033
3070
  /* ------------- Actions ------------ */
3034
3071
  // Types of actions