An Object.assign shim.
此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.greasyfork.org/scripts/2666/7344/Objectassign%20shim.js
// ==UserScript==
// @name Object.assign shim
// @description An Object.assign shim.
// @version 0.13.0
// @license MIT License;
// ==/UserScript==
// modified from https://github.com/es-shims/es6-shim
(function(){
'use strict';
var isObject = function (obj) {
return obj && typeof obj === 'object';
};
if(Object.assign) return;
Object.defineProperty(Object, 'assign', {
value: function(target, source){
var s, i, props;
if (!isObject(target)) { throw new TypeError('target must be an object'); }
for (s = 1; s < arguments.length; ++s) {
source = arguments[s];
if (!isObject(source)) { throw new TypeError('source ' + s + ' must be an object'); }
props = Object.keys(Object(source));
for (i = 0; i < props.length; ++i) {
target[props[i]] = source[props[i]];
}
}
return target;
},
enumerable: false
});
})();