Upsilon-VsCode/Client/node_modules/kind-of/index.js

46 lines
959 B
JavaScript
Raw Normal View History

2019-02-17 17:07:28 +00:00
var toString = Object.prototype.toString;
/**
* Get the native `typeof` a value.
*
* @param {*} `val`
* @return {*} Native javascript type
*/
module.exports = function kindOf(val) {
if (val === undefined) {
return 'undefined';
}
if (val === null) {
return 'null';
}
if (val === true || val === false || val instanceof Boolean) {
return 'boolean';
}
if (typeof val !== 'object') {
return typeof val;
}
if (Array.isArray(val)) {
return 'array';
}
var type = toString.call(val);
if (val instanceof RegExp || type === '[object RegExp]') {
return 'regexp';
}
if (val instanceof Date || type === '[object Date]') {
return 'date';
}
if (type === '[object Function]') {
return 'function';
}
if (type === '[object Arguments]') {
return 'arguments';
}
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(val)) {
return 'buffer';
}
return type.slice(8, -1).toLowerCase();
};