summaryrefslogtreecommitdiff
path: root/js/src/index.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/index.ts')
-rw-r--r--js/src/index.ts24
1 files changed, 14 insertions, 10 deletions
diff --git a/js/src/index.ts b/js/src/index.ts
index e56849c..38505d3 100644
--- a/js/src/index.ts
+++ b/js/src/index.ts
@@ -9,18 +9,22 @@ const dingbatsByCodePoint: {[key: string]: UnicodeScalarValue} = {};
const fromCodePoint = String.fromCodePoint ? String.fromCodePoint : fromCodePointPolyfill;
-for (const dingbat of dingbats) {
- const codePoint = parseInt(dingbat["Unicode dec"], 10);
- const scalarValue = {
- codePoint: codePoint,
- string: fromCodePoint(codePoint),
- };
+export function codePoint(typeface: string, codePoint: number): UnicodeScalarValue | undefined {
+ const codePointMap = dingbats[typeface.toUpperCase()];
- dingbatsByCodePoint[dingbat["Typeface name"].toUpperCase() + "_" + dingbat["Dingbat dec"]] = scalarValue;
-}
+ if (codePointMap === undefined) {
+ return undefined;
+ }
-export function codePoint(typeface: string, codePoint: number): UnicodeScalarValue | undefined {
- return dingbatsByCodePoint[typeface.toUpperCase() + "_" + codePoint];
+ const unicodeCodePoint = codePointMap[codePoint];
+ if (unicodeCodePoint === undefined) {
+ return undefined;
+ }
+
+ return {
+ codePoint: unicodeCodePoint,
+ string: fromCodePoint(unicodeCodePoint),
+ };
}
export function dec(typeface: string, dec: string): UnicodeScalarValue | undefined {