UNPKG

nf-icons

Version:

Easily use Nerd Fonts icons in JavaScript!

19 lines (15 loc) 509 B
import data from "./data.json"; export { default as names } from "./names"; function hex(name: string): string { return (data.iconHexByName as any)[name]; } /** * @param name - Name of icon. Use `names` for an index of recognized icon names * @returns UTF-16 code for icon or, if name is recognized, undefined */ export function utf16(name: string): string | undefined { const hexCode = hex(name); return hexCode !== undefined ? String.fromCharCode(parseInt(hex(name), 16)) : undefined; }