Projekt

Obecné

Profil

Stáhnout (576 Bajtů) Statistiky
| Větev: | Revize:
1 3a515b92 cagy
'use strict';
2
3
var isObject = require('is-extendable');
4
5
module.exports = function extend(o/*, objects*/) {
6
  if (!isObject(o)) { o = {}; }
7
8
  var len = arguments.length;
9
  for (var i = 1; i < len; i++) {
10
    var obj = arguments[i];
11
12
    if (isObject(obj)) {
13
      assign(o, obj);
14
    }
15
  }
16
  return o;
17
};
18
19
function assign(a, b) {
20
  for (var key in b) {
21
    if (hasOwn(b, key)) {
22
      a[key] = b[key];
23
    }
24
  }
25
}
26
27
/**
28
 * Returns true if the given `key` is an own property of `obj`.
29
 */
30
31
function hasOwn(obj, key) {
32
  return Object.prototype.hasOwnProperty.call(obj, key);
33
}