1
>
/*---------------------------------------------------------------------------------------------
normalization.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import { LRUCache } from './map.js';
7
>
8
>
const nfcCache = new LRUCache<string, string>(10000); // bounded to 10000 elements
9
>
export function normalizeNFC(str: string): string {
10
return normalize(str, 'NFC', nfcCache);
11
}
13
>
const nfdCache = new LRUCache<string, string>(10000); // bounded to 10000 elements
14
>
export function normalizeNFD(str: string): string {
15
return normalize(str, 'NFD', nfdCache);
16
}
18
>
const nonAsciiCharactersPattern = /[^\u0000-\u0080]/;
19
function normalize(str: string, form: string, normalizedCache: LRUCache<string, string>): string {
20
if (!str) {