"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
Object.defineProperty(exports, "funcInterceptor", {
    enumerable: true,
    get: function() {
        return funcInterceptor;
    }
});
var _index = require("./index");
var funcInterceptor = function funcInterceptor(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 ((0, _index.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();
    }
};
