<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>katsube</author_name>
  <author_url>https://blog.hatena.ne.jp/katsube/</author_url>
  <blog_title>ねこの足跡R</blog_title>
  <blog_url>https://blog.katsubemakito.net/</blog_url>
  <categories>
    <anon>Node.js</anon>
    <anon>JavaScript</anon>
    <anon>Promise</anon>
    <anon>sleep</anon>
    <anon>setTimeout</anon>
  </categories>
  <description>小ネタです。 多くのスクリプト言語やシェルなどで実装されているsleep機能がNode.jsには存在しないため、使いたくなったら自分で用意する必要があります。いくつか方法がありますがお手軽なのはPromiseとsetTimeoutを利用した物です。 あっちこっちで使う場合は以下のように適当なモジュールを用意します。 /** * sleep.js */ const sleep = (time) =&gt; { return new Promise((resolve, reject) =&gt; { setTimeout(() =&gt; { resolve() }, time) }) } module.expor…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fblog.katsubemakito.net%2Fnodejs%2Fsleep&quot; title=&quot; [Node.js] 指定した時間sleepする - Promise版 - ねこの足跡R&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url></image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2021-04-02 03:05:59</published>
  <title> [Node.js] 指定した時間sleepする - Promise版</title>
  <type>rich</type>
  <url>https://blog.katsubemakito.net/nodejs/sleep</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
