@danielhaim/titlecaser 1.4.0 → 1.6.0

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.4.0",
3
+ "version": "1.6.0",
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
@@ -15,13 +15,12 @@ export class TitleCaser {
15
15
  this.correctPhraseCasingList = correctPhraseCasingList;
16
16
  }
17
17
 
18
- log_warning(message) {
18
+ logWarning(message) {
19
19
  if (this.debug) {
20
20
  console.warn(`Warning: ${message}`);
21
21
  }
22
22
  }
23
23
 
24
-
25
24
  toTitleCase(str) {
26
25
  try {
27
26
  // If input is empty, throw an error.
@@ -58,8 +57,8 @@ export class TitleCaser {
58
57
  replaceTermList.map((term) => [Object.keys(term)[0].toLowerCase(), Object.values(term)[0]]),
59
58
  );
60
59
 
61
- this.log_warning(`replaceTermsArray: ${replaceTermsArray}`);
62
- this.log_warning(`this.wordReplacementsList: ${this.wordReplacementsList}`);
60
+ this.logWarning(`replaceTermsArray: ${replaceTermsArray}`);
61
+ this.logWarning(`this.wordReplacementsList: ${this.wordReplacementsList}`);
63
62
 
64
63
  const map = {
65
64
  "&": "&",
@@ -133,31 +132,31 @@ export class TitleCaser {
133
132
  ? word.charAt(0).toUpperCase() + word.slice(1)
134
133
  : word.toLowerCase();
135
134
  case TitleCaserUtils.endsWithSymbol(word):
136
- this.log_warning(`Check if the word ends with a symbol: ${word}`);
135
+ this.logWarning(`Check if the word ends with a symbol: ${word}`);
137
136
  // If the word ends with a symbol, return the correct casing.
138
137
  const splitWord = word.split(/([.,\/#!$%\^&\*;:{}=\-_`~()?])/g);
139
- this.log_warning(`Splitting word at symbols, result: ${splitWord}`);
138
+ this.logWarning(`Splitting word at symbols, result: ${splitWord}`);
140
139
  // Process each part for correct casing
141
140
  const processedWords = splitWord.map((part) => {
142
- this.log_warning(`Processing part: ${part}`);
141
+ this.logWarning(`Processing part: ${part}`);
143
142
  // Check if part is a symbol
144
143
  if (TitleCaserUtils.endsWithSymbol(part)) {
145
- this.log_warning(`Part is a symbol: ${part}`);
144
+ this.logWarning(`Part is a symbol: ${part}`);
146
145
  return part;
147
146
  } else {
148
- this.log_warning(`Part is a word: ${part}`);
147
+ this.logWarning(`Part is a word: ${part}`);
149
148
  // If it's a word, process it for correct casing
150
149
  if (TitleCaserUtils.isWordInArray(part, correctTitleCasingList)) {
151
150
  const correctedTerm = TitleCaserUtils.correctTerm(part, correctTitleCasingList);
152
- this.log_warning(`Word is in correctTitleCasingList, corrected term: ${correctedTerm}`);
151
+ this.logWarning(`Word is in correctTitleCasingList, corrected term: ${correctedTerm}`);
153
152
  return correctedTerm;
154
153
  } else if (replaceTermsArray.includes(part)) {
155
154
  const replacement = replaceTermObj[part];
156
- this.log_warning(`Word is in replaceTermsArray, replacement: ${replacement}`);
155
+ this.logWarning(`Word is in replaceTermsArray, replacement: ${replacement}`);
157
156
  return replacement;
158
157
  } else {
159
158
  const titledWord = part.charAt(0).toUpperCase() + part.slice(1).toLowerCase();
160
- this.log_warning(`Applying title casing to word: ${titledWord}`);
159
+ this.logWarning(`Applying title casing to word: ${titledWord}`);
161
160
  return titledWord;
162
161
  }
163
162
  }
@@ -270,7 +269,7 @@ export class TitleCaser {
270
269
 
271
270
  this.options.wordReplacementsList = this.wordReplacementsList;
272
271
 
273
- this.log_warning(`Log the updated this.wordReplacementsList: ${this.wordReplacementsList}`);
272
+ this.logWarning(`Log the updated this.wordReplacementsList: ${this.wordReplacementsList}`);
274
273
  }
275
274
 
276
275
  addReplaceTerm(term, replacement) {
@@ -308,7 +307,7 @@ export class TitleCaser {
308
307
  // Update the replace terms option
309
308
  this.options.wordReplacementsList = this.wordReplacementsList;
310
309
 
311
- this.log_warning(`Log the updated this.wordReplacementsList: ${this.wordReplacementsList}`);
310
+ this.logWarning(`Log the updated this.wordReplacementsList: ${this.wordReplacementsList}`);
312
311
  }
313
312
 
314
313
  addExactPhraseReplacements(newPhrases) {
@@ -343,7 +342,7 @@ export class TitleCaser {
343
342
  }
344
343
  });
345
344
 
346
- this.log_warning(`Log the this.correctPhraseCasingList: ${this.correctPhraseCasingList}`);
345
+ this.logWarning(`Log the this.correctPhraseCasingList: ${this.correctPhraseCasingList}`);
347
346
  }
348
347
 
349
348
  setStyle(style) {
@@ -31,6 +31,6 @@
31
31
  "Redux", "Vue.js", "VueX", "SCSS", "AJAX", "GraphQL", "HTML",
32
32
  "HTML5", "MySQL", "MongoDB", "PostgresQL", "SQLite", "ASP", "ASPX",
33
33
  "Elasticsearch", "Nginx", "OpenSSL", "Webpack", "Unity3D",
34
- "Kubernetes", "TensorFlow", "NPM"
34
+ "Kubernetes", "TensorFlow", "NPM", "cURL"
35
35
  ]
36
36
  }