deno_std icon indicating copy to clipboard operation
deno_std copied to clipboard

feat(fmt/case): Add casing helpers

Open Gustrb opened this issue 2 years ago • 5 comments

This PR implements a few casing helpers, as were asked in the issue #3125 It adds a few helpers methods such as:

  • toPascalCase
  • toCamelCase
  • toSnakeCase
  • toScreamingSnakeCase
  • toKebabCase
  • toTitleCase

Any suggestions on more methods would be appreciated, I've just implemented the ones I could find any use for

Gustrb avatar Jun 09 '23 23:06 Gustrb

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jun 09 '23 23:06 CLAassistant

Title case maybe?

aapoalas avatar Jun 10 '23 04:06 aapoalas

I think it would make more sense to have an implementation that doesn't just split by whitespaces but also other separators and by words so a case can be applied to another like in lodash. Example:

toKebabCase('Foo Bar') // => 'foo-bar'
toKebabCase('fooBar') // => 'foo-bar'
toKebabCase('__FOO_BAR__') // => 'foo-bar'

timreichen avatar Jun 10 '23 05:06 timreichen

@timreichen true, it would make a lot more sense, I'll take a look at their implementation then :)

Gustrb avatar Jun 10 '23 08:06 Gustrb

toSentenceCase

guy-borderless avatar Aug 17 '23 19:08 guy-borderless

Closing this in favour of #4082, which continues the work started here. Thank you for your contribution, @Gustrb!

iuioiua avatar Jan 05 '24 02:01 iuioiua