Comparing version 2.1.0 to 2.1.1
{ | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"tags": { | ||
@@ -4,0 +4,0 @@ "allowUnknownTags" : true |
@@ -29,2 +29,22 @@ 'use strict'; | ||
/** | ||
* Performs a deep clone of an object | ||
* | ||
* @example | ||
* let x = { | ||
* a: 1, | ||
* b: 2, | ||
* c: 3, | ||
* } | ||
* | ||
* y = ob.cloneDeep(x) | ||
* y === x | ||
* // → false | ||
* | ||
* @param {object} subject The object to clone. | ||
* @returns {object} The cloned object | ||
*/ | ||
cloneDeep: function cloneDeep(subject) { | ||
return ob.expand(ob.flatten(subject)); | ||
}, | ||
/** | ||
* Returns an object without the given keys. | ||
@@ -58,4 +78,2 @@ * @example <caption>Basic usage.</caption> | ||
var allKeys = ob.keys(ob.flatten(subject)); | ||
console.log('---------'); | ||
console.log(allKeys); | ||
var keysToKeep = []; | ||
@@ -429,2 +447,5 @@ | ||
removeUndefs: function removeUndefs(subject) { | ||
// Make sure we don't mutate the original object | ||
subject = ob.cloneDeep(subject); | ||
var res = undefined; | ||
@@ -431,0 +452,0 @@ |
{ | ||
"name": "objob", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A tool for controlling and manipulating javascript object fields and output.", | ||
@@ -5,0 +5,0 @@ "main": "lib/objob.js", |
@@ -15,2 +15,22 @@ 'use strict'; | ||
/** | ||
* Performs a deep clone of an object | ||
* | ||
* @example | ||
* let x = { | ||
* a: 1, | ||
* b: 2, | ||
* c: 3, | ||
* } | ||
* | ||
* y = ob.cloneDeep(x) | ||
* y === x | ||
* // → false | ||
* | ||
* @param {object} subject The object to clone. | ||
* @returns {object} The cloned object | ||
*/ | ||
cloneDeep: function(subject){ | ||
return ob.expand(ob.flatten(subject)); | ||
}, | ||
/** | ||
* Returns an object without the given keys. | ||
@@ -42,4 +62,2 @@ * @example <caption>Basic usage.</caption> | ||
let allKeys = ob.keys(ob.flatten(subject)); | ||
console.log('---------'); | ||
console.log(allKeys); | ||
let keysToKeep = []; | ||
@@ -302,2 +320,5 @@ | ||
removeUndefs: (subject) => { | ||
// Make sure we don't mutate the original object | ||
subject = ob.cloneDeep(subject); | ||
let res; | ||
@@ -304,0 +325,0 @@ |
@@ -175,2 +175,10 @@ /* eslint max-nested-callbacks: 0*/ | ||
describe('clone deep', () => { | ||
it('should return a clone of the object', (done) => { | ||
expect(ob.cloneDeep(ob3)).to.deep.equal(ob3); | ||
expect(ob.cloneDeep(ob3)).to.not.equal(ob3); | ||
done(); | ||
}); | ||
}); | ||
describe('Chaining', () => { | ||
@@ -177,0 +185,0 @@ it('should return many of an object after filtering select select', (done) => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1234017
3938