File tree 1 file changed +4
-4
lines changed
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change 3
3
// Merge two objects, including their prototypes
4
4
function mergePrototypes ( to , from ) {
5
5
const prototypes = [ ...getPrototypes ( to ) , ...getPrototypes ( from ) ] ;
6
- const newPrototype = prototypes . reduce ( reducePrototype , { } ) ;
7
- return Object . assign ( Object . setPrototypeOf ( to , newPrototype ) , to , from ) ;
6
+ const prototype = prototypes . reduce ( shallowMerge , { } ) ;
7
+ return Object . assign ( Object . setPrototypeOf ( to , prototype ) , from ) ;
8
8
}
9
9
10
10
function getPrototypes ( object , prototypes = [ ] ) {
@@ -16,8 +16,8 @@ function getPrototypes(object, prototypes = []) {
16
16
return prototypes ;
17
17
}
18
18
19
- function reducePrototype ( prototype , constructor ) {
20
- return Object . defineProperties ( prototype , Object . getOwnPropertyDescriptors ( constructor ) ) ;
19
+ function shallowMerge ( toObject , fromObject ) {
20
+ return Object . defineProperties ( toObject , Object . getOwnPropertyDescriptors ( fromObject ) ) ;
21
21
}
22
22
23
23
module . exports = mergePrototypes ;
You can’t perform that action at this time.
0 commit comments