-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
41 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import forOwn from './forOwn' | ||
|
||
/** | ||
* 分配来源对象的可枚举属性到目标对象上。 | ||
* 来源对象的应用规则是从左到右,随后的下一个对象的属性会覆盖上一个对象的属性。 | ||
* | ||
* @param target 目标对象 | ||
* @param sources 来源对象 | ||
* @returns 目标对象 | ||
*/ | ||
export default function assign<T extends Record<string, any>>(target: T, ...sources: any[]): T { | ||
sources.forEach(source => { | ||
forOwn(source, (value, key) => { | ||
target[key] = value | ||
}) | ||
}) | ||
return target | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters