js: Make 'Mopidy()' work without 'new'
This commit is contained in:
parent
3ee8485d7e
commit
a032e45c35
@ -1,6 +1,10 @@
|
||||
/*global bane:false, when:false*/
|
||||
|
||||
function Mopidy(settings) {
|
||||
if (!(this instanceof Mopidy)) {
|
||||
return new Mopidy(settings);
|
||||
}
|
||||
|
||||
this._settings = this._configure(settings || {});
|
||||
this._console = this._getConsole();
|
||||
|
||||
|
||||
@ -48,6 +48,15 @@ buster.testCase("Mopidy", {
|
||||
new Mopidy({webSocket: {}});
|
||||
|
||||
refute.called(this.webSocketConstructorStub);
|
||||
},
|
||||
|
||||
"works without 'new' keyword": function () {
|
||||
var mopidyConstructor = Mopidy; // To trick jshint into submission
|
||||
|
||||
var mopidy = mopidyConstructor({webSocket: {}});
|
||||
|
||||
assert.isObject(mopidy);
|
||||
assert(mopidy instanceof Mopidy);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
/*! Mopidy.js - built 2012-12-04
|
||||
/*! Mopidy.js - built 2013-01-16
|
||||
* http://www.mopidy.com/
|
||||
* Copyright (c) 2012 Stein Magnus Jodal and contributors
|
||||
* Copyright (c) 2013 Stein Magnus Jodal and contributors
|
||||
* Licensed under the Apache License, Version 2.0 */
|
||||
|
||||
/**
|
||||
@ -910,6 +910,10 @@ define(['module'], function () {
|
||||
/*global bane:false, when:false*/
|
||||
|
||||
function Mopidy(settings) {
|
||||
if (!(this instanceof Mopidy)) {
|
||||
return new Mopidy(settings);
|
||||
}
|
||||
|
||||
this._settings = this._configure(settings || {});
|
||||
this._console = this._getConsole();
|
||||
|
||||
|
||||
6
mopidy/frontends/http/data/mopidy.min.js
vendored
6
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