Sha256: fde30c053be50f489c5b440151d00035c0d1d9c53d18c9926fe0d56924c0c329

Contents?: true

Size: 1.25 KB

Versions: 53

Compression:

Stored size: 1.25 KB

Contents

'use strict';

var implementation = require('./implementation');

var lacksProperEnumerationOrder = function () {
	if (!Object.assign) {
		return false;
	}
	// v8, specifically in node 4.x, has a bug with incorrect property enumeration order
	// note: this does not detect the bug unless there's 20 characters
	var str = 'abcdefghijklmnopqrst';
	var letters = str.split('');
	var map = {};
	for (var i = 0; i < letters.length; ++i) {
		map[letters[i]] = letters[i];
	}
	var obj = Object.assign({}, map);
	var actual = '';
	for (var k in obj) {
		actual += k;
	}
	return str !== actual;
};

var assignHasPendingExceptions = function () {
	if (!Object.assign || !Object.preventExtensions) {
		return false;
	}
	// Firefox 37 still has "pending exception" logic in its Object.assign implementation,
	// which is 72% slower than our shim, and Firefox 40's native implementation.
	var thrower = Object.preventExtensions({ 1: 2 });
	try {
		Object.assign(thrower, 'xy');
	} catch (e) {
		return thrower[1] === 'y';
	}
	return false;
};

module.exports = function getPolyfill() {
	if (!Object.assign) {
		return implementation;
	}
	if (lacksProperEnumerationOrder()) {
		return implementation;
	}
	if (assignHasPendingExceptions()) {
		return implementation;
	}
	return Object.assign;
};

Version data entries

53 entries across 53 versions & 11 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/object.assign/polyfill.js
disco_app-0.18.0 test/dummy/node_modules/object.assign/polyfill.js
disco_app-0.18.2 test/dummy/node_modules/object.assign/polyfill.js
disco_app-0.16.1 test/dummy/node_modules/object.assign/polyfill.js
disco_app-0.15.2 test/dummy/node_modules/object.assign/polyfill.js
disco_app-0.18.4 test/dummy/node_modules/object.assign/polyfill.js
disco_app-0.18.1 test/dummy/node_modules/object.assign/polyfill.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/object.assign/polyfill.js
disco_app-0.14.0 test/dummy/node_modules/object.assign/polyfill.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/object.assign/polyfill.js
enju_library-0.3.8 spec/dummy/node_modules/object.assign/polyfill.js
condenser-0.3 lib/condenser/processors/node_modules/object.assign/polyfill.js
ilog-0.4.1 node_modules/object.assign/polyfill.js
ilog-0.4.0 node_modules/object.assign/polyfill.js
ilog-0.3.3 node_modules/object.assign/polyfill.js
condenser-0.2 lib/condenser/processors/node_modules/object.assign/polyfill.js
condenser-0.1 lib/condenser/processors/node_modules/object.assign/polyfill.js
condenser-0.0.12 lib/condenser/processors/node_modules/object.assign/polyfill.js
condenser-0.0.11 lib/condenser/processors/node_modules/object.assign/polyfill.js
condenser-0.0.10 lib/condenser/processors/node_modules/object.assign/polyfill.js