freddi301/flow-validator

View on GitHub
src/async/asyncIntersection.js

Summary

Maintainability
A
0 mins
Test Coverage
// @flow

import { AsyncType, AsyncIntersectionType } from "./AsyncType";

export function asyncIntersection<A, B>(
  a: AsyncType<A>,
  b: AsyncType<B>
): AsyncIntersectionType<A, B> {
  return new AsyncIntersectionType(a, b, async v => {
    await a.parse(v);
    await b.parse(v); // TODO: which one to take? how to merge
    return ((v: any): A & B); // eslint-disable-line flowtype/no-weak-types
  });
}