"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Functional_1 = require("../../../../Class/Functional");
const _ids_1 = require("../../../_ids");
class Timer extends Functional_1.Functional {
    constructor(system) {
        super({
            i: ['ms'],
            o: ['ms'],
        }, {}, system, _ids_1.ID_TIMER);
        this._timer = null;
        this.addListener('reset', this._reset);
        this.addListener('destroy', this._reset);
    }
    _reset() {
        if (this._timer !== null) {
            clearTimeout(this._timer);
            this._timer = null;
        }
    }
    f({ ms }, done) {
        this._reset();
        // @ts-ignore
        this._timer = setTimeout(() => {
            this._timer = null;
            done({ ms });
        }, ms);
    }
}
exports.default = Timer;
//# sourceMappingURL=index.js.map