diff --git a/javascript/JZZ.js b/javascript/JZZ.js index 73f2c4b..2e78ce4 100644 --- a/javascript/JZZ.js +++ b/javascript/JZZ.js @@ -631,13 +631,13 @@ this._pause(); document.addEventListener('jazz-midi-msg', eventHandle); try { document.dispatchEvent(new Event('jazz-midi')); } catch (err) {} - setTimeout(function() { if (!inst) self._crash(); }, 0); + _schedule(function() { if (!inst) self._crash(); }); } function _zeroBreak() { this._pause(); var self = this; - setTimeout(function() { self._crash(); }, 0); + _schedule(function() { self._crash(); }); } function _filterEngines(opt) { @@ -979,12 +979,12 @@ _engine._watch = function() { _engine._access.onstatechange = function() { watcher = true; - setTimeout(function() { + _schedule(function() { if (watcher) { _engine._refresh(); watcher = false; } - }, 0); + }); }; }; _engine._unwatch = function() { @@ -1016,9 +1016,9 @@ _engine._refresh = function(client) { _engine.refreshClients.push(client); client._pause(); - setTimeout(function() { + _schedule(function() { document.dispatchEvent(new CustomEvent('jazz-midi', { detail: ['refresh'] })); - }, 0); + }); }; function _closeAll() { for (var i = 0; i < this.clients.length; i++) this._close(this.clients[i]); diff --git a/package.json b/package.json index 784870f..6132771 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ }, "devDependencies": { "coveralls": "^3.0.6", - "eslint": "^6.2.1", + "eslint": "^6.2.2", "grunt": "^1.0.4", "grunt-contrib-jshint": "^2.1.0", "grunt-contrib-uglify": "^4.0.1", diff --git a/test/tests.js b/test/tests.js index d1e1112..d34935d 100644 --- a/test/tests.js +++ b/test/tests.js @@ -114,7 +114,7 @@ module.exports = function(JZZ, PARAMS, DRIVER) { JZZ.lib.registerMidiOut('Widget MIDI-Out', widget2); // should ignore second call port2 = engine.openMidiOut('Widget MIDI-Out'); port2.connect(port1); - port2.and(function() { assert.equal(this.connected(), 1); this.noteOn(0, 60); }); + port2.and(function() { assert.equal(this.connected(), 1); this.send([]); this.noteOn(0, 60); }); }); }, @@ -158,7 +158,7 @@ module.exports = function(JZZ, PARAMS, DRIVER) { }; port1 = engine.openMidiOut(name1); port2 = engine.openMidiOut(name2); - port2.and(function() { this.noteOn(0, 60, 127); }); + port2.and(function() { this.send([]); this.noteOn(0, 60, 127); }); }); },