@danielhaim/titlecaser 1.2.29 → 1.2.31
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 +19 -15
- package/dist/titlecaser.amd.js +1 -0
- package/dist/titlecaser.js +1 -0
- package/dist/titlecaser.min.js +1 -0
- package/package.json +12 -9
- package/src/TitleCaseConsts.js +4 -7
- package/src/TitleCaser.js +4 -4
package/README.md
CHANGED
|
@@ -12,8 +12,10 @@ Transform any text to proper title case format using popular style guides such a
|
|
|
12
12
|
|
|
13
13
|
## Table of Contents
|
|
14
14
|
|
|
15
|
-
[TitleCaser](#titlecaser)
|
|
15
|
+
- [TitleCaser](#titlecaser)
|
|
16
16
|
* [Demo](#demo)
|
|
17
|
+
* [Table of Contents](#table-of-contents)
|
|
18
|
+
* [Introduction](#introduction)
|
|
17
19
|
* [Key Features:](#key-features)
|
|
18
20
|
* [Installation](#installation)
|
|
19
21
|
* [Usage](#usage)
|
|
@@ -33,13 +35,15 @@ Transform any text to proper title case format using popular style guides such a
|
|
|
33
35
|
|
|
34
36
|
## Introduction
|
|
35
37
|
|
|
36
|
-
The Language Conventions and Style Module is a comprehensive library designed to help web content developers adhere to the latest style guides and English language conventions. It offers a wide range of features, including support for various style guides such as AP, APA, Chicago, NY Times, Wikipedia, and British styles, and customizable preferences to suit your specific needs.
|
|
37
38
|
|
|
38
|
-
To streamline workflow, the Language Conventions and Style Module is available in both browser and node environment versions and includes a command-line interface for building, testing, and minimizing the module. Additionally, it features a filter ability that allows users to ignore certain phrases containing short words, preventing the module from mistakenly flagging instances where short words are used as part of a larger term or phrase.
|
|
39
39
|
|
|
40
|
-
The
|
|
40
|
+
The comprehensive Language Conventions and Style Library is specifically designed to assist web content developers in adhering to the latest style guides and English language conventions. This all-inclusive library has various features, including support for numerous style guides such as AP, APA, Chicago, NY Times, Wikipedia, and British styles and customizable preferences to tailor to individual needs. TitleCaser is a component of this library, and LCSL is set to be open-sourced by the end of 2023
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
To streamline workflow, modules are available in both browser and node environment versions and include a command-line interface for building, testing, and minimizing the module. Additionally, it features a filter ability that allows users to ignore certain phrases containing short words, preventing the module from mistakenly flagging instances where short words are used as part of a larger term or phrase.
|
|
43
|
+
|
|
44
|
+
The module has been designed to handle various capitalization scenarios, including hyphenated words, prefixes, suffixes, reserved words, Roman numerals, proper nouns that contain lowercase letters, and words that require capitalization in specific contexts. This ensures that your content meets the appropriate style and formatting guidelines, regardless of the context. It also offers word replacement capabilities, as well as ignored phrases to create consistency in cases where certain terms may be capitalized differently depending on the context.
|
|
45
|
+
|
|
46
|
+
Whether you're developing web content for a major news organization or simply looking to improve your writing skills, this module is an essential tool that can help ensure your work is accurate, consistent, and conforms to the latest style guidelines.
|
|
43
47
|
|
|
44
48
|
## Key Features:
|
|
45
49
|
|
|
@@ -48,7 +52,7 @@ So whether you're developing web content for a major news organization or simply
|
|
|
48
52
|
- Support for proper capitalization of Roman numerals and exclusion of specific words and phrases from title capitalization
|
|
49
53
|
- Word replacement capabilities for consistency in capitalization
|
|
50
54
|
Command-line interface for building, testing, and minimizing the module
|
|
51
|
-
- Pre-defined word lists for articles, conjunctions, prepositions, and
|
|
55
|
+
- Pre-defined word lists for articles, conjunctions, prepositions, and non-capitalized words in titles
|
|
52
56
|
- Exclusion of common phrases from title capitalization
|
|
53
57
|
|
|
54
58
|
## Installation
|
|
@@ -83,12 +87,12 @@ console.log(output); // 'The Book of Life'
|
|
|
83
87
|
|
|
84
88
|
## Usage in the Browser
|
|
85
89
|
|
|
86
|
-
The function can also be used in a browser environment by including the `titlecaser.
|
|
90
|
+
The function can also be used in a browser environment by including the `titlecaser.amd.js` script in your HTML file:
|
|
87
91
|
|
|
88
92
|
Here's an example of how to use the modulate function:
|
|
89
93
|
|
|
90
94
|
```html
|
|
91
|
-
<script src="./path/to/titlecaser.
|
|
95
|
+
<script src="./path/to/titlecaser.amd.js"></script>
|
|
92
96
|
```
|
|
93
97
|
|
|
94
98
|
After that, the `toTitleCase()` function can be accessed in your JavaScript code like this:
|
|
@@ -117,9 +121,9 @@ The `{options}` parameter is an object that contains the settings for the conver
|
|
|
117
121
|
## Methods
|
|
118
122
|
|
|
119
123
|
- `setReplaceTerms(terms: object)`: Sets word replacement terms to be used during title casing. Multiple calls can be made to add or update multiple word replacements.
|
|
120
|
-
- `removeReplaceTerm(term: string)`: Removes a
|
|
121
|
-
- `addReplaceTerm(term: string, replacement: string)`: Adds a new
|
|
122
|
-
- `setStyle(style: string)`: Sets the style option in the
|
|
124
|
+
- `removeReplaceTerm(term: string)`: Removes a replaced term from the `wordReplacementsList` array in the option object of the `TitleCaser` instance. Throws an error if the term is not found in the array, otherwise removes it from the array and updates the option object.
|
|
125
|
+
- `addReplaceTerm(term: string, replacement: string)`: Adds a new term to the `wordReplacementsList` array in the options object of the TitleCaser instance. The method takes two string arguments: term specifies the word to be replaced, and replacement specifies the replacement for the word. If the term already exists in the array, the method updates its replacement value. Otherwise, it adds a new object with the term and replacement to the array. The method then updates the wordReplacementsList property in the object.
|
|
126
|
+
- `setStyle(style: string)`: Sets the style option in the object of the TitleCaser instance. The method takes a string argument style that specifies the style to use for the title casing. If the argument is not a string, the method throws a TypeError. Otherwise, it updates the style option in the object.
|
|
123
127
|
|
|
124
128
|
## Examples
|
|
125
129
|
|
|
@@ -139,7 +143,7 @@ console.log(output); // The Book of Life
|
|
|
139
143
|
|
|
140
144
|
### Customizing Word Replacements Method
|
|
141
145
|
|
|
142
|
-
In the example below, we create a new instance of the `TitleCaser` class with the `APA` style option. We then set multiple replacement terms using two separate calls to the `setReplaceTerms()` method. Descriptive variable names are used for the input string and expected output. We call `toTitleCase()` to convert the input string to title case.
|
|
146
|
+
In the example below, we create a new instance of the `TitleCaser` class with the `APA` style option. We then set multiple replacement terms using two separate calls to the `setReplaceTerms()` method. Descriptive variable names are used for the input string and expected output. We call `toTitleCase()` to convert the input string to a title case.
|
|
143
147
|
|
|
144
148
|
```js
|
|
145
149
|
// CommonJS
|
|
@@ -166,7 +170,7 @@ const outputString = titleCaser.toTitleCase(inputString);
|
|
|
166
170
|
|
|
167
171
|
### Customizing TitleCaser
|
|
168
172
|
|
|
169
|
-
The example below demonstrates how to use the TitleCaser class to convert a string to title case with specific settings.
|
|
173
|
+
The example below demonstrates how to use the TitleCaser class to convert a string to a title case with specific settings.
|
|
170
174
|
|
|
171
175
|
```js
|
|
172
176
|
// Set the options object
|
|
@@ -197,7 +201,7 @@ console.log(actualOutput);
|
|
|
197
201
|
|
|
198
202
|
### TitleCaser With Default Word Replacement
|
|
199
203
|
|
|
200
|
-
The example below demonstrates how to use the TitleCaser class to convert a string to title case with AP style formatting, including hyphenated words and word/brand replacement.
|
|
204
|
+
The example below demonstrates how to use the TitleCaser class to convert a string to a title case with AP style formatting, including hyphenated words and word/brand replacement.
|
|
201
205
|
|
|
202
206
|
```js
|
|
203
207
|
// Instantiate a new TitleCaser object with AP style formatting
|
|
@@ -307,4 +311,4 @@ Useful materials for improving your knowledge of writing and language style guid
|
|
|
307
311
|
|
|
308
312
|
If you encounter any bugs or issues while using the library or the demo page, please report them by opening a new issue in the repository's issue tracker.
|
|
309
313
|
|
|
310
|
-
When reporting a bug, please provide as much detail as possible, including the steps to reproduce the issue and any error messages that you see. I appreciate any contribution to
|
|
314
|
+
When reporting a bug, please provide as much detail as possible, including the steps to reproduce the issue and any error messages that you see. I appreciate any contribution to improving this library.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{var e={541:(e,t)=>{var r;void 0===(r=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),t.wordReplacementsList=t.titleCaseStylesList=t.titleCaseDefaultOptionsList=t.ignoredWordList=t.correctTitleCasingList=t.correctPhraseCasingList=t.commonAbbreviationList=t.allowedTitleCaseStylesList=void 0;t.commonAbbreviationList=["a","an","the","as","at","by","for","in","of","on","to","up","yet","so","but","nor","or","and"];t.correctTitleCasingList=["AJAX","CSS","DOM","ES6","HTML","JavaScript","jQuery","MobX","SCSS","TypeScript","Vue.js",".NET","ASP","ASPX","MySQL","PHP","PostgresQL","Python","SQL","GraphQL","HTML5","API","APIs","ASCII","CI","CircleCI","CLI","DLL","DNS","EC2","FTP","HTTP","HTTPs","ICMP","IDE","IP","ISP","JSON","JSP","LPWAN","M2M","MQTT","OOP","REST","SSH","SSL","TCP","UDP","URL","WLAN","WYSIWYG","XML","YAML","YML","IMAP","RSS","IaaS","PaaS","SaaS","CaaS","FaaS","XaaS","RaaS","IoE","IoT","LoRa","NB-IoT","RFID","RF","RFI","RFQ","ECMAScript","IO","I/O","DevOps","SecOps","DDoS","VoIP","AI","AR","ML","VR","w/","w/o","e-Book","e-Books","eBook","eBooks","eCommerce","eMarket","eMarketplace","eMarketplaces","eMarkets","eReader","eShop","eShops","eStore","eStores","E-commerce","AP","COGS","EBIT","EPS","FIFO","GAAP","LIFO","P&L","ROI","SOX","TCO","VAT","CAGR","DCF","ETF","IPO","IRR","M&A","NAV","PE","PEG","PPE","ROE","S&P","TVM","VC","B2B","B2C","CMO","CPA","CPC","CPL","CPM","CRM","CTA","CTR","SEO","SEM","SMM","USP","A/B","CTA","CTOR","CTR","KPI","PWA","SEM","SERP","SERPs","SMM","SMO","FAQ","FAQA","FAQS","UI","UI/UX","UX","T&C","TOS","PP","CRM","PoE","PoW","PoC","A11Y","PR","BANT","KPI","MQL","NPS","POS","SPIN","SQL","SWOT","AFA","ADR","CCPA","CFAA","CISG","DMCA","EULA","GDPR","HIPAA","NDA","SOW","TOS","CEO","CEOs","CFO","CFOs","CIO","CIOs","CMO","CMOs","COO","COOs","CPO","CPOs","CRO","CROs","CSO","CSOs","CTO","CTOs","EVP","EVPs","HR","HRs","SVP","SVPs","VP","VPs","NGO","NPO","NGOs","NPOs","UN","UNESCO","UNICEF","UNHCR","UNODC","UNDP","UNFPA","UNEP","Adobe","Airbnb","Alibaba","Allstate","American Express","Apple","AT&T","BMW","Boeing","Cisco","Citigroup","Coca","Deloitte","Disney","Dropbox","ExxonMobil","Ford","GE","General","Goldman Sachs","Google","Hilton","HP","IBM","Intel","JPMorgan","Johnson & Johnson","LinkedIn","McDonald's","Mercedes-Benz","Microsoft","Nestle","Nike","Nissan","Oracle","PepsiCo","Pfizer","Salesforce","Samsung","Shell","Sony","Tesla","Toyota","Uber","Verizon","Visa","Walmart","Wells Fargo","Yahoo","Zara","IKEA","Facebook","YouTube","Instagram","Twitter","TensorFlow","Amazon","Netflix","eBay","iPhone","iPad","iPod","PlayStation","PayPal","GitHub","GitLab","CodeIgniter","WordPress","WooCommerce","MongoDB","JIRA","HubSpot","AirDrop","AirPlay","AirPods","AirTags","FinalCut","GarageBand","iBooks","iCloud","iLife","iMac","iMessage","iMovie","iPhoto","iWatch","iWork","LogicPro","macOS","ProTools","QuickTime","AdWords","AdSense","TikTok","Slack","Trello","Zoom","Twitch","Snapchat","WhatsApp","Telegram","Discord","Reddit","Quora","StackOverflow","StackExchange","Coca-Cola","AWS","GCP","VMware","CVS","ESL","EE","NBA","NCAA","NFL","WWE","WWF","FIFA","a.m.","p.m.","ca.","cc.","fig.","pl.","pt.","rev.","sr.","v.","vol.","et al.","pp.","p.","ph.d.","m.d.","d.d.s.","d.m.d.","d.o.","d.c.","d.v.m.","d.n.p.","d.p.m.","d.s.w.","d.s.n.","d.n.sc.","d.n.a.","d.n.t.","d.n.p.t.","d.n.o.","d.n.m.","d.n.e.","d.n.s.","d.n.p.s.","adj.","adv.","cf.","cm.","co.","corp.","dept.","dist.","ed.","edn.","esp.","etc.","ex.","i.e.","e.g.","op. cit.","vs.","Ltd.","Co.","Inc.","St.","Ave.","Bldg.","No."];t.wordReplacementsList=[{"a.k.a":"AKA"},{"a.s.a.p":"ASAP"},{angularjs:"Angular.js"},{"back-end":"Backend"},{"d.i.y":"DIY"},{"e-book":"eBook"},{"e-books":"eBooks"},{"e-commerce":"eCommerce"},{ecom:"eCommerce"},{ecommerce:"eCommerce"},{"f.a.q":"FAQ"},{"f.a.q.a":"FAQs"},{"f.a.q.s":"FAQs"},{"f.y.i":"FYI"},{"front-end":"Frontend"},{"full-stack":"Fullstack"},{nextjs:"Next.js"},{nodejs:"Node.js"},{nuxtjs:"Nuxt.js"},{reactjs:"React.js"},{"t.b.d":"TBD"},{vuejs:"Vue.js"},{phd:"ph.d."}];var r=Object.freeze({AP:"ap",APA:"apa",BRITISH:"british",CHICAGO:"chicago",NYT:"nyt",WIKIPEDIA:"wikipedia"});t.titleCaseStylesList=r;var n=Object.values(r);t.allowedTitleCaseStylesList=n;var o=Object.freeze({ap:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]},apa:{shortConjunctionsList:["and","as","but","by","for","in","nor","of","on","or","so","to","yet"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","for","in","of","on","to","up","via"],neverCapitalizedList:[]},british:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]},chicago:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","for","in","of","on","to","up","with","via"],neverCapitalizedList:["etc."]},nyt:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]},wikipedia:{shortConjunctionsList:["and","as","but","for","if","nor","or","so","yet"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]}});t.titleCaseDefaultOptionsList=o;t.ignoredWordList=[];t.correctPhraseCasingList=["The Cybersmile Foundation","CO. by Colgate","The Simpsons"]}.apply(t,[t]))||(e.exports=r)},675:(e,t,r)=>{var n,o;n=[t,r(541)],void 0===(o=function(e,r){"use strict";function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function o(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return s}}(e,t)||l(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?a(Object(r),!0).forEach((function(t){p(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):a(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function u(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=l(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}function l(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,d(n.key),n)}}function p(e,t,r){return(t=d(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function d(e){var t=function(e,t){if("object"!==n(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,t||"default");if("object"!==n(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===n(t)?t:String(t)}Object.defineProperty(e,"__esModule",{value:!0}),t.default=void 0;var y=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}var t,a,l;return t=e,l=[{key:"validateOption",value:function(e,t){if(!Array.isArray(t))throw new TypeError("Invalid option: ".concat(e," must be an array"));if(!t.every((function(e){return"string"==typeof e})))throw new TypeError("Invalid option: ".concat(e," must be an array of strings"))}},{key:"validateOptions",value:function(e){for(var t=0,n=Object.keys(e);t<n.length;t++){var o=n[t];if("style"!==o)if("wordReplacementsList"!==o){if(!r.titleCaseDefaultOptionsList.hasOwnProperty(o))throw new TypeError("Invalid option: ".concat(o));this.TitleCaseValidator.validateOption(o,e[o])}else{if(!Array.isArray(e.wordReplacementsList))throw new TypeError("Invalid option: ".concat(o," must be an array"));var i,a=u(e.wordReplacementsList);try{for(a.s();!(i=a.n()).done;)if("string"!=typeof i.value)throw new TypeError("Invalid option: ".concat(o," must contain only strings"))}catch(e){a.e(e)}finally{a.f()}}else{if("string"!=typeof e.style)throw new TypeError("Invalid option: ".concat(o," must be a string"));if(!r.allowedTitleCaseStylesList.includes(e.style))throw new TypeError("Invalid option: ".concat(o," must be a string"))}}}},{key:"getTitleCaseOptions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],a=JSON.stringify({options:t,lowercaseWords:n});if(e.titleCaseOptionsCache.has(a))return e.titleCaseOptionsCache.get(a);var u=s(s({},r.titleCaseDefaultOptionsList[t.style||"ap"]),t),l=u.articlesList.concat(n).filter((function(e,t,r){return r.indexOf(e)===t})),c=u.shortConjunctionsList.concat(n).filter((function(e,t,r){return r.indexOf(e)===t})),f=u.shortPrepositionsList.concat(n).filter((function(e,t,r){return r.indexOf(e)===t})),p=[].concat(i((u.replaceTerms||[]).map((function(e){var t=o(e,2),r=t[0],n=t[1];return[r.toLowerCase(),n]}))),i(r.wordReplacementsList)),d={articlesList:l,shortConjunctionsList:c,shortPrepositionsList:f,neverCapitalizedList:i(u.neverCapitalizedList),replaceTerms:p};return e.titleCaseOptionsCache.set(a,d),d}},{key:"isShortConjunction",value:function(t,r){var n=i(e.getTitleCaseOptions({style:r}).shortConjunctionsList),o=t.toLowerCase();return n.includes(o)}},{key:"isArticle",value:function(t,r){return e.getTitleCaseOptions({style:r}).articlesList.includes(t.toLowerCase())}},{key:"isShortPreposition",value:function(t,r){return e.getTitleCaseOptions({style:r}).shortPrepositionsList.includes(t.toLowerCase())}},{key:"isNeverCapitalized",value:function(t,r){var n="".concat(r,"_").concat(t.toLowerCase());if(e.isNeverCapitalizedCache.has(n))return e.isNeverCapitalizedCache.get(n);var o=e.getTitleCaseOptions({style:r}).neverCapitalizedList.includes(t.toLowerCase());return e.isNeverCapitalizedCache.set(n,o),o}},{key:"isShortWord",value:function(t,o){if("string"!=typeof t)throw new TypeError("Invalid input: word must be a string. Received ".concat(n(t),"."));if(!r.allowedTitleCaseStylesList.includes(o))throw new Error("Invalid option: style must be one of ".concat(r.allowedTitleCaseStylesList.join(", "),"."));return e.isShortConjunction(t,o)||e.isArticle(t,o)||e.isShortPreposition(t,o)||e.isNeverCapitalized(t,o)}},{key:"hasNumbers",value:function(e){return/\d/.test(e)}},{key:"hasUppercaseMultiple",value:function(e){for(var t=0,r=0;r<e.length&&t<2;r++)/[A-Z]/.test(e[r])&&t++;return t>=2}},{key:"hasUppercaseIntentional",value:function(e){return/[A-Z]/.test(e.slice(1))&&/[a-z]/.test(e.slice(0,-1))}},{key:"hasSuffix",value:function(e){return e.length>"'s".length&&e.endsWith("'s")}},{key:"hasApostrophe",value:function(e){return-1!==e.indexOf("'")}},{key:"hasHyphen",value:function(e){return-1!==e.indexOf("-")||-1!==e.indexOf("–")||-1!==e.indexOf("—")}},{key:"hasRomanNumeral",value:function(e){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");return/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/i.test(e)}},{key:"hasHyphenRomanNumeral",value:function(t){if("string"!=typeof t||""===t)throw new TypeError("Invalid input: word must be a non-empty string.");for(var r=t.split("-"),n=0;n<r.length;n++)if(!e.hasRomanNumeral(r[n]))return!1;return!0}},{key:"hasHtmlBreak",value:function(e){return"nl2br"===e}},{key:"hasUnicodeSymbols",value:function(e){return/[^\x00-\x7F\u00A0-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u02B0-\u02FF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0800-\u083F\u0840-\u085F\u0860-\u087F\u0880-\u08AF\u08B0-\u08FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF]/.test(e)}},{key:"hasCurrencySymbols",value:function(e){return/[^\x00-\x7F\u00A0-\u00FF\u20AC\u20A0-\u20B9\u20BD\u20A1-\u20A2\u00A3-\u00A5\u058F\u060B\u09F2-\u09F3\u0AF1\u0BF9\u0E3F\u17DB\u20A6\u20A8\u20B1\u2113\u20AA-\u20AB\u20AA\u20AC-\u20AD\u20B9]/.test(e)}},{key:"isWordAmpersand",value:function(e){return/&|&/.test(e)}},{key:"startsWithSymbol",value:function(e){if("string"!=typeof e)throw new Error("Parameter 'word' must be a string. Received '".concat(n(e),"' instead."));if(0===e.length)return!1;var t=e.charAt(0);return"#"===t||"@"===t||"."===t}},{key:"escapeSpecialCharacters",value:function(e){return e.replace(/[&<>"']/g,(function(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case"'":return"'";default:return e}}))}},{key:"unescapeSpecialCharacters",value:function(e){return e.replace(/&|<|>|"|'/g,(function(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case""":return'"';case"'":return"'";default:return e}}))}},{key:"endsWithSymbol",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[".",",",";",":","?","!"];if("string"!=typeof e||!Array.isArray(t))throw new Error("Invalid arguments");return t.some((function(t){return e.endsWith(t)}))||t.includes(e.slice(-2))}},{key:"isWordIgnored",value:function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.ignoredWordList;if(!Array.isArray(n))throw new TypeError("Invalid input: ignoredWords must be an array.");if("string"!=typeof e||""===e.trim())throw new TypeError("Invalid input: word must be a non-empty string.");return t=e.toLowerCase().trim(),n.includes(t)}},{key:"isWordInArray",value:function(e,t){return!!Array.isArray(t)&&t.some((function(t){return t.toLowerCase()===e.toLowerCase()}))}},{key:"replaceTerm",value:function(e,t){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");if(!t||"object"!==n(t))throw new TypeError("Invalid input: replaceTermObj must be a non-null object.");var r;if(r=e.toLowerCase(),t.hasOwnProperty(r))return t[r];if(t.hasOwnProperty(e))return t[e];var o=e.toUpperCase();return t.hasOwnProperty(o)?t[o]:e}},{key:"correctSuffix",value:function(e,t){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");if(!t||!Array.isArray(t)||t.some((function(e){return"string"!=typeof e})))throw new TypeError("Invalid input: correctTerms must be an array of strings.");if(/'s$/i.test(e)){var r=e.slice(0,-2),n=t.findIndex((function(e){return e.toLowerCase()===r.toLowerCase()}));if(n>=0){var o=t[n];return"".concat(o,"'s")}var i=r.charAt(0).toUpperCase()+r.slice(1);return"".concat(i,"'s")}return e}},{key:"correctTerm",value:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:/[-']/;if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");if(!t||!Array.isArray(t))throw new TypeError("Invalid input: correctTerms must be an array.");if(!("string"==typeof r||Array.isArray(r)||r instanceof RegExp))throw new TypeError("Invalid input: delimiters must be a string, an array of strings, or a regular expression.");"string"==typeof r?r=new RegExp("[".concat(r,"]")):Array.isArray(r)&&(r=new RegExp("[".concat(r.join(""),"]")));for(var n=e.split(r),o=n.length,i=function(){var e=n[a].toLowerCase(),r=t.findIndex((function(t){return t.toLowerCase()===e}));r>=0&&(n[a]=t[r])},a=0;a<o;a++)i();return n.join(r.source.charAt(0))}},{key:"correctTermHyphenated",value:function(t,n){var o=t.split("-"),i=function(e){return e.charAt(0).toUpperCase()+e.slice(1)},a=function(e){return e.charAt(0)+e.slice(1).toLowerCase()},s={ap:function(e,t){return 0===t?i(e):a(e)},chicago:i,apa:function(t,r,o){return e.isShortWord(t,n)&&r>0&&r<o-1?t.toLowerCase():i(t)},nyt:function(e,t){return 0===t?i(e):a(e)},wikipedia:function(e,t){return 0===t?i(e):a(e)}},u=s[n]||a,l=o.map((function(e,t){if(/^(M{0,3})(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/i.test(e))return e.toUpperCase();var n=e,i=e.toLowerCase(),a=r.correctTitleCasingList.findIndex((function(e){return e.toLowerCase()===i}));if(a>=0)n=r.correctTitleCasingList[a];else if(i.endsWith("'s")){var s=i.substring(0,i.length-2),l=r.correctTitleCasingList.findIndex((function(e){return e.toLowerCase()===s}));l>=0&&(n="".concat(r.correctTitleCasingList[l],"'s"))}return u(n,t,o.length)}));return l.join("-")}}],(a=null)&&f(t.prototype,a),l&&f(t,l),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.default=y,p(y,"TitleCaseValidator",void 0),p(y,"titleCaseOptionsCache",new Map),p(y,"isNeverCapitalizedCache",new Map)}.apply(t,n))||(e.exports=o)},429:(e,t,r)=>{var n,o;e=r.nmd(e),n=[t,r(541),r(675)],void 0===(o=function(r,n,o){"use strict";var i;function a(e,t,r){return(t=d(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,i,a,s=[],u=!0,l=!1;try{if(i=(r=r.call(e)).next,0===t){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(s.push(n.value),s.length!==t);u=!0);}catch(e){l=!0,o=e}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return s}}(e,t)||l(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function u(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function l(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function f(e){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},f(e)}function p(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,d(n.key),n)}}function d(e){var t=function(e,t){if("object"!==f(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!==f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===f(t)?t:String(t)}Object.defineProperty(r,"__esModule",{value:!0}),t.TitleCaser=void 0,o=(i=o)&&i.__esModule?i:{default:i};var y=function(){function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.options=t,this.wordReplacementsList=n.wordReplacementsList}var t,r,i;return t=e,r=[{key:"toTitleCase",value:function(e){try{if(0===e.trim().length)throw new TypeError("Invalid input: input must not be empty.");if("string"!=typeof e)throw new TypeError("Invalid input: input must be a string.");if(void 0!==this.options&&"object"!==f(this.options))throw new TypeError("Invalid options: options must be an object.");var t=this.options,r=t.style,i=void 0===r?"ap":r,a=t.neverCapitalize,s=void 0===a?[]:a,c=t.replaceTermList,p=void 0===c?n.wordReplacementsList:c,d=["nl2br"].concat(u(s)),y=o.default.getTitleCaseOptions(this.options,n.commonAbbreviationList,n.wordReplacementsList),m=(y.articlesList,y.shortConjunctionsList,y.shortPrepositionsList,y.neverCapitalizedList,y.replaceTerms,p.map((function(e){return Object.keys(e)[0].toLowerCase()}))),h=Object.fromEntries(p.map((function(e){return[Object.keys(e)[0].toLowerCase(),Object.values(e)[0]]}))),v=e.trim(),b=(v=(v=v.replace(/ {2,}/g,(function(e){return e.slice(0,1)}))).replace(/<br\s*\/?>/gi,"nl2br ")).split(" ");v=b.map((function(e,t){switch(!0){case o.default.isWordAmpersand(e):case o.default.hasHtmlBreak(e):case o.default.isWordIgnored(e,d):return e;case m.includes(e.toLowerCase()):return h[e.toLowerCase()];case o.default.isWordInArray(e,n.correctTitleCasingList):return o.default.correctTerm(e,n.correctTitleCasingList);case o.default.hasSuffix(e,i):return o.default.correctSuffix(e,n.correctTitleCasingList);case o.default.hasHyphen(e):return o.default.correctTermHyphenated(e,i);case o.default.hasUppercaseIntentional(e):return e;case o.default.isShortWord(e,i)&&0!==t:return t>0&&o.default.endsWithSymbol(b[t-1],[":","?","!","."])?e.charAt(0).toUpperCase()+e.slice(1):e.toLowerCase();case o.default.endsWithSymbol(e):var r=e.split(/([.,\/#!$%\^&\*;:{}=\-_`~()])/g).map((function(e,t){return o.default.isWordInArray(e,n.correctTitleCasingList)?o.default.correctTerm(e,n.correctTitleCasingList):(t>0&&o.default.endsWithSymbol(e),e.charAt(0).toUpperCase()+e.slice(1))}));return r.join("");case o.default.startsWithSymbol(e):return o.default.isWordInArray(e,n.correctTitleCasingList)?o.default.correctTerm(e):e;case o.default.hasRomanNumeral(e):return e.toUpperCase();case o.default.hasNumbers(e):return e;default:return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}})).join(" ");var C,w=function(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=l(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,s=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw i}}}}(n.correctPhraseCasingList);try{for(w.s();!(C=w.n()).done;){var g=C.value;v.toLowerCase().includes(g.toLowerCase())&&(v=v.replace(new RegExp(g,"gi"),g))}}catch(e){w.e(e)}finally{w.f()}return v=v.replace(/nl2br /gi,"<br />")}catch(e){throw new Error(e)}}},{key:"setReplaceTerms",value:function(e){if("object"!==f(e))throw new TypeError("Invalid argument: replace terms must be an object.");Object.entries(e).forEach((function(e){var t=s(e,2),r=t[0],o=t[1],i=n.wordReplacementsList.findIndex((function(e){return e[r]}));-1!==i?n.wordReplacementsList[i][r]=o:n.wordReplacementsList.push(a({},r,o))})),this.options.wordReplacementsList=n.wordReplacementsList}},{key:"addReplaceTerm",value:function(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Invalid argument: term and replacement must be strings.");var r=this.wordReplacementsList.findIndex((function(t){return t[e]}));-1!==r?this.wordReplacementsList[r][e]=t:this.wordReplacementsList.push(a({},e,t)),this.options.wordReplacementsList=this.wordReplacementsList}},{key:"removeReplaceTerm",value:function(e){if("string"!=typeof e)throw new TypeError("Invalid argument: term must be a string.");var t=this.wordReplacementsList.findIndex((function(t){return Object.keys(t)[0]===e}));if(-1===t)throw new Error("Term '".concat(e,"' not found in word replacements list."));this.wordReplacementsList.splice(t,1),this.options.wordReplacementsList=this.wordReplacementsList}},{key:"setStyle",value:function(e){if("string"!=typeof e)throw new TypeError("Invalid argument: style must be a string.");this.options.style=e}}],r&&p(t.prototype,r),i&&p(t,i),Object.defineProperty(t,"prototype",{writable:!1}),e}();t.TitleCaser=y,"object"===f(e)&&e.exports&&(e.exports={TitleCaser:y})}.apply(t,n))||(e.exports=o)},352:(e,t,r)=>{var n,o;n=[t,r(429)],void 0===(o=function(e,t){"use strict";function r(e){return r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(e)}Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"TitleCaser",{enumerable:!0,get:function(){return t.TitleCaser}}),"function"!=typeof String.prototype.toTitleCase&&(String.prototype.toTitleCase=function(e){return new t.TitleCaser(e).toTitleCase(this)}),"object"===("undefined"==typeof window?"undefined":r(window))&&(window.TitleCaser=t.TitleCaser)}.apply(t,n))||(e.exports=o)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={id:n,loaded:!1,exports:{}};return e[n](i,i.exports,r),i.loaded=!0,i.exports}r.nmd=e=>(e.paths=[],e.children||(e.children=[]),e);r(352)})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";var e={541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wordReplacementsList=t.titleCaseStylesList=t.titleCaseDefaultOptionsList=t.ignoredWordList=t.correctTitleCasingList=t.correctPhraseCasingList=t.commonAbbreviationList=t.allowedTitleCaseStylesList=void 0;t.commonAbbreviationList=["a","an","the","as","at","by","for","in","of","on","to","up","yet","so","but","nor","or","and"];t.correctTitleCasingList=["AJAX","CSS","DOM","ES6","HTML","JavaScript","jQuery","MobX","SCSS","TypeScript","Vue.js",".NET","ASP","ASPX","MySQL","PHP","PostgresQL","Python","SQL","GraphQL","HTML5","API","APIs","ASCII","CI","CircleCI","CLI","DLL","DNS","EC2","FTP","HTTP","HTTPs","ICMP","IDE","IP","ISP","JSON","JSP","LPWAN","M2M","MQTT","OOP","REST","SSH","SSL","TCP","UDP","URL","WLAN","WYSIWYG","XML","YAML","YML","IMAP","RSS","IaaS","PaaS","SaaS","CaaS","FaaS","XaaS","RaaS","IoE","IoT","LoRa","NB-IoT","RFID","RF","RFI","RFQ","ECMAScript","IO","I/O","DevOps","SecOps","DDoS","VoIP","AI","AR","ML","VR","w/","w/o","e-Book","e-Books","eBook","eBooks","eCommerce","eMarket","eMarketplace","eMarketplaces","eMarkets","eReader","eShop","eShops","eStore","eStores","E-commerce","AP","COGS","EBIT","EPS","FIFO","GAAP","LIFO","P&L","ROI","SOX","TCO","VAT","CAGR","DCF","ETF","IPO","IRR","M&A","NAV","PE","PEG","PPE","ROE","S&P","TVM","VC","B2B","B2C","CMO","CPA","CPC","CPL","CPM","CRM","CTA","CTR","SEO","SEM","SMM","USP","A/B","CTA","CTOR","CTR","KPI","PWA","SEM","SERP","SERPs","SMM","SMO","FAQ","FAQA","FAQS","UI","UI/UX","UX","T&C","TOS","PP","CRM","PoE","PoW","PoC","A11Y","PR","BANT","KPI","MQL","NPS","POS","SPIN","SQL","SWOT","AFA","ADR","CCPA","CFAA","CISG","DMCA","EULA","GDPR","HIPAA","NDA","SOW","TOS","CEO","CEOs","CFO","CFOs","CIO","CIOs","CMO","CMOs","COO","COOs","CPO","CPOs","CRO","CROs","CSO","CSOs","CTO","CTOs","EVP","EVPs","HR","HRs","SVP","SVPs","VP","VPs","NGO","NPO","NGOs","NPOs","UN","UNESCO","UNICEF","UNHCR","UNODC","UNDP","UNFPA","UNEP","Adobe","Airbnb","Alibaba","Allstate","American Express","Apple","AT&T","BMW","Boeing","Cisco","Citigroup","Coca","Deloitte","Disney","Dropbox","ExxonMobil","Ford","GE","General","Goldman Sachs","Google","Hilton","HP","IBM","Intel","JPMorgan","Johnson & Johnson","LinkedIn","McDonald's","Mercedes-Benz","Microsoft","Nestle","Nike","Nissan","Oracle","PepsiCo","Pfizer","Salesforce","Samsung","Shell","Sony","Tesla","Toyota","Uber","Verizon","Visa","Walmart","Wells Fargo","Yahoo","Zara","IKEA","Facebook","YouTube","Instagram","Twitter","TensorFlow","Amazon","Netflix","eBay","iPhone","iPad","iPod","PlayStation","PayPal","GitHub","GitLab","CodeIgniter","WordPress","WooCommerce","MongoDB","JIRA","HubSpot","AirDrop","AirPlay","AirPods","AirTags","FinalCut","GarageBand","iBooks","iCloud","iLife","iMac","iMessage","iMovie","iPhoto","iWatch","iWork","LogicPro","macOS","ProTools","QuickTime","AdWords","AdSense","TikTok","Slack","Trello","Zoom","Twitch","Snapchat","WhatsApp","Telegram","Discord","Reddit","Quora","StackOverflow","StackExchange","Coca-Cola","AWS","GCP","VMware","CVS","ESL","EE","NBA","NCAA","NFL","WWE","WWF","FIFA","a.m.","p.m.","ca.","cc.","fig.","pl.","pt.","rev.","sr.","v.","vol.","et al.","pp.","p.","ph.d.","m.d.","d.d.s.","d.m.d.","d.o.","d.c.","d.v.m.","d.n.p.","d.p.m.","d.s.w.","d.s.n.","d.n.sc.","d.n.a.","d.n.t.","d.n.p.t.","d.n.o.","d.n.m.","d.n.e.","d.n.s.","d.n.p.s.","adj.","adv.","cf.","cm.","co.","corp.","dept.","dist.","ed.","edn.","esp.","etc.","ex.","i.e.","e.g.","op. cit.","vs.","Ltd.","Co.","Inc.","St.","Ave.","Bldg.","No."];t.wordReplacementsList=[{"a.k.a":"AKA"},{"a.s.a.p":"ASAP"},{angularjs:"Angular.js"},{"back-end":"Backend"},{"d.i.y":"DIY"},{"e-book":"eBook"},{"e-books":"eBooks"},{"e-commerce":"eCommerce"},{ecom:"eCommerce"},{ecommerce:"eCommerce"},{"f.a.q":"FAQ"},{"f.a.q.a":"FAQs"},{"f.a.q.s":"FAQs"},{"f.y.i":"FYI"},{"front-end":"Frontend"},{"full-stack":"Fullstack"},{nextjs:"Next.js"},{nodejs:"Node.js"},{nuxtjs:"Nuxt.js"},{reactjs:"React.js"},{"t.b.d":"TBD"},{vuejs:"Vue.js"},{phd:"ph.d."}];const r=Object.freeze({AP:"ap",APA:"apa",BRITISH:"british",CHICAGO:"chicago",NYT:"nyt",WIKIPEDIA:"wikipedia"});t.titleCaseStylesList=r;const s=Object.values(r);t.allowedTitleCaseStylesList=s;const i=Object.freeze({ap:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]},apa:{shortConjunctionsList:["and","as","but","by","for","in","nor","of","on","or","so","to","yet"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","for","in","of","on","to","up","via"],neverCapitalizedList:[]},british:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]},chicago:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","for","in","of","on","to","up","with","via"],neverCapitalizedList:["etc."]},nyt:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]},wikipedia:{shortConjunctionsList:["and","as","but","for","if","nor","or","so","yet"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]}});t.titleCaseDefaultOptionsList=i;t.ignoredWordList=[];t.correctPhraseCasingList=["The Cybersmile Foundation","CO. by Colgate","The Simpsons"]},675:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(541);function i(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class o{static validateOption(e,t){if(!Array.isArray(t))throw new TypeError(`Invalid option: ${e} must be an array`);if(!t.every((e=>"string"==typeof e)))throw new TypeError(`Invalid option: ${e} must be an array of strings`)}static validateOptions(e){for(const t of Object.keys(e))if("style"!==t)if("wordReplacementsList"!==t){if(!s.titleCaseDefaultOptionsList.hasOwnProperty(t))throw new TypeError(`Invalid option: ${t}`);this.TitleCaseValidator.validateOption(t,e[t])}else{if(!Array.isArray(e.wordReplacementsList))throw new TypeError(`Invalid option: ${t} must be an array`);for(const r of e.wordReplacementsList)if("string"!=typeof r)throw new TypeError(`Invalid option: ${t} must contain only strings`)}else{if("string"!=typeof e.style)throw new TypeError(`Invalid option: ${t} must be a string`);if(!s.allowedTitleCaseStylesList.includes(e.style))throw new TypeError(`Invalid option: ${t} must be a string`)}}static getTitleCaseOptions(e={},t=[]){const r=JSON.stringify({options:e,lowercaseWords:t});if(o.titleCaseOptionsCache.has(r))return o.titleCaseOptionsCache.get(r);const i={...s.titleCaseDefaultOptionsList[e.style||"ap"],...e},a=i.articlesList.concat(t).filter(((e,t,r)=>r.indexOf(e)===t)),n=i.shortConjunctionsList.concat(t).filter(((e,t,r)=>r.indexOf(e)===t)),c=i.shortPrepositionsList.concat(t).filter(((e,t,r)=>r.indexOf(e)===t)),l=[...(i.replaceTerms||[]).map((([e,t])=>[e.toLowerCase(),t])),...s.wordReplacementsList],u={articlesList:a,shortConjunctionsList:n,shortPrepositionsList:c,neverCapitalizedList:[...i.neverCapitalizedList],replaceTerms:l};return o.titleCaseOptionsCache.set(r,u),u}static isShortConjunction(e,t){const r=[...o.getTitleCaseOptions({style:t}).shortConjunctionsList],s=e.toLowerCase();return r.includes(s)}static isArticle(e,t){return o.getTitleCaseOptions({style:t}).articlesList.includes(e.toLowerCase())}static isShortPreposition(e,t){const{shortPrepositionsList:r}=o.getTitleCaseOptions({style:t});return r.includes(e.toLowerCase())}static isNeverCapitalized(e,t){const r=`${t}_${e.toLowerCase()}`;if(o.isNeverCapitalizedCache.has(r))return o.isNeverCapitalizedCache.get(r);const{neverCapitalizedList:s}=o.getTitleCaseOptions({style:t}),i=s.includes(e.toLowerCase());return o.isNeverCapitalizedCache.set(r,i),i}static isShortWord(e,t){if("string"!=typeof e)throw new TypeError(`Invalid input: word must be a string. Received ${typeof e}.`);if(!s.allowedTitleCaseStylesList.includes(t))throw new Error(`Invalid option: style must be one of ${s.allowedTitleCaseStylesList.join(", ")}.`);return o.isShortConjunction(e,t)||o.isArticle(e,t)||o.isShortPreposition(e,t)||o.isNeverCapitalized(e,t)}static hasNumbers(e){return/\d/.test(e)}static hasUppercaseMultiple(e){let t=0;for(let r=0;r<e.length&&t<2;r++)/[A-Z]/.test(e[r])&&t++;return t>=2}static hasUppercaseIntentional(e){return/[A-Z]/.test(e.slice(1))&&/[a-z]/.test(e.slice(0,-1))}static hasSuffix(e){return e.length>"'s".length&&e.endsWith("'s")}static hasApostrophe(e){return-1!==e.indexOf("'")}static hasHyphen(e){return-1!==e.indexOf("-")||-1!==e.indexOf("–")||-1!==e.indexOf("—")}static hasRomanNumeral(e){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");return/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/i.test(e)}static hasHyphenRomanNumeral(e){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");const t=e.split("-");for(let e=0;e<t.length;e++)if(!o.hasRomanNumeral(t[e]))return!1;return!0}static hasHtmlBreak(e){return"nl2br"===e}static hasUnicodeSymbols(e){return/[^\x00-\x7F\u00A0-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u02B0-\u02FF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0800-\u083F\u0840-\u085F\u0860-\u087F\u0880-\u08AF\u08B0-\u08FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF]/.test(e)}static hasCurrencySymbols(e){return/[^\x00-\x7F\u00A0-\u00FF\u20AC\u20A0-\u20B9\u20BD\u20A1-\u20A2\u00A3-\u00A5\u058F\u060B\u09F2-\u09F3\u0AF1\u0BF9\u0E3F\u17DB\u20A6\u20A8\u20B1\u2113\u20AA-\u20AB\u20AA\u20AC-\u20AD\u20B9]/.test(e)}static isWordAmpersand(e){return/&|&/.test(e)}static startsWithSymbol(e){if("string"!=typeof e)throw new Error(`Parameter 'word' must be a string. Received '${typeof e}' instead.`);if(0===e.length)return!1;const t=e.charAt(0);return"#"===t||"@"===t||"."===t}static escapeSpecialCharacters(e){return e.replace(/[&<>"']/g,(function(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case"'":return"'";default:return e}}))}static unescapeSpecialCharacters(e){return e.replace(/&|<|>|"|'/g,(function(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case""":return'"';case"'":return"'";default:return e}}))}static endsWithSymbol(e,t=[".",",",";",":","?","!"]){if("string"!=typeof e||!Array.isArray(t))throw new Error("Invalid arguments");return t.some((t=>e.endsWith(t)))||t.includes(e.slice(-2))}static isWordIgnored(e,t=s.ignoredWordList){if(!Array.isArray(t))throw new TypeError("Invalid input: ignoredWords must be an array.");if("string"!=typeof e||""===e.trim())throw new TypeError("Invalid input: word must be a non-empty string.");let r;return r=e.toLowerCase().trim(),t.includes(r)}static isWordInArray(e,t){return!!Array.isArray(t)&&t.some((t=>t.toLowerCase()===e.toLowerCase()))}static replaceTerm(e,t){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");if(!t||"object"!=typeof t)throw new TypeError("Invalid input: replaceTermObj must be a non-null object.");let r;if(r=e.toLowerCase(),t.hasOwnProperty(r))return t[r];if(t.hasOwnProperty(e))return t[e];const s=e.toUpperCase();return t.hasOwnProperty(s)?t[s]:e}static correctSuffix(e,t){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");if(!t||!Array.isArray(t)||t.some((e=>"string"!=typeof e)))throw new TypeError("Invalid input: correctTerms must be an array of strings.");if(/'s$/i.test(e)){const r=e.slice(0,-2),s=t.findIndex((e=>e.toLowerCase()===r.toLowerCase()));if(s>=0){return`${t[s]}'s`}return`${r.charAt(0).toUpperCase()+r.slice(1)}'s`}return e}static correctTerm(e,t,r=/[-']/){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");if(!t||!Array.isArray(t))throw new TypeError("Invalid input: correctTerms must be an array.");if(!("string"==typeof r||Array.isArray(r)||r instanceof RegExp))throw new TypeError("Invalid input: delimiters must be a string, an array of strings, or a regular expression.");"string"==typeof r?r=new RegExp(`[${r}]`):Array.isArray(r)&&(r=new RegExp(`[${r.join("")}]`));const s=e.split(r),i=s.length;for(let e=0;e<i;e++){const r=s[e].toLowerCase(),i=t.findIndex((e=>e.toLowerCase()===r));i>=0&&(s[e]=t[i])}return s.join(r.source.charAt(0))}static correctTermHyphenated(e,t){const r=e.split("-"),i=e=>e.charAt(0).toUpperCase()+e.slice(1),a=e=>e.charAt(0)+e.slice(1).toLowerCase(),n={ap:(e,t)=>0===t?i(e):a(e),chicago:i,apa:(e,r,s)=>o.isShortWord(e,t)&&r>0&&r<s-1?e.toLowerCase():i(e),nyt:(e,t)=>0===t?i(e):a(e),wikipedia:(e,t)=>0===t?i(e):a(e)},c=n[t]||a,l=r.map(((e,t)=>{if(/^(M{0,3})(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/i.test(e))return e.toUpperCase();let i=e;const o=e.toLowerCase(),a=s.correctTitleCasingList.findIndex((e=>e.toLowerCase()===o));if(a>=0)i=s.correctTitleCasingList[a];else if(o.endsWith("'s")){const e=o.substring(0,o.length-2),t=s.correctTitleCasingList.findIndex((t=>t.toLowerCase()===e));t>=0&&(i=`${s.correctTitleCasingList[t]}'s`)}return c(i,t,r.length)}));return l.join("-")}}t.default=o,i(o,"TitleCaseValidator",void 0),i(o,"titleCaseOptionsCache",new Map),i(o,"isNeverCapitalizedCache",new Map)},429:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TitleCaser=void 0;var s,i=r(541),o=(s=r(675))&&s.__esModule?s:{default:s};class a{constructor(e={}){this.options=e,this.wordReplacementsList=i.wordReplacementsList}toTitleCase(e){try{if(0===e.trim().length)throw new TypeError("Invalid input: input must not be empty.");if("string"!=typeof e)throw new TypeError("Invalid input: input must be a string.");if(void 0!==this.options&&"object"!=typeof this.options)throw new TypeError("Invalid options: options must be an object.");const{style:t="ap",neverCapitalize:r=[],replaceTermList:s=i.wordReplacementsList}=this.options,a=["nl2br",...r],{articlesList:n,shortConjunctionsList:c,shortPrepositionsList:l,neverCapitalizedList:u,replaceTerms:p}=o.default.getTitleCaseOptions(this.options,i.commonAbbreviationList,i.wordReplacementsList),d=s.map((e=>Object.keys(e)[0].toLowerCase())),C=Object.fromEntries(s.map((e=>[Object.keys(e)[0].toLowerCase(),Object.values(e)[0]])));let f=e.trim();f=f.replace(/ {2,}/g,(e=>e.slice(0,1))),f=f.replace(/<br\s*\/?>/gi,"nl2br ");const h=f.split(" ");f=h.map(((e,r)=>{switch(!0){case o.default.isWordAmpersand(e):case o.default.hasHtmlBreak(e):case o.default.isWordIgnored(e,a):return e;case d.includes(e.toLowerCase()):return C[e.toLowerCase()];case o.default.isWordInArray(e,i.correctTitleCasingList):return o.default.correctTerm(e,i.correctTitleCasingList);case o.default.hasSuffix(e,t):return o.default.correctSuffix(e,i.correctTitleCasingList);case o.default.hasHyphen(e):return o.default.correctTermHyphenated(e,t);case o.default.hasUppercaseIntentional(e):return e;case o.default.isShortWord(e,t)&&0!==r:return r>0&&o.default.endsWithSymbol(h[r-1],[":","?","!","."])?e.charAt(0).toUpperCase()+e.slice(1):e.toLowerCase();case o.default.endsWithSymbol(e):const s=e.split(/([.,\/#!$%\^&\*;:{}=\-_`~()])/g).map(((e,t)=>o.default.isWordInArray(e,i.correctTitleCasingList)?o.default.correctTerm(e,i.correctTitleCasingList):(t>0&&o.default.endsWithSymbol(e),e.charAt(0).toUpperCase()+e.slice(1))));return s.join("");case o.default.startsWithSymbol(e):return o.default.isWordInArray(e,i.correctTitleCasingList)?o.default.correctTerm(e):e;case o.default.hasRomanNumeral(e):return e.toUpperCase();case o.default.hasNumbers(e):return e;default:return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}})).join(" ");for(const e of i.correctPhraseCasingList)f.toLowerCase().includes(e.toLowerCase())&&(f=f.replace(new RegExp(e,"gi"),e));return f=f.replace(/nl2br /gi,"<br />"),f}catch(e){throw new Error(e)}}setReplaceTerms(e){if("object"!=typeof e)throw new TypeError("Invalid argument: replace terms must be an object.");Object.entries(e).forEach((([e,t])=>{const r=i.wordReplacementsList.findIndex((t=>t[e]));-1!==r?i.wordReplacementsList[r][e]=t:i.wordReplacementsList.push({[e]:t})})),this.options.wordReplacementsList=i.wordReplacementsList}addReplaceTerm(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Invalid argument: term and replacement must be strings.");const r=this.wordReplacementsList.findIndex((t=>t[e]));-1!==r?this.wordReplacementsList[r][e]=t:this.wordReplacementsList.push({[e]:t}),this.options.wordReplacementsList=this.wordReplacementsList}removeReplaceTerm(e){if("string"!=typeof e)throw new TypeError("Invalid argument: term must be a string.");const t=this.wordReplacementsList.findIndex((t=>Object.keys(t)[0]===e));if(-1===t)throw new Error(`Term '${e}' not found in word replacements list.`);this.wordReplacementsList.splice(t,1),this.options.wordReplacementsList=this.wordReplacementsList}setStyle(e){if("string"!=typeof e)throw new TypeError("Invalid argument: style must be a string.");this.options.style=e}}t.TitleCaser=a,e.exports&&(e.exports={TitleCaser:a})}},t={};function r(s){var i=t[s];if(void 0!==i)return i.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,r),o.exports}var s={};(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"TitleCaser",{enumerable:!0,get:function(){return t.TitleCaser}});var t=r(429);"function"!=typeof String.prototype.toTitleCase&&(String.prototype.toTitleCase=function(e){return new t.TitleCaser(e).toTitleCase(this)}),"object"==typeof window&&(window.TitleCaser=t.TitleCaser)})(),module.exports=s})();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
(()=>{"use strict";var e={541:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.wordReplacementsList=t.titleCaseStylesList=t.titleCaseDefaultOptionsList=t.ignoredWordList=t.correctTitleCasingList=t.correctPhraseCasingList=t.commonAbbreviationList=t.allowedTitleCaseStylesList=void 0;t.commonAbbreviationList=["a","an","the","as","at","by","for","in","of","on","to","up","yet","so","but","nor","or","and"];t.correctTitleCasingList=["AJAX","CSS","DOM","ES6","HTML","JavaScript","jQuery","MobX","SCSS","TypeScript","Vue.js",".NET","ASP","ASPX","MySQL","PHP","PostgresQL","Python","SQL","GraphQL","HTML5","API","APIs","ASCII","CI","CircleCI","CLI","DLL","DNS","EC2","FTP","HTTP","HTTPs","ICMP","IDE","IP","ISP","JSON","JSP","LPWAN","M2M","MQTT","OOP","REST","SSH","SSL","TCP","UDP","URL","WLAN","WYSIWYG","XML","YAML","YML","IMAP","RSS","IaaS","PaaS","SaaS","CaaS","FaaS","XaaS","RaaS","IoE","IoT","LoRa","NB-IoT","RFID","RF","RFI","RFQ","ECMAScript","IO","I/O","DevOps","SecOps","DDoS","VoIP","AI","AR","ML","VR","w/","w/o","e-Book","e-Books","eBook","eBooks","eCommerce","eMarket","eMarketplace","eMarketplaces","eMarkets","eReader","eShop","eShops","eStore","eStores","E-commerce","AP","COGS","EBIT","EPS","FIFO","GAAP","LIFO","P&L","ROI","SOX","TCO","VAT","CAGR","DCF","ETF","IPO","IRR","M&A","NAV","PE","PEG","PPE","ROE","S&P","TVM","VC","B2B","B2C","CMO","CPA","CPC","CPL","CPM","CRM","CTA","CTR","SEO","SEM","SMM","USP","A/B","CTA","CTOR","CTR","KPI","PWA","SEM","SERP","SERPs","SMM","SMO","FAQ","FAQA","FAQS","UI","UI/UX","UX","T&C","TOS","PP","CRM","PoE","PoW","PoC","A11Y","PR","BANT","KPI","MQL","NPS","POS","SPIN","SQL","SWOT","AFA","ADR","CCPA","CFAA","CISG","DMCA","EULA","GDPR","HIPAA","NDA","SOW","TOS","CEO","CEOs","CFO","CFOs","CIO","CIOs","CMO","CMOs","COO","COOs","CPO","CPOs","CRO","CROs","CSO","CSOs","CTO","CTOs","EVP","EVPs","HR","HRs","SVP","SVPs","VP","VPs","NGO","NPO","NGOs","NPOs","UN","UNESCO","UNICEF","UNHCR","UNODC","UNDP","UNFPA","UNEP","Adobe","Airbnb","Alibaba","Allstate","American Express","Apple","AT&T","BMW","Boeing","Cisco","Citigroup","Coca","Deloitte","Disney","Dropbox","ExxonMobil","Ford","GE","General","Goldman Sachs","Google","Hilton","HP","IBM","Intel","JPMorgan","Johnson & Johnson","LinkedIn","McDonald's","Mercedes-Benz","Microsoft","Nestle","Nike","Nissan","Oracle","PepsiCo","Pfizer","Salesforce","Samsung","Shell","Sony","Tesla","Toyota","Uber","Verizon","Visa","Walmart","Wells Fargo","Yahoo","Zara","IKEA","Facebook","YouTube","Instagram","Twitter","TensorFlow","Amazon","Netflix","eBay","iPhone","iPad","iPod","PlayStation","PayPal","GitHub","GitLab","CodeIgniter","WordPress","WooCommerce","MongoDB","JIRA","HubSpot","AirDrop","AirPlay","AirPods","AirTags","FinalCut","GarageBand","iBooks","iCloud","iLife","iMac","iMessage","iMovie","iPhoto","iWatch","iWork","LogicPro","macOS","ProTools","QuickTime","AdWords","AdSense","TikTok","Slack","Trello","Zoom","Twitch","Snapchat","WhatsApp","Telegram","Discord","Reddit","Quora","StackOverflow","StackExchange","Coca-Cola","AWS","GCP","VMware","CVS","ESL","EE","NBA","NCAA","NFL","WWE","WWF","FIFA","a.m.","p.m.","ca.","cc.","fig.","pl.","pt.","rev.","sr.","v.","vol.","et al.","pp.","p.","ph.d.","m.d.","d.d.s.","d.m.d.","d.o.","d.c.","d.v.m.","d.n.p.","d.p.m.","d.s.w.","d.s.n.","d.n.sc.","d.n.a.","d.n.t.","d.n.p.t.","d.n.o.","d.n.m.","d.n.e.","d.n.s.","d.n.p.s.","adj.","adv.","cf.","cm.","co.","corp.","dept.","dist.","ed.","edn.","esp.","etc.","ex.","i.e.","e.g.","op. cit.","vs.","Ltd.","Co.","Inc.","St.","Ave.","Bldg.","No."];t.wordReplacementsList=[{"a.k.a":"AKA"},{"a.s.a.p":"ASAP"},{angularjs:"Angular.js"},{"back-end":"Backend"},{"d.i.y":"DIY"},{"e-book":"eBook"},{"e-books":"eBooks"},{"e-commerce":"eCommerce"},{ecom:"eCommerce"},{ecommerce:"eCommerce"},{"f.a.q":"FAQ"},{"f.a.q.a":"FAQs"},{"f.a.q.s":"FAQs"},{"f.y.i":"FYI"},{"front-end":"Frontend"},{"full-stack":"Fullstack"},{nextjs:"Next.js"},{nodejs:"Node.js"},{nuxtjs:"Nuxt.js"},{reactjs:"React.js"},{"t.b.d":"TBD"},{vuejs:"Vue.js"},{phd:"ph.d."}];const r=Object.freeze({AP:"ap",APA:"apa",BRITISH:"british",CHICAGO:"chicago",NYT:"nyt",WIKIPEDIA:"wikipedia"});t.titleCaseStylesList=r;const s=Object.values(r);t.allowedTitleCaseStylesList=s;const i=Object.freeze({ap:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]},apa:{shortConjunctionsList:["and","as","but","by","for","in","nor","of","on","or","so","to","yet"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","for","in","of","on","to","up","via"],neverCapitalizedList:[]},british:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]},chicago:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","for","in","of","on","to","up","with","via"],neverCapitalizedList:["etc."]},nyt:{shortConjunctionsList:["and","but","or","for","nor","yet","so"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]},wikipedia:{shortConjunctionsList:["and","as","but","for","if","nor","or","so","yet"],articlesList:["a","an","the"],shortPrepositionsList:["as","at","by","in","of","on","to","up","via"],neverCapitalizedList:[]}});t.titleCaseDefaultOptionsList=i;t.ignoredWordList=[];t.correctPhraseCasingList=["The Cybersmile Foundation","CO. by Colgate","The Simpsons"]},675:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var s=r(541);function i(e,t,r){return(t=function(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var s=r.call(e,t||"default");if("object"!=typeof s)return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}class o{static validateOption(e,t){if(!Array.isArray(t))throw new TypeError(`Invalid option: ${e} must be an array`);if(!t.every((e=>"string"==typeof e)))throw new TypeError(`Invalid option: ${e} must be an array of strings`)}static validateOptions(e){for(const t of Object.keys(e))if("style"!==t)if("wordReplacementsList"!==t){if(!s.titleCaseDefaultOptionsList.hasOwnProperty(t))throw new TypeError(`Invalid option: ${t}`);this.TitleCaseValidator.validateOption(t,e[t])}else{if(!Array.isArray(e.wordReplacementsList))throw new TypeError(`Invalid option: ${t} must be an array`);for(const r of e.wordReplacementsList)if("string"!=typeof r)throw new TypeError(`Invalid option: ${t} must contain only strings`)}else{if("string"!=typeof e.style)throw new TypeError(`Invalid option: ${t} must be a string`);if(!s.allowedTitleCaseStylesList.includes(e.style))throw new TypeError(`Invalid option: ${t} must be a string`)}}static getTitleCaseOptions(e={},t=[]){const r=JSON.stringify({options:e,lowercaseWords:t});if(o.titleCaseOptionsCache.has(r))return o.titleCaseOptionsCache.get(r);const i={...s.titleCaseDefaultOptionsList[e.style||"ap"],...e},a=i.articlesList.concat(t).filter(((e,t,r)=>r.indexOf(e)===t)),n=i.shortConjunctionsList.concat(t).filter(((e,t,r)=>r.indexOf(e)===t)),c=i.shortPrepositionsList.concat(t).filter(((e,t,r)=>r.indexOf(e)===t)),l=[...(i.replaceTerms||[]).map((([e,t])=>[e.toLowerCase(),t])),...s.wordReplacementsList],u={articlesList:a,shortConjunctionsList:n,shortPrepositionsList:c,neverCapitalizedList:[...i.neverCapitalizedList],replaceTerms:l};return o.titleCaseOptionsCache.set(r,u),u}static isShortConjunction(e,t){const r=[...o.getTitleCaseOptions({style:t}).shortConjunctionsList],s=e.toLowerCase();return r.includes(s)}static isArticle(e,t){return o.getTitleCaseOptions({style:t}).articlesList.includes(e.toLowerCase())}static isShortPreposition(e,t){const{shortPrepositionsList:r}=o.getTitleCaseOptions({style:t});return r.includes(e.toLowerCase())}static isNeverCapitalized(e,t){const r=`${t}_${e.toLowerCase()}`;if(o.isNeverCapitalizedCache.has(r))return o.isNeverCapitalizedCache.get(r);const{neverCapitalizedList:s}=o.getTitleCaseOptions({style:t}),i=s.includes(e.toLowerCase());return o.isNeverCapitalizedCache.set(r,i),i}static isShortWord(e,t){if("string"!=typeof e)throw new TypeError(`Invalid input: word must be a string. Received ${typeof e}.`);if(!s.allowedTitleCaseStylesList.includes(t))throw new Error(`Invalid option: style must be one of ${s.allowedTitleCaseStylesList.join(", ")}.`);return o.isShortConjunction(e,t)||o.isArticle(e,t)||o.isShortPreposition(e,t)||o.isNeverCapitalized(e,t)}static hasNumbers(e){return/\d/.test(e)}static hasUppercaseMultiple(e){let t=0;for(let r=0;r<e.length&&t<2;r++)/[A-Z]/.test(e[r])&&t++;return t>=2}static hasUppercaseIntentional(e){return/[A-Z]/.test(e.slice(1))&&/[a-z]/.test(e.slice(0,-1))}static hasSuffix(e){return e.length>"'s".length&&e.endsWith("'s")}static hasApostrophe(e){return-1!==e.indexOf("'")}static hasHyphen(e){return-1!==e.indexOf("-")||-1!==e.indexOf("–")||-1!==e.indexOf("—")}static hasRomanNumeral(e){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");return/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/i.test(e)}static hasHyphenRomanNumeral(e){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");const t=e.split("-");for(let e=0;e<t.length;e++)if(!o.hasRomanNumeral(t[e]))return!1;return!0}static hasHtmlBreak(e){return"nl2br"===e}static hasUnicodeSymbols(e){return/[^\x00-\x7F\u00A0-\u00FF\u0100-\u017F\u0180-\u024F\u0250-\u02AF\u02B0-\u02FF\u0300-\u036F\u0370-\u03FF\u0400-\u04FF\u0500-\u052F\u0530-\u058F\u0590-\u05FF\u0600-\u06FF\u0700-\u074F\u0750-\u077F\u0780-\u07BF\u07C0-\u07FF\u0800-\u083F\u0840-\u085F\u0860-\u087F\u0880-\u08AF\u08B0-\u08FF\u0900-\u097F\u0980-\u09FF\u0A00-\u0A7F\u0A80-\u0AFF\u0B00-\u0B7F\u0B80-\u0BFF\u0C00-\u0C7F\u0C80-\u0CFF\u0D00-\u0D7F\u0D80-\u0DFF\u0E00-\u0E7F\u0E80-\u0EFF\u0F00-\u0FFF]/.test(e)}static hasCurrencySymbols(e){return/[^\x00-\x7F\u00A0-\u00FF\u20AC\u20A0-\u20B9\u20BD\u20A1-\u20A2\u00A3-\u00A5\u058F\u060B\u09F2-\u09F3\u0AF1\u0BF9\u0E3F\u17DB\u20A6\u20A8\u20B1\u2113\u20AA-\u20AB\u20AA\u20AC-\u20AD\u20B9]/.test(e)}static isWordAmpersand(e){return/&|&/.test(e)}static startsWithSymbol(e){if("string"!=typeof e)throw new Error(`Parameter 'word' must be a string. Received '${typeof e}' instead.`);if(0===e.length)return!1;const t=e.charAt(0);return"#"===t||"@"===t||"."===t}static escapeSpecialCharacters(e){return e.replace(/[&<>"']/g,(function(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case'"':return""";case"'":return"'";default:return e}}))}static unescapeSpecialCharacters(e){return e.replace(/&|<|>|"|'/g,(function(e){switch(e){case"&":return"&";case"<":return"<";case">":return">";case""":return'"';case"'":return"'";default:return e}}))}static endsWithSymbol(e,t=[".",",",";",":","?","!"]){if("string"!=typeof e||!Array.isArray(t))throw new Error("Invalid arguments");return t.some((t=>e.endsWith(t)))||t.includes(e.slice(-2))}static isWordIgnored(e,t=s.ignoredWordList){if(!Array.isArray(t))throw new TypeError("Invalid input: ignoredWords must be an array.");if("string"!=typeof e||""===e.trim())throw new TypeError("Invalid input: word must be a non-empty string.");let r;return r=e.toLowerCase().trim(),t.includes(r)}static isWordInArray(e,t){return!!Array.isArray(t)&&t.some((t=>t.toLowerCase()===e.toLowerCase()))}static replaceTerm(e,t){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");if(!t||"object"!=typeof t)throw new TypeError("Invalid input: replaceTermObj must be a non-null object.");let r;if(r=e.toLowerCase(),t.hasOwnProperty(r))return t[r];if(t.hasOwnProperty(e))return t[e];const s=e.toUpperCase();return t.hasOwnProperty(s)?t[s]:e}static correctSuffix(e,t){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");if(!t||!Array.isArray(t)||t.some((e=>"string"!=typeof e)))throw new TypeError("Invalid input: correctTerms must be an array of strings.");if(/'s$/i.test(e)){const r=e.slice(0,-2),s=t.findIndex((e=>e.toLowerCase()===r.toLowerCase()));if(s>=0){return`${t[s]}'s`}return`${r.charAt(0).toUpperCase()+r.slice(1)}'s`}return e}static correctTerm(e,t,r=/[-']/){if("string"!=typeof e||""===e)throw new TypeError("Invalid input: word must be a non-empty string.");if(!t||!Array.isArray(t))throw new TypeError("Invalid input: correctTerms must be an array.");if(!("string"==typeof r||Array.isArray(r)||r instanceof RegExp))throw new TypeError("Invalid input: delimiters must be a string, an array of strings, or a regular expression.");"string"==typeof r?r=new RegExp(`[${r}]`):Array.isArray(r)&&(r=new RegExp(`[${r.join("")}]`));const s=e.split(r),i=s.length;for(let e=0;e<i;e++){const r=s[e].toLowerCase(),i=t.findIndex((e=>e.toLowerCase()===r));i>=0&&(s[e]=t[i])}return s.join(r.source.charAt(0))}static correctTermHyphenated(e,t){const r=e.split("-"),i=e=>e.charAt(0).toUpperCase()+e.slice(1),a=e=>e.charAt(0)+e.slice(1).toLowerCase(),n={ap:(e,t)=>0===t?i(e):a(e),chicago:i,apa:(e,r,s)=>o.isShortWord(e,t)&&r>0&&r<s-1?e.toLowerCase():i(e),nyt:(e,t)=>0===t?i(e):a(e),wikipedia:(e,t)=>0===t?i(e):a(e)},c=n[t]||a,l=r.map(((e,t)=>{if(/^(M{0,3})(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/i.test(e))return e.toUpperCase();let i=e;const o=e.toLowerCase(),a=s.correctTitleCasingList.findIndex((e=>e.toLowerCase()===o));if(a>=0)i=s.correctTitleCasingList[a];else if(o.endsWith("'s")){const e=o.substring(0,o.length-2),t=s.correctTitleCasingList.findIndex((t=>t.toLowerCase()===e));t>=0&&(i=`${s.correctTitleCasingList[t]}'s`)}return c(i,t,r.length)}));return l.join("-")}}t.default=o,i(o,"TitleCaseValidator",void 0),i(o,"titleCaseOptionsCache",new Map),i(o,"isNeverCapitalizedCache",new Map)},429:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TitleCaser=void 0;var s,i=r(541),o=(s=r(675))&&s.__esModule?s:{default:s};class a{constructor(e={}){this.options=e,this.wordReplacementsList=i.wordReplacementsList}toTitleCase(e){try{if(0===e.trim().length)throw new TypeError("Invalid input: input must not be empty.");if("string"!=typeof e)throw new TypeError("Invalid input: input must be a string.");if(void 0!==this.options&&"object"!=typeof this.options)throw new TypeError("Invalid options: options must be an object.");const{style:t="ap",neverCapitalize:r=[],replaceTermList:s=i.wordReplacementsList}=this.options,a=["nl2br",...r],{articlesList:n,shortConjunctionsList:c,shortPrepositionsList:l,neverCapitalizedList:u,replaceTerms:p}=o.default.getTitleCaseOptions(this.options,i.commonAbbreviationList,i.wordReplacementsList),d=s.map((e=>Object.keys(e)[0].toLowerCase())),C=Object.fromEntries(s.map((e=>[Object.keys(e)[0].toLowerCase(),Object.values(e)[0]])));let f=e.trim();f=f.replace(/ {2,}/g,(e=>e.slice(0,1))),f=f.replace(/<br\s*\/?>/gi,"nl2br ");const h=f.split(" ");f=h.map(((e,r)=>{switch(!0){case o.default.isWordAmpersand(e):case o.default.hasHtmlBreak(e):case o.default.isWordIgnored(e,a):return e;case d.includes(e.toLowerCase()):return C[e.toLowerCase()];case o.default.isWordInArray(e,i.correctTitleCasingList):return o.default.correctTerm(e,i.correctTitleCasingList);case o.default.hasSuffix(e,t):return o.default.correctSuffix(e,i.correctTitleCasingList);case o.default.hasHyphen(e):return o.default.correctTermHyphenated(e,t);case o.default.hasUppercaseIntentional(e):return e;case o.default.isShortWord(e,t)&&0!==r:return r>0&&o.default.endsWithSymbol(h[r-1],[":","?","!","."])?e.charAt(0).toUpperCase()+e.slice(1):e.toLowerCase();case o.default.endsWithSymbol(e):const s=e.split(/([.,\/#!$%\^&\*;:{}=\-_`~()])/g).map(((e,t)=>o.default.isWordInArray(e,i.correctTitleCasingList)?o.default.correctTerm(e,i.correctTitleCasingList):(t>0&&o.default.endsWithSymbol(e),e.charAt(0).toUpperCase()+e.slice(1))));return s.join("");case o.default.startsWithSymbol(e):return o.default.isWordInArray(e,i.correctTitleCasingList)?o.default.correctTerm(e):e;case o.default.hasRomanNumeral(e):return e.toUpperCase();case o.default.hasNumbers(e):return e;default:return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}})).join(" ");for(const e of i.correctPhraseCasingList)f.toLowerCase().includes(e.toLowerCase())&&(f=f.replace(new RegExp(e,"gi"),e));return f=f.replace(/nl2br /gi,"<br />"),f}catch(e){throw new Error(e)}}setReplaceTerms(e){if("object"!=typeof e)throw new TypeError("Invalid argument: replace terms must be an object.");Object.entries(e).forEach((([e,t])=>{const r=i.wordReplacementsList.findIndex((t=>t[e]));-1!==r?i.wordReplacementsList[r][e]=t:i.wordReplacementsList.push({[e]:t})})),this.options.wordReplacementsList=i.wordReplacementsList}addReplaceTerm(e,t){if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Invalid argument: term and replacement must be strings.");const r=this.wordReplacementsList.findIndex((t=>t[e]));-1!==r?this.wordReplacementsList[r][e]=t:this.wordReplacementsList.push({[e]:t}),this.options.wordReplacementsList=this.wordReplacementsList}removeReplaceTerm(e){if("string"!=typeof e)throw new TypeError("Invalid argument: term must be a string.");const t=this.wordReplacementsList.findIndex((t=>Object.keys(t)[0]===e));if(-1===t)throw new Error(`Term '${e}' not found in word replacements list.`);this.wordReplacementsList.splice(t,1),this.options.wordReplacementsList=this.wordReplacementsList}setStyle(e){if("string"!=typeof e)throw new TypeError("Invalid argument: style must be a string.");this.options.style=e}}t.TitleCaser=a,e.exports&&(e.exports={TitleCaser:a})}},t={};function r(s){var i=t[s];if(void 0!==i)return i.exports;var o=t[s]={exports:{}};return e[s](o,o.exports,r),o.exports}var s={};(()=>{var e=s;Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"TitleCaser",{enumerable:!0,get:function(){return t.TitleCaser}});var t=r(429);"function"!=typeof String.prototype.toTitleCase&&(String.prototype.toTitleCase=function(e){return new t.TitleCaser(e).toTitleCase(this)}),"object"==typeof window&&(window.TitleCaser=t.TitleCaser)})(),module.exports=s})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielhaim/titlecaser",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.31",
|
|
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
|
"titlecase",
|
|
@@ -28,7 +28,10 @@
|
|
|
28
28
|
"src/index.js",
|
|
29
29
|
"src/TitleCaseConsts.js",
|
|
30
30
|
"src/TitleCaser.js",
|
|
31
|
-
"src/index.js"
|
|
31
|
+
"src/index.js",
|
|
32
|
+
"dist/titlecaser.js",
|
|
33
|
+
"dist/titlecaser.min.js",
|
|
34
|
+
"dist/titlecaser.amd.js"
|
|
32
35
|
],
|
|
33
36
|
"author": {
|
|
34
37
|
"name": "Daniel Haim",
|
|
@@ -37,24 +40,24 @@
|
|
|
37
40
|
"license": "MIT",
|
|
38
41
|
"devDependencies": {
|
|
39
42
|
"@babel/cli": "^7.21.0",
|
|
40
|
-
"@babel/core": "^7.21.
|
|
43
|
+
"@babel/core": "^7.21.4",
|
|
41
44
|
"@babel/plugin-transform-modules-commonjs": "^7.21.2",
|
|
42
|
-
"@babel/preset-env": "^7.
|
|
45
|
+
"@babel/preset-env": "^7.21.4",
|
|
43
46
|
"@babel/runtime-corejs3": "^7.21.0",
|
|
44
47
|
"babel-loader": "^9.1.2",
|
|
45
48
|
"esbuild-jest": "^0.5.0",
|
|
46
49
|
"exports-loader": "^4.0.0",
|
|
47
50
|
"terser-webpack-plugin": "^5.3.7",
|
|
48
|
-
"webpack": "^5.
|
|
51
|
+
"webpack": "^5.78.0",
|
|
49
52
|
"webpack-cli": "^5.0.1",
|
|
50
53
|
"webpack-node-externals": "^3.0.0",
|
|
51
54
|
"@jest/expect": "^29.5.0",
|
|
52
55
|
"babel-jest": "^29.5.0",
|
|
53
56
|
"jest": "^29.5.0",
|
|
54
57
|
"jest-environment-jsdom": "^29.5.0",
|
|
55
|
-
"jest-environment-puppeteer": "^8.0.
|
|
56
|
-
"jest-puppeteer": "^8.0.
|
|
57
|
-
"puppeteer": "^19.8.
|
|
58
|
-
"puppeteer-core": "^19.8.
|
|
58
|
+
"jest-environment-puppeteer": "^8.0.6",
|
|
59
|
+
"jest-puppeteer": "^8.0.6",
|
|
60
|
+
"puppeteer": "^19.8.5",
|
|
61
|
+
"puppeteer-core": "^19.8.5"
|
|
59
62
|
}
|
|
60
63
|
}
|
package/src/TitleCaseConsts.js
CHANGED
|
@@ -7,7 +7,7 @@ export const correctTitleCasingList = [
|
|
|
7
7
|
// Web Technologies
|
|
8
8
|
'AJAX', 'CSS', 'DOM', 'ES6', 'HTML', 'JavaScript', 'jQuery',
|
|
9
9
|
'MobX', 'SCSS', 'TypeScript', 'Vue.js', '.NET', 'ASP', 'ASPX',
|
|
10
|
-
'MySQL', 'PHP', '
|
|
10
|
+
'MySQL', 'PHP', 'PostgresQL', 'Python', 'SQL', 'GraphQL',
|
|
11
11
|
'HTML5',
|
|
12
12
|
|
|
13
13
|
// Acronyms/Abbreviations
|
|
@@ -45,7 +45,7 @@ export const correctTitleCasingList = [
|
|
|
45
45
|
'PP', 'CRM', 'PoE', 'PoW', 'PoC', 'A11Y', 'PR',
|
|
46
46
|
|
|
47
47
|
// Sales terms
|
|
48
|
-
'BANT', '
|
|
48
|
+
'BANT', 'KPI', 'MQL', 'NPS', 'POS', 'SPIN', 'SQL',
|
|
49
49
|
'SWOT',
|
|
50
50
|
|
|
51
51
|
// Legal terms
|
|
@@ -78,25 +78,22 @@ export const correctTitleCasingList = [
|
|
|
78
78
|
'ProTools', 'QuickTime', 'AdWords', 'AdSense', 'TikTok', 'Slack', 'Trello',
|
|
79
79
|
'Zoom', 'Twitch', 'Snapchat', 'WhatsApp', 'Telegram', 'Discord', 'Reddit',
|
|
80
80
|
'Quora', 'StackOverflow', 'StackExchange', 'Coca-Cola',
|
|
81
|
-
'AWS', 'GCP', 'VMware', 'CVS',
|
|
81
|
+
'AWS', 'GCP', 'VMware', 'CVS', 'ESL', 'EE',
|
|
82
82
|
|
|
83
83
|
// Sports
|
|
84
84
|
'NBA', 'NCAA', 'NFL', 'WWE', 'WWF', 'FIFA',
|
|
85
85
|
|
|
86
86
|
// Time-related, numbers, and measurements: Includes abbreviations for
|
|
87
|
-
// time-related terms, numbers, and measurements.
|
|
88
87
|
'a.m.', 'p.m.', 'ca.', 'cc.', 'fig.', 'pl.', 'pt.', 'rev.',
|
|
89
88
|
'sr.', 'v.', 'vol.', 'et al.', 'pp.', 'p.',
|
|
90
89
|
|
|
91
90
|
// Professional abbreviations, degrees, and titles: Includes abbreviations
|
|
92
|
-
// for professional titles, degrees, and certifications.
|
|
93
91
|
'ph.d.', 'm.d.', 'd.d.s.', 'd.m.d.', 'd.o.', 'd.c.', 'd.v.m.',
|
|
94
92
|
'd.n.p.', 'd.p.m.', 'd.s.w.', 'd.s.n.', 'd.n.sc.', 'd.n.a.',
|
|
95
93
|
'd.n.t.', 'd.n.p.t.', 'd.n.o.', 'd.n.m.', 'd.n.e.', 'd.n.s.',
|
|
96
94
|
'd.n.p.s.',
|
|
97
95
|
|
|
98
96
|
// Academic & literary abbreviations: Includes abbreviations for academic
|
|
99
|
-
// and literary terms, such as 'ed.' for 'edition' and 'vol.' for 'volume'.
|
|
100
97
|
'adj.', 'adv.', 'cf.', 'cm.', 'co.', 'corp.', 'dept.',
|
|
101
98
|
'dist.', 'ed.', 'edn.', 'esp.', 'etc.', 'ex.', 'i.e.', 'e.g.',
|
|
102
99
|
'op. cit.', 'vs.',
|
|
@@ -206,7 +203,7 @@ export const titleCaseDefaultOptionsList = Object.freeze({
|
|
|
206
203
|
},
|
|
207
204
|
});
|
|
208
205
|
|
|
209
|
-
export const
|
|
206
|
+
export const ignoredWordList = [];
|
|
210
207
|
export const correctPhraseCasingList = [
|
|
211
208
|
'The Cybersmile Foundation',
|
|
212
209
|
'CO. by Colgate',
|
package/src/TitleCaser.js
CHANGED
|
@@ -27,7 +27,7 @@ export class TitleCaser {
|
|
|
27
27
|
const {
|
|
28
28
|
style = "ap",
|
|
29
29
|
neverCapitalize = [],
|
|
30
|
-
|
|
30
|
+
replaceTermList = wordReplacementsList
|
|
31
31
|
} = this.options;
|
|
32
32
|
const ignoreList = ["nl2br", ...neverCapitalize];
|
|
33
33
|
const {
|
|
@@ -39,9 +39,9 @@ export class TitleCaser {
|
|
|
39
39
|
} = TitleCaseHelper.getTitleCaseOptions(this.options, commonAbbreviationList, wordReplacementsList);
|
|
40
40
|
|
|
41
41
|
// Prerocess the replaceTerms array to make it easier to search for.
|
|
42
|
-
const replaceTermsArray =
|
|
42
|
+
const replaceTermsArray = replaceTermList.map(term => Object.keys(term)[0].toLowerCase());
|
|
43
43
|
// Create an object from the replaceTerms array to make it easier to search for.
|
|
44
|
-
const
|
|
44
|
+
const replaceTermObj = Object.fromEntries(replaceTermList.map(
|
|
45
45
|
term => [Object.keys(term)[0].toLowerCase(), Object.values(term)[0]]
|
|
46
46
|
));
|
|
47
47
|
|
|
@@ -78,7 +78,7 @@ export class TitleCaser {
|
|
|
78
78
|
return word;
|
|
79
79
|
case replaceTermsArray.includes(word.toLowerCase()):
|
|
80
80
|
// If the word is in the replaceTerms array, return the replacement.
|
|
81
|
-
return
|
|
81
|
+
return replaceTermObj[word.toLowerCase()];
|
|
82
82
|
case TitleCaseHelper.isWordInArray(word, correctTitleCasingList):
|
|
83
83
|
// If the word is in the correctTitleCasingList array, return the correct casing.
|
|
84
84
|
return TitleCaseHelper.correctTerm(word, correctTitleCasingList);
|