- Если обрабатываем промис и возвращаем его, в
onRejected
возвращаемPromise.reject(error)
либо не используемonRejected
, чтобы в любом случае была возможность обработать reject снаружи.const load = () => { return fetcher.get('/url') .then( (data) => { // Do something
return data;
This file contains 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
# file comment | |
invoice: 34843 | |
date: 2001-01-23 | |
# Русский коммент | |
bill-to: &id001 | |
given: Джон | |
family: Коннор | |
address: |
This file contains 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
/* Запустить на странице https://www.instagram.com/%username%/ */ | |
var promise = new Promise((resolve, reject) => { | |
const DELAY = 1000; | |
const DEVATION = 250; | |
const limit = 50; | |
// Сколько «страниц» скачать (на каждой по ${limit} фоток), 0 == без ограничений | |
const totalPages = 0; | |
// true если аккаунт друга (на кого подписан) или свой, иначе false | |
const isMyFriendPage = true; |
This file contains 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 { useCallback, useState } from 'react'; | |
/** | |
* Хук для хранения уникального набора элементов в массиве. | |
* Возвращает массив и функцию переключения элемента. | |
*/ | |
export default (initialValue = []) => { | |
const [items, setItems] = useState(initialValue); | |
const toggle = useCallback( | |
(item, force = null) => { |
This file contains 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
// https://www.humanbenchmark.com/tests/reactiontime | |
var timeout; | |
var wait = false; | |
var el = document.querySelector('.test-standard'); | |
var check = function() { | |
console.log('Working...'); | |
if (wait && el.classList.contains('view-go')) { | |
wait = false; | |
console.log('Fire!!!'); |
This file contains 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
www./a | |
www./a/ | |
www./a/go/to | |
www./a/go/to/ | |
www./a/джа/ва | |
www./a/джа/ва/ | |
www./aдж_а-ва | |
www./a/%D0%B4%D0%B6%D0%B0/%D0%B2%D0%B0 | |
www./a/go/to/index.html | |
www./a/джа/ва/index.html |
This file contains 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
size=50 | |
mkdir converted | |
find . -type f -maxdepth 1 -print0 | \ | |
xargs -0 -n 1 -P 8 -I __FILE__ \ | |
convert __FILE__ -resize $size -set filename:new '%d/%t' \ | |
\( -clone 0 -tile overlay.png -draw "color 0,0 reset" \) \ | |
# -compose blend -define compose:args=50 \ | |
-compose overlay \ | |
-composite "converted/%[filename:new]_${size}.png" |
This file contains 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 axios, { CancelToken, isCancel } from 'axios'; | |
const instance = axios.create({ | |
withCredentials: true, | |
headers: { | |
Accept: 'application/json', | |
'Content-Type': 'application/json', | |
}, | |
}); |
NewerOlder