Skip to content

Instantly share code, notes, and snippets.

View bolatovumar's full-sized avatar
💭
github stories when?

Umar Bolatov bolatovumar

💭
github stories when?
View GitHub Profile
type KVPair = {k: PropertyKey; v: unknown}
type OmitKV<T extends KVPair, V> = T extends {v: V} ? never : T;
type Unionize<T extends object> = {
[k in keyof T]: {k: k; v: T[k]}
}[keyof T];
type Objectify<T extends KVPair> = {
[k in T['k']]: Extract<T, {k: k}>['v']
};
type OmitProperties<T extends object, V> = Objectify<OmitKV<Unionize<T>, V>>;
@bolatovumar
bolatovumar / async-parallel.js
Last active May 16, 2019 00:39
Function to process items asynchronously in groups of N
// Resolves when all promises are done resolving
function processItems(promises) {
return Promise.all(promises.map(el => el()));
}
// Simulates asyncronous work in range of 0 to 5 seconds
function processItem(item) {
console.log(`processing item ${item}`);

Keybase proof

I hereby claim:

  • I am bolatovumar on github.
  • I am ubolator (https://keybase.io/ubolator) on keybase.
  • I have a public key ASAA28OFBQb7MC1SumgK7qrZHTRgcE1Od1IXdKTVWlPeaAo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am bolatovumar on github.
  • I am ubolator (https://keybase.io/ubolator) on keybase.
  • I have a public key ASCqywBiCiDOvGjy9qRfC5oq46EAie9iW14-cA5Ks8Qc2Ao

To claim this, I am signing this object: