str-fns
A collection of type-safe string functions written in pure JavaScript + JSDoc.
Why str-fns
- I copy and paste useful functions from my notepad for every project using TypeScript/JavaScript. This library is a library of those functions.
- I need some useful functions to deal with
string
types in my projects. This library is a collection of those functions with type-safety.
Why JavaScript + JSDoc / Why not TypeScript
As Svelte team said, TypeScript is a great tool for library authors, but not for library users.
One of the reasons is that it is hard to jump to the definition of a function when using TypeScript.
I want to make it easy to jump to the definition of a function, so I use JavaScript.
Don't worry, I use JSDoc to make it type-safe.
API
capitalize
- Capitalize the first letter of a string.uncapitalize
- Uncapitalize the first letter of a string.uppercase
- Convert a string to uppercase.lowercase
- Convert a string to lowercase.split
- Split a string into substrings using the specified separator and return them as an array.