{
class Ancestor {
constructor() {
this.prop = 0;
this.prop2 = 2;
}
a1() {
console.log('a1() called');
}
}
class Klass extends Ancestor {
constructor() {
super();
this.prop = 1;
this[Symbol('something')] = 0;
}
m1() {
console.log('m1() called');
}
m2() {
console.log('m2() called');
}
}
const klass = new Klass();
let allProps = new Set();
let current = klass;
do {
Object.getOwnPropertyNames(current).forEach(p => allProps.add(p));
Object.getOwnPropertySymbols(current).forEach(p => allProps.add(p));
current = Object.getPrototypeOf(current);
} while (current != null);
return Array.from(allProps).sort((a, b) => {
if (typeof a === 'symbol' && typeof b === 'symbol') return 0;
if (typeof a === 'symbol') return -1;
if (typeof b === 'symbol') return 1;
if (a < b) return -1;
if (a > b) return 1;
return 0;
});
}