Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mutexlight

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mutexlight - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

2

package.json
{
"name": "mutexlight",
"version": "1.0.0",
"version": "1.0.1",
"description": "minimal mutex lirbary",

@@ -5,0 +5,0 @@ "main": "mutexlight.js",

<h1>wspromise</h1>
websock-lowfat-promise is a zero-dependencies low-fat-promisified ws-websocket
library.
mutexlight is a zero-dependencies minimal mutex library.

@@ -10,4 +9,2 @@ ## Requirements

It can be used with most existing websocket libraries.
## Basic usage

@@ -18,13 +15,10 @@

```js
const WebSocket = require("ws");
const wspromise = require("websocket-lowfat-promise");
const mutexlight = require("mutexlight");
const mutex = new mutexlight;
async function runme() {
const wsp = new wsppromise(new WebSocket("wsp://foo.com/bar"));
await wsp.open();
await wsp.send("Hello world! Send me a response please.");
var response = await wsp.recv();
console.log(response);
await wsp.close();
console.log("Socket has been closed");
const release = await mutex.acquire(); // Acquire mutex lock
// Do some stuff
release(); // Release mutex lock
}

@@ -40,21 +34,12 @@

Specified parameters:
- `websocket`<br />
Should be a websocket obtained from any of the existing websocket
libraries compatible with the event-system provided by `ws`.
Exposed API-list:
- `new wspromise(websocket)`<br />
Creates a reference to the promisified version of the passed websocket.
- `this.open()`<br />
Returns a promise that resolves once the connection has been established.
- `this.send(data, options)`<br />
Returns a promise that resolves once the data-frame has been sent.
- `this.recv()`<br />
Returns a promise that resolves once a data-frame has been received.
- `this.ping()`<br />
Returns a promise that resolves once a pong has been received from the
far end.
- `this.close()`<br />
Returns a promise that resolves once the connection has been closed.
- `new mutexlight()`<br />
Creates a new mutex.
- `this.acquire(tryonly)`<br />
Returns a promise that resolves once the mutex lock has been acquired.
The promise resolves to a release function which needs to be called as
soon as the mutex lock needs to be released (acquired locks that are not
explicitly released will stay stuck in locked state indefinately).
If `trylock` is true, the promise will resolve to zero immediately if the
mutex lock has already been acquired.

@@ -61,0 +46,0 @@ ## References

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc