Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Cleanup `isHostType` and update vendor/platform.

  • Loading branch information...
commit 6e07ee774765fd1821ca9878c1e48f8a76b91d03 1 parent 3e5cea2
@jdalton jdalton authored
Showing with 10 additions and 5 deletions.
  1. +9 −4 benchmark.js
  2. +1 −1  vendor/platform.js/platform.js
View
13 benchmark.js
@@ -30,6 +30,9 @@
/** Used to assign each benchmark an incrimented id */
var counter = 0;
+ /** Used to detect primitive types */
+ var rePrimitive = /^(?:boolean|number|string|undefined)$/;
+
/** Used to assign default `context` object properties */
var contextProps = [
'Array', 'Date', 'Function', 'Math', 'Object', 'RegExp', 'String', '_',
@@ -613,7 +616,7 @@
/**
* Host objects can return type values that are different from their actual
* data type. The objects we are concerned with usually return non-primitive
- * types of object, function, or unknown.
+ * types of "object", "function", or "unknown".
*
* @private
* @param {Mixed} object The owner of the property.
@@ -621,9 +624,11 @@
* @returns {Boolean} Returns `true` if the property value is a non-primitive, else `false`.
*/
function isHostType(object, property) {
- var type = object != null ? typeof object[property] : 'number';
- return !/^(?:boolean|number|string|undefined)$/.test(type) &&
- (type == 'object' ? !!object[property] : true);
+ if (object == null) {
+ return false;
+ }
+ var type = typeof object[property];
+ return !rePrimitive.test(type) && (type != 'object' || !!object[property]);
}
/**
View
2  vendor/platform.js/platform.js
@@ -20,7 +20,7 @@
var reOpera = /Opera/;
/** Used to resolve a value's internal [[Class]] */
- var toString = {}.toString;
+ var toString = Object.prototype.toString;
/** Detect Java environment */
var java = /Java/.test(getClassOf(window.java)) && window.java;
Please sign in to comment.
Something went wrong with that request. Please try again.