UNPKG

typedash

Version:

modern, type-safe collection of utility functions

1 lines 653 B
{"version":3,"sources":["../../src/functions/capitalize/capitalize.ts"],"names":[],"mappings":";AAUO,SAAS,WAA6B,QAA0B;AACrE,SAAO,GAAG,OAAO,OAAO,CAAC,EAAE,YAAY,CAAC,GAAG,OAAO,MAAM,CAAC,CAAC;AAC5D","sourcesContent":["/**\n * Returns a new string with the first character capitalized.\n * @param string The input string to capitalize.\n * @returns A new string with the first character capitalized.\n * @example\n * ```ts\n * capitalize('foo'); // 'Foo'\n * capitalize(''); // ''\n * ```\n */\nexport function capitalize<S extends string>(string: S): Capitalize<S> {\n return `${string.charAt(0).toUpperCase()}${string.slice(1)}` as Capitalize<S>;\n}\n"]}