This app provides monitoring and information features for the common freifunk user and the technical stuff of a freifunk community.
Code base is taken from a TUM Practical Course project and added here to see if Freifunk Altdorf can use it.
https://www.freifunk-altdorf.de
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
959 B
46 lines
959 B
6 years ago
|
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();
|
||
|
};
|