itty-sockets 0.5.4-next.1 → 0.5.4-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
|
|
19
19
|
---
|
|
20
20
|
|
|
21
|
-
## Type-safe WebSocket routing in
|
|
21
|
+
## Type-safe WebSocket routing in 512 bytes
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
### Features ✨
|
|
24
24
|
1. **Quality of Life Improvements (over native WebSocket)**
|
|
25
25
|
- auto JSON handling
|
|
26
26
|
- top-level payload access (`text` instead of `e.data.text`)
|
|
@@ -35,9 +35,16 @@
|
|
|
35
35
|
- `.on<Chat>('chat', ({ text }) => console.log(text))`
|
|
36
36
|
- `.send<Chat>({ type: 'chat', text: 'hello' })`
|
|
37
37
|
1. **Works with any JSON-based WebSocket server**
|
|
38
|
-
1. **Tiny footprint** -
|
|
38
|
+
1. **Tiny footprint** - smaller than virtually any WebSocket boilerplate
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
### Optional use with `itty.ws` public server
|
|
41
|
+
- great for testing/prototyping
|
|
42
|
+
- `connect<UseItty>('my-channel')` - connect to a channel and go
|
|
43
|
+
- adds `uid`, `alias`, and `date` to all messages
|
|
44
|
+
- adds `join` and `leave` events to announce user changes
|
|
45
|
+
- allows private messaging (by uid)
|
|
46
|
+
|
|
47
|
+
### Basic Example
|
|
41
48
|
```ts
|
|
42
49
|
import { connect } from 'itty-sockets'
|
|
43
50
|
|