Gathering detailed insights and metrics for websocket-promise-lite
Gathering detailed insights and metrics for websocket-promise-lite
Gathering detailed insights and metrics for websocket-promise-lite
Gathering detailed insights and metrics for websocket-promise-lite
npm install websocket-promise-lite
Typescript
Module System
Node Version
NPM Version
71
Supply Chain
94.1
Quality
75.7
Maintenance
100
Vulnerability
100
License
TypeScript (94.52%)
JavaScript (5.48%)
Love this project? Help keep it running — sponsor us today! 🚀
Total Downloads
2,297
Last Day
2
Last Week
7
Last Month
38
Last Year
326
10 Stars
22 Commits
2 Forks
1 Watching
2 Branches
1 Contributors
Latest Version
2.1.1
Package Id
websocket-promise-lite@2.1.1
Unpacked Size
15.75 kB
Size
5.11 kB
File Count
8
NPM Version
8.11.0
Node Version
16.16.0
Publised On
16 Jun 2023
Cumulative downloads
Total Downloads
Last day
0%
2
Compared to previous day
Last week
-65%
7
Compared to previous week
Last month
15.2%
38
Compared to previous month
Last year
-50.6%
326
Compared to previous year
4
This is an Axios for WebSockets :-)
To easily work with sockets in async / await style.
npm i websocket-promise-lite
1import WebsocketPromiseLiteClient from 'websocket-promise-lite' 2 3const demoFunc = async () => { 4 const WS = new WebsocketPromiseLiteClient({ 5 url: 'wss://ws.postman-echo.com/raw' 6 }) 7 await WS.connectionEstablished() 8 const answer = await WS.send({ 9 myMessage: 'hello websocket!' 10 }) 11 console.log(answer) 12 13 // next actions ... 14 15 WS.close() 16} 17 18demoFunc()
Back-end (websocket server) have to answer with the same "messageId" parameter!
1const WS = new WebsocketPromiseLiteClient(config)
where config is an object with a possible properties:
url: WebSocket URL. Must start with "ws://" or "wss://". The only required param
maxNumberOfReconnects: maximum number of reconnections, after which there will be no more reconnections. If -1 then will be no reconnections. Default Infinity
.
pauseBetweenReconnects: pause between reconnections (in ms). If 0 then reconnections will become after randomized pause. Pauses are stored in array [xyz, 3xyz, 5xyz, 8xyz, 12xyz, 17xyz ... 17xyz], where xyz is random number. This is so that all clients reconnects at different time for stable back-end. Default 0
.
connectTimeout: time in ms after which connection is considered unsuccessful (and then reconnects again). Default 5000
.
serializer: serializer function. For example, CBOR.encode
. Default JSON.stringify
.
deserializer: deserializer function. For example, CBOR.decode
. Default JSON.parse
.
binaryType: type of data to be transmitted. In most cases it's "arraybuffer". But You may specify it as blob
. Default arraybuffer
.
urlAdditionalGenerator: use it when second url part have to be generated by some algorythm. Pass a function.
onConnectionOpen: function (async or not) which is called when a connection is opened successfully for a 1st time
onConnectionClose: function (async or not) which is called when a connection is closed.
onConnectionReOpen: function (async or not) which is called when a connection is before reopen.
onBeforeReOpen: function (async or not) which is called when a connection is before reopen.
onNotPromisedData: function (async or not) which is called when server sends not promised data (simple WS data from back-end)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
7 existing vulnerabilities detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/22 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More