pax_global_header00006660000000000000000000000064130371640610014513gustar00rootroot0000000000000052 comment=a89774b252c91612203876984bbd6addbe3b5a0e object-assign-4.1.1/000077500000000000000000000000001303716406100142465ustar00rootroot00000000000000object-assign-4.1.1/.editorconfig000066400000000000000000000002761303716406100167300ustar00rootroot00000000000000root = true [*] indent_style = tab end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [{package.json,*.yml}] indent_style = space indent_size = 2 object-assign-4.1.1/.gitattributes000066400000000000000000000000351303716406100171370ustar00rootroot00000000000000* text=auto *.js text eol=lf object-assign-4.1.1/.gitignore000066400000000000000000000000151303716406100162320ustar00rootroot00000000000000node_modules object-assign-4.1.1/.travis.yml000066400000000000000000000001151303716406100163540ustar00rootroot00000000000000sudo: false language: node_js node_js: - '6' - '4' - '0.12' - '0.10' object-assign-4.1.1/bench.js000066400000000000000000000021341303716406100156630ustar00rootroot00000000000000'use strict'; /* globals bench suite */ var lodash = require('lodash'); var objectAssign = require('./'); var source1 = { a: 1, b: 2, c: 3 }; var source2 = { c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10, k: 11, l: 12, m: 13, n: 15, o: 15, p: 16 }; if (Object.assign) { suite('Object.assign', function () { bench('small', function () { Object.assign({foo: 0}, {bar: 1}); }); bench('default options', function () { Object.assign({}, {foo: 0}, {foo: 1}); }); bench('big', function () { Object.assign({}, source1, source2); }); }); } suite('object-assign', function () { bench('small', function () { objectAssign({foo: 0}, {bar: 1}); }); bench('default options', function () { objectAssign({}, {foo: 0}, {foo: 1}); }); bench('big', function () { objectAssign({}, source1, source2); }); }); suite('lodash', function () { bench('small', function () { lodash.assign({foo: 0}, {bar: 1}); }); bench('default options', function () { lodash.assign({}, {foo: 0}, {foo: 1}); }); bench('big', function () { lodash.assign({}, source1, source2); }); }); object-assign-4.1.1/index.js000066400000000000000000000040741303716406100157200ustar00rootroot00000000000000/* object-assign (c) Sindre Sorhus @license MIT */ 'use strict'; /* eslint-disable no-unused-vars */ var getOwnPropertySymbols = Object.getOwnPropertySymbols; var hasOwnProperty = Object.prototype.hasOwnProperty; var propIsEnumerable = Object.prototype.propertyIsEnumerable; function toObject(val) { if (val === null || val === undefined) { throw new TypeError('Object.assign cannot be called with null or undefined'); } return Object(val); } function shouldUseNative() { try { if (!Object.assign) { return false; } // Detect buggy property enumeration order in older V8 versions. // https://bugs.chromium.org/p/v8/issues/detail?id=4118 var test1 = new String('abc'); // eslint-disable-line no-new-wrappers test1[5] = 'de'; if (Object.getOwnPropertyNames(test1)[0] === '5') { return false; } // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test2 = {}; for (var i = 0; i < 10; i++) { test2['_' + String.fromCharCode(i)] = i; } var order2 = Object.getOwnPropertyNames(test2).map(function (n) { return test2[n]; }); if (order2.join('') !== '0123456789') { return false; } // https://bugs.chromium.org/p/v8/issues/detail?id=3056 var test3 = {}; 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { test3[letter] = letter; }); if (Object.keys(Object.assign({}, test3)).join('') !== 'abcdefghijklmnopqrst') { return false; } return true; } catch (err) { // We don't expect any of the above to throw, but better to be safe. return false; } } module.exports = shouldUseNative() ? Object.assign : function (target, source) { var from; var to = toObject(target); var symbols; for (var s = 1; s < arguments.length; s++) { from = Object(arguments[s]); for (var key in from) { if (hasOwnProperty.call(from, key)) { to[key] = from[key]; } } if (getOwnPropertySymbols) { symbols = getOwnPropertySymbols(from); for (var i = 0; i < symbols.length; i++) { if (propIsEnumerable.call(from, symbols[i])) { to[symbols[i]] = from[symbols[i]]; } } } } return to; }; object-assign-4.1.1/license000066400000000000000000000021371303716406100156160ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Sindre Sorhus (sindresorhus.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. object-assign-4.1.1/package.json000066400000000000000000000013741303716406100165410ustar00rootroot00000000000000{ "name": "object-assign", "version": "4.1.1", "description": "ES2015 `Object.assign()` ponyfill", "license": "MIT", "repository": "sindresorhus/object-assign", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, "engines": { "node": ">=0.10.0" }, "scripts": { "test": "xo && ava", "bench": "matcha bench.js" }, "files": [ "index.js" ], "keywords": [ "object", "assign", "extend", "properties", "es2015", "ecmascript", "harmony", "ponyfill", "prollyfill", "polyfill", "shim", "browser" ], "devDependencies": { "ava": "^0.16.0", "lodash": "^4.16.4", "matcha": "^0.7.0", "xo": "^0.16.0" } } object-assign-4.1.1/readme.md000066400000000000000000000027361303716406100160350ustar00rootroot00000000000000# object-assign [![Build Status](https://travis-ci.org/sindresorhus/object-assign.svg?branch=master)](https://travis-ci.org/sindresorhus/object-assign) > ES2015 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) [ponyfill](https://ponyfill.com) ## Use the built-in Node.js 4 and up, as well as every evergreen browser (Chrome, Edge, Firefox, Opera, Safari), support `Object.assign()` :tada:. If you target only those environments, then by all means, use `Object.assign()` instead of this package. ## Install ``` $ npm install --save object-assign ``` ## Usage ```js const objectAssign = require('object-assign'); objectAssign({foo: 0}, {bar: 1}); //=> {foo: 0, bar: 1} // multiple sources objectAssign({foo: 0}, {bar: 1}, {baz: 2}); //=> {foo: 0, bar: 1, baz: 2} // overwrites equal keys objectAssign({foo: 0}, {foo: 1}, {foo: 2}); //=> {foo: 2} // ignores null and undefined sources objectAssign({foo: 0}, null, {bar: 1}, undefined); //=> {foo: 0, bar: 1} ``` ## API ### objectAssign(target, [source, ...]) Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones. ## Resources - [ES2015 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) ## Related - [deep-assign](https://github.com/sindresorhus/deep-assign) - Recursive `Object.assign()` ## License MIT © [Sindre Sorhus](https://sindresorhus.com) object-assign-4.1.1/test.js000066400000000000000000000053641303716406100155730ustar00rootroot00000000000000import test from 'ava'; Object.assign = require('./'); const objectAssign = require('./'); test('have the correct length', t => { t.is(objectAssign.length, 2); }); test('throw when target is not an object', t => { t.throws(() => { objectAssign(null); }, TypeError); t.throws(() => { objectAssign(undefined); }, TypeError); }); test('objectAssign own enumerable properties from source to target object', t => { t.deepEqual(objectAssign({foo: 0}, {bar: 1}), { foo: 0, bar: 1 }); t.deepEqual(objectAssign({foo: 0}, null, undefined), {foo: 0}); t.deepEqual(objectAssign({foo: 0}, null, undefined, {bar: 1}, null), { foo: 0, bar: 1 }); }); test('throw on null/undefined target', t => { t.throws(() => { objectAssign(null, {}); }); t.throws(() => { objectAssign(undefined, {}); }); t.throws(() => { objectAssign(undefined, undefined); }); }); test('not throw on null/undefined sources', t => { t.notThrows(() => { objectAssign({}, null); }); t.notThrows(() => { objectAssign({}, undefined); }); t.notThrows(() => { objectAssign({}, undefined, null); }); }); test('support multiple sources', t => { t.deepEqual(objectAssign({foo: 0}, {bar: 1}, {bar: 2}), { foo: 0, bar: 2 }); t.deepEqual(objectAssign({}, {}, {foo: 1}), {foo: 1}); }); test('only iterate own keys', t => { const Unicorn = function () {}; Unicorn.prototype.rainbows = 'many'; const unicorn = new Unicorn(); unicorn.bar = 1; t.deepEqual(objectAssign({foo: 1}, unicorn), { foo: 1, bar: 1 }); }); test('return the modified target object', t => { const target = {}; const returned = objectAssign(target, {a: 1}); t.is(returned, target); }); test('support `Object.create(null)` objects', t => { const obj = Object.create(null); obj.foo = true; t.deepEqual(objectAssign({}, obj), {foo: true}); }); test('preserve property order', t => { const letters = 'abcdefghijklmnopqrst'; const source = {}; letters.split('').forEach(letter => { source[letter] = letter; }); const target = objectAssign({}, source); t.is(Object.keys(target).join(''), letters); }); test('accept primitives as target', t => { const target = objectAssign('abcdefg', {foo: 'bar'}); const strObj = Object('abcdefg'); strObj.foo = 'bar'; t.deepEqual(target, strObj); }); if (typeof global.Symbol !== 'undefined') { test('support symbol properties', t => { const target = {}; const source = {}; const sym = Symbol('foo'); source[sym] = 'bar'; objectAssign(target, source); t.is(target[sym], 'bar'); }); test('only copy enumerable symbols', t => { const target = {}; const source = {}; const sym = Symbol('foo'); Object.defineProperty(source, sym, { enumerable: false, value: 'bar' }); objectAssign(target, source); t.is(target[sym], undefined); }); }