starting a huge rewrite

This commit is contained in:
2025-10-27 02:05:43 -05:00
parent 444faea651
commit 6c59334c27
23 changed files with 2233 additions and 43 deletions
+26
View File
@@ -0,0 +1,26 @@
export function defaults(original: Record<string, any>, defaults: Record<string, any>) {
const final: Record<string, any> = {};
for (const prop of Object.keys(defaults)) {
final[prop] = defaults[prop];
}
for (const prop of Object.keys(original)) {
final[prop] = original[prop];
}
return final;
}
export const isNil = (value: any): value is null | undefined => value === null || value === undefined;
export const exists = <T>(value: T | null | undefined): value is NonNullable<T> => !isNil(value);
export const isObject = (value: any): value is Record<string, any> =>
typeof value === 'object' && !Array.isArray(value);
export const log = (...args: any[]) => {
const LOG_LEVEL = process.env.UNICORD_LOG_LEVEL?.toLocaleLowerCase();
if (LOG_LEVEL === 'debug') {
const timestamp = `\x1b[37m[${new Date().toLocaleString()}]\x1b[0m`;
const prefix = `\x1b[35m[unicord]`;
console.log(`${timestamp} ${prefix} \x1b[0m`, ...args);
}
};