1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-05 17:53:12 +02:00

fix: pull isDefined functions from main so that this compiles

This commit is contained in:
sighphyre 2022-06-29 10:38:51 +02:00
parent 48d2c74a3d
commit 16dbd7b30d
2 changed files with 11 additions and 0 deletions

View File

@ -0,0 +1,8 @@
import { isDefined } from './isDefined';
test('isDefined', () => {
expect(isDefined(null)).toEqual(false);
expect(isDefined(undefined)).toEqual(false);
expect(isDefined(0)).toEqual(true);
expect(isDefined(false)).toEqual(true);
});

View File

@ -0,0 +1,3 @@
export const isDefined = <T>(value: T | null | undefined): value is T => {
return value !== null && typeof value !== 'undefined';
};