MCPcopy Index your code
hub / github.com/angular/angular / constructor

Method constructor

packages/common/http/src/params.ts:171–192  ·  view source on GitHub ↗
(options: HttpParamsOptions = {} as HttpParamsOptions)

Source from the content-addressed store, hash-verified

169 private cloneFrom: HttpParams | null = null;
170
171 constructor(options: HttpParamsOptions = {} as HttpParamsOptions) {
172 this.encoder = options.encoder || new HttpUrlEncodingCodec();
173 if (options.fromString) {
174 if (options.fromObject) {
175 throw new RuntimeError(
176 RuntimeErrorCode.CANNOT_SPECIFY_BOTH_FROM_STRING_AND_FROM_OBJECT,
177 ngDevMode && 'Cannot specify both fromString and fromObject.',
178 );
179 }
180 this.map = paramParser(options.fromString, this.encoder);
181 } else if (!!options.fromObject) {
182 this.map = new Map<string, string[]>();
183 Object.keys(options.fromObject).forEach((key) => {
184 const value = (options.fromObject as any)[key];
185 // convert the values to strings
186 const values = Array.isArray(value) ? value.map(valueToString) : [valueToString(value)];
187 this.map!.set(key, values);
188 });
189 } else {
190 this.map = null;
191 }
192 }
193
194 /**
195 * Reports whether the body includes one or more values for a given parameter.

Callers

nothing calls this directly

Calls 7

paramParserFunction · 0.85
valueToStringFunction · 0.85
isArrayMethod · 0.80
mapMethod · 0.80
keysMethod · 0.65
setMethod · 0.65
forEachMethod · 0.45

Tested by

no test coverage detected