2.0.0 • Published 5 years ago

@jf/cc2sep v2.0.0

Weekly downloads
24
License
MIT
Repository
github
Last release
5 years ago

@jf/cc2sep stable

npm install @jf/cc2sep

Transform a camelized string into a lowercased one using a custom separator and accepting unicode uppercase chars.

You can modify regexp property for customizing the text transformations in your application.

Arguments

  • text: Text to convert.
  • separator: Separator to use between words (- by defatul).
  • trim: true if you want to remove separators beginning or ending text (true by default).

Examples

cc2sep(text)

'onceuponatime'    => 'onceuponatime'
'onceUponATime'    => 'once-upon-a-time'
'OnceUponATime'    => 'once-upon-a-time'
'ONCE UPON A TIME' => 'o-n-c-e u-p-o-n a t-i-m-e'
'once-upon-a-time' => 'once-upon-a-time'
'innerHTML'        => 'inner-h-t-m-l'
'ÁáááÉéééÍíÓóó'    => 'áááá-éééé-íí-óóó'

cc2sep(text, '-', false)

'OnceUponATime'    -> '-once-upon-a-time'
'ONCE UPON A TIME' -> '-o-n-c-e -u-p-o-n -a -t-i-m-e'
'ÁáááÉéééÍíÓóó'    -> '-áááá-éééé-íí-óóó'