pubo-utils 1.0.129 → 1.0.142
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/dist/pubo-utils.js +1 -1
- package/es/color/utils.js +21 -19
- package/es/debounce/index.js +16 -52
- package/es/emitter/index.js +217 -229
- package/es/factory/index.js +3 -32
- package/es/filter/sensor.js +58 -65
- package/es/level/index.js +6 -4
- package/es/loop/index.d.ts +1 -1
- package/es/loop/index.js +92 -163
- package/es/math/geometry.js +28 -107
- package/es/promise/index.js +9 -41
- package/es/queue/index.js +97 -174
- package/es/random/index.js +1 -32
- package/es/regexp-list/index.js +6 -5
- package/es/sleep/index.js +23 -128
- package/es/stack/index.js +20 -17
- package/es/throttle/index.js +1 -36
- package/es/trigger/index.js +17 -12
- package/es/watch-dog/index.js +12 -10
- package/lib/color/utils.js +20 -17
- package/lib/debounce/index.js +16 -52
- package/lib/emitter/index.js +216 -226
- package/lib/factory/index.js +3 -32
- package/lib/filter/sensor.js +57 -62
- package/lib/level/index.js +5 -2
- package/lib/loop/index.d.ts +1 -1
- package/lib/loop/index.js +78 -150
- package/lib/math/geometry.js +28 -107
- package/lib/promise/index.js +9 -41
- package/lib/queue/index.js +96 -172
- package/lib/random/index.js +1 -32
- package/lib/regexp-list/index.js +5 -3
- package/lib/sleep/index.js +22 -129
- package/lib/stack/index.js +19 -15
- package/lib/throttle/index.js +1 -36
- package/lib/trigger/index.js +16 -10
- package/lib/watch-dog/index.js +11 -8
- package/package.json +2 -2
package/lib/promise/index.js
CHANGED
|
@@ -1,36 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var __read = this && this.__read || function (o, n) {
|
|
4
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
5
|
-
if (!m) return o;
|
|
6
|
-
var i = m.call(o),
|
|
7
|
-
r,
|
|
8
|
-
ar = [],
|
|
9
|
-
e;
|
|
10
|
-
try {
|
|
11
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
12
|
-
} catch (error) {
|
|
13
|
-
e = {
|
|
14
|
-
error: error
|
|
15
|
-
};
|
|
16
|
-
} finally {
|
|
17
|
-
try {
|
|
18
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
19
|
-
} finally {
|
|
20
|
-
if (e) throw e.error;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
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
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
-
};
|
|
34
3
|
Object.defineProperty(exports, "__esModule", {
|
|
35
4
|
value: true
|
|
36
5
|
});
|
|
@@ -38,25 +7,24 @@ exports.callbackToPromise = void 0;
|
|
|
38
7
|
// 回调函数转异步函数
|
|
39
8
|
var callbackToPromise = function callbackToPromise(fn) {
|
|
40
9
|
return function () {
|
|
41
|
-
var args =
|
|
42
|
-
|
|
43
|
-
args[_i] = arguments[_i];
|
|
10
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
11
|
+
args[_key] = arguments[_key];
|
|
44
12
|
}
|
|
45
13
|
return new Promise(function (resolve, reject) {
|
|
46
|
-
fn.apply(void 0,
|
|
47
|
-
var rest = [];
|
|
48
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
49
|
-
rest[_i - 1] = arguments[_i];
|
|
50
|
-
}
|
|
14
|
+
fn.apply(void 0, args.concat([function (err) {
|
|
51
15
|
if (err) {
|
|
52
16
|
reject(err);
|
|
53
17
|
}
|
|
18
|
+
for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
19
|
+
rest[_key2 - 1] = arguments[_key2];
|
|
20
|
+
}
|
|
54
21
|
if (rest.length < 2) {
|
|
55
22
|
resolve(rest[0]);
|
|
56
23
|
} else {
|
|
57
|
-
resolve(
|
|
24
|
+
resolve([].concat(rest));
|
|
58
25
|
}
|
|
59
|
-
}]
|
|
26
|
+
}]));
|
|
27
|
+
fn = null;
|
|
60
28
|
});
|
|
61
29
|
};
|
|
62
30
|
};
|
package/lib/queue/index.js
CHANGED
|
@@ -1,205 +1,129 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return
|
|
6
|
-
resolve(value);
|
|
7
|
-
});
|
|
3
|
+
function _call(body, then, direct) {
|
|
4
|
+
if (direct) {
|
|
5
|
+
return then ? then(body()) : body();
|
|
8
6
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
reject(e);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function rejected(value) {
|
|
18
|
-
try {
|
|
19
|
-
step(generator["throw"](value));
|
|
20
|
-
} catch (e) {
|
|
21
|
-
reject(e);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function step(result) {
|
|
25
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
26
|
-
}
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
|
-
var __generator = this && this.__generator || function (thisArg, body) {
|
|
31
|
-
var _ = {
|
|
32
|
-
label: 0,
|
|
33
|
-
sent: function sent() {
|
|
34
|
-
if (t[0] & 1) throw t[1];
|
|
35
|
-
return t[1];
|
|
36
|
-
},
|
|
37
|
-
trys: [],
|
|
38
|
-
ops: []
|
|
39
|
-
},
|
|
40
|
-
f,
|
|
41
|
-
y,
|
|
42
|
-
t,
|
|
43
|
-
g;
|
|
44
|
-
return g = {
|
|
45
|
-
next: verb(0),
|
|
46
|
-
"throw": verb(1),
|
|
47
|
-
"return": verb(2)
|
|
48
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
49
|
-
return this;
|
|
50
|
-
}), g;
|
|
51
|
-
function verb(n) {
|
|
52
|
-
return function (v) {
|
|
53
|
-
return step([n, v]);
|
|
54
|
-
};
|
|
7
|
+
try {
|
|
8
|
+
var result = Promise.resolve(body());
|
|
9
|
+
return then ? result.then(then) : result;
|
|
10
|
+
} catch (e) {
|
|
11
|
+
return Promise.reject(e);
|
|
55
12
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
case 7:
|
|
78
|
-
op = _.ops.pop();
|
|
79
|
-
_.trys.pop();
|
|
80
|
-
continue;
|
|
81
|
-
default:
|
|
82
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
83
|
-
_ = 0;
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
87
|
-
_.label = op[1];
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
91
|
-
_.label = t[1];
|
|
92
|
-
t = op;
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
if (t && _.label < t[2]) {
|
|
96
|
-
_.label = t[2];
|
|
97
|
-
_.ops.push(op);
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
if (t[2]) _.ops.pop();
|
|
101
|
-
_.trys.pop();
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
op = body.call(thisArg, _);
|
|
105
|
-
} catch (e) {
|
|
106
|
-
op = [6, e];
|
|
107
|
-
y = 0;
|
|
108
|
-
} finally {
|
|
109
|
-
f = t = 0;
|
|
110
|
-
}
|
|
111
|
-
if (op[0] & 5) throw op[1];
|
|
112
|
-
return {
|
|
113
|
-
value: op[0] ? op[1] : void 0,
|
|
114
|
-
done: true
|
|
115
|
-
};
|
|
13
|
+
}
|
|
14
|
+
function _catch(body, recover) {
|
|
15
|
+
try {
|
|
16
|
+
var result = body();
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return recover(e);
|
|
19
|
+
}
|
|
20
|
+
if (result && result.then) {
|
|
21
|
+
return result.then(void 0, recover);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
}
|
|
25
|
+
function _continue(value, then) {
|
|
26
|
+
return value && value.then ? value.then(then) : then(value);
|
|
27
|
+
}
|
|
28
|
+
function _await(value, then, direct) {
|
|
29
|
+
if (direct) {
|
|
30
|
+
return then ? then(value) : value;
|
|
31
|
+
}
|
|
32
|
+
if (!value || !value.then) {
|
|
33
|
+
value = Promise.resolve(value);
|
|
116
34
|
}
|
|
117
|
-
|
|
35
|
+
return then ? value.then(then) : value;
|
|
36
|
+
}
|
|
37
|
+
function _empty() {}
|
|
38
|
+
function _awaitIgnored(value, direct) {
|
|
39
|
+
if (!direct) {
|
|
40
|
+
return value && value.then ? value.then(_empty) : Promise.resolve();
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function _invoke(body, then) {
|
|
44
|
+
var result = body();
|
|
45
|
+
if (result && result.then) {
|
|
46
|
+
return result.then(then);
|
|
47
|
+
}
|
|
48
|
+
return then(result);
|
|
49
|
+
}
|
|
50
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
51
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
52
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
53
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
118
54
|
Object.defineProperty(exports, "__esModule", {
|
|
119
55
|
value: true
|
|
120
56
|
});
|
|
121
57
|
exports.SyncQueue = void 0;
|
|
122
|
-
var SyncQueue =
|
|
58
|
+
var SyncQueue = /*#__PURE__*/function () {
|
|
123
59
|
function SyncQueue() {
|
|
124
60
|
this.cache = [];
|
|
125
61
|
this.running = false;
|
|
126
62
|
this.len = 0;
|
|
127
63
|
}
|
|
128
|
-
SyncQueue.prototype
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
case 3:
|
|
147
|
-
return [2 /*return*/];
|
|
148
|
-
}
|
|
149
|
-
});
|
|
150
|
-
});
|
|
64
|
+
var _proto = SyncQueue.prototype;
|
|
65
|
+
_proto._run = function _run(_ref) {
|
|
66
|
+
var fn = _ref.fn,
|
|
67
|
+
promise = _ref.promise;
|
|
68
|
+
try {
|
|
69
|
+
return _await(_continue(_catch(function () {
|
|
70
|
+
return _call(fn, function (res) {
|
|
71
|
+
promise.resolve(res);
|
|
72
|
+
});
|
|
73
|
+
}, function (err) {
|
|
74
|
+
promise.reject(err);
|
|
75
|
+
}), function () {
|
|
76
|
+
fn = null;
|
|
77
|
+
promise = null;
|
|
78
|
+
}));
|
|
79
|
+
} catch (e) {
|
|
80
|
+
return Promise.reject(e);
|
|
81
|
+
}
|
|
151
82
|
};
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
this.len -= 1;
|
|
167
|
-
if (!(typeof item.fn === 'function')) return [3 /*break*/, 2];
|
|
168
|
-
return [4 /*yield*/, this._run(item)];
|
|
169
|
-
case 1:
|
|
170
|
-
_a.sent();
|
|
171
|
-
_a.label = 2;
|
|
172
|
-
case 2:
|
|
173
|
-
this.run();
|
|
174
|
-
return [2 /*return*/];
|
|
83
|
+
_proto.run = function run() {
|
|
84
|
+
try {
|
|
85
|
+
var _this = this;
|
|
86
|
+
if (_this.cache.length < 1) {
|
|
87
|
+
_this.running = false;
|
|
88
|
+
return _await();
|
|
89
|
+
} else {
|
|
90
|
+
_this.running = true;
|
|
91
|
+
}
|
|
92
|
+
var item = _this.cache.shift();
|
|
93
|
+
_this.len -= 1;
|
|
94
|
+
return _await(_invoke(function () {
|
|
95
|
+
if (typeof item.fn === 'function') {
|
|
96
|
+
return _awaitIgnored(_this._run(item));
|
|
175
97
|
}
|
|
176
|
-
})
|
|
177
|
-
|
|
98
|
+
}, function () {
|
|
99
|
+
_this.run();
|
|
100
|
+
}));
|
|
101
|
+
} catch (e) {
|
|
102
|
+
return Promise.reject(e);
|
|
103
|
+
}
|
|
178
104
|
};
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
var _this = this;
|
|
105
|
+
_proto.push = function push(fn) {
|
|
106
|
+
var _this2 = this;
|
|
182
107
|
this.len += 1;
|
|
183
108
|
return new Promise(function (resolve, reject) {
|
|
184
|
-
|
|
109
|
+
_this2.cache.push({
|
|
185
110
|
fn: fn,
|
|
186
111
|
promise: {
|
|
187
112
|
resolve: resolve,
|
|
188
113
|
reject: reject
|
|
189
114
|
}
|
|
190
115
|
});
|
|
191
|
-
if (!
|
|
192
|
-
|
|
116
|
+
if (!_this2.running) {
|
|
117
|
+
_this2.run();
|
|
193
118
|
}
|
|
194
119
|
});
|
|
195
120
|
};
|
|
196
|
-
|
|
121
|
+
_createClass(SyncQueue, [{
|
|
122
|
+
key: "length",
|
|
197
123
|
get: function get() {
|
|
198
124
|
return this.len;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
configurable: true
|
|
202
|
-
});
|
|
125
|
+
}
|
|
126
|
+
}]);
|
|
203
127
|
return SyncQueue;
|
|
204
128
|
}();
|
|
205
129
|
exports.SyncQueue = SyncQueue;
|
package/lib/random/index.js
CHANGED
|
@@ -6,37 +6,6 @@
|
|
|
6
6
|
* @param {number} n - The length of the random string to generate
|
|
7
7
|
* @return {string} The randomly generated string
|
|
8
8
|
*/
|
|
9
|
-
var __read = this && this.__read || function (o, n) {
|
|
10
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
11
|
-
if (!m) return o;
|
|
12
|
-
var i = m.call(o),
|
|
13
|
-
r,
|
|
14
|
-
ar = [],
|
|
15
|
-
e;
|
|
16
|
-
try {
|
|
17
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
-
} catch (error) {
|
|
19
|
-
e = {
|
|
20
|
-
error: error
|
|
21
|
-
};
|
|
22
|
-
} finally {
|
|
23
|
-
try {
|
|
24
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
25
|
-
} finally {
|
|
26
|
-
if (e) throw e.error;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return ar;
|
|
30
|
-
};
|
|
31
|
-
var __spreadArray = this && this.__spreadArray || function (to, from, pack) {
|
|
32
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
33
|
-
if (ar || !(i in from)) {
|
|
34
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
35
|
-
ar[i] = from[i];
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
39
|
-
};
|
|
40
9
|
Object.defineProperty(exports, "__esModule", {
|
|
41
10
|
value: true
|
|
42
11
|
});
|
|
@@ -70,6 +39,6 @@ exports.random = random;
|
|
|
70
39
|
*/
|
|
71
40
|
var randomRangeNum = function randomRangeNum(range) {
|
|
72
41
|
var size = Math.abs(range[1] - range[0]);
|
|
73
|
-
return Math.random() * size + Math.min.apply(Math,
|
|
42
|
+
return Math.random() * size + Math.min.apply(Math, range);
|
|
74
43
|
};
|
|
75
44
|
exports.randomRangeNum = randomRangeNum;
|
package/lib/regexp-list/index.js
CHANGED
|
@@ -4,16 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.RegExpList = void 0;
|
|
7
|
-
var RegExpList =
|
|
7
|
+
var RegExpList = /*#__PURE__*/function () {
|
|
8
8
|
function RegExpList(list) {
|
|
9
|
+
this.list = void 0;
|
|
9
10
|
this._RegExpList = null;
|
|
10
11
|
this.list = list;
|
|
11
12
|
}
|
|
12
|
-
RegExpList.prototype
|
|
13
|
+
var _proto = RegExpList.prototype;
|
|
14
|
+
_proto.getRegEXP = function getRegEXP(item) {
|
|
13
15
|
var str = item.replace('/', '\\/').replace('*', '.*');
|
|
14
16
|
return new RegExp(str);
|
|
15
17
|
};
|
|
16
|
-
|
|
18
|
+
_proto.include = function include(value) {
|
|
17
19
|
if (!this._RegExpList) {
|
|
18
20
|
this._RegExpList = this.list.map(this.getRegEXP);
|
|
19
21
|
}
|
package/lib/sleep/index.js
CHANGED
|
@@ -6,141 +6,34 @@
|
|
|
6
6
|
* @param {number} time - The duration in milliseconds to sleep
|
|
7
7
|
* @return {Promise<void>} A promise that resolves after the specified time
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
});
|
|
9
|
+
function _empty() {}
|
|
10
|
+
function _awaitIgnored(value, direct) {
|
|
11
|
+
if (!direct) {
|
|
12
|
+
return value && value.then ? value.then(_empty) : Promise.resolve();
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
reject(e);
|
|
21
|
-
}
|
|
14
|
+
}
|
|
15
|
+
function _async(f) {
|
|
16
|
+
return function () {
|
|
17
|
+
for (var args = [], i = 0; i < arguments.length; i++) {
|
|
18
|
+
args[i] = arguments[i];
|
|
22
19
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
step(generator["throw"](value));
|
|
26
|
-
} catch (e) {
|
|
27
|
-
reject(e);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
function step(result) {
|
|
31
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
32
|
-
}
|
|
33
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
34
|
-
});
|
|
35
|
-
};
|
|
36
|
-
var __generator = this && this.__generator || function (thisArg, body) {
|
|
37
|
-
var _ = {
|
|
38
|
-
label: 0,
|
|
39
|
-
sent: function sent() {
|
|
40
|
-
if (t[0] & 1) throw t[1];
|
|
41
|
-
return t[1];
|
|
42
|
-
},
|
|
43
|
-
trys: [],
|
|
44
|
-
ops: []
|
|
45
|
-
},
|
|
46
|
-
f,
|
|
47
|
-
y,
|
|
48
|
-
t,
|
|
49
|
-
g;
|
|
50
|
-
return g = {
|
|
51
|
-
next: verb(0),
|
|
52
|
-
"throw": verb(1),
|
|
53
|
-
"return": verb(2)
|
|
54
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
55
|
-
return this;
|
|
56
|
-
}), g;
|
|
57
|
-
function verb(n) {
|
|
58
|
-
return function (v) {
|
|
59
|
-
return step([n, v]);
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function step(op) {
|
|
63
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
64
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
65
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
66
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
67
|
-
switch (op[0]) {
|
|
68
|
-
case 0:
|
|
69
|
-
case 1:
|
|
70
|
-
t = op;
|
|
71
|
-
break;
|
|
72
|
-
case 4:
|
|
73
|
-
_.label++;
|
|
74
|
-
return {
|
|
75
|
-
value: op[1],
|
|
76
|
-
done: false
|
|
77
|
-
};
|
|
78
|
-
case 5:
|
|
79
|
-
_.label++;
|
|
80
|
-
y = op[1];
|
|
81
|
-
op = [0];
|
|
82
|
-
continue;
|
|
83
|
-
case 7:
|
|
84
|
-
op = _.ops.pop();
|
|
85
|
-
_.trys.pop();
|
|
86
|
-
continue;
|
|
87
|
-
default:
|
|
88
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
89
|
-
_ = 0;
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
93
|
-
_.label = op[1];
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
97
|
-
_.label = t[1];
|
|
98
|
-
t = op;
|
|
99
|
-
break;
|
|
100
|
-
}
|
|
101
|
-
if (t && _.label < t[2]) {
|
|
102
|
-
_.label = t[2];
|
|
103
|
-
_.ops.push(op);
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
if (t[2]) _.ops.pop();
|
|
107
|
-
_.trys.pop();
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
op = body.call(thisArg, _);
|
|
20
|
+
try {
|
|
21
|
+
return Promise.resolve(f.apply(this, args));
|
|
111
22
|
} catch (e) {
|
|
112
|
-
|
|
113
|
-
y = 0;
|
|
114
|
-
} finally {
|
|
115
|
-
f = t = 0;
|
|
23
|
+
return Promise.reject(e);
|
|
116
24
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
value: op[0] ? op[1] : void 0,
|
|
120
|
-
done: true
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
};
|
|
25
|
+
};
|
|
26
|
+
}
|
|
124
27
|
Object.defineProperty(exports, "__esModule", {
|
|
125
28
|
value: true
|
|
126
29
|
});
|
|
127
30
|
exports.sleep = void 0;
|
|
128
|
-
var sleep = function
|
|
129
|
-
return
|
|
130
|
-
return
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}, time);
|
|
137
|
-
})];
|
|
138
|
-
case 1:
|
|
139
|
-
_a.sent();
|
|
140
|
-
return [2 /*return*/];
|
|
141
|
-
}
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
|
|
31
|
+
var sleep = _async(function (time) {
|
|
32
|
+
return _awaitIgnored(new Promise(function (resolve) {
|
|
33
|
+
return setTimeout(function () {
|
|
34
|
+
resolve();
|
|
35
|
+
resolve = null;
|
|
36
|
+
}, time);
|
|
37
|
+
}));
|
|
38
|
+
});
|
|
146
39
|
exports.sleep = sleep;
|
package/lib/stack/index.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
4
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
5
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
6
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
3
7
|
Object.defineProperty(exports, "__esModule", {
|
|
4
8
|
value: true
|
|
5
9
|
});
|
|
6
10
|
exports.HistoryStack = void 0;
|
|
7
|
-
var HistoryStack =
|
|
11
|
+
var HistoryStack = /*#__PURE__*/function () {
|
|
8
12
|
function HistoryStack(len) {
|
|
9
13
|
if (len === void 0) {
|
|
10
14
|
len = 10;
|
|
@@ -14,21 +18,12 @@ var HistoryStack = /** @class */function () {
|
|
|
14
18
|
this.point = 0;
|
|
15
19
|
this.len = len;
|
|
16
20
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (this.point < this.stack.length && this.point > -1) {
|
|
20
|
-
return this.stack[this.point];
|
|
21
|
-
}
|
|
22
|
-
return undefined;
|
|
23
|
-
},
|
|
24
|
-
enumerable: false,
|
|
25
|
-
configurable: true
|
|
26
|
-
});
|
|
27
|
-
HistoryStack.prototype.clear = function () {
|
|
21
|
+
var _proto = HistoryStack.prototype;
|
|
22
|
+
_proto.clear = function clear() {
|
|
28
23
|
this.stack.length = 0;
|
|
29
24
|
this.point = 0;
|
|
30
25
|
};
|
|
31
|
-
|
|
26
|
+
_proto.backup = function backup(item) {
|
|
32
27
|
if (this.point > 0 && this.stack.length > 0) {
|
|
33
28
|
this.stack.splice(0, this.point);
|
|
34
29
|
this.point = 0;
|
|
@@ -38,18 +33,27 @@ var HistoryStack = /** @class */function () {
|
|
|
38
33
|
this.stack.pop();
|
|
39
34
|
}
|
|
40
35
|
};
|
|
41
|
-
|
|
36
|
+
_proto.undo = function undo() {
|
|
42
37
|
if (this.point < this.stack.length - 1) {
|
|
43
38
|
this.point += 1;
|
|
44
39
|
}
|
|
45
40
|
return this.current;
|
|
46
41
|
};
|
|
47
|
-
|
|
42
|
+
_proto.redo = function redo() {
|
|
48
43
|
if (this.point > 0) {
|
|
49
44
|
this.point -= 1;
|
|
50
45
|
}
|
|
51
46
|
return this.current;
|
|
52
47
|
};
|
|
48
|
+
_createClass(HistoryStack, [{
|
|
49
|
+
key: "current",
|
|
50
|
+
get: function get() {
|
|
51
|
+
if (this.point < this.stack.length && this.point > -1) {
|
|
52
|
+
return this.stack[this.point];
|
|
53
|
+
}
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}]);
|
|
53
57
|
return HistoryStack;
|
|
54
58
|
}();
|
|
55
59
|
exports.HistoryStack = HistoryStack;
|