mirror of
https://github.com/FunkinCrew/Funkin.git
synced 2024-11-23 16:17:53 -05:00
42d8d55067
* Initial test suite * Fix some build warnings * Implemented working unit tests with coverage * Reduced some warnings * Fix a mac-specific issue * Add 2 additional unit test classes. * Multiple new unit tests * Some fixins * Remove auto-generated file * WIP on hiding ignored tests * Added list of debug hotkeys * Remove old website * Remove empty file * Add more unit tests * Fix bug where arrows would nudge BF * Fix bug where ctrl/alt would flash capsules * Fixed bug where bf-old easter egg broke * Remove duplicate lines * More test-related stuff * Some code cleanup * Add mocking and a test assets folder * More TESTS! * Update Hmm... * Update artist on Monster * More minor fixes to individual functions * 1.38% unit test coverage! * Even more tests? :O * More unit test work * Rework migration for BaseRegistry * gameover fix * Fix an issue with Lime * Fix issues with version parsing on data files * 100 total unit tests! * Added even MORE unit tests! * Additional test tweaks :3 * Fixed tests on windows by updating libraries. * Set versions for flixel-ui and hamcrest --------- Co-authored-by: Cameron Taylor <cameron.taylor.ninja@gmail.com>
62 lines
1.6 KiB
Haxe
62 lines
1.6 KiB
Haxe
package funkin.util.tools;
|
|
|
|
/**
|
|
* A static extension which provides utility functions for Strings.
|
|
*/
|
|
class StringTools
|
|
{
|
|
/**
|
|
* Converts a string to title case. For example, "hello world" becomes "Hello World".
|
|
*
|
|
* @param value The string to convert.
|
|
* @return The converted string.
|
|
*/
|
|
public static function toTitleCase(value:String):String
|
|
{
|
|
var words:Array<String> = value.split(" ");
|
|
var result:String = "";
|
|
for (i in 0...words.length)
|
|
{
|
|
var word:String = words[i];
|
|
result += word.charAt(0).toUpperCase() + word.substr(1).toLowerCase();
|
|
if (i < words.length - 1)
|
|
{
|
|
result += " ";
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
/**
|
|
* Converts a string to lower kebab case. For example, "Hello World" becomes "hello-world".
|
|
*
|
|
* @param value The string to convert.
|
|
* @return The converted string.
|
|
*/
|
|
public static function toLowerKebabCase(value:String):String
|
|
{
|
|
return value.toLowerCase().replace(' ', "-");
|
|
}
|
|
|
|
/**
|
|
* Converts a string to upper kebab case, aka screaming kebab case. For example, "Hello World" becomes "HELLO-WORLD".
|
|
*
|
|
* @param value The string to convert.
|
|
* @return The converted string.
|
|
*/
|
|
public static function toUpperKebabCase(value:String):String
|
|
{
|
|
return value.toUpperCase().replace(' ', "-");
|
|
}
|
|
|
|
/**
|
|
* Parses the string data as JSON and returns the resulting object.
|
|
* This is here so you can use `string.parseJSON()` when `using StringTools`.
|
|
*
|
|
* @return The parsed object.
|
|
*/
|
|
public static function parseJSON(value:String):Dynamic
|
|
{
|
|
return SerializerUtil.fromJSON(value);
|
|
}
|
|
}
|