Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let editableThings = new WeakMap();
- function finisherFor(prop) {
- function finisher(C) {
- let list = editableThings.get(C);
- if (!list) {
- list = [];
- editableThings.set(C, list);
- }
- list.push(prop);
- }
- }
- function Editable() {
- return function ({ key, ... props}) {
- return { key, ... props, finisher: finisherFor(key) };
- }
- }
- function getEditableProps(C) {
- return editableThings.get(C) || [];
- }
- class Blog {
- @Editable title;
- @Editable author;
- }
- print(getEditableProps(Blog)); // ['title', 'author']
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement