frontend/.pnpm-store/v3/files/ed/caafdc303868f533bcc0a355afae68728b3cced7c595ef8d172aaaf24758fa2f67fea6bdd99391d570243eb4f5f68dee0f7b7abd0754de0eafa7affe86e596-exec

26 lines
738 B
Plaintext
Executable File

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.IsWellFormedCurrencyCode = void 0;
/**
* This follows https://tc39.es/ecma402/#sec-case-sensitivity-and-case-mapping
* @param str string to convert
*/
function toUpperCase(str) {
return str.replace(/([a-z])/g, function (_, c) { return c.toUpperCase(); });
}
var NOT_A_Z_REGEX = /[^A-Z]/;
/**
* https://tc39.es/ecma402/#sec-iswellformedcurrencycode
*/
function IsWellFormedCurrencyCode(currency) {
currency = toUpperCase(currency);
if (currency.length !== 3) {
return false;
}
if (NOT_A_Z_REGEX.test(currency)) {
return false;
}
return true;
}
exports.IsWellFormedCurrencyCode = IsWellFormedCurrencyCode;