mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-03-17 13:13:33 +01:00
Fix silly isinstance parameter names.
This commit is contained in:
@@ -399,15 +399,15 @@ function isSubclass(targ, src) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if targ is an instance or src. If src is an array,
|
* Returns true if object is an instance or interfaces. If interfaces is an array,
|
||||||
* returns true if targ is an instance of any element of src. If src is
|
* returns true if object is an instance of any element of interfaces. If interfaces is
|
||||||
* the object form of a primitive type, returns true if targ is a
|
* the object form of a primitive type, returns true if object is a
|
||||||
* non-boxed version of the type, i.e., if (typeof targ == "string"),
|
* non-boxed version of the type, i.e., if (typeof object == "string"),
|
||||||
* isinstance(targ, String) is true. Finally, if src is a string,
|
* isinstance(object, String) is true. Finally, if interfaces is a string,
|
||||||
* returns true if ({}.toString.call(targ) == "[object <src>]").
|
* returns true if ({}.toString.call(object) == "[object <interfaces>]").
|
||||||
*
|
*
|
||||||
* @param {object} targ The object to check.
|
* @param {object} object The object to check.
|
||||||
* @param {object|string|[object|string]} src The types to check targ against.
|
* @param {object|string|[object|string]} interfaces The types to check object against.
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
var isinstance_types = {
|
var isinstance_types = {
|
||||||
@@ -416,25 +416,25 @@ var isinstance_types = {
|
|||||||
function: Function,
|
function: Function,
|
||||||
number: Number
|
number: Number
|
||||||
};
|
};
|
||||||
function isinstance(targ, src) {
|
function isinstance(object, interfaces) {
|
||||||
if (targ == null)
|
if (object == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
src = Array.concat(src);
|
interfaces = Array.concat(interfaces);
|
||||||
for (var i = 0; i < src.length; i++) {
|
for (var i = 0; i < interfaces.length; i++) {
|
||||||
if (typeof src[i] === "string") {
|
if (typeof interfaces[i] === "string") {
|
||||||
if (objproto.toString.call(targ) === "[object " + src[i] + "]")
|
if (objproto.toString.call(object) === "[object " + interfaces[i] + "]")
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if ("isinstance" in targ) {
|
else if ("isinstance" in object && object.isinstance !== isinstance) {
|
||||||
if (targ.isinstance(src[i]) && targ.isinstance !== isinstance)
|
if (object.isinstance(interfaces[i]))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (targ instanceof src[i])
|
if (object instanceof interfaces[i])
|
||||||
return true;
|
return true;
|
||||||
var type = isinstance_types[typeof targ];
|
var type = isinstance_types[typeof object];
|
||||||
if (type && isSubclass(src[i], type))
|
if (type && isSubclass(interfaces[i], type))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user