@nxtedition/lib 21.8.3 → 21.8.4

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/http.js +11 -24
  2. package/package.json +1 -1
package/http.js CHANGED
@@ -363,7 +363,6 @@ export async function request(ctx, next) {
363
363
  }
364
364
 
365
365
  export class ServerResponse extends http.ServerResponse {
366
- #now = 0
367
366
  #created = 0
368
367
  #timing = {
369
368
  connect: -1,
@@ -380,15 +379,13 @@ export class ServerResponse extends http.ServerResponse {
380
379
  super(req)
381
380
 
382
381
  this.#created = performance.now()
383
- this.#now = this.#created
384
382
  this.#timing.connect = 0
385
383
  }
386
384
 
387
385
  flushHeaders() {
388
386
  if (!this.destroyed) {
389
387
  if (this.#timing.headers === -1) {
390
- this.#timing.headers = performance.now() - this.#now
391
- this.#now += this.#timing.headers
388
+ this.#timing.headers = performance.now() - this.#created
392
389
  }
393
390
  }
394
391
  return super.flushHeaders()
@@ -397,8 +394,7 @@ export class ServerResponse extends http.ServerResponse {
397
394
  write(chunk, encoding, callback) {
398
395
  if (!this.destroyed) {
399
396
  if (this.#timing.data === -1) {
400
- this.#timing.data = performance.now() - this.#now
401
- this.#now += this.#timing.data
397
+ this.#timing.data = performance.now() - this.#created
402
398
  }
403
399
 
404
400
  if (this.#timing.headers === -1) {
@@ -411,17 +407,15 @@ export class ServerResponse extends http.ServerResponse {
411
407
 
412
408
  end(chunk, encoding, callback) {
413
409
  if (!this.destroyed) {
410
+ this.#timing.end = performance.now() - this.#created
411
+
414
412
  if (this.#timing.data === -1) {
415
- this.#timing.data = performance.now() - this.#now
416
- this.#now += this.#timing.data
413
+ this.#timing.data = this.#timing.end
417
414
  }
418
415
 
419
416
  if (this.#timing.headers === -1) {
420
417
  this.#timing.headers = this.#timing.data
421
418
  }
422
-
423
- this.#timing.end = performance.now() - this.#now
424
- this.#now += this.#timing.end
425
419
  }
426
420
 
427
421
  return super.end(chunk, encoding, callback)
@@ -430,8 +424,7 @@ export class ServerResponse extends http.ServerResponse {
430
424
  destroy(err) {
431
425
  if (!this.destroyed) {
432
426
  if (this.#timing.end === -1) {
433
- this.#timing.end = performance.now() - this.#now
434
- this.#now += this.#timing.end
427
+ this.#timing.end = performance.now() - this.#created
435
428
  }
436
429
  }
437
430
 
@@ -440,7 +433,6 @@ export class ServerResponse extends http.ServerResponse {
440
433
  }
441
434
 
442
435
  export class Http2ServerResponse extends http2.Http2ServerResponse {
443
- #now = 0
444
436
  #created = 0
445
437
  #timing = {
446
438
  connect: -1,
@@ -457,15 +449,13 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
457
449
  super(req)
458
450
 
459
451
  this.#created = performance.now()
460
- this.#now = this.#created
461
452
  this.#timing.connect = 0
462
453
  }
463
454
 
464
455
  flushHeaders() {
465
456
  if (!this.destroyed) {
466
457
  if (this.#timing.headers === -1) {
467
- this.#timing.headers = performance.now() - this.#now
468
- this.#now += this.#timing.headers
458
+ this.#timing.headers = performance.now() - this.#created
469
459
  }
470
460
  }
471
461
  return super.flushHeaders()
@@ -474,8 +464,7 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
474
464
  write(chunk, encoding, callback) {
475
465
  if (!this.destroyed) {
476
466
  if (this.#timing.data === -1) {
477
- this.#timing.data = performance.now() - this.#now
478
- this.#now += this.#timing.data
467
+ this.#timing.data = performance.now() - this.#created
479
468
  }
480
469
 
481
470
  if (this.#timing.headers === -1) {
@@ -488,17 +477,15 @@ export class Http2ServerResponse extends http2.Http2ServerResponse {
488
477
 
489
478
  end(chunk, encoding, callback) {
490
479
  if (!this.destroyed) {
480
+ this.#timing.end = performance.now() - this.#created
481
+
491
482
  if (this.#timing.data === -1) {
492
- this.#timing.data = performance.now() - this.#now
493
- this.#now += this.#timing.data
483
+ this.#timing.data = this.#timing.end
494
484
  }
495
485
 
496
486
  if (this.#timing.headers === -1) {
497
487
  this.#timing.headers = this.#timing.data
498
488
  }
499
-
500
- this.#timing.end = performance.now() - this.#now
501
- this.#now += this.#timing.end
502
489
  }
503
490
 
504
491
  return super.end(chunk, encoding, callback)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/lib",
3
- "version": "21.8.3",
3
+ "version": "21.8.4",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "type": "module",