mesqueeb / copy-anything

An optimised way to copy'ing (cloning) an Object or Array. A small and simple integration

Home Page:https://npmjs.com/copy-anything

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

props should be typed

ShravanSunder opened this issue · comments

props should be typed to keyof T, we will get type safety this way

export type Options<T> = {
    props?: (keyof T)[];
    nonenumerable?: boolean;
};
/**
 * Copy (clone) an object and all its props recursively to get rid of any prop referenced of the original object. Arrays are also cloned, however objects inside arrays are still linked.
 *
 * @param target Target can be anything
 * @param [options = {}] Options can be `props` or `nonenumerable`
 * @returns the target with replaced values
 */
export declare function copy<T>(target: T, options?: Options<T>): T;