import { isPromise } from "./index";
export var funcInterceptor = function(interceptor, param) {
    var _param_args = param.args, args = _param_args === void 0 ? [] : _param_args, done = param.done, canceled = param.canceled;
    if (interceptor) {
        // eslint-disable-next-line prefer-spread
        var returnVal = interceptor.apply(null, args);
        if (isPromise(returnVal)) {
            returnVal.then(function(value) {
                if (value) {
                    done(value);
                } else if (canceled) {
                    canceled();
                }
            }).catch(function() {});
        } else if (returnVal) {
            done();
        } else if (canceled) {
            canceled();
        }
    } else {
        done();
    }
};
