web-atoms-core
Version:
46 lines • 1.64 kB
JavaScript
(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 });
var AtomDisposableList = /** @class */ (function () {
function AtomDisposableList() {
// tslint:disable-next-line:ban-types
this.disposables = [];
}
// tslint:disable-next-line:ban-types
AtomDisposableList.prototype.add = function (d) {
var _this = this;
if (typeof d === "function") {
var fx = d;
d = {
dispose: fx
};
}
this.disposables.push(d);
var dx = d;
return {
dispose: function () {
_this.disposables = _this.disposables.filter(function (x) { return x !== dx; });
dx.dispose();
}
};
};
AtomDisposableList.prototype.dispose = function () {
for (var _i = 0, _a = this.disposables; _i < _a.length; _i++) {
var iterator = _a[_i];
iterator.dispose();
}
this.disposables.length = 0;
};
return AtomDisposableList;
}());
exports.AtomDisposableList = AtomDisposableList;
});
//# sourceMappingURL=AtomDisposableList.js.map