Skip to content

Instantly share code, notes, and snippets.

View akleandrov's full-sized avatar

Alexey Kleandrov akleandrov

  • Russia,Saint-Petersburg
View GitHub Profile
Тестовое задание:
Coding task:
Please write a function wrapper slow_guard(timeout, fn) that logs a warning if
the function takes too long to complete. Here is a typical example of how your wrapper can be used:
Array.prototype.sort = slow_guard(1000, Array.prototype.sort);
After this, if sorting an array ever takes longer than one second, a warning
should appear on the developer console.
We expect a short solution about 5-10 lines of code.
Ответ: Если опустить тот факт что так делать ни в коем случае не надо,