Merge pull request #3153 from progre/feature/clone

clone: add the 3rd parameter and one function
This commit is contained in:
Masahiro Wakame
2014-11-18 20:38:59 +09:00
2 changed files with 13 additions and 4 deletions

View File

@@ -6,4 +6,5 @@ var original = {
var copy = clone(original);
copy = clone(original, false);
copy = clone(original, true);
copy = clone(original, true, 1);
copy = clone.clonePrototype(original);

14
clone/clone.d.ts vendored
View File

@@ -8,10 +8,18 @@
*/
declare module "clone" {
/**
* @param parent
* @param circular If not given, defaults to true in JS lib.
* @param val the value that you want to clone, any type allowed
* @param circular Call clone with circular set to false if you are certain that obj contains no circular references. This will give better performance if needed. There is no error if undefined or null is passed as obj.
* @param depth to wich the object is to be cloned (optional, defaults to infinity)
*/
function clone(parent: Object, circular?: boolean): Object
function clone<T>(val: T, circular?: boolean, depth?: number): T;
module clone {
/**
* @param obj the object that you want to clone
*/
function clonePrototype<T>(obj: T): T;
}
export = clone
}