Skip to content

Instantly share code, notes, and snippets.

@alexsoin
Last active June 26, 2019 12:19
Show Gist options
  • Save alexsoin/13ab10d60302edcb930d23c9b94b2edb to your computer and use it in GitHub Desktop.
Save alexsoin/13ab10d60302edcb930d23c9b94b2edb to your computer and use it in GitHub Desktop.
Полезные функции для js [logger, dd]
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