Skip to content
This repository was archived by the owner on Oct 1, 2018. It is now read-only.

Commit 29198f5

Browse files
committed
fix(operators): Use Map for operators map
1 parent a7f4182 commit 29198f5

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/app/operators/components/operator/operator.component.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const OPERATOR_TOKEN = new InjectionToken<string>('operators');
2020
})
2121
export class OperatorComponent implements OnInit {
2222
public operator: OperatorDoc;
23-
public operatorsMap: { string?: OperatorDoc };
23+
public operatorsMap = new Map<string, OperatorDoc>();
2424

2525
private readonly baseSourceUrl = 'https://github.com/ReactiveX/rxjs/blob/master/src/operators/';
2626
private readonly baseSpecUrl = 'http://reactivex.io/rxjs/test-file/spec-js/operators';
@@ -33,19 +33,14 @@ export class OperatorComponent implements OnInit {
3333
) {}
3434

3535
ngOnInit() {
36-
this.operatorsMap = this.operators.reduce(
37-
(acc: { string?: OperatorDoc }, value: OperatorDoc) => {
38-
acc[value.name] = value;
39-
return acc;
40-
},
41-
{}
42-
);
43-
36+
this.operators.forEach((op: OperatorDoc) => {
37+
this.operatorsMap.set(op.name, op);
38+
});
4439
this._activatedRoute.params
4540
.pipe(pluck('operator'))
4641
.subscribe((name: string) => {
47-
if (name in this.operatorsMap) {
48-
this.operator = this.operatorsMap[name];
42+
if (this.operatorsMap.has(name)) {
43+
this.operator = this.operatorsMap.get(name);
4944
} else {
5045
this.notfound();
5146
return;

0 commit comments

Comments
 (0)