Guest User

Untitled

a guest
Jan 17th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. export interface Modifiable {
  2. $modified: boolean;
  3. }
  4. export function toModifiable<T, P extends keyof T>(object: T, options: { includes?: P[], excludes?: P[] } = {}): T & Modifiable {
  5. const properties = options.includes || Object.keys(object) as P[];
  6. properties.forEach(property => {
  7. Object.defineProperty(object, property, {
  8. // implement accessor
  9. // get: () => {},
  10. // set: (value: any) => {}
  11. });
  12. return;
  13. });
  14. return object as (T & Modifiable);
  15. }
Add Comment
Please, Sign In to add comment