1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-04-27 20:32:54 +02:00
TableFilter/src/types.js

82 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

2016-05-08 07:26:52 +02:00
2014-11-16 01:29:07 +01:00
/**
* Types utilities
*/
2015-05-30 14:23:33 +02:00
const UNDEFINED = void 0;
2014-11-16 01:29:07 +01:00
2016-12-21 10:54:21 +01:00
/**
* Return an empty function
* @return {Function}
*/
export const EMPTY_FN = function() {};
2016-05-15 04:56:12 +02:00
/**
* Check passed argument is an object
* @param {Object} obj
* @return {Boolean}
*/
export const isObj =
2016-12-21 10:54:21 +01:00
(obj) => Object.prototype.toString.call(obj) === '[object Object]';
2014-11-16 01:29:07 +01:00
2016-05-15 04:56:12 +02:00
/**
* Check passed argument is a function
* @param {Function} obj
* @return {Boolean}
*/
export const isFn =
2016-12-21 10:54:21 +01:00
(obj) => Object.prototype.toString.call(obj) === '[object Function]';
2014-11-16 01:29:07 +01:00
2016-05-15 04:56:12 +02:00
/**
* Check passed argument is an array
* @param {Array} obj
* @return {Boolean}
*/
export const isArray =
2016-12-21 10:54:21 +01:00
(obj) => Object.prototype.toString.call(obj) === '[object Array]';
2016-05-15 04:56:12 +02:00
/**
* Check passed argument is a string
2017-07-09 07:11:51 +02:00
* @param {String} obj obj
2016-05-15 04:56:12 +02:00
* @returns {Boolean}
*/
export const isString =
2016-12-21 10:54:21 +01:00
(obj) => Object.prototype.toString.call(obj) === '[object String]';
2016-05-15 04:56:12 +02:00
/**
* Check passed argument is a number
* @param {Number} obj
* @returns {Boolean}
*/
export const isNumber =
2016-12-21 10:54:21 +01:00
(obj) => Object.prototype.toString.call(obj) === '[object Number]';
2017-07-09 07:11:51 +02:00
/**
* Check passed argument is a boolean
* @param {Boolean} obj
* @returns {Boolean}
*/
export const isBoolean =
(obj) => Object.prototype.toString.call(obj) === '[object Boolean]';
2016-05-15 04:56:12 +02:00
/**
* Check passed argument is undefined
* @param {Any} obj
* @return {Boolean}
*/
2016-12-21 10:54:21 +01:00
export const isUndef = (obj) => obj === UNDEFINED;
2014-11-16 01:29:07 +01:00
2016-05-15 04:56:12 +02:00
/**
* Check passed argument is null
* @param {Any} obj
* @return {Boolean}
*/
2017-01-15 04:57:52 +01:00
export const isNull = (obj) => obj === null;
2015-06-14 04:44:02 +02:00
2016-05-15 04:56:12 +02:00
/**
* Check passed argument is empty (undefined, null or empty string)
* @param {Any} obj
* @return {Boolean}
*/
2016-12-21 10:54:21 +01:00
export const isEmpty = (obj) => isUndef(obj) || isNull(obj) || obj.length === 0;