# mutexor

> Create mutex in javascript

Latest version **0.1.0** (published 2016-09-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install mutexor
pnpm add mutexor
yarn add mutexor
bun add mutexor
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.0 |
| Published | 2016-09-14 |
| First published | 2016-09-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Lionel Seguin |
| Maintainers | lseguin |
| Keywords | mutex, lock, async, unlock |

## Links

- npm: https://www.npmjs.com/package/mutexor
- npm.io page: https://npm.io/package/mutexor

## Dependencies (1)

- [bluebird](https://npm.io/package/bluebird.md) ^3.4.6

## Alternatives

- [@commercetools/sync-actions](https://npm.io/package/@commercetools/sync-actions.md) — 25.1K weekly downloads
- [cwait](https://npm.io/package/cwait.md) — 21.4K weekly downloads
- [@ledgerhq/hw-app-cosmos](https://npm.io/package/@ledgerhq/hw-app-cosmos.md) — 4.2K weekly downloads
- [@financial-times/o-loading](https://npm.io/package/@financial-times/o-loading.md) — 2.8K weekly downloads
- [fa](https://npm.io/package/fa.md) — 185 weekly downloads

## Recent versions

- 0.1.0 (latest) — 2016-09-14

## README

# Mutexor

## install

```shell
npm install --save mutexor
```

## how to use it

```javascript
const Mutex = require('mutexor');
const fs = require('fs');

let mutex = Mutex();

for (let i = 0; i < 10000; i++) {
    mutex.lock(function (unlock) {
        // called when mutex is locked
        fs.writeFile('myFile', `myData${i}`, function (err) {
            console.log(i);
            unlock(); // unlock mutex
        });
    })
    .then(function () {
        // called when mutex is unlocked
    });
}
```

OR

```javascript
const Mutex = require('mutexor');
const fs = require('fs');

let mutex = Mutex();

for (let i = 0; i < 10000; i++) {
    mutex
        .lock()
        .then(function (unlock) {
            // called when mutex is locked
            fs.writeFile('myFile', `myData${i}`, function (err) {
                console.log(i);
                unlock(); // unlock mutex
            });
        });
}
```

---
_Source: https://npm.io/package/mutexor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
