mirror of
https://github.com/Tonejs/Tone.js
synced 2024-11-16 08:38:00 +00:00
using only static type queries
This commit is contained in:
parent
edfa168713
commit
4bd1044cb4
5 changed files with 12 additions and 78 deletions
|
@ -98,7 +98,7 @@ function(Tone){
|
|||
* @type {boolean}
|
||||
* @private
|
||||
*/
|
||||
Tone.Panner.prototype._hasStereoPanner = Tone.prototype.isFunction(Tone.context.createStereoPanner);
|
||||
Tone.Panner.prototype._hasStereoPanner = Tone.isFunction(Tone.context.createStereoPanner);
|
||||
|
||||
/**
|
||||
* Clean up.
|
||||
|
|
|
@ -380,7 +380,7 @@ define(["Tone/core/Tone", "Tone/core/Emitter", "Tone/core/Timeline"], function (
|
|||
function toneConnect(B, outNum, inNum){
|
||||
if (B.input){
|
||||
if (Array.isArray(B.input)){
|
||||
if (Tone.prototype.isUndef(inNum)){
|
||||
if (Tone.isUndef(inNum)){
|
||||
inNum = 0;
|
||||
}
|
||||
this.connect(B.input[inNum]);
|
||||
|
@ -403,7 +403,7 @@ define(["Tone/core/Tone", "Tone/core/Emitter", "Tone/core/Timeline"], function (
|
|||
//replace the old disconnect method
|
||||
function toneDisconnect(B, outNum, inNum){
|
||||
if (B && B.input && Array.isArray(B.input)){
|
||||
if (Tone.prototype.isUndef(inNum)){
|
||||
if (Tone.isUndef(inNum)){
|
||||
inNum = 0;
|
||||
}
|
||||
this.disconnect(B.input[inNum], outNum, inNum);
|
||||
|
|
|
@ -56,7 +56,7 @@ define(["Tone/core/Tone"], function (Tone) {
|
|||
for (var ev = 0; ev < events.length; ev++){
|
||||
event = events[ev];
|
||||
if (this._events.hasOwnProperty(event)){
|
||||
if (Tone.prototype.isUndef(callback)){
|
||||
if (Tone.isUndef(callback)){
|
||||
this._events[event] = [];
|
||||
} else {
|
||||
var eventList = this._events[event];
|
||||
|
|
|
@ -463,78 +463,6 @@ define(function(){
|
|||
// TYPE CHECKING
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* test if the arg is undefined
|
||||
* @param {*} arg the argument to test
|
||||
* @returns {boolean} true if the arg is undefined
|
||||
* @function
|
||||
*/
|
||||
Tone.prototype.isUndef = function(val){
|
||||
return typeof val === "undefined";
|
||||
};
|
||||
|
||||
/**
|
||||
* test if the arg is a function
|
||||
* @param {*} arg the argument to test
|
||||
* @returns {boolean} true if the arg is a function
|
||||
* @function
|
||||
*/
|
||||
Tone.prototype.isFunction = function(val){
|
||||
return typeof val === "function";
|
||||
};
|
||||
|
||||
/**
|
||||
* Test if the argument is a number.
|
||||
* @param {*} arg the argument to test
|
||||
* @returns {boolean} true if the arg is a number
|
||||
*/
|
||||
Tone.prototype.isNumber = function(arg){
|
||||
return (typeof arg === "number");
|
||||
};
|
||||
|
||||
/**
|
||||
* Test if the given argument is an object literal (i.e. `{}`);
|
||||
* @param {*} arg the argument to test
|
||||
* @returns {boolean} true if the arg is an object literal.
|
||||
*/
|
||||
Tone.prototype.isObject = function(arg){
|
||||
return (Object.prototype.toString.call(arg) === "[object Object]" && arg.constructor === Object);
|
||||
};
|
||||
|
||||
/**
|
||||
* Test if the argument is a boolean.
|
||||
* @param {*} arg the argument to test
|
||||
* @returns {boolean} true if the arg is a boolean
|
||||
*/
|
||||
Tone.prototype.isBoolean = function(arg){
|
||||
return (typeof arg === "boolean");
|
||||
};
|
||||
|
||||
/**
|
||||
* Test if the argument is an Array
|
||||
* @param {*} arg the argument to test
|
||||
* @returns {boolean} true if the arg is an array
|
||||
*/
|
||||
Tone.prototype.isArray = function(arg){
|
||||
return (Array.isArray(arg));
|
||||
};
|
||||
|
||||
/**
|
||||
* Test if the argument is a string.
|
||||
* @param {*} arg the argument to test
|
||||
* @returns {boolean} true if the arg is a string
|
||||
*/
|
||||
Tone.prototype.isString = function(arg){
|
||||
return (typeof arg === "string");
|
||||
};
|
||||
|
||||
/**
|
||||
* An empty function.
|
||||
* @static
|
||||
*/
|
||||
Tone.noOp = function(){};
|
||||
|
||||
|
||||
/**
|
||||
* test if the arg is undefined
|
||||
* @param {*} arg the argument to test
|
||||
|
@ -600,6 +528,12 @@ define(function(){
|
|||
return (typeof arg === "string");
|
||||
};
|
||||
|
||||
/**
|
||||
* An empty function.
|
||||
* @static
|
||||
*/
|
||||
Tone.noOp = function(){};
|
||||
|
||||
/**
|
||||
* Make the property not writable. Internal use only.
|
||||
* @private
|
||||
|
@ -729,7 +663,7 @@ define(function(){
|
|||
* will inherit from Tone
|
||||
*/
|
||||
Tone.extend = function(child, parent){
|
||||
if (Tone.prototype.isUndef(parent)){
|
||||
if (Tone.isUndef(parent)){
|
||||
parent = Tone;
|
||||
}
|
||||
function TempConstructor(){}
|
||||
|
|
|
@ -275,7 +275,7 @@ define(["Tone/core/Tone", "Tone/component/Volume"], function(Tone){
|
|||
*/
|
||||
Object.defineProperty(Tone.UserMedia, "supported", {
|
||||
get : function(){
|
||||
return !Tone.prototype.isUndef(navigator.mediaDevices) && Tone.prototype.isFunction(navigator.mediaDevices.getUserMedia);
|
||||
return !Tone.isUndef(navigator.mediaDevices) && Tone.isFunction(navigator.mediaDevices.getUserMedia);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue