|
|
@@ -2,22 +2,22 @@
|
|
|
|
|
|
// these helpers produces better vm code in JS engines due to their
|
|
|
// explicitness and function inlining
|
|
|
-export function isUndef (v: any): boolean {
|
|
|
+export function isUndef (v: any): boolean %checks {
|
|
|
return v === undefined || v === null
|
|
|
}
|
|
|
|
|
|
-export function isDef (v: any) /* : %checks */ {
|
|
|
+export function isDef (v: any): boolean %checks {
|
|
|
return v !== undefined && v !== null
|
|
|
}
|
|
|
|
|
|
-export function isTrue (v: any): boolean {
|
|
|
+export function isTrue (v: any): boolean %checks {
|
|
|
return v === true
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Check if value is primitive
|
|
|
*/
|
|
|
-export function isPrimitive (value: any): boolean {
|
|
|
+export function isPrimitive (value: any): boolean %checks {
|
|
|
return typeof value === 'string' || typeof value === 'number'
|
|
|
}
|
|
|
|
|
|
@@ -26,28 +26,28 @@ export function isPrimitive (value: any): boolean {
|
|
|
* Objects from primitive values when we know the value
|
|
|
* is a JSON-compliant type.
|
|
|
*/
|
|
|
-export function isObject (obj: mixed): boolean {
|
|
|
+export function isObject (obj: mixed): boolean %checks {
|
|
|
return obj !== null && typeof obj === 'object'
|
|
|
}
|
|
|
|
|
|
-const toString = Object.prototype.toString
|
|
|
+const _toString = Object.prototype.toString
|
|
|
|
|
|
/**
|
|
|
* Strict object type check. Only returns true
|
|
|
* for plain JavaScript objects.
|
|
|
*/
|
|
|
export function isPlainObject (obj: any): boolean {
|
|
|
- return toString.call(obj) === '[object Object]'
|
|
|
+ return _toString.call(obj) === '[object Object]'
|
|
|
}
|
|
|
|
|
|
export function isRegExp (v: any): boolean {
|
|
|
- return toString.call(v) === '[object RegExp]'
|
|
|
+ return _toString.call(v) === '[object RegExp]'
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Convert a value to a string that is actually rendered.
|
|
|
*/
|
|
|
-export function _toString (val: any): string {
|
|
|
+export function toString (val: any): string {
|
|
|
return val == null
|
|
|
? ''
|
|
|
: typeof val === 'object'
|