renamed folder "app" to "src"

This commit is contained in:
2025-10-20 16:38:28 +02:00
parent 1890d28f47
commit 272c9519b9
8 changed files with 0 additions and 0 deletions

29
src/util.ts Normal file
View File

@@ -0,0 +1,29 @@
export const createPlaceholders = ( arr: any[] ) => {
return arr.map(() => '?').join(', ');
}
export type AddDollarPrefix<T> = {
[K in keyof T as `$${string & K}`]: T[K];
};
export function prefixKeysWithDollar<T extends Record<string, any>>(obj: T): AddDollarPrefix<T> {
const result = {} as AddDollarPrefix<T>;
for (const key in obj) {
const newKey = `$${key}` as keyof AddDollarPrefix<T>;
result[newKey] = obj[key] as any;
}
return result;
}
export function transformArray<T extends Record<string, any>>(arr: T[]): AddDollarPrefix<T>[] {
return arr.map(prefixKeysWithDollar);
}
export function pad_l2 ( _thing: string | number ): string {
if ( typeof _thing == "number" ) {
_thing = JSON.stringify(_thing);
};
return _thing.padStart(2, "0");
}