( ...objects: Record<string, Value>[] )
| 4 | * @returns The merged object |
| 5 | */ |
| 6 | export function mergeStrict<Value>( |
| 7 | ...objects: Record<string, Value>[] |
| 8 | ): Record<string, Value> { |
| 9 | const returnValue: Record<string, Value> = {}; |
| 10 | |
| 11 | objects.forEach((object: object) => { |
| 12 | for (const [key, value] of Object.entries(object)) { |
| 13 | if (returnValue.hasOwnProperty(key)) { |
| 14 | throw new Error(`Found duplicate property ${key}`); |
| 15 | } |
| 16 | |
| 17 | returnValue[key] = value; |
| 18 | } |
| 19 | }); |
| 20 | |
| 21 | return returnValue; |
| 22 | } |
no outgoing calls
no test coverage detected