From 04417c35f9e5d31fef07c8f3760aaccd8c35d4d2 Mon Sep 17 00:00:00 2001 From: Ma_124 Date: Tue, 3 Jul 2018 20:36:59 +0200 Subject: [PATCH] Added doc and kebab --- camel.go | 3 +++ others.go | 27 --------------------------- snake.go | 10 ++++++++++ 3 files changed, 13 insertions(+), 27 deletions(-) delete mode 100644 others.go diff --git a/camel.go b/camel.go index 1a5d778..7c2e2b7 100644 --- a/camel.go +++ b/camel.go @@ -2,6 +2,7 @@ * The MIT License (MIT) * * Copyright (c) 2015 Ian Coleman + * Copyright (c) 2018 Ma_124, * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -57,10 +58,12 @@ func toCamelInitCase(s string, initCase bool) string { return n } +// Converts a string to CamelCase func ToCamel(s string) string { return toCamelInitCase(s, true) } +// Converts a string to lowerCamelCase func ToLowerCamel(s string) string { if s == "" { return s diff --git a/others.go b/others.go deleted file mode 100644 index 6cae65f..0000000 --- a/others.go +++ /dev/null @@ -1,27 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2018 Ma_124, - * - * 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 - - diff --git a/snake.go b/snake.go index 2dd744e..1d2f520 100644 --- a/snake.go +++ b/snake.go @@ -40,6 +40,16 @@ func ToScreamingSnake(s string) string { 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 = '.'`) func ToDelimited(s string, del uint8) string { return ToScreamingDelimited(s, del, false)