{
  "source": "timers.markdown",
  "modules": [
    {
      "textRaw": "定时器",
      "name": "定时器",
      "desc": "<pre><code>稳定度: 5 - 已锁定</code></pre>\n<p>All of the timer functions are globals.  You do not need to <code>require()</code>\nthis module in order to use them.\n\n</p>\n<p>所有的定时器函数都是全局变量. 你使用这些函数时不需要 <code>require()</code>模块.\n\n</p>\n",
      "methods": [
        {
          "textRaw": "setTimeout(callback, delay, [arg], [...])",
          "type": "method",
          "name": "setTimeout",
          "desc": "<p>To schedule execution of a one-time <code>callback</code> after <code>delay</code> milliseconds. Returns a\n<code>timeoutId</code> for possible use with <code>clearTimeout()</code>. Optionally you can\nalso pass arguments to the callback.\n\n</p>\n<p>调度 <code>delay</code> 毫秒后的一次 <code>callback</code> 执行。返回一个可能被 <code>clearTimeout()</code> 用到的 <code>timeoutId</code>。可选地，您还能给回调传入参数。\n\n</p>\n<p>It is important to note that your callback will probably not be called in exactly\n<code>delay</code> milliseconds - Node.js makes no guarantees about the exact timing of when\nthe callback will fire, nor of the ordering things will fire in. The callback will\nbe called as close as possible to the time specified.\n\n</p>\n<p>请务必注意，您的回调有可能不会在准确的 <code>delay</code> 毫秒后被调用。Node.js 不保证回调被触发的精确时间和顺序。回调会在尽可能接近所指定时间上被调用。\n\n</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "callback"
                },
                {
                  "name": "delay"
                },
                {
                  "name": "arg",
                  "optional": true
                },
                {
                  "name": "...",
                  "optional": true
                }
              ]
            }
          ]
        },
        {
          "textRaw": "clearTimeout(timeoutId)",
          "type": "method",
          "name": "clearTimeout",
          "desc": "<p>Prevents a timeout from triggering.\n\n</p>\n<p>阻止一个 timeout 被触发。\n\n</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "timeoutId"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "setInterval(callback, delay, [arg], [...])",
          "type": "method",
          "name": "setInterval",
          "desc": "<p>To schedule the repeated execution of <code>callback</code> every <code>delay</code> milliseconds.\nReturns a <code>intervalId</code> for possible use with <code>clearInterval()</code>. Optionally\nyou can also pass arguments to the callback.\n\n</p>\n<p>调度每隔 <code>delay</code> 毫秒执行一次的 <code>callback</code>。返回一个可能被 <code>clearInterval()</code> 用到的 <code>intervalId</code>。可选地，您还能给回调传入参数。\n\n</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "callback"
                },
                {
                  "name": "delay"
                },
                {
                  "name": "arg",
                  "optional": true
                },
                {
                  "name": "...",
                  "optional": true
                }
              ]
            }
          ]
        },
        {
          "textRaw": "clearInterval(intervalId)",
          "type": "method",
          "name": "clearInterval",
          "desc": "<p>Stops a interval from triggering.\n\n</p>\n<p>停止一个 interval 的触发。\n\n</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "intervalId"
                }
              ]
            }
          ]
        },
        {
          "textRaw": "unref()",
          "type": "method",
          "name": "unref",
          "desc": "<p>The opaque value returned by <code>setTimeout</code> and <code>setInterval</code> also has the method\n<code>timer.unref()</code> which will allow you to create a timer that is active but if\nit is the only item left in the event loop won&apos;t keep the program running.\nIf the timer is already <code>unref</code>d calling <code>unref</code> again will have no effect.\n\n</p>\n<p><code>setTimeout</code> 和 <code>setInterval</code> 所返回的值同时具有 <code>timer.unref()</code> 方法，允许您创建一个活动的、但当它是事件循环中仅剩的项目时不会保持程序运行的定时器。如果定时器已被 <code>unref</code>，再次调用 <code>unref</code> 不会产生其它影响。\n\n</p>\n<p>In the case of <code>setTimeout</code> when you <code>unref</code> you create a separate timer that\nwill wakeup the event loop, creating too many of these may adversely effect\nevent loop performance -- use wisely.\n\n</p>\n<p>在 <code>setTimeout</code> 的情景中当您 <code>unref</code> 您会创建另一个定时器，并唤醒事件循环。创建太多这种定时器可能会影响事件循环的性能，慎用。\n\n</p>\n",
          "signatures": [
            {
              "params": []
            }
          ]
        },
        {
          "textRaw": "ref()",
          "type": "method",
          "name": "ref",
          "desc": "<p>If you had previously <code>unref()</code>d a timer you can call <code>ref()</code> to explicitly\nrequest the timer hold the program open. If the timer is already <code>ref</code>d calling\n<code>ref</code> again will have no effect.\n\n</p>\n<p>如果您之前 <code>unref()</code> 了一个定时器，您可以调用 <code>ref()</code> 来明确要求定时器让程序保持运行。如果定时器已被 <code>ref</code> 那么再次调用 <code>ref</code> 不会产生其它影响。\n\n</p>\n",
          "signatures": [
            {
              "params": []
            }
          ]
        },
        {
          "textRaw": "setImmediate(callback, [arg], [...])",
          "type": "method",
          "name": "setImmediate",
          "desc": "<p>To schedule the &quot;immediate&quot; execution of <code>callback</code> after I/O events\ncallbacks and before <code>setTimeout</code> and <code>setInterval</code> . Returns an\n<code>immediateId</code> for possible use with <code>clearImmediate()</code>. Optionally you\ncan also pass arguments to the callback.\n\n</p>\n<p>调度在所有 I/O 事件回调之后、<code>setTimeout</code> 和 <code>setInterval</code> 之前“立即”执行 <code>callback</code>。返回一个可能被 <code>clearImmediate()</code> 用到的 <code>immediateId</code>。可选地，您还能给回调传入参数。\n\n</p>\n<p>Callbacks for immediates are queued in the order in which they were created.\nThe entire callback queue is processed every event loop iteration. If you queue\nan immediate from a inside an executing callback that immediate won&apos;t fire\nuntil the next event loop iteration.\n\n</p>\n<p>immediate 的回调以它们创建的顺序被加入队列。整个回调队列会在每个事件循环迭代中被处理。如果您在一个正被执行的回调中添加 immediate，那么这个 immediate 在下一个事件循环迭代之前都不会被触发。\n\n</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "callback"
                },
                {
                  "name": "arg",
                  "optional": true
                },
                {
                  "name": "...",
                  "optional": true
                }
              ]
            }
          ]
        },
        {
          "textRaw": "clearImmediate(immediateId)",
          "type": "method",
          "name": "clearImmediate",
          "desc": "<p>Stops an immediate from triggering.\n\n\n</p>\n<p>停止一个 immediate 的触发。</p>\n",
          "signatures": [
            {
              "params": [
                {
                  "name": "immediateId"
                }
              ]
            }
          ]
        }
      ],
      "type": "module",
      "displayName": "定时器"
    }
  ]
}