node-synchronized

import { Synchronized } from 'node-synchronized';

Usage no npm install needed!

<script type="module">
  import nodeSynchronized from 'https://cdn.skypack.dev/node-synchronized';
</script>

README

node-synchronized

import { Synchronized }  from 'node-synchronized';

const block = new Synchronized();

block.synchronized((isFirst) => {
  // When acquiring the first lock, isFirst == true.
});

block.synchronized((first) => {
  // When acquiring the first lock, isFirst == true.
});

example

example.ts

output:

A: isFirst=true
B: isFirst=false

C: isFirst=true
D: isFirst=false

License

Apache-2.0 License