fix: 💡 add comments in use-string hook with some examples

This commit is contained in:
Alexis Gousseau 2026-02-05 11:19:08 +01:00
parent 526890ddf9
commit fd56f22068

View file

@ -2,20 +2,110 @@ import slugify from "slugify";
import pluralize, { singular } from "pluralize";
interface Stringable {
/**
* Trim a word based.
* Examples:
* - "...Some.$.in.the.GARDEN !..." -> Some $ in the GARDEN !
*
* @return Stringable
*/
trim: () => Stringable;
/**
* Slugify a word based.
* Examples:
* - Some $ in the GARDEN ! -> some-dollar-in-the-garden
*
* @return Stringable
*/
slug: () => Stringable;
/**
* Pascal case a word based.
* Examples:
* - some $ in the GARDEN ! -> Some $ in the GARDEN !
*
* @return Stringable
*/
ucFirst: () => Stringable;
/**
* Pascal case a word based.
* Examples:
* - Some $ in the GARDEN ! -> some$InTheGarden!
*
* @return Stringable
*/
camelCase: () => Stringable;
/**
* Pascal case a word based.
* Examples:
* - some $ in the GARDEN ! -> Some$InTheGarden!
*
* @return Stringable
*/
pascalCase: () => Stringable;
/**
* Kebab case a word based.
* Examples:
* - Some $ in the GARDEN ! -> some-$-in-the-garden-!
*
* @return Stringable
*/
kebabCase: () => Stringable;
/**
* Snake case a word based.
* Examples:
* - Some $ in the GARDEN ! -> some_$_in_the_garden_!
*
* @return Stringable
*/
snakeCase: () => Stringable;
/**
* Upper case a word based.
* Examples:
* - Some $ in the GARDEN ! -> SOME $ IN THE GARDEN !
*
* @return Stringable
*/
upperCase: () => Stringable;
/**
* Lower case a word based.
* Examples:
* - Some $ in the GARDEN ! -> some $ in the garden !
*
* @return Stringable
*/
lowerCase: () => Stringable;
/**
* Pluralize a word based.
* Examples:
* - word -> words
* - story -> stories
*
* @return Stringable
*/
plural: () => Stringable;
/**
* Singularize a word based.
* Examples:
* - words -> word
* - stories -> story
*
* @return Stringable
*/
singular: () => Stringable;
/**
* Return the transformated string.
*
* @return string
*/
value: () => string;
}
/**
* Get a Stringable object.
*
* @param string initialValue
* @return Stringable
*/
const str = (initialValue: string): Stringable => {
let value = initialValue;