1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-06-10 10:23:12 +00:00

Added some utility functions

This commit is contained in:
EliteMasterEric 2023-05-30 16:21:24 -04:00
parent 6412cb3aee
commit 121fc13153
2 changed files with 34 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package funkin.util; package funkin.util;
import haxe.Json; import haxe.Json;
import haxe.io.Bytes;
import thx.semver.Version; import thx.semver.Version;
typedef ScoreInput = typedef ScoreInput =
@ -38,6 +39,14 @@ class SerializerUtil
return Json.parse(input); return Json.parse(input);
} }
/**
* Convert a JSON byte array to a Haxe object.
*/
public static function fromJSONBytes(input:Bytes):Dynamic
{
return Json.parse(input.toString());
}
/** /**
* Customize how certain types are serialized when converting to JSON. * Customize how certain types are serialized when converting to JSON.
*/ */

View file

@ -0,0 +1,25 @@
package funkin.util.tools;
/**
* A static extension which provides utility functions for Arrays.
*/
class ArrayTools
{
/**
* Returns a copy of the array with all duplicate elements removed.
* @param array The array to remove duplicates from.
* @return A copy of the array with all duplicate elements removed.
*/
public static function unique<T>(array:Array<T>):Array<T>
{
var result:Array<T> = [];
for (element in array)
{
if (!result.contains(element))
{
result.push(element);
}
}
return result;
}
}