Updated to v1.9.9

This commit is contained in:
Henry Whitaker
2020-11-07 15:27:50 +00:00
parent 15d3583423
commit 8d811862a0
6349 changed files with 338454 additions and 213438 deletions

View File

@@ -1,7 +0,0 @@
{
"rules": {
"max-statements-per-line": [2, { "max": 3 }],
"no-magic-numbers": 0,
"object-curly-newline": 0,
}
}

View File

@@ -3,7 +3,7 @@
var test = require('tape');
var defineProperties = require('define-properties');
var isEnumerable = Object.prototype.propertyIsEnumerable;
var functionsHaveNames = function f() {}.name === 'f';
var functionsHaveNames = require('functions-have-names')();
var runTests = require('./tests');
@@ -30,8 +30,10 @@ test('native', function (t) {
// v8 in node 0.8 and 0.10 have non-enumerable string properties
var stringCharsAreEnumerable = isEnumerable.call('xy', 0);
t.test('when Object.assign is present and has pending exceptions', { skip: !stringCharsAreEnumerable || !Object.preventExtensions }, function (st) {
// 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.
/*
* 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' });
var error;
try { Object.assign(thrower, 'xy'); } catch (e) { error = e; }

View File

@@ -0,0 +1,12 @@
'use strict';
/* globals lockdown */
// requiring ses exposes "lockdown" on the global
require('ses');
// lockdown freezes the primordials
lockdown({ errorTaming: 'unsafe' });
// initialize the module
require('./');

View File

@@ -6,7 +6,7 @@ assign.shim();
var test = require('tape');
var defineProperties = require('define-properties');
var isEnumerable = Object.prototype.propertyIsEnumerable;
var functionsHaveNames = function f() {}.name === 'f';
var functionsHaveNames = require('functions-have-names')();
var runTests = require('./tests');
@@ -33,8 +33,10 @@ test('shimmed', function (t) {
// v8 in node 0.8 and 0.10 have non-enumerable string properties
var stringCharsAreEnumerable = isEnumerable.call('xy', 0);
t.test('when Object.assign is present and has pending exceptions', { skip: !stringCharsAreEnumerable || !Object.preventExtensions }, function (st) {
// 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.
/*
* 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' });
var error;
try { Object.assign(thrower, 'xy'); } catch (e) { error = e; }

View File

@@ -2,6 +2,7 @@
var hasSymbols = require('has-symbols/shams')();
var forEach = require('for-each');
var has = require('has');
module.exports = function (assign, t) {
t.test('error cases', function (st) {
@@ -34,7 +35,7 @@ module.exports = function (assign, t) {
st.test('boolean', function (st2) {
var bool = assign(true, { a: signal });
st2.equal(typeof bool, 'object', 'bool is object');
st.equal(Boolean.prototype.valueOf.call(bool), true, 'bool coerces to `true`');
st2.equal(Boolean.prototype.valueOf.call(bool), true, 'bool coerces to `true`');
st2.equal(bool.a, signal, 'source properties copied');
st2.end();
});
@@ -103,6 +104,18 @@ module.exports = function (assign, t) {
st.end();
});
/* globals window */
t.test('works with window.location', { skip: typeof window === 'undefined' }, function (st) {
var target = {};
assign(target, window.location);
for (var prop in window.location) {
if (has(window.location, prop)) {
st.deepEqual(target[prop], window.location[prop], prop + ' is copied');
}
}
st.end();
});
t.test('merge N objects', function (st) {
var target = { a: 1 };
var source1 = { b: 2 };
@@ -146,7 +159,7 @@ module.exports = function (assign, t) {
st.end();
});
t.test('does not fail when symbols are not present', function (st) {
t.test('does not fail when symbols are not present', { skip: !Object.isFrozen || Object.isFrozen(Object) }, function (st) {
var getSyms;
if (hasSymbols) {
getSyms = Object.getOwnPropertySymbols;