aboutsummaryrefslogtreecommitdiff
path: root/src/helpers.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/helpers.ts')
-rw-r--r--src/helpers.ts8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/helpers.ts b/src/helpers.ts
index e5eb40211..eff5fa731 100644
--- a/src/helpers.ts
+++ b/src/helpers.ts
@@ -83,6 +83,10 @@ export function canonicalJson(obj: any): string {
}
+/**
+ * Check for deep equality of two objects.
+ * Only arrays, objects and primitives are supported.
+ */
export function deepEquals(x: any, y: any): boolean {
if (x === y) {
return true;
@@ -98,6 +102,10 @@ export function deepEquals(x: any, y: any): boolean {
}
+/**
+ * Map from a collection to a list or results and then
+ * concatenate the results.
+ */
export function flatMap<T, U>(xs: T[], f: (x: T) => U[]): U[] {
return xs.reduce((acc: U[], next: T) => [...f(next), ...acc], []);
}