Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export interface Modifiable {
- $modified: boolean;
- }
- export function toModifiable<T, P extends keyof T>(object: T, options: { includes?: P[], excludes?: P[] } = {}): T & Modifiable {
- const properties = options.includes || Object.keys(object) as P[];
- properties.forEach(property => {
- Object.defineProperty(object, property, {
- // implement accessor
- // get: () => {},
- // set: (value: any) => {}
- });
- return;
- });
- return object as (T & Modifiable);
- }
Add Comment
Please, Sign In to add comment