/**
 * Copyright (c) 2016-present, Facebook, Inc.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */ export function match < T , U > ( just , nothing , maybe ) { if ( maybe == null ) { return nothing ( ) ; } else { return just ( maybe ) ; } } export function catMaybes < T > ( maybes ) { return maybes . reduce ( ( soFar , thisVal ) => { return match ( function ( val ) { return soFar . concat ( val ) ; } , function ( ) { return soFar ; } , thisVal ) ; } , [ ] as T [ ] ) ; } export function map < T , U > ( f , maybe ) { return match ( f , ( ) => null , maybe ) ; } export function mbind < T , U > ( f , maybe ) { return match ( f , ( ) => null , maybe ) ; } export function and < A , B > ( a , b ) { if ( a == null ) { return null ; } else if ( b == null ) { return null ; } else { return [ a , b ] ; } } export function or < T > ( a , b ) { return match ( ( aValue ) => aValue , ( ) => b , a ) ; }