refactor: extract entry creation logic

This commit is contained in:
Carlos Valente
2026-02-13 20:36:54 +01:00
committed by Carlos Valente
parent 5777ef3532
commit 4827117163
11 changed files with 196 additions and 112 deletions
-12
View File
@@ -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