different types of inputDataProcess functions

Benchmark created on


Test runner

Ready to run.

Testing in
TestOps/sec
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

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.