.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / extend-shallow / index.js
1 'use strict';
2
3 var isExtendable = require('is-extendable');
4 var assignSymbols = require('assign-symbols');
5
6 module.exports = Object.assign || function(obj/*, objects*/) {
7   if (obj === null || typeof obj === 'undefined') {
8     throw new TypeError('Cannot convert undefined or null to object');
9   }
10   if (!isObject(obj)) {
11     obj = {};
12   }
13   for (var i = 1; i < arguments.length; i++) {
14     var val = arguments[i];
15     if (isString(val)) {
16       val = toObject(val);
17     }
18     if (isObject(val)) {
19       assign(obj, val);
20       assignSymbols(obj, val);
21     }
22   }
23   return obj;
24 };
25
26 function assign(a, b) {
27   for (var key in b) {
28     if (hasOwn(b, key)) {
29       a[key] = b[key];
30     }
31   }
32 }
33
34 function isString(val) {
35   return (val && typeof val === 'string');
36 }
37
38 function toObject(str) {
39   var obj = {};
40   for (var i in str) {
41     obj[i] = str[i];
42   }
43   return obj;
44 }
45
46 function isObject(val) {
47   return (val && typeof val === 'object') || isExtendable(val);
48 }
49
50 /**
51  * Returns true if the given `key` is an own property of `obj`.
52  */
53
54 function hasOwn(obj, key) {
55   return Object.prototype.hasOwnProperty.call(obj, key);
56 }
57
58 function isEnum(obj, key) {
59   return Object.prototype.propertyIsEnumerable.call(obj, key);
60 }