gr2m / initials

extract initials from and add initials to names
https://gr2m.github.io/initials
MIT License
44 stars 14 forks source link

Initials when passing a single word #49

Closed oyeanuj closed 4 years ago

oyeanuj commented 6 years ago

Hi @gr2m, thank you for open-sourcing this library!

I noticed when I pass in a single word, it returns the first two letters of that name as the initial. That too me felt counter-intuitive, since initials tend to be the first letter from each word. I wonder if the behavior should accomodate for providing just one letter (either by default or as a param) per word - in which case if someone passed in "Github", it would return just "G".

Thoughts?

gr2m commented 6 years ago

The context I created initials for are meeting protocols. From my research folks would always use 2 letters or more. I’d rather not change it but leave the issue open to see if there are more opinions on it.

As a workaround, you can do initials.find('GitHub (G)') to get the single letter G as a custom initial. I know in that case you won’t need to use initials in the first place, but that’s all I got right now.

nikoladev commented 4 years ago

I would also like the possibility to get a single letter for a single name. My use case is that I want to create initials based on first and middle names (without their last name). So if the user only has one first name I would need a one letter initial.

Would it be possible to add an option for minLength?

If not, that's ok. I can fork the project and just change the defaultValue to 1, but it would be nice to be able to officially use this library and any future bug fixes that come with it.

Thanks for the project!

gr2m commented 4 years ago

maybe just get the first letter in the case of just having one name?

nikoladev commented 4 years ago

That would work, I suppose. In the end I just implemented my own small version of this that only works for my use case.

Thanks anyway :)