File / Directory |
Mutation score |
# Killed |
# Survived |
# Timeout |
# No coverage |
# Runtime errors |
# Transpile errors |
Total detected |
Total undetected |
Total mutants | |
---|---|---|---|---|---|---|---|---|---|---|---|
route.decorators.ts | 98.08 | 48 | 1 | 3 | 0 | 22 | 0 | 51 | 1 | 74 |
import { Observable } from 'rxjs/Observable';
import { map } from 'rxjs/operators';
import { OperatorFunction } from 'rxjs/src/interfaces';
export interface RouteXxlConfig {
observable?: boolean;
pipe?: OperatorFunction<any, any>[];
inherit?: boolean;
}
/**
* Traverses the routes, from the current route all the way up to the
* root route and stores each for the route data, params or queryParams observable
*
* @param {ActivatedRoute} parent
* @param {string} routeProperty
* @returns {Observable<Data | Params>[]}
*/
function extractRoute(parent: any, routeProperty: string, inherit = 0truefalse): Observable<any> 1{}{
if (2false3trueinherit) 4{}{
// Move up to the highest level
while (5falseparent.firstChild) 6{}{
7false8trueparent = parent.firstChild;
}
}
return parent[routeProperty];
}
/**
* Merge all observables from {@link extractRoutes} into a single stream passing through only the data/params
* of decorator. Depending on how the decorator was initialized (`{observable: false}`) the observable or the actual
* values are passed into the callback.
*
* @param {Observable<Data | Params>[]} routes
* @param {string[]} args list of the decorator's arguments
* @param {RouteConfigXxl} config the decorator's configuration object
* @param {(Observable<any> | any) => void} cb callback function receiving the final observable or the actual values as its arguments
*/
function extractValues(args: string[], stream$: Observable<any>): Observable<any> 9{}{
return stream$.pipe(
map(routeValues => 10{}{
const values = args.reduce((data, arg) => 11{}{
if (12false13truerouteValues 14||&& routeValues[arg]) 15{}{
16false17truedata[arg] = routeValues[arg];
}
return data;
}, {});
return 18false19trueargs.length 20!===== 1 ? values[args[0]] : values;
}),
);
}
/**
* Factory function which creates decorators for resolved route data, route params or query parameters.
*
* @param {string} routeProperty used to create a data, params or queryParams decorator function
* @returns {(...args: string | RouteXxlConfig[]) => PropertyDecorator}
*/
function routeDecoratorFactory(routeProperty, args, extractor?): PropertyDecorator 21{}{
const config = (22true23falsetypeof args[args.length 24+- 1] 25!===== 26""'object' ? args.pop() : {}) as RouteXxlConfig;
return (prototype: { ngOnInit(): void }, key: string): void => 27{}{
if (28true29false30args.length!args.length) 31{}{
32false33trueargs = 34[][key.replace(/\$$/, 35"Stryker was here!"'')];
}
// `ngOnInit` should exist on the component, otherwise the decorator will not work with the AOT compiler!!
if (36true37false38prototype.ngOnInit!prototype.ngOnInit) 39{}{
throw (new Error(40""`${prototype.constructor.name} uses the ${routeProperty} @decorator without implementing 'ngOnInit'`));
}
const ngOnInit = prototype.ngOnInit;
41false42trueprototype.ngOnInit = function(): void 43{}{
// Finally we have the instance!!
if (44true45false46this.route!this.route) 47{}{
throw (new Error(48""`${this.constructor.name} uses a route-xxl @decorator without a 'route: ActivatedRoute' property`));
}
let stream$ = extractor(this.route, routeProperty, config.inherit);
49false50truestream$ = extractValues(args, stream$);
if (51false52trueconfig.pipe) 53{}{
54true55falsestream$ = stream$.pipe(...config.pipe);
}
if (56true57falseconfig.observable 58!===== 59truefalse) 60{}{
stream$.subscribe(data => 61{}{
62false63truethis[key] = data;
});
} else 64{}{
65false66truethis[key] = stream$;
}
ngOnInit.call(this);
};
};
}
/*
The factory is wrapped in a function for the AOT compiler
*/
export function RouteData(...args: Array<string | RouteXxlConfig>): PropertyDecorator 67{}{
return routeDecoratorFactory(68""'data', args, extractRoute);
}
export function RouteParams(...args: Array<string | RouteXxlConfig>): PropertyDecorator 69{}{
return routeDecoratorFactory(70""'params', args, extractRoute);
}
export function RouteQueryParams(...args: Array<string | RouteXxlConfig>): PropertyDecorator 71{}{
return routeDecoratorFactory(72""'queryParams', args, 73() => undefinedroute => route.queryParams);
}
# | Mutator | State | Location | Original | Replacement |
---|---|---|---|---|---|
0 | BooleanSubstitution | Killed | 18 : 68 |
|
|
1 | Block | RuntimeError | 18 : 92 | {
... ];
} |
{} |
2 | IfStatement | RuntimeError | 19 : 8 |
|
|
3 | IfStatement | Killed | 19 : 8 |
|
|
4 | Block | Killed | 19 : 17 | {
... } |
{} |
5 | WhileStatement | RuntimeError | 21 : 15 | . |
|
6 | Block | TimedOut | 21 : 34 | {
... } |
{} |
7 | ConditionalExpression | TimedOut | 22 : 12 | = . |
|
8 | ConditionalExpression | TimedOut | 22 : 12 | = . |
|
9 | Block | RuntimeError | 39 : 82 | {
... );
} |
{} |
10 | Block | Killed | 41 : 27 | {
... } |
{} |
11 | Block | RuntimeError | 42 : 54 | {
... } |
{} |
12 | IfStatement | RuntimeError | 43 : 20 | && ...[ ] |
|
13 | IfStatement | Killed | 43 : 20 | && ...[ ] |
|
14 | BinaryExpression | Killed | 43 : 32 | && |
|| |
15 | Block | Killed | 43 : 53 | {
... } |
{} |
16 | ConditionalExpression | Killed | 44 : 20 | [ ]...[ ] |
|
17 | ConditionalExpression | Killed | 44 : 20 | [ ]...[ ] |
|
18 | ConditionalExpression | Killed | 50 : 19 | . === |
|
19 | ConditionalExpression | Killed | 50 : 19 | . === |
|
20 | BinaryExpression | Killed | 50 : 31 | === |
!== |
21 | Block | RuntimeError | 61 : 83 | {
... };
} |
{} |
22 | ConditionalExpression | Killed | 62 : 20 | [ ... ' |
|
23 | ConditionalExpression | Killed | 62 : 20 | [ ... ' |
|
24 | BinaryExpression | Killed | 62 : 44 | - |
+ |
25 | BinaryExpression | Killed | 62 : 49 | === |
!== |
26 | StringLiteral | RuntimeError | 62 : 53 | ' ' |
"" |
27 | Block | Killed | 64 : 67 | {
... } |
{} |
28 | IfStatement | Killed | 65 : 12 | ! . |
|
29 | IfStatement | RuntimeError | 65 : 12 | ! . |
|
30 | PrefixUnaryExpression | Killed | 65 : 12 | ! . |
. |
31 | Block | Killed | 65 : 26 | {
... } |
{} |
32 | ConditionalExpression | Killed | 66 : 12 | = [ ... '')] |
|
33 | ConditionalExpression | Killed | 66 : 12 | = [ ... '')] |
|
34 | ArrayLiteral | Killed | 66 : 19 | [ .... '')] |
[] |
35 | StringLiteral | Killed | 66 : 39 | '' |
" ... !" |
36 | IfStatement | RuntimeError | 70 : 12 | ! . |
|
37 | IfStatement | RuntimeError | 70 : 12 | ! . |
|
38 | PrefixUnaryExpression | Killed | 70 : 12 | ! . |
. |
39 | Block | Killed | 70 : 33 | {
... } |
{} |
40 | StringLiteral | Killed | 71 : 29 | `${ ... '` |
"" |
41 | ConditionalExpression | Killed | 76 : 8 | . ... } |
|
42 | ConditionalExpression | Killed | 76 : 8 | . ... } |
|
43 | Block | Killed | 76 : 46 | {
... } |
{} |
44 | IfStatement | RuntimeError | 78 : 16 | ! . |
|
45 | IfStatement | RuntimeError | 78 : 16 | ! . |
|
46 | PrefixUnaryExpression | Killed | 78 : 16 | ! . |
. |
47 | Block | Killed | 78 : 29 | {
... } |
{} |
48 | StringLiteral | Killed | 79 : 33 | `${ ... ` |
"" |
49 | ConditionalExpression | Killed | 83 : 12 | $ = ... $) |
|
50 | ConditionalExpression | Killed | 83 : 12 | $ = ... $) |
|
51 | IfStatement | RuntimeError | 85 : 16 | . |
|
52 | IfStatement | Survived | 85 : 16 | . |
|
53 | Block | RuntimeError | 85 : 29 | {
... } |
{} |
54 | ConditionalExpression | RuntimeError | 86 : 16 | $ = ... ) |
|
55 | ConditionalExpression | RuntimeError | 86 : 16 | $ = ... ) |
|
56 | IfStatement | RuntimeError | 89 : 16 | . === |
|
57 | IfStatement | RuntimeError | 89 : 16 | . === |
|
58 | BinaryExpression | Killed | 89 : 34 | === |
!== |
59 | BooleanSubstitution | Killed | 89 : 38 |
|
|
60 | Block | Killed | 89 : 45 | {
... } |
{} |
61 | Block | Killed | 90 : 42 | {
... } |
{} |
62 | ConditionalExpression | Killed | 91 : 20 | [ ] = |
|
63 | ConditionalExpression | Killed | 91 : 20 | [ ] = |
|
64 | Block | Killed | 93 : 19 | {
... } |
{} |
65 | ConditionalExpression | Killed | 94 : 16 | [ ] = $ |
|
66 | ConditionalExpression | Killed | 94 : 16 | [ ] = $ |
|
67 | Block | RuntimeError | 105 : 86 | {
... );
} |
{} |
68 | StringLiteral | Killed | 106 : 33 | ' ' |
"" |
69 | Block | RuntimeError | 109 : 88 | {
... );
} |
{} |
70 | StringLiteral | Killed | 110 : 33 | ' ' |
"" |
71 | Block | RuntimeError | 113 : 93 | {
... );
} |
{} |
72 | StringLiteral | Killed | 114 : 33 | ' ' |
"" |
73 | ArrowFunction | Killed | 114 : 54 | => . |
() => |