Skip to content

Conversation

@thibaultzanini
Copy link
Collaborator

@thibaultzanini thibaultzanini commented Aug 14, 2025

Adds a toKebabCase() method to the String prototype for converting strings to kebab-case format.

Usage:

"Hello World".toKebabCase();     // "hello-world"

@thibaultzanini thibaultzanini self-assigned this Aug 14, 2025
@thibaultzanini thibaultzanini added the enhancement New feature or request label Aug 14, 2025
@thibaultzanini thibaultzanini changed the title feat: added toKebabCase method on String prototype Adds a toKebabCase() method to the String prototype Aug 14, 2025
Copy link
Contributor

@marchant marchant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have logic for that we should use

* @example
* "Hello World".toKebabCase(); // "hello-world"
*/
Object.defineProperty(String.prototype, "toKebabCase", {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a KebabCaseConverter that uses an external dependency ( https://www.npmjs.com/package/just-kebab-case ) that is now at 4.2.0 vs
"just-kebab-case": "^4.0.1",
in mod's package.json.

The code us here:
https://github.com/angus-c/just/blob/master/packages/string-kebab-case/index.cjs

which seems a bit more complete than what you have here. I've known of Angus Croll the author for a while, it might take sense to keep those kind of low level dependencies.

In term of pattern, the method from this package is effectively a converter in mod's terms. So it would make sense to limit the dependencies for String to use Mod's KebabCaseConverter as the core logic, and if for some reason we decide to inline the code and remove the dependency, the the String's toKebabCase() method wouldn't need to change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants