//#region src/capitalize/capitalize.d.ts /** Options of `capitalize`. */ export type CapitalizeOptions = { /** Words to keep in lower case when they are not the first word (default: the Portuguese prepositions). */ lowerCaseWords?: string[]; /** Words to keep in upper case wherever they appear (default: the Brazilian company designations, document abbreviations and roman numerals). */ upperCaseWords?: string[]; }; /** * Capitalizes a given string according to the way a Brazilian name, company name or address is * written, with no configuration needed: `"jose da silva"` becomes `"Jose da Silva"`, * `"empresa ltda"` becomes `"Empresa LTDA"` and `"santana/rs"` becomes `"Santana/RS"`. * * Words are separated by whitespace, by `-` and `/`, by the apostrophe (`"d'oeste"` becomes * `"d'Oeste"`) and by punctuation that touches a word (`"(empresa)"` becomes `"(Empresa)"`, * `"bairro:centro"` becomes `"Bairro:Centro"`), so `"MOGI-GUAÇU"` becomes `"Mogi-Guaçu"`. The * separators are kept where they are, while every run of whitespace (spaces, tabs, newlines) * collapses into a single space and the leading and trailing whitespace is dropped. The particles * of foreign-origin names (`del`, `della`, `di`, `du`, `van`, `von`, `der`, `den`) stay lower * case like the Portuguese prepositions, so `"luiz von schmidt"` becomes `"Luiz von Schmidt"`. * * - Words listed in `lowerCaseWords` are converted to lower case when they link two words, that * is, when they are neither the first word nor the last one and another word follows them * across whitespace, `-`, `/` or an apostrophe. The default list is the Portuguese * prepositions, articles and conjunctions that stay in lower case inside a proper name ("de", * "da", "do", "e", ...), so `"JOSÉ DA SILVA"` becomes `"José da Silva"`. A word of the list * that ends the value or is followed by punctuation is a designator instead, and keeps its * capital: `"rua a, 100"` becomes `"Rua A, 100"` and `"condomínio a, quadra d, lote o"` becomes * `"Condomínio A, Quadra D, Lote O"`. * - The elided particle `d'` is written in lower case wherever it appears, including as the first * word, but only when an apostrophe and a word follow it, so `"santa bárbara d'oeste"` becomes * `"Santa Bárbara d'Oeste"` and `"dias d'ávila"` becomes `"Dias d'Ávila"` while the designator * `"rua d"` becomes `"Rua D"`. A single letter written right after an apostrophe is the English * possessive and stays in lower case, so `"bob's"` becomes `"Bob's"`, not `"Bob'S"`. * - Words listed in `upperCaseWords` are converted to upper case wherever they appear. The * default list is the company designations and document abbreviations that are written in upper * case in Brazilian usage (`LTDA`, `S.A.`, `S/A`, `S.S.`, `S/S`, `ME`, `EPP`, `MEI`, `EIRELI`, * `CIA`, `SCP`, `CNPJ`, `CPF`, `RG`, `CEP`, `UF`) plus the roman numerals that appear in names * and addresses (`II` through `XXIII`, except `VI`, so `"joão paulo ii"` becomes * `"João Paulo II"` and `"rua xv de novembro"` becomes `"Rua XV de Novembro"`). `ME` is also * the pt-BR pronoun "me", so it is only upper cased in the designation position, as the last * word of the value (`"fulano comércio me"` becomes `"Fulano Comércio ME"`) or right before * another designation (`"fulano me epp"` becomes `"Fulano ME EPP"`); anywhere else it is an * ordinary word, so `"diga-me a verdade"` becomes `"Diga-Me a Verdade"` and the municipality * `"não-me-toque"` becomes `"Não-Me-Toque"`. A designation * written around a slash, `S/A` and `S/S`, is matched across that slash even though a slash * separates words, so `"casa de carnes s/a"` becomes `"Casa de Carnes S/A"`. * - A two letter word that follows a `/` is converted to upper case when it is the code of a * Brazilian state, the way a municipality and its Federative Unit are written together, so * `"porto alegre/rs"` becomes `"Porto Alegre/RS"` while `"santana/br"` becomes `"Santana/Br"`. * A state code that does not follow a `/` is left alone (`"santana rs"` becomes * `"Santana Rs"`), and so is any other two letter word. * - All other words are capitalized (first letter upper case, rest lower case). * * Both lists are compared ignoring the case of the words, and either one given in `options` * replaces its default list entirely, so `capitalize("empresa ltda", { upperCaseWords: [] })` * gives `"Empresa Ltda"`. A `lowerCaseWords`/`upperCaseWords` that is not an array falls back to * its default, and a member of either list that is not a string is ignored, so a malformed * option never throws. * * @param {string} value - The input string to be capitalized. * @param {CapitalizeOptions} [options] - Optional configuration for capitalization. * @param {string[]} [options.lowerCaseWords] - Array of words to keep in lower case (default: the Portuguese prepositions). * @param {string[]} [options.upperCaseWords] - Array of words to keep in upper case (default: the Brazilian company designations, document abbreviations and roman numerals). * @returns {string} The capitalized string according to the specified rules. * * The default `lowerCaseWords` list is the set of prepositions and conjunctions the Manual de * Redação da Presidência da República keeps in lower case inside a proper name, and the default * `upperCaseWords` list is sourced in `constants.ts` from the laws that create each designation. * * @see Official: https://www4.planalto.gov.br/centrodeestudos/assuntos/manual-de-redacao-da-presidencia-da-republica/manual-de-redacao.pdf * Manual de Redação da Presidência da República, 3ª edição (Portaria nº 1.369/2018), item 5.1.8 * b) and item 10.2 a). * @see Official: https://www4.planalto.gov.br/centrodeestudos/assuntos/manual-de-redacao-da-presidencia-da-republica * The Presidência page that publishes it. * * @example * ```typescript * capitalize("JOSÉ DA SILVA"); // "José da Silva" * capitalize("empresa ltda"); // "Empresa LTDA" * capitalize("banco do brasil s.a."); // "Banco do Brasil S.A." * capitalize("santa bárbara d'oeste"); // "Santa Bárbara d'Oeste" * capitalize("bob's"); // "Bob's" * capitalize("rua a, 100"); // "Rua A, 100" * capitalize("fulano comércio me"); // "Fulano Comércio ME" * capitalize("não-me-toque"); // "Não-Me-Toque" * capitalize("(empresa) ltda"); // "(Empresa) LTDA" * capitalize("luiz von schmidt"); // "Luiz von Schmidt" * capitalize("casa de carnes s/a"); // "Casa de Carnes S/A" * capitalize("MOGI-GUAÇU"); // "Mogi-Guaçu" * capitalize("santana/rs"); // "Santana/RS" * capitalize("rua xv de novembro"); // "Rua XV de Novembro" * capitalize("empresa ltda", { upperCaseWords: [] }); // "Empresa Ltda" * capitalize("joao\tsilva"); // "Joao Silva" * ``` */ export declare const capitalize: (value: string, options?: CapitalizeOptions) => string; //#endregion