mirror of
https://github.com/atom/atom.git
synced 2026-02-14 08:35:11 -05:00
Add underscore, camelize and dasherize to underscore
This commit is contained in:
@@ -69,6 +69,25 @@ _.mixin
|
||||
else
|
||||
"#{count} #{plural}"
|
||||
|
||||
camelize: (string) ->
|
||||
string.replace /[_-]+(\w)/g, (m) -> m[1].toUpperCase()
|
||||
|
||||
dasherize: (string) ->
|
||||
string = string[0].toLowerCase() + string[1..]
|
||||
string.replace /([A-Z])|(_)/g, (m, letter, underscore) ->
|
||||
if letter
|
||||
"-" + letter.toLowerCase()
|
||||
else
|
||||
"-"
|
||||
|
||||
underscore: (string) ->
|
||||
string = string[0].toLowerCase() + string[1..]
|
||||
string.replace /([A-Z])|(-)/g, (m, letter, dash) ->
|
||||
if letter
|
||||
"_" + letter.toLowerCase()
|
||||
else
|
||||
"_"
|
||||
|
||||
losslessInvert: (hash) ->
|
||||
inverted = {}
|
||||
for key, value of hash
|
||||
|
||||
Reference in New Issue
Block a user