diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8dd679816..76dcdaf1e 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -538,6 +538,11 @@ var result = _.clone(stoogesAges, true, function(value) { return _.isElement(value) ? value.cloneNode(false) : undefined; }); +var result = _.cloneDeep(stoogesAges); +var result = _.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) => { diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 23633e0d0..8c9334356 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -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( + 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