Skip to content

Commit

Permalink
Fixed French and Spanish for browsers without Uint8Array.forEach.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Oct 4, 2018
1 parent aeac2cd commit cb5f9f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
13 changes: 4 additions & 9 deletions src.ts/wordlists/lang-es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ let lookup: { [word: string]: number } = {};
let wordlist: Array<string> = null;

function dropDiacritic(word: string): string {
let output: Array<number> = [];
toUtf8Bytes(word.normalize('NFD').toLowerCase()).forEach((c) => {
if ((c >= 65 && c <= 90) || (c >= 97 && c <= 123)) {
output.push(c);
}
});
return toUtf8String(output);
return toUtf8String(Array.prototype.filter.call(toUtf8Bytes(word.normalize('NFD').toLowerCase()), (c: number) => {
return ((c >= 65 && c <= 90) || (c >= 97 && c <= 123));
}));
}

function expand(word: string): string {
let output: Array<number> = [];

toUtf8Bytes(word).forEach((c) => {
Array.prototype.forEach.call(toUtf8Bytes(word), (c: number) => {
// Acute accent
if (c === 47) {
output.push(204);
Expand Down
12 changes: 4 additions & 8 deletions src.ts/wordlists/lang-fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@ let wordlist: Array<string> = null;
let lookup: { [word: string]: number } = { }

function dropDiacritic(word: string): string {
let output: Array<number> = [];
toUtf8Bytes(word.normalize('NFD').toLowerCase()).forEach((c) => {
if ((c >= 65 && c <= 90) || (c >= 97 && c <= 123)) {
output.push(c);
}
});
return toUtf8String(output);
return toUtf8String(Array.prototype.filter.call(toUtf8Bytes(word.normalize('NFD').toLowerCase()), (c: number) => {
return ((c >= 65 && c <= 90) || (c >= 97 && c <= 123));
}));
}

function expand(word: string): string {
let output: Array<number> = [];

toUtf8Bytes(word).forEach((c) => {
Array.prototype.forEach.call(toUtf8Bytes(word), (c: number) => {
// Acute accent
if (c === 47) {
output.push(204);
Expand Down

0 comments on commit cb5f9f5

Please sign in to comment.