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

Add TitleCase and Titleize #303

Closed
wants to merge 4 commits into from
Closed

Conversation

grumpyTofu
Copy link

#299 TitleCase


Adds TitleCase and Titleize types:

  • typeOfAnimal -> Type of Animal (Title Case APA Compliant)
  • typeOfAnimal -> Type Of Animal (Titleize)

@grumpyTofu
Copy link
Author

@sindresorhus

@sindresorhus
Copy link
Owner

It's cool that you managed to implement APA style titleization, but are there any realistic use-cases for that? The contention in the issue was really the naming, not whether or not to add APA style titleization.

@grumpyTofu
Copy link
Author

@sindresorhus I think the use case is the same. It will be for data display. I would think it would depend on the data you are displaying. For example, if you had book titles as keys in a hashmap structure in any of the other types of casing, you could type the conversion back to APA format. Otherwise the first one would work fine. I did also make the Title Case option extendable so, it could be configured to skip certain words if desired.

Either way, just let me know if you like it, or would like something changed and I can make the changes.

@sindresorhus
Copy link
Owner

Since there's no standard for title case, if we decide to keep it, it should be named TitleCaseAPA or something similar.

@sindresorhus
Copy link
Owner

So it seems like a common naming for the case when you uppercase the first characters in each word is commonly known as "StartCase", "CapitalizedCase", or "Capitalize".

https://en.wikipedia.org/wiki/Letter_case#Stylistic_or_specialised_usage

@sindresorhus
Copy link
Owner

@voxpelli @jonahsnider Any opinions whether to keep TitleCaseAPA and what to call the other simple capitalize case type?

@voxpelli
Copy link
Collaborator

voxpelli commented Nov 24, 2021

@sindresorhus I'm myself getting a bit hesitant in adding too many of these capitalization helpers to type-fest, at some point it becomes the dominant part of this project and then would maybe be better as part of some kind of type-capitalization project?

Especially exotic ones like TitleCaseAPA I would rather like to see outside of this project.

We have Camel, Kebab, Pascal and Snake – those are the four most common – and we have two additional helpers for each, Properties and PropertiesDeep, + we have the general helper Delimiter which can be used to easily construct even more types of helpers locally in a project.

Especially when seeing the complexity that some of these add, like eg. #326

@sindresorhus
Copy link
Owner

After thinking about this for a while, I agree, it's a bit obscure. I have often needed camel-case conversion, etc. But never title case. I recommend publishing this as a separate package and I'd be happy to link to it from the type-fest readme ;)

@aglemann
Copy link

aglemann commented Mar 22, 2022

fwiw this is useful to type the output of lodash's startCase.. common use-case is mapping enum values to more friendly representation..

nvm, looking at the code this is different than startCase (which is just PascalCase with spaces between words)

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

Successfully merging this pull request may close these issues.

4 participants