Socket
Socket
Sign inDemoInstall

object.assign

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object.assign - npm Package Compare versions

Comparing version 3.0.1 to 4.0.0

implementation.js

12

CHANGELOG.md

@@ -0,1 +1,13 @@

4.0.0 / 2015-08-15
==================
* [Breaking] Implement the [es-shim API](es-shims/api).
* [Robustness] Make implementation robust against later modification of environment methods.
* [Refactor] Move implementation to `implementation.js`
* [Docs] Switch from vb.teelaun.ch to versionbadg.es for the npm version badge SVG
* [Deps] update `object-keys`, `define-properties`
* [Dev Deps] update `browserify`, `tape`, `eslint`, `jscs`, `browserify`
* [Tests] Add `npm run tests-only`
* [Tests] use my personal shared `eslint` config.
* [Tests] up to `io.js` `v3.0`
3.0.1 / 2015-06-28

@@ -2,0 +14,0 @@ ==================

207

dist/browser.js
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
'use strict';
var keys = require('object-keys').shim();

@@ -11,3 +13,5 @@ delete keys.shim;

},{"./":3,"object-keys":6}],2:[function(require,module,exports){
},{"./":4,"object-keys":8}],2:[function(require,module,exports){
'use strict';
var keys = require('object-keys');

@@ -43,3 +47,3 @@

},{"object-keys":6}],3:[function(require,module,exports){
},{"object-keys":8}],3:[function(require,module,exports){
'use strict';

@@ -49,2 +53,3 @@

var keys = require('object-keys');
var bind = require('function-bind');
var canBeObject = function (obj) {

@@ -54,8 +59,7 @@ return typeof obj !== 'undefined' && obj !== null;

var hasSymbols = require('./hasSymbols')();
var defineProperties = require('define-properties');
var toObject = Object;
var push = Array.prototype.push;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
var push = bind.call(Function.call, Array.prototype.push);
var propIsEnumerable = bind.call(Function.call, Object.prototype.propertyIsEnumerable);
var assignShim = function assign(target, source1) {
module.exports = function assign(target, source1) {
if (!canBeObject(target)) { throw new TypeError('target must be an object'); }

@@ -70,4 +74,4 @@ var objTarget = toObject(target);

for (i = 0; i < syms.length; ++i) {
if (propIsEnumerable.call(source, syms[i])) {
push.call(props, syms[i]);
if (propIsEnumerable(source, syms[i])) {
push(props, syms[i]);
}

@@ -83,29 +87,20 @@ }

defineProperties(assignShim, {
shim: function shimObjectAssign() {
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';
}
};
defineProperties(
Object,
{ assign: assignShim },
{ assign: assignHasPendingExceptions }
);
return Object.assign || assignShim;
}
},{"./hasSymbols":2,"function-bind":7,"object-keys":8}],4:[function(require,module,exports){
'use strict';
var defineProperties = require('define-properties');
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
defineProperties(implementation, {
implementation: implementation,
getPolyfill: getPolyfill,
shim: shim
});
module.exports = assignShim;
module.exports = implementation;
},{"./hasSymbols":2,"define-properties":4,"object-keys":6}],4:[function(require,module,exports){
},{"./implementation":3,"./polyfill":10,"./shim":11,"define-properties":5}],5:[function(require,module,exports){
'use strict';

@@ -115,2 +110,3 @@

var foreach = require('foreach');
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol';

@@ -126,3 +122,6 @@ var toStr = Object.prototype.toString;

try {
Object.defineProperty(obj, 'x', { value: obj });
Object.defineProperty(obj, 'x', { value: obj, enumerable: false });
/* eslint-disable no-unused-vars */
for (var _ in obj) { return false; }
/* eslint-enable no-unused-vars */
return obj.x === obj;

@@ -153,3 +152,7 @@ } catch (e) { /* this is IE 8. */

var predicates = arguments.length > 2 ? arguments[2] : {};
foreach(keys(map), function (name) {
var props = keys(map);
if (hasSymbols) {
props = props.concat(Object.getOwnPropertySymbols(map));
}
foreach(props, function (name) {
defineProperty(object, name, map[name], predicates[name]);

@@ -163,3 +166,3 @@ });

},{"foreach":5,"object-keys":6}],5:[function(require,module,exports){
},{"foreach":6,"object-keys":8}],6:[function(require,module,exports){

@@ -188,3 +191,53 @@ var hasOwn = Object.prototype.hasOwnProperty;

},{}],6:[function(require,module,exports){
},{}],7:[function(require,module,exports){
var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible ';
var slice = Array.prototype.slice;
var toStr = Object.prototype.toString;
var funcType = '[object Function]';
module.exports = function bind(that) {
var target = this;
if (typeof target !== 'function' || toStr.call(target) !== funcType) {
throw new TypeError(ERROR_MESSAGE + target);
}
var args = slice.call(arguments, 1);
var binder = function () {
if (this instanceof bound) {
var result = target.apply(
this,
args.concat(slice.call(arguments))
);
if (Object(result) === result) {
return result;
}
return this;
} else {
return target.apply(
that,
args.concat(slice.call(arguments))
);
}
};
var boundLength = Math.max(0, target.length - args.length);
var boundArgs = [];
for (var i = 0; i < boundLength; i++) {
boundArgs.push('$' + i);
}
var bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder);
if (target.prototype) {
var Empty = function Empty() {};
Empty.prototype = target.prototype;
bound.prototype = new Empty();
Empty.prototype = null;
}
return bound;
};
},{}],8:[function(require,module,exports){
'use strict';

@@ -208,2 +261,40 @@

];
var equalsConstructorPrototype = function (o) {
var ctor = o.constructor;
return ctor && ctor.prototype === o;
};
var blacklistedKeys = {
$window: true,
$console: true,
$parent: true,
$self: true,
$frames: true,
$webkitIndexedDB: true,
$webkitStorageInfo: true
};
var hasAutomationEqualityBug = (function () {
/* global window */
if (typeof window === 'undefined') { return false; }
for (var k in window) {
if (!blacklistedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') {
try {
equalsConstructorPrototype(window[k]);
} catch (e) {
return true;
}
}
}
return false;
}());
var equalsConstructorPrototypeIfNotBuggy = function (o) {
/* global window */
if (typeof window === 'undefined' && !hasAutomationEqualityBug) {
return equalsConstructorPrototype(o);
}
try {
return equalsConstructorPrototype(o);
} catch (e) {
return false;
}
};

@@ -241,4 +332,3 @@ var keysShim = function keys(object) {

if (hasDontEnumBug) {
var ctor = object.constructor;
var skipConstructor = ctor && ctor.prototype === object;
var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object);

@@ -278,3 +368,3 @@ for (var k = 0; k < dontEnums.length; ++k) {

},{"./isArguments":7}],7:[function(require,module,exports){
},{"./isArguments":9}],9:[function(require,module,exports){
'use strict';

@@ -298,2 +388,39 @@

},{}]},{},[1]);
},{}],10:[function(require,module,exports){
'use strict';
var implementation = require('./implementation');
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';
}
};
module.exports = function getPolyfill() {
return !Object.assign || assignHasPendingExceptions() ? implementation : Object.assign;
};
},{"./implementation":3}],11:[function(require,module,exports){
'use strict';
var define = require('define-properties');
var getPolyfill = require('./polyfill');
module.exports = function shimAssign() {
var polyfill = getPolyfill();
if (Object.assign !== polyfill) {
define(Object, { assign: polyfill });
}
return polyfill;
};
},{"./polyfill":10,"define-properties":5}]},{},[1]);

@@ -0,1 +1,3 @@

'use strict';
var keys = require('object-keys');

@@ -2,0 +4,0 @@

61

index.js
'use strict';
// modified from https://github.com/es-shims/es6-shim
var keys = require('object-keys');
var canBeObject = function (obj) {
return typeof obj !== 'undefined' && obj !== null;
};
var hasSymbols = require('./hasSymbols')();
var defineProperties = require('define-properties');
var toObject = Object;
var push = Array.prototype.push;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
var assignShim = function assign(target, source1) {
if (!canBeObject(target)) { throw new TypeError('target must be an object'); }
var objTarget = toObject(target);
var s, source, i, props, syms;
for (s = 1; s < arguments.length; ++s) {
source = toObject(arguments[s]);
props = keys(source);
if (hasSymbols && Object.getOwnPropertySymbols) {
syms = Object.getOwnPropertySymbols(source);
for (i = 0; i < syms.length; ++i) {
if (propIsEnumerable.call(source, syms[i])) {
push.call(props, syms[i]);
}
}
}
for (i = 0; i < props.length; ++i) {
objTarget[props[i]] = source[props[i]];
}
}
return objTarget;
};
var implementation = require('./implementation');
var getPolyfill = require('./polyfill');
var shim = require('./shim');
defineProperties(assignShim, {
shim: function shimObjectAssign() {
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';
}
};
defineProperties(
Object,
{ assign: assignShim },
{ assign: assignHasPendingExceptions }
);
return Object.assign || assignShim;
}
defineProperties(implementation, {
implementation: implementation,
getPolyfill: getPolyfill,
shim: shim
});
module.exports = assignShim;
module.exports = implementation;
{
"name": "object.assign",
"version": "3.0.1",
"version": "4.0.0",
"author": "Jordan Harband",

@@ -9,3 +9,4 @@ "description": "ES6 spec-compliant Object.assign shim. From https://github.com/es-shims/es6-shim",

"scripts": {
"test": "npm run lint && node test/index.js && npm run test:symbol-shim && npm run security",
"test": "npm run lint && es-shim-api && npm run tests-only && npm run security",
"tests-only": "node test/index.js && npm run test:symbol-shim",
"test:symbol-shim": "node test/symbolShim.js",

@@ -36,14 +37,17 @@ "coverage": "covert test/*.js",

"dependencies": {
"object-keys": "^1.0.4",
"define-properties": "^1.0.2"
"function-bind": "^1.0.2",
"object-keys": "^1.0.7",
"define-properties": "^1.1.1"
},
"devDependencies": {
"browserify": "^10.2.4",
"browserify": "^11.0.1",
"is": "^3.0.1",
"tape": "^4.0.0",
"tape": "^4.2.0",
"covert": "^1.1.0",
"jscs": "^1.13.1",
"jscs": "^2.1.0",
"nsp": "^1.0.3",
"eslint": "^0.24.0",
"get-own-property-symbols": "^0.5.1"
"eslint": "^1.1.0",
"@ljharb/eslint-config": "^1.0.4",
"get-own-property-symbols": "^0.5.1",
"@es-shims/api": "^1.0.0"
},

@@ -50,0 +54,0 @@ "testling": {

@@ -15,2 +15,4 @@ #object.assign <sup>[![Version Badge][npm-version-svg]][npm-url]</sup>

This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](http://www.ecma-international.org/ecma-262/6.0/#sec-object.assign).
Takes a minimum of 2 arguments: `target` and `source`.

@@ -22,3 +24,3 @@ Takes a variable sized list of source arguments - at least 1, as many as you want.

```js
var assign = Object.assign || require('object.assign');
var assign = require('object.assign').getPolyfill(); // returns native method if compliant
```

@@ -124,3 +126,3 @@

[npm-url]: https://npmjs.org/package/object.assign
[npm-version-svg]: http://vb.teelaun.ch/ljharb/object.assign.svg
[npm-version-svg]: http://versionbadg.es/ljharb/object.assign.svg
[travis-svg]: https://travis-ci.org/ljharb/object.assign.svg

@@ -127,0 +129,0 @@ [travis-url]: https://travis-ci.org/ljharb/object.assign

@@ -0,1 +1,3 @@

'use strict';
var test = require('tape');

@@ -196,4 +198,2 @@ var assign = require('../');

t.test('when Object.assign is present and has pending exceptions', { skip: !Object.assign || !Object.preventExtensions }, function (st) {
'use strict';
var originalObjectAssign = Object.assign;

@@ -200,0 +200,0 @@ delete Object.assign;

@@ -0,1 +1,3 @@

'use strict';
var test = require('tape');

@@ -2,0 +4,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc