Skip to content

Commit

Permalink
Merge pull request #354 from Consdata/IKC-383-event-preview
Browse files Browse the repository at this point in the history
IKC-383 Event preview
  • Loading branch information
pbelke authored May 24, 2024
2 parents 2333109 + 65caf69 commit 4b52d43
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@ describe('ObjectUtils', () => {
}
});
});

it('should return value when it is null', () => {
expect(ObjectUtils.removeNull(null)).toBeNull();
});

it('should return value when it is undefined', () => {
expect(ObjectUtils.removeNull(undefined)).toBeUndefined();
});
});
16 changes: 9 additions & 7 deletions kouncil-frontend/libs/common-utils/src/lib/util/object-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ export class ObjectUtils {

// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
public static removeNull(value: any): string {
Object.keys(value).forEach(key => {
if (value[key] && typeof value[key] === 'object') {
this.removeNull(value[key]);
} else if (value[key] === null) {
delete value[key];
}
});
if (value) {
Object.keys(value).forEach(key => {
if (value[key] && typeof value[key] === 'object') {
this.removeNull(value[key]);
} else if (value[key] === null) {
delete value[key];
}
});
}
return value;
}
}

0 comments on commit 4b52d43

Please sign in to comment.