@@ -2,6 +2,7 @@ | |||||
* The MIT License (MIT) | * The MIT License (MIT) | ||||
* | * | ||||
* Copyright (c) 2015 Ian Coleman | * Copyright (c) 2015 Ian Coleman | ||||
* Copyright (c) 2018 Ma_124, <github.com/Ma124> | |||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining a copy | * Permission is hereby granted, free of charge, to any person obtaining a copy | ||||
* of this software and associated documentation files (the "Software"), to deal | * of this software and associated documentation files (the "Software"), to deal | ||||
@@ -57,10 +58,12 @@ func toCamelInitCase(s string, initCase bool) string { | |||||
return n | return n | ||||
} | } | ||||
// Converts a string to CamelCase | |||||
func ToCamel(s string) string { | func ToCamel(s string) string { | ||||
return toCamelInitCase(s, true) | return toCamelInitCase(s, true) | ||||
} | } | ||||
// Converts a string to lowerCamelCase | |||||
func ToLowerCamel(s string) string { | func ToLowerCamel(s string) string { | ||||
if s == "" { | if s == "" { | ||||
return s | return s | ||||
@@ -1,27 +0,0 @@ | |||||
/* | |||||
* The MIT License (MIT) | |||||
* | |||||
* Copyright (c) 2018 Ma_124, <github.com/Ma124> | |||||
* | |||||
* Permission is hereby granted, free of charge, to any person obtaining a copy | |||||
* of this software and associated documentation files (the "Software"), to deal | |||||
* in the Software without restriction, including without limitation the rights | |||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |||||
* copies of the Software, and to permit persons to whom the Software is | |||||
* furnished to do so, Subject to the following conditions: | |||||
* | |||||
* The above copyright notice and this permission notice shall be included in all | |||||
* copies or Substantial portions of the Software. | |||||
* | |||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |||||
* SOFTWARE. | |||||
*/ | |||||
package strcase | |||||
@@ -40,6 +40,16 @@ func ToScreamingSnake(s string) string { | |||||
return ToScreamingDelimited(s, '_', true) | return ToScreamingDelimited(s, '_', true) | ||||
} | } | ||||
// Converts a string to kebab-case | |||||
func ToKebab(s string) string { | |||||
return ToDelimited(s, '-') | |||||
} | |||||
// Converts a string to SCREAMING-KEBAB-CASE | |||||
func ToScreamingKebab(s string) string { | |||||
return ToScreamingDelimited(s, '-', true) | |||||
} | |||||
// Converts a string to delimited.snake.case (in this case `del = '.'`) | // Converts a string to delimited.snake.case (in this case `del = '.'`) | ||||
func ToDelimited(s string, del uint8) string { | func ToDelimited(s string, del uint8) string { | ||||
return ToScreamingDelimited(s, del, false) | return ToScreamingDelimited(s, del, false) | ||||