UNPKG

@metamask/snaps-utils

Version:
20 lines 874 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.currency = void 0; const superstruct_1 = require("@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. */ function currency(string) { const lowerCase = string.toLowerCase(); return (0, superstruct_1.coerce)((0, superstruct_1.literal)(lowerCase), (0, superstruct_1.literal)(string.toUpperCase()), (value) => { return (0, superstruct_1.create)(value.toLowerCase(), (0, superstruct_1.literal)(lowerCase)); }); } exports.currency = currency; //# sourceMappingURL=currency.cjs.map