Last active
June 26, 2019 12:19
-
-
Save alexsoin/13ab10d60302edcb930d23c9b94b2edb to your computer and use it in GitHub Desktop.
Полезные функции для js [logger, dd]
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
let time_start = Date.now(), | |
time_last = time_start; | |
// Функция показывает время с момента старта загрузки страницы и с момента последнего вызова функции | |
function logger(text) { | |
let now = Date.now(); | |
console.log('%c@ %dms (waited %dms): %c%s', 'color: #6ecc21;', now - time_start, now - time_last, 'color: #39aceb;', text); | |
time_last = now; | |
} | |
// Красивый вывод console.log | |
// также есть возможность вывода заголовка | |
function dd(text, title = false) { | |
if (title) { | |
console.log('%c%s: %c%s', 'color: #8A2BE2;', title, 'color: #39aceb;', text); | |
} else { | |
console.log('%c%s', 'color: #39aceb;', text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment