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/emitter/index.js
CHANGED
|
@@ -1,177 +1,203 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
3
|
+
function _empty() {}
|
|
4
|
+
function _awaitIgnored(value, direct) {
|
|
5
|
+
if (!direct) {
|
|
6
|
+
return value && value.then ? value.then(_empty) : Promise.resolve();
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function _invokeIgnored(body) {
|
|
10
|
+
var result = body();
|
|
11
|
+
if (result && result.then) {
|
|
12
|
+
return result.then(_empty);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
var _iteratorSymbol = /*#__PURE__*/typeof Symbol !== "undefined" ? Symbol.iterator || (Symbol.iterator = Symbol("Symbol.iterator")) : "@@iterator";
|
|
16
|
+
function _settle(pact, state, value) {
|
|
17
|
+
if (!pact.s) {
|
|
18
|
+
if (value instanceof _Pact) {
|
|
19
|
+
if (value.s) {
|
|
20
|
+
if (state & 1) {
|
|
21
|
+
state = value.s;
|
|
22
|
+
}
|
|
23
|
+
value = value.v;
|
|
24
|
+
} else {
|
|
25
|
+
value.o = _settle.bind(null, pact, state);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
19
28
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
if (value && value.then) {
|
|
30
|
+
value.then(_settle.bind(null, pact, state), _settle.bind(null, pact, 2));
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
pact.s = state;
|
|
34
|
+
pact.v = value;
|
|
35
|
+
var observer = pact.o;
|
|
36
|
+
if (observer) {
|
|
37
|
+
observer(pact);
|
|
28
38
|
}
|
|
29
|
-
return t;
|
|
30
|
-
};
|
|
31
|
-
return __assign.apply(this, arguments);
|
|
32
|
-
};
|
|
33
|
-
var __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {
|
|
34
|
-
function adopt(value) {
|
|
35
|
-
return value instanceof P ? value : new P(function (resolve) {
|
|
36
|
-
resolve(value);
|
|
37
|
-
});
|
|
38
39
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
}
|
|
41
|
+
var _Pact = /*#__PURE__*/function () {
|
|
42
|
+
function _Pact() {}
|
|
43
|
+
_Pact.prototype.then = function (onFulfilled, onRejected) {
|
|
44
|
+
var result = new _Pact();
|
|
45
|
+
var state = this.s;
|
|
46
|
+
if (state) {
|
|
47
|
+
var callback = state & 1 ? onFulfilled : onRejected;
|
|
48
|
+
if (callback) {
|
|
49
|
+
try {
|
|
50
|
+
_settle(result, 1, callback(this.v));
|
|
51
|
+
} catch (e) {
|
|
52
|
+
_settle(result, 2, e);
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
} else {
|
|
56
|
+
return this;
|
|
45
57
|
}
|
|
46
58
|
}
|
|
47
|
-
function
|
|
59
|
+
this.o = function (_this) {
|
|
48
60
|
try {
|
|
49
|
-
|
|
61
|
+
var value = _this.v;
|
|
62
|
+
if (_this.s & 1) {
|
|
63
|
+
_settle(result, 1, onFulfilled ? onFulfilled(value) : value);
|
|
64
|
+
} else if (onRejected) {
|
|
65
|
+
_settle(result, 1, onRejected(value));
|
|
66
|
+
} else {
|
|
67
|
+
_settle(result, 2, value);
|
|
68
|
+
}
|
|
50
69
|
} catch (e) {
|
|
51
|
-
|
|
70
|
+
_settle(result, 2, e);
|
|
52
71
|
}
|
|
53
|
-
}
|
|
54
|
-
function step(result) {
|
|
55
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
56
|
-
}
|
|
57
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
var __generator = this && this.__generator || function (thisArg, body) {
|
|
61
|
-
var _ = {
|
|
62
|
-
label: 0,
|
|
63
|
-
sent: function sent() {
|
|
64
|
-
if (t[0] & 1) throw t[1];
|
|
65
|
-
return t[1];
|
|
66
|
-
},
|
|
67
|
-
trys: [],
|
|
68
|
-
ops: []
|
|
69
|
-
},
|
|
70
|
-
f,
|
|
71
|
-
y,
|
|
72
|
-
t,
|
|
73
|
-
g;
|
|
74
|
-
return g = {
|
|
75
|
-
next: verb(0),
|
|
76
|
-
"throw": verb(1),
|
|
77
|
-
"return": verb(2)
|
|
78
|
-
}, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
|
|
79
|
-
return this;
|
|
80
|
-
}), g;
|
|
81
|
-
function verb(n) {
|
|
82
|
-
return function (v) {
|
|
83
|
-
return step([n, v]);
|
|
84
72
|
};
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
continue;
|
|
107
|
-
case 7:
|
|
108
|
-
op = _.ops.pop();
|
|
109
|
-
_.trys.pop();
|
|
110
|
-
continue;
|
|
111
|
-
default:
|
|
112
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
113
|
-
_ = 0;
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
117
|
-
_.label = op[1];
|
|
118
|
-
break;
|
|
119
|
-
}
|
|
120
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
121
|
-
_.label = t[1];
|
|
122
|
-
t = op;
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
if (t && _.label < t[2]) {
|
|
126
|
-
_.label = t[2];
|
|
127
|
-
_.ops.push(op);
|
|
128
|
-
break;
|
|
73
|
+
return result;
|
|
74
|
+
};
|
|
75
|
+
return _Pact;
|
|
76
|
+
}();
|
|
77
|
+
function _isSettledPact(thenable) {
|
|
78
|
+
return thenable instanceof _Pact && thenable.s & 1;
|
|
79
|
+
}
|
|
80
|
+
function _forTo(array, body, check) {
|
|
81
|
+
var i = -1,
|
|
82
|
+
pact,
|
|
83
|
+
reject;
|
|
84
|
+
function _cycle(result) {
|
|
85
|
+
try {
|
|
86
|
+
while (++i < array.length && (!check || !check())) {
|
|
87
|
+
result = body(i);
|
|
88
|
+
if (result && result.then) {
|
|
89
|
+
if (_isSettledPact(result)) {
|
|
90
|
+
result = result.v;
|
|
91
|
+
} else {
|
|
92
|
+
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
|
|
93
|
+
return;
|
|
129
94
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (pact) {
|
|
98
|
+
_settle(pact, 1, result);
|
|
99
|
+
} else {
|
|
100
|
+
pact = result;
|
|
133
101
|
}
|
|
134
|
-
op = body.call(thisArg, _);
|
|
135
102
|
} catch (e) {
|
|
136
|
-
|
|
137
|
-
y = 0;
|
|
138
|
-
} finally {
|
|
139
|
-
f = t = 0;
|
|
103
|
+
_settle(pact || (pact = new _Pact()), 2, e);
|
|
140
104
|
}
|
|
141
|
-
if (op[0] & 5) throw op[1];
|
|
142
|
-
return {
|
|
143
|
-
value: op[0] ? op[1] : void 0,
|
|
144
|
-
done: true
|
|
145
|
-
};
|
|
146
105
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
106
|
+
_cycle();
|
|
107
|
+
return pact;
|
|
108
|
+
}
|
|
109
|
+
function _forOf(target, body, check) {
|
|
110
|
+
if (typeof target[_iteratorSymbol] === "function") {
|
|
111
|
+
var _cycle = function _cycle(result) {
|
|
112
|
+
try {
|
|
113
|
+
while (!(step = iterator.next()).done && (!check || !check())) {
|
|
114
|
+
result = body(step.value);
|
|
115
|
+
if (result && result.then) {
|
|
116
|
+
if (_isSettledPact(result)) {
|
|
117
|
+
result = result.v;
|
|
118
|
+
} else {
|
|
119
|
+
result.then(_cycle, reject || (reject = _settle.bind(null, pact = new _Pact(), 2)));
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (pact) {
|
|
125
|
+
_settle(pact, 1, result);
|
|
126
|
+
} else {
|
|
127
|
+
pact = result;
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
_settle(pact || (pact = new _Pact()), 2, e);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
var iterator = target[_iteratorSymbol](),
|
|
134
|
+
step,
|
|
135
|
+
pact,
|
|
136
|
+
reject;
|
|
137
|
+
_cycle();
|
|
138
|
+
if (iterator["return"]) {
|
|
139
|
+
var _fixup = function _fixup(value) {
|
|
140
|
+
try {
|
|
141
|
+
if (!step.done) {
|
|
142
|
+
iterator["return"]();
|
|
143
|
+
}
|
|
144
|
+
} catch (e) {}
|
|
145
|
+
return value;
|
|
159
146
|
};
|
|
147
|
+
if (pact && pact.then) {
|
|
148
|
+
return pact.then(_fixup, function (e) {
|
|
149
|
+
throw _fixup(e);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
_fixup();
|
|
160
153
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
154
|
+
return pact;
|
|
155
|
+
}
|
|
156
|
+
// No support for Symbol.iterator
|
|
157
|
+
if (!("length" in target)) {
|
|
158
|
+
throw new TypeError("Object is not iterable");
|
|
159
|
+
}
|
|
160
|
+
// Handle live collections properly
|
|
161
|
+
var values = [];
|
|
162
|
+
for (var i = 0; i < target.length; i++) {
|
|
163
|
+
values.push(target[i]);
|
|
164
|
+
}
|
|
165
|
+
return _forTo(values, function (i) {
|
|
166
|
+
return body(values[i]);
|
|
167
|
+
}, check);
|
|
168
|
+
}
|
|
169
|
+
function _continueIgnored(value) {
|
|
170
|
+
if (value && value.then) {
|
|
171
|
+
return value.then(_empty);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
function _await(value, then, direct) {
|
|
175
|
+
if (direct) {
|
|
176
|
+
return then ? then(value) : value;
|
|
177
|
+
}
|
|
178
|
+
if (!value || !value.then) {
|
|
179
|
+
value = Promise.resolve(value);
|
|
180
|
+
}
|
|
181
|
+
return then ? value.then(then) : value;
|
|
182
|
+
}
|
|
183
|
+
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
|
|
184
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
185
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
186
|
+
function _createForOfIteratorHelperLoose(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (it) return (it = it.call(o)).next.bind(it); if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; return function () { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
187
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
188
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
164
189
|
Object.defineProperty(exports, "__esModule", {
|
|
165
190
|
value: true
|
|
166
191
|
});
|
|
167
192
|
exports.CacheEmitter = exports.Emitter = void 0;
|
|
168
193
|
var random_1 = require("../random");
|
|
169
|
-
var Emitter =
|
|
194
|
+
var Emitter = /*#__PURE__*/function () {
|
|
170
195
|
function Emitter() {
|
|
171
196
|
this.state = {};
|
|
172
197
|
this.ids = {};
|
|
173
198
|
}
|
|
174
|
-
Emitter.prototype
|
|
199
|
+
var _proto = Emitter.prototype;
|
|
200
|
+
_proto.on = function on(event, func) {
|
|
175
201
|
if (!this.state[event]) {
|
|
176
202
|
this.state[event] = [];
|
|
177
203
|
}
|
|
@@ -186,15 +212,15 @@ var Emitter = /** @class */function () {
|
|
|
186
212
|
};
|
|
187
213
|
return key;
|
|
188
214
|
};
|
|
189
|
-
|
|
215
|
+
_proto.cancel = function cancel(id) {
|
|
190
216
|
var _this = this;
|
|
191
217
|
if (!id) {
|
|
192
218
|
this.clear();
|
|
193
219
|
return;
|
|
194
220
|
}
|
|
195
|
-
var
|
|
196
|
-
event =
|
|
197
|
-
index =
|
|
221
|
+
var _ref = this.ids[id] || {},
|
|
222
|
+
event = _ref.event,
|
|
223
|
+
index = _ref.index;
|
|
198
224
|
if (!event) {
|
|
199
225
|
return;
|
|
200
226
|
}
|
|
@@ -209,103 +235,67 @@ var Emitter = /** @class */function () {
|
|
|
209
235
|
}
|
|
210
236
|
});
|
|
211
237
|
};
|
|
212
|
-
|
|
238
|
+
_proto.clear = function clear() {
|
|
213
239
|
this.state.length = 0;
|
|
214
240
|
};
|
|
215
|
-
|
|
216
|
-
var e_1, _a;
|
|
241
|
+
_proto.emit = function emit(event, payload) {
|
|
217
242
|
if (Array.isArray(this.state[event])) {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
func(payload);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
} catch (e_1_1) {
|
|
226
|
-
e_1 = {
|
|
227
|
-
error: e_1_1
|
|
228
|
-
};
|
|
229
|
-
} finally {
|
|
230
|
-
try {
|
|
231
|
-
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
|
|
232
|
-
} finally {
|
|
233
|
-
if (e_1) throw e_1.error;
|
|
243
|
+
for (var _iterator = _createForOfIteratorHelperLoose(this.state[event]), _step; !(_step = _iterator()).done;) {
|
|
244
|
+
var func = _step.value;
|
|
245
|
+
if (typeof func === 'function') {
|
|
246
|
+
func(payload);
|
|
234
247
|
}
|
|
235
248
|
}
|
|
236
249
|
}
|
|
237
250
|
};
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
var
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
_d.label = 2;
|
|
251
|
-
case 2:
|
|
252
|
-
if (!!_b.done) return [3 /*break*/, 5];
|
|
253
|
-
func = _b.value;
|
|
254
|
-
if (!(typeof func === 'function')) return [3 /*break*/, 4];
|
|
255
|
-
return [4 /*yield*/, func(payload)];
|
|
256
|
-
case 3:
|
|
257
|
-
_d.sent();
|
|
258
|
-
_d.label = 4;
|
|
259
|
-
case 4:
|
|
260
|
-
_b = _a.next();
|
|
261
|
-
return [3 /*break*/, 2];
|
|
262
|
-
case 5:
|
|
263
|
-
return [3 /*break*/, 8];
|
|
264
|
-
case 6:
|
|
265
|
-
e_2_1 = _d.sent();
|
|
266
|
-
e_2 = {
|
|
267
|
-
error: e_2_1
|
|
268
|
-
};
|
|
269
|
-
return [3 /*break*/, 8];
|
|
270
|
-
case 7:
|
|
271
|
-
try {
|
|
272
|
-
if (_b && !_b.done && (_c = _a["return"])) _c.call(_a);
|
|
273
|
-
} finally {
|
|
274
|
-
if (e_2) throw e_2.error;
|
|
275
|
-
}
|
|
276
|
-
return [7 /*endfinally*/];
|
|
277
|
-
case 8:
|
|
278
|
-
return [2 /*return*/];
|
|
251
|
+
_proto.emitSync = function emitSync(event, payload) {
|
|
252
|
+
try {
|
|
253
|
+
var _this2 = this;
|
|
254
|
+
return _await(_invokeIgnored(function () {
|
|
255
|
+
if (Array.isArray(_this2.state[event])) {
|
|
256
|
+
return _continueIgnored(_forOf(_this2.state[event], function (func) {
|
|
257
|
+
return _invokeIgnored(function () {
|
|
258
|
+
if (typeof func === 'function') {
|
|
259
|
+
return _awaitIgnored(func(payload));
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
}));
|
|
279
263
|
}
|
|
280
|
-
});
|
|
281
|
-
})
|
|
264
|
+
}));
|
|
265
|
+
} catch (e) {
|
|
266
|
+
return Promise.reject(e);
|
|
267
|
+
}
|
|
282
268
|
};
|
|
283
|
-
|
|
284
|
-
Emitter.prototype.clone = function () {
|
|
269
|
+
_proto.clone = function clone() {
|
|
285
270
|
return {
|
|
286
|
-
state:
|
|
287
|
-
ids:
|
|
271
|
+
state: _extends({}, this.state),
|
|
272
|
+
ids: _extends({}, this.ids)
|
|
288
273
|
};
|
|
289
274
|
};
|
|
290
|
-
|
|
275
|
+
_proto.restore = function restore(snapshot) {
|
|
291
276
|
this.state = snapshot.state;
|
|
292
277
|
this.ids = snapshot.ids;
|
|
293
278
|
};
|
|
294
279
|
return Emitter;
|
|
295
280
|
}();
|
|
296
281
|
exports.Emitter = Emitter;
|
|
297
|
-
var CacheEmitter =
|
|
298
|
-
|
|
282
|
+
var CacheEmitter = /*#__PURE__*/function (_Emitter) {
|
|
283
|
+
_inheritsLoose(CacheEmitter, _Emitter);
|
|
299
284
|
function CacheEmitter() {
|
|
300
|
-
var
|
|
301
|
-
|
|
302
|
-
|
|
285
|
+
var _this3;
|
|
286
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
287
|
+
args[_key] = arguments[_key];
|
|
288
|
+
}
|
|
289
|
+
_this3 = _Emitter.call.apply(_Emitter, [this].concat(args)) || this;
|
|
290
|
+
_this3._cache = {};
|
|
291
|
+
return _this3;
|
|
303
292
|
}
|
|
304
|
-
CacheEmitter.prototype
|
|
293
|
+
var _proto2 = CacheEmitter.prototype;
|
|
294
|
+
_proto2.emit = function emit(event, payload) {
|
|
305
295
|
this._cache[event] = payload;
|
|
306
|
-
|
|
296
|
+
_Emitter.prototype.emit.call(this, event, payload);
|
|
307
297
|
};
|
|
308
|
-
|
|
298
|
+
_proto2.getState = function getState(event) {
|
|
309
299
|
return this._cache[event];
|
|
310
300
|
};
|
|
311
301
|
return CacheEmitter;
|
package/lib/factory/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var __values = this && this.__values || function (o) {
|
|
4
|
-
var s = typeof Symbol === "function" && Symbol.iterator,
|
|
5
|
-
m = s && o[s],
|
|
6
|
-
i = 0;
|
|
7
|
-
if (m) return m.call(o);
|
|
8
|
-
if (o && typeof o.length === "number") return {
|
|
9
|
-
next: function next() {
|
|
10
|
-
if (o && i >= o.length) o = void 0;
|
|
11
|
-
return {
|
|
12
|
-
value: o && o[i++],
|
|
13
|
-
done: !o
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
18
|
-
};
|
|
19
3
|
Object.defineProperty(exports, "__esModule", {
|
|
20
4
|
value: true
|
|
21
5
|
});
|
|
@@ -28,23 +12,10 @@ exports.superFactory = void 0;
|
|
|
28
12
|
*/
|
|
29
13
|
var superFactory = function superFactory(factory) {
|
|
30
14
|
return function (options) {
|
|
31
|
-
var e_1, _a;
|
|
32
15
|
var product = {};
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
product[key] = factory(options[key], key);
|
|
37
|
-
}
|
|
38
|
-
} catch (e_1_1) {
|
|
39
|
-
e_1 = {
|
|
40
|
-
error: e_1_1
|
|
41
|
-
};
|
|
42
|
-
} finally {
|
|
43
|
-
try {
|
|
44
|
-
if (_c && !_c.done && (_a = _b["return"])) _a.call(_b);
|
|
45
|
-
} finally {
|
|
46
|
-
if (e_1) throw e_1.error;
|
|
47
|
-
}
|
|
16
|
+
for (var _i = 0, _Object$keys = Object.keys(options); _i < _Object$keys.length; _i++) {
|
|
17
|
+
var key = _Object$keys[_i];
|
|
18
|
+
product[key] = factory(options[key], key);
|
|
48
19
|
}
|
|
49
20
|
return product;
|
|
50
21
|
};
|