Utility function to solve issue#288 of class-transformer: ES6 Maps are not constructed properly
npm i gist:f65ddd8f17f8c388659aab76890f194b
# or
yarn add gist:f65ddd8f17f8c388659aab76890f194b| alert('hello world'); |
| import { ref } from 'vue'; | |
| const CacheMap = new Map<string, QuerablePromise<any>>(); | |
| export function useFetcher<T>(key: string, fetcherFn: () => Promise<T>) { | |
| const data = ref<T | null>(null); | |
| const error = ref<any | null>(null); | |
| let cache = CacheMap.get(key); | |
| if (cache === undefined) { |
| const LS_KEY_PREFIX = '__expirable-storage-'; | |
| export interface ExpirableStorage<T = any> { | |
| getItem(key: string): T | null; | |
| hasItem(key: string): boolean; | |
| setItem(key: string, value: T, expiresAt: number): void; | |
| } | |
| /** 설정한 기간이 지나면 파기되는 스토리지를 만든다. */ | |
| export function useExpirableStorage<T = any>( |
| import { computed, ref } from 'vue'; | |
| /** | |
| * Tracks a pending state of async functions. | |
| * 등록된 비동기 잡 함수의 진행 상태를 추적합니다. | |
| */ | |
| export function useAsyncJobsState() { | |
| const pendingJobsCount = ref(0); | |
| const isPending = computed(() => pendingJobsCount.value > 0); |
| import { MaybeRef } from '@vueuse/core'; | |
| import { computed, ComputedRef, unref } from 'vue'; | |
| /** | |
| * Union generic type of `Raw Value` | `Ref Value`, `Value Getter`. | |
| * `Raw 값`, `Ref 값`, `값 Getter` 타입을 모두 포용하는 Union Generic 타입입니다. | |
| */ | |
| export type ReactiveParam<T> = T extends Function ? never : MaybeRef<T> | (() => T); | |
| /** Unwraps `ReactiveParam<T>` and converts it to `ComputedRef<T>`. |
| type AnyFunction = (...args: any) => void; | |
| export function rafThrottle<T extends AnyFunction>(func: T) { | |
| let rafHandle: number | null = null; | |
| const throttled: { | |
| (this: ThisType<T> | void, ...args: Parameters<T>): void, | |
| cancel(): void, | |
| } = Object.assign( | |
| function (this: any, ...args: any) { |
| import { onUnmounted, Ref, watch } from '@vue/composition-api'; | |
| export type UseIntersectionObserverEntry<E extends HTMLElement> = | |
| IntersectionObserverEntry & { target: E }; | |
| export type UseIntersectionObserverCallback<E extends HTMLElement> = ( | |
| entry: UseIntersectionObserverEntry<E>, | |
| ) => void; | |
| export const useIntersectionObserver = <E extends HTMLElement>( |
Utility function to solve issue#288 of class-transformer: ES6 Maps are not constructed properly
npm i gist:f65ddd8f17f8c388659aab76890f194b
# or
yarn add gist:f65ddd8f17f8c388659aab76890f194b| from django.utils.encoding import escape_uri_path | |
| def build_url_with_query(origin_url: str, **params) -> str: | |
| """ | |
| Builds an URL with query string for the GET requesting method. | |
| """ | |
| mapped_params = map( | |
| lambda k: f"{escape_uri_path(k)}={escape_uri_path(params[k])}", params | |
| ) |
| @mixin animation( | |
| $duration: 1s, | |
| // ease, linear, ease-in, ease-out, ease-in-out, step-start, step-end, steps(), cubic-bezier() | |
| $timing-function: linear, | |
| $delay: 0s, | |
| // infinite | |
| $iteration-count: 1, | |
| // normal, reverse, alternate, alternate-reverse | |
| $direction: normal, | |
| // none, forwards, backwards, both |