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
function measureExecutionTime(callback: () => void) { | |
return function () { | |
const startTime = performance.now(); | |
callback(); | |
const endTime = performance.now(); | |
const executionTime = endTime - startTime; | |
console.log(`Execution time for '${callback.name}': ${executionTime} milliseconds`); | |
}; | |
} |
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
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
type Primitive = string | number | boolean | bigint | symbol | undefined | null; | |
interface Constructor<T = unknown, P extends unknown[] = never> { | |
new (...args: P): T; | |
} | |
type Guard<P = any, T extends P = P> = (x: P) => x is T; | |
type SomeOf<T extends Guard[]> = T[number] extends Guard<infer P, infer R> | |
? (x: P) => x is R |
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 dayjs from 'dayjs'; | |
import { instanceOf } from '../typeguard'; | |
export type Coordinates = { x1: number; y1: number; x2: number; y2: number }; | |
const ResultType = { | |
blob: 'blob', | |
file: 'file', | |
url: 'url', | |
image: 'image', |
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
/* eslint-disable @typescript-eslint/no-explicit-any */ | |
/* eslint-disable @typescript-eslint/no-unused-vars */ | |
import { set } from 'lodash'; | |
import { useMemo } from 'react'; | |
import { Schema, ValidationError } from 'yup'; | |
/** | |
* Sets the `innerError.message` in an `errors` object at the key | |
* defined by `innerError.path`. | |
* @param {Object} errors The object to set the error in. |
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 { sleep } from './utils'; | |
export type RetryOptions = { | |
/** | |
* Maximum Retry Count (Following Circuit Breaker Strategy) | |
* @default 3 | |
*/ | |
retryCount?: number; | |
/** Prevent retry after link has expired */ | |
linkTtlSec?: number | null; |
OlderNewer