Function tokenize

  • Tokenizes a string into an array of tokens.

    Parameters

    • string: string

      The string to tokenize.

    • wordDiff: boolean = false

      If true, performs word-based tokenization. Default is false.

    Returns string[]

    An array of tokens.

    import { tokenize } from "@std/internal/diff-str";
    import { assertEquals } from "@std/assert";

    assertEquals(tokenize("Hello\nWorld"), ["Hello\n", "World"]);