Skip to content

Instantly share code, notes, and snippets.

View igorvolnyi's full-sized avatar

Igor Volnyi igorvolnyi

View GitHub Profile
@loilo
loilo / deepAsync.js
Last active May 29, 2019 12:17
Deeply resolves all promises in a data structure
// Arbitrarily nested object containing Promises goes in
// Plain data structure comes out
async function deepAsync (object) {
// Walk arrays
if (Array.isArray(object)) {
return Promise.all(object.map(async item => await deepAsync(item)))
// Walk objects
} else if (typeof object === 'object' && String(object) === '[object Object]') {
return Object
@loilo
loilo / bubble.md
Last active April 27, 2023 00:21
Make Vue events bubble

Make Vue events bubble

Vue events don't bubble the component tree on their own. However when writing wrapper components this can be the desired behaviour.

This code registers a global bubble directive which allows to re-emit all given events:

Let's say we want to bubble events start, accelerate and brake of our component Car.

Without any help, we'd roughly have to do this:

@loilo
loilo / split-pull-requests.md
Last active April 3, 2024 07:24
Split a large pull request into two