fix(striker-ui): enable isEmpty to check objects

main
Tsu-ba-me 2 years ago
parent bc44d92bbd
commit 65871e32c7
  1. 6
      striker-ui/lib/isEmpty.ts
  2. 1
      striker-ui/types/MapToType.d.ts

@ -1,4 +1,7 @@
type IsEmptyTypeMap = Pick<MapToType, 'number' | 'string' | 'undefined'>;
type IsEmptyTypeMap = Pick<
MapToType,
'number' | 'object' | 'string' | 'undefined'
>;
type MapToValueIsEmptyFunction = {
[TypeName in keyof IsEmptyTypeMap]: (
@ -8,6 +11,7 @@ type MapToValueIsEmptyFunction = {
const MAP_TO_VALUE_IS_EMPTY_FUNCTION: MapToValueIsEmptyFunction = {
number: (value = 0) => value === 0,
object: (value) => Object.keys(value).length === 0,
string: (value = '') => value.trim().length === 0,
undefined: () => true,
};

@ -1,6 +1,7 @@
declare type MapToType = {
boolean: boolean;
number: number;
object: Record<string, unknown>;
string: string;
undefined: undefined;
};

Loading…
Cancel
Save