utiller 1.0.130 → 1.0.133

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.
@@ -355,7 +355,7 @@ var InfinitePool = /*#__PURE__*/function () {
355
355
  _this.setState(_configerer.configerer.POOLLER_STATE.RUN_INFINITE);
356
356
 
357
357
  case 14:
358
- if (!_this.ruleOfInfiniteRun()) {
358
+ if (_this.ruleOfStopInfiniteRun()) {
359
359
  _context2.next = 20;
360
360
  break;
361
361
  }
@@ -376,8 +376,8 @@ var InfinitePool = /*#__PURE__*/function () {
376
376
  }
377
377
  }, _callee2);
378
378
  })));
379
- (0, _defineProperty2["default"])(this, "ruleOfInfiniteRun", function () {
380
- return _this.isRunning() || !_this.isExecutingTaskQueueEmpty();
379
+ (0, _defineProperty2["default"])(this, "ruleOfStopInfiniteRun", function () {
380
+ return !_this.isRunning() && _this.isExecutingTaskQueueEmpty();
381
381
  });
382
382
  (0, _defineProperty2["default"])(this, "isExecutingTaskQueueEmpty", function () {
383
383
  return _lodash["default"].size(_this.queueOfExecutingTask) === 0;
@@ -433,7 +433,7 @@ var InfinitePool = /*#__PURE__*/function () {
433
433
  _this.setState(_configerer.configerer.POOLLER_STATE.RUN_BY_PARAMS);
434
434
 
435
435
  case 10:
436
- if (!(_this.ruleOfInfiniteRun() && _lodash["default"].size(_this.queueOfWaitingParam) > 0)) {
436
+ if (!(!_this.ruleOfStopInfiniteRun() && _lodash["default"].size(_this.queueOfWaitingParam) > 0)) {
437
437
  _context3.next = 15;
438
438
  break;
439
439
  }
@@ -459,12 +459,14 @@ var InfinitePool = /*#__PURE__*/function () {
459
459
  }());
460
460
  (0, _defineProperty2["default"])(this, "runByEachTask", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
461
461
  var tasks,
462
+ self,
462
463
  _args4 = arguments;
463
464
  return _regenerator["default"].wrap(function _callee4$(_context4) {
464
465
  while (1) {
465
466
  switch (_context4.prev = _context4.next) {
466
467
  case 0:
467
468
  tasks = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : [];
469
+ self = _this;
468
470
  _this.id = _index2.utiller.getRandomHash(15);
469
471
 
470
472
  _this.beforeRun();
@@ -473,29 +475,29 @@ var InfinitePool = /*#__PURE__*/function () {
473
475
 
474
476
  _this.setState(_configerer.configerer.POOLLER_STATE.RUN_BY_EACH_TASK);
475
477
 
476
- case 5:
477
- if (!_this.ruleOfInfiniteRun()) {
478
+ case 6:
479
+ if (_this.ruleOfStopInfiniteRun()) {
478
480
  _context4.next = 14;
479
481
  break;
480
482
  }
481
483
 
482
- _context4.next = 8;
484
+ _context4.next = 9;
483
485
  return (0, _classPrivateFieldGet2["default"])(_this, _run).call(_this, _this.id);
484
486
 
485
- case 8:
486
- if (!(_this.getCountOfAssignTaskInQueue() <= 0)) {
487
- _context4.next = 12;
488
- break;
489
- }
487
+ case 9:
488
+ if (_this.getCountOfAssignTaskInQueue() <= 0) {
489
+ _this.terminate();
490
490
 
491
- _this.terminate();
491
+ _this.printLogMessage("788121, runByEachTask() \u56E0\u70BA taskOfWaitingQueue \u6E05\u7A7A\u800C\u505C\u6B62");
492
+ }
493
+ /** 為了讓while不要停止運算 !this.ruleOfStopInfiniteRun(),不然 runByTask不會停止 */
492
494
 
493
- _this.printLogMessage("788121, runByEachTask() \u56E0\u70BA taskOfWaitingQueue \u6E05\u7A7A\u800C\u505C\u6B62");
494
495
 
495
- return _context4.abrupt("break", 14);
496
+ _context4.next = 12;
497
+ return _index2.utiller.syncDelay(10);
496
498
 
497
499
  case 12:
498
- _context4.next = 5;
500
+ _context4.next = 6;
499
501
  break;
500
502
 
501
503
  case 14:
@@ -523,7 +525,7 @@ var InfinitePool = /*#__PURE__*/function () {
523
525
  _this.setState(_configerer.configerer.POOLLER_STATE.RUN_BY_TIMES);
524
526
 
525
527
  case 5:
526
- if (!(_this.ruleOfInfiniteRun() && _this.countsOfRunByTimes > 0)) {
528
+ if (!(!_this.ruleOfStopInfiniteRun() && _this.countsOfRunByTimes > 0)) {
527
529
  _context5.next = 10;
528
530
  break;
529
531
  }
@@ -553,13 +553,20 @@ var Utiller = /*#__PURE__*/function () {
553
553
  }()
554
554
  /** 如果是array,用 indexOf檢查each
555
555
  * 如果是object,看有沒有這個key
556
- * 如果是string, 就檢查有沒有包含 */
556
+ * 如果是string, 就檢查有沒有包含
557
+ * precisely 就是用findIndex,去比較value
558
+ *
559
+ * */
557
560
 
558
561
  }, {
559
562
  key: "has",
560
563
  value: function has(collection, item) {
564
+ var precisely = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
565
+
561
566
  if (_lodash["default"].isArray(collection)) {
562
- return _lodash["default"].indexOf(collection, item) > -1;
567
+ if (precisely) return _lodash["default"].findIndex(collection, function (each) {
568
+ return _lodash["default"].isEqual(item, each);
569
+ }) > -1;else return _lodash["default"].indexOf(collection, item) > -1;
563
570
  }
564
571
 
565
572
  if (_lodash["default"].isObject(item)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utiller",
3
- "version": "1.0.130",
3
+ "version": "1.0.133",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  "license": "ISC",
12
12
  "dependencies": {
13
13
  "configerer": "^1.0.11",
14
- "utiller": "^1.0.129",
14
+ "utiller": "^1.0.132",
15
15
  "linepayer": "^1.0.4",
16
16
  "databazer": "^1.0.11",
17
17
  "lodash": "^4.17.20",