braid-text 0.2.5 → 0.2.6

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/index.js +5 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -386,9 +386,12 @@ braid_text.put = async (key, options) => {
386
386
 
387
387
  let og_v = version?.[0] || `${(is_valid_actor(peer) && peer) || Math.random().toString(36).slice(2, 7)}-${change_count - 1}`
388
388
 
389
- // reduce the version sequence by the number of char-edits
390
389
  let v = decode_version(og_v)
391
390
 
391
+ resource.length_cache.put(`${v[0]}-${v[1]}`, patches.reduce((a, b) =>
392
+ a + (b.content_codepoints.length ? b.content_codepoints.length : -(b.range[1] - b.range[0])),
393
+ max_pos))
394
+
392
395
  // validate version: make sure we haven't seen it already
393
396
  if (v[1] <= (resource.actor_seqs[v[0]] ?? -1)) {
394
397
 
@@ -453,10 +456,7 @@ braid_text.put = async (key, options) => {
453
456
  }
454
457
  resource.actor_seqs[v[0]] = v[1]
455
458
 
456
- resource.length_cache.put(`${v[0]}-${v[1]}`, patches.reduce((a, b) =>
457
- a + (b.content_codepoints.length ? b.content_codepoints.length : -(b.range[1] - b.range[0])),
458
- max_pos))
459
-
459
+ // reduce the version sequence by the number of char-edits
460
460
  v = `${v[0]}-${v[1] + 1 - change_count}`
461
461
 
462
462
  let ps = og_parents
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-text",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Library for collaborative text over http using braid.",
5
5
  "author": "Braid Working Group",
6
6
  "repository": "braid-org/braidjs",