added _.cloneDeep definitions

This commit is contained in:
Brian Zengel
2013-10-20 11:54:11 -04:00
parent eb66130889
commit d3fd1d96f7
2 changed files with 24 additions and 3 deletions
+5 -3
View File
@@ -538,6 +538,11 @@ var result = <any>_.clone(stoogesAges, true, function(value) {
return _.isElement(value) ? value.cloneNode(false) : undefined;
});
var result = <any>_.cloneDeep(stoogesAges);
var result = <any>_.cloneDeep(stoogesAges, function(value) {
return _.isElement(value) ? value.cloneNode(false) : undefined;
});
var mergeNames = {
'stooges': [
{ 'name': 'moe' },
@@ -594,9 +599,6 @@ _.omit({ name: 'moe', age: 50, userid: 'moe1' }, ['name', 'age']);
var iceCream = { flavor: "chocolate" };
_.defaults(iceCream, { flavor: "vanilla", sprinkles: "lots" });
_.clone({ name: 'moe' });
_.clone(['i', 'am', 'an', 'object!']);
_([1, 2, 3, 4])
.chain()
.filter((num: number) => {
+19
View File
@@ -2175,6 +2175,25 @@ declare module _ {
callback?: (value: any) => any,
thisArg?: any): T;
/**
* Creates a deep clone of value. If a callback is provided it will be executed to produce the
* cloned values. If the callback returns undefined cloning will be handled by the method instead.
* The callback is bound to thisArg and invoked with one argument; (value).
*
* Note: This method is loosely based on the structured clone algorithm. Functions and DOM nodes
* are not cloned. The enumerable properties of arguments objects and objects created by constructors
* other than Object are cloned to plain Object objects.
* See http://www.w3.org/TR/html5/infrastructure.html#internal-structured-cloning-algorithm.
* @param value The value to clone.
* @param callback The function to customize cloning values.
* @param thisArg The this binding of callback.
* @return The cloned value.
**/
export function cloneDeep<T>(
value: T,
callback?: (value: any) => any,
thisArg?: any): T;
/**
* Recursively merges own enumerable properties of the source object(s), that don't resolve
* to undefined into the destination object. Subsequent sources will overwrite property