heyujie
2021-06-07 8f8155aa4c83f7c2577ac123add550766b6a7ce3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
"use strict";
 
var value = require("./valid-value")
  , mixin = require("./mixin");
 
var getPrototypeOf = Object.getPrototypeOf;
 
module.exports = function (target, source) {
    target = Object(value(target));
    source = Object(value(source));
    if (target === source) return target;
 
    var sources = [];
    while (source && !isPrototypeOf.call(source, target)) {
        sources.unshift(source);
        source = getPrototypeOf(source);
    }
 
    var error;
    sources.forEach(function (sourceProto) {
        try { mixin(target, sourceProto); } catch (mixinError) { error = mixinError; }
    });
    if (error) throw error;
    return target;
};