diff options
author | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2018-09-20 02:56:13 +0200 |
commit | bbff7403fbf46f9ad92240ac213df8d30ef31b64 (patch) | |
tree | c58400ec5124da1c7d56b01aea83309f80a56c3b /node_modules/is-descriptor | |
parent | 003fb34971cf63466184351b4db5f7c67df4f444 (diff) |
update packages
Diffstat (limited to 'node_modules/is-descriptor')
-rw-r--r-- | node_modules/is-descriptor/node_modules/kind-of/README.md | 207 | ||||
-rw-r--r-- | node_modules/is-descriptor/node_modules/kind-of/index.js | 226 | ||||
-rw-r--r-- | node_modules/is-descriptor/node_modules/kind-of/package.json | 27 | ||||
-rw-r--r-- | node_modules/is-descriptor/package.json | 10 |
4 files changed, 236 insertions, 234 deletions
diff --git a/node_modules/is-descriptor/node_modules/kind-of/README.md b/node_modules/is-descriptor/node_modules/kind-of/README.md index 170bf3049..4b0d4a818 100644 --- a/node_modules/is-descriptor/node_modules/kind-of/README.md +++ b/node_modules/is-descriptor/node_modules/kind-of/README.md @@ -25,7 +25,7 @@ $ bower install kind-of --save ## Usage -> es5, browser and es6 ready +> es5, es6, and browser ready ```js var kindOf = require('kind-of'); @@ -42,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' @@ -75,29 +66,26 @@ kindOf(new Test()); kindOf(new Date()); //=> 'date' -kindOf([]); -//=> 'array' - kindOf([1, 2, 3]); //=> 'array' -kindOf(new Array()); -//=> 'array' - kindOf(/foo/); //=> 'regexp' kindOf(new RegExp('foo')); //=> 'regexp' +kindOf(new Error('error')); +//=> 'error' + kindOf(function () {}); //=> 'function' kindOf(function * () {}); -//=> 'function' +//=> 'generatorfunction' -kindOf(new Function()); -//=> 'function' +kindOf(Symbol('str')); +//=> 'symbol' kindOf(new Map()); //=> 'map' @@ -111,9 +99,6 @@ kindOf(new Set()); kindOf(new WeakSet()); //=> 'weakset' -kindOf(Symbol('str')); -//=> 'symbol' - kindOf(new Int8Array()); //=> 'int8array' @@ -142,79 +127,115 @@ kindOf(new Float64Array()); //=> 'float64array' ``` -## Release history +## Benchmarks -### v4.0.0 +Benchmarked against [typeof](http://github.com/CodingFu/typeof) and [type-of](https://github.com/ForbesLindesay/type-of). -**Added** +```bash +# 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) -* `promise` support + fastest is kind-of (by 161% avg) -### v5.0.0 +# 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) -**Added** + fastest is kind-of (by 196% avg) -* `Set Iterator` and `Map Iterator` support +# 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) -**Fixed** + fastest is kind-of (by 204% avg) -* Now returns `generatorfunction` for generator functions +# 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) -## Benchmarks + fastest is kind-of (by 247% avg) -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`. +# 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) -```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) + 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 ``` @@ -229,11 +250,11 @@ In 7 out of 8 cases, this library is 2x-10x faster than other top libraries incl ## Better type checking -kind-of is more correct than other type checking libs I've looked at. For example, here are some differing results from other popular libs: +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](https://github.com/CodingFu/typeof) lib -Incorrectly tests instances of custom constructors (pretty common): +Incorrectly identifies instances of custom constructors (pretty common): ```js var typeOf = require('typeof'); @@ -278,7 +299,7 @@ console.log(typeOf(new WeakSet())); Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). -<details> +</details> <details> <summary><strong>Running Tests</strong></summary> @@ -289,7 +310,7 @@ Running and reviewing unit tests is a great way to get familiarized with a libra $ npm install && npm test ``` -<details> +</details> <details> <summary><strong>Building docs</strong></summary> @@ -302,7 +323,7 @@ To generate the readme, run the following command: $ npm install -g verbose/verb#dev verb-generate-readme && verb ``` -<details> +</details> ### Related projects @@ -316,19 +337,21 @@ You might also be interested in these projects: | **Commits** | **Contributor** | | --- | --- | -| 82 | [jonschlinkert](https://github.com/jonschlinkert) | +| 98 | [jonschlinkert](https://github.com/jonschlinkert) | | 3 | [aretecode](https://github.com/aretecode) | | 2 | [miguelmota](https://github.com/miguelmota) | | 1 | [dtothefp](https://github.com/dtothefp) | +| 1 | [ianstormtaylor](https://github.com/ianstormtaylor) | | 1 | [ksheedlo](https://github.com/ksheedlo) | | 1 | [pdehaan](https://github.com/pdehaan) | | 1 | [laggingreflex](https://github.com/laggingreflex) | -| 1 | [charlike](https://github.com/charlike) | +| 1 | [charlike-old](https://github.com/charlike-old) | ### Author **Jon Schlinkert** +* [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert) * [github/jonschlinkert](https://github.com/jonschlinkert) * [twitter/jonschlinkert](https://twitter.com/jonschlinkert) @@ -339,4 +362,4 @@ Released under the [MIT License](LICENSE). *** -_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on October 13, 2017._
\ 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 December 01, 2017._
\ No newline at end of file diff --git a/node_modules/is-descriptor/node_modules/kind-of/index.js b/node_modules/is-descriptor/node_modules/kind-of/index.js index fc5cde96e..aa2bb3944 100644 --- a/node_modules/is-descriptor/node_modules/kind-of/index.js +++ b/node_modules/is-descriptor/node_modules/kind-of/index.js @@ -1,147 +1,129 @@ var toString = Object.prototype.toString; -/** - * Get the native `typeof` a value. - * - * @param {*} `val` - * @return {*} Native javascript type - */ - module.exports = function kindOf(val) { - var type = typeof val; + if (val === void 0) return 'undefined'; + if (val === null) return 'null'; - // primitivies - if (type === 'undefined') { - return 'undefined'; - } - if (val === null) { - return 'null'; - } - if (val === true || val === false || val instanceof Boolean) { - return 'boolean'; - } - if (type === 'string' || val instanceof String) { - return 'string'; - } - if (type === 'number' || val instanceof Number) { - return 'number'; + 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'; } - // functions - if (type === 'function' || val instanceof Function) { - if (typeof val.constructor.name !== 'undefined' && val.constructor.name.slice(0, 9) === 'Generator') { - return 'generatorfunction'; - } - return 'function'; - } + 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'; - // array - if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) { - return 'array'; - } + switch (ctorName(val)) { + case 'Symbol': return 'symbol'; + case 'Promise': return 'promise'; - // check for instances of RegExp and Date before calling `toString` - if (val instanceof RegExp) { - return 'regexp'; - } - if (val instanceof Date) { - return 'date'; - } + // Set, Map, WeakSet, WeakMap + case 'WeakMap': return 'weakmap'; + case 'WeakSet': return 'weakset'; + case 'Map': return 'map'; + case 'Set': return 'set'; - // other objects - type = toString.call(val); + // 8-bit typed arrays + case 'Int8Array': return 'int8array'; + case 'Uint8Array': return 'uint8array'; + case 'Uint8ClampedArray': return 'uint8clampedarray'; - if (type === '[object RegExp]') { - return 'regexp'; - } - if (type === '[object Date]') { - return 'date'; - } - if (type === '[object Arguments]') { - return 'arguments'; - } - if (type === '[object Error]') { - return 'error'; - } - if (type === '[object Promise]') { - return 'promise'; - } + // 16-bit typed arrays + case 'Int16Array': return 'int16array'; + case 'Uint16Array': return 'uint16array'; - // buffer - if (isBuffer(val)) { - return 'buffer'; + // 32-bit typed arrays + case 'Int32Array': return 'int32array'; + case 'Uint32Array': return 'uint32array'; + case 'Float32Array': return 'float32array'; + case 'Float64Array': return 'float64array'; } - // 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'; - } - - if (type === '[object Map Iterator]') { - return 'mapiterator'; - } - if (type === '[object Set Iterator]') { - return 'setiterator'; - } - if (type === '[object String Iterator]') { - return 'stringiterator'; - } - if (type === '[object Array Iterator]') { - return 'arrayiterator'; - } - - // typed arrays - if (type === '[object Int8Array]') { - return 'int8array'; + if (isGeneratorObj(val)) { + return 'generator'; } - if (type === '[object Uint8Array]') { - return 'uint8array'; - } - 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) { - return val.constructor - && typeof val.constructor.isBuffer === 'function' - && val.constructor.isBuffer(val); + if (val.constructor && typeof val.constructor.isBuffer === 'function') { + return val.constructor.isBuffer(val); + } + return false; } diff --git a/node_modules/is-descriptor/node_modules/kind-of/package.json b/node_modules/is-descriptor/node_modules/kind-of/package.json index 334235fb0..73d70aee4 100644 --- a/node_modules/is-descriptor/node_modules/kind-of/package.json +++ b/node_modules/is-descriptor/node_modules/kind-of/package.json @@ -1,7 +1,7 @@ { "name": "kind-of", "description": "Get the native type of a value.", - "version": "5.1.0", + "version": "6.0.2", "homepage": "https://github.com/jonschlinkert/kind-of", "author": "Jon Schlinkert (https://github.com/jonschlinkert)", "contributors": [ @@ -31,14 +31,11 @@ "prepublish": "browserify -o browser.js -e index.js -s index --bare" }, "devDependencies": { - "ansi-bold": "^0.1.1", - "benchmarked": "^1.1.1", + "benchmarked": "^2.0.0", "browserify": "^14.4.0", - "gulp-format-md": "^0.1.12", - "matched": "^0.4.4", - "mocha": "^3.4.2", - "type-of": "^2.0.1", - "typeof": "^1.0.0" + "gulp-format-md": "^1.0.0", + "mocha": "^4.0.1", + "write": "^1.0.3" }, "keywords": [ "arguments", @@ -64,13 +61,6 @@ "types" ], "verb": { - "related": { - "list": [ - "is-glob", - "is-number", - "is-primitive" - ] - }, "toc": false, "layout": "default", "tasks": [ @@ -82,6 +72,13 @@ "lint": { "reflinks": true }, + "related": { + "list": [ + "is-glob", + "is-number", + "is-primitive" + ] + }, "reflinks": [ "type-of", "typeof", diff --git a/node_modules/is-descriptor/package.json b/node_modules/is-descriptor/package.json index a561bfefc..87b2975b0 100644 --- a/node_modules/is-descriptor/package.json +++ b/node_modules/is-descriptor/package.json @@ -1,7 +1,7 @@ { "name": "is-descriptor", "description": "Returns true if a value has the characteristics of a valid JavaScript descriptor. Works for data descriptors and accessor descriptors.", - "version": "0.1.6", + "version": "1.0.2", "homepage": "https://github.com/jonschlinkert/is-descriptor", "author": "Jon Schlinkert (https://github.com/jonschlinkert)", "contributors": [ @@ -25,13 +25,13 @@ "test": "mocha" }, "dependencies": { - "is-accessor-descriptor": "^0.1.6", - "is-data-descriptor": "^0.1.4", - "kind-of": "^5.0.0" + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" }, "devDependencies": { "gulp-format-md": "^1.0.0", - "mocha": "^3.4.2" + "mocha": "^3.5.3" }, "keywords": [ "accessor", |