Home Reference Source Repository

src/utils/validators.js

/**
 * Checks that a given object is a plain object.
 * @param obj The object to check.
 * @returns {boolean}
 */
export function isPlainObject(obj) {
	return typeof(obj) === 'object' && obj.constructor === Object;
}

/**
 * Checks that a given object is a function.
 * @param obj The object to check.
 * @returns {boolean}
 */
export function isFunction(obj) {
	return typeof(obj) === 'function' && {}.toString.call(obj) === '[object Function]';
}

/**
 * Checks that a given object is a string.
 * @param obj The object to check.
 * @returns {boolean}
 */
export function isString(obj) {
	return typeof(obj) === 'string' && {}.toString.call(obj) === '[object String]';
}