johnny-five
Version:
The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!
30 lines (25 loc) • 479 B
JavaScript
const EventEmitter = require("events");
const wm = new WeakMap();
class Emitter extends EventEmitter {
pause() {
wm.set(this, {
...this._events
});
this._events = { __proto__: null };
}
resume() {
const events = wm.get(this);
if (events) {
this._events = {
__proto__: null,
...events
};
wm.set(this, null);
}
}
}
Object.assign(
Emitter.prototype,
EventEmitter.prototype
);
module.exports = Emitter;