braid-text 0.2.11 → 0.2.13

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 (3) hide show
  1. package/index.js +1 -1
  2. package/package.json +2 -2
  3. package/test.html +16 -0
package/index.js CHANGED
@@ -380,7 +380,7 @@ braid_text.put = async (key, options) => {
380
380
  let v = decode_version(og_v)
381
381
 
382
382
  resource.length_cache.put(`${v[0]}-${v[1]}`, patches.reduce((a, b) =>
383
- a + (b.content_codepoints.length ? b.content_codepoints.length : -(b.range[1] - b.range[0])),
383
+ a + (b.content_codepoints?.length ?? 0) - (b.range[1] - b.range[0]),
384
384
  max_pos))
385
385
 
386
386
  // validate version: make sure we haven't seen it already
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "braid-text",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "Library for collaborative text over http using braid.",
5
5
  "author": "Braid Working Group",
6
- "repository": "braid-org/braidjs",
6
+ "repository": "braid-org/braid-text",
7
7
  "homepage": "https://braid.org",
8
8
  "dependencies": {
9
9
  "diamond-types-node": "^1.0.2",
package/test.html CHANGED
@@ -222,4 +222,20 @@ runTest(
222
222
  JSON.stringify({b: 6}, null, 4)
223
223
  )
224
224
 
225
+ runTest(
226
+ "test length updating",
227
+ async () => {
228
+ let key = 'test-' + Math.random().toString(36).slice(2)
229
+
230
+ await fetch(`/${key}`, { method: 'PUT', body: '' })
231
+ await fetch(`/${key}`, { method: 'PUT', body: '0123456789' })
232
+ await fetch(`/${key}`, { method: 'PUT', body: '0123456789' })
233
+ await fetch(`/${key}`, { method: 'PUT', body: '0123456789' })
234
+
235
+ let r = await fetch(`/${key}`, { method: 'HEAD' })
236
+ return '' + parseInt(r.headers.get('version').split('-')[1])
237
+ },
238
+ '19'
239
+ )
240
+
225
241
  </script>