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