braid-http 1.3.81 → 1.3.83

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.
@@ -557,16 +557,23 @@ var subscription_parser = (cb) => ({
557
557
  for (var k in update)
558
558
  if (update[k] === undefined) delete update[k]
559
559
 
560
+ var body_text_cache = null
560
561
  Object.defineProperty(update, 'body_text', {
561
562
  get: function () {
562
- if (this.body != null)
563
- return new TextDecoder('utf-8').decode(this.body.buffer)
563
+ if (body_text_cache !== null) return body_text_cache
564
+ return body_text_cache = this.body != null ?
565
+ new TextDecoder('utf-8').decode(this.body.buffer) : undefined
564
566
  }
565
567
  })
566
568
 
567
569
  for (let p of update.patches ?? []) {
570
+ let content_text_cache = null
568
571
  Object.defineProperty(p, 'content_text', {
569
- get: () => new TextDecoder('utf-8').decode(p.content)
572
+ get: () => {
573
+ if (content_text_cache !== null) return content_text_cache
574
+ return content_text_cache =
575
+ new TextDecoder('utf-8').decode(p.content)
576
+ }
570
577
  })
571
578
  }
572
579
 
@@ -246,6 +246,7 @@ function braidify (req, res, next) {
246
246
  // Define convenience variables
247
247
  req.version = version
248
248
  req.parents = parents
249
+ req.peer = peer
249
250
  req.subscribe = subscribe
250
251
 
251
252
  // Multiplexer stuff
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "braid-http",
3
- "version": "1.3.81",
3
+ "version": "1.3.83",
4
4
  "description": "An implementation of Braid-HTTP for Node.js and Browsers",
5
5
  "scripts": {
6
6
  "test": "node test/server.js"