Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@agape/string",
"version": "2.2.5",
"version": "2.2.6",
"description": "String and token manipulation",
"main": "./cjs/index.js",
"module": "./es2020/index.js",
Expand Down
7 changes: 5 additions & 2 deletions src/lib/functions/camelize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@
* Converts a string to camelCase.
* Removes all non-alphanumeric separators and capitalizes each word except the first.
*
* ## Usage
*
* @example
* ```ts
* camelize("hello world"); // "helloWorld"
* ```
*
* @example
* ```ts
* camelize("Hello_world"); // "helloWorld"
* ```
*
* @example
* ```ts
* camelize("API_response_code"); // "apiResponseCode"
* ```
*
* @example
* ```ts
* camelize("user-42-profile"); // "user42Profile"
* ```
*
* @example
* ```ts
* camelize("ThisIsALongVariableName"); // "thisIsALongVariableName"
* ```
Expand Down
8 changes: 6 additions & 2 deletions src/lib/functions/kebabify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,32 @@ import { PLACEHOLDER } from "../private/constants";
* Replaces spaces, underscores, camelCase transitions, and other separators with dashes.
* It also preserves version tokens like "v2" and lowercases the result.
*
* ## Usage
*
* @example
* ```ts
* kebabify("hello world"); // "hello-world"
* ```
*
* @example
* ```ts
* kebabify("first_name"); // "first-name"
* ```
*
* @example
* ```ts
* kebabify("userProfile42"); // "user-profile-42"
* ```
*
* @example
* ```ts
* kebabify("APIResponseV2"); // "api-response-v2"
* ```
*
* @example
* ```ts
* kebabify("HTML5_Parser v3"); // "html-5-parser-v3"
* ```
*
* @example
* ```ts
* kebabify(" Leading_and trailing "); // "leading-and-trailing"
* ```
Expand Down
7 changes: 5 additions & 2 deletions src/lib/functions/pascalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@
* Removes non-alphanumeric characters, splits on casing and digits,
* capitalizes each word, and strips leading/trailing separators.
*
* ## Usage
*
* @example
* ```ts
* pascalize("hello world"); // "HelloWorld"
* ```
*
* @example
* ```ts
* pascalize("first_name"); // "FirstName"
* ```
*
* @example
* ```ts
* pascalize("user42Profile"); // "User42Profile"
* ```
*
* @example
* ```ts
* pascalize("API response code"); // "ApiResponseCode"
* ```
*
* @example
* ```ts
* pascalize(" messy__input--string "); // "MessyInputString"
* ```
Expand Down
13 changes: 11 additions & 2 deletions src/lib/functions/pluralize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,48 +11,57 @@ import { preserveCasing } from '../private/util';
*
* The output preserves the casing of the input, especially the prefix.
*
* ## Usage
*
* @example
* ```ts
* pluralize("city"); // "cities"
* ```
*
* @example
* ```ts
* pluralize("box"); // "boxes"
* ```
*
* @example
* ```ts
* pluralize("child"); // "children"
* ```
*
* @example
* ```ts
* pluralize("person"); // "people"
* ```
*
* @example
* ```ts
* pluralize("API"); // "APIs"
* ```
*
* @example
* ```ts
* pluralize("ID"); // "IDs"
* ```
*
* @example
* ```ts
* pluralize("File"); // "Files"
* ```
*
* @example
* ```ts
* pluralize("buzz"); // "buzzes"
* ```
*
* @example
* ```ts
* pluralize("CPU"); // "CPUs"
* ```
*
* @example
* ```ts
* pluralize("DOG"); // "DOGS"
* ```
*
* @example
* ```ts
* pluralize("A"); // "As"
* ```
Expand Down
8 changes: 6 additions & 2 deletions src/lib/functions/quantify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,32 @@ import { pluralize } from './pluralize';
* <code><reference>pluralize</reference>(<property>unit</property>)</code>
* to generate one.
*
* ## Usage
*
* @example
* ```ts
* quantify(1, "apple"); // "1 apple"
* ```
*
* @example
* ```ts
* quantify(3, "apple"); // "3 apples"
* ```
*
* @example
* ```ts
* quantify("02", "box"); // "02 boxes"
* ```
*
* @example
* ```ts
* quantify(1, "child", "children"); // "1 child"
* ```
*
* @example
* ```ts
* quantify(2, "child", "children"); // "2 children"
* ```
*
* @example
* ```ts
* quantify(5, "CPU"); // "5 CPUs"
* ```
Expand Down
9 changes: 7 additions & 2 deletions src/lib/functions/singularize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,37 @@ import { preserveCasing } from '../private/util';
*
* Preserves the casing of the original input, including acronyms or title case.
*
* ## Usage
*
* @example
* ```ts
* singularize("cities"); // "city"
* ```
*
* @example
* ```ts
* singularize("boxes"); // "box"
* ```
*
* @example
* ```ts
* singularize("children"); // "child"
* ```
*
* @example
* ```ts
* singularize("teeth"); // "tooth"
* ```
*
* @example
* ```ts
* singularize("dogs"); // "dog"
* ```
*
* @example
* ```ts
* singularize("BUZZES"); // "BUZZ"
* ```
*
* @example
* ```ts
* singularize("IDs"); // "ID"
* ```
Expand Down
7 changes: 5 additions & 2 deletions src/lib/functions/snakify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,27 @@ import { PLACEHOLDER } from '../private/constants';
* removes special characters, preserves embedded version tokens (like "v2"),
* and lowercases the result.
*
* ## Usage
*
* @example
* ```ts
* snakify("hello world"); // "hello_world"
* ```
*
* @example
* ```ts
* snakify("UserProfileV2"); // "user_profile_v2"
* ```
*
* @example
* ```ts
* snakify("HTML5 Parser"); // "html_5_parser"
* ```
*
* @example
* ```ts
* snakify(" messy-input_string "); // "messy_input_string"
* ```
*
* @example
* ```ts
* snakify("ReportV3Final"); // "report_v3_final"
* ```
Expand Down
7 changes: 5 additions & 2 deletions src/lib/functions/titalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,27 @@
* (like "of", "and", "the") unless they appear at the beginning.
* Preserves words already containing uppercase letters (e.g., acronyms).
*
* ## Usage
*
* @example
* ```ts
* titalize("the quick brown fox"); // "The Quick Brown Fox"
* ```
*
* @example
* ```ts
* titalize("a tale of two cities"); // "A Tale of Two Cities"
* ```
*
* @example
* ```ts
* titalize("in the heart of the sea"); // "In the Heart of the Sea"
* ```
*
* @example
* ```ts
* titalize("API reference guide"); // "API Reference Guide"
* ```
*
* @example
* ```ts
* titalize(" war and peace "); // "War and Peace"
* ```
Expand Down
8 changes: 6 additions & 2 deletions src/lib/functions/verbalize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,32 @@ import { PLACEHOLDER } from '../private/constants';
* identifiers into space-separated words. Capitalizes the first word, and
* preserves acronyms and version tokens (e.g., `v2`, `v3.1`).
*
* ## Usage
*
* @example
* ```ts
* verbalize("helloWorld"); // "Hello world"
* ```
*
* @example
* ```ts
* verbalize("HTML5Parser"); // "HTML 5 parser"
* ```
*
* @example
* ```ts
* verbalize("api_v2_response"); // "Api v2 response"
* ```
*
* @example
* ```ts
* verbalize("User-ID"); // "User ID"
* ```
*
* @example
* ```ts
* verbalize("employeeV3Final"); // "Employee v3 final"
* ```
*
* @example
* ```ts
* verbalize("version_2_0_release"); // "Version 2 0 release"
* ```
Expand Down