@zajno/common 1.4.3 → 1.4.4
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/coverage/clover.xml +2 -2
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/src/__tests__/helpers/index.html +1 -1
- package/coverage/lcov-report/src/__tests__/helpers/main.ts.html +1 -1
- package/coverage/lcov-report/src/async/arrays.ts.html +1 -1
- package/coverage/lcov-report/src/async/index.html +1 -1
- package/coverage/lcov-report/src/dates/calc.ts.html +1 -1
- package/coverage/lcov-report/src/dates/convert.ts.html +1 -1
- package/coverage/lcov-report/src/dates/datex.ts.html +1 -1
- package/coverage/lcov-report/src/dates/format.ts.html +1 -1
- package/coverage/lcov-report/src/dates/index.html +1 -1
- package/coverage/lcov-report/src/dates/index.ts.html +1 -1
- package/coverage/lcov-report/src/dates/parse.ts.html +1 -1
- package/coverage/lcov-report/src/dates/period.ts.html +1 -1
- package/coverage/lcov-report/src/dates/shift.ts.html +1 -1
- package/coverage/lcov-report/src/dates/types.ts.html +1 -1
- package/coverage/lcov-report/src/dates/yearDate.ts.html +1 -1
- package/coverage/lcov-report/src/enumHelper.ts.html +1 -1
- package/coverage/lcov-report/src/event.ts.html +1 -1
- package/coverage/lcov-report/src/fields/index.html +1 -1
- package/coverage/lcov-report/src/fields/update.ts.html +1 -1
- package/coverage/lcov-report/src/functions.ts.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/lazy.light.ts.html +1 -1
- package/coverage/lcov-report/src/logger/batch.ts.html +1 -1
- package/coverage/lcov-report/src/logger/console.ts.html +1 -1
- package/coverage/lcov-report/src/logger/index.html +1 -1
- package/coverage/lcov-report/src/logger/index.ts.html +1 -1
- package/coverage/lcov-report/src/logger/named.ts.html +1 -1
- package/coverage/lcov-report/src/logger/proxy.ts.html +1 -1
- package/coverage/lcov-report/src/math/arrays.ts.html +1 -1
- package/coverage/lcov-report/src/math/calc.ts.html +1 -1
- package/coverage/lcov-report/src/math/distribution.ts.html +1 -1
- package/coverage/lcov-report/src/math/index.html +1 -1
- package/coverage/lcov-report/src/math/index.ts.html +1 -1
- package/coverage/lcov-report/src/transitionObserver.ts.html +1 -1
- package/coverage/lcov-report/src/types.ts.html +1 -1
- package/coverage/lcov-report/src/validation/ValidationErrors.ts.html +1 -1
- package/coverage/lcov-report/src/validation/creditCard.ts.html +1 -1
- package/coverage/lcov-report/src/validation/helpers.ts.html +1 -1
- package/coverage/lcov-report/src/validation/index.html +1 -1
- package/coverage/lcov-report/src/validation/index.ts.html +1 -1
- package/coverage/lcov-report/src/validation/types.ts.html +1 -1
- package/coverage/lcov-report/src/validation/validators.ts.html +2 -2
- package/coverage/lcov-report/src/validation/wrappers.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/FlagModel.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/MultiSelectModel.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/NumberModel.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/SelectModel.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/Validatable.ts.html +1 -1
- package/coverage/lcov-report/src/viewModels/index.html +1 -1
- package/coverage/lcov-report/src/viewModels/wrappers.ts.html +1 -1
- package/lib/observers.d.ts +16 -0
- package/lib/observers.d.ts.map +1 -0
- package/lib/observers.js +74 -0
- package/lib/observers.js.map +1 -0
- package/lib/validation/validators.js +1 -1
- package/package.json +1 -1
- package/src/observers.ts +82 -0
- package/src/validation/validators.ts +1 -1
package/coverage/clover.xml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<coverage generated="
|
|
3
|
-
<project timestamp="
|
|
2
|
+
<coverage generated="1644317470371" clover="3.2.0">
|
|
3
|
+
<project timestamp="1644317470371" name="All files">
|
|
4
4
|
<metrics statements="1217" coveredstatements="1030" conditionals="781" coveredconditionals="623" methods="359" coveredmethods="257" elements="2357" coveredelements="1910" complexity="0" loc="1217" ncloc="1217" packages="9" files="41" classes="41"/>
|
|
5
5
|
<package name="src">
|
|
6
6
|
<metrics statements="184" coveredstatements="160" conditionals="101" coveredconditionals="83" methods="69" coveredmethods="55"/>
|
|
@@ -215,7 +215,7 @@
|
|
|
215
215
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
216
216
|
Code coverage generated by
|
|
217
217
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
218
|
-
at Tue Feb
|
|
218
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
219
219
|
</div>
|
|
220
220
|
</div>
|
|
221
221
|
<script src="prettify.js"></script>
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
96
96
|
Code coverage generated by
|
|
97
97
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
98
|
-
at Tue Feb
|
|
98
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
99
99
|
</div>
|
|
100
100
|
</div>
|
|
101
101
|
<script src="../../../prettify.js"></script>
|
|
@@ -100,7 +100,7 @@ export const toArbitrary = (fakerGen) => {
|
|
|
100
100
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
101
101
|
Code coverage generated by
|
|
102
102
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
103
|
-
at Tue Feb
|
|
103
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
104
104
|
</div>
|
|
105
105
|
</div>
|
|
106
106
|
<script src="../../../prettify.js"></script>
|
|
@@ -178,7 +178,7 @@ export async function <span class="fstat-no" title="function not covered" >mapAs
|
|
|
178
178
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
179
179
|
Code coverage generated by
|
|
180
180
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
181
|
-
at Tue Feb
|
|
181
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
182
182
|
</div>
|
|
183
183
|
</div>
|
|
184
184
|
<script src="../../prettify.js"></script>
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
96
96
|
Code coverage generated by
|
|
97
97
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
98
|
-
at Tue Feb
|
|
98
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
99
99
|
</div>
|
|
100
100
|
</div>
|
|
101
101
|
<script src="../../prettify.js"></script>
|
|
@@ -280,7 +280,7 @@ export function clamp(d: Date, low: Date, high: Date) {
|
|
|
280
280
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
281
281
|
Code coverage generated by
|
|
282
282
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
283
|
-
at Tue Feb
|
|
283
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
284
284
|
</div>
|
|
285
285
|
</div>
|
|
286
286
|
<script src="../../prettify.js"></script>
|
|
@@ -637,7 +637,7 @@ export function getDaysStreak(dates: number[], descentOrder: boolean): number {
|
|
|
637
637
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
638
638
|
Code coverage generated by
|
|
639
639
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
640
|
-
at Tue Feb
|
|
640
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
641
641
|
</div>
|
|
642
642
|
</div>
|
|
643
643
|
<script src="../../prettify.js"></script>
|
|
@@ -190,7 +190,7 @@ export namespace DateX {
|
|
|
190
190
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
191
191
|
Code coverage generated by
|
|
192
192
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
193
|
-
at Tue Feb
|
|
193
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
194
194
|
</div>
|
|
195
195
|
</div>
|
|
196
196
|
<script src="../../prettify.js"></script>
|
|
@@ -382,7 +382,7 @@ export namespace Format {
|
|
|
382
382
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
383
383
|
Code coverage generated by
|
|
384
384
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
385
|
-
at Tue Feb
|
|
385
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
386
386
|
</div>
|
|
387
387
|
</div>
|
|
388
388
|
<script src="../../prettify.js"></script>
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
231
231
|
Code coverage generated by
|
|
232
232
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
233
|
-
at Tue Feb
|
|
233
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
234
234
|
</div>
|
|
235
235
|
</div>
|
|
236
236
|
<script src="../../prettify.js"></script>
|
|
@@ -91,7 +91,7 @@ export * from './yearDate';
|
|
|
91
91
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
92
92
|
Code coverage generated by
|
|
93
93
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
94
|
-
at Tue Feb
|
|
94
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
95
95
|
</div>
|
|
96
96
|
</div>
|
|
97
97
|
<script src="../../prettify.js"></script>
|
|
@@ -136,7 +136,7 @@ export namespace Parse {
|
|
|
136
136
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
137
137
|
Code coverage generated by
|
|
138
138
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
139
|
-
at Tue Feb
|
|
139
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
140
140
|
</div>
|
|
141
141
|
</div>
|
|
142
142
|
<script src="../../prettify.js"></script>
|
|
@@ -133,7 +133,7 @@ export namespace Period {
|
|
|
133
133
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
134
134
|
Code coverage generated by
|
|
135
135
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
136
|
-
at Tue Feb
|
|
136
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
137
137
|
</div>
|
|
138
138
|
</div>
|
|
139
139
|
<script src="../../prettify.js"></script>
|
|
@@ -334,7 +334,7 @@ export function isSame(d1: Date | number, d2: Date | number, g: Granularity, loc
|
|
|
334
334
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
335
335
|
Code coverage generated by
|
|
336
336
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
337
|
-
at Tue Feb
|
|
337
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
338
338
|
</div>
|
|
339
339
|
</div>
|
|
340
340
|
<script src="../../prettify.js"></script>
|
|
@@ -160,7 +160,7 @@ export namespace ConstantGranularity {
|
|
|
160
160
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
161
161
|
Code coverage generated by
|
|
162
162
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
163
|
-
at Tue Feb
|
|
163
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
164
164
|
</div>
|
|
165
165
|
</div>
|
|
166
166
|
<script src="../../prettify.js"></script>
|
|
@@ -172,7 +172,7 @@ export namespace YearDate {
|
|
|
172
172
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
173
173
|
Code coverage generated by
|
|
174
174
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
175
|
-
at Tue Feb
|
|
175
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
176
176
|
</div>
|
|
177
177
|
</div>
|
|
178
178
|
<script src="../../prettify.js"></script>
|
|
@@ -433,7 +433,7 @@ export class EnumBitwiseHelper<T extends number> extends EnumHelper<T&g
|
|
|
433
433
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
434
434
|
Code coverage generated by
|
|
435
435
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
436
|
-
at Tue Feb
|
|
436
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
437
437
|
</div>
|
|
438
438
|
</div>
|
|
439
439
|
<script src="../prettify.js"></script>
|
|
@@ -262,7 +262,7 @@ export class Event<T = any> implements IEvent<T> {
|
|
|
262
262
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
263
263
|
Code coverage generated by
|
|
264
264
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
265
|
-
at Tue Feb
|
|
265
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
266
266
|
</div>
|
|
267
267
|
</div>
|
|
268
268
|
<script src="../prettify.js"></script>
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
96
96
|
Code coverage generated by
|
|
97
97
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
98
|
-
at Tue Feb
|
|
98
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
99
99
|
</div>
|
|
100
100
|
</div>
|
|
101
101
|
<script src="../../prettify.js"></script>
|
|
@@ -415,7 +415,7 @@ export function updateArray<T>(
|
|
|
415
415
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
416
416
|
Code coverage generated by
|
|
417
417
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
418
|
-
at Tue Feb
|
|
418
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
419
419
|
</div>
|
|
420
420
|
</div>
|
|
421
421
|
<script src="../../prettify.js"></script>
|
|
@@ -106,7 +106,7 @@ export function safeCall<T extends (...args: any) => any>(cb: T | undef
|
|
|
106
106
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
107
107
|
Code coverage generated by
|
|
108
108
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
109
|
-
at Tue Feb
|
|
109
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
110
110
|
</div>
|
|
111
111
|
</div>
|
|
112
112
|
<script src="../prettify.js"></script>
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
171
171
|
Code coverage generated by
|
|
172
172
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
173
|
-
at Tue Feb
|
|
173
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
174
174
|
</div>
|
|
175
175
|
</div>
|
|
176
176
|
<script src="../prettify.js"></script>
|
|
@@ -151,7 +151,7 @@ export function createLazy<T>(factory: () => T) {
|
|
|
151
151
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
152
152
|
Code coverage generated by
|
|
153
153
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
154
|
-
at Tue Feb
|
|
154
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
155
155
|
</div>
|
|
156
156
|
</div>
|
|
157
157
|
<script src="../prettify.js"></script>
|
|
@@ -91,7 +91,7 @@ export function batchLoggers(...loggers: ILogger[]): ILogger {
|
|
|
91
91
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
92
92
|
Code coverage generated by
|
|
93
93
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
94
|
-
at Tue Feb
|
|
94
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
95
95
|
</div>
|
|
96
96
|
</div>
|
|
97
97
|
<script src="../../prettify.js"></script>
|
|
@@ -220,7 +220,7 @@ export class BufferedConsoleLogger implements ILogger {
|
|
|
220
220
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
221
221
|
Code coverage generated by
|
|
222
222
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
223
|
-
at Tue Feb
|
|
223
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
224
224
|
</div>
|
|
225
225
|
</div>
|
|
226
226
|
<script src="../../prettify.js"></script>
|
|
@@ -155,7 +155,7 @@
|
|
|
155
155
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
156
156
|
Code coverage generated by
|
|
157
157
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
158
|
-
at Tue Feb
|
|
158
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
159
159
|
</div>
|
|
160
160
|
</div>
|
|
161
161
|
<script src="../../prettify.js"></script>
|
|
@@ -277,7 +277,7 @@ function _createImplementation(overrideMode: typeof Mode = undefined): ILogger {
|
|
|
277
277
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
278
278
|
Code coverage generated by
|
|
279
279
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
280
|
-
at Tue Feb
|
|
280
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
281
281
|
</div>
|
|
282
282
|
</div>
|
|
283
283
|
<script src="../../prettify.js"></script>
|
|
@@ -205,7 +205,7 @@ export abstract class NamedLogger implements ILogger, ILoggerSwitchable {
|
|
|
205
205
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
206
206
|
Code coverage generated by
|
|
207
207
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
208
|
-
at Tue Feb
|
|
208
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
209
209
|
</div>
|
|
210
210
|
</div>
|
|
211
211
|
<script src="../../prettify.js"></script>
|
|
@@ -151,7 +151,7 @@ export class ProxyLogger extends NamedLogger {
|
|
|
151
151
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
152
152
|
Code coverage generated by
|
|
153
153
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
154
|
-
at Tue Feb
|
|
154
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
155
155
|
</div>
|
|
156
156
|
</div>
|
|
157
157
|
<script src="../../prettify.js"></script>
|
|
@@ -847,7 +847,7 @@ export function arrayRepeat<T>(factory: Getter<T>, count = <span cla
|
|
|
847
847
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
848
848
|
Code coverage generated by
|
|
849
849
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
850
|
-
at Tue Feb
|
|
850
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
851
851
|
</div>
|
|
852
852
|
</div>
|
|
853
853
|
<script src="../../prettify.js"></script>
|
|
@@ -271,7 +271,7 @@ export function <span class="fstat-no" title="function not covered" >badRandomSt
|
|
|
271
271
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
272
272
|
Code coverage generated by
|
|
273
273
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
274
|
-
at Tue Feb
|
|
274
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
275
275
|
</div>
|
|
276
276
|
</div>
|
|
277
277
|
<script src="../../prettify.js"></script>
|
|
@@ -124,7 +124,7 @@ export function extendDistribution<T extends keyof any>(count: number, typ
|
|
|
124
124
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
125
125
|
Code coverage generated by
|
|
126
126
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
127
|
-
at Tue Feb
|
|
127
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
128
128
|
</div>
|
|
129
129
|
</div>
|
|
130
130
|
<script src="../../prettify.js"></script>
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
141
141
|
Code coverage generated by
|
|
142
142
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
143
|
-
at Tue Feb
|
|
143
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
144
144
|
</div>
|
|
145
145
|
</div>
|
|
146
146
|
<script src="../../prettify.js"></script>
|
|
@@ -145,7 +145,7 @@ export function format(n: number, digits?: number) {
|
|
|
145
145
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
146
146
|
Code coverage generated by
|
|
147
147
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
148
|
-
at Tue Feb
|
|
148
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
149
149
|
</div>
|
|
150
150
|
</div>
|
|
151
151
|
<script src="../../prettify.js"></script>
|
|
@@ -613,7 +613,7 @@ export function <span class="fstat-no" title="function not covered" >waitFor<
|
|
|
613
613
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
614
614
|
Code coverage generated by
|
|
615
615
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
616
|
-
at Tue Feb
|
|
616
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
617
617
|
</div>
|
|
618
618
|
</div>
|
|
619
619
|
<script src="../prettify.js"></script>
|
|
@@ -154,7 +154,7 @@ export type TypedKeys<T extends Object, K> = {
|
|
|
154
154
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
155
155
|
Code coverage generated by
|
|
156
156
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
157
|
-
at Tue Feb
|
|
157
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
158
158
|
</div>
|
|
159
159
|
</div>
|
|
160
160
|
<script src="../prettify.js"></script>
|
|
@@ -142,7 +142,7 @@ export namespace <span class="branch-1 cbranch-no" title="branch not covered" >V
|
|
|
142
142
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
143
143
|
Code coverage generated by
|
|
144
144
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
145
|
-
at Tue Feb
|
|
145
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
146
146
|
</div>
|
|
147
147
|
</div>
|
|
148
148
|
<script src="../../prettify.js"></script>
|
|
@@ -139,7 +139,7 @@ export default {
|
|
|
139
139
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
140
140
|
Code coverage generated by
|
|
141
141
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
142
|
-
at Tue Feb
|
|
142
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
143
143
|
</div>
|
|
144
144
|
</div>
|
|
145
145
|
<script src="../../prettify.js"></script>
|
|
@@ -208,7 +208,7 @@ export function <span class="fstat-no" title="function not covered" >validateObj
|
|
|
208
208
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
209
209
|
Code coverage generated by
|
|
210
210
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
211
|
-
at Tue Feb
|
|
211
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
212
212
|
</div>
|
|
213
213
|
</div>
|
|
214
214
|
<script src="../../prettify.js"></script>
|
|
@@ -185,7 +185,7 @@
|
|
|
185
185
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
186
186
|
Code coverage generated by
|
|
187
187
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
188
|
-
at Tue Feb
|
|
188
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
189
189
|
</div>
|
|
190
190
|
</div>
|
|
191
191
|
<script src="../../prettify.js"></script>
|
|
@@ -91,7 +91,7 @@ export * from './helpers';
|
|
|
91
91
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
92
92
|
Code coverage generated by
|
|
93
93
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
94
|
-
at Tue Feb
|
|
94
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
95
95
|
</div>
|
|
96
96
|
</div>
|
|
97
97
|
<script src="../../prettify.js"></script>
|
|
@@ -109,7 +109,7 @@ export class ValidationError<TErrors = ValidationErrors> extends Error {
|
|
|
109
109
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
110
110
|
Code coverage generated by
|
|
111
111
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
112
|
-
at Tue Feb
|
|
112
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
113
113
|
</div>
|
|
114
114
|
</div>
|
|
115
115
|
<script src="../../prettify.js"></script>
|
|
@@ -191,7 +191,7 @@ export const ValidatorsRegExps = {
|
|
|
191
191
|
expiryDateCard: /^\d+$/,
|
|
192
192
|
cvv: /^\d+$/,
|
|
193
193
|
// eslint-disable-next-line no-useless-escape
|
|
194
|
-
website: /^(https?:\/\/)?([a-z0-9]+(
|
|
194
|
+
website: /^(https?:\/\/)?([a-z0-9]+([a-z0-9\-]+\.))+[a-z]{2,}(:[0-9]{1,})?(\/.*)?$/i,
|
|
195
195
|
linkedin: /^(https?:\/\/)?([a-z]+\d*[a-z]*\.)?linkedin\.com\/.*$/i,
|
|
196
196
|
};
|
|
197
197
|
|
|
@@ -229,7 +229,7 @@ export const Validators = {
|
|
|
229
229
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
230
230
|
Code coverage generated by
|
|
231
231
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
232
|
-
at Tue Feb
|
|
232
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
233
233
|
</div>
|
|
234
234
|
</div>
|
|
235
235
|
<script src="../../prettify.js"></script>
|
|
@@ -142,7 +142,7 @@ export const Wrappers = {
|
|
|
142
142
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
143
143
|
Code coverage generated by
|
|
144
144
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
145
|
-
at Tue Feb
|
|
145
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
146
146
|
</div>
|
|
147
147
|
</div>
|
|
148
148
|
<script src="../../prettify.js"></script>
|
|
@@ -253,7 +253,7 @@ export class FlagModel implements IFlagModel, IFlagModelReadonly {
|
|
|
253
253
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
254
254
|
Code coverage generated by
|
|
255
255
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
256
|
-
at Tue Feb
|
|
256
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
257
257
|
</div>
|
|
258
258
|
</div>
|
|
259
259
|
<script src="../../prettify.js"></script>
|
|
@@ -568,7 +568,7 @@ export class MultiSelectString<T extends string = string> extends MultiSel
|
|
|
568
568
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
569
569
|
Code coverage generated by
|
|
570
570
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
571
|
-
at Tue Feb
|
|
571
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
572
572
|
</div>
|
|
573
573
|
</div>
|
|
574
574
|
<script src="../../prettify.js"></script>
|
|
@@ -196,7 +196,7 @@ export default NumberModel;
|
|
|
196
196
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
197
197
|
Code coverage generated by
|
|
198
198
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
199
|
-
at Tue Feb
|
|
199
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
200
200
|
</div>
|
|
201
201
|
</div>
|
|
202
202
|
<script src="../../prettify.js"></script>
|
|
@@ -475,7 +475,7 @@ export class SelectString<T extends string = string> extends Select<T&g
|
|
|
475
475
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
476
476
|
Code coverage generated by
|
|
477
477
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
478
|
-
at Tue Feb
|
|
478
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
479
479
|
</div>
|
|
480
480
|
</div>
|
|
481
481
|
<script src="../../prettify.js"></script>
|
|
@@ -361,7 +361,7 @@ export abstract class ValidatableModel<T = string> {
|
|
|
361
361
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
362
362
|
Code coverage generated by
|
|
363
363
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
364
|
-
at Tue Feb
|
|
364
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
365
365
|
</div>
|
|
366
366
|
</div>
|
|
367
367
|
<script src="../../prettify.js"></script>
|
|
@@ -170,7 +170,7 @@
|
|
|
170
170
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
171
171
|
Code coverage generated by
|
|
172
172
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
173
|
-
at Tue Feb
|
|
173
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
174
174
|
</div>
|
|
175
175
|
</div>
|
|
176
176
|
<script src="../../prettify.js"></script>
|
|
@@ -211,7 +211,7 @@ export function mixinLabel<T, TModel extends IValueModel<T>, TLabel = s
|
|
|
211
211
|
<div class='footer quiet pad2 space-top1 center small'>
|
|
212
212
|
Code coverage generated by
|
|
213
213
|
<a href="https://istanbul.js.org/" target="_blank">istanbul</a>
|
|
214
|
-
at Tue Feb
|
|
214
|
+
at Tue Feb 08 2022 10:51:10 GMT+0000 (Coordinated Universal Time)
|
|
215
215
|
</div>
|
|
216
216
|
</div>
|
|
217
217
|
<script src="../../prettify.js"></script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IDisposable } from './disposer';
|
|
2
|
+
declare type Unsub = () => void;
|
|
3
|
+
export declare class Observers implements IDisposable {
|
|
4
|
+
readonly subscribe: (key: string) => Promise<Unsub[]>;
|
|
5
|
+
readonly name?: string;
|
|
6
|
+
private readonly _map;
|
|
7
|
+
private readonly _timeouts;
|
|
8
|
+
private readonly _logger;
|
|
9
|
+
constructor(subscribe: (key: string) => Promise<Unsub[]>, name?: string);
|
|
10
|
+
getIsObserving(key: string): boolean;
|
|
11
|
+
enable(key: string, enable: boolean, clearAfter?: number): Promise<void>;
|
|
12
|
+
private refreshTimeout;
|
|
13
|
+
dispose(): void;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=observers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observers.d.ts","sourceRoot":"","sources":["../src/observers.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D,aAAK,KAAK,GAAG,MAAM,IAAI,CAAC;AAExB,qBAAa,SAAU,YAAW,WAAW;IAM7B,QAAQ,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM;IALzF,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiC;IACtD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA0B;IAEpD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;gBAEpB,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,EAAE,CAAC,EAAW,IAAI,CAAC,EAAE,MAAM;IAIlF,cAAc,CAAC,GAAG,EAAE,MAAM;IAIpB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAE,MAAa;IAiC3E,OAAO,CAAC,cAAc;IAkBf,OAAO;CAWjB"}
|
package/lib/observers.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Observers = void 0;
|
|
4
|
+
const logger_1 = require("./logger");
|
|
5
|
+
const disposer_1 = require("./disposer");
|
|
6
|
+
class Observers {
|
|
7
|
+
constructor(subscribe, name) {
|
|
8
|
+
this.subscribe = subscribe;
|
|
9
|
+
this.name = name;
|
|
10
|
+
this._map = new Map();
|
|
11
|
+
this._timeouts = new Map();
|
|
12
|
+
this._logger = null;
|
|
13
|
+
this._logger = logger_1.createLogger(`[Observers:${this.name || '?'}]`);
|
|
14
|
+
}
|
|
15
|
+
getIsObserving(key) {
|
|
16
|
+
return this._map.has(key);
|
|
17
|
+
}
|
|
18
|
+
async enable(key, enable, clearAfter = null) {
|
|
19
|
+
if (enable === this.getIsObserving(key)) {
|
|
20
|
+
this.refreshTimeout(key, enable, clearAfter, true);
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (enable) {
|
|
24
|
+
this._logger.log('Adding observer for key =', key, clearAfter ? `, clearAfter = ${clearAfter}` : '');
|
|
25
|
+
// this marker will help to determine whether unsubscribe was requested while we were in process of subscribing
|
|
26
|
+
let disabed = false;
|
|
27
|
+
const marker = () => { disabed = true; };
|
|
28
|
+
this._map.set(key, marker);
|
|
29
|
+
const unsubs = await this.subscribe(key);
|
|
30
|
+
const result = disposer_1.combineDisposers(...unsubs);
|
|
31
|
+
if (disabed) { // unsubscribe was requested
|
|
32
|
+
result();
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this._map.set(key, result);
|
|
36
|
+
this.refreshTimeout(key, true, clearAfter);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this._logger.log('Removing observer for key =', key);
|
|
41
|
+
this.refreshTimeout(key, false);
|
|
42
|
+
const unsub = this._map.get(key);
|
|
43
|
+
this._map.delete(key);
|
|
44
|
+
unsub();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
refreshTimeout(key, enable, timeout, refresh = false) {
|
|
48
|
+
const current = this._timeouts.get(key);
|
|
49
|
+
if (current) {
|
|
50
|
+
clearTimeout(current);
|
|
51
|
+
this._timeouts.delete(key);
|
|
52
|
+
}
|
|
53
|
+
if (enable && refresh && current == null) {
|
|
54
|
+
// DO NOT setup new timeout because it's not intended to clear subscribtion if it was previously enabled for long term
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (enable && timeout) {
|
|
58
|
+
const t = setTimeout(() => this.enable(key, false), timeout);
|
|
59
|
+
this._timeouts.set(key, t);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
dispose() {
|
|
63
|
+
for (const u of this._map.values()) {
|
|
64
|
+
u();
|
|
65
|
+
}
|
|
66
|
+
this._map.clear();
|
|
67
|
+
for (const t of this._timeouts.values()) {
|
|
68
|
+
clearTimeout(t);
|
|
69
|
+
}
|
|
70
|
+
this._timeouts.clear();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.Observers = Observers;
|
|
74
|
+
//# sourceMappingURL=observers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"observers.js","sourceRoot":"","sources":["../src/observers.ts"],"names":[],"mappings":"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"}
|
|
@@ -22,7 +22,7 @@ exports.ValidatorsRegExps = {
|
|
|
22
22
|
expiryDateCard: /^\d+$/,
|
|
23
23
|
cvv: /^\d+$/,
|
|
24
24
|
// eslint-disable-next-line no-useless-escape
|
|
25
|
-
website: /^(https?:\/\/)?([a-z0-9]+(
|
|
25
|
+
website: /^(https?:\/\/)?([a-z0-9]+([a-z0-9\-]+\.))+[a-z]{2,}(:[0-9]{1,})?(\/.*)?$/i,
|
|
26
26
|
linkedin: /^(https?:\/\/)?([a-z]+\d*[a-z]*\.)?linkedin\.com\/.*$/i,
|
|
27
27
|
};
|
|
28
28
|
exports.Validators = {
|
package/package.json
CHANGED
package/src/observers.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { createLogger, ILogger } from './logger';
|
|
2
|
+
import { combineDisposers, IDisposable } from './disposer';
|
|
3
|
+
|
|
4
|
+
type Unsub = () => void;
|
|
5
|
+
|
|
6
|
+
export class Observers implements IDisposable {
|
|
7
|
+
private readonly _map = new Map<string, () => void>();
|
|
8
|
+
private readonly _timeouts = new Map<string, any>();
|
|
9
|
+
|
|
10
|
+
private readonly _logger: ILogger = null;
|
|
11
|
+
|
|
12
|
+
constructor(readonly subscribe: (key: string) => Promise<Unsub[]>, readonly name?: string) {
|
|
13
|
+
this._logger = createLogger(`[Observers:${this.name || '?'}]`);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
public getIsObserving(key: string) {
|
|
17
|
+
return this._map.has(key);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
public async enable(key: string, enable: boolean, clearAfter: number = null) {
|
|
21
|
+
if (enable === this.getIsObserving(key)) {
|
|
22
|
+
this.refreshTimeout(key, enable, clearAfter, true);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (enable) {
|
|
27
|
+
this._logger.log('Adding observer for key =', key, clearAfter ? `, clearAfter = ${clearAfter}` : '');
|
|
28
|
+
|
|
29
|
+
// this marker will help to determine whether unsubscribe was requested while we were in process of subscribing
|
|
30
|
+
let disabed = false;
|
|
31
|
+
const marker = () => { disabed = true; };
|
|
32
|
+
|
|
33
|
+
this._map.set(key, marker);
|
|
34
|
+
|
|
35
|
+
const unsubs = await this.subscribe(key);
|
|
36
|
+
const result = combineDisposers(...unsubs);
|
|
37
|
+
|
|
38
|
+
if (disabed) { // unsubscribe was requested
|
|
39
|
+
result();
|
|
40
|
+
} else {
|
|
41
|
+
this._map.set(key, result);
|
|
42
|
+
this.refreshTimeout(key, true, clearAfter);
|
|
43
|
+
}
|
|
44
|
+
} else {
|
|
45
|
+
this._logger.log('Removing observer for key =', key);
|
|
46
|
+
this.refreshTimeout(key, false);
|
|
47
|
+
const unsub = this._map.get(key);
|
|
48
|
+
this._map.delete(key);
|
|
49
|
+
unsub();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
private refreshTimeout(key: string, enable: boolean, timeout?: number, refresh = false) {
|
|
54
|
+
const current = this._timeouts.get(key);
|
|
55
|
+
if (current) {
|
|
56
|
+
clearTimeout(current);
|
|
57
|
+
this._timeouts.delete(key);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (enable && refresh && current == null) {
|
|
61
|
+
// DO NOT setup new timeout because it's not intended to clear subscribtion if it was previously enabled for long term
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (enable && timeout) {
|
|
66
|
+
const t = setTimeout(() => this.enable(key, false), timeout);
|
|
67
|
+
this._timeouts.set(key, t);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public dispose() {
|
|
72
|
+
for (const u of this._map.values()) {
|
|
73
|
+
u();
|
|
74
|
+
}
|
|
75
|
+
this._map.clear();
|
|
76
|
+
|
|
77
|
+
for (const t of this._timeouts.values()) {
|
|
78
|
+
clearTimeout(t);
|
|
79
|
+
}
|
|
80
|
+
this._timeouts.clear();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
@@ -22,7 +22,7 @@ export const ValidatorsRegExps = {
|
|
|
22
22
|
expiryDateCard: /^\d+$/,
|
|
23
23
|
cvv: /^\d+$/,
|
|
24
24
|
// eslint-disable-next-line no-useless-escape
|
|
25
|
-
website: /^(https?:\/\/)?([a-z0-9]+(
|
|
25
|
+
website: /^(https?:\/\/)?([a-z0-9]+([a-z0-9\-]+\.))+[a-z]{2,}(:[0-9]{1,})?(\/.*)?$/i,
|
|
26
26
|
linkedin: /^(https?:\/\/)?([a-z]+\d*[a-z]*\.)?linkedin\.com\/.*$/i,
|
|
27
27
|
};
|
|
28
28
|
|