From d8f1e10fb5eda60112841fe6c844c56e5e18bad4 Mon Sep 17 00:00:00 2001 From: jmainguytalend Date: Tue, 12 Sep 2023 16:40:04 +0200 Subject: [PATCH] Update function name --- packages/utils/src/types/types.util.test.ts | 8 +++----- packages/utils/src/types/types.util.ts | 3 +-- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/utils/src/types/types.util.test.ts b/packages/utils/src/types/types.util.test.ts index bd78c7c76ca..7ed94a732bb 100644 --- a/packages/utils/src/types/types.util.test.ts +++ b/packages/utils/src/types/types.util.test.ts @@ -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); diff --git a/packages/utils/src/types/types.util.ts b/packages/utils/src/types/types.util.ts index 1f3941036d3..7c0eb6ca57e 100644 --- a/packages/utils/src/types/types.util.ts +++ b/packages/utils/src/types/types.util.ts @@ -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 = (val: T | undefined | null): val is T => - val !== undefined && val !== null; +export const valued = (val: T | undefined | null): val is T => val !== undefined && val !== null;