MCPcopy Create free account
hub / github.com/denoland/std / getEncodingPriority

Function getEncodingPriority

http/_negotiation/encoding.ts:117–138  ·  view source on GitHub ↗
(
  encoding: string,
  accepted: Specificity[],
  index: number,
)

Source from the content-addressed store, hash-verified

115}
116
117function getEncodingPriority(
118 encoding: string,
119 accepted: Specificity[],
120 index: number,
121): Specificity {
122 let priority: Specificity = { o: -1, q: 0, s: 0, i: 0 };
123
124 for (const s of accepted) {
125 const spec = specify(encoding, s, index);
126
127 if (
128 spec &&
129 (priority.s! - spec.s! || priority.q - spec.q ||
130 priority.o! - spec.o!) <
131 0
132 ) {
133 priority = spec;
134 }
135 }
136
137 return priority;
138}
139
140/** Given an `Accept-Encoding` string, parse out the encoding returning a
141 * negotiated encoding based on the `provided` encodings otherwise just a

Callers 1

preferredEncodingsFunction · 0.85

Calls 1

specifyFunction · 0.70

Tested by

no test coverage detected