This file contains some config files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script lang="ts"> | |
import { computed, PropType, defineComponent } from 'vue'; | |
import { RouterLink, useLink } from 'vue-router'; | |
import type { RouterLinkProps } from 'vue-router'; | |
declare module 'vue-router' { | |
interface _RouterLinkI { | |
props: { | |
[k in keyof RouterLinkProps]-?: { | |
type: PropType<RouterLinkProps[k]>; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const groupBy = <X, K extends PropertyKey>( | |
getKey: (x: X) => K, | |
xs: readonly X[], | |
): { readonly [k in K]?: readonly (X | undefined)[] } => { | |
const grouped: { [k in K]?: (X | undefined)[] } = {}; | |
for (const x of xs) { | |
const key = getKey(x); | |
grouped[key] ??= []; | |
// we have initialised ^ so grouped[key] won't be undefined |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type OmitRecursive<T extends object, O extends string> = Omit< | |
{ [K in keyof T]: T[K] extends object ? OmitRecursive<T[K], O> : T[K] }, | |
O | |
> | |
const removeKeysRecursive = <T extends object, K extends readonly string[]>( | |
object: T, | |
keys: K, | |
): OmitRecursive<T, K[number]> => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const requestAnimationFrameRecursive = ( | |
fn: ( | |
highResTimestamp: DOMHighResTimeStamp, | |
additionalInfo: { | |
stop: () => void; | |
totalTimelapse: DOMHighResTimeStamp; | |
timelapseSinceLast: DOMHighResTimeStamp; | |
}, | |
) => void, | |
o?: { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div ref="container"> | |
<Card v-for="(card, i) of cards" ref="cards"> | |
<IntersectionObserver :getTarget="() => this.$refs.cards[i]" @intersect="liftCard" @disintersect="unliftCard" /> | |
... | |
</Card> | |
</div> | |
<!-- vs --> | |
<div ref="container"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const mergeSort = (xs) => { | |
if (xs.length <= 1) return xs; | |
const midIndex = Math.trunc(xs.length / 2); | |
return merge( | |
mergeSort(xs.slice(0, midIndex)), | |
mergeSort(xs.slice(midIndex)), | |
); | |
} | |
const merge = (xs, ys) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const retryAsyncWithTimeout = (fns, ms) => new Promise((res, rej) => { | |
let hasTimeout = false; | |
const retryAsyncUntilSucceed = fn => new Promise((res, rej) => { | |
fn().then(res).catch(() => { | |
if (!hasTimeout) { | |
retryAsyncUntilSucceed(fn) | |
} | |
}); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const flatMap = (xs, fn, thisArg) => { | |
if (typeof Array.prototype.flatMap === 'function') { | |
return Array.prototype.flatMap.call(xs, fn, thisArg); | |
} | |
const bFn = fn.bind(thisArg); | |
return xs.reduce((acc, x) => { | |
const r = bFn(x); | |
if (Array.isArray(r)) return [...acc, ...r]; | |
return [...acc, r]; |