utiller 1.0.58 → 1.0.59
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/lib/pooller/index.js +29 -16
- package/package.json +1 -1
- package/template/sample.package.json +1 -1
package/lib/pooller/index.js
CHANGED
|
@@ -348,22 +348,30 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
348
348
|
}
|
|
349
349
|
}, _callee2);
|
|
350
350
|
})));
|
|
351
|
+
(0, _defineProperty2["default"])(this, "appendParamInToQueue", function () {
|
|
352
|
+
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
353
|
+
params[_key] = arguments[_key];
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
for (var _i = 0, _params = params; _i < _params.length; _i++) {
|
|
357
|
+
var param = _params[_i];
|
|
358
|
+
|
|
359
|
+
_this.paramQueue.push(param);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
351
362
|
(0, _defineProperty2["default"])(this, "runByParams", /*#__PURE__*/function () {
|
|
352
363
|
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(functionOfAsyncTask) {
|
|
353
|
-
var
|
|
364
|
+
var _len2,
|
|
354
365
|
params,
|
|
355
|
-
|
|
356
|
-
_i,
|
|
357
|
-
_params,
|
|
358
|
-
param,
|
|
366
|
+
_key2,
|
|
359
367
|
_args3 = arguments;
|
|
360
368
|
|
|
361
369
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
362
370
|
while (1) {
|
|
363
371
|
switch (_context3.prev = _context3.next) {
|
|
364
372
|
case 0:
|
|
365
|
-
for (
|
|
366
|
-
params[
|
|
373
|
+
for (_len2 = _args3.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
374
|
+
params[_key2 - 1] = _args3[_key2];
|
|
367
375
|
}
|
|
368
376
|
|
|
369
377
|
if (_lodash["default"].isFunction(functionOfAsyncTask)) {
|
|
@@ -382,11 +390,7 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
382
390
|
throw new _exceptioner["default"](4006, "runByParams error, typeof params can't be ".concat((0, _typeof2["default"])(params)));
|
|
383
391
|
|
|
384
392
|
case 5:
|
|
385
|
-
|
|
386
|
-
param = _params[_i];
|
|
387
|
-
|
|
388
|
-
_this.paramQueue.push(param);
|
|
389
|
-
}
|
|
393
|
+
_this.appendParamInToQueue.apply(_this, params);
|
|
390
394
|
|
|
391
395
|
_this.add(functionOfAsyncTask);
|
|
392
396
|
|
|
@@ -422,6 +426,11 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
422
426
|
(0, _defineProperty2["default"])(this, "runByEachTaskInBackGround", function () {
|
|
423
427
|
if (_this.atomicBgInstance !== undefined) clearTimeout(_this.atomicBgInstance);
|
|
424
428
|
_this.atomicBgInstance = _this.runInBackGround(_this.runByEachTask);
|
|
429
|
+
/** 因為偷懶, 所以回傳整個instance, 這樣程式碼就只要寫一行
|
|
430
|
+
* const pool = new InfinitePool(1).runByEachTaskInBackGround();
|
|
431
|
+
* */
|
|
432
|
+
|
|
433
|
+
return _this;
|
|
425
434
|
});
|
|
426
435
|
(0, _defineProperty2["default"])(this, "runByEachTask", /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
427
436
|
var tasks,
|
|
@@ -510,8 +519,8 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
510
519
|
};
|
|
511
520
|
}());
|
|
512
521
|
(0, _defineProperty2["default"])(this, "runInBackGround", function (asyncfunc) {
|
|
513
|
-
for (var
|
|
514
|
-
params[
|
|
522
|
+
for (var _len3 = arguments.length, params = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
523
|
+
params[_key3 - 1] = arguments[_key3];
|
|
515
524
|
}
|
|
516
525
|
|
|
517
526
|
if (!(typeof asyncfunc === "function")) {
|
|
@@ -749,14 +758,18 @@ var InfinitePool = /*#__PURE__*/function () {
|
|
|
749
758
|
_this.runInBackGround(_this.runInInfinite, functionOfAsyncTask, interval);
|
|
750
759
|
});
|
|
751
760
|
(0, _defineProperty2["default"])(this, "runByParamInBackground", function (functionOfAsyncTask) {
|
|
752
|
-
for (var
|
|
753
|
-
params[
|
|
761
|
+
for (var _len4 = arguments.length, params = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
|
|
762
|
+
params[_key4 - 1] = arguments[_key4];
|
|
754
763
|
}
|
|
755
764
|
|
|
756
765
|
_this.runInBackGround.apply(_this, [_this.runByParams, functionOfAsyncTask].concat(params));
|
|
766
|
+
|
|
767
|
+
return _this;
|
|
757
768
|
});
|
|
758
769
|
(0, _defineProperty2["default"])(this, "runByTimesInBackground", function (functionOfAsyncTask, times) {
|
|
759
770
|
_this.runInBackGround(_this.runByTimes, functionOfAsyncTask, times);
|
|
771
|
+
|
|
772
|
+
return _this;
|
|
760
773
|
});
|
|
761
774
|
this.maxWorker = maxWorkers;
|
|
762
775
|
this.setPoolId(_lodash["default"].toString(name));
|
package/package.json
CHANGED