From e5fa551dbc800959676e270acd87ca4ec93d0b83 Mon Sep 17 00:00:00 2001 From: Rafael Wendel <44540213+rafawendel@users.noreply.github.com> Date: Fri, 21 Jun 2024 17:40:44 -0300 Subject: [PATCH] feat(capitalize): make types for capitalize infer format for constant strings --- package.json | 2 +- src/string.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 0f7a54c7..8e991847 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "radash", - "version": "12.1.0", + "version": "12.1.1", "description": "Functional utility library - modern, simple, typed, powerful", "main": "dist/cjs/index.cjs", "module": "dist/esm/index.mjs", diff --git a/src/string.ts b/src/string.ts index 40de090d..5dfcc54c 100644 --- a/src/string.ts +++ b/src/string.ts @@ -4,10 +4,11 @@ * capitalize('hello') -> 'Hello' * capitalize('va va voom') -> 'Va va voom' */ -export const capitalize = (str: string): string => { - if (!str || str.length === 0) return '' +export const capitalize = (str: Str): Capitalize => { + if (!str || str.length === 0) return '' as Capitalize const lower = str.toLowerCase() - return lower.substring(0, 1).toUpperCase() + lower.substring(1, lower.length) + return (lower.substring(0, 1).toUpperCase() + + lower.substring(1, lower.length)) as Capitalize } /**