itty-sockets 0.2.0 → 0.2.2
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 +4 -4
- package/package.json +5 -2
package/README.md
CHANGED
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
---
|
|
18
18
|
|
|
19
|
-
Tiny messaging client in under
|
|
19
|
+
Tiny realtime messaging client in under 450 bytes. No backend needed.
|
|
20
20
|
|
|
21
|
-
## Example (using ittysockets.io public channels)
|
|
21
|
+
## Example (using [ittysockets.io](https://ittysockets.io) public channels)
|
|
22
22
|
```ts
|
|
23
|
-
import { connect } from 'itty-sockets' // ~
|
|
23
|
+
import { connect } from 'itty-sockets' // ~422 bytes
|
|
24
24
|
|
|
25
25
|
// connect to a channel (optionally echo messages back to yourself)
|
|
26
26
|
const foo = connect('my-secret-room-name', { echo: true })
|
|
@@ -86,7 +86,7 @@ connect('foo').push('hello world!')
|
|
|
86
86
|
| **connect(id, options)** | Creates a new channel connection | `connect('foo')` |
|
|
87
87
|
| **.open()** | Opens/re-opens the connection (manually, usually not needed) | `channel.open()` |
|
|
88
88
|
| **.close()** | Closes the connection | `channel.close()` |
|
|
89
|
-
| **.send(message)** | Sends a message to the
|
|
89
|
+
| **.send(message)** | Sends a message to the channel | `channel.send({ type: 'chat', text: 'hello' })` |
|
|
90
90
|
| **.push(message)** | Sends a message and closes the connection | `channel.push({ type: 'goodbye' })` |
|
|
91
91
|
| **.on('message', listener)** | Adds a message listener (multiple allowed) | `channel.on('message', event => console.log(event))` |
|
|
92
92
|
| **.on('open', listener)** | Executes a listener on channel open (one allowed) | `channel.on('open', () => console.log('channel opened'))` |
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itty-sockets",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.2",
|
|
4
|
+
"description": "Tiny realtime messaging client in under 450 bytes. No backend needed.",
|
|
5
5
|
"main": "./sockets.js",
|
|
6
6
|
"module": "./sockets.mjs",
|
|
7
7
|
"types": "./sockets.d.ts",
|
|
@@ -19,6 +19,9 @@
|
|
|
19
19
|
"keywords": [
|
|
20
20
|
"websockets",
|
|
21
21
|
"realtime",
|
|
22
|
+
"public",
|
|
23
|
+
"messages",
|
|
24
|
+
"tiny",
|
|
22
25
|
"free",
|
|
23
26
|
"p2p"
|
|
24
27
|
],
|