import { OptionsFunc , CallbackResult } from './types/index' ; export const incrementId = ( ) => { let id = 0 ; return ( ) => ( id ++ ) . toString ( ) ; } ; export function isFunction ( o ) { return typeof o === 'function' ; } export const EMPTY_OBJ = { } ; export const isArray = Array . isArray ; export function successHandler ( success , complete ) { return function ( res ) { success && isFunction ( success ) && success ( res ) ; complete && isFunction ( complete ) && complete ( res ) ; return Promise . resolve ( res ) ; } ; } export function errorHandler ( fail , complete ) { return function ( res ) { fail && isFunction ( fail ) && fail ( res ) ; complete && isFunction ( complete ) && complete ( res ) ; return Promise . reject ( res ) ; } ; }