File / Directory |
Mutation score |
# Killed |
# Survived |
# Timeout |
# No coverage |
# Runtime errors |
# Transpile errors |
Total detected |
Total undetected |
Total mutants | |
|---|---|---|---|---|---|---|---|---|---|---|---|
| convert-data.js | 93.65 | 55 | 4 | 4 | 0 | 0 | 0 | 59 | 4 | 63 | |
/**
* Create query portion of url for serialize method
* @param {string} name
* @param {object|Array|string} data
* @returns {string} - part of url
*/
export function getQueryPart(name, data) 0{}{
if (1false2trueArray.isArray(data)) 3{}{
return data.reduce((part, value) => 4part - getQueryPart(`${name}[]`, value)part + getQueryPart(5""`${name}[]`, value), 6"Stryker was here!"'');
}
if (7false8true9typeof data !== 'object'typeof data === 10""'object') 11{}{
return Object.keys(data).reduce((part, index) => 12part - getQueryPart(`${name}[${index}]`, data[index])part + getQueryPart(13""`${name}[${index}]`, data[index]), 14"Stryker was here!"'');
}
return 15""`${name}=${encodeURIComponent(data)}&`;
}
/**
* Name regexp for conversion to path
* @type {RegExp}
*/
const NAME = /(\[(\w*)\]|\w*)/gi;
/**
* Convert input name to path array
* @param {string} name - input name
* @returns {Array} - path to value in data object
*/
export function convertNameToPath(name) 16{}{
const path = [];
let matches = NAME.exec(name);
while (17false18matches === nullmatches !== null) 19{}{
if (20false21true22matches.index !== NAME.lastIndexmatches.index === NAME.lastIndex) 23{}{
NAME.lastIndex += 1;
}
path.push(24matches[2] && matches[1]25true26falsematches[2] || matches[1]);
matches = NAME.exec(name);
}
return path;
}
/**
* Convert data object to a value for sending
* @param {object} data - data object
* @param {string} type - type of conversion
* @param {function} FileListType
* @param {function} FormDataType
* @returns {string|FormData} - output value
*/
export function convertData(data, type, FileListType = FileList, FormDataType = FormData) 27{}{
let convertedData;
switch (type) {
28case 'serialize':case 29""'serialize':
convertedData = Object.keys(data).reduce((query, name) => 30""`${query}${getQueryPart(name, data[name])}`, 31"Stryker was here!"'');
return convertedData.length ? convertedData.slice(0, 32+1-1) : 33"Stryker was here!"'';
34case 'formData':case 35""'formData':
return Object.keys(data).reduce((formData, name) => 36{}{
if (37false38truedata[name] instanceof FileListType) 39{}{
if (40false41true42data[name].length >= 143data[name].length <= 1data[name].length > 1) 44{}{
for (let i = 0; 45false46i <= data[name].length47i >= data[name].lengthi < data[name].length; i += 1) 48{}{
formData.append(49""`${name}[${i}]`, data[name][i]);
}
} else if (50false51true52data[name].length !== 1data[name].length === 1) 53{}{
formData.append(name, data[name][0]);
}
} else if (54false55true56typeof data[name] !== 'object'typeof data[name] === 57""'object') 58{}{
Object.keys(data[name]).forEach(key => formData.append(59""`${name}[${key}]`, data[name][key]));
} else 60{}{
formData.append(name, data[name]);
}
return formData;
}, new FormDataType());
case 61""'json':
62default:default:
return JSON.stringify(data);
}
}
| # | Mutator | State | Location | Original | Replacement |
|---|---|---|---|---|---|
| 0 | Block | Killed | 6 : 41 | {
...&`;
} |
{} |
| 1 | IfStatement | Killed | 7 : 8 | . ( ) |
|
| 2 | IfStatement | Killed | 7 : 8 | . ( ) |
|
| 3 | Block | Killed | 7 : 29 | {
... } |
{} |
| 4 | BinaryExpression | Killed | 8 : 44 | + ... ) |
- ... ) |
| 5 | StringLiteral | Killed | 8 : 64 | `${ }[]` |
"" |
| 6 | StringLiteral | Killed | 8 : 85 | '' |
" ... !" |
| 7 | IfStatement | Killed | 11 : 8 | === ' ' |
|
| 8 | IfStatement | Killed | 11 : 8 | === ' ' |
|
| 9 | BinaryExpression | Killed | 11 : 8 | === ' ' |
!== ' ' |
| 10 | StringLiteral | Killed | 11 : 24 | ' ' |
"" |
| 11 | Block | Killed | 11 : 34 | {
... } |
{} |
| 12 | BinaryExpression | Killed | 12 : 57 | + ... ]) |
- ... ]) |
| 13 | StringLiteral | Killed | 12 : 77 | `${ ... }]` |
"" |
| 14 | StringLiteral | Killed | 12 : 112 | '' |
" ... !" |
| 15 | StringLiteral | Killed | 15 : 11 | `${ ... )}&` |
"" |
| 16 | Block | Killed | 29 : 40 | {
... ;
} |
{} |
| 17 | WhileStatement | Killed | 33 : 11 | !== |
|
| 18 | BinaryExpression | Killed | 33 : 11 | !== |
=== |
| 19 | Block | TimedOut | 33 : 29 | {
... } |
{} |
| 20 | IfStatement | TimedOut | 34 : 12 | . ... . |
|
| 21 | IfStatement | Survived | 34 : 12 | . ... . |
|
| 22 | BinaryExpression | TimedOut | 34 : 12 | . ... . |
. ... . |
| 23 | Block | TimedOut | 34 : 46 | {
... } |
{} |
| 24 | BinaryExpression | Killed | 38 : 18 | [ ] |... [ ] |
[ ] &... [ ] |
| 25 | ConditionalExpression | Killed | 38 : 18 | [ ] |... [ ] |
|
| 26 | ConditionalExpression | Killed | 38 : 18 | [ ] |... [ ] |
|
| 27 | Block | Killed | 54 : 90 | {
... }
} |
{} |
| 28 | SwitchCase | Killed | 58 : 8 | ' ...: ''; |
' ': |
| 29 | StringLiteral | Killed | 58 : 13 | ' ' |
"" |
| 30 | StringLiteral | Killed | 59 : 70 | `${ ... ])}` |
"" |
| 31 | StringLiteral | Killed | 59 : 115 | '' |
" ... !" |
| 32 | PrefixUnaryExpression | Killed | 60 : 65 | - |
+ |
| 33 | StringLiteral | Killed | 60 : 71 | '' |
" ... !" |
| 34 | SwitchCase | Killed | 61 : 8 | ' ... ()); |
' ': |
| 35 | StringLiteral | Killed | 61 : 13 | ' ' |
"" |
| 36 | Block | Killed | 62 : 64 | {
... } |
{} |
| 37 | IfStatement | Killed | 63 : 20 | [ ] |
|
| 38 | IfStatement | Killed | 63 : 20 | [ ] |
|
| 39 | Block | Killed | 63 : 56 | {
... } |
{} |
| 40 | IfStatement | Killed | 64 : 24 | [ ]. > |
|
| 41 | IfStatement | Killed | 64 : 24 | [ ]. > |
|
| 42 | BinaryExpression | Killed | 64 : 24 | [ ]. > |
[ ... >= |
| 43 | BinaryExpression | Killed | 64 : 24 | [ ]. > |
[ ... <= |
| 44 | Block | Killed | 64 : 47 | {
... } |
{} |
| 45 | ForStatement | Killed | 65 : 40 | < [ ]. |
|
| 46 | BinaryExpression | Survived | 65 : 40 | < [ ]. |
<= [ ]. |
| 47 | BinaryExpression | Killed | 65 : 40 | < [ ]. |
>= [ ]. |
| 48 | Block | Killed | 65 : 71 | {
... } |
{} |
| 49 | StringLiteral | Killed | 66 : 44 | `${ }[${ }]` |
"" |
| 50 | IfStatement | Killed | 68 : 31 | [ ... === |
|
| 51 | IfStatement | Survived | 68 : 31 | [ ... === |
|
| 52 | BinaryExpression | Killed | 68 : 31 | [ ... === |
[ ... !== |
| 53 | Block | Killed | 68 : 56 | {
... } |
{} |
| 54 | IfStatement | Killed | 71 : 27 | [ ... ' |
|
| 55 | IfStatement | Killed | 71 : 27 | [ ... ' |
|
| 56 | BinaryExpression | Killed | 71 : 27 | [ ... ' |
[ ... ' |
| 57 | StringLiteral | Killed | 71 : 49 | ' ' |
"" |
| 58 | Block | Killed | 71 : 59 | {
... } |
{} |
| 59 | StringLiteral | Killed | 72 : 75 | `${ ... }]` |
"" |
| 60 | Block | Killed | 73 : 23 | {
... } |
{} |
| 61 | StringLiteral | Survived | 79 : 13 | ' ' |
"" |
| 62 | SwitchCase | Killed | 80 : 8 | :
... ); |
: |