import { curry } from '@typed/lambda' ; import { hasNoData } from './hasNoData' ; import { isFailure } from './isFailure' ; import { isLoading } from './isLoading' ; import { isRefreshingFailure } from './isRefreshingFailure' ; import { isRefreshingSuccess } from './isRefreshingSuccess' ; import { RemoteData } from './RemoteData' ; export const unpack = curry ( __unpackRemoteData ) ; function __unpackRemoteData < A , B , C > ( noData , loading , failure , success , remoteData ) { if ( hasNoData ( remoteData ) ) { return noData ( ) ; } if ( isLoading ( remoteData ) ) { return loading ( ) ; } if ( isFailure ( remoteData ) ) { return failure ( remoteData . value , false ) ; } if ( isRefreshingFailure ( remoteData ) ) { return failure ( remoteData . value , true ) ; } return success ( remoteData . value , isRefreshingSuccess ( remoteData ) ) ; }