Initial release!

This commit is contained in:
Wessel Tip
2019-04-22 22:15:37 +02:00
parent df1358f86e
commit 91de4c8c20
30 changed files with 1654 additions and 0 deletions

24
lib/util/type.js Normal file
View File

@@ -0,0 +1,24 @@
const symbol = require('./isSymbol');
const types = {
'string' : 0,
'symbol' : 1,
'object' : 2,
'boolean' : 3,
'function' : 4,
'array' : 5,
'float' : 6,
'integer' : 7,
'NULL' : 8,
'undefined': 9
};
module.exports = (val) => {
if (Array.isArray(val)) return types['array'];
if (symbol(val)) return types['symbol'];
if (Number(val) === val && val % 1 !== 0) return types['float'];
if (Number(val) === val && val % 1 === 0) return types['integer'];
if (types.hasOwnProperty(typeof val)) return types[typeof val];
if (val === null) return types['NULL'];
return types['undefined'];
};