A TypeScript library for word case conversions, using Template Literal Types(TS >= 4.1).
# NPM
npm install literal-case
# YARN
yarn add literal-case
const str: "fooBar" = camelCase("foo bar");
const str: "FooBar" = pascalCase("foo bar");
const str: "foo_bar" = snakeCase("foo bar");
const str: "FOO_BAR" = constantCase("foo bar");
const str: "foo-bar" = kebabCase("foo bar");
const str: "foo.bar" = dotCase("foo bar");
const str: "foo Bar" = noCase("fooBar");
// Expect: "fooBar"
type Result = CamelCase<"foo bar">;
// Expect: "FooBar"
type Result = PascalCase<"foo bar">;
// Expect: "foo_bar"
type Result = SnakeCase<"foo bar">;
// Expect: "FOO_BAR"
type Result = ConstantCase<"foo bar">;
// Expect: "foo-bar"
type Result = KebabCase<"foo bar">;
// Expect: "foo.bar"
type Result = DotCase<"foo bar">;
// Expect: "foo Bar"
type Result0 = NoCase<"fooBar">;
// Expect: "foo,Bar"
type Result1 = NoCase<"fooBar", ",">;
Distributed under the MIT License. See LICENSE
for more information.
Madono - @MadonoHaru - madonoharu@gmail.com
Project Link: https://github.com/MadonoHaru/literal-case.git