1
0
Fork 0
mirror of https://gitlab.com/mfocko/CodeWars.git synced 2024-11-22 00:23:47 +01:00
CodeWars/4kyu/priori_incantatem/solution.js
Matej Focko fc899b0b02
chore: initial commit
Signed-off-by: Matej Focko <mfocko@redhat.com>
2021-12-28 16:19:58 +01:00

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'];
}
}