const EventEmitter = require('eventemitter2').EventEmitter2;

function filter(v, min, max) {
    v = Math.min(v, max);
    v = Math.max(v, min);
    return v;
}

class MagicPoint extends EventEmitter {
    constructor(current, max) {
        this.max = max;
        this.min = 0;
        this.current = filter(current, 0, this.max);
    };

    change(next) {
        this.current = filter(next, 0, this.max);
        this.emit("changed", {
            next: this
        });
        return this;
    }
}

module.exports = MagicPoint;

const EventEmitter = require('eventemitter2').EventEmitter2;

function filter(v, min, max) {
    v = Math.min(v, max);
    v = Math.max(v, min);
    return v;
}

class MagicPoint extends EventEmitter {
    constructor(current, max) {
        super();
        this.max = max;
        this.min = 0;
        this.current = filter(current, 0, this.max);
    };

    change(next) {
        this.current = filter(next, 0, this.max);
        this.emit("changed", {
            next: this
        });
        return this;
    }
}

module.exports = MagicPoint;

Add super to constructor of magic point
[FIX] Add super to constructor of magic point
