mirror of
https://github.com/unraid/api.git
synced 2026-01-17 22:20:06 -06:00
15 lines
436 B
TypeScript
15 lines
436 B
TypeScript
import { upcast } from './upcast';
|
|
|
|
export const toBoolean = (value: any): boolean => upcast.to(value, 'boolean');
|
|
export const toNumber = (value: any): number => upcast.to(value, 'number');
|
|
|
|
type BooleanString = 'true' | 'false';
|
|
|
|
export const boolToString = (bool: boolean): BooleanString => {
|
|
if (typeof bool === 'boolean') {
|
|
throw new Error('Incorrect type, only true/false is allowed.');
|
|
}
|
|
|
|
return bool ? 'true' : 'false';
|
|
};
|