Socket
Socket
Sign inDemoInstall

wspromisify

Package Overview
Dependencies
0
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.501 to 0.0.502

4

package.json

@@ -52,3 +52,3 @@ {

],
"license": "ISC",
"license": "MIT",
"main": "dist/ws.js",

@@ -68,3 +68,3 @@ "module": "dist/ws.esm.js",

},
"version": "0.0.501",
"version": "0.0.502",
"devDependencies": {

@@ -71,0 +71,0 @@ "@types/node": "^8.0.58",

# WebsocketPromisify
Makes websocket's API just like REST with Promise-like API, with native Promises.
Has yummies and very lightweight!
// If you detected some bug or so, please, fill an issue.
// Large data support, streams and different server-side implementations are coming.

@@ -13,2 +15,3 @@

- Automatically reconnects.
- You can use the WebSocket (or your ws-like implementation) further in other stuff (socket property).
- Any id and data keys to negotiate with your back-end.

@@ -23,3 +26,10 @@ - Lazy connect: connects only if something sent, then send all of them!

How it on Server Side ?
```
1. Serialized JSON is sent by this lib = {id: 'generated_id', data: your data}
2. Some Server processing...
3. Serialized JSON is sent back by the Server = {id: 'the same generated_id', data: feedback data}
```
Default constructor config is

@@ -55,2 +65,9 @@ ```javascript

Fields/Props:
```javascript
// read-only, returns WebSocket (or so) instance to use with other stuff.
socket
```
Methods:

@@ -61,3 +78,5 @@ ```javascript

send(message),
on(event_name, handler, predicate),
// .addEventListener with optional predicate.
on(event_name, handler, predicate = (WebSocketEvent) => true),
// Closes the connection and free up memory.
close()

@@ -64,0 +83,0 @@

@@ -142,2 +142,6 @@

public get socket() {
return this.ws
}
public on(event_name, handler, predicate) {

@@ -144,0 +148,0 @@ return add_event(this.ws, event_name, event => {

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc