mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
24 lines
686 B
TypeScript
24 lines
686 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
// This module is browser compatible.
|
|
|
|
import { capitalizeWord, splitToWords } from "./_util.ts";
|
|
|
|
/**
|
|
* Converts a string into PascalCase.
|
|
*
|
|
* @example Usage
|
|
* ```ts
|
|
* import { toPascalCase } from "@std/text/to-pascal-case";
|
|
* import { assertEquals } from "@std/assert";
|
|
*
|
|
* assertEquals(toPascalCase("deno is awesome"), "DenoIsAwesome");
|
|
* ```
|
|
*
|
|
* @param input The string that is going to be converted into PascalCase
|
|
* @returns The string as PascalCase
|
|
*/
|
|
export function toPascalCase(input: string): string {
|
|
input = input.trim();
|
|
return splitToWords(input).map(capitalizeWord).join("");
|
|
}
|