@oazmi/kitchensink - v0.9.13
    Preparing search index...

    Function convertCase

    • converts a string token from one case type to another, by performing a composition operation of tokenToWords and wordsToToken.

      Parameters

      Returns string

      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, "-"]

      eq(convertCase(
      snakeCase, screamingSnakeCase,
      "convert_windows_path_to_unix",
      ), "CONVERT_WINDOWS_PATH_TO_UNIX")

      eq(convertCase(
      kebabCase, camelCase,
      "convert-windows-path-to-unix",
      ), "convertWindowsPathToUnix")

      eq(convertCase(
      camelCase, kebabCase,
      "convertWindowsPathToUnix",
      ), "convert-windows-path-to-unix")

      eq(convertCase(
      kebabCase, kebabCase,
      "convert-windows-path-to-unix",
      ), "convert-windows-path-to-unix")

      eq(convertCase(
      screamingKebabCase, pascalCase,
      "CONVERT-WINDOWS-PATH-TO-UNIX",
      ), "ConvertWindowsPathToUnix")