<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>atsuhiro-me</author_name>
  <author_url>https://blog.hatena.ne.jp/atsuhiro-me/</author_url>
  <blog_title>みーのぺーじ</blog_title>
  <blog_url>https://pc.atsuhiro-me.net/</blog_url>
  <categories>
    <anon>JavaScript</anon>
  </categories>
  <description>Node.js はシングルスレッドで実行されるので，排他処理は原則不要ですが，非同期関数が含まれるとその限りではないと思ったので，排他処理ができるライブラリを探したのですが，自分で作った方が簡単だと思ったので，実験してみました． 以下のソースコードは全て TypeScript の Vitest 用単体テストです． 排他処理が必要になる例として，変数の値を取得して，非同期的に更新する操作を実装します． lock.spec.ts import { assert, test } from &quot;vitest&quot;; test(&quot;once&quot;, async () =&gt; { let v = 0; const ad…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fpc.atsuhiro-me.net%2Fentry%2F2023%2F08%2F25%2F211454&quot; title=&quot;JavaScript で排他処理 - みーのぺーじ&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>2023-08-25 21:14:54</published>
  <title>JavaScript で排他処理</title>
  <type>rich</type>
  <url>https://pc.atsuhiro-me.net/entry/2023/08/25/211454</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
