MCPcopy
hub / github.com/angular/angular / applyUpdate

Method applyUpdate

packages/common/http/src/headers.ts:208–245  ·  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) : undefined) || [];
222 base.push(...value);
223 this.headers.set(key, base);
224 break;
225 case 'd':
226 const toDelete = update.value as string | undefined;
227 if (!toDelete) {
228 this.headers.delete(key);
229 this.normalizedNames.delete(key);
230 } else {
231 let existing = this.headers.get(key);
232 if (!existing) {
233 return;
234 }
235 existing = existing.filter((value) => toDelete.indexOf(value) === -1);
236 if (existing.length === 0) {
237 this.headers.delete(key);
238 this.normalizedNames.delete(key);
239 } else {
240 this.headers.set(key, existing);
241 }
242 }
243 break;
244 }
245 }
246
247 private addHeaderEntry(name: string, value: string) {
248 const key = name.toLowerCase();

Callers 1

initMethod · 0.95

Calls 7

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

Tested by

no test coverage detected