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 useScrollIntoView = <T extends HTMLElement>(trigger: any) => { | |
| const refOfElementToScrollIntoView = useRef<T>(null) | |
| /** | |
| * when the trigger transitions from "off" to "on" (e.g. the data was initialized) | |
| * scroll the designated element (refOfElementToScrollIntoView) into view | |
| */ | |
| const previousTrigger = usePrevious(trigger) | |
| useEffect(() => { |
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 intersectionNode = { value: 8 }; | |
| const headNodeOfListA = { | |
| value: 4, | |
| next: { | |
| value: 1, | |
| next: intersectionNode | |
| } | |
| }; |
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
| import { useRef, useEffect } from 'react'; | |
| /** | |
| * a type-safe version of the `usePrevious` hook described here: | |
| * @see {@link https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state} | |
| */ | |
| export function usePrevious<T>( | |
| value: T, | |
| ): ReturnType<typeof useRef<T>>['current'] { | |
| const ref = useRef<T>(); |
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
| declare const deepFreeze: <T>(object: T) => T | |
| export default deepFreeze |
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
| /* ******************************** utility types ******************************** */ | |
| declare export type Modify<T, R> = Pick<T, Exclude<keyof T, keyof R>> & R; | |
| /** @deprecated @see `ElementType` */ | |
| declare export type ArrayElement<ArrayType> = ArrayType extends (infer ElementType)[] | |
| ? ElementType | |
| : ArrayType extends ReadonlyArray<infer ElementType> | |
| ? ElementType | |
| : never; |
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
| module.exports = (endpoint, query = {}) => { | |
| const queryEntries = Object.entries(query || {}).filter(([key, value]) => value || typeof value === 'boolean'); | |
| return queryEntries.length | |
| ? `${endpoint}?${queryEntries | |
| .map(pair => pair.map(encodeURIComponent).join('=')) | |
| .join('&')}` | |
| : endpoint; | |
| }; |
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 deepCloneVuexModule module => ({ | |
| ...module, | |
| state: JSON.parse(JSON.stringify(module.state)), | |
| modules: Object.entries(module.modules || {}) | |
| .map(([moduleName, module]) => [moduleName, deepCloneVuexModule(module)]) | |
| .reduce((acc, [moduleName, module]) => ({ ...acc, [moduleName]: module }), {}), | |
| }); |
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
| <template> | |
| <div class="loader" :class="{ 'loader--done': succeeded || errored }"> | |
| <template v-if="succeeded"> | |
| <slot name="success" :response="response"> | |
| <template v-if="showSuccessMessage"> | |
| <slot name="successIcon" :response="response"><i | |
| class="fa" | |
| :class="{ | |
| [successIconClass]: successIconClass, | |
| [`fa-${successIcon}`]: successIcon, |
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 ArrayElement<ArrayType> = | |
| ArrayType extends (infer ElementType)[] ? ElementType : | |
| ArrayType extends ReadonlyArray<infer ElementType> ? ElementType : | |
| never; | |
| type Flatten<T> = T extends Array<infer U> ? U : T; |
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
| interface NoverlapConfig { | |
| hash?: (...args:any[]) => any | |
| comparator?: (hash:any, existingKey:any) => boolean | |
| wait?: number | |
| start?: (...args:any[]) => any | |
| queue?: (...args:any[]) => any | |
| beforeFinish?: (...args:any[]) => any | |
| success?: (result:any, ...args:any[]) => any | |
| fail?: (result:Error, ...args:any[]) => any | |
| finish?: (result:any, ...args:any[]) => any |