提交 409a875c 编写于 作者: J Johannes Rieken

perf - shave off ~4ms from startup by using a better isObject-implementation

上级 1ef6a709
......@@ -40,16 +40,16 @@ export function isStringArray(value: any): value is string[] {
}
/**
* @returns whether the provided parameter is a JavaScript Object or not.
*
* @returns whether the provided parameter is of type `object` but **not**
* `null`, an `array`, a `regexp`, nor a `date`.
*/
export function isObject(obj: any): obj is any {
// Needed for IE8
if (typeof obj === 'undefined' || obj === null) {
return false;
}
return Object.prototype.toString.call(obj) === '[object Object]';
return typeof obj === 'object'
&& obj !== null
&& !Array.isArray(obj)
&& !(obj instanceof RegExp)
&& !(obj instanceof Date);
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册