diff options
| author | Michael Williamson <mike@zwobble.org> | 2021-01-16 16:07:52 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2021-01-16 16:07:52 +0000 |
| commit | f8207fffcc62ce42f4930251f56ac7d50e1a2156 (patch) | |
| tree | fa8622d9f825905e6b2b8ca555992501a0d39323 | |
| parent | f2c669264288a04a6429fd2deb210e112eaee023 (diff) | |
Make typeface case insensitivejs-1.0.0
| -rw-r--r-- | js/src/index.ts | 6 | ||||
| -rw-r--r-- | js/test/tests.ts | 6 |
2 files changed, 9 insertions, 3 deletions
diff --git a/js/src/index.ts b/js/src/index.ts index f1b27d3..e56849c 100644 --- a/js/src/index.ts +++ b/js/src/index.ts @@ -16,15 +16,15 @@ for (const dingbat of dingbats) { string: fromCodePoint(codePoint), }; - dingbatsByCodePoint[dingbat["Typeface name"] + "_" + dingbat["Dingbat dec"]] = scalarValue; + dingbatsByCodePoint[dingbat["Typeface name"].toUpperCase() + "_" + dingbat["Dingbat dec"]] = scalarValue; } export function codePoint(typeface: string, codePoint: number): UnicodeScalarValue | undefined { - return dingbatsByCodePoint[typeface + "_" + codePoint]; + return dingbatsByCodePoint[typeface.toUpperCase() + "_" + codePoint]; } export function dec(typeface: string, dec: string): UnicodeScalarValue | undefined { - return dingbatsByCodePoint[typeface + "_" + dec]; + return codePoint(typeface, parseInt(dec, 10)); } export function hex(typeface: string, hex: string): UnicodeScalarValue | undefined { diff --git a/js/test/tests.ts b/js/test/tests.ts index 68a4bdf..769ee8b 100644 --- a/js/test/tests.ts +++ b/js/test/tests.ts @@ -49,3 +49,9 @@ export function whenUnicodeCodePointIsInAstralPlaneThenReturnedValueIncludesStri assert.strictEqual(result.string, "🕿"); } + +export function typefaceIsCaseInsensitive() { + const result = dingbatToUnicode.codePoint("wingDingS", 41)!!; + + assert.strictEqual(result.codePoint, 0x2706); +} |
