Skip to content

Commit

Permalink
Update function name
Browse files Browse the repository at this point in the history
  • Loading branch information
jmainguytalend committed Sep 12, 2023
1 parent c9b91d3 commit d8f1e10
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
8 changes: 3 additions & 5 deletions packages/utils/src/types/types.util.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { filterUndefinedOrNull } from './types.util';
import { valued } from './types.util';

describe('types.util', () => {
describe('filterUndefinedOrNull', () => {
describe('valued', () => {
it('Filter array with null and undefined values', () => {
const result = ['Terra', undefined, 'Mars', 'Baal', null, 'Valhalla'].filter(
filterUndefinedOrNull,
);
const result = ['Terra', undefined, 'Mars', 'Baal', null, 'Valhalla'].filter(valued);

expect(result).toBeDefined();
expect(result.length).toEqual(4);
Expand Down
3 changes: 1 addition & 2 deletions packages/utils/src/types/types.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@
* So result is typed without "| null" nor "| undefined".
* This is not possible with a simple function like ".filter(v => !!v)" or ".filter(Boolean)"
*/
export const filterUndefinedOrNull = <T>(val: T | undefined | null): val is T =>
val !== undefined && val !== null;
export const valued = <T>(val: T | undefined | null): val is T => val !== undefined && val !== null;

0 comments on commit d8f1e10

Please sign in to comment.