vest 4.2.3-dev-87ebfa → 4.3.0
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 +58 -23
- package/dist/cjs/classnames.production.js +1 -1
- package/dist/cjs/parser.development.js +84 -22
- package/dist/cjs/parser.production.js +1 -1
- package/dist/cjs/vest.development.js +447 -440
- package/dist/cjs/vest.production.js +1 -1
- package/dist/es/classnames.development.js +58 -23
- package/dist/es/classnames.production.js +1 -1
- package/dist/es/parser.development.js +84 -22
- package/dist/es/parser.production.js +1 -1
- package/dist/es/vest.development.js +447 -440
- package/dist/es/vest.production.js +1 -1
- package/dist/umd/classnames.development.js +58 -23
- package/dist/umd/classnames.production.js +1 -1
- package/dist/umd/enforce/compose.development.js +16 -16
- package/dist/umd/enforce/compose.production.js +1 -1
- package/dist/umd/enforce/compounds.development.js +16 -16
- package/dist/umd/enforce/compounds.production.js +1 -1
- package/dist/umd/enforce/schema.development.js +16 -16
- package/dist/umd/enforce/schema.production.js +1 -1
- package/dist/umd/parser.development.js +84 -22
- package/dist/umd/parser.production.js +1 -1
- package/dist/umd/vest.development.js +320 -313
- package/dist/umd/vest.production.js +1 -1
- package/package.json +3 -3
- package/testUtils/suiteDummy.ts +5 -1
- package/types/classnames.d.ts +13 -55
- package/types/enforce/compose.d.ts +2 -1
- package/types/enforce/compounds.d.ts +2 -1
- package/types/enforce/schema.d.ts +2 -1
- package/types/parser.d.ts +12 -54
- package/types/promisify.d.ts +12 -10
- package/types/vest.d.ts +63 -61
|
@@ -4,6 +4,13 @@ function isFunction(value) {
|
|
|
4
4
|
return typeof value === 'function';
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* A safe hasOwnProperty access
|
|
9
|
+
*/
|
|
10
|
+
function hasOwnProperty(obj, key) {
|
|
11
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
12
|
+
}
|
|
13
|
+
|
|
7
14
|
function optionalFunctionValue(value) {
|
|
8
15
|
var args = [];
|
|
9
16
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
@@ -37,35 +44,64 @@ function greaterThan(value, gt) {
|
|
|
37
44
|
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
38
45
|
}
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
*/
|
|
43
|
-
function hasOwnProperty(obj, key) {
|
|
44
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
47
|
+
function isPositive(value) {
|
|
48
|
+
return greaterThan(value, 0);
|
|
45
49
|
}
|
|
46
50
|
|
|
51
|
+
var Severity;
|
|
52
|
+
(function (Severity) {
|
|
53
|
+
Severity["WARNINGS"] = "warnings";
|
|
54
|
+
Severity["ERRORS"] = "errors";
|
|
55
|
+
})(Severity || (Severity = {}));
|
|
56
|
+
var SeverityCount;
|
|
57
|
+
(function (SeverityCount) {
|
|
58
|
+
SeverityCount["ERROR_COUNT"] = "errorCount";
|
|
59
|
+
SeverityCount["WARN_COUNT"] = "warnCount";
|
|
60
|
+
})(SeverityCount || (SeverityCount = {}));
|
|
61
|
+
|
|
62
|
+
// eslint-disable-next-line max-lines-per-function
|
|
47
63
|
function parse(res) {
|
|
64
|
+
invariant(res && hasOwnProperty(res, 'valid'), "Vest parser: expected argument at position 0 to be Vest's result object.");
|
|
48
65
|
var testedStorage = {};
|
|
49
66
|
var selectors = {
|
|
50
|
-
invalid:
|
|
51
|
-
tested:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (hasOwnProperty(testedStorage, fieldName))
|
|
56
|
-
return testedStorage[fieldName];
|
|
57
|
-
testedStorage[fieldName] =
|
|
58
|
-
hasOwnProperty(res.tests, fieldName) &&
|
|
59
|
-
greaterThan(res.tests[fieldName].testCount, 0);
|
|
60
|
-
return selectors.tested(fieldName);
|
|
61
|
-
},
|
|
62
|
-
untested: function (fieldName) {
|
|
63
|
-
return res.testCount === 0 || !selectors.tested(fieldName);
|
|
64
|
-
},
|
|
65
|
-
valid: res.isValid,
|
|
66
|
-
warning: res.hasWarnings
|
|
67
|
+
invalid: hasErrors,
|
|
68
|
+
tested: isTested,
|
|
69
|
+
untested: isUntested,
|
|
70
|
+
valid: isValid,
|
|
71
|
+
warning: hasWarnings
|
|
67
72
|
};
|
|
68
73
|
return selectors;
|
|
74
|
+
function isTested(fieldName) {
|
|
75
|
+
if (!fieldName) {
|
|
76
|
+
return isPositive(res.testCount);
|
|
77
|
+
}
|
|
78
|
+
if (hasOwnProperty(testedStorage, fieldName))
|
|
79
|
+
return testedStorage[fieldName];
|
|
80
|
+
testedStorage[fieldName] =
|
|
81
|
+
hasOwnProperty(res.tests, fieldName) &&
|
|
82
|
+
isPositive(res.tests[fieldName].testCount);
|
|
83
|
+
return selectors.tested(fieldName);
|
|
84
|
+
}
|
|
85
|
+
function isUntested(fieldName) {
|
|
86
|
+
return res.testCount === 0 || !selectors.tested(fieldName);
|
|
87
|
+
}
|
|
88
|
+
function isValid(fieldName) {
|
|
89
|
+
var _a, _b;
|
|
90
|
+
return Boolean(fieldName ? (_b = (_a = res.tests) === null || _a === void 0 ? void 0 : _a[fieldName]) === null || _b === void 0 ? void 0 : _b.valid : res.valid);
|
|
91
|
+
}
|
|
92
|
+
function hasWarnings(fieldName) {
|
|
93
|
+
return hasFailures(res, SeverityCount.WARN_COUNT, fieldName);
|
|
94
|
+
}
|
|
95
|
+
function hasErrors(fieldName) {
|
|
96
|
+
return hasFailures(res, SeverityCount.ERROR_COUNT, fieldName);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function hasFailures(res, countKey, fieldName) {
|
|
100
|
+
var _a, _b, _c;
|
|
101
|
+
var failureCount = fieldName
|
|
102
|
+
? (_b = (_a = res.tests) === null || _a === void 0 ? void 0 : _a[fieldName]) === null || _b === void 0 ? void 0 : _b[countKey]
|
|
103
|
+
: (_c = res[countKey]) !== null && _c !== void 0 ? _c : 0;
|
|
104
|
+
return isPositive(failureCount);
|
|
69
105
|
}
|
|
70
106
|
|
|
71
107
|
/**
|
|
@@ -73,7 +109,6 @@ function parse(res) {
|
|
|
73
109
|
*/
|
|
74
110
|
function classnames(res, classes) {
|
|
75
111
|
if (classes === void 0) { classes = {}; }
|
|
76
|
-
invariant(res && isFunction(res.hasErrors), "classnames: Expected first argument to be Vest's result object.");
|
|
77
112
|
var selectors = parse(res);
|
|
78
113
|
return function (key) {
|
|
79
114
|
var classesArray = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function t(t){return"function"==typeof t}function
|
|
1
|
+
"use strict";function t(t){return"function"==typeof t}function n(t,n){return Object.prototype.hasOwnProperty.call(t,n)}function r(n,r){if(!n)throw r instanceof String?r.valueOf():Error(r?function(n){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return t(n)?n.apply(void 0,r):n}(r):r)}function e(t){var n=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(n))}function u(t){return function(t,n){return e(t)&&e(n)&&Number(t)>Number(n)}(t,0)}var o,i,s;function a(t,n,r){var e,o,i;return u(t=r?null===(o=null===(e=t.tests)||void 0===e?void 0:e[r])||void 0===o?void 0:o[n]:null!==(i=t[n])&&void 0!==i?i:0)}(i=o||(o={})).WARNINGS="warnings",i.ERRORS="errors",function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(s||(s={})),module.exports=function(e,o){void 0===o&&(o={});var i=function(t){r(t&&n(t,"valid"),"Vest parser: expected argument at position 0 to be Vest's result object.");var e={},o={invalid:function(n){return a(t,s.ERROR_COUNT,n)},tested:function(r){return r?n(e,r)?e[r]:(e[r]=n(t.tests,r)&&u(t.tests[r].testCount),o.tested(r)):u(t.testCount)},untested:function(n){return 0===t.testCount||!o.tested(n)},valid:function(n){var r,e;return!!(n?null!==(e=null===(r=t.tests)||void 0===r?void 0:r[n])&&void 0!==e&&e.valid:t.valid)},warning:function(n){return a(t,s.WARN_COUNT,n)}};return o}(e);return function(n){var r,e=[];for(r in o){var u=r;t(i[u])&&i[u](n)&&e.push(o[u])}return e.join(" ")}};
|
|
@@ -2,6 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* A safe hasOwnProperty access
|
|
7
|
+
*/
|
|
8
|
+
function hasOwnProperty(obj, key) {
|
|
9
|
+
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function isFunction(value) {
|
|
13
|
+
return typeof value === 'function';
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function optionalFunctionValue(value) {
|
|
17
|
+
var args = [];
|
|
18
|
+
for (var _i = 1; _i < arguments.length; _i++) {
|
|
19
|
+
args[_i - 1] = arguments[_i];
|
|
20
|
+
}
|
|
21
|
+
return isFunction(value) ? value.apply(void 0, args) : value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function invariant(condition,
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
26
|
+
message) {
|
|
27
|
+
if (condition) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// If message is a string object (rather than string literal)
|
|
31
|
+
// Throw the value directly as a string
|
|
32
|
+
// Alternatively, throw an error with the message
|
|
33
|
+
throw message instanceof String
|
|
34
|
+
? message.valueOf()
|
|
35
|
+
: new Error(message ? optionalFunctionValue(message) : message);
|
|
36
|
+
}
|
|
37
|
+
|
|
5
38
|
function isNumeric(value) {
|
|
6
39
|
var str = String(value);
|
|
7
40
|
var num = Number(value);
|
|
@@ -13,35 +46,64 @@ function greaterThan(value, gt) {
|
|
|
13
46
|
return isNumeric(value) && isNumeric(gt) && Number(value) > Number(gt);
|
|
14
47
|
}
|
|
15
48
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*/
|
|
19
|
-
function hasOwnProperty(obj, key) {
|
|
20
|
-
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
49
|
+
function isPositive(value) {
|
|
50
|
+
return greaterThan(value, 0);
|
|
21
51
|
}
|
|
22
52
|
|
|
53
|
+
var Severity;
|
|
54
|
+
(function (Severity) {
|
|
55
|
+
Severity["WARNINGS"] = "warnings";
|
|
56
|
+
Severity["ERRORS"] = "errors";
|
|
57
|
+
})(Severity || (Severity = {}));
|
|
58
|
+
var SeverityCount;
|
|
59
|
+
(function (SeverityCount) {
|
|
60
|
+
SeverityCount["ERROR_COUNT"] = "errorCount";
|
|
61
|
+
SeverityCount["WARN_COUNT"] = "warnCount";
|
|
62
|
+
})(SeverityCount || (SeverityCount = {}));
|
|
63
|
+
|
|
64
|
+
// eslint-disable-next-line max-lines-per-function
|
|
23
65
|
function parse(res) {
|
|
66
|
+
invariant(res && hasOwnProperty(res, 'valid'), "Vest parser: expected argument at position 0 to be Vest's result object.");
|
|
24
67
|
var testedStorage = {};
|
|
25
68
|
var selectors = {
|
|
26
|
-
invalid:
|
|
27
|
-
tested:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (hasOwnProperty(testedStorage, fieldName))
|
|
32
|
-
return testedStorage[fieldName];
|
|
33
|
-
testedStorage[fieldName] =
|
|
34
|
-
hasOwnProperty(res.tests, fieldName) &&
|
|
35
|
-
greaterThan(res.tests[fieldName].testCount, 0);
|
|
36
|
-
return selectors.tested(fieldName);
|
|
37
|
-
},
|
|
38
|
-
untested: function (fieldName) {
|
|
39
|
-
return res.testCount === 0 || !selectors.tested(fieldName);
|
|
40
|
-
},
|
|
41
|
-
valid: res.isValid,
|
|
42
|
-
warning: res.hasWarnings
|
|
69
|
+
invalid: hasErrors,
|
|
70
|
+
tested: isTested,
|
|
71
|
+
untested: isUntested,
|
|
72
|
+
valid: isValid,
|
|
73
|
+
warning: hasWarnings
|
|
43
74
|
};
|
|
44
75
|
return selectors;
|
|
76
|
+
function isTested(fieldName) {
|
|
77
|
+
if (!fieldName) {
|
|
78
|
+
return isPositive(res.testCount);
|
|
79
|
+
}
|
|
80
|
+
if (hasOwnProperty(testedStorage, fieldName))
|
|
81
|
+
return testedStorage[fieldName];
|
|
82
|
+
testedStorage[fieldName] =
|
|
83
|
+
hasOwnProperty(res.tests, fieldName) &&
|
|
84
|
+
isPositive(res.tests[fieldName].testCount);
|
|
85
|
+
return selectors.tested(fieldName);
|
|
86
|
+
}
|
|
87
|
+
function isUntested(fieldName) {
|
|
88
|
+
return res.testCount === 0 || !selectors.tested(fieldName);
|
|
89
|
+
}
|
|
90
|
+
function isValid(fieldName) {
|
|
91
|
+
var _a, _b;
|
|
92
|
+
return Boolean(fieldName ? (_b = (_a = res.tests) === null || _a === void 0 ? void 0 : _a[fieldName]) === null || _b === void 0 ? void 0 : _b.valid : res.valid);
|
|
93
|
+
}
|
|
94
|
+
function hasWarnings(fieldName) {
|
|
95
|
+
return hasFailures(res, SeverityCount.WARN_COUNT, fieldName);
|
|
96
|
+
}
|
|
97
|
+
function hasErrors(fieldName) {
|
|
98
|
+
return hasFailures(res, SeverityCount.ERROR_COUNT, fieldName);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
function hasFailures(res, countKey, fieldName) {
|
|
102
|
+
var _a, _b, _c;
|
|
103
|
+
var failureCount = fieldName
|
|
104
|
+
? (_b = (_a = res.tests) === null || _a === void 0 ? void 0 : _a[fieldName]) === null || _b === void 0 ? void 0 : _b[countKey]
|
|
105
|
+
: (_c = res[countKey]) !== null && _c !== void 0 ? _c : 0;
|
|
106
|
+
return isPositive(failureCount);
|
|
45
107
|
}
|
|
46
108
|
|
|
47
109
|
exports.parse = parse;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function t(t){var e=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(
|
|
1
|
+
"use strict";function t(t,n){return Object.prototype.hasOwnProperty.call(t,n)}function n(t){return"function"==typeof t}function r(t,r){if(!t)throw r instanceof String?r.valueOf():Error(r?function(t){for(var r=[],e=1;e<arguments.length;e++)r[e-1]=arguments[e];return n(t)?t.apply(void 0,r):t}(r):r)}function e(t){var n=Number(t);return!(isNaN(parseFloat(String(t)))||isNaN(Number(t))||!isFinite(n))}function u(t){return function(t,n){return e(t)&&e(n)&&Number(t)>Number(n)}(t,0)}var o,i,s;function a(t,n,r){var e,o,i;return u(t=r?null===(o=null===(e=t.tests)||void 0===e?void 0:e[r])||void 0===o?void 0:o[n]:null!==(i=t[n])&&void 0!==i?i:0)}Object.defineProperty(exports,"__esModule",{value:!0}),(i=o||(o={})).WARNINGS="warnings",i.ERRORS="errors",function(t){t.ERROR_COUNT="errorCount",t.WARN_COUNT="warnCount"}(s||(s={})),exports.parse=function(n){r(n&&t(n,"valid"),"Vest parser: expected argument at position 0 to be Vest's result object.");var e={},o={invalid:function(t){return a(n,s.ERROR_COUNT,t)},tested:function(r){return r?t(e,r)?e[r]:(e[r]=t(n.tests,r)&&u(n.tests[r].testCount),o.tested(r)):u(n.testCount)},untested:function(t){return 0===n.testCount||!o.tested(t)},valid:function(t){var r,e;return!!(t?null!==(e=null===(r=n.tests)||void 0===r?void 0:r[t])&&void 0!==e&&e.valid:n.valid)},warning:function(t){return a(n,s.WARN_COUNT,t)}};return o};
|