mirror of
https://gitlab.com/mfocko/CodeWars.git
synced 2024-11-09 11:09:07 +01:00
24 lines
472 B
JavaScript
24 lines
472 B
JavaScript
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'];
|
|
}
|
|
}
|