Bladeren bron

fixed js performance for check type

Piotr Labudda 8 jaren geleden
bovenliggende
commit
a3deac237a
1 gewijzigde bestanden met toevoegingen van 3 en 3 verwijderingen
  1. 3 3
      SE/static/p5UI/utils.js

+ 3 - 3
SE/static/p5UI/utils.js

@@ -91,9 +91,9 @@ function p5Utils__promisify(fun) {
 // Object.prototype.toString.call({}) // "[object Object]"
 // Object.prototype.toString.call(null) // "[object Null]"
 // Object.prototype.toString.call() // "[object Undefined]"
-function p5Utils__isString(arg) { return '[object String]' === Object.prototype.toString.call(arg); }
-function p5Utils__isArray(arg) { return '[object Array]' === Object.prototype.toString.call(arg); }
-function p5Utils__isObject(arg) { return '[object Object]' === Object.prototype.toString.call(arg); }
+function p5Utils__isString(arg) { return ('string' === typeof arg); }// '[object String]' === Object.prototype.toString.call(arg); }
+function p5Utils__isArray(arg) { return (Array.isArray) ? Array.isArray(arg) : '[object Array]' === Object.prototype.toString.call(arg); }
+function p5Utils__isObject(arg) { return ('object' === typeof arg && null !== arg && 'function' === typeof arg.constructor && !p5Utils__isArray(arg)); } // '[object Object]' === Object.prototype.toString.call(arg); }
 
 global.p5Utils__format = p5Utils__format
 global.p5Utils__parseFloatOrZero = p5Utils__parseFloatOrZero