pubo-utils 1.0.67 → 1.0.68

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.
Files changed (48) hide show
  1. package/dist/pubo-utils.js +1 -1
  2. package/es/base64/index.js +16 -21
  3. package/es/color/utils.d.ts +10 -1
  4. package/es/color/utils.js +2 -15
  5. package/es/debounce/index.js +13 -25
  6. package/es/emitter/index.js +17 -42
  7. package/es/factory/index.d.ts +5 -5
  8. package/es/factory/index.js +2 -6
  9. package/es/index.d.ts +1 -0
  10. package/es/index.js +2 -1
  11. package/es/level/index.js +1 -9
  12. package/es/loop/index.d.ts +1 -1
  13. package/es/loop/index.js +67 -118
  14. package/es/math/geometry.js +11 -23
  15. package/es/promise/index.js +16 -25
  16. package/es/queue/index.js +70 -129
  17. package/es/random/index.js +0 -5
  18. package/es/regexp-list/index.d.ts +7 -0
  19. package/es/regexp-list/index.js +20 -0
  20. package/es/sleep/index.js +62 -96
  21. package/es/stack/index.js +1 -16
  22. package/es/throttle/index.js +12 -19
  23. package/es/trigger/index.js +1 -10
  24. package/es/watch-dog/index.js +3 -11
  25. package/lib/base64/index.js +16 -24
  26. package/lib/color/utils.d.ts +10 -1
  27. package/lib/color/utils.js +9 -22
  28. package/lib/debounce/index.js +16 -28
  29. package/lib/emitter/index.js +18 -44
  30. package/lib/factory/index.d.ts +5 -5
  31. package/lib/factory/index.js +5 -9
  32. package/lib/index.d.ts +1 -0
  33. package/lib/index.js +19 -44
  34. package/lib/level/index.js +1 -10
  35. package/lib/loop/index.d.ts +1 -1
  36. package/lib/loop/index.js +73 -125
  37. package/lib/math/geometry.js +21 -36
  38. package/lib/promise/index.js +19 -27
  39. package/lib/queue/index.js +70 -130
  40. package/lib/random/index.js +3 -8
  41. package/lib/regexp-list/index.d.ts +7 -0
  42. package/lib/regexp-list/index.js +26 -0
  43. package/lib/sleep/index.js +66 -99
  44. package/lib/stack/index.js +1 -17
  45. package/lib/throttle/index.js +12 -21
  46. package/lib/trigger/index.js +1 -11
  47. package/lib/watch-dog/index.js +3 -12
  48. package/package.json +2 -2
@@ -4,68 +4,52 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.HistoryStack = void 0;
7
-
8
- var HistoryStack =
9
- /** @class */
10
- function () {
7
+ var HistoryStack = /** @class */function () {
11
8
  function HistoryStack(len) {
12
9
  if (len === void 0) {
13
10
  len = 10;
14
11
  }
15
-
16
12
  this.stack = [];
17
13
  this.len = 10;
18
14
  this.point = 0;
19
15
  this.len = len;
20
16
  }
21
-
22
17
  Object.defineProperty(HistoryStack.prototype, "current", {
23
18
  get: function get() {
24
19
  if (this.point < this.stack.length && this.point > -1) {
25
20
  return this.stack[this.point];
26
21
  }
27
-
28
22
  return undefined;
29
23
  },
30
24
  enumerable: false,
31
25
  configurable: true
32
26
  });
33
-
34
27
  HistoryStack.prototype.clear = function () {
35
28
  this.stack.length = 0;
36
29
  this.point = 0;
37
30
  };
38
-
39
31
  HistoryStack.prototype.backup = function (item) {
40
32
  if (this.point > 0 && this.stack.length > 0) {
41
33
  this.stack.splice(0, this.point);
42
34
  this.point = 0;
43
35
  }
44
-
45
36
  this.stack.unshift(item);
46
-
47
37
  if (this.stack.length > this.len) {
48
38
  this.stack.pop();
49
39
  }
50
40
  };
51
-
52
41
  HistoryStack.prototype.undo = function () {
53
42
  if (this.point < this.stack.length - 1) {
54
43
  this.point += 1;
55
44
  }
56
-
57
45
  return this.current;
58
46
  };
59
-
60
47
  HistoryStack.prototype.redo = function () {
61
48
  if (this.point > 0) {
62
49
  this.point -= 1;
63
50
  }
64
-
65
51
  return this.current;
66
52
  };
67
-
68
53
  return HistoryStack;
69
54
  }();
70
-
71
55
  exports.HistoryStack = HistoryStack;
@@ -4,14 +4,11 @@ var __read = this && this.__read || function (o, n) {
4
4
  var m = typeof Symbol === "function" && o[Symbol.iterator];
5
5
  if (!m) return o;
6
6
  var i = m.call(o),
7
- r,
8
- ar = [],
9
- e;
10
-
7
+ r,
8
+ ar = [],
9
+ e;
11
10
  try {
12
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) {
13
- ar.push(r.value);
14
- }
11
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
15
12
  } catch (error) {
16
13
  e = {
17
14
  error: error
@@ -23,45 +20,39 @@ var __read = this && this.__read || function (o, n) {
23
20
  if (e) throw e.error;
24
21
  }
25
22
  }
26
-
27
23
  return ar;
28
24
  };
29
-
30
- var __spread = this && this.__spread || function () {
31
- for (var ar = [], i = 0; i < arguments.length; i++) {
32
- ar = ar.concat(__read(arguments[i]));
25
+ var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
26
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
27
+ if (ar || !(i in from)) {
28
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
29
+ ar[i] = from[i];
30
+ }
33
31
  }
34
-
35
- return ar;
32
+ return to.concat(ar || Array.prototype.slice.call(from));
36
33
  };
37
-
38
34
  Object.defineProperty(exports, "__esModule", {
39
35
  value: true
40
36
  });
41
37
  exports.throttle = void 0;
42
-
43
38
  function throttle(cb, time) {
44
39
  var t;
45
40
  var onOff = true;
46
41
  return function () {
47
42
  var args = [];
48
-
49
43
  for (var _i = 0; _i < arguments.length; _i++) {
50
44
  args[_i] = arguments[_i];
51
45
  }
52
-
53
46
  if (!t) {
54
47
  t = setTimeout(function () {
55
48
  onOff = true;
56
49
  t = null;
57
50
  }, time);
58
51
  }
59
-
60
52
  if (onOff) {
61
53
  onOff = false;
62
- cb.apply(void 0, __spread(args));
54
+ cb.apply(void 0, __spreadArray([], __read(args), false));
63
55
  }
64
56
  };
65
57
  }
66
-
67
58
  exports.throttle = throttle;
@@ -4,15 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ContinuousTrigger = void 0;
7
-
8
- var ContinuousTrigger =
9
- /** @class */
10
- function () {
7
+ var ContinuousTrigger = /** @class */function () {
11
8
  function ContinuousTrigger(props) {
12
9
  this._count = 0;
13
10
  this.props = props;
14
11
  }
15
-
16
12
  Object.defineProperty(ContinuousTrigger.prototype, "count", {
17
13
  get: function get() {
18
14
  return this._count;
@@ -20,26 +16,20 @@ function () {
20
16
  enumerable: false,
21
17
  configurable: true
22
18
  });
23
-
24
19
  ContinuousTrigger.prototype.increment = function () {
25
20
  var _this = this;
26
-
27
21
  clearTimeout(this.timeout);
28
22
  this.timeout = setTimeout(function () {
29
23
  return _this.clear();
30
24
  }, this.props.resetTime);
31
25
  this._count = this._count + 1;
32
-
33
26
  if (this._count > this.props.count) {
34
27
  this.props.cb();
35
28
  }
36
29
  };
37
-
38
30
  ContinuousTrigger.prototype.clear = function () {
39
31
  this._count = 0;
40
32
  };
41
-
42
33
  return ContinuousTrigger;
43
34
  }();
44
-
45
35
  exports.ContinuousTrigger = ContinuousTrigger;
@@ -4,40 +4,31 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.WatchDog = void 0;
7
-
8
- var WatchDog =
9
- /** @class */
10
- function () {
7
+ var WatchDog = /** @class */function () {
11
8
  function WatchDog(_a) {
12
9
  var _b = _a.limit,
13
- limit = _b === void 0 ? 10 : _b,
14
- onTimeout = _a.onTimeout;
10
+ limit = _b === void 0 ? 10 : _b,
11
+ onTimeout = _a.onTimeout;
15
12
  this.limit = 10;
16
13
  this.timeout = null;
17
14
  this.limit = limit;
18
15
  this.onTimeout = onTimeout;
19
16
  }
20
-
21
17
  WatchDog.prototype.feed = function () {
22
18
  clearTimeout(this.timeout);
23
19
  this.init();
24
20
  };
25
-
26
21
  WatchDog.prototype.init = function () {
27
22
  var _this = this;
28
-
29
23
  this.timeout = setTimeout(function () {
30
24
  return _this.onTimeout();
31
25
  }, this.limit * 1000);
32
26
  };
33
-
34
27
  WatchDog.prototype.stop = function () {
35
28
  if (this.timeout) {
36
29
  clearTimeout(this.timeout);
37
30
  }
38
31
  };
39
-
40
32
  return WatchDog;
41
33
  }();
42
-
43
34
  exports.WatchDog = WatchDog;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pubo-utils",
3
- "version": "1.0.67",
3
+ "version": "1.0.68",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -18,5 +18,5 @@
18
18
  "engines": {
19
19
  "node": ">=8.0.0"
20
20
  },
21
- "gitHead": "16e383170f644fddb2732f1767f2b424b2b9effb"
21
+ "gitHead": "899d754737a6d62cc70078e99a8999484a345d1c"
22
22
  }