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

Method cloneTypeOptionsMap

src/type-manager.ts:831–902  ·  view source on GitHub ↗

* Creates a clone of type options map. * * @returns {Map , TypeOptions >} Type options map clone.

()

Source from the content-addressed store, hash-verified

829 * @returns {Map<TypeFn<any>, TypeOptions<any>>} Type options map clone.
830 */
831 private cloneTypeOptionsMap(): Map<TypeFn<any>, TypeOptions<any>>
832 {
833 const typeOptionsMap = this.typeOptionsMap;
834 const typeOptionsMapClone = new Map<TypeFn<any>, TypeOptions<any>>();
835
836 for (const [typeFn, typeOptions] of typeOptionsMap)
837 {
838 const typeOptionsClone = Object.assign({}, typeOptions);
839 const typeCustomValueMap = typeOptions.customValueMap;
840
841 if (typeCustomValueMap !== undefined)
842 {
843 const typeCustomValueMapClone = new Map<CustomKey<any>, CustomValue>();
844
845 for (const [customKey, customValue] of typeCustomValueMap)
846 {
847 typeCustomValueMapClone.set(customKey, customValue);
848 }
849
850 typeOptionsClone.customValueMap = typeCustomValueMapClone;
851 }
852
853 const propertyOptionsMap = typeOptions.propertyOptionsMap;
854
855 if (propertyOptionsMap !== undefined)
856 {
857 const propertyOptionsMapClone = new Map<PropertyName, PropertyOptions<any>>();
858
859 for (const [propertyName, propertyOptions] of propertyOptionsMap)
860 {
861 const propertyOptionsClone = Object.assign({}, propertyOptions);
862 const propertyCustomValueMap = propertyOptions.customValueMap;
863
864 if (propertyCustomValueMap !== undefined)
865 {
866 const propertyCustomValueMapClone = new Map<CustomKey<any>, CustomValue>();
867
868 for (const [customKey, customValue] of propertyCustomValueMap)
869 {
870 propertyCustomValueMapClone.set(customKey, customValue);
871 }
872
873 propertyOptionsClone.customValueMap = propertyCustomValueMapClone;
874 }
875
876 propertyOptionsMapClone.set(propertyName, propertyOptionsClone);
877 }
878
879 typeOptionsClone.propertyOptionsMap = propertyOptionsMapClone;
880 }
881
882 const injectOptionsMap = typeOptions.injectOptionsMap;
883
884 if (injectOptionsMap !== undefined)
885 {
886 const injectOptionsMapClone = new Map<InjectIndex, InjectOptions<any>>();
887
888 for (const [injectIndex, injectOptions] of injectOptionsMap)

Callers 1

cloneMethod · 0.95

Calls 1

setMethod · 0.80

Tested by

no test coverage detected