Async semaphore for shared or exclusive execution.
npm install semaAsync semaphore for shared or exclusive execution of JavaScript functions.

```
npm install sema
`js
var sema = require('sema')
var s = sema()
// exclusive mode
s.acquire(function () {
...
doReadWrite(function (err) {
...
s.release()
})
})
// shared mode
s.acquire(sema.SHARED, function () {
...
doReadOnly(function (err) {
...
s.release()
})
})
`
to acquire a shared mode.Callback to asynchronous function
fn when semaphore available.
Invoked immediately if semaphore is free or shared only. Otherwise pushed to the wait queue.Returns a promise if no
fn provided. However this yields a slight delay when acquiring, due to the nature of promise. If such timing is important then callback function should be used.$3
Release semaphore.Invokes function from the wait queue if queue is not empty.
$3
Returns mode constant, the current state of semaphore.
$3
*
sema.FREE = null
* sema.SHARED = 1
* sema.EXCLUSIVE = 2
* sema.WAIT = 3`