use ternary + regexRep pattern matching Hex.mjs
This commit is contained in:
parent
d09ba82159
commit
7d522416a7
@ -24,13 +24,8 @@ import Utils from "../Utils.mjs";
|
|||||||
* fromDecimal("10:20:30", "Colon");
|
* fromDecimal("10:20:30", "Colon");
|
||||||
*/
|
*/
|
||||||
export function fromDecimal(data, delim="Auto") {
|
export function fromDecimal(data, delim="Auto") {
|
||||||
let byteStr;
|
const delimRegex = delim === "Auto" ? /[^\d-]+/ : Utils.regexRep(delim);
|
||||||
if (delim === "Auto") {
|
let byteStr = data.split(delimRegex);
|
||||||
byteStr = data.split(/[^\d-]+/);
|
|
||||||
} else {
|
|
||||||
delim = Utils.charRep(delim);
|
|
||||||
byteStr = data.split(delim);
|
|
||||||
}
|
|
||||||
|
|
||||||
byteStr = byteStr.filter(str => str !== "");
|
byteStr = byteStr.filter(str => str !== "");
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user