Comparing version 2.2.0 to 2.3.0
@@ -29,3 +29,3 @@ 'use strict'; | ||
/** | ||
* Performs a deep clone of an object | ||
* Performs a deep clone of an object or array. | ||
* | ||
@@ -39,14 +39,14 @@ * @example | ||
* | ||
* y = ob.cloneDeep(x) | ||
* y = ob.clone(x) | ||
* y === x | ||
* // → false | ||
* | ||
* @param {object} subject The object to clone. | ||
* @returns {object} The cloned object | ||
* @param {object|object[]} subject The object or array to clone. | ||
* @returns {object|object[]} The cloned object or arraay | ||
*/ | ||
cloneDeep: function cloneDeep(subject) { | ||
clone: function clone(subject) { | ||
return ob.expand(ob.flatten(subject)); | ||
}, | ||
/** | ||
* Returns an object without the given keys. | ||
* Returns an object without the given keys or an array with each object not having the given keys. | ||
* @example <caption>Basic usage.</caption> | ||
@@ -71,5 +71,5 @@ * let x = { | ||
* | ||
* @param {object} subject The object to perform the deselect operation on. | ||
* @param {object|object[]} subject The object or array to perform the deselect operation on. | ||
* @param {string[]} keys The keys of the object or nested object that you would like to deselect. | ||
* @returns {object} The object without the deselected keys | ||
* @returns {object|object[]} The object or array of objects without the deselected keys | ||
*/ | ||
@@ -141,3 +141,3 @@ deselect: function deselect(subject) { | ||
/** | ||
* Takes a flattened object and expands it back to a full object. | ||
* Takes a flattened object and expands it back to a full object or array of objects. | ||
* | ||
@@ -156,3 +156,3 @@ * @example | ||
* @param {object} subject The object to expand | ||
* @returns {object} The expanded object. | ||
* @returns {object|object[]} The expanded object or array of objects. | ||
*/ | ||
@@ -265,3 +265,3 @@ expand: function expand(subject) { | ||
* | ||
* @param {object} subject The object to perform the flattening on | ||
* @param {object|object[]} subject The object or array of objects to perform the flattening on | ||
* @returns {object} The flat representation of the object | ||
@@ -330,3 +330,3 @@ */ | ||
/** | ||
* Return all keys for an object recursively, including in arrays. | ||
* Return all keys for an object recursively, including keys in objects that are in arrays. | ||
* | ||
@@ -349,3 +349,3 @@ * @example | ||
* | ||
* @param {object} subject The object whose keys you wish to retrieve. | ||
* @param {object|object[]} subject The object or array of objects whose keys you wish to retrieve. | ||
* @returns {string[]} The keys | ||
@@ -394,3 +394,3 @@ */ | ||
/** | ||
* Removes all keys with undefined values from an object. | ||
* Removes all keys with undefined values from an object and/or arrays of objects. | ||
* | ||
@@ -416,8 +416,8 @@ * @example | ||
* | ||
* @param {object} subject The object you would like to remove undefined values from. | ||
* @returns {object} The object without any undefined values | ||
* @param {object|object[]} subject The object or array of objects you would like to remove undefined values from. | ||
* @returns {object|object[]} The object or array of objects without any undefined values | ||
*/ | ||
removeUndefs: function removeUndefs(subject) { | ||
// Make sure we don't mutate the original object | ||
subject = ob.cloneDeep(subject); | ||
subject = ob.clone(subject); | ||
@@ -450,3 +450,3 @@ var res = undefined; | ||
/** | ||
* Returns an object only with the given keys. | ||
* Returns an object only with the given keys. If an array is passed, it will return an array of each given object only having the selected keys. | ||
* | ||
@@ -473,5 +473,5 @@ * @example <caption>Basic usage.</caption> | ||
* | ||
* @param {object} subject The object to perform the select operation on | ||
* @param {object|object[]} subject The object or array of objects to perform the select operation on | ||
* @param {string[]} keys The keys you would like to select | ||
* @returns {object} The object only with the selected keys. | ||
* @returns {object|object[]} The object or array of objects with only the selected keys. | ||
*/ | ||
@@ -549,3 +549,3 @@ select: function select(subject) { | ||
/** | ||
* Returns all values for a given object recursively. | ||
* Returns all values for a given object or array recursively. | ||
* | ||
@@ -573,3 +573,3 @@ * @example | ||
* | ||
* @param {object} subject The object to get the values of | ||
* @param {object|object[]} subject The object or array of objects to get the values of | ||
* @returns {any[]} | ||
@@ -576,0 +576,0 @@ */ |
{ | ||
"name": "objob", | ||
"version": "2.2.0", | ||
"version": "2.3.0", | ||
"description": "A tool for controlling and manipulating javascript object fields and output.", | ||
@@ -5,0 +5,0 @@ "main": "lib/objob.js", |
@@ -15,3 +15,3 @@ 'use strict'; | ||
/** | ||
* Performs a deep clone of an object | ||
* Performs a deep clone of an object or array. | ||
* | ||
@@ -25,14 +25,14 @@ * @example | ||
* | ||
* y = ob.cloneDeep(x) | ||
* y = ob.clone(x) | ||
* y === x | ||
* // → false | ||
* | ||
* @param {object} subject The object to clone. | ||
* @returns {object} The cloned object | ||
* @param {object|object[]} subject The object or array to clone. | ||
* @returns {object|object[]} The cloned object or arraay | ||
*/ | ||
cloneDeep: function(subject){ | ||
clone: function(subject){ | ||
return ob.expand(ob.flatten(subject)); | ||
}, | ||
/** | ||
* Returns an object without the given keys. | ||
* Returns an object without the given keys or an array with each object not having the given keys. | ||
* @example <caption>Basic usage.</caption> | ||
@@ -57,5 +57,5 @@ * let x = { | ||
* | ||
* @param {object} subject The object to perform the deselect operation on. | ||
* @param {object|object[]} subject The object or array to perform the deselect operation on. | ||
* @param {string[]} keys The keys of the object or nested object that you would like to deselect. | ||
* @returns {object} The object without the deselected keys | ||
* @returns {object|object[]} The object or array of objects without the deselected keys | ||
*/ | ||
@@ -83,3 +83,3 @@ deselect: function(subject, keys = []){ | ||
/** | ||
* Takes a flattened object and expands it back to a full object. | ||
* Takes a flattened object and expands it back to a full object or array of objects. | ||
* | ||
@@ -98,3 +98,3 @@ * @example | ||
* @param {object} subject The object to expand | ||
* @returns {object} The expanded object. | ||
* @returns {object|object[]} The expanded object or array of objects. | ||
*/ | ||
@@ -185,3 +185,3 @@ expand: function(subject, depth = 1){ | ||
* | ||
* @param {object} subject The object to perform the flattening on | ||
* @param {object|object[]} subject The object or array of objects to perform the flattening on | ||
* @returns {object} The flat representation of the object | ||
@@ -226,3 +226,3 @@ */ | ||
/** | ||
* Return all keys for an object recursively, including in arrays. | ||
* Return all keys for an object recursively, including keys in objects that are in arrays. | ||
* | ||
@@ -245,3 +245,3 @@ * @example | ||
* | ||
* @param {object} subject The object whose keys you wish to retrieve. | ||
* @param {object|object[]} subject The object or array of objects whose keys you wish to retrieve. | ||
* @returns {string[]} The keys | ||
@@ -269,3 +269,3 @@ */ | ||
/** | ||
* Removes all keys with undefined values from an object. | ||
* Removes all keys with undefined values from an object and/or arrays of objects. | ||
* | ||
@@ -291,8 +291,8 @@ * @example | ||
* | ||
* @param {object} subject The object you would like to remove undefined values from. | ||
* @returns {object} The object without any undefined values | ||
* @param {object|object[]} subject The object or array of objects you would like to remove undefined values from. | ||
* @returns {object|object[]} The object or array of objects without any undefined values | ||
*/ | ||
removeUndefs: (subject) => { | ||
// Make sure we don't mutate the original object | ||
subject = ob.cloneDeep(subject); | ||
subject = ob.clone(subject); | ||
@@ -326,3 +326,3 @@ let res; | ||
/** | ||
* Returns an object only with the given keys. | ||
* Returns an object only with the given keys. If an array is passed, it will return an array of each given object only having the selected keys. | ||
* | ||
@@ -349,5 +349,5 @@ * @example <caption>Basic usage.</caption> | ||
* | ||
* @param {object} subject The object to perform the select operation on | ||
* @param {object|object[]} subject The object or array of objects to perform the select operation on | ||
* @param {string[]} keys The keys you would like to select | ||
* @returns {object} The object only with the selected keys. | ||
* @returns {object|object[]} The object or array of objects with only the selected keys. | ||
*/ | ||
@@ -381,3 +381,3 @@ select: (subject, keys = []) => { | ||
/** | ||
* Returns all values for a given object recursively. | ||
* Returns all values for a given object or array recursively. | ||
* | ||
@@ -405,3 +405,3 @@ * @example | ||
* | ||
* @param {object} subject The object to get the values of | ||
* @param {object|object[]} subject The object or array of objects to get the values of | ||
* @returns {any[]} | ||
@@ -408,0 +408,0 @@ */ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
625056