@firestitch/common 12.4.2 → 12.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/firestitch-common.umd.js +86 -50
- package/bundles/firestitch-common.umd.js.map +1 -1
- package/esm2015/libs/util/queue/index.js +3 -2
- package/esm2015/libs/util/queue/operation.js +1 -1
- package/esm2015/libs/util/queue/queue-stats.js +2 -0
- package/esm2015/libs/util/queue/queue.js +80 -52
- package/fesm2015/firestitch-common.js +78 -50
- package/fesm2015/firestitch-common.js.map +1 -1
- package/libs/util/queue/index.d.ts +2 -1
- package/libs/util/queue/operation.d.ts +1 -1
- package/libs/util/queue/queue-stats.d.ts +5 -0
- package/libs/util/queue/queue.d.ts +13 -6
- package/package.json +1 -1
|
@@ -1502,25 +1502,42 @@
|
|
|
1502
1502
|
function Queue(_limit) {
|
|
1503
1503
|
if (_limit === void 0) { _limit = Infinity; }
|
|
1504
1504
|
this._limit = _limit;
|
|
1505
|
+
this._queueStats = {
|
|
1506
|
+
completed: 0,
|
|
1507
|
+
total: 0,
|
|
1508
|
+
errors: [],
|
|
1509
|
+
};
|
|
1510
|
+
this._doneQueueStats = {
|
|
1511
|
+
completed: 0,
|
|
1512
|
+
total: 0,
|
|
1513
|
+
errors: [],
|
|
1514
|
+
};
|
|
1515
|
+
this._completeQueueStats = {
|
|
1516
|
+
completed: 0,
|
|
1517
|
+
total: 0,
|
|
1518
|
+
errors: [],
|
|
1519
|
+
};
|
|
1505
1520
|
this._done = new rxjs.Subject();
|
|
1506
1521
|
this._queue = [];
|
|
1507
1522
|
this._inProgress = [];
|
|
1508
|
-
this._total = 0;
|
|
1509
|
-
this._completed = 0;
|
|
1510
|
-
this._errors = 0;
|
|
1511
1523
|
this._state = exports.QueueState.Idle;
|
|
1512
1524
|
this._destroy$ = new rxjs.Subject();
|
|
1525
|
+
// if(_targets) {
|
|
1526
|
+
// _targets.forEach((target) => {
|
|
1527
|
+
// this.push(target);
|
|
1528
|
+
// });
|
|
1529
|
+
// }
|
|
1513
1530
|
}
|
|
1514
1531
|
Object.defineProperty(Queue.prototype, "total", {
|
|
1515
1532
|
get: function () {
|
|
1516
|
-
return this.
|
|
1533
|
+
return this._queueStats.total;
|
|
1517
1534
|
},
|
|
1518
1535
|
enumerable: false,
|
|
1519
1536
|
configurable: true
|
|
1520
1537
|
});
|
|
1521
1538
|
Object.defineProperty(Queue.prototype, "completed", {
|
|
1522
1539
|
get: function () {
|
|
1523
|
-
return this.
|
|
1540
|
+
return this._queueStats.completed;
|
|
1524
1541
|
},
|
|
1525
1542
|
enumerable: false,
|
|
1526
1543
|
configurable: true
|
|
@@ -1541,7 +1558,7 @@
|
|
|
1541
1558
|
});
|
|
1542
1559
|
Object.defineProperty(Queue.prototype, "errors", {
|
|
1543
1560
|
get: function () {
|
|
1544
|
-
return this.
|
|
1561
|
+
return this._queueStats.errors;
|
|
1545
1562
|
},
|
|
1546
1563
|
enumerable: false,
|
|
1547
1564
|
configurable: true
|
|
@@ -1585,31 +1602,41 @@
|
|
|
1585
1602
|
Queue.prototype.setLimit = function (value) {
|
|
1586
1603
|
this._limit = value;
|
|
1587
1604
|
};
|
|
1605
|
+
/**
|
|
1606
|
+
* @depreated
|
|
1607
|
+
*/
|
|
1588
1608
|
Queue.prototype.subscribe = function (fun, err, complete) {
|
|
1589
|
-
this.
|
|
1590
|
-
.pipe(operators.takeUntil(this._destroy$))
|
|
1609
|
+
this.observe$
|
|
1591
1610
|
.subscribe(fun, err, complete);
|
|
1592
1611
|
};
|
|
1593
|
-
Queue.prototype
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1612
|
+
Object.defineProperty(Queue.prototype, "observe$", {
|
|
1613
|
+
get: function () {
|
|
1614
|
+
return this._done
|
|
1615
|
+
.pipe(operators.takeUntil(this._destroy$));
|
|
1616
|
+
},
|
|
1617
|
+
enumerable: false,
|
|
1618
|
+
configurable: true
|
|
1619
|
+
});
|
|
1620
|
+
Object.defineProperty(Queue.prototype, "complete$", {
|
|
1621
|
+
get: function () {
|
|
1622
|
+
var _this = this;
|
|
1623
|
+
if (!this.isProcessing()) {
|
|
1624
|
+
return rxjs.of({ total: 0, completed: 0, errors: [] });
|
|
1600
1625
|
}
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1626
|
+
return this.observe$
|
|
1627
|
+
.pipe(operators.take(1), operators.map(function () { return (_this._completeQueueStats); }));
|
|
1628
|
+
},
|
|
1629
|
+
enumerable: false,
|
|
1630
|
+
configurable: true
|
|
1631
|
+
});
|
|
1632
|
+
Queue.prototype.complete = function (fun, err, complete) {
|
|
1633
|
+
this.complete$.subscribe(fun, err, complete);
|
|
1609
1634
|
};
|
|
1610
1635
|
Queue.prototype.push = function (target, name) {
|
|
1611
1636
|
var operation = new Operation(target, name);
|
|
1612
|
-
this.
|
|
1637
|
+
this._queueStats.total++;
|
|
1638
|
+
this._doneQueueStats.total++;
|
|
1639
|
+
this._completeQueueStats.total++;
|
|
1613
1640
|
this._state = exports.QueueState.Processing;
|
|
1614
1641
|
if (this._inProgress.length < this._limit) {
|
|
1615
1642
|
this._processOperation(operation);
|
|
@@ -1621,53 +1648,62 @@
|
|
|
1621
1648
|
};
|
|
1622
1649
|
Queue.prototype.clear = function () {
|
|
1623
1650
|
this._queue = [];
|
|
1624
|
-
this._total = 0;
|
|
1625
|
-
this._errors = 0;
|
|
1626
|
-
this._completed = 0;
|
|
1627
1651
|
this._state = exports.QueueState.Idle;
|
|
1628
|
-
this.
|
|
1652
|
+
this._queueStats = {
|
|
1653
|
+
total: 0,
|
|
1654
|
+
errors: [],
|
|
1655
|
+
completed: 0,
|
|
1656
|
+
};
|
|
1657
|
+
this._clearDoneQueueStats();
|
|
1629
1658
|
};
|
|
1630
1659
|
Queue.prototype.destroy = function () {
|
|
1631
|
-
this.clear();
|
|
1632
1660
|
this._done.complete();
|
|
1661
|
+
this.clear();
|
|
1633
1662
|
};
|
|
1634
1663
|
Queue.prototype._processOperation = function (operation) {
|
|
1635
1664
|
var _this = this;
|
|
1636
1665
|
this._inProgress.push(operation);
|
|
1637
1666
|
operation.target
|
|
1638
1667
|
.pipe(operators.delay(200), // Hack to prevent extra quick proccess execution
|
|
1639
|
-
operators.
|
|
1668
|
+
operators.finalize(function () {
|
|
1669
|
+
var opIndex = _this._inProgress.indexOf(operation);
|
|
1670
|
+
_this._inProgress.splice(opIndex, 1);
|
|
1671
|
+
if (_this.empty) {
|
|
1672
|
+
_this._state = exports.QueueState.Idle;
|
|
1673
|
+
_this._done.next(_this._doneQueueStats);
|
|
1674
|
+
_this._clearDoneQueueStats();
|
|
1675
|
+
}
|
|
1676
|
+
else {
|
|
1677
|
+
if (_this._queue.length) {
|
|
1678
|
+
var queueItem = _this._queue.shift();
|
|
1679
|
+
_this._processOperation(queueItem);
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
}), operators.takeUntil(this._destroy$)).subscribe({
|
|
1640
1683
|
next: function (data) {
|
|
1641
1684
|
operation.ready$.next(data);
|
|
1642
1685
|
},
|
|
1643
1686
|
error: function (error) {
|
|
1644
|
-
|
|
1645
|
-
_this.
|
|
1646
|
-
_this.
|
|
1687
|
+
_this._queueStats.errors.push(error);
|
|
1688
|
+
_this._doneQueueStats.errors.push(error);
|
|
1689
|
+
_this._completeQueueStats.errors.push(error);
|
|
1647
1690
|
operation.ready$.error(error);
|
|
1648
|
-
if (_this.empty) {
|
|
1649
|
-
_this._state = exports.QueueState.Idle;
|
|
1650
|
-
_this._done.error(error);
|
|
1651
|
-
}
|
|
1652
1691
|
},
|
|
1653
1692
|
complete: function () {
|
|
1654
|
-
|
|
1655
|
-
_this.
|
|
1656
|
-
_this.
|
|
1693
|
+
_this._queueStats.completed++;
|
|
1694
|
+
_this._doneQueueStats.completed++;
|
|
1695
|
+
_this._completeQueueStats.completed++;
|
|
1657
1696
|
operation.ready$.complete();
|
|
1658
|
-
if (_this.empty) {
|
|
1659
|
-
_this._state = exports.QueueState.Idle;
|
|
1660
|
-
_this._done.next();
|
|
1661
|
-
}
|
|
1662
|
-
else {
|
|
1663
|
-
if (_this._queue.length) {
|
|
1664
|
-
var queueItem = _this._queue.shift();
|
|
1665
|
-
_this._processOperation(queueItem);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
1697
|
}
|
|
1669
1698
|
});
|
|
1670
1699
|
};
|
|
1700
|
+
Queue.prototype._clearDoneQueueStats = function () {
|
|
1701
|
+
this._doneQueueStats = {
|
|
1702
|
+
total: 0,
|
|
1703
|
+
errors: [],
|
|
1704
|
+
completed: 0,
|
|
1705
|
+
};
|
|
1706
|
+
};
|
|
1671
1707
|
return Queue;
|
|
1672
1708
|
}());
|
|
1673
1709
|
|