File / Directory |
Mutation score |
# Killed |
# Survived |
# Timeout |
# No coverage |
# Runtime errors |
# Transpile errors |
Total detected |
Total undetected |
Total mutants | |
---|---|---|---|---|---|---|---|---|---|---|---|
methods.js | 77.89 | 74 | 21 | 0 | 0 | 0 | 0 | 74 | 21 | 95 |
/**
* Check value is not empty
* @param {string|FileList|Array} value
* @returns {boolean} - true == valid, false == invalid
*/
export function required(value) 0{}{
if (1false2true3value!value) return 4truefalse;
if (5false6true7value.length !== 0value.length === 0) return 8truefalse;
if (9false10true11typeof value === 'string' || value.trim() === ''12typeof value !== 'string'13false14truetypeof value === 15""'string' && 16value.trim() !== ''17false18truevalue.trim() === 19"Stryker was here!"'') return 20truefalse;
return 21falsetrue;
}
/**
* Test RegExp
* @param {string} value
* @param {RegExp} exp - regular expression
* @returns {boolean} - true == valid, false == invalid
*/
export function regexp(value, exp) 22{}{
return exp.test(value);
}
/**
* Check value is an email
* @param {string} value - email
* @returns {boolean} - true == valid, false == invalid
*/
export function email(value) 23{}{
return /[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/i.test(value);
}
/**
* Check file sizes are less than max
* @param {FileList} value - FileList
* @param {number} size - max file size
* @returns {boolean} - true == valid, false == invalid
*/
export function filesize(value, size) 24{}{
return Array.from(value).reduce((r, file) => 25file.size <= size || r26false27true28file.size < size29file.size > size30false31truefile.size <= size && r, 32falsetrue);
}
/**
* Check file extensions
* @param {FileList} value - FileList
* @param {string} extensions - extensions list
* @returns {boolean} - true == valid, false == invalid
*/
export function extension(value, extensions) 33{}{
return Array.from(value).reduce((r, file) => 34extensions.indexOf(file.name.split('.').pop()) !== -1 || r35false36true37extensions.indexOf(file.name.split('.').pop()) === -138false39trueextensions.indexOf(file.name.split(40""'.').pop()) !== 41+1-1 && r, 42falsetrue);
}
/**
* Check value is phone number
* @param {string} value - phone number
* @returns {boolean} - true == valid, false == invalid
*/
export function tel(value) 43{}{
return /^([+]+)*[0-9\x20\x28\x29-]{5,20}$/.test(value);
}
/**
* Check value is url
* @param {string} value - url
* @returns {boolean} - true == valid, false == invalid
*/
export function url(value) 44{}{
return /[-a-zA-Z0-9@:%_+.~#?&//=]{2,256}\.[a-z]{2,4}\b(\/[-a-zA-Z0-9@:%_+.~#?&//=]*)?/gi.test(value);
}
/**
* Check value is greater than min number
* @param {number} value - number
* @param {number} number - min number
* @returns {boolean} - true == valid, false == invalid
*/
export function min(value, number) 45{}{
return 46number < value47number > value48false49truenumber <= value;
}
/**
* Check value is less than max number
* @param {number} value - number
* @param {number} number - max number
* @returns {boolean} - true == valid, false == invalid
*/
export function max(value, number) 50{}{
return 51value < number52value > number53false54truevalue <= number;
}
/**
* Check value is multiple of number
* @param {number} value - number
* @param {number} number - factor
* @returns {boolean} - true == valid, false == invalid
*/
export function step(value, number) 55{}{
return 56value % number !== 057false58true59value * numbervalue % number === 0;
}
/**
* Check value is greater than min date
* @param {Date} date - current date
* @param {Date} mindate - max date
* @returns {boolean} - true == valid, false == invalid
*/
export function minDate(date, mindate) 60{}{
return 61mindate < date62mindate > date63false64truemindate <= date;
}
/**
* Check date is less than max date
* @param {Date} date - current date
* @param {Date} maxdate - max date
* @returns {boolean} - true == valid, false == invalid
*/
export function maxDate(date, maxdate) 65{}{
return 66date < maxdate67date > maxdate68false69truedate <= maxdate;
}
export default 70{}{
required: 71{}{
func: required,
message: 72""'This field is required',
},
regexp: 73{}{
func: regexp,
message: 74""'Please, provide correct value',
},
email: 75{}{
func: email,
message: 76""'This email is incorrect',
},
filesize: 77{}{
func: filesize,
message: 78""'This file is too large',
},
extension: 79{}{
func: extension,
message: 80""'This extension is not supported',
},
tel: 81{}{
func: tel,
message: 82""'This phone number is incorrect',
},
url: 83{}{
func: url,
message: 84""'Wrong url',
},
min: 85{}{
func: min,
message: 86""'This number is too less',
},
max: 87{}{
func: max,
message: 88""'This number is too large',
},
step: 89{}{
func: step,
message: 90""'This value is not a multiple of the specified step value',
},
minDate: 91{}{
func: minDate,
message: 92""'This date is too early',
},
maxDate: 93{}{
func: maxDate,
message: 94""'This date is too late',
},
};
# | Mutator | State | Location | Original | Replacement |
---|---|---|---|---|---|
0 | Block | Killed | 5 : 32 | {
... ;
} |
{} |
1 | IfStatement | Killed | 6 : 8 | ! |
|
2 | IfStatement | Killed | 6 : 8 | ! |
|
3 | PrefixUnaryExpression | Killed | 6 : 8 | ! |
|
4 | BooleanSubstitution | Killed | 6 : 23 |
|
|
5 | IfStatement | Killed | 7 : 8 | . === |
|
6 | IfStatement | Killed | 7 : 8 | . === |
|
7 | BinaryExpression | Killed | 7 : 8 | . === |
. !== |
8 | BooleanSubstitution | Killed | 7 : 35 |
|
|
9 | IfStatement | Killed | 8 : 8 | === '...== '' |
|
10 | IfStatement | Killed | 8 : 8 | === '...== '' |
|
11 | BinaryExpression | Killed | 8 : 8 | === '...== '' |
=== '...== '' |
12 | BinaryExpression | Killed | 8 : 8 | === ' ' |
!== ' ' |
13 | ConditionalExpression | Killed | 8 : 8 | === ' ' |
|
14 | ConditionalExpression | Killed | 8 : 8 | === ' ' |
|
15 | StringLiteral | Killed | 8 : 25 | ' ' |
"" |
16 | BinaryExpression | Killed | 8 : 37 | . () === '' |
. () !== '' |
17 | ConditionalExpression | Killed | 8 : 37 | . () === '' |
|
18 | ConditionalExpression | Killed | 8 : 37 | . () === '' |
|
19 | StringLiteral | Killed | 8 : 54 | '' |
" ... !" |
20 | BooleanSubstitution | Killed | 8 : 65 |
|
|
21 | BooleanSubstitution | Killed | 10 : 11 |
|
|
22 | Block | Killed | 19 : 35 | {
... );
} |
{} |
23 | Block | Killed | 28 : 29 | {
... );
} |
{} |
24 | Block | Killed | 38 : 38 | {
... );
} |
{} |
25 | BinaryExpression | Killed | 39 : 49 | . ... && |
. ... || |
26 | ConditionalExpression | Killed | 39 : 49 | . ... && |
|
27 | ConditionalExpression | Killed | 39 : 49 | . ... && |
|
28 | BinaryExpression | Killed | 39 : 49 | . <= |
. < |
29 | BinaryExpression | Killed | 39 : 49 | . <= |
. > |
30 | ConditionalExpression | Killed | 39 : 49 | . <= |
|
31 | ConditionalExpression | Killed | 39 : 49 | . <= |
|
32 | BooleanSubstitution | Killed | 39 : 73 |
|
|
33 | Block | Killed | 48 : 45 | {
... );
} |
{} |
34 | BinaryExpression | Killed | 49 : 49 | . ...- && |
. ...- || |
35 | ConditionalExpression | Killed | 49 : 49 | . ...- && |
|
36 | ConditionalExpression | Killed | 49 : 49 | . ...- && |
|
37 | BinaryExpression | Killed | 49 : 49 | . ...!== - |
. ...=== - |
38 | ConditionalExpression | Killed | 49 : 49 | . ...!== - |
|
39 | ConditionalExpression | Killed | 49 : 49 | . ...!== - |
|
40 | StringLiteral | Killed | 49 : 84 | '.' |
"" |
41 | PrefixUnaryExpression | Killed | 49 : 100 | - |
+ |
42 | BooleanSubstitution | Killed | 49 : 109 |
|
|
43 | Block | Killed | 57 : 27 | {
... );
} |
{} |
44 | Block | Killed | 66 : 27 | {
... );
} |
{} |
45 | Block | Killed | 76 : 35 | {
... ;
} |
{} |
46 | BinaryExpression | Killed | 77 : 11 | <= |
< |
47 | BinaryExpression | Killed | 77 : 11 | <= |
> |
48 | ConditionalExpression | Killed | 77 : 11 | <= |
|
49 | ConditionalExpression | Killed | 77 : 11 | <= |
|
50 | Block | Killed | 86 : 35 | {
... ;
} |
{} |
51 | BinaryExpression | Killed | 87 : 11 | <= |
< |
52 | BinaryExpression | Killed | 87 : 11 | <= |
> |
53 | ConditionalExpression | Killed | 87 : 11 | <= |
|
54 | ConditionalExpression | Killed | 87 : 11 | <= |
|
55 | Block | Killed | 96 : 36 | {
... ;
} |
{} |
56 | BinaryExpression | Killed | 97 : 11 | % === |
% !== |
57 | ConditionalExpression | Killed | 97 : 11 | % === |
|
58 | ConditionalExpression | Killed | 97 : 11 | % === |
|
59 | BinaryExpression | Killed | 97 : 11 | % |
* |
60 | Block | Killed | 106 : 39 | {
... ;
} |
{} |
61 | BinaryExpression | Killed | 107 : 11 | <= |
< |
62 | BinaryExpression | Killed | 107 : 11 | <= |
> |
63 | ConditionalExpression | Killed | 107 : 11 | <= |
|
64 | ConditionalExpression | Killed | 107 : 11 | <= |
|
65 | Block | Killed | 116 : 39 | {
... ;
} |
{} |
66 | BinaryExpression | Killed | 117 : 11 | <= |
< |
67 | BinaryExpression | Killed | 117 : 11 | <= |
> |
68 | ConditionalExpression | Killed | 117 : 11 | <= |
|
69 | ConditionalExpression | Killed | 117 : 11 | <= |
|
70 | ObjectLiteral | Killed | 120 : 15 | {
... },
} |
{} |
71 | ObjectLiteral | Killed | 121 : 14 | {
... } |
{} |
72 | StringLiteral | Survived | 123 : 17 | ' ... ' |
"" |
73 | ObjectLiteral | Killed | 125 : 12 | {
... } |
{} |
74 | StringLiteral | Survived | 127 : 17 | ' ... ' |
"" |
75 | ObjectLiteral | Survived | 129 : 11 | {
... } |
{} |
76 | StringLiteral | Survived | 131 : 17 | ' ... ' |
"" |
77 | ObjectLiteral | Survived | 133 : 14 | {
... } |
{} |
78 | StringLiteral | Survived | 135 : 17 | ' ... ' |
"" |
79 | ObjectLiteral | Survived | 137 : 15 | {
... } |
{} |
80 | StringLiteral | Survived | 139 : 17 | ' ... ' |
"" |
81 | ObjectLiteral | Killed | 141 : 9 | {
... } |
{} |
82 | StringLiteral | Survived | 143 : 17 | ' ... ' |
"" |
83 | ObjectLiteral | Survived | 145 : 9 | {
... } |
{} |
84 | StringLiteral | Survived | 147 : 17 | ' ' |
"" |
85 | ObjectLiteral | Survived | 149 : 9 | {
... } |
{} |
86 | StringLiteral | Survived | 151 : 17 | ' ... ' |
"" |
87 | ObjectLiteral | Survived | 153 : 9 | {
... } |
{} |
88 | StringLiteral | Survived | 155 : 17 | ' ... ' |
"" |
89 | ObjectLiteral | Survived | 157 : 10 | {
... } |
{} |
90 | StringLiteral | Survived | 159 : 17 | ' ... ' |
"" |
91 | ObjectLiteral | Survived | 161 : 13 | {
... } |
{} |
92 | StringLiteral | Survived | 163 : 17 | ' ... ' |
"" |
93 | ObjectLiteral | Survived | 165 : 13 | {
... } |
{} |
94 | StringLiteral | Survived | 167 : 17 | ' ... ' |
"" |