diff options
author | Sebastian <sebasjm@gmail.com> | 2021-07-07 13:28:02 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2021-07-07 13:28:10 -0300 |
commit | ebfc79756f14b08ac3735b2746ac48fd3483b5e4 (patch) | |
tree | 2937c7377b9620088d660aebcb4e2974fb646880 /packages/taler-util | |
parent | ff09c98f3b0515dd92dc5f9bab887336b080b4f5 (diff) | |
download | wallet-core-ebfc79756f14b08ac3735b2746ac48fd3483b5e4.tar.xz |
add providers filter to runBackupCycle
Diffstat (limited to 'packages/taler-util')
-rw-r--r-- | packages/taler-util/src/helpers.ts | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/taler-util/src/helpers.ts b/packages/taler-util/src/helpers.ts index 53a9a43d4..089602c9d 100644 --- a/packages/taler-util/src/helpers.ts +++ b/packages/taler-util/src/helpers.ts @@ -110,3 +110,18 @@ export function strcmp(s1: string, s2: string): number { export function j2s(x: any): string { return JSON.stringify(x, undefined, 2); } + +/** + * Use this to filter null or undefined from an array in a type-safe fashion + * + * example: + * const array: Array<T | undefined> = [undefined, null] + * const filtered: Array<T> = array.filter(notEmpty) + * + * @param value + * @returns + */ +export function notEmpty<T>(value: T | null | undefined): value is T { + return value !== null && value !== undefined; +} + |