@@ -220,43 +220,52 @@ idrinth.core = {
220220 var min = 10 ;
221221 /**
222222 *
223- * @param {Number } durationLeft
224- * @param {Number } minDuration
223+ * @param {Number } min
224+ * @param {Number } property
225225 * @returns {Number }
226226 */
227- var getVal = function ( durationLeft , minDuration ) {
228- if ( durationLeft < 0.1 ) {
229- return 0.1 ;
227+ var check = function ( min , property , date ) {
228+ /**
229+ *
230+ * @param {Number } durationLeft
231+ * @param {string } minDuration
232+ * @returns {Number }
233+ */
234+ var getVal = function ( durationLeft , minDuration ) {
235+ if ( durationLeft < 0.1 ) {
236+ return 0.1 ;
237+ }
238+ return durationLeft < minDuration ? durationLeft : minDuration ;
239+ } ;
240+ /**
241+ *
242+ * @param {string } property
243+ * @returns {undefined }
244+ */
245+ var handle = function ( property , min ) {
246+ idrinth . core . timeouts . list [ property ] . func ( ) ;
247+ idrinth . core . timeouts . list [ property ] . repeats = Math . max ( - 1 , idrinth . core . timeouts . list [ property ] . repeats - 1 ) ;
248+ if ( idrinth . core . timeouts . list [ property ] . repeats ) {
249+ min = getVal ( idrinth . core . timeouts . list [ property ] . duration , min ) ;
250+ idrinth . core . timeouts . list [ property ] . next = date + idrinth . core . timeouts . list [ property ] . duration / 1000 ;
251+ } else {
252+ delete idrinth . core . timeouts . list [ property ] ;
253+ }
254+ return min ;
255+ } ;
256+ if ( date < idrinth . core . timeouts . list [ property ] . next ) {
257+ return getVal ( idrinth . core . timeouts . list [ property ] . next - date , min ) ;
230258 }
231- return durationLeft < minDuration ? durationLeft : minDuration ;
232- } ;
233- /**
234- *
235- * @param {string } property
236- * @returns {undefined }
237- */
238- var handle = function ( property , min ) {
239- idrinth . core . timeouts . list [ property ] . func ( ) ;
240- idrinth . core . timeouts . list [ property ] . repeats = Math . max ( - 1 , idrinth . core . timeouts . list [ property ] . repeats - 1 ) ;
241- if ( idrinth . core . timeouts . list [ property ] . repeats ) {
242- min = getVal ( idrinth . core . timeouts . list [ property ] . duration , min ) ;
243- idrinth . core . timeouts . list [ property ] . next = date + idrinth . core . timeouts . list [ property ] . duration / 1000 ;
244- } else {
245- delete idrinth . core . timeouts . list [ property ] ;
259+ try {
260+ return handle ( property , min ) ;
261+ } catch ( e ) {
262+ idrinth . core . log ( e . message ? e . message : e . getMessage ( ) ) ;
263+ return min ;
246264 }
247- return min ;
248265 } ;
249266 for ( var property in idrinth . core . timeouts . list ) {
250267 if ( idrinth . core . timeouts . list . hasOwnProperty ( property ) ) {
251- if ( date >= idrinth . core . timeouts . list [ property ] . next ) {
252- try {
253- min = handle ( property , min ) ;
254- } catch ( e ) {
255- idrinth . core . log ( e . message ? e . message : e . getMessage ( ) ) ;
256- }
257- } else {
258- min = getVal ( idrinth . core . timeouts . list [ property ] . next - date , min ) ;
259- }
268+ min = check ( min , property , date ) ;
260269 }
261270 }
262271 if ( Object . keys ( idrinth . core . timeouts . list ) . length ) {
0 commit comments