Use Object.assign
This commit is contained in:
@@ -2,37 +2,6 @@
|
||||
* @module ol/obj
|
||||
*/
|
||||
|
||||
/**
|
||||
* Polyfill for Object.assign(). Assigns enumerable and own properties from
|
||||
* one or more source objects to a target object.
|
||||
* See https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign.
|
||||
*
|
||||
* @param {!Object} target The target object.
|
||||
* @param {...Object} var_sources The source object(s).
|
||||
* @return {!Object} The modified target object.
|
||||
*/
|
||||
export const assign =
|
||||
typeof Object.assign === 'function'
|
||||
? Object.assign
|
||||
: function (target, var_sources) {
|
||||
if (target === undefined || target === null) {
|
||||
throw new TypeError('Cannot convert undefined or null to object');
|
||||
}
|
||||
|
||||
const output = Object(target);
|
||||
for (let i = 1, ii = arguments.length; i < ii; ++i) {
|
||||
const source = arguments[i];
|
||||
if (source !== undefined && source !== null) {
|
||||
for (const key in source) {
|
||||
if (source.hasOwnProperty(key)) {
|
||||
output[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
/**
|
||||
* Removes all properties from an object.
|
||||
* @param {Object} object The object to clear.
|
||||
|
||||
Reference in New Issue
Block a user