MCPcopy Create free account
hub / github.com/dipscope/TypeManager.TS / constructTypeOptionsMap

Method constructTypeOptionsMap

src/type-manager.ts:385–421  ·  view source on GitHub ↗

* Constructs type options map. * * @param {Map , TypeOptions >} typeOptionsMap Type options map. * * @returns {Map , TypeOptions >} Constructed type options map.

(typeOptionsMap: Map<TypeFn<any>, TypeOptions<any>>)

Source from the content-addressed store, hash-verified

383 * @returns {Map<TypeFn<any>, TypeOptions<any>>} Constructed type options map.
384 */
385 private constructTypeOptionsMap(typeOptionsMap: Map<TypeFn<any>, TypeOptions<any>>): Map<TypeFn<any>, TypeOptions<any>>
386 {
387 const initialTypeOptionsMap = new Map<TypeFn<any>, TypeOptions<any>>();
388
389 for (const [typeFn, typeOptions] of TypeManager.defaultTypeOptionsMap)
390 {
391 let mapTypeOptions = initialTypeOptionsMap.get(typeFn);
392
393 if (mapTypeOptions === undefined)
394 {
395 mapTypeOptions = {};
396 }
397
398 initialTypeOptionsMap.set(typeFn, Object.assign(mapTypeOptions, typeOptions));
399 }
400
401 for (const [typeFn, typeOptions] of typeOptionsMap)
402 {
403 let mapTypeOptions = initialTypeOptionsMap.get(typeFn);
404
405 if (mapTypeOptions === undefined)
406 {
407 mapTypeOptions = {};
408 }
409
410 initialTypeOptionsMap.set(typeFn, Object.assign(typeOptions, Object.assign(mapTypeOptions, typeOptions)));
411 }
412
413 typeOptionsMap.clear();
414
415 for (const [typeFn, typeOptions] of initialTypeOptionsMap)
416 {
417 typeOptionsMap.set(typeFn, typeOptions);
418 }
419
420 return typeOptionsMap;
421 }
422
423 /**
424 * Configures type metadata for provided type function in a static context.

Callers 3

typeOptionsMapMethod · 0.95
declareTypeMetadataMethod · 0.95

Calls 3

setMethod · 0.80
clearMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected