Skip to content

Conversation

@webdevia
Copy link
Owner

No description provided.


export const removeFirstZeros = (value: string): string => value.replace(/^(-)?[0]+(-?\d+.*)$/, '$1$2');

export const getBeautifulNumber = (value?: number | null, separator: string = ' ') =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добрый день тут достаточно (value: number separator: string = ' '):string
Мы жестко принимает примитив => приводим к строке и разбиваем как нужно
separator: string = ' ' если мы кладем значение в переменную то тип указывать не нужно так как будет работать утиная типизация
Стоит указать что возвращает ф-ия так при разработке будет меньше ошибок

const transformRegexp: RegExp =
/(matrix\(-?\d+(\.\d+)?, -?\d+(\.\d+)?, -?\d+(\.\d+)?, -?\d+(\.\d+)?, )(-?\d+(\.\d+)?), (-?\d+(\.\d+)?)\)/;

type TransformedRegexp = {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Прекрасно

// http://www.w3.org/TR/AERT#color-contrast
Math.round((red * 299 + green * 587 + blue * 114) / 1000);

type BlackOrWhite = 'black' | 'white';

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Отличное решение которое в дальнейшем может сэкономить уйму сил, времени и денег

number: number;
};

export const getNumberedArray = (arr: unknown[]): NumberedArrayItem[] =>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хорошее решение, еще можно использовать джинерики

@webdevia webdevia merged commit 2277f22 into main Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants