mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-12 02:43:50 +00:00
refactor: extract entry creation logic
This commit is contained in:
committed by
Carlos Valente
parent
5777ef3532
commit
4827117163
@@ -1,17 +1,5 @@
|
||||
export type ErrorEmitter = (message: string) => void;
|
||||
|
||||
/**
|
||||
* @description Ensures variable is string, it skips object types
|
||||
* @param val - variable to convert
|
||||
* @param {string} [fallback=''] - fallback value
|
||||
* @returns {string} - value as string or fallback if not possible
|
||||
*/
|
||||
export const makeString = (val: unknown, fallback = ''): string => {
|
||||
if (typeof val === 'string') return val.trim();
|
||||
else if (val == null || val.constructor === Object) return fallback;
|
||||
return val.toString().trim();
|
||||
};
|
||||
|
||||
/**
|
||||
* @description Verifies if object is empty
|
||||
* @param {object} obj
|
||||
|
||||
Reference in New Issue
Block a user