UNPKG

@metamask/snaps-utils

Version:
16 lines 662 B
import { coerce, create, literal } from "@metamask/superstruct"; /** * A wrapper of Superstruct's `literal` struct that accepts a value in either * completely lowercase or completely uppercase (i.e., "usd" or "USD"). * * @param string - The currency symbol. * @returns The struct that accepts the currency symbol in either case. It will * return the currency symbol in lowercase. */ export function currency(string) { const lowerCase = string.toLowerCase(); return coerce(literal(lowerCase), literal(string.toUpperCase()), (value) => { return create(value.toLowerCase(), literal(lowerCase)); }); } //# sourceMappingURL=currency.mjs.map