Greasy Fork is available in English.

Object.assign shim

An Object.assign shim.

Tätä skriptiä ei tulisi asentaa suoraan. Se on kirjasto muita skriptejä varten sisällytettäväksi metadirektiivillä // @require https://update.greasyfork.org/scripts/2666/7344/Objectassign%20shim.js.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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
	});
})();