| 9181 | } |
| 9182 | |
| 9183 | function delayed() { |
| 9184 | var remaining = wait - (now() - stamp); |
| 9185 | if (remaining <= 0 || remaining > wait) { |
| 9186 | if (maxTimeoutId) { |
| 9187 | clearTimeout(maxTimeoutId); |
| 9188 | } |
| 9189 | var isCalled = trailingCall; |
| 9190 | maxTimeoutId = timeoutId = trailingCall = undefined; |
| 9191 | if (isCalled) { |
| 9192 | lastCalled = now(); |
| 9193 | result = func.apply(thisArg, args); |
| 9194 | if (!timeoutId && !maxTimeoutId) { |
| 9195 | args = thisArg = null; |
| 9196 | } |
| 9197 | } |
| 9198 | } else { |
| 9199 | timeoutId = setTimeout(delayed, remaining); |
| 9200 | } |
| 9201 | } |
| 9202 | |
| 9203 | function maxDelayed() { |
| 9204 | if (timeoutId) { |