<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Javon Ayers</title>
    <description>The latest articles on DEV Community by Javon Ayers (@javonayers999).</description>
    <link>https://dev.to/javonayers999</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4076168%2F44a122e7-7917-4be7-a20c-89708d3cd66c.png</url>
      <title>DEV Community: Javon Ayers</title>
      <link>https://dev.to/javonayers999</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/javonayers999"/>
    <language>en</language>
    <item>
      <title>Introducing mutex-forge: Mutex &amp; Semaphore for async JavaScript</title>
      <dc:creator>Javon Ayers</dc:creator>
      <pubDate>Thu, 13 Aug 2026 11:38:37 +0000</pubDate>
      <link>https://dev.to/javonayers999/introducing-mutex-forge-mutex-semaphore-for-async-javascript-1bef</link>
      <guid>https://dev.to/javonayers999/introducing-mutex-forge-mutex-semaphore-for-async-javascript-1bef</guid>
      <description>&lt;p&gt;JavaScript is single-threaded, but async code still races. Two functions can &lt;code&gt;await&lt;/code&gt; at the same time and both update shared state — caches, balances, worker message flows. Those bugs are hard to reproduce.&lt;/p&gt;

&lt;p&gt;I built &lt;strong&gt;mutex-forge&lt;/strong&gt; to bring classic mutex and semaphore patterns to async JavaScript and TypeScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mutex&lt;/strong&gt; — exclusive access to a critical section
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Semaphore&lt;/strong&gt; — limit how many jobs run at once (pools, rate limits)
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;runExclusive&lt;/strong&gt; — acquire, run, and release automatically
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;withTimeout&lt;/strong&gt; — fail if the lock takes too long
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;tryAcquire&lt;/strong&gt; — non-blocking lock attempts
&lt;/li&gt;
&lt;li&gt;TypeScript types included
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example: prevent overlapping updates
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
javascript
const { Mutex } = require('mutex-forge');

const mutex = new Mutex();
let balance = 0;

async function credit(amount) {
  await mutex.runExclusive(async () =&amp;gt; {
    const current = balance;
    await someAsyncWork();
    balance = current + amount;
  });
}

await Promise.all([credit(10), credit(20)]);
// balance === 30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>npm</category>
      <category>node</category>
    </item>
  </channel>
</rss>
