Skip to content

Instantly share code, notes, and snippets.

View alexislargaiolli's full-sized avatar

Alexis Largaiolli alexislargaiolli

View GitHub Profile
@erikvullings
erikvullings / deep-copy.ts
Last active September 3, 2024 09:02
Deep copy or clone in TypeScript
/**
* Deep copy function for TypeScript.
* @param T Generic type of target/copied value.
* @param target Target value to be copied.
* @see Source project, ts-deepcopy https://github.com/ykdr2017/ts-deepcopy
* @see Code pen https://codepen.io/erikvullings/pen/ejyBYg
*/
export const deepCopy = <T>(target: T): T => {
if (target === null) {
return target;