Skip to content

Rewrite your app in Rust, piece by piece, checked against the original at every step. Works with TypeScript, JavaScript, Python, Go, Ruby, Java, C, PHP, C#, Kotlin, PowerShell and Swift.

501 B
Raw Blame
const after = /(?<=\$)\w+/g

export function rangeOf(text: string, word: string) {
  const start = text.indexOf(word)
  return { start, end: start + word.length, rest: text.slice(start) }
}

export function words(text: string): string[] {
  const out: string[] = []
  for (const match of text.matchAll(after))
    out.push(match[0])
  return out
}

export function count(text: string): number {
  let n = 0
  for (let i = 0; i < text.length; i++) {
    if (text[i] === ' ')
      n++
  }
  return n
}