( map: IdMap<MapValue> | undefined, valueMapper?: (mapValue: MapValue, id: Id) => ObjValue, excludeMapValue?: (mapValue: MapValue, id: Id) => boolean, excludeObjValue?: (objValue: ObjValue) => boolean, )
| 83 | }; |
| 84 | |
| 85 | export const mapToObj = <MapValue, ObjValue = MapValue>( |
| 86 | map: IdMap<MapValue> | undefined, |
| 87 | valueMapper?: (mapValue: MapValue, id: Id) => ObjValue, |
| 88 | excludeMapValue?: (mapValue: MapValue, id: Id) => boolean, |
| 89 | excludeObjValue?: (objValue: ObjValue) => boolean, |
| 90 | ): IdObj<ObjValue> => { |
| 91 | const obj: IdObj<ObjValue> = {}; |
| 92 | collForEach(map, (mapValue, id) => { |
| 93 | if (!excludeMapValue?.(mapValue, id)) { |
| 94 | const objValue = valueMapper |
| 95 | ? valueMapper(mapValue, id) |
| 96 | : (mapValue as any as ObjValue); |
| 97 | if (!excludeObjValue?.(objValue)) { |
| 98 | obj[id] = objValue; |
| 99 | } |
| 100 | } |
| 101 | }); |
| 102 | return obj; |
| 103 | }; |
| 104 | |
| 105 | export const mapToObj2 = <MapValue, ObjValue = MapValue>( |
| 106 | map: IdMap2<MapValue> | undefined, |
no test coverage detected
searching dependent graphs…