File / Directory |
Mutation score |
# Killed |
# Survived |
# Timeout |
# No coverage |
# Runtime errors |
# Transpile errors |
Total detected |
Total undetected |
Total mutants | |
---|---|---|---|---|---|---|---|---|---|---|---|
route.decorators.ts | 98.48 | 62 | 1 | 3 | 0 | 8 | 0 | 65 | 1 | 74 |
import {OperatorFunction, Observable} from "rxjs";
import {map} from "rxjs/operators";
export interface RouteXxlConfig {
observable?: boolean;
pipe?: Array<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 (2true3falseinherit) 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 (12true13falserouteValues 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 (28false29true30args.length!args.length) 31{}{
32true33falseargs = 34[][key.replace(/\$$/, 35"Stryker was here!""")];
}
// `ngOnInit` should exist on the component, otherwise the decorator will not work with the AOT compiler!!
if (36true37prototype.ngOnInit38false!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 (44true45this.route46false!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{}{
54false55truestream$ = 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 | 17 : 68 |
|
|
1 | Block | RuntimeError | 17 : 92 | {
... ];
} |
{} |
2 | IfStatement | Killed | 18 : 8 |
|
|
3 | IfStatement | Killed | 18 : 8 |
|
|
4 | Block | Killed | 18 : 17 | {
... } |
{} |
5 | WhileStatement | Killed | 20 : 15 | . |
|
6 | Block | TimedOut | 20 : 34 | {
... } |
{} |
7 | ConditionalExpression | TimedOut | 21 : 12 | = . |
|
8 | ConditionalExpression | TimedOut | 21 : 12 | = . |
|
9 | Block | RuntimeError | 38 : 82 | {
... );
} |
{} |
10 | Block | Killed | 40 : 27 | {
... } |
{} |
11 | Block | RuntimeError | 41 : 54 | {
... } |
{} |
12 | IfStatement | Killed | 42 : 20 | && ...[ ] |
|
13 | IfStatement | Killed | 42 : 20 | && ...[ ] |
|
14 | BinaryExpression | Killed | 42 : 32 | && |
|| |
15 | Block | Killed | 42 : 53 | {
... } |
{} |
16 | ConditionalExpression | Killed | 43 : 20 | [ ]...[ ] |
|
17 | ConditionalExpression | Killed | 43 : 20 | [ ]...[ ] |
|
18 | ConditionalExpression | Killed | 49 : 19 | . === |
|
19 | ConditionalExpression | Killed | 49 : 19 | . === |
|
20 | BinaryExpression | Killed | 49 : 31 | === |
!== |
21 | Block | RuntimeError | 60 : 83 | {
... };
} |
{} |
22 | ConditionalExpression | Killed | 61 : 20 | [ ... " |
|
23 | ConditionalExpression | Killed | 61 : 20 | [ ... " |
|
24 | BinaryExpression | Killed | 61 : 44 | - |
+ |
25 | BinaryExpression | Killed | 61 : 49 | === |
!== |
26 | StringLiteral | RuntimeError | 61 : 53 | " " |
"" |
27 | Block | Killed | 63 : 67 | {
... } |
{} |
28 | IfStatement | Killed | 64 : 12 | ! . |
|
29 | IfStatement | Killed | 64 : 12 | ! . |
|
30 | PrefixUnaryExpression | Killed | 64 : 12 | ! . |
. |
31 | Block | Killed | 64 : 26 | {
... } |
{} |
32 | ConditionalExpression | Killed | 65 : 12 | = [ ... "")] |
|
33 | ConditionalExpression | Killed | 65 : 12 | = [ ... "")] |
|
34 | ArrayLiteral | Killed | 65 : 19 | [ .... "")] |
[] |
35 | StringLiteral | Killed | 65 : 39 | "" |
" ... !" |
36 | IfStatement | Killed | 69 : 12 | ! . |
|
37 | PrefixUnaryExpression | Killed | 69 : 12 | ! . |
. |
38 | IfStatement | Killed | 69 : 12 | ! . |
|
39 | Block | Killed | 69 : 33 | {
... } |
{} |
40 | StringLiteral | Killed | 70 : 29 | `${ ... '` |
"" |
41 | ConditionalExpression | Killed | 75 : 8 | . ... } |
|
42 | ConditionalExpression | Killed | 75 : 8 | . ... } |
|
43 | Block | Killed | 75 : 46 | {
... } |
{} |
44 | IfStatement | Killed | 77 : 16 | ! . |
|
45 | PrefixUnaryExpression | Killed | 77 : 16 | ! . |
. |
46 | IfStatement | Killed | 77 : 16 | ! . |
|
47 | Block | Killed | 77 : 29 | {
... } |
{} |
48 | StringLiteral | Killed | 78 : 33 | `${ ... ` |
"" |
49 | ConditionalExpression | Killed | 82 : 12 | $ = ... $) |
|
50 | ConditionalExpression | Killed | 82 : 12 | $ = ... $) |
|
51 | IfStatement | Killed | 84 : 16 | . |
|
52 | IfStatement | Survived | 84 : 16 | . |
|
53 | Block | Killed | 84 : 29 | {
... } |
{} |
54 | ConditionalExpression | Killed | 85 : 16 | $ = ... ) |
|
55 | ConditionalExpression | Killed | 85 : 16 | $ = ... ) |
|
56 | IfStatement | Killed | 88 : 16 | . === |
|
57 | IfStatement | Killed | 88 : 16 | . === |
|
58 | BinaryExpression | Killed | 88 : 34 | === |
!== |
59 | BooleanSubstitution | Killed | 88 : 38 |
|
|
60 | Block | Killed | 88 : 45 | {
... } |
{} |
61 | Block | Killed | 89 : 42 | {
... } |
{} |
62 | ConditionalExpression | Killed | 90 : 20 | [ ] = |
|
63 | ConditionalExpression | Killed | 90 : 20 | [ ] = |
|
64 | Block | Killed | 92 : 19 | {
... } |
{} |
65 | ConditionalExpression | Killed | 93 : 16 | [ ] = $ |
|
66 | ConditionalExpression | Killed | 93 : 16 | [ ] = $ |
|
67 | Block | RuntimeError | 104 : 86 | {
... );
} |
{} |
68 | StringLiteral | Killed | 105 : 33 | " " |
"" |
69 | Block | RuntimeError | 108 : 88 | {
... );
} |
{} |
70 | StringLiteral | Killed | 109 : 33 | " " |
"" |
71 | Block | RuntimeError | 112 : 93 | {
... );
} |
{} |
72 | StringLiteral | Killed | 113 : 33 | " " |
"" |
73 | ArrowFunction | Killed | 113 : 54 | => . |
() => |