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