INNER CODE UNIT · JavaScript

commentStart

karanb192/claude-code-hooks · plugins/bounty-board/bounty-board.js:133

function commentStart(line) {
  const candidates = [];
  for (let i = line.indexOf('//'); i !== -1; i = line.indexOf('//', i + 1)) {
    if (i === 0 || line[i - 1] !== ':') {
      candidates.push(i);
      break;
    }
  }
  const block = line.indexOf('/*');
  if (block !== -1) candidates.push(block);
  const hash = line.match(/(?:^|\s)#(?!!)/);
  if (hash) candidates.push(hash.index + hash[0].length - 1);
  const html = line.indexOf('<!--');
  if (html !== -1) candidates.push(html);
  const lead = line.match(/^\s*(?:\*|--|;)/);
  if (lead) candidates.push(lead[0].length - 1);
  return candidates.length ? Math.min(...candidates) : -1;
}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…