main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
670 bytes
|
Rev | Line | |
---|
[d565449] | 1 | /** Error message constants. */
|
---|
| 2 | var FUNC_ERROR_TEXT = 'Expected a function';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * The base implementation of `_.delay` and `_.defer` which accepts `args`
|
---|
| 6 | * to provide to `func`.
|
---|
| 7 | *
|
---|
| 8 | * @private
|
---|
| 9 | * @param {Function} func The function to delay.
|
---|
| 10 | * @param {number} wait The number of milliseconds to delay invocation.
|
---|
| 11 | * @param {Array} args The arguments to provide to `func`.
|
---|
| 12 | * @returns {number|Object} Returns the timer id or timeout object.
|
---|
| 13 | */
|
---|
| 14 | function baseDelay(func, wait, args) {
|
---|
| 15 | if (typeof func != 'function') {
|
---|
| 16 | throw new TypeError(FUNC_ERROR_TEXT);
|
---|
| 17 | }
|
---|
| 18 | return setTimeout(function() { func.apply(undefined, args); }, wait);
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | export default baseDelay;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.