object.js 532 B

123456789101112131415161718192021222324
  1. 'use strict';
  2. module.exports = {
  3. isObject: function(obj) {
  4. var type = typeof obj;
  5. return type === 'function' || type === 'object' && !!obj;
  6. }
  7. , extend: function(obj) {
  8. if (!this.isObject(obj)) {
  9. return obj;
  10. }
  11. var source, prop;
  12. for (var i = 1, length = arguments.length; i < length; i++) {
  13. source = arguments[i];
  14. for (prop in source) {
  15. if (Object.prototype.hasOwnProperty.call(source, prop)) {
  16. obj[prop] = source[prop];
  17. }
  18. }
  19. }
  20. return obj;
  21. }
  22. };