js: Upgrade BANE to 0.4
This commit is contained in:
parent
126b7815d0
commit
b807c38b01
@ -3,7 +3,7 @@
|
||||
*
|
||||
* https://github.com/busterjs/bane
|
||||
*
|
||||
* @version 0.3.0
|
||||
* @version 0.4.0
|
||||
*/
|
||||
|
||||
((typeof define === "function" && define.amd && function (m) { define(m); }) ||
|
||||
@ -43,6 +43,11 @@
|
||||
return event ? object.listeners[event] : object.listeners;
|
||||
}
|
||||
|
||||
function errbacks(object) {
|
||||
if (!object.errbacks) { object.errbacks = []; }
|
||||
return object.errbacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @signature var emitter = bane.createEmitter([object]);
|
||||
*
|
||||
@ -56,7 +61,7 @@
|
||||
try {
|
||||
listener.listener.apply(listener.thisp || object, args);
|
||||
} catch (e) {
|
||||
handleError(event, e, object.errbacks || []);
|
||||
handleError(event, e, errbacks(object));
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,7 +79,24 @@
|
||||
};
|
||||
|
||||
object.off = function (event, listener) {
|
||||
var fns, i, l;
|
||||
var fns, events, i, l;
|
||||
if (!event) {
|
||||
fns = supervisors(this);
|
||||
fns.splice(0, fns.length);
|
||||
|
||||
events = listeners(this);
|
||||
for (i in events) {
|
||||
if (events.hasOwnProperty(i)) {
|
||||
fns = listeners(this, i);
|
||||
fns.splice(0, fns.length);
|
||||
}
|
||||
}
|
||||
|
||||
fns = errbacks(this);
|
||||
fns.splice(0, fns.length);
|
||||
|
||||
return;
|
||||
}
|
||||
if (typeof event === "function") {
|
||||
fns = supervisors(this);
|
||||
listener = event;
|
||||
@ -82,8 +104,8 @@
|
||||
fns = listeners(this, event);
|
||||
}
|
||||
if (!listener) {
|
||||
fns.splice(0, fns.length);
|
||||
return;
|
||||
fns.splice(0, fns.length);
|
||||
return;
|
||||
}
|
||||
for (i = 0, l = fns.length; i < l; ++i) {
|
||||
if (fns[i].listener === listener) {
|
||||
@ -123,15 +145,15 @@
|
||||
};
|
||||
|
||||
object.emit = function (event) {
|
||||
var toNotify = listeners(this, event).slice();
|
||||
var args = slice.call(arguments, 1), i, l;
|
||||
var toNotify = supervisors(this);
|
||||
var args = slice.call(arguments), i, l;
|
||||
|
||||
for (i = 0, l = toNotify.length; i < l; i++) {
|
||||
for (i = 0, l = toNotify.length; i < l; ++i) {
|
||||
notifyListener(event, toNotify[i], args);
|
||||
}
|
||||
|
||||
toNotify = supervisors(this);
|
||||
args = slice.call(arguments);
|
||||
toNotify = listeners(this, event).slice()
|
||||
args = slice.call(arguments, 1);
|
||||
for (i = 0, l = toNotify.length; i < l; ++i) {
|
||||
notifyListener(event, toNotify[i], args);
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
/*! Mopidy.js - built 2012-12-03
|
||||
/*! Mopidy.js - built 2012-12-04
|
||||
* http://www.mopidy.com/
|
||||
* Copyright (c) 2012 Stein Magnus Jodal and contributors
|
||||
* Licensed under the Apache License, Version 2.0 */
|
||||
@ -8,7 +8,7 @@
|
||||
*
|
||||
* https://github.com/busterjs/bane
|
||||
*
|
||||
* @version 0.3.0
|
||||
* @version 0.4.0
|
||||
*/
|
||||
|
||||
((typeof define === "function" && define.amd && function (m) { define(m); }) ||
|
||||
@ -48,6 +48,11 @@
|
||||
return event ? object.listeners[event] : object.listeners;
|
||||
}
|
||||
|
||||
function errbacks(object) {
|
||||
if (!object.errbacks) { object.errbacks = []; }
|
||||
return object.errbacks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @signature var emitter = bane.createEmitter([object]);
|
||||
*
|
||||
@ -61,7 +66,7 @@
|
||||
try {
|
||||
listener.listener.apply(listener.thisp || object, args);
|
||||
} catch (e) {
|
||||
handleError(event, e, object.errbacks || []);
|
||||
handleError(event, e, errbacks(object));
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,7 +84,24 @@
|
||||
};
|
||||
|
||||
object.off = function (event, listener) {
|
||||
var fns, i, l;
|
||||
var fns, events, i, l;
|
||||
if (!event) {
|
||||
fns = supervisors(this);
|
||||
fns.splice(0, fns.length);
|
||||
|
||||
events = listeners(this);
|
||||
for (i in events) {
|
||||
if (events.hasOwnProperty(i)) {
|
||||
fns = listeners(this, i);
|
||||
fns.splice(0, fns.length);
|
||||
}
|
||||
}
|
||||
|
||||
fns = errbacks(this);
|
||||
fns.splice(0, fns.length);
|
||||
|
||||
return;
|
||||
}
|
||||
if (typeof event === "function") {
|
||||
fns = supervisors(this);
|
||||
listener = event;
|
||||
@ -87,8 +109,8 @@
|
||||
fns = listeners(this, event);
|
||||
}
|
||||
if (!listener) {
|
||||
fns.splice(0, fns.length);
|
||||
return;
|
||||
fns.splice(0, fns.length);
|
||||
return;
|
||||
}
|
||||
for (i = 0, l = fns.length; i < l; ++i) {
|
||||
if (fns[i].listener === listener) {
|
||||
@ -128,15 +150,15 @@
|
||||
};
|
||||
|
||||
object.emit = function (event) {
|
||||
var toNotify = listeners(this, event).slice();
|
||||
var args = slice.call(arguments, 1), i, l;
|
||||
var toNotify = supervisors(this);
|
||||
var args = slice.call(arguments), i, l;
|
||||
|
||||
for (i = 0, l = toNotify.length; i < l; i++) {
|
||||
for (i = 0, l = toNotify.length; i < l; ++i) {
|
||||
notifyListener(event, toNotify[i], args);
|
||||
}
|
||||
|
||||
toNotify = supervisors(this);
|
||||
args = slice.call(arguments);
|
||||
toNotify = listeners(this, event).slice()
|
||||
args = slice.call(arguments, 1);
|
||||
for (i = 0, l = toNotify.length; i < l; ++i) {
|
||||
notifyListener(event, toNotify[i], args);
|
||||
}
|
||||
|
||||
4
mopidy/frontends/http/data/mopidy.min.js
vendored
4
mopidy/frontends/http/data/mopidy.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user