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 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 */ | |
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
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
type BaseObj = { | |
id: string; | |
parentId: string | null; | |
}; | |
type Result<T extends BaseObj> = T & { | |
children: Result<T>[]; | |
}; | |
export const listToTree = ( | |
arr: BaseObj[], |
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 { DateTime } from 'luxon'; | |
const units: Intl.RelativeTimeFormatUnit[] = ['year', 'month', 'week', 'day', 'hour', 'minute', 'second']; | |
/** | |
* https://github.com/moment/luxon/issues/274#issuecomment-649347238 | |
* | |
* @param dateTime DateTime.fromISO(isoString) | |
* @returns string | |
* |
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 interface Color { | |
50: string; | |
100: string; | |
200: string; | |
300: string; | |
400: string; | |
500: string; | |
600: string; | |
700: string; | |
800: string; |
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 { useEffect } from 'react'; | |
import { addStylesToHtml } from 'shared/ui/addStyles'; | |
const createGrabbingStyles = () => { | |
const style = document.createElement('style'); | |
style.textContent = ` | |
.useDragScrolling.grabbing { | |
scroll-behavior: auto; | |
cursor: grabbing; | |
} |
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
/** | |
* @description | |
* https://realadmin.ru/coding/sklonenie-na-javascript.html | |
* @param n number | |
* @param text_forms string[] | |
* @returns string | |
* | |
* @example | |
* ```js | |
* declOfNum(1, ['минута', 'минуты', 'минут']); // вернёт — минута |
NewerOlder