@danielhaim/titlecaser 1.2.59 → 1.2.61

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielhaim/titlecaser",
3
- "version": "1.2.59",
3
+ "version": "1.2.61",
4
4
  "description": "Converts a string to title case with multiple style options, ability to ignore certain words, and handle acronyms",
5
5
  "keywords": [
6
6
  "title case",
package/src/TitleCaser.js CHANGED
@@ -111,10 +111,8 @@ export class TitleCaser {
111
111
  const isReplaced = !replacedParts.every((part, index) => part === parts[index]);
112
112
 
113
113
  // Reassemble the word with the hyphen, reattach trailing punctuation, and return
114
- return (
115
- (isReplaced ? replacedParts.join("-") : TitleCaserUtils.correctTermHyphenated(word, style)) +
116
- trailingPunctuation
117
- );
114
+ const processedWord = isReplaced ? replacedParts.join("-") : TitleCaserUtils.correctTermHyphenated(word, style);
115
+ return processedWord.endsWith(trailingPunctuation) ? processedWord : processedWord + trailingPunctuation;
118
116
  case TitleCaserUtils.hasSuffix(word, style):
119
117
  // If the word has a suffix, return the correct casing.
120
118
  return TitleCaserUtils.correctSuffix(word, correctTitleCasingList);
@@ -64,36 +64,23 @@ const mergedArray = mergeArrays(
64
64
  export const correctTitleCasingList = mergedArray;
65
65
 
66
66
  export const wordReplacementsList = [
67
- { "e-book": "eBook" },
68
- { "e-books": "eBooks" },
69
- { "e-commerce": "eCommerce" },
70
- { ecom: "eCommerce" },
71
- { ecommerce: "eCommerce" },
72
67
  { "a.k.a": "AKA" },
73
68
  { "a.s.a.p": "ASAP" },
74
69
  { "f.a.q": "FAQ" },
75
- { "f.a.q.a": "FAQs" },
76
70
  { "f.a.q.s": "FAQs" },
77
71
  { "f.y.i": "FYI" },
78
72
  { "d.i.y": "DIY" },
79
73
  { "t.b.d": "TBD" },
80
- { phd: "Ph.D." },
81
74
  { "back-end": "Backend" },
82
75
  { "front-end": "Frontend" },
83
76
  { "full-stack": "Fullstack" },
84
- { angularjs: "Angular.js" },
85
- { nextjs: "Next.js" },
86
- { nodejs: "Node.js" },
87
- { nuxtjs: "Nuxt.js" },
88
- { reactjs: "React.js" },
89
- { vuejs: "Vue.js" },
77
+ { "nodejs" : "Node.js" },
78
+ { "nextjs": "Next.js" },
79
+ { "nuxtjs": "Nuxt.js" },
80
+ { "reactjs": "React" },
81
+ { "react.js": "React" },
90
82
  { "cyber-security": "Cybersecurity" },
91
- { skoda: "Škoda" },
92
- { mcdonalds: "McDonald's" },
93
- { sainsburys: "Sainsbury's" },
94
- { hersheys: "Hershey's" },
95
- { kellogs: "Kellogg's" },
96
- { dominos: "Domino's" },
83
+ // { 'twitter': '𝕏' }
97
84
  ];
98
85
 
99
86
  export const titleCaseStylesList = Object.freeze({