Skip to content

Instantly share code, notes, and snippets.

View iGoodie's full-sized avatar
🍀
Rocking

Anılcan Metinyurt iGoodie

🍀
Rocking
View GitHub Profile
@iGoodie
iGoodie / mixins.ts
Created August 2, 2024 15:54
Dart-like Typescript Mixins
/* --------------------------------- */
/* Implementation ------------------ */
/* --------------------------------- */
type Class<A extends any[] = [], T = {}> = new (...args: A) => T;
type StaticProps<T> = T extends Class<any, infer I>
? Omit<T, "prototype" | "constructor"> & { prototype: I }
: never;
type NotFunction =
| string
| number
| boolean
| null
| undefined
| bigint
| readonly any[]
| { apply?: never; [k: string]: any }
| { call?: never; [k: string]: any };
@iGoodie
iGoodie / flatten-object.ts
Last active May 31, 2022 16:38
Flatten JavaScript Object by Mapping Keys Recursively
export function flattenObject(
obj: object,
opts: {
prefix?: string;
postfix?: string;
delimiter?: string;
wordExtractor?: (text: string) => string[];
}
) {
const flattened: Record<string, any> = {};