@superhero/http-server 4.2.5 → 4.2.7

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/package.json +1 -1
  2. package/view.js +24 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@superhero/http-server",
3
- "version": "4.2.5",
3
+ "version": "4.2.7",
4
4
  "description": "HTTP(S) server component supporting both HTTP 1.1 and HTTP 2.0",
5
5
  "keywords": [
6
6
  "http server",
package/view.js CHANGED
@@ -53,7 +53,7 @@ export default class View
53
53
  body : { enumerable: true, get: () => body, set: (value) => body = deepmerge(body, value) },
54
54
  // The stream property is a transform stream in object mode that by default encodes objects
55
55
  // as stringified JSON data records according to HTML5 standard Server-Sent Events (SSE).
56
- stream : { enumerable: true, configurable: true, get: () => this.#lazyloadStream },
56
+ stream : { enumerable: false, configurable: true, get: () => this.#lazyloadStream },
57
57
  // The headers property is an object that represents the response headers.
58
58
  headers : { enumerable: true, value: headers },
59
59
  // The session property has a reference to this view object, not enumerable because
@@ -285,4 +285,27 @@ export default class View
285
285
  }
286
286
  }
287
287
  }
288
+
289
+ toJSON()
290
+ {
291
+ const
292
+ descriptors = Object.getOwnPropertyDescriptors(this),
293
+ output = {}
294
+
295
+ for(const property in descriptors)
296
+ {
297
+ if(descriptors[property].enumerable)
298
+ {
299
+ output[property] = this[property]
300
+ }
301
+ }
302
+
303
+ return Object(output)
304
+ }
305
+
306
+ // It's useful for debugging and logging to provide a more readable output.
307
+ [Symbol.for('nodejs.util.inspect.custom')]()
308
+ {
309
+ return this.toJSON()
310
+ }
288
311
  }