1 | /* --------------------------------------------------------------------------------------------
|
2 | * Copyright (c) 2018-2022 TypeFox GmbH (http://www.typefox.io). All rights reserved.
|
3 | * Licensed under the MIT License. See License.txt in the project root for license information.
|
4 | * ------------------------------------------------------------------------------------------ */
|
5 | export class DisposableCollection {
|
6 | disposables = [];
|
7 | dispose() {
|
8 | while (this.disposables.length !== 0) {
|
9 | this.disposables.pop().dispose();
|
10 | }
|
11 | }
|
12 | push(disposable) {
|
13 | const disposables = this.disposables;
|
14 | disposables.push(disposable);
|
15 | return {
|
16 | dispose() {
|
17 | const index = disposables.indexOf(disposable);
|
18 | if (index !== -1) {
|
19 | disposables.splice(index, 1);
|
20 | }
|
21 | }
|
22 | };
|
23 | }
|
24 | }
|
25 | //# sourceMappingURL=disposable.js.map |
\ | No newline at end of file |