summaryrefslogtreecommitdiffstats
path: root/src/pybind/mgr/dashboard/frontend/src/app/shared/pipes/map.pipe.ts
blob: 1c0839d080b20454f03b6e8e456fff098d12680e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import { Pipe, PipeTransform } from '@angular/core';

import _ from 'lodash';

@Pipe({
  name: 'map'
})
export class MapPipe implements PipeTransform {
  transform(value: string | number, map?: object): any {
    if (!_.isPlainObject(map)) {
      return value;
    }
    return _.get(map, value, value);
  }
}