Sha256: 6e660d3accc4fe2f9cdd84ba17de0a4c8488b754a2e563f410039c3760a5e18f

Contents?: true

Size: 959 Bytes

Versions: 19

Compression:

Stored size: 959 Bytes

Contents

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();
};

Version data entries

19 entries across 16 versions & 3 rubygems

Version Path
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/randomatic/node_modules/kind-of/index.js
es6_tilt-0.1.2 test/dummy/app/assets/javascripts/node_modules/micromatch/node_modules/kind-of/index.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/randomatic/node_modules/kind-of/index.js
es6_tilt-0.1.1 test/dummy/app/assets/javascripts/node_modules/micromatch/node_modules/kind-of/index.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/randomatic/node_modules/kind-of/index.js
es6_tilt-0.1.0 test/dummy/app/assets/javascripts/node_modules/micromatch/node_modules/kind-of/index.js
hooch-0.4.2 jasmine/node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
gulp_assets-1.0.0.pre.5 template/node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
gulp_assets-1.0.0.pre.4 template/node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
gulp_assets-1.0.0.pre.3 template/node_modules/webpack/node_modules/watchpack/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/chokidar/node_modules/anymatch/node_modules/micromatch/node_modules/kind-of/index.js