@nwtgck

ts-copyable

Type-safe .copy() for TypeScript inspired by Scala case-class

import Copyable  from 'ts-copyable';

class Person extends Copyable<Person>{
  constructor(readonly name: string, readonly age: number){
    super(Person);
  }
}
const p1 = new Person("jack", 10);

p1.copy({age: 2});
// => Person("jack", 2)

p1.mapCopy({age: prev => prev+1});
// => Person("jack", 11)