Reference · Countries and lookup tools
foldfunction
What two ways of typing a name have in common: width (full-width letters to ASCII, half-width katakana to full), case, accents (except the two marks that make が and ぱ), katakana to hiragana, apostrophes dropped, and every other run of punctuation or space to one space. The lookups compare names folded, and so can a page.
Import it
import { fold } from "@johnmorrisdotca/kuni";
Definition
function fold(text: string): string
Parameters
| Name | Type | Description |
|---|---|---|
text | string | Any text. |
Returns
string
The text folded; "" for text that is only punctuation or space.
Examples
import { fold } from "@johnmorrisdotca/kuni";
console.log(fold("Côte d'Ivoire")); // "cote divoire"
console.log(fold("USA")); // "usa"
console.log(fold("ドイツ")); // "どいつ"cote divoire
usa
どいつWhat it prints (run when this page was built)