@nxtedition/nxt-undici 7.2.10 → 7.2.11

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/lib/index.js +19 -1
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import undici from '@nxtedition/undici'
2
+ import { Scheduler } from '@nxtedition/scheduler'
2
3
  import { parseHeaders } from './utils.js'
3
4
  import { request as _request } from './request.js'
4
5
  import { SqliteCacheStore } from './sqlite-cache-store.js'
@@ -79,6 +80,22 @@ export function compose(...interceptors) {
79
80
  return dispatch
80
81
  }
81
82
 
83
+ const PRIORITY_TOS_MAP = {}
84
+ PRIORITY_TOS_MAP[Scheduler.HIGHEST] = 0xb8 // EF
85
+ PRIORITY_TOS_MAP['highest'] = 0xb8 // EF
86
+ PRIORITY_TOS_MAP[Scheduler.HIGHER] = 0x88 // AF41
87
+ PRIORITY_TOS_MAP['higher'] = 0x88 // AF41
88
+ PRIORITY_TOS_MAP[Scheduler.HIGH] = 0x68 // AF31
89
+ PRIORITY_TOS_MAP['high'] = 0x68 // AF31
90
+ PRIORITY_TOS_MAP[Scheduler.NORMAL] = 0x00 // BE
91
+ PRIORITY_TOS_MAP['normal'] = 0x00 // BE
92
+ PRIORITY_TOS_MAP[Scheduler.LOW] = 0x04 // LE
93
+ PRIORITY_TOS_MAP['low'] = 0x04 // LE
94
+ PRIORITY_TOS_MAP[Scheduler.LOWER] = 0x04 // LE
95
+ PRIORITY_TOS_MAP['lower'] = 0x04 // LE
96
+ PRIORITY_TOS_MAP[Scheduler.LOWEST] = 0x04 // LE
97
+ PRIORITY_TOS_MAP['lowest'] = 0x04 // LE
98
+
82
99
  function wrapDispatch(dispatcher) {
83
100
  let wrappedDispatcher = dispatcherCache.get(dispatcher)
84
101
  if (wrappedDispatcher == null) {
@@ -135,7 +152,8 @@ function wrapDispatch(dispatcher) {
135
152
  opts.timeout?.headers ?? opts.headersTimeout ?? opts.headerTimeout ?? opts.timeout,
136
153
  bodyTimeout: opts.timeout?.body ?? opts.bodyTimeout ?? opts.timeout,
137
154
  idempotent: opts.idempotent,
138
- typeOfService: opts.typeOfService ?? 0,
155
+ typeOfService:
156
+ opts.typeOfService ?? (opts.priority ? (PRIORITY_TOS_MAP[opts.priority] ?? 0) : 0),
139
157
  retry: opts.retry ?? 8,
140
158
  proxy: opts.proxy ?? false,
141
159
  cache: opts.cache ?? false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nxtedition/nxt-undici",
3
- "version": "7.2.10",
3
+ "version": "7.2.11",
4
4
  "license": "MIT",
5
5
  "author": "Robert Nagy <robert.nagy@boffins.se>",
6
6
  "main": "lib/index.js",