API
@agape/string

toWords Function

Returns a string formatted as spoken words.

API

function toWords(  input: string): string

toWords

string

Returns a string formatted as spoken words.

@paraminput:  string
A string to be returned as spoken words.
@returnsstring

Description

Returns a string formatted as spoken words.

Converts camelCase, PascalCase, snake_case, kebab-case, or mixed alphanumeric identifiers into space-separated words. Capitalizes the first word, and preserves acronyms and version tokens (e.g., v2, v3.1).

Usage

toWords("helloWorld"); // "Hello world"
toWords("HTML5Parser"); // "HTML 5 parser"
toWords("api_v2_response"); // "Api v2 response"
toWords("User-ID"); // "User ID"
toWords("employeeV3Final"); // "Employee v3 final"
toWords("version_2_0_release"); // "Version 2 0 release"