Files
typing-test/node_modules/copy-anything/dist/index.d.ts
T
2026-08-27 17:57:30 +07:00

24 lines
1.1 KiB
TypeScript

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 and the objects inside them are cloned as well.
*
* Nesting depth is limited only by available memory, and circular references are reproduced in the
* copy rather than followed forever. Two props pointing at the same object still point at one
* shared copy afterwards.
*
* @param target Target can be anything
* @param [options={}] See type {@link Options} for more details.
*
* - `{ props: ['key1'] }` will only copy the `key1` property. When using this you will need to cast
* the return type manually (in order to keep the TS implementation in here simple I didn't
* built a complex auto resolved type for those few cases people want to use this option)
* - `{ nonenumerable: true }` will copy all non-enumerable properties. Default is `{}`
*
* @returns The target with replaced values
*/
export declare function copy<T>(target: T, options?: Options<T>): T;