Skip to content

Instantly share code, notes, and snippets.

View on3dd's full-sized avatar
👽

Artyom on3dd

👽
View GitHub Profile
@on3dd
on3dd / helper.ts
Created April 10, 2021 03:46
typescript helper inferring type from union type by key
type Helper<T, K extends string | number> = Extract<T, Record<K, unknown>>;
@on3dd
on3dd / unriddle_me_1.ts
Last active January 29, 2021 03:58
fp flavored solutions for https://youtu.be/XlI1zoH2gjU
const unriddle_me_1 = (str: string): string => {
const length = Math.ceil(str.length / 2);
const [a, b] = [str.slice(0, length), str.slice(length)];
return a.split('').reduce((acc, curr, idx) => {
return acc + curr + (b[idx] || '');
}, '');
};
console.log(