You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
532 B

4 years ago
  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. };