es5-ext
Advanced tools
Comparing version 0.10.19 to 0.10.20
@@ -5,2 +5,13 @@ # Change Log | ||
<a name="0.10.20"></a> | ||
## [0.10.20](https://github.com/medikoo/es5-ext/compare/v0.10.19...v0.10.20) (2017-05-17) | ||
### Features | ||
* if listed copy not only if own property ([d7e7cef](https://github.com/medikoo/es5-ext/commit/d7e7cef)) | ||
* support `ensure` option in Object.copy ([295326f](https://github.com/medikoo/es5-ext/commit/295326f)) | ||
<a name="0.10.19"></a> | ||
@@ -7,0 +18,0 @@ ## [0.10.19](https://github.com/medikoo/es5-ext/compare/v0.10.18...v0.10.19) (2017-05-17) |
@@ -1,16 +0,14 @@ | ||
"use strict"; | ||
'use strict'; | ||
var aFrom = require("../array/from") | ||
, assign = require("./assign") | ||
, value = require("./valid-value") | ||
, propertyIsEnumerable = Object.prototype.propertyIsEnumerable; | ||
var aFrom = require('../array/from') | ||
, assign = require('./assign') | ||
, value = require('./valid-value'); | ||
module.exports = function(obj /*, propertyNames*/) { | ||
var copy = Object(value(obj)), propertyNames = arguments[1]; | ||
module.exports = function (obj/*, propertyNames, options*/) { | ||
var copy = Object(value(obj)), propertyNames = arguments[1], options = Object(arguments[2]); | ||
if (copy !== obj && !propertyNames) return copy; | ||
var result = {}; | ||
if (propertyNames) { | ||
aFrom(propertyNames, function(propertyName) { | ||
if (propertyIsEnumerable.call(obj, propertyName)) | ||
result[propertyName] = obj[propertyName]; | ||
aFrom(propertyNames, function (propertyName) { | ||
if (options.ensure || propertyName in obj) result[propertyName] = obj[propertyName]; | ||
}); | ||
@@ -17,0 +15,0 @@ } else { |
{ | ||
"name": "es5-ext", | ||
"version": "0.10.19", | ||
"version": "0.10.20", | ||
"description": "ECMAScript extensions and shims", | ||
@@ -5,0 +5,0 @@ "author": "Mariusz Nowak <medyk@medikoo.com> (http://www.medikoo.com/)", |
@@ -1,20 +0,20 @@ | ||
"use strict"; | ||
'use strict'; | ||
var stringify = JSON.stringify; | ||
module.exports = function(t, a) { | ||
var o = { 1: "raz", 2: "dwa", 3: "trzy" }, no = t(o); | ||
module.exports = function (t, a) { | ||
var o = { 1: 'raz', 2: 'dwa', 3: 'trzy' }, no = t(o); | ||
a.not(no, o, "Return different object"); | ||
a(stringify(no), stringify(o), "Match properties and values"); | ||
a.not(no, o, 'Return different object'); | ||
a(stringify(no), stringify(o), 'Match properties and values'); | ||
o = { | ||
foo: "bar", | ||
foo: 'bar', | ||
raz: { | ||
dwa: "dwa", | ||
trzy: { cztery: "pięć", sześć: "siedem" }, | ||
dwa: 'dwa', | ||
trzy: { cztery: 'pięć', "sześć": 'siedem' }, | ||
osiem: {}, | ||
dziewięć: function() {} | ||
"dziewięć": function () {} | ||
}, | ||
dziesięć: 10 | ||
"dziesięć": 10 | ||
}; | ||
@@ -24,5 +24,8 @@ o.raz.rec = o; | ||
no = t(o); | ||
a(o.raz, no.raz, "Shallow"); | ||
a(o.raz, no.raz, 'Shallow'); | ||
a.deep(t(o, ["foo"]), { foo: "bar" }); | ||
a.deep(t(o, ['foo']), { foo: 'bar' }); | ||
a.deep(t(Object.create(o), ['foo']), { foo: 'bar' }); | ||
a.deep(t(o, ['foo', 'habla']), { foo: 'bar' }); | ||
a.deep(t(o, ['foo', 'habla'], { ensure: true }), { foo: 'bar', habla: undefined }); | ||
}; |
432424
7492