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
<img className={ styles.shippersConsigneesForm__mapImage } | |
src={ 'тут картинка, которая иногда не загружается' } | |
onError={ ( { currentTarget } ) => { | |
currentTarget.onerror = null; // prevents looping | |
currentTarget.src = mapImage // картинка, которая ТОЧНО есть | |
} } | |
alt="map"/> |
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
// нормализуем query Запрос для работы из объекта | |
export const qsNormalize = (params: {}, {nullIsRequired = true, decodeisRequired = true}): string => { | |
let urlObj = new URLSearchParams(Object.fromEntries( Object | |
.entries( params ) | |
// // чистим пустые значения | |
.filter( n => n[1] !== '' ) | |
.filter( n => n[1] !== undefined ) | |
.map(([a,b])=> [a, (b===null && nullIsRequired) ? 'null': b]) //переводим null в строку | |
.filter( n => n[1] !== null ) |
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 Foo = Promise<{a: number}> | |
type ExtractPromiseArg<X> = X extends Promise<infer T> ? T : never | |
type FooArg = ExtractPromiseArg<Foo> |
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 FIBONACCI(number) | |
Summ = Summ Mod 9 | |
If Summ = 0 Then | |
FIBONACCI = 9 | |
Else | |
FIBONACCI = Summ | |
End If | |
End Function |
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 query = Object.fromEntries( Object | |
.entries( { | |
page: 77, //этот удалится при значении page: 1 | |
term: '', | |
friend: null, | |
extra: 'Этот ключ не удалится', | |
} ) | |
// чистим дефолтные значения | |
.filter( n => n[1] !== null ) |
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
// возвращает массив из необходимого числа элементов needArraySize | |
// рандомных /НЕ ОДИНАКОВЫХ/ целых чисел (from 0 to realArraySize) | |
// к которому можно потом "замапится" для перемешивания значений искомого массива, например: | |
// randomDifferentIntegersArrayCreator(array.length)(from 1 to array.length).map(el=>array[el]) | |
const randomDifferentIntegersArrayCreator = (realArraySize = 1) => | |
(needArraySize = realArraySize) => { | |
const justArray = (a, b = []) => { while (a--) b[a] = a; return b } | |
let arrayOfNumbers = justArray(realArraySize), |
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 errorParser = errorStringArray => { | |
// c сервера приходят ошибки в таком формате | |
// errorStringArray = [ | |
// "The AboutMe field is required. (AboutMe)", | |
// "Invalid url format (Contacts->Twitter)", | |
// "Invalid url format (Contacts->Youtube)", | |
// "Invalid url format (Contacts->Vk)" | |
// ] | |
//убираем первую заглавную букву из названий будущих полей переменных |
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 randMinMax = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min |
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 wheelListener (elem, func) { | |
if (elem.addEventListener) { | |
if ('onwheel' in document) { | |
// IE9+, FF17+ | |
elem.addEventListener("wheel", func); | |
} else if ('onmousewheel' in document) { | |
// устаревший вариант события | |
elem.addEventListener("mousewheel", func); | |
} else { |
NewerOlder