jsshort
Version:
It will make your codes much short and easiar
28 lines (22 loc) • 709 B
text/typescript
// conversion.ts
// Function to convert a value to an integer
export const int = parseInt;
// Function to convert a value to a string
export const str = String;
// Function to convert a value to a float (floating-point number)
export const float = parseFloat;
// Function to convert a value to a boolean
export const bool = Boolean;
// Function to convert a value to an array
export const array = function(value: any): any[] {
if (Array.isArray(value)) {
return value;
} else {
return [value];
}
};
(global as any).int = int;
(global as any).str = str;
(global as any).float = float;
(global as any).bool = bool;
(global as any).array = array;