[Pkg-javascript-commits] [node-kind-of] 01/06: New upstream version 6.0.1+dfsg

Julien Puydt julien.puydt at laposte.net
Sat Nov 25 09:39:13 UTC 2017


This is an automated email from the git hooks/post-receive script.

jpuydt-guest pushed a commit to branch master
in repository node-kind-of.

commit 09cfd17e845dfb55ad759e3a36b5491cf94362d0
Author: Julien Puydt <julien.puydt at laposte.net>
Date:   Sat Nov 25 10:29:27 2017 +0100

    New upstream version 6.0.1+dfsg
---
 .editorconfig                                      |   9 +-
 .eslintrc.json                                     |   5 -
 .gitignore                                         |  71 ++---
 .travis.yml                                        |  10 +-
 .verb.md                                           |  83 ++++--
 CHANGELOG.md                                       | 157 +++++++++++
 LICENSE                                            |   2 +-
 README.md                                          | 297 ++++++++++++++-------
 benchmark/check.js                                 |  22 --
 benchmark/code/current.js                          |   1 -
 benchmark/code/kind-of.js                          |   8 +
 benchmark/code/lib-type-of.js                      |  44 ++-
 benchmark/code/lib-typeof.js                       |  23 +-
 benchmark/code/slice-switch.js                     |   8 +-
 benchmark/code/switch.js                           | 116 ++++++++
 benchmark/fixtures/arguments.js                    |   2 +-
 benchmark/fixtures/buffer.js                       |   2 +-
 benchmark/fixtures/error.js                        |   1 +
 .../fixtures/{object.js => object-instance.js}     |   0
 benchmark/fixtures/object-plain.js                 |   2 +
 benchmark/fixtures/{undef.js => undefined.js}      |   0
 benchmark/index.js                                 |  20 +-
 benchmark/last.md                                  |  49 ----
 benchmark/stats.md                                 | 104 ++++++++
 bower.json                                         |  44 ++-
 index.js                                           | 208 ++++++++-------
 package.json                                       |  48 ++--
 test/es6/index.js                                  |  50 +++-
 test/test.js                                       |  26 +-
 29 files changed, 1003 insertions(+), 409 deletions(-)

diff --git a/.editorconfig b/.editorconfig
index 818e072..449f0da 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -1,13 +1,14 @@
+# http://editorconfig.org/
 root = true
 
 [*]
-indent_style = space
-end_of_line = lf
 charset = utf-8
+end_of_line = lf
 indent_size = 2
-trim_trailing_whitespace = true
+indent_style = space
 insert_final_newline = true
+trim_trailing_whitespace = true
 
 [{**/{actual,fixtures,expected,templates}/**,*.md}]
 trim_trailing_whitespace = false
-insert_final_newline = false
\ No newline at end of file
+insert_final_newline = false
diff --git a/.eslintrc.json b/.eslintrc.json
index 948dbdb..61e8895 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -1,9 +1,4 @@
 {
-  "ecmaFeatures": {
-    "modules": true,
-    "experimentalObjectRestSpread": true
-  },
-
   "env": {
     "browser": false,
     "es6": true,
diff --git a/.gitignore b/.gitignore
index 096c55d..4bf0a60 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,52 +1,29 @@
-# Numerous always-ignore extensions
-*.csv
-*.dat
-*.diff
-*.err
-*.gz
-*.log
-*.orig
-*.out
-*.pid
-*.rar
-*.rej
-*.seed
-*.swo
-*.swp
-*.vi
-*.yo-rc.json
-*.zip
-*~
-.ruby-version
-lib-cov
-npm-debug.log
+# always ignore files
+*.DS_Store
+.idea
+*.sublime-*
 
-# Always-ignore dirs
-/bower_components/
-/node_modules/
-/temp/
-/tmp/
-/vendor/
-_gh_pages
+# test related, or directories generated by tests
+test/actual
+actual
+coverage
+.nyc*
 
-# OS or Editor folders
-*.esproj
-*.komodoproject
-.komodotools
-*.sublime-*
-._*
-.cache
-.DS_Store
-.idea
-.project
-.settings
-.tmproj
-nbproject
-Thumbs.db
+# npm
+node_modules
+npm-debug.log
 
-# grunt-html-validation
-validation-status.json
-validation-report.json
+# yarn
+yarn.lock
+yarn-error.log
 
 # misc
-TODO.md
\ No newline at end of file
+_gh_pages
+_draft
+_drafts
+bower_components
+vendor
+temp
+tmp
+TODO.md
+package-lock.json
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index 3932eaa..0ba64a2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,14 +1,18 @@
 sudo: false
+os:
+  - linux
+  - osx
 language: node_js
 node_js:
+  - node
+  - '8'
+  - '7'
   - '6'
   - '5'
   - '4'
   - '0.12'
   - '0.10'
 matrix:
-  fast_finish: true
   allow_failures:
-    - node_js: '4'
-    - node_js: '0.10'
     - node_js: '0.12'
+    - node_js: '0.10'
diff --git a/.verb.md b/.verb.md
index 376b40c..d09e1be 100644
--- a/.verb.md
+++ b/.verb.md
@@ -1,9 +1,13 @@
-## Install
-
 {%= include("install-bower", {save: true}) %}
 
+## Why use this?
+
+1. [it's fast](#benchmarks) | [optimizations](#optimizations)
+1. [better type checking](#better-type-checking)
+
+
 ## Usage
-> es5, browser and es6 ready
+> es5, es6, and browser ready
 
 ```js
 var kindOf = require('{%= name %}');
@@ -20,24 +24,15 @@ kindOf(true);
 kindOf(false);
 //=> 'boolean'
 
-kindOf(new Boolean(true));
-//=> 'boolean'
-
 kindOf(new Buffer(''));
 //=> 'buffer'
 
 kindOf(42);
 //=> 'number'
 
-kindOf(new Number(42));
-//=> 'number'
-
 kindOf('str');
 //=> 'string'
 
-kindOf(new String('str'));
-//=> 'string'
-
 kindOf(arguments);
 //=> 'arguments'
 
@@ -53,15 +48,9 @@ kindOf(new Test());
 kindOf(new Date());
 //=> 'date'
 
-kindOf([]);
-//=> 'array'
-
 kindOf([1, 2, 3]);
 //=> 'array'
 
-kindOf(new Array());
-//=> 'array'
-
 kindOf(/foo/);
 //=> 'regexp'
 
@@ -72,10 +61,10 @@ kindOf(function () {});
 //=> 'function'
 
 kindOf(function * () {});
-//=> 'function'
+//=> 'generatorfunction'
 
-kindOf(new Function());
-//=> 'function'
+kindOf(Symbol('str'));
+//=> 'symbol'
 
 kindOf(new Map());
 //=> 'map'
@@ -89,9 +78,6 @@ kindOf(new Set());
 kindOf(new WeakSet());
 //=> 'weakset'
 
-kindOf(Symbol('str'));
-//=> 'symbol'
-
 kindOf(new Int8Array());
 //=> 'int8array'
 
@@ -123,10 +109,9 @@ kindOf(new Float64Array());
 ## Benchmarks
 
 Benchmarked against [typeof](http://github.com/CodingFu/typeof) and [type-of](https://github.com/ForbesLindesay/type-of).
-Note that performaces is slower for es6 features `Map`, `WeakMap`, `Set` and `WeakSet`.
 
 ```bash
-{%= docs("benchmark/last.md") %}
+{%= include("benchmark/stats.md") %}
 ```
 
 ## Optimizations
@@ -136,3 +121,49 @@ In 7 out of 8 cases, this library is 2x-10x faster than other top libraries incl
 1. Optimize around the fastest and most common use cases first. Of course, this will change from project-to-project, but I took some time to understand how and why `typeof` checks were being used in my own libraries and other libraries I use a lot.
 1. Optimize around bottlenecks - In other words, the order in which conditionals are implemented is significant, because each check is only as fast as the failing checks that came before it. Here, the biggest bottleneck by far is checking for plain objects (an object that was created by the `Object` constructor). I opted to make this check happen by process of elimination rather than brute force up front (e.g. by using something like `val.constructor.name`), so that every other type chec [...]
 1. Don't do uneccessary processing - why do `.slice(8, -1).toLowerCase();` just to get the word `regex`? It's much faster to do `if (type === '[object RegExp]') return 'regex'`
+1. There is no reason to make the code in a microlib as terse as possible, just to win points for making it shorter. It's always better to favor performant code over terse code. You will always only be using a single `require()` statement to use the library anyway, regardless of how the code is written.
+
+
+## Better type checking
+
+kind-of seems to be more consistently "correct" than other type checking libs I've looked at. For example, here are some differing results from other popular libs:
+
+### [typeof][] lib
+
+Incorrectly identifies instances of custom constructors (pretty common):
+
+```js
+var typeOf = require('typeof');
+function Test() {}
+console.log(typeOf(new Test()));
+//=> 'test'
+```
+
+Returns `object` instead of `arguments`:
+
+```js
+function foo() {
+  console.log(typeOf(arguments)) //=> 'object'
+}
+foo();
+```
+
+### [type-of][] lib
+
+Incorrectly returns `object` for generator functions, buffers, `Map`, `Set`, `WeakMap` and `WeakSet`:
+
+```js
+function * foo() {}
+console.log(typeOf(foo));
+//=> 'object'
+console.log(typeOf(new Buffer('')));
+//=> 'object'
+console.log(typeOf(new Map()));
+//=> 'object'
+console.log(typeOf(new Set()));
+//=> 'object'
+console.log(typeOf(new WeakMap()));
+//=> 'object'
+console.log(typeOf(new WeakSet()));
+//=> 'object'
+```
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..fb30b06
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,157 @@
+# Release history
+
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
+and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
+
+<details>
+  <summary><strong>Guiding Principles</strong></summary>
+
+- Changelogs are for humans, not machines.
+- There should be an entry for every single version.
+- The same types of changes should be grouped.
+- Versions and sections should be linkable.
+- The latest version comes first.
+- The release date of each versions is displayed.
+- Mention whether you follow Semantic Versioning.
+
+</details>
+
+<details>
+  <summary><strong>Types of changes</strong></summary>
+
+Changelog entries are classified using the following labels _(from [keep-a-changelog](http://keepachangelog.com/)_):
+
+- `Added` for new features.
+- `Changed` for changes in existing functionality.
+- `Deprecated` for soon-to-be removed features.
+- `Removed` for now removed features.
+- `Fixed` for any bug fixes.
+- `Security` in case of vulnerabilities.
+
+</details>
+
+## [6.0.0] - 2017-10-13
+
+- refactor code to be more performant
+- refactor benchmarks
+
+## [5.1.0] - 2017-10-13
+
+**Added**
+
+- Merge pull request #15 from aretecode/patch-1
+- adds support and tests for string & array iterators
+
+**Changed**
+
+- updates benchmarks
+
+## [5.0.2] - 2017-08-02
+
+- Merge pull request #14 from struct78/master
+- Added `undefined` check
+
+## [5.0.0] - 2017-06-21
+
+- Merge pull request #12 from aretecode/iterator
+- Set Iterator + Map Iterator
+- streamline `isbuffer`, minor edits
+
+## [4.0.0] - 2017-05-19
+
+- Merge pull request #8 from tunnckoCore/master
+- update deps
+
+## [3.2.2] - 2017-05-16
+
+- fix version
+
+## [3.2.1] - 2017-05-16
+
+- add browserify
+
+## [3.2.0] - 2017-04-25
+
+- Merge pull request #10 from ksheedlo/unrequire-buffer
+- add `promise` support and tests
+- Remove unnecessary `Buffer` check
+
+## [3.1.0] - 2016-12-07
+
+- Merge pull request #7 from laggingreflex/err
+- add support for `error` and tests
+- run update
+
+## [3.0.4] - 2016-07-29
+
+- move tests
+- run update
+
+## [3.0.3] - 2016-05-03
+
+- fix prepublish script
+- remove unused dep
+
+## [3.0.0] - 2015-11-17
+
+- add typed array support
+- Merge pull request #5 from miguelmota/typed-arrays
+- adds new tests
+
+## [2.0.1] - 2015-08-21
+
+- use `is-buffer` module
+
+## [2.0.0] - 2015-05-31
+
+- Create fallback for `Array.isArray` if used as a browser package
+- Merge pull request #2 from dtothefp/patch-1
+- Merge pull request #3 from pdehaan/patch-1
+- Merge branch 'master' of https://github.com/chorks/kind-of into chorks-master
+- optimizations, mostly date and regex
+
+## [1.1.0] - 2015-02-09
+
+- adds `buffer` support
+- adds tests for `buffer`
+
+## [1.0.0] - 2015-01-19
+
+- update benchmarks
+- optimizations based on benchmarks
+
+## [0.1.2] - 2014-10-26
+
+- return `typeof` value if it's not an object. very slight speed improvement
+- use `.slice`
+- adds benchmarks
+
+## [0.1.0] - 2014-9-26
+
+- first commit
+
+[6.0.0]: https://github.com/jonschlinkert/kind-of/compare/5.1.0...6.0.0
+[5.1.0]: https://github.com/jonschlinkert/kind-of/compare/5.0.2...5.1.0
+[5.0.2]: https://github.com/jonschlinkert/kind-of/compare/5.0.1...5.0.2
+[5.0.1]: https://github.com/jonschlinkert/kind-of/compare/5.0.0...5.0.1
+[5.0.0]: https://github.com/jonschlinkert/kind-of/compare/4.0.0...5.0.0
+[4.0.0]: https://github.com/jonschlinkert/kind-of/compare/3.2.2...4.0.0
+[3.2.2]: https://github.com/jonschlinkert/kind-of/compare/3.2.1...3.2.2
+[3.2.1]: https://github.com/jonschlinkert/kind-of/compare/3.2.0...3.2.1
+[3.2.0]: https://github.com/jonschlinkert/kind-of/compare/3.1.0...3.2.0
+[3.1.0]: https://github.com/jonschlinkert/kind-of/compare/3.0.4...3.1.0
+[3.0.4]: https://github.com/jonschlinkert/kind-of/compare/3.0.3...3.0.4
+[3.0.3]: https://github.com/jonschlinkert/kind-of/compare/3.0.0...3.0.3
+[3.0.0]: https://github.com/jonschlinkert/kind-of/compare/2.0.1...3.0.0
+[2.0.1]: https://github.com/jonschlinkert/kind-of/compare/2.0.0...2.0.1
+[2.0.0]: https://github.com/jonschlinkert/kind-of/compare/1.1.0...2.0.0
+[1.1.0]: https://github.com/jonschlinkert/kind-of/compare/1.0.0...1.1.0
+[1.0.0]: https://github.com/jonschlinkert/kind-of/compare/0.1.2...1.0.0
+[0.1.2]: https://github.com/jonschlinkert/kind-of/compare/0.1.0...0.1.2
+[0.1.0]: https://github.com/jonschlinkert/kind-of/commit/2fae09b0b19b1aadb558e9be39f0c3ef6034eb87
+
+[Unreleased]: https://github.com/jonschlinkert/kind-of/compare/0.1.2...HEAD
+[keep-a-changelog]: https://github.com/olivierlacan/keep-a-changelog
+
diff --git a/LICENSE b/LICENSE
index 39245ac..3f2eca1 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 The MIT License (MIT)
 
-Copyright (c) 2014-2016, Jon Schlinkert.
+Copyright (c) 2014-2017, Jon Schlinkert.
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/README.md b/README.md
index 4ac4f18..885ff86 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
-# kind-of [![NPM version](https://img.shields.io/npm/v/kind-of.svg?style=flat)](https://www.npmjs.com/package/kind-of) [![NPM downloads](https://img.shields.io/npm/dm/kind-of.svg?style=flat)](https://npmjs.org/package/kind-of) [![Build Status](https://img.shields.io/travis/jonschlinkert/kind-of.svg?style=flat)](https://travis-ci.org/jonschlinkert/kind-of)
+# kind-of [![NPM version](https://img.shields.io/npm/v/kind-of.svg?style=flat)](https://www.npmjs.com/package/kind-of) [![NPM monthly downloads](https://img.shields.io/npm/dm/kind-of.svg?style=flat)](https://npmjs.org/package/kind-of) [![NPM total downloads](https://img.shields.io/npm/dt/kind-of.svg?style=flat)](https://npmjs.org/package/kind-of) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/kind-of.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/kind-of)
 
-Get the native type of a value.
+> Get the native type of a value.
+
+Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
 
 ## Install
 
@@ -10,15 +12,20 @@ Install with [npm](https://www.npmjs.com/):
 $ npm install --save kind-of
 ```
 
-Install with [bower](http://bower.io/)
+Install with [bower](https://bower.io/)
 
 ```sh
 $ bower install kind-of --save
 ```
 
+## Why use this?
+
+1. [it's fast](#benchmarks) | [optimizations](#optimizations)
+2. [better type checking](#better-type-checking)
+
 ## Usage
 
-> es5, browser and es6 ready
+> es5, es6, and browser ready
 
 ```js
 var kindOf = require('kind-of');
@@ -35,24 +42,15 @@ kindOf(true);
 kindOf(false);
 //=> 'boolean'
 
-kindOf(new Boolean(true));
-//=> 'boolean'
-
 kindOf(new Buffer(''));
 //=> 'buffer'
 
 kindOf(42);
 //=> 'number'
 
-kindOf(new Number(42));
-//=> 'number'
-
 kindOf('str');
 //=> 'string'
 
-kindOf(new String('str'));
-//=> 'string'
-
 kindOf(arguments);
 //=> 'arguments'
 
@@ -68,15 +66,9 @@ kindOf(new Test());
 kindOf(new Date());
 //=> 'date'
 
-kindOf([]);
-//=> 'array'
-
 kindOf([1, 2, 3]);
 //=> 'array'
 
-kindOf(new Array());
-//=> 'array'
-
 kindOf(/foo/);
 //=> 'regexp'
 
@@ -87,10 +79,10 @@ kindOf(function () {});
 //=> 'function'
 
 kindOf(function * () {});
-//=> 'function'
+//=> 'generatorfunction'
 
-kindOf(new Function());
-//=> 'function'
+kindOf(Symbol('str'));
+//=> 'symbol'
 
 kindOf(new Map());
 //=> 'map'
@@ -104,9 +96,6 @@ kindOf(new Set());
 kindOf(new WeakSet());
 //=> 'weakset'
 
-kindOf(Symbol('str'));
-//=> 'symbol'
-
 kindOf(new Int8Array());
 //=> 'int8array'
 
@@ -138,58 +127,113 @@ kindOf(new Float64Array());
 ## Benchmarks
 
 Benchmarked against [typeof](http://github.com/CodingFu/typeof) and [type-of](https://github.com/ForbesLindesay/type-of).
-Note that performaces is slower for es6 features `Map`, `WeakMap`, `Set` and `WeakSet`.
 
 ```bash
-#1: array
-  current x 23,329,397 ops/sec ±0.82% (94 runs sampled)
-  lib-type-of x 4,170,273 ops/sec ±0.55% (94 runs sampled)
-  lib-typeof x 9,686,935 ops/sec ±0.59% (98 runs sampled)
-
-#2: boolean
-  current x 27,197,115 ops/sec ±0.85% (94 runs sampled)
-  lib-type-of x 3,145,791 ops/sec ±0.73% (97 runs sampled)
-  lib-typeof x 9,199,562 ops/sec ±0.44% (99 runs sampled)
-
-#3: date
-  current x 20,190,117 ops/sec ±0.86% (92 runs sampled)
-  lib-type-of x 5,166,970 ops/sec ±0.74% (94 runs sampled)
-  lib-typeof x 9,610,821 ops/sec ±0.50% (96 runs sampled)
-
-#4: function
-  current x 23,855,460 ops/sec ±0.60% (97 runs sampled)
-  lib-type-of x 5,667,740 ops/sec ±0.54% (100 runs sampled)
-  lib-typeof x 10,010,644 ops/sec ±0.44% (100 runs sampled)
-
-#5: null
-  current x 27,061,047 ops/sec ±0.97% (96 runs sampled)
-  lib-type-of x 13,965,573 ops/sec ±0.62% (97 runs sampled)
-  lib-typeof x 8,460,194 ops/sec ±0.61% (97 runs sampled)
-
-#6: number
-  current x 25,075,682 ops/sec ±0.53% (99 runs sampled)
-  lib-type-of x 2,266,405 ops/sec ±0.41% (98 runs sampled)
-  lib-typeof x 9,821,481 ops/sec ±0.45% (99 runs sampled)
-
-#7: object
-  current x 3,348,980 ops/sec ±0.49% (99 runs sampled)
-  lib-type-of x 3,245,138 ops/sec ±0.60% (94 runs sampled)
-  lib-typeof x 9,262,952 ops/sec ±0.59% (99 runs sampled)
-
-#8: regex
-  current x 21,284,827 ops/sec ±0.72% (96 runs sampled)
-  lib-type-of x 4,689,241 ops/sec ±0.43% (100 runs sampled)
-  lib-typeof x 8,957,593 ops/sec ±0.62% (98 runs sampled)
-
-#9: string
-  current x 25,379,234 ops/sec ±0.58% (96 runs sampled)
-  lib-type-of x 3,635,148 ops/sec ±0.76% (93 runs sampled)
-  lib-typeof x 9,494,134 ops/sec ±0.49% (98 runs sampled)
-
-#10: undef
-  current x 27,459,221 ops/sec ±1.01% (93 runs sampled)
-  lib-type-of x 14,360,433 ops/sec ±0.52% (99 runs sampled)
-  lib-typeof x 23,202,868 ops/sec ±0.59% (94 runs sampled)
+# arguments (32 bytes)
+  kind-of x 17,024,098 ops/sec ±1.90% (86 runs sampled)
+  lib-type-of x 11,926,235 ops/sec ±1.34% (83 runs sampled)
+  lib-typeof x 9,245,257 ops/sec ±1.22% (87 runs sampled)
+
+  fastest is kind-of (by 161% avg)
+
+# array (22 bytes)
+  kind-of x 17,196,492 ops/sec ±1.07% (88 runs sampled)
+  lib-type-of x 8,838,283 ops/sec ±1.02% (87 runs sampled)
+  lib-typeof x 8,677,848 ops/sec ±0.87% (87 runs sampled)
+
+  fastest is kind-of (by 196% avg)
+
+# boolean (24 bytes)
+  kind-of x 16,841,600 ops/sec ±1.10% (86 runs sampled)
+  lib-type-of x 8,096,787 ops/sec ±0.95% (87 runs sampled)
+  lib-typeof x 8,423,345 ops/sec ±1.15% (86 runs sampled)
+
+  fastest is kind-of (by 204% avg)
+
+# buffer (38 bytes)
+  kind-of x 14,848,060 ops/sec ±1.05% (86 runs sampled)
+  lib-type-of x 3,671,577 ops/sec ±1.49% (87 runs sampled)
+  lib-typeof x 8,360,236 ops/sec ±1.24% (86 runs sampled)
+
+  fastest is kind-of (by 247% avg)
+
+# date (30 bytes)
+  kind-of x 16,067,761 ops/sec ±1.58% (86 runs sampled)
+  lib-type-of x 8,954,436 ops/sec ±1.40% (87 runs sampled)
+  lib-typeof x 8,488,307 ops/sec ±1.51% (84 runs sampled)
+
+  fastest is kind-of (by 184% avg)
+
+# error (36 bytes)
+  kind-of x 9,634,090 ops/sec ±1.12% (89 runs sampled)
+  lib-type-of x 7,735,624 ops/sec ±1.32% (86 runs sampled)
+  lib-typeof x 7,442,160 ops/sec ±1.11% (90 runs sampled)
+
+  fastest is kind-of (by 127% avg)
+
+# function (34 bytes)
+  kind-of x 10,031,494 ops/sec ±1.27% (86 runs sampled)
+  lib-type-of x 9,502,757 ops/sec ±1.17% (89 runs sampled)
+  lib-typeof x 8,278,985 ops/sec ±1.08% (88 runs sampled)
+
+  fastest is kind-of (by 113% avg)
+
+# null (24 bytes)
+  kind-of x 18,159,808 ops/sec ±1.92% (86 runs sampled)
+  lib-type-of x 12,927,635 ops/sec ±1.01% (88 runs sampled)
+  lib-typeof x 7,958,234 ops/sec ±1.21% (89 runs sampled)
+
+  fastest is kind-of (by 174% avg)
+
+# number (22 bytes)
+  kind-of x 17,846,779 ops/sec ±0.91% (85 runs sampled)
+  lib-type-of x 3,316,636 ops/sec ±1.19% (86 runs sampled)
+  lib-typeof x 2,329,477 ops/sec ±2.21% (85 runs sampled)
+
+  fastest is kind-of (by 632% avg)
+
+# object-plain (47 bytes)
+  kind-of x 7,085,155 ops/sec ±1.05% (88 runs sampled)
+  lib-type-of x 8,870,930 ops/sec ±1.06% (83 runs sampled)
+  lib-typeof x 8,716,024 ops/sec ±1.05% (87 runs sampled)
+
+  fastest is lib-type-of (by 112% avg)
+
+# regex (25 bytes)
+  kind-of x 14,196,052 ops/sec ±1.65% (84 runs sampled)
+  lib-type-of x 9,554,164 ops/sec ±1.25% (88 runs sampled)
+  lib-typeof x 8,359,691 ops/sec ±1.07% (87 runs sampled)
+
+  fastest is kind-of (by 158% avg)
+
+# string (33 bytes)
+  kind-of x 16,131,428 ops/sec ±1.41% (85 runs sampled)
+  lib-type-of x 7,273,172 ops/sec ±1.05% (87 runs sampled)
+  lib-typeof x 7,382,635 ops/sec ±1.17% (85 runs sampled)
+
+  fastest is kind-of (by 220% avg)
+
+# symbol (34 bytes)
+  kind-of x 17,011,537 ops/sec ±1.24% (86 runs sampled)
+  lib-type-of x 3,492,454 ops/sec ±1.23% (89 runs sampled)
+  lib-typeof x 7,471,235 ops/sec ±2.48% (87 runs sampled)
+
+  fastest is kind-of (by 310% avg)
+
+# template-strings (36 bytes)
+  kind-of x 15,434,250 ops/sec ±1.46% (83 runs sampled)
+  lib-type-of x 7,157,907 ops/sec ±0.97% (87 runs sampled)
+  lib-typeof x 7,517,986 ops/sec ±0.92% (86 runs sampled)
+
+  fastest is kind-of (by 210% avg)
+
+# undefined (29 bytes)
+  kind-of x 19,167,115 ops/sec ±1.71% (87 runs sampled)
+  lib-type-of x 15,477,740 ops/sec ±1.63% (85 runs sampled)
+  lib-typeof x 19,075,495 ops/sec ±1.17% (83 runs sampled)
+
+  fastest is lib-typeof,kind-of
+
 ```
 
 ## Optimizations
@@ -199,49 +243,118 @@ In 7 out of 8 cases, this library is 2x-10x faster than other top libraries incl
 1. Optimize around the fastest and most common use cases first. Of course, this will change from project-to-project, but I took some time to understand how and why `typeof` checks were being used in my own libraries and other libraries I use a lot.
 2. Optimize around bottlenecks - In other words, the order in which conditionals are implemented is significant, because each check is only as fast as the failing checks that came before it. Here, the biggest bottleneck by far is checking for plain objects (an object that was created by the `Object` constructor). I opted to make this check happen by process of elimination rather than brute force up front (e.g. by using something like `val.constructor.name`), so that every other type chec [...]
 3. Don't do uneccessary processing - why do `.slice(8, -1).toLowerCase();` just to get the word `regex`? It's much faster to do `if (type === '[object RegExp]') return 'regex'`
+4. There is no reason to make the code in a microlib as terse as possible, just to win points for making it shorter. It's always better to favor performant code over terse code. You will always only be using a single `require()` statement to use the library anyway, regardless of how the code is written.
 
-## About
+## Better type checking
 
-### Related projects
+kind-of seems to be more consistently "correct" than other type checking libs I've looked at. For example, here are some differing results from other popular libs:
 
-* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet")
-* [is-number](https://www.npmjs.com/package/is-number): Returns true if the value is a number. comprehensive tests. | [homepage](https://github.com/jonschlinkert/is-number "Returns true if the value is a number. comprehensive tests.")
-* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive.  | [homepage](https://github.com/jonschlinkert/is-primitive "Returns `true` if the value is a primitive. ")
+### [typeof](https://github.com/CodingFu/typeof) lib
+
+Incorrectly identifies instances of custom constructors (pretty common):
+
+```js
+var typeOf = require('typeof');
+function Test() {}
+console.log(typeOf(new Test()));
+//=> 'test'
+```
+
+Returns `object` instead of `arguments`:
+
+```js
+function foo() {
+  console.log(typeOf(arguments)) //=> 'object'
+}
+foo();
+```
+
+### [type-of](https://github.com/ForbesLindesay/type-of) lib
+
+Incorrectly returns `object` for generator functions, buffers, `Map`, `Set`, `WeakMap` and `WeakSet`:
+
+```js
+function * foo() {}
+console.log(typeOf(foo));
+//=> 'object'
+console.log(typeOf(new Buffer('')));
+//=> 'object'
+console.log(typeOf(new Map()));
+//=> 'object'
+console.log(typeOf(new Set()));
+//=> 'object'
+console.log(typeOf(new WeakMap()));
+//=> 'object'
+console.log(typeOf(new WeakSet()));
+//=> 'object'
+```
 
-### Contributing
+## About
+
+<details>
+<summary><strong>Contributing</strong></summary>
 
 Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
 
-### Building docs
+</details>
 
-_(This document was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_
+<details>
+<summary><strong>Running Tests</strong></summary>
 
-To generate the readme and API documentation with [verb](https://github.com/verbose/verb):
+Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
 
 ```sh
-$ npm install -g verb verb-generate-readme && verb
+$ npm install && npm test
 ```
 
-### Running tests
+</details>
+
+<details>
+<summary><strong>Building docs</strong></summary>
 
-Install dev dependencies:
+_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
+
+To generate the readme, run the following command:
 
 ```sh
-$ npm install -d && npm test
+$ npm install -g verbose/verb#dev verb-generate-readme && verb
 ```
 
+</details>
+
+### Related projects
+
+You might also be interested in these projects:
+
+* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet")
+* [is-number](https://www.npmjs.com/package/is-number): Returns true if the value is a number. comprehensive tests. | [homepage](https://github.com/jonschlinkert/is-number "Returns true if the value is a number. comprehensive tests.")
+* [is-primitive](https://www.npmjs.com/package/is-primitive): Returns `true` if the value is a primitive.  | [homepage](https://github.com/jonschlinkert/is-primitive "Returns `true` if the value is a primitive. ")
+
+### Contributors
+
+| **Commits** | **Contributor** | 
+| --- | --- |
+| 94 | [jonschlinkert](https://github.com/jonschlinkert) |
+| 3 | [aretecode](https://github.com/aretecode) |
+| 2 | [miguelmota](https://github.com/miguelmota) |
+| 1 | [dtothefp](https://github.com/dtothefp) |
+| 1 | [ksheedlo](https://github.com/ksheedlo) |
+| 1 | [pdehaan](https://github.com/pdehaan) |
+| 1 | [laggingreflex](https://github.com/laggingreflex) |
+| 1 | [charlike-old](https://github.com/charlike-old) |
+
 ### Author
 
 **Jon Schlinkert**
 
 * [github/jonschlinkert](https://github.com/jonschlinkert)
-* [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
+* [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
 
 ### License
 
-Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert).
-Released under the [MIT license](https://github.com/jonschlinkert/kind-of/blob/master/LICENSE).
+Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
+Released under the [MIT License](LICENSE).
 
 ***
 
-_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.1.28, on July 29, 2016._
\ No newline at end of file
+_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on November 18, 2017._
\ No newline at end of file
diff --git a/benchmark/check.js b/benchmark/check.js
deleted file mode 100644
index 6abf3a0..0000000
--- a/benchmark/check.js
+++ /dev/null
@@ -1,22 +0,0 @@
-'use strict';
-
-var bold = require('ansi-bold');
-var path = require('path');
-var glob = require('glob');
-
-/**
- * Sanity check
- *
- * Run to ensure that all fns return the same result.
- */
-
-var fixtures = glob.sync(__dirname + '/fixtures/*.*');
-
-glob.sync(__dirname + '/code/*.js').forEach(function (fp) {
-  var fn = require(path.resolve(__dirname, 'code', fp));
-  var name = path.basename(fp, path.extname(fp));
-
-  fixtures.forEach(function (fixture) {
-    console.log(bold(name) + ':', fn.apply(null, require(fixture)));
-  });
-});
diff --git a/benchmark/code/current.js b/benchmark/code/current.js
deleted file mode 100644
index 24b4202..0000000
--- a/benchmark/code/current.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require('../..');
\ No newline at end of file
diff --git a/benchmark/code/kind-of.js b/benchmark/code/kind-of.js
new file mode 100644
index 0000000..a7ba67c
--- /dev/null
+++ b/benchmark/code/kind-of.js
@@ -0,0 +1,8 @@
+var typeOf = require('../..');
+
+module.exports = function(val) {
+  if (val === 'arguments') {
+    return typeOf(arguments);
+  }
+  return typeOf(val);
+};
diff --git a/benchmark/code/lib-type-of.js b/benchmark/code/lib-type-of.js
index 9d1da27..1325c36 100644
--- a/benchmark/code/lib-type-of.js
+++ b/benchmark/code/lib-type-of.js
@@ -1,4 +1,46 @@
 /**
  * https://github.com/ForbesLindesay/type-of
  */
-module.exports = require('type-of');
\ No newline at end of file
+// var typeOf = require('type-of');
+var toString = Object.prototype.toString;
+
+module.exports = function(val) {
+  if (val === 'arguments') {
+    return typeOf(arguments);
+  }
+  return typeOf(val);
+};
+
+function typeOf(val) {
+  switch (toString.call(val)) {
+    case '[object Function]':
+      return 'function';
+    case '[object Date]':
+      return 'date';
+    case '[object RegExp]':
+      return 'regexp';
+    case '[object Arguments]':
+      return 'arguments';
+    case '[object Array]':
+      return 'array';
+    case '[object String]':
+      return 'string';
+  }
+
+  if (typeof val == 'object' && val && typeof val.length == 'number') {
+    try {
+      if (typeof val.callee == 'function') return 'arguments';
+    } catch (ex) {
+      if (ex instanceof TypeError) {
+        return 'arguments';
+      }
+    }
+  }
+
+  if (val === null) return 'null';
+  if (val === undefined) return 'undefined';
+  if (val && val.nodeType === 1) return 'element';
+  if (val === Object(val)) return 'object';
+
+  return typeof val;
+}
diff --git a/benchmark/code/lib-typeof.js b/benchmark/code/lib-typeof.js
index 143625d..581cdba 100644
--- a/benchmark/code/lib-typeof.js
+++ b/benchmark/code/lib-typeof.js
@@ -1,4 +1,25 @@
 /**
  * http://github.com/CodingFu/typeof
  */
-module.exports = require('typeof');
\ No newline at end of file
+// var typeOf = require('typeof');
+var toString = Object.prototype.toString;
+
+module.exports = function(val) {
+  if (val === 'arguments') {
+    return typeOf(arguments);
+  }
+  return typeOf(val);
+};
+
+function typeOf(object) {
+  var type = typeof object;
+  if (type === 'undefined') {
+    return 'undefined';
+  }
+  if (object) {
+    type = object.constructor.name;
+  } else if (type === 'object') {
+    type = toString.call(object).slice(8, -1);
+  }
+  return type.toLowerCase();
+}
diff --git a/benchmark/code/slice-switch.js b/benchmark/code/slice-switch.js
index 8121340..5735ed3 100644
--- a/benchmark/code/slice-switch.js
+++ b/benchmark/code/slice-switch.js
@@ -1,16 +1,16 @@
 module.exports = function typeOf(val) {
   if (val === null) return 'null';
-
   if (val === undefined) {
     return 'undefined';
   }
 
   var type = typeof val;
   switch (type) {
-    case "string":
-    case "number":
-    case "boolean":
+    case 'string':
+    case 'number':
+    case 'boolean': {
       return type;
+    }
   }
 
   if (Array.isArray(val)) {
diff --git a/benchmark/code/switch.js b/benchmark/code/switch.js
new file mode 100644
index 0000000..cfabf36
--- /dev/null
+++ b/benchmark/code/switch.js
@@ -0,0 +1,116 @@
+var toString = Object.prototype.toString;
+
+module.exports = function(val) {
+  if (val === 'arguments') {
+    return kindOf(arguments);
+  }
+  return kindOf(val);
+};
+
+function kindOf(val) {
+  if (val === void 0) {
+    return 'undefined';
+  }
+  if (val === null) {
+    return 'null';
+  }
+  if (val === true || val === false) {
+    return 'boolean';
+  }
+
+  var type = typeof val;
+  if (type === 'number') {
+    return 'number';
+  }
+  if (type === 'string') {
+    return 'string';
+  }
+  if (type === 'function') {
+    return isGeneratorFn(val) ? 'generatorfunction' : 'function';
+  }
+  if (Array.isArray && Array.isArray(val)) {
+    return 'array';
+  }
+  if (isBuffer(val)) {
+    return 'buffer';
+  }
+
+  var name = ctorName(val);
+  if (name === 'Date') {
+    return 'date';
+  }
+
+  type = toString.call(val);
+  switch (type) {
+    // Common object types
+    case '[object Object]': return 'object';
+    case '[object Arguments]': return 'arguments';
+    // case '[object Function]': return 'function';
+    case '[object RegExp]': return 'regexp';
+    case '[object Date]': return 'date';
+    case '[object Error]': return 'error';
+    case '[object Promise]': return 'promise';
+    // case '[object GeneratorFunction]': return 'generatorfunction';
+
+    // Set, Map, WeakSet, WeakMap, Symbol
+    case '[object Set]': return 'set';
+    case '[object Map]': return 'map';
+    case '[object WeakSet]': return 'weakset';
+    case '[object WeakMap]': return 'weakmap';
+    case '[object Symbol]': return 'symbol';
+
+    // iterators
+    case '[object Map Iterator]': return 'mapiterator';
+    case '[object Set Iterator]': return 'setiterator';
+    case '[object String Iterator]': return 'stringiterator';
+    case '[object Array Iterator]': return 'arrayiterator';
+
+    // 16-bit typed arrays
+    case '[object Int16Array]': return 'int16array';
+    case '[object Uint16Array]': return 'uint16array';
+
+    // 32-bit typed arrays
+    case '[object Int32Array]': return 'int32array';
+    case '[object Uint32Array]': return 'uint32array';
+    case '[object Float32Array]': return 'float32array';
+    case '[object Float64Array]': return 'float64array';
+
+    // 8-bit typed arrays
+    case '[object Int8Array]': return 'int8array';
+    case '[object Uint8Array]': return 'uint8array';
+    case '[object Uint8ClampedArray]': return 'uint8clampedarray';
+
+    default: {
+      if (isGeneratorObj(val)) {
+        return 'generator';
+      }
+      return type.slice(8, -1).split(' ').join('').toLowerCase();
+    }
+  }
+}
+
+function ctorName(val) {
+  return val.constructor ? val.constructor.name : null;
+}
+
+function isGeneratorFn(val) {
+  return ctorName(val) === 'GeneratorFunction';
+}
+
+function isGeneratorObj(val) {
+  return typeof val.throw === 'function'
+    && typeof val.return === 'function'
+    && typeof val.next === 'function';
+}
+
+/**
+ * If you need to support Safari 5-7 (8-10 yr-old browser),
+ * take a look at https://github.com/feross/is-buffer
+ */
+
+function isBuffer(val) {
+  if (val.constructor && typeof val.constructor.isBuffer === 'function') {
+    return val.constructor.isBuffer(val);
+  }
+  return false;
+}
diff --git a/benchmark/fixtures/arguments.js b/benchmark/fixtures/arguments.js
index d863304..4e79e9a 100644
--- a/benchmark/fixtures/arguments.js
+++ b/benchmark/fixtures/arguments.js
@@ -1 +1 @@
-module.exports = [arguments];
+module.exports = ['arguments'];
diff --git a/benchmark/fixtures/buffer.js b/benchmark/fixtures/buffer.js
index 20e9408..9a9b50f 100644
--- a/benchmark/fixtures/buffer.js
+++ b/benchmark/fixtures/buffer.js
@@ -1 +1 @@
-module.exports = [new Buffer('')];
+module.exports = [new Buffer('foo')];
diff --git a/benchmark/fixtures/error.js b/benchmark/fixtures/error.js
new file mode 100644
index 0000000..65027a4
--- /dev/null
+++ b/benchmark/fixtures/error.js
@@ -0,0 +1 @@
+module.exports = [new Error('foo')];
\ No newline at end of file
diff --git a/benchmark/fixtures/object.js b/benchmark/fixtures/object-instance.js
similarity index 100%
rename from benchmark/fixtures/object.js
rename to benchmark/fixtures/object-instance.js
diff --git a/benchmark/fixtures/object-plain.js b/benchmark/fixtures/object-plain.js
new file mode 100644
index 0000000..fbf186f
--- /dev/null
+++ b/benchmark/fixtures/object-plain.js
@@ -0,0 +1,2 @@
+function Foo() {}
+module.exports = [new Foo()];
\ No newline at end of file
diff --git a/benchmark/fixtures/undef.js b/benchmark/fixtures/undefined.js
similarity index 100%
rename from benchmark/fixtures/undef.js
rename to benchmark/fixtures/undefined.js
diff --git a/benchmark/index.js b/benchmark/index.js
index e49c379..9f1fca6 100644
--- a/benchmark/index.js
+++ b/benchmark/index.js
@@ -1,11 +1,15 @@
 'use strict';
 
-var Suite = require('benchmarked');
-var suite = new Suite({
-  result: false,
-  fixtures: ['fixtures/*.js', '!**/fixtures/gen*'],
-  add: 'code/{current,lib-*}.js',
-  cwd: __dirname
-});
+var path = require('path');
+var suite = require('benchmarked');
+var write = require('write');
 
-suite.run();
+suite.run({
+  fixtures: 'fixtures/*.js',
+  code: 'code/{kind-of,lib-*}.js'
+})
+  .then(function(stats) {
+    write.sync(path.join(__dirname, 'stats.json'), JSON.stringify(stats, null, 2))
+    write.sync(path.join(__dirname, 'stats.md'), suite.render(stats));
+  })
+  .catch(console.error);
diff --git a/benchmark/last.md b/benchmark/last.md
deleted file mode 100644
index 095dd4b..0000000
--- a/benchmark/last.md
+++ /dev/null
@@ -1,49 +0,0 @@
-#1: array
-  current x 23,329,397 ops/sec ±0.82% (94 runs sampled)
-  lib-type-of x 4,170,273 ops/sec ±0.55% (94 runs sampled)
-  lib-typeof x 9,686,935 ops/sec ±0.59% (98 runs sampled)
-
-#2: boolean
-  current x 27,197,115 ops/sec ±0.85% (94 runs sampled)
-  lib-type-of x 3,145,791 ops/sec ±0.73% (97 runs sampled)
-  lib-typeof x 9,199,562 ops/sec ±0.44% (99 runs sampled)
-
-#3: date
-  current x 20,190,117 ops/sec ±0.86% (92 runs sampled)
-  lib-type-of x 5,166,970 ops/sec ±0.74% (94 runs sampled)
-  lib-typeof x 9,610,821 ops/sec ±0.50% (96 runs sampled)
-
-#4: function
-  current x 23,855,460 ops/sec ±0.60% (97 runs sampled)
-  lib-type-of x 5,667,740 ops/sec ±0.54% (100 runs sampled)
-  lib-typeof x 10,010,644 ops/sec ±0.44% (100 runs sampled)
-
-#5: null
-  current x 27,061,047 ops/sec ±0.97% (96 runs sampled)
-  lib-type-of x 13,965,573 ops/sec ±0.62% (97 runs sampled)
-  lib-typeof x 8,460,194 ops/sec ±0.61% (97 runs sampled)
-
-#6: number
-  current x 25,075,682 ops/sec ±0.53% (99 runs sampled)
-  lib-type-of x 2,266,405 ops/sec ±0.41% (98 runs sampled)
-  lib-typeof x 9,821,481 ops/sec ±0.45% (99 runs sampled)
-
-#7: object
-  current x 3,348,980 ops/sec ±0.49% (99 runs sampled)
-  lib-type-of x 3,245,138 ops/sec ±0.60% (94 runs sampled)
-  lib-typeof x 9,262,952 ops/sec ±0.59% (99 runs sampled)
-
-#8: regex
-  current x 21,284,827 ops/sec ±0.72% (96 runs sampled)
-  lib-type-of x 4,689,241 ops/sec ±0.43% (100 runs sampled)
-  lib-typeof x 8,957,593 ops/sec ±0.62% (98 runs sampled)
-
-#9: string
-  current x 25,379,234 ops/sec ±0.58% (96 runs sampled)
-  lib-type-of x 3,635,148 ops/sec ±0.76% (93 runs sampled)
-  lib-typeof x 9,494,134 ops/sec ±0.49% (98 runs sampled)
-
-#10: undef
-  current x 27,459,221 ops/sec ±1.01% (93 runs sampled)
-  lib-type-of x 14,360,433 ops/sec ±0.52% (99 runs sampled)
-  lib-typeof x 23,202,868 ops/sec ±0.59% (94 runs sampled)
diff --git a/benchmark/stats.md b/benchmark/stats.md
new file mode 100644
index 0000000..6b1afc0
--- /dev/null
+++ b/benchmark/stats.md
@@ -0,0 +1,104 @@
+# arguments (32 bytes)
+  kind-of x 17,024,098 ops/sec ±1.90% (86 runs sampled)
+  lib-type-of x 11,926,235 ops/sec ±1.34% (83 runs sampled)
+  lib-typeof x 9,245,257 ops/sec ±1.22% (87 runs sampled)
+
+  fastest is kind-of (by 161% avg)
+
+# array (22 bytes)
+  kind-of x 17,196,492 ops/sec ±1.07% (88 runs sampled)
+  lib-type-of x 8,838,283 ops/sec ±1.02% (87 runs sampled)
+  lib-typeof x 8,677,848 ops/sec ±0.87% (87 runs sampled)
+
+  fastest is kind-of (by 196% avg)
+
+# boolean (24 bytes)
+  kind-of x 16,841,600 ops/sec ±1.10% (86 runs sampled)
+  lib-type-of x 8,096,787 ops/sec ±0.95% (87 runs sampled)
+  lib-typeof x 8,423,345 ops/sec ±1.15% (86 runs sampled)
+
+  fastest is kind-of (by 204% avg)
+
+# buffer (38 bytes)
+  kind-of x 14,848,060 ops/sec ±1.05% (86 runs sampled)
+  lib-type-of x 3,671,577 ops/sec ±1.49% (87 runs sampled)
+  lib-typeof x 8,360,236 ops/sec ±1.24% (86 runs sampled)
+
+  fastest is kind-of (by 247% avg)
+
+# date (30 bytes)
+  kind-of x 16,067,761 ops/sec ±1.58% (86 runs sampled)
+  lib-type-of x 8,954,436 ops/sec ±1.40% (87 runs sampled)
+  lib-typeof x 8,488,307 ops/sec ±1.51% (84 runs sampled)
+
+  fastest is kind-of (by 184% avg)
+
+# error (36 bytes)
+  kind-of x 9,634,090 ops/sec ±1.12% (89 runs sampled)
+  lib-type-of x 7,735,624 ops/sec ±1.32% (86 runs sampled)
+  lib-typeof x 7,442,160 ops/sec ±1.11% (90 runs sampled)
+
+  fastest is kind-of (by 127% avg)
+
+# function (34 bytes)
+  kind-of x 10,031,494 ops/sec ±1.27% (86 runs sampled)
+  lib-type-of x 9,502,757 ops/sec ±1.17% (89 runs sampled)
+  lib-typeof x 8,278,985 ops/sec ±1.08% (88 runs sampled)
+
+  fastest is kind-of (by 113% avg)
+
+# null (24 bytes)
+  kind-of x 18,159,808 ops/sec ±1.92% (86 runs sampled)
+  lib-type-of x 12,927,635 ops/sec ±1.01% (88 runs sampled)
+  lib-typeof x 7,958,234 ops/sec ±1.21% (89 runs sampled)
+
+  fastest is kind-of (by 174% avg)
+
+# number (22 bytes)
+  kind-of x 17,846,779 ops/sec ±0.91% (85 runs sampled)
+  lib-type-of x 3,316,636 ops/sec ±1.19% (86 runs sampled)
+  lib-typeof x 2,329,477 ops/sec ±2.21% (85 runs sampled)
+
+  fastest is kind-of (by 632% avg)
+
+# object-plain (47 bytes)
+  kind-of x 7,085,155 ops/sec ±1.05% (88 runs sampled)
+  lib-type-of x 8,870,930 ops/sec ±1.06% (83 runs sampled)
+  lib-typeof x 8,716,024 ops/sec ±1.05% (87 runs sampled)
+
+  fastest is lib-type-of (by 112% avg)
+
+# regex (25 bytes)
+  kind-of x 14,196,052 ops/sec ±1.65% (84 runs sampled)
+  lib-type-of x 9,554,164 ops/sec ±1.25% (88 runs sampled)
+  lib-typeof x 8,359,691 ops/sec ±1.07% (87 runs sampled)
+
+  fastest is kind-of (by 158% avg)
+
+# string (33 bytes)
+  kind-of x 16,131,428 ops/sec ±1.41% (85 runs sampled)
+  lib-type-of x 7,273,172 ops/sec ±1.05% (87 runs sampled)
+  lib-typeof x 7,382,635 ops/sec ±1.17% (85 runs sampled)
+
+  fastest is kind-of (by 220% avg)
+
+# symbol (34 bytes)
+  kind-of x 17,011,537 ops/sec ±1.24% (86 runs sampled)
+  lib-type-of x 3,492,454 ops/sec ±1.23% (89 runs sampled)
+  lib-typeof x 7,471,235 ops/sec ±2.48% (87 runs sampled)
+
+  fastest is kind-of (by 310% avg)
+
+# template-strings (36 bytes)
+  kind-of x 15,434,250 ops/sec ±1.46% (83 runs sampled)
+  lib-type-of x 7,157,907 ops/sec ±0.97% (87 runs sampled)
+  lib-typeof x 7,517,986 ops/sec ±0.92% (86 runs sampled)
+
+  fastest is kind-of (by 210% avg)
+
+# undefined (29 bytes)
+  kind-of x 19,167,115 ops/sec ±1.71% (87 runs sampled)
+  lib-type-of x 15,477,740 ops/sec ±1.63% (85 runs sampled)
+  lib-typeof x 19,075,495 ops/sec ±1.17% (83 runs sampled)
+
+  fastest is lib-typeof,kind-of
diff --git a/bower.json b/bower.json
index 00e6a9a..c393191 100644
--- a/bower.json
+++ b/bower.json
@@ -11,17 +11,14 @@
     "index.js"
   ],
   "dependencies": {
-    "is-buffer": "^1.0.2"
+    "is-buffer": "^1.1.5"
   },
   "devDependencies": {
-    "benchmarked": "^0.1.3",
-    "browserify": "^11.0.1",
-    "chalk": "^0.5.1",
-    "glob": "^4.3.5",
-    "mocha": "*",
-    "should": "*",
-    "type-of": "^2.0.1",
-    "typeof": "^1.0.0"
+    "benchmarked": "^2.0.0",
+    "browserify": "^14.4.0",
+    "gulp-format-md": "^1.0.0",
+    "mocha": "^4.0.1",
+    "write": "^1.0.3"
   },
   "keywords": [
     "arguments",
@@ -44,5 +41,32 @@
     "type-of",
     "typeof",
     "types"
+  ],
+  "version": "6.0.0",
+  "contributors": [
+    "David Fox-Powell (https://dtothefp.github.io/me)",
+    "James (https://twitter.com/aretecode)",
+    "Jon Schlinkert (http://twitter.com/jonschlinkert)",
+    "Ken Sheedlo (kensheedlo.com)",
+    "laggingreflex (https://github.com/laggingreflex)",
+    "Miguel Mota (https://miguelmota.com)",
+    "Peter deHaan (http://about.me/peterdehaan)",
+    "tunnckoCore (https://i.am.charlike.online)"
+  ],
+  "bugs": {
+    "url": "https://github.com/jonschlinkert/kind-of/issues"
+  },
+  "files": [
+    "index.js"
+  ],
+  "ignore": [
+    "actual",
+    "bower_components",
+    "fixtures",
+    "node_modules",
+    "temp",
+    "test",
+    "test.js",
+    "tmp"
   ]
-}
+}
\ No newline at end of file
diff --git a/index.js b/index.js
index 87938c9..aa2bb39 100644
--- a/index.js
+++ b/index.js
@@ -1,113 +1,129 @@
-var isBuffer = require('is-buffer');
 var toString = Object.prototype.toString;
 
-/**
- * Get the native `typeof` a value.
- *
- * @param  {*} `val`
- * @return {*} Native javascript type
- */
-
 module.exports = function kindOf(val) {
-  // primitivies
-  if (typeof val === 'undefined') {
-    return 'undefined';
-  }
-  if (val === null) {
-    return 'null';
-  }
-  if (val === true || val === false || val instanceof Boolean) {
-    return 'boolean';
-  }
-  if (typeof val === 'string' || val instanceof String) {
-    return 'string';
-  }
-  if (typeof val === 'number' || val instanceof Number) {
-    return 'number';
-  }
+  if (val === void 0) return 'undefined';
+  if (val === null) return 'null';
 
-  // functions
-  if (typeof val === 'function' || val instanceof Function) {
-    return 'function';
+  var type = typeof val;
+  if (type === 'boolean') return 'boolean';
+  if (type === 'string') return 'string';
+  if (type === 'number') return 'number';
+  if (type === 'symbol') return 'symbol';
+  if (type === 'function') {
+    return isGeneratorFn(val) ? 'generatorfunction' : 'function';
   }
 
-  // array
-  if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
-    return 'array';
-  }
+  if (isArray(val)) return 'array';
+  if (isBuffer(val)) return 'buffer';
+  if (isArguments(val)) return 'arguments';
+  if (isDate(val)) return 'date';
+  if (isError(val)) return 'error';
+  if (isRegexp(val)) return 'regexp';
 
-  // check for instances of RegExp and Date before calling `toString`
-  if (val instanceof RegExp) {
-    return 'regexp';
-  }
-  if (val instanceof Date) {
-    return 'date';
-  }
+  switch (ctorName(val)) {
+    case 'Symbol': return 'symbol';
+    case 'Promise': return 'promise';
 
-  // other objects
-  var type = toString.call(val);
+    // Set, Map, WeakSet, WeakMap
+    case 'WeakMap': return 'weakmap';
+    case 'WeakSet': return 'weakset';
+    case 'Map': return 'map';
+    case 'Set': return 'set';
 
-  if (type === '[object RegExp]') {
-    return 'regexp';
-  }
-  if (type === '[object Date]') {
-    return 'date';
-  }
-  if (type === '[object Arguments]') {
-    return 'arguments';
-  }
+    // 8-bit typed arrays
+    case 'Int8Array': return 'int8array';
+    case 'Uint8Array': return 'uint8array';
+    case 'Uint8ClampedArray': return 'uint8clampedarray';
 
-  // buffer
-  if (typeof Buffer !== 'undefined' && isBuffer(val)) {
-    return 'buffer';
-  }
+    // 16-bit typed arrays
+    case 'Int16Array': return 'int16array';
+    case 'Uint16Array': return 'uint16array';
 
-  // es6: Map, WeakMap, Set, WeakSet
-  if (type === '[object Set]') {
-    return 'set';
-  }
-  if (type === '[object WeakSet]') {
-    return 'weakset';
-  }
-  if (type === '[object Map]') {
-    return 'map';
-  }
-  if (type === '[object WeakMap]') {
-    return 'weakmap';
-  }
-  if (type === '[object Symbol]') {
-    return 'symbol';
+    // 32-bit typed arrays
+    case 'Int32Array': return 'int32array';
+    case 'Uint32Array': return 'uint32array';
+    case 'Float32Array': return 'float32array';
+    case 'Float64Array': return 'float64array';
   }
 
-  // typed arrays
-  if (type === '[object Int8Array]') {
-    return 'int8array';
-  }
-  if (type === '[object Uint8Array]') {
-    return 'uint8array';
+  if (isGeneratorObj(val)) {
+    return 'generator';
   }
-  if (type === '[object Uint8ClampedArray]') {
-    return 'uint8clampedarray';
-  }
-  if (type === '[object Int16Array]') {
-    return 'int16array';
-  }
-  if (type === '[object Uint16Array]') {
-    return 'uint16array';
-  }
-  if (type === '[object Int32Array]') {
-    return 'int32array';
-  }
-  if (type === '[object Uint32Array]') {
-    return 'uint32array';
-  }
-  if (type === '[object Float32Array]') {
-    return 'float32array';
-  }
-  if (type === '[object Float64Array]') {
-    return 'float64array';
+
+  // Non-plain objects
+  type = toString.call(val);
+  switch (type) {
+    case '[object Object]': return 'object';
+    // iterators
+    case '[object Map Iterator]': return 'mapiterator';
+    case '[object Set Iterator]': return 'setiterator';
+    case '[object String Iterator]': return 'stringiterator';
+    case '[object Array Iterator]': return 'arrayiterator';
   }
 
-  // must be a plain object
-  return 'object';
+  // other
+  return type.slice(8, -1).toLowerCase().replace(/\s/g, '');
 };
+
+function ctorName(val) {
+  return val.constructor ? val.constructor.name : null;
+}
+
+function isArray(val) {
+  if (Array.isArray) return Array.isArray(val);
+  return val instanceof Array;
+}
+
+function isError(val) {
+  return val instanceof Error || (typeof val.message === 'string' && val.constructor && typeof val.constructor.stackTraceLimit === 'number');
+}
+
+function isDate(val) {
+  if (val instanceof Date) return true;
+  return typeof val.toDateString === 'function'
+    && typeof val.getDate === 'function'
+    && typeof val.setDate === 'function';
+}
+
+function isRegexp(val) {
+  if (val instanceof RegExp) return true;
+  return typeof val.flags === 'string'
+    && typeof val.ignoreCase === 'boolean'
+    && typeof val.multiline === 'boolean'
+    && typeof val.global === 'boolean';
+}
+
+function isGeneratorFn(name, val) {
+  return ctorName(name) === 'GeneratorFunction';
+}
+
+function isGeneratorObj(val) {
+  return typeof val.throw === 'function'
+    && typeof val.return === 'function'
+    && typeof val.next === 'function';
+}
+
+function isArguments(val) {
+  try {
+    if (typeof val.length === 'number' && typeof val.callee === 'function') {
+      return true;
+    }
+  } catch (err) {
+    if (err.message.indexOf('callee') !== -1) {
+      return true;
+    }
+  }
+  return false;
+}
+
+/**
+ * If you need to support Safari 5-7 (8-10 yr-old browser),
+ * take a look at https://github.com/feross/is-buffer
+ */
+
+function isBuffer(val) {
+  if (val.constructor && typeof val.constructor.isBuffer === 'function') {
+    return val.constructor.isBuffer(val);
+  }
+  return false;
+}
diff --git a/package.json b/package.json
index e649719..205487e 100644
--- a/package.json
+++ b/package.json
@@ -1,18 +1,26 @@
 {
   "name": "kind-of",
   "description": "Get the native type of a value.",
-  "version": "3.0.4",
+  "version": "6.0.1",
   "homepage": "https://github.com/jonschlinkert/kind-of",
   "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
+  "contributors": [
+    "David Fox-Powell (https://dtothefp.github.io/me)",
+    "James (https://twitter.com/aretecode)",
+    "Jon Schlinkert (http://twitter.com/jonschlinkert)",
+    "Ken Sheedlo (kensheedlo.com)",
+    "laggingreflex (https://github.com/laggingreflex)",
+    "Miguel Mota (https://miguelmota.com)",
+    "Peter deHaan (http://about.me/peterdehaan)",
+    "tunnckoCore (https://i.am.charlike.online)"
+  ],
   "repository": "jonschlinkert/kind-of",
   "bugs": {
     "url": "https://github.com/jonschlinkert/kind-of/issues"
   },
   "license": "MIT",
   "files": [
-    "index.js",
-    "LICENSE",
-    "README.md"
+    "index.js"
   ],
   "main": "index.js",
   "engines": {
@@ -22,18 +30,12 @@
     "test": "mocha",
     "prepublish": "browserify -o browser.js -e index.js -s index --bare"
   },
-  "dependencies": {
-    "is-buffer": "^1.0.2"
-  },
   "devDependencies": {
-    "ansi-bold": "^0.1.1",
-    "benchmarked": "^0.2.5",
-    "browserify": "^13.1.0",
-    "glob": "^7.0.5",
-    "gulp-format-md": "^0.1.9",
-    "mocha": "^2.5.3",
-    "type-of": "^2.0.1",
-    "typeof": "^1.0.0"
+    "benchmarked": "^2.0.0",
+    "browserify": "^14.4.0",
+    "gulp-format-md": "^1.0.0",
+    "mocha": "^4.0.1",
+    "write": "^1.0.3"
   },
   "keywords": [
     "arguments",
@@ -59,13 +61,6 @@
     "types"
   ],
   "verb": {
-    "related": {
-      "list": [
-        "is-glob",
-        "is-number",
-        "is-primitive"
-      ]
-    },
     "toc": false,
     "layout": "default",
     "tasks": [
@@ -77,7 +72,16 @@
     "lint": {
       "reflinks": true
     },
+    "related": {
+      "list": [
+        "is-glob",
+        "is-number",
+        "is-primitive"
+      ]
+    },
     "reflinks": [
+      "type-of",
+      "typeof",
       "verb"
     ]
   }
diff --git a/test/es6/index.js b/test/es6/index.js
index 7fb3097..ce681c2 100644
--- a/test/es6/index.js
+++ b/test/es6/index.js
@@ -6,14 +6,35 @@ var kindOf = require('../..');
 
 module.exports = function() {
   describe('es6 features', function() {
-    it('should work for generators', function() {
-      var gen = function * named() {return true;};
-      assert.equal(kindOf(gen), 'function');
+    it('should work for resolved promises', function() {
+      var promise = Promise.resolve(123);
+      assert.strictEqual(kindOf(promise), 'promise');
+    });
+
+    it('should work for rejected promises', function() {
+      var promise = Promise.reject(new Error('foo bar'));
+      promise.catch(function() {});
+      assert.strictEqual(kindOf(promise), 'promise');
+    });
+
+    it('should work for generator functions', function() {
+      var gen = function * named() {
+        return true;
+      };
+      assert.equal(kindOf(gen), 'generatorfunction');
+    });
+
+    it('should work for generator objects', function() {
+      var gen = function * named() {
+        return true;
+      };
+      assert.equal(kindOf(gen()), 'generator');
     });
 
     it('should work for template strings', function() {
-      var str = `Welcome buddy`;
-      assert.equal(kindOf(str), 'string');
+      /* eslint quotes: 0 */
+      var name = 'Foo';
+      assert.equal(kindOf(`Welcome ${name} buddy`), 'string');
     });
 
     it('should work for Map', function() {
@@ -48,6 +69,23 @@ module.exports = function() {
       assert.equal(kindOf(weakset.get), 'undefined');
     });
 
+    it('should work for Set Iterator', function() {
+      var SetValuesIterator = new Set().values();
+      assert.equal(kindOf(SetValuesIterator), 'setiterator');
+    });
+    it('should work for Map Iterator', function() {
+      var MapValuesIterator = new Map().values();
+      assert.equal(kindOf(MapValuesIterator), 'mapiterator');
+    });
+    it('should work for Array Iterator', function() {
+      var ArrayEntriesIterator = [].entries();
+      assert.equal(kindOf(ArrayEntriesIterator), 'arrayiterator');
+    })
+    it('should work for String Iterator', function() {
+      var StringCharIterator = ''[Symbol.iterator]();
+      assert.equal(kindOf(StringCharIterator), 'stringiterator');
+    })
+
     it('should work for Symbol', function() {
       assert.equal(kindOf(Symbol('foo')), 'symbol');
       assert.equal(kindOf(Symbol.prototype), 'symbol');
@@ -98,4 +136,4 @@ module.exports = function() {
       assert.equal(kindOf(float64array), 'float64array');
     });
   });
-};
\ No newline at end of file
+};
diff --git a/test/test.js b/test/test.js
index 418b724..4b5b65e 100644
--- a/test/test.js
+++ b/test/test.js
@@ -4,11 +4,12 @@ require('mocha');
 var assert = require('assert');
 var kindOf = require('..');
 
-var version = process.version.match(/^.(\d+)\.(\d+)/);
+var version = process.version.match(/^v(\d+)\.(\d+)\.(\d+)/);
 var major = version[1];
-var minor = version[2];
 
 describe('kindOf', function() {
+  /* eslint no-new-wrappers: 0 */
+
   describe('null and undefined', function() {
     it('should work for undefined', function() {
       assert.equal(kindOf(undefined), 'undefined');
@@ -40,8 +41,7 @@ describe('kindOf', function() {
   describe('objects', function() {
     it('should work for arguments', function() {
       (function() {
-      assert.equal(kindOf(arguments), 'arguments');
-        return;
+        assert.equal(kindOf(arguments), 'arguments');
       })();
     });
 
@@ -53,11 +53,13 @@ describe('kindOf', function() {
       function Test() {}
       var instance = new Test();
       var literal = {};
-      var create = Object.create(null);
+      var createdNull = Object.create(null);
+      var createdObj = Object.create({});
 
       assert.equal(kindOf(instance), 'object');
       assert.equal(kindOf(literal), 'object');
-      assert.equal(kindOf(create), 'object');
+      assert.equal(kindOf(createdNull), 'object');
+      assert.equal(kindOf(createdObj), 'object');
     });
 
     it('should work for dates', function() {
@@ -65,23 +67,29 @@ describe('kindOf', function() {
     });
 
     it('should work for arrays', function() {
+      /* eslint no-array-constructor: 0 */
       assert.equal(kindOf([]), 'array');
       assert.equal(kindOf([1, 2, 3]), 'array');
       assert.equal(kindOf(new Array()), 'array');
     });
 
     it('should work for regular expressions', function() {
-      assert.equal(kindOf(/[\s\S]+/), 'regexp');
-      assert.equal(kindOf(new RegExp('^' + 'foo$')), 'regexp');
+      assert.equal(kindOf(/./), 'regexp');
+      assert.equal(kindOf(new RegExp('^foo$')), 'regexp');
     });
 
     it('should work for functions', function() {
+      /* eslint no-new-func: 0 */
       assert.equal(kindOf(function() {}), 'function');
       assert.equal(kindOf(new Function()), 'function');
     });
+
+    it('should work for Errors', function() {
+      assert.equal(kindOf(new Error('')), 'error');
+    });
   });
 
-  if (major > 0 || minor > 11) {
+  if (major > 5) {
     require('./es6')();
   }
 });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-kind-of.git



More information about the Pkg-javascript-commits mailing list