(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports"], factory);
    }
})(function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.AtomDisposableList = void 0;
    class AtomDisposableList {
        constructor() {
            // tslint:disable-next-line:ban-types
            this.disposables = [];
        }
        // tslint:disable-next-line:ban-types
        add(d) {
            if (typeof d === "function") {
                const fx = d;
                d = {
                    dispose: fx
                };
            }
            this.disposables.push(d);
            const dx = d;
            return {
                dispose: () => {
                    this.disposables = this.disposables.filter((x) => x !== dx);
                    dx.dispose();
                }
            };
        }
        dispose() {
            for (const iterator of this.disposables) {
                iterator.dispose();
            }
            this.disposables.length = 0;
        }
    }
    exports.AtomDisposableList = AtomDisposableList;
});
//# sourceMappingURL=AtomDisposableList.js.map