braid-text 0.0.7 → 0.0.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.
- package/README.md +12 -8
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,7 +7,8 @@ This library provides a simple http route handler, along with client code, enabl
|
|
|
7
7
|
- Enables light clients
|
|
8
8
|
- As little as 50 lines of code!
|
|
9
9
|
- With zero history overhead on client
|
|
10
|
-
- Supports backpressure to run smoothly on constrained servers
|
|
10
|
+
- Supports [backpressure](https://braid.org/meeting-81/simpleton) to run smoothly on constrained servers
|
|
11
|
+
- Sever merges with Diamond-Types
|
|
11
12
|
- Supports [Diamond Types](https://github.com/josephg/diamond-types) merge-type
|
|
12
13
|
- Fast / Robust / Extensively fuzz-tested
|
|
13
14
|
- Developed in [braid.org](https://braid.org)
|
|
@@ -42,7 +43,7 @@ Import the request handler into your code, and use it to handle HTTP requests wh
|
|
|
42
43
|
```javascript
|
|
43
44
|
var braid_text = require("braid-text")
|
|
44
45
|
|
|
45
|
-
|
|
46
|
+
http_server.on("request", (req, res) => {
|
|
46
47
|
// Your server logic...
|
|
47
48
|
|
|
48
49
|
// Whenever desired, serve braid text for this request/response:
|
|
@@ -57,7 +58,7 @@ server.on("request", (req, res) => {
|
|
|
57
58
|
- This folder will be created if it doesn't exist.
|
|
58
59
|
- The files for a resource will all be prefixed with a url-encoding of `key` within this folder.
|
|
59
60
|
|
|
60
|
-
`braid_text.
|
|
61
|
+
`braid_text.serve(req, res, options)`
|
|
61
62
|
- `req`: The incoming HTTP request object.
|
|
62
63
|
- `res`: The HTTP response object to send the response.
|
|
63
64
|
- `options`: <small style="color:lightgrey">[optional]</small> An object containing additional options:
|
|
@@ -105,11 +106,14 @@ server.on("request", (req, res) => {
|
|
|
105
106
|
},
|
|
106
107
|
generate_local_diff_update: (prev_state) => {
|
|
107
108
|
|
|
108
|
-
// Compute diff between prev_state ^ and the current textarea string,
|
|
109
|
-
//
|
|
110
|
-
//
|
|
111
|
-
//
|
|
112
|
-
//
|
|
109
|
+
// Compute diff between prev_state ^ and the current textarea string, such as:
|
|
110
|
+
//
|
|
111
|
+
// var patches = [{
|
|
112
|
+
// range: [5:5],
|
|
113
|
+
// content: " World"
|
|
114
|
+
// }]
|
|
115
|
+
//
|
|
116
|
+
// ...to insert something after a prev_state of "Hello".
|
|
113
117
|
|
|
114
118
|
// Then return the new state (as a string) and the diff (as `patches`)
|
|
115
119
|
return {new_state, patches}
|
package/index.js
CHANGED
|
@@ -261,7 +261,7 @@ braid_text.get = async (key, options) => {
|
|
|
261
261
|
let local_version = OpLog_remote_to_local(resource.doc, x.parents)
|
|
262
262
|
if (local_version) {
|
|
263
263
|
x.patches = get_xf_patches(resource.doc, local_version)
|
|
264
|
-
options.subscribe(x)
|
|
264
|
+
if (x.patches.length) options.subscribe(x)
|
|
265
265
|
}
|
|
266
266
|
}
|
|
267
267
|
|