1 | /*
|
2 | * Copyright 2012-2013 the original author or authors
|
3 | * @license MIT, see LICENSE.txt for details
|
4 | *
|
5 | * @author Scott Andrews
|
6 | */
|
7 |
|
8 | (function (define) {
|
9 | ;
|
10 |
|
11 | // derived from dojo.mixin
|
12 | define(function (/* require */) {
|
13 |
|
14 | var empty = {};
|
15 |
|
16 | /**
|
17 | * Mix the properties from the source object into the destination object.
|
18 | * When the same property occurs in more then one object, the right most
|
19 | * value wins.
|
20 | *
|
21 | * @param {Object} dest the object to copy properties to
|
22 | * @param {Object} sources the objects to copy properties from. May be 1 to N arguments, but not an Array.
|
23 | * @return {Object} the destination object
|
24 | */
|
25 | function mixin(dest /*, sources... */) {
|
26 | var i, l, source, name;
|
27 |
|
28 | if (!dest) { dest = {}; }
|
29 | for (i = 1, l = arguments.length; i < l; i += 1) {
|
30 | source = arguments[i];
|
31 | for (name in source) {
|
32 | if (!(name in dest) || (dest[name] !== source[name] && (!(name in empty) || empty[name] !== source[name]))) {
|
33 | dest[name] = source[name];
|
34 | }
|
35 | }
|
36 | }
|
37 |
|
38 | return dest; // Object
|
39 | }
|
40 |
|
41 | return mixin;
|
42 |
|
43 | });
|
44 |
|
45 | }(
|
46 | typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
|
47 | // Boilerplate for AMD and Node
|
48 | ));
|