提交 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[] { ...@@ -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 { export function isObject(obj: any): obj is any {
return typeof obj === 'object'
// Needed for IE8 && obj !== null
if (typeof obj === 'undefined' || obj === null) { && !Array.isArray(obj)
return false; && !(obj instanceof RegExp)
} && !(obj instanceof Date);
return Object.prototype.toString.call(obj) === '[object Object]';
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册