Skip to content

Commit

Permalink
Add capitals option
Browse files Browse the repository at this point in the history
- Issue #2
  • Loading branch information
charlesLoder committed Jul 29, 2021
1 parent 8a31394 commit 7dc649b
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/transliterate.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { titForTat } from "./titForTat";
import { testEach } from "./testEach";

export const transliterate = (text: string) => {
export interface Options {
preserveCapitals: boolean;
}

export const transliterate = (text: string, options: Options = { preserveCapitals: false }) => {
const normalize = text.normalize("NFKD");
const titTat = titForTat(normalize);
const textCase = options.preserveCapitals ? normalize : normalize.toLowerCase();
const titTat = titForTat(textCase);
const array = titTat.split(" ");
const modArray = testEach(array);
const transliteration = modArray.join(" ");
Expand Down

0 comments on commit 7dc649b

Please sign in to comment.