Skip to content

Commit

Permalink
perf(shared): return early if obj is falsy, avoiding an additional tr…
Browse files Browse the repository at this point in the history
…aversal (#2843)

perf(shared): return early if obj is falsy, avoiding an additional
traversal
  • Loading branch information
Jonas-C authored Sep 7, 2024
1 parent df982ad commit 67909ed
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/shared/src/merge-props.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { isObject } from './assert'

export function mergeProps<T extends Record<string, unknown>>(...sources: T[]): T {
const objects = sources.filter(Boolean)
return objects.reduce((prev: any, obj) => {
return sources.reduce((prev: any, obj) => {
if (!obj) return prev
Object.keys(obj).forEach((key) => {
const prevValue = prev[key]
const value = obj[key]
Expand Down

0 comments on commit 67909ed

Please sign in to comment.