vest 4.4.2 → 4.4.3-dev-c786f7
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/cjs/classnames.development.js +9 -60
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/enforce/compose.development.js +5 -58
- package/dist/cjs/enforce/compose.production.js +1 -1
- package/dist/cjs/enforce/compounds.development.js +8 -51
- package/dist/cjs/enforce/compounds.production.js +1 -1
- package/dist/cjs/enforce/schema.development.js +5 -57
- package/dist/cjs/enforce/schema.production.js +1 -1
- package/dist/cjs/parser.development.js +8 -59
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/promisify.development.js +2 -26
- package/dist/cjs/promisify.production.js +1 -1
- package/dist/cjs/vest.development.js +119 -368
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +1 -52
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/enforce/compose.development.js +1 -54
- package/dist/es/enforce/compose.production.js +1 -1
- package/dist/es/enforce/compounds.development.js +2 -45
- package/dist/es/enforce/compounds.production.js +1 -1
- package/dist/es/enforce/schema.development.js +1 -53
- package/dist/es/enforce/schema.production.js +1 -1
- package/dist/es/parser.development.js +1 -52
- package/dist/es/parser.production.js +1 -1
- package/dist/es/promisify.development.js +1 -25
- package/dist/es/promisify.production.js +1 -1
- package/dist/es/vest.development.js +44 -293
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +11 -11
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +94 -94
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +117 -117
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +117 -117
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +11 -11
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/vest.development.js +296 -295
- package/dist/umd/vest.production.js +1 -1
- package/package.json +4 -3
- package/testUtils/__tests__/partition.test.ts +21 -0
- package/testUtils/mockThrowError.ts +2 -1
- package/testUtils/partition.ts +13 -0
- package/testUtils/suiteDummy.ts +1 -1
- package/types/enforce/compose.d.ts +15 -31
- package/types/enforce/compounds.d.ts +15 -31
- package/types/enforce/schema.d.ts +15 -31
- package/types/vest.d.ts +1 -1
|
@@ -4,12 +4,6 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.vest = {}));
|
|
5
5
|
}(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
var assign = Object.assign;
|
|
8
|
-
|
|
9
|
-
function isFunction(value) {
|
|
10
|
-
return typeof value === 'function';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
7
|
function bindNot(fn) {
|
|
14
8
|
return function () {
|
|
15
9
|
var args = [];
|
|
@@ -20,6 +14,69 @@
|
|
|
20
14
|
};
|
|
21
15
|
}
|
|
22
16
|
|
|
17
|
+
function isNumeric(value) {
|
|
18
|
+
var str = String(value);
|
|
19
|
+
var num = Number(value);
|
|
20
|
+
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
21
|
+
return Boolean(result);
|
|
22
|
+
}
|
|
23
|
+
var isNotNumeric = bindNot(isNumeric);
|
|
24
|
+
|
|
25
|
+
function numberEquals(value, eq) {
|
|
26
|
+
return isNumeric(value) && isNumeric(eq) && Number(value) === Number(eq);
|
|
27
|
+
}
|
|
28
|
+
var numberNotEquals = bindNot(numberEquals);
|
|
29
|
+
|
|
30
|
+
function lengthEquals(value, arg1) {
|
|
31
|
+
return numberEquals(value.length, arg1);
|
|
32
|
+
}
|
|
33
|
+
var lengthNotEquals = bindNot(lengthEquals);
|
|
34
|
+
|
|
35
|
+
function greaterThan(value, gt) {
|
|
36
|
+
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function longerThan(value, arg1) {
|
|
40
|
+
return greaterThan(value.length, arg1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Creates a cache function
|
|
45
|
+
*/
|
|
46
|
+
function createCache(maxSize) {
|
|
47
|
+
if (maxSize === void 0) { maxSize = 1; }
|
|
48
|
+
var cacheStorage = [];
|
|
49
|
+
var cache = function (deps, cacheAction) {
|
|
50
|
+
var cacheHit = cache.get(deps);
|
|
51
|
+
// cache hit is not null
|
|
52
|
+
if (cacheHit)
|
|
53
|
+
return cacheHit[1];
|
|
54
|
+
var result = cacheAction();
|
|
55
|
+
cacheStorage.unshift([deps.concat(), result]);
|
|
56
|
+
if (longerThan(cacheStorage, maxSize))
|
|
57
|
+
cacheStorage.length = maxSize;
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
// invalidate an item in the cache by its dependencies
|
|
61
|
+
cache.invalidate = function (deps) {
|
|
62
|
+
var index = findIndex(deps);
|
|
63
|
+
if (index > -1)
|
|
64
|
+
cacheStorage.splice(index, 1);
|
|
65
|
+
};
|
|
66
|
+
// Retrieves an item from the cache.
|
|
67
|
+
cache.get = function (deps) {
|
|
68
|
+
return cacheStorage[findIndex(deps)] || null;
|
|
69
|
+
};
|
|
70
|
+
return cache;
|
|
71
|
+
function findIndex(deps) {
|
|
72
|
+
return cacheStorage.findIndex(function (_a) {
|
|
73
|
+
var cachedDeps = _a[0];
|
|
74
|
+
return lengthEquals(deps, cachedDeps.length) &&
|
|
75
|
+
deps.every(function (dep, i) { return dep === cachedDeps[i]; });
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
23
80
|
function isNull(value) {
|
|
24
81
|
return value === null;
|
|
25
82
|
}
|
|
@@ -35,39 +92,25 @@
|
|
|
35
92
|
}
|
|
36
93
|
var isNotNullish = bindNot(isNullish);
|
|
37
94
|
|
|
38
|
-
function
|
|
39
|
-
return
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function endsWith(value, arg1) {
|
|
43
|
-
return isStringValue(value) && isStringValue(arg1) && value.endsWith(arg1);
|
|
44
|
-
}
|
|
45
|
-
var doesNotEndWith = bindNot(endsWith);
|
|
46
|
-
|
|
47
|
-
function equals(value, arg1) {
|
|
48
|
-
return value === arg1;
|
|
49
|
-
}
|
|
50
|
-
var notEquals = bindNot(equals);
|
|
51
|
-
|
|
52
|
-
function isNumeric(value) {
|
|
53
|
-
var str = String(value);
|
|
54
|
-
var num = Number(value);
|
|
55
|
-
var result = !isNaN(parseFloat(str)) && !isNaN(Number(value)) && isFinite(num);
|
|
56
|
-
return Boolean(result);
|
|
95
|
+
function asArray(possibleArg) {
|
|
96
|
+
return [].concat(possibleArg);
|
|
57
97
|
}
|
|
58
|
-
var isNotNumeric = bindNot(isNumeric);
|
|
59
98
|
|
|
60
|
-
function
|
|
61
|
-
return
|
|
99
|
+
function isFunction(value) {
|
|
100
|
+
return typeof value === 'function';
|
|
62
101
|
}
|
|
63
102
|
|
|
64
|
-
function
|
|
65
|
-
|
|
103
|
+
function optionalFunctionValue(value) {
|
|
104
|
+
var args = [];
|
|
105
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
106
|
+
args[_i - 1] = arguments[_i];
|
|
107
|
+
}
|
|
108
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
66
109
|
}
|
|
67
|
-
var numberNotEquals = bindNot(numberEquals);
|
|
68
110
|
|
|
69
|
-
function
|
|
70
|
-
|
|
111
|
+
function defaultTo(value, defaultValue) {
|
|
112
|
+
var _a;
|
|
113
|
+
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
71
114
|
}
|
|
72
115
|
|
|
73
116
|
// The module is named "isArrayValue" since it
|
|
@@ -78,67 +121,218 @@
|
|
|
78
121
|
}
|
|
79
122
|
var isNotArray = bindNot(isArray);
|
|
80
123
|
|
|
81
|
-
function
|
|
82
|
-
|
|
83
|
-
|
|
124
|
+
function last(values) {
|
|
125
|
+
var valuesArray = asArray(values);
|
|
126
|
+
return valuesArray[valuesArray.length - 1];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// This is kind of a map/filter in one function.
|
|
130
|
+
// Normally, behaves like a nested-array map,
|
|
131
|
+
// but returning `null` will drop the element from the array
|
|
132
|
+
function transform(array, cb) {
|
|
133
|
+
var res = [];
|
|
134
|
+
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
|
135
|
+
var v = array_1[_i];
|
|
136
|
+
if (isArray(v)) {
|
|
137
|
+
res.push(transform(v, cb));
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
var output = cb(v);
|
|
141
|
+
if (isNotNull(output)) {
|
|
142
|
+
res.push(output);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
84
145
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
146
|
+
return res;
|
|
147
|
+
}
|
|
148
|
+
function valueAtPath(array, path) {
|
|
149
|
+
return getCurrent(array, path)[last(path)];
|
|
150
|
+
}
|
|
151
|
+
function setValueAtPath(array, path, value) {
|
|
152
|
+
var current = getCurrent(array, path);
|
|
153
|
+
current[last(path)] = value;
|
|
154
|
+
return array;
|
|
155
|
+
}
|
|
156
|
+
function flatten(values) {
|
|
157
|
+
return asArray(values).reduce(function (acc, value) {
|
|
158
|
+
if (isArray(value)) {
|
|
159
|
+
return acc.concat(flatten(value));
|
|
160
|
+
}
|
|
161
|
+
return asArray(acc).concat(value);
|
|
162
|
+
}, []);
|
|
163
|
+
}
|
|
164
|
+
function getCurrent(array, path) {
|
|
165
|
+
var current = array;
|
|
166
|
+
for (var _i = 0, _a = path.slice(0, -1); _i < _a.length; _i++) {
|
|
167
|
+
var p = _a[_i];
|
|
168
|
+
current[p] = defaultTo(current[p], []);
|
|
169
|
+
current = current[p];
|
|
88
170
|
}
|
|
89
|
-
return
|
|
171
|
+
return current;
|
|
90
172
|
}
|
|
91
|
-
var notInside = bindNot(inside);
|
|
92
173
|
|
|
93
|
-
function
|
|
94
|
-
return
|
|
174
|
+
function callEach(arr) {
|
|
175
|
+
return arr.forEach(function (fn) { return fn(); });
|
|
95
176
|
}
|
|
96
177
|
|
|
97
|
-
|
|
98
|
-
|
|
178
|
+
/**
|
|
179
|
+
* A safe hasOwnProperty access
|
|
180
|
+
*/
|
|
181
|
+
function hasOwnProperty(obj, key) {
|
|
182
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
99
183
|
}
|
|
100
184
|
|
|
101
|
-
function
|
|
102
|
-
return
|
|
185
|
+
function isPromise(value) {
|
|
186
|
+
return value && isFunction(value.then);
|
|
103
187
|
}
|
|
104
|
-
var isNotBetween = bindNot(isBetween);
|
|
105
188
|
|
|
106
|
-
|
|
107
|
-
|
|
189
|
+
var assign = Object.assign;
|
|
190
|
+
|
|
191
|
+
function invariant(condition,
|
|
192
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
193
|
+
message) {
|
|
194
|
+
if (condition) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
// If message is a string object (rather than string literal)
|
|
198
|
+
// Throw the value directly as a string
|
|
199
|
+
// Alternatively, throw an error with the message
|
|
200
|
+
throw message instanceof String
|
|
201
|
+
? message.valueOf()
|
|
202
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
203
|
+
}
|
|
204
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
205
|
+
function StringObject(value) {
|
|
206
|
+
return new String(optionalFunctionValue(value));
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
function isStringValue(v) {
|
|
210
|
+
return String(v) === v;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
function either(a, b) {
|
|
214
|
+
return !!a !== !!b;
|
|
108
215
|
}
|
|
109
|
-
var isNotBlank = bindNot(isBlank);
|
|
110
216
|
|
|
111
217
|
function isBoolean(value) {
|
|
112
218
|
return !!value === value;
|
|
113
219
|
}
|
|
114
220
|
|
|
115
|
-
|
|
221
|
+
function deferThrow(message) {
|
|
222
|
+
setTimeout(function () {
|
|
223
|
+
throw new Error(message);
|
|
224
|
+
}, 0);
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
function createBus() {
|
|
228
|
+
var listeners = {};
|
|
229
|
+
return {
|
|
230
|
+
emit: function (event, data) {
|
|
231
|
+
listener(event).forEach(function (handler) {
|
|
232
|
+
handler(data);
|
|
233
|
+
});
|
|
234
|
+
},
|
|
235
|
+
on: function (event, handler) {
|
|
236
|
+
listeners[event] = listener(event).concat(handler);
|
|
237
|
+
return {
|
|
238
|
+
off: function () {
|
|
239
|
+
listeners[event] = listener(event).filter(function (h) { return h !== handler; });
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
function listener(event) {
|
|
245
|
+
return listeners[event] || [];
|
|
246
|
+
}
|
|
247
|
+
}
|
|
116
248
|
|
|
117
249
|
/**
|
|
118
|
-
*
|
|
250
|
+
* @returns a unique numeric id.
|
|
119
251
|
*/
|
|
120
|
-
function
|
|
121
|
-
return
|
|
252
|
+
var genId = (function (n) { return function () {
|
|
253
|
+
return "".concat(n++);
|
|
254
|
+
}; })(0);
|
|
255
|
+
|
|
256
|
+
function mapFirst(array, callback) {
|
|
257
|
+
var broke = false;
|
|
258
|
+
var breakoutValue = null;
|
|
259
|
+
for (var i = 0; i < array.length; i++) {
|
|
260
|
+
callback(array[i], breakout, i);
|
|
261
|
+
if (broke) {
|
|
262
|
+
return breakoutValue;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
function breakout(conditional, value) {
|
|
266
|
+
if (conditional) {
|
|
267
|
+
broke = true;
|
|
268
|
+
breakoutValue = value;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function isEmpty(value) {
|
|
274
|
+
if (!value) {
|
|
275
|
+
return true;
|
|
276
|
+
}
|
|
277
|
+
else if (hasOwnProperty(value, 'length')) {
|
|
278
|
+
return lengthEquals(value, 0);
|
|
279
|
+
}
|
|
280
|
+
else if (typeof value === 'object') {
|
|
281
|
+
return lengthEquals(Object.keys(value), 0);
|
|
282
|
+
}
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
var isNotEmpty = bindNot(isEmpty);
|
|
286
|
+
|
|
287
|
+
function isPositive(value) {
|
|
288
|
+
return greaterThan(value, 0);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
function endsWith(value, arg1) {
|
|
292
|
+
return isStringValue(value) && isStringValue(arg1) && value.endsWith(arg1);
|
|
293
|
+
}
|
|
294
|
+
var doesNotEndWith = bindNot(endsWith);
|
|
295
|
+
|
|
296
|
+
function equals(value, arg1) {
|
|
297
|
+
return value === arg1;
|
|
298
|
+
}
|
|
299
|
+
var notEquals = bindNot(equals);
|
|
300
|
+
|
|
301
|
+
function greaterThanOrEquals(value, gte) {
|
|
302
|
+
return numberEquals(value, gte) || greaterThan(value, gte);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
function inside(value, arg1) {
|
|
306
|
+
if (isArray(arg1)) {
|
|
307
|
+
return arg1.indexOf(value) !== -1;
|
|
308
|
+
}
|
|
309
|
+
// both value and arg1 are strings
|
|
310
|
+
if (isStringValue(arg1) && isStringValue(value)) {
|
|
311
|
+
return arg1.indexOf(value) !== -1;
|
|
312
|
+
}
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
var notInside = bindNot(inside);
|
|
316
|
+
|
|
317
|
+
function lessThan(value, lt) {
|
|
318
|
+
return isNumeric(value) && isNumeric(lt) && Number(value) < Number(lt);
|
|
122
319
|
}
|
|
123
320
|
|
|
124
|
-
function
|
|
125
|
-
return numberEquals(value
|
|
321
|
+
function lessThanOrEquals(value, lte) {
|
|
322
|
+
return numberEquals(value, lte) || lessThan(value, lte);
|
|
126
323
|
}
|
|
127
|
-
var lengthNotEquals = bindNot(lengthEquals);
|
|
128
324
|
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
else if (hasOwnProperty(value, 'length')) {
|
|
134
|
-
return lengthEquals(value, 0);
|
|
135
|
-
}
|
|
136
|
-
else if (typeof value === 'object') {
|
|
137
|
-
return lengthEquals(Object.keys(value), 0);
|
|
138
|
-
}
|
|
139
|
-
return false;
|
|
325
|
+
function isBetween(value, min, max) {
|
|
326
|
+
return greaterThanOrEquals(value, min) && lessThanOrEquals(value, max);
|
|
140
327
|
}
|
|
141
|
-
var
|
|
328
|
+
var isNotBetween = bindNot(isBetween);
|
|
329
|
+
|
|
330
|
+
function isBlank(value) {
|
|
331
|
+
return isNullish(value) || (isStringValue(value) && !value.trim());
|
|
332
|
+
}
|
|
333
|
+
var isNotBlank = bindNot(isBlank);
|
|
334
|
+
|
|
335
|
+
var isNotBoolean = bindNot(isBoolean);
|
|
142
336
|
|
|
143
337
|
/**
|
|
144
338
|
* Validates that a given value is an even number
|
|
@@ -179,10 +373,6 @@
|
|
|
179
373
|
return false;
|
|
180
374
|
};
|
|
181
375
|
|
|
182
|
-
function isPositive(value) {
|
|
183
|
-
return greaterThan(value, 0);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
376
|
var isNotString = bindNot(isStringValue);
|
|
187
377
|
|
|
188
378
|
function isTruthy(value) {
|
|
@@ -203,10 +393,6 @@
|
|
|
203
393
|
}
|
|
204
394
|
var isNotValueOf = bindNot(isValueOf);
|
|
205
395
|
|
|
206
|
-
function longerThan(value, arg1) {
|
|
207
|
-
return greaterThan(value.length, arg1);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
396
|
function longerThanOrEquals(value, arg1) {
|
|
211
397
|
return greaterThanOrEquals(value.length, arg1);
|
|
212
398
|
}
|
|
@@ -327,37 +513,6 @@
|
|
|
327
513
|
}
|
|
328
514
|
}
|
|
329
515
|
|
|
330
|
-
function optionalFunctionValue(value) {
|
|
331
|
-
var args = [];
|
|
332
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
333
|
-
args[_i - 1] = arguments[_i];
|
|
334
|
-
}
|
|
335
|
-
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
function defaultTo(value, defaultValue) {
|
|
339
|
-
var _a;
|
|
340
|
-
return (_a = optionalFunctionValue(value)) !== null && _a !== void 0 ? _a : optionalFunctionValue(defaultValue);
|
|
341
|
-
}
|
|
342
|
-
|
|
343
|
-
function invariant(condition,
|
|
344
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
345
|
-
message) {
|
|
346
|
-
if (condition) {
|
|
347
|
-
return;
|
|
348
|
-
}
|
|
349
|
-
// If message is a string object (rather than string literal)
|
|
350
|
-
// Throw the value directly as a string
|
|
351
|
-
// Alternatively, throw an error with the message
|
|
352
|
-
throw message instanceof String
|
|
353
|
-
? message.valueOf()
|
|
354
|
-
: new Error(message ? optionalFunctionValue(message) : message);
|
|
355
|
-
}
|
|
356
|
-
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
357
|
-
function StringObject(value) {
|
|
358
|
-
return new String(optionalFunctionValue(value));
|
|
359
|
-
}
|
|
360
|
-
|
|
361
516
|
// eslint-disable-next-line max-lines-per-function
|
|
362
517
|
function createContext(init) {
|
|
363
518
|
var storage = { ancestry: [] };
|
|
@@ -544,23 +699,6 @@
|
|
|
544
699
|
}
|
|
545
700
|
}
|
|
546
701
|
|
|
547
|
-
function mapFirst(array, callback) {
|
|
548
|
-
var broke = false;
|
|
549
|
-
var breakoutValue = null;
|
|
550
|
-
for (var i = 0; i < array.length; i++) {
|
|
551
|
-
callback(array[i], breakout, i);
|
|
552
|
-
if (broke) {
|
|
553
|
-
return breakoutValue;
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
function breakout(conditional, value) {
|
|
557
|
-
if (conditional) {
|
|
558
|
-
broke = true;
|
|
559
|
-
breakoutValue = value;
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
|
|
564
702
|
// eslint-disable-next-line max-lines-per-function
|
|
565
703
|
function genEnforceLazy(key) {
|
|
566
704
|
var registeredRules = [];
|
|
@@ -674,109 +812,11 @@
|
|
|
674
812
|
}
|
|
675
813
|
var enforce = genEnforce();
|
|
676
814
|
|
|
677
|
-
/**
|
|
678
|
-
* @returns a unique numeric id.
|
|
679
|
-
*/
|
|
680
|
-
var genId = (function (n) { return function () {
|
|
681
|
-
return "".concat(n++);
|
|
682
|
-
}; })(0);
|
|
683
|
-
|
|
684
815
|
function shouldUseErrorAsMessage(message, error) {
|
|
685
816
|
// kind of cheating with this safe guard, but it does the job
|
|
686
817
|
return isUndefined(message) && isStringValue(error);
|
|
687
818
|
}
|
|
688
819
|
|
|
689
|
-
function asArray(possibleArg) {
|
|
690
|
-
return [].concat(possibleArg);
|
|
691
|
-
}
|
|
692
|
-
|
|
693
|
-
/**
|
|
694
|
-
* Creates a cache function
|
|
695
|
-
*/
|
|
696
|
-
function createCache(maxSize) {
|
|
697
|
-
if (maxSize === void 0) { maxSize = 1; }
|
|
698
|
-
var cacheStorage = [];
|
|
699
|
-
var cache = function (deps, cacheAction) {
|
|
700
|
-
var cacheHit = cache.get(deps);
|
|
701
|
-
// cache hit is not null
|
|
702
|
-
if (cacheHit)
|
|
703
|
-
return cacheHit[1];
|
|
704
|
-
var result = cacheAction();
|
|
705
|
-
cacheStorage.unshift([deps.concat(), result]);
|
|
706
|
-
if (longerThan(cacheStorage, maxSize))
|
|
707
|
-
cacheStorage.length = maxSize;
|
|
708
|
-
return result;
|
|
709
|
-
};
|
|
710
|
-
// invalidate an item in the cache by its dependencies
|
|
711
|
-
cache.invalidate = function (deps) {
|
|
712
|
-
var index = findIndex(deps);
|
|
713
|
-
if (index > -1)
|
|
714
|
-
cacheStorage.splice(index, 1);
|
|
715
|
-
};
|
|
716
|
-
// Retrieves an item from the cache.
|
|
717
|
-
cache.get = function (deps) {
|
|
718
|
-
return cacheStorage[findIndex(deps)] || null;
|
|
719
|
-
};
|
|
720
|
-
return cache;
|
|
721
|
-
function findIndex(deps) {
|
|
722
|
-
return cacheStorage.findIndex(function (_a) {
|
|
723
|
-
var cachedDeps = _a[0];
|
|
724
|
-
return lengthEquals(deps, cachedDeps.length) &&
|
|
725
|
-
deps.every(function (dep, i) { return dep === cachedDeps[i]; });
|
|
726
|
-
});
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
|
|
730
|
-
function last(values) {
|
|
731
|
-
var valuesArray = asArray(values);
|
|
732
|
-
return valuesArray[valuesArray.length - 1];
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
// This is kind of a map/filter in one function.
|
|
736
|
-
// Normally, behaves like a nested-array map,
|
|
737
|
-
// but returning `null` will drop the element from the array
|
|
738
|
-
function transform(array, cb) {
|
|
739
|
-
var res = [];
|
|
740
|
-
for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
|
|
741
|
-
var v = array_1[_i];
|
|
742
|
-
if (isArray(v)) {
|
|
743
|
-
res.push(transform(v, cb));
|
|
744
|
-
}
|
|
745
|
-
else {
|
|
746
|
-
var output = cb(v);
|
|
747
|
-
if (isNotNull(output)) {
|
|
748
|
-
res.push(output);
|
|
749
|
-
}
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
return res;
|
|
753
|
-
}
|
|
754
|
-
function valueAtPath(array, path) {
|
|
755
|
-
return getCurrent(array, path)[last(path)];
|
|
756
|
-
}
|
|
757
|
-
function setValueAtPath(array, path, value) {
|
|
758
|
-
var current = getCurrent(array, path);
|
|
759
|
-
current[last(path)] = value;
|
|
760
|
-
return array;
|
|
761
|
-
}
|
|
762
|
-
function flatten(values) {
|
|
763
|
-
return asArray(values).reduce(function (acc, value) {
|
|
764
|
-
if (isArray(value)) {
|
|
765
|
-
return acc.concat(flatten(value));
|
|
766
|
-
}
|
|
767
|
-
return asArray(acc).concat(value);
|
|
768
|
-
}, []);
|
|
769
|
-
}
|
|
770
|
-
function getCurrent(array, path) {
|
|
771
|
-
var current = array;
|
|
772
|
-
for (var _i = 0, _a = path.slice(0, -1); _i < _a.length; _i++) {
|
|
773
|
-
var p = _a[_i];
|
|
774
|
-
current[p] = defaultTo(current[p], []);
|
|
775
|
-
current = current[p];
|
|
776
|
-
}
|
|
777
|
-
return current;
|
|
778
|
-
}
|
|
779
|
-
|
|
780
820
|
var IsolateTypes;
|
|
781
821
|
(function (IsolateTypes) {
|
|
782
822
|
IsolateTypes[IsolateTypes["DEFAULT"] = 0] = "DEFAULT";
|
|
@@ -1140,10 +1180,24 @@
|
|
|
1140
1180
|
};
|
|
1141
1181
|
}
|
|
1142
1182
|
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1183
|
+
/**
|
|
1184
|
+
* @returns {Isolate} The current isolate layer
|
|
1185
|
+
*/
|
|
1186
|
+
function useIsolate() {
|
|
1187
|
+
return context.useX().isolate;
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* @returns {number[]} The current cursor path of the isolate tree
|
|
1191
|
+
*/
|
|
1192
|
+
function useCurrentPath() {
|
|
1193
|
+
var isolate = useIsolate();
|
|
1194
|
+
return isolate.path.concat(isolate.cursor.current());
|
|
1195
|
+
}
|
|
1196
|
+
/**
|
|
1197
|
+
* @returns {IsolateCursor} The cursor object for the current isolate
|
|
1198
|
+
*/
|
|
1199
|
+
function useCursor() {
|
|
1200
|
+
return useIsolate().cursor;
|
|
1147
1201
|
}
|
|
1148
1202
|
|
|
1149
1203
|
function usePrevKeys() {
|
|
@@ -1188,31 +1242,12 @@
|
|
|
1188
1242
|
useCursor().next();
|
|
1189
1243
|
return output;
|
|
1190
1244
|
}
|
|
1191
|
-
/**
|
|
1192
|
-
* @returns {Isolate} The current isolate layer
|
|
1193
|
-
*/
|
|
1194
|
-
function useIsolate() {
|
|
1195
|
-
return context.useX().isolate;
|
|
1196
|
-
}
|
|
1197
1245
|
/**
|
|
1198
1246
|
* @returns {boolean} Whether or not the current isolate allows tests to be reordered
|
|
1199
1247
|
*/
|
|
1200
1248
|
function shouldAllowReorder() {
|
|
1201
1249
|
return useIsolate().type === IsolateTypes.EACH;
|
|
1202
1250
|
}
|
|
1203
|
-
/**
|
|
1204
|
-
* @returns {number[]} The current cursor path of the isolate tree
|
|
1205
|
-
*/
|
|
1206
|
-
function useCurrentPath() {
|
|
1207
|
-
var isolate = useIsolate();
|
|
1208
|
-
return isolate.path.concat(isolate.cursor.current());
|
|
1209
|
-
}
|
|
1210
|
-
/**
|
|
1211
|
-
* @returns {IsolateCursor} The cursor object for the current isolate
|
|
1212
|
-
*/
|
|
1213
|
-
function useCursor() {
|
|
1214
|
-
return useIsolate().cursor;
|
|
1215
|
-
}
|
|
1216
1251
|
|
|
1217
1252
|
var Severity;
|
|
1218
1253
|
(function (Severity) {
|
|
@@ -1242,10 +1277,6 @@
|
|
|
1242
1277
|
return testObject.groupName === groupName;
|
|
1243
1278
|
}
|
|
1244
1279
|
|
|
1245
|
-
function either(a, b) {
|
|
1246
|
-
return !!a !== !!b;
|
|
1247
|
-
}
|
|
1248
|
-
|
|
1249
1280
|
/**
|
|
1250
1281
|
* Checks that a given test object matches the currently specified severity level
|
|
1251
1282
|
*/
|
|
@@ -1684,28 +1715,6 @@
|
|
|
1684
1715
|
});
|
|
1685
1716
|
}
|
|
1686
1717
|
|
|
1687
|
-
function createBus() {
|
|
1688
|
-
var listeners = {};
|
|
1689
|
-
return {
|
|
1690
|
-
emit: function (event, data) {
|
|
1691
|
-
listener(event).forEach(function (handler) {
|
|
1692
|
-
handler(data);
|
|
1693
|
-
});
|
|
1694
|
-
},
|
|
1695
|
-
on: function (event, handler) {
|
|
1696
|
-
listeners[event] = listener(event).concat(handler);
|
|
1697
|
-
return {
|
|
1698
|
-
off: function () {
|
|
1699
|
-
listeners[event] = listener(event).filter(function (h) { return h !== handler; });
|
|
1700
|
-
}
|
|
1701
|
-
};
|
|
1702
|
-
}
|
|
1703
|
-
};
|
|
1704
|
-
function listener(event) {
|
|
1705
|
-
return listeners[event] || [];
|
|
1706
|
-
}
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
1718
|
function omitOptionalFields() {
|
|
1710
1719
|
var optionalFields = useOptionalFields()[0];
|
|
1711
1720
|
if (isEmpty(optionalFields)) {
|
|
@@ -1748,10 +1757,6 @@
|
|
|
1748
1757
|
});
|
|
1749
1758
|
}
|
|
1750
1759
|
|
|
1751
|
-
function callEach(arr) {
|
|
1752
|
-
return arr.forEach(function (fn) { return fn(); });
|
|
1753
|
-
}
|
|
1754
|
-
|
|
1755
1760
|
/**
|
|
1756
1761
|
* Runs done callback per field when async tests are finished running.
|
|
1757
1762
|
*/
|
|
@@ -1773,10 +1778,10 @@
|
|
|
1773
1778
|
|
|
1774
1779
|
// eslint-disable-next-line max-lines-per-function
|
|
1775
1780
|
function initBus() {
|
|
1776
|
-
var
|
|
1781
|
+
var vestBus = createBus();
|
|
1777
1782
|
// Report a the completion of a test. There may be other tests with the same
|
|
1778
1783
|
// name that are still running, or not yet started.
|
|
1779
|
-
|
|
1784
|
+
vestBus.on(Events.TEST_COMPLETED, function (testObject) {
|
|
1780
1785
|
if (testObject.isCanceled()) {
|
|
1781
1786
|
return;
|
|
1782
1787
|
}
|
|
@@ -1784,21 +1789,21 @@
|
|
|
1784
1789
|
runFieldCallbacks(testObject.fieldName);
|
|
1785
1790
|
if (!hasRemainingTests()) {
|
|
1786
1791
|
// When no more tests are running, emit the done event
|
|
1787
|
-
|
|
1792
|
+
vestBus.emit(Events.ALL_RUNNING_TESTS_FINISHED);
|
|
1788
1793
|
}
|
|
1789
1794
|
});
|
|
1790
1795
|
// Report that the suite completed its synchronous test run.
|
|
1791
1796
|
// Async operations may still be running.
|
|
1792
|
-
|
|
1797
|
+
vestBus.on(Events.SUITE_CALLBACK_DONE_RUNNING, function () {
|
|
1793
1798
|
// Remove tests that are optional and need to be omitted
|
|
1794
1799
|
omitOptionalFields();
|
|
1795
1800
|
});
|
|
1796
1801
|
// Called when all the tests, including async, are done running
|
|
1797
|
-
|
|
1802
|
+
vestBus.on(Events.ALL_RUNNING_TESTS_FINISHED, function () {
|
|
1798
1803
|
runDoneCallbacks();
|
|
1799
1804
|
});
|
|
1800
1805
|
// Removes a certain field from the state.
|
|
1801
|
-
|
|
1806
|
+
vestBus.on(Events.REMOVE_FIELD, function (fieldName) {
|
|
1802
1807
|
useEachTestObject(function (testObject) {
|
|
1803
1808
|
if (matchingFieldName(testObject, fieldName)) {
|
|
1804
1809
|
testObject.cancel();
|
|
@@ -1807,14 +1812,14 @@
|
|
|
1807
1812
|
});
|
|
1808
1813
|
});
|
|
1809
1814
|
// Resets a certain field in the state.
|
|
1810
|
-
|
|
1815
|
+
vestBus.on(Events.RESET_FIELD, function (fieldName) {
|
|
1811
1816
|
useEachTestObject(function (testObject) {
|
|
1812
1817
|
if (matchingFieldName(testObject, fieldName)) {
|
|
1813
1818
|
testObject.reset();
|
|
1814
1819
|
}
|
|
1815
1820
|
});
|
|
1816
1821
|
});
|
|
1817
|
-
return
|
|
1822
|
+
return vestBus;
|
|
1818
1823
|
}
|
|
1819
1824
|
function useBus() {
|
|
1820
1825
|
var context$1 = context.useX();
|
|
@@ -1938,10 +1943,10 @@
|
|
|
1938
1943
|
* only('username');
|
|
1939
1944
|
*/
|
|
1940
1945
|
function only(item) {
|
|
1941
|
-
return addTo(0 /* ONLY */, 'tests', item);
|
|
1946
|
+
return addTo(0 /* ExclusionGroup.ONLY */, 'tests', item);
|
|
1942
1947
|
}
|
|
1943
1948
|
only.group = function (item) {
|
|
1944
|
-
return addTo(0 /* ONLY */, 'groups', item);
|
|
1949
|
+
return addTo(0 /* ExclusionGroup.ONLY */, 'groups', item);
|
|
1945
1950
|
};
|
|
1946
1951
|
/**
|
|
1947
1952
|
* Adds a field or a list of fields into the exclusion list
|
|
@@ -1951,10 +1956,10 @@
|
|
|
1951
1956
|
* skip('username');
|
|
1952
1957
|
*/
|
|
1953
1958
|
function skip(item) {
|
|
1954
|
-
return addTo(1 /* SKIP */, 'tests', item);
|
|
1959
|
+
return addTo(1 /* ExclusionGroup.SKIP */, 'tests', item);
|
|
1955
1960
|
}
|
|
1956
1961
|
skip.group = function (item) {
|
|
1957
|
-
return addTo(1 /* SKIP */, 'groups', item);
|
|
1962
|
+
return addTo(1 /* ExclusionGroup.SKIP */, 'groups', item);
|
|
1958
1963
|
};
|
|
1959
1964
|
//Checks whether a certain test profile excluded by any of the exclusion groups.
|
|
1960
1965
|
// eslint-disable-next-line complexity, max-statements, max-lines-per-function
|
|
@@ -2033,7 +2038,7 @@
|
|
|
2033
2038
|
return;
|
|
2034
2039
|
}
|
|
2035
2040
|
context$1.exclusion[itemType][itemName] =
|
|
2036
|
-
exclusionGroup === 0 /* ONLY */;
|
|
2041
|
+
exclusionGroup === 0 /* ExclusionGroup.ONLY */;
|
|
2037
2042
|
});
|
|
2038
2043
|
}
|
|
2039
2044
|
/**
|
|
@@ -2199,10 +2204,6 @@
|
|
|
2199
2204
|
}
|
|
2200
2205
|
}
|
|
2201
2206
|
|
|
2202
|
-
function isPromise(value) {
|
|
2203
|
-
return value && isFunction(value.then);
|
|
2204
|
-
}
|
|
2205
|
-
|
|
2206
2207
|
function isSameProfileTest(testObject1, testObject2) {
|
|
2207
2208
|
return (testObject1.fieldName === testObject2.fieldName &&
|
|
2208
2209
|
testObject1.groupName === testObject2.groupName);
|
|
@@ -2467,7 +2468,7 @@
|
|
|
2467
2468
|
ctx.currentTest.warn();
|
|
2468
2469
|
}
|
|
2469
2470
|
|
|
2470
|
-
var VERSION = "4.4.
|
|
2471
|
+
var VERSION = "4.4.3-dev-c786f7";
|
|
2471
2472
|
|
|
2472
2473
|
exports.VERSION = VERSION;
|
|
2473
2474
|
exports.context = context;
|