From eb66130889e497d0946c8018b5f6ca037a9fdc9b Mon Sep 17 00:00:00 2001 From: Brian Zengel Date: Sun, 20 Oct 2013 11:50:25 -0400 Subject: [PATCH] added _.clone defintions --- lodash/lodash-tests.ts | 6 ++++++ lodash/lodash.d.ts | 24 +++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 6ad3a7265..8dd679816 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -532,6 +532,12 @@ result = _.assign({ 'name': 'moe' }, { 'age': 40 }, function(a, b) { return typeof a == 'undefined' ? b : a; }); +var result = _.clone(stoogesAges); +var result = _.clone(stoogesAges, true); +var result = _.clone(stoogesAges, true, function(value) { + return _.isElement(value) ? value.cloneNode(false) : undefined; +}); + var mergeNames = { 'stooges': [ { 'name': 'moe' }, diff --git a/lodash/lodash.d.ts b/lodash/lodash.d.ts index 34f2d81db..23633e0d0 100644 --- a/lodash/lodash.d.ts +++ b/lodash/lodash.d.ts @@ -2158,6 +2158,22 @@ declare module _ { callback?: (objectValue: any, sourceValue: any) => any, thisArg?: any): any; + /** + * Creates a clone of value. If deep is true nested objects will also be cloned, otherwise + * they will be assigned by reference. 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). + * @param value The value to clone. + * @param deep Specify a deep clone. + * @param callback The function to customize cloning values. + * @param thisArg The this binding of callback. + * @return The cloned value. + **/ + export function clone( + value: T, + deep?: boolean, + callback?: (value: any) => any, + thisArg?: any): T; /** * Recursively merges own enumerable properties of the source object(s), that don't resolve @@ -2407,13 +2423,7 @@ declare module _ { object: any, ...defaults: any[]): any; - /** - * Create a shallow-copied clone of the object. - * Any nested objects or arrays will be copied by reference, not duplicated. - * @param object Object to clone. - * @return Copy of `object`. - **/ - export function clone(object: T): T; + /** * Invokes interceptor with the object, and then returns object. The primary purpose of this method