'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; };
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
.github | Folder | 0755 |
|
|
dist | Folder | 0755 |
|
|
test | Folder | 0755 |
|
|
.editorconfig | File | 286 B | 0644 |
|
.eslintrc | File | 627 B | 0644 |
|
.nycrc | File | 139 B | 0644 |
|
CHANGELOG.md | File | 8.71 KB | 0644 |
|
LICENSE | File | 1.05 KB | 0644 |
|
README.md | File | 3.77 KB | 0644 |
|
auto.js | File | 36 B | 0644 |
|
hasSymbols.js | File | 1.58 KB | 0644 |
|
implementation.js | File | 1.38 KB | 0644 |
|
index.js | File | 532 B | 0644 |
|
package.json | File | 2.25 KB | 0644 |
|
polyfill.js | File | 1.27 KB | 0644 |
|
shim.js | File | 305 B | 0644 |
|
test.html | File | 1.05 MB | 0644 |
|