"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) {
        const f = unit[method];
        if (typeof f === 'function') {
            try {
                const _return = f.call(unit, ...args);
                done({ return: _return });
            }
            catch (err) {
                done(undefined, err.message);
            }
        }
        else {
            done(undefined, 'invalid method');
        }
    }
}
exports.default = Exec;
//# sourceMappingURL=index.js.map