new refactor | function inputDataProcess(args) {
const itemNameRegex = /(?<=\:).+?(?=\:)/g;
let itemsBeforeSeparator = [], itemsAfterSeparator = [];
let trading = "", lf = "";
let isSeparator = false;
for(let i = 0, numOfArgs = args.length; i < numOfArgs; i++) {
if(args[i].indexOf("👉") >= 0) {
continue;
}
if(!isSeparator) {
itemsBeforeSeparator.push(args[i].match(itemNameRegex)[0]);
trading += `<${args[i]}> `;
} else {
itemsAfterSeparator.push(args[i].match(itemNameRegex)[0]);
lf += `<${args[i]}> `;
}
}
return {
itemsBeforeSeparator,
itemsAfterSeparator,
trading,
lf,
};
}
args = [
':torit:1068131428589645864',
'👉',
':gorot:1068128925269643335'
];
inputDataProcess(args);
| ready |
old refactor | function inputDataProcess(args) {
const fruitName = /(?<=\:).+?(?=\:)/g;
let itemsBeforeSeparator = [], itemsAfterSeparator = [];
let trading = "", lf = "";
let isSeparator = false;
args.forEach((el) => {
if(el.indexOf("👉") >= 0) {
isSeparator = true;
return;
}
if(!isSeparator) {
itemsBeforeSeparator.push(el.match(fruitName)[0]);
trading += `<${el}> `;
} else {
itemsAfterSeparator.push(el.match(fruitName)[0]);
lf += `<${el}> `;
}
})
return {
itemsBeforeSeparator,
itemsAfterSeparator,
trading,
lf,
};
}
args = [
':torit:1068131428589645864',
'👉',
':gorot:1068128925269643335'
];
inputDataProcess(args);
| ready |