1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-22 16:43:46 +01:00
CodeWars/4kyu/priori_incantatem/solution.js

25 lines
472 B
JavaScript
Raw Normal View History

class Wand {
constructor(spells) {
this.history = [];
Object.assign(this, spells);
return new Proxy(this, {
get: (target, property) => {
const val = target[property];
if (typeof val === 'function') {
target.history.unshift(property);
}
return val;
}
});
}
prioriIncantatem() {
return this.history.slice(1, MAX_PRIOR_SPELLS + 1);
}
deletrius() {
this.history = ['deletrius'];
}
}