Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reverse camelcase? #58

Open
jsodeman opened this issue May 7, 2021 · 1 comment
Open

Reverse camelcase? #58

jsodeman opened this issue May 7, 2021 · 1 comment

Comments

@jsodeman
Copy link

jsodeman commented May 7, 2021

I like Voca better than the alternatives, but I can't see how you would convert camelcase into words. In other libs it's called .humanize

For example:

"camelCase" -> "camel case"

@darthf1
Copy link

darthf1 commented Sep 10, 2021

Looking for the same. Found a solution on https://zellwk.com/blog/case-conversion/, first convert the string to kebabCase via voca, then applying the presented solution.

import { kebabCase } from 'voca'

const humanize = (string: string) => {
  const interim = kebabCase(string).replace(/-/g, ' ')

  return interim.slice(0, 1).toUpperCase() + interim.slice(1)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants