Sha256: c6b7e9f05cb9e3fd5d505710bb6083396a8ebd20dddfa846037cf20e0aa0d6e7
Contents?: true
Size: 1.06 KB
Versions: 100
Compression:
Stored size: 1.06 KB
Contents
/*! * Chai - type utility * Copyright(c) 2012-2013 Jake Luer <jake@alogicalparadox.com> * MIT Licensed */ /*! * Detectable javascript natives */ var natives = { '[object Arguments]': 'arguments' , '[object Array]': 'array' , '[object Date]': 'date' , '[object Function]': 'function' , '[object Number]': 'number' , '[object RegExp]': 'regexp' , '[object String]': 'string' }; /** * ### type(object) * * Better implementation of `typeof` detection that can * be used cross-browser. Handles the inconsistencies of * Array, `null`, and `undefined` detection. * * utils.type({}) // 'object' * utils.type(null) // `null' * utils.type(undefined) // `undefined` * utils.type([]) // `array` * * @param {Mixed} object to detect type of * @name type * @api private */ module.exports = function (obj) { var str = Object.prototype.toString.call(obj); if (natives[str]) return natives[str]; if (obj === null) return 'null'; if (obj === undefined) return 'undefined'; if (obj === Object(obj)) return 'object'; return typeof obj; };
Version data entries
100 entries across 68 versions & 1 rubygems