# fnlock

> Locking for function calls and queuing on lock

Latest version **0.0.4** (published 2013-07-03) · Copyleft license · 0 weekly downloads

## Install

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

## 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.0.4 |
| Published | 2013-07-03 |
| First published | 2013-07-02 |
| Weekly downloads | 0 |
| License | Copyleft |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.5 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | David Oliveira |
| Maintainers | doliveira |
| Keywords | function, lock, locks |

## Links

- npm: https://www.npmjs.com/package/fnlock
- Repository: https://github.com/davidfoliveira/node-fnlock/
- npm.io page: https://npm.io/package/fnlock

## Alternatives

- [@oh-my-pi/pi-natives](https://npm.io/package/@oh-my-pi/pi-natives.md) — 51.8K weekly downloads
- [@capgo/capacitor-light-sensor](https://npm.io/package/@capgo/capacitor-light-sensor.md) — 3.0K weekly downloads
- [@heyhuynhgiabuu/pi-diff](https://npm.io/package/@heyhuynhgiabuu/pi-diff.md) — 492 weekly downloads
- [@lotsa/verdant-lang-asm](https://npm.io/package/@lotsa/verdant-lang-asm.md) — 38 weekly downloads
- [new-era-syntax](https://npm.io/package/new-era-syntax.md) — 20 weekly downloads

## Recent versions

- 0.0.4 (latest) — 2013-07-03
- 0.0.3 — 2013-07-02
- 0.0.2 — 2013-07-02
- 0.0.1 — 2013-07-02

## README

# fnlock: Locking for function calls and queuing on lock

`fnlock` is a module that allows locking on asyncronous functions and queuing of function calls, to be called on release.

# Installing

	npm install fnlock

# Using

Simple lock with function call queuing:

	var fnlock = require('fnlock');
	function run(arg){
	   fnlock.lock(function(release){
              console.log("Enter "+arg);
              setTimeout(release,1000);
           });
	}
	run(1);
	run(2);
	run(3);

It's supposed that the script takes 3 seconds to run.


Setting lock state on a function

	var fnlock = require('fnlock');
	function run(arg) {
	   fnlock.lock('run',function(release){
	      console.log("Enter "+arg);
	      release();
	   });
	}

	fnlock.lock('run');
	run('YEY');
	setTimeout(function(){ fnlock.unlock('run'); },1000);

It's supposed that the script takes 1 second to run.

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