Skip to content

Commit cbf3ad8

Browse files
committed
v1.1.2
1 parent 491cc29 commit cbf3ad8

1 file changed

Lines changed: 6 additions & 18 deletions

File tree

src/utils/typof.ts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,11 @@ export const string = (value: unknown): string => {
9292
return types.includes('object') || types.includes('array') ? JSON.stringify(value) : String(value);
9393
};
9494

95-
export const number = (value: unknown): number => {
96-
return typof(value).includes('number') ? Number(value) : NaN;
97-
};
95+
export const number = (value: unknown): number => (typof(value).includes('number') ? Number(value) : NaN);
9896

99-
export const integer = (value: unknown): number => {
100-
return typof(value).includes('number') ? Math.trunc(Number(value)) : NaN;
101-
};
97+
export const integer = (value: unknown): number => (typof(value).includes('number') ? Math.trunc(Number(value)) : NaN);
10298

103-
export const float = <Value>(value: Value, fraction_digits: number): string | Value => {
104-
return typof(value).includes('number') ? Number(value).toFixed(fraction_digits) : value;
105-
};
99+
export const float = <Value>(value: Value, fraction_digits: number): string | Value => (typof(value).includes('number') ? Number(value).toFixed(fraction_digits) : value);
106100

107101
export const boolean = <Value>(value: Value): boolean | Value => {
108102
const types = typof(value);
@@ -120,9 +114,7 @@ export const boolean = <Value>(value: Value): boolean | Value => {
120114
}
121115
};
122116

123-
export const date = <Value>(value: Value): Date | Value => {
124-
return typof(value).includes('date') ? new Date(value as string) : value;
125-
};
117+
export const date = <Value>(value: Value): Date | Value => (typof(value).includes('date') ? new Date(value as string) : value);
126118

127119
export const object = <Value>(value: Value): UnknownObject | Value => {
128120
const types = typof(value);
@@ -136,10 +128,6 @@ export const array = <Value>(value: Value): unknown[] | Value => {
136128
return types.includes('array') && types.includes('string') ? (JSON.parse(value as string) as unknown[]) : value;
137129
};
138130

139-
export const _null = <Value>(value: Value): null | Value => {
140-
return typof(value).includes('null') ? null : value;
141-
};
131+
export const _null = <Value>(value: Value): null | Value => (typof(value).includes('null') ? null : value);
142132

143-
export const _undefined = <Value>(value: Value): undefined | Value => {
144-
return typof(value).includes('undefined') ? undefined : value;
145-
};
133+
export const _undefined = <Value>(value: Value): undefined | Value => (typof(value).includes('undefined') ? undefined : value);

0 commit comments

Comments
 (0)