definma-ui/src/app/object.pipe.ts

16 lines
344 B
TypeScript
Raw Normal View History

2020-07-13 10:52:10 +02:00
import { Pipe, PipeTransform } from '@angular/core';
2020-07-27 17:52:03 +02:00
import _ from 'lodash';
2020-07-13 10:52:10 +02:00
@Pipe({
2020-07-22 10:45:34 +02:00
name: 'object',
pure: true
2020-07-13 10:52:10 +02:00
})
export class ObjectPipe implements PipeTransform {
2020-07-27 17:52:03 +02:00
transform(value: object, omit: string[] = []): string {
const res = _.omit(value, omit);
return res && Object.keys(res).length ? JSON.stringify(res) : '';
2020-07-13 10:52:10 +02:00
}
}