@web3r/flowerkit
Version:
Tree-shakable JavaScript and TypeScript utility library for frontend/browser apps: DOM, events, arrays, objects, strings, date, JSON, and network helpers (ESM/CJS, SSR-friendly).
1 lines • 1.22 kB
Source Map (JSON)
{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["export type TGetStrWithCapitalizedArgs = Parameters<typeof getStrWithCapitalized>;\r\n\r\nexport type TGetStrWithCapitalizedReturn = ReturnType<typeof getStrWithCapitalized>;\r\n\r\n/**\r\n * Gets a string with uppercase first letter\r\n * @param str{string} source string\r\n * @returns {string} String with first character uppercased\r\n * @throws {TypeError} If str is not a string\r\n * @example\r\n * getStrWithCapitalized(\"hello world\"); // \"Hello world\"\r\n */\r\nexport const getStrWithCapitalized = (str: string): string => {\r\n if (typeof str !== \"string\") {\r\n throw new TypeError(\"getStrWithCapitalized: str must be a string\");\r\n }\r\n if (!str.length) {\r\n return \"\";\r\n }\r\n const trimmed = str.trim();\r\n if (!trimmed) {\r\n return \"\";\r\n }\r\n return trimmed[0].toUpperCase() + trimmed.slice(1);\r\n};\r\n"],"names":["getStrWithCapitalized","str","TypeError","length","trimmed","trim","toUpperCase","slice"],"mappings":";;;;;;;;AAYO,MAAMA,sBAAyBC,MACpC,UAAWA,MAAQ,SACjB,MAAM,IAAIC,UAAU,+CAEtB,IAAKD,IAAIE,OACP,MAAO,GAET,MAAMC,QAAUH,IAAII,OACpB,IAAKD,QACH,MAAO,GAET,OAAOA,QAAQ,GAAGE,cAAgBF,QAAQG,MAAM"}