breakdown a single token into its constituent words, based on the configuration provided in casetype.

this function performs the inverse operation of wordsToToken, provided that you use the same casetype config.

import { assertEquals as eq } from "jsr:@std/assert"

const
snakeCase: NamingCaseTuple = [-1, -1, -1, "_"],
kebabCase: NamingCaseTuple = [-1, -1, -1, "-"],
camelCase: NamingCaseTuple = [-1, 1, -1, ""],
pascalCase: NamingCaseTuple = [1, 1, -1, ""],
screamingSnakeCase: NamingCaseTuple = [1, 1, 1, "_"],
screamingKebabCase: NamingCaseTuple = [1, 1, 1, "-"]

// the expected list of words that our tokens should breakdown into
const words = ["convert", "windows", "path", "to", "unix"]

eq(tokenToWords(snakeCase, "convert_windows_path_to_unix"), words)
eq(tokenToWords(kebabCase, "convert-windows-path-to-unix"), words)
eq(tokenToWords(camelCase, "convertWindowsPathToUnix"), words)
eq(tokenToWords(pascalCase, "ConvertWindowsPathToUnix"), words)
eq(tokenToWords(screamingSnakeCase, "CONVERT_WINDOWS_PATH_TO_UNIX"), words)
eq(tokenToWords(screamingKebabCase, "CONVERT-WINDOWS-PATH-TO-UNIX"), words)