1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.removeFromCollection = exports.addAndRemoveFromCollection = void 0;
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | function addAndRemoveFromCollection(collection, item, then) {
|
12 | collection.push(item);
|
13 | return function () {
|
14 | return removeFromCollection(collection, item, then);
|
15 | };
|
16 | }
|
17 | exports.addAndRemoveFromCollection = addAndRemoveFromCollection;
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | function removeFromCollection(collection, item, then) {
|
25 | var idx = collection.findIndex(function (i) { return i === item; });
|
26 | if (idx >= 0) {
|
27 | collection.splice(idx, 1);
|
28 | if (then) {
|
29 | then(item);
|
30 | }
|
31 | return true;
|
32 | }
|
33 | return false;
|
34 | }
|
35 | exports.removeFromCollection = removeFromCollection;
|