1 var isBuffer = require('is-buffer');
2 var toString = Object.prototype.toString;
5 * Get the native `typeof` a value.
8 * @return {*} Native javascript type
11 module.exports = function kindOf(val) {
13 if (typeof val === 'undefined') {
19 if (val === true || val === false || val instanceof Boolean) {
22 if (typeof val === 'string' || val instanceof String) {
25 if (typeof val === 'number' || val instanceof Number) {
30 if (typeof val === 'function' || val instanceof Function) {
35 if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
39 // check for instances of RegExp and Date before calling `toString`
40 if (val instanceof RegExp) {
43 if (val instanceof Date) {
48 var type = toString.call(val);
50 if (type === '[object RegExp]') {
53 if (type === '[object Date]') {
56 if (type === '[object Arguments]') {
59 if (type === '[object Error]') {
64 if (typeof Buffer !== 'undefined' && isBuffer(val)) {
68 // es6: Map, WeakMap, Set, WeakSet
69 if (type === '[object Set]') {
72 if (type === '[object WeakSet]') {
75 if (type === '[object Map]') {
78 if (type === '[object WeakMap]') {
81 if (type === '[object Symbol]') {
86 if (type === '[object Int8Array]') {
89 if (type === '[object Uint8Array]') {
92 if (type === '[object Uint8ClampedArray]') {
93 return 'uint8clampedarray';
95 if (type === '[object Int16Array]') {
98 if (type === '[object Uint16Array]') {
101 if (type === '[object Int32Array]') {
104 if (type === '[object Uint32Array]') {
105 return 'uint32array';
107 if (type === '[object Float32Array]') {
108 return 'float32array';
110 if (type === '[object Float64Array]') {
111 return 'float64array';
114 // must be a plain object