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

16 lines
352 B
TypeScript
Raw Normal View History

2020-07-13 10:52:10 +02:00
import { Pipe, PipeTransform } from '@angular/core';
2020-07-30 14:23:51 +02:00
import omit from 'lodash/omit';
2020-07-13 10:52:10 +02:00
@Pipe({
2021-01-25 12:34:23 +01:00
name: 'object',
pure: true
2020-07-13 10:52:10 +02:00
})
export class ObjectPipe implements PipeTransform {
2021-01-25 12:34:23 +01:00
transform(value: object, omitValue: string[] = []): string {
const res = omit(value, omitValue);
return res && Object.keys(res).length ? JSON.stringify(res) : '';
}
2020-07-13 10:52:10 +02:00
}