diff options
| -rw-r--r-- | js/src/index.ts | 8 | ||||
| -rw-r--r-- | js/test/tests.ts | 24 |
2 files changed, 22 insertions, 10 deletions
diff --git a/js/src/index.ts b/js/src/index.ts index b808cba..13b1f3b 100644 --- a/js/src/index.ts +++ b/js/src/index.ts @@ -16,10 +16,14 @@ for (const dingbat of dingbats) { dingbatsByHex[dingbat["Typeface name"] + "_" + dingbat["Dingbat hex"]] = scalarValue; } -export function hex(typeface: string, hex: string): UnicodeScalarValue | undefined { - return dingbatsByHex[typeface + "_" + hex.toUpperCase()]; +export function codePoint(typeface: string, codePoint: number): UnicodeScalarValue | undefined { + return dingbatsByDec[typeface + "_" + codePoint]; } export function dec(typeface: string, dec: string): UnicodeScalarValue | undefined { return dingbatsByDec[typeface + "_" + dec]; } + +export function hex(typeface: string, hex: string): UnicodeScalarValue | undefined { + return dingbatsByHex[typeface + "_" + hex.toUpperCase()]; +} diff --git a/js/test/tests.ts b/js/test/tests.ts index e92eedc..a00b827 100644 --- a/js/test/tests.ts +++ b/js/test/tests.ts @@ -2,6 +2,22 @@ import assert from "assert"; import * as dingbatToUnicode from "../"; +export function canConvertFromDingbatCodePointToUnicode() { + const result = dingbatToUnicode.codePoint("Wingdings", 41); + + assert.deepStrictEqual(result, { + codePoint: 0x2706, + }); +} + +export function canConvertFromDecimalDingbatToUnicode() { + const result = dingbatToUnicode.dec("Wingdings", "41"); + + assert.deepStrictEqual(result, { + codePoint: 0x2706, + }); +} + export function canConvertFromHexDingbatToUnicode() { const result = dingbatToUnicode.hex("Wingdings", "29"); @@ -25,11 +41,3 @@ export function canConvertFromLowercaseHexDingbatToUnicode() { codePoint: 0x2707, }); } - -export function canConvertFromDecimalDingbatToUnicode() { - const result = dingbatToUnicode.dec("Wingdings", "41"); - - assert.deepStrictEqual(result, { - codePoint: 0x2706, - }); -} |
