added throw error parameter to convertToByteArray in Utils.mjs

This commit is contained in:
Katie Makarska 2025-04-23 21:07:58 -04:00
parent 0a4fd20518
commit 6c046f4fe8

View file

@ -339,12 +339,12 @@ class Utils {
* // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130] * // returns [208, 159, 209, 128, 208, 184, 208, 178, 208, 181, 209, 130]
* Utils.convertToByteArray("0JfQtNGA0LDQstGB0YLQstGD0LnRgtC1", "base64"); * Utils.convertToByteArray("0JfQtNGA0LDQstGB0YLQstGD0LnRgtC1", "base64");
*/ */
static convertToByteArray(str, type, delim = "Auto") { static convertToByteArray(str, type, delim = "Auto", throwError = false) {
switch (type.toLowerCase()) { switch (type.toLowerCase()) {
case "binary": case "binary":
return fromBinary(str); return fromBinary(str);
case "hex": case "hex":
return fromHex(str, delim); return fromHex(str, delim, 2, throwError);
case "decimal": case "decimal":
return fromDecimal(str); return fromDecimal(str);
case "base64": case "base64":