UNPKG

@spree/storefront-api-v2-sdk

Version:

Node module to easily integrate your JavaScript or TypeScript application with Spree API V2. You can create an entirely custom Storefront in JS/TS with this package including one page checkout, Single Page Apps, PWAs and so on

29 lines (25 loc) 618 B
import { Result } from '../interfaces/Result' const makeSuccess = (value: any) => { return { isSuccess: () => true, isFail: () => false, success: () => value, fail: () => { throw new Error('Cannot call fail() on success.') } } } const makeFail = (value: any) => { return { isSuccess: () => false, isFail: () => true, success: () => { throw new Error('Cannot call success() on fail.') }, fail: () => value } } export default { success: <F, S>(value: any): Result<F, S> => makeSuccess(value), fail: <F, S>(value: any): Result<F, S> => makeFail(value) }