|
@@ -49,4 +49,19 @@ export function DeepClone(value: any): any {
|
|
|
*/
|
|
|
export function ExtractNumbers(str: string): number[] {
|
|
|
return str.split(/[^\-0-9]/).filter((n) => n.length).map((n) => Number(n));
|
|
|
+}
|
|
|
+
|
|
|
+/**
|
|
|
+ * Check if an array only contains one unique value
|
|
|
+ *
|
|
|
+ * @see https://stackoverflow.com/a/14438954/2708601
|
|
|
+ * @param arr An array of any type
|
|
|
+ * @returns Whether the array only contains duplicates or not
|
|
|
+ */
|
|
|
+export function ArrayIsOnlyDuplicates(arr: Array<any>): boolean {
|
|
|
+ if (arr.length === 1) { return true; }
|
|
|
+
|
|
|
+ return arr.filter((val, idx, array) => {
|
|
|
+ return array.indexOf(val) === idx;
|
|
|
+ }).length == 1;
|
|
|
}
|