提交学习笔记专用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
896 B

  1. export type Options<T> = {
  2. props?: (keyof T)[];
  3. nonenumerable?: boolean;
  4. };
  5. /**
  6. * Copy (clone) an object and all its props recursively to get rid of any prop referenced of the
  7. * original object. Arrays are also cloned, however objects inside arrays are still linked.
  8. *
  9. * @param target Target can be anything
  10. * @param [options={}] See type {@link Options} for more details.
  11. *
  12. * - `{ props: ['key1'] }` will only copy the `key1` property. When using this you will need to cast
  13. * the return type manually (in order to keep the TS implementation in here simple I didn't
  14. * built a complex auto resolved type for those few cases people want to use this option)
  15. * - `{ nonenumerable: true }` will copy all non-enumerable properties. Default is `{}`
  16. *
  17. * @returns The target with replaced values
  18. */
  19. export declare function copy<T>(target: T, options?: Options<T>): T;