braid-http 1.3.7 → 1.3.8

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.
Files changed (2) hide show
  1. package/README.md +19 -7
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Braid-HTTP
2
2
 
3
- This polyfill library implements the [Braid-HTTP v04 protocol](https://github.com/braid-org/braid-spec/blob/master/draft-toomim-httpbis-braid-http-04.txt) in Javascript. It gives browsers a `braid_fetch()` drop-in replacement for the `fetch()` API, and gives nodejs an `http` plugin, allowing them to speak Braid in a simple way.
3
+ This polyfill library implements the [Braid-HTTP v04 protocol](https://github.com/braid-org/braid-spec/blob/master/draft-toomim-httpbis-braid-http-04.txt), modified slightly to follow the HTTP Multiresponse concept discussed at [braid.org/meeting-89](https://braid.org/meeting-89). It provides browsers with a `braid_fetch()` drop-in replacement for the `fetch()` API, and offers nodejs an `http` plugin, enabling simple Braid communication.
4
4
 
5
5
  Developed in [braid.org](https://braid.org).
6
6
 
@@ -53,8 +53,14 @@ fetch('https://braid.org/chat', {subscribe: true}).then(
53
53
  // {
54
54
  // version: ["me"],
55
55
  // parents: ["mom", "dad"],
56
- // patches: [{unit: "json", range: ".foo", content: "3"}]
57
- // body: "3"
56
+ // patches: [{
57
+ //. unit: "json",
58
+ // range: ".foo",
59
+ // content: new Uint8Array([51]),
60
+ // content_text: "3" <-- getter
61
+ //. }],
62
+ // body: new Uint8Array([51]),
63
+ // body_text: "3" <-- getter
58
64
  // }
59
65
  //
60
66
  // Note that `update` will contain either patches *or* body
@@ -113,7 +119,7 @@ for await (var update of subscription_iterator) {
113
119
  // Or complete snapshots:
114
120
  else
115
121
  // Beware the server doesn't send these yet.
116
- chat = JSON.parse(update.body)
122
+ chat = JSON.parse(update.body_text)
117
123
 
118
124
  render_stuff()
119
125
  }
@@ -233,10 +239,16 @@ function connect () {
233
239
  // {
234
240
  // version: ["me"],
235
241
  // parents: ["mom", "dad"],
236
- // patches: [{unit: "json", range: ".foo", content: "3"}]
237
- // body: "3"
242
+ // patches: [{
243
+ //. unit: "json",
244
+ // range: ".foo",
245
+ // content: new Uint8Array([51]),
246
+ // content_text: "3" <-- getter
247
+ //. }],
248
+ // body: new Uint8Array([51]),
249
+ // body_text: "3" <-- getter
238
250
  // }
239
- // // Update will contain either patches *or* body, but not both
251
+ // Update will contain either patches *or* body, but not both
240
252
  console.log('We got a new update!', update)
241
253
  })
242
254
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"