Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/js/sale/checkout/lib/src/ |
Upload File : |
class Timer { constructor() { this.list = []; } add(fields) { if (!fields.hasOwnProperty('index')) { return false; } this.list[fields.index] = { id: fields.id }; } get(index) { if (!this.list[index] || this.list[index].length <= 0) { return {}; } return this.list[index]; } delete(fields) { this.list.splice(fields.index, 1); } clean(fields) { let timer = this.get(fields.index); clearTimeout(timer.id); this.delete({ index: fields.index }); } create(time, index = 'default', callback = null, callbackParams) { this.clean({index}); index = index == null? 'default': index; callback = typeof callback === 'function'? callback: function() {} let timer = setTimeout(callback, time); let item = {id: timer, index: index}; this.add(item) } isEmpty() { return this.list.length === 0; } } export {Timer}