2016-05-19 13:37:19 -04:00
|
|
|
var toString = Object.prototype.toString,
|
2016-08-22 10:30:46 -04:00
|
|
|
arrayLikePattern = /^\[object (?:Array|FileList)\]$/;
|
2016-05-19 13:37:19 -04:00
|
|
|
|
|
|
|
|
// thanks, http://perfectionkills.com/instanceof-considered-harmful-or-how-to-write-a-robust-isarray/
|
|
|
|
|
export function isArray ( thing ) {
|
2016-08-22 10:30:46 -04:00
|
|
|
return toString.call( thing ) === '[object Array]';
|
2016-05-19 13:37:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isArrayLike ( obj ) {
|
2016-08-22 10:30:46 -04:00
|
|
|
return arrayLikePattern.test( toString.call( obj ) );
|
2016-05-19 13:37:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isEqual ( a, b ) {
|
2016-08-22 10:30:46 -04:00
|
|
|
if ( a === null && b === null ) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2016-05-19 13:37:19 -04:00
|
|
|
|
2016-08-22 10:30:46 -04:00
|
|
|
if ( typeof a === 'object' || typeof b === 'object' ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2016-05-19 13:37:19 -04:00
|
|
|
|
2016-08-22 10:30:46 -04:00
|
|
|
return a === b;
|
2016-05-19 13:37:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric
|
|
|
|
|
export function isNumeric ( thing ) {
|
2016-08-22 10:30:46 -04:00
|
|
|
return !isNaN( parseFloat( thing ) ) && isFinite( thing );
|
2016-05-19 13:37:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isObject ( thing ) {
|
2016-08-22 10:30:46 -04:00
|
|
|
return ( thing && toString.call( thing ) === '[object Object]' );
|
2016-05-19 13:37:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function isFunction( thing ) {
|
2016-08-22 10:30:46 -04:00
|
|
|
var getType = {};
|
|
|
|
|
return thing && getType.toString.call(thing) === '[object Function]';
|
2016-05-19 13:37:19 -04:00
|
|
|
}
|