on master help sign in
bridge/src/lib/maybeGetResult.ts
12 lines 295 B history raw
1//@ts-nocheck
2import { get } from 'lodash';
4export const maybeGetResult = (obj, key, defaultValue) =>
5 obj.matchWith({
6 Nothing: () => defaultValue,
7 Just: p =>
8 p.value.matchWith({
9 Ok: r => get(r.value, key, defaultValue),
10 Error: e => defaultValue,
11 }),
12 });