-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.js
37 lines (30 loc) · 924 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*!
* assign-symbols <https://github.com/jonschlinkert/assign-symbols>
*
* Copyright (c) 2015-present, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
const toString = Object.prototype.toString;
const isEnumerable = Object.prototype.propertyIsEnumerable;
const getSymbols = Object.getOwnPropertySymbols;
module.exports = (target, ...args) => {
if (!isObject(target)) {
throw new TypeError('expected the first argument to be an object');
}
if (args.length === 0 || typeof Symbol !== 'function' || typeof getSymbols !== 'function') {
return target;
}
for (let arg of args) {
let names = getSymbols(arg);
for (let key of names) {
if (isEnumerable.call(arg, key)) {
target[key] = arg[key];
}
}
}
return target;
};
function isObject(val) {
return typeof val === 'function' || toString.call(val) === '[object Object]' || Array.isArray(val);
}