MCPcopy Create free account
hub / github.com/angular/angular / applyUpdate

Method applyUpdate

packages/common/http/src/headers.ts:208–246  ·  view source on GitHub ↗
(update: Update)

Source from the content-addressed store, hash-verified

206 }
207
208 private applyUpdate(update: Update): void {
209 const key = update.name.toLowerCase();
210 switch (update.op) {
211 case 'a':
212 case 's':
213 let value = update.value!;
214 if (typeof value === 'string') {
215 value = [value];
216 }
217 if (value.length === 0) {
218 return;
219 }
220 this.maybeSetNormalizedName(update.name, key);
221 const base = update.op === 'a' ? (this.headers.get(key) || []).slice() : [];
222 base.push(...value);
223 this.headers.set(key, base);
224 break;
225 case 'd':
226 const toDelete = update.value;
227 if (toDelete === undefined) {
228 this.headers.delete(key);
229 this.normalizedNames.delete(key);
230 } else {
231 const valuesToDelete = Array.isArray(toDelete) ? toDelete : [toDelete];
232 let existing = this.headers.get(key);
233 if (!existing) {
234 return;
235 }
236 existing = existing.filter((value) => valuesToDelete.indexOf(value) === -1);
237 if (existing.length === 0) {
238 this.headers.delete(key);
239 this.normalizedNames.delete(key);
240 } else {
241 this.headers.set(key, existing);
242 }
243 }
244 break;
245 }
246 }
247
248 private addHeaderEntry(name: string, value: string) {
249 const key = name.toLowerCase();

Callers 1

initMethod · 0.95

Calls 8

isArrayMethod · 0.80
indexOfMethod · 0.80
getMethod · 0.65
setMethod · 0.65
pushMethod · 0.45
deleteMethod · 0.45
filterMethod · 0.45

Tested by

no test coverage detected