"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../Class/Functional");
const _ids_1 = require("../../../_ids");
class Exec extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['unit', 'method', 'args'],
            o: ['return'],
        }, {
            input: {
                unit: {
                    ref: true,
                },
            },
        }, system, _ids_1.ID_EXEC);
    }
    f({ unit, method, args }, done, fail) {
        const f = unit[method];
        let _return;
        if (typeof f === 'function') {
            try {
                _return = f.call(unit, ...args);
            }
            catch (err) {
                fail(err.message);
                return;
            }
        }
        else {
            fail('invalid method');
            return;
        }
        done({ return: _return });
    }
}
exports.default = Exec;
//# sourceMappingURL=index.js.map