[Pkg-javascript-commits] [node-object-assign] 01/04: New upstream version 4.1.1
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Tue Jan 23 11:32:30 UTC 2018
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository node-object-assign.
commit 5f45052991a74faee28f854ec7dfda3356846b98
Author: Pirate Praveen <praveen at debian.org>
Date: Tue Jan 23 16:30:09 2018 +0530
New upstream version 4.1.1
---
.gitattributes | 1 +
.travis.yml | 2 +-
bench.js | 16 ++++++++
index.js | 15 +++++--
package.json | 12 +++---
readme.md | 11 +++--
test.js | 126 ++++++++++++++++++++++++++++++++-------------------------
7 files changed, 115 insertions(+), 68 deletions(-)
diff --git a/.gitattributes b/.gitattributes
index 176a458..391f0a4 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1 +1,2 @@
* text=auto
+*.js text eol=lf
diff --git a/.travis.yml b/.travis.yml
index a78e23d..2c6e9b0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,7 @@
sudo: false
language: node_js
node_js:
- - '5'
+ - '6'
- '4'
- '0.12'
- '0.10'
diff --git a/bench.js b/bench.js
index a9df2d1..1df71e2 100644
--- a/bench.js
+++ b/bench.js
@@ -26,6 +26,22 @@ var source2 = {
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});
diff --git a/index.js b/index.js
index 5085048..0930cf8 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,12 @@
+/*
+object-assign
+(c) Sindre Sorhus
+ at license MIT
+*/
+
'use strict';
/* eslint-disable no-unused-vars */
+var getOwnPropertySymbols = Object.getOwnPropertySymbols;
var hasOwnProperty = Object.prototype.hasOwnProperty;
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
@@ -20,7 +27,7 @@ function shouldUseNative() {
// 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
+ var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
test1[5] = 'de';
if (Object.getOwnPropertyNames(test1)[0] === '5') {
return false;
@@ -49,7 +56,7 @@ function shouldUseNative() {
}
return true;
- } catch (e) {
+ } catch (err) {
// We don't expect any of the above to throw, but better to be safe.
return false;
}
@@ -69,8 +76,8 @@ module.exports = shouldUseNative() ? Object.assign : function (target, source) {
}
}
- if (Object.getOwnPropertySymbols) {
- symbols = Object.getOwnPropertySymbols(from);
+ 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]];
diff --git a/package.json b/package.json
index a25d428..503eb1e 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "object-assign",
- "version": "4.1.0",
- "description": "ES2015 Object.assign() ponyfill",
+ "version": "4.1.1",
+ "description": "ES2015 `Object.assign()` ponyfill",
"license": "MIT",
"repository": "sindresorhus/object-assign",
"author": {
@@ -13,7 +13,7 @@
"node": ">=0.10.0"
},
"scripts": {
- "test": "xo && mocha",
+ "test": "xo && ava",
"bench": "matcha bench.js"
},
"files": [
@@ -34,9 +34,9 @@
"browser"
],
"devDependencies": {
- "lodash": "^4.8.2",
+ "ava": "^0.16.0",
+ "lodash": "^4.16.4",
"matcha": "^0.7.0",
- "mocha": "*",
- "xo": "*"
+ "xo": "^0.16.0"
}
}
diff --git a/readme.md b/readme.md
index 13c0977..1be09d3 100644
--- a/readme.md
+++ b/readme.md
@@ -1,8 +1,13 @@
# 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
+> ES2015 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) [ponyfill](https://ponyfill.com)
-> Ponyfill: A polyfill that doesn't overwrite the native method
+
+## 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
@@ -36,7 +41,7 @@ objectAssign({foo: 0}, null, {bar: 1}, undefined);
## API
-### objectAssign(target, source, [source, ...])
+### 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.
diff --git a/test.js b/test.js
index 9719c2c..36a4c00 100644
--- a/test.js
+++ b/test.js
@@ -1,111 +1,129 @@
-'use strict';
-/* eslint-env mocha */
-var assert = require('assert');
-Object.assign = undefined;
-var objectAssign = require('./');
-
-it('should have the correct length', function () {
- assert.equal(objectAssign.length, 2);
+import test from 'ava';
+
+Object.assign = require('./');
+const objectAssign = require('./');
+
+test('have the correct length', t => {
+ t.is(objectAssign.length, 2);
});
-it('should throw when target is not an object', function () {
- assert.throws(function () {
+test('throw when target is not an object', t => {
+ t.throws(() => {
objectAssign(null);
}, TypeError);
- assert.throws(function () {
+ t.throws(() => {
objectAssign(undefined);
}, TypeError);
});
-it('should objectAssign own enumerable properties from source to target object', function () {
- assert.deepEqual(objectAssign({foo: 0}, {bar: 1}), {foo: 0, bar: 1});
- assert.deepEqual(objectAssign({foo: 0}, null, undefined), {foo: 0});
- assert.deepEqual(objectAssign({foo: 0}, null, undefined, {bar: 1}, null), {foo: 0, bar: 1});
+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
+ });
});
-it('should throw on null/undefined target', function () {
- assert.throws(function () {
+test('throw on null/undefined target', t => {
+ t.throws(() => {
objectAssign(null, {});
});
- assert.throws(function () {
+ t.throws(() => {
objectAssign(undefined, {});
});
- assert.throws(function () {
+ t.throws(() => {
objectAssign(undefined, undefined);
});
});
-it('should not throw on null/undefined sources', function () {
- assert.doesNotThrow(function () {
+test('not throw on null/undefined sources', t => {
+ t.notThrows(() => {
objectAssign({}, null);
});
- assert.doesNotThrow(function () {
+ t.notThrows(() => {
objectAssign({}, undefined);
});
- assert.doesNotThrow(function () {
+ t.notThrows(() => {
objectAssign({}, undefined, null);
});
});
-it('should support multiple sources', function () {
- assert.deepEqual(objectAssign({foo: 0}, {bar: 1}, {bar: 2}), {foo: 0, bar: 2});
- assert.deepEqual(objectAssign({}, {}, {foo: 1}), {foo: 1});
+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});
});
-it('should only iterate own keys', function () {
- var Unicorn = function () {};
+test('only iterate own keys', t => {
+ const Unicorn = function () {};
Unicorn.prototype.rainbows = 'many';
- var unicorn = new Unicorn();
+ const unicorn = new Unicorn();
unicorn.bar = 1;
- assert.deepEqual(objectAssign({foo: 1}, unicorn), {foo: 1, bar: 1});
+ t.deepEqual(objectAssign({foo: 1}, unicorn), {
+ foo: 1,
+ bar: 1
+ });
});
-it('should return the modified target object', function () {
- var target = {};
- var returned = objectAssign(target, {a: 1});
- assert.equal(returned, target);
+test('return the modified target object', t => {
+ const target = {};
+ const returned = objectAssign(target, {a: 1});
+ t.is(returned, target);
});
-it('should support `Object.create(null)` objects', function () {
- var obj = Object.create(null);
+test('support `Object.create(null)` objects', t => {
+ const obj = Object.create(null);
obj.foo = true;
- assert.deepEqual(objectAssign({}, obj), {foo: true});
+ t.deepEqual(objectAssign({}, obj), {foo: true});
});
-it('should preserve property order', function () {
- var letters = 'abcdefghijklmnopqrst';
- var source = {};
- letters.split('').forEach(function (letter) {
+test('preserve property order', t => {
+ const letters = 'abcdefghijklmnopqrst';
+ const source = {};
+ letters.split('').forEach(letter => {
source[letter] = letter;
});
- var target = objectAssign({}, source);
- assert.equal(Object.keys(target).join(''), letters);
+ 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 Symbol !== 'undefined') {
- it('should support symbol properties', function () {
- var target = {};
- var source = {};
- var sym = Symbol('foo');
+if (typeof global.Symbol !== 'undefined') {
+ test('support symbol properties', t => {
+ const target = {};
+ const source = {};
+ const sym = Symbol('foo');
source[sym] = 'bar';
objectAssign(target, source);
- assert.equal(target[sym], 'bar');
+ t.is(target[sym], 'bar');
});
- it('should only copy enumerable symbols', function () {
- var target = {};
- var source = {};
- var sym = Symbol('foo');
+ 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);
- assert.equal(target[sym], undefined);
+ t.is(target[sym], undefined);
});
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-object-assign.git
More information about the Pkg-javascript-commits
mailing list