diff --git a/.eslintignore b/.eslintignore index 6791fbf312a08b..1ccb8f831baa0b 100644 --- a/.eslintignore +++ b/.eslintignore @@ -6,3 +6,4 @@ test/disabled test/tmp*/ tools/eslint node_modules +benchmark/tmp/ diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 0aed06ca55f5c3..00000000000000 --- a/.eslintrc +++ /dev/null @@ -1,149 +0,0 @@ -env: - node: true - es6: true - -parserOptions: - ecmaVersion: 2016 - -rules: - # Possible Errors - # http://eslint.org/docs/rules/#possible-errors - comma-dangle: [2, only-multiline] - no-control-regex: 2 - no-debugger: 2 - no-dupe-args: 2 - no-dupe-keys: 2 - no-duplicate-case: 2 - no-empty-character-class: 2 - no-ex-assign: 2 - no-extra-boolean-cast: 2 - no-extra-parens: [2, functions] - no-extra-semi: 2 - no-func-assign: 2 - no-invalid-regexp: 2 - no-irregular-whitespace: 2 - no-obj-calls: 2 - no-proto: 2 - no-template-curly-in-string: 2 - no-unexpected-multiline: 2 - no-unreachable: 2 - no-unsafe-negation: 2 - use-isnan: 2 - valid-typeof: 2 - - # Best Practices - # http://eslint.org/docs/rules/#best-practices - dot-location: [2, property] - no-fallthrough: 2 - no-global-assign: 2 - no-multi-spaces: 2 - no-octal: 2 - no-redeclare: 2 - no-self-assign: 2 - no-unused-labels: 2 - no-useless-call: 2 - no-useless-escape: 2 - no-void: 2 - no-with: 2 - - # Strict Mode - # http://eslint.org/docs/rules/#strict-mode - strict: [2, global] - - # Variables - # http://eslint.org/docs/rules/#variables - no-delete-var: 2 - no-undef: 2 - no-unused-vars: [2, {args: none}] - - # Node.js and CommonJS - # http://eslint.org/docs/rules/#nodejs-and-commonjs - no-mixed-requires: 2 - no-new-require: 2 - no-path-concat: 2 - no-restricted-modules: [2, sys, _linklist] - no-restricted-properties: [2, { - object: assert, - property: deepEqual, - message: Please use assert.deepStrictEqual(). - }, { - property: __defineGetter__, - message: __defineGetter__ is deprecated. - }, { - property: __defineSetter__, - message: __defineSetter__ is deprecated. - }] - - # Stylistic Issues - # http://eslint.org/docs/rules/#stylistic-issues - block-spacing: 2 - brace-style: [2, 1tbs, {allowSingleLine: true}] - comma-spacing: 2 - comma-style: 2 - computed-property-spacing: 2 - eol-last: 2 - func-call-spacing: 2 - func-name-matching: 2 - indent: [2, 2, {SwitchCase: 1, MemberExpression: 1}] - key-spacing: [2, {mode: minimum}] - keyword-spacing: 2 - linebreak-style: [2, unix] - max-len: [2, 80, 2] - new-parens: 2 - no-mixed-spaces-and-tabs: 2 - no-multiple-empty-lines: [2, {max: 2, maxEOF: 0, maxBOF: 0}] - no-tabs: 2 - no-trailing-spaces: 2 - operator-linebreak: [2, after] - quotes: [2, single, avoid-escape] - semi: 2 - semi-spacing: 2 - space-before-blocks: [2, always] - space-before-function-paren: [2, never] - space-in-parens: [2, never] - space-infix-ops: 2 - space-unary-ops: 2 - - # ECMAScript 6 - # http://eslint.org/docs/rules/#ecmascript-6 - arrow-parens: [2, always] - arrow-spacing: [2, {before: true, after: true}] - constructor-super: 2 - no-class-assign: 2 - no-confusing-arrow: 2 - no-const-assign: 2 - no-dupe-class-members: 2 - no-new-symbol: 2 - no-this-before-super: 2 - prefer-const: [2, {ignoreReadBeforeAssign: true}] - rest-spread-spacing: 2 - template-curly-spacing: 2 - - # Custom rules in tools/eslint-rules - align-function-arguments: 2 - align-multiline-assignment: 2 - assert-fail-single-argument: 2 - assert-throws-arguments: [2, { requireTwo: false }] - new-with-error: [2, Error, RangeError, TypeError, SyntaxError, ReferenceError] - no-useless-regex-char-class-escape: [2, { override: ['[', ']'] }] - -# Global scoped method and vars -globals: - COUNTER_HTTP_CLIENT_REQUEST: false - COUNTER_HTTP_CLIENT_RESPONSE: false - COUNTER_HTTP_SERVER_REQUEST: false - COUNTER_HTTP_SERVER_RESPONSE: false - COUNTER_NET_SERVER_CONNECTION: false - COUNTER_NET_SERVER_CONNECTION_CLOSE: false - DTRACE_HTTP_CLIENT_REQUEST: false - DTRACE_HTTP_CLIENT_RESPONSE: false - DTRACE_HTTP_SERVER_REQUEST: false - DTRACE_HTTP_SERVER_RESPONSE: false - DTRACE_NET_SERVER_CONNECTION: false - DTRACE_NET_STREAM_END: false - LTTNG_HTTP_CLIENT_REQUEST: false - LTTNG_HTTP_CLIENT_RESPONSE: false - LTTNG_HTTP_SERVER_REQUEST: false - LTTNG_HTTP_SERVER_RESPONSE: false - LTTNG_NET_SERVER_CONNECTION: false - LTTNG_NET_STREAM_END: false diff --git a/.eslintrc.yaml b/.eslintrc.yaml new file mode 100644 index 00000000000000..4f691caefd3a78 --- /dev/null +++ b/.eslintrc.yaml @@ -0,0 +1,156 @@ +env: + node: true + es6: true + +parserOptions: + ecmaVersion: 2016 + +rules: + # Possible Errors + # http://eslint.org/docs/rules/#possible-errors + comma-dangle: [2, only-multiline] + no-control-regex: 2 + no-debugger: 2 + no-dupe-args: 2 + no-dupe-keys: 2 + no-duplicate-case: 2 + no-empty-character-class: 2 + no-ex-assign: 2 + no-extra-boolean-cast: 2 + no-extra-parens: [2, functions] + no-extra-semi: 2 + no-func-assign: 2 + no-invalid-regexp: 2 + no-irregular-whitespace: 2 + no-obj-calls: 2 + no-proto: 2 + no-template-curly-in-string: 2 + no-unexpected-multiline: 2 + no-unreachable: 2 + no-unsafe-negation: 2 + use-isnan: 2 + valid-typeof: 2 + + # Best Practices + # http://eslint.org/docs/rules/#best-practices + dot-location: [2, property] + no-fallthrough: 2 + no-global-assign: 2 + no-multi-spaces: 2 + no-octal: 2 + no-redeclare: 2 + no-self-assign: 2 + no-unused-labels: 2 + no-useless-call: 2 + no-useless-escape: 2 + no-void: 2 + no-with: 2 + + # Strict Mode + # http://eslint.org/docs/rules/#strict-mode + strict: [2, global] + + # Variables + # http://eslint.org/docs/rules/#variables + no-delete-var: 2 + no-undef: 2 + no-unused-vars: [2, {args: none}] + + # Node.js and CommonJS + # http://eslint.org/docs/rules/#nodejs-and-commonjs + no-mixed-requires: 2 + no-new-require: 2 + no-path-concat: 2 + no-restricted-modules: [2, sys, _linklist] + no-restricted-properties: + - 2 + - object: assert + property: deepEqual + message: Use assert.deepStrictEqual(). + - object: assert + property: equal + message: Use assert.strictEqual() rather than assert.equal(). + - object: assert + property: notEqual + message: Use assert.notStrictEqual() rather than assert.notEqual(). + - property: __defineGetter__ + message: __defineGetter__ is deprecated. + - property: __defineSetter__, + message: __defineSetter__ is deprecated. + + # Stylistic Issues + # http://eslint.org/docs/rules/#stylistic-issues + block-spacing: 2 + brace-style: [2, 1tbs, {allowSingleLine: true}] + comma-spacing: 2 + comma-style: 2 + computed-property-spacing: 2 + eol-last: 2 + func-call-spacing: 2 + func-name-matching: 2 + indent: [2, 2, {ArrayExpression: first, + CallExpression: {arguments: first}, + MemberExpression: 1, + ObjectExpression: first, + SwitchCase: 1}] + key-spacing: [2, {mode: minimum}] + keyword-spacing: 2 + linebreak-style: [2, unix] + max-len: [2, 80, 2] + new-parens: 2 + no-mixed-spaces-and-tabs: 2 + no-multiple-empty-lines: [2, {max: 2, maxEOF: 0, maxBOF: 0}] + no-tabs: 2 + no-trailing-spaces: 2 + operator-linebreak: [2, after] + quotes: [2, single, avoid-escape] + semi: 2 + semi-spacing: 2 + space-before-blocks: [2, always] + space-before-function-paren: [2, never] + space-in-parens: [2, never] + space-infix-ops: 2 + space-unary-ops: 2 + + # ECMAScript 6 + # http://eslint.org/docs/rules/#ecmascript-6 + arrow-parens: [2, always] + arrow-spacing: [2, {before: true, after: true}] + constructor-super: 2 + no-class-assign: 2 + no-confusing-arrow: 2 + no-const-assign: 2 + no-dupe-class-members: 2 + no-new-symbol: 2 + no-this-before-super: 2 + prefer-const: [2, {ignoreReadBeforeAssign: true}] + rest-spread-spacing: 2 + template-curly-spacing: 2 + + # Custom rules in tools/eslint-rules + align-multiline-assignment: 2 + assert-fail-single-argument: 2 + assert-throws-arguments: [2, { requireTwo: false }] + new-with-error: [2, Error, RangeError, TypeError, SyntaxError, ReferenceError] + timer-arguments: 2 + +# Global scoped method and vars +globals: + COUNTER_HTTP_CLIENT_REQUEST: false + COUNTER_HTTP_CLIENT_RESPONSE: false + COUNTER_HTTP_SERVER_REQUEST: false + COUNTER_HTTP_SERVER_RESPONSE: false + COUNTER_NET_SERVER_CONNECTION: false + COUNTER_NET_SERVER_CONNECTION_CLOSE: false + DTRACE_HTTP_CLIENT_REQUEST: false + DTRACE_HTTP_CLIENT_RESPONSE: false + DTRACE_HTTP_SERVER_REQUEST: false + DTRACE_HTTP_SERVER_RESPONSE: false + DTRACE_NET_SERVER_CONNECTION: false + DTRACE_NET_STREAM_END: false + LTTNG_HTTP_CLIENT_REQUEST: false + LTTNG_HTTP_CLIENT_RESPONSE: false + LTTNG_HTTP_SERVER_REQUEST: false + LTTNG_HTTP_SERVER_RESPONSE: false + LTTNG_NET_SERVER_CONNECTION: false + LTTNG_NET_STREAM_END: false diff --git a/AUTHORS b/AUTHORS index f52fb4d2d72c28..6d4c9842d4774c 100644 --- a/AUTHORS +++ b/AUTHORS @@ -935,7 +935,7 @@ Felix Becker Igor Klopov Tsarevich Dmitry Ojas Shirekar -Noah Rose +Noah Rose Ledesma Rafael Cepeda Chinedu Francis Nwafili Braydon Fuller diff --git a/BUILDING.md b/BUILDING.md index b98bb75d79b656..75ef93f8c73a13 100644 --- a/BUILDING.md +++ b/BUILDING.md @@ -109,7 +109,8 @@ Prerequisites: * One of: * [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools) * [Visual Studio 2015 Update 3](https://www.visualstudio.com/), all editions - including the Community edition. + including the Community edition (remember to select + "Common Tools for Visual C++ 2015" feature during installation). * Basic Unix tools required for some tests, [Git for Windows](http://git-scm.com/download/win) includes Git Bash and tools which can be included in the global `PATH`. @@ -121,7 +122,7 @@ Prerequisites: To run the tests: ```console -> .\vcbuild test +> .\vcbuild nosign test ``` To test if Node.js was built correctly: @@ -179,7 +180,7 @@ $ ./configure --with-intl=full-icu --download=all ##### Windows: ```console -> .\vcbuild full-icu download-all +> .\vcbuild nosign full-icu download-all ``` #### Building without Intl support @@ -196,7 +197,7 @@ $ ./configure --without-intl ##### Windows: ```console -> .\vcbuild without-intl +> .\vcbuild nosign without-intl ``` #### Use existing installed ICU (Unix / OS X only): @@ -239,7 +240,7 @@ First unpack latest ICU to `deps/icu` as `deps/icu` (You'll have: `deps/icu/source/...`) ```console -> .\vcbuild full-icu +> .\vcbuild nosign full-icu ``` ## Building Node.js with FIPS-compliant OpenSSL diff --git a/CHANGELOG.md b/CHANGELOG.md index 4be43de6d81fbb..2f02748767dad7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,8 @@ release. - 7.4.0
+ 7.5.0
+ 7.4.0
7.3.0
7.2.1
7.2.0
diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index 32533304fecc67..7ac8f49ee09ff0 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -120,6 +120,7 @@ information regarding the change process: for an issue, and/or the hash and commit message if the commit fixes a bug in a previous commit. Multiple `Fixes:` lines may be added if appropriate. +- A `Refs:` line referencing a URL for any relevant background. - A `Reviewed-By: Name ` line for yourself and any other Collaborators who have reviewed the change. - Useful for @mentions / contact list if something goes wrong in the PR. @@ -318,9 +319,8 @@ CTC for further discussion. #### How are LTS Branches Managed? -There are currently three LTS branches: `v4.x`, `v0.10`, and `v0.12`. Each -of these is paired with a "staging" branch: `v4.x-staging`, `v0.10-staging`, -and `v0.12-staging`. +There are currently two LTS branches: `v6.x` and `v4.x`. Each of these is paired +with a "staging" branch: `v6.x-staging` and `v4.x-staging`. As commits land in `master`, they are cherry-picked back to each staging branch as appropriate. If the commit applies only to the LTS branch, the @@ -341,18 +341,14 @@ please feel free to include that information in the PR thread. Several LTS related issue and PR labels have been provided: +* `lts-watch-v6.x` - tells the LTS WG that the issue/PR needs to be considered + for landing in the `v6.x-staging` branch. * `lts-watch-v4.x` - tells the LTS WG that the issue/PR needs to be considered for landing in the `v4.x-staging` branch. -* `lts-watch-v0.10` - tells the LTS WG that the issue/PR needs to be considered - for landing in the `v0.10-staging` branch. -* `lts-watch-v0.12` - tells the LTS WG that the issue/PR needs to be considered - for landing in the `v0.12-staging` branch. +* `land-on-v6.x` - tells the release team that the commit should be landed + in a future v6.x release * `land-on-v4.x` - tells the release team that the commit should be landed in a future v4.x release -* `land-on-v0.10` - tells the release team that the commit should be landed - in a future v0.10 release -* `land-on-v0.12` - tells the release team that the commit should be landed - in a future v0.12 release Any collaborator can attach these labels to any PR/issue. As commits are landed into the staging branches, the `lts-watch-` label will be removed. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6d419aa4954fde..736a9542c42baf 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -136,10 +136,13 @@ Check the output of `git log --oneline files_that_you_changed` to find out what subsystem (or subsystems) your changes touch. If your patch fixes an open issue, you can add a reference to it at the end -of the log. Use the `Fixes:` prefix and the full issue URL. For example: +of the log. Use the `Fixes:` prefix and the full issue URL. For other references +use `Refs:`. For example: ```txt Fixes: https://github.com/nodejs/node/issues/1337 +Refs: http://eslint.org/docs/rules/space-in-parens.html +Refs: https://github.com/nodejs/node/pull/3615 ``` ### Step 4: Rebase @@ -167,7 +170,7 @@ $ ./configure && make -j4 test Windows: ```text -> vcbuild test + .\vcbuild nosign test ``` (See the [BUILDING.md](./BUILDING.md) for more details.) @@ -175,11 +178,11 @@ Windows: Make sure the linter is happy and that all tests pass. Please, do not submit patches that fail either check. -Running `make test`/`vcbuild test` will run the linter as well unless one or +Running `make test`/`.\vcbuild nosign test` will run the linter as well unless one or more tests fail. If you want to run the linter without running tests, use -`make lint`/`vcbuild jslint`. +`make lint`/`.\vcbuild nosign jslint`. If you are updating tests and just want to run a single test to check it, you can use this syntax to run it exactly as the test harness would: diff --git a/Makefile b/Makefile index d17930776f3d67..7cd85983708fbd 100644 --- a/Makefile +++ b/Makefile @@ -300,6 +300,11 @@ test-v8 test-v8-intl test-v8-benchmarks test-v8-all: "$ git clone https://github.com/nodejs/node.git" endif +# Google Analytics ID used for tracking API docs page views, empty +# DOCS_ANALYTICS means no tracking scripts will be included in the +# generated .html files +DOCS_ANALYTICS ?= + apidoc_sources = $(wildcard doc/api/*.md) apidocs_html = $(apidoc_dirs) $(apiassets) $(addprefix out/,$(apidoc_sources:.md=.html)) apidocs_json = $(apidoc_dirs) $(apiassets) $(addprefix out/,$(apidoc_sources:.md=.json)) @@ -333,7 +338,8 @@ out/doc/api/%.json: doc/api/%.md [ -x $(NODE) ] && $(NODE) $(gen-json) || node $(gen-json) # check if ./node is actually set, else use user pre-installed binary -gen-html = tools/doc/generate.js --node-version=$(FULLVERSION) --format=html --template=doc/template.html $< > $@ +gen-html = tools/doc/generate.js --node-version=$(FULLVERSION) --format=html \ + --template=doc/template.html --analytics=$(DOCS_ANALYTICS) $< > $@ out/doc/api/%.html: doc/api/%.md @[ -e tools/doc/node_modules/js-yaml/package.json ] || \ [ -e tools/eslint/node_modules/js-yaml/package.json ] || \ @@ -587,7 +593,7 @@ ifeq ($(XZ), 0) ssh $(STAGINGSERVER) "touch nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/node-$(FULLVERSION).tar.xz.done" endif -doc-upload: tar +doc-upload: doc ssh $(STAGINGSERVER) "mkdir -p nodejs/$(DISTTYPEDIR)/$(FULLVERSION)" chmod -R ug=rw-x+X,o=r+X out/doc/ scp -pr out/doc/ $(STAGINGSERVER):nodejs/$(DISTTYPEDIR)/$(FULLVERSION)/docs/ diff --git a/README.md b/README.md index 3bc0bea7020e8b..0ff8e13791a96a 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,8 @@ more information about the governance of the Node.js project, see **Julien Gilli** <jgilli@nodejs.org> * [mscdex](https://github.com/mscdex) - **Brian White** <mscdex@mscdex.net> +* [MylesBorins](https://github.com/MylesBorins) - +**Myles Borins** <myles.borins@gmail.com> * [ofrobots](https://github.com/ofrobots) - **Ali Ijaz Sheikh** <ofrobots@google.com> * [rvagg](https://github.com/rvagg) - @@ -186,8 +188,6 @@ more information about the governance of the Node.js project, see **Shigeki Ohtsu** <ohtsu@iij.ad.jp> * [targos](https://github.com/targos) - **Michaël Zasso** <targos@protonmail.com> -* [TheAlphaNerd](https://github.com/TheAlphaNerd) - -**Myles Borins** <myles.borins@gmail.com> * [thefourtheye](https://github.com/thefourtheye) - **Sakthipriyan Vairamani** <thechargingvolcano@gmail.com> * [trevnorris](https://github.com/trevnorris) - @@ -197,6 +197,8 @@ more information about the governance of the Node.js project, see ### Collaborators +* [abouthiroppy](https://github.com/abouthiroppy) - +**Yuta Hiroto** <hello@about-hiroppy.com> * [ak239](https://github.com/ak239) - **Aleksei Koziatinskii** <ak239spb@gmail.com> * [andrasq](https://github.com/andrasq) - @@ -219,6 +221,8 @@ more information about the governance of the Node.js project, see **Claudio Rodriguez** <cjrodr@yahoo.com> * [danbev](https://github.com/danbev) - **Daniel Bevenius** <daniel.bevenius@gmail.com> +* [edsadr](https://github.com/edsadr) - +**Adrian Estrada** <edsadr@gmail.com> * [eljefedelrodeodeljefe](https://github.com/eljefedelrodeodeljefe) - **Robert Jefe Lindstaedt** <robert.lindstaedt@gmail.com> * [estliberitas](https://github.com/estliberitas) - @@ -327,6 +331,8 @@ more information about the governance of the Node.js project, see **Glen Keane** <glenkeane.94@gmail.com> * [thlorenz](https://github.com/thlorenz) - **Thorsten Lorenz** <thlorenz@gmx.de> +* [TimothyGu](https://github.com/TimothyGu) - +**Timothy Gu** <timothygu99@gmail.com> * [tunniclm](https://github.com/tunniclm) - **Mike Tunnicliffe** <m.j.tunnicliffe@gmail.com> * [vkurchatkin](https://github.com/vkurchatkin) - @@ -346,8 +352,6 @@ project. Releases of Node.js and io.js will be signed with one of the following GPG keys: -* **Chris Dickinson** <christopher.s.dickinson@gmail.com> -`9554F04D7259F04124DE6B476D5A82AC7E37093B` * **Colin Ihrig** <cjihrig@gmail.com> `94AE36675C464D64BAFA68DD7434390BDBE9B9C5` * **Evan Lucas** <evanlucas@me.com> @@ -364,7 +368,6 @@ Releases of Node.js and io.js will be signed with one of the following GPG keys: The full set of trusted release keys can be imported by running: ```shell -gpg --keyserver pool.sks-keyservers.net --recv-keys 9554F04D7259F04124DE6B476D5A82AC7E37093B gpg --keyserver pool.sks-keyservers.net --recv-keys 94AE36675C464D64BAFA68DD7434390BDBE9B9C5 gpg --keyserver pool.sks-keyservers.net --recv-keys FD3A5288F042B6850C66B31F09FE44734EB7990E gpg --keyserver pool.sks-keyservers.net --recv-keys 71DCFD284A79C3B38668286BC97EC7A07EDE3FC1 @@ -379,6 +382,8 @@ on what to do with these keys to verify that a downloaded file is official. Previous releases of Node.js have been signed with one of the following GPG keys: +* **Chris Dickinson** <christopher.s.dickinson@gmail.com> +`9554F04D7259F04124DE6B476D5A82AC7E37093B` * **Isaac Z. Schlueter** <i@izs.me> `93C7E9E91B49E432C2F75674B0A78B0A6C481CF6` * **Julien Gilli** <jgilli@fastmail.fm> diff --git a/WORKING_GROUPS.md b/WORKING_GROUPS.md index 0367165a81a5d2..6ba06c9cafa697 100644 --- a/WORKING_GROUPS.md +++ b/WORKING_GROUPS.md @@ -42,7 +42,6 @@ Top Level Working Group](https://github.com/nodejs/TSC/blob/master/WORKING_GROUP * [Benchmarking](#benchmarking) * [Post-mortem](#post-mortem) * [Intl](#intl) -* [HTTP](#http) * [Documentation](#documentation) * [Testing](#testing) @@ -189,21 +188,6 @@ Responsibilities include: * Publishing regular update summaries and other promotional content. -### [HTTP](https://github.com/nodejs/http) - -The HTTP Working Group is chartered for the support and improvement of the -HTTP implementation in Node.js. - -Responsibilities include: -* Addressing HTTP issues on the Node.js issue tracker. -* Authoring and editing HTTP documentation within the Node.js project. -* Reviewing changes to HTTP functionality within the Node.js project. -* Working with the ecosystem of HTTP related module developers to evolve the - HTTP implementation and APIs in core. -* Advising the CTC on all HTTP related issues and discussions. -* Messaging about the future of HTTP to give the community advance notice of - changes. - ### [Docker](https://github.com/nodejs/docker-iojs) The Docker Working Group's purpose is to build, maintain, and improve official diff --git a/benchmark/README.md b/benchmark/README.md index aa198f2b414444..8796e1e7b6ad38 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -161,7 +161,7 @@ For analysing the benchmark results use the `compare.R` tool. ```console $ cat compare-pr-5134.csv | Rscript benchmark/compare.R - improvement significant p.value + improvement confidence p.value string_decoder/string-decoder.js n=250000 chunk=1024 inlen=1024 encoding=ascii 12.46 % *** 1.165345e-04 string_decoder/string-decoder.js n=250000 chunk=1024 inlen=1024 encoding=base64-ascii 24.70 % *** 1.820615e-15 string_decoder/string-decoder.js n=250000 chunk=1024 inlen=1024 encoding=base64-utf8 23.60 % *** 2.105625e-12 @@ -171,7 +171,7 @@ string_decoder/string-decoder.js n=250000 chunk=1024 inlen=128 encoding=ascii ``` In the output, _improvement_ is the relative improvement of the new version, -hopefully this is positive. _significant_ tells if there is enough +hopefully this is positive. _confidence_ tells if there is enough statistical evidence to validate the _improvement_. If there is enough evidence then there will be at least one star (`*`), more stars is just better. **However if there are no stars, then you shouldn't make any conclusions based on the @@ -189,7 +189,7 @@ may require more runs to obtain (can be set with `--runs`). _For the statistically minded, the R script performs an [independent/unpaired 2-group t-test][t-test], with the null hypothesis that the performance is the -same for both versions. The significant field will show a star if the p-value +same for both versions. The confidence field will show a star if the p-value is less than `0.05`._ The `compare.R` tool can also produce a box plot by using the `--plot filename` @@ -202,7 +202,7 @@ keep the first line since that contains the header information. ```console $ cat compare-pr-5134.csv | sed '1p;/encoding=ascii/!d' | Rscript benchmark/compare.R --plot compare-plot.png - improvement significant p.value + improvement confidence p.value string_decoder/string-decoder.js n=250000 chunk=1024 inlen=1024 encoding=ascii 12.46 % *** 1.165345e-04 string_decoder/string-decoder.js n=250000 chunk=1024 inlen=128 encoding=ascii 6.70 % * 2.928003e-02 string_decoder/string-decoder.js n=250000 chunk=1024 inlen=32 encoding=ascii 7.47 % *** 5.780583e-04 diff --git a/benchmark/_benchmark_progress.js b/benchmark/_benchmark_progress.js new file mode 100644 index 00000000000000..2a2a458c5c4e4b --- /dev/null +++ b/benchmark/_benchmark_progress.js @@ -0,0 +1,120 @@ +'use strict'; + +const readline = require('readline'); + +function pad(input, minLength, fill) { + var result = input + ''; + return fill.repeat(Math.max(0, minLength - result.length)) + result; +} + +function fraction(numerator, denominator) { + const fdenominator = denominator + ''; + const fnumerator = pad(numerator, fdenominator.length, ' '); + return `${fnumerator}/${fdenominator}`; +} + +function getTime(diff) { + const time = Math.ceil(diff[0] + diff[1] / 1e9); + const seconds = pad(time % 60, 2, '0'); + const minutes = pad(Math.floor(time / 60) % (60 * 60), 2, '0'); + const hours = pad(Math.floor(time / (60 * 60)), 2, '0'); + return `${hours}:${minutes}:${seconds}`; +} + +// A run is an item in the job queue: { binary, filename, iter } +// A config is an item in the subqueue: { binary, filename, iter, configs } +class BenchmarkProgress { + constructor(queue, benchmarks) { + this.queue = queue; // Scheduled runs. + this.benchmarks = benchmarks; // Filenames of scheduled benchmarks. + this.completedRuns = 0; // Number of completed runs. + this.scheduledRuns = queue.length; // Number of scheduled runs. + // Time when starting to run benchmarks. + this.startTime = process.hrtime(); + // Number of times each file will be run (roughly). + this.runsPerFile = queue.length / benchmarks.length; + this.currentFile = ''; // Filename of current benchmark. + this.currentFileConfig; // Configurations for current file + // Number of configurations already run for the current file. + this.completedConfig = 0; + // Total number of configurations for the current file + this.scheduledConfig = 0; + this.interval = 0; // result of setInterval for updating the elapsed time + } + + startQueue(index) { + this.kStartOfQueue = index; + this.currentFile = this.queue[index].filename; + this.interval = setInterval(() => { + if (this.completedRuns === this.scheduledRuns) { + clearInterval(this.interval); + } else { + this.updateProgress(); + } + }, 1000); + } + + startSubqueue(data, index) { + // This subqueue is generated by a new benchmark + if (data.name !== this.currentFile || index === this.kStartOfQueue) { + this.currentFile = data.name; + this.scheduledConfig = data.queueLength; + } + this.completedConfig = 0; + this.updateProgress(); + } + + completeConfig(data) { + this.completedConfig++; + this.updateProgress(); + } + + completeRun(job) { + this.completedRuns++; + this.updateProgress(); + } + + getProgress() { + // Get time as soon as possible. + const diff = process.hrtime(this.startTime); + + const completedRuns = this.completedRuns; + const scheduledRuns = this.scheduledRuns; + const finished = completedRuns === scheduledRuns; + + // Calculate numbers for fractions. + const runsPerFile = this.runsPerFile; + const completedFiles = Math.floor(completedRuns / runsPerFile); + const scheduledFiles = this.benchmarks.length; + const completedRunsForFile = finished ? runsPerFile : + completedRuns % runsPerFile; + const completedConfig = this.completedConfig; + const scheduledConfig = this.scheduledConfig; + + // Calculate the percentage. + let runRate = 0; // Rate of current incomplete run. + if (completedConfig !== scheduledConfig) { + runRate = completedConfig / scheduledConfig; + } + const completedRate = ((completedRuns + runRate) / scheduledRuns); + const percent = pad(Math.floor(completedRate * 100), 3, ' '); + + const caption = finished ? 'Done\n' : this.currentFile; + return `[${getTime(diff)}|% ${percent}` + + `| ${fraction(completedFiles, scheduledFiles)} files ` + + `| ${fraction(completedRunsForFile, runsPerFile)} runs ` + + `| ${fraction(completedConfig, scheduledConfig)} configs]` + + `: ${caption}`; + } + + updateProgress(finished) { + if (!process.stderr.isTTY || process.stdout.isTTY) { + return; + } + readline.clearLine(process.stderr); + readline.cursorTo(process.stderr, 0); + process.stderr.write(this.getProgress()); + } +} + +module.exports = BenchmarkProgress; diff --git a/benchmark/_cli.js b/benchmark/_cli.js index be2f7ffff83624..17718c4c4d757a 100644 --- a/benchmark/_cli.js +++ b/benchmark/_cli.js @@ -45,13 +45,13 @@ function CLI(usage, settings) { currentOptional = arg.slice(1); } - // Default the value to true - if (!settings.arrayArgs.includes(currentOptional)) { + if (settings.boolArgs && settings.boolArgs.includes(currentOptional)) { this.optional[currentOptional] = true; + mode = 'both'; + } else { + // expect the next value to be option related (either -- or the value) + mode = 'option'; } - - // expect the next value to be option related (either -- or the value) - mode = 'option'; } else if (mode === 'option') { // Optional arguments value diff --git a/benchmark/buffers/buffer-compare-instance-method.js b/benchmark/buffers/buffer-compare-instance-method.js index 0becbeee23a7d7..bb07326f3de218 100644 --- a/benchmark/buffers/buffer-compare-instance-method.js +++ b/benchmark/buffers/buffer-compare-instance-method.js @@ -4,26 +4,80 @@ const v8 = require('v8'); const bench = common.createBenchmark(main, { size: [16, 512, 1024, 4096, 16386], + args: [1, 2, 3, 4, 5], millions: [1] }); function main(conf) { const iter = (conf.millions >>> 0) * 1e6; const size = (conf.size >>> 0); - const b0 = new Buffer(size).fill('a'); - const b1 = new Buffer(size).fill('a'); + const args = (conf.args >>> 0); + const b0 = Buffer.alloc(size, 'a'); + const b1 = Buffer.alloc(size, 'a'); + const b0Len = b0.length; + const b1Len = b1.length; + var i; b1[size - 1] = 'b'.charCodeAt(0); // Force optimization before starting the benchmark - b0.compare(b1); + switch (args) { + case 2: + b0.compare(b1, 0); + break; + case 3: + b0.compare(b1, 0, b1Len); + break; + case 4: + b0.compare(b1, 0, b1Len, 0); + break; + case 5: + b0.compare(b1, 0, b1Len, 0, b0Len); + break; + default: + b0.compare(b1); + } v8.setFlagsFromString('--allow_natives_syntax'); eval('%OptimizeFunctionOnNextCall(b0.compare)'); - b0.compare(b1); - - bench.start(); - for (var i = 0; i < iter; i++) { - b0.compare(b1); + switch (args) { + case 2: + b0.compare(b1, 0); + bench.start(); + for (i = 0; i < iter; i++) { + b0.compare(b1, 0); + } + bench.end(iter / 1e6); + break; + case 3: + b0.compare(b1, 0, b1Len); + bench.start(); + for (i = 0; i < iter; i++) { + b0.compare(b1, 0, b1Len); + } + bench.end(iter / 1e6); + break; + case 4: + b0.compare(b1, 0, b1Len, 0); + bench.start(); + for (i = 0; i < iter; i++) { + b0.compare(b1, 0, b1Len, 0); + } + bench.end(iter / 1e6); + break; + case 5: + b0.compare(b1, 0, b1Len, 0, b0Len); + bench.start(); + for (i = 0; i < iter; i++) { + b0.compare(b1, 0, b1Len, 0, b0Len); + } + bench.end(iter / 1e6); + break; + default: + b0.compare(b1); + bench.start(); + for (i = 0; i < iter; i++) { + b0.compare(b1); + } + bench.end(iter / 1e6); } - bench.end(iter / 1e6); } diff --git a/benchmark/buffers/buffer-tojson.js b/benchmark/buffers/buffer-tojson.js new file mode 100644 index 00000000000000..1be59952c3fe60 --- /dev/null +++ b/benchmark/buffers/buffer-tojson.js @@ -0,0 +1,18 @@ +'use strict'; + +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + n: [1e4], + len: [0, 10, 256, 4 * 1024] +}); + +function main(conf) { + var n = +conf.n; + var buf = Buffer.allocUnsafe(+conf.len); + + bench.start(); + for (var i = 0; i < n; ++i) + buf.toJSON(); + bench.end(n); +} diff --git a/benchmark/child_process/child-process-read-ipc.js b/benchmark/child_process/child-process-read-ipc.js index 28f2b6f9272772..30dead18032f98 100644 --- a/benchmark/child_process/child-process-read-ipc.js +++ b/benchmark/child_process/child-process-read-ipc.js @@ -1,14 +1,20 @@ 'use strict'; if (process.argv[2] === 'child') { const len = +process.argv[3]; - const msg = `"${'.'.repeat(len)}"`; - while (true) { - process.send(msg); - } + const msg = '.'.repeat(len); + const send = () => { + while (process.send(msg)); + // Wait: backlog of unsent messages exceeds threshold + setImmediate(send); + }; + send(); } else { const common = require('../common.js'); const bench = common.createBenchmark(main, { - len: [64, 256, 1024, 4096, 32768], + len: [ + 64, 256, 1024, 4096, 16384, 65536, + 65536 << 4, 65536 << 8 + ], dur: [5] }); const spawn = require('child_process').spawn; @@ -18,7 +24,7 @@ if (process.argv[2] === 'child') { const dur = +conf.dur; const len = +conf.len; - const options = { 'stdio': ['ignore', 'ignore', 'ignore', 'ipc'] }; + const options = { 'stdio': ['ignore', 1, 2, 'ipc'] }; const child = spawn(process.argv[0], [process.argv[1], 'child', len], options); @@ -29,8 +35,7 @@ if (process.argv[2] === 'child') { setTimeout(function() { child.kill(); - const gbits = (bytes * 8) / (1024 * 1024 * 1024); - bench.end(gbits); + bench.end(bytes); }, dur * 1000); } } diff --git a/benchmark/common.js b/benchmark/common.js index 9e7253504f9e7e..6a9b2ba0f71681 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -128,6 +128,14 @@ Benchmark.prototype.http = function(options, cb) { Benchmark.prototype._run = function() { const self = this; + // If forked, report to the parent. + if (process.send) { + process.send({ + type: 'config', + name: this.name, + queueLength: this.queue.length + }); + } (function recursive(queueIndex) { const config = self.queue[queueIndex]; @@ -195,8 +203,9 @@ function formatResult(data) { conf += ' ' + key + '=' + JSON.stringify(data.conf[key]); } - const rate = Math.floor(data.rate) - .toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + var rate = data.rate.toString().split('.'); + rate[0] = rate[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + rate = (rate[1] ? rate.join('.') : rate[0]); return `${data.name}${conf}: ${rate}`; } @@ -216,7 +225,8 @@ Benchmark.prototype.report = function(rate, elapsed) { name: this.name, conf: this.config, rate: rate, - time: elapsed[0] + elapsed[1] / 1e9 + time: elapsed[0] + elapsed[1] / 1e9, + type: 'report' }); }; diff --git a/benchmark/compare.R b/benchmark/compare.R index b4316ca7f81600..3f37cad74ad847 100644 --- a/benchmark/compare.R +++ b/benchmark/compare.R @@ -46,7 +46,7 @@ statistics = ddply(dat, "name", function(subdat) { improvement = sprintf("%.2f %%", ((new.mu - old.mu) / old.mu * 100)); p.value = NA; - significant = 'NA'; + confidence = 'NA'; # Check if there is enough data to calulate the calculate the p-value if (length(old.rate) > 1 && length(new.rate) > 1) { # Perform a statistics test to see of there actually is a difference in @@ -56,19 +56,19 @@ statistics = ddply(dat, "name", function(subdat) { # Add user friendly stars to the table. There should be at least one star # before you can say that there is an improvement. - significant = ''; + confidence = ''; if (p.value < 0.001) { - significant = '***'; + confidence = '***'; } else if (p.value < 0.01) { - significant = '**'; + confidence = '**'; } else if (p.value < 0.05) { - significant = '*'; + confidence = '*'; } } r = list( improvement = improvement, - significant = significant, + confidence = confidence, p.value = p.value ); return(data.frame(r)); diff --git a/benchmark/compare.js b/benchmark/compare.js index ea431b18cb4cd9..af36d1c4239edf 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -3,6 +3,7 @@ const fork = require('child_process').fork; const path = require('path'); const CLI = require('./_cli.js'); +const BenchmarkProgress = require('./_benchmark_progress.js'); // // Parse arguments @@ -13,13 +14,15 @@ const cli = CLI(`usage: ./node compare.js [options] [--] ... The output is formatted as csv, which can be processed using for example 'compare.R'. - --new ./new-node-binary new node binary (required) - --old ./old-node-binary old node binary (required) - --runs 30 number of samples - --filter pattern string to filter benchmark scripts - --set variable=value set benchmark variable (can be repeated) + --new ./new-node-binary new node binary (required) + --old ./old-node-binary old node binary (required) + --runs 30 number of samples + --filter pattern string to filter benchmark scripts + --set variable=value set benchmark variable (can be repeated) + --no-progress don't show benchmark progress indicator `, { - arrayArgs: ['set'] + arrayArgs: ['set'], + boolArgs: ['no-progress'] }); if (!cli.optional.new || !cli.optional.old) { @@ -39,6 +42,9 @@ if (benchmarks.length === 0) { // Create queue from the benchmarks list such both node versions are tested // `runs` amount of times each. +// Note: BenchmarkProgress relies on this order to estimate +// how much runs remaining for a file. All benchmarks generated from +// the same file must be run consecutively. const queue = []; for (const filename of benchmarks) { for (let iter = 0; iter < runs; iter++) { @@ -47,10 +53,20 @@ for (const filename of benchmarks) { } } } +// queue.length = binary.length * runs * benchmarks.length // Print csv header console.log('"binary", "filename", "configuration", "rate", "time"'); +const kStartOfQueue = 0; + +const showProgress = !cli.optional['no-progress']; +let progress; +if (showProgress) { + progress = new BenchmarkProgress(queue, benchmarks); + progress.startQueue(kStartOfQueue); +} + (function recursive(i) { const job = queue[i]; @@ -59,18 +75,26 @@ console.log('"binary", "filename", "configuration", "rate", "time"'); }); child.on('message', function(data) { - // Construct configuration string, " A=a, B=b, ..." - let conf = ''; - for (const key of Object.keys(data.conf)) { - conf += ' ' + key + '=' + JSON.stringify(data.conf[key]); - } - conf = conf.slice(1); + if (data.type === 'report') { + // Construct configuration string, " A=a, B=b, ..." + let conf = ''; + for (const key of Object.keys(data.conf)) { + conf += ' ' + key + '=' + JSON.stringify(data.conf[key]); + } + conf = conf.slice(1); + // Escape quotes (") for correct csv formatting + conf = conf.replace(/"/g, '""'); - // Escape quotes (") for correct csv formatting - conf = conf.replace(/"/g, '""'); - - console.log(`"${job.binary}", "${job.filename}", "${conf}", ` + - `${data.rate}, ${data.time}`); + console.log(`"${job.binary}", "${job.filename}", "${conf}", ` + + `${data.rate}, ${data.time}`); + if (showProgress) { + // One item in the subqueue has been completed. + progress.completeConfig(data); + } + } else if (showProgress && data.type === 'config') { + // The child has computed the configurations, ready to run subqueue. + progress.startSubqueue(data, i); + } }); child.once('close', function(code) { @@ -78,10 +102,13 @@ console.log('"binary", "filename", "configuration", "rate", "time"'); process.exit(code); return; } + if (showProgress) { + progress.completeRun(job); + } // If there are more benchmarks execute the next if (i + 1 < queue.length) { recursive(i + 1); } }); -})(0); +})(kStartOfQueue); diff --git a/benchmark/http/create-clientrequest.js b/benchmark/http/create-clientrequest.js new file mode 100644 index 00000000000000..76134663d00a79 --- /dev/null +++ b/benchmark/http/create-clientrequest.js @@ -0,0 +1,23 @@ +'use strict'; + +var common = require('../common.js'); +var ClientRequest = require('http').ClientRequest; + +var bench = common.createBenchmark(main, { + pathlen: [1, 8, 16, 32, 64, 128], + n: [1e6] +}); + +function main(conf) { + var pathlen = +conf.pathlen; + var n = +conf.n; + + var path = '/'.repeat(pathlen); + var opts = { path: path, createConnection: function() {} }; + + bench.start(); + for (var i = 0; i < n; i++) { + new ClientRequest(opts); + } + bench.end(n); +} diff --git a/benchmark/misc/object-property-bench.js b/benchmark/misc/object-property-bench.js new file mode 100644 index 00000000000000..8ac7683cd54d7e --- /dev/null +++ b/benchmark/misc/object-property-bench.js @@ -0,0 +1,81 @@ +'use strict'; + +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + method: ['property', 'string', 'variable', 'symbol'], + millions: [1000] +}); + +function runProperty(n) { + const object = {}; + var i = 0; + bench.start(); + for (; i < n; i++) { + object.p1 = 21; + object.p2 = 21; + object.p1 += object.p2; + } + bench.end(n / 1e6); +} + +function runString(n) { + const object = {}; + var i = 0; + bench.start(); + for (; i < n; i++) { + object['p1'] = 21; + object['p2'] = 21; + object['p1'] += object['p2']; + } + bench.end(n / 1e6); +} + +function runVariable(n) { + const object = {}; + const var1 = 'p1'; + const var2 = 'p2'; + var i = 0; + bench.start(); + for (; i < n; i++) { + object[var1] = 21; + object[var2] = 21; + object[var1] += object[var2]; + } + bench.end(n / 1e6); +} + +function runSymbol(n) { + const object = {}; + const symbol1 = Symbol('p1'); + const symbol2 = Symbol('p2'); + var i = 0; + bench.start(); + for (; i < n; i++) { + object[symbol1] = 21; + object[symbol2] = 21; + object[symbol1] += object[symbol2]; + } + bench.end(n / 1e6); +} + +function main(conf) { + const n = +conf.millions * 1e6; + + switch (conf.method) { + case 'property': + runProperty(n); + break; + case 'string': + runString(n); + break; + case 'variable': + runVariable(n); + break; + case 'symbol': + runSymbol(n); + break; + default: + throw new Error('Unexpected method'); + } +} diff --git a/benchmark/net/punycode.js b/benchmark/misc/punycode.js similarity index 100% rename from benchmark/net/punycode.js rename to benchmark/misc/punycode.js diff --git a/benchmark/net/net-c2s.js b/benchmark/net/net-c2s.js index 9b4df2f5a79fe7..7e59bc528b681c 100644 --- a/benchmark/net/net-c2s.js +++ b/benchmark/net/net-c2s.js @@ -65,8 +65,17 @@ Writer.prototype.emit = function() {}; Writer.prototype.prependListener = function() {}; +function flow() { + var dest = this.dest; + var res = dest.write(chunk, encoding); + if (!res) + dest.once('drain', this.flow); + else + process.nextTick(this.flow); +} + function Reader() { - this.flow = this.flow.bind(this); + this.flow = flow.bind(this); this.readable = true; } @@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) { return dest; }; -Reader.prototype.flow = function() { - var dest = this.dest; - var res = dest.write(chunk, encoding); - if (!res) - dest.once('drain', this.flow); - else - process.nextTick(this.flow); -}; - function server() { var reader = new Reader(); diff --git a/benchmark/net/net-pipe.js b/benchmark/net/net-pipe.js index 03db348878ede0..7d4849c4ef7bbb 100644 --- a/benchmark/net/net-pipe.js +++ b/benchmark/net/net-pipe.js @@ -65,8 +65,17 @@ Writer.prototype.emit = function() {}; Writer.prototype.prependListener = function() {}; +function flow() { + var dest = this.dest; + var res = dest.write(chunk, encoding); + if (!res) + dest.once('drain', this.flow); + else + process.nextTick(this.flow); +} + function Reader() { - this.flow = this.flow.bind(this); + this.flow = flow.bind(this); this.readable = true; } @@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) { return dest; }; -Reader.prototype.flow = function() { - var dest = this.dest; - var res = dest.write(chunk, encoding); - if (!res) - dest.once('drain', this.flow); - else - process.nextTick(this.flow); -}; - function server() { var reader = new Reader(); diff --git a/benchmark/net/net-s2c.js b/benchmark/net/net-s2c.js index 469b66a25a3ee4..a4a5b4ab4987a0 100644 --- a/benchmark/net/net-s2c.js +++ b/benchmark/net/net-s2c.js @@ -65,8 +65,17 @@ Writer.prototype.emit = function() {}; Writer.prototype.prependListener = function() {}; +function flow() { + var dest = this.dest; + var res = dest.write(chunk, encoding); + if (!res) + dest.once('drain', this.flow); + else + process.nextTick(this.flow); +} + function Reader() { - this.flow = this.flow.bind(this); + this.flow = flow.bind(this); this.readable = true; } @@ -76,15 +85,6 @@ Reader.prototype.pipe = function(dest) { return dest; }; -Reader.prototype.flow = function() { - var dest = this.dest; - var res = dest.write(chunk, encoding); - if (!res) - dest.once('drain', this.flow); - else - process.nextTick(this.flow); -}; - function server() { var reader = new Reader(); diff --git a/benchmark/querystring/querystring-parse.js b/benchmark/querystring/querystring-parse.js index d78ef99f84f3d4..fe14d95a53f0a0 100644 --- a/benchmark/querystring/querystring-parse.js +++ b/benchmark/querystring/querystring-parse.js @@ -3,35 +3,26 @@ var common = require('../common.js'); var querystring = require('querystring'); var v8 = require('v8'); -var types = [ - 'noencode', - 'multicharsep', - 'encodemany', - 'encodelast', - 'multivalue', - 'multivaluemany', - 'manypairs' -]; +var inputs = { + noencode: 'foo=bar&baz=quux&xyzzy=thud', + multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud', + encodefake: 'foo=%©ar&baz=%A©uux&xyzzy=%©ud', + encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d', + encodelast: 'foo=bar&baz=quux&xyzzy=thu%64', + multivalue: 'foo=bar&foo=baz&foo=quux&quuy=quuz', + multivaluemany: 'foo=bar&foo=baz&foo=quux&quuy=quuz&foo=abc&foo=def&' + + 'foo=ghi&foo=jkl&foo=mno&foo=pqr&foo=stu&foo=vwxyz', + manypairs: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z' +}; var bench = common.createBenchmark(main, { - type: types, + type: Object.keys(inputs), n: [1e6], }); function main(conf) { var type = conf.type; var n = conf.n | 0; - - var inputs = { - noencode: 'foo=bar&baz=quux&xyzzy=thud', - multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud', - encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d', - encodelast: 'foo=bar&baz=quux&xyzzy=thu%64', - multivalue: 'foo=bar&foo=baz&foo=quux&quuy=quuz', - multivaluemany: 'foo=bar&foo=baz&foo=quux&quuy=quuz&foo=abc&foo=def&' + - 'foo=ghi&foo=jkl&foo=mno&foo=pqr&foo=stu&foo=vwxyz', - manypairs: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z' - }; var input = inputs[type]; // Force-optimize querystring.parse() so that the benchmark doesn't get diff --git a/benchmark/querystring/querystring-unescapebuffer.js b/benchmark/querystring/querystring-unescapebuffer.js new file mode 100644 index 00000000000000..fe48a6f149bc6a --- /dev/null +++ b/benchmark/querystring/querystring-unescapebuffer.js @@ -0,0 +1,23 @@ +'use strict'; +var common = require('../common.js'); +var querystring = require('querystring'); + +var bench = common.createBenchmark(main, { + input: [ + 'there is nothing to unescape here', + 'there%20are%20several%20spaces%20that%20need%20to%20be%20unescaped', + 'there%2Qare%0-fake%escaped values in%%%%this%9Hstring', + '%20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F%30%31%32%33%34%35%36%37' + ], + n: [10e6], +}); + +function main(conf) { + var input = conf.input; + var n = conf.n | 0; + + bench.start(); + for (var i = 0; i < n; i += 1) + querystring.unescapeBuffer(input); + bench.end(n); +} diff --git a/benchmark/run.js b/benchmark/run.js index 52ce74024e1ae4..cb4f8cc00487fe 100644 --- a/benchmark/run.js +++ b/benchmark/run.js @@ -6,7 +6,7 @@ const CLI = require('./_cli.js'); const cli = CLI(`usage: ./node run.js [options] [--] ... Run each benchmark in the directory a single time, more than one - directory can be specified. + directory can be specified. --filter pattern string to filter benchmark scripts --set variable=value set benchmark variable (can be repeated) @@ -44,6 +44,9 @@ if (format === 'csv') { } child.on('message', function(data) { + if (data.type !== 'report') { + return; + } // Construct configuration string, " A=a, B=b, ..." let conf = ''; for (const key of Object.keys(data.conf)) { @@ -56,8 +59,9 @@ if (format === 'csv') { conf = conf.replace(/"/g, '""'); console.log(`"${data.name}", "${conf}", ${data.rate}, ${data.time}`); } else { - const rate = Math.floor(data.rate) - .toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + var rate = data.rate.toString().split('.'); + rate[0] = rate[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1,'); + rate = (rate[1] ? rate.join('.') : rate[0]); console.log(`${data.name} ${conf}: ${rate}`); } }); diff --git a/benchmark/scatter.js b/benchmark/scatter.js index 3003616b58eee4..65d1a5f604877d 100644 --- a/benchmark/scatter.js +++ b/benchmark/scatter.js @@ -42,6 +42,10 @@ function csvEncodeValue(value) { const child = fork(path.resolve(__dirname, filepath), cli.optional.set); child.on('message', function(data) { + if (data.type !== 'report') { + return; + } + // print csv header if (printHeader) { const confHeader = Object.keys(data.conf) diff --git a/benchmark/streams/writable-manywrites.js b/benchmark/streams/writable-manywrites.js new file mode 100644 index 00000000000000..fadafe86e4cf70 --- /dev/null +++ b/benchmark/streams/writable-manywrites.js @@ -0,0 +1,23 @@ +'use strict'; + +const common = require('../common'); +const Writable = require('stream').Writable; + +const bench = common.createBenchmark(main, { + n: [2e6] +}); + +function main(conf) { + const n = +conf.n; + const b = Buffer.allocUnsafe(1024); + const s = new Writable(); + s._write = function(chunk, encoding, cb) { + cb(); + }; + + bench.start(); + for (var k = 0; k < n; ++k) { + s.write(b); + } + bench.end(n); +} diff --git a/benchmark/misc/set-immediate-breadth-args.js b/benchmark/timers/set-immediate-breadth-args.js similarity index 100% rename from benchmark/misc/set-immediate-breadth-args.js rename to benchmark/timers/set-immediate-breadth-args.js diff --git a/benchmark/misc/set-immediate-breadth.js b/benchmark/timers/set-immediate-breadth.js similarity index 100% rename from benchmark/misc/set-immediate-breadth.js rename to benchmark/timers/set-immediate-breadth.js diff --git a/benchmark/misc/set-immediate-depth-args.js b/benchmark/timers/set-immediate-depth-args.js similarity index 100% rename from benchmark/misc/set-immediate-depth-args.js rename to benchmark/timers/set-immediate-depth-args.js diff --git a/benchmark/misc/set-immediate-depth.js b/benchmark/timers/set-immediate-depth.js similarity index 100% rename from benchmark/misc/set-immediate-depth.js rename to benchmark/timers/set-immediate-depth.js diff --git a/benchmark/timers/timers-cancel-pooled.js b/benchmark/timers/timers-cancel-pooled.js new file mode 100644 index 00000000000000..47c9fea2cb5b61 --- /dev/null +++ b/benchmark/timers/timers-cancel-pooled.js @@ -0,0 +1,32 @@ +'use strict'; +var common = require('../common.js'); +var assert = require('assert'); + +var bench = common.createBenchmark(main, { + thousands: [500], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + + var timer = setTimeout(() => {}, 1); + for (var i = 0; i < iterations; i++) { + setTimeout(cb, 1); + } + var next = timer._idlePrev; + clearTimeout(timer); + + bench.start(); + + for (var j = 0; j < iterations; j++) { + timer = next; + next = timer._idlePrev; + clearTimeout(timer); + } + + bench.end(iterations / 1e3); +} + +function cb() { + assert(false, 'Timer should not call callback'); +} diff --git a/benchmark/timers/timers-cancel-unpooled.js b/benchmark/timers/timers-cancel-unpooled.js new file mode 100644 index 00000000000000..a040fad69e1c66 --- /dev/null +++ b/benchmark/timers/timers-cancel-unpooled.js @@ -0,0 +1,26 @@ +'use strict'; +var common = require('../common.js'); +var assert = require('assert'); + +var bench = common.createBenchmark(main, { + thousands: [100], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + + var timersList = []; + for (var i = 0; i < iterations; i++) { + timersList.push(setTimeout(cb, i + 1)); + } + + bench.start(); + for (var j = 0; j < iterations + 1; j++) { + clearTimeout(timersList[j]); + } + bench.end(iterations / 1e3); +} + +function cb() { + assert(false, 'Timer ' + this._idleTimeout + ' should not call callback'); +} diff --git a/benchmark/timers/timers-insert-pooled.js b/benchmark/timers/timers-insert-pooled.js new file mode 100644 index 00000000000000..11c35319b11d69 --- /dev/null +++ b/benchmark/timers/timers-insert-pooled.js @@ -0,0 +1,18 @@ +'use strict'; +var common = require('../common.js'); + +var bench = common.createBenchmark(main, { + thousands: [500], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + + bench.start(); + + for (var i = 0; i < iterations; i++) { + setTimeout(() => {}, 1); + } + + bench.end(iterations / 1e3); +} diff --git a/benchmark/timers/timers-insert-unpooled.js b/benchmark/timers/timers-insert-unpooled.js new file mode 100644 index 00000000000000..91eabeb04e9d4f --- /dev/null +++ b/benchmark/timers/timers-insert-unpooled.js @@ -0,0 +1,27 @@ +'use strict'; +var common = require('../common.js'); +var assert = require('assert'); + +var bench = common.createBenchmark(main, { + thousands: [100], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + + var timersList = []; + + bench.start(); + for (var i = 0; i < iterations; i++) { + timersList.push(setTimeout(cb, i + 1)); + } + bench.end(iterations / 1e3); + + for (var j = 0; j < iterations + 1; j++) { + clearTimeout(timersList[j]); + } +} + +function cb() { + assert(false, 'Timer ' + this._idleTimeout + ' should not call callback'); +} diff --git a/benchmark/timers/timers-timeout-pooled.js b/benchmark/timers/timers-timeout-pooled.js new file mode 100644 index 00000000000000..feaec23237f13d --- /dev/null +++ b/benchmark/timers/timers-timeout-pooled.js @@ -0,0 +1,23 @@ +'use strict'; +var common = require('../common.js'); + +var bench = common.createBenchmark(main, { + thousands: [500], +}); + +function main(conf) { + var iterations = +conf.thousands * 1e3; + var count = 0; + + for (var i = 0; i < iterations; i++) { + setTimeout(cb, 1); + } + + bench.start(); + + function cb() { + count++; + if (count === iterations) + bench.end(iterations / 1e3); + } +} diff --git a/benchmark/url/legacy-vs-whatwg-url-get-prop.js b/benchmark/url/legacy-vs-whatwg-url-get-prop.js new file mode 100644 index 00000000000000..f703b75b16f6f7 --- /dev/null +++ b/benchmark/url/legacy-vs-whatwg-url-get-prop.js @@ -0,0 +1,109 @@ +'use strict'; +const common = require('../common.js'); +const url = require('url'); +const URL = url.URL; +const assert = require('assert'); + +const inputs = { + long: 'http://nodejs.org:89/docs/latest/api/url.html#test?' + + 'payload1=true&payload2=false&test=1&benchmark=3&' + + 'foo=38.38.011.293&bar=1234834910480&test=19299&3992&' + + 'key=f5c65e1e98fe07e648249ad41e1cfdb0', + short: 'https://nodejs.org/en/blog/', + idn: 'http://你好你好', + auth: 'https://user:pass@example.com/path?search=1', + special: 'file:///foo/bar/test/node.js', + percent: 'https://%E4%BD%A0/foo', + dot: 'https://example.org/./a/../b/./c' +}; + +const bench = common.createBenchmark(main, { + type: Object.keys(inputs), + method: ['legacy', 'whatwg'], + n: [1e5] +}); + +// At the time of writing, when using a passed property name to index +// the object, Crankshaft would generate a LoadKeyedGeneric even when it +// remains a constant in the function, so here we must use the literal +// instead to get a LoadNamedField. +function useLegacy(n, input) { + var obj = url.parse(input); + var noDead = { + protocol: obj.protocol, + auth: obj.auth, + host: obj.host, + hostname: obj.hostname, + port: obj.port, + pathname: obj.pathname, + search: obj.search, + hash: obj.hash + }; + // It's necessary to assign the values to an object + // to avoid loop invariant code motion. + bench.start(); + for (var i = 0; i < n; i += 1) { + noDead.protocol = obj.protocol; + noDead.auth = obj.auth; + noDead.host = obj.host; + noDead.hostname = obj.hostname; + noDead.port = obj.port; + noDead.pathname = obj.pathname; + noDead.search = obj.search; + noDead.hash = obj.hash; + } + bench.end(n); + return noDead; +} + +function useWHATWG(n, input) { + var obj = new URL(input); + var noDead = { + protocol: obj.protocol, + auth: obj.username + ':' + obj.password, + host: obj.host, + hostname: obj.hostname, + port: obj.port, + pathname: obj.pathname, + search: obj.search, + hash: obj.hash + }; + bench.start(); + for (var i = 0; i < n; i += 1) { + noDead.protocol = obj.protocol; + noDead.auth = obj.username + ':' + obj.password; + noDead.host = obj.host; + noDead.hostname = obj.hostname; + noDead.port = obj.port; + noDead.pathname = obj.pathname; + noDead.search = obj.search; + noDead.hash = obj.hash; + } + bench.end(n); + return noDead; +} + +function main(conf) { + const type = conf.type; + const n = conf.n | 0; + const method = conf.method; + + const input = inputs[type]; + if (!input) { + throw new Error('Unknown input type'); + } + + var noDead; // Avoid dead code elimination. + switch (method) { + case 'legacy': + noDead = useLegacy(n, input); + break; + case 'whatwg': + noDead = useWHATWG(n, input); + break; + default: + throw new Error('Unknown method'); + } + + assert.ok(noDead); +} diff --git a/benchmark/url/legacy-vs-whatwg-url-parse.js b/benchmark/url/legacy-vs-whatwg-url-parse.js new file mode 100644 index 00000000000000..ca7a48466c7dc3 --- /dev/null +++ b/benchmark/url/legacy-vs-whatwg-url-parse.js @@ -0,0 +1,69 @@ +'use strict'; +const common = require('../common.js'); +const url = require('url'); +const URL = url.URL; +const assert = require('assert'); + +const inputs = { + long: 'http://nodejs.org:89/docs/latest/api/url.html#test?' + + 'payload1=true&payload2=false&test=1&benchmark=3&' + + 'foo=38.38.011.293&bar=1234834910480&test=19299&3992&' + + 'key=f5c65e1e98fe07e648249ad41e1cfdb0', + short: 'https://nodejs.org/en/blog/', + idn: 'http://你好你好', + auth: 'https://user:pass@example.com/path?search=1', + special: 'file:///foo/bar/test/node.js', + percent: 'https://%E4%BD%A0/foo', + dot: 'https://example.org/./a/../b/./c' +}; + +const bench = common.createBenchmark(main, { + type: Object.keys(inputs), + method: ['legacy', 'whatwg'], + n: [1e5] +}); + +function useLegacy(n, input) { + var noDead = url.parse(input); + bench.start(); + for (var i = 0; i < n; i += 1) { + noDead = url.parse(input); + } + bench.end(n); + return noDead; +} + +function useWHATWG(n, input) { + var noDead = url.parse(input); + bench.start(); + for (var i = 0; i < n; i += 1) { + noDead = new URL(input); + } + bench.end(n); + return noDead; +} + +function main(conf) { + const type = conf.type; + const n = conf.n | 0; + const method = conf.method; + + const input = inputs[type]; + if (!input) { + throw new Error('Unknown input type'); + } + + var noDead; // Avoid dead code elimination. + switch (method) { + case 'legacy': + noDead = useLegacy(n, input); + break; + case 'whatwg': + noDead = useWHATWG(n, input); + break; + default: + throw new Error('Unknown method'); + } + + assert.ok(noDead); +} diff --git a/benchmark/url/legacy-vs-whatwg-url-serialize.js b/benchmark/url/legacy-vs-whatwg-url-serialize.js new file mode 100644 index 00000000000000..c0b7f5a6ce1565 --- /dev/null +++ b/benchmark/url/legacy-vs-whatwg-url-serialize.js @@ -0,0 +1,71 @@ +'use strict'; +const common = require('../common.js'); +const url = require('url'); +const URL = url.URL; +const assert = require('assert'); + +const inputs = { + long: 'http://nodejs.org:89/docs/latest/api/url.html#test?' + + 'payload1=true&payload2=false&test=1&benchmark=3&' + + 'foo=38.38.011.293&bar=1234834910480&test=19299&3992&' + + 'key=f5c65e1e98fe07e648249ad41e1cfdb0', + short: 'https://nodejs.org/en/blog/', + idn: 'http://你好你好', + auth: 'https://user:pass@example.com/path?search=1', + special: 'file:///foo/bar/test/node.js', + percent: 'https://%E4%BD%A0/foo', + dot: 'https://example.org/./a/../b/./c' +}; + +const bench = common.createBenchmark(main, { + type: Object.keys(inputs), + method: ['legacy', 'whatwg'], + n: [1e5] +}); + +function useLegacy(n, input, prop) { + var obj = url.parse(input); + var noDead = url.format(obj); + bench.start(); + for (var i = 0; i < n; i += 1) { + noDead = url.format(obj); + } + bench.end(n); + return noDead; +} + +function useWHATWG(n, input, prop) { + var obj = new URL(input); + var noDead = obj.toString(); + bench.start(); + for (var i = 0; i < n; i += 1) { + noDead = obj.toString(); + } + bench.end(n); + return noDead; +} + +function main(conf) { + const type = conf.type; + const n = conf.n | 0; + const method = conf.method; + + const input = inputs[type]; + if (!input) { + throw new Error('Unknown input type'); + } + + var noDead; // Avoid dead code elimination. + switch (method) { + case 'legacy': + noDead = useLegacy(n, input); + break; + case 'whatwg': + noDead = useWHATWG(n, input); + break; + default: + throw new Error('Unknown method'); + } + + assert.ok(noDead); +} diff --git a/benchmark/url/new-url-parse.js b/benchmark/url/new-url-parse.js deleted file mode 100644 index ef60e81847682b..00000000000000 --- a/benchmark/url/new-url-parse.js +++ /dev/null @@ -1,57 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const url = require('url'); -const v8 = require('v8'); - -const bench = common.createBenchmark(main, { - type: 'one two three four five'.split(' '), - method: ['old', 'new'], - n: [25e4] -}); - -function useOld(n, input) { - // Force-optimize url.parse() so that the benchmark doesn't get - // disrupted by the optimizer kicking in halfway through. - url.parse(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(url.parse)'); - - bench.start(); - for (var i = 0; i < n; i += 1) - url.parse(input); - bench.end(n); -} - -function useNew(n, input) { - bench.start(); - for (var i = 0; i < n; i += 1) - new url.URL(input); - bench.end(n); -} - -function main(conf) { - const type = conf.type; - const n = conf.n | 0; - const method = conf.method; - - var inputs = { - one: 'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj', - two: 'http://blog.nodejs.org/', - three: 'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en', - four: 'javascript:alert("node is awesome");', - //five: 'some.ran/dom/url.thing?oh=yes#whoo', - five: 'https://user:pass@example.com/', - }; - var input = inputs[type] || ''; - - switch (method) { - case 'old': - useOld(n, input); - break; - case 'new': - useNew(n, input); - break; - default: - throw new Error('Unknown method'); - } -} diff --git a/benchmark/url/url-searchparams-iteration.js b/benchmark/url/url-searchparams-iteration.js new file mode 100644 index 00000000000000..caa4e45c41247e --- /dev/null +++ b/benchmark/url/url-searchparams-iteration.js @@ -0,0 +1,60 @@ +'use strict'; +const common = require('../common.js'); +const assert = require('assert'); +const URLSearchParams = new (require('url').URL)('a:').searchParams.constructor; + +const bench = common.createBenchmark(main, { + method: ['forEach', 'iterator'], + n: [1e6] +}); + +const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd'; + +function forEach(n) { + const params = new URLSearchParams(str); + const noDead = []; + const cb = (val, key) => { + noDead[0] = key; + noDead[1] = val; + }; + + bench.start(); + for (var i = 0; i < n; i += 1) + params.forEach(cb); + bench.end(n); + + assert.strictEqual(noDead[0], 'three'); + assert.strictEqual(noDead[1], '3rd'); +} + +function iterator(n) { + const params = new URLSearchParams(str); + const noDead = []; + + bench.start(); + for (var i = 0; i < n; i += 1) + for (var pair of params) { + noDead[0] = pair[0]; + noDead[1] = pair[1]; + } + bench.end(n); + + assert.strictEqual(noDead[0], 'three'); + assert.strictEqual(noDead[1], '3rd'); +} + +function main(conf) { + const method = conf.method; + const n = conf.n | 0; + + switch (method) { + case 'forEach': + forEach(n); + break; + case 'iterator': + iterator(n); + break; + default: + throw new Error('Unknown method'); + } +} diff --git a/benchmark/url/url-searchparams-parse.js b/benchmark/url/url-searchparams-parse.js new file mode 100644 index 00000000000000..61796a7d327bd4 --- /dev/null +++ b/benchmark/url/url-searchparams-parse.js @@ -0,0 +1,31 @@ +'use strict'; +const common = require('../common.js'); +const URLSearchParams = new (require('url').URL)('a:').searchParams.constructor; + +const inputs = { + noencode: 'foo=bar&baz=quux&xyzzy=thud', + // multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud', + multicharsep: '&&&&&&&&&&&&&&&&&&&&&&&&&&&&', + encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d', + encodelast: 'foo=bar&baz=quux&xyzzy=thu%64', + multivalue: 'foo=bar&foo=baz&foo=quux&quuy=quuz', + multivaluemany: 'foo=bar&foo=baz&foo=quux&quuy=quuz&foo=abc&foo=def&' + + 'foo=ghi&foo=jkl&foo=mno&foo=pqr&foo=stu&foo=vwxyz', + manypairs: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z' +}; + +const bench = common.createBenchmark(main, { + type: Object.keys(inputs), + n: [1e5] +}); + +function main(conf) { + const input = inputs[conf.type]; + const n = conf.n | 0; + + var i; + bench.start(); + for (i = 0; i < n; i++) + new URLSearchParams(input); + bench.end(n); +} diff --git a/benchmark/url/url-searchparams-read.js b/benchmark/url/url-searchparams-read.js new file mode 100644 index 00000000000000..4cee49c74d2baa --- /dev/null +++ b/benchmark/url/url-searchparams-read.js @@ -0,0 +1,58 @@ +'use strict'; +const common = require('../common.js'); +const URLSearchParams = new (require('url').URL)('a:').searchParams.constructor; + +const bench = common.createBenchmark(main, { + method: ['get', 'getAll', 'has'], + param: ['one', 'two', 'three', 'nonexistent'], + n: [1e6] +}); + +const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd'; + +function get(n, param) { + const params = new URLSearchParams(str); + + bench.start(); + for (var i = 0; i < n; i += 1) + params.get(param); + bench.end(n); +} + +function getAll(n, param) { + const params = new URLSearchParams(str); + + bench.start(); + for (var i = 0; i < n; i += 1) + params.getAll(param); + bench.end(n); +} + +function has(n, param) { + const params = new URLSearchParams(str); + + bench.start(); + for (var i = 0; i < n; i += 1) + params.has(param); + bench.end(n); +} + +function main(conf) { + const method = conf.method; + const param = conf.param; + const n = conf.n | 0; + + switch (method) { + case 'get': + get(n, param); + break; + case 'getAll': + getAll(n, param); + break; + case 'has': + has(n, param); + break; + default: + throw new Error('Unknown method'); + } +} diff --git a/benchmark/url/url-searchparams-stringifier.js b/benchmark/url/url-searchparams-stringifier.js new file mode 100644 index 00000000000000..2979064b322592 --- /dev/null +++ b/benchmark/url/url-searchparams-stringifier.js @@ -0,0 +1,35 @@ +'use strict'; +const common = require('../common.js'); +const Buffer = require('buffer').Buffer; +const URLSearchParams = new (require('url').URL)('a:').searchParams.constructor; + +const inputs = { + noencode: 'foo=bar&baz=quux&xyzzy=thud', + // multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud', + multicharsep: '&&&&&&&&&&&&&&&&&&&&&&&&&&&&', + encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d', + encodelast: 'foo=bar&baz=quux&xyzzy=thu%64', + multivalue: 'foo=bar&foo=baz&foo=quux&quuy=quuz', + multivaluemany: 'foo=bar&foo=baz&foo=quux&quuy=quuz&foo=abc&foo=def&' + + 'foo=ghi&foo=jkl&foo=mno&foo=pqr&foo=stu&foo=vwxyz', + manypairs: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z' +}; + +const bench = common.createBenchmark(main, { + type: Object.keys(inputs), + n: [1e5] +}); + +function main(conf) { + const input = inputs[conf.type]; + const n = conf.n | 0; + + const params = new URLSearchParams(input); + + bench.start(); + // Using Buffer.from to prevent JS version from cheating with ropes instead + // of strings + for (var i = 0; i < n; i += 1) + Buffer.from(params.toString()); + bench.end(n); +} diff --git a/benchmark/url/whatwg-url-properties.js b/benchmark/url/whatwg-url-properties.js index a3c4d886bd3c90..375939c601d363 100644 --- a/benchmark/url/whatwg-url-properties.js +++ b/benchmark/url/whatwg-url-properties.js @@ -11,8 +11,8 @@ var bench = common.createBenchmark(main, { 'http://user:pass@foo.bar.com:21/aaa/zzz?l=24#test' ], prop: ['toString', 'href', 'origin', 'protocol', - 'username', 'password', 'host', 'hostname', 'port', - 'pathname', 'search', 'searchParams', 'hash'], + 'username', 'password', 'host', 'hostname', 'port', + 'pathname', 'search', 'searchParams', 'hash'], n: [1e4] }); diff --git a/benchmark/util/normalize-encoding.js b/benchmark/util/normalize-encoding.js new file mode 100644 index 00000000000000..8c4d03478104b0 --- /dev/null +++ b/benchmark/util/normalize-encoding.js @@ -0,0 +1,65 @@ +'use strict'; + +const common = require('../common.js'); +const assert = require('assert'); + +const groupedInputs = { + group_common: ['undefined', 'utf8', 'utf-8', 'base64', 'binary', 'latin1'], + group_upper: ['UTF-8', 'UTF8', 'UCS2', 'UTF-16LE', 'UTF16LE', 'BASE64'], + group_uncommon: [ 'foo', '1', 'false', 'undefined', '[]'], + group_misc: ['', 'utf16le', 'usc2', 'hex', 'HEX', 'BINARY'] +}; + +const inputs = [ + '', 'utf8', 'utf-8', 'UTF-8', + 'UTF8', 'Utf8', 'uTf-8', 'utF-8', 'ucs2', + 'UCS2', 'utf16le', 'utf-16le', 'UTF-16LE', 'UTF16LE', + 'binary', 'BINARY', 'latin1', 'base64', 'BASE64', + 'hex', 'HEX', 'foo', '1', 'false', 'undefined', '[]']; + +const bench = common.createBenchmark(main, { + input: inputs.concat(Object.keys(groupedInputs)), + n: [1e5] +}, { + flags: '--expose-internals' +}); + +function getInput(input) { + switch (input) { + case 'group_common': + return groupedInputs.group_common; + case 'group_upper': + return groupedInputs.group_upper; + case 'group_uncommon': + return groupedInputs.group_uncommon; + case 'group_misc': + return groupedInputs.group_misc; + case '1': + return [1]; + case 'false': + return [false]; + case 'undefined': + return [undefined]; + case '[]': + return [[]]; + default: + return [input]; + } +} + +function main(conf) { + const normalizeEncoding = require('internal/util').normalizeEncoding; + + const n = conf.n | 0; + const inputs = getInput(conf.input); + var noDead = ''; + + bench.start(); + for (var i = 0; i < n; i += 1) { + for (var j = 0; j < inputs.length; ++j) { + noDead = normalizeEncoding(inputs[j]); + } + } + bench.end(n); + assert.ok(noDead === undefined || noDead.length > 0); +} diff --git a/benchmark/vm/run-in-context.js b/benchmark/vm/run-in-context.js new file mode 100644 index 00000000000000..62ebe29146e705 --- /dev/null +++ b/benchmark/vm/run-in-context.js @@ -0,0 +1,32 @@ +'use strict'; + +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + n: [1], + breakOnSigint: [0, 1], + withSigintListener: [0, 1] +}); + +const vm = require('vm'); + +function main(conf) { + const n = +conf.n; + const options = conf.breakOnSigint ? {breakOnSigint: true} : {}; + const withSigintListener = !!conf.withSigintListener; + + process.removeAllListeners('SIGINT'); + if (withSigintListener) + process.on('SIGINT', () => {}); + + var i = 0; + + const contextifiedSandbox = vm.createContext(); + + common.v8ForceOptimization(vm.runInContext, + '0', contextifiedSandbox, options); + bench.start(); + for (; i < n; i++) + vm.runInContext('0', contextifiedSandbox, options); + bench.end(n); +} diff --git a/benchmark/vm/run-in-this-context.js b/benchmark/vm/run-in-this-context.js new file mode 100644 index 00000000000000..f66fd31a1a949e --- /dev/null +++ b/benchmark/vm/run-in-this-context.js @@ -0,0 +1,29 @@ +'use strict'; + +const common = require('../common.js'); + +const bench = common.createBenchmark(main, { + n: [1], + breakOnSigint: [0, 1], + withSigintListener: [0, 1] +}); + +const vm = require('vm'); + +function main(conf) { + const n = +conf.n; + const options = conf.breakOnSigint ? {breakOnSigint: true} : {}; + const withSigintListener = !!conf.withSigintListener; + + process.removeAllListeners('SIGINT'); + if (withSigintListener) + process.on('SIGINT', () => {}); + + var i = 0; + + common.v8ForceOptimization(vm.runInThisContext, '0', options); + bench.start(); + for (; i < n; i++) + vm.runInThisContext('0', options); + bench.end(n); +} diff --git a/configure b/configure index d926cec7d5d7ea..e12a5382a1960f 100755 --- a/configure +++ b/configure @@ -144,6 +144,11 @@ parser.add_option('--openssl-fips', dest='openssl_fips', help='Build OpenSSL using FIPS canister .o file in supplied folder') +parser.add_option('--openssl-use-def-ca-store', + action='store_true', + dest='use_openssl_ca_store', + help='Use OpenSSL supplied CA store instead of compiled-in Mozilla CA copy.') + shared_optgroup.add_option('--shared-http-parser', action='store_true', dest='shared_http_parser', @@ -940,6 +945,8 @@ def configure_openssl(o): o['variables']['node_use_openssl'] = b(not options.without_ssl) o['variables']['node_shared_openssl'] = b(options.shared_openssl) o['variables']['openssl_no_asm'] = 1 if options.openssl_no_asm else 0 + if options.use_openssl_ca_store: + o['defines'] += ['NODE_OPENSSL_CERT_STORE'] if options.openssl_fips: o['variables']['openssl_fips'] = options.openssl_fips fips_dir = os.path.join(root_dir, 'deps', 'openssl', 'fips') diff --git a/deps/npm/.travis.yml b/deps/npm/.travis.yml index 4c6548d1ecd4f7..6e1950523bdf6a 100644 --- a/deps/npm/.travis.yml +++ b/deps/npm/.travis.yml @@ -20,10 +20,6 @@ matrix: # then master - node_js: "7" env: DEPLOY_VERSION=testing - # then 0.12, which is still in maintenance mode until the end of 2016 I guess? - # https://github.com/nodejs/LTS#lts-schedule - - node_js: "0.12" - env: DEPLOY_VERSION=testing before_install: # required by test/tap/registry.js - "mkdir -p /var/run/couchdb" diff --git a/deps/npm/AUTHORS b/deps/npm/AUTHORS index 96d8ecf66c4b2c..c91ce4a2c615b8 100644 --- a/deps/npm/AUTHORS +++ b/deps/npm/AUTHORS @@ -445,3 +445,4 @@ Alex Jordan Ville Lahdenvuo Natalie Wolfe Andrew Schmadel +Jonah Moses diff --git a/deps/npm/CHANGELOG.md b/deps/npm/CHANGELOG.md index fe673ef39c098e..d879e7584a76f0 100644 --- a/deps/npm/CHANGELOG.md +++ b/deps/npm/CHANGELOG.md @@ -1,3 +1,299 @@ +### v4.1.2 (2017-01-12) + +We have a twee little release this week as we come back from the holidays. + +#### 0.12 IS UNSUPPORTED NOW (really) + +After [jumping the gun a +little](https://github.com/npm/npm/releases/tag/v4.0.2), we can now +officially remove 0.12 from our supported versions list. The Node.js +project has now officially ended even maintenance support for 0.12 and thus, +so will we. To reiterate from the last time we did this: + +What this means: + +* Your contributions will no longer block on the tests passing on 0.12. +* We will no longer block dependency upgrades on working with 0.12. +* Bugs filed on the npm CLI that are due to incompatibilities with 0.12 + (and older versions) will be closed with a strong urging to upgrade to a + supported version of Node. +* On the flip side, we'll continue to (happily!) accept patches that + address regressions seen when running the CLI with Node.js 0.12. + +What this doesn't mean: + +* The CLI is going to start depending on ES2015+ features. npm continues + to work, in almost all cases, all the way back to Node.js 0.8, and our + long history of backwards compatibility is a source of pride for the + team. +* We aren't concerned about the problems of users who, for whatever + reason, can't update to newer versions of npm. As mentioned above, we're + happy to take community patches intended to address regressions. + +We're not super interested in taking sides on what version of Node.js +you "should" be running. We're a workflow tool, and we understand that +you all have a diverse set of operational environments you need to be +able to support. At the same time, we _are_ a small team, and we need +to put some limits on what we support. Tracking what's supported by our +runtime's own team seems most practical, so that's what we're doing. + +* [`c7bbba8`](https://github.com/npm/npm/commit/c7bbba8744b62448103a1510c65d9751288abb5d) + Remove 0.12 from our supported versions list. + ([@iarna](https://github.com/iarna)) + +#### WRITING TO SYMLINKED `package.json` (AND OTHER FILES) + +If your `package.json`, `npm-shrinkwrap.json` or `.npmrc` were a symlink and +you used an `npm` command that modified one of these (eg `npm config set` or +`npm install --save`) then previously we would have removed your symlink and +replaced it with an ordinary file. While making these files symlinks is pretty +uncommon, this was still surprising behavior. With this fix we now overwrite +the _destination_ of the symlink and preserve the symlink itself. + +* [`a583983`](https://github.com/npm/npm/commit/a5839833d3de7072be06884b91902c093aff1aed) + [write-file-atomic/#5](https://github.com/npm/write-file-atomic/issues/5) + [#10223](https://github.com/npm/npm/10223) + `write-file-atomic@1.3.1`: + When the target is a symlink, write-file-atomic now overwrites the + _destination_ of the symlink, instead of replacing the symlink itself. This + makes it's behavior match `fs.writeFile`. + + Fixed a bug where it would ALWAYS fs.stat to look up default mode and chown + values even if you'd passed them in. (It still used the values you passed + in, but did a needless stat.) + ([@iarna](https://github.com/iarna)) + +#### DEPENDENCY UPDATES + +* [`521f230`](https://github.com/npm/npm/commit/521f230dd57261e64ac9613b3db62f5312971dca) + `node-gyp@3.5.0`: + Improvements to how Python is located. New `--devdir` flag. + ([@bnoordhuis](https://github.com/bnoordhuis)) + ([@mhart](https://github.com/mhart)) +* [`ccd83e8`](https://github.com/npm/npm/commit/ccd83e8a70d35fb0904f8a9adb2ff7ac8a6b2706) + `JSONStream@1.3.0`: + Add new emitPath option. + ([@nathanwills](https://github.com/nathanwills)) + +#### TEST IMPROVEMENTS + +* [`d76e084`](https://github.com/npm/npm/commit/d76e08463fd65705217624b861a1443811692f34) + Disable metric reporting for test suite even if the user has it enabled. + ([@iarna](https://github.com/iarna)) + +### v4.1.1 (2016-12-16) + +This fixes a bug in the metrics reporting where, if you had enabled it then +installs would create a metrics reporting process, that would create a +metrics reporting process, that would… well, you get the idea. The only +way to actually kill these processes is to turn off your networking, then +on MacOS/Linux kill them with `kill -9`. Alternatively you can just reboot. + +Anyway, this is a quick release to fix that bug: + +* [`51c393f`](https://github.com/npm/npm/commit/51c393feff5f4908c8a9fb02baef505b1f2259be) + [#15237](https://github.com/npm/npm/pull/15237) + Don't launch a metrics sender process if we're running from a metrics + sender process. + ([@iarna](https://github.com/iarna)) + +### v4.1.0 (2016-12-15) + +I'm really excited about `npm@4.1.0`. I know, I know, I'm kinda overexcited +in my changelogs, but this one is GREAT. We've got a WHOLE NEW subcommand, I +mean, when was the last time you saw that? YEARS! And we have the beginnings +of usage metrics reporting. Then there's a fix for a really subtle bug that +resulted in `shasum` errors. And then we also have a few more bug fixes and +other improvements. + +#### ANONYMOUS METRIC REPORTING + +We're adding the ability for you all to help us track the quality of your +experiences using `npm`. Metrics will be sent if you run: + +``` +npm config set send-metrics true +``` + +Then `npm` will report to `registry.npmjs.org` the number of successful and +failed installations you've had. The data contains no identifying +information and npm will not attempt to correlate things like IP address +with the metrics being submitted. + +Currently we only track number of successful and failed installations. In +the future we would like to find additional metrics to help us better +quantify the quality of the `npm` experience. + +* [`190a658`](https://github.com/npm/npm/commit/190a658c4222f6aa904cbc640fc394a5c875e4db) + [#15084](https://github.com/npm/npm/pull/15084) + Add facility for recording and reporting success metrics. + ([@iarna](https://github.com/iarna)) +* [`87afc8b`](https://github.com/npm/npm/commit/87afc8b466f553fb49746c932c259173de48d0a4) + [npm/npm-registry-client#147](https://github.com/npm/npm-registry-client/pull/148) + `npm-registry-client@7.4.5`: + Add support for sending anonymous CLI metrics. + ([@iarna](https://github.com/iarna), + [@sisidovski](https://github.com/sisidovski)) + +### NPM DOCTOR + +
+Check                               Value                        Recommendation
+npm ping                            ok
+npm -v                              v4.0.5
+node -v                             v4.6.1                       Use node v6.9.2
+npm config get registry             https://registry.npmjs.org/
+which git                           /Users/rebecca/bin/git
+Perms check on cached files         ok
+Perms check on global node_modules  ok
+Perms check on local node_modules   ok
+Checksum cached files               ok
+
+ +It's a rare day that we add a new command to `npm`, so I'm excited to +present to you `npm doctor`. It checks for a number of common problems and +provides some recommended solutions. It was put together through the hard +work of [@watilde](https://github.com/watilde). + +* [`2359505`](https://github.com/npm/npm/commit/23595055669f76c9fe8f5f1cf4a705c2e794f0dc) + [`0209ee5`](https://github.com/npm/npm/commit/0209ee50448441695fbf9699019d34178b69ba73) + [#14582](https://github.com/npm/npm/pull/14582) + Add new `npm doctor` to give your project environment a health check. + ([@watilde](https://github.com/watilde)) + +#### FIX MAJOR SOURCE OF SHASUM ERRORS + +If you've been getting intermittent shasum errors then you'll be pleased to +know that we've tracked down at least one source of them, if not THE source +of them. + +* [`87afc8b`](https://github.com/npm/npm/commit/87afc8b466f553fb49746c932c259173de48d0a4) + [#14626](https://github.com/npm/npm/issues/14626) + [npm/npm-registry-client#148](https://github.com/npm/npm-registry-client/pull/148) + `npm-registry-client@7.4.5`: + Fix a bug where an `ECONNRESET` while fetching a package file would result + in a partial download that would be reported as a "shasum mismatch". It + now throws away the partial download and retries it. + ([@iarna](https://github.com/iarna)) + +#### FILE URLS AND NODE.JS 7 + +When `npm` was formatting `file` URLs we took advantage of `url.format` to +construct them. Node.js 7 changed the behavior in such a way that our use of +`url.format` stopped producing URLs that we could make use of. + +The reasons for this have to do with the `file` URL specification and how +invalid (according to the specification) URLs are handled. How this changed +is most easily explained with a table: + + + + + + + +
URLNode.js <= 6npm's understandingNode.js 7npm's understanding
VALIDfile:///abc/deffile:///abc/def/abc/deffile:///abc/def/abc/def
invalidfile:/abc/deffile:/abc/def/abc/deffile:///abc/def/abc/def
invalidfile:abc/deffile:abc/def$CWD/abc/deffile://abc/def/def on the abc host
invalidfile:../abc/deffile:../abc/def$CWD/../abc/deffile://../abc/def/abc/def on the .. host
+ +So the result was that passing a `file` URL that npm had received that used +through Node.js 7's `url.format` changed its meaning as far as `npm` was +concerned. As those kinds of URLs are, per the specification, invalid, how +they should be handled is undefined and so the change in Node.js wasn't a +bug per se. + +Our solution is to stop using `url.format` when constructing this kind of +URL. + +* [`173935b`](https://github.com/npm/npm/commit/173935b4298e09c4fdcb8f3a44b06134d5aff181) + [#15114](https://github.com/npm/npm/issues/15114) + Stop using `url.format` for relative local dep paths. + ([@zkat](https://github.com/zkat)) + +#### EXTRANEOUS LIFECYCLE SCRIPT EXECUTION WHEN REMOVING + +* [`afb1dfd`](https://github.com/npm/npm/commit/afb1dfd944e57add25a05770c0d52d983dc4e96c) + [#15090](https://github.com/npm/npm/pull/15090) + Skip top level lifecycles when uninstalling. + ([@iarna](https://github.com/iarna)) + +#### REFACTORING AND INTERNALS + +* [`c9b279a`](https://github.com/npm/npm/commit/c9b279aca0fcb8d0e483e534c7f9a7250e2a9392) + [#15205](https://github.com/npm/npm/pull/15205) + [#15196](https://github.com/npm/npm/pull/15196) + Only have one function that determines which version of a package to use + given a specifier and a list of versions. + ([@iarna](https://github.com/iarna), + [@zkat](https://github.com/zkat)) + +* [`981ce63`](https://github.com/npm/npm/commit/981ce6395e7892dde2591b44e484e191f8625431) + [#15090](https://github.com/npm/npm/pull/15090) + Rewrite prune to use modern npm plumbing. + ([@iarna](https://github.com/iarna)) + +* [`bc4b739`](https://github.com/npm/npm/commit/bc4b73911f58a11b4a2d28b49e24b4dd7365f95b) + [#15089](https://github.com/npm/npm/pull/15089) + Rename functions and variables in the module that computes what changes to + make to your installation. + ([@iarna](https://github.com/iarna)) + +* [`2449f74`](https://github.com/npm/npm/commit/2449f74a202b3efdb1b2f5a83356a78ea9ecbe35) + [#15089](https://github.com/npm/npm/pull/15089) + When computing changes to make to your installation, use a function to add + new actions to take instead of just pushing on a list. + ([@iarna](https://github.com/iarna)) + +#### IMPROVED LOGGING + +* [`335933a`](https://github.com/npm/npm/commit/335933a05396258eead139d27eea3f7668ccdfab) + [#15089](https://github.com/npm/npm/pull/15089) + Log when we remove obsolete dependencies in the tree. + ([@iarna](https://github.com/iarna)) + +#### DOCUMENTATION + +* [`33ca4e6`](https://github.com/npm/npm/commit/33ca4e6db3c1878cbc40d5e862ab49bb0e82cfb2) + [#15157](https://github.com/npm/npm/pull/15157) + Update `npm cache` docs to use more consistent language + ([@JonahMoses](https://github.com/JonahMoses)) + +#### DEPENDENCY UPDATES + +* [`c2d22fa`](https://github.com/npm/npm/commit/c2d22faf916e8260136a1cc95913ca474421c0d3) + [#15215](https://github.com/npm/npm/pull/15215) + `nopt@4.0.1`: + The breaking change is a small tweak to how empty string values are + handled. See the brand-new + [CHANGELOG.md for nopt](https://github.com/npm/nopt/blob/v4.0.1/CHANGELOG.md) for further + details about what's changed in this release! + ([@adius](https://github.com/adius), + [@samjonester](https://github.com/samjonester), + [@elidoran](https://github.com/elidoran), + [@helio](https://github.com/helio), + [@silkentrance](https://github.com/silkentrance), + [@othiym23](https://github.com/othiym23)) +* [`54d949b`](https://github.com/npm/npm/commit/54d949b05adefffeb7b5b10229c5fe0ccb929ac3) + [npm/lockfile#24](https://github.com/npm/lockfile/pull/24) + `lockfile@1.0.3`: + Handled case where callback was not passed in by the user. + ([@ORESoftware](https://github.com/ORESoftware)) +* [`54acc03`](https://github.com/npm/npm/commit/54acc0389b39850c0725d0868cb5e61317b57503) + `npmlog@4.0.2`: + Documentation update. + ([@helio-frota](https://github.com/helio-frota)) +* [`57f4bc1`](https://github.com/npm/npm/commit/57f4bc1150322294c1ea0a287ad0a8e457c151e6) + `osenv@0.1.4`: + Test changes. + ([@isaacs](https://github.com/isaacs)) +* [`bea1a2d`](https://github.com/npm/npm/commit/bea1a2d0db566560e13ecc1d5f42e55811269c88) + `retry@0.10.1`: + No changes. + ([@tim-kos](https://github.com/tim-kos)) +* [`6749e39`](https://github.com/npm/npm/commit/6749e395f868109afd97f79d36507e6567dd48fb) + [kapouer/marked-man#9](https://github.com/kapouer/marked-man/pull/9) + `marked-man@0.2.0`: + Add table support. + ([@gholk](https://github.com/gholk)) + ### v4.0.5 (2016-12-01) It's that time of year! December is upon us, which means y'all are just going to @@ -49,13 +345,13 @@ On to the actual changes! `EPERM` errors are Windows are now handled more gracefully. Windows users that tended to see these errors due to, say, an antivirus-induced race condition, should see them much more rarely, if at all. - ([@Kat Marchán](https://github.com/Kat Marchán)) + ([@zkatr](https://github.com/zkat)) * [`85b0174`](https://github.com/npm/npm/commit/85b0174ba9842e8e89f3c33d009e4b4a9e877c7d) `request@2.79.0` - ([@Kat Marchán](https://github.com/Kat Marchán)) + ([@zkat](https://github.com/zkat)) * [`9664d36`](https://github.com/npm/npm/commit/9664d36653503247737630440bc2ff657de965c3) `tap@8.0.1` - ([@Kat Marchán](https://github.com/Kat Marchán)) + ([@zkat](https://github.com/zkat)) #### MISCELLANEOUS @@ -596,6 +892,7 @@ sending `Npm-Scope` and `Npm-In-CI` headers in outgoing requests. * [`846f61c`](https://github.com/npm/npm/commit/846f61c1dd4a033f77aa736ab01c27ae6724fe1c) [npm/npm-registry-client#145](https://github.com/npm/npm-registry-client/pull/145) + [npm/npm-registry-client#147](https://github.com/npm/npm-registry-client/pull/147) `npm-registry-client@7.3.0`: * Allow npm to add headers to outgoing requests. * Add `Npm-In-CI` header that reports whether we're running in CI. diff --git a/deps/npm/doc/cli/npm-cache.md b/deps/npm/doc/cli/npm-cache.md index 03b5902bd4c00f..ea8cb1b9917759 100644 --- a/deps/npm/doc/cli/npm-cache.md +++ b/deps/npm/doc/cli/npm-cache.md @@ -11,10 +11,11 @@ npm-cache(1) -- Manipulates packages cache npm cache ls [] npm cache clean [] + aliases: npm cache clear, npm cache rm ## DESCRIPTION -Used to add, list, or clear the npm cache folder. +Used to add, list, or clean the npm cache folder. * add: Add the specified package to the local cache. This command is primarily @@ -29,7 +30,7 @@ Used to add, list, or clear the npm cache folder. * clean: Delete data out of the cache folder. If an argument is provided, then it specifies a subpath to delete. If no argument is provided, then - the entire cache is cleared. + the entire cache is deleted. ## DETAILS diff --git a/deps/npm/doc/cli/npm-doctor.md b/deps/npm/doc/cli/npm-doctor.md new file mode 100644 index 00000000000000..1a5738505cefee --- /dev/null +++ b/deps/npm/doc/cli/npm-doctor.md @@ -0,0 +1,102 @@ +npm-doctor(1) -- Check your environments +======================================================== + +## SYNOPSIS + + npm doctor + +## DESCRIPTION + +`npm doctor` runs a set of checks to ensure that your npm installation has +what it needs to manage your JavaScript packages. npm is mostly a standalone tool, but it does +have some basic requirements that must be met: + ++ Node.js and git must be executable by npm. ++ The primary npm registry, `registry.npmjs.com`, or another service that uses + the registry API, is available. ++ The directories that npm uses, `node_modules` (both locally and globally), + exist and can be written by the current user. ++ The npm cache exists, and the package tarballs within it aren't corrupt. + +Without all of these working properly, npm may not work properly. Many issues +are often attributable to things that are outside npm's code base, so `npm +doctor` confirms that the npm installation is in a good state. + +Also, in addition to this, there are also very many issue reports due to using +old versions of npm. Since npm is constantly improving, running `npm@latest` is +better than an old version. + +`npm doctor` verifies the following items in your environment, and if there are +any recommended changes, it will display them. + +### `npm ping` + +By default, npm installs from the primary npm registry, `registry.npmjs.org`. +`npm doctor` hits a special ping endpoint within the registry. This can also be +checked with `npm ping`. If this check fails, you may be using a proxy that +needs to be configured, or may need to talk to your IT staff to get access over +HTTPS to `registry.npmjs.org`. + +This check is done against whichever registry you've configured (you can see +what that is by running `npm config get registry`), and if you're using a +private registry that doesn't support the `/whoami` endpoint supported by the +primary registry, this check may fail. + +### `npm -v` + +While Node.js may come bundled with a particular version of npm, it's the +policy of the CLI team that we recommend all users run `npm@latest` if they +can. As the CLI is maintained by a small team of contributors, there are only +resources for a single line of development, so npm's own long-term support +releases typically only receive critical security and regression fixes. The +team believes that the latest tested version of npm is almost always likely to +be the most functional and defect-free version of npm. + +### `node -v` + +For most users, in most circumstances, the best version of Node will be the +latest long-term support (LTS) release. Those of you who want access to new +ECMAscript features or bleeding-edge changes to Node's standard library may be +running a newer version, and some of you may be required to run an older +version of Node because of enterprise change control policies. That's OK! But +in general, the npm team recommends that most users run Node.js LTS. + +### `npm config get registry` + +Some of you may be installing from private package registries for your project +or company. That's great! Others of you may be following tutorials or +StackOverflow questions in an effort to troubleshoot problems you may be +having. Sometimes, this may entail changing the registry you're pointing at. +This part of `npm doctor` just lets you, and maybe whoever's helping you with +support, know that you're not using the default registry. + +### `which git` + +While it's documented in the README, it may not be obvious that npm needs Git +installed to do many of the things that it does. Also, in some cases +– especially on Windows – you may have Git set up in such a way that it's not +accessible via your `PATH` so that npm can find it. This check ensures that Git +is available. + +### Permissions checks + +* Your cache must be readable and writable by the user running npm. +* Global package binaries must be writable by the user running npm. +* Your local `node_modules` path, if you're running `npm doctor` with a project + directory, must be readable and writable by the user running npm. + +### Validate the checksums of cached packages + +When an npm package is published, the publishing process generates a checksum +that npm uses at install time to verify that the package didn't get corrupted +in transit. `npm doctor` uses these checksums to validate the package tarballs +in your local cache (you can see where that cache is located with `npm config +get cache`, and see what's in that cache with `npm cache ls` – probably more +than you were expecting!). In the event that there are corrupt packages in your +cache, you should probably run `npm cache clean` and reset the cache. + +## SEE ALSO + +* npm-bugs(1) +* npm-help(1) +* npm-ping(1) diff --git a/deps/npm/doc/misc/npm-config.md b/deps/npm/doc/misc/npm-config.md index 26f7d3c61f92dc..e93e42a3fb71f9 100644 --- a/deps/npm/doc/misc/npm-config.md +++ b/deps/npm/doc/misc/npm-config.md @@ -600,6 +600,13 @@ Commit message which is used by `npm version` when creating version commit. Any "%s" in the message will be replaced with the version number. +### metrics-registry + +* Default: "https://registry.npmjs.org/" +* Type: String + +The registry you want to send cli metrics to if `send-metrics` is true. + ### node-version * Default: process.version @@ -844,6 +851,16 @@ Space-separated options that are always passed to search. The age of the cache, in seconds, before another registry request is made. +### send-metrics + +* Default: false +* Type: Boolean + +If true, success/failure metrics will be reported to the registry stored in +`metrics-registry`. These requests contain the number of successful and +failing runs of the npm CLI and the time period overwhich those counts were +gathered. No identifying information is included in these requests. + ### shell * Default: SHELL environment variable, or "bash" on Posix, or "cmd" on diff --git a/deps/npm/doc/misc/npm-index.md b/deps/npm/doc/misc/npm-index.md index 775558f4a8c60c..7569a225c7f146 100644 --- a/deps/npm/doc/misc/npm-index.md +++ b/deps/npm/doc/misc/npm-index.md @@ -65,6 +65,10 @@ Modify package distribution tags Docs for a package in a web browser maybe +### npm-doctor(1) + +Check your environments + ### npm-edit(1) Edit an installed package diff --git a/deps/npm/html/doc/README.html b/deps/npm/html/doc/README.html index 0d97ebb0153119..1ec7db7078eefd 100644 --- a/deps/npm/html/doc/README.html +++ b/deps/npm/html/doc/README.html @@ -126,5 +126,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-access.html b/deps/npm/html/doc/cli/npm-access.html index 80a1da3423359d..85154d56b06553 100644 --- a/deps/npm/html/doc/cli/npm-access.html +++ b/deps/npm/html/doc/cli/npm-access.html @@ -84,5 +84,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-adduser.html b/deps/npm/html/doc/cli/npm-adduser.html index 9f6ccada72eae4..6e0fcdd59d4898 100644 --- a/deps/npm/html/doc/cli/npm-adduser.html +++ b/deps/npm/html/doc/cli/npm-adduser.html @@ -73,5 +73,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-bin.html b/deps/npm/html/doc/cli/npm-bin.html index 57a372baffc9bc..2f423f08f3c3d2 100644 --- a/deps/npm/html/doc/cli/npm-bin.html +++ b/deps/npm/html/doc/cli/npm-bin.html @@ -35,5 +35,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-bugs.html b/deps/npm/html/doc/cli/npm-bugs.html index 607d245c27128e..48d374ad760f0a 100644 --- a/deps/npm/html/doc/cli/npm-bugs.html +++ b/deps/npm/html/doc/cli/npm-bugs.html @@ -55,5 +55,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-build.html b/deps/npm/html/doc/cli/npm-build.html index 5f89aca15cb458..0ab879ec551211 100644 --- a/deps/npm/html/doc/cli/npm-build.html +++ b/deps/npm/html/doc/cli/npm-build.html @@ -40,5 +40,5 @@

DESCRIPTION

       - + diff --git a/deps/npm/html/doc/cli/npm-bundle.html b/deps/npm/html/doc/cli/npm-bundle.html index 41a4229c999b49..2465a582f71b49 100644 --- a/deps/npm/html/doc/cli/npm-bundle.html +++ b/deps/npm/html/doc/cli/npm-bundle.html @@ -31,5 +31,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-cache.html b/deps/npm/html/doc/cli/npm-cache.html index 1b6b34adb94405..a2f6339bb48a46 100644 --- a/deps/npm/html/doc/cli/npm-cache.html +++ b/deps/npm/html/doc/cli/npm-cache.html @@ -19,8 +19,9 @@

SYNOPSIS

npm cache ls [<path>] npm cache clean [<path>] +aliases: npm cache clear, npm cache rm

DESCRIPTION

-

Used to add, list, or clear the npm cache folder.

+

Used to add, list, or clean the npm cache folder.

  • add: Add the specified package to the local cache. This command is primarily @@ -35,7 +36,7 @@

    SYNOPSIS

  • clean: Delete data out of the cache folder. If an argument is provided, then it specifies a subpath to delete. If no argument is provided, then -the entire cache is cleared.

    +the entire cache is deleted.

DETAILS

@@ -81,5 +82,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-completion.html b/deps/npm/html/doc/cli/npm-completion.html index 2f5cad2d33b4f2..31b6d7c0846af9 100644 --- a/deps/npm/html/doc/cli/npm-completion.html +++ b/deps/npm/html/doc/cli/npm-completion.html @@ -43,5 +43,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-config.html b/deps/npm/html/doc/cli/npm-config.html index 9036bf84d5ac4d..a9232c539a9b13 100644 --- a/deps/npm/html/doc/cli/npm-config.html +++ b/deps/npm/html/doc/cli/npm-config.html @@ -67,5 +67,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-dedupe.html b/deps/npm/html/doc/cli/npm-dedupe.html index e822dd5e65c19c..59a83a101eb3bf 100644 --- a/deps/npm/html/doc/cli/npm-dedupe.html +++ b/deps/npm/html/doc/cli/npm-dedupe.html @@ -61,5 +61,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-deprecate.html b/deps/npm/html/doc/cli/npm-deprecate.html index 8402c36fca768f..5215a2e5b0027d 100644 --- a/deps/npm/html/doc/cli/npm-deprecate.html +++ b/deps/npm/html/doc/cli/npm-deprecate.html @@ -38,5 +38,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-dist-tag.html b/deps/npm/html/doc/cli/npm-dist-tag.html index b1b5c038bf149d..bdac1bd3c72acc 100644 --- a/deps/npm/html/doc/cli/npm-dist-tag.html +++ b/deps/npm/html/doc/cli/npm-dist-tag.html @@ -86,5 +86,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-docs.html b/deps/npm/html/doc/cli/npm-docs.html index a713ca1f3a7c55..391e94e72469c5 100644 --- a/deps/npm/html/doc/cli/npm-docs.html +++ b/deps/npm/html/doc/cli/npm-docs.html @@ -56,5 +56,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-doctor.html b/deps/npm/html/doc/cli/npm-doctor.html new file mode 100644 index 00000000000000..05315e7809b266 --- /dev/null +++ b/deps/npm/html/doc/cli/npm-doctor.html @@ -0,0 +1,106 @@ + + + npm-doctor + + + + + + +
+ +

npm-doctor

Check your environments

+

SYNOPSIS

+
npm doctor
+

DESCRIPTION

+

npm doctor runs a set of checks to ensure that your npm installation has +what it needs to manage your JavaScript packages. npm is mostly a standalone tool, but it does +have some basic requirements that must be met:

+
    +
  • Node.js and git must be executable by npm.
  • +
  • The primary npm registry, registry.npmjs.com, or another service that uses +the registry API, is available.
  • +
  • The directories that npm uses, node_modules (both locally and globally), +exist and can be written by the current user.
  • +
  • The npm cache exists, and the package tarballs within it aren't corrupt.
  • +
+

Without all of these working properly, npm may not work properly. Many issues +are often attributable to things that are outside npm's code base, so npm +doctor confirms that the npm installation is in a good state.

+

Also, in addition to this, there are also very many issue reports due to using +old versions of npm. Since npm is constantly improving, running npm@latest is +better than an old version.

+

npm doctor verifies the following items in your environment, and if there are +any recommended changes, it will display them.

+

npm ping

+

By default, npm installs from the primary npm registry, registry.npmjs.org. +npm doctor hits a special ping endpoint within the registry. This can also be +checked with npm ping. If this check fails, you may be using a proxy that +needs to be configured, or may need to talk to your IT staff to get access over +HTTPS to registry.npmjs.org.

+

This check is done against whichever registry you've configured (you can see +what that is by running npm config get registry), and if you're using a +private registry that doesn't support the /whoami endpoint supported by the +primary registry, this check may fail.

+

npm -v

+

While Node.js may come bundled with a particular version of npm, it's the +policy of the CLI team that we recommend all users run npm@latest if they +can. As the CLI is maintained by a small team of contributors, there are only +resources for a single line of development, so npm's own long-term support +releases typically only receive critical security and regression fixes. The +team believes that the latest tested version of npm is almost always likely to +be the most functional and defect-free version of npm.

+

node -v

+

For most users, in most circumstances, the best version of Node will be the +latest long-term support (LTS) release. Those of you who want access to new +ECMAscript features or bleeding-edge changes to Node's standard library may be +running a newer version, and some of you may be required to run an older +version of Node because of enterprise change control policies. That's OK! But +in general, the npm team recommends that most users run Node.js LTS.

+

npm config get registry

+

Some of you may be installing from private package registries for your project +or company. That's great! Others of you may be following tutorials or +StackOverflow questions in an effort to troubleshoot problems you may be +having. Sometimes, this may entail changing the registry you're pointing at. +This part of npm doctor just lets you, and maybe whoever's helping you with +support, know that you're not using the default registry.

+

which git

+

While it's documented in the README, it may not be obvious that npm needs Git +installed to do many of the things that it does. Also, in some cases +– especially on Windows – you may have Git set up in such a way that it's not +accessible via your PATH so that npm can find it. This check ensures that Git +is available.

+

Permissions checks

+
    +
  • Your cache must be readable and writable by the user running npm.
  • +
  • Global package binaries must be writable by the user running npm.
  • +
  • Your local node_modules path, if you're running npm doctor with a project +directory, must be readable and writable by the user running npm.
  • +
+

Validate the checksums of cached packages

+

When an npm package is published, the publishing process generates a checksum +that npm uses at install time to verify that the package didn't get corrupted +in transit. npm doctor uses these checksums to validate the package tarballs +in your local cache (you can see where that cache is located with npm config +get cache, and see what's in that cache with npm cache ls – probably more +than you were expecting!). In the event that there are corrupt packages in your +cache, you should probably run npm cache clean and reset the cache.

+

SEE ALSO

+ + +
+ + + + + + + + + + + diff --git a/deps/npm/html/doc/cli/npm-edit.html b/deps/npm/html/doc/cli/npm-edit.html index db4eba41111280..8ec44dc44579c0 100644 --- a/deps/npm/html/doc/cli/npm-edit.html +++ b/deps/npm/html/doc/cli/npm-edit.html @@ -49,5 +49,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-explore.html b/deps/npm/html/doc/cli/npm-explore.html index 2fb651064c2d8d..65d542ea294079 100644 --- a/deps/npm/html/doc/cli/npm-explore.html +++ b/deps/npm/html/doc/cli/npm-explore.html @@ -49,5 +49,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-help-search.html b/deps/npm/html/doc/cli/npm-help-search.html index 7a7980a97de6bc..a976c2590f1e5f 100644 --- a/deps/npm/html/doc/cli/npm-help-search.html +++ b/deps/npm/html/doc/cli/npm-help-search.html @@ -45,5 +45,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-help.html b/deps/npm/html/doc/cli/npm-help.html index 7249903ccc974f..817603d3802925 100644 --- a/deps/npm/html/doc/cli/npm-help.html +++ b/deps/npm/html/doc/cli/npm-help.html @@ -50,5 +50,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-init.html b/deps/npm/html/doc/cli/npm-init.html index b4cec6b41689f9..9c8f752118da33 100644 --- a/deps/npm/html/doc/cli/npm-init.html +++ b/deps/npm/html/doc/cli/npm-init.html @@ -48,5 +48,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-install-test.html b/deps/npm/html/doc/cli/npm-install-test.html index d283317a71b4cf..76dba877bda01a 100644 --- a/deps/npm/html/doc/cli/npm-install-test.html +++ b/deps/npm/html/doc/cli/npm-install-test.html @@ -42,5 +42,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-install.html b/deps/npm/html/doc/cli/npm-install.html index c647781dcf7ae7..0a16a3e8134e9a 100644 --- a/deps/npm/html/doc/cli/npm-install.html +++ b/deps/npm/html/doc/cli/npm-install.html @@ -316,5 +316,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-link.html b/deps/npm/html/doc/cli/npm-link.html index f10b790bc2bb0f..64b7a8c17d6ad3 100644 --- a/deps/npm/html/doc/cli/npm-link.html +++ b/deps/npm/html/doc/cli/npm-link.html @@ -74,5 +74,5 @@

SYNOPSIS

       - + diff --git a/deps/npm/html/doc/cli/npm-logout.html b/deps/npm/html/doc/cli/npm-logout.html index 6543b578511561..0058b380621857 100644 --- a/deps/npm/html/doc/cli/npm-logout.html +++ b/deps/npm/html/doc/cli/npm-logout.html @@ -51,5 +51,5 @@

scope

       - + diff --git a/deps/npm/html/doc/cli/npm-ls.html b/deps/npm/html/doc/cli/npm-ls.html index 1b5d61bd380f82..d2ce3981539fdd 100644 --- a/deps/npm/html/doc/cli/npm-ls.html +++ b/deps/npm/html/doc/cli/npm-ls.html @@ -21,7 +21,7 @@

SYNOPSIS

limit the results to only the paths to the packages named. Note that nested packages will also show the paths to the specified packages. For example, running npm ls promzard in npm's source tree will show:

-
npm@4.0.5 /path/to/npm
+
npm@4.1.2 /path/to/npm
 └─┬ init-package-json@0.0.4
   └── promzard@0.1.5
 

It will print out extraneous, missing, and invalid packages.

@@ -104,5 +104,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-outdated.html b/deps/npm/html/doc/cli/npm-outdated.html index 04a0da5155da8c..ca9f0ad9de0d2e 100644 --- a/deps/npm/html/doc/cli/npm-outdated.html +++ b/deps/npm/html/doc/cli/npm-outdated.html @@ -116,5 +116,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-owner.html b/deps/npm/html/doc/cli/npm-owner.html index 9f6d4db959d509..5fe0a8b6b1e7d5 100644 --- a/deps/npm/html/doc/cli/npm-owner.html +++ b/deps/npm/html/doc/cli/npm-owner.html @@ -51,5 +51,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-pack.html b/deps/npm/html/doc/cli/npm-pack.html index 92cea267476eb6..bdaf2c08e9aa19 100644 --- a/deps/npm/html/doc/cli/npm-pack.html +++ b/deps/npm/html/doc/cli/npm-pack.html @@ -41,5 +41,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-ping.html b/deps/npm/html/doc/cli/npm-ping.html index f094762e62989e..8890f58f84f1e4 100644 --- a/deps/npm/html/doc/cli/npm-ping.html +++ b/deps/npm/html/doc/cli/npm-ping.html @@ -32,5 +32,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-prefix.html b/deps/npm/html/doc/cli/npm-prefix.html index 906de75ff820b7..bc6e193a5e7673 100644 --- a/deps/npm/html/doc/cli/npm-prefix.html +++ b/deps/npm/html/doc/cli/npm-prefix.html @@ -38,5 +38,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-prune.html b/deps/npm/html/doc/cli/npm-prune.html index 9e40f28103076b..1d7668847df81d 100644 --- a/deps/npm/html/doc/cli/npm-prune.html +++ b/deps/npm/html/doc/cli/npm-prune.html @@ -40,5 +40,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-publish.html b/deps/npm/html/doc/cli/npm-publish.html index a6959ce0a45c1f..51132f75b69e34 100644 --- a/deps/npm/html/doc/cli/npm-publish.html +++ b/deps/npm/html/doc/cli/npm-publish.html @@ -76,5 +76,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-rebuild.html b/deps/npm/html/doc/cli/npm-rebuild.html index b2d06701895be2..ce6bd26a21d4a3 100644 --- a/deps/npm/html/doc/cli/npm-rebuild.html +++ b/deps/npm/html/doc/cli/npm-rebuild.html @@ -35,5 +35,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-repo.html b/deps/npm/html/doc/cli/npm-repo.html index 83af6875167253..740d7672e18a18 100644 --- a/deps/npm/html/doc/cli/npm-repo.html +++ b/deps/npm/html/doc/cli/npm-repo.html @@ -41,5 +41,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-restart.html b/deps/npm/html/doc/cli/npm-restart.html index 6d4c455659c04e..b4f56de4d00b36 100644 --- a/deps/npm/html/doc/cli/npm-restart.html +++ b/deps/npm/html/doc/cli/npm-restart.html @@ -53,5 +53,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-root.html b/deps/npm/html/doc/cli/npm-root.html index 343790ab5799c0..96a1d56b251421 100644 --- a/deps/npm/html/doc/cli/npm-root.html +++ b/deps/npm/html/doc/cli/npm-root.html @@ -35,5 +35,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-run-script.html b/deps/npm/html/doc/cli/npm-run-script.html index d68504647a79a3..8c4c64eb78823a 100644 --- a/deps/npm/html/doc/cli/npm-run-script.html +++ b/deps/npm/html/doc/cli/npm-run-script.html @@ -66,5 +66,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-search.html b/deps/npm/html/doc/cli/npm-search.html index 015d4a3ddb92f6..ddc946c1016d7c 100644 --- a/deps/npm/html/doc/cli/npm-search.html +++ b/deps/npm/html/doc/cli/npm-search.html @@ -109,5 +109,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-shrinkwrap.html b/deps/npm/html/doc/cli/npm-shrinkwrap.html index 0f80895acf155c..baad291a3c0ad5 100644 --- a/deps/npm/html/doc/cli/npm-shrinkwrap.html +++ b/deps/npm/html/doc/cli/npm-shrinkwrap.html @@ -180,5 +180,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-star.html b/deps/npm/html/doc/cli/npm-star.html index 2564d61dfcce9d..6b29ed04e6c0da 100644 --- a/deps/npm/html/doc/cli/npm-star.html +++ b/deps/npm/html/doc/cli/npm-star.html @@ -36,5 +36,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-stars.html b/deps/npm/html/doc/cli/npm-stars.html index a4889bd84dae3e..53d91da15c8e49 100644 --- a/deps/npm/html/doc/cli/npm-stars.html +++ b/deps/npm/html/doc/cli/npm-stars.html @@ -36,5 +36,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-start.html b/deps/npm/html/doc/cli/npm-start.html index 65c229ec95b16b..f0d07e595612b4 100644 --- a/deps/npm/html/doc/cli/npm-start.html +++ b/deps/npm/html/doc/cli/npm-start.html @@ -39,5 +39,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-stop.html b/deps/npm/html/doc/cli/npm-stop.html index 277b5a845eda92..e162b4e5d42237 100644 --- a/deps/npm/html/doc/cli/npm-stop.html +++ b/deps/npm/html/doc/cli/npm-stop.html @@ -34,5 +34,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-team.html b/deps/npm/html/doc/cli/npm-team.html index 2fea57d08e5f57..3446eed20b3597 100644 --- a/deps/npm/html/doc/cli/npm-team.html +++ b/deps/npm/html/doc/cli/npm-team.html @@ -67,5 +67,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-test.html b/deps/npm/html/doc/cli/npm-test.html index 041ce2130bb74e..52b87d2fb18315 100644 --- a/deps/npm/html/doc/cli/npm-test.html +++ b/deps/npm/html/doc/cli/npm-test.html @@ -36,5 +36,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-uninstall.html b/deps/npm/html/doc/cli/npm-uninstall.html index b1d9de78099b45..399d5c9f5bad84 100644 --- a/deps/npm/html/doc/cli/npm-uninstall.html +++ b/deps/npm/html/doc/cli/npm-uninstall.html @@ -60,5 +60,5 @@

SYNOPSIS

       - + diff --git a/deps/npm/html/doc/cli/npm-unpublish.html b/deps/npm/html/doc/cli/npm-unpublish.html index 147e42221ad485..d9a94d5bd58de5 100644 --- a/deps/npm/html/doc/cli/npm-unpublish.html +++ b/deps/npm/html/doc/cli/npm-unpublish.html @@ -47,5 +47,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-update.html b/deps/npm/html/doc/cli/npm-update.html index c2b8b18d486e77..12046b2b103497 100644 --- a/deps/npm/html/doc/cli/npm-update.html +++ b/deps/npm/html/doc/cli/npm-update.html @@ -118,5 +118,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-version.html b/deps/npm/html/doc/cli/npm-version.html index adbfb7ab7c9224..d015d34c7e9e6c 100644 --- a/deps/npm/html/doc/cli/npm-version.html +++ b/deps/npm/html/doc/cli/npm-version.html @@ -107,5 +107,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-view.html b/deps/npm/html/doc/cli/npm-view.html index f1de2303d0265c..eec35f2b748935 100644 --- a/deps/npm/html/doc/cli/npm-view.html +++ b/deps/npm/html/doc/cli/npm-view.html @@ -86,5 +86,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm-whoami.html b/deps/npm/html/doc/cli/npm-whoami.html index 50ff32f00cd7e7..c6199636314a9e 100644 --- a/deps/npm/html/doc/cli/npm-whoami.html +++ b/deps/npm/html/doc/cli/npm-whoami.html @@ -33,5 +33,5 @@

SEE ALSO

       - + diff --git a/deps/npm/html/doc/cli/npm.html b/deps/npm/html/doc/cli/npm.html index 44685d4a29667a..fa780891aaa64f 100644 --- a/deps/npm/html/doc/cli/npm.html +++ b/deps/npm/html/doc/cli/npm.html @@ -13,7 +13,7 @@

npm

javascript package manager

SYNOPSIS

npm <command> [args]
 

VERSION

-

4.0.5

+

4.1.2

DESCRIPTION

npm is the package manager for the Node JavaScript platform. It puts modules in place so that node can find them, and manages dependency @@ -126,7 +126,7 @@

AUTHOR

Isaac Z. Schlueter :: isaacs :: @izs :: -i@izs.me

+i@izs.me

SEE ALSO

  • npm-help(1)
  • @@ -150,5 +150,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/files/npm-folders.html b/deps/npm/html/doc/files/npm-folders.html index b54e1a3f4d8011..036edccd18116a 100644 --- a/deps/npm/html/doc/files/npm-folders.html +++ b/deps/npm/html/doc/files/npm-folders.html @@ -182,5 +182,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/files/npm-global.html b/deps/npm/html/doc/files/npm-global.html index b54e1a3f4d8011..036edccd18116a 100644 --- a/deps/npm/html/doc/files/npm-global.html +++ b/deps/npm/html/doc/files/npm-global.html @@ -182,5 +182,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/files/npm-json.html b/deps/npm/html/doc/files/npm-json.html index 392d8552f84a83..5b7d54a34207aa 100644 --- a/deps/npm/html/doc/files/npm-json.html +++ b/deps/npm/html/doc/files/npm-json.html @@ -586,5 +586,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/files/npmrc.html b/deps/npm/html/doc/files/npmrc.html index 8385a103a35e20..08e417aecd24a2 100644 --- a/deps/npm/html/doc/files/npmrc.html +++ b/deps/npm/html/doc/files/npmrc.html @@ -85,5 +85,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/files/package.json.html b/deps/npm/html/doc/files/package.json.html index 392d8552f84a83..5b7d54a34207aa 100644 --- a/deps/npm/html/doc/files/package.json.html +++ b/deps/npm/html/doc/files/package.json.html @@ -586,5 +586,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/index.html b/deps/npm/html/doc/index.html index 83baa43e6e6364..9323a0af02e332 100644 --- a/deps/npm/html/doc/index.html +++ b/deps/npm/html/doc/index.html @@ -42,6 +42,8 @@

    npm-dist-tag(1)

    Modify package distribution tags

    npm-docs(1)

    Docs for a package in a web browser maybe

    +

    npm-doctor(1)

    +

    Check your environments

    npm-edit(1)

    Edit an installed package

    npm-explore(1)

    @@ -160,5 +162,5 @@

    semver(7)

           - + diff --git a/deps/npm/html/doc/misc/npm-coding-style.html b/deps/npm/html/doc/misc/npm-coding-style.html index 0873b5f82fb67c..f56c3dfc3485f5 100644 --- a/deps/npm/html/doc/misc/npm-coding-style.html +++ b/deps/npm/html/doc/misc/npm-coding-style.html @@ -153,5 +153,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/misc/npm-config.html b/deps/npm/html/doc/misc/npm-config.html index c4dca1bc183180..f6ba450b1a3bab 100644 --- a/deps/npm/html/doc/misc/npm-config.html +++ b/deps/npm/html/doc/misc/npm-config.html @@ -517,6 +517,12 @@

    message

Commit message which is used by npm version when creating version commit.

Any "%s" in the message will be replaced with the version number.

+

metrics-registry

+ +

The registry you want to send cli metrics to if send-metrics is true.

node-version

  • Default: process.version
  • @@ -722,6 +728,15 @@

    searchstaleness

  • Type: Number

The age of the cache, in seconds, before another registry request is made.

+

send-metrics

+
    +
  • Default: false
  • +
  • Type: Boolean
  • +
+

If true, success/failure metrics will be reported to the registry stored in +metrics-registry. These requests contain the number of successful and +failing runs of the npm CLI and the time period overwhich those counts were +gathered. No identifying information is included in these requests.

shell

  • Default: SHELL environment variable, or "bash" on Posix, or "cmd" on @@ -872,5 +887,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/misc/npm-developers.html b/deps/npm/html/doc/misc/npm-developers.html index 3b04dffacf97b1..b0b07a936f813f 100644 --- a/deps/npm/html/doc/misc/npm-developers.html +++ b/deps/npm/html/doc/misc/npm-developers.html @@ -194,5 +194,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/misc/npm-disputes.html b/deps/npm/html/doc/misc/npm-disputes.html index 3db7ef27db6a26..3add632e0d8322 100644 --- a/deps/npm/html/doc/misc/npm-disputes.html +++ b/deps/npm/html/doc/misc/npm-disputes.html @@ -20,7 +20,7 @@

    npm-disputes

    Handling Module

    TL;DR

    1. Get the author email with npm owner ls <pkgname>
    2. -
    3. Email the author, CC support@npmjs.com
    4. +
    5. Email the author, CC support@npmjs.com
    6. After a few weeks, if there's no resolution, we'll sort it out.

    Don't squat on package names. Publish code or move out of the way.

    @@ -55,12 +55,12 @@

    DESCRIPTION

  • Alice emails Yusuf, explaining the situation as respectfully as possible, and what she would like to do with the module name. She adds the npm support -staff support@npmjs.com to the CC list of the email. Mention in the email +staff support@npmjs.com to the CC list of the email. Mention in the email that Yusuf can run npm owner add alice foo to add Alice as an owner of the foo package.
  • After a reasonable amount of time, if Yusuf has not responded, or if Yusuf and Alice can't come to any sort of resolution, email support -support@npmjs.com and we'll sort it out. ("Reasonable" is usually at least +support@npmjs.com and we'll sort it out. ("Reasonable" is usually at least 4 weeks.)
  • REASONING

    @@ -96,12 +96,12 @@

    EXCEPTIONS

    Code of Conduct such as hateful language, pornographic content, or harassment. -

    If you see bad behavior like this, please report it to abuse@npmjs.com right +

    If you see bad behavior like this, please report it to abuse@npmjs.com right away. You are never expected to resolve abusive behavior on your own. We are here to help.

    TRADEMARKS

    If you think another npm publisher is infringing your trademark, such as by -using a confusingly similar package name, email abuse@npmjs.com with a link to +using a confusingly similar package name, email abuse@npmjs.com with a link to the package or user account on https://npmjs.com. Attach a copy of your trademark registration certificate.

    If we see that the package's publisher is intentionally misleading others by @@ -134,5 +134,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/misc/npm-index.html b/deps/npm/html/doc/misc/npm-index.html index 4e590dabe7c254..171efc448fe835 100644 --- a/deps/npm/html/doc/misc/npm-index.html +++ b/deps/npm/html/doc/misc/npm-index.html @@ -42,6 +42,8 @@

    npm-dist-tag(1)<

    Modify package distribution tags

    npm-docs(1)

    Docs for a package in a web browser maybe

    +

    npm-doctor(1)

    +

    Check your environments

    npm-edit(1)

    Edit an installed package

    npm-explore(1)

    @@ -160,5 +162,5 @@

    semver(7)

           - + diff --git a/deps/npm/html/doc/misc/npm-orgs.html b/deps/npm/html/doc/misc/npm-orgs.html index 92aa4257e8d67c..57a40ca7e74bed 100644 --- a/deps/npm/html/doc/misc/npm-orgs.html +++ b/deps/npm/html/doc/misc/npm-orgs.html @@ -86,5 +86,5 @@

    Team Admins create teams

           - + diff --git a/deps/npm/html/doc/misc/npm-registry.html b/deps/npm/html/doc/misc/npm-registry.html index a780c98a458fc7..727c174dfd39e2 100644 --- a/deps/npm/html/doc/misc/npm-registry.html +++ b/deps/npm/html/doc/misc/npm-registry.html @@ -90,5 +90,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/misc/npm-scope.html b/deps/npm/html/doc/misc/npm-scope.html index 7295c81fd8ca05..109e68c0f78267 100644 --- a/deps/npm/html/doc/misc/npm-scope.html +++ b/deps/npm/html/doc/misc/npm-scope.html @@ -94,5 +94,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/misc/npm-scripts.html b/deps/npm/html/doc/misc/npm-scripts.html index c140ea2152b54e..453e76035e049f 100644 --- a/deps/npm/html/doc/misc/npm-scripts.html +++ b/deps/npm/html/doc/misc/npm-scripts.html @@ -237,5 +237,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/misc/removing-npm.html b/deps/npm/html/doc/misc/removing-npm.html index 63d0648844c2c2..b04d851e0184b5 100644 --- a/deps/npm/html/doc/misc/removing-npm.html +++ b/deps/npm/html/doc/misc/removing-npm.html @@ -57,5 +57,5 @@

    SEE ALSO

           - + diff --git a/deps/npm/html/doc/misc/semver.html b/deps/npm/html/doc/misc/semver.html index 2ae0288f994de4..dcee1f356db589 100644 --- a/deps/npm/html/doc/misc/semver.html +++ b/deps/npm/html/doc/misc/semver.html @@ -325,5 +325,5 @@

    Ranges

           - + diff --git a/deps/npm/lib/cache/add-named.js b/deps/npm/lib/cache/add-named.js index f0e5e2c33a8f31..3a48b42e7f675a 100644 --- a/deps/npm/lib/cache/add-named.js +++ b/deps/npm/lib/cache/add-named.js @@ -14,6 +14,7 @@ var cachedPackageRoot = require('./cached-package-root.js') var mapToRegistry = require('../utils/map-to-registry.js') var pulseTillDone = require('../utils/pulse-till-done.js') var packageId = require('../utils/package-id.js') +var pickManifestFromRegistryMetadata = require('../utils/pick-manifest-from-registry-metadata.js') module.exports = addNamed @@ -252,28 +253,10 @@ function addNameRange (name, range, data, cb) { log.silly('addNameRange', 'versions' , [data.name, Object.keys(data.versions || {})]) - // if the tagged version satisfies, then use that. - var tagged = data['dist-tags'][npm.config.get('tag')] - if (tagged && - data.versions[tagged] && - semver.satisfies(tagged, range, true)) { - return addNamed(name, tagged, data.versions[tagged], cb) - } - - // find the max satisfying version. - var versions = Object.keys(data.versions || {}) - var ms = semver.maxSatisfying(versions, range, true) - if (!ms) { - if (range === '*' && versions.length) { - return addNameTag(name, 'latest', data, cb) - } else { - return cb(installTargetsError(range, data)) - } - } - - // if we don't have a registry connection, try to see if - // there's a cached copy that will be ok. - addNamed(name, ms, data.versions[ms], cb) + var versions = Object.keys(data.versions).filter(function (v) { return semver.valid(v) }) + var picked = pickManifestFromRegistryMetadata(range, npm.config.get('tag'), versions, data) + if (picked) return addNamed(name, picked.resolvedTo, picked.manifest, cb) + return cb(installTargetsError(range, data)) } } diff --git a/deps/npm/lib/config/cmd-list.js b/deps/npm/lib/config/cmd-list.js index eb79e9df0659dd..a1abe80fb0b829 100644 --- a/deps/npm/lib/config/cmd-list.js +++ b/deps/npm/lib/config/cmd-list.js @@ -98,7 +98,8 @@ var cmdList = [ 'start', 'restart', 'run-script', - 'completion' + 'completion', + 'doctor' ] var plumbing = [ diff --git a/deps/npm/lib/config/defaults.js b/deps/npm/lib/config/defaults.js index 05a06a4e202926..81ead08b6f9738 100644 --- a/deps/npm/lib/config/defaults.js +++ b/deps/npm/lib/config/defaults.js @@ -167,6 +167,7 @@ Object.defineProperty(exports, 'defaults', {get: function () { long: false, maxsockets: 50, message: '%s', + 'metrics-registry': 'https://registry.npmjs.org/', 'node-version': process.version, 'onload-script': false, only: null, @@ -196,6 +197,7 @@ Object.defineProperty(exports, 'defaults', {get: function () { searchopts: '', searchexclude: null, searchstaleness: 15 * 60, + 'send-metrics': false, shell: osenv.shell(), shrinkwrap: true, 'sign-git-tag': false, @@ -279,6 +281,7 @@ exports.types = { long: Boolean, maxsockets: Number, message: String, + 'metrics-registry': String, 'node-version': [null, semver], 'onload-script': [null, String], only: [null, 'dev', 'development', 'prod', 'production'], @@ -303,6 +306,7 @@ exports.types = { searchopts: String, searchexclude: [null, String], searchstaleness: Number, + 'send-metrics': Boolean, shell: String, shrinkwrap: Boolean, 'sign-git-tag': Boolean, diff --git a/deps/npm/lib/doctor.js b/deps/npm/lib/doctor.js new file mode 100644 index 00000000000000..f2037ab86c0abd --- /dev/null +++ b/deps/npm/lib/doctor.js @@ -0,0 +1,109 @@ +var path = require('path') +var chain = require('slide').chain +var table = require('text-table') +var color = require('ansicolors') +var styles = require('ansistyles') +var semver = require('semver') +var npm = require('./npm.js') +var log = require('npmlog') +var ansiTrim = require('./utils/ansi-trim.js') +var output = require('./utils/output.js') +var defaultRegistry = require('./config/defaults.js').defaults.registry +var checkPing = require('./doctor/check-ping.js') +var getGitPath = require('./doctor/get-git-path.js') +var checksumCachedFiles = require('./doctor/checksum-cached-files.js') +var checkFilesPermission = require('./doctor/check-files-permission.js') +var getLatestNodejsVersion = require('./doctor/get-latest-nodejs-version.js') +var getLatestNpmVersion = require('./doctor/get-latest-npm-version') +var globalNodeModules = path.join(npm.config.globalPrefix, 'lib', 'node_modules') +var localNodeModules = path.join(npm.config.localPrefix, 'node_modules') + +module.exports = doctor + +doctor.usage = 'npm doctor' + +function doctor (args, silent, cb) { + args = args || {} + if (typeof cb !== 'function') { + cb = silent + silent = false + } + + var actionsToRun = [ + [checkPing], + [getLatestNpmVersion], + [getLatestNodejsVersion, args['node-url']], + [getGitPath], + [checkFilesPermission, npm.cache, 6], + [checkFilesPermission, globalNodeModules, 4], + [checkFilesPermission, localNodeModules, 6], + [checksumCachedFiles] + ] + + log.info('doctor', 'Running checkup') + chain(actionsToRun, function (stderr, stdout) { + if (stderr && stderr.message !== 'not found: git') return cb(stderr) + var outHead = ['Check', 'Value', 'Recommendation'] + var list = makePretty(stdout) + var outBody = list + + if (npm.color) { + outHead = outHead.map(function (item) { + return styles.underline(item) + }) + outBody = outBody.map(function (item) { + if (item[2]) { + item[0] = color.red(item[0]) + item[2] = color.magenta(item[2]) + } + return item + }) + } + + var outTable = [outHead].concat(outBody) + var tableOpts = { + stringLength: function (s) { return ansiTrim(s).length } + } + + if (!silent) output(table(outTable, tableOpts)) + + cb(null, list) + }) +} + +function makePretty (p) { + var ping = p[0] ? 'ok' : 'notOk' + var npmLTS = p[1] + var nodeLTS = p[2].replace('v', '') + var whichGit = p[3] || 'not installed' + var readbleCaches = p[4] ? 'ok' : 'notOk' + var executableGlobalModules = p[5] ? 'ok' : 'notOk' + var executableLocalModules = p[6] ? 'ok' : 'notOk' + var checksumCachedFiles = p[7] ? 'ok' : 'notOk' + var npmV = npm.version + var nodeV = process.version.replace('v', '') + var registry = npm.config.get('registry') + var list = [ + ['npm ping', ping], + ['npm -v', 'v' + npmV], + ['node -v', 'v' + nodeV], + ['npm config get registry', registry], + ['which git', whichGit], + ['Perms check on cached files', readbleCaches], + ['Perms check on global node_modules', executableGlobalModules], + ['Perms check on local node_modules', executableLocalModules], + ['Checksum cached files', checksumCachedFiles] + ] + + if (ping !== 'ok') list[0][2] = 'Check your internet connection' + if (!semver.satisfies(npmV, '>=' + npmLTS)) list[1][2] = 'Use npm v' + npmLTS + if (!semver.satisfies(nodeV, '>=' + nodeLTS)) list[2][2] = 'Use node v' + nodeLTS + if (registry !== defaultRegistry) list[3][2] = 'Try `npm config set registry ' + defaultRegistry + if (whichGit === 'not installed') list[4][2] = 'Install git and ensure it\'s in your PATH.' + if (readbleCaches !== 'ok') list[5][2] = 'Check the permissions of your files in ' + npm.config.get('cache') + if (executableGlobalModules !== 'ok') list[6][2] = globalNodeModules + ' must be readable and writable by the current user.' + if (executableLocalModules !== 'ok') list[7][2] = localNodeModules + ' must be readable and writable by the current user.' + if (checksumCachedFiles !== 'ok') list[8][2] = 'You have some broken packages in your cache.' + + return list +} diff --git a/deps/npm/lib/doctor/check-files-permission.js b/deps/npm/lib/doctor/check-files-permission.js new file mode 100644 index 00000000000000..ac3bb40bc6d394 --- /dev/null +++ b/deps/npm/lib/doctor/check-files-permission.js @@ -0,0 +1,55 @@ +var fs = require('fs') +var path = require('path') +var getUid = require('uid-number') +var chain = require('slide').chain +var log = require('npmlog') +var npm = require('../npm.js') +var fileCompletion = require('../utils/completion/file-completion.js') + +function checkFilesPermission (root, mask, cb) { + if (process.platform === 'win32') return cb(null, true) + getUid(npm.config.get('user'), npm.config.get('group'), function (e, uid, gid) { + if (e) { + tracker.finish() + tracker.warn('checkFilePermissions', 'Error looking up user and group:', e) + return cb(e) + } + var tracker = log.newItem('checkFilePermissions', 1) + tracker.info('checkFilePermissions', 'Building file list of ' + root) + fileCompletion(root, '.', Infinity, function (e, files) { + if (e) { + tracker.warn('checkFilePermissions', 'Error building file list:', e) + tracker.finish() + return cb(e) + } + tracker.addWork(files.length) + tracker.completeWork(1) + chain(files.map(andCheckFile), function (er) { + tracker.finish() + cb(null, !er) + }) + function andCheckFile (f) { + return [checkFile, f] + } + function checkFile (f, next) { + var file = path.join(root, f) + tracker.silly('checkFilePermissions', f) + fs.stat(file, function (e, stat) { + tracker.completeWork(1) + if (e) return next(e) + if (!stat.isFile()) return next() + var mode = stat.mode + var isGroup = stat.gid ? stat.gid === gid : true + var isUser = stat.uid ? stat.uid === uid : true + if ((mode & parseInt('000' + mask, 8))) return next() + if ((isGroup && mode & parseInt('00' + mask + '0', 8))) return next() + if ((isUser && mode & parseInt('0' + mask + '00', 8))) return next() + tracker.error('checkFilePermissions', 'Missing permissions on (' + isGroup + ', ' + isUser + ', ' + mode + ')', file) + return next(new Error('Missing permissions for ' + file)) + }) + } + }) + }) +} + +module.exports = checkFilesPermission diff --git a/deps/npm/lib/doctor/check-ping.js b/deps/npm/lib/doctor/check-ping.js new file mode 100644 index 00000000000000..99e4ea2ba26e6b --- /dev/null +++ b/deps/npm/lib/doctor/check-ping.js @@ -0,0 +1,13 @@ +var log = require('npmlog') +var ping = require('../ping.js') + +function checkPing (cb) { + var tracker = log.newItem('checkPing', 1) + tracker.info('checkPing', 'Pinging registry') + ping({}, true, function (err, pong) { + tracker.finish() + cb(err, pong) + }) +} + +module.exports = checkPing diff --git a/deps/npm/lib/doctor/checksum-cached-files.js b/deps/npm/lib/doctor/checksum-cached-files.js new file mode 100644 index 00000000000000..d50c32685210a1 --- /dev/null +++ b/deps/npm/lib/doctor/checksum-cached-files.js @@ -0,0 +1,62 @@ +var crypto = require('crypto') +var fs = require('fs') +var path = require('path') +var chain = require('slide').chain +var log = require('npmlog') +var npm = require('../npm') +var fileCompletion = require('../utils/completion/file-completion.js') + +function checksum (str) { + return crypto + .createHash('sha1') + .update(str, 'utf8') + .digest('hex') +} + +function checksumCachedFiles (cb) { + var tracker = log.newItem('checksumCachedFiles', 1) + tracker.info('checksumCachedFiles', 'Building file list of ' + npm.cache) + fileCompletion(npm.cache, '.', Infinity, function (e, files) { + if (e) { + tracker.finish() + return cb(e) + } + tracker.addWork(files.length) + tracker.completeWork(1) + chain(files.map(andChecksumFile), function (er) { + tracker.finish() + cb(null, !er) + }) + function andChecksumFile (f) { + return [function (next) { process.nextTick(function () { checksumFile(f, next) }) }] + } + function checksumFile (f, next) { + var file = path.join(npm.cache, f) + tracker.silly('checksumFile', f) + if (!/.tgz$/.test(file)) { + tracker.completeWork(1) + return next() + } + fs.readFile(file, function (err, tgz) { + tracker.completeWork(1) + if (err) return next(err) + try { + var pkgJSON = fs.readFileSync(path.join(path.dirname(file), 'package/package.json')) + } catch (e) { + return next() // no package.json in cche is ok + } + try { + var pkg = JSON.parse(pkgJSON) + var shasum = (pkg.dist && pkg.dist.shasum) || pkg._shasum + var actual = checksum(tgz) + if (actual !== shasum) return next(new Error('Checksum mismatch on ' + file + ', expected: ' + shasum + ', got: ' + shasum)) + return next() + } catch (e) { + return next(new Error('Error parsing JSON in ' + file + ': ' + e)) + } + }) + } + }) +} + +module.exports = checksumCachedFiles diff --git a/deps/npm/lib/doctor/get-git-path.js b/deps/npm/lib/doctor/get-git-path.js new file mode 100644 index 00000000000000..5b00e9d54e6bc9 --- /dev/null +++ b/deps/npm/lib/doctor/get-git-path.js @@ -0,0 +1,13 @@ +var log = require('npmlog') +var which = require('which') + +function getGitPath (cb) { + var tracker = log.newItem('getGitPath', 1) + tracker.info('getGitPath', 'Finding git in your PATH') + which('git', function (err, path) { + tracker.finish() + cb(err, path) + }) +} + +module.exports = getGitPath diff --git a/deps/npm/lib/doctor/get-latest-nodejs-version.js b/deps/npm/lib/doctor/get-latest-nodejs-version.js new file mode 100644 index 00000000000000..a21229692fb30f --- /dev/null +++ b/deps/npm/lib/doctor/get-latest-nodejs-version.js @@ -0,0 +1,26 @@ +var log = require('npmlog') +var request = require('request') + +function getLatestNodejsVersion (url, cb) { + var tracker = log.newItem('getLatestNodejsVersion', 1) + tracker.info('getLatestNodejsVersion', 'Getting Node.js release information') + var version = '' + url = url || 'https://nodejs.org/dist/index.json' + request(url, function (e, res, index) { + tracker.finish() + if (e) return cb(e) + if (res.statusCode !== 200) { + return cb(new Error('Status not 200, ' + res.statusCode)) + } + try { + JSON.parse(index).forEach(function (item) { + if (item.lts && item.version > version) version = item.version + }) + cb(null, version) + } catch (e) { + cb(e) + } + }) +} + +module.exports = getLatestNodejsVersion diff --git a/deps/npm/lib/doctor/get-latest-npm-version.js b/deps/npm/lib/doctor/get-latest-npm-version.js new file mode 100644 index 00000000000000..4df0fee0fa3940 --- /dev/null +++ b/deps/npm/lib/doctor/get-latest-npm-version.js @@ -0,0 +1,13 @@ +var log = require('npmlog') +var fetchPackageMetadata = require('../fetch-package-metadata') + +function getLatestNpmVersion (cb) { + var tracker = log.newItem('getLatestNpmVersion', 1) + tracker.info('getLatestNpmVersion', 'Getting npm package information') + fetchPackageMetadata('npm@latest', '.', function (e, d) { + tracker.finish() + cb(e, d.version) + }) +} + +module.exports = getLatestNpmVersion diff --git a/deps/npm/lib/fetch-package-metadata.js b/deps/npm/lib/fetch-package-metadata.js index 85322304d5f15c..bd6e47e17c132c 100644 --- a/deps/npm/lib/fetch-package-metadata.js +++ b/deps/npm/lib/fetch-package-metadata.js @@ -26,6 +26,7 @@ var getCacheStat = require('./cache/get-stat.js') var unpack = require('./utils/tar.js').unpack var pulseTillDone = require('./utils/pulse-till-done.js') var parseJSON = require('./utils/parse-json.js') +var pickManifestFromRegistryMetadata = require('./utils/pick-manifest-from-registry-metadata.js') function andLogAndFinish (spec, tracker, done) { validate('SF', [spec, done]) @@ -113,7 +114,7 @@ function fetchNamedPackageData (dep, next) { } else { npm.registry.get(url, {auth: auth}, pulseTillDone('fetchMetadata', iferr(next, pickVersionFromRegistryDocument))) } - function returnAndAddMetadata (pkg) { + function thenAddMetadata (pkg) { pkg._from = dep.raw pkg._resolved = pkg.dist.tarball pkg._shasum = pkg.dist.shasum @@ -130,35 +131,14 @@ function fetchNamedPackageData (dep, next) { 'You should delete or re-publish the invalid versions.', pkg.name, invalidVersions.join(', ')) } - versions = versions.filter(function (v) { return semver.valid(v) }).sort(semver.rcompare) + versions = versions.filter(function (v) { return semver.valid(v) }) if (dep.type === 'tag') { var tagVersion = pkg['dist-tags'][dep.spec] - if (pkg.versions[tagVersion]) return returnAndAddMetadata(pkg.versions[tagVersion]) + if (pkg.versions[tagVersion]) return thenAddMetadata(pkg.versions[tagVersion]) } else { - var latestVersion = pkg['dist-tags'][npm.config.get('tag')] || versions[0] - - // Find the the most recent version less than or equal - // to latestVersion that satisfies our spec - for (var ii = 0; ii < versions.length; ++ii) { - if (semver.gt(versions[ii], latestVersion)) continue - if (semver.satisfies(versions[ii], dep.spec)) { - return returnAndAddMetadata(pkg.versions[versions[ii]]) - } - } - - // Failing that, try finding the most recent version that matches - // our spec - for (var jj = 0; jj < versions.length; ++jj) { - if (semver.satisfies(versions[jj], dep.spec)) { - return returnAndAddMetadata(pkg.versions[versions[jj]]) - } - } - - // Failing THAT, if the range was '*' uses latestVersion - if (dep.spec === '*') { - return returnAndAddMetadata(pkg.versions[latestVersion]) - } + var picked = pickManifestFromRegistryMetadata(dep.spec, npm.config.get('tag'), versions, pkg) + if (picked) return thenAddMetadata(picked.manifest) } // We didn't manage to find a compatible version diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js index 0cf6a2b2d632c3..1b0601d9f4586b 100644 --- a/deps/npm/lib/install.js +++ b/deps/npm/lib/install.js @@ -114,6 +114,7 @@ var unlock = locker.unlock var ls = require('./ls.js') var parseJSON = require('./utils/parse-json.js') var output = require('./utils/output.js') +var saveMetrics = require('./utils/metrics.js').save // install specific libraries var copyTree = require('./install/copy-tree.js') @@ -216,9 +217,14 @@ function Installer (where, dryrun, args) { } Installer.prototype = {} -Installer.prototype.run = function (cb) { +Installer.prototype.run = function (_cb) { validate('F', arguments) + var cb = function (err) { + saveMetrics(!err) + return _cb.apply(this, arguments) + } + // FIXME: This is bad and I should feel bad. // lib/install needs to have some way of sharing _limited_ // state with the things it calls. Passing the object is too diff --git a/deps/npm/lib/install/deps.js b/deps/npm/lib/install/deps.js index bdbd81700745a7..a31976a50d78a1 100644 --- a/deps/npm/lib/install/deps.js +++ b/deps/npm/lib/install/deps.js @@ -188,9 +188,13 @@ function addRequiredDep (tree, child, cb) { } exports.removeObsoleteDep = removeObsoleteDep -function removeObsoleteDep (child) { +function removeObsoleteDep (child, log) { if (child.removed) return child.removed = true + if (log) { + log.silly('removeObsoleteDep', 'removing ' + packageId(child) + + ' from the tree as its been replaced by a newer version or is no longer required') + } // remove from physical tree if (child.parent) { child.parent.children = child.parent.children.filter(function (pchild) { return pchild !== child }) @@ -199,7 +203,7 @@ function removeObsoleteDep (child) { var requires = child.requires || [] requires.forEach(function (requirement) { requirement.requiredBy = requirement.requiredBy.filter(function (reqBy) { return reqBy !== child }) - if (requirement.requiredBy.length === 0) removeObsoleteDep(requirement) + if (requirement.requiredBy.length === 0) removeObsoleteDep(requirement, log) }) } diff --git a/deps/npm/lib/install/diff-trees.js b/deps/npm/lib/install/diff-trees.js index db4fb3ce31242a..1429c71dcb8c34 100644 --- a/deps/npm/lib/install/diff-trees.js +++ b/deps/npm/lib/install/diff-trees.js @@ -23,7 +23,7 @@ function pkgAreEquiv (aa, bb) { return false } -function getNameAndVersion (pkg) { +function getUniqueId (pkg) { var versionspec = pkg._shasum if (!versionspec && nonRegistrySource(pkg)) { @@ -113,21 +113,25 @@ var sortActions = module.exports.sortActions = function (differences) { return sorted } +function setAction (differences, action, pkg) { + differences.push([action, pkg]) +} + var diffTrees = module.exports._diffTrees = function (oldTree, newTree) { validate('OO', arguments) var differences = [] var flatOldTree = flattenTree(oldTree) var flatNewTree = flattenTree(newTree) var toRemove = {} - var toRemoveByNameAndVer = {} + var toRemoveByUniqueId = {} // find differences Object.keys(flatOldTree).forEach(function (flatname) { if (flatNewTree[flatname]) return var pkg = flatOldTree[flatname] toRemove[flatname] = pkg - var namever = getNameAndVersion(pkg.package) - if (!toRemoveByNameAndVer[namever]) toRemoveByNameAndVer[namever] = [] - toRemoveByNameAndVer[namever].push(flatname) + var pkgunique = getUniqueId(pkg.package) + if (!toRemoveByUniqueId[pkgunique]) toRemoveByUniqueId[pkgunique] = [] + toRemoveByUniqueId[pkgunique].push(flatname) }) Object.keys(flatNewTree).forEach(function (path) { var pkg = flatNewTree[path] @@ -138,21 +142,21 @@ var diffTrees = module.exports._diffTrees = function (oldTree, newTree) { if (pkg.oldPkg) { if (!pkg.userRequired && pkgAreEquiv(pkg.oldPkg.package, pkg.package)) return if (!pkg.isInLink && (isLink(pkg.oldPkg) || isLink(pkg))) { - differences.push(['update-linked', pkg]) + setAction(differences, 'update-linked', pkg) } else { - differences.push(['update', pkg]) + setAction(differences, 'update', pkg) } } else { - var vername = getNameAndVersion(pkg.package) - var removing = toRemoveByNameAndVer[vername] && toRemoveByNameAndVer[vername].length + var vername = getUniqueId(pkg.package) + var removing = toRemoveByUniqueId[vername] && toRemoveByUniqueId[vername].length var bundlesOrFromBundle = pkg.fromBundle || pkg.package.bundleDependencies if (removing && !bundlesOrFromBundle) { - var flatname = toRemoveByNameAndVer[vername].shift() + var flatname = toRemoveByUniqueId[vername].shift() pkg.fromPath = toRemove[flatname].path - differences.push(['move', pkg]) + setAction(differences, 'move', pkg) delete toRemove[flatname] } else { - differences.push(['add', pkg]) + setAction(differences, 'add', pkg) } } }) @@ -160,7 +164,7 @@ var diffTrees = module.exports._diffTrees = function (oldTree, newTree) { .keys(toRemove) .map(function (path) { return toRemove[path] }) .forEach(function (pkg) { - differences.push(['remove', pkg]) + setAction(differences, 'remove', pkg) }) return differences } diff --git a/deps/npm/lib/install/save.js b/deps/npm/lib/install/save.js index d5c97bfaa26f4e..18028a3c26f48f 100644 --- a/deps/npm/lib/install/save.js +++ b/deps/npm/lib/install/save.js @@ -167,11 +167,7 @@ function computeVersionSpec (child) { pathname: requested.spec }) } else { - return url.format({ - protocol: 'file', - slashes: false, - pathname: relativePath - }) + return 'file:' + relativePath } } else if (requested.type === 'hosted') { return requested.spec diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js index 05749b3fd2614e..d0af64b19579a4 100644 --- a/deps/npm/lib/npm.js +++ b/deps/npm/lib/npm.js @@ -35,6 +35,7 @@ var cmdList = require('./config/cmd-list').cmdList var plumbing = require('./config/cmd-list').plumbing var output = require('./utils/output.js') + var startMetrics = require('./utils/metrics.js').start npm.config = { loaded: false, @@ -308,6 +309,8 @@ // go ahead and spin up the registry client. npm.registry = new CachingRegClient(npm.config) + startMetrics() + return cb(null, npm) }) }) diff --git a/deps/npm/lib/outdated.js b/deps/npm/lib/outdated.js index 9f6a8b75eb0d9f..a4a0d15abbf448 100644 --- a/deps/npm/lib/outdated.js +++ b/deps/npm/lib/outdated.js @@ -41,6 +41,7 @@ var isExtraneous = require('./install/is-extraneous.js') var recalculateMetadata = require('./install/deps.js').recalculateMetadata var moduleName = require('./utils/module-name.js') var output = require('./utils/output.js') +var ansiTrim = require('./utils/ansi-trim') function uniqName (item) { return item[0].path + '|' + item[1] + '|' + item[7] @@ -149,12 +150,6 @@ function makePretty (p) { return columns } -function ansiTrim (str) { - var r = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' + - '\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g') - return str.replace(r, '') -} - function makeParseable (list) { return list.map(function (p) { var dep = p[0] diff --git a/deps/npm/lib/prune.js b/deps/npm/lib/prune.js index 46373742f59afd..6d103fc5086455 100644 --- a/deps/npm/lib/prune.js +++ b/deps/npm/lib/prune.js @@ -1,54 +1,66 @@ // prune extraneous packages. module.exports = prune +module.exports.Pruner = Pruner prune.usage = 'npm prune [[<@scope>/]...] [--production]' -var readInstalled = require('read-installed') var npm = require('./npm.js') -var path = require('path') -var readJson = require('read-package-json') var log = require('npmlog') +var util = require('util') +var moduleName = require('./utils/module-name.js') +var Installer = require('./install.js').Installer +var isExtraneous = require('./install/is-extraneous.js') +var isDev = require('./install/is-dev-dep.js') +var removeDeps = require('./install/deps.js').removeDeps +var loadExtraneous = require('./install/deps.js').loadExtraneous +var chain = require('slide').chain prune.completion = require('./utils/completion/installed-deep.js') function prune (args, cb) { - // check if is a valid package.json file - var jsonFile = path.resolve(npm.dir, '..', 'package.json') - readJson(jsonFile, log.warn, function (er) { - if (er) return cb(er) - next() - }) - - function next () { - var opt = { - depth: npm.config.get('depth'), - dev: !npm.config.get('production') || npm.config.get('dev') - } - readInstalled(npm.prefix, opt, function (er, data) { - if (er) return cb(er) - prune_(args, data, cb) - }) - } + var dryrun = !!npm.config.get('dry-run') + new Pruner('.', dryrun, args).run(cb) } -function prune_ (args, data, cb) { - npm.commands.unbuild(prunables(args, data, []), cb) +function Pruner (where, dryrun, args) { + Installer.call(this, where, dryrun, args) } +util.inherits(Pruner, Installer) + +Pruner.prototype.loadAllDepsIntoIdealTree = function (cb) { + log.silly('uninstall', 'loadAllDepsIntoIdealtree') + + var cg = this.progress.loadAllDepsIntoIdealTree + var steps = [] -function prunables (args, data, seen) { - var deps = data.dependencies || {} - return Object.keys(deps).map(function (d) { - if (typeof deps[d] !== 'object' || seen.indexOf(deps[d]) !== -1) return null - seen.push(deps[d]) - if (deps[d].extraneous && (args.length === 0 || args.indexOf(d) !== -1)) { - var extra = deps[d] - delete deps[d] - return extra.path - } - return prunables(args, deps[d], seen) - }).filter(function (d) { return d !== null }) - .reduce(function FLAT (l, r) { - return l.concat(Array.isArray(r) ? r.reduce(FLAT, []) : r) - }, []) + var self = this + var excludeDev = npm.config.get('production') || /^prod(uction)?$/.test(npm.config.get('only')) + function shouldPrune (child) { + if (isExtraneous(child)) return true + if (!excludeDev) return false + var childName = moduleName(child) + var isChildDev = function (parent) { return isDev(parent, childName) } + if (child.requiredBy.every(isChildDev)) return true + } + function getModuleName (child) { + // wrapping because moduleName doesn't like extra args and we're called + // from map. + return moduleName(child) + } + function matchesArg (name) { + return self.args.length === 0 || self.args.indexOf(name) !== -1 + } + function nameObj (name) { + return {name: name} + } + var toPrune = this.currentTree.children.filter(shouldPrune).map(getModuleName).filter(matchesArg).map(nameObj) + + steps.push( + [removeDeps, toPrune, this.idealTree, null, cg.newGroup('removeDeps')], + [loadExtraneous, this.idealTree, cg.newGroup('loadExtraneous')]) + chain(steps, cb) } + +Pruner.prototype.runPreinstallTopLevelLifecycles = function (cb) { cb() } +Pruner.prototype.runPostinstallTopLevelLifecycles = function (cb) { cb() } diff --git a/deps/npm/lib/shrinkwrap.js b/deps/npm/lib/shrinkwrap.js index 57ad0ab5d9ed9e..5e12f0bd819927 100644 --- a/deps/npm/lib/shrinkwrap.js +++ b/deps/npm/lib/shrinkwrap.js @@ -165,7 +165,7 @@ function isOnlyDev (node, seen) { // There is a known limitation with this implementation: If a dependency is // ONLY required by cycles that are detached from the top level then it will -// ultimately return ture. +// ultimately return true. // // This is ok though: We don't allow shrinkwraps with extraneous deps and // these situation is caught by the extraneous checker before we get here. diff --git a/deps/npm/lib/uninstall.js b/deps/npm/lib/uninstall.js index 9a05e6697fb37e..2176048843f6b2 100644 --- a/deps/npm/lib/uninstall.js +++ b/deps/npm/lib/uninstall.js @@ -74,3 +74,6 @@ Uninstaller.prototype.loadAllDepsIntoIdealTree = function (cb) { [loadExtraneous, this.idealTree, cg.newGroup('loadExtraneous')]) chain(steps, cb) } + +Uninstaller.prototype.runPreinstallTopLevelLifecycles = function (cb) { cb() } +Uninstaller.prototype.runPostinstallTopLevelLifecycles = function (cb) { cb() } diff --git a/deps/npm/lib/utils/ansi-trim.js b/deps/npm/lib/utils/ansi-trim.js new file mode 100644 index 00000000000000..7f9a6c30ec9b1a --- /dev/null +++ b/deps/npm/lib/utils/ansi-trim.js @@ -0,0 +1,7 @@ +function ansiTrim (str) { + var r = new RegExp('\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|' + + '\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)', 'g') + return str.replace(r, '') +} + +module.exports = ansiTrim diff --git a/deps/npm/lib/utils/error-handler.js b/deps/npm/lib/utils/error-handler.js index 6b2bf1c72d253b..f3cfc3c5ea22b5 100644 --- a/deps/npm/lib/utils/error-handler.js +++ b/deps/npm/lib/utils/error-handler.js @@ -13,10 +13,15 @@ var rollbacks = npm.rollbacks var chain = require('slide').chain var writeStreamAtomic = require('fs-write-stream-atomic') var errorMessage = require('./error-message.js') +var stopMetrics = require('./metrics.js').stop process.on('exit', function (code) { log.disableProgress() if (!npm.config || !npm.config.loaded) return + + // kill any outstanding stats reporter if it hasn't finished yet + stopMetrics() + if (code) itWorked = false if (itWorked) log.info('ok') else { diff --git a/deps/npm/lib/utils/metrics-launch.js b/deps/npm/lib/utils/metrics-launch.js new file mode 100644 index 00000000000000..821f8bc7e4fde3 --- /dev/null +++ b/deps/npm/lib/utils/metrics-launch.js @@ -0,0 +1,39 @@ +'use strict' +module.exports = launchSendMetrics +var fs = require('graceful-fs') +var child_process = require('child_process') + +if (require.main === module) main() + +function launchSendMetrics () { + var path = require('path') + var npm = require('../npm.js') + try { + if (!npm.config.get('send-metrics')) return + var cliMetrics = path.join(npm.config.get('cache'), 'anonymous-cli-metrics.json') + var targetRegistry = npm.config.get('metrics-registry') + fs.statSync(cliMetrics) + return runInBackground(__filename, [cliMetrics, targetRegistry]) + } catch (ex) { + // if the metrics file doesn't exist, don't run + } +} + +function runInBackground (js, args, opts) { + if (!args) args = [] + args.unshift(js) + if (!opts) opts = {} + opts.stdio = 'ignore' + opts.detached = true + var child = child_process.spawn(process.execPath, args, opts) + child.unref() + return child +} + +function main () { + var sendMetrics = require('./metrics.js').send + var metricsFile = process.argv[2] + var metricsRegistry = process.argv[3] + + sendMetrics(metricsFile, metricsRegistry) +} diff --git a/deps/npm/lib/utils/metrics.js b/deps/npm/lib/utils/metrics.js new file mode 100644 index 00000000000000..c51136e78cdb72 --- /dev/null +++ b/deps/npm/lib/utils/metrics.js @@ -0,0 +1,73 @@ +'use strict' +exports.start = startMetrics +exports.stop = stopMetrics +exports.save = saveMetrics +exports.send = sendMetrics + +var fs = require('fs') +var path = require('path') +var npm = require('../npm.js') +var uuid = require('uuid') + +var inMetrics = false + +function startMetrics () { + if (inMetrics) return + // loaded on demand to avoid any recursive deps when `./metrics-launch` requires us. + var metricsLaunch = require('./metrics-launch.js') + npm.metricsProcess = metricsLaunch() +} + +function stopMetrics () { + if (inMetrics) return + if (npm.metricsProcess) npm.metricsProcess.kill('SIGKILL') +} + +function saveMetrics (itWorked) { + if (inMetrics) return + // If the metrics reporter hasn't managed to PUT yet then kill it so that it doesn't + // step on our updating the anonymous-cli-metrics json + stopMetrics() + var metricsFile = path.join(npm.config.get('cache'), 'anonymous-cli-metrics.json') + var metrics + try { + metrics = JSON.parse(fs.readFileSync(metricsFile)) + metrics.metrics.to = new Date().toISOString() + if (itWorked) { + ++metrics.metrics.successfulInstalls + } else { + ++metrics.metrics.failedInstalls + } + } catch (ex) { + metrics = { + metricId: uuid.v4(), + metrics: { + from: new Date().toISOString(), + to: new Date().toISOString(), + successfulInstalls: itWorked ? 1 : 0, + failedInstalls: itWorked ? 0 : 1 + } + } + } + try { + fs.writeFileSync(metricsFile, JSON.stringify(metrics)) + } catch (ex) { + // we couldn't write the error metrics file, um, well, oh well. + } +} + +function sendMetrics (metricsFile, metricsRegistry) { + inMetrics = true + var cliMetrics = JSON.parse(fs.readFileSync(metricsFile)) + npm.load({}, function (err) { + if (err) return + npm.registry.config.retry.retries = 0 + npm.registry.sendAnonymousCLIMetrics(metricsRegistry, cliMetrics, function (err) { + if (err) { + fs.writeFileSync(path.join(path.dirname(metricsFile), 'last-send-metrics-error.txt'), err.stack) + } else { + fs.unlinkSync(metricsFile) + } + }) + }) +} diff --git a/deps/npm/lib/utils/pick-manifest-from-registry-metadata.js b/deps/npm/lib/utils/pick-manifest-from-registry-metadata.js new file mode 100644 index 00000000000000..e2c0d2e5aa45e0 --- /dev/null +++ b/deps/npm/lib/utils/pick-manifest-from-registry-metadata.js @@ -0,0 +1,26 @@ +'use strict' +module.exports = pickManifestFromRegistryMetadata + +var log = require('npmlog') +var semver = require('semver') + +function pickManifestFromRegistryMetadata (spec, tag, versions, metadata) { + log.silly('pickManifestFromRegistryMetadata', 'spec', spec, 'tag', tag, 'versions', versions) + + // if the tagged version satisfies, then use that. + var tagged = metadata['dist-tags'][tag] + if (tagged && + metadata.versions[tagged] && + semver.satisfies(tagged, spec, true)) { + return {resolvedTo: tag, manifest: metadata.versions[tagged]} + } + // find the max satisfying version. + var ms = semver.maxSatisfying(versions, spec, true) + if (ms) { + return {resolvedTo: ms, manifest: metadata.versions[ms]} + } else if (spec === '*' && versions.length && tagged && metadata.versions[tagged]) { + return {resolvedTo: tag, manifest: metadata.versions[tagged]} + } else { + return + } +} diff --git a/deps/npm/lib/utils/unsupported.js b/deps/npm/lib/utils/unsupported.js index 5e74e3490faea0..91f494f4be88f0 100644 --- a/deps/npm/lib/utils/unsupported.js +++ b/deps/npm/lib/utils/unsupported.js @@ -1,6 +1,6 @@ 'use strict' var semver = require('semver') -var supportedNode = '0.12 || >= 4' +var supportedNode = '>= 4' var knownBroken = '>=0.1 <=0.7' var checkVersion = exports.checkVersion = function (version) { diff --git a/deps/npm/man/man1/npm-README.1 b/deps/npm/man/man1/npm-README.1 index 264624dfa12d54..b7c50819f83e35 100644 --- a/deps/npm/man/man1/npm-README.1 +++ b/deps/npm/man/man1/npm-README.1 @@ -1,4 +1,4 @@ -.TH "NPM" "1" "December 2016" "" "" +.TH "NPM" "1" "January 2017" "" "" .SH "NAME" \fBnpm\fR \- a JavaScript package manager .P diff --git a/deps/npm/man/man1/npm-access.1 b/deps/npm/man/man1/npm-access.1 index dfe958dbb0effc..049e228e4fd6cd 100644 --- a/deps/npm/man/man1/npm-access.1 +++ b/deps/npm/man/man1/npm-access.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ACCESS" "1" "December 2016" "" "" +.TH "NPM\-ACCESS" "1" "January 2017" "" "" .SH "NAME" \fBnpm-access\fR \- Set access level on published packages .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-adduser.1 b/deps/npm/man/man1/npm-adduser.1 index e1142dd49b639a..3b68c1efff1b2a 100644 --- a/deps/npm/man/man1/npm-adduser.1 +++ b/deps/npm/man/man1/npm-adduser.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ADDUSER" "1" "December 2016" "" "" +.TH "NPM\-ADDUSER" "1" "January 2017" "" "" .SH "NAME" \fBnpm-adduser\fR \- Add a registry user account .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-bin.1 b/deps/npm/man/man1/npm-bin.1 index 1fc8994c8cfa13..c10997f3f63587 100644 --- a/deps/npm/man/man1/npm-bin.1 +++ b/deps/npm/man/man1/npm-bin.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BIN" "1" "December 2016" "" "" +.TH "NPM\-BIN" "1" "January 2017" "" "" .SH "NAME" \fBnpm-bin\fR \- Display npm bin folder .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-bugs.1 b/deps/npm/man/man1/npm-bugs.1 index 3a9eb1352e9efe..f95d7383862dd2 100644 --- a/deps/npm/man/man1/npm-bugs.1 +++ b/deps/npm/man/man1/npm-bugs.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BUGS" "1" "December 2016" "" "" +.TH "NPM\-BUGS" "1" "January 2017" "" "" .SH "NAME" \fBnpm-bugs\fR \- Bugs for a package in a web browser maybe .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-build.1 b/deps/npm/man/man1/npm-build.1 index b6f860139e5904..5016086c62fe00 100644 --- a/deps/npm/man/man1/npm-build.1 +++ b/deps/npm/man/man1/npm-build.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BUILD" "1" "December 2016" "" "" +.TH "NPM\-BUILD" "1" "January 2017" "" "" .SH "NAME" \fBnpm-build\fR \- Build a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-bundle.1 b/deps/npm/man/man1/npm-bundle.1 index 72e8deb547333c..f42848ce47f034 100644 --- a/deps/npm/man/man1/npm-bundle.1 +++ b/deps/npm/man/man1/npm-bundle.1 @@ -1,4 +1,4 @@ -.TH "NPM\-BUNDLE" "1" "December 2016" "" "" +.TH "NPM\-BUNDLE" "1" "January 2017" "" "" .SH "NAME" \fBnpm-bundle\fR \- REMOVED .SH DESCRIPTION diff --git a/deps/npm/man/man1/npm-cache.1 b/deps/npm/man/man1/npm-cache.1 index 29b5a1f89dd7af..6ece75060320bf 100644 --- a/deps/npm/man/man1/npm-cache.1 +++ b/deps/npm/man/man1/npm-cache.1 @@ -1,4 +1,4 @@ -.TH "NPM\-CACHE" "1" "December 2016" "" "" +.TH "NPM\-CACHE" "1" "January 2017" "" "" .SH "NAME" \fBnpm-cache\fR \- Manipulates packages cache .SH SYNOPSIS @@ -13,11 +13,12 @@ npm cache add @ npm cache ls [] npm cache clean [] +aliases: npm cache clear, npm cache rm .fi .RE .SH DESCRIPTION .P -Used to add, list, or clear the npm cache folder\. +Used to add, list, or clean the npm cache folder\. .RS 0 .IP \(bu 2 add: @@ -33,7 +34,7 @@ folder\. Works a bit like the \fBfind\fP program, but limited by the clean: Delete data out of the cache folder\. If an argument is provided, then it specifies a subpath to delete\. If no argument is provided, then -the entire cache is cleared\. +the entire cache is deleted\. .RE .SH DETAILS diff --git a/deps/npm/man/man1/npm-completion.1 b/deps/npm/man/man1/npm-completion.1 index 241ab9cf5c5163..f3e72de7100123 100644 --- a/deps/npm/man/man1/npm-completion.1 +++ b/deps/npm/man/man1/npm-completion.1 @@ -1,4 +1,4 @@ -.TH "NPM\-COMPLETION" "1" "December 2016" "" "" +.TH "NPM\-COMPLETION" "1" "January 2017" "" "" .SH "NAME" \fBnpm-completion\fR \- Tab Completion for npm .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-config.1 b/deps/npm/man/man1/npm-config.1 index 5b69e6d9da1214..b6088f4b42b6e1 100644 --- a/deps/npm/man/man1/npm-config.1 +++ b/deps/npm/man/man1/npm-config.1 @@ -1,4 +1,4 @@ -.TH "NPM\-CONFIG" "1" "December 2016" "" "" +.TH "NPM\-CONFIG" "1" "January 2017" "" "" .SH "NAME" \fBnpm-config\fR \- Manage the npm configuration files .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-dedupe.1 b/deps/npm/man/man1/npm-dedupe.1 index 4a9c1af29e11dd..964aa929aaab0f 100644 --- a/deps/npm/man/man1/npm-dedupe.1 +++ b/deps/npm/man/man1/npm-dedupe.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DEDUPE" "1" "December 2016" "" "" +.TH "NPM\-DEDUPE" "1" "January 2017" "" "" .SH "NAME" \fBnpm-dedupe\fR \- Reduce duplication .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-deprecate.1 b/deps/npm/man/man1/npm-deprecate.1 index 6dbeebabc8aa48..6408c1095de0f0 100644 --- a/deps/npm/man/man1/npm-deprecate.1 +++ b/deps/npm/man/man1/npm-deprecate.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DEPRECATE" "1" "December 2016" "" "" +.TH "NPM\-DEPRECATE" "1" "January 2017" "" "" .SH "NAME" \fBnpm-deprecate\fR \- Deprecate a version of a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-dist-tag.1 b/deps/npm/man/man1/npm-dist-tag.1 index af30e6634af7f4..418a383d2b5d0e 100644 --- a/deps/npm/man/man1/npm-dist-tag.1 +++ b/deps/npm/man/man1/npm-dist-tag.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DIST\-TAG" "1" "December 2016" "" "" +.TH "NPM\-DIST\-TAG" "1" "January 2017" "" "" .SH "NAME" \fBnpm-dist-tag\fR \- Modify package distribution tags .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-docs.1 b/deps/npm/man/man1/npm-docs.1 index a6e879031df9f7..89d3cfb5b24edc 100644 --- a/deps/npm/man/man1/npm-docs.1 +++ b/deps/npm/man/man1/npm-docs.1 @@ -1,4 +1,4 @@ -.TH "NPM\-DOCS" "1" "December 2016" "" "" +.TH "NPM\-DOCS" "1" "January 2017" "" "" .SH "NAME" \fBnpm-docs\fR \- Docs for a package in a web browser maybe .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-doctor.1 b/deps/npm/man/man1/npm-doctor.1 new file mode 100644 index 00000000000000..72ec355e472546 --- /dev/null +++ b/deps/npm/man/man1/npm-doctor.1 @@ -0,0 +1,113 @@ +.TH "NPM\-DOCTOR" "1" "January 2017" "" "" +.SH "NAME" +\fBnpm-doctor\fR \- Check your environments +.SH SYNOPSIS +.P +.RS 2 +.nf +npm doctor +.fi +.RE +.SH DESCRIPTION +.P +\fBnpm doctor\fP runs a set of checks to ensure that your npm installation has +what it needs to manage your JavaScript packages\. npm is mostly a standalone tool, but it does +have some basic requirements that must be met: +.RS 0 +.IP \(bu 2 +Node\.js and git must be executable by npm\. +.IP \(bu 2 +The primary npm registry, \fBregistry\.npmjs\.com\fP, or another service that uses +the registry API, is available\. +.IP \(bu 2 +The directories that npm uses, \fBnode_modules\fP (both locally and globally), +exist and can be written by the current user\. +.IP \(bu 2 +The npm cache exists, and the package tarballs within it aren't corrupt\. + +.RE +.P +Without all of these working properly, npm may not work properly\. Many issues +are often attributable to things that are outside npm's code base, so \fBnpm +doctor\fP confirms that the npm installation is in a good state\. +.P +Also, in addition to this, there are also very many issue reports due to using +old versions of npm\. Since npm is constantly improving, running \fBnpm@latest\fP is +better than an old version\. +.P +\fBnpm doctor\fP verifies the following items in your environment, and if there are +any recommended changes, it will display them\. +.SS \fBnpm ping\fP +.P +By default, npm installs from the primary npm registry, \fBregistry\.npmjs\.org\fP\|\. +\fBnpm doctor\fP hits a special ping endpoint within the registry\. This can also be +checked with \fBnpm ping\fP\|\. If this check fails, you may be using a proxy that +needs to be configured, or may need to talk to your IT staff to get access over +HTTPS to \fBregistry\.npmjs\.org\fP\|\. +.P +This check is done against whichever registry you've configured (you can see +what that is by running \fBnpm config get registry\fP), and if you're using a +private registry that doesn't support the \fB/whoami\fP endpoint supported by the +primary registry, this check may fail\. +.SS \fBnpm \-v\fP +.P +While Node\.js may come bundled with a particular version of npm, it's the +policy of the CLI team that we recommend all users run \fBnpm@latest\fP if they +can\. As the CLI is maintained by a small team of contributors, there are only +resources for a single line of development, so npm's own long\-term support +releases typically only receive critical security and regression fixes\. The +team believes that the latest tested version of npm is almost always likely to +be the most functional and defect\-free version of npm\. +.SS \fBnode \-v\fP +.P +For most users, in most circumstances, the best version of Node will be the +latest long\-term support (LTS) release\. Those of you who want access to new +ECMAscript features or bleeding\-edge changes to Node's standard library may be +running a newer version, and some of you may be required to run an older +version of Node because of enterprise change control policies\. That's OK! But +in general, the npm team recommends that most users run Node\.js LTS\. +.SS \fBnpm config get registry\fP +.P +Some of you may be installing from private package registries for your project +or company\. That's great! Others of you may be following tutorials or +StackOverflow questions in an effort to troubleshoot problems you may be +having\. Sometimes, this may entail changing the registry you're pointing at\. +This part of \fBnpm doctor\fP just lets you, and maybe whoever's helping you with +support, know that you're not using the default registry\. +.SS \fBwhich git\fP +.P +While it's documented in the README, it may not be obvious that npm needs Git +installed to do many of the things that it does\. Also, in some cases +– especially on Windows – you may have Git set up in such a way that it's not +accessible via your \fBPATH\fP so that npm can find it\. This check ensures that Git +is available\. +.SS Permissions checks +.RS 0 +.IP \(bu 2 +Your cache must be readable and writable by the user running npm\. +.IP \(bu 2 +Global package binaries must be writable by the user running npm\. +.IP \(bu 2 +Your local \fBnode_modules\fP path, if you're running \fBnpm doctor\fP with a project +directory, must be readable and writable by the user running npm\. + +.RE +.SS Validate the checksums of cached packages +.P +When an npm package is published, the publishing process generates a checksum +that npm uses at install time to verify that the package didn't get corrupted +in transit\. \fBnpm doctor\fP uses these checksums to validate the package tarballs +in your local cache (you can see where that cache is located with \fBnpm config +get cache\fP, and see what's in that cache with \fBnpm cache ls\fP – probably more +than you were expecting!)\. In the event that there are corrupt packages in your +cache, you should probably run \fBnpm cache clean\fP and reset the cache\. +.SH SEE ALSO +.RS 0 +.IP \(bu 2 +npm help bugs +.IP \(bu 2 +npm help help +.IP \(bu 2 +npm help ping + +.RE diff --git a/deps/npm/man/man1/npm-edit.1 b/deps/npm/man/man1/npm-edit.1 index 11d8960e0ecf46..6476986e92982a 100644 --- a/deps/npm/man/man1/npm-edit.1 +++ b/deps/npm/man/man1/npm-edit.1 @@ -1,4 +1,4 @@ -.TH "NPM\-EDIT" "1" "December 2016" "" "" +.TH "NPM\-EDIT" "1" "January 2017" "" "" .SH "NAME" \fBnpm-edit\fR \- Edit an installed package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-explore.1 b/deps/npm/man/man1/npm-explore.1 index 72e5cebc94cda4..0d9ec036a74d27 100644 --- a/deps/npm/man/man1/npm-explore.1 +++ b/deps/npm/man/man1/npm-explore.1 @@ -1,4 +1,4 @@ -.TH "NPM\-EXPLORE" "1" "December 2016" "" "" +.TH "NPM\-EXPLORE" "1" "January 2017" "" "" .SH "NAME" \fBnpm-explore\fR \- Browse an installed package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-help-search.1 b/deps/npm/man/man1/npm-help-search.1 index 7e2a432e1f001e..5b5412f22edd4e 100644 --- a/deps/npm/man/man1/npm-help-search.1 +++ b/deps/npm/man/man1/npm-help-search.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HELP\-SEARCH" "1" "December 2016" "" "" +.TH "NPM\-HELP\-SEARCH" "1" "January 2017" "" "" .SH "NAME" \fBnpm-help-search\fR \- Search npm help documentation .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-help.1 b/deps/npm/man/man1/npm-help.1 index 7f420d43bf6a49..bbdb7a1f6be32d 100644 --- a/deps/npm/man/man1/npm-help.1 +++ b/deps/npm/man/man1/npm-help.1 @@ -1,4 +1,4 @@ -.TH "NPM\-HELP" "1" "December 2016" "" "" +.TH "NPM\-HELP" "1" "January 2017" "" "" .SH "NAME" \fBnpm-help\fR \- Get help on npm .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-init.1 b/deps/npm/man/man1/npm-init.1 index 81edab5534cc29..246516e8b400b8 100644 --- a/deps/npm/man/man1/npm-init.1 +++ b/deps/npm/man/man1/npm-init.1 @@ -1,4 +1,4 @@ -.TH "NPM\-INIT" "1" "December 2016" "" "" +.TH "NPM\-INIT" "1" "January 2017" "" "" .SH "NAME" \fBnpm-init\fR \- Interactively create a package\.json file .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-install-test.1 b/deps/npm/man/man1/npm-install-test.1 index b1899955163f2a..b68e51af87eae9 100644 --- a/deps/npm/man/man1/npm-install-test.1 +++ b/deps/npm/man/man1/npm-install-test.1 @@ -1,4 +1,4 @@ -.TH "NPM" "" "December 2016" "" "" +.TH "NPM" "" "January 2017" "" "" .SH "NAME" \fBnpm\fR .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-install.1 b/deps/npm/man/man1/npm-install.1 index bacdea8c0ea1fb..7fed774466261a 100644 --- a/deps/npm/man/man1/npm-install.1 +++ b/deps/npm/man/man1/npm-install.1 @@ -1,4 +1,4 @@ -.TH "NPM\-INSTALL" "1" "December 2016" "" "" +.TH "NPM\-INSTALL" "1" "January 2017" "" "" .SH "NAME" \fBnpm-install\fR \- Install a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-link.1 b/deps/npm/man/man1/npm-link.1 index fe7ac0aebba194..9d8eb459d4c5c5 100644 --- a/deps/npm/man/man1/npm-link.1 +++ b/deps/npm/man/man1/npm-link.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LINK" "1" "December 2016" "" "" +.TH "NPM\-LINK" "1" "January 2017" "" "" .SH "NAME" \fBnpm-link\fR \- Symlink a package folder .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-logout.1 b/deps/npm/man/man1/npm-logout.1 index 39b9f212db6cc3..e79ccba5a86d4d 100644 --- a/deps/npm/man/man1/npm-logout.1 +++ b/deps/npm/man/man1/npm-logout.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LOGOUT" "1" "December 2016" "" "" +.TH "NPM\-LOGOUT" "1" "January 2017" "" "" .SH "NAME" \fBnpm-logout\fR \- Log out of the registry .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-ls.1 b/deps/npm/man/man1/npm-ls.1 index d0d5ed1022d6ae..6ce7bd5bc2eb57 100644 --- a/deps/npm/man/man1/npm-ls.1 +++ b/deps/npm/man/man1/npm-ls.1 @@ -1,4 +1,4 @@ -.TH "NPM\-LS" "1" "December 2016" "" "" +.TH "NPM\-LS" "1" "January 2017" "" "" .SH "NAME" \fBnpm-ls\fR \- List installed packages .SH SYNOPSIS @@ -22,7 +22,7 @@ For example, running \fBnpm ls promzard\fP in npm's source tree will show: .P .RS 2 .nf -npm@4.0.5 /path/to/npm +npm@4.1.2 /path/to/npm └─┬ init\-package\-json@0\.0\.4 └── promzard@0\.1\.5 .fi diff --git a/deps/npm/man/man1/npm-outdated.1 b/deps/npm/man/man1/npm-outdated.1 index e3e84a9cb14198..d324f09f821466 100644 --- a/deps/npm/man/man1/npm-outdated.1 +++ b/deps/npm/man/man1/npm-outdated.1 @@ -1,4 +1,4 @@ -.TH "NPM\-OUTDATED" "1" "December 2016" "" "" +.TH "NPM\-OUTDATED" "1" "January 2017" "" "" .SH "NAME" \fBnpm-outdated\fR \- Check for outdated packages .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-owner.1 b/deps/npm/man/man1/npm-owner.1 index d35ed5b7e8e10f..62d4a85f08738d 100644 --- a/deps/npm/man/man1/npm-owner.1 +++ b/deps/npm/man/man1/npm-owner.1 @@ -1,4 +1,4 @@ -.TH "NPM\-OWNER" "1" "December 2016" "" "" +.TH "NPM\-OWNER" "1" "January 2017" "" "" .SH "NAME" \fBnpm-owner\fR \- Manage package owners .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-pack.1 b/deps/npm/man/man1/npm-pack.1 index 8efafd0b519c68..623dec83a4c1d8 100644 --- a/deps/npm/man/man1/npm-pack.1 +++ b/deps/npm/man/man1/npm-pack.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PACK" "1" "December 2016" "" "" +.TH "NPM\-PACK" "1" "January 2017" "" "" .SH "NAME" \fBnpm-pack\fR \- Create a tarball from a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-ping.1 b/deps/npm/man/man1/npm-ping.1 index 79eccd8840b93a..24262c25804d5f 100644 --- a/deps/npm/man/man1/npm-ping.1 +++ b/deps/npm/man/man1/npm-ping.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PING" "1" "December 2016" "" "" +.TH "NPM\-PING" "1" "January 2017" "" "" .SH "NAME" \fBnpm-ping\fR \- Ping npm registry .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-prefix.1 b/deps/npm/man/man1/npm-prefix.1 index f293b2e4477af9..da1569e50e20b7 100644 --- a/deps/npm/man/man1/npm-prefix.1 +++ b/deps/npm/man/man1/npm-prefix.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PREFIX" "1" "December 2016" "" "" +.TH "NPM\-PREFIX" "1" "January 2017" "" "" .SH "NAME" \fBnpm-prefix\fR \- Display prefix .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-prune.1 b/deps/npm/man/man1/npm-prune.1 index 1e448536e6d2d4..895327b41e280b 100644 --- a/deps/npm/man/man1/npm-prune.1 +++ b/deps/npm/man/man1/npm-prune.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PRUNE" "1" "December 2016" "" "" +.TH "NPM\-PRUNE" "1" "January 2017" "" "" .SH "NAME" \fBnpm-prune\fR \- Remove extraneous packages .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-publish.1 b/deps/npm/man/man1/npm-publish.1 index da13f889e4d98f..cd3ddf45aeaca5 100644 --- a/deps/npm/man/man1/npm-publish.1 +++ b/deps/npm/man/man1/npm-publish.1 @@ -1,4 +1,4 @@ -.TH "NPM\-PUBLISH" "1" "December 2016" "" "" +.TH "NPM\-PUBLISH" "1" "January 2017" "" "" .SH "NAME" \fBnpm-publish\fR \- Publish a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-rebuild.1 b/deps/npm/man/man1/npm-rebuild.1 index cd55fa533780c2..16cbea997d0127 100644 --- a/deps/npm/man/man1/npm-rebuild.1 +++ b/deps/npm/man/man1/npm-rebuild.1 @@ -1,4 +1,4 @@ -.TH "NPM\-REBUILD" "1" "December 2016" "" "" +.TH "NPM\-REBUILD" "1" "January 2017" "" "" .SH "NAME" \fBnpm-rebuild\fR \- Rebuild a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-repo.1 b/deps/npm/man/man1/npm-repo.1 index fe119dafd8f733..e8b6f6e8f07897 100644 --- a/deps/npm/man/man1/npm-repo.1 +++ b/deps/npm/man/man1/npm-repo.1 @@ -1,4 +1,4 @@ -.TH "NPM\-REPO" "1" "December 2016" "" "" +.TH "NPM\-REPO" "1" "January 2017" "" "" .SH "NAME" \fBnpm-repo\fR \- Open package repository page in the browser .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-restart.1 b/deps/npm/man/man1/npm-restart.1 index 9297a4453324a4..b326b4f9744638 100644 --- a/deps/npm/man/man1/npm-restart.1 +++ b/deps/npm/man/man1/npm-restart.1 @@ -1,4 +1,4 @@ -.TH "NPM\-RESTART" "1" "December 2016" "" "" +.TH "NPM\-RESTART" "1" "January 2017" "" "" .SH "NAME" \fBnpm-restart\fR \- Restart a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-root.1 b/deps/npm/man/man1/npm-root.1 index 49c650dd9197a2..3f9fd2a2b807c5 100644 --- a/deps/npm/man/man1/npm-root.1 +++ b/deps/npm/man/man1/npm-root.1 @@ -1,4 +1,4 @@ -.TH "NPM\-ROOT" "1" "December 2016" "" "" +.TH "NPM\-ROOT" "1" "January 2017" "" "" .SH "NAME" \fBnpm-root\fR \- Display npm root .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-run-script.1 b/deps/npm/man/man1/npm-run-script.1 index d86fa8d5024dcb..471a82425cb4b9 100644 --- a/deps/npm/man/man1/npm-run-script.1 +++ b/deps/npm/man/man1/npm-run-script.1 @@ -1,4 +1,4 @@ -.TH "NPM\-RUN\-SCRIPT" "1" "December 2016" "" "" +.TH "NPM\-RUN\-SCRIPT" "1" "January 2017" "" "" .SH "NAME" \fBnpm-run-script\fR \- Run arbitrary package scripts .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-search.1 b/deps/npm/man/man1/npm-search.1 index c994847e669c5e..bdd3028bc7a380 100644 --- a/deps/npm/man/man1/npm-search.1 +++ b/deps/npm/man/man1/npm-search.1 @@ -1,4 +1,4 @@ -.TH "NPM\-SEARCH" "1" "December 2016" "" "" +.TH "NPM\-SEARCH" "1" "January 2017" "" "" .SH "NAME" \fBnpm-search\fR \- Search for packages .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-shrinkwrap.1 b/deps/npm/man/man1/npm-shrinkwrap.1 index edcfbee8baf193..ddf341356f8218 100644 --- a/deps/npm/man/man1/npm-shrinkwrap.1 +++ b/deps/npm/man/man1/npm-shrinkwrap.1 @@ -1,4 +1,4 @@ -.TH "NPM\-SHRINKWRAP" "1" "December 2016" "" "" +.TH "NPM\-SHRINKWRAP" "1" "January 2017" "" "" .SH "NAME" \fBnpm-shrinkwrap\fR \- Lock down dependency versions .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-star.1 b/deps/npm/man/man1/npm-star.1 index cfb2056ae75cd0..fde504ee60054d 100644 --- a/deps/npm/man/man1/npm-star.1 +++ b/deps/npm/man/man1/npm-star.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STAR" "1" "December 2016" "" "" +.TH "NPM\-STAR" "1" "January 2017" "" "" .SH "NAME" \fBnpm-star\fR \- Mark your favorite packages .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-stars.1 b/deps/npm/man/man1/npm-stars.1 index 554e01c0d118f8..a2e44c9bc4cf34 100644 --- a/deps/npm/man/man1/npm-stars.1 +++ b/deps/npm/man/man1/npm-stars.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STARS" "1" "December 2016" "" "" +.TH "NPM\-STARS" "1" "January 2017" "" "" .SH "NAME" \fBnpm-stars\fR \- View packages marked as favorites .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-start.1 b/deps/npm/man/man1/npm-start.1 index b98a6338309d53..9571756354f1b6 100644 --- a/deps/npm/man/man1/npm-start.1 +++ b/deps/npm/man/man1/npm-start.1 @@ -1,4 +1,4 @@ -.TH "NPM\-START" "1" "December 2016" "" "" +.TH "NPM\-START" "1" "January 2017" "" "" .SH "NAME" \fBnpm-start\fR \- Start a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-stop.1 b/deps/npm/man/man1/npm-stop.1 index c52f34e46df1cb..4c2d64802ef348 100644 --- a/deps/npm/man/man1/npm-stop.1 +++ b/deps/npm/man/man1/npm-stop.1 @@ -1,4 +1,4 @@ -.TH "NPM\-STOP" "1" "December 2016" "" "" +.TH "NPM\-STOP" "1" "January 2017" "" "" .SH "NAME" \fBnpm-stop\fR \- Stop a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-team.1 b/deps/npm/man/man1/npm-team.1 index 71b9081ab1d48b..88a71c41bdb8fe 100644 --- a/deps/npm/man/man1/npm-team.1 +++ b/deps/npm/man/man1/npm-team.1 @@ -1,4 +1,4 @@ -.TH "NPM\-TEAM" "1" "December 2016" "" "" +.TH "NPM\-TEAM" "1" "January 2017" "" "" .SH "NAME" \fBnpm-team\fR \- Manage organization teams and team memberships .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-test.1 b/deps/npm/man/man1/npm-test.1 index dea00f178c02ec..ee2f896ec5bf5b 100644 --- a/deps/npm/man/man1/npm-test.1 +++ b/deps/npm/man/man1/npm-test.1 @@ -1,4 +1,4 @@ -.TH "NPM\-TEST" "1" "December 2016" "" "" +.TH "NPM\-TEST" "1" "January 2017" "" "" .SH "NAME" \fBnpm-test\fR \- Test a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-uninstall.1 b/deps/npm/man/man1/npm-uninstall.1 index c32a9cf82ee642..fb89c977f1e26c 100644 --- a/deps/npm/man/man1/npm-uninstall.1 +++ b/deps/npm/man/man1/npm-uninstall.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UNINSTALL" "1" "December 2016" "" "" +.TH "NPM\-UNINSTALL" "1" "January 2017" "" "" .SH "NAME" \fBnpm-uninstall\fR \- Remove a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-unpublish.1 b/deps/npm/man/man1/npm-unpublish.1 index edee140ab7aa90..ff7d0f7c120f4a 100644 --- a/deps/npm/man/man1/npm-unpublish.1 +++ b/deps/npm/man/man1/npm-unpublish.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UNPUBLISH" "1" "December 2016" "" "" +.TH "NPM\-UNPUBLISH" "1" "January 2017" "" "" .SH "NAME" \fBnpm-unpublish\fR \- Remove a package from the registry .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-update.1 b/deps/npm/man/man1/npm-update.1 index 7dcdde27144068..4ba2029e5eedaf 100644 --- a/deps/npm/man/man1/npm-update.1 +++ b/deps/npm/man/man1/npm-update.1 @@ -1,4 +1,4 @@ -.TH "NPM\-UPDATE" "1" "December 2016" "" "" +.TH "NPM\-UPDATE" "1" "January 2017" "" "" .SH "NAME" \fBnpm-update\fR \- Update a package .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-version.1 b/deps/npm/man/man1/npm-version.1 index 7d503e90b8c320..b5b65dc5b63e62 100644 --- a/deps/npm/man/man1/npm-version.1 +++ b/deps/npm/man/man1/npm-version.1 @@ -1,4 +1,4 @@ -.TH "NPM\-VERSION" "1" "December 2016" "" "" +.TH "NPM\-VERSION" "1" "January 2017" "" "" .SH "NAME" \fBnpm-version\fR \- Bump a package version .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-view.1 b/deps/npm/man/man1/npm-view.1 index 5b9b04c2fc3212..4913e0bd42b72d 100644 --- a/deps/npm/man/man1/npm-view.1 +++ b/deps/npm/man/man1/npm-view.1 @@ -1,4 +1,4 @@ -.TH "NPM\-VIEW" "1" "December 2016" "" "" +.TH "NPM\-VIEW" "1" "January 2017" "" "" .SH "NAME" \fBnpm-view\fR \- View registry info .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm-whoami.1 b/deps/npm/man/man1/npm-whoami.1 index 39a55d8b67942b..21207f0f786109 100644 --- a/deps/npm/man/man1/npm-whoami.1 +++ b/deps/npm/man/man1/npm-whoami.1 @@ -1,4 +1,4 @@ -.TH "NPM\-WHOAMI" "1" "December 2016" "" "" +.TH "NPM\-WHOAMI" "1" "January 2017" "" "" .SH "NAME" \fBnpm-whoami\fR \- Display npm username .SH SYNOPSIS diff --git a/deps/npm/man/man1/npm.1 b/deps/npm/man/man1/npm.1 index 7d249f4229f71a..71856669b131f2 100644 --- a/deps/npm/man/man1/npm.1 +++ b/deps/npm/man/man1/npm.1 @@ -1,4 +1,4 @@ -.TH "NPM" "1" "December 2016" "" "" +.TH "NPM" "1" "January 2017" "" "" .SH "NAME" \fBnpm\fR \- javascript package manager .SH SYNOPSIS @@ -10,7 +10,7 @@ npm [args] .RE .SH VERSION .P -4.0.5 +4.1.2 .SH DESCRIPTION .P npm is the package manager for the Node JavaScript platform\. It puts diff --git a/deps/npm/man/man5/npm-folders.5 b/deps/npm/man/man5/npm-folders.5 index d7be6670002795..93ab0441319395 100644 --- a/deps/npm/man/man5/npm-folders.5 +++ b/deps/npm/man/man5/npm-folders.5 @@ -1,4 +1,4 @@ -.TH "NPM\-FOLDERS" "5" "December 2016" "" "" +.TH "NPM\-FOLDERS" "5" "January 2017" "" "" .SH "NAME" \fBnpm-folders\fR \- Folder Structures Used by npm .SH DESCRIPTION diff --git a/deps/npm/man/man5/npm-global.5 b/deps/npm/man/man5/npm-global.5 index d7be6670002795..93ab0441319395 100644 --- a/deps/npm/man/man5/npm-global.5 +++ b/deps/npm/man/man5/npm-global.5 @@ -1,4 +1,4 @@ -.TH "NPM\-FOLDERS" "5" "December 2016" "" "" +.TH "NPM\-FOLDERS" "5" "January 2017" "" "" .SH "NAME" \fBnpm-folders\fR \- Folder Structures Used by npm .SH DESCRIPTION diff --git a/deps/npm/man/man5/npm-json.5 b/deps/npm/man/man5/npm-json.5 index 7464f9609f4e84..5bb1b64f4100cb 100644 --- a/deps/npm/man/man5/npm-json.5 +++ b/deps/npm/man/man5/npm-json.5 @@ -1,4 +1,4 @@ -.TH "PACKAGE\.JSON" "5" "December 2016" "" "" +.TH "PACKAGE\.JSON" "5" "January 2017" "" "" .SH "NAME" \fBpackage.json\fR \- Specifics of npm's package\.json handling .SH DESCRIPTION diff --git a/deps/npm/man/man5/npmrc.5 b/deps/npm/man/man5/npmrc.5 index 45aa7ace8f81b9..e47da0d5167cdf 100644 --- a/deps/npm/man/man5/npmrc.5 +++ b/deps/npm/man/man5/npmrc.5 @@ -1,4 +1,4 @@ -.TH "NPMRC" "5" "December 2016" "" "" +.TH "NPMRC" "5" "January 2017" "" "" .SH "NAME" \fBnpmrc\fR \- The npm config files .SH DESCRIPTION diff --git a/deps/npm/man/man5/package.json.5 b/deps/npm/man/man5/package.json.5 index 7464f9609f4e84..5bb1b64f4100cb 100644 --- a/deps/npm/man/man5/package.json.5 +++ b/deps/npm/man/man5/package.json.5 @@ -1,4 +1,4 @@ -.TH "PACKAGE\.JSON" "5" "December 2016" "" "" +.TH "PACKAGE\.JSON" "5" "January 2017" "" "" .SH "NAME" \fBpackage.json\fR \- Specifics of npm's package\.json handling .SH DESCRIPTION diff --git a/deps/npm/man/man7/npm-coding-style.7 b/deps/npm/man/man7/npm-coding-style.7 index 614cd60ddc78b9..d6854ea9efaee1 100644 --- a/deps/npm/man/man7/npm-coding-style.7 +++ b/deps/npm/man/man7/npm-coding-style.7 @@ -1,4 +1,4 @@ -.TH "NPM\-CODING\-STYLE" "7" "December 2016" "" "" +.TH "NPM\-CODING\-STYLE" "7" "January 2017" "" "" .SH "NAME" \fBnpm-coding-style\fR \- npm's "funny" coding style .SH DESCRIPTION diff --git a/deps/npm/man/man7/npm-config.7 b/deps/npm/man/man7/npm-config.7 index 25bb498c6262ae..13cd86763011ee 100644 --- a/deps/npm/man/man7/npm-config.7 +++ b/deps/npm/man/man7/npm-config.7 @@ -1,4 +1,4 @@ -.TH "NPM\-CONFIG" "7" "December 2016" "" "" +.TH "NPM\-CONFIG" "7" "January 2017" "" "" .SH "NAME" \fBnpm-config\fR \- More than you probably want to know about npm configuration .SH DESCRIPTION @@ -831,6 +831,16 @@ Type: String Commit message which is used by \fBnpm version\fP when creating version commit\. .P Any "%s" in the message will be replaced with the version number\. +.SS metrics\-registry +.RS 0 +.IP \(bu 2 +Default: "https://registry\.npmjs\.org/" +.IP \(bu 2 +Type: String + +.RE +.P +The registry you want to send cli metrics to if \fBsend\-metrics\fP is true\. .SS node\-version .RS 0 .IP \(bu 2 @@ -1151,6 +1161,19 @@ Type: Number .RE .P The age of the cache, in seconds, before another registry request is made\. +.SS send\-metrics +.RS 0 +.IP \(bu 2 +Default: false +.IP \(bu 2 +Type: Boolean + +.RE +.P +If true, success/failure metrics will be reported to the registry stored in +\fBmetrics\-registry\fP\|\. These requests contain the number of successful and +failing runs of the npm CLI and the time period overwhich those counts were +gathered\. No identifying information is included in these requests\. .SS shell .RS 0 .IP \(bu 2 diff --git a/deps/npm/man/man7/npm-developers.7 b/deps/npm/man/man7/npm-developers.7 index 58c1298d969006..a56bd183b4e4ed 100644 --- a/deps/npm/man/man7/npm-developers.7 +++ b/deps/npm/man/man7/npm-developers.7 @@ -1,4 +1,4 @@ -.TH "NPM\-DEVELOPERS" "7" "December 2016" "" "" +.TH "NPM\-DEVELOPERS" "7" "January 2017" "" "" .SH "NAME" \fBnpm-developers\fR \- Developer Guide .SH DESCRIPTION diff --git a/deps/npm/man/man7/npm-disputes.7 b/deps/npm/man/man7/npm-disputes.7 index bdd922b03b5ebf..fc0634dfba5fc7 100644 --- a/deps/npm/man/man7/npm-disputes.7 +++ b/deps/npm/man/man7/npm-disputes.7 @@ -1,4 +1,4 @@ -.TH "NPM\-DISPUTES" "7" "December 2016" "" "" +.TH "NPM\-DISPUTES" "7" "January 2017" "" "" .SH "NAME" \fBnpm-disputes\fR \- Handling Module Name Disputes .P diff --git a/deps/npm/man/man7/npm-index.7 b/deps/npm/man/man7/npm-index.7 index f2a76256dffde4..e70504241ae7e1 100644 --- a/deps/npm/man/man7/npm-index.7 +++ b/deps/npm/man/man7/npm-index.7 @@ -1,4 +1,4 @@ -.TH "NPM\-INDEX" "7" "December 2016" "" "" +.TH "NPM\-INDEX" "7" "January 2017" "" "" .SH "NAME" \fBnpm-index\fR \- Index of all npm documentation .SS npm help README @@ -49,6 +49,9 @@ Modify package distribution tags .SS npm help docs .P Docs for a package in a web browser maybe +.SS npm help doctor +.P +Check your environments .SS npm help edit .P Edit an installed package diff --git a/deps/npm/man/man7/npm-orgs.7 b/deps/npm/man/man7/npm-orgs.7 index 11d12adf51ccb0..5948bf85304a8c 100644 --- a/deps/npm/man/man7/npm-orgs.7 +++ b/deps/npm/man/man7/npm-orgs.7 @@ -1,4 +1,4 @@ -.TH "NPM\-ORGS" "7" "December 2016" "" "" +.TH "NPM\-ORGS" "7" "January 2017" "" "" .SH "NAME" \fBnpm-orgs\fR \- Working with Teams & Orgs .SH DESCRIPTION diff --git a/deps/npm/man/man7/npm-registry.7 b/deps/npm/man/man7/npm-registry.7 index 88d802a9dcaa35..639395eee657e3 100644 --- a/deps/npm/man/man7/npm-registry.7 +++ b/deps/npm/man/man7/npm-registry.7 @@ -1,4 +1,4 @@ -.TH "NPM\-REGISTRY" "7" "December 2016" "" "" +.TH "NPM\-REGISTRY" "7" "January 2017" "" "" .SH "NAME" \fBnpm-registry\fR \- The JavaScript Package Registry .SH DESCRIPTION diff --git a/deps/npm/man/man7/npm-scope.7 b/deps/npm/man/man7/npm-scope.7 index a18f0673a646a0..5d362460c6aa1a 100644 --- a/deps/npm/man/man7/npm-scope.7 +++ b/deps/npm/man/man7/npm-scope.7 @@ -1,4 +1,4 @@ -.TH "NPM\-SCOPE" "7" "December 2016" "" "" +.TH "NPM\-SCOPE" "7" "January 2017" "" "" .SH "NAME" \fBnpm-scope\fR \- Scoped packages .SH DESCRIPTION diff --git a/deps/npm/man/man7/npm-scripts.7 b/deps/npm/man/man7/npm-scripts.7 index efcf992f953b60..4f8554367aade8 100644 --- a/deps/npm/man/man7/npm-scripts.7 +++ b/deps/npm/man/man7/npm-scripts.7 @@ -1,4 +1,4 @@ -.TH "NPM\-SCRIPTS" "7" "December 2016" "" "" +.TH "NPM\-SCRIPTS" "7" "January 2017" "" "" .SH "NAME" \fBnpm-scripts\fR \- How npm handles the "scripts" field .SH DESCRIPTION diff --git a/deps/npm/man/man7/removing-npm.7 b/deps/npm/man/man7/removing-npm.7 index 7bbdc633991eb5..f6df37784c6198 100644 --- a/deps/npm/man/man7/removing-npm.7 +++ b/deps/npm/man/man7/removing-npm.7 @@ -1,4 +1,4 @@ -.TH "NPM\-REMOVAL" "1" "December 2016" "" "" +.TH "NPM\-REMOVAL" "1" "January 2017" "" "" .SH "NAME" \fBnpm-removal\fR \- Cleaning the Slate .SH SYNOPSIS diff --git a/deps/npm/man/man7/semver.7 b/deps/npm/man/man7/semver.7 index 23c46f16658c0d..e71137f473998b 100644 --- a/deps/npm/man/man7/semver.7 +++ b/deps/npm/man/man7/semver.7 @@ -1,4 +1,4 @@ -.TH "SEMVER" "7" "December 2016" "" "" +.TH "SEMVER" "7" "January 2017" "" "" .SH "NAME" \fBsemver\fR \- The semantic versioner for npm .SH Usage diff --git a/deps/npm/node_modules/JSONStream/index.js b/deps/npm/node_modules/JSONStream/index.js index 701b1fa4aeb949..86ad5c744362d4 100755 --- a/deps/npm/node_modules/JSONStream/index.js +++ b/deps/npm/node_modules/JSONStream/index.js @@ -58,6 +58,7 @@ exports.parse = function (path, map) { var i = 0 // iterates on path var j = 0 // iterates on stack var emitKey = false; + var emitPath = false; while (i < path.length) { var key = path[i] var c @@ -71,6 +72,7 @@ exports.parse = function (path, map) { return } emitKey = !!key.emitKey; + emitPath = !!key.emitPath; i++ } else { i++ @@ -99,7 +101,14 @@ exports.parse = function (path, map) { var data = this.value[this.key] if(null != data) if(null != (data = map ? map(data, actualPath) : data)) { - data = emitKey ? { value: data, key: this.key } : data; + if (emitKey || emitPath) { + data = { value: data }; + if (emitKey) + data["key"] = this.key; + if (emitPath) + data["path"] = actualPath; + } + stream.queue(data) } delete this.value[this.key] diff --git a/deps/npm/node_modules/JSONStream/package.json b/deps/npm/node_modules/JSONStream/package.json index c86c7113e7e34c..75eacb3b0f6155 100644 --- a/deps/npm/node_modules/JSONStream/package.json +++ b/deps/npm/node_modules/JSONStream/package.json @@ -2,50 +2,50 @@ "_args": [ [ { - "raw": "JSONStream", + "raw": "JSONStream@1.3.0", "scope": null, "escapedName": "JSONStream", "name": "JSONStream", - "rawSpec": "", - "spec": "latest", - "type": "tag" + "rawSpec": "1.3.0", + "spec": "1.3.0", + "type": "version" }, - "/Users/zkat/Documents/code/npm" + "/Users/rebecca/code/npm" ] ], - "_from": "JSONStream@latest", - "_id": "JSONStream@1.2.1", + "_from": "JSONStream@1.3.0", + "_id": "JSONStream@1.3.0", "_inCache": true, "_location": "/JSONStream", - "_nodeVersion": "6.4.0", + "_nodeVersion": "6.5.0", "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/JSONStream-1.2.1.tgz_1474751953169_0.9057570598088205" + "host": "packages-18-east.internal.npmjs.com", + "tmp": "tmp/JSONStream-1.3.0.tgz_1481845260408_0.7681232686154544" }, "_npmUser": { "name": "dominictarr", "email": "dominic.tarr@gmail.com" }, - "_npmVersion": "3.9.3", + "_npmVersion": "3.10.3", "_phantomChildren": {}, "_requested": { - "raw": "JSONStream", + "raw": "JSONStream@1.3.0", "scope": null, "escapedName": "JSONStream", "name": "JSONStream", - "rawSpec": "", - "spec": "latest", - "type": "tag" + "rawSpec": "1.3.0", + "spec": "1.3.0", + "type": "version" }, "_requiredBy": [ "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.2.1.tgz", - "_shasum": "32aa5790e799481083b49b4b7fa94e23bae69bf9", + "_resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.0.tgz", + "_shasum": "680ab9ac6572a8a1a207e0b38721db1c77b215e5", "_shrinkwrap": null, - "_spec": "JSONStream", - "_where": "/Users/zkat/Documents/code/npm", + "_spec": "JSONStream@1.3.0", + "_where": "/Users/rebecca/code/npm", "author": { "name": "Dominic Tarr", "email": "dominic.tarr@gmail.com", @@ -72,13 +72,13 @@ }, "directories": {}, "dist": { - "shasum": "32aa5790e799481083b49b4b7fa94e23bae69bf9", - "tarball": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.2.1.tgz" + "shasum": "680ab9ac6572a8a1a207e0b38721db1c77b215e5", + "tarball": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.0.tgz" }, "engines": { "node": "*" }, - "gitHead": "641402b48dbf3db5380e9bc857753c237d4ee9d9", + "gitHead": "3d5d3283d79e23da81fa6fc4b76bc1f44ff0047d", "homepage": "http://github.com/dominictarr/JSONStream", "keywords": [ "json", @@ -109,5 +109,5 @@ "scripts": { "test": "set -e; for t in test/*.js; do echo '***' $t '***'; node $t; done" }, - "version": "1.2.1" + "version": "1.3.0" } diff --git a/deps/npm/node_modules/JSONStream/readme.markdown b/deps/npm/node_modules/JSONStream/readme.markdown index 4628902e033caa..7e94ddd7f4c029 100644 --- a/deps/npm/node_modules/JSONStream/readme.markdown +++ b/deps/npm/node_modules/JSONStream/readme.markdown @@ -104,6 +104,18 @@ stream.on('data', function(data) { ``` +You can also emit the path: + +``` js +var stream = JSONStream.parse(['rows', true, 'doc', {emitPath: true}]) //rows, ANYTHING, doc, items in docs with keys + +stream.on('data', function(data) { + console.log('path:', data.path); + console.log('value:', data.value); +}); + +``` + ### recursive patterns (..) `JSONStream.parse('docs..value')` diff --git a/deps/npm/node_modules/JSONStream/test/keys.js b/deps/npm/node_modules/JSONStream/test/keys.js index c60088afa0edc3..86b65b257b9572 100644 --- a/deps/npm/node_modules/JSONStream/test/keys.js +++ b/deps/npm/node_modules/JSONStream/test/keys.js @@ -39,6 +39,26 @@ test('keys via array', function(t) { assertFixtureKeys(stream, t); }); +test('path via array', function(t) { + var stream = JSONStream.parse(['obj',{emitPath: true}]); + + var paths = []; + var values = []; + stream.on('data', function(data) { + console.log(JSON.stringify(data)); + paths.push(data.path); + values.push(data.value); + }); + + stream.on('end', function() { + t.deepEqual(paths, [['obj', 'one'], ['obj', 'two'], ['obj', 'three']]); + t.deepEqual(values, [1,2,3]); + t.end(); + }); + stream.write(JSON.stringify(fixture)); + stream.end(); +}); + test('advanced keys', function(t) { var advanced = fs.readFileSync(couch_sample_file); var stream = JSONStream.parse(['rows', true, 'doc', {emitKey: true}]); diff --git a/deps/npm/node_modules/lockfile/CHANGELOG.md b/deps/npm/node_modules/lockfile/CHANGELOG.md index 6d9005b1d03229..38f44af041eb87 100644 --- a/deps/npm/node_modules/lockfile/CHANGELOG.md +++ b/deps/npm/node_modules/lockfile/CHANGELOG.md @@ -1,11 +1,16 @@ # Changes +## v1.0.3 + +* handle the case where callback is not passed by user + ## v1.0.2 * git ignore coverage and node_modules * update tap to v7 * build a changelog +* package: fix repository link * pass tests on 0.8 * before_script needs to be before_install * tap 1.2.0 and travis diff --git a/deps/npm/node_modules/lockfile/lockfile.js b/deps/npm/node_modules/lockfile/lockfile.js index 0c2c6f597ad9b9..fd49717b8c3b9a 100644 --- a/deps/npm/node_modules/lockfile/lockfile.js +++ b/deps/npm/node_modules/lockfile/lockfile.js @@ -58,7 +58,7 @@ exports.unlock = function (path, cb) { debug('unlock', path) // best-effort. unlocking an already-unlocked lock is a noop delete locks[path] - fs.unlink(path, function (unlinkEr) { cb() }) + fs.unlink(path, function (unlinkEr) { cb && cb() }) } exports.unlockSync = function (path) { diff --git a/deps/npm/node_modules/lockfile/package.json b/deps/npm/node_modules/lockfile/package.json index 0fa61f34b0d6a5..e559a82165a206 100644 --- a/deps/npm/node_modules/lockfile/package.json +++ b/deps/npm/node_modules/lockfile/package.json @@ -2,49 +2,49 @@ "_args": [ [ { - "raw": "lockfile@1.0.2", + "raw": "lockfile@^1.0.3", "scope": null, "escapedName": "lockfile", "name": "lockfile", - "rawSpec": "1.0.2", - "spec": "1.0.2", - "type": "version" + "rawSpec": "^1.0.3", + "spec": ">=1.0.3 <2.0.0", + "type": "range" }, "/Users/rebecca/code/npm" ] ], - "_from": "lockfile@1.0.2", - "_id": "lockfile@1.0.2", + "_from": "lockfile@>=1.0.3 <2.0.0", + "_id": "lockfile@1.0.3", "_inCache": true, "_location": "/lockfile", "_nodeVersion": "6.5.0", "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/lockfile-1.0.2.tgz_1474488698320_0.008735276060178876" + "host": "packages-18-east.internal.npmjs.com", + "tmp": "tmp/lockfile-1.0.3.tgz_1481132515120_0.9350064944010228" }, "_npmUser": { "name": "isaacs", "email": "i@izs.me" }, - "_npmVersion": "3.10.7", + "_npmVersion": "3.10.9", "_phantomChildren": {}, "_requested": { - "raw": "lockfile@1.0.2", + "raw": "lockfile@^1.0.3", "scope": null, "escapedName": "lockfile", "name": "lockfile", - "rawSpec": "1.0.2", - "spec": "1.0.2", - "type": "version" + "rawSpec": "^1.0.3", + "spec": ">=1.0.3 <2.0.0", + "type": "range" }, "_requiredBy": [ "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/lockfile/-/lockfile-1.0.2.tgz", - "_shasum": "97e1990174f696cbe0a3acd58a43b84aa30c7c83", + "_resolved": "https://registry.npmjs.org/lockfile/-/lockfile-1.0.3.tgz", + "_shasum": "2638fc39a0331e9cac1a04b71799931c9c50df79", "_shrinkwrap": null, - "_spec": "lockfile@1.0.2", + "_spec": "lockfile@^1.0.3", "_where": "/Users/rebecca/code/npm", "author": { "name": "Isaac Z. Schlueter", @@ -52,7 +52,7 @@ "url": "http://blog.izs.me/" }, "bugs": { - "url": "https://github.com/isaacs/lockfile/issues" + "url": "https://github.com/npm/lockfile/issues" }, "dependencies": {}, "description": "A very polite lock file utility, which endeavors to not litter, and to wait patiently for others.", @@ -64,11 +64,11 @@ "test": "test" }, "dist": { - "shasum": "97e1990174f696cbe0a3acd58a43b84aa30c7c83", - "tarball": "https://registry.npmjs.org/lockfile/-/lockfile-1.0.2.tgz" + "shasum": "2638fc39a0331e9cac1a04b71799931c9c50df79", + "tarball": "https://registry.npmjs.org/lockfile/-/lockfile-1.0.3.tgz" }, - "gitHead": "a25076ca142a08951a9265bc1091e715e9bc7f05", - "homepage": "https://github.com/isaacs/lockfile#readme", + "gitHead": "96549505fcca4b8b0ff0e833719720bd463306d7", + "homepage": "https://github.com/npm/lockfile#readme", "keywords": [ "lockfile", "lock", @@ -93,12 +93,12 @@ "readme": "ERROR: No README data found!", "repository": { "type": "git", - "url": "git://github.com/isaacs/lockfile.git" + "url": "git+https://github.com/npm/lockfile.git" }, "scripts": { "changelog": "bash gen-changelog.sh", "postversion": "npm run changelog && git add CHANGELOG.md && git commit -m 'update changelog - '${npm_package_version}", "test": "tap test/*.js --cov" }, - "version": "1.0.2" + "version": "1.0.3" } diff --git a/deps/npm/node_modules/lockfile/test/unlock-no-cb.js b/deps/npm/node_modules/lockfile/test/unlock-no-cb.js new file mode 100644 index 00000000000000..df160923ebc6de --- /dev/null +++ b/deps/npm/node_modules/lockfile/test/unlock-no-cb.js @@ -0,0 +1,10 @@ +var t = require('tap') +if (/0\.(10|8)/.test(process.version)) { + t.pass('just a dummy test, no beforeExit in this node version') +} else { + process.on('beforeExit', function (code) { + t.equal(code, 0, 'did not throw') + }) +} +var lf = require('lockfile') +lf.unlock('no-file-no-cb') diff --git a/deps/npm/node_modules/node-gyp/CHANGELOG.md b/deps/npm/node_modules/node-gyp/CHANGELOG.md index cb63589e24317f..4e8a85617b8689 100644 --- a/deps/npm/node_modules/node-gyp/CHANGELOG.md +++ b/deps/npm/node_modules/node-gyp/CHANGELOG.md @@ -1,4 +1,20 @@ +v3.5.0 2017-01-10 +================= + +* [[`762d19a39e`](https://github.com/nodejs/node-gyp/commit/762d19a39e)] - \[doc\] merge History.md and CHANGELOG.md (Rod Vagg) +* [[`80fc5c3d31`](https://github.com/nodejs/node-gyp/commit/80fc5c3d31)] - Fix deprecated dependency warning (Simone Primarosa) [#1069](https://github.com/nodejs/node-gyp/pull/1069) +* [[`05c44944fd`](https://github.com/nodejs/node-gyp/commit/05c44944fd)] - Open the build file with universal-newlines mode (Guy Margalit) [#1053](https://github.com/nodejs/node-gyp/pull/1053) +* [[`37ae7be114`](https://github.com/nodejs/node-gyp/commit/37ae7be114)] - Try python launcher when stock python is python 3. (Ben Noordhuis) [#992](https://github.com/nodejs/node-gyp/pull/992) +* [[`e3778d9907`](https://github.com/nodejs/node-gyp/commit/e3778d9907)] - Add lots of findPython() tests. (Ben Noordhuis) [#992](https://github.com/nodejs/node-gyp/pull/992) +* [[`afc766adf6`](https://github.com/nodejs/node-gyp/commit/afc766adf6)] - Unset executable bit for .bat files (Pavel Medvedev) [#969](https://github.com/nodejs/node-gyp/pull/969) +* [[`ddac348991`](https://github.com/nodejs/node-gyp/commit/ddac348991)] - Use push on PYTHONPATH and add tests (Michael Hart) [#990](https://github.com/nodejs/node-gyp/pull/990) +* [[`b182a19042`](https://github.com/nodejs/node-gyp/commit/b182a19042)] - ***Revert*** "add "path-array" dep" (Michael Hart) [#990](https://github.com/nodejs/node-gyp/pull/990) +* [[`7c08b85c5a`](https://github.com/nodejs/node-gyp/commit/7c08b85c5a)] - ***Revert*** "**configure**: use "path-array" for PYTHONPATH" (Michael Hart) [#990](https://github.com/nodejs/node-gyp/pull/990) +* [[`9c8d275526`](https://github.com/nodejs/node-gyp/commit/9c8d275526)] - Add --devdir flag. (Ben Noordhuis) [#916](https://github.com/nodejs/node-gyp/pull/916) +* [[`f6eab1f9e4`](https://github.com/nodejs/node-gyp/commit/f6eab1f9e4)] - **doc**: add windows-build-tools to readme (Felix Rieseberg) [#970](https://github.com/nodejs/node-gyp/pull/970) + v3.4.0 2016-06-28 +================= * [[`ce5fd04e94`](https://github.com/nodejs/node-gyp/commit/ce5fd04e94)] - **deps**: update minimatch version (delphiactual) [#961](https://github.com/nodejs/node-gyp/pull/961) * [[`77383ddd85`](https://github.com/nodejs/node-gyp/commit/77383ddd85)] - Replace fs.accessSync call to fs.statSync (Richard Lau) [#955](https://github.com/nodejs/node-gyp/pull/955) @@ -19,10 +35,12 @@ v3.4.0 2016-06-28 * [[`3bcb1720e4`](https://github.com/nodejs/node-gyp/commit/3bcb1720e4)] - Add support for the Python launcher on Windows (Patrick Westerhoff) [#894](https://github.com/nodejs/node-gyp/pull/894 v3.3.1 2016-03-04 +================= * [[`a981ef847a`](https://github.com/nodejs/node-gyp/commit/a981ef847a)] - **gyp**: fix android generator (Robert Chiras) [#889](https://github.com/nodejs/node-gyp/pull/889) v3.3.0 2016-02-16 +================= * [[`818d854a4d`](https://github.com/nodejs/node-gyp/commit/818d854a4d)] - Introduce NODEJS_ORG_MIRROR and IOJS_ORG_MIRROR (Rod Vagg) [#878](https://github.com/nodejs/node-gyp/pull/878) * [[`d1e4cc4b62`](https://github.com/nodejs/node-gyp/commit/d1e4cc4b62)] - **(SEMVER-MINOR)** Download headers tarball for ~0.12.10 || ~0.10.42 (Rod Vagg) [#877](https://github.com/nodejs/node-gyp/pull/877) @@ -32,11 +50,13 @@ v3.3.0 2016-02-16 * [[`b3ad43498e`](https://github.com/nodejs/node-gyp/commit/b3ad43498e)] - **(SEMVER-MINOR)** Make download() function testable. (Ben Noordhuis) [#837](https://github.com/nodejs/node-gyp/pull/837) v3.2.1 2015-12-03 +================= * [[`ab89b477c4`](https://github.com/nodejs/node-gyp/commit/ab89b477c4)] - Upgrade gyp to b3cef02. (Ben Noordhuis) [#831](https://github.com/nodejs/node-gyp/pull/831) * [[`90078ecb17`](https://github.com/nodejs/node-gyp/commit/90078ecb17)] - Define WIN32_LEAN_AND_MEAN conditionally. (Ben Noordhuis) [#824](https://github.com/nodejs/node-gyp/pull/824) v3.2.0 2015-11-25 +================= * [[`268f1ca4c7`](https://github.com/nodejs/node-gyp/commit/268f1ca4c7)] - Use result of `which` when searching for python. (Refael Ackermann) [#668](https://github.com/nodejs/node-gyp/pull/668) * [[`817ed9bd78`](https://github.com/nodejs/node-gyp/commit/817ed9bd78)] - Add test for python executable search logic. (Ben Noordhuis) [#756](https://github.com/nodejs/node-gyp/pull/756) @@ -46,6 +66,7 @@ v3.2.0 2015-11-25 * [[`d1d6015276`](https://github.com/nodejs/node-gyp/commit/d1d6015276)] - Update broken links and switch to HTTPS. (andrew morton) v3.1.0 2015-11-14 +================= * [[`9049241f91`](https://github.com/nodejs/node-gyp/commit/9049241f91)] - **gyp**: don't use links at all, just copy the files instead (Nathan Zadoks) * [[`8ef90348d1`](https://github.com/nodejs/node-gyp/commit/8ef90348d1)] - **gyp**: apply https://codereview.chromium.org/11361103/ (Nathan Rajlich) @@ -56,19 +77,23 @@ v3.1.0 2015-11-14 * [[`101bed639b`](https://github.com/nodejs/node-gyp/commit/101bed639b)] - This platform value came from debian package, and now the value (Jérémy Lal) [#738](https://github.com/nodejs/node-gyp/pull/738) v3.0.3 2015-09-14 +================= * [[`ad827cda30`](https://github.com/nodejs/node-gyp/commit/ad827cda30)] - tarballUrl global and && when checking for iojs (Lars-Magnus Skog) [#729](https://github.com/nodejs/node-gyp/pull/729) v3.0.2 2015-09-12 +================= * [[`6e8c3bf3c6`](https://github.com/nodejs/node-gyp/commit/6e8c3bf3c6)] - add back support for passing additional cmdline args (Rod Vagg) [#723](https://github.com/nodejs/node-gyp/pull/723) * [[`ff82f2f3b9`](https://github.com/nodejs/node-gyp/commit/ff82f2f3b9)] - fixed broken link in docs to Visual Studio 2013 download (simon-p-r) [#722](https://github.com/nodejs/node-gyp/pull/722) v3.0.1 2015-09-08 +================= * [[`846337e36b`](https://github.com/nodejs/node-gyp/commit/846337e36b)] - normalise versions for target == this comparison (Rod Vagg) [#716](https://github.com/nodejs/node-gyp/pull/716) v3.0.0 2015-09-08 +================= * [[`9720d0373c`](https://github.com/nodejs/node-gyp/commit/9720d0373c)] - remove node_modules from tree (Rod Vagg) [#711](https://github.com/nodejs/node-gyp/pull/711) * [[`6dcf220db7`](https://github.com/nodejs/node-gyp/commit/6dcf220db7)] - test version major directly, don't use semver.satisfies() (Rod Vagg) [#711](https://github.com/nodejs/node-gyp/pull/711) @@ -79,3 +104,44 @@ v3.0.0 2015-09-08 * [[`bbedb8868b`](https://github.com/nodejs/node-gyp/commit/bbedb8868b)] - **(SEMVER-MAJOR)** **win**: enable delay-load hook by default (Jeremiah Senkpiel) [#708](https://github.com/nodejs/node-gyp/pull/708) * [[`85ed107565`](https://github.com/nodejs/node-gyp/commit/85ed107565)] - Merge pull request #664 from othiym23/othiym23/allow-semver-5 (Nathan Rajlich) * [[`0c720d234c`](https://github.com/nodejs/node-gyp/commit/0c720d234c)] - allow semver@5 (Forrest L Norvell) + +2.0.2 / 2015-07-14 +================== + + * Use HTTPS for dist url (#656, @SonicHedgehog) + * Merge pull request #648 from nevosegal/master + * Merge pull request #650 from magic890/patch-1 + * Updated Installation section on README + * Updated link to gyp user documentation + * Fix download error message spelling (#643, @tomxtobin) + * Merge pull request #637 from lygstate/master + * Set NODE_GYP_DIR for addon.gypi to setting absolute path for + src/win_delay_load_hook.c, and fixes of the long relative path issue on Win32. + Fixes #636 (#637, @lygstate). + +2.0.1 / 2015-05-28 +================== + + * configure: try/catch the semver range.test() call + * README: update for visual studio 2013 (#510, @samccone) + +2.0.0 / 2015-05-24 +================== + + * configure: check for python2 executable by default, fallback to python + * configure: don't clobber existing $PYTHONPATH + * configure: use "path-array" for PYTHONPATH + * gyp: fix for non-acsii userprofile name on Windows + * gyp: always install into $PRODUCT_DIR + * gyp: apply https://codereview.chromium.org/11361103/ + * gyp: don't use links at all, just copy the files instead + * gyp: update gyp to e1c8fcf7 + * Updated README.md with updated Windows build info + * Show URL when a download fails + * package: add a "license" field + * move HMODULE m declaration to top + * Only add "-undefined dynamic_lookup" to loadable_module targets + * win: optionally allow node.exe/iojs.exe to be renamed + * Avoid downloading shasums if using tarPath + * Add target name preprocessor define: `NODE_GYP_MODULE_NAME` + * Show better error message in case of bad network settings diff --git a/deps/npm/node_modules/node-gyp/History.md b/deps/npm/node_modules/node-gyp/History.md deleted file mode 100644 index 8768081ea03a79..00000000000000 --- a/deps/npm/node_modules/node-gyp/History.md +++ /dev/null @@ -1,41 +0,0 @@ - -2.0.2 / 2015-07-14 -================== - - * Use HTTPS for dist url (#656, @SonicHedgehog) - * Merge pull request #648 from nevosegal/master - * Merge pull request #650 from magic890/patch-1 - * Updated Installation section on README - * Updated link to gyp user documentation - * Fix download error message spelling (#643, @tomxtobin) - * Merge pull request #637 from lygstate/master - * Set NODE_GYP_DIR for addon.gypi to setting absolute path for - src/win_delay_load_hook.c, and fixes of the long relative path issue on Win32. - Fixes #636 (#637, @lygstate). - -2.0.1 / 2015-05-28 -================== - - * configure: try/catch the semver range.test() call - * README: update for visual studio 2013 (#510, @samccone) - -2.0.0 / 2015-05-24 -================== - - * configure: check for python2 executable by default, fallback to python - * configure: don't clobber existing $PYTHONPATH - * configure: use "path-array" for PYTHONPATH - * gyp: fix for non-acsii userprofile name on Windows - * gyp: always install into $PRODUCT_DIR - * gyp: apply https://codereview.chromium.org/11361103/ - * gyp: don't use links at all, just copy the files instead - * gyp: update gyp to e1c8fcf7 - * Updated README.md with updated Windows build info - * Show URL when a download fails - * package: add a "license" field - * move HMODULE m declaration to top - * Only add "-undefined dynamic_lookup" to loadable_module targets - * win: optionally allow node.exe/iojs.exe to be renamed - * Avoid downloading shasums if using tarPath - * Add target name preprocessor define: `NODE_GYP_MODULE_NAME` - * Show better error message in case of bad network settings diff --git a/deps/npm/node_modules/node-gyp/README.md b/deps/npm/node_modules/node-gyp/README.md index 5212b124f98628..7d13b038eef373 100644 --- a/deps/npm/node_modules/node-gyp/README.md +++ b/deps/npm/node_modules/node-gyp/README.md @@ -42,15 +42,17 @@ You will also need to install: * You also need to install the `Command Line Tools` via Xcode. You can find this under the menu `Xcode -> Preferences -> Downloads` * This step will install `gcc` and the related toolchain containing `make` * On Windows: - * Visual C++ Build Environment: - * Option 1: Install [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools) using the **Default Install** option. + * Option 1: Install all the required tools and configurations using Microsoft's [windows-build-tools](https://github.com/felixrieseberg/windows-build-tools) using `npm install --global --production windows-build-tools` from an elevated PowerShell or CMD.exe (run as Administrator). + * Option 2: Install tools and configuration manually: + * Visual C++ Build Environment: + * Option 1: Install [Visual C++ Build Tools](http://landinghub.visualstudio.com/visual-cpp-build-tools) using the **Default Install** option. - * Option 2: Install [Visual Studio 2015](https://www.visualstudio.com/products/visual-studio-community-vs) (or modify an existing installation) and select *Common Tools for Visual C++* during setup. This also works with the free Community and Express for Desktop editions. + * Option 2: Install [Visual Studio 2015](https://www.visualstudio.com/products/visual-studio-community-vs) (or modify an existing installation) and select *Common Tools for Visual C++* during setup. This also works with the free Community and Express for Desktop editions. - > :bulb: [Windows Vista / 7 only] requires [.NET Framework 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40773) + > :bulb: [Windows Vista / 7 only] requires [.NET Framework 4.5.1](http://www.microsoft.com/en-us/download/details.aspx?id=40773) - * Install [Python 2.7](https://www.python.org/downloads/) (`v3.x.x` is not supported), and run `npm config set python python2.7` (or see below for further instructions on specifying the proper Python version and path.) - * Launch cmd, `npm config set msvs_version 2015` + * Install [Python 2.7](https://www.python.org/downloads/) (`v3.x.x` is not supported), and run `npm config set python python2.7` (or see below for further instructions on specifying the proper Python version and path.) + * Launch cmd, `npm config set msvs_version 2015` If the above steps didn't work for you, please visit [Microsoft's Node.js Guidelines for Windows](https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules) for additional tips. @@ -173,6 +175,7 @@ Command Options | `--thin=yes` | Enable thin static libraries | `--arch=$arch` | Set target architecture (e.g. ia32) | `--tarball=$path` | Get headers from a local tarball +| `--devdir=$path` | SDK download directory (default=~/.node-gyp) | `--ensure` | Don't reinstall headers if already present | `--dist-url=$url` | Download header tarball from custom URL | `--proxy=$url` | Set HTTP proxy for downloading header tarball diff --git a/deps/npm/node_modules/node-gyp/bin/node-gyp.js b/deps/npm/node_modules/node-gyp/bin/node-gyp.js index e44e73877c73b9..70d7d502628bcc 100755 --- a/deps/npm/node_modules/node-gyp/bin/node-gyp.js +++ b/deps/npm/node_modules/node-gyp/bin/node-gyp.js @@ -12,6 +12,8 @@ process.title = 'node-gyp' var gyp = require('../') var log = require('npmlog') +var osenv = require('osenv') +var path = require('path') /** * Process and execute the selected commands. @@ -20,6 +22,19 @@ var log = require('npmlog') var prog = gyp() var completed = false prog.parseArgv(process.argv) +prog.devDir = prog.opts.devdir + +var homeDir = osenv.home() +if (prog.devDir) { + prog.devDir = prog.devDir.replace(/^~/, homeDir) +} else if (homeDir) { + prog.devDir = path.resolve(homeDir, '.node-gyp') +} else { + throw new Error( + "node-gyp requires that the user's home directory is specified " + + "in either of the environmental variables HOME or USERPROFILE. " + + "Overide with: --devdir /path/to/.node-gyp") +} if (prog.todo.length === 0) { if (~process.argv.indexOf('-v') || ~process.argv.indexOf('--version')) { diff --git a/deps/npm/node_modules/node-gyp/gyp/gyp.bat b/deps/npm/node_modules/node-gyp/gyp/gyp.bat old mode 100755 new mode 100644 diff --git a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py index 20178672b23bd8..7567d0a05b02a1 100644 --- a/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py +++ b/deps/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py @@ -230,7 +230,10 @@ def LoadOneBuildFile(build_file_path, data, aux_data, includes, return data[build_file_path] if os.path.exists(build_file_path): - build_file_contents = open(build_file_path).read() + # Open the build file for read ('r') with universal-newlines mode ('U') + # to make sure platform specific newlines ('\r\n' or '\r') are converted to '\n' + # which otherwise will fail eval() + build_file_contents = open(build_file_path, 'rU').read() else: raise GypError("%s not found (cwd: %s)" % (build_file_path, os.getcwd())) diff --git a/deps/npm/node_modules/node-gyp/lib/configure.js b/deps/npm/node_modules/node-gyp/lib/configure.js index 4543bce7d71ba0..66c33e6947d303 100644 --- a/deps/npm/node_modules/node-gyp/lib/configure.js +++ b/deps/npm/node_modules/node-gyp/lib/configure.js @@ -1,6 +1,9 @@ module.exports = exports = configure -module.exports.test = { findAccessibleSync: findAccessibleSync, - findPython: findPython } +module.exports.test = { + PythonFinder: PythonFinder, + findAccessibleSync: findAccessibleSync, + findPython: findPython, +} /** * Module dependencies. @@ -14,11 +17,8 @@ var fs = require('graceful-fs') , semver = require('semver') , mkdirp = require('mkdirp') , cp = require('child_process') - , PathArray = require('path-array') , extend = require('util')._extend , processRelease = require('./process-release') - , spawn = cp.spawn - , execFile = cp.execFile , win = process.platform == 'win32' , findNodeDirectory = require('./find-node-directory') , msgFormat = require('util').format @@ -288,8 +288,11 @@ function configure (gyp, argv, callback) { argv.unshift(gyp_script) // make sure python uses files that came with this particular node package - var pypath = new PathArray(process.env, 'PYTHONPATH') - pypath.unshift(path.join(__dirname, '..', 'gyp', 'pylib')) + var pypath = [path.join(__dirname, '..', 'gyp', 'pylib')] + if (process.env.PYTHONPATH) { + pypath.push(process.env.PYTHONPATH) + } + process.env.PYTHONPATH = pypath.join(win ? ';' : ':') var cp = gyp.spawn(python, argv) cp.on('exit', onCpExit) @@ -334,34 +337,46 @@ function findAccessibleSync (logprefix, dir, candidates) { return undefined } -function findPython (python, callback) { - checkPython() +function PythonFinder(python, callback) { + this.callback = callback + this.python = python +} - // Check if Python is in the $PATH - function checkPython () { - log.verbose('check python', 'checking for Python executable "%s" in the PATH', python) - which(python, function (err, execPath) { +PythonFinder.prototype = { + checkPythonLauncherDepth: 0, + env: process.env, + execFile: cp.execFile, + log: log, + stat: fs.stat, + which: which, + win: win, + + checkPython: function checkPython () { + this.log.verbose('check python', + 'checking for Python executable "%s" in the PATH', + this.python) + this.which(this.python, function (err, execPath) { if (err) { - log.verbose('`which` failed', python, err) - if (python === 'python2') { - python = 'python' - return checkPython() + this.log.verbose('`which` failed', this.python, err) + if (this.python === 'python2') { + this.python = 'python' + return this.checkPython() } - if (win) { - checkPythonLauncher() + if (this.win) { + this.checkPythonLauncher() } else { - failNoPython() + this.failNoPython() } } else { - log.verbose('`which` succeeded', python, execPath) - // Found the `python` exceutable, and from now on we use it explicitly. + this.log.verbose('`which` succeeded', this.python, execPath) + // Found the `python` executable, and from now on we use it explicitly. // This solves #667 and #750 (`execFile` won't run batch files // (*.cmd, and *.bat)) - python = execPath - checkPythonVersion() + this.python = execPath + this.checkPythonVersion() } - }) - } + }.bind(this)) + }, // Distributions of Python on Windows by default install with the "py.exe" // Python launcher which is more likely to exist than the Python executable @@ -371,63 +386,48 @@ function findPython (python, callback) { // the first command line argument. Since "py.exe -2" would be an invalid // executable for "execFile", we have to use the launcher to figure out // where the actual "python.exe" executable is located. - function checkPythonLauncher () { - log.verbose('could not find "' + python + '". checking python launcher') - var env = extend({}, process.env) + checkPythonLauncher: function checkPythonLauncher () { + this.checkPythonLauncherDepth += 1 + + this.log.verbose( + 'could not find "' + this.python + '". checking python launcher') + var env = extend({}, this.env) env.TERM = 'dumb' var launcherArgs = ['-2', '-c', 'import sys; print sys.executable'] - execFile('py.exe', launcherArgs, { env: env }, function (err, stdout) { + this.execFile('py.exe', launcherArgs, { env: env }, function (err, stdout) { if (err) { - guessPython() - return - } - python = stdout.trim() - log.verbose('check python launcher', 'python executable found: %j', python) - checkPythonVersion() - }) - } - - // Called on Windows when "python" isn't available in the current $PATH. - // We're gonna check if "%SystemDrive%\python27\python.exe" exists. - function guessPython () { - log.verbose('could not find "' + python + '". guessing location') - var rootDir = process.env.SystemDrive || 'C:\\' - if (rootDir[rootDir.length - 1] !== '\\') { - rootDir += '\\' - } - var pythonPath = path.resolve(rootDir, 'Python27', 'python.exe') - log.verbose('ensuring that file exists:', pythonPath) - fs.stat(pythonPath, function (err, stat) { - if (err) { - if (err.code == 'ENOENT') { - failNoPython() - } else { - callback(err) - } - return + this.guessPython() + } else { + this.python = stdout.trim() + this.log.verbose('check python launcher', + 'python executable found: %j', + this.python) + this.checkPythonVersion() } - python = pythonPath - checkPythonVersion() - }) - } + this.checkPythonLauncherDepth -= 1 + }.bind(this)) + }, - function checkPythonVersion () { - var env = extend({}, process.env) + checkPythonVersion: function checkPythonVersion () { + var args = ['-c', 'import platform; print(platform.python_version());'] + var env = extend({}, this.env) env.TERM = 'dumb' - execFile(python, ['-c', 'import platform; print(platform.python_version());'], { env: env }, function (err, stdout) { + this.execFile(this.python, args, { env: env }, function (err, stdout) { if (err) { - return callback(err) + return this.callback(err) } - log.verbose('check python version', '`%s -c "import platform; print(platform.python_version());"` returned: %j', python, stdout) + this.log.verbose('check python version', + '`%s -c "' + args[1] + '"` returned: %j', + this.python, stdout) var version = stdout.trim() if (~version.indexOf('+')) { - log.silly('stripping "+" sign(s) from version') + this.log.silly('stripping "+" sign(s) from version') version = version.replace(/\+/g, '') } if (~version.indexOf('rc')) { - log.silly('stripping "rc" identifier from version') + this.log.silly('stripping "rc" identifier from version') version = version.replace(/rc(.*)$/ig, '') } var range = semver.Range('>=2.5.0 <3.0.0') @@ -435,24 +435,61 @@ function findPython (python, callback) { try { valid = range.test(version) } catch (e) { - log.silly('range.test() error', e) + this.log.silly('range.test() error', e) } if (valid) { - callback(null, python) + this.callback(null, this.python) + } else if (this.win && this.checkPythonLauncherDepth === 0) { + this.checkPythonLauncher() } else { - failPythonVersion(version) + this.failPythonVersion(version) } - }) - } + }.bind(this)) + }, + + failNoPython: function failNoPython () { + var errmsg = + 'Can\'t find Python executable "' + this.python + + '", you can set the PYTHON env variable.' + this.callback(new Error(errmsg)) + }, + + failPythonVersion: function failPythonVersion (badVersion) { + var errmsg = + 'Python executable "' + this.python + + '" is v' + badVersion + ', which is not supported by gyp.\n' + + 'You can pass the --python switch to point to ' + + 'Python >= v2.5.0 & < 3.0.0.' + this.callback(new Error(errmsg)) + }, - function failNoPython () { - callback(new Error('Can\'t find Python executable "' + python + - '", you can set the PYTHON env variable.')) - } + // Called on Windows when "python" isn't available in the current $PATH. + // We are going to check if "%SystemDrive%\python27\python.exe" exists. + guessPython: function guessPython () { + this.log.verbose('could not find "' + this.python + '". guessing location') + var rootDir = this.env.SystemDrive || 'C:\\' + if (rootDir[rootDir.length - 1] !== '\\') { + rootDir += '\\' + } + var resolve = path.win32 && path.win32.resolve || path.resolve + var pythonPath = resolve(rootDir, 'Python27', 'python.exe') + this.log.verbose('ensuring that file exists:', pythonPath) + this.stat(pythonPath, function (err, stat) { + if (err) { + if (err.code == 'ENOENT') { + this.failNoPython() + } else { + this.callback(err) + } + return + } + this.python = pythonPath + this.checkPythonVersion() + }.bind(this)) + }, +} - function failPythonVersion (badVersion) { - callback(new Error('Python executable "' + python + - '" is v' + badVersion + ', which is not supported by gyp.\n' + - 'You can pass the --python switch to point to Python >= v2.5.0 & < 3.0.0.')) - } +function findPython (python, callback) { + var finder = new PythonFinder(python, callback) + finder.checkPython() } diff --git a/deps/npm/node_modules/node-gyp/lib/node-gyp.js b/deps/npm/node_modules/node-gyp/lib/node-gyp.js index 3b8f5b0a1c2e04..a841161e32eec6 100644 --- a/deps/npm/node_modules/node-gyp/lib/node-gyp.js +++ b/deps/npm/node_modules/node-gyp/lib/node-gyp.js @@ -46,18 +46,7 @@ function gyp () { function Gyp () { var self = this - // set the dir where node-gyp dev files get installed - // TODO: make this *more* configurable? - // see: https://github.com/nodejs/node-gyp/issues/21 - var homeDir = process.env.HOME || process.env.USERPROFILE - if (!homeDir) { - throw new Error( - "node-gyp requires that the user's home directory is specified " + - "in either of the environmental variables HOME or USERPROFILE" - ); - } - this.devDir = path.resolve(homeDir, '.node-gyp') - + this.devDir = '' this.commands = {} commands.forEach(function (command) { @@ -92,6 +81,7 @@ proto.configDefs = { , ensure: Boolean // 'install' , solution: String // 'build' (windows only) , proxy: String // 'install' + , devdir: String // everywhere , nodedir: String // 'configure' , loglevel: String // everywhere , python: String // 'configure' diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/nopt/.npmignore similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/.npmignore rename to deps/npm/node_modules/node-gyp/node_modules/nopt/.npmignore diff --git a/deps/npm/node_modules/node-gyp/node_modules/nopt/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/nopt/.travis.yml new file mode 100644 index 00000000000000..99f2bbf5068a8c --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/nopt/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +language: node_js +node_js: + - '0.8' + - '0.10' + - '0.12' + - 'iojs' +before_install: + - npm install -g npm@latest diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/nopt/LICENSE similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/npmlog/LICENSE rename to deps/npm/node_modules/node-gyp/node_modules/nopt/LICENSE diff --git a/deps/npm/node_modules/node-gyp/node_modules/nopt/README.md b/deps/npm/node_modules/node-gyp/node_modules/nopt/README.md new file mode 100644 index 00000000000000..f21a4b31c5d482 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/nopt/README.md @@ -0,0 +1,211 @@ +If you want to write an option parser, and have it be good, there are +two ways to do it. The Right Way, and the Wrong Way. + +The Wrong Way is to sit down and write an option parser. We've all done +that. + +The Right Way is to write some complex configurable program with so many +options that you hit the limit of your frustration just trying to +manage them all, and defer it with duct-tape solutions until you see +exactly to the core of the problem, and finally snap and write an +awesome option parser. + +If you want to write an option parser, don't write an option parser. +Write a package manager, or a source control system, or a service +restarter, or an operating system. You probably won't end up with a +good one of those, but if you don't give up, and you are relentless and +diligent enough in your procrastination, you may just end up with a very +nice option parser. + +## USAGE + + // my-program.js + var nopt = require("nopt") + , Stream = require("stream").Stream + , path = require("path") + , knownOpts = { "foo" : [String, null] + , "bar" : [Stream, Number] + , "baz" : path + , "bloo" : [ "big", "medium", "small" ] + , "flag" : Boolean + , "pick" : Boolean + , "many1" : [String, Array] + , "many2" : [path] + } + , shortHands = { "foofoo" : ["--foo", "Mr. Foo"] + , "b7" : ["--bar", "7"] + , "m" : ["--bloo", "medium"] + , "p" : ["--pick"] + , "f" : ["--flag"] + } + // everything is optional. + // knownOpts and shorthands default to {} + // arg list defaults to process.argv + // slice defaults to 2 + , parsed = nopt(knownOpts, shortHands, process.argv, 2) + console.log(parsed) + +This would give you support for any of the following: + +```bash +$ node my-program.js --foo "blerp" --no-flag +{ "foo" : "blerp", "flag" : false } + +$ node my-program.js ---bar 7 --foo "Mr. Hand" --flag +{ bar: 7, foo: "Mr. Hand", flag: true } + +$ node my-program.js --foo "blerp" -f -----p +{ foo: "blerp", flag: true, pick: true } + +$ node my-program.js -fp --foofoo +{ foo: "Mr. Foo", flag: true, pick: true } + +$ node my-program.js --foofoo -- -fp # -- stops the flag parsing. +{ foo: "Mr. Foo", argv: { remain: ["-fp"] } } + +$ node my-program.js --blatzk -fp # unknown opts are ok. +{ blatzk: true, flag: true, pick: true } + +$ node my-program.js --blatzk=1000 -fp # but you need to use = if they have a value +{ blatzk: 1000, flag: true, pick: true } + +$ node my-program.js --no-blatzk -fp # unless they start with "no-" +{ blatzk: false, flag: true, pick: true } + +$ node my-program.js --baz b/a/z # known paths are resolved. +{ baz: "/Users/isaacs/b/a/z" } + +# if Array is one of the types, then it can take many +# values, and will always be an array. The other types provided +# specify what types are allowed in the list. + +$ node my-program.js --many1 5 --many1 null --many1 foo +{ many1: ["5", "null", "foo"] } + +$ node my-program.js --many2 foo --many2 bar +{ many2: ["/path/to/foo", "path/to/bar"] } +``` + +Read the tests at the bottom of `lib/nopt.js` for more examples of +what this puppy can do. + +## Types + +The following types are supported, and defined on `nopt.typeDefs` + +* String: A normal string. No parsing is done. +* path: A file system path. Gets resolved against cwd if not absolute. +* url: A url. If it doesn't parse, it isn't accepted. +* Number: Must be numeric. +* Date: Must parse as a date. If it does, and `Date` is one of the options, + then it will return a Date object, not a string. +* Boolean: Must be either `true` or `false`. If an option is a boolean, + then it does not need a value, and its presence will imply `true` as + the value. To negate boolean flags, do `--no-whatever` or `--whatever + false` +* NaN: Means that the option is strictly not allowed. Any value will + fail. +* Stream: An object matching the "Stream" class in node. Valuable + for use when validating programmatically. (npm uses this to let you + supply any WriteStream on the `outfd` and `logfd` config options.) +* Array: If `Array` is specified as one of the types, then the value + will be parsed as a list of options. This means that multiple values + can be specified, and that the value will always be an array. + +If a type is an array of values not on this list, then those are +considered valid values. For instance, in the example above, the +`--bloo` option can only be one of `"big"`, `"medium"`, or `"small"`, +and any other value will be rejected. + +When parsing unknown fields, `"true"`, `"false"`, and `"null"` will be +interpreted as their JavaScript equivalents. + +You can also mix types and values, or multiple types, in a list. For +instance `{ blah: [Number, null] }` would allow a value to be set to +either a Number or null. When types are ordered, this implies a +preference, and the first type that can be used to properly interpret +the value will be used. + +To define a new type, add it to `nopt.typeDefs`. Each item in that +hash is an object with a `type` member and a `validate` method. The +`type` member is an object that matches what goes in the type list. The +`validate` method is a function that gets called with `validate(data, +key, val)`. Validate methods should assign `data[key]` to the valid +value of `val` if it can be handled properly, or return boolean +`false` if it cannot. + +You can also call `nopt.clean(data, types, typeDefs)` to clean up a +config object and remove its invalid properties. + +## Error Handling + +By default, nopt outputs a warning to standard error when invalid values for +known options are found. You can change this behavior by assigning a method +to `nopt.invalidHandler`. This method will be called with +the offending `nopt.invalidHandler(key, val, types)`. + +If no `nopt.invalidHandler` is assigned, then it will console.error +its whining. If it is assigned to boolean `false` then the warning is +suppressed. + +## Abbreviations + +Yes, they are supported. If you define options like this: + +```javascript +{ "foolhardyelephants" : Boolean +, "pileofmonkeys" : Boolean } +``` + +Then this will work: + +```bash +node program.js --foolhar --pil +node program.js --no-f --pileofmon +# etc. +``` + +## Shorthands + +Shorthands are a hash of shorter option names to a snippet of args that +they expand to. + +If multiple one-character shorthands are all combined, and the +combination does not unambiguously match any other option or shorthand, +then they will be broken up into their constituent parts. For example: + +```json +{ "s" : ["--loglevel", "silent"] +, "g" : "--global" +, "f" : "--force" +, "p" : "--parseable" +, "l" : "--long" +} +``` + +```bash +npm ls -sgflp +# just like doing this: +npm ls --loglevel silent --global --force --long --parseable +``` + +## The Rest of the args + +The config object returned by nopt is given a special member called +`argv`, which is an object with the following fields: + +* `remain`: The remaining args after all the parsing has occurred. +* `original`: The args as they originally appeared. +* `cooked`: The args after flags and shorthands are expanded. + +## Slicing + +Node programs are called with more or less the exact argv as it appears +in C land, after the v8 and node-specific options have been plucked off. +As such, `argv[0]` is always `node` and `argv[1]` is always the +JavaScript program being run. + +That's usually not very useful to you. So they're sliced off by +default. If you want them, then you can pass in `0` as the last +argument, or any other number that you'd like to slice off the start of +the list. diff --git a/deps/npm/node_modules/node-gyp/node_modules/nopt/bin/nopt.js b/deps/npm/node_modules/node-gyp/node_modules/nopt/bin/nopt.js new file mode 100755 index 00000000000000..3232d4c570fdcb --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/nopt/bin/nopt.js @@ -0,0 +1,54 @@ +#!/usr/bin/env node +var nopt = require("../lib/nopt") + , path = require("path") + , types = { num: Number + , bool: Boolean + , help: Boolean + , list: Array + , "num-list": [Number, Array] + , "str-list": [String, Array] + , "bool-list": [Boolean, Array] + , str: String + , clear: Boolean + , config: Boolean + , length: Number + , file: path + } + , shorthands = { s: [ "--str", "astring" ] + , b: [ "--bool" ] + , nb: [ "--no-bool" ] + , tft: [ "--bool-list", "--no-bool-list", "--bool-list", "true" ] + , "?": ["--help"] + , h: ["--help"] + , H: ["--help"] + , n: [ "--num", "125" ] + , c: ["--config"] + , l: ["--length"] + , f: ["--file"] + } + , parsed = nopt( types + , shorthands + , process.argv + , 2 ) + +console.log("parsed", parsed) + +if (parsed.help) { + console.log("") + console.log("nopt cli tester") + console.log("") + console.log("types") + console.log(Object.keys(types).map(function M (t) { + var type = types[t] + if (Array.isArray(type)) { + return [t, type.map(function (type) { return type.name })] + } + return [t, type && type.name] + }).reduce(function (s, i) { + s[i[0]] = i[1] + return s + }, {})) + console.log("") + console.log("shorthands") + console.log(shorthands) +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/nopt/examples/my-program.js b/deps/npm/node_modules/node-gyp/node_modules/nopt/examples/my-program.js new file mode 100755 index 00000000000000..142447e18e756c --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/nopt/examples/my-program.js @@ -0,0 +1,30 @@ +#!/usr/bin/env node + +//process.env.DEBUG_NOPT = 1 + +// my-program.js +var nopt = require("../lib/nopt") + , Stream = require("stream").Stream + , path = require("path") + , knownOpts = { "foo" : [String, null] + , "bar" : [Stream, Number] + , "baz" : path + , "bloo" : [ "big", "medium", "small" ] + , "flag" : Boolean + , "pick" : Boolean + } + , shortHands = { "foofoo" : ["--foo", "Mr. Foo"] + , "b7" : ["--bar", "7"] + , "m" : ["--bloo", "medium"] + , "p" : ["--pick"] + , "f" : ["--flag", "true"] + , "g" : ["--flag"] + , "s" : "--flag" + } + // everything is optional. + // knownOpts and shorthands default to {} + // arg list defaults to process.argv + // slice defaults to 2 + , parsed = nopt(knownOpts, shortHands, process.argv, 2) + +console.log("parsed =\n"+ require("util").inspect(parsed)) diff --git a/deps/npm/node_modules/node-gyp/node_modules/nopt/lib/nopt.js b/deps/npm/node_modules/node-gyp/node_modules/nopt/lib/nopt.js new file mode 100644 index 00000000000000..97707e784243bc --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/nopt/lib/nopt.js @@ -0,0 +1,415 @@ +// info about each config option. + +var debug = process.env.DEBUG_NOPT || process.env.NOPT_DEBUG + ? function () { console.error.apply(console, arguments) } + : function () {} + +var url = require("url") + , path = require("path") + , Stream = require("stream").Stream + , abbrev = require("abbrev") + +module.exports = exports = nopt +exports.clean = clean + +exports.typeDefs = + { String : { type: String, validate: validateString } + , Boolean : { type: Boolean, validate: validateBoolean } + , url : { type: url, validate: validateUrl } + , Number : { type: Number, validate: validateNumber } + , path : { type: path, validate: validatePath } + , Stream : { type: Stream, validate: validateStream } + , Date : { type: Date, validate: validateDate } + } + +function nopt (types, shorthands, args, slice) { + args = args || process.argv + types = types || {} + shorthands = shorthands || {} + if (typeof slice !== "number") slice = 2 + + debug(types, shorthands, args, slice) + + args = args.slice(slice) + var data = {} + , key + , remain = [] + , cooked = args + , original = args.slice(0) + + parse(args, data, remain, types, shorthands) + // now data is full + clean(data, types, exports.typeDefs) + data.argv = {remain:remain,cooked:cooked,original:original} + Object.defineProperty(data.argv, 'toString', { value: function () { + return this.original.map(JSON.stringify).join(" ") + }, enumerable: false }) + return data +} + +function clean (data, types, typeDefs) { + typeDefs = typeDefs || exports.typeDefs + var remove = {} + , typeDefault = [false, true, null, String, Array] + + Object.keys(data).forEach(function (k) { + if (k === "argv") return + var val = data[k] + , isArray = Array.isArray(val) + , type = types[k] + if (!isArray) val = [val] + if (!type) type = typeDefault + if (type === Array) type = typeDefault.concat(Array) + if (!Array.isArray(type)) type = [type] + + debug("val=%j", val) + debug("types=", type) + val = val.map(function (val) { + // if it's an unknown value, then parse false/true/null/numbers/dates + if (typeof val === "string") { + debug("string %j", val) + val = val.trim() + if ((val === "null" && ~type.indexOf(null)) + || (val === "true" && + (~type.indexOf(true) || ~type.indexOf(Boolean))) + || (val === "false" && + (~type.indexOf(false) || ~type.indexOf(Boolean)))) { + val = JSON.parse(val) + debug("jsonable %j", val) + } else if (~type.indexOf(Number) && !isNaN(val)) { + debug("convert to number", val) + val = +val + } else if (~type.indexOf(Date) && !isNaN(Date.parse(val))) { + debug("convert to date", val) + val = new Date(val) + } + } + + if (!types.hasOwnProperty(k)) { + return val + } + + // allow `--no-blah` to set 'blah' to null if null is allowed + if (val === false && ~type.indexOf(null) && + !(~type.indexOf(false) || ~type.indexOf(Boolean))) { + val = null + } + + var d = {} + d[k] = val + debug("prevalidated val", d, val, types[k]) + if (!validate(d, k, val, types[k], typeDefs)) { + if (exports.invalidHandler) { + exports.invalidHandler(k, val, types[k], data) + } else if (exports.invalidHandler !== false) { + debug("invalid: "+k+"="+val, types[k]) + } + return remove + } + debug("validated val", d, val, types[k]) + return d[k] + }).filter(function (val) { return val !== remove }) + + if (!val.length) delete data[k] + else if (isArray) { + debug(isArray, data[k], val) + data[k] = val + } else data[k] = val[0] + + debug("k=%s val=%j", k, val, data[k]) + }) +} + +function validateString (data, k, val) { + data[k] = String(val) +} + +function validatePath (data, k, val) { + if (val === true) return false + if (val === null) return true + + val = String(val) + var homePattern = process.platform === 'win32' ? /^~(\/|\\)/ : /^~\// + if (val.match(homePattern) && process.env.HOME) { + val = path.resolve(process.env.HOME, val.substr(2)) + } + data[k] = path.resolve(String(val)) + return true +} + +function validateNumber (data, k, val) { + debug("validate Number %j %j %j", k, val, isNaN(val)) + if (isNaN(val)) return false + data[k] = +val +} + +function validateDate (data, k, val) { + debug("validate Date %j %j %j", k, val, Date.parse(val)) + var s = Date.parse(val) + if (isNaN(s)) return false + data[k] = new Date(val) +} + +function validateBoolean (data, k, val) { + if (val instanceof Boolean) val = val.valueOf() + else if (typeof val === "string") { + if (!isNaN(val)) val = !!(+val) + else if (val === "null" || val === "false") val = false + else val = true + } else val = !!val + data[k] = val +} + +function validateUrl (data, k, val) { + val = url.parse(String(val)) + if (!val.host) return false + data[k] = val.href +} + +function validateStream (data, k, val) { + if (!(val instanceof Stream)) return false + data[k] = val +} + +function validate (data, k, val, type, typeDefs) { + // arrays are lists of types. + if (Array.isArray(type)) { + for (var i = 0, l = type.length; i < l; i ++) { + if (type[i] === Array) continue + if (validate(data, k, val, type[i], typeDefs)) return true + } + delete data[k] + return false + } + + // an array of anything? + if (type === Array) return true + + // NaN is poisonous. Means that something is not allowed. + if (type !== type) { + debug("Poison NaN", k, val, type) + delete data[k] + return false + } + + // explicit list of values + if (val === type) { + debug("Explicitly allowed %j", val) + // if (isArray) (data[k] = data[k] || []).push(val) + // else data[k] = val + data[k] = val + return true + } + + // now go through the list of typeDefs, validate against each one. + var ok = false + , types = Object.keys(typeDefs) + for (var i = 0, l = types.length; i < l; i ++) { + debug("test type %j %j %j", k, val, types[i]) + var t = typeDefs[types[i]] + if (t && + ((type && type.name && t.type && t.type.name) ? (type.name === t.type.name) : (type === t.type))) { + var d = {} + ok = false !== t.validate(d, k, val) + val = d[k] + if (ok) { + // if (isArray) (data[k] = data[k] || []).push(val) + // else data[k] = val + data[k] = val + break + } + } + } + debug("OK? %j (%j %j %j)", ok, k, val, types[i]) + + if (!ok) delete data[k] + return ok +} + +function parse (args, data, remain, types, shorthands) { + debug("parse", args, data, remain) + + var key = null + , abbrevs = abbrev(Object.keys(types)) + , shortAbbr = abbrev(Object.keys(shorthands)) + + for (var i = 0; i < args.length; i ++) { + var arg = args[i] + debug("arg", arg) + + if (arg.match(/^-{2,}$/)) { + // done with keys. + // the rest are args. + remain.push.apply(remain, args.slice(i + 1)) + args[i] = "--" + break + } + var hadEq = false + if (arg.charAt(0) === "-" && arg.length > 1) { + if (arg.indexOf("=") !== -1) { + hadEq = true + var v = arg.split("=") + arg = v.shift() + v = v.join("=") + args.splice.apply(args, [i, 1].concat([arg, v])) + } + + // see if it's a shorthand + // if so, splice and back up to re-parse it. + var shRes = resolveShort(arg, shorthands, shortAbbr, abbrevs) + debug("arg=%j shRes=%j", arg, shRes) + if (shRes) { + debug(arg, shRes) + args.splice.apply(args, [i, 1].concat(shRes)) + if (arg !== shRes[0]) { + i -- + continue + } + } + arg = arg.replace(/^-+/, "") + var no = null + while (arg.toLowerCase().indexOf("no-") === 0) { + no = !no + arg = arg.substr(3) + } + + if (abbrevs[arg]) arg = abbrevs[arg] + + var isArray = types[arg] === Array || + Array.isArray(types[arg]) && types[arg].indexOf(Array) !== -1 + + // allow unknown things to be arrays if specified multiple times. + if (!types.hasOwnProperty(arg) && data.hasOwnProperty(arg)) { + if (!Array.isArray(data[arg])) + data[arg] = [data[arg]] + isArray = true + } + + var val + , la = args[i + 1] + + var isBool = typeof no === 'boolean' || + types[arg] === Boolean || + Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 || + (typeof types[arg] === 'undefined' && !hadEq) || + (la === "false" && + (types[arg] === null || + Array.isArray(types[arg]) && ~types[arg].indexOf(null))) + + if (isBool) { + // just set and move along + val = !no + // however, also support --bool true or --bool false + if (la === "true" || la === "false") { + val = JSON.parse(la) + la = null + if (no) val = !val + i ++ + } + + // also support "foo":[Boolean, "bar"] and "--foo bar" + if (Array.isArray(types[arg]) && la) { + if (~types[arg].indexOf(la)) { + // an explicit type + val = la + i ++ + } else if ( la === "null" && ~types[arg].indexOf(null) ) { + // null allowed + val = null + i ++ + } else if ( !la.match(/^-{2,}[^-]/) && + !isNaN(la) && + ~types[arg].indexOf(Number) ) { + // number + val = +la + i ++ + } else if ( !la.match(/^-[^-]/) && ~types[arg].indexOf(String) ) { + // string + val = la + i ++ + } + } + + if (isArray) (data[arg] = data[arg] || []).push(val) + else data[arg] = val + + continue + } + + if (types[arg] === String && la === undefined) + la = "" + + if (la && la.match(/^-{2,}$/)) { + la = undefined + i -- + } + + val = la === undefined ? true : la + if (isArray) (data[arg] = data[arg] || []).push(val) + else data[arg] = val + + i ++ + continue + } + remain.push(arg) + } +} + +function resolveShort (arg, shorthands, shortAbbr, abbrevs) { + // handle single-char shorthands glommed together, like + // npm ls -glp, but only if there is one dash, and only if + // all of the chars are single-char shorthands, and it's + // not a match to some other abbrev. + arg = arg.replace(/^-+/, '') + + // if it's an exact known option, then don't go any further + if (abbrevs[arg] === arg) + return null + + // if it's an exact known shortopt, same deal + if (shorthands[arg]) { + // make it an array, if it's a list of words + if (shorthands[arg] && !Array.isArray(shorthands[arg])) + shorthands[arg] = shorthands[arg].split(/\s+/) + + return shorthands[arg] + } + + // first check to see if this arg is a set of single-char shorthands + var singles = shorthands.___singles + if (!singles) { + singles = Object.keys(shorthands).filter(function (s) { + return s.length === 1 + }).reduce(function (l,r) { + l[r] = true + return l + }, {}) + shorthands.___singles = singles + debug('shorthand singles', singles) + } + + var chrs = arg.split("").filter(function (c) { + return singles[c] + }) + + if (chrs.join("") === arg) return chrs.map(function (c) { + return shorthands[c] + }).reduce(function (l, r) { + return l.concat(r) + }, []) + + + // if it's an arg abbrev, and not a literal shorthand, then prefer the arg + if (abbrevs[arg] && !shorthands[arg]) + return null + + // if it's an abbr for a shorthand, then use that + if (shortAbbr[arg]) + arg = shortAbbr[arg] + + // make it an array, if it's a list of words + if (shorthands[arg] && !Array.isArray(shorthands[arg])) + shorthands[arg] = shorthands[arg].split(/\s+/) + + return shorthands[arg] +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/nopt/package.json b/deps/npm/node_modules/node-gyp/node_modules/nopt/package.json new file mode 100644 index 00000000000000..8973e66ffdc470 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/nopt/package.json @@ -0,0 +1,96 @@ +{ + "_args": [ + [ + { + "raw": "nopt@2 || 3", + "scope": null, + "escapedName": "nopt", + "name": "nopt", + "rawSpec": "2 || 3", + "spec": ">=2.0.0 <3.0.0||>=3.0.0 <4.0.0", + "type": "range" + }, + "/Users/ogd/Documents/projects/npm/npm/node_modules/node-gyp" + ] + ], + "_from": "nopt@>=2.0.0 <3.0.0||>=3.0.0 <4.0.0", + "_id": "nopt@3.0.6", + "_inCache": true, + "_location": "/node-gyp/nopt", + "_nodeVersion": "4.2.1", + "_npmUser": { + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" + }, + "_npmVersion": "2.14.10", + "_phantomChildren": {}, + "_requested": { + "raw": "nopt@2 || 3", + "scope": null, + "escapedName": "nopt", + "name": "nopt", + "rawSpec": "2 || 3", + "spec": ">=2.0.0 <3.0.0||>=3.0.0 <4.0.0", + "type": "range" + }, + "_requiredBy": [ + "/node-gyp" + ], + "_resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", + "_shasum": "c6465dbf08abcd4db359317f79ac68a646b28ff9", + "_shrinkwrap": null, + "_spec": "nopt@2 || 3", + "_where": "/Users/ogd/Documents/projects/npm/npm/node_modules/node-gyp", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "bin": { + "nopt": "./bin/nopt.js" + }, + "bugs": { + "url": "https://github.com/npm/nopt/issues" + }, + "dependencies": { + "abbrev": "1" + }, + "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", + "devDependencies": { + "tap": "^1.2.0" + }, + "directories": {}, + "dist": { + "shasum": "c6465dbf08abcd4db359317f79ac68a646b28ff9", + "tarball": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz" + }, + "gitHead": "10a750c9bb99c1950160353459e733ac2aa18cb6", + "homepage": "https://github.com/npm/nopt#readme", + "license": "ISC", + "main": "lib/nopt.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + }, + { + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" + }, + { + "name": "zkat", + "email": "kat@sykosomatic.org" + } + ], + "name": "nopt", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/nopt.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "3.0.6" +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/nopt/test/basic.js b/deps/npm/node_modules/node-gyp/node_modules/nopt/test/basic.js new file mode 100644 index 00000000000000..d399de9209932c --- /dev/null +++ b/deps/npm/node_modules/node-gyp/node_modules/nopt/test/basic.js @@ -0,0 +1,273 @@ +var nopt = require("../") + , test = require('tap').test + + +test("passing a string results in a string", function (t) { + var parsed = nopt({ key: String }, {}, ["--key", "myvalue"], 0) + t.same(parsed.key, "myvalue") + t.end() +}) + +// https://github.com/npm/nopt/issues/31 +test("Empty String results in empty string, not true", function (t) { + var parsed = nopt({ empty: String }, {}, ["--empty"], 0) + t.same(parsed.empty, "") + t.end() +}) + +test("~ path is resolved to $HOME", function (t) { + var path = require("path") + if (!process.env.HOME) process.env.HOME = "/tmp" + var parsed = nopt({key: path}, {}, ["--key=~/val"], 0) + t.same(parsed.key, path.resolve(process.env.HOME, "val")) + t.end() +}) + +// https://github.com/npm/nopt/issues/24 +test("Unknown options are not parsed as numbers", function (t) { + var parsed = nopt({"parse-me": Number}, null, ['--leave-as-is=1.20', '--parse-me=1.20'], 0) + t.equal(parsed['leave-as-is'], '1.20') + t.equal(parsed['parse-me'], 1.2) + t.end() +}); + +// https://github.com/npm/nopt/issues/48 +test("Check types based on name of type", function (t) { + var parsed = nopt({"parse-me": {name: "Number"}}, null, ['--parse-me=1.20'], 0) + t.equal(parsed['parse-me'], 1.2) + t.end() +}) + + +test("Missing types are not parsed", function (t) { + var parsed = nopt({"parse-me": {}}, null, ['--parse-me=1.20'], 0) + //should only contain argv + t.equal(Object.keys(parsed).length, 1) + t.end() +}) + +test("Types passed without a name are not parsed", function (t) { + var parsed = nopt({"parse-me": {}}, {}, ['--parse-me=1.20'], 0) + //should only contain argv + t.equal(Object.keys(parsed).length, 1) + t.end() +}) + +test("other tests", function (t) { + + var util = require("util") + , Stream = require("stream") + , path = require("path") + , url = require("url") + + , shorthands = + { s : ["--loglevel", "silent"] + , d : ["--loglevel", "info"] + , dd : ["--loglevel", "verbose"] + , ddd : ["--loglevel", "silly"] + , noreg : ["--no-registry"] + , reg : ["--registry"] + , "no-reg" : ["--no-registry"] + , silent : ["--loglevel", "silent"] + , verbose : ["--loglevel", "verbose"] + , h : ["--usage"] + , H : ["--usage"] + , "?" : ["--usage"] + , help : ["--usage"] + , v : ["--version"] + , f : ["--force"] + , desc : ["--description"] + , "no-desc" : ["--no-description"] + , "local" : ["--no-global"] + , l : ["--long"] + , p : ["--parseable"] + , porcelain : ["--parseable"] + , g : ["--global"] + } + + , types = + { aoa: Array + , nullstream: [null, Stream] + , date: Date + , str: String + , browser : String + , cache : path + , color : ["always", Boolean] + , depth : Number + , description : Boolean + , dev : Boolean + , editor : path + , force : Boolean + , global : Boolean + , globalconfig : path + , group : [String, Number] + , gzipbin : String + , logfd : [Number, Stream] + , loglevel : ["silent","win","error","warn","info","verbose","silly"] + , long : Boolean + , "node-version" : [false, String] + , npaturl : url + , npat : Boolean + , "onload-script" : [false, String] + , outfd : [Number, Stream] + , parseable : Boolean + , pre: Boolean + , prefix: path + , proxy : url + , "rebuild-bundle" : Boolean + , registry : url + , searchopts : String + , searchexclude: [null, String] + , shell : path + , t: [Array, String] + , tag : String + , tar : String + , tmp : path + , "unsafe-perm" : Boolean + , usage : Boolean + , user : String + , username : String + , userconfig : path + , version : Boolean + , viewer: path + , _exit : Boolean + , path: path + } + + ; [["-v", {version:true}, []] + ,["---v", {version:true}, []] + ,["ls -s --no-reg connect -d", + {loglevel:"info",registry:null},["ls","connect"]] + ,["ls ---s foo",{loglevel:"silent"},["ls","foo"]] + ,["ls --registry blargle", {}, ["ls"]] + ,["--no-registry", {registry:null}, []] + ,["--no-color true", {color:false}, []] + ,["--no-color false", {color:true}, []] + ,["--no-color", {color:false}, []] + ,["--color false", {color:false}, []] + ,["--color --logfd 7", {logfd:7,color:true}, []] + ,["--color=true", {color:true}, []] + ,["--logfd=10", {logfd:10}, []] + ,["--tmp=/tmp -tar=gtar",{tmp:"/tmp",tar:"gtar"},[]] + ,["--tmp=tmp -tar=gtar", + {tmp:path.resolve(process.cwd(), "tmp"),tar:"gtar"},[]] + ,["--logfd x", {}, []] + ,["a -true -- -no-false", {true:true},["a","-no-false"]] + ,["a -no-false", {false:false},["a"]] + ,["a -no-no-true", {true:true}, ["a"]] + ,["a -no-no-no-false", {false:false}, ["a"]] + ,["---NO-no-No-no-no-no-nO-no-no"+ + "-No-no-no-no-no-no-no-no-no"+ + "-no-no-no-no-NO-NO-no-no-no-no-no-no"+ + "-no-body-can-do-the-boogaloo-like-I-do" + ,{"body-can-do-the-boogaloo-like-I-do":false}, []] + ,["we are -no-strangers-to-love "+ + "--you-know=the-rules --and=so-do-i "+ + "---im-thinking-of=a-full-commitment "+ + "--no-you-would-get-this-from-any-other-guy "+ + "--no-gonna-give-you-up "+ + "-no-gonna-let-you-down=true "+ + "--no-no-gonna-run-around false "+ + "--desert-you=false "+ + "--make-you-cry false "+ + "--no-tell-a-lie "+ + "--no-no-and-hurt-you false" + ,{"strangers-to-love":false + ,"you-know":"the-rules" + ,"and":"so-do-i" + ,"you-would-get-this-from-any-other-guy":false + ,"gonna-give-you-up":false + ,"gonna-let-you-down":false + ,"gonna-run-around":false + ,"desert-you":false + ,"make-you-cry":false + ,"tell-a-lie":false + ,"and-hurt-you":false + },["we", "are"]] + ,["-t one -t two -t three" + ,{t: ["one", "two", "three"]} + ,[]] + ,["-t one -t null -t three four five null" + ,{t: ["one", "null", "three"]} + ,["four", "five", "null"]] + ,["-t foo" + ,{t:["foo"]} + ,[]] + ,["--no-t" + ,{t:["false"]} + ,[]] + ,["-no-no-t" + ,{t:["true"]} + ,[]] + ,["-aoa one -aoa null -aoa 100" + ,{aoa:["one", null, '100']} + ,[]] + ,["-str 100" + ,{str:"100"} + ,[]] + ,["--color always" + ,{color:"always"} + ,[]] + ,["--no-nullstream" + ,{nullstream:null} + ,[]] + ,["--nullstream false" + ,{nullstream:null} + ,[]] + ,["--notadate=2011-01-25" + ,{notadate: "2011-01-25"} + ,[]] + ,["--date 2011-01-25" + ,{date: new Date("2011-01-25")} + ,[]] + ,["-cl 1" + ,{config: true, length: 1} + ,[] + ,{config: Boolean, length: Number, clear: Boolean} + ,{c: "--config", l: "--length"}] + ,["--acount bla" + ,{"acount":true} + ,["bla"] + ,{account: Boolean, credentials: Boolean, options: String} + ,{a:"--account", c:"--credentials",o:"--options"}] + ,["--clear" + ,{clear:true} + ,[] + ,{clear:Boolean,con:Boolean,len:Boolean,exp:Boolean,add:Boolean,rep:Boolean} + ,{c:"--con",l:"--len",e:"--exp",a:"--add",r:"--rep"}] + ,["--file -" + ,{"file":"-"} + ,[] + ,{file:String} + ,{}] + ,["--file -" + ,{"file":true} + ,["-"] + ,{file:Boolean} + ,{}] + ,["--path" + ,{"path":null} + ,[]] + ,["--path ." + ,{"path":process.cwd()} + ,[]] + ].forEach(function (test) { + var argv = test[0].split(/\s+/) + , opts = test[1] + , rem = test[2] + , actual = nopt(test[3] || types, test[4] || shorthands, argv, 0) + , parsed = actual.argv + delete actual.argv + for (var i in opts) { + var e = JSON.stringify(opts[i]) + , a = JSON.stringify(actual[i] === undefined ? null : actual[i]) + if (e && typeof e === "object") { + t.deepEqual(e, a) + } else { + t.equal(e, a) + } + } + t.deepEqual(rem, parsed.remain) + }) + t.end() +}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/CHANGELOG.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/CHANGELOG.md deleted file mode 100644 index f549a1f3de81e3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/CHANGELOG.md +++ /dev/null @@ -1,36 +0,0 @@ -### v3.1.2 - -* Update to `gauge@1.6.0` adding support for default values for template - items. - -### v3.1.1 - -* Update to `gauge@1.5.3` to fix to `1.x` compatibility when it comes to - when a progress bar is enabled. In `1.x` if you didn't have a TTY the - progress bar was never shown. In `2.x` it merely defaults to disabled, - but you can enable it explicitly if you still want progress updates. - -### v3.1.0 - -* Update to `gauge@2.5.2`: - * Updates the `signal-exit` dependency which fixes an incompatibility with - the node profiler. - * Uses externalizes its ansi code generation in `console-control-strings` -* Make the default progress bar include the last line printed, colored as it - would be when printing to a tty. - -### v3.0.0 - -* Switch to `gauge@2.0.0`, for better performance, better look. -* Set stderr/stdout blocking if they're tty's, so that we can hide a - progress bar going to stderr and then safely print to stdout. Without - this the two can end up overlapping producing confusing and sometimes - corrupted output. - -### v2.0.0 - -* Make the `error` event non-fatal so that folks can use it as a prefix. - -### v1.0.0 - -* Add progress bar with `gauge@1.1.0` diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/README.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/README.md deleted file mode 100644 index dba35501614e91..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/README.md +++ /dev/null @@ -1,210 +0,0 @@ -# npmlog - -The logger util that npm uses. - -This logger is very basic. It does the logging for npm. It supports -custom levels and colored output. - -By default, logs are written to stderr. If you want to send log messages -to outputs other than streams, then you can change the `log.stream` -member, or you can just listen to the events that it emits, and do -whatever you want with them. - -# Basic Usage - -``` -var log = require('npmlog') - -// additional stuff ---------------------------+ -// message ----------+ | -// prefix ----+ | | -// level -+ | | | -// v v v v - log.info('fyi', 'I have a kitty cat: %j', myKittyCat) -``` - -## log.level - -* {String} - -The level to display logs at. Any logs at or above this level will be -displayed. The special level `silent` will prevent anything from being -displayed ever. - -## log.record - -* {Array} - -An array of all the log messages that have been entered. - -## log.maxRecordSize - -* {Number} - -The maximum number of records to keep. If log.record gets bigger than -10% over this value, then it is sliced down to 90% of this value. - -The reason for the 10% window is so that it doesn't have to resize a -large array on every log entry. - -## log.prefixStyle - -* {Object} - -A style object that specifies how prefixes are styled. (See below) - -## log.headingStyle - -* {Object} - -A style object that specifies how the heading is styled. (See below) - -## log.heading - -* {String} Default: "" - -If set, a heading that is printed at the start of every line. - -## log.stream - -* {Stream} Default: `process.stderr` - -The stream where output is written. - -## log.enableColor() - -Force colors to be used on all messages, regardless of the output -stream. - -## log.disableColor() - -Disable colors on all messages. - -## log.enableProgress() - -Enable the display of log activity spinner and progress bar - -## log.disableProgress() - -Disable the display of a progress bar - -## log.enableUnicode() - -Force the unicode theme to be used for the progress bar. - -## log.disableUnicode() - -Disable the use of unicode in the progress bar. - -## log.setGaugeTemplate(template) - -Set a template for outputting the progress bar. See the [gauge documentation] for details. - -[gauge documentation]: https://npmjs.com/package/gauge - -## log.setGaugeThemeset(themes) - -Select a themeset to pick themes from for the progress bar. See the [gauge documentation] for details. - -## log.pause() - -Stop emitting messages to the stream, but do not drop them. - -## log.resume() - -Emit all buffered messages that were written while paused. - -## log.log(level, prefix, message, ...) - -* `level` {String} The level to emit the message at -* `prefix` {String} A string prefix. Set to "" to skip. -* `message...` Arguments to `util.format` - -Emit a log message at the specified level. - -## log\[level](prefix, message, ...) - -For example, - -* log.silly(prefix, message, ...) -* log.verbose(prefix, message, ...) -* log.info(prefix, message, ...) -* log.http(prefix, message, ...) -* log.warn(prefix, message, ...) -* log.error(prefix, message, ...) - -Like `log.log(level, prefix, message, ...)`. In this way, each level is -given a shorthand, so you can do `log.info(prefix, message)`. - -## log.addLevel(level, n, style, disp) - -* `level` {String} Level indicator -* `n` {Number} The numeric level -* `style` {Object} Object with fg, bg, inverse, etc. -* `disp` {String} Optional replacement for `level` in the output. - -Sets up a new level with a shorthand function and so forth. - -Note that if the number is `Infinity`, then setting the level to that -will cause all log messages to be suppressed. If the number is -`-Infinity`, then the only way to show it is to enable all log messages. - -## log.newItem(name, todo, weight) - -* `name` {String} Optional; progress item name. -* `todo` {Number} Optional; total amount of work to be done. Default 0. -* `weight` {Number} Optional; the weight of this item relative to others. Default 1. - -This adds a new `are-we-there-yet` item tracker to the progress tracker. The -object returned has the `log[level]` methods but is otherwise an -`are-we-there-yet` `Tracker` object. - -## log.newStream(name, todo, weight) - -This adds a new `are-we-there-yet` stream tracker to the progress tracker. The -object returned has the `log[level]` methods but is otherwise an -`are-we-there-yet` `TrackerStream` object. - -## log.newGroup(name, weight) - -This adds a new `are-we-there-yet` tracker group to the progress tracker. The -object returned has the `log[level]` methods but is otherwise an -`are-we-there-yet` `TrackerGroup` object. - -# Events - -Events are all emitted with the message object. - -* `log` Emitted for all messages -* `log.` Emitted for all messages with the `` level. -* `` Messages with prefixes also emit their prefix as an event. - -# Style Objects - -Style objects can have the following fields: - -* `fg` {String} Color for the foreground text -* `bg` {String} Color for the background -* `bold`, `inverse`, `underline` {Boolean} Set the associated property -* `bell` {Boolean} Make a noise (This is pretty annoying, probably.) - -# Message Objects - -Every log event is emitted with a message object, and the `log.record` -list contains all of them that have been created. They have the -following fields: - -* `id` {Number} -* `level` {String} -* `prefix` {String} -* `message` {String} Result of `util.format()` -* `messageRaw` {Array} Arguments to `util.format()` - -# Blocking TTYs - -We use [`set-blocking`](https://npmjs.com/package/set-blocking) to set -stderr and stdout blocking if they are tty's and have the setBlocking call. -This is a work around for an issue in early versions of Node.js 6.x, which -made stderr and stdout non-blocking on OSX. (They are always blocking -Windows and were never blocking on Linux.) `npmlog` needs them to be blocking -so that it can allow output to stdout and stderr to be interlaced. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/log.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/log.js deleted file mode 100644 index e5b70f1f80b743..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/log.js +++ /dev/null @@ -1,298 +0,0 @@ -'use strict' -var Progress = require('are-we-there-yet') -var Gauge = require('gauge') -var EE = require('events').EventEmitter -var log = exports = module.exports = new EE() -var util = require('util') - -var setBlocking = require('set-blocking') -var consoleControl = require('console-control-strings') - -setBlocking(true) -var stream = process.stderr -Object.defineProperty(log, 'stream', { - set: function (newStream) { - stream = newStream - if (this.gauge) this.gauge.setWriteTo(stream, stream) - }, - get: function () { - return stream - } -}) - -// by default, decide based on tty-ness. -var colorEnabled -log.useColor = function () { - return colorEnabled != null ? colorEnabled : stream.isTTY -} - -log.enableColor = function () { - colorEnabled = true - this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled}) -} -log.disableColor = function () { - colorEnabled = false - this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled}) -} - -// default level -log.level = 'info' - -log.gauge = new Gauge(stream, { - theme: {hasColor: log.useColor()}, - template: [ - {type: 'progressbar', length: 20}, - {type: 'activityIndicator', kerning: 1, length: 1}, - {type: 'section', default: ''}, - ':', - {type: 'logline', kerning: 1, default: ''} - ] -}) - -log.tracker = new Progress.TrackerGroup() - -// no progress bars unless asked -log.progressEnabled = false - -var unicodeEnabled - -log.enableUnicode = function () { - unicodeEnabled = true - this.gauge.setTheme({hasColor: this.useColor(), hasUnicode: unicodeEnabled}) -} - -log.disableUnicode = function () { - unicodeEnabled = false - this.gauge.setTheme({hasColor: this.useColor(), hasUnicode: unicodeEnabled}) -} - -log.setGaugeThemeset = function (themes) { - this.gauge.setThemeset(themes) -} - -log.setGaugeTemplate = function (template) { - this.gauge.setTemplate(template) -} - -log.enableProgress = function () { - if (this.progressEnabled) return - this.progressEnabled = true - if (this._pause) return - this.tracker.on('change', this.showProgress) - this.gauge.enable() - this.showProgress() -} - -log.disableProgress = function () { - if (!this.progressEnabled) return - this.clearProgress() - this.progressEnabled = false - this.tracker.removeListener('change', this.showProgress) - this.gauge.disable() -} - -var trackerConstructors = ['newGroup', 'newItem', 'newStream'] - -var mixinLog = function (tracker) { - // mixin the public methods from log into the tracker - // (except: conflicts and one's we handle specially) - Object.keys(log).forEach(function (P) { - if (P[0] === '_') return - if (trackerConstructors.filter(function (C) { return C === P }).length) return - if (tracker[P]) return - if (typeof log[P] !== 'function') return - var func = log[P] - tracker[P] = function () { - return func.apply(log, arguments) - } - }) - // if the new tracker is a group, make sure any subtrackers get - // mixed in too - if (tracker instanceof Progress.TrackerGroup) { - trackerConstructors.forEach(function (C) { - var func = tracker[C] - tracker[C] = function () { return mixinLog(func.apply(tracker, arguments)) } - }) - } - return tracker -} - -// Add tracker constructors to the top level log object -trackerConstructors.forEach(function (C) { - log[C] = function () { return mixinLog(this.tracker[C].apply(this.tracker, arguments)) } -}) - -log.clearProgress = function (cb) { - if (!this.progressEnabled) return cb && process.nextTick(cb) - this.gauge.hide(cb) -} - -log.showProgress = function (name, completed) { - if (!this.progressEnabled) return - var values = {} - if (name) values.section = name - var last = log.record[log.record.length - 1] - if (last) { - values.subsection = last.prefix - var disp = log.disp[last.level] || last.level - var logline = this._format(disp, log.style[last.level]) - if (last.prefix) logline += ' ' + this._format(last.prefix, this.prefixStyle) - logline += ' ' + last.message.split(/\r?\n/)[0] - values.logline = logline - } - values.completed = completed || this.tracker.completed() - this.gauge.show(values) -}.bind(log) // bind for use in tracker's on-change listener - -// temporarily stop emitting, but don't drop -log.pause = function () { - this._paused = true -} - -log.resume = function () { - if (!this._paused) return - this._paused = false - - var b = this._buffer - this._buffer = [] - b.forEach(function (m) { - this.emitLog(m) - }, this) - if (this.progressEnabled) this.enableProgress() -} - -log._buffer = [] - -var id = 0 -log.record = [] -log.maxRecordSize = 10000 -log.log = function (lvl, prefix, message) { - var l = this.levels[lvl] - if (l === undefined) { - return this.emit('error', new Error(util.format( - 'Undefined log level: %j', lvl))) - } - - var a = new Array(arguments.length - 2) - var stack = null - for (var i = 2; i < arguments.length; i++) { - var arg = a[i - 2] = arguments[i] - - // resolve stack traces to a plain string. - if (typeof arg === 'object' && arg && - (arg instanceof Error) && arg.stack) { - arg.stack = stack = arg.stack + '' - } - } - if (stack) a.unshift(stack + '\n') - message = util.format.apply(util, a) - - var m = { id: id++, - level: lvl, - prefix: String(prefix || ''), - message: message, - messageRaw: a } - - this.emit('log', m) - this.emit('log.' + lvl, m) - if (m.prefix) this.emit(m.prefix, m) - - this.record.push(m) - var mrs = this.maxRecordSize - var n = this.record.length - mrs - if (n > mrs / 10) { - var newSize = Math.floor(mrs * 0.9) - this.record = this.record.slice(-1 * newSize) - } - - this.emitLog(m) -}.bind(log) - -log.emitLog = function (m) { - if (this._paused) { - this._buffer.push(m) - return - } - if (this.progressEnabled) this.gauge.pulse(m.prefix) - var l = this.levels[m.level] - if (l === undefined) return - if (l < this.levels[this.level]) return - if (l > 0 && !isFinite(l)) return - - var disp = log.disp[m.level] || m.level - this.clearProgress() - m.message.split(/\r?\n/).forEach(function (line) { - if (this.heading) { - this.write(this.heading, this.headingStyle) - this.write(' ') - } - this.write(disp, log.style[m.level]) - var p = m.prefix || '' - if (p) this.write(' ') - this.write(p, this.prefixStyle) - this.write(' ' + line + '\n') - }, this) - this.showProgress() -} - -log._format = function (msg, style) { - if (!stream) return - - var output = '' - if (this.useColor()) { - style = style || {} - var settings = [] - if (style.fg) settings.push(style.fg) - if (style.bg) settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1)) - if (style.bold) settings.push('bold') - if (style.underline) settings.push('underline') - if (style.inverse) settings.push('inverse') - if (settings.length) output += consoleControl.color(settings) - if (style.beep) output += consoleControl.beep() - } - output += msg - if (this.useColor()) { - output += consoleControl.color('reset') - } - return output -} - -log.write = function (msg, style) { - if (!stream) return - - stream.write(this._format(msg, style)) -} - -log.addLevel = function (lvl, n, style, disp) { - if (!disp) disp = lvl - this.levels[lvl] = n - this.style[lvl] = style - if (!this[lvl]) { - this[lvl] = function () { - var a = new Array(arguments.length + 1) - a[0] = lvl - for (var i = 0; i < arguments.length; i++) { - a[i + 1] = arguments[i] - } - return this.log.apply(this, a) - }.bind(this) - } - this.disp[lvl] = disp -} - -log.prefixStyle = { fg: 'magenta' } -log.headingStyle = { fg: 'white', bg: 'black' } - -log.style = {} -log.levels = {} -log.disp = {} -log.addLevel('silly', -Infinity, { inverse: true }, 'sill') -log.addLevel('verbose', 1000, { fg: 'blue', bg: 'black' }, 'verb') -log.addLevel('info', 2000, { fg: 'green' }) -log.addLevel('http', 3000, { fg: 'green', bg: 'black' }) -log.addLevel('warn', 4000, { fg: 'black', bg: 'yellow' }, 'WARN') -log.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!') -log.addLevel('silent', Infinity) - -// allow 'error' prefix -log.on('error', function () {}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/.npmignore deleted file mode 100644 index bc818974f8633f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -*~ -.#* -node_modules -coverage -.nyc_output diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/CHANGES.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/CHANGES.md deleted file mode 100644 index e990b86ddfb416..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/CHANGES.md +++ /dev/null @@ -1,19 +0,0 @@ -Hi, figured we could actually use a changelog now: - -## 1.1.1 2016-01-29 - -* Fix a typo in stream completion tracker - -## 1.1.0 2016-01-29 - -* Rewrote completion percent computation to be low impact– no more walking a - tree of completion groups every time we need this info. Previously, with - medium sized tree of completion groups, even a relatively modest number of - calls to the top level `completed()` method would result in absurd numbers - of calls overall as it walked down the tree. We now, instead, keep track as - we bubble up changes, so the computation is limited to when data changes and - to the depth of that one branch, instead of _every_ node. (Plus, we were already - incurring _this_ cost, since we already bubbled out changes.) -* Moved different tracker types out to their own files. -* Made tests test for TOO MANY events too. -* Standarized the source code formatting diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE deleted file mode 100644 index af4588069db82d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE +++ /dev/null @@ -1,5 +0,0 @@ -Copyright (c) 2015, Rebecca Turner - -Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/README.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/README.md deleted file mode 100644 index c41d39229244d2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/README.md +++ /dev/null @@ -1,194 +0,0 @@ -are-we-there-yet ----------------- - -Track complex hiearchies of asynchronous task completion statuses. This is -intended to give you a way of recording and reporting the progress of the big -recursive fan-out and gather type workflows that are so common in async. - -What you do with this completion data is up to you, but the most common use case is to -feed it to one of the many progress bar modules. - -Most progress bar modules include a rudamentary version of this, but my -needs were more complex. - -Usage -===== - -```javascript -var TrackerGroup = require("are-we-there-yet").TrackerGroup - -var top = new TrackerGroup("program") - -var single = top.newItem("one thing", 100) -single.completeWork(20) - -console.log(top.completed()) // 0.2 - -fs.stat("file", function(er, stat) { - if (er) throw er - var stream = top.newStream("file", stat.size) - console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete - // and 50% * 20% == 10% - fs.createReadStream("file").pipe(stream).on("data", function (chunk) { - // do stuff with chunk - }) - top.on("change", function (name) { - // called each time a chunk is read from "file" - // top.completed() will start at 0.1 and fill up to 0.6 as the file is read - }) -}) -``` - -Shared Methods -============== - -All tracker objects described below have the following methods, they, along -with the event comprise the interface for consumers of tracker objects. - -* var completed = tracker.completed() - -Returns the ratio of completed work to work to be done. Range of 0 to 1. - -* tracker.finish() - -Marks the tracker as completed. With a TrackerGroup this marks all of its -components as completed. - -Marks all of the components of this tracker as finished, which in turn means -that `tracker.completed()` for this will now be 1. - -This will result in one or more `change` events being emitted. - -Events -====== - -All tracker objects emit `change` events with the following arguments: - -``` -function (name, completed, tracker) -``` - -`name` is the name of the tracker that originally emitted the event, -or if it didn't have one, the first containing tracker group that had one. - -`completed` is the percent complete (as returned by `tracker.completed()` method). - -`tracker` is the tracker object that you are listening for events on. - -TrackerGroup -============ - -* var tracker = new TrackerGroup(**name**) - - * **name** *(optional)* - The name of this tracker group, used in change - notifications if the component updating didn't have a name. Defaults to undefined. - -Creates a new empty tracker aggregation group. These are trackers whose -completion status is determined by the completion status of other trackers. - -* tracker.addUnit(**otherTracker**, **weight**) - - * **otherTracker** - Any of the other are-we-there-yet tracker objects - * **weight** *(optional)* - The weight to give the tracker, defaults to 1. - -Adds the **otherTracker** to this aggregation group. The weight determines -how long you expect this tracker to take to complete in proportion to other -units. So for instance, if you add one tracker with a weight of 1 and -another with a weight of 2, you're saying the second will take twice as long -to complete as the first. As such, the first will account for 33% of the -completion of this tracker and the second will account for the other 67%. - -Returns **otherTracker**. - -* var subGroup = tracker.newGroup(**name**, **weight**) - -The above is exactly equivalent to: - -```javascript - var subGroup = tracker.addUnit(new TrackerGroup(name), weight) -``` - -* var subItem = tracker.newItem(**name**, **todo**, **weight**) - -The above is exactly equivalent to: - -```javascript - var subItem = tracker.addUnit(new Tracker(name, todo), weight) -``` - -* var subStream = tracker.newStream(**name**, **todo**, **weight**) - -The above is exactly equivalent to: - -```javascript - var subStream = tracker.addUnit(new TrackerStream(name, todo), weight) -``` - -* console.log( tracker.debug() ) - -Returns a tree showing the completion of this tracker group and all of its -children, including recursively entering all of the children. - -Tracker -======= - -* var tracker = new Tracker(**name**, **todo**) - - * **name** *(optional)* The name of this counter to report in change - events. Defaults to undefined. - * **todo** *(optional)* The amount of work todo (a number). Defaults to 0. - -Ordinarily these are constructed as a part of a tracker group (via -`newItem`). - -* var completed = tracker.completed() - -Returns the ratio of completed work to work to be done. Range of 0 to 1. If -total work to be done is 0 then it will return 0. - -* tracker.addWork(**todo**) - - * **todo** A number to add to the amount of work to be done. - -Increases the amount of work to be done, thus decreasing the completion -percentage. Triggers a `change` event. - -* tracker.completeWork(**completed**) - - * **completed** A number to add to the work complete - -Increase the amount of work complete, thus increasing the completion percentage. -Will never increase the work completed past the amount of work todo. That is, -percentages > 100% are not allowed. Triggers a `change` event. - -* tracker.finish() - -Marks this tracker as finished, tracker.completed() will now be 1. Triggers -a `change` event. - -TrackerStream -============= - -* var tracker = new TrackerStream(**name**, **size**, **options**) - - * **name** *(optional)* The name of this counter to report in change - events. Defaults to undefined. - * **size** *(optional)* The number of bytes being sent through this stream. - * **options** *(optional)* A hash of stream options - -The tracker stream object is a pass through stream that updates an internal -tracker object each time a block passes through. It's intended to track -downloads, file extraction and other related activities. You use it by piping -your data source into it and then using it as your data source. - -If your data has a length attribute then that's used as the amount of work -completed when the chunk is passed through. If it does not (eg, object -streams) then each chunk counts as completing 1 unit of work, so your size -should be the total number of objects being streamed. - -* tracker.addWork(**todo**) - - * **todo** Increase the expected overall size by **todo** bytes. - -Increases the amount of work to be done, thus decreasing the completion -percentage. Triggers a `change` event. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/index.js deleted file mode 100644 index 57d8743fdad177..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict' -exports.TrackerGroup = require('./tracker-group.js') -exports.Tracker = require('./tracker.js') -exports.TrackerStream = require('./tracker-stream.js') diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/.npmignore deleted file mode 100644 index c2658d7d1b3184..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules/ diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/History.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/History.md deleted file mode 100644 index 25959eab67b840..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/History.md +++ /dev/null @@ -1,22 +0,0 @@ - -1.0.0 / 2015-12-14 -================== - - * Merge pull request #12 from kasicka/master - * Add license text - -0.1.0 / 2014-10-17 -================== - - * adds `.fluent()` to api - -0.0.3 / 2014-01-13 -================== - - * fix receiver for .method() - -0.0.2 / 2014-01-13 -================== - - * Object.defineProperty() sucks - * Initial commit diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/License b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/License deleted file mode 100644 index 60de60addbe7e9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/License +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2015 TJ Holowaychuk - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Makefile b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Makefile deleted file mode 100644 index a9dcfd50dbdb22..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -test: - @./node_modules/.bin/mocha \ - --require should \ - --reporter spec \ - --bail - -.PHONY: test \ No newline at end of file diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Readme.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Readme.md deleted file mode 100644 index ab8cf4ace15939..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Readme.md +++ /dev/null @@ -1,94 +0,0 @@ - -# delegates - - Node method and accessor delegation utilty. - -## Installation - -``` -$ npm install delegates -``` - -## Example - -```js -var delegate = require('delegates'); - -... - -delegate(proto, 'request') - .method('acceptsLanguages') - .method('acceptsEncodings') - .method('acceptsCharsets') - .method('accepts') - .method('is') - .access('querystring') - .access('idempotent') - .access('socket') - .access('length') - .access('query') - .access('search') - .access('status') - .access('method') - .access('path') - .access('body') - .access('host') - .access('url') - .getter('subdomains') - .getter('protocol') - .getter('header') - .getter('stale') - .getter('fresh') - .getter('secure') - .getter('ips') - .getter('ip') -``` - -# API - -## Delegate(proto, prop) - -Creates a delegator instance used to configure using the `prop` on the given -`proto` object. (which is usually a prototype) - -## Delegate#method(name) - -Allows the given method `name` to be accessed on the host. - -## Delegate#getter(name) - -Creates a "getter" for the property with the given `name` on the delegated -object. - -## Delegate#setter(name) - -Creates a "setter" for the property with the given `name` on the delegated -object. - -## Delegate#access(name) - -Creates an "accessor" (ie: both getter *and* setter) for the property with the -given `name` on the delegated object. - -## Delegate#fluent(name) - -A unique type of "accessor" that works for a "fluent" API. When called as a -getter, the method returns the expected value. However, if the method is called -with a value, it will return itself so it can be chained. For example: - -```js -delegate(proto, 'request') - .fluent('query') - -// getter -var q = request.query(); - -// setter (chainable) -request - .query({ a: 1 }) - .query({ b: 2 }); -``` - -# License - - MIT diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/index.js deleted file mode 100644 index 17c222d52935c6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/index.js +++ /dev/null @@ -1,121 +0,0 @@ - -/** - * Expose `Delegator`. - */ - -module.exports = Delegator; - -/** - * Initialize a delegator. - * - * @param {Object} proto - * @param {String} target - * @api public - */ - -function Delegator(proto, target) { - if (!(this instanceof Delegator)) return new Delegator(proto, target); - this.proto = proto; - this.target = target; - this.methods = []; - this.getters = []; - this.setters = []; - this.fluents = []; -} - -/** - * Delegate method `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.method = function(name){ - var proto = this.proto; - var target = this.target; - this.methods.push(name); - - proto[name] = function(){ - return this[target][name].apply(this[target], arguments); - }; - - return this; -}; - -/** - * Delegator accessor `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.access = function(name){ - return this.getter(name).setter(name); -}; - -/** - * Delegator getter `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.getter = function(name){ - var proto = this.proto; - var target = this.target; - this.getters.push(name); - - proto.__defineGetter__(name, function(){ - return this[target][name]; - }); - - return this; -}; - -/** - * Delegator setter `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.setter = function(name){ - var proto = this.proto; - var target = this.target; - this.setters.push(name); - - proto.__defineSetter__(name, function(val){ - return this[target][name] = val; - }); - - return this; -}; - -/** - * Delegator fluent accessor - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.fluent = function (name) { - var proto = this.proto; - var target = this.target; - this.fluents.push(name); - - proto[name] = function(val){ - if ('undefined' != typeof val) { - this[target][name] = val; - return this; - } else { - return this[target][name]; - } - }; - - return this; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/package.json deleted file mode 100644 index 6a5ea8189c5f6f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/package.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "delegates@^1.0.0", - "scope": null, - "escapedName": "delegates", - "name": "delegates", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/are-we-there-yet" - ], - [ - { - "raw": "delegates@^1.0.0", - "scope": null, - "escapedName": "delegates", - "name": "delegates", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet" - ] - ], - "_from": "delegates@^1.0.0", - "_id": "delegates@1.0.0", - "_inCache": true, - "_location": "/node-gyp/npmlog/are-we-there-yet/delegates", - "_nodeVersion": "4.2.1", - "_npmUser": { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - "_npmVersion": "3.3.12", - "_phantomChildren": {}, - "_requested": { - "raw": "delegates@^1.0.0", - "scope": null, - "escapedName": "delegates", - "name": "delegates", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog/are-we-there-yet" - ], - "_resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "_shasum": "84c6e159b81904fdca59a0ef44cd870d31250f9a", - "_shrinkwrap": null, - "_spec": "delegates@^1.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet", - "bugs": { - "url": "https://github.com/visionmedia/node-delegates/issues" - }, - "dependencies": {}, - "description": "delegate methods and accessors to another property", - "devDependencies": { - "mocha": "*", - "should": "*" - }, - "directories": {}, - "dist": { - "shasum": "84c6e159b81904fdca59a0ef44cd870d31250f9a", - "tarball": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz" - }, - "gitHead": "c4dc07ef1ed51c2b2a63f3585e5ef949ee577a49", - "homepage": "https://github.com/visionmedia/node-delegates#readme", - "keywords": [ - "delegate", - "delegation" - ], - "license": "MIT", - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "dominicbarnes", - "email": "dominic@dbarnes.info" - } - ], - "name": "delegates", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/visionmedia/node-delegates.git" - }, - "scripts": {}, - "version": "1.0.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/test/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/test/index.js deleted file mode 100644 index 7b6e3d4df19d90..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/test/index.js +++ /dev/null @@ -1,94 +0,0 @@ - -var assert = require('assert'); -var delegate = require('..'); - -describe('.method(name)', function(){ - it('should delegate methods', function(){ - var obj = {}; - - obj.request = { - foo: function(bar){ - assert(this == obj.request); - return bar; - } - }; - - delegate(obj, 'request').method('foo'); - - obj.foo('something').should.equal('something'); - }) -}) - -describe('.getter(name)', function(){ - it('should delegate getters', function(){ - var obj = {}; - - obj.request = { - get type() { - return 'text/html'; - } - } - - delegate(obj, 'request').getter('type'); - - obj.type.should.equal('text/html'); - }) -}) - -describe('.setter(name)', function(){ - it('should delegate setters', function(){ - var obj = {}; - - obj.request = { - get type() { - return this._type.toUpperCase(); - }, - - set type(val) { - this._type = val; - } - } - - delegate(obj, 'request').setter('type'); - - obj.type = 'hey'; - obj.request.type.should.equal('HEY'); - }) -}) - -describe('.access(name)', function(){ - it('should delegate getters and setters', function(){ - var obj = {}; - - obj.request = { - get type() { - return this._type.toUpperCase(); - }, - - set type(val) { - this._type = val; - } - } - - delegate(obj, 'request').access('type'); - - obj.type = 'hey'; - obj.type.should.equal('HEY'); - }) -}) - -describe('.fluent(name)', function () { - it('should delegate in a fluent fashion', function () { - var obj = { - settings: { - env: 'development' - } - }; - - delegate(obj, 'settings').fluent('env'); - - obj.env().should.equal('development'); - obj.env('production').should.equal(obj); - obj.settings.env.should.equal('production'); - }) -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/package.json deleted file mode 100644 index 66ca32888b025e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/package.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "are-we-there-yet@~1.1.2", - "scope": null, - "escapedName": "are-we-there-yet", - "name": "are-we-there-yet", - "rawSpec": "~1.1.2", - "spec": ">=1.1.2 <1.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog" - ], - [ - { - "raw": "are-we-there-yet@~1.1.2", - "scope": null, - "escapedName": "are-we-there-yet", - "name": "are-we-there-yet", - "rawSpec": "~1.1.2", - "spec": ">=1.1.2 <1.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog" - ] - ], - "_from": "are-we-there-yet@~1.1.2", - "_id": "are-we-there-yet@1.1.2", - "_inCache": true, - "_location": "/node-gyp/npmlog/are-we-there-yet", - "_nodeVersion": "4.2.2", - "_npmOperationalInternal": { - "host": "packages-13-west.internal.npmjs.com", - "tmp": "tmp/are-we-there-yet-1.1.2.tgz_1458084397358_0.15847722673788667" - }, - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "_npmVersion": "3.8.1", - "_phantomChildren": {}, - "_requested": { - "raw": "are-we-there-yet@~1.1.2", - "scope": null, - "escapedName": "are-we-there-yet", - "name": "are-we-there-yet", - "rawSpec": "~1.1.2", - "spec": ">=1.1.2 <1.2.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog" - ], - "_resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz", - "_shasum": "80e470e95a084794fe1899262c5667c6e88de1b3", - "_shrinkwrap": null, - "_spec": "are-we-there-yet@~1.1.2", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog", - "author": { - "name": "Rebecca Turner", - "url": "http://re-becca.org" - }, - "bugs": { - "url": "https://github.com/iarna/are-we-there-yet/issues" - }, - "dependencies": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.0 || ^1.1.13" - }, - "description": "Keep track of the overall completion of many dispirate processes", - "devDependencies": { - "standard": "^6.0.8", - "tap": "^5.7.0" - }, - "directories": {}, - "dist": { - "shasum": "80e470e95a084794fe1899262c5667c6e88de1b3", - "tarball": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz" - }, - "gitHead": "dd5706e2204cb681e78031d0ffe156ed4cc75823", - "homepage": "https://github.com/iarna/are-we-there-yet", - "license": "ISC", - "main": "index.js", - "maintainers": [ - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "name": "are-we-there-yet", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/iarna/are-we-there-yet.git" - }, - "scripts": { - "test": "standard && tap test/*.js" - }, - "version": "1.1.2" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/lib/test-event.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/lib/test-event.js deleted file mode 100644 index 2aa7c05c5864fa..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/lib/test-event.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict' -var util = require('util') - -module.exports = function (obj, event, next) { - var timeout = setTimeout(gotTimeout, 10) - obj.once(event, gotResult) - - function gotTimeout () { - obj.removeListener(event, gotResult) - next(new Error('Timeout listening for ' + event)) - } - var result = [] - function gotResult () { - result = Array.prototype.slice.call(arguments) - clearTimeout(timeout) - timeout = setTimeout(gotNoMoreResults, 10) - obj.once(event, gotTooManyResults) - } - function gotNoMoreResults () { - obj.removeListener(event, gotTooManyResults) - var args = [null].concat(result) - next.apply(null, args) - } - function gotTooManyResults () { - var secondResult = Array.prototype.slice.call(arguments) - clearTimeout(timeout) - next(new Error('Got too many results, first ' + util.inspect(result) + ' and then ' + util.inspect(secondResult))) - } -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/tracker.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/tracker.js deleted file mode 100644 index 374c7739d0c011..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/tracker.js +++ /dev/null @@ -1,57 +0,0 @@ -'use strict' -var test = require('tap').test -var Tracker = require('../index.js').Tracker - -var testEvent = require('./lib/test-event.js') - -var name = 'test' - -test('initialization', function (t) { - var simple = new Tracker(name) - - t.is(simple.completed(), 0, 'Nothing todo is 0 completion') - t.done() -}) - -var track -var todo = 100 -test('completion', function (t) { - track = new Tracker(name, todo) - t.is(track.completed(), 0, 'Nothing done is 0 completion') - - testEvent(track, 'change', afterCompleteWork) - - track.completeWork(todo) - t.is(track.completed(), 1, 'completeWork: 100% completed') - - function afterCompleteWork (er, onChangeName) { - t.is(er, null, 'completeWork: on change event fired') - t.is(onChangeName, name, 'completeWork: on change emits the correct name') - t.done() - } -}) - -test('add more work', function (t) { - testEvent(track, 'change', afterAddWork) - track.addWork(todo) - t.is(track.completed(), 0.5, 'addWork: 50% completed') - function afterAddWork (er, onChangeName) { - t.is(er, null, 'addWork: on change event fired') - t.is(onChangeName, name, 'addWork: on change emits the correct name') - t.done() - } -}) - -test('complete more work', function (t) { - track.completeWork(200) - t.is(track.completed(), 1, 'completeWork: Over completion is still only 100% complete') - t.done() -}) - -test('finish is always 100%', function (t) { - var finishtest = new Tracker(name, todo) - finishtest.completeWork(50) - finishtest.finish() - t.is(finishtest.completed(), 1, 'finish: Explicitly finishing moves to 100%') - t.done() -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackergroup.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackergroup.js deleted file mode 100644 index 799a7670b65934..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackergroup.js +++ /dev/null @@ -1,96 +0,0 @@ -'use strict' -var test = require('tap').test -var TrackerGroup = require('../index.js').TrackerGroup -var testEvent = require('./lib/test-event.js') - -test('TrackerGroup', function (t) { - var name = 'test' - - var track = new TrackerGroup(name) - t.is(track.completed(), 0, 'Nothing todo is 0 completion') - testEvent(track, 'change', afterFinishEmpty) - track.finish() - var a, b - function afterFinishEmpty (er, onChangeName, completion) { - t.is(er, null, 'finishEmpty: on change event fired') - t.is(onChangeName, name, 'finishEmpty: on change emits the correct name') - t.is(completion, 1, 'finishEmpty: passed through completion was correct') - t.is(track.completed(), 1, 'finishEmpty: Finishing an empty group actually finishes it') - - track = new TrackerGroup(name) - a = track.newItem('a', 10, 1) - b = track.newItem('b', 10, 1) - t.is(track.completed(), 0, 'Initially empty') - testEvent(track, 'change', afterCompleteWork) - a.completeWork(5) - } - function afterCompleteWork (er, onChangeName, completion) { - t.is(er, null, 'on change event fired') - t.is(onChangeName, 'a', 'on change emits the correct name') - t.is(completion, 0.25, 'Complete half of one is a quarter overall') - t.is(track.completed(), 0.25, 'Complete half of one is a quarter overall') - testEvent(track, 'change', afterFinishAll) - track.finish() - } - function afterFinishAll (er, onChangeName, completion) { - t.is(er, null, 'finishAll: on change event fired') - t.is(onChangeName, name, 'finishAll: on change emits the correct name') - t.is(completion, 1, 'Finishing everything ') - t.is(track.completed(), 1, 'Finishing everything ') - - track = new TrackerGroup(name) - a = track.newItem('a', 10, 2) - b = track.newItem('b', 10, 1) - t.is(track.completed(), 0, 'weighted: Initially empty') - testEvent(track, 'change', afterWeightedCompleteWork) - a.completeWork(5) - } - function afterWeightedCompleteWork (er, onChangeName, completion) { - t.is(er, null, 'weighted: on change event fired') - t.is(onChangeName, 'a', 'weighted: on change emits the correct name') - t.is(Math.floor(completion * 100), 33, 'weighted: Complete half of double weighted') - t.is(Math.floor(track.completed() * 100), 33, 'weighted: Complete half of double weighted') - testEvent(track, 'change', afterWeightedFinishAll) - track.finish() - } - function afterWeightedFinishAll (er, onChangeName, completion) { - t.is(er, null, 'weightedFinishAll: on change event fired') - t.is(onChangeName, name, 'weightedFinishAll: on change emits the correct name') - t.is(completion, 1, 'weightedFinishaAll: Finishing everything ') - t.is(track.completed(), 1, 'weightedFinishaAll: Finishing everything ') - - track = new TrackerGroup(name) - a = track.newGroup('a', 10) - b = track.newGroup('b', 10) - var a1 = a.newItem('a.1', 10) - a1.completeWork(5) - t.is(track.completed(), 0.25, 'nested: Initially quarter done') - testEvent(track, 'change', afterNestedComplete) - b.finish() - } - function afterNestedComplete (er, onChangeName, completion) { - t.is(er, null, 'nestedComplete: on change event fired') - t.is(onChangeName, 'b', 'nestedComplete: on change emits the correct name') - t.is(completion, 0.75, 'nestedComplete: Finishing everything ') - t.is(track.completed(), 0.75, 'nestedComplete: Finishing everything ') - t.end() - } -}) - -test('cycles', function (t) { - var track = new TrackerGroup('top') - testCycle(track, track) - var layer1 = track.newGroup('layer1') - testCycle(layer1, track) - t.end() - - function testCycle (addTo, toAdd) { - try { - addTo.addUnit(toAdd) - t.fail(toAdd.name) - } catch (ex) { - console.log(ex) - t.pass(toAdd.name) - } - } -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackerstream.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackerstream.js deleted file mode 100644 index 65f04b03769190..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/test/trackerstream.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict' -var test = require('tap').test -var util = require('util') -var stream = require('readable-stream') -var TrackerStream = require('../index.js').TrackerStream -var testEvent = require('./lib/test-event.js') - -var Sink = function () { - stream.Writable.apply(this, arguments) -} -util.inherits(Sink, stream.Writable) -Sink.prototype._write = function (data, encoding, cb) { - cb() -} - -test('TrackerStream', function (t) { - t.plan(9) - - var name = 'test' - var track = new TrackerStream(name) - - t.is(track.completed(), 0, 'Nothing todo is 0 completion') - - var todo = 10 - track = new TrackerStream(name, todo) - t.is(track.completed(), 0, 'Nothing done is 0 completion') - - track.pipe(new Sink()) - - testEvent(track, 'change', afterCompleteWork) - track.write('0123456789') - function afterCompleteWork (er, onChangeName) { - t.is(er, null, 'write: on change event fired') - t.is(onChangeName, name, 'write: on change emits the correct name') - t.is(track.completed(), 1, 'write: 100% completed') - - testEvent(track, 'change', afterAddWork) - track.addWork(10) - } - function afterAddWork (er, onChangeName) { - t.is(er, null, 'addWork: on change event fired') - t.is(track.completed(), 0.5, 'addWork: 50% completed') - - testEvent(track, 'change', afterAllWork) - track.write('ABCDEFGHIJKLMNOPQRST') - } - function afterAllWork (er) { - t.is(er, null, 'allWork: on change event fired') - t.is(track.completed(), 1, 'allWork: 100% completed') - } -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker-base.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker-base.js deleted file mode 100644 index 6f436875578a7a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker-base.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict' -var EventEmitter = require('events').EventEmitter -var util = require('util') - -var trackerId = 0 -var TrackerBase = module.exports = function (name) { - EventEmitter.call(this) - this.id = ++trackerId - this.name = name -} -util.inherits(TrackerBase, EventEmitter) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js deleted file mode 100644 index 9759e1226db046..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict' -var util = require('util') -var TrackerBase = require('./tracker-base.js') -var Tracker = require('./tracker.js') -var TrackerStream = require('./tracker-stream.js') - -var TrackerGroup = module.exports = function (name) { - TrackerBase.call(this, name) - this.parentGroup = null - this.trackers = [] - this.completion = {} - this.weight = {} - this.totalWeight = 0 - this.finished = false - this.bubbleChange = bubbleChange(this) -} -util.inherits(TrackerGroup, TrackerBase) - -function bubbleChange (trackerGroup) { - return function (name, completed, tracker) { - trackerGroup.completion[tracker.id] = completed - if (trackerGroup.finished) return - trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup) - } -} - -TrackerGroup.prototype.nameInTree = function () { - var names = [] - var from = this - while (from) { - names.unshift(from.name) - from = from.parentGroup - } - return names.join('/') -} - -TrackerGroup.prototype.addUnit = function (unit, weight) { - if (unit.addUnit) { - var toTest = this - while (toTest) { - if (unit === toTest) { - throw new Error( - 'Attempted to add tracker group ' + - unit.name + ' to tree that already includes it ' + - this.nameInTree(this)) - } - toTest = toTest.parentGroup - } - unit.parentGroup = this - } - this.weight[unit.id] = weight || 1 - this.totalWeight += this.weight[unit.id] - this.trackers.push(unit) - this.completion[unit.id] = unit.completed() - unit.on('change', this.bubbleChange) - if (!this.finished) this.emit('change', unit.name, this.completion[unit.id], unit) - return unit -} - -TrackerGroup.prototype.completed = function () { - if (this.trackers.length === 0) return 0 - var valPerWeight = 1 / this.totalWeight - var completed = 0 - for (var ii = 0; ii < this.trackers.length; ii++) { - var trackerId = this.trackers[ii].id - completed += valPerWeight * this.weight[trackerId] * this.completion[trackerId] - } - return completed -} - -TrackerGroup.prototype.newGroup = function (name, weight) { - return this.addUnit(new TrackerGroup(name), weight) -} - -TrackerGroup.prototype.newItem = function (name, todo, weight) { - return this.addUnit(new Tracker(name, todo), weight) -} - -TrackerGroup.prototype.newStream = function (name, todo, weight) { - return this.addUnit(new TrackerStream(name, todo), weight) -} - -TrackerGroup.prototype.finish = function () { - this.finished = true - if (!this.trackers.length) this.addUnit(new Tracker(), 1, true) - for (var ii = 0; ii < this.trackers.length; ii++) { - var tracker = this.trackers[ii] - tracker.finish() - tracker.removeListener('change', this.bubbleChange) - } - this.emit('change', this.name, 1, this) -} - -var buffer = ' ' -TrackerGroup.prototype.debug = function (depth) { - depth = depth || 0 - var indent = depth ? buffer.substr(0, depth) : '' - var output = indent + (this.name || 'top') + ': ' + this.completed() + '\n' - this.trackers.forEach(function (tracker) { - if (tracker instanceof TrackerGroup) { - output += tracker.debug(depth + 1) - } else { - output += indent + ' ' + tracker.name + ': ' + tracker.completed() + '\n' - } - }) - return output -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js deleted file mode 100644 index fb9598ed4e9c31..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict' -var util = require('util') -var stream = require('readable-stream') -var delegate = require('delegates') -var Tracker = require('./tracker.js') - -var TrackerStream = module.exports = function (name, size, options) { - stream.Transform.call(this, options) - this.tracker = new Tracker(name, size) - this.name = name - this.id = this.tracker.id - this.tracker.on('change', delegateChange(this)) -} -util.inherits(TrackerStream, stream.Transform) - -function delegateChange (trackerStream) { - return function (name, completion, tracker) { - trackerStream.emit('change', name, completion, trackerStream) - } -} - -TrackerStream.prototype._transform = function (data, encoding, cb) { - this.tracker.completeWork(data.length ? data.length : 1) - this.push(data) - cb() -} - -TrackerStream.prototype._flush = function (cb) { - this.tracker.finish() - cb() -} - -delegate(TrackerStream.prototype, 'tracker') - .method('completed') - .method('addWork') diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker.js deleted file mode 100644 index 68c2339b45409a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/are-we-there-yet/tracker.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict' -var util = require('util') -var TrackerBase = require('./tracker-base.js') - -var Tracker = module.exports = function (name, todo) { - TrackerBase.call(this, name) - this.workDone = 0 - this.workTodo = todo || 0 -} -util.inherits(Tracker, TrackerBase) - -Tracker.prototype.completed = function () { - return this.workTodo === 0 ? 0 : this.workDone / this.workTodo -} - -Tracker.prototype.addWork = function (work) { - this.workTodo += work - this.emit('change', this.name, this.completed(), this) -} - -Tracker.prototype.completeWork = function (work) { - this.workDone += work - if (this.workDone > this.workTodo) this.workDone = this.workTodo - this.emit('change', this.name, this.completed(), this) -} - -Tracker.prototype.finish = function () { - this.workTodo = this.workDone = 1 - this.emit('change', this.name, 1, this) -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/LICENSE deleted file mode 100644 index e756052969b780..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2014, Rebecca Turner - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/README.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/README.md deleted file mode 100644 index f58cc8d8925060..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/README.md +++ /dev/null @@ -1,145 +0,0 @@ -# Console Control Strings - -A library of cross-platform tested terminal/console command strings for -doing things like color and cursor positioning. This is a subset of both -ansi and vt100. All control codes included work on both Windows & Unix-like -OSes, except where noted. - -## Usage - -```js -var consoleControl = require('console-control-strings') - -console.log(consoleControl.color('blue','bgRed', 'bold') + 'hi there' + consoleControl.color('reset')) -process.stdout.write(consoleControl.goto(75, 10)) -``` - -## Why Another? - -There are tons of libraries similar to this one. I wanted one that was: - -1. Very clear about compatibility goals. -2. Could emit, for instance, a start color code without an end one. -3. Returned strings w/o writing to streams. -4. Was not weighed down with other unrelated baggage. - -## Functions - -### var code = consoleControl.up(_num = 1_) - -Returns the escape sequence to move _num_ lines up. - -### var code = consoleControl.down(_num = 1_) - -Returns the escape sequence to move _num_ lines down. - -### var code = consoleControl.forward(_num = 1_) - -Returns the escape sequence to move _num_ lines righ. - -### var code = consoleControl.back(_num = 1_) - -Returns the escape sequence to move _num_ lines left. - -### var code = consoleControl.nextLine(_num = 1_) - -Returns the escape sequence to move _num_ lines down and to the beginning of -the line. - -### var code = consoleControl.previousLine(_num = 1_) - -Returns the escape sequence to move _num_ lines up and to the beginning of -the line. - -### var code = consoleControl.eraseData() - -Returns the escape sequence to erase everything from the current cursor -position to the bottom right of the screen. This is line based, so it -erases the remainder of the current line and all following lines. - -### var code = consoleControl.eraseLine() - -Returns the escape sequence to erase to the end of the current line. - -### var code = consoleControl.goto(_x_, _y_) - -Returns the escape sequence to move the cursor to the designated position. -Note that the origin is _1, 1_ not _0, 0_. - -### var code = consoleControl.gotoSOL() - -Returns the escape sequence to move the cursor to the beginning of the -current line. (That is, it returns a carriage return, `\r`.) - -### var code = consoleControl.beep() - -Returns the escape sequence to cause the termianl to beep. (That is, it -returns unicode character `\x0007`, a Control-G.) - -### var code = consoleControl.hideCursor() - -Returns the escape sequence to hide the cursor. - -### var code = consoleControl.showCursor() - -Returns the escape sequence to show the cursor. - -### var code = consoleControl.color(_colors = []_) - -### var code = consoleControl.color(_color1_, _color2_, _…_, _colorn_) - -Returns the escape sequence to set the current terminal display attributes -(mostly colors). Arguments can either be a list of attributes or an array -of attributes. The difference between passing in an array or list of colors -and calling `.color` separately for each one, is that in the former case a -single escape sequence will be produced where as in the latter each change -will have its own distinct escape sequence. Each attribute can be one of: - -* Reset: - * **reset** – Reset all attributes to the terminal default. -* Styles: - * **bold** – Display text as bold. In some terminals this means using a - bold font, in others this means changing the color. In some it means - both. - * **italic** – Display text as italic. This is not available in most Windows terminals. - * **underline** – Underline text. This is not available in most Windows Terminals. - * **inverse** – Invert the foreground and background colors. - * **stopBold** – Do not display text as bold. - * **stopItalic** – Do not display text as italic. - * **stopUnderline** – Do not underline text. - * **stopInverse** – Do not invert foreground and background. -* Colors: - * **white** - * **black** - * **blue** - * **cyan** - * **green** - * **magenta** - * **red** - * **yellow** - * **grey** / **brightBlack** - * **brightRed** - * **brightGreen** - * **brightYellow** - * **brightBlue** - * **brightMagenta** - * **brightCyan** - * **brightWhite** -* Background Colors: - * **bgWhite** - * **bgBlack** - * **bgBlue** - * **bgCyan** - * **bgGreen** - * **bgMagenta** - * **bgRed** - * **bgYellow** - * **bgGrey** / **bgBrightBlack** - * **bgBrightRed** - * **bgBrightGreen** - * **bgBrightYellow** - * **bgBrightBlue** - * **bgBrightMagenta** - * **bgBrightCyan** - * **bgBrightWhite** - diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/index.js deleted file mode 100644 index bf890348ec6e35..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/index.js +++ /dev/null @@ -1,125 +0,0 @@ -'use strict' - -// These tables borrowed from `ansi` - -var prefix = '\x1b[' - -exports.up = function up (num) { - return prefix + (num || '') + 'A' -} - -exports.down = function down (num) { - return prefix + (num || '') + 'B' -} - -exports.forward = function forward (num) { - return prefix + (num || '') + 'C' -} - -exports.back = function back (num) { - return prefix + (num || '') + 'D' -} - -exports.nextLine = function nextLine (num) { - return prefix + (num || '') + 'E' -} - -exports.previousLine = function previousLine (num) { - return prefix + (num || '') + 'F' -} - -exports.horizontalAbsolute = function horizontalAbsolute (num) { - if (num == null) throw new Error('horizontalAboslute requires a column to position to') - return prefix + num + 'G' -} - -exports.eraseData = function eraseData () { - return prefix + 'J' -} - -exports.eraseLine = function eraseLine () { - return prefix + 'K' -} - -exports.goto = function (x, y) { - return prefix + y + ';' + x + 'H' -} - -exports.gotoSOL = function () { - return '\r' -} - -exports.beep = function () { - return '\x07' -} - -exports.hideCursor = function hideCursor () { - return prefix + '?25l' -} - -exports.showCursor = function showCursor () { - return prefix + '?25h' -} - -var colors = { - reset: 0, -// styles - bold: 1, - italic: 3, - underline: 4, - inverse: 7, -// resets - stopBold: 22, - stopItalic: 23, - stopUnderline: 24, - stopInverse: 27, -// colors - white: 37, - black: 30, - blue: 34, - cyan: 36, - green: 32, - magenta: 35, - red: 31, - yellow: 33, - bgWhite: 47, - bgBlack: 40, - bgBlue: 44, - bgCyan: 46, - bgGreen: 42, - bgMagenta: 45, - bgRed: 41, - bgYellow: 43, - - grey: 90, - brightBlack: 90, - brightRed: 91, - brightGreen: 92, - brightYellow: 93, - brightBlue: 94, - brightMagenta: 95, - brightCyan: 96, - brightWhite: 97, - - bgGrey: 100, - bgBrightBlack: 100, - bgBrightRed: 101, - bgBrightGreen: 102, - bgBrightYellow: 103, - bgBrightBlue: 104, - bgBrightMagenta: 105, - bgBrightCyan: 106, - bgBrightWhite: 107 -} - -exports.color = function color (colorWith) { - if (arguments.length !== 1 || !Array.isArray(colorWith)) { - colorWith = Array.prototype.slice.call(arguments) - } - return prefix + colorWith.map(colorNameToCode).join(';') + 'm' -} - -function colorNameToCode (color) { - if (colors[color] != null) return colors[color] - throw new Error('Unknown color or style name: ' + color) -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/package.json deleted file mode 100644 index 581b0eb4d48f94..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/console-control-strings/package.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "console-control-strings@~1.1.0", - "scope": null, - "escapedName": "console-control-strings", - "name": "console-control-strings", - "rawSpec": "~1.1.0", - "spec": ">=1.1.0 <1.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog" - ], - [ - { - "raw": "console-control-strings@~1.1.0", - "scope": null, - "escapedName": "console-control-strings", - "name": "console-control-strings", - "rawSpec": "~1.1.0", - "spec": ">=1.1.0 <1.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog" - ] - ], - "_from": "console-control-strings@~1.1.0", - "_id": "console-control-strings@1.1.0", - "_inCache": true, - "_location": "/node-gyp/npmlog/console-control-strings", - "_nodeVersion": "4.4.0", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/console-control-strings-1.1.0.tgz_1466033396831_0.9470485949423164" - }, - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "_npmVersion": "3.9.2", - "_phantomChildren": {}, - "_requested": { - "raw": "console-control-strings@~1.1.0", - "scope": null, - "escapedName": "console-control-strings", - "name": "console-control-strings", - "rawSpec": "~1.1.0", - "spec": ">=1.1.0 <1.2.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog", - "/node-gyp/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "_shasum": "3d7cf4464db6446ea644bf4b39507f9851008e8e", - "_shrinkwrap": null, - "_spec": "console-control-strings@~1.1.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog", - "author": { - "name": "Rebecca Turner", - "email": "me@re-becca.org", - "url": "http://re-becca.org/" - }, - "bugs": { - "url": "https://github.com/iarna/console-control-strings/issues" - }, - "dependencies": {}, - "description": "A library of cross-platform tested terminal/console command strings for doing things like color and cursor positioning. This is a subset of both ansi and vt100. All control codes included work on both Windows & Unix-like OSes, except where noted.", - "devDependencies": { - "standard": "^7.1.2", - "tap": "^5.7.2" - }, - "directories": { - "test": "test" - }, - "dist": { - "shasum": "3d7cf4464db6446ea644bf4b39507f9851008e8e", - "tarball": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz" - }, - "files": [ - "LICENSE", - "index.js" - ], - "gitHead": "722439b4998d2964ac3d3f9ec175c008aa9b7b4b", - "homepage": "https://github.com/iarna/console-control-strings#readme", - "keywords": [], - "license": "ISC", - "main": "index.js", - "maintainers": [ - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "name": "console-control-strings", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/iarna/console-control-strings.git" - }, - "scripts": { - "test": "standard && tap test/*.js" - }, - "version": "1.1.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/CHANGELOG.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/CHANGELOG.md deleted file mode 100644 index efd08fc7c19dd7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/CHANGELOG.md +++ /dev/null @@ -1,131 +0,0 @@ -### v2.6.0 - -* Bug fix: Don't run the code associated with `enable`/`disable` if the gauge - is already enabled or disabled respectively. This prevents leaking event - listeners, amongst other weirdness. -* New feature: Template items can have default values that will be used if no - value was otherwise passed in. - -### v2.5.3 - -* Default to `enabled` only if we have a tty. Users can always override - this by passing in the `enabled` option explicitly or by calling calling - `gauge.enable()`. - -### v2.5.2 - -* Externalized `./console-strings.js` into `console-control-strings`. - -### v2.5.1 - -* Update to `signal-exit@3.0.0`, which fixes a compatibility bug with the - node profiler. -* [#39](https://github.com/iarna/gauge/pull/39) Fix tests on 0.10 and add - a missing devDependency. ([@helloyou2012](https://github.com/helloyou2012)) - -### v2.5.0 - -* Add way to programmatically fetch a list of theme names in a themeset - (`Themeset.getThemeNames`). - -### v2.4.0 - -* Add support for setting themesets on existing gauge objects. -* Add post-IO callback to `gauge.hide()` as it is somtetimes necessary when - your terminal is interleaving output from multiple filehandles (ie, stdout - & stderr). - -### v2.3.1 - -* Fix a refactor bug in setTheme where it wasn't accepting the various types - of args it should. - -### v2.3.0 - -#### FEATURES - -* Add setTemplate & setTheme back in. -* Add support for named themes, you can now ask for things like 'colorASCII' - and 'brailleSpinner'. Of course, you can still pass in theme objects. - Additionally you can now pass in an object with `hasUnicode`, `hasColor` and - `platform` keys in order to override our guesses as to those values when - selecting a default theme from the themeset. -* Make the output stream optional (it defaults to `process.stderr` now). -* Add `setWriteTo(stream[, tty])` to change the output stream and, - optionally, tty. - -#### BUG FIXES & REFACTORING - -* Abort the display phase early if we're supposed to be hidden and we are. -* Stop printing a bunch of spaces at the end of lines, since we're already - using an erase-to-end-of-line code anyway. -* The unicode themes were missing the subsection separator. - -### v2.2.1 - -* Fix image in readme - -### v2.2.0 - -* All new themes API– reference themes by name and pass in custom themes and - themesets (themesets get platform support autodetection done on them to - select the best theme). Theme mixins let you add features to all existing - themes. -* Much, much improved test coverage. - -### v2.1.0 - -* Got rid of ░ in the default platform, noUnicode, hasColor theme. Thanks - to @yongtw123 for pointing out this had snuck in. -* Fiddled with the demo output to make it easier to see the spinner spin. Also - added prints before each platforms test output. -* I forgot to include `signal-exit` in our deps. <.< Thank you @KenanY for - finding this. Then I was lazy and made a new commit instead of using his - PR. Again, thank you for your patience @KenenY. -* Drastically speed up travis testing. -* Add a small javascript demo (demo.js) for showing off the various themes - (and testing them on diff platforms). -* Change: The subsection separator from ⁄ and / (different chars) to >. -* Fix crasher: A show or pulse without a label would cause the template renderer - to complain about a missing value. -* New feature: Add the ability to disable the clean-up-on-exit behavior. - Not something I expect to be widely desirable, but important if you have - multiple distinct gauge instances in your app. -* Use our own color support detection. - The `has-color` module proved too magic for my needs, making assumptions - as to which stream we write to and reading command line arguments. - -### v2.0.0 - -This is a major rewrite of the internals. Externally there are fewer -changes: - -* On node>0.8 gauge object now prints updates at a fixed rate. This means - that when you call `show` it may wate up to `updateInterval` ms before it - actually prints an update. You override this behavior with the - `fixedFramerate` option. -* The gauge object now keeps the cursor hidden as long as it's enabled and - shown. -* The constructor's arguments have changed, now it takes a mandatory output - stream and an optional options object. The stream no longer needs to be - an `ansi`ified stream, although it can be if you want (but we won't make - use of its special features). -* Previously the gauge was disabled by default if `process.stdout` wasn't a - tty. Now it always defaults to enabled. If you want the previous - behavior set the `enabled` option to `process.stdout.isTTY`. -* The constructor's options have changed– see the docs for details. -* Themes are entirely different. If you were using a custom theme, or - referring to one directly (eg via `Gauge.unicode` or `Gauge.ascii`) then - you'll need to change your code. You can get the equivalent of the latter - with: - ``` - var themes = require('gauge/themes') - var unicodeTheme = themes(true, true) // returns the color unicode theme for your platform - ``` - The default themes no longer use any ambiguous width characters, so even - if you choose to display those as wide your progress bar should still - display correctly. -* Templates are entirely different and if you were using a custom one, you - should consult the documentation to learn how to recreate it. If you were - using the default, be aware that it has changed and the result looks quite - a bit different. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/LICENSE deleted file mode 100644 index e756052969b780..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2014, Rebecca Turner - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/README.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/README.md deleted file mode 100644 index bf87d189f1b5c1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/README.md +++ /dev/null @@ -1,395 +0,0 @@ -gauge -===== - -A nearly stateless terminal based horizontal gauge / progress bar. - -```javascript -var Gauge = require("gauge") - -var gauge = new Gauge() - -gauge.show("test", 0.20) - -gauge.pulse("this") - -gauge.hide() -``` - -![](gauge-demo.gif) - - -### CHANGES FROM 1.x - -Gauge 2.x is breaking release, please see the [changelog] for details on -what's changed if you were previously a user of this module. - -[changelog]: CHANGELOG.md - -### THE GAUGE CLASS - -This is the typical interface to the module– it provides a pretty -fire-and-forget interface to displaying your status information. - -``` -var Gauge = require("gauge") - -var gauge = new Gauge([stream], [options]) -``` - -* **stream** – *(optional, default STDERR)* A stream that progress bar - updates are to be written to. Gauge honors backpressure and will pause - most writing if it is indicated. -* **options** – *(optional)* An option object. - -Constructs a new gauge. Gauges are drawn on a single line, and are not drawn -if **stream** isn't a tty and a tty isn't explicitly provided. - -If **stream** is a terminal or if you pass in **tty** to **options** then we -will detect terminal resizes and redraw to fit. We do this by watching for -`resize` events on the tty. (To work around a bug in verisons of Node prior -to 2.5.0, we watch for them on stdout if the tty is stderr.) Resizes to -larger window sizes will be clean, but shrinking the window will always -result in some cruft. - -**IMPORTANT:** If you prevously were passing in a non-tty stream but you still -want output (for example, a stream wrapped by the `ansi` module) then you -need to pass in the **tty** option below, as `gauge` needs access to -the underlying tty in order to do things like terminal resizes and terminal -width detection. - -The **options** object can have the following properties, all of which are -optional: - -* **updateInterval**: How often gauge updates should be drawn, in miliseconds. -* **fixedFramerate**: Defaults to false on node 0.8, true on everything - else. When this is true a timer is created to trigger once every - `updateInterval` ms, when false, updates are printed as soon as they come - in but updates more often than `updateInterval` are ignored. The reason - 0.8 doesn't have this set to true is that it can't `unref` its timer and - so it would stop your program from exiting– if you want to use this - feature with 0.8 just make sure you call `gauge.disable()` before you - expect your program to exit. -* **themes**: A themeset to use when selecting the theme to use. Defaults - to `gauge/themes`, see the [themes] documentation for details. -* **theme**: Select a theme for use, it can be a: - * Theme object, in which case the **themes** is not used. - * The name of a theme, which will be looked up in the current *themes* - object. - * A configuration object with any of `hasUnicode`, `hasColor` or - `platform` keys, which if wlll be used to override our guesses when making - a default theme selection. - - If no theme is selected then a default is picked using a combination of our - best guesses at your OS, color support and unicode support. -* **template**: Describes what you want your gauge to look like. The - default is what npm uses. Detailed [documentation] is later in this - document. -* **hideCursor**: Defaults to true. If true, then the cursor will be hidden - while the gauge is displayed. -* **tty**: The tty that you're ultimately writing to. Defaults to the same - as **stream**. This is used for detecting the width of the terminal and - resizes. The width used is `tty.columns - 1`. If no tty is available then - a width of `79` is assumed. -* **enabled**: Defaults to true if `tty` is a TTY, false otherwise. If true - the gauge starts enabled. If disabled then all update commands are - ignored and no gauge will be printed until you call `.enable()`. -* **Plumbing**: The class to use to actually generate the gauge for - printing. This defaults to `require('gauge/plumbing')` and ordinarly you - shouldn't need to override this. -* **cleanupOnExit**: Defaults to true. Ordinarily we register an exit - handler to make sure your cursor is turned back on and the progress bar - erased when your process exits, even if you Ctrl-C out or otherwise exit - unexpectedly. You can disable this and it won't register the exit handler. - -[has-unicode]: https://www.npmjs.com/package/has-unicode -[themes]: #themes -[documentation]: #templates - -#### `gauge.show(section | status, [completed])` - -The first argument is either the section, the name of the current thing -contributing to progress, or an object with keys like **section**, -**subsection** & **completed** (or any others you have types for in a custom -template). If you don't want to update or set any of these you can pass -`null` and it will be ignored. - -The second argument is the percent completed as a value between 0 and 1. -Without it, completion is just not updated. You'll also note that completion -can be passed in as part of a status object as the first argument. If both -it and the completed argument are passed in, the completed argument wins. - -#### `gauge.hide([cb])` - -Removes the gauge from the terminal. Optionally, callback `cb` after IO has -had an opportunity to happen (currently this just means after `setImmediate` -has called back.) - -It turns out this is important when you're pausing the progress bar on one -filehandle and printing to another– otherwise (with a big enough print) node -can end up printing the "end progress bar" bits to the progress bar filehandle -while other stuff is printing to another filehandle. These getting interleaved -can cause corruption in some terminals. - -#### `gauge.pulse([subsection])` - -* **subsection** – *(optional)* The specific thing that triggered this pulse - -Spins the spinner in the gauge to show output. If **subsection** is -included then it will be combined with the last name passed to `gauge.show`. - -#### `gauge.disable()` - -Hides the gauge and ignores further calls to `show` or `pulse`. - -#### `gauge.enable()` - -Shows the gauge and resumes updating when `show` or `pulse` is called. - -#### `gauge.setThemeset(themes)` - -Change the themeset to select a theme from. The same as the `themes` option -used in the constructor. The theme will be reselected from this themeset. - -#### `gauge.setTheme(theme)` - -Change the active theme, will be displayed with the next show or pulse. This can be: - -* Theme object, in which case the **themes** is not used. -* The name of a theme, which will be looked up in the current *themes* - object. -* A configuration object with any of `hasUnicode`, `hasColor` or - `platform` keys, which if wlll be used to override our guesses when making - a default theme selection. - -If no theme is selected then a default is picked using a combination of our -best guesses at your OS, color support and unicode support. - -#### `gauge.setTemplate(template)` - -Change the active template, will be displayed with the next show or pulse - -### Tracking Completion - -If you have more than one thing going on that you want to track completion -of, you may find the related [are-we-there-yet] helpful. It's `change` -event can be wired up to the `show` method to get a more traditional -progress bar interface. - -[are-we-there-yet]: https://www.npmjs.com/package/are-we-there-yet - -### THEMES - -``` -var themes = require('gauge/themes') - -// fetch the default color unicode theme for this platform -var ourTheme = themes({hasUnicode: true, hasColor: true}) - -// fetch the default non-color unicode theme for osx -var ourTheme = themes({hasUnicode: true, hasColor: false, platform: 'darwin'}) - -// create a new theme based on the color ascii theme for this platform -// that brackets the progress bar with arrows -var ourTheme = themes.newTheme(theme(hasUnicode: false, hasColor: true}), { - preProgressbar: '→', - postProgressbar: '←' -}) -``` - -The object returned by `gauge/themes` is an instance of the `ThemeSet` class. - -``` -var ThemeSet = require('gauge/theme-set') -var themes = new ThemeSet() -// or -var themes = require('gauge/themes') -var mythemes = themes.newThemeset() // creates a new themeset based on the default themes -``` - -#### themes(opts) -#### themes.getDefault(opts) - -Theme objects are a function that fetches the default theme based on -platform, unicode and color support. - -Options is an object with the following properties: - -* **hasUnicode** - If true, fetch a unicode theme, if no unicode theme is - available then a non-unicode theme will be used. -* **hasColor** - If true, fetch a color theme, if no color theme is - available a non-color theme will be used. -* **platform** (optional) - Defaults to `process.platform`. If no - platform match is available then `fallback` is used instead. - -If no compatible theme can be found then an error will be thrown with a -`code` of `EMISSINGTHEME`. - -#### themes.addTheme(themeName, themeObj) -#### themes.addTheme(themeName, [parentTheme], newTheme) - -Adds a named theme to the themeset. You can pass in either a theme object, -as returned by `themes.newTheme` or the arguments you'd pass to -`themes.newTheme`. - -#### themes.getThemeNames() - -Return a list of all of the names of the themes in this themeset. Suitable -for use in `themes.getTheme(…)`. - -#### themes.getTheme(name) - -Returns the theme object from this theme set named `name`. - -If `name` does not exist in this themeset an error will be thrown with -a `code` of `EMISSINGTHEME`. - -#### themes.setDefault([opts], themeName) - -`opts` is an object with the following properties. - -* **platform** - Defaults to `'fallback'`. If your theme is platform - specific, specify that here with the platform from `process.platform`, eg, - `win32`, `darwin`, etc. -* **hasUnicode** - Defaults to `false`. If your theme uses unicode you - should set this to true. -* **hasColor** - Defaults to `false`. If your theme uses color you should - set this to true. - -`themeName` is the name of the theme (as given to `addTheme`) to use for -this set of `opts`. - -#### themes.newTheme([parentTheme,] newTheme) - -Create a new theme object based on `parentTheme`. If no `parentTheme` is -provided then a minimal parentTheme that defines functions for rendering the -activity indicator (spinner) and progress bar will be defined. (This -fallback parent is defined in `gauge/base-theme`.) - -newTheme should be a bare object– we'll start by discussing the properties -defined by the default themes: - -* **preProgressbar** - displayed prior to the progress bar, if the progress - bar is displayed. -* **postProgressbar** - displayed after the progress bar, if the progress bar - is displayed. -* **progressBarTheme** - The subtheme passed through to the progress bar - renderer, it's an object with `complete` and `remaining` properties - that are the strings you want repeated for those sections of the progress - bar. -* **activityIndicatorTheme** - The theme for the activity indicator (spinner), - this can either be a string, in which each character is a different step, or - an array of strings. -* **preSubsection** - Displayed as a separator between the `section` and - `subsection` when the latter is printed. - -More generally, themes can have any value that would be a valid value when rendering -templates. The properties in the theme are used when their name matches a type in -the template. Their values can be: - -* **strings & numbers** - They'll be included as is -* **function (values, theme, width)** - Should return what you want in your output. - *values* is an object with values provided via `gauge.show`, - *theme* is the theme specific to this item (see below) or this theme object, - and *width* is the number of characters wide your result should be. - -There are a couple of special prefixes: - -* **pre** - Is shown prior to the property, if its displayed. -* **post** - Is shown after the property, if its displayed. - -And one special suffix: - -* **Theme** - Its value is passed to a function-type item as the theme. - -#### themes.addToAllThemes(theme) - -This *mixes-in* `theme` into all themes currently defined. It also adds it -to the default parent theme for this themeset, so future themes added to -this themeset will get the values from `theme` by default. - -#### themes.newThemeset() - -Copy the current themeset into a new one. This allows you to easily inherit -one themeset from another. - -### TEMPLATES - -A template is an array of objects and strings that, after being evaluated, -will be turned into the gauge line. The default template is: - -```javascript -[ - {type: 'progressbar', length: 20}, - {type: 'activityIndicator', kerning: 1, length: 1}, - {type: 'section', kerning: 1, default: ''}, - {type: 'subsection', kerning: 1, default: ''} -] -``` - -The various template elements can either be **plain strings**, in which case they will -be be included verbatum in the output, or objects with the following properties: - -* *type* can be any of the following plus any keys you pass into `gauge.show` plus - any keys you have on a custom theme. - * `section` – What big thing you're working on now. - * `subsection` – What component of that thing is currently working. - * `activityIndicator` – Shows a spinner using the `activityIndicatorTheme` - from your active theme. - * `progressbar` – A progress bar representing your current `completed` - using the `progressbarTheme` from your active theme. -* *kerning* – Number of spaces that must be between this item and other - items, if this item is displayed at all. -* *maxLength* – The maximum length for this element. If its value is longer it - will be truncated. -* *minLength* – The minimum length for this element. If its value is shorter it - will be padded according to the *align* value. -* *align* – (Default: left) Possible values "left", "right" and "center". Works - as you'd expect from word processors. -* *length* – Provides a single value for both *minLength* and *maxLength*. If both - *length* and *minLength or *maxLength* are specifed then the latter take precedence. -* *value* – A literal value to use for this template item. -* *default* – A default value to use for this template item if a value - wasn't otherwise passed in. - -### PLUMBING - -This is the super simple, assume nothing, do no magic internals used by gauge to -implement its ordinary interface. - -``` -var Plumbing = require('gauge/plumbing') -var gauge = new Plumbing(theme, template, width) -``` - -* **theme**: The theme to use. -* **template**: The template to use. -* **width**: How wide your gauge should be - -#### `gauge.setTheme(theme)` - -Change the active theme. - -#### `gauge.setTemplate(template)` - -Change the active template. - -#### `gauge.setWidth(width)` - -Change the width to render at. - -#### `gauge.hide()` - -Return the string necessary to hide the progress bar - -#### `gauge.hideCursor()` - -Return a string to hide the cursor. - -#### `gauge.showCursor()` - -Return a string to show the cursor. - -#### `gauge.show(status)` - -Using `status` for values, render the provided template with the theme and return -a string that is suitable for printing to update the gauge. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/base-theme.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/base-theme.js deleted file mode 100644 index 0b67638e0211d0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/base-theme.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict' -var spin = require('./spin.js') -var progressBar = require('./progress-bar.js') - -module.exports = { - activityIndicator: function (values, theme, width) { - if (values.spun == null) return - return spin(theme, values.spun) - }, - progressbar: function (values, theme, width) { - if (values.completed == null) return - return progressBar(theme, width, values.completed) - } -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/error.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/error.js deleted file mode 100644 index d9914ba5335d25..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/error.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict' -var util = require('util') - -var User = exports.User = function User (msg) { - var err = new Error(msg) - Error.captureStackTrace(err, User) - err.code = 'EGAUGE' - return err -} - -exports.MissingTemplateValue = function MissingTemplateValue (item, values) { - var err = new User(util.format('Missing template value "%s"', item.type)) - Error.captureStackTrace(err, MissingTemplateValue) - err.template = item - err.values = values - return err -} - -exports.Internal = function Internal (msg) { - var err = new Error(msg) - Error.captureStackTrace(err, Internal) - err.code = 'EGAUGEINTERNAL' - return err -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/has-color.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/has-color.js deleted file mode 100644 index e283a256f26b74..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/has-color.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict' - -module.exports = isWin32() || isColorTerm() - -function isWin32 () { - return process.platform === 'win32' -} - -function isColorTerm () { - var termHasColor = /^screen|^xterm|^vt100|color|ansi|cygwin|linux/i - return !!process.env.COLORTERM || termHasColor.test(process.env.TERM) -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/index.js deleted file mode 100644 index 7eefb9507bb47e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/index.js +++ /dev/null @@ -1,226 +0,0 @@ -'use strict' -var Plumbing = require('./plumbing.js') -var hasUnicode = require('has-unicode') -var hasColor = require('./has-color.js') -var onExit = require('signal-exit') -var defaultThemes = require('./themes') -var setInterval = require('./set-interval.js') -var process = require('./process.js') -var setImmediate = require('./set-immediate') - -module.exports = Gauge - -function callWith (obj, method) { - return function () { - return method.call(obj) - } -} - -function Gauge (arg1, arg2) { - var options, writeTo - if (arg1 && arg1.write) { - writeTo = arg1 - options = arg2 || {} - } else if (arg2 && arg2.write) { - writeTo = arg2 - options = arg1 || {} - } else { - writeTo = process.stderr - options = arg1 || arg2 || {} - } - - this._status = { - spun: 0, - section: '', - subsection: '' - } - this._paused = false // are we paused for back pressure? - this._disabled = true // are all progress bar updates disabled? - this._showing = false // do we WANT the progress bar on screen - this._onScreen = false // IS the progress bar on screen - this._needsRedraw = false // should we print something at next tick? - this._hideCursor = options.hideCursor == null ? true : options.hideCursor - this._fixedFramerate = options.fixedFramerate == null - ? !(/^v0\.8\./.test(process.version)) - : options.fixedFramerate - this._lastUpdateAt = null - this._updateInterval = options.updateInterval == null ? 50 : options.updateInterval - - this._themes = options.themes || defaultThemes - this._theme = options.theme - var theme = this._computeTheme(options.theme) - var template = options.template || [ - {type: 'progressbar', length: 20}, - {type: 'activityIndicator', kerning: 1, length: 1}, - {type: 'section', kerning: 1, default: ''}, - {type: 'subsection', kerning: 1, default: ''} - ] - this.setWriteTo(writeTo, options.tty) - var PlumbingClass = options.Plumbing || Plumbing - this._gauge = new PlumbingClass(theme, template, this.getWidth()) - - this._$$doRedraw = callWith(this, this._doRedraw) - this._$$handleSizeChange = callWith(this, this._handleSizeChange) - - if (options.cleanupOnExit == null || options.cleanupOnExit) { - onExit(callWith(this, this.disable)) - } - - if (options.enabled || (options.enabled == null && this._tty && this._tty.isTTY)) { - this.enable() - } else { - this.disable() - } -} -Gauge.prototype = {} - -Gauge.prototype.setTemplate = function (template) { - this._gauge.setTemplate(template) - if (this._showing) this._requestRedraw() -} - -Gauge.prototype._computeTheme = function (theme) { - if (!theme) theme = {} - if (theme && (Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null)) { - var useUnicode = theme.hasUnicode == null ? hasUnicode() : theme.hasUnicode - var useColor = theme.hasColor == null ? hasColor : theme.hasColor - theme = this._themes.getDefault({hasUnicode: useUnicode, hasColor: useColor, platform: theme.platform}) - } else if (typeof theme === 'string') { - theme = this._themes.getTheme(theme) - } - return theme -} - -Gauge.prototype.setThemeset = function (themes) { - this._themes = themes - this.setTheme(this._theme) -} - -Gauge.prototype.setTheme = function (theme) { - this._gauge.setTheme(this._computeTheme(theme)) - if (this._showing) this._requestRedraw() - this._theme = theme -} - -Gauge.prototype._requestRedraw = function () { - this._needsRedraw = true - if (!this._fixedFramerate) this._doRedraw() -} - -Gauge.prototype.getWidth = function () { - return ((this._tty && this._tty.columns) || 80) - 1 -} - -Gauge.prototype.setWriteTo = function (writeTo, tty) { - var enabled = !this._disabled - if (enabled) this.disable() - this._writeTo = writeTo - this._tty = tty || - (writeTo === process.stderr && process.stdout.isTTY && process.stdout) || - (writeTo.isTTY && writeTo) || - this._tty - if (this._gauge) this._gauge.setWidth(this.getWidth()) - if (enabled) this.enable() -} - -Gauge.prototype.enable = function () { - if (!this._disabled) return - this._disabled = false - if (this._tty) this._enableEvents() - if (this._showing) this.show() -} - -Gauge.prototype.disable = function () { - if (this._disabled) return - if (this._showing) { - this._lastUpdateAt = null - this._showing = false - this._doRedraw() - this._showing = true - } - this._disabled = true - if (this._tty) this._disableEvents() -} - -Gauge.prototype._enableEvents = function () { - this._tty.on('resize', this._$$handleSizeChange) - if (this._fixedFramerate) { - this.redrawTracker = setInterval(this._$$doRedraw, this._updateInterval) - if (this.redrawTracker.unref) this.redrawTracker.unref() - } -} - -Gauge.prototype._disableEvents = function () { - this._tty.removeListener('resize', this._$$handleSizeChange) - if (this._fixedFramerate) clearInterval(this.redrawTracker) -} - -Gauge.prototype.hide = function (cb) { - if (this._disabled) return cb && process.nextTick(cb) - if (!this._showing) return cb && process.nextTick(cb) - this._showing = false - this._doRedraw() - cb && setImmediate(cb) -} - -Gauge.prototype.show = function (section, completed) { - if (this._disabled) return - this._showing = true - if (typeof section === 'string') { - this._status.section = section - } else if (typeof section === 'object') { - var sectionKeys = Object.keys(section) - for (var ii = 0; ii < sectionKeys.length; ++ii) { - var key = sectionKeys[ii] - this._status[key] = section[key] - } - } - if (completed != null) this._status.completed = completed - this._requestRedraw() -} - -Gauge.prototype.pulse = function (subsection) { - if (this._disabled) return - if (!this._showing) return - this._status.subsection = subsection || '' - this._status.spun ++ - this._requestRedraw() -} - -Gauge.prototype._handleSizeChange = function () { - this._gauge.setWidth(this._tty.columns - 1) - this._requestRedraw() -} - -Gauge.prototype._doRedraw = function () { - if (this._disabled || this._paused) return - if (!this._fixedFramerate) { - var now = Date.now() - if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) return - this._lastUpdateAt = now - } - if (!this._showing && this._onScreen) { - this._onScreen = false - var result = this._gauge.hide() - if (this._hideCursor) { - result += this._gauge.showCursor() - } - return this._writeTo.write(result) - } - if (!this._showing && !this._onScreen) return - if (this._showing && !this._onScreen) { - this._onScreen = true - this._needsRedraw = true - if (this._hideCursor) { - this._writeTo.write(this._gauge.hideCursor()) - } - } - if (!this._needsRedraw) return - if (!this._writeTo.write(this._gauge.show(this._status))) { - this._paused = true - this._writeTo.on('drain', callWith(this, function () { - this._paused = false - this._doRedraw() - })) - } -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-color/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-color/package.json deleted file mode 100644 index 7ca2bd4e108122..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-color/package.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "has-color@^0.1.7", - "scope": null, - "escapedName": "has-color", - "name": "has-color", - "rawSpec": "^0.1.7", - "spec": ">=0.1.7 <0.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge" - ], - [ - { - "raw": "has-color@^0.1.7", - "scope": null, - "escapedName": "has-color", - "name": "has-color", - "rawSpec": "^0.1.7", - "spec": ">=0.1.7 <0.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "has-color@^0.1.7", - "_id": "has-color@0.1.7", - "_inCache": true, - "_location": "/node-gyp/npmlog/gauge/has-color", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "1.4.6", - "_phantomChildren": {}, - "_requested": { - "raw": "has-color@^0.1.7", - "scope": null, - "escapedName": "has-color", - "name": "has-color", - "rawSpec": "^0.1.7", - "spec": ">=0.1.7 <0.2.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz", - "_shasum": "67144a5260c34fc3cca677d041daf52fe7b78b2f", - "_shrinkwrap": null, - "_spec": "has-color@^0.1.7", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "http://sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/has-color/issues" - }, - "dependencies": {}, - "description": "Detect whether a terminal supports color", - "devDependencies": { - "mocha": "*" - }, - "directories": {}, - "dist": { - "shasum": "67144a5260c34fc3cca677d041daf52fe7b78b2f", - "tarball": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "homepage": "https://github.com/sindresorhus/has-color", - "keywords": [ - "color", - "colour", - "colors", - "terminal", - "console", - "cli", - "ansi", - "styles", - "tty", - "rgb", - "256", - "shell", - "xterm", - "command-line", - "support", - "capability", - "detect" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "has-color", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/sindresorhus/has-color.git" - }, - "scripts": { - "test": "mocha" - }, - "version": "0.1.7" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-color/readme.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-color/readme.md deleted file mode 100644 index 37bbd8991a6423..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-color/readme.md +++ /dev/null @@ -1,30 +0,0 @@ -# has-color [![Build Status](https://travis-ci.org/sindresorhus/has-color.svg?branch=master)](https://travis-ci.org/sindresorhus/has-color) - -> Detect whether a terminal supports color. - -Used in the terminal color module [chalk](https://github.com/sindresorhus/chalk). - - -## Install - -```bash -$ npm install --save has-color -``` - - -## Usage - -```js -var hasColor = require('has-color'); - -if (hasColor) { - console.log('Terminal supports color.'); -} -``` - -It obeys the `--color` and `--no-color` CLI flags. - - -## License - -[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/index.js deleted file mode 100644 index 508504840dc61d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/index.js +++ /dev/null @@ -1,83 +0,0 @@ -'use strict'; -/* eslint-disable no-unused-vars */ -var hasOwnProperty = Object.prototype.hasOwnProperty; -var propIsEnumerable = Object.prototype.propertyIsEnumerable; - -function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); -} - -function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (e) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } -} - -module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (Object.getOwnPropertySymbols) { - symbols = Object.getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - - return to; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/package.json deleted file mode 100644 index ed10c835989889..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/package.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "object-assign@^4.1.0", - "scope": null, - "escapedName": "object-assign", - "name": "object-assign", - "rawSpec": "^4.1.0", - "spec": ">=4.1.0 <5.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge" - ], - [ - { - "raw": "object-assign@^4.1.0", - "scope": null, - "escapedName": "object-assign", - "name": "object-assign", - "rawSpec": "^4.1.0", - "spec": ">=4.1.0 <5.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "object-assign@^4.1.0", - "_id": "object-assign@4.1.0", - "_inCache": true, - "_location": "/node-gyp/npmlog/gauge/object-assign", - "_nodeVersion": "4.1.0", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/object-assign-4.1.0.tgz_1462212593641_0.3332549517508596" - }, - "_npmUser": { - "name": "spicyj", - "email": "ben@benalpert.com" - }, - "_npmVersion": "2.14.19", - "_phantomChildren": {}, - "_requested": { - "raw": "object-assign@^4.1.0", - "scope": null, - "escapedName": "object-assign", - "name": "object-assign", - "rawSpec": "^4.1.0", - "spec": ">=4.1.0 <5.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", - "_shasum": "7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0", - "_shrinkwrap": null, - "_spec": "object-assign@^4.1.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/object-assign/issues" - }, - "dependencies": {}, - "description": "ES2015 Object.assign() ponyfill", - "devDependencies": { - "lodash": "^4.8.2", - "matcha": "^0.7.0", - "mocha": "*", - "xo": "*" - }, - "directories": {}, - "dist": { - "shasum": "7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0", - "tarball": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "72fe21c86911758f3342fdf41c2a57860d5829bc", - "homepage": "https://github.com/sindresorhus/object-assign#readme", - "keywords": [ - "object", - "assign", - "extend", - "properties", - "es2015", - "ecmascript", - "harmony", - "ponyfill", - "prollyfill", - "polyfill", - "shim", - "browser" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - { - "name": "spicyj", - "email": "ben@benalpert.com" - } - ], - "name": "object-assign", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/object-assign.git" - }, - "scripts": { - "bench": "matcha bench.js", - "test": "xo && mocha" - }, - "version": "4.1.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/readme.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/readme.md deleted file mode 100644 index 13c097734cfd18..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/readme.md +++ /dev/null @@ -1,56 +0,0 @@ -# object-assign [![Build Status](https://travis-ci.org/sindresorhus/object-assign.svg?branch=master)](https://travis-ci.org/sindresorhus/object-assign) - -> ES2015 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill - -> Ponyfill: A polyfill that doesn't overwrite the native method - - -## Install - -``` -$ npm install --save object-assign -``` - - -## Usage - -```js -const objectAssign = require('object-assign'); - -objectAssign({foo: 0}, {bar: 1}); -//=> {foo: 0, bar: 1} - -// multiple sources -objectAssign({foo: 0}, {bar: 1}, {baz: 2}); -//=> {foo: 0, bar: 1, baz: 2} - -// overwrites equal keys -objectAssign({foo: 0}, {foo: 1}, {foo: 2}); -//=> {foo: 2} - -// ignores null and undefined sources -objectAssign({foo: 0}, null, {bar: 1}, undefined); -//=> {foo: 0, bar: 1} -``` - - -## API - -### objectAssign(target, source, [source, ...]) - -Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones. - - -## Resources - -- [ES2015 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) - - -## Related - -- [deep-assign](https://github.com/sindresorhus/deep-assign) - Recursive `Object.assign()` - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/CHANGELOG.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/CHANGELOG.md deleted file mode 100644 index e2f70d22503634..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/CHANGELOG.md +++ /dev/null @@ -1,27 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - - -## [3.0.1](https://github.com/tapjs/signal-exit/compare/v3.0.0...v3.0.1) (2016-09-08) - - -### Bug Fixes - -* do not listen on SIGBUS, SIGFPE, SIGSEGV and SIGILL ([#40](https://github.com/tapjs/signal-exit/issues/40)) ([5b105fb](https://github.com/tapjs/signal-exit/commit/5b105fb)) - - - - -# [3.0.0](https://github.com/tapjs/signal-exit/compare/v2.1.2...v3.0.0) (2016-06-13) - - -### Bug Fixes - -* get our test suite running on Windows ([#23](https://github.com/tapjs/signal-exit/issues/23)) ([6f3eda8](https://github.com/tapjs/signal-exit/commit/6f3eda8)) -* hooking SIGPROF was interfering with profilers see [#21](https://github.com/tapjs/signal-exit/issues/21) ([#24](https://github.com/tapjs/signal-exit/issues/24)) ([1248a4c](https://github.com/tapjs/signal-exit/commit/1248a4c)) - - -### BREAKING CHANGES - -* signal-exit no longer wires into SIGPROF diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/LICENSE.txt b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/LICENSE.txt deleted file mode 100644 index eead04a12162dc..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/LICENSE.txt +++ /dev/null @@ -1,16 +0,0 @@ -The ISC License - -Copyright (c) 2015, Contributors - -Permission to use, copy, modify, and/or distribute this software -for any purpose with or without fee is hereby granted, provided -that the above copyright notice and this permission notice -appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE -LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES -OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/README.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/README.md deleted file mode 100644 index 8ebccabecaea4c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# signal-exit - -[![Build Status](https://travis-ci.org/tapjs/signal-exit.png)](https://travis-ci.org/tapjs/signal-exit) -[![Coverage](https://coveralls.io/repos/tapjs/signal-exit/badge.svg?branch=master)](https://coveralls.io/r/tapjs/signal-exit?branch=master) -[![NPM version](https://img.shields.io/npm/v/signal-exit.svg)](https://www.npmjs.com/package/signal-exit) -[![Windows Tests](https://img.shields.io/appveyor/ci/bcoe/signal-exit/master.svg?label=Windows%20Tests)](https://ci.appveyor.com/project/bcoe/signal-exit) -[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version) - -When you want to fire an event no matter how a process exits: - -* reaching the end of execution. -* explicitly having `process.exit(code)` called. -* having `process.kill(pid, sig)` called. -* receiving a fatal signal from outside the process - -Use `signal-exit`. - -```js -var onExit = require('signal-exit') - -onExit(function (code, signal) { - console.log('process exited!') -}) -``` - -## API - -`var remove = onExit(function (code, signal) {}, options)` - -The return value of the function is a function that will remove the -handler. - -Note that the function *only* fires for signals if the signal would -cause the proces to exit. That is, there are no other listeners, and -it is a fatal signal. - -## Options - -* `alwaysLast`: Run this handler after any other signal or exit - handlers. This causes `process.emit` to be monkeypatched. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js deleted file mode 100644 index 7dd8d917dc507b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js +++ /dev/null @@ -1,148 +0,0 @@ -// Note: since nyc uses this module to output coverage, any lines -// that are in the direct sync flow of nyc's outputCoverage are -// ignored, since we can never get coverage for them. -var assert = require('assert') -var signals = require('./signals.js') - -var EE = require('events') -/* istanbul ignore if */ -if (typeof EE !== 'function') { - EE = EE.EventEmitter -} - -var emitter -if (process.__signal_exit_emitter__) { - emitter = process.__signal_exit_emitter__ -} else { - emitter = process.__signal_exit_emitter__ = new EE() - emitter.count = 0 - emitter.emitted = {} -} - -module.exports = function (cb, opts) { - assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler') - - if (loaded === false) { - load() - } - - var ev = 'exit' - if (opts && opts.alwaysLast) { - ev = 'afterexit' - } - - var remove = function () { - emitter.removeListener(ev, cb) - if (emitter.listeners('exit').length === 0 && - emitter.listeners('afterexit').length === 0) { - unload() - } - } - emitter.on(ev, cb) - - return remove -} - -module.exports.unload = unload -function unload () { - if (!loaded) { - return - } - loaded = false - - signals.forEach(function (sig) { - try { - process.removeListener(sig, sigListeners[sig]) - } catch (er) {} - }) - process.emit = originalProcessEmit - process.reallyExit = originalProcessReallyExit - emitter.count -= 1 -} - -function emit (event, code, signal) { - if (emitter.emitted[event]) { - return - } - emitter.emitted[event] = true - emitter.emit(event, code, signal) -} - -// { : , ... } -var sigListeners = {} -signals.forEach(function (sig) { - sigListeners[sig] = function listener () { - // If there are no other listeners, an exit is coming! - // Simplest way: remove us and then re-send the signal. - // We know that this will kill the process, so we can - // safely emit now. - var listeners = process.listeners(sig) - if (listeners.length === emitter.count) { - unload() - emit('exit', null, sig) - /* istanbul ignore next */ - emit('afterexit', null, sig) - /* istanbul ignore next */ - process.kill(process.pid, sig) - } - } -}) - -module.exports.signals = function () { - return signals -} - -module.exports.load = load - -var loaded = false - -function load () { - if (loaded) { - return - } - loaded = true - - // This is the number of onSignalExit's that are in play. - // It's important so that we can count the correct number of - // listeners on signals, and don't wait for the other one to - // handle it instead of us. - emitter.count += 1 - - signals = signals.filter(function (sig) { - try { - process.on(sig, sigListeners[sig]) - return true - } catch (er) { - return false - } - }) - - process.emit = processEmit - process.reallyExit = processReallyExit -} - -var originalProcessReallyExit = process.reallyExit -function processReallyExit (code) { - process.exitCode = code || 0 - emit('exit', process.exitCode, null) - /* istanbul ignore next */ - emit('afterexit', process.exitCode, null) - /* istanbul ignore next */ - originalProcessReallyExit.call(process, process.exitCode) -} - -var originalProcessEmit = process.emit -function processEmit (ev, arg) { - if (ev === 'exit') { - if (arg !== undefined) { - process.exitCode = arg - } - var ret = originalProcessEmit.apply(this, arguments) - emit('exit', process.exitCode, null) - /* istanbul ignore next */ - emit('afterexit', process.exitCode, null) - return ret - } else { - return originalProcessEmit.apply(this, arguments) - } -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/package.json deleted file mode 100644 index 697cc40928ac2d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/package.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "signal-exit@^3.0.0", - "scope": null, - "escapedName": "signal-exit", - "name": "signal-exit", - "rawSpec": "^3.0.0", - "spec": ">=3.0.0 <4.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm2/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "signal-exit@>=3.0.0 <4.0.0", - "_id": "signal-exit@3.0.1", - "_inCache": true, - "_location": "/node-gyp/npmlog/gauge/signal-exit", - "_nodeVersion": "6.5.0", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/signal-exit-3.0.1.tgz_1473354783379_0.4592130535747856" - }, - "_npmUser": { - "name": "bcoe", - "email": "ben@npmjs.com" - }, - "_npmVersion": "3.10.3", - "_phantomChildren": {}, - "_requested": { - "raw": "signal-exit@^3.0.0", - "scope": null, - "escapedName": "signal-exit", - "name": "signal-exit", - "rawSpec": "^3.0.0", - "spec": ">=3.0.0 <4.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.1.tgz", - "_shasum": "5a4c884992b63a7acd9badb7894c3ee9cfccad81", - "_shrinkwrap": null, - "_spec": "signal-exit@^3.0.0", - "_where": "/Users/rebecca/code/npm2/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge", - "author": { - "name": "Ben Coe", - "email": "ben@npmjs.com" - }, - "bugs": { - "url": "https://github.com/tapjs/signal-exit/issues" - }, - "dependencies": {}, - "description": "when you want to fire an event no matter how a process exits.", - "devDependencies": { - "chai": "^3.5.0", - "coveralls": "^2.11.10", - "nyc": "^8.1.0", - "standard": "^7.1.2", - "standard-version": "^2.3.0", - "tap": "^7.1.0" - }, - "directories": {}, - "dist": { - "shasum": "5a4c884992b63a7acd9badb7894c3ee9cfccad81", - "tarball": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.1.tgz" - }, - "files": [ - "index.js", - "signals.js" - ], - "gitHead": "6859aff54f5198c63fff91baef279b86026bde69", - "homepage": "https://github.com/tapjs/signal-exit", - "keywords": [ - "signal", - "exit" - ], - "license": "ISC", - "main": "index.js", - "maintainers": [ - { - "name": "bcoe", - "email": "ben@npmjs.com" - }, - { - "name": "isaacs", - "email": "isaacs@npmjs.com" - } - ], - "name": "signal-exit", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/tapjs/signal-exit.git" - }, - "scripts": { - "coverage": "nyc report --reporter=text-lcov | coveralls", - "pretest": "standard", - "release": "standard-version", - "test": "tap --timeout=240 ./test/*.js --cov" - }, - "version": "3.0.1" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/signals.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/signals.js deleted file mode 100644 index 3bd67a8a554e30..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/signals.js +++ /dev/null @@ -1,53 +0,0 @@ -// This is not the set of all possible signals. -// -// It IS, however, the set of all signals that trigger -// an exit on either Linux or BSD systems. Linux is a -// superset of the signal names supported on BSD, and -// the unknown signals just fail to register, so we can -// catch that easily enough. -// -// Don't bother with SIGKILL. It's uncatchable, which -// means that we can't fire any callbacks anyway. -// -// If a user does happen to register a handler on a non- -// fatal signal like SIGWINCH or something, and then -// exit, it'll end up firing `process.emit('exit')`, so -// the handler will be fired anyway. -// -// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised -// artificially, inherently leave the process in a -// state from which it is not safe to try and enter JS -// listeners. -module.exports = [ - 'SIGABRT', - 'SIGALRM', - 'SIGHUP', - 'SIGINT', - 'SIGTERM' -] - -if (process.platform !== 'win32') { - module.exports.push( - 'SIGVTALRM', - 'SIGXCPU', - 'SIGXFSZ', - 'SIGUSR2', - 'SIGTRAP', - 'SIGSYS', - 'SIGQUIT', - 'SIGIOT' - // should detect profiler and enable/disable accordingly. - // see #21 - // 'SIGPROF' - ) -} - -if (process.platform === 'linux') { - module.exports.push( - 'SIGIO', - 'SIGPOLL', - 'SIGPWR', - 'SIGSTKFLT', - 'SIGUNUSED' - ) -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/index.js deleted file mode 100644 index b9bec62440a468..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/index.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; -var stripAnsi = require('strip-ansi'); -var codePointAt = require('code-point-at'); -var isFullwidthCodePoint = require('is-fullwidth-code-point'); - -// https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1345 -module.exports = function (str) { - if (typeof str !== 'string' || str.length === 0) { - return 0; - } - - var width = 0; - - str = stripAnsi(str); - - for (var i = 0; i < str.length; i++) { - var code = codePointAt(str, i); - - // ignore control characters - if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) { - continue; - } - - // surrogates - if (code >= 0x10000) { - i++; - } - - if (isFullwidthCodePoint(code)) { - width += 2; - } else { - width++; - } - } - - return width; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/index.js deleted file mode 100644 index 0335117977237f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/index.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; -var numberIsNan = require('number-is-nan'); - -module.exports = function (str, pos) { - if (str === null || str === undefined) { - throw TypeError(); - } - - str = String(str); - - var size = str.length; - var i = pos ? Number(pos) : 0; - - if (numberIsNan(i)) { - i = 0; - } - - if (i < 0 || i >= size) { - return undefined; - } - - var first = str.charCodeAt(i); - - if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { - var second = str.charCodeAt(i + 1); - - if (second >= 0xDC00 && second <= 0xDFFF) { - return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; - } - } - - return first; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/index.js deleted file mode 100644 index 79be4b9cb8c3bc..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; -module.exports = Number.isNaN || function (x) { - return x !== x; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/package.json deleted file mode 100644 index 44730ebd4101fc..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/package.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at" - ], - [ - { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at" - ] - ], - "_from": "number-is-nan@^1.0.0", - "_id": "number-is-nan@1.0.0", - "_inCache": true, - "_location": "/node-gyp/npmlog/gauge/string-width/code-point-at/number-is-nan", - "_nodeVersion": "0.12.3", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "2.10.0", - "_phantomChildren": {}, - "_requested": { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog/gauge/string-width/code-point-at" - ], - "_resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.0.tgz", - "_shasum": "c020f529c5282adfdd233d91d4b181c3d686dc4b", - "_shrinkwrap": null, - "_spec": "number-is-nan@^1.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/number-is-nan/issues" - }, - "dependencies": {}, - "description": "ES6 Number.isNaN() ponyfill", - "devDependencies": { - "ava": "0.0.4" - }, - "directories": {}, - "dist": { - "shasum": "c020f529c5282adfdd233d91d4b181c3d686dc4b", - "tarball": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.0.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "0f394b1bc33185c40304363b209e3f0588dbeeb3", - "homepage": "https://github.com/sindresorhus/number-is-nan#readme", - "keywords": [ - "es6", - "es2015", - "ecmascript", - "harmony", - "ponyfill", - "polyfill", - "shim", - "number", - "is", - "nan", - "not" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "number-is-nan", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/number-is-nan.git" - }, - "scripts": { - "test": "node test.js" - }, - "version": "1.0.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/readme.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/readme.md deleted file mode 100644 index 93d851a14f1ac5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/readme.md +++ /dev/null @@ -1,30 +0,0 @@ -# number-is-nan [![Build Status](https://travis-ci.org/sindresorhus/number-is-nan.svg?branch=master)](https://travis-ci.org/sindresorhus/number-is-nan) - -> ES6 [`Number.isNaN()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) ponyfill - -> Ponyfill: A polyfill that doesn't overwrite the native method - - -## Install - -``` -$ npm install --save number-is-nan -``` - - -## Usage - -```js -var numberIsNan = require('number-is-nan'); - -numberIsNan(NaN); -//=> true - -numberIsNan('unicorn'); -//=> false -``` - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/package.json deleted file mode 100644 index 2f4b7334796213..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/package.json +++ /dev/null @@ -1,116 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "code-point-at@^1.0.0", - "scope": null, - "escapedName": "code-point-at", - "name": "code-point-at", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge/node_modules/string-width" - ], - [ - { - "raw": "code-point-at@^1.0.0", - "scope": null, - "escapedName": "code-point-at", - "name": "code-point-at", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width" - ] - ], - "_from": "code-point-at@^1.0.0", - "_id": "code-point-at@1.0.0", - "_inCache": true, - "_location": "/node-gyp/npmlog/gauge/string-width/code-point-at", - "_nodeVersion": "0.12.5", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "2.11.2", - "_phantomChildren": {}, - "_requested": { - "raw": "code-point-at@^1.0.0", - "scope": null, - "escapedName": "code-point-at", - "name": "code-point-at", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog/gauge/string-width" - ], - "_resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.0.0.tgz", - "_shasum": "f69b192d3f7d91e382e4b71bddb77878619ab0c6", - "_shrinkwrap": null, - "_spec": "code-point-at@^1.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/code-point-at/issues" - }, - "dependencies": { - "number-is-nan": "^1.0.0" - }, - "description": "ES2015 String#codePointAt() ponyfill", - "devDependencies": { - "ava": "0.0.4" - }, - "directories": {}, - "dist": { - "shasum": "f69b192d3f7d91e382e4b71bddb77878619ab0c6", - "tarball": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.0.0.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "c2ffa4064718b37c84c73a633abeeed5b486a469", - "homepage": "https://github.com/sindresorhus/code-point-at", - "keywords": [ - "es2015", - "es6", - "ponyfill", - "polyfill", - "shim", - "string", - "str", - "code", - "point", - "at", - "codepoint", - "unicode" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "code-point-at", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/code-point-at.git" - }, - "scripts": { - "test": "node test.js" - }, - "version": "1.0.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/readme.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/readme.md deleted file mode 100644 index 71e7d0931b8b0c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/readme.md +++ /dev/null @@ -1,34 +0,0 @@ -# code-point-at [![Build Status](https://travis-ci.org/sindresorhus/code-point-at.svg?branch=master)](https://travis-ci.org/sindresorhus/code-point-at) - -> ES2015 [`String#codePointAt()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt) ponyfill - -> Ponyfill: A polyfill that doesn't overwrite the native method - - -## Install - -``` -$ npm install --save code-point-at -``` - - -## Usage - -```js -var codePointAt = require('code-point-at'); - -codePointAt('🐴'); -//=> 128052 - -codePointAt('abc', 2); -//=> 99 -``` - -## API - -### codePointAt(input, [position]) - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js deleted file mode 100644 index a7d3e3855f1c24..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; -var numberIsNan = require('number-is-nan'); - -module.exports = function (x) { - if (numberIsNan(x)) { - return false; - } - - // https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1369 - - // code points are derived from: - // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt - if (x >= 0x1100 && ( - x <= 0x115f || // Hangul Jamo - 0x2329 === x || // LEFT-POINTING ANGLE BRACKET - 0x232a === x || // RIGHT-POINTING ANGLE BRACKET - // CJK Radicals Supplement .. Enclosed CJK Letters and Months - (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || - // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - 0x3250 <= x && x <= 0x4dbf || - // CJK Unified Ideographs .. Yi Radicals - 0x4e00 <= x && x <= 0xa4c6 || - // Hangul Jamo Extended-A - 0xa960 <= x && x <= 0xa97c || - // Hangul Syllables - 0xac00 <= x && x <= 0xd7a3 || - // CJK Compatibility Ideographs - 0xf900 <= x && x <= 0xfaff || - // Vertical Forms - 0xfe10 <= x && x <= 0xfe19 || - // CJK Compatibility Forms .. Small Form Variants - 0xfe30 <= x && x <= 0xfe6b || - // Halfwidth and Fullwidth Forms - 0xff01 <= x && x <= 0xff60 || - 0xffe0 <= x && x <= 0xffe6 || - // Kana Supplement - 0x1b000 <= x && x <= 0x1b001 || - // Enclosed Ideographic Supplement - 0x1f200 <= x && x <= 0x1f251 || - // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - 0x20000 <= x && x <= 0x3fffd)) { - return true; - } - - return false; -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/index.js deleted file mode 100644 index 79be4b9cb8c3bc..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; -module.exports = Number.isNaN || function (x) { - return x !== x; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/license b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/license deleted file mode 100644 index 654d0bfe943437..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/package.json deleted file mode 100644 index a0eb06f0150602..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/package.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at" - ], - [ - { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point" - ] - ], - "_from": "number-is-nan@^1.0.0", - "_id": "number-is-nan@1.0.0", - "_inCache": true, - "_location": "/node-gyp/npmlog/gauge/string-width/is-fullwidth-code-point/number-is-nan", - "_nodeVersion": "0.12.3", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "2.10.0", - "_phantomChildren": {}, - "_requested": { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog/gauge/string-width/is-fullwidth-code-point" - ], - "_resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.0.tgz", - "_shasum": "c020f529c5282adfdd233d91d4b181c3d686dc4b", - "_shrinkwrap": null, - "_spec": "number-is-nan@^1.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/number-is-nan/issues" - }, - "dependencies": {}, - "description": "ES6 Number.isNaN() ponyfill", - "devDependencies": { - "ava": "0.0.4" - }, - "directories": {}, - "dist": { - "shasum": "c020f529c5282adfdd233d91d4b181c3d686dc4b", - "tarball": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.0.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "0f394b1bc33185c40304363b209e3f0588dbeeb3", - "homepage": "https://github.com/sindresorhus/number-is-nan#readme", - "keywords": [ - "es6", - "es2015", - "ecmascript", - "harmony", - "ponyfill", - "polyfill", - "shim", - "number", - "is", - "nan", - "not" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "number-is-nan", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/number-is-nan.git" - }, - "scripts": { - "test": "node test.js" - }, - "version": "1.0.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/readme.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/readme.md deleted file mode 100644 index 93d851a14f1ac5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/readme.md +++ /dev/null @@ -1,30 +0,0 @@ -# number-is-nan [![Build Status](https://travis-ci.org/sindresorhus/number-is-nan.svg?branch=master)](https://travis-ci.org/sindresorhus/number-is-nan) - -> ES6 [`Number.isNaN()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) ponyfill - -> Ponyfill: A polyfill that doesn't overwrite the native method - - -## Install - -``` -$ npm install --save number-is-nan -``` - - -## Usage - -```js -var numberIsNan = require('number-is-nan'); - -numberIsNan(NaN); -//=> true - -numberIsNan('unicorn'); -//=> false -``` - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json deleted file mode 100644 index 7b83e53a972fa4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "is-fullwidth-code-point@^1.0.0", - "scope": null, - "escapedName": "is-fullwidth-code-point", - "name": "is-fullwidth-code-point", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge/node_modules/string-width" - ], - [ - { - "raw": "is-fullwidth-code-point@^1.0.0", - "scope": null, - "escapedName": "is-fullwidth-code-point", - "name": "is-fullwidth-code-point", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width" - ] - ], - "_from": "is-fullwidth-code-point@^1.0.0", - "_id": "is-fullwidth-code-point@1.0.0", - "_inCache": true, - "_location": "/node-gyp/npmlog/gauge/string-width/is-fullwidth-code-point", - "_nodeVersion": "0.12.5", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "2.11.2", - "_phantomChildren": {}, - "_requested": { - "raw": "is-fullwidth-code-point@^1.0.0", - "scope": null, - "escapedName": "is-fullwidth-code-point", - "name": "is-fullwidth-code-point", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog/gauge/string-width" - ], - "_resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "_shasum": "ef9e31386f031a7f0d643af82fde50c457ef00cb", - "_shrinkwrap": null, - "_spec": "is-fullwidth-code-point@^1.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/is-fullwidth-code-point/issues" - }, - "dependencies": { - "number-is-nan": "^1.0.0" - }, - "description": "Check if the character represented by a given Unicode code point is fullwidth", - "devDependencies": { - "ava": "0.0.4", - "code-point-at": "^1.0.0" - }, - "directories": {}, - "dist": { - "shasum": "ef9e31386f031a7f0d643af82fde50c457ef00cb", - "tarball": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "f2152d357f41f82785436d428e4f8ede143b7548", - "homepage": "https://github.com/sindresorhus/is-fullwidth-code-point", - "keywords": [ - "fullwidth", - "full-width", - "full", - "width", - "unicode", - "character", - "char", - "string", - "str", - "codepoint", - "code", - "point", - "is", - "detect", - "check" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "is-fullwidth-code-point", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/is-fullwidth-code-point.git" - }, - "scripts": { - "test": "node test.js" - }, - "version": "1.0.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md deleted file mode 100644 index 4936464b1b4155..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md +++ /dev/null @@ -1,39 +0,0 @@ -# is-fullwidth-code-point [![Build Status](https://travis-ci.org/sindresorhus/is-fullwidth-code-point.svg?branch=master)](https://travis-ci.org/sindresorhus/is-fullwidth-code-point) - -> Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) - - -## Install - -``` -$ npm install --save is-fullwidth-code-point -``` - - -## Usage - -```js -var isFullwidthCodePoint = require('is-fullwidth-code-point'); - -isFullwidthCodePoint('谢'.codePointAt()); -//=> true - -isFullwidthCodePoint('a'.codePointAt()); -//=> false -``` - - -## API - -### isFullwidthCodePoint(input) - -#### input - -Type: `number` - -[Code point](https://en.wikipedia.org/wiki/Code_point) of a character. - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/package.json deleted file mode 100644 index 624a60c613c5b0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/package.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "string-width@^1.0.1", - "scope": null, - "escapedName": "string-width", - "name": "string-width", - "rawSpec": "^1.0.1", - "spec": ">=1.0.1 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge" - ], - [ - { - "raw": "string-width@^1.0.1", - "scope": null, - "escapedName": "string-width", - "name": "string-width", - "rawSpec": "^1.0.1", - "spec": ">=1.0.1 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "string-width@^1.0.1", - "_id": "string-width@1.0.2", - "_inCache": true, - "_location": "/node-gyp/npmlog/gauge/string-width", - "_nodeVersion": "4.4.5", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/string-width-1.0.2.tgz_1471188233009_0.6573935742489994" - }, - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "2.15.5", - "_phantomChildren": {}, - "_requested": { - "raw": "string-width@^1.0.1", - "scope": null, - "escapedName": "string-width", - "name": "string-width", - "rawSpec": "^1.0.1", - "spec": ">=1.0.1 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog/gauge", - "/node-gyp/npmlog/gauge/wide-align" - ], - "_resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "_shasum": "118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3", - "_shrinkwrap": null, - "_spec": "string-width@^1.0.1", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/string-width/issues" - }, - "dependencies": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - }, - "description": "Get the visual width of a string - the number of columns required to display it", - "devDependencies": { - "ava": "*", - "xo": "*" - }, - "directories": {}, - "dist": { - "shasum": "118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3", - "tarball": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "282cf3d53918a92cc3ee0778dcf938039bcbc47b", - "homepage": "https://github.com/sindresorhus/string-width#readme", - "keywords": [ - "string", - "str", - "character", - "char", - "unicode", - "width", - "visual", - "column", - "columns", - "fullwidth", - "full-width", - "full", - "ansi", - "escape", - "codes", - "cli", - "command-line", - "terminal", - "console", - "cjk", - "chinese", - "japanese", - "korean", - "fixed-width" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "string-width", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/string-width.git" - }, - "scripts": { - "test": "xo && ava" - }, - "version": "1.0.2" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/.npmignore deleted file mode 100644 index d1a6b0054bc8f3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -*~ -/node_modules -.#* -/.nyc_output -/coverage diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/LICENSE deleted file mode 100644 index f4be44d881b2d9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/LICENSE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) 2015, Rebecca Turner - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/README.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/README.md deleted file mode 100644 index 32f1be04f09776..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/README.md +++ /dev/null @@ -1,47 +0,0 @@ -wide-align ----------- - -A wide-character aware text alignment function for use in terminals / on the -console. - -### Usage - -``` -var align = require('wide-align') - -// Note that if you view this on a unicode console, all of the slashes are -// aligned. This is because on a console, all narrow characters are -// an en wide and all wide characters are an em. In browsers, this isn't -// held to and wide characters like "古" can be less than two narrow -// characters even with a fixed width font. - -console.log(align.center('abc', 10)) // ' abc ' -console.log(align.center('古古古', 10)) // ' 古古古 ' -console.log(align.left('abc', 10)) // 'abc ' -console.log(align.left('古古古', 10)) // '古古古 ' -console.log(align.right('abc', 10)) // ' abc' -console.log(align.right('古古古', 10)) // ' 古古古' -``` - -### Functions - -#### `align.center(str, length)` → `str` - -Returns *str* with spaces added to both sides such that that it is *length* -chars long and centered in the spaces. - -#### `align.left(str, length)` → `str` - -Returns *str* with spaces to the right such that it is *length* chars long. - -### `align.right(str, length)` → `str` - -Returns *str* with spaces to the left such that it is *length* chars long. - -### Origins - -These functions were originally taken from -[cliui](https://npmjs.com/package/cliui). Changes include switching to the -MUCH faster pad generation function from -[lodash](https://npmjs.com/package/lodash), making center alignment pad -both sides and adding left alignment. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/align.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/align.js deleted file mode 100644 index 4f94ca4cde19b5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/align.js +++ /dev/null @@ -1,65 +0,0 @@ -'use strict' -var stringWidth = require('string-width') - -exports.center = alignCenter -exports.left = alignLeft -exports.right = alignRight - -// lodash's way of generating pad characters. - -function createPadding (width) { - var result = '' - var string = ' ' - var n = width - do { - if (n % 2) { - result += string; - } - n = Math.floor(n / 2); - string += string; - } while (n); - - return result; -} - -function alignLeft (str, width) { - var trimmed = str.trimRight() - if (trimmed.length === 0 && str.length >= width) return str - var padding = '' - var strWidth = stringWidth(trimmed) - - if (strWidth < width) { - padding = createPadding(width - strWidth) - } - - return trimmed + padding -} - -function alignRight (str, width) { - var trimmed = str.trimLeft() - if (trimmed.length === 0 && str.length >= width) return str - var padding = '' - var strWidth = stringWidth(trimmed) - - if (strWidth < width) { - padding = createPadding(width - strWidth) - } - - return padding + trimmed -} - -function alignCenter (str, width) { - var trimmed = str.trim() - if (trimmed.length === 0 && str.length >= width) return str - var padLeft = '' - var padRight = '' - var strWidth = stringWidth(trimmed) - - if (strWidth < width) { - var padLeftBy = parseInt((width - strWidth) / 2, 10) - padLeft = createPadding(padLeftBy) - padRight = createPadding(width - (strWidth + padLeftBy)) - } - - return padLeft + trimmed + padRight -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/package.json deleted file mode 100644 index 6729516f83b95c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/package.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "wide-align@^1.1.0", - "scope": null, - "escapedName": "wide-align", - "name": "wide-align", - "rawSpec": "^1.1.0", - "spec": ">=1.1.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge" - ], - [ - { - "raw": "wide-align@^1.1.0", - "scope": null, - "escapedName": "wide-align", - "name": "wide-align", - "rawSpec": "^1.1.0", - "spec": ">=1.1.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "wide-align@^1.1.0", - "_id": "wide-align@1.1.0", - "_inCache": true, - "_location": "/node-gyp/npmlog/gauge/wide-align", - "_nodeVersion": "4.2.2", - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "_npmVersion": "3.5.3", - "_phantomChildren": {}, - "_requested": { - "raw": "wide-align@^1.1.0", - "scope": null, - "escapedName": "wide-align", - "name": "wide-align", - "rawSpec": "^1.1.0", - "spec": ">=1.1.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.0.tgz", - "_shasum": "40edde802a71fea1f070da3e62dcda2e7add96ad", - "_shrinkwrap": null, - "_spec": "wide-align@^1.1.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge", - "author": { - "name": "Rebecca Turner", - "email": "me@re-becca.org", - "url": "http://re-becca.org/" - }, - "bugs": { - "url": "https://github.com/iarna/wide-align/issues" - }, - "dependencies": { - "string-width": "^1.0.1" - }, - "description": "A wide-character aware text alignment function for use on the console or with fixed width fonts.", - "devDependencies": { - "tap": "^2.3.2" - }, - "directories": {}, - "dist": { - "shasum": "40edde802a71fea1f070da3e62dcda2e7add96ad", - "tarball": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.0.tgz" - }, - "gitHead": "fe3f7f210650913d5bee702d7e19938f6977bc8a", - "homepage": "https://github.com/iarna/wide-align#readme", - "keywords": [ - "wide", - "double", - "unicode", - "cjkv", - "pad", - "align" - ], - "license": "ISC", - "main": "align.js", - "maintainers": [ - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "name": "wide-align", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/iarna/wide-align.git" - }, - "scripts": { - "test": "tap --coverage test/*.js" - }, - "version": "1.1.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/test/align.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/test/align.js deleted file mode 100644 index 64e9f9dbda4697..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/test/align.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict' -var test = require('tap').test -var align = require('..') - -test('align', function (t) { - t.is(align.center('abc', 10), ' abc ', 'center narrow') - t.is(align.center('古古古', 10), ' 古古古 ', 'center wide') - t.is(align.left('abc', 10), 'abc ', 'left narrow') - t.is(align.left('古古古', 10), '古古古 ', 'left wide') - t.is(align.right('abc', 10), ' abc', 'right narrow') - t.is(align.right('古古古', 10), ' 古古古', 'right wide') - - t.is(align.center('abc', 2), 'abc', 'center narrow overflow') - t.is(align.center('古古古', 4), '古古古', 'center wide overflow') - t.is(align.left('abc', 2), 'abc', 'left narrow overflow') - t.is(align.left('古古古', 4), '古古古', 'left wide overflow') - t.is(align.right('abc', 2), 'abc', 'right narrow overflow') - t.is(align.right('古古古', 4), '古古古', 'right wide overflow') - - t.is(align.left('', 5), ' ', 'left align nothing') - t.is(align.center('', 5), ' ', 'center align nothing') - t.is(align.right('', 5), ' ', 'right align nothing') - - t.is(align.left(' ', 5), ' ', 'left align whitespace') - t.is(align.center(' ', 5), ' ', 'center align whitespace') - t.is(align.right(' ', 5), ' ', 'right align whitespace') - - t.is(align.left(' ', 2), ' ', 'left align whitespace overflow') - t.is(align.center(' ', 2), ' ', 'center align whitespace overflow') - t.is(align.right(' ', 2), ' ', 'right align whitespace overflow') - - t.is(align.left('x ', 10), 'x ', 'left align whitespace mix') - t.is(align.center('x ', 10), ' x ', 'center align whitespace mix') - t.is(align.right('x ', 10), ' x', 'right align whitespace mix') - - t.end() -}) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/package.json deleted file mode 100644 index 86fcce6f26980e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/package.json +++ /dev/null @@ -1,140 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "gauge@~2.6.0", - "scope": null, - "escapedName": "gauge", - "name": "gauge", - "rawSpec": "~2.6.0", - "spec": ">=2.6.0 <2.7.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog" - ], - [ - { - "raw": "gauge@~2.6.0", - "scope": null, - "escapedName": "gauge", - "name": "gauge", - "rawSpec": "~2.6.0", - "spec": ">=2.6.0 <2.7.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog" - ] - ], - "_from": "gauge@~2.6.0", - "_id": "gauge@2.6.0", - "_inCache": true, - "_location": "/node-gyp/npmlog/gauge", - "_nodeVersion": "4.4.0", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/gauge-2.6.0.tgz_1466067371972_0.20705468393862247" - }, - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "_npmVersion": "3.9.2", - "_phantomChildren": { - "strip-ansi": "3.0.1" - }, - "_requested": { - "raw": "gauge@~2.6.0", - "scope": null, - "escapedName": "gauge", - "name": "gauge", - "rawSpec": "~2.6.0", - "spec": ">=2.6.0 <2.7.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog" - ], - "_resolved": "https://registry.npmjs.org/gauge/-/gauge-2.6.0.tgz", - "_shasum": "d35301ad18e96902b4751dcbbe40f4218b942a46", - "_shrinkwrap": null, - "_spec": "gauge@~2.6.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog", - "author": { - "name": "Rebecca Turner", - "email": "me@re-becca.org" - }, - "bugs": { - "url": "https://github.com/iarna/gauge/issues" - }, - "dependencies": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-color": "^0.1.7", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - }, - "description": "A terminal based horizontal guage", - "devDependencies": { - "readable-stream": "^2.0.6", - "require-inject": "^1.4.0", - "standard": "^7.1.2", - "tap": "^5.7.2", - "through2": "^2.0.0" - }, - "directories": {}, - "dist": { - "shasum": "d35301ad18e96902b4751dcbbe40f4218b942a46", - "tarball": "https://registry.npmjs.org/gauge/-/gauge-2.6.0.tgz" - }, - "files": [ - "base-theme.js", - "CHANGELOG.md", - "error.js", - "has-color.js", - "index.js", - "LICENSE", - "package.json", - "plumbing.js", - "process.js", - "progress-bar.js", - "README.md", - "render-template.js", - "set-immediate.js", - "set-interval.js", - "spin.js", - "template-item.js", - "theme-set.js", - "themes.js", - "wide-truncate.js" - ], - "gitHead": "d51040a71c269432c16cc542143f403a831630e6", - "homepage": "https://github.com/iarna/gauge", - "keywords": [ - "progressbar", - "progress", - "gauge" - ], - "license": "ISC", - "main": "index.js", - "maintainers": [ - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "name": "gauge", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/iarna/gauge.git" - }, - "scripts": { - "test": "standard && tap test/*.js --coverage" - }, - "version": "2.6.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/plumbing.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/plumbing.js deleted file mode 100644 index 589a9c92878ebf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/plumbing.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict' -var consoleControl = require('console-control-strings') -var renderTemplate = require('./render-template.js') -var validate = require('aproba') - -var Plumbing = module.exports = function (theme, template, width) { - if (!width) width = 80 - validate('OAN', [theme, template, width]) - this.showing = false - this.theme = theme - this.width = width - this.template = template -} -Plumbing.prototype = {} - -Plumbing.prototype.setTheme = function (theme) { - validate('O', [theme]) - this.theme = theme -} - -Plumbing.prototype.setTemplate = function (template) { - validate('A', [template]) - this.template = template -} - -Plumbing.prototype.setWidth = function (width) { - validate('N', [width]) - this.width = width -} - -Plumbing.prototype.hide = function () { - return consoleControl.gotoSOL() + consoleControl.eraseLine() -} - -Plumbing.prototype.hideCursor = consoleControl.hideCursor - -Plumbing.prototype.showCursor = consoleControl.showCursor - -Plumbing.prototype.show = function (status) { - var values = Object.create(this.theme) - for (var key in status) { - values[key] = status[key] - } - - return renderTemplate(this.width, this.template, values).trim() + - consoleControl.eraseLine() + consoleControl.gotoSOL() -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/process.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/process.js deleted file mode 100644 index 05e85694d755b6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/process.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict' -// this exists so we can replace it during testing -module.exports = process diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/progress-bar.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/progress-bar.js deleted file mode 100644 index 7f8dd68be24cf0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/progress-bar.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict' -var validate = require('aproba') -var renderTemplate = require('./render-template.js') -var wideTruncate = require('./wide-truncate') -var stringWidth = require('string-width') - -module.exports = function (theme, width, completed) { - validate('ONN', [theme, width, completed]) - if (completed < 0) completed = 0 - if (completed > 1) completed = 1 - if (width <= 0) return '' - var sofar = Math.round(width * completed) - var rest = width - sofar - var template = [ - {type: 'complete', value: repeat(theme.complete, sofar), length: sofar}, - {type: 'remaining', value: repeat(theme.remaining, rest), length: rest} - ] - return renderTemplate(width, template, theme) -} - -// lodash's way of repeating -function repeat (string, width) { - var result = '' - var n = width - do { - if (n % 2) { - result += string - } - n = Math.floor(n / 2) - /*eslint no-self-assign: 0*/ - string += string - } while (n && stringWidth(result) < width) - - return wideTruncate(result, width) -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/render-template.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/render-template.js deleted file mode 100644 index 3261bfbe6f4be5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/render-template.js +++ /dev/null @@ -1,181 +0,0 @@ -'use strict' -var align = require('wide-align') -var validate = require('aproba') -var objectAssign = require('object-assign') -var wideTruncate = require('./wide-truncate') -var error = require('./error') -var TemplateItem = require('./template-item') - -function renderValueWithValues (values) { - return function (item) { - return renderValue(item, values) - } -} - -var renderTemplate = module.exports = function (width, template, values) { - var items = prepareItems(width, template, values) - var rendered = items.map(renderValueWithValues(values)).join('') - return align.left(wideTruncate(rendered, width), width) -} - -function preType (item) { - var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1) - return 'pre' + cappedTypeName -} - -function postType (item) { - var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1) - return 'post' + cappedTypeName -} - -function hasPreOrPost (item, values) { - if (!item.type) return - return values[preType(item)] || values[postType(item)] -} - -function generatePreAndPost (baseItem, parentValues) { - var item = objectAssign({}, baseItem) - var values = Object.create(parentValues) - var template = [] - var pre = preType(item) - var post = postType(item) - if (values[pre]) { - template.push({value: values[pre]}) - values[pre] = null - } - item.minLength = null - item.length = null - item.maxLength = null - template.push(item) - values[item.type] = values[item.type] - if (values[post]) { - template.push({value: values[post]}) - values[post] = null - } - return function ($1, $2, length) { - return renderTemplate(length, template, values) - } -} - -function prepareItems (width, template, values) { - function cloneAndObjectify (item, index, arr) { - var cloned = new TemplateItem(item, width) - var type = cloned.type - if (cloned.value == null) { - if (!(type in values)) { - if (cloned.default == null) { - throw new error.MissingTemplateValue(cloned, values) - } else { - cloned.value = cloned.default - } - } else { - cloned.value = values[type] - } - } - if (cloned.value == null || cloned.value === '') return null - cloned.index = index - cloned.first = index === 0 - cloned.last = index === arr.length - 1 - if (hasPreOrPost(cloned, values)) cloned.value = generatePreAndPost(cloned, values) - return cloned - } - - var output = template.map(cloneAndObjectify).filter(function (item) { return item != null }) - - var outputLength = 0 - var remainingSpace = width - var variableCount = output.length - - function consumeSpace (length) { - if (length > remainingSpace) length = remainingSpace - outputLength += length - remainingSpace -= length - } - - function finishSizing (item, length) { - if (item.finished) throw new error.Internal('Tried to finish template item that was already finished') - if (length === Infinity) throw new error.Internal('Length of template item cannot be infinity') - if (length != null) item.length = length - item.minLength = null - item.maxLength = null - --variableCount - item.finished = true - if (item.length == null) item.length = item.getBaseLength() - if (item.length == null) throw new error.Internal('Finished template items must have a length') - consumeSpace(item.getLength()) - } - - output.forEach(function (item) { - if (!item.kerning) return - var prevPadRight = item.first ? 0 : output[item.index - 1].padRight - if (!item.first && prevPadRight < item.kerning) item.padLeft = item.kerning - prevPadRight - if (!item.last) item.padRight = item.kerning - }) - - // Finish any that have a fixed (literal or intuited) length - output.forEach(function (item) { - if (item.getBaseLength() == null) return - finishSizing(item) - }) - - var resized = 0 - var resizing - var hunkSize - do { - resizing = false - hunkSize = Math.round(remainingSpace / variableCount) - output.forEach(function (item) { - if (item.finished) return - if (!item.maxLength) return - if (item.getMaxLength() < hunkSize) { - finishSizing(item, item.maxLength) - resizing = true - } - }) - } while (resizing && resized++ < output.length) - if (resizing) throw new error.Internal('Resize loop iterated too many times while determining maxLength') - - resized = 0 - do { - resizing = false - hunkSize = Math.round(remainingSpace / variableCount) - output.forEach(function (item) { - if (item.finished) return - if (!item.minLength) return - if (item.getMinLength() >= hunkSize) { - finishSizing(item, item.minLength) - resizing = true - } - }) - } while (resizing && resized++ < output.length) - if (resizing) throw new error.Internal('Resize loop iterated too many times while determining minLength') - - hunkSize = Math.round(remainingSpace / variableCount) - output.forEach(function (item) { - if (item.finished) return - finishSizing(item, hunkSize) - }) - - return output -} - -function renderFunction (item, values, length) { - validate('OON', arguments) - if (item.type) { - return item.value(values, values[item.type + 'Theme'] || {}, length) - } else { - return item.value(values, {}, length) - } -} - -function renderValue (item, values) { - var length = item.getBaseLength() - var value = typeof item.value === 'function' ? renderFunction(item, values, length) : item.value - if (value == null || value === '') return '' - var alignWith = align[item.align] || align.left - var leftPadding = item.padLeft ? align.left('', item.padLeft) : '' - var rightPadding = item.padRight ? align.right('', item.padRight) : '' - var truncated = wideTruncate(String(value), length) - var aligned = alignWith(truncated, length) - return leftPadding + aligned + rightPadding -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/set-immediate.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/set-immediate.js deleted file mode 100644 index 6650a485c49933..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/set-immediate.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' -var process = require('./process') -try { - module.exports = setImmediate -} catch (ex) { - module.exports = process.nextTick -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/set-interval.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/set-interval.js deleted file mode 100644 index 576198793c5504..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/set-interval.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict' -// this exists so we can replace it during testing -module.exports = setInterval diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/spin.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/spin.js deleted file mode 100644 index 34142ee31acc7c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/spin.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict' - -module.exports = function spin (spinstr, spun) { - return spinstr[spun % spinstr.length] -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/template-item.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/template-item.js deleted file mode 100644 index e46f447c941d38..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/template-item.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict' -var stringWidth = require('string-width') - -module.exports = TemplateItem - -function isPercent (num) { - if (typeof num !== 'string') return false - return num.slice(-1) === '%' -} - -function percent (num) { - return Number(num.slice(0, -1)) / 100 -} - -function TemplateItem (values, outputLength) { - this.overallOutputLength = outputLength - this.finished = false - this.type = null - this.value = null - this.length = null - this.maxLength = null - this.minLength = null - this.kerning = null - this.align = 'left' - this.padLeft = 0 - this.padRight = 0 - this.index = null - this.first = null - this.last = null - if (typeof values === 'string') { - this.value = values - } else { - for (var prop in values) this[prop] = values[prop] - } - // Realize percents - if (isPercent(this.length)) { - this.length = Math.round(this.overallOutputLength * percent(this.length)) - } - if (isPercent(this.minLength)) { - this.minLength = Math.round(this.overallOutputLength * percent(this.minLength)) - } - if (isPercent(this.maxLength)) { - this.maxLength = Math.round(this.overallOutputLength * percent(this.maxLength)) - } - return this -} - -TemplateItem.prototype = {} - -TemplateItem.prototype.getBaseLength = function () { - var length = this.length - if (length == null && typeof this.value === 'string' && this.maxLength == null && this.minLength == null) { - length = stringWidth(this.value) - } - return length -} - -TemplateItem.prototype.getLength = function () { - var length = this.getBaseLength() - if (length == null) return null - return length + this.padLeft + this.padRight -} - -TemplateItem.prototype.getMaxLength = function () { - if (this.maxLength == null) return null - return this.maxLength + this.padLeft + this.padRight -} - -TemplateItem.prototype.getMinLength = function () { - if (this.minLength == null) return null - return this.minLength + this.padLeft + this.padRight -} - diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/theme-set.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/theme-set.js deleted file mode 100644 index 68971d5d231b07..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/theme-set.js +++ /dev/null @@ -1,115 +0,0 @@ -'use strict' -var objectAssign = require('object-assign') - -module.exports = function () { - return ThemeSetProto.newThemeSet() -} - -var ThemeSetProto = {} - -ThemeSetProto.baseTheme = require('./base-theme.js') - -ThemeSetProto.newTheme = function (parent, theme) { - if (!theme) { - theme = parent - parent = this.baseTheme - } - return objectAssign({}, parent, theme) -} - -ThemeSetProto.getThemeNames = function () { - return Object.keys(this.themes) -} - -ThemeSetProto.addTheme = function (name, parent, theme) { - this.themes[name] = this.newTheme(parent, theme) -} - -ThemeSetProto.addToAllThemes = function (theme) { - var themes = this.themes - Object.keys(themes).forEach(function (name) { - objectAssign(themes[name], theme) - }) - objectAssign(this.baseTheme, theme) -} - -ThemeSetProto.getTheme = function (name) { - if (!this.themes[name]) throw this.newMissingThemeError(name) - return this.themes[name] -} - -ThemeSetProto.setDefault = function (opts, name) { - if (name == null) { - name = opts - opts = {} - } - var platform = opts.platform == null ? 'fallback' : opts.platform - var hasUnicode = !!opts.hasUnicode - var hasColor = !!opts.hasColor - if (!this.defaults[platform]) this.defaults[platform] = {true: {}, false: {}} - this.defaults[platform][hasUnicode][hasColor] = name -} - -ThemeSetProto.getDefault = function (opts) { - if (!opts) opts = {} - var platformName = opts.platform || process.platform - var platform = this.defaults[platformName] || this.defaults.fallback - var hasUnicode = !!opts.hasUnicode - var hasColor = !!opts.hasColor - if (!platform) throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor) - if (!platform[hasUnicode][hasColor]) { - if (hasUnicode && hasColor && platform[!hasUnicode][hasColor]) { - hasUnicode = false - } else if (hasUnicode && hasColor && platform[hasUnicode][!hasColor]) { - hasColor = false - } else if (hasUnicode && hasColor && platform[!hasUnicode][!hasColor]) { - hasUnicode = false - hasColor = false - } else if (hasUnicode && !hasColor && platform[!hasUnicode][hasColor]) { - hasUnicode = false - } else if (!hasUnicode && hasColor && platform[hasUnicode][!hasColor]) { - hasColor = false - } else if (platform === this.defaults.fallback) { - throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor) - } - } - if (platform[hasUnicode][hasColor]) { - return this.getTheme(platform[hasUnicode][hasColor]) - } else { - return this.getDefault(objectAssign({}, opts, {platform: 'fallback'})) - } -} - -ThemeSetProto.newMissingThemeError = function newMissingThemeError (name) { - var err = new Error('Could not find a gauge theme named "' + name + '"') - Error.captureStackTrace.call(err, newMissingThemeError) - err.theme = name - err.code = 'EMISSINGTHEME' - return err -} - -ThemeSetProto.newMissingDefaultThemeError = function newMissingDefaultThemeError (platformName, hasUnicode, hasColor) { - var err = new Error( - 'Could not find a gauge theme for your platform/unicode/color use combo:\n' + - ' platform = ' + platformName + '\n' + - ' hasUnicode = ' + hasUnicode + '\n' + - ' hasColor = ' + hasColor) - Error.captureStackTrace.call(err, newMissingDefaultThemeError) - err.platform = platformName - err.hasUnicode = hasUnicode - err.hasColor = hasColor - err.code = 'EMISSINGTHEME' - return err -} - -ThemeSetProto.newThemeSet = function () { - var themeset = function (opts) { - return themeset.getDefault(opts) - } - return objectAssign(themeset, ThemeSetProto, { - themes: objectAssign({}, this.themes), - baseTheme: objectAssign({}, this.baseTheme), - defaults: JSON.parse(JSON.stringify(this.defaults || {})) - }) -} - diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/themes.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/themes.js deleted file mode 100644 index eb5a4f5b5e1034..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/themes.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict' -var consoleControl = require('console-control-strings') -var ThemeSet = require('./theme-set.js') - -var themes = module.exports = new ThemeSet() - -themes.addTheme('ASCII', { - preProgressbar: '[', - postProgressbar: ']', - progressbarTheme: { - complete: '#', - remaining: '.' - }, - activityIndicatorTheme: '-\\|/', - preSubsection: '>' -}) - -themes.addTheme('colorASCII', themes.getTheme('ASCII'), { - progressbarTheme: { - preComplete: consoleControl.color('inverse'), - complete: ' ', - postComplete: consoleControl.color('stopInverse'), - preRemaining: consoleControl.color('brightBlack'), - remaining: '.', - postRemaining: consoleControl.color('reset') - } -}) - -themes.addTheme('brailleSpinner', { - preProgressbar: '⸨', - postProgressbar: '⸩', - progressbarTheme: { - complete: '░', - remaining: '⠂' - }, - activityIndicatorTheme: '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏', - preSubsection: '>' -}) - -themes.addTheme('colorBrailleSpinner', themes.getTheme('brailleSpinner'), { - progressbarTheme: { - preComplete: consoleControl.color('inverse'), - complete: ' ', - postComplete: consoleControl.color('stopInverse'), - preRemaining: consoleControl.color('brightBlack'), - remaining: '░', - postRemaining: consoleControl.color('reset') - } -}) - -themes.setDefault({}, 'ASCII') -themes.setDefault({hasColor: true}, 'colorASCII') -themes.setDefault({platform: 'darwin', hasUnicode: true}, 'brailleSpinner') -themes.setDefault({platform: 'darwin', hasUnicode: true, hasColor: true}, 'colorBrailleSpinner') diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/wide-truncate.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/wide-truncate.js deleted file mode 100644 index c531bc491fbb58..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/wide-truncate.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict' -var stringWidth = require('string-width') -var stripAnsi = require('strip-ansi') - -module.exports = wideTruncate - -function wideTruncate (str, target) { - if (stringWidth(str) === 0) return str - if (target <= 0) return '' - if (stringWidth(str) <= target) return str - - // We compute the number of bytes of ansi sequences here and add - // that to our initial truncation to ensure that we don't slice one - // that we want to keep in half. - var noAnsi = stripAnsi(str) - var ansiSize = str.length + noAnsi.length - var truncated = str.slice(0, target + ansiSize) - - // we have to shrink the result to account for our ansi sequence buffer - // (if an ansi sequence was truncated) and double width characters. - while (stringWidth(truncated) > target) { - truncated = truncated.slice(0, -1) - } - return truncated -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/CHANGELOG.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/CHANGELOG.md deleted file mode 100644 index 03bf591923d782..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/CHANGELOG.md +++ /dev/null @@ -1,26 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - - -# [2.0.0](https://github.com/yargs/set-blocking/compare/v1.0.0...v2.0.0) (2016-05-17) - - -### Features - -* add an isTTY check ([#3](https://github.com/yargs/set-blocking/issues/3)) ([66ce277](https://github.com/yargs/set-blocking/commit/66ce277)) - - -### BREAKING CHANGES - -* stdio/stderr will not be set to blocking if isTTY === false - - - - -# 1.0.0 (2016-05-14) - - -### Features - -* implemented shim for stream._handle.setBlocking ([6bde0c0](https://github.com/yargs/set-blocking/commit/6bde0c0)) diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/LICENSE.txt b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/LICENSE.txt deleted file mode 100644 index 836440bef7cf14..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/LICENSE.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) 2016, Contributors - -Permission to use, copy, modify, and/or distribute this software -for any purpose with or without fee is hereby granted, provided -that the above copyright notice and this permission notice -appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE -LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES -OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/README.md b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/README.md deleted file mode 100644 index e93b4202b59d65..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# set-blocking - -[![Build Status](https://travis-ci.org/yargs/set-blocking.svg)](https://travis-ci.org/yargs/set-blocking) -[![NPM version](https://img.shields.io/npm/v/set-blocking.svg)](https://www.npmjs.com/package/set-blocking) -[![Coverage Status](https://coveralls.io/repos/yargs/set-blocking/badge.svg?branch=)](https://coveralls.io/r/yargs/set-blocking?branch=master) -[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version) - -set blocking `stdio` and `stderr` ensuring that terminal output does not truncate. - -```js -const setBlocking = require('set-blocking') -setBlocking(true) -console.log(someLargeStringToOutput) -``` - -## Historical Context/Word of Warning - -This was created as a shim to address the bug discussed in [node #6456](https://github.com/nodejs/node/issues/6456). This bug crops up on -newer versions of Node.js (`0.12+`), truncating terminal output. - -You should be mindful of the side-effects caused by using `set-blocking`: - -* if your module sets blocking to `true`, it will effect other modules - consuming your library. In [yargs](https://github.com/yargs/yargs/blob/master/yargs.js#L653) we only call - `setBlocking(true)` once we already know we are about to call `process.exit(code)`. -* this patch will not apply to subprocesses spawned with `isTTY = true`, this is - the [default `spawn()` behavior](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). - -## License - -ISC diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/index.js b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/index.js deleted file mode 100644 index 6f78774bb63ee6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/index.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = function (blocking) { - [process.stdout, process.stderr].forEach(function (stream) { - if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') { - stream._handle.setBlocking(blocking) - } - }) -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/package.json deleted file mode 100644 index 1db092f9c4ee05..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/set-blocking/package.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "set-blocking@~2.0.0", - "scope": null, - "escapedName": "set-blocking", - "name": "set-blocking", - "rawSpec": "~2.0.0", - "spec": ">=2.0.0 <2.1.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog" - ], - [ - { - "raw": "set-blocking@~2.0.0", - "scope": null, - "escapedName": "set-blocking", - "name": "set-blocking", - "rawSpec": "~2.0.0", - "spec": ">=2.0.0 <2.1.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog" - ] - ], - "_from": "set-blocking@~2.0.0", - "_id": "set-blocking@2.0.0", - "_inCache": true, - "_location": "/node-gyp/npmlog/set-blocking", - "_nodeVersion": "0.12.7", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/set-blocking-2.0.0.tgz_1463525966987_0.5456729622092098" - }, - "_npmUser": { - "name": "bcoe", - "email": "ben@npmjs.com" - }, - "_npmVersion": "2.11.3", - "_phantomChildren": {}, - "_requested": { - "raw": "set-blocking@~2.0.0", - "scope": null, - "escapedName": "set-blocking", - "name": "set-blocking", - "rawSpec": "~2.0.0", - "spec": ">=2.0.0 <2.1.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/npmlog" - ], - "_resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "_shasum": "045f9782d011ae9a6803ddd382b24392b3d890f7", - "_shrinkwrap": null, - "_spec": "set-blocking@~2.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/npmlog", - "author": { - "name": "Ben Coe", - "email": "ben@npmjs.com" - }, - "bugs": { - "url": "https://github.com/yargs/set-blocking/issues" - }, - "dependencies": {}, - "description": "set blocking stdio and stderr ensuring that terminal output does not truncate", - "devDependencies": { - "chai": "^3.5.0", - "coveralls": "^2.11.9", - "mocha": "^2.4.5", - "nyc": "^6.4.4", - "standard": "^7.0.1", - "standard-version": "^2.2.1" - }, - "directories": {}, - "dist": { - "shasum": "045f9782d011ae9a6803ddd382b24392b3d890f7", - "tarball": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz" - }, - "files": [ - "index.js", - "LICENSE.txt" - ], - "gitHead": "7eec10577b5fff264de477ba3b9d07f404946eff", - "homepage": "https://github.com/yargs/set-blocking#readme", - "keywords": [ - "flush", - "terminal", - "blocking", - "shim", - "stdio", - "stderr" - ], - "license": "ISC", - "main": "index.js", - "maintainers": [ - { - "name": "bcoe", - "email": "ben@npmjs.com" - } - ], - "name": "set-blocking", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/yargs/set-blocking.git" - }, - "scripts": { - "coverage": "nyc report --reporter=text-lcov | coveralls", - "pretest": "standard", - "test": "nyc mocha ./test/*.js", - "version": "standard-version" - }, - "version": "2.0.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/package.json b/deps/npm/node_modules/node-gyp/node_modules/npmlog/package.json deleted file mode 100644 index 83078bd19721c7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/npmlog/package.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "npmlog@0 || 1 || 2 || 3", - "scope": null, - "escapedName": "npmlog", - "name": "npmlog", - "rawSpec": "0 || 1 || 2 || 3", - "spec": ">=0.0.0 <1.0.0||>=1.0.0 <2.0.0||>=2.0.0 <3.0.0||>=3.0.0 <4.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp" - ] - ], - "_from": "npmlog@>=0.0.0 <1.0.0||>=1.0.0 <2.0.0||>=2.0.0 <3.0.0||>=3.0.0 <4.0.0", - "_id": "npmlog@3.1.2", - "_inCache": true, - "_location": "/node-gyp/npmlog", - "_nodeVersion": "4.4.0", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/npmlog-3.1.2.tgz_1466073052641_0.36111341998912394" - }, - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "_npmVersion": "3.9.6", - "_phantomChildren": { - "aproba": "1.0.4", - "has-unicode": "2.0.1", - "readable-stream": "2.1.4", - "strip-ansi": "3.0.1" - }, - "_requested": { - "raw": "npmlog@0 || 1 || 2 || 3", - "scope": null, - "escapedName": "npmlog", - "name": "npmlog", - "rawSpec": "0 || 1 || 2 || 3", - "spec": ">=0.0.0 <1.0.0||>=1.0.0 <2.0.0||>=2.0.0 <3.0.0||>=3.0.0 <4.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp" - ], - "_resolved": "https://registry.npmjs.org/npmlog/-/npmlog-3.1.2.tgz", - "_shasum": "2d46fa874337af9498a2f12bb43d8d0be4a36873", - "_shrinkwrap": null, - "_spec": "npmlog@0 || 1 || 2 || 3", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "bugs": { - "url": "https://github.com/npm/npmlog/issues" - }, - "dependencies": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.6.0", - "set-blocking": "~2.0.0" - }, - "description": "logger for npm", - "devDependencies": { - "standard": "~7.1.2", - "tap": "~5.7.0" - }, - "directories": {}, - "dist": { - "shasum": "2d46fa874337af9498a2f12bb43d8d0be4a36873", - "tarball": "https://registry.npmjs.org/npmlog/-/npmlog-3.1.2.tgz" - }, - "files": [ - "log.js" - ], - "gitHead": "444e237743fa1339cb91bea2d3f16f710be56984", - "homepage": "https://github.com/npm/npmlog#readme", - "license": "ISC", - "main": "log.js", - "maintainers": [ - { - "name": "iarna", - "email": "me@re-becca.org" - }, - { - "name": "isaacs", - "email": "i@izs.me" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - { - "name": "zkat", - "email": "kat@sykosomatic.org" - } - ], - "name": "npmlog", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/npm/npmlog.git" - }, - "scripts": { - "test": "standard && tap test/*.js" - }, - "version": "3.1.2" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/path-array/.npmignore deleted file mode 100644 index 07e6e472cc75fa..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/.npmignore +++ /dev/null @@ -1 +0,0 @@ -/node_modules diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/path-array/.travis.yml deleted file mode 100644 index 41840cb357b87a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -sudo: false - -language: node_js - -node_js: - - "0.8" - - "0.10" - - "0.12" - - "1" - - "2" - - "3" - - "4" - - "5" - -install: - - PATH="`npm bin`:`npm bin -g`:$PATH" - # Node 0.8 comes with a too obsolete npm - - if [[ "`node --version`" =~ ^v0\.8\. ]]; then npm install -g npm@1.4.28 ; fi - # Install dependencies and build - - npm install - -script: - # Output useful info for debugging - - node --version - - npm --version - # Run tests - - npm test diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/History.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/History.md deleted file mode 100644 index bbdacd30a0001a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/History.md +++ /dev/null @@ -1,30 +0,0 @@ - -1.0.1 / 2016-01-14 -================== - - * add MIT LICENSE file - * update "array-index" to v1.0.0 with new API - * travis: test more node versions and fix v0.8 - * travis: use quotes around node versions - -1.0.0 / 2014-11-11 -================== - - * index: add support for a configrable `property` name to use - * README: fix Travis badge - -0.0.2 / 2013-12-22 -================== - - * README++ - * test: add unshift() test - * test: add more tests - * index: ensure that the indexed getters/setters are set up in the constructor - * add .travis.yml file - * add initial tests - -0.0.1 / 2013-12-21 -================== - - * add README.md - * initial commit diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/path-array/LICENSE deleted file mode 100644 index 2a54ccd2ebe03d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -(The MIT License) - -Copyright (c) 2013 Nathan Rajlich - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/README.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/README.md deleted file mode 100644 index 2595316a191e6b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/README.md +++ /dev/null @@ -1,92 +0,0 @@ -path-array -========== -### Treat your `$PATH` like a JavaScript Array -[![Build Status](https://travis-ci.org/TooTallNate/path-array.svg?branch=master)](https://travis-ci.org/TooTallNate/path-array) - -This module provides a JavaScript `Array` implementation that is backed by your -`$PATH` env variable. That is, you can use regular Array functions like `shift()`, -`pop()`, `push()`, `unshift()`, etc. to mutate your `$PATH`. - -Also works for preparing an `env` object for passing to -[`child_process.spawn()`][cp.spawn]. - - -Installation ------------- - -Install with `npm`: - -``` bash -$ npm install path-array -``` - - -Example -------- - -Interacting with your own `$PATH` env variable: - -``` js -var PathArray = require('path-array'); - -// no args uses `process.env` by default -var p = new PathArray(); - -console.log(p); -// [ './node_modules/.bin', -// '/opt/local/bin', -// '/opt/local/sbin', -// '/usr/local/bin', -// '/usr/local/sbin', -// '/usr/bin', -// '/bin', -// '/usr/sbin', -// '/sbin', -// '/usr/local/bin', -// '/opt/X11/bin' ] - -// push another path entry. this function mutates the `process.env.PATH` -p.unshift('/foo'); - -console.log(process.env.PATH); -// '/foo:./node_modules/.bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin' -``` - - -API ---- - -### new PathArray([env]) → PathArray - -Creates and returns a new `PathArray` instance with the given `env` object. If no -`env` is specified, then [`process.env`][process.env] is used by default. - - -License -------- - -(The MIT License) - -Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -[process.env]: http://nodejs.org/docs/latest/api/process.html#process_process_env -[cp.spawn]: http://nodejs.org/docs/latest/api/child_process.html#child_process_child_process_spawn_command_args_options diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/index.js deleted file mode 100644 index 1e8170136e7e9e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/index.js +++ /dev/null @@ -1,137 +0,0 @@ - -/** - * Module dependencies. - */ - -var inherits = require('util').inherits; -var delimiter = require('path').delimiter || ':'; -var ArrayIndex = require('array-index'); - -/** - * Module exports. - */ - -module.exports = PathArray; - -/** - * `PathArray` constructor. Treat your `$PATH` like a mutable JavaScript Array! - * - * @param {Env} env - `process.env` object to use. - * @param {String} [property] - optional property name to use (`PATH` by default). - * @public - */ - -function PathArray (env, property) { - if (!(this instanceof PathArray)) return new PathArray(env); - ArrayIndex.call(this); - - this.property = property || 'PATH'; - - // overwrite only the `get` operator of the ".length" property - Object.defineProperty(this, 'length', { - get: this._getLength - }); - - // store the `process.env` object as a non-enumerable `_env` - Object.defineProperty(this, '_env', { - value: env || process.env, - writable: true, - enumerable: false, - configurable: true - }); - - // need to invoke the `length` getter to ensure that the - // indexed getters/setters are set up at this point - void(this.length); -} - -// inherit from ArrayIndex -inherits(PathArray, ArrayIndex); - -/** - * Returns the current $PATH representation as an Array. - * - * @api private - */ - -PathArray.prototype._array = function () { - var path = this._env[this.property]; - if (!path) return []; - return path.split(delimiter); -}; - -/** - * Sets the `env` object's `PATH` string to the values in the passed in Array - * instance. - * - * @api private - */ - -PathArray.prototype._setArray = function (arr) { - // mutate the $PATH - this._env[this.property] = arr.join(delimiter); -}; - -/** - * `.length` getter operation implementation. - * - * @api private - */ - -PathArray.prototype._getLength = function () { - var length = this._array().length; - - // invoke the ArrayIndex internal `set` operator to ensure that - // there's getters/setters defined for the determined length so far... - this.length = length; - - return length; -}; - -/** - * ArrayIndex [0] getter operator implementation. - * - * @api private - */ - -PathArray.prototype[ArrayIndex.get] = function get (index) { - return this._array()[index]; -}; - -/** - * ArrayIndex [0]= setter operator implementation. - * - * @api private - */ - -PathArray.prototype[ArrayIndex.set] = function set (index, value) { - var arr = this._array(); - arr[index] = value; - this._setArray(arr); - return value; -}; - -/** - * `toString()` returns the current $PATH string. - * - * @api public - */ - -PathArray.prototype.toString = function toString () { - return this._env[this.property] || ''; -}; - -// proxy the JavaScript Array functions, and mutate the $PATH -Object.getOwnPropertyNames(Array.prototype).forEach(function (name) { - if ('constructor' == name) return; - if ('function' != typeof Array.prototype[name]) return; - if (/to(Locale)?String/.test(name)) return; - //console.log('proxy %s', name); - - PathArray.prototype[name] = function () { - var arr = this._array(); - var rtn = arr[name].apply(arr, arguments); - this._setArray(arr); - return rtn; - }; -}); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/.jshintrc b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/.jshintrc deleted file mode 100644 index 182e34d07d7835..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/.jshintrc +++ /dev/null @@ -1,4 +0,0 @@ -{ - "asi": true, - "laxcomma": true -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/.travis.yml deleted file mode 100644 index 41840cb357b87a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -sudo: false - -language: node_js - -node_js: - - "0.8" - - "0.10" - - "0.12" - - "1" - - "2" - - "3" - - "4" - - "5" - -install: - - PATH="`npm bin`:`npm bin -g`:$PATH" - # Node 0.8 comes with a too obsolete npm - - if [[ "`node --version`" =~ ^v0\.8\. ]]; then npm install -g npm@1.4.28 ; fi - # Install dependencies and build - - npm install - -script: - # Output useful info for debugging - - node --version - - npm --version - # Run tests - - npm test diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/History.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/History.md deleted file mode 100644 index 12990228a43a13..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/History.md +++ /dev/null @@ -1,67 +0,0 @@ - -1.0.0 / 2016-01-02 -================== - - * remove `__get__` and `__set__` functionality - * README: s/->/→/ - -0.9.1 / 2015-12-29 -================== - - * fix backwards compat with tests - * README: update samples for new Symbols API - * travis: attempt to fix node v8 - -0.9.0 / 2015-12-27 -================== - - * add backwards compat logic with deprecate message - * add LICENSE field and entry in package.json - * convert to using es6 Symbols - * remove extraneous debug() calls - * travis: test moar Node.js versions - -0.2.0 / 2015-12-02 -================== - - * add support for invoking as a Mixin - * travis: test node v0.6 - -0.1.1 / 2014-11-03 -================== - - * index: use `%o` debug formatters - * .travis: don't test node v0.9.x - * README: use svg for Travis badge - * add .jshintrc file - -0.1.0 / 2013-12-01 -================== - - * add `History.md` file - * .travis.yml: test node v0.8-v0.11 - * add component.json - * package: update "main" field - * package: beautify - -0.0.4 / 2013-09-27 -================== - - * ensure that the `length` property has the same maximum as regular Arrays - -0.0.3 / 2013-09-15 -================== - - * add `toArray()`, `toJSON()`, and `toString()` functions - * add an `inspect()` function - -0.0.2 / 2013-09-15 -================== - - * use "configurable: true" - * add `travis.yml` file - -0.0.1 / 2013-06-14 -================== - - * Initial release diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/LICENSE deleted file mode 100644 index 2ea4dc5efb8729..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/LICENSE +++ /dev/null @@ -1,24 +0,0 @@ -(The MIT License) - -Copyright (c) 2012 Nathan Rajlich - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/Makefile b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/Makefile deleted file mode 100644 index 0f14dac306f8e0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/Makefile +++ /dev/null @@ -1,11 +0,0 @@ - -build: components index.js - @component build --dev - -components: component.json - @component install --dev - -clean: - rm -fr build components template.js - -.PHONY: clean diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/README.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/README.md deleted file mode 100644 index b8d715d6ebf6c0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/README.md +++ /dev/null @@ -1,155 +0,0 @@ -array-index -=========== -### Invoke getter/setter functions on array-like objects -[![Build Status](https://secure.travis-ci.org/TooTallNate/array-index.svg)](http://travis-ci.org/TooTallNate/array-index) - - -This little module provides an `ArrayIndex` constructor function that you can -inherit from with your own objects. When a numbered property gets read, then the -`ArrayIndex.get` function on the object will be invoked. When a numbered property gets -set, then the `ArrayIndex.set` function on the object will be invoked. - - -Installation ------------- - -Install with `npm`: - -``` bash -$ npm install array-index -``` - - -Examples --------- - -A quick silly example, using `Math.sqrt()` for the "getter": - -``` js -var ArrayIndex = require('array-index'); - -// let's just create a singleton instance. -var a = new ArrayIndex(); - -// the "ArrayIndex.get" function is invoked for each "a[n]" access. -// it is given a single argument, the "index" currently being accessed. -// so here, we're passing in the `Math.sqrt()` function, so accessing -// "a[9]" will return `Math.sqrt(9)`. -a[ArrayIndex.get] = Math.sqrt; - -// the "ArrayIndex.get" and "ArrayIndex.set" functions are only invoked up -// to "a.length", so we must set that manually. -a.length = 10; - -console.log(a); -// [ 0, -// 1, -// 1.4142135623730951, -// 1.7320508075688772, -// 2, -// 2.23606797749979, -// 2.449489742783178, -// 2.6457513110645907, -// 2.8284271247461903, -// 3 ] -``` - -Here's an example of creating a subclass of `ArrayIndex` using `util.inherits()`: - -``` js -var ArrayIndex = require('array-index'); -var inherits = require('util').inherits; - -function MyArray (length) { - // be sure to call the ArrayIndex constructor in your own constructor - ArrayIndex.call(this, length); - - // the "set" object will contain values at indexes previously set, - // so that they can be returned in the "getter" function. This is just a - // silly example, your subclass will have more meaningful logic. - Object.defineProperty(this, 'set', { - value: Object.create(null), - enumerable: false - }); -} - -// inherit from the ArrayIndex's prototype -inherits(MyArray, ArrayIndex); - -MyArray.prototype[ArrayIndex.get] = function (index) { - if (index in this.set) return this.set[index]; - return index * 2; -}; - -MyArray.prototype[ArrayIndex.set] = function (index, v) { - this.set[index] = v; -}; - - -// and now you can create some instances -var a = new MyArray(15); -a[9] = a[10] = a[14] = '_'; -a[0] = 'nate'; - -console.log(a); -// [ 'nate', 2, 4, 6, 8, 10, 12, 14, 16, '_', '_', 22, 24, 26, '_' ] -``` - -API ---- - -The `ArrayIndex` base class is meant to be subclassed, but it also has a few -convenient functions built-in. - -### "length" → Number - -The length of the ArrayIndex instance. The `ArrayIndex.get` and `ArrayIndex.set` functions will -only be invoked on the object up to this "length". You may set this length at any -time to adjust the amount range where the getters/setters will be invoked. - -### "toArray()" → Array - -Returns a new regular Array instance with the same values that this ArrayIndex -class would have. This function calls the `ArrayIndex.get` function repeatedly from -`0...length-1` and returns the "flattened" array instance. - -### "toJSON()" → Array - -All `ArrayIndex` instances get basic support for `JSON.stringify()`, which is -the same as a "flattened" Array being stringified. - -### "toString()" → String - -The `toString()` override is basically just `array.toArray().toString()`. - -### "format()" → String - -The `inspect()` implementation for the REPL attempts to mimic what a regular -Array looks like in the REPL. - - -License -------- - -(The MIT License) - -Copyright (c) 2012 Nathan Rajlich <nathan@tootallnate.net> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/component.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/component.json deleted file mode 100644 index f5f21fc7d642e8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/component.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "array-index", - "repo": "TooTallNate/array-index", - "description": "Invoke getter/setter functions on array-like objects", - "keywords": [ - "index", - "array", - "getter", - "setter", - "proxy" - ], - "version": "1.0.0", - "dependencies": { - "visionmedia/debug": "*" - }, - "development": {}, - "license": "MIT", - "main": "index.js", - "scripts": [ - "index.js" - ] -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/index.js deleted file mode 100644 index a2e4110c1802b7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/index.js +++ /dev/null @@ -1,182 +0,0 @@ - -/** - * Module dependencies. - */ - -var Symbol = require('es6-symbol'); -var debug = require('debug')('array-index'); - -var get = Symbol('get'); -var set = Symbol('set'); -var length = Symbol('length'); - -/** - * JavaScript Array "length" is bound to an unsigned 32-bit int. - * See: http://stackoverflow.com/a/6155063/376773 - */ - -var MAX_LENGTH = Math.pow(2, 32); - -/** - * Module exports. - */ - -module.exports = ArrayIndex; -ArrayIndex.get = get; -ArrayIndex.set = set; - -/** - * Subclass this. - */ - -function ArrayIndex (_length) { - Object.defineProperty(this, 'length', { - get: getLength, - set: setLength, - enumerable: false, - configurable: true - }); - - this[length] = 0; - - if (arguments.length > 0) { - setLength.call(this, _length); - } -} - -/** - * You overwrite the "get" Symbol in your subclass. - */ - -ArrayIndex.prototype[ArrayIndex.get] = function () { - throw new Error('you must implement the `ArrayIndex.get` Symbol'); -}; - -/** - * You overwrite the "set" Symbol in your subclass. - */ - -ArrayIndex.prototype[ArrayIndex.set] = function () { - throw new Error('you must implement the `ArrayIndex.set` Symbol'); -}; - -/** - * Converts this array class into a real JavaScript Array. Note that this - * is a "flattened" array and your defined getters and setters won't be invoked - * when you interact with the returned Array. This function will call the - * getter on every array index of the object. - * - * @return {Array} The flattened array - * @api public - */ - -ArrayIndex.prototype.toArray = function toArray () { - var i = 0; - var l = this.length; - var array = new Array(l); - for (; i < l; i++) { - array[i] = this[i]; - } - return array; -}; - -/** - * Basic support for `JSON.stringify()`. - */ - -ArrayIndex.prototype.toJSON = function toJSON () { - return this.toArray(); -}; - -/** - * toString() override. Use Array.prototype.toString(). - */ - -ArrayIndex.prototype.toString = function toString () { - var a = this.toArray(); - return a.toString.apply(a, arguments); -}; - -/** - * inspect() override. For the REPL. - */ - -ArrayIndex.prototype.inspect = function inspect () { - var a = this.toArray(); - Object.keys(this).forEach(function (k) { - a[k] = this[k]; - }, this); - return a; -}; - -/** - * Getter for the "length" property. - * Returns the value of the "length" Symbol. - */ - -function getLength () { - debug('getting "length": %o', this[length]); - return this[length]; -}; - -/** - * Setter for the "length" property. - * Calls "ensureLength()", then sets the "length" Symbol. - */ - -function setLength (v) { - debug('setting "length": %o', v); - return this[length] = ensureLength(this, v); -}; - -/** - * Ensures that getters/setters from 0 up to "_newLength" have been defined - * on `Object.getPrototypeOf(this)`. - * - * @api private - */ - -function ensureLength (self, _newLength) { - var newLength; - if (_newLength > MAX_LENGTH) { - newLength = MAX_LENGTH; - } else { - newLength = _newLength | 0; - } - var proto = Object.getPrototypeOf(self); - var cur = proto[length] | 0; - var num = newLength - cur; - if (num > 0) { - var desc = {}; - debug('creating a descriptor object with %o entries', num); - for (var i = cur; i < newLength; i++) { - desc[i] = setup(i); - } - debug('calling `Object.defineProperties()` with %o entries', num); - Object.defineProperties(proto, desc); - proto[length] = newLength; - } - return newLength; -} - -/** - * Returns a property descriptor for the given "index", with "get" and "set" - * functions created within the closure. - * - * @api private - */ - -function setup (index) { - function get () { - return this[ArrayIndex.get](index); - } - function set (v) { - return this[ArrayIndex.set](index, v); - } - return { - enumerable: true, - configurable: true, - get: get, - set: set - }; -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/.npmignore deleted file mode 100644 index 7e6163db02e5e7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/.npmignore +++ /dev/null @@ -1,6 +0,0 @@ -support -test -examples -example -*.sock -dist diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/History.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/History.md deleted file mode 100644 index 854c9711c6fd68..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/History.md +++ /dev/null @@ -1,195 +0,0 @@ - -2.2.0 / 2015-05-09 -================== - - * package: update "ms" to v0.7.1 (#202, @dougwilson) - * README: add logging to file example (#193, @DanielOchoa) - * README: fixed a typo (#191, @amir-s) - * browser: expose `storage` (#190, @stephenmathieson) - * Makefile: add a `distclean` target (#189, @stephenmathieson) - -2.1.3 / 2015-03-13 -================== - - * Updated stdout/stderr example (#186) - * Updated example/stdout.js to match debug current behaviour - * Renamed example/stderr.js to stdout.js - * Update Readme.md (#184) - * replace high intensity foreground color for bold (#182, #183) - -2.1.2 / 2015-03-01 -================== - - * dist: recompile - * update "ms" to v0.7.0 - * package: update "browserify" to v9.0.3 - * component: fix "ms.js" repo location - * changed bower package name - * updated documentation about using debug in a browser - * fix: security error on safari (#167, #168, @yields) - -2.1.1 / 2014-12-29 -================== - - * browser: use `typeof` to check for `console` existence - * browser: check for `console.log` truthiness (fix IE 8/9) - * browser: add support for Chrome apps - * Readme: added Windows usage remarks - * Add `bower.json` to properly support bower install - -2.1.0 / 2014-10-15 -================== - - * node: implement `DEBUG_FD` env variable support - * package: update "browserify" to v6.1.0 - * package: add "license" field to package.json (#135, @panuhorsmalahti) - -2.0.0 / 2014-09-01 -================== - - * package: update "browserify" to v5.11.0 - * node: use stderr rather than stdout for logging (#29, @stephenmathieson) - -1.0.4 / 2014-07-15 -================== - - * dist: recompile - * example: remove `console.info()` log usage - * example: add "Content-Type" UTF-8 header to browser example - * browser: place %c marker after the space character - * browser: reset the "content" color via `color: inherit` - * browser: add colors support for Firefox >= v31 - * debug: prefer an instance `log()` function over the global one (#119) - * Readme: update documentation about styled console logs for FF v31 (#116, @wryk) - -1.0.3 / 2014-07-09 -================== - - * Add support for multiple wildcards in namespaces (#122, @seegno) - * browser: fix lint - -1.0.2 / 2014-06-10 -================== - - * browser: update color palette (#113, @gscottolson) - * common: make console logging function configurable (#108, @timoxley) - * node: fix %o colors on old node <= 0.8.x - * Makefile: find node path using shell/which (#109, @timoxley) - -1.0.1 / 2014-06-06 -================== - - * browser: use `removeItem()` to clear localStorage - * browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777) - * package: add "contributors" section - * node: fix comment typo - * README: list authors - -1.0.0 / 2014-06-04 -================== - - * make ms diff be global, not be scope - * debug: ignore empty strings in enable() - * node: make DEBUG_COLORS able to disable coloring - * *: export the `colors` array - * npmignore: don't publish the `dist` dir - * Makefile: refactor to use browserify - * package: add "browserify" as a dev dependency - * Readme: add Web Inspector Colors section - * node: reset terminal color for the debug content - * node: map "%o" to `util.inspect()` - * browser: map "%j" to `JSON.stringify()` - * debug: add custom "formatters" - * debug: use "ms" module for humanizing the diff - * Readme: add "bash" syntax highlighting - * browser: add Firebug color support - * browser: add colors for WebKit browsers - * node: apply log to `console` - * rewrite: abstract common logic for Node & browsers - * add .jshintrc file - -0.8.1 / 2014-04-14 -================== - - * package: re-add the "component" section - -0.8.0 / 2014-03-30 -================== - - * add `enable()` method for nodejs. Closes #27 - * change from stderr to stdout - * remove unnecessary index.js file - -0.7.4 / 2013-11-13 -================== - - * remove "browserify" key from package.json (fixes something in browserify) - -0.7.3 / 2013-10-30 -================== - - * fix: catch localStorage security error when cookies are blocked (Chrome) - * add debug(err) support. Closes #46 - * add .browser prop to package.json. Closes #42 - -0.7.2 / 2013-02-06 -================== - - * fix package.json - * fix: Mobile Safari (private mode) is broken with debug - * fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript - -0.7.1 / 2013-02-05 -================== - - * add repository URL to package.json - * add DEBUG_COLORED to force colored output - * add browserify support - * fix component. Closes #24 - -0.7.0 / 2012-05-04 -================== - - * Added .component to package.json - * Added debug.component.js build - -0.6.0 / 2012-03-16 -================== - - * Added support for "-" prefix in DEBUG [Vinay Pulim] - * Added `.enabled` flag to the node version [TooTallNate] - -0.5.0 / 2012-02-02 -================== - - * Added: humanize diffs. Closes #8 - * Added `debug.disable()` to the CS variant - * Removed padding. Closes #10 - * Fixed: persist client-side variant again. Closes #9 - -0.4.0 / 2012-02-01 -================== - - * Added browser variant support for older browsers [TooTallNate] - * Added `debug.enable('project:*')` to browser variant [TooTallNate] - * Added padding to diff (moved it to the right) - -0.3.0 / 2012-01-26 -================== - - * Added millisecond diff when isatty, otherwise UTC string - -0.2.0 / 2012-01-22 -================== - - * Added wildcard support - -0.1.0 / 2011-12-02 -================== - - * Added: remove colors unless stderr isatty [TooTallNate] - -0.0.1 / 2010-01-03 -================== - - * Initial release diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/Makefile b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/Makefile deleted file mode 100644 index 5cf4a5962b8ba3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/Makefile +++ /dev/null @@ -1,36 +0,0 @@ - -# get Makefile directory name: http://stackoverflow.com/a/5982798/376773 -THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) -THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd) - -# BIN directory -BIN := $(THIS_DIR)/node_modules/.bin - -# applications -NODE ?= $(shell which node) -NPM ?= $(NODE) $(shell which npm) -BROWSERIFY ?= $(NODE) $(BIN)/browserify - -all: dist/debug.js - -install: node_modules - -clean: - @rm -rf dist - -dist: - @mkdir -p $@ - -dist/debug.js: node_modules browser.js debug.js dist - @$(BROWSERIFY) \ - --standalone debug \ - . > $@ - -distclean: clean - @rm -rf node_modules - -node_modules: package.json - @NODE_ENV= $(NPM) install - @touch node_modules - -.PHONY: all install clean distclean diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/Readme.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/Readme.md deleted file mode 100644 index b4f45e3cc6a33a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/Readme.md +++ /dev/null @@ -1,188 +0,0 @@ -# debug - - tiny node.js debugging utility modelled after node core's debugging technique. - -## Installation - -```bash -$ npm install debug -``` - -## Usage - - With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility. - -Example _app.js_: - -```js -var debug = require('debug')('http') - , http = require('http') - , name = 'My App'; - -// fake app - -debug('booting %s', name); - -http.createServer(function(req, res){ - debug(req.method + ' ' + req.url); - res.end('hello\n'); -}).listen(3000, function(){ - debug('listening'); -}); - -// fake worker of some kind - -require('./worker'); -``` - -Example _worker.js_: - -```js -var debug = require('debug')('worker'); - -setInterval(function(){ - debug('doing some work'); -}, 1000); -``` - - The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: - - ![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png) - - ![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png) - -#### Windows note - - On Windows the environment variable is set using the `set` command. - - ```cmd - set DEBUG=*,-not_this - ``` - -Then, run the program to be debugged as usual. - -## Millisecond diff - - When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. - - ![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png) - - When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: - - ![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png) - -## Conventions - - If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". - -## Wildcards - - The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. - - You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". - -## Browser support - - Debug works in the browser as well, currently persisted by `localStorage`. Consider the situation shown below where you have `worker:a` and `worker:b`, and wish to debug both. Somewhere in the code on your page, include: - -```js -window.myDebug = require("debug"); -``` - - ("debug" is a global object in the browser so we give this object a different name.) When your page is open in the browser, type the following in the console: - -```js -myDebug.enable("worker:*") -``` - - Refresh the page. Debug output will continue to be sent to the console until it is disabled by typing `myDebug.disable()` in the console. - -```js -a = debug('worker:a'); -b = debug('worker:b'); - -setInterval(function(){ - a('doing some work'); -}, 1000); - -setInterval(function(){ - b('doing some work'); -}, 1200); -``` - -#### Web Inspector Colors - - Colors are also enabled on "Web Inspectors" that understand the `%c` formatting - option. These are WebKit web inspectors, Firefox ([since version - 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) - and the Firebug plugin for Firefox (any version). - - Colored output looks something like: - - ![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png) - -### stderr vs stdout - -You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally: - -Example _stdout.js_: - -```js -var debug = require('debug'); -var error = debug('app:error'); - -// by default stderr is used -error('goes to stderr!'); - -var log = debug('app:log'); -// set this namespace to log via console.log -log.log = console.log.bind(console); // don't forget to bind to console! -log('goes to stdout'); -error('still goes to stderr!'); - -// set all output to go via console.info -// overrides all per-namespace log settings -debug.log = console.info.bind(console); -error('now goes to stdout via console.info'); -log('still goes to stdout, but via console.info now'); -``` - -### Save debug output to a file - -You can save all debug statements to a file by piping them. - -Example: - -```bash -$ DEBUG_FD=3 node your-app.js 3> whatever.log -``` - -## Authors - - - TJ Holowaychuk - - Nathan Rajlich - -## License - -(The MIT License) - -Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca> - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -'Software'), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/bower.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/bower.json deleted file mode 100644 index 6af573ff5c260d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/bower.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "name": "visionmedia-debug", - "main": "dist/debug.js", - "version": "2.2.0", - "homepage": "https://github.com/visionmedia/debug", - "authors": [ - "TJ Holowaychuk " - ], - "description": "visionmedia-debug", - "moduleType": [ - "amd", - "es6", - "globals", - "node" - ], - "keywords": [ - "visionmedia", - "debug" - ], - "license": "MIT", - "ignore": [ - "**/.*", - "node_modules", - "bower_components", - "test", - "tests" - ] -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/browser.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/browser.js deleted file mode 100644 index 7c76452219939f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/browser.js +++ /dev/null @@ -1,168 +0,0 @@ - -/** - * This is the web browser implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; -exports.storage = 'undefined' != typeof chrome - && 'undefined' != typeof chrome.storage - ? chrome.storage.local - : localstorage(); - -/** - * Colors. - */ - -exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' -]; - -/** - * Currently only WebKit-based Web Inspectors, Firefox >= v31, - * and the Firebug extension (any Firefox version) are known - * to support "%c" CSS customizations. - * - * TODO: add a `localStorage` variable to explicitly enable/disable colors - */ - -function useColors() { - // is webkit? http://stackoverflow.com/a/16459606/376773 - return ('WebkitAppearance' in document.documentElement.style) || - // is firebug? http://stackoverflow.com/a/398120/376773 - (window.console && (console.firebug || (console.exception && console.table))) || - // is firefox >= v31? - // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages - (navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31); -} - -/** - * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. - */ - -exports.formatters.j = function(v) { - return JSON.stringify(v); -}; - - -/** - * Colorize log arguments if enabled. - * - * @api public - */ - -function formatArgs() { - var args = arguments; - var useColors = this.useColors; - - args[0] = (useColors ? '%c' : '') - + this.namespace - + (useColors ? ' %c' : ' ') - + args[0] - + (useColors ? '%c ' : ' ') - + '+' + exports.humanize(this.diff); - - if (!useColors) return args; - - var c = 'color: ' + this.color; - args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1)); - - // the final "%c" is somewhat tricky, because there could be other - // arguments passed either before or after the %c, so we need to - // figure out the correct index to insert the CSS into - var index = 0; - var lastC = 0; - args[0].replace(/%[a-z%]/g, function(match) { - if ('%%' === match) return; - index++; - if ('%c' === match) { - // we only are interested in the *last* %c - // (the user may have provided their own) - lastC = index; - } - }); - - args.splice(lastC, 0, c); - return args; -} - -/** - * Invokes `console.log()` when available. - * No-op when `console.log` is not a "function". - * - * @api public - */ - -function log() { - // this hackery is required for IE8/9, where - // the `console.log` function doesn't have 'apply' - return 'object' === typeof console - && console.log - && Function.prototype.apply.call(console.log, console, arguments); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - try { - if (null == namespaces) { - exports.storage.removeItem('debug'); - } else { - exports.storage.debug = namespaces; - } - } catch(e) {} -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - var r; - try { - r = exports.storage.debug; - } catch(e) {} - return r; -} - -/** - * Enable namespaces listed in `localStorage.debug` initially. - */ - -exports.enable(load()); - -/** - * Localstorage attempts to return the localstorage. - * - * This is necessary because safari throws - * when a user disables cookies/localstorage - * and you attempt to access it. - * - * @return {LocalStorage} - * @api private - */ - -function localstorage(){ - try { - return window.localStorage; - } catch (e) {} -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/component.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/component.json deleted file mode 100644 index ca1063724a4498..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/component.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "debug", - "repo": "visionmedia/debug", - "description": "small debugging utility", - "version": "2.2.0", - "keywords": [ - "debug", - "log", - "debugger" - ], - "main": "browser.js", - "scripts": [ - "browser.js", - "debug.js" - ], - "dependencies": { - "rauchg/ms.js": "0.7.1" - } -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/debug.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/debug.js deleted file mode 100644 index 7571a86058aec0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/debug.js +++ /dev/null @@ -1,197 +0,0 @@ - -/** - * This is the common logic for both the Node.js and web browser - * implementations of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = debug; -exports.coerce = coerce; -exports.disable = disable; -exports.enable = enable; -exports.enabled = enabled; -exports.humanize = require('ms'); - -/** - * The currently active debug mode names, and names to skip. - */ - -exports.names = []; -exports.skips = []; - -/** - * Map of special "%n" handling functions, for the debug "format" argument. - * - * Valid key names are a single, lowercased letter, i.e. "n". - */ - -exports.formatters = {}; - -/** - * Previously assigned color. - */ - -var prevColor = 0; - -/** - * Previous log timestamp. - */ - -var prevTime; - -/** - * Select a color. - * - * @return {Number} - * @api private - */ - -function selectColor() { - return exports.colors[prevColor++ % exports.colors.length]; -} - -/** - * Create a debugger with the given `namespace`. - * - * @param {String} namespace - * @return {Function} - * @api public - */ - -function debug(namespace) { - - // define the `disabled` version - function disabled() { - } - disabled.enabled = false; - - // define the `enabled` version - function enabled() { - - var self = enabled; - - // set `diff` timestamp - var curr = +new Date(); - var ms = curr - (prevTime || curr); - self.diff = ms; - self.prev = prevTime; - self.curr = curr; - prevTime = curr; - - // add the `color` if not set - if (null == self.useColors) self.useColors = exports.useColors(); - if (null == self.color && self.useColors) self.color = selectColor(); - - var args = Array.prototype.slice.call(arguments); - - args[0] = exports.coerce(args[0]); - - if ('string' !== typeof args[0]) { - // anything else let's inspect with %o - args = ['%o'].concat(args); - } - - // apply any `formatters` transformations - var index = 0; - args[0] = args[0].replace(/%([a-z%])/g, function(match, format) { - // if we encounter an escaped % then don't increase the array index - if (match === '%%') return match; - index++; - var formatter = exports.formatters[format]; - if ('function' === typeof formatter) { - var val = args[index]; - match = formatter.call(self, val); - - // now we need to remove `args[index]` since it's inlined in the `format` - args.splice(index, 1); - index--; - } - return match; - }); - - if ('function' === typeof exports.formatArgs) { - args = exports.formatArgs.apply(self, args); - } - var logFn = enabled.log || exports.log || console.log.bind(console); - logFn.apply(self, args); - } - enabled.enabled = true; - - var fn = exports.enabled(namespace) ? enabled : disabled; - - fn.namespace = namespace; - - return fn; -} - -/** - * Enables a debug mode by namespaces. This can include modes - * separated by a colon and wildcards. - * - * @param {String} namespaces - * @api public - */ - -function enable(namespaces) { - exports.save(namespaces); - - var split = (namespaces || '').split(/[\s,]+/); - var len = split.length; - - for (var i = 0; i < len; i++) { - if (!split[i]) continue; // ignore empty strings - namespaces = split[i].replace(/\*/g, '.*?'); - if (namespaces[0] === '-') { - exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); - } else { - exports.names.push(new RegExp('^' + namespaces + '$')); - } - } -} - -/** - * Disable debug output. - * - * @api public - */ - -function disable() { - exports.enable(''); -} - -/** - * Returns true if the given mode name is enabled, false otherwise. - * - * @param {String} name - * @return {Boolean} - * @api public - */ - -function enabled(name) { - var i, len; - for (i = 0, len = exports.skips.length; i < len; i++) { - if (exports.skips[i].test(name)) { - return false; - } - } - for (i = 0, len = exports.names.length; i < len; i++) { - if (exports.names[i].test(name)) { - return true; - } - } - return false; -} - -/** - * Coerce `val`. - * - * @param {Mixed} val - * @return {Mixed} - * @api private - */ - -function coerce(val) { - if (val instanceof Error) return val.stack || val.message; - return val; -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node.js deleted file mode 100644 index 1d392a81d6c785..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node.js +++ /dev/null @@ -1,209 +0,0 @@ - -/** - * Module dependencies. - */ - -var tty = require('tty'); -var util = require('util'); - -/** - * This is the Node.js implementation of `debug()`. - * - * Expose `debug()` as the module. - */ - -exports = module.exports = require('./debug'); -exports.log = log; -exports.formatArgs = formatArgs; -exports.save = save; -exports.load = load; -exports.useColors = useColors; - -/** - * Colors. - */ - -exports.colors = [6, 2, 3, 4, 5, 1]; - -/** - * The file descriptor to write the `debug()` calls to. - * Set the `DEBUG_FD` env variable to override with another value. i.e.: - * - * $ DEBUG_FD=3 node script.js 3>debug.log - */ - -var fd = parseInt(process.env.DEBUG_FD, 10) || 2; -var stream = 1 === fd ? process.stdout : - 2 === fd ? process.stderr : - createWritableStdioStream(fd); - -/** - * Is stdout a TTY? Colored output is enabled when `true`. - */ - -function useColors() { - var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase(); - if (0 === debugColors.length) { - return tty.isatty(fd); - } else { - return '0' !== debugColors - && 'no' !== debugColors - && 'false' !== debugColors - && 'disabled' !== debugColors; - } -} - -/** - * Map %o to `util.inspect()`, since Node doesn't do that out of the box. - */ - -var inspect = (4 === util.inspect.length ? - // node <= 0.8.x - function (v, colors) { - return util.inspect(v, void 0, void 0, colors); - } : - // node > 0.8.x - function (v, colors) { - return util.inspect(v, { colors: colors }); - } -); - -exports.formatters.o = function(v) { - return inspect(v, this.useColors) - .replace(/\s*\n\s*/g, ' '); -}; - -/** - * Adds ANSI color escape codes if enabled. - * - * @api public - */ - -function formatArgs() { - var args = arguments; - var useColors = this.useColors; - var name = this.namespace; - - if (useColors) { - var c = this.color; - - args[0] = ' \u001b[3' + c + ';1m' + name + ' ' - + '\u001b[0m' - + args[0] + '\u001b[3' + c + 'm' - + ' +' + exports.humanize(this.diff) + '\u001b[0m'; - } else { - args[0] = new Date().toUTCString() - + ' ' + name + ' ' + args[0]; - } - return args; -} - -/** - * Invokes `console.error()` with the specified arguments. - */ - -function log() { - return stream.write(util.format.apply(this, arguments) + '\n'); -} - -/** - * Save `namespaces`. - * - * @param {String} namespaces - * @api private - */ - -function save(namespaces) { - if (null == namespaces) { - // If you set a process.env field to null or undefined, it gets cast to the - // string 'null' or 'undefined'. Just delete instead. - delete process.env.DEBUG; - } else { - process.env.DEBUG = namespaces; - } -} - -/** - * Load `namespaces`. - * - * @return {String} returns the previously persisted debug modes - * @api private - */ - -function load() { - return process.env.DEBUG; -} - -/** - * Copied from `node/src/node.js`. - * - * XXX: It's lame that node doesn't expose this API out-of-the-box. It also - * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame. - */ - -function createWritableStdioStream (fd) { - var stream; - var tty_wrap = process.binding('tty_wrap'); - - // Note stream._type is used for test-module-load-list.js - - switch (tty_wrap.guessHandleType(fd)) { - case 'TTY': - stream = new tty.WriteStream(fd); - stream._type = 'tty'; - - // Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - case 'FILE': - var fs = require('fs'); - stream = new fs.SyncWriteStream(fd, { autoClose: false }); - stream._type = 'fs'; - break; - - case 'PIPE': - case 'TCP': - var net = require('net'); - stream = new net.Socket({ - fd: fd, - readable: false, - writable: true - }); - - // FIXME Should probably have an option in net.Socket to create a - // stream from an existing fd which is writable only. But for now - // we'll just add this hack and set the `readable` member to false. - // Test: ./node test/fixtures/echo.js < /etc/passwd - stream.readable = false; - stream.read = null; - stream._type = 'pipe'; - - // FIXME Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - default: - // Probably an error on in uv_guess_handle() - throw new Error('Implement me. Unknown stream file type!'); - } - - // For supporting legacy API we put the FD here. - stream.fd = fd; - - stream._isStdio = true; - - return stream; -} - -/** - * Enable namespaces listed in `process.env.DEBUG` initially. - */ - -exports.enable(load()); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/.npmignore deleted file mode 100644 index d1aa0ce42e1360..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -node_modules -test -History.md -Makefile -component.json diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/History.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/History.md deleted file mode 100644 index 32fdfc17623565..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/History.md +++ /dev/null @@ -1,66 +0,0 @@ - -0.7.1 / 2015-04-20 -================== - - * prevent extraordinary long inputs (@evilpacket) - * Fixed broken readme link - -0.7.0 / 2014-11-24 -================== - - * add time abbreviations, updated tests and readme for the new units - * fix example in the readme. - * add LICENSE file - -0.6.2 / 2013-12-05 -================== - - * Adding repository section to package.json to suppress warning from NPM. - -0.6.1 / 2013-05-10 -================== - - * fix singularization [visionmedia] - -0.6.0 / 2013-03-15 -================== - - * fix minutes - -0.5.1 / 2013-02-24 -================== - - * add component namespace - -0.5.0 / 2012-11-09 -================== - - * add short formatting as default and .long option - * add .license property to component.json - * add version to component.json - -0.4.0 / 2012-10-22 -================== - - * add rounding to fix crazy decimals - -0.3.0 / 2012-09-07 -================== - - * fix `ms()` [visionmedia] - -0.2.0 / 2012-09-03 -================== - - * add component.json [visionmedia] - * add days support [visionmedia] - * add hours support [visionmedia] - * add minutes support [visionmedia] - * add seconds support [visionmedia] - * add ms string support [visionmedia] - * refactor tests to facilitate ms(number) [visionmedia] - -0.1.0 / 2012-03-07 -================== - - * Initial release diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/LICENSE deleted file mode 100644 index 6c07561b62ddfa..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/LICENSE +++ /dev/null @@ -1,20 +0,0 @@ -(The MIT License) - -Copyright (c) 2014 Guillermo Rauch - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/README.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/README.md deleted file mode 100644 index 9b4fd03581b18c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/README.md +++ /dev/null @@ -1,35 +0,0 @@ -# ms.js: miliseconds conversion utility - -```js -ms('2 days') // 172800000 -ms('1d') // 86400000 -ms('10h') // 36000000 -ms('2.5 hrs') // 9000000 -ms('2h') // 7200000 -ms('1m') // 60000 -ms('5s') // 5000 -ms('100') // 100 -``` - -```js -ms(60000) // "1m" -ms(2 * 60000) // "2m" -ms(ms('10 hours')) // "10h" -``` - -```js -ms(60000, { long: true }) // "1 minute" -ms(2 * 60000, { long: true }) // "2 minutes" -ms(ms('10 hours'), { long: true }) // "10 hours" -``` - -- Node/Browser compatible. Published as [`ms`](https://www.npmjs.org/package/ms) in [NPM](http://nodejs.org/download). -- If a number is supplied to `ms`, a string with a unit is returned. -- If a string that contains the number is supplied, it returns it as -a number (e.g: it returns `100` for `'100'`). -- If you pass a string with a number and a valid unit, the number of -equivalent ms is returned. - -## License - -MIT diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/index.js deleted file mode 100644 index 4f9277169674b4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/index.js +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Helpers. - */ - -var s = 1000; -var m = s * 60; -var h = m * 60; -var d = h * 24; -var y = d * 365.25; - -/** - * Parse or format the given `val`. - * - * Options: - * - * - `long` verbose formatting [false] - * - * @param {String|Number} val - * @param {Object} options - * @return {String|Number} - * @api public - */ - -module.exports = function(val, options){ - options = options || {}; - if ('string' == typeof val) return parse(val); - return options.long - ? long(val) - : short(val); -}; - -/** - * Parse the given `str` and return milliseconds. - * - * @param {String} str - * @return {Number} - * @api private - */ - -function parse(str) { - str = '' + str; - if (str.length > 10000) return; - var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(str); - if (!match) return; - var n = parseFloat(match[1]); - var type = (match[2] || 'ms').toLowerCase(); - switch (type) { - case 'years': - case 'year': - case 'yrs': - case 'yr': - case 'y': - return n * y; - case 'days': - case 'day': - case 'd': - return n * d; - case 'hours': - case 'hour': - case 'hrs': - case 'hr': - case 'h': - return n * h; - case 'minutes': - case 'minute': - case 'mins': - case 'min': - case 'm': - return n * m; - case 'seconds': - case 'second': - case 'secs': - case 'sec': - case 's': - return n * s; - case 'milliseconds': - case 'millisecond': - case 'msecs': - case 'msec': - case 'ms': - return n; - } -} - -/** - * Short format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function short(ms) { - if (ms >= d) return Math.round(ms / d) + 'd'; - if (ms >= h) return Math.round(ms / h) + 'h'; - if (ms >= m) return Math.round(ms / m) + 'm'; - if (ms >= s) return Math.round(ms / s) + 's'; - return ms + 'ms'; -} - -/** - * Long format for `ms`. - * - * @param {Number} ms - * @return {String} - * @api private - */ - -function long(ms) { - return plural(ms, d, 'day') - || plural(ms, h, 'hour') - || plural(ms, m, 'minute') - || plural(ms, s, 'second') - || ms + ' ms'; -} - -/** - * Pluralization helper. - */ - -function plural(ms, n, name) { - if (ms < n) return; - if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name; - return Math.ceil(ms / n) + ' ' + name + 's'; -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/package.json deleted file mode 100644 index f037c9bfd85416..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/node_modules/ms/package.json +++ /dev/null @@ -1,83 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "ms@0.7.1", - "scope": null, - "escapedName": "ms", - "name": "ms", - "rawSpec": "0.7.1", - "spec": "0.7.1", - "type": "version" - }, - "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug" - ] - ], - "_from": "ms@0.7.1", - "_id": "ms@0.7.1", - "_inCache": true, - "_installable": true, - "_location": "/node-gyp/path-array/array-index/debug/ms", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "rauchg", - "email": "rauchg@gmail.com" - }, - "_npmVersion": "2.7.5", - "_phantomChildren": {}, - "_requested": { - "raw": "ms@0.7.1", - "scope": null, - "escapedName": "ms", - "name": "ms", - "rawSpec": "0.7.1", - "spec": "0.7.1", - "type": "version" - }, - "_requiredBy": [ - "/node-gyp/path-array/array-index/debug" - ], - "_resolved": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz", - "_shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "_shrinkwrap": null, - "_spec": "ms@0.7.1", - "_where": "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug", - "bugs": { - "url": "https://github.com/guille/ms.js/issues" - }, - "component": { - "scripts": { - "ms/index.js": "index.js" - } - }, - "dependencies": {}, - "description": "Tiny ms conversion utility", - "devDependencies": { - "expect.js": "*", - "mocha": "*", - "serve": "*" - }, - "directories": {}, - "dist": { - "shasum": "9cd13c03adbff25b65effde7ce864ee952017098", - "tarball": "https://registry.npmjs.org/ms/-/ms-0.7.1.tgz" - }, - "gitHead": "713dcf26d9e6fd9dbc95affe7eff9783b7f1b909", - "homepage": "https://github.com/guille/ms.js", - "main": "./index", - "maintainers": [ - { - "name": "rauchg", - "email": "rauchg@gmail.com" - } - ], - "name": "ms", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/guille/ms.js.git" - }, - "scripts": {}, - "version": "0.7.1" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/package.json deleted file mode 100644 index 08cc48fc547aa2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/debug/package.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "debug@^2.2.0", - "scope": null, - "escapedName": "debug", - "name": "debug", - "rawSpec": "^2.2.0", - "spec": ">=2.2.0 <3.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index" - ] - ], - "_from": "debug@>=2.2.0 <3.0.0", - "_id": "debug@2.2.0", - "_inCache": true, - "_installable": true, - "_location": "/node-gyp/path-array/array-index/debug", - "_nodeVersion": "0.12.2", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "_npmVersion": "2.7.4", - "_phantomChildren": {}, - "_requested": { - "raw": "debug@^2.2.0", - "scope": null, - "escapedName": "debug", - "name": "debug", - "rawSpec": "^2.2.0", - "spec": ">=2.2.0 <3.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/path-array/array-index" - ], - "_resolved": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz", - "_shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "_shrinkwrap": null, - "_spec": "debug@^2.2.0", - "_where": "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index", - "author": { - "name": "TJ Holowaychuk", - "email": "tj@vision-media.ca" - }, - "browser": "./browser.js", - "bugs": { - "url": "https://github.com/visionmedia/debug/issues" - }, - "component": { - "scripts": { - "debug/index.js": "browser.js", - "debug/debug.js": "debug.js" - } - }, - "contributors": [ - { - "name": "Nathan Rajlich", - "email": "nathan@tootallnate.net", - "url": "http://n8.io" - } - ], - "dependencies": { - "ms": "0.7.1" - }, - "description": "small debugging utility", - "devDependencies": { - "browserify": "9.0.3", - "mocha": "*" - }, - "directories": {}, - "dist": { - "shasum": "f87057e995b1a1f6ae6a4960664137bc56f039da", - "tarball": "https://registry.npmjs.org/debug/-/debug-2.2.0.tgz" - }, - "gitHead": "b38458422b5aa8aa6d286b10dfe427e8a67e2b35", - "homepage": "https://github.com/visionmedia/debug", - "keywords": [ - "debug", - "log", - "debugger" - ], - "license": "MIT", - "main": "./node.js", - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } - ], - "name": "debug", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/visionmedia/debug.git" - }, - "scripts": {}, - "version": "2.2.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.lint b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.lint deleted file mode 100644 index df1e53cd5f547e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.lint +++ /dev/null @@ -1,15 +0,0 @@ -@root - -module - -tabs -indent 2 -maxlen 100 - -ass -nomen -plusplus -newcap -vars - -predef+ Symbol diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.npmignore deleted file mode 100644 index 155e41f69142ef..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -.DS_Store -/node_modules -/npm-debug.log -/.lintcache diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.travis.yml deleted file mode 100644 index 0b1f5e4ae340b6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -sudo: false # http://docs.travis-ci.com/user/workers/container-based-infrastructure/ -language: node_js -node_js: - - 0.12 - - v4 - - v5 - - v6 - -notifications: - email: - - medikoo+es6-symbol@medikoo.com diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/CHANGES b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/CHANGES deleted file mode 100644 index 6aebe74ada9f65..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/CHANGES +++ /dev/null @@ -1,52 +0,0 @@ -v3.1.0 -- 2016.05.17 -* Fix internals of symbol detection -* Ensure Symbol.prototype[Symbol.toPrimitive] in all cases returns primitive value - (fixes Node v6 support) -* Create native symbols whenver possible - -v3.0.2 -- 2015.12.12 -* Fix definition flow, so uneven state of Symbol implementation doesn't crash initialization of - polyfill. See #13 - -v3.0.1 -- 2015.10.22 -* Workaround for IE11 bug (reported in #12) - -v3.0.0 -- 2015.10.02 -* Reuse native symbols (e.g. iterator, toStringTag etc.) in a polyfill if they're available - Otherwise polyfill symbols may not be recognized by other functions -* Improve documentation - -v2.0.1 -- 2015.01.28 -* Fix Symbol.prototype[Symbol.isPrimitive] implementation -* Improve validation within Symbol.prototype.toString and - Symbol.prototype.valueOf - -v2.0.0 -- 2015.01.28 -* Update up to changes in specification: - * Implement `for` and `keyFor` - * Remove `Symbol.create` and `Symbol.isRegExp` - * Add `Symbol.match`, `Symbol.replace`, `Symbol.search`, `Symbol.species` and - `Symbol.split` -* Rename `validSymbol` to `validateSymbol` -* Improve documentation -* Remove dead test modules - -v1.0.0 -- 2015.01.26 -* Fix enumerability for symbol properties set normally (e.g. obj[symbol] = value) -* Introduce initialization via hidden constructor -* Fix isSymbol handling of polyfill values when native Symbol is present -* Fix spelling of LICENSE -* Configure lint scripts - -v0.1.1 -- 2014.10.07 -* Fix isImplemented, so it returns true in case of polyfill -* Improve documentations - -v0.1.0 -- 2014.04.28 -* Assure strictly npm dependencies -* Update to use latest versions of dependencies -* Fix implementation detection so it doesn't crash on `String(symbol)` -* throw on `new Symbol()` (as decided by TC39) - -v0.0.0 -- 2013.11.15 -* Initial (dev) version \ No newline at end of file diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/LICENSE deleted file mode 100644 index 04724a3ab1b70b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/README.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/README.md deleted file mode 100644 index 0fa8978450cb4f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# es6-symbol -## ECMAScript 6 Symbol polyfill - -For more information about symbols see following links -- [Symbols in ECMAScript 6 by Axel Rauschmayer](http://www.2ality.com/2014/12/es6-symbols.html) -- [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) -- [Specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-constructor) - -### Limitations - -Underneath it uses real string property names which can easily be retrieved, however accidental collision with other property names is unlikely. - -### Usage - -It’s safest to use *es6-symbol* as a [ponyfill](http://kikobeats.com/polyfill-ponyfill-and-prollyfill/) – a polyfill which doesn’t touch global objects: - -```javascript -var Symbol = require('es6-symbol'); -``` - -If you want to make sure your environment implements `Symbol` globally, do: - -```javascript -require('es6-symbol/implement'); -``` - -If you strictly want to use polyfill even if native `Symbol` exists (hard to find a good reason for that), do: - -```javascript -var Symbol = require('es6-symbol/polyfill'); -``` - -#### API - -Best is to refer to [specification](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-symbol-objects). Still if you want quick look, follow examples: - -```javascript -var Symbol = require('es6-symbol'); - -var symbol = Symbol('My custom symbol'); -var x = {}; - -x[symbol] = 'foo'; -console.log(x[symbol]); 'foo' - -// Detect iterable: -var iterator, result; -if (possiblyIterable[Symbol.iterator]) { - iterator = possiblyIterable[Symbol.iterator](); - result = iterator.next(); - while(!result.done) { - console.log(result.value); - result = iterator.next(); - } -} -``` - -### Installation -#### NPM - -In your project path: - - $ npm install es6-symbol - -##### Browser - -To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) - -## Tests [![Build Status](https://travis-ci.org/medikoo/es6-symbol.png)](https://travis-ci.org/medikoo/es6-symbol) - - $ npm test diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/implement.js deleted file mode 100644 index 153edacdbedf9b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/implement.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(require('es5-ext/global'), 'Symbol', - { value: require('./polyfill'), configurable: true, enumerable: false, - writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/index.js deleted file mode 100644 index 609f1faf551164..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? Symbol : require('./polyfill'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-implemented.js deleted file mode 100644 index 93629d2f84768a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-implemented.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var validTypes = { object: true, symbol: true }; - -module.exports = function () { - var symbol; - if (typeof Symbol !== 'function') return false; - symbol = Symbol('test symbol'); - try { String(symbol); } catch (e) { return false; } - - // Return 'true' also for polyfills - if (!validTypes[typeof Symbol.iterator]) return false; - if (!validTypes[typeof Symbol.toPrimitive]) return false; - if (!validTypes[typeof Symbol.toStringTag]) return false; - - return true; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-native-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-native-implemented.js deleted file mode 100644 index 5f073a19cab7c8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-native-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -// Exports true if environment provides native `Symbol` implementation - -'use strict'; - -module.exports = (function () { - if (typeof Symbol !== 'function') return false; - return (typeof Symbol() === 'symbol'); -}()); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-symbol.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-symbol.js deleted file mode 100644 index 074cb07fb575c2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/is-symbol.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (x) { - if (!x) return false; - if (typeof x === 'symbol') return true; - if (!x.constructor) return false; - if (x.constructor.name !== 'Symbol') return false; - return (x[x.constructor.toStringTag] === 'Symbol'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/.lint b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/.lint deleted file mode 100644 index 858b75353b331c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/.lint +++ /dev/null @@ -1,12 +0,0 @@ -@root - -es5 -module - -tabs -indent 2 -maxlen 80 - -ass -nomen -plusplus diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/.npmignore deleted file mode 100644 index 155e41f69142ef..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -.DS_Store -/node_modules -/npm-debug.log -/.lintcache diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/.travis.yml deleted file mode 100644 index 50008b23e6bcb9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: node_js -node_js: - - 0.8 - - 0.10 - - 0.11 - -notifications: - email: - - medikoo+d@medikoo.com diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/CHANGES b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/CHANGES deleted file mode 100644 index 45233f747eca72..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/CHANGES +++ /dev/null @@ -1,7 +0,0 @@ -v0.1.1 -- 2014.04.24 -- Add `autoBind` and `lazy` utilities -- Allow to pass other options to be merged onto created descriptor. - Useful when used with other custom utilties - -v0.1.0 -- 2013.06.20 -Initial (derived from es5-ext project) diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/LICENCE b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/LICENCE deleted file mode 100644 index aaf35282f41f57..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/LICENCE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2013 Mariusz Nowak (www.medikoo.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/README.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/README.md deleted file mode 100644 index 872d493ed86b6b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/README.md +++ /dev/null @@ -1,108 +0,0 @@ -# D - Property descriptor factory - -_Originally derived from [es5-ext](https://github.com/medikoo/es5-ext) package._ - -Defining properties with descriptors is very verbose: - -```javascript -var Account = function () {}; -Object.defineProperties(Account.prototype, { - deposit: { value: function () { - /* ... */ - }, configurable: true, enumerable: false, writable: true }, - whithdraw: { value: function () { - /* ... */ - }, configurable: true, enumerable: false, writable: true }, - balance: { get: function () { - /* ... */ - }, configurable: true, enumerable: false } -}); -``` - -D cuts that to: - -```javascript -var d = require('d'); - -var Account = function () {}; -Object.defineProperties(Account.prototype, { - deposit: d(function () { - /* ... */ - }), - whithdraw: d(function () { - /* ... */ - }), - balance: d.gs(function () { - /* ... */ - }) -}); -``` - -By default, created descriptor follow characteristics of native ES5 properties, and defines values as: - -```javascript -{ configurable: true, enumerable: false, writable: true } -``` - -You can overwrite it by preceding _value_ argument with instruction: -```javascript -d('c', value); // { configurable: true, enumerable: false, writable: false } -d('ce', value); // { configurable: true, enumerable: true, writable: false } -d('e', value); // { configurable: false, enumerable: true, writable: false } - -// Same way for get/set: -d.gs('e', value); // { configurable: false, enumerable: true } -``` - -### Other utilities - -#### autoBind(obj, props) _(d/auto-bind)_ - -Define methods which will be automatically bound to its instances - -```javascript -var d = require('d'); -var autoBind = require('d/auto-bind'); - -var Foo = function () { this._count = 0; }; -autoBind(Foo.prototype, { - increment: d(function () { ++this._count; }); -}); - -var foo = new Foo(); - -// Increment foo counter on each domEl click -domEl.addEventListener('click', foo.increment, false); -``` - -#### lazy(obj, props) _(d/lazy)_ - -Define lazy properties, which will be resolved on first access - -```javascript -var d = require('d'); -var lazy = require('d/lazy'); - -var Foo = function () {}; -lazy(Foo.prototype, { - items: d(function () { return []; }) -}); - -var foo = new Foo(); -foo.items.push(1, 2); // foo.items array created -``` - -## Installation -### NPM - -In your project path: - - $ npm install d - -### Browser - -You can easily bundle _D_ for browser with [modules-webmake](https://github.com/medikoo/modules-webmake) - -## Tests [![Build Status](https://travis-ci.org/medikoo/d.png)](https://travis-ci.org/medikoo/d) - - $ npm test diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/auto-bind.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/auto-bind.js deleted file mode 100644 index 1b00dba3cc3ddf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/auto-bind.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -var copy = require('es5-ext/object/copy') - , map = require('es5-ext/object/map') - , callable = require('es5-ext/object/valid-callable') - , validValue = require('es5-ext/object/valid-value') - - , bind = Function.prototype.bind, defineProperty = Object.defineProperty - , hasOwnProperty = Object.prototype.hasOwnProperty - , define; - -define = function (name, desc, bindTo) { - var value = validValue(desc) && callable(desc.value), dgs; - dgs = copy(desc); - delete dgs.writable; - delete dgs.value; - dgs.get = function () { - if (hasOwnProperty.call(this, name)) return value; - desc.value = bind.call(value, (bindTo == null) ? this : this[bindTo]); - defineProperty(this, name, desc); - return this[name]; - }; - return dgs; -}; - -module.exports = function (props/*, bindTo*/) { - var bindTo = arguments[1]; - return map(props, function (desc, name) { - return define(name, desc, bindTo); - }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/index.js deleted file mode 100644 index 076ae465f60c4b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/index.js +++ /dev/null @@ -1,63 +0,0 @@ -'use strict'; - -var assign = require('es5-ext/object/assign') - , normalizeOpts = require('es5-ext/object/normalize-options') - , isCallable = require('es5-ext/object/is-callable') - , contains = require('es5-ext/string/#/contains') - - , d; - -d = module.exports = function (dscr, value/*, options*/) { - var c, e, w, options, desc; - if ((arguments.length < 2) || (typeof dscr !== 'string')) { - options = value; - value = dscr; - dscr = null; - } else { - options = arguments[2]; - } - if (dscr == null) { - c = w = true; - e = false; - } else { - c = contains.call(dscr, 'c'); - e = contains.call(dscr, 'e'); - w = contains.call(dscr, 'w'); - } - - desc = { value: value, configurable: c, enumerable: e, writable: w }; - return !options ? desc : assign(normalizeOpts(options), desc); -}; - -d.gs = function (dscr, get, set/*, options*/) { - var c, e, options, desc; - if (typeof dscr !== 'string') { - options = set; - set = get; - get = dscr; - dscr = null; - } else { - options = arguments[3]; - } - if (get == null) { - get = undefined; - } else if (!isCallable(get)) { - options = get; - get = set = undefined; - } else if (set == null) { - set = undefined; - } else if (!isCallable(set)) { - options = set; - set = undefined; - } - if (dscr == null) { - c = true; - e = false; - } else { - c = contains.call(dscr, 'c'); - e = contains.call(dscr, 'e'); - } - - desc = { get: get, set: set, configurable: c, enumerable: e }; - return !options ? desc : assign(normalizeOpts(options), desc); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/lazy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/lazy.js deleted file mode 100644 index 61e466535f3dab..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/lazy.js +++ /dev/null @@ -1,111 +0,0 @@ -'use strict'; - -var map = require('es5-ext/object/map') - , isCallable = require('es5-ext/object/is-callable') - , validValue = require('es5-ext/object/valid-value') - , contains = require('es5-ext/string/#/contains') - - , call = Function.prototype.call - , defineProperty = Object.defineProperty - , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor - , getPrototypeOf = Object.getPrototypeOf - , hasOwnProperty = Object.prototype.hasOwnProperty - , cacheDesc = { configurable: false, enumerable: false, writable: false, - value: null } - , define; - -define = function (name, options) { - var value, dgs, cacheName, desc, writable = false, resolvable - , flat; - options = Object(validValue(options)); - cacheName = options.cacheName; - flat = options.flat; - if (cacheName == null) cacheName = name; - delete options.cacheName; - value = options.value; - resolvable = isCallable(value); - delete options.value; - dgs = { configurable: Boolean(options.configurable), - enumerable: Boolean(options.enumerable) }; - if (name !== cacheName) { - dgs.get = function () { - if (hasOwnProperty.call(this, cacheName)) return this[cacheName]; - cacheDesc.value = resolvable ? call.call(value, this, options) : value; - cacheDesc.writable = writable; - defineProperty(this, cacheName, cacheDesc); - cacheDesc.value = null; - if (desc) defineProperty(this, name, desc); - return this[cacheName]; - }; - } else if (!flat) { - dgs.get = function self() { - var ownDesc; - if (hasOwnProperty.call(this, name)) { - ownDesc = getOwnPropertyDescriptor(this, name); - // It happens in Safari, that getter is still called after property - // was defined with a value, following workarounds that - if (ownDesc.hasOwnProperty('value')) return ownDesc.value; - if ((typeof ownDesc.get === 'function') && (ownDesc.get !== self)) { - return ownDesc.get.call(this); - } - return value; - } - desc.value = resolvable ? call.call(value, this, options) : value; - defineProperty(this, name, desc); - desc.value = null; - return this[name]; - }; - } else { - dgs.get = function self() { - var base = this, ownDesc; - if (hasOwnProperty.call(this, name)) { - // It happens in Safari, that getter is still called after property - // was defined with a value, following workarounds that - ownDesc = getOwnPropertyDescriptor(this, name); - if (ownDesc.hasOwnProperty('value')) return ownDesc.value; - if ((typeof ownDesc.get === 'function') && (ownDesc.get !== self)) { - return ownDesc.get.call(this); - } - } - while (!hasOwnProperty.call(base, name)) base = getPrototypeOf(base); - desc.value = resolvable ? call.call(value, base, options) : value; - defineProperty(base, name, desc); - desc.value = null; - return base[name]; - }; - } - dgs.set = function (value) { - dgs.get.call(this); - this[cacheName] = value; - }; - if (options.desc) { - desc = { - configurable: contains.call(options.desc, 'c'), - enumerable: contains.call(options.desc, 'e') - }; - if (cacheName === name) { - desc.writable = contains.call(options.desc, 'w'); - desc.value = null; - } else { - writable = contains.call(options.desc, 'w'); - desc.get = dgs.get; - desc.set = dgs.set; - } - delete options.desc; - } else if (cacheName === name) { - desc = { - configurable: Boolean(options.configurable), - enumerable: Boolean(options.enumerable), - writable: Boolean(options.writable), - value: null - }; - } - delete options.configurable; - delete options.enumerable; - delete options.writable; - return dgs; -}; - -module.exports = function (props) { - return map(props, function (desc, name) { return define(name, desc); }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/package.json deleted file mode 100644 index 0c7a110a4d164d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/package.json +++ /dev/null @@ -1,94 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "d@~0.1.1", - "scope": null, - "escapedName": "d", - "name": "d", - "rawSpec": "~0.1.1", - "spec": ">=0.1.1 <0.2.0", - "type": "range" - }, - "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol" - ] - ], - "_from": "d@>=0.1.1 <0.2.0", - "_id": "d@0.1.1", - "_inCache": true, - "_installable": true, - "_location": "/node-gyp/path-array/array-index/es6-symbol/d", - "_npmUser": { - "name": "medikoo", - "email": "medikoo+npm@medikoo.com" - }, - "_npmVersion": "1.4.3", - "_phantomChildren": {}, - "_requested": { - "raw": "d@~0.1.1", - "scope": null, - "escapedName": "d", - "name": "d", - "rawSpec": "~0.1.1", - "spec": ">=0.1.1 <0.2.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/path-array/array-index/es6-symbol", - "/node-gyp/path-array/array-index/es6-symbol/es5-ext/es6-iterator" - ], - "_resolved": "https://registry.npmjs.org/d/-/d-0.1.1.tgz", - "_shasum": "da184c535d18d8ee7ba2aa229b914009fae11309", - "_shrinkwrap": null, - "_spec": "d@~0.1.1", - "_where": "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol", - "author": { - "name": "Mariusz Nowak", - "email": "medyk@medikoo.com", - "url": "http://www.medikoo.com/" - }, - "bugs": { - "url": "https://github.com/medikoo/d/issues" - }, - "dependencies": { - "es5-ext": "~0.10.2" - }, - "description": "Property descriptor factory", - "devDependencies": { - "tad": "~0.1.21" - }, - "directories": {}, - "dist": { - "shasum": "da184c535d18d8ee7ba2aa229b914009fae11309", - "tarball": "https://registry.npmjs.org/d/-/d-0.1.1.tgz" - }, - "homepage": "https://github.com/medikoo/d", - "keywords": [ - "descriptor", - "es", - "ecmascript", - "ecma", - "property", - "descriptors", - "meta", - "properties" - ], - "license": "MIT", - "maintainers": [ - { - "name": "medikoo", - "email": "medikoo+npm@medikoo.com" - } - ], - "name": "d", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/medikoo/d.git" - }, - "scripts": { - "test": "node node_modules/tad/bin/tad" - }, - "version": "0.1.1" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/test/auto-bind.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/test/auto-bind.js deleted file mode 100644 index 89edfb88bbec53..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/test/auto-bind.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var d = require('../'); - -module.exports = function (t, a) { - var o = Object.defineProperties({}, t({ - bar: d(function () { return this === o; }), - bar2: d(function () { return this; }) - })); - - a.deep([(o.bar)(), (o.bar2)()], [true, o]); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/test/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/test/index.js deleted file mode 100644 index 3db0af10acd3ca..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/test/index.js +++ /dev/null @@ -1,182 +0,0 @@ -'use strict'; - -var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - -module.exports = function (t, a) { - var o, c, cg, cs, ce, ceg, ces, cew, cw, e, eg, es, ew, v, vg, vs, w, df, dfg - , dfs; - - o = Object.create(Object.prototype, { - c: t('c', c = {}), - cgs: t.gs('c', cg = function () {}, cs = function () {}), - ce: t('ce', ce = {}), - cegs: t.gs('ce', ceg = function () {}, ces = function () {}), - cew: t('cew', cew = {}), - cw: t('cw', cw = {}), - e: t('e', e = {}), - egs: t.gs('e', eg = function () {}, es = function () {}), - ew: t('ew', ew = {}), - v: t('', v = {}), - vgs: t.gs('', vg = function () {}, vs = function () {}), - w: t('w', w = {}), - - df: t(df = {}), - dfgs: t.gs(dfg = function () {}, dfs = function () {}) - }); - - return { - c: function (a) { - var d = getOwnPropertyDescriptor(o, 'c'); - a(d.value, c, "Value"); - a(d.get, undefined, "Get"); - a(d.set, undefined, "Set"); - a(d.configurable, true, "Configurable"); - a(d.enumerable, false, "Enumerable"); - a(d.writable, false, "Writable"); - - d = getOwnPropertyDescriptor(o, 'cgs'); - a(d.value, undefined, "GS Value"); - a(d.get, cg, "GS Get"); - a(d.set, cs, "GS Set"); - a(d.configurable, true, "GS Configurable"); - a(d.enumerable, false, "GS Enumerable"); - a(d.writable, undefined, "GS Writable"); - }, - ce: function (a) { - var d = getOwnPropertyDescriptor(o, 'ce'); - a(d.value, ce, "Value"); - a(d.get, undefined, "Get"); - a(d.set, undefined, "Set"); - a(d.configurable, true, "Configurable"); - a(d.enumerable, true, "Enumerable"); - a(d.writable, false, "Writable"); - - d = getOwnPropertyDescriptor(o, 'cegs'); - a(d.value, undefined, "GS Value"); - a(d.get, ceg, "GS Get"); - a(d.set, ces, "GS Set"); - a(d.configurable, true, "GS Configurable"); - a(d.enumerable, true, "GS Enumerable"); - a(d.writable, undefined, "GS Writable"); - }, - cew: function (a) { - var d = getOwnPropertyDescriptor(o, 'cew'); - a(d.value, cew, "Value"); - a(d.get, undefined, "Get"); - a(d.set, undefined, "Set"); - a(d.configurable, true, "Configurable"); - a(d.enumerable, true, "Enumerable"); - a(d.writable, true, "Writable"); - }, - cw: function (a) { - var d = getOwnPropertyDescriptor(o, 'cw'); - a(d.value, cw, "Value"); - a(d.get, undefined, "Get"); - a(d.set, undefined, "Set"); - a(d.configurable, true, "Configurable"); - a(d.enumerable, false, "Enumerable"); - a(d.writable, true, "Writable"); - }, - e: function (a) { - var d = getOwnPropertyDescriptor(o, 'e'); - a(d.value, e, "Value"); - a(d.get, undefined, "Get"); - a(d.set, undefined, "Set"); - a(d.configurable, false, "Configurable"); - a(d.enumerable, true, "Enumerable"); - a(d.writable, false, "Writable"); - - d = getOwnPropertyDescriptor(o, 'egs'); - a(d.value, undefined, "GS Value"); - a(d.get, eg, "GS Get"); - a(d.set, es, "GS Set"); - a(d.configurable, false, "GS Configurable"); - a(d.enumerable, true, "GS Enumerable"); - a(d.writable, undefined, "GS Writable"); - }, - ew: function (a) { - var d = getOwnPropertyDescriptor(o, 'ew'); - a(d.value, ew, "Value"); - a(d.get, undefined, "Get"); - a(d.set, undefined, "Set"); - a(d.configurable, false, "Configurable"); - a(d.enumerable, true, "Enumerable"); - a(d.writable, true, "Writable"); - }, - v: function (a) { - var d = getOwnPropertyDescriptor(o, 'v'); - a(d.value, v, "Value"); - a(d.get, undefined, "Get"); - a(d.set, undefined, "Set"); - a(d.configurable, false, "Configurable"); - a(d.enumerable, false, "Enumerable"); - a(d.writable, false, "Writable"); - - d = getOwnPropertyDescriptor(o, 'vgs'); - a(d.value, undefined, "GS Value"); - a(d.get, vg, "GS Get"); - a(d.set, vs, "GS Set"); - a(d.configurable, false, "GS Configurable"); - a(d.enumerable, false, "GS Enumerable"); - a(d.writable, undefined, "GS Writable"); - }, - w: function (a) { - var d = getOwnPropertyDescriptor(o, 'w'); - a(d.value, w, "Value"); - a(d.get, undefined, "Get"); - a(d.set, undefined, "Set"); - a(d.configurable, false, "Configurable"); - a(d.enumerable, false, "Enumerable"); - a(d.writable, true, "Writable"); - }, - d: function (a) { - var d = getOwnPropertyDescriptor(o, 'df'); - a(d.value, df, "Value"); - a(d.get, undefined, "Get"); - a(d.set, undefined, "Set"); - a(d.configurable, true, "Configurable"); - a(d.enumerable, false, "Enumerable"); - a(d.writable, true, "Writable"); - - d = getOwnPropertyDescriptor(o, 'dfgs'); - a(d.value, undefined, "GS Value"); - a(d.get, dfg, "GS Get"); - a(d.set, dfs, "GS Set"); - a(d.configurable, true, "GS Configurable"); - a(d.enumerable, false, "GS Enumerable"); - a(d.writable, undefined, "GS Writable"); - }, - Options: { - v: function (a) { - var x = {}, d = t(x, { foo: true }); - a.deep(d, { configurable: true, enumerable: false, writable: true, - value: x, foo: true }, "No descriptor"); - d = t('c', 'foo', { marko: 'elo' }); - a.deep(d, { configurable: true, enumerable: false, writable: false, - value: 'foo', marko: 'elo' }, "Descriptor"); - }, - gs: function (a) { - var gFn = function () {}, sFn = function () {}, d; - d = t.gs(gFn, sFn, { foo: true }); - a.deep(d, { configurable: true, enumerable: false, get: gFn, set: sFn, - foo: true }, "No descriptor"); - d = t.gs(null, sFn, { foo: true }); - a.deep(d, { configurable: true, enumerable: false, get: undefined, - set: sFn, foo: true }, "No descriptor: Just set"); - d = t.gs(gFn, { foo: true }); - a.deep(d, { configurable: true, enumerable: false, get: gFn, - set: undefined, foo: true }, "No descriptor: Just get"); - - d = t.gs('e', gFn, sFn, { bar: true }); - a.deep(d, { configurable: false, enumerable: true, get: gFn, set: sFn, - bar: true }, "Descriptor"); - d = t.gs('e', null, sFn, { bar: true }); - a.deep(d, { configurable: false, enumerable: true, get: undefined, - set: sFn, bar: true }, "Descriptor: Just set"); - d = t.gs('e', gFn, { bar: true }); - a.deep(d, { configurable: false, enumerable: true, get: gFn, - set: undefined, bar: true }, "Descriptor: Just get"); - } - } - }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/test/lazy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/test/lazy.js deleted file mode 100644 index 8266deb240fda3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/d/test/lazy.js +++ /dev/null @@ -1,77 +0,0 @@ -'use strict'; - -var d = require('../') - - , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor; - -module.exports = function (t, a) { - var Foo = function () {}, i = 1, o, o2, desc; - Object.defineProperties(Foo.prototype, t({ - bar: d(function () { return ++i; }), - bar2: d(function () { return this.bar + 23; }), - bar3: d(function () { return this.bar2 + 34; }, { desc: 'ew' }), - bar4: d(function () { return this.bar3 + 12; }, { cacheName: '_bar4_' }), - bar5: d(function () { return this.bar4 + 3; }, - { cacheName: '_bar5_', desc: 'e' }) - })); - - desc = getOwnPropertyDescriptor(Foo.prototype, 'bar'); - a(desc.configurable, true, "Configurable: default"); - a(desc.enumerable, false, "Enumerable: default"); - - o = new Foo(); - a.deep([o.bar, o.bar2, o.bar3, o.bar4, o.bar5], [2, 25, 59, 71, 74], - "Values"); - - a.deep(getOwnPropertyDescriptor(o, 'bar3'), { configurable: false, - enumerable: true, writable: true, value: 59 }, "Desc"); - a(o.hasOwnProperty('bar4'), false, "Cache not exposed"); - desc = getOwnPropertyDescriptor(o, 'bar5'); - a.deep(desc, { configurable: false, - enumerable: true, get: desc.get, set: desc.set }, "Cache & Desc: desc"); - - o2 = Object.create(o); - o2.bar = 30; - o2.bar3 = 100; - - a.deep([o2.bar, o2.bar2, o2.bar3, o2.bar4, o2.bar5], [30, 25, 100, 112, 115], - "Extension Values"); - - Foo = function () {}; - Object.defineProperties(Foo.prototype, t({ - test: d('w', function () { return 'raz'; }), - test2: d('', function () { return 'raz'; }, { desc: 'w' }), - test3: d('', function () { return 'raz'; }, - { cacheName: '__test3__', desc: 'w' }), - test4: d('w', 'bar') - })); - - o = new Foo(); - o.test = 'marko'; - a.deep(getOwnPropertyDescriptor(o, 'test'), - { configurable: false, enumerable: false, writable: true, value: 'marko' }, - "Set before get"); - o.test2 = 'marko2'; - a.deep(getOwnPropertyDescriptor(o, 'test2'), - { configurable: false, enumerable: false, writable: true, value: 'marko2' }, - "Set before get: Custom desc"); - o.test3 = 'marko3'; - a.deep(getOwnPropertyDescriptor(o, '__test3__'), - { configurable: false, enumerable: false, writable: true, value: 'marko3' }, - "Set before get: Custom cache name"); - a(o.test4, 'bar', "Resolve by value"); - - a.h1("Flat"); - Object.defineProperties(Foo.prototype, t({ - flat: d(function () { return 'foo'; }, { flat: true }), - flat2: d(function () { return 'bar'; }, { flat: true }) - })); - - a.h2("Instance"); - a(o.flat, 'foo', "Value"); - a(o.hasOwnProperty('flat'), false, "Instance"); - a(Foo.prototype.flat, 'foo', "Prototype"); - - a.h2("Direct"); - a(Foo.prototype.flat2, 'bar'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.lint b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.lint deleted file mode 100644 index d1da610376a524..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.lint +++ /dev/null @@ -1,38 +0,0 @@ -@root - -module - -indent 2 -maxlen 100 -tabs - -ass -continue -forin -nomen -plusplus -vars - -./global.js -./function/_define-length.js -./function/#/copy.js -./object/unserialize.js -./test/function/valid-function.js -evil - -./math/_pack-ieee754.js -./math/_unpack-ieee754.js -./math/clz32/shim.js -./math/imul/shim.js -./number/to-uint32.js -./string/#/at.js -bitwise - -./math/fround/shim.js -predef+ Float32Array - -./object/first-key.js -forin - -./test/reg-exp/#/index.js -predef+ __dirname diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.lintignore b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.lintignore deleted file mode 100644 index eece4ff3c76f4a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.lintignore +++ /dev/null @@ -1,9 +0,0 @@ -/string/#/normalize/_data.js -/test/boolean/is-boolean.js -/test/date/is-date.js -/test/number/is-number.js -/test/object/is-copy.js -/test/object/is-number-value.js -/test/object/is-object.js -/test/reg-exp/is-reg-exp.js -/test/string/is-string.js diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.npmignore deleted file mode 100644 index eb09b500d63ec8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -.DS_Store -/node_modules -/.lintcache -/npm-debug.log diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.travis.yml deleted file mode 100644 index 39fd70e64ed706..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/.travis.yml +++ /dev/null @@ -1,16 +0,0 @@ -sudo: false # http://docs.travis-ci.com/user/workers/container-based-infrastructure/ -language: node_js -node_js: - - 0.12 - - 4 - - 5 - - 6 - -before_install: - - mkdir node_modules; ln -s ../ node_modules/es5-ext - -notifications: - email: - - medikoo+es5-ext@medikoo.com - -script: "npm test && npm run lint" diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/CHANGES b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/CHANGES deleted file mode 100644 index 4ecc2db0753863..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/CHANGES +++ /dev/null @@ -1,633 +0,0 @@ -v0.10.12 -- 2016.07.01 -* Ensure symbols are copied in Object.mixin -* Prevent RangeError errors in array#flatten -* Do not validate invalidate dates in validDate - -v0.10.11 -- 2015.12.18 -* Ensure that check for implementation of RegExp flags doesn't crash in V8 (thanks @mathiasbynens) - -v0.10.10 -- 2015.12.11 -* Add Object.isNumberValue util - -v0.10.9 -- 2015.12.01 -* Add Object.ensureNaturalNumber and Object.ensureNaturalNumberValue - -v0.10.8 -- 2015.10.02 -* Add Number.isNatural -* Add Object.find and Object.findKey -* Support arrays in Object.copyDeep -* Fix iteration issue in forEachRight and someRight -* Fix detection of native sinh -* Depend on es6-symbol v3 - -v0.10.7 -- 2015.04.22 -* New utlitities. They're convention differs from v0.10, as they were supposed to land in v1. - Still they're non breaking and start the conventions to be used in v1 - * Object.validateArrayLike - * Object.validateArrayLikeObject - * Object.validateStringifiable - * Object.validateStringifiableValue - * Universal utilities for array-like/iterable objects - * Iterable.is - * Iterable.validate - * Iterable.validateObject - * Iterable.forEach -* Fix camelToHyphen resolution, it must be absolutely reversable by hyphenToCamel -* Fix calculations of large numbers in Math.tanh -* Fix algorithm of Math.sinh -* Fix indexes to not use real symbols -* Fix length of String.fromCodePoint -* Fix tests of Array#copyWithin -* Update Travis CI configuration - -v0.10.6 -- 2015.02.02 -* Fix handling of infinite values in Math.trunc -* Fix handling of getters in Object.normalizeOptions - -v0.10.5 -- 2015.01.20 -* Add Function#toStringTokens -* Add Object.serialize and Object.unserialize -* Add String.randomUniq -* Fix Strin#camelToHyphen issue with tokens that end with digit -* Optimise Number.isInteger logic -* Improve documentation -* Configure lint scripts -* Fix spelling of LICENSE - -v0.10.4 -- 2014.04.30 -* Assure maximum spec compliance of Array.of and Array.from (thanks @mathiasbynens) -* Improve documentations - -v0.10.3 -- 2014.04.29 -Provide accurate iterators handling: -* Array.from improvements: - * Assure right unicode symbols resolution when processing strings in Array.from - * Rely on ES6 symbol shim and use native @@iterator Symbol if provided by environment -* Add methods: - * Array.prototype.entries - * Array.prototype.keys - * Array.prototype.values - * Array.prototype[@@iterator] - * String.prototype[@@iterator] - -Improve documentation - -v0.10.2 -- 2014.04.24 -- Simplify and deprecate `isCallable`. It seems in ES5 based engines there are - no callable objects which are `typeof obj !== 'function'` -- Update Array.from map callback signature (up to latest resolution of TC39) -- Improve documentation - -v0.10.1 -- 2014.04.14 -Bump version for npm -(Workaround for accidental premature publish & unpublish of v0.10.0 a while ago) - -v0.10.0 -- 2014.04.13 -Major update: -- All methods and function specified for ECMAScript 6 are now introduced as - shims accompanied with functions through which (optionally) they can be - implementend on native objects -- Filename convention was changed to shorter and strictly lower case names. e.g. - `lib/String/prototype/starts-with` became `string/#/starts-with` -- Generated functions are guaranteed to have expected length -- Objects with null prototype (created via `Object.create(null)`) are widely - supported (older version have crashed due to implied `obj.hasOwnProperty` and - related invocations) -- Support array subclasses -- When handling lists do not limit its length to Uint32 range -- Use newly introduced `Object.eq` for strict equality in place of `Object.is` -- Iteration of Object have been improved so properties that were hidden or - removed after iteration started are not iterated. - -Additions: -- `Array.isPlainArray` -- `Array.validArray` -- `Array.prototype.concat` (as updated with ES6) -- `Array.prototype.copyWithin` (as introduced with ES6) -- `Array.prototype.fill` (as introduced with ES6) -- `Array.prototype.filter` (as updated with ES6) -- `Array.prototype.findIndex` (as introduced with ES6) -- `Array.prototype.map` (as updated with ES6) -- `Array.prototype.separate` -- `Array.prototype.slice` (as updated with ES6) -- `Array.prototype.splice` (as updated with ES6) -- `Function.prototype.copy` -- `Math.acosh` (as introduced with ES6) -- `Math.atanh` (as introduced with ES6) -- `Math.cbrt` (as introduced with ES6) -- `Math.clz32` (as introduced with ES6) -- `Math.cosh` (as introduced with ES6) -- `Math.expm1` (as introduced with ES6) -- `Math.fround` (as introduced with ES6) -- `Math.hypot` (as introduced with ES6) -- `Math.imul` (as introduced with ES6) -- `Math.log2` (as introduced with ES6) -- `Math.log10` (as introduced with ES6) -- `Math.log1p` (as introduced with ES6) -- `Math.sinh` (as introduced with ES6) -- `Math.tanh` (as introduced with ES6) -- `Math.trunc` (as introduced with ES6) -- `Number.EPSILON` (as introduced with ES6) -- `Number.MIN_SAFE_INTEGER` (as introduced with ES6) -- `Number.MAX_SAFE_INTEGER` (as introduced with ES6) -- `Number.isFinite` (as introduced with ES6) -- `Number.isInteger` (as introduced with ES6) -- `Number.isSafeInteger` (as introduced with ES6) -- `Object.create` (with fix for V8 issue which disallows prototype turn of - objects derived from null -- `Object.eq` - Less restrictive version of `Object.is` based on SameValueZero - algorithm -- `Object.firstKey` -- `Object.keys` (as updated with ES6) -- `Object.mixinPrototypes` -- `Object.primitiveSet` -- `Object.setPrototypeOf` (as introduced with ES6) -- `Object.validObject` -- `RegExp.escape` -- `RegExp.prototype.match` (as introduced with ES6) -- `RegExp.prototype.replace` (as introduced with ES6) -- `RegExp.prototype.search` (as introduced with ES6) -- `RegExp.prototype.split` (as introduced with ES6) -- `RegExp.prototype.sticky` (as introduced with ES6) -- `RegExp.prototype.unicode` (as introduced with ES6) -- `String.fromCodePoint` (as introduced with ES6) -- `String.raw` (as introduced with ES6) -- `String.prototype.at` -- `String.prototype.codePointAt` (as introduced with ES6) -- `String.prototype.normalize` (as introduced with ES6) -- `String.prototype.plainReplaceAll` - -Removals: -- `reserved` set -- `Array.prototype.commonLeft` -- `Function.insert` -- `Function.remove` -- `Function.prototype.silent` -- `Function.prototype.wrap` -- `Object.descriptor` Move to external `d` project. - See: https://github.com/medikoo/d -- `Object.diff` -- `Object.extendDeep` -- `Object.reduce` -- `Object.values` -- `String.prototype.trimCommonLeft` - -Renames: -- `Function.i` into `Function.identity` -- `Function.k` into `Function.constant` -- `Number.toInt` into `Number.toInteger` -- `Number.toUint` into `Number.toPosInteger` -- `Object.extend` into `Object.assign` (as introduced in ES 6) -- `Object.extendProperties` into `Object.mixin`, with improved internal - handling, so it matches temporarily specified `Object.mixin` for ECMAScript 6 -- `Object.isList` into `Object.isArrayLike` -- `Object.mapToArray` into `Object.toArray` (with fixed function length) -- `Object.toPlainObject` into `Object.normalizeOptions` (as this is the real - use case where we use this function) -- `Function.prototype.chain` into `Function.prototype.compose` -- `Function.prototype.match` into `Function.prototype.spread` -- `String.prototype.format` into `String.formatMethod` - -Improvements & Fixes: -- Remove workaround for primitive values handling in object iterators -- `Array.from`: Update so it follows ES 6 spec -- `Array.prototype.compact`: filters just null and undefined values - (not all falsies) -- `Array.prototype.eIndexOf` and `Array.prototype.eLastIndexOf`: fix position - handling, improve internals -- `Array.prototype.find`: return undefined not null, in case of not found - (follow ES 6) -- `Array.prototype.remove` fix function length -- `Error.custom`: simplify, Custom class case is addressed by outer - `error-create` project -> https://github.com/medikoo/error-create -- `Error.isError` true only for Error instances (remove detection of host - Exception objects) -- `Number.prototype.pad`: Normalize negative pad -- `Object.clear`: Handle errors same way as in `Object.assign` -- `Object.compact`: filters just null and undefined values (not all falsies) -- `Object.compare`: Take into account NaN values -- `Object.copy`: Split into `Object.copy` and `Object.copyDeep` -- `Object.isCopy`: Separate into `Object.isCopy` and `Object.isCopyDeep`, where - `isCopyDeep` handles nested plain objects and plain arrays only -- `String.prototype.endsWith`: Adjust up to ES6 specification -- `String.prototype.repeat`: Adjust up to ES6 specification and improve algorithm -- `String.prototype.simpleReplace`: Rename into `String.prototype.plainReplace` -- `String.prototype.startsWith`: Adjust up to ES6 specification -- Update lint rules, and adjust code to that -- Update Travis CI configuration -- Remove Makefile (it's cross-env utility) - -v0.9.2 -- 2013.03.11 -Added: -* Array.prototype.isCopy -* Array.prototype.isUniq -* Error.CustomError -* Function.validFunction -* Object.extendDeep -* Object.descriptor.binder -* Object.safeTraverse -* RegExp.validRegExp -* String.prototype.capitalize -* String.prototype.simpleReplace - -Fixed: -* Fix Array.prototype.diff for sparse arrays -* Accept primitive objects as input values in Object iteration methods and - Object.clear, Object.count, Object.diff, Object.extend, - Object.getPropertyNames, Object.values -* Pass expected arguments to callbacks of Object.filter, Object.mapKeys, - Object.mapToArray, Object.map -* Improve callable callback support in Object.mapToArray - -v0.9.1 -- 2012.09.17 -* Object.reduce - reduce for hash-like collections -* Accapt any callable object as callback in Object.filter, mapKeys and map -* Convention cleanup - -v0.9.0 -- 2012.09.13 -We're getting to real solid API - -Removed: -* Function#memoize - it's grown up to be external package, to be soon published - as 'memoizee' -* String.guid - it doesn't fit es5-ext (extensions) concept, will be provided as - external package -# Function.arguments - obsolete -# Function.context - obsolete -# Function#flip - not readable when used, so it was never used -# Object.clone - obsolete and confusing - -Added: -* String#camelToHyphen - String format convertion - -Renamed: -* String#dashToCamelCase -> String#hyphenToCamel - -Fixes: -* Object.isObject - Quote names in literals that match reserved keywords - (older implementations crashed on that) -* String#repeat - Do not accept negative values (coerce them to 1) - -Improvements: -* Array#remove - Accepts many arguments, we can now remove many values at once -* Object iterators (forEach, map, some) - Compare function invoked with scope - object bound to this -* Function#curry - Algorithm cleanup -* Object.isCopy - Support for all types, not just plain objects -* Object.isPlainObject - Support for cross-frame objects -* Do not memoize any of the functions, it shouldn't be decided internally -* Remove Object.freeze calls in reserved, it's not up to convention -* Improved documentation -* Better linting (hard-core approach using both JSLint mod and JSHint) -* Optional arguments are now documented in funtions signature - -v0.8.2 -- 2012.06.22 -Fix errors in Array's intersection and exclusion methods, related to improper -usage of contains method - -v0.8.1 -- 2012.06.13 -Reorganized internal logic of Function.prototype.memoize. So it's more safe now -and clears cache properly. Additionally preventCache option was provided. - -v0.8.0 -- 2012.05.28 -Again, major overhaul. Probably last experimental stuff was trashed, all API -looks more like standard extensions now. - -Changes: -* Turn all Object.prototype extensions into functions and move them to Object -namespace. We learned that extending Object.prototype is bad idea in any case. -* Rename Function.prototype.curry into Function.prototype.partial. This function - is really doing partial application while currying is slightly different - concept. -* Convert Function.prototype.ncurry to new implementation of - Function.prototype.curry, it now serves real curry concept additionaly it - covers use cases for aritize and hold, which were removed. -* Rename Array's peek to last, and provide support for sparse arrays in it -* Rename Date's monthDaysCount into daysInMonth -* Simplify object iterators, now order of iteration can be configured with just - compareFn argument (no extra byKeys option) -* Rename Object.isDuplicate to Object.isCopy -* Rename Object.isEqual to Object.is which is compatible with future 'is' - keyword -* Function.memoize is now Function.prototype.memoize. Additionally clear cache - functionality is added, and access to original arguments object. -* Rename validation functions: assertNotNull to validValue, assertCallable to - validCallable. validValue was moved to Object namespace. On success they now - return validated value instead of true, it supports better composition. - Additionally created Date.validDate and Error.validError -* All documentation is now held in README.md not in code files. -* Move guid to String namespace. All guids now start with numbers. -* Array.generate: fill argument is now optional -* Object.toArray is now Array.from (as new ES6 specification draft suggests) -* All methods that rely on indexOf or lastIndexOf, now rely on egal (Object.is) - versions of them (eIndexOf, eLastIndexOf) -* Turn all get* functions that returned methods into actuall methods (get* - functionality can still be achieved with help of Function.prototype.partial). - So: Date.getFormat is now Date.prototype.format, - Number.getPad is now Number.prototype.pad, - String.getFormat is now String.prototype.format, - String.getIndent is now String.prototype.indent, - String.getPad is now String.prototype.pad -* Refactored Object.descriptor, it is now just two functions, main one and - main.gs, main is for describing values, and gs for describing getters and - setters. Configuration is passed with first argument as string e.g. 'ce' for - configurable and enumerable. If no configuration string is provided then by - default it returns configurable and writable but not enumerable for value or - configurable but not enumerable for getter/setter -* Function.prototype.silent now returns prepared function (it was - expected to be fixed for 0.7) -* Reserved keywords map (reserved) is now array not hash. -* Object.merge is now Object.extend (while former Object.extend was completely - removed) - 'extend' implies that we change object, not creating new one (as - 'merge' may imply). Similarily Object.mergeProperties was renamed to - Object.extendProperties -* Position argument support in Array.prototype.contains and - String.prototype.contains (so it follows ES6 specification draft) -* endPosition argument support in String.prototype.endsWith and fromPosition - argument support in String.prototype.startsWith (so it follows ES6 - specification draft) -* Better and cleaner String.prototype.indent implementation. No default value - for indent string argument, optional nest value (defaults to 1), remove - nostart argument -* Correct length values for most methods (so they reflect length of similar - methods in standard) -* Length argument is now optional in number and string pad methods. -* Improve arguments validation in general, so it adheres to standard conventions -* Fixed format of package.json - -Removed methods and functions: -* Object.prototype.slice - Object is not ordered collection, so slice doesn't - make sense. -* Function's rcurry, rncurry, s - too cumbersome for JS, not many use cases for - that -* Function.prototype.aritize and Function.prototype.hold - same functionality - can be achieved with new Function.prototype.curry -* Function.prototype.log - provided more generic Function.prototype.wrap for - same use case -* getNextIdGenerator - no use case for that (String.guid should be used if - needed) -* Object.toObject - Can be now acheived with Object(validValue(x)) -* Array.prototype.someValue - no real use case (personally used once and - case was already controversial) -* Date.prototype.duration - moved to external package -* Number.getAutoincrement - No real use case -* Object.prototype.extend, Object.prototype.override, - Object.prototype.plainCreate, Object.prototype.plainExtend - It was probably - too complex, same should be achieved just with Object.create, - Object.descriptor and by saving references to super methods in local scope. -* Object.getCompareBy - Functions should be created individually for each use - case -* Object.get, Object.getSet, Object.set, Object.unset - Not many use cases and - same can be easily achieved with simple inline function -* String.getPrefixWith - Not real use case for something that can be easily - achieved with '+' operator -* Object.isPrimitive - It's just negation of Object.isObject -* Number.prototype.isLess, Number.prototype.isLessOrEqual - they shouldn't be in - Number namespace and should rather be addressed with simple inline functions. -* Number.prototype.subtract - Should rather be addressed with simple inline - function - -New methods and functions: -* Array.prototype.lastIndex - Returns last declared index in array -* String.prototype.last - last for strings -* Function.prototype.wrap - Wrap function with other, it allows to specify - before and after behavior transform return value or prevent original function - from being called. -* Math.sign - Returns sign of a number (already in ES6 specification draft) -* Number.toInt - Converts value to integer (already in ES6 specification draft) -* Number.isNaN - Returns true if value is NaN (already in ES6 specification - draft) -* Number.toUint - Converts value to unsigned integer -* Number.toUint32 - Converts value to 32bit unsigned integer -* Array.prototype.eIndexOf, eLastIndexOf - Egal version (that uses Object.is) of - standard methods (all methods that were using native indexOf or lastIndexOf - now uses eIndexOf and elastIndexOf respectively) -* Array.of - as it's specified for ES6 - -Fixes: -* Fixed binarySearch so it always returns valid list index -* Object.isList - it failed on lists that are callable (e.g. NodeList in Nitro - engine) -* Object.map now supports third argument for callback - -v0.7.1 -- 2012.01.05 -New methods: -* Array.prototype.firstIndex - returns first valid index of array (for - sparse arrays it may not be '0' - -Improvements: -* Array.prototype.first - now returns value for index returned by firstIndex -* Object.prototype.mapToArray - can be called without callback, then array of - key-value pairs is returned - -Fixes -* Array.prototype.forEachRight, object's length read through UInt32 conversion - -v0.7.0 -- 2011.12.27 -Major update. -Stepped back from experimental ideas and introduced more standard approach -taking example from how ES5 methods and functions are designed. One exceptions -is that, we don’t refrain from declaring methods for Object.prototype - it’s up -to developer whether how he decides to use it in his context (as function or as -method). - -In general: -* Removed any method 'functionalization' and functionalize method itself. - es5-ext declares plain methods, which can be configured to work as functions - with call.bind(method) - see documentation. -* Removed separation of Object methods for ES5 (with descriptors) and - ES3 (plain) - we're following ES5 idea on that, some methods are intended just - for enumerable properties and some are for all properties, all are declared - for Object.prototype -* Removed separation of Array generic (collected in List folder) and not generic - methods (collected in Array folder). Now all methods are generic and are in - Array/prototype folder. This separation also meant, that methods in Array are - usually destructive. We don’t do that separation now, there’s generally no use - case for destructive iterators, we should be fine with one version of each - method, (same as ES5 is fine with e.g. one, non destructive 'filter' method) -* Folder structure resembles tree of native ES5 Objects -* All methods are written with ES5 conventions in mind, it means that most - methods are generic and can be run on any object. In more detail: - ** Array.prototype and Object.prototype methods can be run on any object (any - not null or undefined value), - ** Date.prototype methods should be called only on Date instances. - ** Function.prototype methods can be called on any callable objects (not - necessarily functions) - ** Number.prototype & String.prototype methods can be called on any value, in - case of Number it it’ll be degraded to number, in case of string it’ll be - degraded to string. -* Travis CI support (only for Node v0.6 branch, as v0.4 has buggy V8 version) - -Improvements for existing functions and methods: -* Function.memoize (was Function.cache) is now fully generic, can operate on any - type of arguments and it’s NaN safe (all NaN objects are considered equal) -* Method properties passed to Object.prototype.extend or - Object.prototype.override can aside of _super optionally take prototype object - via _proto argument -* Object iterators: forEach, mapToArray and every can now iterate in specified - order -* pluck, invoke and other functions that return reusable functions or methods - have now their results memoized. - -New methods: -* Global: assertNotNull, getNextIdGenerator, guid, isEqual, isPrimitive, - toObject -* Array: generate -* Array.prototype: binarySearch, clear, contains, diff, exclusion, find, first, - forEachRight, group, indexesOf, intersection, remove, someRight, someValue -* Boolean: isBoolean -* Date: isDate -* Function: arguments, context, insert, isArguments, remove -* Function.prototype: not, silent -* Number: getAutoincrement, isNumber -* Number.prototype: isLessOrEqual, isLess, subtract -* Object: assertCallable, descriptor (functions for clean descriptors), - getCompareBy, isCallable, isObject -* Object.prototype: clone (real clone), compact, count, diff, empty, - getPropertyNames, get, keyOf, mapKeys, override, plainCreate, plainExtend, - slice, some, unset -* RegExp: isRegExp -* String: getPrefixWith, isString -* String.prototype: caseInsensitiveCompare, contains, isNumeric - -Renamed methods: -* Date.clone -> Date.prototype.copy -* Date.format -> Date.getFormat -* Date/day/floor -> Date.prototype.floorDay -* Date/month/floor -> Date.prototype.floorMonth -* Date/month/year -> Date.prototype.floorYear -* Function.cache -> Function.memoize -* Function.getApplyArg -> Function.prototype.match -* Function.sequence -> Function.prototype.chain -* List.findSameStartLength -> Array.prototype.commonLeft -* Number.pad -> Number.getPad -* Object/plain/clone -> Object.prototype.copy -* Object/plain/elevate -> Object.prototype.flatten -* Object/plain/same -> Object.prototype.isDuplicate -* Object/plain/setValue -> Object.getSet -* String.format -> String.getFormat -* String.indent -> String.getIndent -* String.pad -> String.getPad -* String.trimLeftStr -> String.prototype.trimCommonLeft -* Object.merge -> Object.prototype.mergeProperties -* Object/plain/pluck -> Object.prototype.get -* Array.clone is now Array.prototype.copy and can be used also on any array-like - objects -* List.isList -> Object.isList -* List.toArray -> Object.prototype.toArray -* String/convert/dashToCamelCase -> String.prototype.dashToCamelCase - -Removed methods: -* Array.compact - removed destructive version (that operated on same array), we - have now non destructive version as Array.prototype.compact. -* Function.applyBind -> use apply.bind directly -* Function.bindBind -> use bind.bind directly -* Function.callBind -> use call.bind directly -* Fuction.clone -> no valid use case -* Function.dscope -> controversial approach, shouldn’t be considered seriously -* Function.functionalize -> It was experimental but standards are standards -* List/sort/length -> It can be easy obtained by Object.getCompareBy(‘length’) -* List.concat -> Concat’s for array-like’s makes no sense, just convert to array - first -* List.every -> Use Array.prototype.every directly -* List.filter -> Use Array.prototype.filter directly -* List.forEach -> User Array.prototype.forEach directly -* List.isListObject -> No valid use case, do: isList(list) && (typeof list === - 'object’) -* List.map -> Use Array.prototype.map directly -* List.reduce -> Use Array.prototype.reduce directly -* List.shiftSame -> Use Array.prototype.commonLeft and do slice -* List.slice -> Use Array.prototype.slice directly -* List.some -> Use Array.prototype.some directly -* Object.bindMethods -> it was version that considered descriptors, we have now - Object.prototype.bindMethods which operates only on enumerable properties -* Object.every -> version that considered all properties, we have now - Object.prototype.every which iterates only enumerables -* Object.invoke -> no use case -* Object.mergeDeep -> no use case -* Object.pluck -> no use case -* Object.same -> it considered descriptors, now there’s only Object.isDuplicate - which compares only enumerable properties -* Object.sameType -> no use case -* Object.toDescriptor and Object.toDescriptors -> replaced by much nicer - Object.descriptor functions -* Object/plain/link -> no use case (it was used internally only by - Object/plain/merge) -* Object/plain/setTrue -> now easily configurable by more universal - Object.getSet(true) -* String.trimRightStr -> Eventually String.prototype.trimCommonRight will be - added - -v0.6.3 -- 2011.12.12 -* Cleared npm warning for misnamed property in package.json - -v0.6.2 -- 2011.08.12 -* Calling String.indent without scope (global scope then) now treated as calling - it with null scope, it allows more direct invocations when using default nest - string: indent().call(str, nest) - -v0.6.1 -- 2011.08.08 -* Added TAD test suite to devDependencies, configured test commands. - Tests can be run with 'make test' or 'npm test' - -v0.6.0 -- 2011.08.07 -New methods: -* Array: clone, compact (in place) -* Date: format, duration, clone, monthDaysCount, day.floor, month.floor, - year.floor -* Function: getApplyArg, , ncurry, rncurry, hold, cache, log -* List: findSameStartLength, shiftSame, peek, isListObject -* Number: pad -* Object: sameType, toString, mapToArray, mergeDeep, toDescriptor, - toDescriptors, invoke -* String: startsWith, endsWith, indent, trimLeftStr, trimRightStr, pad, format - -Fixed: -* Object.extend does now prototypal extend as exptected -* Object.merge now tries to overwrite only configurable properties -* Function.flip - -Improved: -* Faster List.toArray -* Better global retrieval -* Functionalized all Function methods -* Renamed bindApply and bindCall to applyBind and callBind -* Removed Function.inherit (as it's unintuitive curry clone) -* Straightforward logic in Function.k -* Fixed naming of some tests files (letter case issue) -* Renamed Function.saturate into Function.lock -* String.dashToCamelCase digits support -* Strings now considered as List objects -* Improved List.compact -* Concise logic for List.concat -* Test wit TAD in clean ES5 context - -v0.5.1 -- 2011.07.11 -* Function's bindBind, bindCall and bindApply now more versatile - -v0.5.0 -- 2011.07.07 -* Removed Object.is and List.apply -* Renamed Object.plain.is to Object.plain.isPlainObject (keep naming convention - consistent) -* Improved documentation - -v0.4.0 -- 2011.07.05 -* Take most functions on Object to Object.plain to keep them away from object - descriptors -* Object functions with ES5 standard in mind (object descriptors) - -v0.3.0 -- 2011.06.24 -* New functions -* Consistent file naming (dash instead of camelCase) - -v0.2.1 -- 2011.05.28 -* Renamed Functions.K and Function.S to to lowercase versions (use consistent - naming) - -v0.2.0 -- 2011.05.28 -* Renamed Array folder to List (as its generic functions for array-like objects) -* Added Makefile -* Added various functions - -v0.1.0 -- 2011.05.24 -* Initial version diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/LICENSE deleted file mode 100644 index de39071f1b8bbf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2011-2015 Mariusz Nowak (www.medikoo.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/README.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/README.md deleted file mode 100644 index 11d8a343d57f1f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/README.md +++ /dev/null @@ -1,993 +0,0 @@ -# es5-ext -## ECMAScript 5 extensions -### (with respect to ECMAScript 6 standard) - -Shims for upcoming ES6 standard and other goodies implemented strictly with ECMAScript conventions in mind. - -It's designed to be used in compliant ECMAScript 5 or ECMAScript 6 environments. Older environments are not supported, although most of the features should work with correct ECMAScript 5 shim on board. - -When used in ECMAScript 6 environment, native implementation (if valid) takes precedence over shims. - -### Installation - - $ npm install es5-ext - -To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) - -### Usage - -#### ECMAScript 6 features - -You can force ES6 features to be implemented in your environment, e.g. following will assign `from` function to `Array` (only if it's not implemented already). - -```javascript -require('es5-ext/array/from/implement'); -Array.from('foo'); // ['f', 'o', 'o'] -``` - -You can also access shims directly, without fixing native objects. Following will return native `Array.from` if it's available and fallback to shim if it's not. - -```javascript -var aFrom = require('es5-ext/array/from'); -aFrom('foo'); // ['f', 'o', 'o'] -``` - -If you want to use shim unconditionally (even if native implementation exists) do: - -```javascript -var aFrom = require('es5-ext/array/from/shim'); -aFrom('foo'); // ['f', 'o', 'o'] -``` - -##### List of ES6 shims - -It's about properties introduced with ES6 and those that have been updated in new spec. - -- `Array.from` -> `require('es5-ext/array/from')` -- `Array.of` -> `require('es5-ext/array/of')` -- `Array.prototype.concat` -> `require('es5-ext/array/#/concat')` -- `Array.prototype.copyWithin` -> `require('es5-ext/array/#/copy-within')` -- `Array.prototype.entries` -> `require('es5-ext/array/#/entries')` -- `Array.prototype.fill` -> `require('es5-ext/array/#/fill')` -- `Array.prototype.filter` -> `require('es5-ext/array/#/filter')` -- `Array.prototype.find` -> `require('es5-ext/array/#/find')` -- `Array.prototype.findIndex` -> `require('es5-ext/array/#/find-index')` -- `Array.prototype.keys` -> `require('es5-ext/array/#/keys')` -- `Array.prototype.map` -> `require('es5-ext/array/#/map')` -- `Array.prototype.slice` -> `require('es5-ext/array/#/slice')` -- `Array.prototype.splice` -> `require('es5-ext/array/#/splice')` -- `Array.prototype.values` -> `require('es5-ext/array/#/values')` -- `Array.prototype[@@iterator]` -> `require('es5-ext/array/#/@@iterator')` -- `Math.acosh` -> `require('es5-ext/math/acosh')` -- `Math.asinh` -> `require('es5-ext/math/asinh')` -- `Math.atanh` -> `require('es5-ext/math/atanh')` -- `Math.cbrt` -> `require('es5-ext/math/cbrt')` -- `Math.clz32` -> `require('es5-ext/math/clz32')` -- `Math.cosh` -> `require('es5-ext/math/cosh')` -- `Math.exmp1` -> `require('es5-ext/math/expm1')` -- `Math.fround` -> `require('es5-ext/math/fround')` -- `Math.hypot` -> `require('es5-ext/math/hypot')` -- `Math.imul` -> `require('es5-ext/math/imul')` -- `Math.log1p` -> `require('es5-ext/math/log1p')` -- `Math.log2` -> `require('es5-ext/math/log2')` -- `Math.log10` -> `require('es5-ext/math/log10')` -- `Math.sign` -> `require('es5-ext/math/sign')` -- `Math.signh` -> `require('es5-ext/math/signh')` -- `Math.tanh` -> `require('es5-ext/math/tanh')` -- `Math.trunc` -> `require('es5-ext/math/trunc')` -- `Number.EPSILON` -> `require('es5-ext/number/epsilon')` -- `Number.MAX_SAFE_INTEGER` -> `require('es5-ext/number/max-safe-integer')` -- `Number.MIN_SAFE_INTEGER` -> `require('es5-ext/number/min-safe-integer')` -- `Number.isFinite` -> `require('es5-ext/number/is-finite')` -- `Number.isInteger` -> `require('es5-ext/number/is-integer')` -- `Number.isNaN` -> `require('es5-ext/number/is-nan')` -- `Number.isSafeInteger` -> `require('es5-ext/number/is-safe-integer')` -- `Object.assign` -> `require('es5-ext/object/assign')` -- `Object.keys` -> `require('es5-ext/object/keys')` -- `Object.setPrototypeOf` -> `require('es5-ext/object/set-prototype-of')` -- `RegExp.prototype.match` -> `require('es5-ext/reg-exp/#/match')` -- `RegExp.prototype.replace` -> `require('es5-ext/reg-exp/#/replace')` -- `RegExp.prototype.search` -> `require('es5-ext/reg-exp/#/search')` -- `RegExp.prototype.split` -> `require('es5-ext/reg-exp/#/split')` -- `RegExp.prototype.sticky` -> Implement with `require('es5-ext/reg-exp/#/sticky/implement')`, use as function with `require('es5-ext/reg-exp/#/is-sticky')` -- `RegExp.prototype.unicode` -> Implement with `require('es5-ext/reg-exp/#/unicode/implement')`, use as function with `require('es5-ext/reg-exp/#/is-unicode')` -- `String.fromCodePoint` -> `require('es5-ext/string/from-code-point')` -- `String.raw` -> `require('es5-ext/string/raw')` -- `String.prototype.codePointAt` -> `require('es5-ext/string/#/code-point-at')` -- `String.prototype.contains` -> `require('es5-ext/string/#/contains')` -- `String.prototype.endsWith` -> `require('es5-ext/string/#/ends-with')` -- `String.prototype.normalize` -> `require('es5-ext/string/#/normalize')` -- `String.prototype.repeat` -> `require('es5-ext/string/#/repeat')` -- `String.prototype.startsWith` -> `require('es5-ext/string/#/starts-with')` -- `String.prototype[@@iterator]` -> `require('es5-ext/string/#/@@iterator')` - -#### Non ECMAScript standard features - -__es5-ext__ provides also other utils, and implements them as if they were proposed for a standard. It mostly offers methods (not functions) which can directly be assigned to native prototypes: - -```javascript -Object.defineProperty(Function.prototype, 'partial', { value: require('es5-ext/function/#/partial'), - configurable: true, enumerable: false, writable: true }); -Object.defineProperty(Array.prototype, 'flatten', { value: require('es5-ext/array/#/flatten'), - configurable: true, enumerable: false, writable: true }); -Object.defineProperty(String.prototype, 'capitalize', { value: require('es5-ext/string/#/capitalize'), - configurable: true, enumerable: false, writable: true }); -``` - -See [es5-extend](https://github.com/wookieb/es5-extend#es5-extend), a great utility that automatically will extend natives for you. - -__Important:__ Remember to __not__ extend natives in scope of generic reusable packages (e.g. ones you intend to publish to npm). Extending natives is fine __only__ if you're the _owner_ of the global scope, so e.g. in final project you lead development of. - -When you're in situation when native extensions are not good idea, then you should use methods indirectly: - - -```javascript -var flatten = require('es5-ext/array/#/flatten'); - -flatten.call([1, [2, [3, 4]]]); // [1, 2, 3, 4] -``` - -for better convenience you can turn methods into functions: - - -```javascript -var call = Function.prototype.call -var flatten = call.bind(require('es5-ext/array/#/flatten')); - -flatten([1, [2, [3, 4]]]); // [1, 2, 3, 4] -``` - -You can configure custom toolkit (like [underscorejs](http://underscorejs.org/)), and use it throughout your application - -```javascript -var util = {}; -util.partial = call.bind(require('es5-ext/function/#/partial')); -util.flatten = call.bind(require('es5-ext/array/#/flatten')); -util.startsWith = call.bind(require('es5-ext/string/#/starts-with')); - -util.flatten([1, [2, [3, 4]]]); // [1, 2, 3, 4] -``` - -As with native ones most methods are generic and can be run on any type of object. - -## API - -### Global extensions - -#### global _(es5-ext/global)_ - -Object that represents global scope - -### Array Constructor extensions - -#### from(arrayLike[, mapFn[, thisArg]]) _(es5-ext/array/from)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from). -Returns array representation of _iterable_ or _arrayLike_. If _arrayLike_ is an instance of array, its copy is returned. - -#### generate([length[, …fill]]) _(es5-ext/array/generate)_ - -Generate an array of pre-given _length_ built of repeated arguments. - -#### isPlainArray(x) _(es5-ext/array/is-plain-array)_ - -Returns true if object is plain array (not instance of one of the Array's extensions). - -#### of([…items]) _(es5-ext/array/of)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.of). -Create an array from given arguments. - -#### toArray(obj) _(es5-ext/array/to-array)_ - -Returns array representation of `obj`. If `obj` is already an array, `obj` is returned back. - -#### validArray(obj) _(es5-ext/array/valid-array)_ - -Returns `obj` if it's an array, otherwise throws `TypeError` - -### Array Prototype extensions - -#### arr.binarySearch(compareFn) _(es5-ext/array/#/binary-search)_ - -In __sorted__ list search for index of item for which _compareFn_ returns value closest to _0_. -It's variant of binary search algorithm - -#### arr.clear() _(es5-ext/array/#/clear)_ - -Clears the array - -#### arr.compact() _(es5-ext/array/#/compact)_ - -Returns a copy of the context with all non-values (`null` or `undefined`) removed. - -#### arr.concat() _(es5-ext/array/#/concat)_ - -[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.concat). -ES6's version of `concat`. Supports `isConcatSpreadable` symbol, and returns array of same type as the context. - -#### arr.contains(searchElement[, position]) _(es5-ext/array/#/contains)_ - -Whether list contains the given value. - -#### arr.copyWithin(target, start[, end]) _(es5-ext/array/#/copy-within)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.copywithin). - -#### arr.diff(other) _(es5-ext/array/#/diff)_ - -Returns the array of elements that are present in context list but not present in other list. - -#### arr.eIndexOf(searchElement[, fromIndex]) _(es5-ext/array/#/e-index-of)_ - -_egal_ version of `indexOf` method. [_SameValueZero_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) logic is used for comparision - -#### arr.eLastIndexOf(searchElement[, fromIndex]) _(es5-ext/array/#/e-last-index-of)_ - -_egal_ version of `lastIndexOf` method. [_SameValueZero_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) logic is used for comparision - -#### arr.entries() _(es5-ext/array/#/entries)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.entries). -Returns iterator object, which traverses the array. Each value is represented with an array, where first value is an index and second is corresponding to index value. - -#### arr.exclusion([…lists]]) _(es5-ext/array/#/exclusion)_ - -Returns the array of elements that are found only in one of the lists (either context list or list provided in arguments). - -#### arr.fill(value[, start, end]) _(es5-ext/array/#/fill)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.fill). - -#### arr.filter(callback[, thisArg]) _(es5-ext/array/#/filter)_ - -[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.filter). -ES6's version of `filter`, returns array of same type as the context. - -#### arr.find(predicate[, thisArg]) _(es5-ext/array/#/find)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.find). -Return first element for which given function returns true - -#### arr.findIndex(predicate[, thisArg]) _(es5-ext/array/#/find-index)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.findindex). -Return first index for which given function returns true - -#### arr.first() _(es5-ext/array/#/first)_ - -Returns value for first defined index - -#### arr.firstIndex() _(es5-ext/array/#/first-index)_ - -Returns first declared index of the array - -#### arr.flatten() _(es5-ext/array/#/flatten)_ - -Returns flattened version of the array - -#### arr.forEachRight(cb[, thisArg]) _(es5-ext/array/#/for-each-right)_ - -`forEach` starting from last element - -#### arr.group(cb[, thisArg]) _(es5-ext/array/#/group)_ - -Group list elements by value returned by _cb_ function - -#### arr.indexesOf(searchElement[, fromIndex]) _(es5-ext/array/#/indexes-of)_ - -Returns array of all indexes of given value - -#### arr.intersection([…lists]) _(es5-ext/array/#/intersection)_ - -Computes the array of values that are the intersection of all lists (context list and lists given in arguments) - -#### arr.isCopy(other) _(es5-ext/array/#/is-copy)_ - -Returns true if both context and _other_ lists have same content - -#### arr.isUniq() _(es5-ext/array/#/is-uniq)_ - -Returns true if all values in array are unique - -#### arr.keys() _(es5-ext/array/#/keys)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.keys). -Returns iterator object, which traverses all array indexes. - -#### arr.last() _(es5-ext/array/#/last)_ - -Returns value of last defined index - -#### arr.lastIndex() _(es5-ext/array/#/last)_ - -Returns last defined index of the array - -#### arr.map(callback[, thisArg]) _(es5-ext/array/#/map)_ - -[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.map). -ES6's version of `map`, returns array of same type as the context. - -#### arr.remove(value[, …valuen]) _(es5-ext/array/#/remove)_ - -Remove values from the array - -#### arr.separate(sep) _(es5-ext/array/#/separate)_ - -Returns array with items separated with `sep` value - -#### arr.slice(callback[, thisArg]) _(es5-ext/array/#/slice)_ - -[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.slice). -ES6's version of `slice`, returns array of same type as the context. - -#### arr.someRight(cb[, thisArg]) _(es5-ext/array/#/someRight)_ - -`some` starting from last element - -#### arr.splice(callback[, thisArg]) _(es5-ext/array/#/splice)_ - -[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.splice). -ES6's version of `splice`, returns array of same type as the context. - -#### arr.uniq() _(es5-ext/array/#/uniq)_ - -Returns duplicate-free version of the array - -#### arr.values() _(es5-ext/array/#/values)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype.values). -Returns iterator object which traverses all array values. - -#### arr[@@iterator] _(es5-ext/array/#/@@iterator)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.prototype-@@iterator). -Returns iterator object which traverses all array values. - -### Boolean Constructor extensions - -#### isBoolean(x) _(es5-ext/boolean/is-boolean)_ - -Whether value is boolean - -### Date Constructor extensions - -#### isDate(x) _(es5-ext/date/is-date)_ - -Whether value is date instance - -#### validDate(x) _(es5-ext/date/valid-date)_ - -If given object is not date throw TypeError in other case return it. - -### Date Prototype extensions - -#### date.copy(date) _(es5-ext/date/#/copy)_ - -Returns a copy of the date object - -#### date.daysInMonth() _(es5-ext/date/#/days-in-month)_ - -Returns number of days of date's month - -#### date.floorDay() _(es5-ext/date/#/floor-day)_ - -Sets the date time to 00:00:00.000 - -#### date.floorMonth() _(es5-ext/date/#/floor-month)_ - -Sets date day to 1 and date time to 00:00:00.000 - -#### date.floorYear() _(es5-ext/date/#/floor-year)_ - -Sets date month to 0, day to 1 and date time to 00:00:00.000 - -#### date.format(pattern) _(es5-ext/date/#/format)_ - -Formats date up to given string. Supported patterns: - -* `%Y` - Year with century, 1999, 2003 -* `%y` - Year without century, 99, 03 -* `%m` - Month, 01..12 -* `%d` - Day of the month 01..31 -* `%H` - Hour (24-hour clock), 00..23 -* `%M` - Minute, 00..59 -* `%S` - Second, 00..59 -* `%L` - Milliseconds, 000..999 - -### Error Constructor extensions - -#### custom(message/*, code, ext*/) _(es5-ext/error/custom)_ - -Creates custom error object, optinally extended with `code` and other extension properties (provided with `ext` object) - -#### isError(x) _(es5-ext/error/is-error)_ - -Whether value is an error (instance of `Error`). - -#### validError(x) _(es5-ext/error/valid-error)_ - -If given object is not error throw TypeError in other case return it. - -### Error Prototype extensions - -#### err.throw() _(es5-ext/error/#/throw)_ - -Throws error - -### Function Constructor extensions - -Some of the functions were inspired by [Functional JavaScript](http://osteele.com/sources/javascript/functional/) project by Olivier Steele - -#### constant(x) _(es5-ext/function/constant)_ - -Returns a constant function that returns pregiven argument - -_k(x)(y) =def x_ - -#### identity(x) _(es5-ext/function/identity)_ - -Identity function. Returns first argument - -_i(x) =def x_ - -#### invoke(name[, …args]) _(es5-ext/function/invoke)_ - -Returns a function that takes an object as an argument, and applies object's -_name_ method to arguments. -_name_ can be name of the method or method itself. - -_invoke(name, …args)(object, …args2) =def object\[name\]\(…args, …args2\)_ - -#### isArguments(x) _(es5-ext/function/is-arguments)_ - -Whether value is arguments object - -#### isFunction(arg) _(es5-ext/function/is-function)_ - -Wether value is instance of function - -#### noop() _(es5-ext/function/noop)_ - -No operation function - -#### pluck(name) _(es5-ext/function/pluck)_ - -Returns a function that takes an object, and returns the value of its _name_ -property - -_pluck(name)(obj) =def obj[name]_ - -#### validFunction(arg) _(es5-ext/function/valid-function)_ - -If given object is not function throw TypeError in other case return it. - -### Function Prototype extensions - -Some of the methods were inspired by [Functional JavaScript](http://osteele.com/sources/javascript/functional/) project by Olivier Steele - -#### fn.compose([…fns]) _(es5-ext/function/#/compose)_ - -Applies the functions in reverse argument-list order. - -_f1.compose(f2, f3, f4)(…args) =def f1(f2(f3(f4(…arg))))_ - -#### fn.copy() _(es5-ext/function/#/copy)_ - -Produces copy of given function - -#### fn.curry([n]) _(es5-ext/function/#/curry)_ - -Invoking the function returned by this function only _n_ arguments are passed to the underlying function. If the underlying function is not saturated, the result is a function that passes all its arguments to the underlying function. -If _n_ is not provided then it defaults to context function length - -_f.curry(4)(arg1, arg2)(arg3)(arg4) =def f(arg1, args2, arg3, arg4)_ - -#### fn.lock([…args]) _(es5-ext/function/#/lock)_ - -Returns a function that applies the underlying function to _args_, and ignores its own arguments. - -_f.lock(…args)(…args2) =def f(…args)_ - -_Named after it's counterpart in Google Closure_ - -#### fn.not() _(es5-ext/function/#/not)_ - -Returns a function that returns boolean negation of value returned by underlying function. - -_f.not()(…args) =def !f(…args)_ - -#### fn.partial([…args]) _(es5-ext/function/#/partial)_ - -Returns a function that when called will behave like context function called with initially passed arguments. If more arguments are suplilied, they are appended to initial args. - -_f.partial(…args1)(…args2) =def f(…args1, …args2)_ - -#### fn.spread() _(es5-ext/function/#/spread)_ - -Returns a function that applies underlying function with first list argument - -_f.match()(args) =def f.apply(null, args)_ - -#### fn.toStringTokens() _(es5-ext/function/#/to-string-tokens)_ - -Serializes function into two (arguments and body) string tokens. Result is plain object with `args` and `body` properties. - -### Math extensions - -#### acosh(x) _(es5-ext/math/acosh)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.acosh). - -#### asinh(x) _(es5-ext/math/asinh)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.asinh). - -#### atanh(x) _(es5-ext/math/atanh)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.atanh). - -#### cbrt(x) _(es5-ext/math/cbrt)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.cbrt). - -#### clz32(x) _(es5-ext/math/clz32)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.clz32). - -#### cosh(x) _(es5-ext/math/cosh)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.cosh). - -#### expm1(x) _(es5-ext/math/expm1)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.expm1). - -#### fround(x) _(es5-ext/math/fround)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.fround). - -#### hypot([…values]) _(es5-ext/math/hypot)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.hypot). - -#### imul(x, y) _(es5-ext/math/imul)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.imul). - -#### log1p(x) _(es5-ext/math/log1p)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.log1p). - -#### log2(x) _(es5-ext/math/log2)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.log2). - -#### log10(x) _(es5-ext/math/log10)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.log10). - -#### sign(x) _(es5-ext/math/sign)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.sign). - -#### sinh(x) _(es5-ext/math/sinh)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.sinh). - -#### tanh(x) _(es5-ext/math/tanh)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.tanh). - -#### trunc(x) _(es5-ext/math/trunc)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-math.trunc). - -### Number Constructor extensions - -#### EPSILON _(es5-ext/number/epsilon)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.epsilon). - -The difference between 1 and the smallest value greater than 1 that is representable as a Number value, which is approximately 2.2204460492503130808472633361816 x 10-16. - -#### isFinite(x) _(es5-ext/number/is-finite)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isfinite). -Whether value is finite. Differs from global isNaN that it doesn't do type coercion. - -#### isInteger(x) _(es5-ext/number/is-integer)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isinteger). -Whether value is integer. - -#### isNaN(x) _(es5-ext/number/is-nan)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.isnan). -Whether value is NaN. Differs from global isNaN that it doesn't do type coercion. - -#### isNumber(x) _(es5-ext/number/is-number)_ - -Whether given value is number - -#### isSafeInteger(x) _(es5-ext/number/is-safe-integer)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.issafeinteger). - -#### MAX_SAFE_INTEGER _(es5-ext/number/max-safe-integer)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.maxsafeinteger). -The value of Number.MAX_SAFE_INTEGER is 9007199254740991. - -#### MIN_SAFE_INTEGER _(es5-ext/number/min-safe-integer)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-number.minsafeinteger). -The value of Number.MIN_SAFE_INTEGER is -9007199254740991 (253-1). - -#### toInteger(x) _(es5-ext/number/to-integer)_ - -Converts value to integer - -#### toPosInteger(x) _(es5-ext/number/to-pos-integer)_ - -Converts value to positive integer. If provided value is less than 0, then 0 is returned - -#### toUint32(x) _(es5-ext/number/to-uint32)_ - -Converts value to unsigned 32 bit integer. This type is used for array lengths. -See: http://www.2ality.com/2012/02/js-integers.html - -### Number Prototype extensions - -#### num.pad(length[, precision]) _(es5-ext/number/#/pad)_ - -Pad given number with zeros. Returns string - -### Object Constructor extensions - -#### assign(target, source[, …sourcen]) _(es5-ext/object/assign)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign). -Extend _target_ by enumerable own properties of other objects. If properties are already set on target object, they will be overwritten. - -#### clear(obj) _(es5-ext/object/clear)_ - -Remove all enumerable own properties of the object - -#### compact(obj) _(es5-ext/object/compact)_ - -Returns copy of the object with all enumerable properties that have no falsy values - -#### compare(obj1, obj2) _(es5-ext/object/compare)_ - -Universal cross-type compare function. To be used for e.g. array sort. - -#### copy(obj) _(es5-ext/object/copy)_ - -Returns copy of the object with all enumerable properties. - -#### copyDeep(obj) _(es5-ext/object/copy-deep)_ - -Returns deep copy of the object with all enumerable properties. - -#### count(obj) _(es5-ext/object/count)_ - -Counts number of enumerable own properties on object - -#### create(obj[, properties]) _(es5-ext/object/create)_ - -`Object.create` alternative that provides workaround for [V8 issue](http://code.google.com/p/v8/issues/detail?id=2804). - -When `null` is provided as a prototype, it's substituted with specially prepared object that derives from Object.prototype but has all Object.prototype properties shadowed with undefined. - -It's quirky solution that allows us to have plain objects with no truthy properties but with turnable prototype. - -Use only for objects that you plan to switch prototypes of and be aware of limitations of this workaround. - -#### eq(x, y) _(es5-ext/object/eq)_ - -Whether two values are equal, using [_SameValueZero_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) algorithm. - -#### every(obj, cb[, thisArg[, compareFn]]) _(es5-ext/object/every)_ - -Analogous to Array.prototype.every. Returns true if every key-value pair in this object satisfies the provided testing function. -Optionally _compareFn_ can be provided which assures that keys are tested in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key). - -#### filter(obj, cb[, thisArg]) _(es5-ext/object/filter)_ - -Analogous to Array.prototype.filter. Returns new object with properites for which _cb_ function returned truthy value. - -#### firstKey(obj) _(es5-ext/object/first-key)_ - -Returns first enumerable key of the object, as keys are unordered by specification, it can be any key of an object. - -#### flatten(obj) _(es5-ext/object/flatten)_ - -Returns new object, with flatten properties of input object - -_flatten({ a: { b: 1 }, c: { d: 1 } }) =def { b: 1, d: 1 }_ - -#### forEach(obj, cb[, thisArg[, compareFn]]) _(es5-ext/object/for-each)_ - -Analogous to Array.prototype.forEach. Calls a function for each key-value pair found in object -Optionally _compareFn_ can be provided which assures that properties are iterated in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key). - -#### getPropertyNames() _(es5-ext/object/get-property-names)_ - -Get all (not just own) property names of the object - -#### is(x, y) _(es5-ext/object/is)_ - -Whether two values are equal, using [_SameValue_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero) algorithm. - -#### isArrayLike(x) _(es5-ext/object/is-array-like)_ - -Whether object is array-like object - -#### isCopy(x, y) _(es5-ext/object/is-copy)_ - -Two values are considered a copy of same value when all of their own enumerable properties have same values. - -#### isCopyDeep(x, y) _(es5-ext/object/is-copy-deep)_ - -Deep comparision of objects - -#### isEmpty(obj) _(es5-ext/object/is-empty)_ - -True if object doesn't have any own enumerable property - -#### isObject(arg) _(es5-ext/object/is-object)_ - -Whether value is not primitive - -#### isPlainObject(arg) _(es5-ext/object/is-plain-object)_ - -Whether object is plain object, its protototype should be Object.prototype and it cannot be host object. - -#### keyOf(obj, searchValue) _(es5-ext/object/key-of)_ - -Search object for value - -#### keys(obj) _(es5-ext/object/keys)_ - -[_Updated with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.keys). -ES6's version of `keys`, doesn't throw on primitive input - -#### map(obj, cb[, thisArg]) _(es5-ext/object/map)_ - -Analogous to Array.prototype.map. Creates a new object with properties which values are results of calling a provided function on every key-value pair in this object. - -#### mapKeys(obj, cb[, thisArg]) _(es5-ext/object/map-keys)_ - -Create new object with same values, but remapped keys - -#### mixin(target, source) _(es5-ext/object/mixin)_ - -Extend _target_ by all own properties of other objects. Properties found in both objects will be overwritten (unless they're not configurable and cannot be overwritten). -_It was for a moment part of ECMAScript 6 draft._ - -#### mixinPrototypes(target, …source]) _(es5-ext/object/mixin-prototypes)_ - -Extends _target_, with all source and source's prototype properties. -Useful as an alternative for `setPrototypeOf` in environments in which it cannot be shimmed (no `__proto__` support). - -#### normalizeOptions(options) _(es5-ext/object/normalize-options)_ - -Normalizes options object into flat plain object. - -Useful for functions in which we either need to keep options object for future reference or need to modify it for internal use. - -- It never returns input `options` object back (always a copy is created) -- `options` can be undefined in such case empty plain object is returned. -- Copies all enumerable properties found down prototype chain. - -#### primitiveSet([…names]) _(es5-ext/object/primitive-set)_ - -Creates `null` prototype based plain object, and sets on it all property names provided in arguments to true. - -#### safeTraverse(obj[, …names]) _(es5-ext/object/safe-traverse)_ - -Safe navigation of object properties. See http://wiki.ecmascript.org/doku.php?id=strawman:existential_operator - -#### serialize(value) _(es5-ext/object/serialize)_ - -Serialize value into string. Differs from [JSON.stringify](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) that it serializes also dates, functions and regular expresssions. - -#### setPrototypeOf(object, proto) _(es5-ext/object/set-prototype-of)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.setprototypeof). -If native version is not provided, it depends on existence of `__proto__` functionality, if it's missing, `null` instead of function is exposed. - -#### some(obj, cb[, thisArg[, compareFn]]) _(es5-ext/object/some)_ - -Analogous to Array.prototype.some Returns true if any key-value pair satisfies the provided -testing function. -Optionally _compareFn_ can be provided which assures that keys are tested in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key). - -#### toArray(obj[, cb[, thisArg[, compareFn]]]) _(es5-ext/object/to-array)_ - -Creates an array of results of calling a provided function on every key-value pair in this object. -Optionally _compareFn_ can be provided which assures that results are added in given order. If provided _compareFn_ is equal to `true`, then order is alphabetical (by key). - -#### unserialize(str) _(es5-ext/object/unserialize)_ - -Userializes value previously serialized with [serialize](#serializevalue-es5-extobjectserialize) - -#### validCallable(x) _(es5-ext/object/valid-callable)_ - -If given object is not callable throw TypeError in other case return it. - -#### validObject(x) _(es5-ext/object/valid-object)_ - -Throws error if given value is not an object, otherwise it is returned. - -#### validValue(x) _(es5-ext/object/valid-value)_ - -Throws error if given value is `null` or `undefined`, otherwise returns value. - -### RegExp Constructor extensions - -#### escape(str) _(es5-ext/reg-exp/escape)_ - -Escapes string to be used in regular expression - -#### isRegExp(x) _(es5-ext/reg-exp/is-reg-exp)_ - -Whether object is regular expression - -#### validRegExp(x) _(es5-ext/reg-exp/valid-reg-exp)_ - -If object is regular expression it is returned, otherwise TypeError is thrown. - -### RegExp Prototype extensions - -#### re.isSticky(x) _(es5-ext/reg-exp/#/is-sticky)_ - -Whether regular expression has `sticky` flag. - -It's to be used as counterpart to [regExp.sticky](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-get-regexp.prototype.sticky) if it's not implemented. - -#### re.isUnicode(x) _(es5-ext/reg-exp/#/is-unicode)_ - -Whether regular expression has `unicode` flag. - -It's to be used as counterpart to [regExp.unicode](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-get-regexp.prototype.unicode) if it's not implemented. - -#### re.match(string) _(es5-ext/reg-exp/#/match)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.match). - -#### re.replace(string, replaceValue) _(es5-ext/reg-exp/#/replace)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.replace). - -#### re.search(string) _(es5-ext/reg-exp/#/search)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.search). - -#### re.split(string) _(es5-ext/reg-exp/#/search)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.split). - -#### re.sticky _(es5-ext/reg-exp/#/sticky/implement)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.sticky). -It's a getter, so only `implement` and `is-implemented` modules are provided. - -#### re.unicode _(es5-ext/reg-exp/#/unicode/implement)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-regexp.prototype.unicode). -It's a getter, so only `implement` and `is-implemented` modules are provided. - -### String Constructor extensions - -#### formatMethod(fMap) _(es5-ext/string/format-method)_ - -Creates format method. It's used e.g. to create `Date.prototype.format` method - -#### fromCodePoint([…codePoints]) _(es5-ext/string/from-code-point)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.fromcodepoint) - -#### isString(x) _(es5-ext/string/is-string)_ - -Whether object is string - -#### randomUniq() _(es5-ext/string/random-uniq)_ - -Returns randomly generated id, with guarantee of local uniqueness (no same id will be returned twice) - -#### raw(callSite[, …substitutions]) _(es5-ext/string/raw)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.raw) - -### String Prototype extensions - -#### str.at(pos) _(es5-ext/string/#/at)_ - -_Proposed for ECMAScript 6/7 standard, but not (yet) in a draft_ - -Returns a string at given position in Unicode-safe manner. -Based on [implementation by Mathias Bynens](https://github.com/mathiasbynens/String.prototype.at). - -#### str.camelToHyphen() _(es5-ext/string/#/camel-to-hyphen)_ - -Convert camelCase string to hyphen separated, e.g. one-two-three -> oneTwoThree. -Useful when converting names from js property convention into filename convention. - -#### str.capitalize() _(es5-ext/string/#/capitalize)_ - -Capitalize first character of a string - -#### str.caseInsensitiveCompare(str) _(es5-ext/string/#/case-insensitive-compare)_ - -Case insensitive compare - -#### str.codePointAt(pos) _(es5-ext/string/#/code-point-at)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.codepointat) - -Based on [implementation by Mathias Bynens](https://github.com/mathiasbynens/String.prototype.codePointAt). - -#### str.contains(searchString[, position]) _(es5-ext/string/#/contains)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.contains) - -Whether string contains given string. - -#### str.endsWith(searchString[, endPosition]) _(es5-ext/string/#/ends-with)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.endswith). -Whether strings ends with given string - -#### str.hyphenToCamel() _(es5-ext/string/#/hyphen-to-camel)_ - -Convert hyphen separated string to camelCase, e.g. one-two-three -> oneTwoThree. -Useful when converting names from filename convention to js property name convention. - -#### str.indent(str[, count]) _(es5-ext/string/#/indent)_ - -Indents each line with provided _str_ (if _count_ given then _str_ is repeated _count_ times). - -#### str.last() _(es5-ext/string/#/last)_ - -Return last character - -#### str.normalize([form]) _(es5-ext/string/#/normalize)_ - -[_Introduced with ECMAScript 6_](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize). -Returns the Unicode Normalization Form of a given string. -Based on Matsuza's version. Code used for integrated shim can be found at [github.com/walling/unorm](https://github.com/walling/unorm/blob/master/lib/unorm.js) - -#### str.pad(fill[, length]) _(es5-ext/string/#/pad)_ - -Pad string with _fill_. -If _length_ si given than _fill_ is reapated _length_ times. -If _length_ is negative then pad is applied from right. - -#### str.repeat(n) _(es5-ext/string/#/repeat)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.repeat). -Repeat given string _n_ times - -#### str.plainReplace(search, replace) _(es5-ext/string/#/plain-replace)_ - -Simple `replace` version. Doesn't support regular expressions. Replaces just first occurrence of search string. Doesn't support insert patterns, therefore it is safe to replace text with text obtained programmatically (there's no need for additional _$_ characters escape in such case). - -#### str.plainReplaceAll(search, replace) _(es5-ext/string/#/plain-replace-all)_ - -Simple `replace` version. Doesn't support regular expressions. Replaces all occurrences of search string. Doesn't support insert patterns, therefore it is safe to replace text with text obtained programmatically (there's no need for additional _$_ characters escape in such case). - -#### str.startsWith(searchString[, position]) _(es5-ext/string/#/starts-with)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype.startswith). -Whether strings starts with given string - -#### str[@@iterator] _(es5-ext/string/#/@@iterator)_ - -[_Introduced with ECMAScript 6_](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-string.prototype-@@iterator). -Returns iterator object which traverses all string characters (with respect to unicode symbols) - -### Tests [![Build Status](https://travis-ci.org/medikoo/es5-ext.png)](https://travis-ci.org/medikoo/es5-ext) - - $ npm test diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/implement.js deleted file mode 100644 index 0f714a1d2795e3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, require('es6-symbol').iterator, { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/index.js deleted file mode 100644 index a69462650e7302..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Array.prototype[require('es6-symbol').iterator] : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/is-implemented.js deleted file mode 100644 index 72eb1f8a27ff30..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/is-implemented.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator; - -module.exports = function () { - var arr = ['foo', 1], iterator, result; - if (typeof arr[iteratorSymbol] !== 'function') return false; - iterator = arr[iteratorSymbol](); - if (!iterator) return false; - if (typeof iterator.next !== 'function') return false; - result = iterator.next(); - if (!result) return false; - if (result.value !== 'foo') return false; - if (result.done !== false) return false; - return true; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/shim.js deleted file mode 100644 index ff295df9961e9a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/@@iterator/shim.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('../values/shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/_compare-by-length.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/_compare-by-length.js deleted file mode 100644 index d8343ce306d3ca..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/_compare-by-length.js +++ /dev/null @@ -1,9 +0,0 @@ -// Used internally to sort array of lists by length - -'use strict'; - -var toPosInt = require('../../number/to-pos-integer'); - -module.exports = function (a, b) { - return toPosInt(a.length) - toPosInt(b.length); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/binary-search.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/binary-search.js deleted file mode 100644 index 8eb45675149256..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/binary-search.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -var toPosInt = require('../../number/to-pos-integer') - , callable = require('../../object/valid-callable') - , value = require('../../object/valid-value') - - , floor = Math.floor; - -module.exports = function (compareFn) { - var length, low, high, middle; - - value(this); - callable(compareFn); - - length = toPosInt(this.length); - low = 0; - high = length - 1; - - while (low <= high) { - middle = floor((low + high) / 2); - if (compareFn(this[middle]) < 0) high = middle - 1; - else low = middle + 1; - } - - if (high < 0) return 0; - if (high >= length) return length - 1; - return high; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/clear.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/clear.js deleted file mode 100644 index 3587bdf972d458..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/clear.js +++ /dev/null @@ -1,12 +0,0 @@ -// Inspired by Google Closure: -// http://closure-library.googlecode.com/svn/docs/ -// closure_goog_array_array.js.html#goog.array.clear - -'use strict'; - -var value = require('../../object/valid-value'); - -module.exports = function () { - value(this).length = 0; - return this; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/compact.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/compact.js deleted file mode 100644 index d529d5a2beab8f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/compact.js +++ /dev/null @@ -1,9 +0,0 @@ -// Inspired by: http://documentcloud.github.com/underscore/#compact - -'use strict'; - -var filter = Array.prototype.filter; - -module.exports = function () { - return filter.call(this, function (val) { return val != null; }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/implement.js deleted file mode 100644 index 80c67cb4faf764..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'concat', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/index.js deleted file mode 100644 index db205ea54a41ad..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? - Array.prototype.concat : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/is-implemented.js deleted file mode 100644 index cab8bc9e323bbd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var SubArray = require('../../_sub-array-dummy-safe'); - -module.exports = function () { - return (new SubArray()).concat('foo') instanceof SubArray; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/shim.js deleted file mode 100644 index 8b28e4ae03b70f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/concat/shim.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -var isPlainArray = require('../../is-plain-array') - , toPosInt = require('../../../number/to-pos-integer') - , isObject = require('../../../object/is-object') - - , isArray = Array.isArray, concat = Array.prototype.concat - , forEach = Array.prototype.forEach - - , isSpreadable; - -isSpreadable = function (value) { - if (!value) return false; - if (!isObject(value)) return false; - if (value['@@isConcatSpreadable'] !== undefined) { - return Boolean(value['@@isConcatSpreadable']); - } - return isArray(value); -}; - -module.exports = function (item/*, …items*/) { - var result; - if (!this || !isArray(this) || isPlainArray(this)) { - return concat.apply(this, arguments); - } - result = new this.constructor(this.length); - forEach.call(this, function (val, i) { result[i] = val; }); - forEach.call(arguments, function (arg) { - var base; - if (isSpreadable(arg)) { - base = result.length; - result.length += toPosInt(arg.length); - forEach.call(arg, function (val, i) { result[base + i] = val; }); - return; - } - result.push(arg); - }); - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/contains.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/contains.js deleted file mode 100644 index 4a2f9f6731c8c6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/contains.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var indexOf = require('./e-index-of'); - -module.exports = function (searchElement/*, position*/) { - return indexOf.call(this, searchElement, arguments[1]) > -1; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/implement.js deleted file mode 100644 index eedbad77eebe09..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/implement.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'copyWithin', - { value: require('./shim'), configurable: true, enumerable: false, - writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/index.js deleted file mode 100644 index bb89d0b87934d1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? - Array.prototype.copyWithin : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/is-implemented.js deleted file mode 100644 index 8f17e06d816d14..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var arr = [1, 2, 3, 4, 5]; - if (typeof arr.copyWithin !== 'function') return false; - return String(arr.copyWithin(1, 3)) === '1,4,5,4,5'; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/shim.js deleted file mode 100644 index c0bfb8b0609f4e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/copy-within/shim.js +++ /dev/null @@ -1,39 +0,0 @@ -// Taken from: https://github.com/paulmillr/es6-shim/ - -'use strict'; - -var toInteger = require('../../../number/to-integer') - , toPosInt = require('../../../number/to-pos-integer') - , validValue = require('../../../object/valid-value') - - , hasOwnProperty = Object.prototype.hasOwnProperty - , max = Math.max, min = Math.min; - -module.exports = function (target, start/*, end*/) { - var o = validValue(this), end = arguments[2], l = toPosInt(o.length) - , to, from, fin, count, direction; - - target = toInteger(target); - start = toInteger(start); - end = (end === undefined) ? l : toInteger(end); - - to = target < 0 ? max(l + target, 0) : min(target, l); - from = start < 0 ? max(l + start, 0) : min(start, l); - fin = end < 0 ? max(l + end, 0) : min(end, l); - count = min(fin - from, l - to); - direction = 1; - - if ((from < to) && (to < (from + count))) { - direction = -1; - from += count - 1; - to += count - 1; - } - while (count > 0) { - if (hasOwnProperty.call(o, from)) o[to] = o[from]; - else delete o[from]; - from += direction; - to += direction; - count -= 1; - } - return o; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/diff.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/diff.js deleted file mode 100644 index a1f95419d4ed65..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/diff.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -var value = require('../../object/valid-value') - , contains = require('./contains') - - , filter = Array.prototype.filter; - -module.exports = function (other) { - (value(this) && value(other)); - return filter.call(this, function (item) { - return !contains.call(other, item); - }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/e-index-of.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/e-index-of.js deleted file mode 100644 index 80864d0666168a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/e-index-of.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -var toPosInt = require('../../number/to-pos-integer') - , value = require('../../object/valid-value') - - , indexOf = Array.prototype.indexOf - , hasOwnProperty = Object.prototype.hasOwnProperty - , abs = Math.abs, floor = Math.floor; - -module.exports = function (searchElement/*, fromIndex*/) { - var i, l, fromIndex, val; - if (searchElement === searchElement) { //jslint: ignore - return indexOf.apply(this, arguments); - } - - l = toPosInt(value(this).length); - fromIndex = arguments[1]; - if (isNaN(fromIndex)) fromIndex = 0; - else if (fromIndex >= 0) fromIndex = floor(fromIndex); - else fromIndex = toPosInt(this.length) - floor(abs(fromIndex)); - - for (i = fromIndex; i < l; ++i) { - if (hasOwnProperty.call(this, i)) { - val = this[i]; - if (val !== val) return i; //jslint: ignore - } - } - return -1; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/e-last-index-of.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/e-last-index-of.js deleted file mode 100644 index 4fc536bd68082d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/e-last-index-of.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -var toPosInt = require('../../number/to-pos-integer') - , value = require('../../object/valid-value') - - , lastIndexOf = Array.prototype.lastIndexOf - , hasOwnProperty = Object.prototype.hasOwnProperty - , abs = Math.abs, floor = Math.floor; - -module.exports = function (searchElement/*, fromIndex*/) { - var i, fromIndex, val; - if (searchElement === searchElement) { //jslint: ignore - return lastIndexOf.apply(this, arguments); - } - - value(this); - fromIndex = arguments[1]; - if (isNaN(fromIndex)) fromIndex = (toPosInt(this.length) - 1); - else if (fromIndex >= 0) fromIndex = floor(fromIndex); - else fromIndex = toPosInt(this.length) - floor(abs(fromIndex)); - - for (i = fromIndex; i >= 0; --i) { - if (hasOwnProperty.call(this, i)) { - val = this[i]; - if (val !== val) return i; //jslint: ignore - } - } - return -1; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/implement.js deleted file mode 100644 index 490de60e207ab4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'entries', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/index.js deleted file mode 100644 index 292792cf159da8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? - Array.prototype.entries : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/is-implemented.js deleted file mode 100644 index e186c17237bd39..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/is-implemented.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = function () { - var arr = [1, 'foo'], iterator, result; - if (typeof arr.entries !== 'function') return false; - iterator = arr.entries(); - if (!iterator) return false; - if (typeof iterator.next !== 'function') return false; - result = iterator.next(); - if (!result || !result.value) return false; - if (result.value[0] !== 0) return false; - if (result.value[1] !== 1) return false; - if (result.done !== false) return false; - return true; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/shim.js deleted file mode 100644 index c052b53f01d89f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/entries/shim.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -var ArrayIterator = require('es6-iterator/array'); -module.exports = function () { return new ArrayIterator(this, 'key+value'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/exclusion.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/exclusion.js deleted file mode 100644 index f08adc81c9631e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/exclusion.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -var value = require('../../object/valid-value') - , aFrom = require('../from') - , toArray = require('../to-array') - , contains = require('./contains') - , byLength = require('./_compare-by-length') - - , filter = Array.prototype.filter, push = Array.prototype.push; - -module.exports = function (/*…lists*/) { - var lists, seen, result; - if (!arguments.length) return aFrom(this); - push.apply(lists = [this], arguments); - lists.forEach(value); - seen = []; - result = []; - lists.sort(byLength).forEach(function (list) { - result = result.filter(function (item) { - return !contains.call(list, item); - }).concat(filter.call(list, function (x) { - return !contains.call(seen, x); - })); - push.apply(seen, toArray(list)); - }); - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/implement.js deleted file mode 100644 index 22511919c516fe..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'fill', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/index.js deleted file mode 100644 index 36c1f66668b29d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? - Array.prototype.fill : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/is-implemented.js deleted file mode 100644 index b8e546888af2b4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var arr = [1, 2, 3, 4, 5, 6]; - if (typeof arr.fill !== 'function') return false; - return String(arr.fill(-1, -3)) === '1,2,3,-1,-1,-1'; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/shim.js deleted file mode 100644 index 45823be51fc193..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/fill/shim.js +++ /dev/null @@ -1,21 +0,0 @@ -// Taken from: https://github.com/paulmillr/es6-shim/ - -'use strict'; - -var toInteger = require('../../../number/to-integer') - , toPosInt = require('../../../number/to-pos-integer') - , validValue = require('../../../object/valid-value') - - , max = Math.max, min = Math.min; - -module.exports = function (value/*, start, end*/) { - var o = validValue(this), start = arguments[1], end = arguments[2] - , l = toPosInt(o.length), relativeStart, i; - - start = (start === undefined) ? 0 : toInteger(start); - end = (end === undefined) ? l : toInteger(end); - - relativeStart = start < 0 ? max(l + start, 0) : min(start, l); - for (i = relativeStart; i < l && i < end; ++i) o[i] = value; - return o; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/implement.js deleted file mode 100644 index 090c5f109aee35..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'filter', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/index.js deleted file mode 100644 index bcf0268dc2dcb4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? - Array.prototype.filter : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/is-implemented.js deleted file mode 100644 index 5577273501531e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/is-implemented.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var SubArray = require('../../_sub-array-dummy-safe') - - , pass = function () { return true; }; - -module.exports = function () { - return (new SubArray()).filter(pass) instanceof SubArray; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/shim.js deleted file mode 100644 index b0116defce5021..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/filter/shim.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -var isPlainArray = require('../../is-plain-array') - , callable = require('../../../object/valid-callable') - - , isArray = Array.isArray, filter = Array.prototype.filter - , forEach = Array.prototype.forEach, call = Function.prototype.call; - -module.exports = function (callbackFn/*, thisArg*/) { - var result, thisArg, i; - if (!this || !isArray(this) || isPlainArray(this)) { - return filter.apply(this, arguments); - } - callable(callbackFn); - thisArg = arguments[1]; - result = new this.constructor(); - i = 0; - forEach.call(this, function (val, j, self) { - if (call.call(callbackFn, thisArg, val, j, self)) result[i++] = val; - }); - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/implement.js deleted file mode 100644 index 556cb846002b0e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/implement.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'findIndex', - { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/index.js deleted file mode 100644 index 03a987e22347bf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? - Array.prototype.findIndex : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/is-implemented.js deleted file mode 100644 index dbd3c814b4650f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/is-implemented.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var fn = function (x) { return x > 3; }; - -module.exports = function () { - var arr = [1, 2, 3, 4, 5, 6]; - if (typeof arr.findIndex !== 'function') return false; - return arr.findIndex(fn) === 3; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/shim.js deleted file mode 100644 index 957939f2ba224a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find-index/shim.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var callable = require('../../../object/valid-callable') - , value = require('../../../object/valid-value') - - , some = Array.prototype.some, apply = Function.prototype.apply; - -module.exports = function (predicate/*, thisArg*/) { - var k, self; - self = Object(value(this)); - callable(predicate); - - return some.call(self, function (value, index) { - if (apply.call(predicate, this, arguments)) { - k = index; - return true; - } - return false; - }, arguments[1]) ? k : -1; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/implement.js deleted file mode 100644 index 0f37104ac8dbbf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'find', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/index.js deleted file mode 100644 index 96819d09f02198..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? - Array.prototype.find : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/is-implemented.js deleted file mode 100644 index cc7ec774df0fa4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/is-implemented.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var fn = function (x) { return x > 3; }; - -module.exports = function () { - var arr = [1, 2, 3, 4, 5, 6]; - if (typeof arr.find !== 'function') return false; - return arr.find(fn) === 4; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/shim.js deleted file mode 100644 index c7ee9069a9a308..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/find/shim.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var findIndex = require('../find-index/shim'); - -module.exports = function (predicate/*, thisArg*/) { - var index = findIndex.apply(this, arguments); - return (index === -1) ? undefined : this[index]; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/first-index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/first-index.js deleted file mode 100644 index 7a9e4c34736ca3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/first-index.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var toPosInt = require('../../number/to-pos-integer') - , value = require('../../object/valid-value') - - , hasOwnProperty = Object.prototype.hasOwnProperty; - -module.exports = function () { - var i, l; - if (!(l = toPosInt(value(this).length))) return null; - i = 0; - while (!hasOwnProperty.call(this, i)) { - if (++i === l) return null; - } - return i; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/first.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/first.js deleted file mode 100644 index 11df571754857f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/first.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var firstIndex = require('./first-index'); - -module.exports = function () { - var i; - if ((i = firstIndex.call(this)) !== null) return this[i]; - return undefined; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/flatten.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/flatten.js deleted file mode 100644 index 4bf267f2bad8d9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/flatten.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var isArray = Array.isArray, forEach = Array.prototype.forEach; - -module.exports = function flatten() { - var r = []; - forEach.call(this, function (x) { - if (isArray(x)) { - r = r.concat(flatten.call(x)); - } else { - r.push(x); - } - }); - return r; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/for-each-right.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/for-each-right.js deleted file mode 100644 index 1702bb164466fb..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/for-each-right.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var toPosInt = require('../../number/to-pos-integer') - , callable = require('../../object/valid-callable') - , value = require('../../object/valid-value') - - , hasOwnProperty = Object.prototype.hasOwnProperty - , call = Function.prototype.call; - -module.exports = function (cb/*, thisArg*/) { - var i, self, thisArg; - - self = Object(value(this)); - callable(cb); - thisArg = arguments[1]; - - for (i = (toPosInt(self.length) - 1); i >= 0; --i) { - if (hasOwnProperty.call(self, i)) call.call(cb, thisArg, self[i], i, self); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/group.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/group.js deleted file mode 100644 index fbb178c35c1730..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/group.js +++ /dev/null @@ -1,23 +0,0 @@ -// Inspired by Underscore's groupBy: -// http://documentcloud.github.com/underscore/#groupBy - -'use strict'; - -var callable = require('../../object/valid-callable') - , value = require('../../object/valid-value') - - , forEach = Array.prototype.forEach, apply = Function.prototype.apply; - -module.exports = function (cb/*, thisArg*/) { - var r; - - (value(this) && callable(cb)); - - r = {}; - forEach.call(this, function (v) { - var key = apply.call(cb, this, arguments); - if (!r.hasOwnProperty(key)) r[key] = []; - r[key].push(v); - }, arguments[1]); - return r; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/index.js deleted file mode 100644 index 97ef65cfd42cf1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/index.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -module.exports = { - '@@iterator': require('./@@iterator'), - binarySearch: require('./binary-search'), - clear: require('./clear'), - compact: require('./compact'), - concat: require('./concat'), - contains: require('./contains'), - copyWithin: require('./copy-within'), - diff: require('./diff'), - eIndexOf: require('./e-index-of'), - eLastIndexOf: require('./e-last-index-of'), - entries: require('./entries'), - exclusion: require('./exclusion'), - fill: require('./fill'), - filter: require('./filter'), - find: require('./find'), - findIndex: require('./find-index'), - first: require('./first'), - firstIndex: require('./first-index'), - flatten: require('./flatten'), - forEachRight: require('./for-each-right'), - keys: require('./keys'), - group: require('./group'), - indexesOf: require('./indexes-of'), - intersection: require('./intersection'), - isCopy: require('./is-copy'), - isUniq: require('./is-uniq'), - last: require('./last'), - lastIndex: require('./last-index'), - map: require('./map'), - remove: require('./remove'), - separate: require('./separate'), - slice: require('./slice'), - someRight: require('./some-right'), - splice: require('./splice'), - uniq: require('./uniq'), - values: require('./values') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/indexes-of.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/indexes-of.js deleted file mode 100644 index 6b89157a35b805..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/indexes-of.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var indexOf = require('./e-index-of'); - -module.exports = function (value/*, fromIndex*/) { - var r = [], i, fromIndex = arguments[1]; - while ((i = indexOf.call(this, value, fromIndex)) !== -1) { - r.push(i); - fromIndex = i + 1; - } - return r; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/intersection.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/intersection.js deleted file mode 100644 index fadcb525308964..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/intersection.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var value = require('../../object/valid-value') - , contains = require('./contains') - , byLength = require('./_compare-by-length') - - , filter = Array.prototype.filter, push = Array.prototype.push - , slice = Array.prototype.slice; - -module.exports = function (/*…list*/) { - var lists; - if (!arguments.length) slice.call(this); - push.apply(lists = [this], arguments); - lists.forEach(value); - lists.sort(byLength); - return lists.reduce(function (a, b) { - return filter.call(a, function (x) { return contains.call(b, x); }); - }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/is-copy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/is-copy.js deleted file mode 100644 index ac7c79bc4521ce..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/is-copy.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -var toPosInt = require('../../number/to-pos-integer') - , eq = require('../../object/eq') - , value = require('../../object/valid-value') - - , hasOwnProperty = Object.prototype.hasOwnProperty; - -module.exports = function (other) { - var i, l; - (value(this) && value(other)); - l = toPosInt(this.length); - if (l !== toPosInt(other.length)) return false; - for (i = 0; i < l; ++i) { - if (hasOwnProperty.call(this, i) !== hasOwnProperty.call(other, i)) { - return false; - } - if (!eq(this[i], other[i])) return false; - } - return true; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/is-uniq.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/is-uniq.js deleted file mode 100644 index b14f461d941ee5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/is-uniq.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var indexOf = require('./e-index-of') - - , every = Array.prototype.every - , isFirst; - -isFirst = function (value, index) { - return indexOf.call(this, value) === index; -}; - -module.exports = function () { return every.call(this, isFirst, this); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/implement.js deleted file mode 100644 index e18e61701fa028..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'keys', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/index.js deleted file mode 100644 index 2f89cffe101d61..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? - Array.prototype.keys : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/is-implemented.js deleted file mode 100644 index 06bd87bf296c15..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/is-implemented.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = function () { - var arr = [1, 'foo'], iterator, result; - if (typeof arr.keys !== 'function') return false; - iterator = arr.keys(); - if (!iterator) return false; - if (typeof iterator.next !== 'function') return false; - result = iterator.next(); - if (!result) return false; - if (result.value !== 0) return false; - if (result.done !== false) return false; - return true; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/shim.js deleted file mode 100644 index 83773f6ec955d2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/keys/shim.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -var ArrayIterator = require('es6-iterator/array'); -module.exports = function () { return new ArrayIterator(this, 'key'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/last-index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/last-index.js deleted file mode 100644 index a191d6e153d6ae..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/last-index.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var toPosInt = require('../../number/to-pos-integer') - , value = require('../../object/valid-value') - - , hasOwnProperty = Object.prototype.hasOwnProperty; - -module.exports = function () { - var i, l; - if (!(l = toPosInt(value(this).length))) return null; - i = l - 1; - while (!hasOwnProperty.call(this, i)) { - if (--i === -1) return null; - } - return i; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/last.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/last.js deleted file mode 100644 index bf9d2f29249d09..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/last.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var lastIndex = require('./last-index'); - -module.exports = function () { - var i; - if ((i = lastIndex.call(this)) !== null) return this[i]; - return undefined; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/implement.js deleted file mode 100644 index 3aabb87440e099..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'map', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/index.js deleted file mode 100644 index 66f66607df4f14..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? - Array.prototype.map : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/is-implemented.js deleted file mode 100644 index c328b473302cea..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var identity = require('../../../function/identity') - , SubArray = require('../../_sub-array-dummy-safe'); - -module.exports = function () { - return (new SubArray()).map(identity) instanceof SubArray; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/shim.js deleted file mode 100644 index 2ee731347b1aee..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/map/shim.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -var isPlainArray = require('../../is-plain-array') - , callable = require('../../../object/valid-callable') - - , isArray = Array.isArray, map = Array.prototype.map - , forEach = Array.prototype.forEach, call = Function.prototype.call; - -module.exports = function (callbackFn/*, thisArg*/) { - var result, thisArg; - if (!this || !isArray(this) || isPlainArray(this)) { - return map.apply(this, arguments); - } - callable(callbackFn); - thisArg = arguments[1]; - result = new this.constructor(this.length); - forEach.call(this, function (val, i, self) { - result[i] = call.call(callbackFn, thisArg, val, i, self); - }); - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/remove.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/remove.js deleted file mode 100644 index dcf843313d5fcb..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/remove.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var indexOf = require('./e-index-of') - - , forEach = Array.prototype.forEach, splice = Array.prototype.splice; - -module.exports = function (item/*, …item*/) { - forEach.call(arguments, function (item) { - var index = indexOf.call(this, item); - if (index !== -1) splice.call(this, index, 1); - }, this); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/separate.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/separate.js deleted file mode 100644 index dc974b832e07d2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/separate.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var forEach = Array.prototype.forEach; - -module.exports = function (sep) { - var result = []; - forEach.call(this, function (val, i) { result.push(val, sep); }); - result.pop(); - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/implement.js deleted file mode 100644 index cd488a063956e6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'slice', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/index.js deleted file mode 100644 index 72200ca9e381b6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Array.prototype.slice : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/is-implemented.js deleted file mode 100644 index ec1985e70ee034..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var SubArray = require('../../_sub-array-dummy-safe'); - -module.exports = function () { - return (new SubArray()).slice() instanceof SubArray; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/shim.js deleted file mode 100644 index 2761a1aad8340d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/slice/shim.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -var toInteger = require('../../../number/to-integer') - , toPosInt = require('../../../number/to-pos-integer') - , isPlainArray = require('../../is-plain-array') - - , isArray = Array.isArray, slice = Array.prototype.slice - , hasOwnProperty = Object.prototype.hasOwnProperty, max = Math.max; - -module.exports = function (start, end) { - var length, result, i; - if (!this || !isArray(this) || isPlainArray(this)) { - return slice.apply(this, arguments); - } - length = toPosInt(this.length); - start = toInteger(start); - if (start < 0) start = max(length + start, 0); - else if (start > length) start = length; - if (end === undefined) { - end = length; - } else { - end = toInteger(end); - if (end < 0) end = max(length + end, 0); - else if (end > length) end = length; - } - if (start > end) start = end; - result = new this.constructor(end - start); - i = 0; - while (start !== end) { - if (hasOwnProperty.call(this, start)) result[i] = this[start]; - ++i; - ++start; - } - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/some-right.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/some-right.js deleted file mode 100644 index f54cf945c38447..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/some-right.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var toPosInt = require('../../number/to-pos-integer') - , callable = require('../../object/valid-callable') - , value = require('../../object/valid-value') - - , hasOwnProperty = Object.prototype.hasOwnProperty - , call = Function.prototype.call; - -module.exports = function (cb/*, thisArg*/) { - var i, self, thisArg; - self = Object(value(this)); - callable(cb); - thisArg = arguments[1]; - - for (i = (toPosInt(self.length) - 1); i >= 0; --i) { - if (hasOwnProperty.call(self, i) && - call.call(cb, thisArg, self[i], i, self)) { - return true; - } - } - return false; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/implement.js deleted file mode 100644 index aab1f8eff677b8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'splice', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/index.js deleted file mode 100644 index e8ecf3cf856171..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Array.prototype.splice : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/is-implemented.js deleted file mode 100644 index ffddaa81ef83dd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var SubArray = require('../../_sub-array-dummy-safe'); - -module.exports = function () { - return (new SubArray()).splice(0) instanceof SubArray; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/shim.js deleted file mode 100644 index a8505a2ce2a201..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/splice/shim.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var isPlainArray = require('../../is-plain-array') - - , isArray = Array.isArray, splice = Array.prototype.splice - , forEach = Array.prototype.forEach; - -module.exports = function (start, deleteCount/*, …items*/) { - var arr = splice.apply(this, arguments), result; - if (!this || !isArray(this) || isPlainArray(this)) return arr; - result = new this.constructor(arr.length); - forEach.call(arr, function (val, i) { result[i] = val; }); - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/uniq.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/uniq.js deleted file mode 100644 index db0146555733a2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/uniq.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -var indexOf = require('./e-index-of') - - , filter = Array.prototype.filter - - , isFirst; - -isFirst = function (value, index) { - return indexOf.call(this, value) === index; -}; - -module.exports = function () { return filter.call(this, isFirst, this); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/implement.js deleted file mode 100644 index 237281fd3beed0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array.prototype, 'values', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/index.js deleted file mode 100644 index c0832c30ea4566..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() ? Array.prototype.values : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/is-implemented.js deleted file mode 100644 index cc0c6294e2af14..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/is-implemented.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = function () { - var arr = ['foo', 1], iterator, result; - if (typeof arr.values !== 'function') return false; - iterator = arr.values(); - if (!iterator) return false; - if (typeof iterator.next !== 'function') return false; - result = iterator.next(); - if (!result) return false; - if (result.value !== 'foo') return false; - if (result.done !== false) return false; - return true; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/shim.js deleted file mode 100644 index f6555fd858e99a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/#/values/shim.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -var ArrayIterator = require('es6-iterator/array'); -module.exports = function () { return new ArrayIterator(this, 'value'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/_is-extensible.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/_is-extensible.js deleted file mode 100644 index 612320647b39f6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/_is-extensible.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = (function () { - var SubArray = require('./_sub-array-dummy'), arr; - - if (!SubArray) return false; - arr = new SubArray(); - if (!Array.isArray(arr)) return false; - if (!(arr instanceof SubArray)) return false; - - arr[34] = 'foo'; - return (arr.length === 35); -}()); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/_sub-array-dummy-safe.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/_sub-array-dummy-safe.js deleted file mode 100644 index 5baf8a8d1127a4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/_sub-array-dummy-safe.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var setPrototypeOf = require('../object/set-prototype-of') - , isExtensible = require('./_is-extensible'); - -module.exports = (function () { - var SubArray; - - if (isExtensible) return require('./_sub-array-dummy'); - - if (!setPrototypeOf) return null; - SubArray = function () { - var arr = Array.apply(this, arguments); - setPrototypeOf(arr, SubArray.prototype); - return arr; - }; - setPrototypeOf(SubArray, Array); - SubArray.prototype = Object.create(Array.prototype, { - constructor: { value: SubArray, enumerable: false, writable: true, - configurable: true } - }); - return SubArray; -}()); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/_sub-array-dummy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/_sub-array-dummy.js deleted file mode 100644 index a926d1a32ddd7e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/_sub-array-dummy.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var setPrototypeOf = require('../object/set-prototype-of'); - -module.exports = (function () { - var SubArray; - - if (!setPrototypeOf) return null; - SubArray = function () { Array.apply(this, arguments); }; - setPrototypeOf(SubArray, Array); - SubArray.prototype = Object.create(Array.prototype, { - constructor: { value: SubArray, enumerable: false, writable: true, - configurable: true } - }); - return SubArray; -}()); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/implement.js deleted file mode 100644 index f3411b13770743..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array, 'from', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/index.js deleted file mode 100644 index 3b99cda8ec3db6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Array.from - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/is-implemented.js deleted file mode 100644 index 63ff2a572a353b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/is-implemented.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function () { - var from = Array.from, arr, result; - if (typeof from !== 'function') return false; - arr = ['raz', 'dwa']; - result = from(arr); - return Boolean(result && (result !== arr) && (result[1] === 'dwa')); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/shim.js deleted file mode 100644 index a90ba2f9730c54..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/from/shim.js +++ /dev/null @@ -1,106 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator - , isArguments = require('../../function/is-arguments') - , isFunction = require('../../function/is-function') - , toPosInt = require('../../number/to-pos-integer') - , callable = require('../../object/valid-callable') - , validValue = require('../../object/valid-value') - , isString = require('../../string/is-string') - - , isArray = Array.isArray, call = Function.prototype.call - , desc = { configurable: true, enumerable: true, writable: true, value: null } - , defineProperty = Object.defineProperty; - -module.exports = function (arrayLike/*, mapFn, thisArg*/) { - var mapFn = arguments[1], thisArg = arguments[2], Constructor, i, j, arr, l, code, iterator - , result, getIterator, value; - - arrayLike = Object(validValue(arrayLike)); - - if (mapFn != null) callable(mapFn); - if (!this || (this === Array) || !isFunction(this)) { - // Result: Plain array - if (!mapFn) { - if (isArguments(arrayLike)) { - // Source: Arguments - l = arrayLike.length; - if (l !== 1) return Array.apply(null, arrayLike); - arr = new Array(1); - arr[0] = arrayLike[0]; - return arr; - } - if (isArray(arrayLike)) { - // Source: Array - arr = new Array(l = arrayLike.length); - for (i = 0; i < l; ++i) arr[i] = arrayLike[i]; - return arr; - } - } - arr = []; - } else { - // Result: Non plain array - Constructor = this; - } - - if (!isArray(arrayLike)) { - if ((getIterator = arrayLike[iteratorSymbol]) !== undefined) { - // Source: Iterator - iterator = callable(getIterator).call(arrayLike); - if (Constructor) arr = new Constructor(); - result = iterator.next(); - i = 0; - while (!result.done) { - value = mapFn ? call.call(mapFn, thisArg, result.value, i) : result.value; - if (!Constructor) { - arr[i] = value; - } else { - desc.value = value; - defineProperty(arr, i, desc); - } - result = iterator.next(); - ++i; - } - l = i; - } else if (isString(arrayLike)) { - // Source: String - l = arrayLike.length; - if (Constructor) arr = new Constructor(); - for (i = 0, j = 0; i < l; ++i) { - value = arrayLike[i]; - if ((i + 1) < l) { - code = value.charCodeAt(0); - if ((code >= 0xD800) && (code <= 0xDBFF)) value += arrayLike[++i]; - } - value = mapFn ? call.call(mapFn, thisArg, value, j) : value; - if (!Constructor) { - arr[j] = value; - } else { - desc.value = value; - defineProperty(arr, j, desc); - } - ++j; - } - l = j; - } - } - if (l === undefined) { - // Source: array or array-like - l = toPosInt(arrayLike.length); - if (Constructor) arr = new Constructor(l); - for (i = 0; i < l; ++i) { - value = mapFn ? call.call(mapFn, thisArg, arrayLike[i], i) : arrayLike[i]; - if (!Constructor) { - arr[i] = value; - } else { - desc.value = value; - defineProperty(arr, i, desc); - } - } - } - if (Constructor) { - desc.value = null; - arr.length = l; - } - return arr; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/generate.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/generate.js deleted file mode 100644 index 5e066750b1d5ba..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/generate.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var toPosInt = require('../number/to-pos-integer') - , value = require('../object/valid-value') - - , slice = Array.prototype.slice; - -module.exports = function (length/*, …fill*/) { - var arr, l; - length = toPosInt(value(length)); - if (length === 0) return []; - - arr = (arguments.length < 2) ? [undefined] : - slice.call(arguments, 1, 1 + length); - - while ((l = arr.length) < length) { - arr = arr.concat(arr.slice(0, length - l)); - } - return arr; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/index.js deleted file mode 100644 index 7a6867894b56dd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/index.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = { - '#': require('./#'), - from: require('./from'), - generate: require('./generate'), - isPlainArray: require('./is-plain-array'), - of: require('./of'), - toArray: require('./to-array'), - validArray: require('./valid-array') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/is-plain-array.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/is-plain-array.js deleted file mode 100644 index 6b37e4069738b4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/is-plain-array.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var isArray = Array.isArray, getPrototypeOf = Object.getPrototypeOf; - -module.exports = function (obj) { - var proto; - if (!obj || !isArray(obj)) return false; - proto = getPrototypeOf(obj); - if (!isArray(proto)) return false; - return !isArray(getPrototypeOf(proto)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/implement.js deleted file mode 100644 index bf2a5a54a740e6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Array, 'of', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/index.js deleted file mode 100644 index 07ee54dbcd4283..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Array.of - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/is-implemented.js deleted file mode 100644 index 4390a10863326b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = function () { - var of = Array.of, result; - if (typeof of !== 'function') return false; - result = of('foo', 'bar'); - return Boolean(result && (result[1] === 'bar')); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/shim.js deleted file mode 100644 index de72bc92291154..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/of/shim.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var isFunction = require('../../function/is-function') - - , slice = Array.prototype.slice, defineProperty = Object.defineProperty - , desc = { configurable: true, enumerable: true, writable: true, value: null }; - -module.exports = function (/*…items*/) { - var result, i, l; - if (!this || (this === Array) || !isFunction(this)) return slice.call(arguments); - result = new this(l = arguments.length); - for (i = 0; i < l; ++i) { - desc.value = arguments[i]; - defineProperty(result, i, desc); - } - desc.value = null; - result.length = l; - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/to-array.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/to-array.js deleted file mode 100644 index ce908dd912959b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/to-array.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var from = require('./from') - - , isArray = Array.isArray; - -module.exports = function (arrayLike) { - return isArray(arrayLike) ? arrayLike : from(arrayLike); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/valid-array.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/valid-array.js deleted file mode 100644 index d86a8f5f242b27..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/array/valid-array.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isArray = Array.isArray; - -module.exports = function (value) { - if (isArray(value)) return value; - throw new TypeError(value + " is not an array"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/boolean/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/boolean/index.js deleted file mode 100644 index c193b948eb9d01..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/boolean/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = { - isBoolean: require('./is-boolean') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/boolean/is-boolean.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/boolean/is-boolean.js deleted file mode 100644 index 5d1a802e11211c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/boolean/is-boolean.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var toString = Object.prototype.toString - - , id = toString.call(true); - -module.exports = function (x) { - return (typeof x === 'boolean') || ((typeof x === 'object') && - ((x instanceof Boolean) || (toString.call(x) === id))); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/copy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/copy.js deleted file mode 100644 index 69e2eb09fcbcf1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/copy.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var getTime = Date.prototype.getTime; - -module.exports = function () { return new Date(getTime.call(this)); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/days-in-month.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/days-in-month.js deleted file mode 100644 index e780efe3c7f99e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/days-in-month.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var getMonth = Date.prototype.getMonth; - -module.exports = function () { - switch (getMonth.call(this)) { - case 1: - return this.getFullYear() % 4 ? 28 : 29; - case 3: - case 5: - case 8: - case 10: - return 30; - default: - return 31; - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/floor-day.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/floor-day.js deleted file mode 100644 index 0c9eb8b62788cf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/floor-day.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var setHours = Date.prototype.setHours; - -module.exports = function () { - setHours.call(this, 0, 0, 0, 0); - return this; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/floor-month.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/floor-month.js deleted file mode 100644 index 7328c250b36506..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/floor-month.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var floorDay = require('./floor-day'); - -module.exports = function () { - floorDay.call(this).setDate(1); - return this; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/floor-year.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/floor-year.js deleted file mode 100644 index 9c5085389fbf67..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/floor-year.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var floorMonth = require('./floor-month'); - -module.exports = function () { - floorMonth.call(this).setMonth(0); - return this; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/format.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/format.js deleted file mode 100644 index 15bd95f7eddf21..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/format.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -var pad = require('../../number/#/pad') - , date = require('../valid-date') - - , format; - -format = require('../../string/format-method')({ - Y: function () { return String(this.getFullYear()); }, - y: function () { return String(this.getFullYear()).slice(-2); }, - m: function () { return pad.call(this.getMonth() + 1, 2); }, - d: function () { return pad.call(this.getDate(), 2); }, - H: function () { return pad.call(this.getHours(), 2); }, - M: function () { return pad.call(this.getMinutes(), 2); }, - S: function () { return pad.call(this.getSeconds(), 2); }, - L: function () { return pad.call(this.getMilliseconds(), 3); } -}); - -module.exports = function (pattern) { - return format.call(date(this), pattern); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/index.js deleted file mode 100644 index f71b2950029e59..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/#/index.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = { - copy: require('./copy'), - daysInMonth: require('./days-in-month'), - floorDay: require('./floor-day'), - floorMonth: require('./floor-month'), - floorYear: require('./floor-year'), - format: require('./format') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/index.js deleted file mode 100644 index eac33fbe6dddce..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/index.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = { - '#': require('./#'), - isDate: require('./is-date'), - validDate: require('./valid-date') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/is-date.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/is-date.js deleted file mode 100644 index 6ba236ecbc0783..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/is-date.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var toString = Object.prototype.toString - - , id = toString.call(new Date()); - -module.exports = function (x) { - return (x && ((x instanceof Date) || (toString.call(x) === id))) || false; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/valid-date.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/valid-date.js deleted file mode 100644 index d0f1b6ce2b83a6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/date/valid-date.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isDate = require('./is-date'); - -module.exports = function (x) { - if (!isDate(x) || isNaN(x)) throw new TypeError(x + " is not valid Date object"); - return x; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/#/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/#/index.js deleted file mode 100644 index b984aa91fef8b4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/#/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = { - throw: require('./throw') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/#/throw.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/#/throw.js deleted file mode 100644 index 7e15ebd1cf028b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/#/throw.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var error = require('../valid-error'); - -module.exports = function () { throw error(this); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/custom.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/custom.js deleted file mode 100644 index bbc2dc20b462b8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/custom.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var assign = require('../object/assign') - - , captureStackTrace = Error.captureStackTrace; - -exports = module.exports = function (message/*, code, ext*/) { - var err = new Error(), code = arguments[1], ext = arguments[2]; - if (ext == null) { - if (code && (typeof code === 'object')) { - ext = code; - code = null; - } - } - if (ext != null) assign(err, ext); - err.message = String(message); - if (code != null) err.code = String(code); - if (captureStackTrace) captureStackTrace(err, exports); - return err; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/index.js deleted file mode 100644 index 62984b52de0871..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/index.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = { - '#': require('./#'), - custom: require('./custom'), - isError: require('./is-error'), - validError: require('./valid-error') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/is-error.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/is-error.js deleted file mode 100644 index 422705faf71d2f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/is-error.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var toString = Object.prototype.toString - - , id = toString.call(new Error()); - -module.exports = function (x) { - return (x && ((x instanceof Error) || (toString.call(x)) === id)) || false; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/valid-error.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/valid-error.js deleted file mode 100644 index 0bef768a776d09..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/error/valid-error.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isError = require('./is-error'); - -module.exports = function (x) { - if (!isError(x)) throw new TypeError(x + " is not an Error object"); - return x; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/compose.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/compose.js deleted file mode 100644 index 1da5e01162dcf5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/compose.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var callable = require('../../object/valid-callable') - , aFrom = require('../../array/from') - - , apply = Function.prototype.apply, call = Function.prototype.call - , callFn = function (arg, fn) { return call.call(fn, this, arg); }; - -module.exports = function (fn/*, …fnn*/) { - var fns, first; - if (!fn) callable(fn); - fns = [this].concat(aFrom(arguments)); - fns.forEach(callable); - fns = fns.reverse(); - first = fns[0]; - fns = fns.slice(1); - return function (arg) { - return fns.reduce(callFn, apply.call(first, this, arguments)); - }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/copy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/copy.js deleted file mode 100644 index e1467f7671946c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/copy.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var mixin = require('../../object/mixin') - , validFunction = require('../valid-function') - - , re = /^\s*function\s*([\0-'\)-\uffff]+)*\s*\(([\0-\(\*-\uffff]*)\)\s*\{/; - -module.exports = function () { - var match = String(validFunction(this)).match(re), fn; - - fn = new Function('fn', 'return function ' + match[1].trim() + '(' + - match[2] + ') { return fn.apply(this, arguments); };')(this); - try { mixin(fn, this); } catch (ignore) {} - return fn; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/curry.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/curry.js deleted file mode 100644 index 943d6faf860772..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/curry.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -var toPosInt = require('../../number/to-pos-integer') - , callable = require('../../object/valid-callable') - , defineLength = require('../_define-length') - - , slice = Array.prototype.slice, apply = Function.prototype.apply - , curry; - -curry = function self(fn, length, preArgs) { - return defineLength(function () { - var args = preArgs ? - preArgs.concat(slice.call(arguments, 0, length - preArgs.length)) : - slice.call(arguments, 0, length); - return (args.length === length) ? apply.call(fn, this, args) : - self(fn, length, args); - }, preArgs ? (length - preArgs.length) : length); -}; - -module.exports = function (/*length*/) { - var length = arguments[0]; - return curry(callable(this), - isNaN(length) ? toPosInt(this.length) : toPosInt(length)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/index.js deleted file mode 100644 index 8d0da007fa182b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/index.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = { - compose: require('./compose'), - copy: require('./copy'), - curry: require('./curry'), - lock: require('./lock'), - not: require('./not'), - partial: require('./partial'), - spread: require('./spread'), - toStringTokens: require('./to-string-tokens') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/lock.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/lock.js deleted file mode 100644 index 91e1a65cd91887..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/lock.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var callable = require('../../object/valid-callable') - - , apply = Function.prototype.apply; - -module.exports = function (/*…args*/) { - var fn = callable(this) - , args = arguments; - - return function () { return apply.call(fn, this, args); }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/not.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/not.js deleted file mode 100644 index c6dbe97fb6ecd9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/not.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var callable = require('../../object/valid-callable') - , defineLength = require('../_define-length') - - , apply = Function.prototype.apply; - -module.exports = function () { - var fn = callable(this); - - return defineLength(function () { - return !apply.call(fn, this, arguments); - }, fn.length); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/partial.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/partial.js deleted file mode 100644 index bf31a3575a56df..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/partial.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var callable = require('../../object/valid-callable') - , aFrom = require('../../array/from') - , defineLength = require('../_define-length') - - , apply = Function.prototype.apply; - -module.exports = function (/*…args*/) { - var fn = callable(this) - , args = aFrom(arguments); - - return defineLength(function () { - return apply.call(fn, this, args.concat(aFrom(arguments))); - }, fn.length - args.length); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/spread.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/spread.js deleted file mode 100644 index d7c93b7e07ee15..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/spread.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var callable = require('../../object/valid-callable') - - , apply = Function.prototype.apply; - -module.exports = function () { - var fn = callable(this); - return function (args) { return apply.call(fn, this, args); }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/to-string-tokens.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/to-string-tokens.js deleted file mode 100644 index 67afeae82def7e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/#/to-string-tokens.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var validFunction = require('../valid-function') - - , re = new RegExp('^\\s*function[\\0-\'\\)-\\uffff]*' + - '\\(([\\0-\\(\\*-\\uffff]*)\\)\\s*\\{([\\0-\\uffff]*)\\}\\s*$'); - -module.exports = function () { - var data = String(validFunction(this)).match(re); - return { args: data[1], body: data[2] }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/_define-length.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/_define-length.js deleted file mode 100644 index 496ea62c52b612..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/_define-length.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; - -var toPosInt = require('../number/to-pos-integer') - - , test = function (a, b) {}, desc, defineProperty - , generate, mixin; - -try { - Object.defineProperty(test, 'length', { configurable: true, writable: false, - enumerable: false, value: 1 }); -} catch (ignore) {} - -if (test.length === 1) { - // ES6 - desc = { configurable: true, writable: false, enumerable: false }; - defineProperty = Object.defineProperty; - module.exports = function (fn, length) { - length = toPosInt(length); - if (fn.length === length) return fn; - desc.value = length; - return defineProperty(fn, 'length', desc); - }; -} else { - mixin = require('../object/mixin'); - generate = (function () { - var cache = []; - return function (l) { - var args, i = 0; - if (cache[l]) return cache[l]; - args = []; - while (l--) args.push('a' + (++i).toString(36)); - return new Function('fn', 'return function (' + args.join(', ') + - ') { return fn.apply(this, arguments); };'); - }; - }()); - module.exports = function (src, length) { - var target; - length = toPosInt(length); - if (src.length === length) return src; - target = generate(length)(src); - try { mixin(target, src); } catch (ignore) {} - return target; - }; -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/constant.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/constant.js deleted file mode 100644 index 10f1e203e2d023..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/constant.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (x) { - return function () { return x; }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/identity.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/identity.js deleted file mode 100644 index a9289f0b21dfac..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/identity.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (x) { return x; }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/index.js deleted file mode 100644 index cfad3f3ec25bf8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/index.js +++ /dev/null @@ -1,15 +0,0 @@ -// Export all modules. - -'use strict'; - -module.exports = { - '#': require('./#'), - constant: require('./constant'), - identity: require('./identity'), - invoke: require('./invoke'), - isArguments: require('./is-arguments'), - isFunction: require('./is-function'), - noop: require('./noop'), - pluck: require('./pluck'), - validFunction: require('./valid-function') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/invoke.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/invoke.js deleted file mode 100644 index 9195afddd8c1e8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/invoke.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var isCallable = require('../object/is-callable') - , value = require('../object/valid-value') - - , slice = Array.prototype.slice, apply = Function.prototype.apply; - -module.exports = function (name/*, …args*/) { - var args = slice.call(arguments, 1), isFn = isCallable(name); - return function (obj) { - value(obj); - return apply.call(isFn ? name : obj[name], obj, - args.concat(slice.call(arguments, 1))); - }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/is-arguments.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/is-arguments.js deleted file mode 100644 index 9a29855f87dc6a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/is-arguments.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var toString = Object.prototype.toString - - , id = toString.call((function () { return arguments; }())); - -module.exports = function (x) { return (toString.call(x) === id); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/is-function.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/is-function.js deleted file mode 100644 index ab4399ce25e98b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/is-function.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var toString = Object.prototype.toString - - , id = toString.call(require('./noop')); - -module.exports = function (f) { - return (typeof f === "function") && (toString.call(f) === id); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/noop.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/noop.js deleted file mode 100644 index aa43baedf1d5d9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/noop.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function () {}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/pluck.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/pluck.js deleted file mode 100644 index 7f70a30cbd95ee..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/pluck.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var value = require('../object/valid-value'); - -module.exports = function (name) { - return function (o) { return value(o)[name]; }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/valid-function.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/valid-function.js deleted file mode 100644 index 05fdee2c3debda..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/function/valid-function.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isFunction = require('./is-function'); - -module.exports = function (x) { - if (!isFunction(x)) throw new TypeError(x + " is not a function"); - return x; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/global.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/global.js deleted file mode 100644 index 872a40e814be44..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/global.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = new Function("return this")(); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/index.js deleted file mode 100644 index db9a7600b47115..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/index.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = { - global: require('./global'), - - array: require('./array'), - boolean: require('./boolean'), - date: require('./date'), - error: require('./error'), - function: require('./function'), - iterable: require('./iterable'), - math: require('./math'), - number: require('./number'), - object: require('./object'), - regExp: require('./reg-exp'), - string: require('./string') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/for-each.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/for-each.js deleted file mode 100644 index f1e20425b329a2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/for-each.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var forOf = require('es6-iterator/for-of') - , isIterable = require('es6-iterator/is-iterable') - , iterable = require('./validate') - - , forEach = Array.prototype.forEach; - -module.exports = function (target, cb/*, thisArg*/) { - if (isIterable(iterable(target))) forOf(target, cb, arguments[2]); - else forEach.call(target, cb, arguments[2]); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/index.js deleted file mode 100644 index a3e16a5e892c6c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/index.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = { - forEach: require('./for-each'), - is: require('./is'), - validate: require('./validate'), - validateObject: require('./validate-object') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/is.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/is.js deleted file mode 100644 index bb8bf287276bee..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/is.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator - , isArrayLike = require('../object/is-array-like'); - -module.exports = function (x) { - if (x == null) return false; - if (typeof x[iteratorSymbol] === 'function') return true; - return isArrayLike(x); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/validate-object.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/validate-object.js deleted file mode 100644 index 988a6adb6249e7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/validate-object.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var isObject = require('../object/is-object') - , is = require('./is'); - -module.exports = function (x) { - if (is(x) && isObject(x)) return x; - throw new TypeError(x + " is not an iterable or array-like object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/validate.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/validate.js deleted file mode 100644 index 1be6d7fcd96e44..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/iterable/validate.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var is = require('./is'); - -module.exports = function (x) { - if (is(x)) return x; - throw new TypeError(x + " is not an iterable or array-like"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/_pack-ieee754.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/_pack-ieee754.js deleted file mode 100644 index eecda5654dad51..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/_pack-ieee754.js +++ /dev/null @@ -1,82 +0,0 @@ -// Credit: https://github.com/paulmillr/es6-shim/ - -'use strict'; - -var abs = Math.abs, floor = Math.floor, log = Math.log, min = Math.min - , pow = Math.pow, LN2 = Math.LN2 - , roundToEven; - -roundToEven = function (n) { - var w = floor(n), f = n - w; - if (f < 0.5) return w; - if (f > 0.5) return w + 1; - return w % 2 ? w + 1 : w; -}; - -module.exports = function (v, ebits, fbits) { - var bias = (1 << (ebits - 1)) - 1, s, e, f, i, bits, str, bytes; - - // Compute sign, exponent, fraction - if (isNaN(v)) { - // NaN - // http://dev.w3.org/2006/webapi/WebIDL/#es-type-mapping - e = (1 << ebits) - 1; - f = pow(2, fbits - 1); - s = 0; - } else if (v === Infinity || v === -Infinity) { - e = (1 << ebits) - 1; - f = 0; - s = (v < 0) ? 1 : 0; - } else if (v === 0) { - e = 0; - f = 0; - s = (1 / v === -Infinity) ? 1 : 0; - } else { - s = v < 0; - v = abs(v); - - if (v >= pow(2, 1 - bias)) { - e = min(floor(log(v) / LN2), 1023); - f = roundToEven(v / pow(2, e) * pow(2, fbits)); - if (f / pow(2, fbits) >= 2) { - e = e + 1; - f = 1; - } - if (e > bias) { - // Overflow - e = (1 << ebits) - 1; - f = 0; - } else { - // Normal - e = e + bias; - f = f - pow(2, fbits); - } - } else { - // Subnormal - e = 0; - f = roundToEven(v / pow(2, 1 - bias - fbits)); - } - } - - // Pack sign, exponent, fraction - bits = []; - for (i = fbits; i; i -= 1) { - bits.push(f % 2 ? 1 : 0); - f = floor(f / 2); - } - for (i = ebits; i; i -= 1) { - bits.push(e % 2 ? 1 : 0); - e = floor(e / 2); - } - bits.push(s ? 1 : 0); - bits.reverse(); - str = bits.join(''); - - // Bits to bytes - bytes = []; - while (str.length) { - bytes.push(parseInt(str.substring(0, 8), 2)); - str = str.substring(8); - } - return bytes; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/_unpack-ieee754.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/_unpack-ieee754.js deleted file mode 100644 index c9f26f2bb6f12e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/_unpack-ieee754.js +++ /dev/null @@ -1,33 +0,0 @@ -// Credit: https://github.com/paulmillr/es6-shim/ - -'use strict'; - -var pow = Math.pow; - -module.exports = function (bytes, ebits, fbits) { - // Bytes to bits - var bits = [], i, j, b, str, - bias, s, e, f; - - for (i = bytes.length; i; i -= 1) { - b = bytes[i - 1]; - for (j = 8; j; j -= 1) { - bits.push(b % 2 ? 1 : 0); - b = b >> 1; - } - } - bits.reverse(); - str = bits.join(''); - - // Unpack sign, exponent, fraction - bias = (1 << (ebits - 1)) - 1; - s = parseInt(str.substring(0, 1), 2) ? -1 : 1; - e = parseInt(str.substring(1, 1 + ebits), 2); - f = parseInt(str.substring(1 + ebits), 2); - - // Produce number - if (e === (1 << ebits) - 1) return f !== 0 ? NaN : s * Infinity; - if (e > 0) return s * pow(2, e - bias) * (1 + f / pow(2, fbits)); - if (f !== 0) return s * pow(2, -(bias - 1)) * (f / pow(2, fbits)); - return s < 0 ? -0 : 0; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/implement.js deleted file mode 100644 index f48ad11de722a1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'acosh', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/index.js deleted file mode 100644 index 00ddea69dd7a46..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.acosh - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/is-implemented.js deleted file mode 100644 index 363f0d8bcdd61b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var acosh = Math.acosh; - if (typeof acosh !== 'function') return false; - return acosh(2) === 1.3169578969248166; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/shim.js deleted file mode 100644 index 89a24b5d767e18..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/acosh/shim.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var log = Math.log, sqrt = Math.sqrt; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x < 1) return NaN; - if (x === 1) return 0; - if (x === Infinity) return x; - return log(x + sqrt(x * x - 1)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/implement.js deleted file mode 100644 index 21f64d50491960..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'asinh', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/index.js deleted file mode 100644 index d415144eea7373..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.asinh - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/is-implemented.js deleted file mode 100644 index 6c205f418cae9b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var asinh = Math.asinh; - if (typeof asinh !== 'function') return false; - return asinh(2) === 1.4436354751788103; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/shim.js deleted file mode 100644 index 42fbf1457f7604..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/asinh/shim.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var log = Math.log, sqrt = Math.sqrt; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x === 0) return x; - if (!isFinite(x)) return x; - if (x < 0) { - x = -x; - return -log(x + sqrt(x * x + 1)); - } - return log(x + sqrt(x * x + 1)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/implement.js deleted file mode 100644 index 1a4851343b3196..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'atanh', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/index.js deleted file mode 100644 index 785b3deba5eb11..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.atanh - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/is-implemented.js deleted file mode 100644 index dbaf18ece2d2b0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var atanh = Math.atanh; - if (typeof atanh !== 'function') return false; - return atanh(0.5) === 0.5493061443340549; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/shim.js deleted file mode 100644 index 531e2891fe2f67..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/atanh/shim.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var log = Math.log; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x < -1) return NaN; - if (x > 1) return NaN; - if (x === -1) return -Infinity; - if (x === 1) return Infinity; - if (x === 0) return x; - return 0.5 * log((1 + x) / (1 - x)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/implement.js deleted file mode 100644 index 3a12dde487eba3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'cbrt', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/index.js deleted file mode 100644 index 89f966dfe4ed1a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.cbrt - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/is-implemented.js deleted file mode 100644 index 69809f3cf4956d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var cbrt = Math.cbrt; - if (typeof cbrt !== 'function') return false; - return cbrt(2) === 1.2599210498948732; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/shim.js deleted file mode 100644 index bca196026c730a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cbrt/shim.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var pow = Math.pow; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x === 0) return x; - if (!isFinite(x)) return x; - if (x < 0) return -pow(-x, 1 / 3); - return pow(x, 1 / 3); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/implement.js deleted file mode 100644 index 339df33ea71822..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'clz32', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/index.js deleted file mode 100644 index 1687b337e3bdf9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.clz32 - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/is-implemented.js deleted file mode 100644 index ccc8f71337bf29..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var clz32 = Math.clz32; - if (typeof clz32 !== 'function') return false; - return clz32(1000) === 22; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/shim.js deleted file mode 100644 index 2a582da3bf0b31..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/clz32/shim.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (value) { - value = value >>> 0; - return value ? 32 - value.toString(2).length : 32; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/implement.js deleted file mode 100644 index f90d83056c8b62..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'cosh', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/index.js deleted file mode 100644 index 000636ab774ae5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.cosh - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/is-implemented.js deleted file mode 100644 index c796bcbf314f05..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var cosh = Math.cosh; - if (typeof cosh !== 'function') return false; - return cosh(1) === 1.5430806348152437; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/shim.js deleted file mode 100644 index f9062bd976c693..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/cosh/shim.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var exp = Math.exp; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x === 0) return 1; - if (!isFinite(x)) return Infinity; - return (exp(x) + exp(-x)) / 2; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/implement.js deleted file mode 100644 index fc20c8cfa068c4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'expm1', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/index.js deleted file mode 100644 index 4c1bc77a222f78..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.expm1 - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/is-implemented.js deleted file mode 100644 index 3b106d5d535858..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var expm1 = Math.expm1; - if (typeof expm1 !== 'function') return false; - return expm1(1).toFixed(15) === '1.718281828459045'; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/shim.js deleted file mode 100644 index 9c8c2360857e59..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/expm1/shim.js +++ /dev/null @@ -1,16 +0,0 @@ -// Thanks: https://github.com/monolithed/ECMAScript-6 - -'use strict'; - -var exp = Math.exp; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x === 0) return x; - if (x === Infinity) return Infinity; - if (x === -Infinity) return -1; - - if ((x > -1.0e-6) && (x < 1.0e-6)) return x + x * x / 2; - return exp(x) - 1; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/implement.js deleted file mode 100644 index c55b26c464bce5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'fround', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/index.js deleted file mode 100644 index a077ed0ba33aa7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.fround - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/is-implemented.js deleted file mode 100644 index ffbf094e6b3447..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var fround = Math.fround; - if (typeof fround !== 'function') return false; - return fround(1.337) === 1.3370000123977661; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/shim.js deleted file mode 100644 index f2c86e46a41c7a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/fround/shim.js +++ /dev/null @@ -1,33 +0,0 @@ -// Credit: https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js - -'use strict'; - -var toFloat32; - -if (typeof Float32Array !== 'undefined') { - toFloat32 = (function () { - var float32Array = new Float32Array(1); - return function (x) { - float32Array[0] = x; - return float32Array[0]; - }; - }()); -} else { - toFloat32 = (function () { - var pack = require('../_pack-ieee754') - , unpack = require('../_unpack-ieee754'); - - return function (x) { - return unpack(pack(x, 8, 23), 8, 23); - }; - }()); -} - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x === 0) return x; - if (!isFinite(x)) return x; - - return toFloat32(x); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/implement.js deleted file mode 100644 index b27fda7a0961b9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'hypot', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/index.js deleted file mode 100644 index 334bc584cf7778..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.hypot - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/is-implemented.js deleted file mode 100644 index e75c5d36be34c8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var hypot = Math.hypot; - if (typeof hypot !== 'function') return false; - return hypot(3, 4) === 5; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/shim.js deleted file mode 100644 index 3d0988bc13dd4e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/hypot/shim.js +++ /dev/null @@ -1,34 +0,0 @@ -// Thanks for hints: https://github.com/paulmillr/es6-shim - -'use strict'; - -var some = Array.prototype.some, abs = Math.abs, sqrt = Math.sqrt - - , compare = function (a, b) { return b - a; } - , divide = function (x) { return x / this; } - , add = function (sum, number) { return sum + number * number; }; - -module.exports = function (val1, val2/*, …valn*/) { - var result, numbers; - if (!arguments.length) return 0; - some.call(arguments, function (val) { - if (isNaN(val)) { - result = NaN; - return; - } - if (!isFinite(val)) { - result = Infinity; - return true; - } - if (result !== undefined) return; - val = Number(val); - if (val === 0) return; - if (!numbers) numbers = [abs(val)]; - else numbers.push(abs(val)); - }); - if (result !== undefined) return result; - if (!numbers) return 0; - - numbers.sort(compare); - return numbers[0] * sqrt(numbers.map(divide, numbers[0]).reduce(add, 0)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/implement.js deleted file mode 100644 index ed207bd271f7f7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'imul', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/index.js deleted file mode 100644 index 41e5d5f010383f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.imul - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/is-implemented.js deleted file mode 100644 index d8495dea2a8ec9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var imul = Math.imul; - if (typeof imul !== 'function') return false; - return imul(-1, 8) === -8; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/shim.js deleted file mode 100644 index 8fd8a8d7a79111..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/imul/shim.js +++ /dev/null @@ -1,13 +0,0 @@ -// Thanks: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference -// /Global_Objects/Math/imul - -'use strict'; - -module.exports = function (x, y) { - var xh = (x >>> 16) & 0xffff, xl = x & 0xffff - , yh = (y >>> 16) & 0xffff, yl = y & 0xffff; - - // the shift by 0 fixes the sign on the high part - // the final |0 converts the unsigned value into a signed value - return ((xl * yl) + (((xh * yl + xl * yh) << 16) >>> 0) | 0); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/index.js deleted file mode 100644 index d112d0bfe0d04d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/index.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -module.exports = { - acosh: require('./acosh'), - asinh: require('./asinh'), - atanh: require('./atanh'), - cbrt: require('./cbrt'), - clz32: require('./clz32'), - cosh: require('./cosh'), - expm1: require('./expm1'), - fround: require('./fround'), - hypot: require('./hypot'), - imul: require('./imul'), - log10: require('./log10'), - log2: require('./log2'), - log1p: require('./log1p'), - sign: require('./sign'), - sinh: require('./sinh'), - tanh: require('./tanh'), - trunc: require('./trunc') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/implement.js deleted file mode 100644 index dd96edd80e0f20..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'log10', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/index.js deleted file mode 100644 index a9eee513130691..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.log10 - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/is-implemented.js deleted file mode 100644 index c7f40ee7753bef..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var log10 = Math.log10; - if (typeof log10 !== 'function') return false; - return log10(2) === 0.3010299956639812; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/shim.js deleted file mode 100644 index fc77287f6176ff..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log10/shim.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var log = Math.log, LOG10E = Math.LOG10E; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x < 0) return NaN; - if (x === 0) return -Infinity; - if (x === 1) return 0; - if (x === Infinity) return Infinity; - - return log(x) * LOG10E; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/implement.js deleted file mode 100644 index f62f91f6877d5b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'log1p', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/index.js deleted file mode 100644 index 107b114713cb57..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.log1p - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/is-implemented.js deleted file mode 100644 index 61e90974c5f5e0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var log1p = Math.log1p; - if (typeof log1p !== 'function') return false; - return log1p(1) === 0.6931471805599453; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/shim.js deleted file mode 100644 index 10acebca4ab9af..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log1p/shim.js +++ /dev/null @@ -1,17 +0,0 @@ -// Thanks: https://github.com/monolithed/ECMAScript-6/blob/master/ES6.js - -'use strict'; - -var log = Math.log; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x < -1) return NaN; - if (x === -1) return -Infinity; - if (x === 0) return x; - if (x === Infinity) return Infinity; - - if (x > -1.0e-8 && x < 1.0e-8) return (x - x * x / 2); - return log(1 + x); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/implement.js deleted file mode 100644 index 8483f0950aa965..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'log2', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/index.js deleted file mode 100644 index 87e9050abe0895..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.log2 - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/is-implemented.js deleted file mode 100644 index 802322faf38e32..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var log2 = Math.log2; - if (typeof log2 !== 'function') return false; - return log2(3).toFixed(15) === '1.584962500721156'; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/shim.js deleted file mode 100644 index cd80994a72b7d5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/log2/shim.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var log = Math.log, LOG2E = Math.LOG2E; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x < 0) return NaN; - if (x === 0) return -Infinity; - if (x === 1) return 0; - if (x === Infinity) return Infinity; - - return log(x) * LOG2E; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/implement.js deleted file mode 100644 index b0db2f413fa598..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'sign', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/index.js deleted file mode 100644 index b2326333432fcb..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.sign - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/is-implemented.js deleted file mode 100644 index 6d0de475aba61e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var sign = Math.sign; - if (typeof sign !== 'function') return false; - return ((sign(10) === 1) && (sign(-20) === -1)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/shim.js deleted file mode 100644 index 4df9c95aa5d64f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sign/shim.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (value) { - value = Number(value); - if (isNaN(value) || (value === 0)) return value; - return (value > 0) ? 1 : -1; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/implement.js deleted file mode 100644 index f259a631b5718a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'sinh', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/index.js deleted file mode 100644 index e5bea572f838d6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.sinh - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/is-implemented.js deleted file mode 100644 index 888ec67a9c8cd8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var sinh = Math.sinh; - if (typeof sinh !== 'function') return false; - return ((sinh(1) === 1.1752011936438014) && (sinh(Number.MIN_VALUE) === 5e-324)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/shim.js deleted file mode 100644 index 5b725bed656d95..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/sinh/shim.js +++ /dev/null @@ -1,17 +0,0 @@ -// Parts of implementation taken from es6-shim project -// See: https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js - -'use strict'; - -var expm1 = require('../expm1') - - , abs = Math.abs, exp = Math.exp, e = Math.E; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x === 0) return x; - if (!isFinite(x)) return x; - if (abs(x) < 1) return (expm1(x) - expm1(-x)) / 2; - return (exp(x - 1) - exp(-x - 1)) * e / 2; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/implement.js deleted file mode 100644 index 5199a029c88b7e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'tanh', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/index.js deleted file mode 100644 index 6099c408a82be9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.tanh - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/is-implemented.js deleted file mode 100644 index a7d22237136416..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var tanh = Math.tanh; - if (typeof tanh !== 'function') return false; - return ((tanh(1) === 0.7615941559557649) && (tanh(Number.MAX_VALUE) === 1)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/shim.js deleted file mode 100644 index f6e948f2c53797..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/tanh/shim.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var exp = Math.exp; - -module.exports = function (x) { - var a, b; - if (isNaN(x)) return NaN; - x = Number(x); - if (x === 0) return x; - if (x === Infinity) return 1; - if (x === -Infinity) return -1; - a = exp(x); - if (a === Infinity) return 1; - b = exp(-x); - if (b === Infinity) return -1; - return (a - b) / (a + b); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/implement.js deleted file mode 100644 index 3ee80ab2a0a0b8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Math, 'trunc', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/index.js deleted file mode 100644 index 0b0f9b2ac93882..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Math.trunc - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/is-implemented.js deleted file mode 100644 index 3e8cde1f0053dd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var trunc = Math.trunc; - if (typeof trunc !== 'function') return false; - return (trunc(13.67) === 13) && (trunc(-13.67) === -13); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/shim.js deleted file mode 100644 index 02e2c2ad3bfcf4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/math/trunc/shim.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -var floor = Math.floor; - -module.exports = function (x) { - if (isNaN(x)) return NaN; - x = Number(x); - if (x === 0) return x; - if (x === Infinity) return Infinity; - if (x === -Infinity) return -Infinity; - if (x > 0) return floor(x); - return -floor(-x); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/#/chain.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/#/chain.js deleted file mode 100644 index 6dc1543b354531..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/#/chain.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -var setPrototypeOf = require('es5-ext/object/set-prototype-of') - , d = require('d') - , Iterator = require('../') - , validIterable = require('../valid-iterable') - - , push = Array.prototype.push - , defineProperties = Object.defineProperties - , IteratorChain; - -IteratorChain = function (iterators) { - defineProperties(this, { - __iterators__: d('', iterators), - __current__: d('w', iterators.shift()) - }); -}; -if (setPrototypeOf) setPrototypeOf(IteratorChain, Iterator); - -IteratorChain.prototype = Object.create(Iterator.prototype, { - constructor: d(IteratorChain), - next: d(function () { - var result; - if (!this.__current__) return { done: true, value: undefined }; - result = this.__current__.next(); - while (result.done) { - this.__current__ = this.__iterators__.shift(); - if (!this.__current__) return { done: true, value: undefined }; - result = this.__current__.next(); - } - return result; - }) -}); - -module.exports = function () { - var iterators = [this]; - push.apply(iterators, arguments); - iterators.forEach(validIterable); - return new IteratorChain(iterators); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/.lint b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/.lint deleted file mode 100644 index cf54d815684b2f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/.lint +++ /dev/null @@ -1,11 +0,0 @@ -@root - -module - -tabs -indent 2 -maxlen 100 - -ass -nomen -plusplus diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/.npmignore b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/.npmignore deleted file mode 100644 index 155e41f69142ef..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/.npmignore +++ /dev/null @@ -1,4 +0,0 @@ -.DS_Store -/node_modules -/npm-debug.log -/.lintcache diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/.travis.yml b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/.travis.yml deleted file mode 100644 index fc254110608e62..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/.travis.yml +++ /dev/null @@ -1,11 +0,0 @@ -sudo: false # http://docs.travis-ci.com/user/workers/container-based-infrastructure/ -language: node_js -node_js: - - 0.12 - - 4 - -notifications: - email: - - medikoo+es6-iterator@medikoo.com - -script: "npm test && npm run lint" diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/CHANGES b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/CHANGES deleted file mode 100644 index ce33180939c05f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/CHANGES +++ /dev/null @@ -1,35 +0,0 @@ -v2.0.0 -- 2015.10.02 -* Use es6-symbol at v3 - -v1.0.0 -- 2015.06.23 -* Implement support for arguments object -* Drop support for v0.8 node ('^' in package.json dependencies) - -v0.1.3 -- 2015.02.02 -* Update dependencies -* Fix spelling of LICENSE - -v0.1.2 -- 2014.11.19 -* Optimise internal `_next` to not verify internal's list length at all times - (#2 thanks @RReverser) -* Fix documentation examples -* Configure lint scripts - -v0.1.1 -- 2014.04.29 -* Fix es6-symbol dependency version - -v0.1.0 -- 2014.04.29 -* Assure strictly npm hosted dependencies -* Remove sparse arrays dedicated handling (as per spec) -* Add: isIterable, validIterable and chain (method) -* Remove toArray, it's addressed by Array.from (polyfil can be found in es5-ext/array/from) -* Add break possiblity to 'forOf' via 'doBreak' function argument -* Provide dedicated iterator for array-likes (ArrayIterator) and for strings (StringIterator) -* Provide @@toStringTag symbol -* When available rely on @@iterator symbol -* Remove 32bit integer maximum list length restriction -* Improve Iterator internals -* Update to use latest version of dependencies - -v0.0.0 -- 2013.10.12 -Initial (dev version) \ No newline at end of file diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/LICENSE b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/LICENSE deleted file mode 100644 index 04724a3ab1b70b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (C) 2013-2015 Mariusz Nowak (www.medikoo.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/README.md b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/README.md deleted file mode 100644 index 288373da7ab506..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/README.md +++ /dev/null @@ -1,148 +0,0 @@ -# es6-iterator -## ECMAScript 6 Iterator interface - -### Installation - - $ npm install es6-iterator - -To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/) - -## API - -### Constructors - -#### Iterator(list) _(es6-iterator)_ - -Abstract Iterator interface. Meant for extensions and not to be used on its own. - -Accepts any _list_ object (technically object with numeric _length_ property). - -_Mind it doesn't iterate strings properly, for that use dedicated [StringIterator](#string-iterator)_ - -```javascript -var Iterator = require('es6-iterator') -var iterator = new Iterator([1, 2, 3]); - -iterator.next(); // { value: 1, done: false } -iterator.next(); // { value: 2, done: false } -iterator.next(); // { value: 3, done: false } -iterator.next(); // { value: undefined, done: true } -``` - - -#### ArrayIterator(arrayLike[, kind]) _(es6-iterator/array)_ - -Dedicated for arrays and array-likes. Supports three iteration kinds: -* __value__ _(default)_ - Iterates values -* __key__ - Iterates indexes -* __key+value__ - Iterates keys and indexes, each iteration value is in _[key, value]_ form. - - -```javascript -var ArrayIterator = require('es6-iterator/array') -var iterator = new ArrayIterator([1, 2, 3], 'key+value'); - -iterator.next(); // { value: [0, 1], done: false } -iterator.next(); // { value: [1, 2], done: false } -iterator.next(); // { value: [2, 3], done: false } -iterator.next(); // { value: undefined, done: true } -``` - -May also be used for _arguments_ objects: - -```javascript -(function () { - var iterator = new ArrayIterator(arguments); - - iterator.next(); // { value: 1, done: false } - iterator.next(); // { value: 2, done: false } - iterator.next(); // { value: 3, done: false } - iterator.next(); // { value: undefined, done: true } -}(1, 2, 3)); -``` - -#### StringIterator(str) _(es6-iterator/string)_ - -Assures proper iteration over unicode symbols. -See: http://mathiasbynens.be/notes/javascript-unicode - -```javascript -var StringIterator = require('es6-iterator/string'); -var iterator = new StringIterator('f🙈o🙉o🙊'); - -iterator.next(); // { value: 'f', done: false } -iterator.next(); // { value: '🙈', done: false } -iterator.next(); // { value: 'o', done: false } -iterator.next(); // { value: '🙉', done: false } -iterator.next(); // { value: 'o', done: false } -iterator.next(); // { value: '🙊', done: false } -iterator.next(); // { value: undefined, done: true } -``` - -### Function utilities - -#### forOf(iterable, callback[, thisArg]) _(es6-iterator/for-of)_ - -Polyfill for ECMAScript 6 [`for...of`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for...of) statement. - -``` -var forOf = require('es6-iterator/for-of'); -var result = []; - -forOf('🙈🙉🙊', function (monkey) { result.push(monkey); }); -console.log(result); // ['🙈', '🙉', '🙊']; -``` - -Optionally you can break iteration at any point: - -```javascript -var result = []; - -forOf([1,2,3,4]', function (val, doBreak) { - result.push(monkey); - if (val >= 3) doBreak(); -}); -console.log(result); // [1, 2, 3]; -``` - -#### get(obj) _(es6-iterator/get)_ - -Return iterator for any iterable object. - -```javascript -var getIterator = require('es6-iterator/get'); -var iterator = get([1,2,3]); - -iterator.next(); // { value: 1, done: false } -iterator.next(); // { value: 2, done: false } -iterator.next(); // { value: 3, done: false } -iterator.next(); // { value: undefined, done: true } -``` - -#### isIterable(obj) _(es6-iterator/is-iterable)_ - -Whether _obj_ is iterable - -```javascript -var isIterable = require('es6-iterator/is-iterable'); - -isIterable(null); // false -isIterable(true); // false -isIterable('str'); // true -isIterable(['a', 'r', 'r']); // true -isIterable(new ArrayIterator([])); // true -``` - -#### validIterable(obj) _(es6-iterator/valid-iterable)_ - -If _obj_ is an iterable it is returned. Otherwise _TypeError_ is thrown. - -### Method extensions - -#### iterator.chain(iterator1[, …iteratorn]) _(es6-iterator/#/chain)_ - -Chain multiple iterators into one. - -### Tests [![Build Status](https://travis-ci.org/medikoo/es6-iterator.png)](https://travis-ci.org/medikoo/es6-iterator) - - $ npm test diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/array.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/array.js deleted file mode 100644 index 885ad0a4fd7870..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/array.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -var setPrototypeOf = require('es5-ext/object/set-prototype-of') - , contains = require('es5-ext/string/#/contains') - , d = require('d') - , Iterator = require('./') - - , defineProperty = Object.defineProperty - , ArrayIterator; - -ArrayIterator = module.exports = function (arr, kind) { - if (!(this instanceof ArrayIterator)) return new ArrayIterator(arr, kind); - Iterator.call(this, arr); - if (!kind) kind = 'value'; - else if (contains.call(kind, 'key+value')) kind = 'key+value'; - else if (contains.call(kind, 'key')) kind = 'key'; - else kind = 'value'; - defineProperty(this, '__kind__', d('', kind)); -}; -if (setPrototypeOf) setPrototypeOf(ArrayIterator, Iterator); - -ArrayIterator.prototype = Object.create(Iterator.prototype, { - constructor: d(ArrayIterator), - _resolve: d(function (i) { - if (this.__kind__ === 'value') return this.__list__[i]; - if (this.__kind__ === 'key+value') return [i, this.__list__[i]]; - return i; - }), - toString: d(function () { return '[object Array Iterator]'; }) -}); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/for-of.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/for-of.js deleted file mode 100644 index c7a28411d59db9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/for-of.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -var isArguments = require('es5-ext/function/is-arguments') - , callable = require('es5-ext/object/valid-callable') - , isString = require('es5-ext/string/is-string') - , get = require('./get') - - , isArray = Array.isArray, call = Function.prototype.call - , some = Array.prototype.some; - -module.exports = function (iterable, cb/*, thisArg*/) { - var mode, thisArg = arguments[2], result, doBreak, broken, i, l, char, code; - if (isArray(iterable) || isArguments(iterable)) mode = 'array'; - else if (isString(iterable)) mode = 'string'; - else iterable = get(iterable); - - callable(cb); - doBreak = function () { broken = true; }; - if (mode === 'array') { - some.call(iterable, function (value) { - call.call(cb, thisArg, value, doBreak); - if (broken) return true; - }); - return; - } - if (mode === 'string') { - l = iterable.length; - for (i = 0; i < l; ++i) { - char = iterable[i]; - if ((i + 1) < l) { - code = char.charCodeAt(0); - if ((code >= 0xD800) && (code <= 0xDBFF)) char += iterable[++i]; - } - call.call(cb, thisArg, char, doBreak); - if (broken) break; - } - return; - } - result = iterable.next(); - - while (!result.done) { - call.call(cb, thisArg, result.value, doBreak); - if (broken) return; - result = iterable.next(); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/get.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/get.js deleted file mode 100644 index 7c7e052b191d63..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/get.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var isArguments = require('es5-ext/function/is-arguments') - , isString = require('es5-ext/string/is-string') - , ArrayIterator = require('./array') - , StringIterator = require('./string') - , iterable = require('./valid-iterable') - , iteratorSymbol = require('es6-symbol').iterator; - -module.exports = function (obj) { - if (typeof iterable(obj)[iteratorSymbol] === 'function') return obj[iteratorSymbol](); - if (isArguments(obj)) return new ArrayIterator(obj); - if (isString(obj)) return new StringIterator(obj); - return new ArrayIterator(obj); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/index.js deleted file mode 100644 index 10fd08958f68c7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/index.js +++ /dev/null @@ -1,90 +0,0 @@ -'use strict'; - -var clear = require('es5-ext/array/#/clear') - , assign = require('es5-ext/object/assign') - , callable = require('es5-ext/object/valid-callable') - , value = require('es5-ext/object/valid-value') - , d = require('d') - , autoBind = require('d/auto-bind') - , Symbol = require('es6-symbol') - - , defineProperty = Object.defineProperty - , defineProperties = Object.defineProperties - , Iterator; - -module.exports = Iterator = function (list, context) { - if (!(this instanceof Iterator)) return new Iterator(list, context); - defineProperties(this, { - __list__: d('w', value(list)), - __context__: d('w', context), - __nextIndex__: d('w', 0) - }); - if (!context) return; - callable(context.on); - context.on('_add', this._onAdd); - context.on('_delete', this._onDelete); - context.on('_clear', this._onClear); -}; - -defineProperties(Iterator.prototype, assign({ - constructor: d(Iterator), - _next: d(function () { - var i; - if (!this.__list__) return; - if (this.__redo__) { - i = this.__redo__.shift(); - if (i !== undefined) return i; - } - if (this.__nextIndex__ < this.__list__.length) return this.__nextIndex__++; - this._unBind(); - }), - next: d(function () { return this._createResult(this._next()); }), - _createResult: d(function (i) { - if (i === undefined) return { done: true, value: undefined }; - return { done: false, value: this._resolve(i) }; - }), - _resolve: d(function (i) { return this.__list__[i]; }), - _unBind: d(function () { - this.__list__ = null; - delete this.__redo__; - if (!this.__context__) return; - this.__context__.off('_add', this._onAdd); - this.__context__.off('_delete', this._onDelete); - this.__context__.off('_clear', this._onClear); - this.__context__ = null; - }), - toString: d(function () { return '[object Iterator]'; }) -}, autoBind({ - _onAdd: d(function (index) { - if (index >= this.__nextIndex__) return; - ++this.__nextIndex__; - if (!this.__redo__) { - defineProperty(this, '__redo__', d('c', [index])); - return; - } - this.__redo__.forEach(function (redo, i) { - if (redo >= index) this.__redo__[i] = ++redo; - }, this); - this.__redo__.push(index); - }), - _onDelete: d(function (index) { - var i; - if (index >= this.__nextIndex__) return; - --this.__nextIndex__; - if (!this.__redo__) return; - i = this.__redo__.indexOf(index); - if (i !== -1) this.__redo__.splice(i, 1); - this.__redo__.forEach(function (redo, i) { - if (redo > index) this.__redo__[i] = --redo; - }, this); - }), - _onClear: d(function () { - if (this.__redo__) clear.call(this.__redo__); - this.__nextIndex__ = 0; - }) -}))); - -defineProperty(Iterator.prototype, Symbol.iterator, d(function () { - return this; -})); -defineProperty(Iterator.prototype, Symbol.toStringTag, d('', 'Iterator')); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/is-iterable.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/is-iterable.js deleted file mode 100644 index 2c6f496c38c4c2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/is-iterable.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var isArguments = require('es5-ext/function/is-arguments') - , isString = require('es5-ext/string/is-string') - , iteratorSymbol = require('es6-symbol').iterator - - , isArray = Array.isArray; - -module.exports = function (value) { - if (value == null) return false; - if (isArray(value)) return true; - if (isString(value)) return true; - if (isArguments(value)) return true; - return (typeof value[iteratorSymbol] === 'function'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/package.json deleted file mode 100644 index 92a871dcfd6116..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/package.json +++ /dev/null @@ -1,100 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "es6-iterator@2", - "scope": null, - "escapedName": "es6-iterator", - "name": "es6-iterator", - "rawSpec": "2", - "spec": ">=2.0.0 <3.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext" - ] - ], - "_from": "es6-iterator@>=2.0.0 <3.0.0", - "_id": "es6-iterator@2.0.0", - "_inCache": true, - "_installable": true, - "_location": "/node-gyp/path-array/array-index/es6-symbol/es5-ext/es6-iterator", - "_nodeVersion": "0.12.7", - "_npmUser": { - "name": "medikoo", - "email": "medikoo+npm@medikoo.com" - }, - "_npmVersion": "2.11.3", - "_phantomChildren": {}, - "_requested": { - "raw": "es6-iterator@2", - "scope": null, - "escapedName": "es6-iterator", - "name": "es6-iterator", - "rawSpec": "2", - "spec": ">=2.0.0 <3.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/path-array/array-index/es6-symbol/es5-ext" - ], - "_resolved": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.0.tgz", - "_shasum": "bd968567d61635e33c0b80727613c9cb4b096bac", - "_shrinkwrap": null, - "_spec": "es6-iterator@2", - "_where": "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext", - "author": { - "name": "Mariusz Nowak", - "email": "medyk@medikoo.com", - "url": "http://www.medikoo.com/" - }, - "bugs": { - "url": "https://github.com/medikoo/es6-iterator/issues" - }, - "dependencies": { - "d": "^0.1.1", - "es5-ext": "^0.10.7", - "es6-symbol": "3" - }, - "description": "Iterator abstraction based on ES6 specification", - "devDependencies": { - "event-emitter": "^0.3.4", - "tad": "^0.2.3", - "xlint": "^0.2.2", - "xlint-jslint-medikoo": "^0.1.3" - }, - "directories": {}, - "dist": { - "shasum": "bd968567d61635e33c0b80727613c9cb4b096bac", - "tarball": "https://registry.npmjs.org/es6-iterator/-/es6-iterator-2.0.0.tgz" - }, - "gitHead": "4d9445834e87780ab373b14d6791e860899e2d31", - "homepage": "https://github.com/medikoo/es6-iterator#readme", - "keywords": [ - "iterator", - "array", - "list", - "set", - "map", - "generator" - ], - "license": "MIT", - "maintainers": [ - { - "name": "medikoo", - "email": "medikoo+npm@medikoo.com" - } - ], - "name": "es6-iterator", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/medikoo/es6-iterator.git" - }, - "scripts": { - "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", - "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", - "test": "node ./node_modules/tad/bin/tad" - }, - "version": "2.0.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/string.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/string.js deleted file mode 100644 index cdb39ea4e49931..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/string.js +++ /dev/null @@ -1,37 +0,0 @@ -// Thanks @mathiasbynens -// http://mathiasbynens.be/notes/javascript-unicode#iterating-over-symbols - -'use strict'; - -var setPrototypeOf = require('es5-ext/object/set-prototype-of') - , d = require('d') - , Iterator = require('./') - - , defineProperty = Object.defineProperty - , StringIterator; - -StringIterator = module.exports = function (str) { - if (!(this instanceof StringIterator)) return new StringIterator(str); - str = String(str); - Iterator.call(this, str); - defineProperty(this, '__length__', d('', str.length)); - -}; -if (setPrototypeOf) setPrototypeOf(StringIterator, Iterator); - -StringIterator.prototype = Object.create(Iterator.prototype, { - constructor: d(StringIterator), - _next: d(function () { - if (!this.__list__) return; - if (this.__nextIndex__ < this.__length__) return this.__nextIndex__++; - this._unBind(); - }), - _resolve: d(function (i) { - var char = this.__list__[i], code; - if (this.__nextIndex__ === this.__length__) return char; - code = char.charCodeAt(0); - if ((code >= 0xD800) && (code <= 0xDBFF)) return char + this.__list__[this.__nextIndex__++]; - return char; - }), - toString: d(function () { return '[object String Iterator]'; }) -}); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/#/chain.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/#/chain.js deleted file mode 100644 index a414c66d78f44f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/#/chain.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var Iterator = require('../../'); - -module.exports = function (t, a) { - var i1 = new Iterator(['raz', 'dwa', 'trzy']) - , i2 = new Iterator(['cztery', 'pięć', 'sześć']) - , i3 = new Iterator(['siedem', 'osiem', 'dziewięć']) - - , iterator = t.call(i1, i2, i3); - - a.deep(iterator.next(), { done: false, value: 'raz' }, "#1"); - a.deep(iterator.next(), { done: false, value: 'dwa' }, "#2"); - a.deep(iterator.next(), { done: false, value: 'trzy' }, "#3"); - a.deep(iterator.next(), { done: false, value: 'cztery' }, "#4"); - a.deep(iterator.next(), { done: false, value: 'pięć' }, "#5"); - a.deep(iterator.next(), { done: false, value: 'sześć' }, "#6"); - a.deep(iterator.next(), { done: false, value: 'siedem' }, "#7"); - a.deep(iterator.next(), { done: false, value: 'osiem' }, "#8"); - a.deep(iterator.next(), { done: false, value: 'dziewięć' }, "#9"); - a.deep(iterator.next(), { done: true, value: undefined }, "Done #1"); - a.deep(iterator.next(), { done: true, value: undefined }, "Done #2"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/array.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/array.js deleted file mode 100644 index ae7c2199e84a72..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/array.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator; - -module.exports = function (T) { - return { - Values: function (a) { - var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it; - - it = new T(x); - a(it[iteratorSymbol](), it, "@@iterator"); - a.deep(it.next(), { done: false, value: 'raz' }, "#1"); - a.deep(it.next(), { done: false, value: 'dwa' }, "#2"); - x.splice(1, 0, 'elo'); - a.deep(it.next(), { done: false, value: 'dwa' }, "Insert"); - a.deep(it.next(), { done: false, value: 'trzy' }, "#3"); - a.deep(it.next(), { done: false, value: 'cztery' }, "#4"); - x.pop(); - a.deep(it.next(), { done: false, value: 'pięć' }, "#5"); - a.deep(it.next(), { done: true, value: undefined }, "End"); - }, - "Keys & Values": function (a) { - var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it; - - it = new T(x, 'key+value'); - a(it[iteratorSymbol](), it, "@@iterator"); - a.deep(it.next(), { done: false, value: [0, 'raz'] }, "#1"); - a.deep(it.next(), { done: false, value: [1, 'dwa'] }, "#2"); - x.splice(1, 0, 'elo'); - a.deep(it.next(), { done: false, value: [2, 'dwa'] }, "Insert"); - a.deep(it.next(), { done: false, value: [3, 'trzy'] }, "#3"); - a.deep(it.next(), { done: false, value: [4, 'cztery'] }, "#4"); - x.pop(); - a.deep(it.next(), { done: false, value: [5, 'pięć'] }, "#5"); - a.deep(it.next(), { done: true, value: undefined }, "End"); - }, - Keys: function (a) { - var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], it; - - it = new T(x, 'key'); - a(it[iteratorSymbol](), it, "@@iterator"); - a.deep(it.next(), { done: false, value: 0 }, "#1"); - a.deep(it.next(), { done: false, value: 1 }, "#2"); - x.splice(1, 0, 'elo'); - a.deep(it.next(), { done: false, value: 2 }, "Insert"); - a.deep(it.next(), { done: false, value: 3 }, "#3"); - a.deep(it.next(), { done: false, value: 4 }, "#4"); - x.pop(); - a.deep(it.next(), { done: false, value: 5 }, "#5"); - a.deep(it.next(), { done: true, value: undefined }, "End"); - }, - Sparse: function (a) { - var x = new Array(6), it; - - x[2] = 'raz'; - x[4] = 'dwa'; - it = new T(x); - a.deep(it.next(), { done: false, value: undefined }, "#1"); - a.deep(it.next(), { done: false, value: undefined }, "#2"); - a.deep(it.next(), { done: false, value: 'raz' }, "#3"); - a.deep(it.next(), { done: false, value: undefined }, "#4"); - a.deep(it.next(), { done: false, value: 'dwa' }, "#5"); - a.deep(it.next(), { done: false, value: undefined }, "#6"); - a.deep(it.next(), { done: true, value: undefined }, "End"); - } - }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/for-of.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/for-of.js deleted file mode 100644 index 108df7d97a3c39..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/for-of.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -var ArrayIterator = require('../array') - - , slice = Array.prototype.slice; - -module.exports = function (t, a) { - var i = 0, x = ['raz', 'dwa', 'trzy'], y = {}, called = 0; - t(x, function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "Array " + i + "#"); - a(this, y, "Array: context: " + (i++) + "#"); - }, y); - i = 0; - t((function () { return arguments; }('raz', 'dwa', 'trzy')), function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "Arguments" + i + "#"); - a(this, y, "Arguments: context: " + (i++) + "#"); - }, y); - i = 0; - t(x = 'foo', function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#"); - a(this, y, "Regular String: context: " + (i++) + "#"); - }, y); - i = 0; - x = ['r', '💩', 'z']; - t('r💩z', function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#"); - a(this, y, "Unicode String: context: " + (i++) + "#"); - }, y); - i = 0; - t(new ArrayIterator(x), function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "Iterator " + i + "#"); - a(this, y, "Iterator: context: " + (i++) + "#"); - }, y); - - t(x = ['raz', 'dwa', 'trzy'], function (value, doBreak) { - ++called; - return doBreak(); - }); - a(called, 1, "Break"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/get.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/get.js deleted file mode 100644 index 81ce6e6ae48b79..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/get.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator - , Iterator = require('../'); - -module.exports = function (t, a) { - var iterator; - a.throws(function () { t(); }, TypeError, "Null"); - a.throws(function () { t({}); }, TypeError, "Plain object"); - a.throws(function () { t({ length: 0 }); }, TypeError, "Array-like"); - iterator = {}; - iterator[iteratorSymbol] = function () { return new Iterator([]); }; - a(t(iterator) instanceof Iterator, true, "Iterator"); - a(String(t([])), '[object Array Iterator]', " Array"); - a(String(t((function () { return arguments; }()))), '[object Array Iterator]', " Arguments"); - a(String(t('foo')), '[object String Iterator]', "String"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/index.js deleted file mode 100644 index ea3621adfebeb5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/index.js +++ /dev/null @@ -1,99 +0,0 @@ -'use strict'; - -var ee = require('event-emitter') - , iteratorSymbol = require('es6-symbol').iterator; - -module.exports = function (T) { - return { - "": function (a) { - var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć'], it, y, z; - - it = new T(x); - a(it[iteratorSymbol](), it, "@@iterator"); - y = it.next(); - a.deep(y, { done: false, value: 'raz' }, "#1"); - z = it.next(); - a.not(y, z, "Recreate result"); - a.deep(z, { done: false, value: 'dwa' }, "#2"); - a.deep(it.next(), { done: false, value: 'trzy' }, "#3"); - a.deep(it.next(), { done: false, value: 'cztery' }, "#4"); - a.deep(it.next(), { done: false, value: 'pięć' }, "#5"); - a.deep(y = it.next(), { done: true, value: undefined }, "End"); - a.not(y, it.next(), "Recreate result on dead"); - }, - Emited: function (a) { - var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć'], y, it; - - y = ee(); - it = new T(x, y); - a.deep(it.next(), { done: false, value: 'raz' }, "#1"); - a.deep(it.next(), { done: false, value: 'dwa' }, "#2"); - y.emit('_add', x.push('sześć') - 1); - a.deep(it.next(), { done: false, value: 'trzy' }, "#3"); - x.splice(1, 0, 'półtora'); - y.emit('_add', 1); - a.deep(it.next(), { done: false, value: 'półtora' }, "Insert"); - x.splice(5, 1); - y.emit('_delete', 5); - a.deep(it.next(), { done: false, value: 'cztery' }, "#4"); - a.deep(it.next(), { done: false, value: 'sześć' }, "#5"); - a.deep(it.next(), { done: true, value: undefined }, "End"); - }, - "Emited #2": function (a) { - var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], y, it; - - y = ee(); - it = new T(x, y); - a.deep(it.next(), { done: false, value: 'raz' }, "#1"); - a.deep(it.next(), { done: false, value: 'dwa' }, "#2"); - x.splice(1, 0, 'półtora'); - y.emit('_add', 1); - x.splice(1, 0, '1.25'); - y.emit('_add', 1); - x.splice(0, 1); - y.emit('_delete', 0); - a.deep(it.next(), { done: false, value: 'półtora' }, "Insert"); - a.deep(it.next(), { done: false, value: '1.25' }, "Insert #2"); - a.deep(it.next(), { done: false, value: 'trzy' }, "#3"); - a.deep(it.next(), { done: false, value: 'cztery' }, "#4"); - x.splice(5, 1); - y.emit('_delete', 5); - a.deep(it.next(), { done: false, value: 'sześć' }, "#5"); - a.deep(it.next(), { done: true, value: undefined }, "End"); - }, - "Emited: Clear #1": function (a) { - var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], y, it; - - y = ee(); - it = new T(x, y); - a.deep(it.next(), { done: false, value: 'raz' }, "#1"); - a.deep(it.next(), { done: false, value: 'dwa' }, "#2"); - x.length = 0; - y.emit('_clear'); - a.deep(it.next(), { done: true, value: undefined }, "End"); - }, - "Emited: Clear #2": function (a) { - var x = ['raz', 'dwa', 'trzy', 'cztery', 'pięć', 'sześć'], y, it; - - y = ee(); - it = new T(x, y); - a.deep(it.next(), { done: false, value: 'raz' }, "#1"); - a.deep(it.next(), { done: false, value: 'dwa' }, "#2"); - x.length = 0; - y.emit('_clear'); - x.push('foo'); - x.push('bar'); - a.deep(it.next(), { done: false, value: 'foo' }, "#3"); - a.deep(it.next(), { done: false, value: 'bar' }, "#4"); - x.splice(1, 0, 'półtora'); - y.emit('_add', 1); - x.splice(1, 0, '1.25'); - y.emit('_add', 1); - x.splice(0, 1); - y.emit('_delete', 0); - a.deep(it.next(), { done: false, value: 'półtora' }, "Insert"); - a.deep(it.next(), { done: false, value: '1.25' }, "Insert #2"); - a.deep(it.next(), { done: true, value: undefined }, "End"); - } - }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/is-iterable.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/is-iterable.js deleted file mode 100644 index 438ad349ca3d48..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/is-iterable.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator - , Iterator = require('../'); - -module.exports = function (t, a) { - var iterator; - a(t(), false, "Undefined"); - a(t(123), false, "Number"); - a(t({}), false, "Plain object"); - a(t({ length: 0 }), false, "Array-like"); - iterator = {}; - iterator[iteratorSymbol] = function () { return new Iterator([]); }; - a(t(iterator), true, "Iterator"); - a(t([]), true, "Array"); - a(t('foo'), true, "String"); - a(t(''), true, "Empty string"); - a(t((function () { return arguments; }())), true, "Arguments"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/string.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/string.js deleted file mode 100644 index d11855f2511609..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/string.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator; - -module.exports = function (T, a) { - var it = new T('foobar'); - - a(it[iteratorSymbol](), it, "@@iterator"); - a.deep(it.next(), { done: false, value: 'f' }, "#1"); - a.deep(it.next(), { done: false, value: 'o' }, "#2"); - a.deep(it.next(), { done: false, value: 'o' }, "#3"); - a.deep(it.next(), { done: false, value: 'b' }, "#4"); - a.deep(it.next(), { done: false, value: 'a' }, "#5"); - a.deep(it.next(), { done: false, value: 'r' }, "#6"); - a.deep(it.next(), { done: true, value: undefined }, "End"); - - a.h1("Outside of BMP"); - it = new T('r💩z'); - a.deep(it.next(), { done: false, value: 'r' }, "#1"); - a.deep(it.next(), { done: false, value: '💩' }, "#2"); - a.deep(it.next(), { done: false, value: 'z' }, "#3"); - a.deep(it.next(), { done: true, value: undefined }, "End"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/valid-iterable.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/valid-iterable.js deleted file mode 100644 index a407f1a0c46923..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/test/valid-iterable.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator - , Iterator = require('../'); - -module.exports = function (t, a) { - var obj; - a.throws(function () { t(); }, TypeError, "Undefined"); - a.throws(function () { t({}); }, TypeError, "Plain object"); - a.throws(function () { t({ length: 0 }); }, TypeError, "Array-like"); - obj = {}; - obj[iteratorSymbol] = function () { return new Iterator([]); }; - a(t(obj), obj, "Iterator"); - obj = []; - a(t(obj), obj, 'Array'); - obj = (function () { return arguments; }()); - a(t(obj), obj, "Arguments"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/valid-iterable.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/valid-iterable.js deleted file mode 100644 index d330997cb1d6af..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/node_modules/es6-iterator/valid-iterable.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isIterable = require('./is-iterable'); - -module.exports = function (value) { - if (!isIterable(value)) throw new TypeError(value + " is not iterable"); - return value; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/#/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/#/index.js deleted file mode 100644 index 324811704b80a0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/#/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = { - pad: require('./pad') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/#/pad.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/#/pad.js deleted file mode 100644 index 4478f6a11e0c9b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/#/pad.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var pad = require('../../string/#/pad') - , toPosInt = require('../to-pos-integer') - - , toFixed = Number.prototype.toFixed; - -module.exports = function (length/*, precision*/) { - var precision; - length = toPosInt(length); - precision = toPosInt(arguments[1]); - - return pad.call(precision ? toFixed.call(this, precision) : this, - '0', length + (precision ? (1 + precision) : 0)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/epsilon/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/epsilon/implement.js deleted file mode 100644 index f0a670ae33824b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/epsilon/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Number, 'EPSILON', { value: require('./'), - configurable: false, enumerable: false, writable: false }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/epsilon/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/epsilon/index.js deleted file mode 100644 index 4e4b621b7bc6f5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/epsilon/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = 2.220446049250313e-16; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/epsilon/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/epsilon/is-implemented.js deleted file mode 100644 index 141f5d2f24a512..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/epsilon/is-implemented.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function () { - return (typeof Number.EPSILON === 'number'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/index.js deleted file mode 100644 index 841b3612c0a7ca..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/index.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = { - '#': require('./#'), - EPSILON: require('./epsilon'), - isFinite: require('./is-finite'), - isInteger: require('./is-integer'), - isNaN: require('./is-nan'), - isNatural: require('./is-natural'), - isNumber: require('./is-number'), - isSafeInteger: require('./is-safe-integer'), - MAX_SAFE_INTEGER: require('./max-safe-integer'), - MIN_SAFE_INTEGER: require('./min-safe-integer'), - toInteger: require('./to-integer'), - toPosInteger: require('./to-pos-integer'), - toUint32: require('./to-uint32') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/implement.js deleted file mode 100644 index 51d7cac07adb71..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Number, 'isFinite', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/index.js deleted file mode 100644 index 15d5f40588134c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Number.isFinite - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/is-implemented.js deleted file mode 100644 index 556e396bb0b0fd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var isFinite = Number.isFinite; - if (typeof isFinite !== 'function') return false; - return !isFinite('23') && isFinite(34) && !isFinite(Infinity); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/shim.js deleted file mode 100644 index e3aee551a7053a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-finite/shim.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (value) { - return (typeof value === 'number') && isFinite(value); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/implement.js deleted file mode 100644 index fe53f28143ad0c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Number, 'isInteger', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/index.js deleted file mode 100644 index 55e039a99d6d97..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Number.isInteger - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/is-implemented.js deleted file mode 100644 index a0e573be7c299d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var isInteger = Number.isInteger; - if (typeof isInteger !== 'function') return false; - return !isInteger('23') && isInteger(34) && !isInteger(32.34); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/shim.js deleted file mode 100644 index 5402939806da40..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-integer/shim.js +++ /dev/null @@ -1,8 +0,0 @@ -// Credit: http://www.2ality.com/2014/05/is-integer.html - -'use strict'; - -module.exports = function (value) { - if (typeof value !== 'number') return false; - return (value % 1 === 0); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/implement.js deleted file mode 100644 index e1c5deea36a653..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Number, 'isNaN', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/index.js deleted file mode 100644 index 3b2c4ca6bd902a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Number.isNaN - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/is-implemented.js deleted file mode 100644 index 4cf276656365ca..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var isNaN = Number.isNaN; - if (typeof isNaN !== 'function') return false; - return !isNaN({}) && isNaN(NaN) && !isNaN(34); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/shim.js deleted file mode 100644 index 070d96cd460d3a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-nan/shim.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (value) { return (value !== value); } //jslint: ignore diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-natural.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-natural.js deleted file mode 100644 index 831090d23c3745..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-natural.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isInteger = require('./is-integer'); - -module.exports = function (num) { return isInteger(num) && (num >= 0); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-number.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-number.js deleted file mode 100644 index 19a99e4f194c2e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-number.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var toString = Object.prototype.toString - - , id = toString.call(1); - -module.exports = function (x) { - return ((typeof x === 'number') || - ((x instanceof Number) || - ((typeof x === 'object') && (toString.call(x) === id)))); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/implement.js deleted file mode 100644 index 51cef960212134..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Number, 'isSafeInteger', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/index.js deleted file mode 100644 index 49adeaaf784e23..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Number.isSafeInteger - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/is-implemented.js deleted file mode 100644 index 510b60e4e4bd43..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = function () { - var isSafeInteger = Number.isSafeInteger; - if (typeof isSafeInteger !== 'function') return false; - return !isSafeInteger('23') && isSafeInteger(34232322323) && - !isSafeInteger(9007199254740992); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/shim.js deleted file mode 100644 index 692acdd6ca7799..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/is-safe-integer/shim.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var isInteger = require('../is-integer/shim') - , maxValue = require('../max-safe-integer') - - , abs = Math.abs; - -module.exports = function (value) { - if (!isInteger(value)) return false; - return abs(value) <= maxValue; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/max-safe-integer/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/max-safe-integer/implement.js deleted file mode 100644 index 4e0bb5741d926d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/max-safe-integer/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Number, 'MAX_SAFE_INTEGER', { value: require('./'), - configurable: false, enumerable: false, writable: false }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/max-safe-integer/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/max-safe-integer/index.js deleted file mode 100644 index ed5d6a5379fe15..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/max-safe-integer/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = Math.pow(2, 53) - 1; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/max-safe-integer/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/max-safe-integer/is-implemented.js deleted file mode 100644 index 7bd08a9da4edc5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/max-safe-integer/is-implemented.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function () { - return (typeof Number.MAX_SAFE_INTEGER === 'number'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/min-safe-integer/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/min-safe-integer/implement.js deleted file mode 100644 index e3f110e419162f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/min-safe-integer/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Number, 'MIN_SAFE_INTEGER', { value: require('./'), - configurable: false, enumerable: false, writable: false }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/min-safe-integer/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/min-safe-integer/index.js deleted file mode 100644 index 1c6cc2744efe14..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/min-safe-integer/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = -(Math.pow(2, 53) - 1); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/min-safe-integer/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/min-safe-integer/is-implemented.js deleted file mode 100644 index efc9875f486d4a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/min-safe-integer/is-implemented.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function () { - return (typeof Number.MIN_SAFE_INTEGER === 'number'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/to-integer.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/to-integer.js deleted file mode 100644 index 60e798c5fda58d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/to-integer.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var sign = require('../math/sign') - - , abs = Math.abs, floor = Math.floor; - -module.exports = function (value) { - if (isNaN(value)) return 0; - value = Number(value); - if ((value === 0) || !isFinite(value)) return value; - return sign(value) * floor(abs(value)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/to-pos-integer.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/to-pos-integer.js deleted file mode 100644 index 605a302c7106f7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/to-pos-integer.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var toInteger = require('./to-integer') - - , max = Math.max; - -module.exports = function (value) { return max(0, toInteger(value)); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/to-uint32.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/to-uint32.js deleted file mode 100644 index 6263e85ed6de95..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/number/to-uint32.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (value) { return value >>> 0; }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/_iterate.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/_iterate.js deleted file mode 100644 index 1ccbaf2742eb16..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/_iterate.js +++ /dev/null @@ -1,29 +0,0 @@ -// Internal method, used by iteration functions. -// Calls a function for each key-value pair found in object -// Optionally takes compareFn to iterate object in specific order - -'use strict'; - -var callable = require('./valid-callable') - , value = require('./valid-value') - - , bind = Function.prototype.bind, call = Function.prototype.call, keys = Object.keys - , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; - -module.exports = function (method, defVal) { - return function (obj, cb/*, thisArg, compareFn*/) { - var list, thisArg = arguments[2], compareFn = arguments[3]; - obj = Object(value(obj)); - callable(cb); - - list = keys(obj); - if (compareFn) { - list.sort((typeof compareFn === 'function') ? bind.call(compareFn, obj) : undefined); - } - if (typeof method !== 'function') method = list[method]; - return call.call(method, list, function (key, index) { - if (!propertyIsEnumerable.call(obj, key)) return defVal; - return call.call(cb, thisArg, obj[key], key, obj, index); - }); - }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/implement.js deleted file mode 100644 index 3bcc68e31e1a44..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Object, 'assign', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/index.js deleted file mode 100644 index ab0f9f249e81a8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Object.assign - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/is-implemented.js deleted file mode 100644 index 579ad2ddc433b9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/is-implemented.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function () { - var assign = Object.assign, obj; - if (typeof assign !== 'function') return false; - obj = { foo: 'raz' }; - assign(obj, { bar: 'dwa' }, { trzy: 'trzy' }); - return (obj.foo + obj.bar + obj.trzy) === 'razdwatrzy'; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/shim.js deleted file mode 100644 index 74da11a86a8556..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/assign/shim.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -var keys = require('../keys') - , value = require('../valid-value') - - , max = Math.max; - -module.exports = function (dest, src/*, …srcn*/) { - var error, i, l = max(arguments.length, 2), assign; - dest = Object(value(dest)); - assign = function (key) { - try { dest[key] = src[key]; } catch (e) { - if (!error) error = e; - } - }; - for (i = 1; i < l; ++i) { - src = arguments[i]; - keys(src).forEach(assign); - } - if (error !== undefined) throw error; - return dest; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/clear.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/clear.js deleted file mode 100644 index 85e463728550d0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/clear.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var keys = require('./keys'); - -module.exports = function (obj) { - var error; - keys(obj).forEach(function (key) { - try { - delete this[key]; - } catch (e) { - if (!error) error = e; - } - }, obj); - if (error !== undefined) throw error; - return obj; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/compact.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/compact.js deleted file mode 100644 index d021da457e3914..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/compact.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var filter = require('./filter'); - -module.exports = function (obj) { - return filter(obj, function (val) { return val != null; }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/compare.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/compare.js deleted file mode 100644 index 2ab11f1a396350..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/compare.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -var strCompare = require('../string/#/case-insensitive-compare') - , isObject = require('./is-object') - - , resolve, typeMap; - -typeMap = { - undefined: 0, - object: 1, - boolean: 2, - string: 3, - number: 4 -}; - -resolve = function (a) { - if (isObject(a)) { - if (typeof a.valueOf !== 'function') return NaN; - a = a.valueOf(); - if (isObject(a)) { - if (typeof a.toString !== 'function') return NaN; - a = a.toString(); - if (typeof a !== 'string') return NaN; - } - } - return a; -}; - -module.exports = function (a, b) { - if (a === b) return 0; // Same - - a = resolve(a); - b = resolve(b); - if (a == b) return typeMap[typeof a] - typeMap[typeof b]; //jslint: ignore - if (a == null) return -1; - if (b == null) return 1; - if ((typeof a === 'string') || (typeof b === 'string')) { - return strCompare.call(a, b); - } - if ((a !== a) && (b !== b)) return 0; //jslint: ignore - return Number(a) - Number(b); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/copy-deep.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/copy-deep.js deleted file mode 100644 index b203a7c6934c57..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/copy-deep.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -var forEach = require('./for-each') - , isPlainObject = require('./is-plain-object') - , value = require('./valid-value') - - , isArray = Array.isArray - , copy, copyItem; - -copyItem = function (value, key) { - var index; - if (!isPlainObject(value) && !isArray(value)) return value; - index = this[0].indexOf(value); - if (index === -1) return copy.call(this, value); - return this[1][index]; -}; - -copy = function (source) { - var target = isArray(source) ? [] : {}; - this[0].push(source); - this[1].push(target); - if (isArray(source)) { - source.forEach(function (value, key) { - target[key] = copyItem.call(this, value, key); - }, this); - } else { - forEach(source, function (value, key) { - target[key] = copyItem.call(this, value, key); - }, this); - } - return target; -}; - -module.exports = function (source) { - var obj = Object(value(source)); - if (obj !== source) return obj; - return copy.call([[], []], obj); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/copy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/copy.js deleted file mode 100644 index 4d7177285fe5b3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/copy.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var assign = require('./assign') - , value = require('./valid-value'); - -module.exports = function (obj) { - var copy = Object(value(obj)); - if (copy !== obj) return copy; - return assign({}, obj); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/count.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/count.js deleted file mode 100644 index 29cfbb53fb40ae..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/count.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var keys = require('./keys'); - -module.exports = function (obj) { return keys(obj).length; }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/create.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/create.js deleted file mode 100644 index f813b4661c4498..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/create.js +++ /dev/null @@ -1,36 +0,0 @@ -// Workaround for http://code.google.com/p/v8/issues/detail?id=2804 - -'use strict'; - -var create = Object.create, shim; - -if (!require('./set-prototype-of/is-implemented')()) { - shim = require('./set-prototype-of/shim'); -} - -module.exports = (function () { - var nullObject, props, desc; - if (!shim) return create; - if (shim.level !== 1) return create; - - nullObject = {}; - props = {}; - desc = { configurable: false, enumerable: false, writable: true, - value: undefined }; - Object.getOwnPropertyNames(Object.prototype).forEach(function (name) { - if (name === '__proto__') { - props[name] = { configurable: true, enumerable: false, writable: true, - value: undefined }; - return; - } - props[name] = desc; - }); - Object.defineProperties(nullObject, props); - - Object.defineProperty(shim, 'nullPolyfill', { configurable: false, - enumerable: false, writable: false, value: nullObject }); - - return function (prototype, props) { - return create((prototype === null) ? nullObject : prototype, props); - }; -}()); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/ensure-natural-number-value.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/ensure-natural-number-value.js deleted file mode 100644 index f58fb4e4a709f5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/ensure-natural-number-value.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var ensure = require('./ensure-natural-number'); - -module.exports = function (arg) { - if (arg == null) throw new TypeError(arg + " is not a natural number"); - return ensure(arg); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/ensure-natural-number.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/ensure-natural-number.js deleted file mode 100644 index af9b4d77c29efe..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/ensure-natural-number.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var isNatural = require('../number/is-natural'); - -module.exports = function (arg) { - var num = Number(arg); - if (!isNatural(num)) throw new TypeError(arg + " is not a natural number"); - return num; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/eq.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/eq.js deleted file mode 100644 index 037937ea6e9749..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/eq.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (x, y) { - return ((x === y) || ((x !== x) && (y !== y))); //jslint: ignore -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/every.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/every.js deleted file mode 100644 index 1303db20958f8d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/every.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./_iterate')('every', true); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/filter.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/filter.js deleted file mode 100644 index e5edb49b1b1610..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/filter.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var callable = require('./valid-callable') - , forEach = require('./for-each') - - , call = Function.prototype.call; - -module.exports = function (obj, cb/*, thisArg*/) { - var o = {}, thisArg = arguments[2]; - callable(cb); - forEach(obj, function (value, key, obj, index) { - if (call.call(cb, thisArg, value, key, obj, index)) o[key] = obj[key]; - }); - return o; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/find-key.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/find-key.js deleted file mode 100644 index 5841fd709a4f86..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/find-key.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./_iterate')(require('../array/#/find'), false); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/find.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/find.js deleted file mode 100644 index c94f643f3f50c6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/find.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var findKey = require('./find-key'); - -module.exports = function (obj, cb/*, thisArg, compareFn*/) { - var key = findKey.apply(this, arguments); - return (key == null) ? key : obj[key]; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/first-key.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/first-key.js deleted file mode 100644 index 7df10b2f7f948d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/first-key.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var value = require('./valid-value') - - , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; - -module.exports = function (obj) { - var i; - value(obj); - for (i in obj) { - if (propertyIsEnumerable.call(obj, i)) return i; - } - return null; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/flatten.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/flatten.js deleted file mode 100644 index e8b40444a94692..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/flatten.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var isPlainObject = require('./is-plain-object') - , forEach = require('./for-each') - - , process; - -process = function self(value, key) { - if (isPlainObject(value)) forEach(value, self, this); - else this[key] = value; -}; - -module.exports = function (obj) { - var flattened = {}; - forEach(obj, process, flattened); - return flattened; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/for-each.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/for-each.js deleted file mode 100644 index 6674f8a614795b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/for-each.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./_iterate')('forEach'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/get-property-names.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/get-property-names.js deleted file mode 100644 index 54a01e5047a392..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/get-property-names.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var uniq = require('../array/#/uniq') - , value = require('./valid-value') - - , push = Array.prototype.push - , getOwnPropertyNames = Object.getOwnPropertyNames - , getPrototypeOf = Object.getPrototypeOf; - -module.exports = function (obj) { - var keys; - obj = Object(value(obj)); - keys = getOwnPropertyNames(obj); - while ((obj = getPrototypeOf(obj))) { - push.apply(keys, getOwnPropertyNames(obj)); - } - return uniq.call(keys); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/index.js deleted file mode 100644 index 77f5b6aebab1e1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/index.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -module.exports = { - assign: require('./assign'), - clear: require('./clear'), - compact: require('./compact'), - compare: require('./compare'), - copy: require('./copy'), - copyDeep: require('./copy-deep'), - count: require('./count'), - create: require('./create'), - ensureNaturalNumber: require('./ensure-natural-number'), - ensureNaturalNumberValue: require('./ensure-natural-number-value'), - eq: require('./eq'), - every: require('./every'), - filter: require('./filter'), - find: require('./find'), - findKey: require('./find-key'), - firstKey: require('./first-key'), - flatten: require('./flatten'), - forEach: require('./for-each'), - getPropertyNames: require('./get-property-names'), - is: require('./is'), - isArrayLike: require('./is-array-like'), - isCallable: require('./is-callable'), - isCopy: require('./is-copy'), - isCopyDeep: require('./is-copy-deep'), - isEmpty: require('./is-empty'), - isNumberValue: require('./is-number-value'), - isObject: require('./is-object'), - isPlainObject: require('./is-plain-object'), - keyOf: require('./key-of'), - keys: require('./keys'), - map: require('./map'), - mapKeys: require('./map-keys'), - normalizeOptions: require('./normalize-options'), - mixin: require('./mixin'), - mixinPrototypes: require('./mixin-prototypes'), - primitiveSet: require('./primitive-set'), - safeTraverse: require('./safe-traverse'), - serialize: require('./serialize'), - setPrototypeOf: require('./set-prototype-of'), - some: require('./some'), - toArray: require('./to-array'), - unserialize: require('./unserialize'), - validateArrayLike: require('./validate-array-like'), - validateArrayLikeObject: require('./validate-array-like-object'), - validCallable: require('./valid-callable'), - validObject: require('./valid-object'), - validateStringifiable: require('./validate-stringifiable'), - validateStringifiableValue: require('./validate-stringifiable-value'), - validValue: require('./valid-value') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-array-like.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-array-like.js deleted file mode 100644 index b8beed225b05ad..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-array-like.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var isFunction = require('../function/is-function') - , isObject = require('./is-object'); - -module.exports = function (x) { - return ((x != null) && (typeof x.length === 'number') && - - // Just checking ((typeof x === 'object') && (typeof x !== 'function')) - // won't work right for some cases, e.g.: - // type of instance of NodeList in Safari is a 'function' - - ((isObject(x) && !isFunction(x)) || (typeof x === "string"))) || false; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-callable.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-callable.js deleted file mode 100644 index 5d5d4b316b2a1c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-callable.js +++ /dev/null @@ -1,5 +0,0 @@ -// Deprecated - -'use strict'; - -module.exports = function (obj) { return typeof obj === 'function'; }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-copy-deep.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-copy-deep.js deleted file mode 100644 index c4b2b42b100836..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-copy-deep.js +++ /dev/null @@ -1,58 +0,0 @@ -'use strict'; - -var eq = require('./eq') - , isPlainObject = require('./is-plain-object') - , value = require('./valid-value') - - , isArray = Array.isArray, keys = Object.keys - , propertyIsEnumerable = Object.prototype.propertyIsEnumerable - - , eqArr, eqVal, eqObj; - -eqArr = function (a, b, recMap) { - var i, l = a.length; - if (l !== b.length) return false; - for (i = 0; i < l; ++i) { - if (a.hasOwnProperty(i) !== b.hasOwnProperty(i)) return false; - if (!eqVal(a[i], b[i], recMap)) return false; - } - return true; -}; - -eqObj = function (a, b, recMap) { - var k1 = keys(a), k2 = keys(b); - if (k1.length !== k2.length) return false; - return k1.every(function (key) { - if (!propertyIsEnumerable.call(b, key)) return false; - return eqVal(a[key], b[key], recMap); - }); -}; - -eqVal = function (a, b, recMap) { - var i, eqX, c1, c2; - if (eq(a, b)) return true; - if (isPlainObject(a)) { - if (!isPlainObject(b)) return false; - eqX = eqObj; - } else if (isArray(a) && isArray(b)) { - eqX = eqArr; - } else { - return false; - } - c1 = recMap[0]; - c2 = recMap[1]; - i = c1.indexOf(a); - if (i !== -1) { - if (c2[i].indexOf(b) !== -1) return true; - } else { - i = c1.push(a) - 1; - c2[i] = []; - } - c2[i].push(b); - return eqX(a, b, recMap); -}; - -module.exports = function (a, b) { - if (eq(value(a), value(b))) return true; - return eqVal(Object(a), Object(b), [[], []]); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-copy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-copy.js deleted file mode 100644 index 4fe639d4efcd2d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-copy.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -var eq = require('./eq') - , value = require('./valid-value') - - , keys = Object.keys - , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; - -module.exports = function (a, b) { - var k1, k2; - - if (eq(value(a), value(b))) return true; - - a = Object(a); - b = Object(b); - - k1 = keys(a); - k2 = keys(b); - if (k1.length !== k2.length) return false; - return k1.every(function (key) { - if (!propertyIsEnumerable.call(b, key)) return false; - return eq(a[key], b[key]); - }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-empty.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-empty.js deleted file mode 100644 index 7b51a87cf57e70..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-empty.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var value = require('./valid-value') - - , propertyIsEnumerable = Object.prototype.propertyIsEnumerable; - -module.exports = function (obj) { - var i; - value(obj); - for (i in obj) { //jslint: ignore - if (propertyIsEnumerable.call(obj, i)) return false; - } - return true; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-number-value.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-number-value.js deleted file mode 100644 index f6396f580f8911..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-number-value.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (value) { return (value != null) && !isNaN(value); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-object.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-object.js deleted file mode 100644 index a86facf187a86f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-object.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var map = { function: true, object: true }; - -module.exports = function (x) { - return ((x != null) && map[typeof x]) || false; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-plain-object.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-plain-object.js deleted file mode 100644 index 9a2823198e746f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is-plain-object.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var getPrototypeOf = Object.getPrototypeOf, prototype = Object.prototype - , toString = prototype.toString - - , id = Object().toString(); - -module.exports = function (value) { - var proto, constructor; - if (!value || (typeof value !== 'object') || (toString.call(value) !== id)) { - return false; - } - proto = getPrototypeOf(value); - if (proto === null) { - constructor = value.constructor; - if (typeof constructor !== 'function') return true; - return (constructor.prototype !== value); - } - return (proto === prototype) || (getPrototypeOf(proto) === null); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is.js deleted file mode 100644 index 5778b502d924cd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/is.js +++ /dev/null @@ -1,10 +0,0 @@ -// Implementation credits go to: -// http://wiki.ecmascript.org/doku.php?id=harmony:egal - -'use strict'; - -module.exports = function (x, y) { - return (x === y) ? - ((x !== 0) || ((1 / x) === (1 / y))) : - ((x !== x) && (y !== y)); //jslint: ignore -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/key-of.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/key-of.js deleted file mode 100644 index 8c44c8d8027f8b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/key-of.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var eq = require('./eq') - , some = require('./some'); - -module.exports = function (obj, searchValue) { - var r; - return some(obj, function (value, name) { - if (eq(value, searchValue)) { - r = name; - return true; - } - return false; - }) ? r : null; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/implement.js deleted file mode 100644 index c6872bd02af0b2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(Object, 'keys', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/index.js deleted file mode 100644 index 5ef052233a76e6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Object.keys - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/is-implemented.js deleted file mode 100644 index 40c32c33940c7c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = function () { - try { - Object.keys('primitive'); - return true; - } catch (e) { return false; } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/shim.js deleted file mode 100644 index 034b6b2981185a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/keys/shim.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var keys = Object.keys; - -module.exports = function (object) { - return keys(object == null ? object : Object(object)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/map-keys.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/map-keys.js deleted file mode 100644 index 26f0ecacb8aef3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/map-keys.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var callable = require('./valid-callable') - , forEach = require('./for-each') - - , call = Function.prototype.call; - -module.exports = function (obj, cb/*, thisArg*/) { - var o = {}, thisArg = arguments[2]; - callable(cb); - forEach(obj, function (value, key, obj, index) { - o[call.call(cb, thisArg, key, value, this, index)] = value; - }, obj); - return o; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/map.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/map.js deleted file mode 100644 index 6b39d3c94b7421..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/map.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var callable = require('./valid-callable') - , forEach = require('./for-each') - - , call = Function.prototype.call; - -module.exports = function (obj, cb/*, thisArg*/) { - var o = {}, thisArg = arguments[2]; - callable(cb); - forEach(obj, function (value, key, obj, index) { - o[key] = call.call(cb, thisArg, value, key, obj, index); - }); - return o; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/mixin-prototypes.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/mixin-prototypes.js deleted file mode 100644 index 1ef5756423cd36..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/mixin-prototypes.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -var value = require('./valid-value') - , mixin = require('./mixin') - - , defineProperty = Object.defineProperty - , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor - , getOwnPropertyNames = Object.getOwnPropertyNames - , getPrototypeOf = Object.getPrototypeOf - , hasOwnProperty = Object.prototype.hasOwnProperty; - -module.exports = function (target, source) { - var error, end, define; - target = Object(value(target)); - source = Object(value(source)); - end = getPrototypeOf(target); - if (source === end) return target; - try { - mixin(target, source); - } catch (e) { error = e; } - source = getPrototypeOf(source); - define = function (name) { - if (hasOwnProperty.call(target, name)) return; - try { - defineProperty(target, name, getOwnPropertyDescriptor(source, name)); - } catch (e) { error = e; } - }; - while (source && (source !== end)) { - getOwnPropertyNames(source).forEach(define); - source = getPrototypeOf(source); - } - if (error) throw error; - return target; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/mixin.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/mixin.js deleted file mode 100644 index 488523eea1d4ff..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/mixin.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -var value = require('./valid-value') - - , defineProperty = Object.defineProperty - , getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor - , getOwnPropertyNames = Object.getOwnPropertyNames - , getOwnPropertySymbols = Object.getOwnPropertySymbols; - -module.exports = function (target, source) { - var error, sourceObject = Object(value(source)); - target = Object(value(target)); - getOwnPropertyNames(sourceObject).forEach(function (name) { - try { - defineProperty(target, name, getOwnPropertyDescriptor(source, name)); - } catch (e) { error = e; } - }); - if (typeof getOwnPropertySymbols === 'function') { - getOwnPropertySymbols(sourceObject).forEach(function (symbol) { - try { - defineProperty(target, symbol, getOwnPropertyDescriptor(source, symbol)); - } catch (e) { error = e; } - }); - } - if (error !== undefined) throw error; - return target; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/normalize-options.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/normalize-options.js deleted file mode 100644 index cf8ed8d38cabd1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/normalize-options.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var forEach = Array.prototype.forEach, create = Object.create; - -var process = function (src, obj) { - var key; - for (key in src) obj[key] = src[key]; -}; - -module.exports = function (options/*, …options*/) { - var result = create(null); - forEach.call(arguments, function (options) { - if (options == null) return; - process(Object(options), result); - }); - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/primitive-set.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/primitive-set.js deleted file mode 100644 index ada109510d4bd9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/primitive-set.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var forEach = Array.prototype.forEach, create = Object.create; - -module.exports = function (arg/*, …args*/) { - var set = create(null); - forEach.call(arguments, function (name) { set[name] = true; }); - return set; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/safe-traverse.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/safe-traverse.js deleted file mode 100644 index 7e1b5f41edf162..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/safe-traverse.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var value = require('./valid-value'); - -module.exports = function (obj/*, …names*/) { - var length, current = 1; - value(obj); - length = arguments.length - 1; - if (!length) return obj; - while (current < length) { - obj = obj[arguments[current++]]; - if (obj == null) return undefined; - } - return obj[arguments[current]]; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/serialize.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/serialize.js deleted file mode 100644 index 8113b6801dd395..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/serialize.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -var toArray = require('./to-array') - , isDate = require('../date/is-date') - , isRegExp = require('../reg-exp/is-reg-exp') - - , isArray = Array.isArray, stringify = JSON.stringify - , keyValueToString = function (value, key) { return stringify(key) + ':' + exports(value); }; - -var sparseMap = function (arr) { - var i, l = arr.length, result = new Array(l); - for (i = 0; i < l; ++i) { - if (!arr.hasOwnProperty(i)) continue; - result[i] = exports(arr[i]); - } - return result; -}; - -module.exports = exports = function (obj) { - if (obj == null) return String(obj); - switch (typeof obj) { - case 'string': - return stringify(obj); - case 'number': - case 'boolean': - case 'function': - return String(obj); - case 'object': - if (isArray(obj)) return '[' + sparseMap(obj) + ']'; - if (isRegExp(obj)) return String(obj); - if (isDate(obj)) return 'new Date(' + obj.valueOf() + ')'; - return '{' + toArray(obj, keyValueToString) + '}'; - default: - throw new TypeError("Serialization of " + String(obj) + "is unsupported"); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/implement.js deleted file mode 100644 index 000e6bdbbebcb7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/implement.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var shim; - -if (!require('./is-implemented')() && (shim = require('./shim'))) { - Object.defineProperty(Object, 'setPrototypeOf', - { value: shim, configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/index.js deleted file mode 100644 index ccc40995b1e6b5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? Object.setPrototypeOf - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/is-implemented.js deleted file mode 100644 index 98d0c8436a8d46..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/is-implemented.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var create = Object.create, getPrototypeOf = Object.getPrototypeOf - , x = {}; - -module.exports = function (/*customCreate*/) { - var setPrototypeOf = Object.setPrototypeOf - , customCreate = arguments[0] || create; - if (typeof setPrototypeOf !== 'function') return false; - return getPrototypeOf(setPrototypeOf(customCreate(null), x)) === x; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/shim.js deleted file mode 100644 index 4ec944675e5685..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/set-prototype-of/shim.js +++ /dev/null @@ -1,73 +0,0 @@ -// Big thanks to @WebReflection for sorting this out -// https://gist.github.com/WebReflection/5593554 - -'use strict'; - -var isObject = require('../is-object') - , value = require('../valid-value') - - , isPrototypeOf = Object.prototype.isPrototypeOf - , defineProperty = Object.defineProperty - , nullDesc = { configurable: true, enumerable: false, writable: true, - value: undefined } - , validate; - -validate = function (obj, prototype) { - value(obj); - if ((prototype === null) || isObject(prototype)) return obj; - throw new TypeError('Prototype must be null or an object'); -}; - -module.exports = (function (status) { - var fn, set; - if (!status) return null; - if (status.level === 2) { - if (status.set) { - set = status.set; - fn = function (obj, prototype) { - set.call(validate(obj, prototype), prototype); - return obj; - }; - } else { - fn = function (obj, prototype) { - validate(obj, prototype).__proto__ = prototype; - return obj; - }; - } - } else { - fn = function self(obj, prototype) { - var isNullBase; - validate(obj, prototype); - isNullBase = isPrototypeOf.call(self.nullPolyfill, obj); - if (isNullBase) delete self.nullPolyfill.__proto__; - if (prototype === null) prototype = self.nullPolyfill; - obj.__proto__ = prototype; - if (isNullBase) defineProperty(self.nullPolyfill, '__proto__', nullDesc); - return obj; - }; - } - return Object.defineProperty(fn, 'level', { configurable: false, - enumerable: false, writable: false, value: status.level }); -}((function () { - var x = Object.create(null), y = {}, set - , desc = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__'); - - if (desc) { - try { - set = desc.set; // Opera crashes at this point - set.call(x, y); - } catch (ignore) { } - if (Object.getPrototypeOf(x) === y) return { set: set, level: 2 }; - } - - x.__proto__ = y; - if (Object.getPrototypeOf(x) === y) return { level: 2 }; - - x = {}; - x.__proto__ = y; - if (Object.getPrototypeOf(x) === y) return { level: 1 }; - - return false; -}()))); - -require('../create'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/some.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/some.js deleted file mode 100644 index cde5ddeecdf749..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/some.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./_iterate')('some', false); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/to-array.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/to-array.js deleted file mode 100644 index a954abb26fdffd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/to-array.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var callable = require('./valid-callable') - , forEach = require('./for-each') - - , call = Function.prototype.call - - , defaultCb = function (value, key) { return [key, value]; }; - -module.exports = function (obj/*, cb, thisArg, compareFn*/) { - var a = [], cb = arguments[1], thisArg = arguments[2]; - cb = (cb == null) ? defaultCb : callable(cb); - - forEach(obj, function (value, key, obj, index) { - a.push(call.call(cb, thisArg, value, key, this, index)); - }, obj, arguments[3]); - return a; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/unserialize.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/unserialize.js deleted file mode 100644 index ce68e403ae1b6e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/unserialize.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var value = require('./valid-value'); - -module.exports = exports = function (code) { - return (new Function('return ' + value(code)))(); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/valid-callable.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/valid-callable.js deleted file mode 100644 index c977527a4fd660..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/valid-callable.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (fn) { - if (typeof fn !== 'function') throw new TypeError(fn + " is not a function"); - return fn; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/valid-object.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/valid-object.js deleted file mode 100644 index f82bd51ed106f2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/valid-object.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isObject = require('./is-object'); - -module.exports = function (value) { - if (!isObject(value)) throw new TypeError(value + " is not an Object"); - return value; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/valid-value.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/valid-value.js deleted file mode 100644 index 36c8ec31e84731..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/valid-value.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (value) { - if (value == null) throw new TypeError("Cannot use null or undefined"); - return value; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-array-like-object.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-array-like-object.js deleted file mode 100644 index 89e12c51c5dfcf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-array-like-object.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var isArrayLike = require('./is-array-like') - , isObject = require('./is-object'); - -module.exports = function (obj) { - if (isObject(obj) && isArrayLike(obj)) return obj; - throw new TypeError(obj + " is not array-like object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-array-like.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-array-like.js deleted file mode 100644 index 6a35b54a14f677..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-array-like.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isArrayLike = require('./is-array-like'); - -module.exports = function (obj) { - if (isArrayLike(obj)) return obj; - throw new TypeError(obj + " is not array-like value"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-stringifiable-value.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-stringifiable-value.js deleted file mode 100644 index 9df3b668fb06c9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-stringifiable-value.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -var value = require('./valid-value') - , stringifiable = require('./validate-stringifiable'); - -module.exports = function (x) { return stringifiable(value(x)); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-stringifiable.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-stringifiable.js deleted file mode 100644 index eba7ce787cdfad..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/object/validate-stringifiable.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (stringifiable) { - try { - return String(stringifiable); - } catch (e) { - throw new TypeError("Passed argument cannot be stringifed"); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/package.json deleted file mode 100644 index 39321320a42d50..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/package.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "es5-ext@~0.10.11", - "scope": null, - "escapedName": "es5-ext", - "name": "es5-ext", - "rawSpec": "~0.10.11", - "spec": ">=0.10.11 <0.11.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol" - ] - ], - "_from": "es5-ext@>=0.10.11 <0.11.0", - "_id": "es5-ext@0.10.12", - "_inCache": true, - "_installable": true, - "_location": "/node-gyp/path-array/array-index/es6-symbol/es5-ext", - "_nodeVersion": "4.4.5", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/es5-ext-0.10.12.tgz_1467387765797_0.7073166444897652" - }, - "_npmUser": { - "name": "medikoo", - "email": "medikoo+npm@medikoo.com" - }, - "_npmVersion": "2.15.5", - "_phantomChildren": { - "d": "0.1.1", - "es5-ext": "0.10.12", - "es6-symbol": "3.1.0" - }, - "_requested": { - "raw": "es5-ext@~0.10.11", - "scope": null, - "escapedName": "es5-ext", - "name": "es5-ext", - "rawSpec": "~0.10.11", - "spec": ">=0.10.11 <0.11.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/path-array/array-index/es6-symbol", - "/node-gyp/path-array/array-index/es6-symbol/d", - "/node-gyp/path-array/array-index/es6-symbol/es5-ext/es6-iterator" - ], - "_resolved": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz", - "_shasum": "aa84641d4db76b62abba5e45fd805ecbab140047", - "_shrinkwrap": null, - "_spec": "es5-ext@~0.10.11", - "_where": "/Users/zkat/Documents/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol", - "author": { - "name": "Mariusz Nowak", - "email": "medyk@medikoo.com", - "url": "http://www.medikoo.com/" - }, - "bugs": { - "url": "https://github.com/medikoo/es5-ext/issues" - }, - "dependencies": { - "es6-iterator": "2", - "es6-symbol": "~3.1" - }, - "description": "ECMAScript extensions and shims", - "devDependencies": { - "tad": "~0.2.4", - "xlint": "~0.2.2", - "xlint-jslint-medikoo": "~0.1.4" - }, - "directories": {}, - "dist": { - "shasum": "aa84641d4db76b62abba5e45fd805ecbab140047", - "tarball": "https://registry.npmjs.org/es5-ext/-/es5-ext-0.10.12.tgz" - }, - "gitHead": "96fddc3a327b3a28b1653af9490e3b905f127fa8", - "homepage": "https://github.com/medikoo/es5-ext#readme", - "keywords": [ - "ecmascript", - "ecmascript5", - "ecmascript6", - "es5", - "es6", - "extensions", - "ext", - "addons", - "extras", - "harmony", - "javascript", - "polyfill", - "shim", - "util", - "utils", - "utilities" - ], - "license": "MIT", - "maintainers": [ - { - "name": "medikoo", - "email": "medikoo+npm@medikoo.com" - } - ], - "name": "es5-ext", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/medikoo/es5-ext.git" - }, - "scripts": { - "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", - "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", - "test": "node ./node_modules/tad/bin/tad" - }, - "version": "0.10.12" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/index.js deleted file mode 100644 index f7e7a58ebd780a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/index.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = { - isSticky: require('./is-sticky'), - isUnicode: require('./is-unicode'), - match: require('./match'), - replace: require('./replace'), - search: require('./search'), - split: require('./split') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/is-sticky.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/is-sticky.js deleted file mode 100644 index 830a481f7e9213..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/is-sticky.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var validRegExp = require('../valid-reg-exp') - - , re = /\/[a-xz]*y[a-xz]*$/; - -module.exports = function () { - return Boolean(String(validRegExp(this)).match(re)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/is-unicode.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/is-unicode.js deleted file mode 100644 index b005f6d9194f1f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/is-unicode.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var validRegExp = require('../valid-reg-exp') - - , re = /\/[a-xz]*u[a-xz]*$/; - -module.exports = function () { - return Boolean(String(validRegExp(this)).match(re)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/implement.js deleted file mode 100644 index 921c9368e780b6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(RegExp.prototype, 'match', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/index.js deleted file mode 100644 index 0534ac3bc352b3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? RegExp.prototype.match - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/is-implemented.js deleted file mode 100644 index b7e99643148089..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var re = /foo/; - -module.exports = function () { - if (typeof re.match !== 'function') return false; - return re.match('barfoobar') && !re.match('elo'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/shim.js deleted file mode 100644 index 4f99cf4d1c02c5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/match/shim.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var validRegExp = require('../../valid-reg-exp'); - -module.exports = function (string) { - validRegExp(this); - return String(string).match(this); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/implement.js deleted file mode 100644 index ad580de890618e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(RegExp.prototype, 'replace', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/index.js deleted file mode 100644 index 5658177d804881..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? RegExp.prototype.replace - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/is-implemented.js deleted file mode 100644 index 1b42d252430bd5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var re = /foo/; - -module.exports = function () { - if (typeof re.replace !== 'function') return false; - return re.replace('foobar', 'mar') === 'marbar'; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/shim.js deleted file mode 100644 index c3e6aebab04cf3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/replace/shim.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var validRegExp = require('../../valid-reg-exp'); - -module.exports = function (string, replaceValue) { - validRegExp(this); - return String(string).replace(this, replaceValue); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/implement.js deleted file mode 100644 index 3804f4eb1c3bb5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(RegExp.prototype, 'search', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/index.js deleted file mode 100644 index 67995d4ac7b9f3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? RegExp.prototype.search - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/is-implemented.js deleted file mode 100644 index efba889f81724d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var re = /foo/; - -module.exports = function () { - if (typeof re.search !== 'function') return false; - return re.search('barfoo') === 3; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/shim.js deleted file mode 100644 index 6d9dcaed8ab26f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/search/shim.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var validRegExp = require('../../valid-reg-exp'); - -module.exports = function (string) { - validRegExp(this); - return String(string).search(this); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/implement.js deleted file mode 100644 index 50facb6834d7c1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(RegExp.prototype, 'split', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/index.js deleted file mode 100644 index f101f5af7503cf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? RegExp.prototype.split - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/is-implemented.js deleted file mode 100644 index 7244c998bf45fd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var re = /\|/; - -module.exports = function () { - if (typeof re.split !== 'function') return false; - return re.split('bar|foo')[1] === 'foo'; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/shim.js deleted file mode 100644 index 76154e7e3c0069..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/split/shim.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var validRegExp = require('../../valid-reg-exp'); - -module.exports = function (string) { - validRegExp(this); - return String(string).split(this); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/sticky/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/sticky/implement.js deleted file mode 100644 index 7e8af1db31641b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/sticky/implement.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isSticky = require('../is-sticky'); - -if (!require('./is-implemented')()) { - Object.defineProperty(RegExp.prototype, 'sticky', { configurable: true, - enumerable: false, get: isSticky }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/sticky/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/sticky/is-implemented.js deleted file mode 100644 index e4184ee4ecef30..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/sticky/is-implemented.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function () { - var dummyRegExp = /a/; - // We need to do check on instance and not on prototype due to how ES2015 spec evolved: - // https://github.com/tc39/ecma262/issues/262 - // https://github.com/tc39/ecma262/pull/263 - // https://bugs.chromium.org/p/v8/issues/detail?id=4617 - return 'sticky' in dummyRegExp; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/unicode/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/unicode/implement.js deleted file mode 100644 index 5a82a4d1d23386..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/unicode/implement.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isUnicode = require('../is-unicode'); - -if (!require('./is-implemented')()) { - Object.defineProperty(RegExp.prototype, 'unicode', { configurable: true, - enumerable: false, get: isUnicode }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/unicode/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/unicode/is-implemented.js deleted file mode 100644 index 3e3a54b6691e55..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/#/unicode/is-implemented.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function () { - var dummyRegExp = /a/; - // We need to do check on instance and not on prototype due to how ES2015 spec evolved: - // https://github.com/tc39/ecma262/issues/262 - // https://github.com/tc39/ecma262/pull/263 - // https://bugs.chromium.org/p/v8/issues/detail?id=4617 - return 'unicode' in dummyRegExp; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/escape.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/escape.js deleted file mode 100644 index a2363fcfc68a03..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/escape.js +++ /dev/null @@ -1,9 +0,0 @@ -// Thanks to Andrew Clover: -// http://stackoverflow.com/questions/3561493 -// /is-there-a-regexp-escape-function-in-javascript - -'use strict'; - -var re = /[\-\/\\\^$*+?.()|\[\]{}]/g; - -module.exports = function (str) { return String(str).replace(re, '\\$&'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/index.js deleted file mode 100644 index 75ea3135a89afe..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/index.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = { - '#': require('./#'), - escape: require('./escape'), - isRegExp: require('./is-reg-exp'), - validRegExp: require('./valid-reg-exp') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/is-reg-exp.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/is-reg-exp.js deleted file mode 100644 index 6eb12977c031d9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/is-reg-exp.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var toString = Object.prototype.toString - - , id = toString.call(/a/); - -module.exports = function (x) { - return (x && (x instanceof RegExp || (toString.call(x) === id))) || false; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/valid-reg-exp.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/valid-reg-exp.js deleted file mode 100644 index d3a77641da0f86..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/reg-exp/valid-reg-exp.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isRegExp = require('./is-reg-exp'); - -module.exports = function (x) { - if (!isRegExp(x)) throw new TypeError(x + " is not a RegExp object"); - return x; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/implement.js deleted file mode 100644 index 4494d7b6af3d93..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(String.prototype, require('es6-symbol').iterator, - { value: require('./shim'), configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/index.js deleted file mode 100644 index 22f15e69600bc0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? String.prototype[require('es6-symbol').iterator] : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/is-implemented.js deleted file mode 100644 index f5c462deb91064..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/is-implemented.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator; - -module.exports = function () { - var str = '🙈f', iterator, result; - if (typeof str[iteratorSymbol] !== 'function') return false; - iterator = str[iteratorSymbol](); - if (!iterator) return false; - if (typeof iterator.next !== 'function') return false; - result = iterator.next(); - if (!result) return false; - if (result.value !== '🙈') return false; - if (result.done !== false) return false; - return true; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/shim.js deleted file mode 100644 index 0be30292f6e98d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/@@iterator/shim.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -var StringIterator = require('es6-iterator/string') - , value = require('../../../object/valid-value'); - -module.exports = function () { return new StringIterator(value(this)); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/at.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/at.js deleted file mode 100644 index 77bd251ac4f1ae..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/at.js +++ /dev/null @@ -1,33 +0,0 @@ -// Based on: https://github.com/mathiasbynens/String.prototype.at -// Thanks @mathiasbynens ! - -'use strict'; - -var toInteger = require('../../number/to-integer') - , validValue = require('../../object/valid-value'); - -module.exports = function (pos) { - var str = String(validValue(this)), size = str.length - , cuFirst, cuSecond, nextPos, len; - pos = toInteger(pos); - - // Account for out-of-bounds indices - // The odd lower bound is because the ToInteger operation is - // going to round `n` to `0` for `-1 < n <= 0`. - if (pos <= -1 || pos >= size) return ''; - - // Second half of `ToInteger` - pos = pos | 0; - // Get the first code unit and code unit value - cuFirst = str.charCodeAt(pos); - nextPos = pos + 1; - len = 1; - if ( // check if it’s the start of a surrogate pair - (cuFirst >= 0xD800) && (cuFirst <= 0xDBFF) && // high surrogate - (size > nextPos) // there is a next code unit - ) { - cuSecond = str.charCodeAt(nextPos); - if (cuSecond >= 0xDC00 && cuSecond <= 0xDFFF) len = 2; // low surrogate - } - return str.slice(pos, pos + len); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/camel-to-hyphen.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/camel-to-hyphen.js deleted file mode 100644 index 1cb8d127796d8b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/camel-to-hyphen.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var replace = String.prototype.replace - , re = /([A-Z])/g; - -module.exports = function () { - var str = replace.call(this, re, "-$1").toLowerCase(); - if (str[0] === '-') str = str.slice(1); - return str; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/capitalize.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/capitalize.js deleted file mode 100644 index ed768273651c9a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/capitalize.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var value = require('../../object/valid-value'); - -module.exports = function () { - var str = String(value(this)); - return str.charAt(0).toUpperCase() + str.slice(1); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/case-insensitive-compare.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/case-insensitive-compare.js deleted file mode 100644 index 599cb83469c149..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/case-insensitive-compare.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var toLowerCase = String.prototype.toLowerCase; - -module.exports = function (other) { - return toLowerCase.call(this).localeCompare(toLowerCase.call(String(other))); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/implement.js deleted file mode 100644 index 1e7a37bd4d34ef..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/implement.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(String.prototype, 'codePointAt', - { value: require('./shim'), configurable: true, enumerable: false, - writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/index.js deleted file mode 100644 index 7e91d833a867e4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? String.prototype.codePointAt - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/is-implemented.js deleted file mode 100644 index b27158913a91d1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var str = 'abc\uD834\uDF06def'; - -module.exports = function () { - if (typeof str.codePointAt !== 'function') return false; - return str.codePointAt(3) === 0x1D306; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/shim.js deleted file mode 100644 index 1c9038b3cb0a79..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/code-point-at/shim.js +++ /dev/null @@ -1,26 +0,0 @@ -// Based on: https://github.com/mathiasbynens/String.prototype.codePointAt -// Thanks @mathiasbynens ! - -'use strict'; - -var toInteger = require('../../../number/to-integer') - , validValue = require('../../../object/valid-value'); - -module.exports = function (pos) { - var str = String(validValue(this)), l = str.length, first, second; - pos = toInteger(pos); - - // Account for out-of-bounds indices: - if (pos < 0 || pos >= l) return undefined; - - // Get the first code unit - first = str.charCodeAt(pos); - if ((first >= 0xD800) && (first <= 0xDBFF) && (l > pos + 1)) { - second = str.charCodeAt(pos + 1); - if (second >= 0xDC00 && second <= 0xDFFF) { - // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae - return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; - } - } - return first; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/implement.js deleted file mode 100644 index 6b7a3c08164c4e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/implement.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(String.prototype, 'contains', - { value: require('./shim'), configurable: true, enumerable: false, - writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/index.js deleted file mode 100644 index abb3e3730bf103..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? String.prototype.contains - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/is-implemented.js deleted file mode 100644 index 6f7d4b719e218e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var str = 'razdwatrzy'; - -module.exports = function () { - if (typeof str.contains !== 'function') return false; - return ((str.contains('dwa') === true) && (str.contains('foo') === false)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/shim.js deleted file mode 100644 index 89e39e793324b7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/contains/shim.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var indexOf = String.prototype.indexOf; - -module.exports = function (searchString/*, position*/) { - return indexOf.call(this, searchString, arguments[1]) > -1; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/implement.js deleted file mode 100644 index 0b09025b0cde8d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/implement.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(String.prototype, 'endsWith', - { value: require('./shim'), configurable: true, enumerable: false, - writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/index.js deleted file mode 100644 index d2d9484827957e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? String.prototype.endsWith - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/is-implemented.js deleted file mode 100644 index f3bb00883bb978..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var str = 'razdwatrzy'; - -module.exports = function () { - if (typeof str.endsWith !== 'function') return false; - return ((str.endsWith('trzy') === true) && (str.endsWith('raz') === false)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/shim.js deleted file mode 100644 index 26cbdb1366be10..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/ends-with/shim.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var toInteger = require('../../../number/to-integer') - , value = require('../../../object/valid-value') - - , min = Math.min, max = Math.max; - -module.exports = function (searchString/*, endPosition*/) { - var self, start, endPos; - self = String(value(this)); - searchString = String(searchString); - endPos = arguments[1]; - start = ((endPos == null) ? self.length : - min(max(toInteger(endPos), 0), self.length)) - searchString.length; - return (start < 0) ? false : (self.indexOf(searchString, start) === start); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/hyphen-to-camel.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/hyphen-to-camel.js deleted file mode 100644 index 8928b02497f1a2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/hyphen-to-camel.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var replace = String.prototype.replace - - , re = /-([a-z0-9])/g - , toUpperCase = function (m, a) { return a.toUpperCase(); }; - -module.exports = function () { return replace.call(this, re, toUpperCase); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/indent.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/indent.js deleted file mode 100644 index 223bd82b0f1a97..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/indent.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var repeat = require('./repeat') - - , replace = String.prototype.replace - , re = /(\r\n|[\n\r\u2028\u2029])([\u0000-\u0009\u000b-\uffff]+)/g; - -module.exports = function (indent/*, count*/) { - var count = arguments[1]; - indent = repeat.call(String(indent), (count == null) ? 1 : count); - return indent + replace.call(this, re, '$1' + indent + '$2'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/index.js deleted file mode 100644 index 3efa01c040b19c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/index.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -module.exports = { - '@@iterator': require('./@@iterator'), - at: require('./at'), - camelToHyphen: require('./camel-to-hyphen'), - capitalize: require('./capitalize'), - caseInsensitiveCompare: require('./case-insensitive-compare'), - codePointAt: require('./code-point-at'), - contains: require('./contains'), - hyphenToCamel: require('./hyphen-to-camel'), - endsWith: require('./ends-with'), - indent: require('./indent'), - last: require('./last'), - normalize: require('./normalize'), - pad: require('./pad'), - plainReplace: require('./plain-replace'), - plainReplaceAll: require('./plain-replace-all'), - repeat: require('./repeat'), - startsWith: require('./starts-with'), - uncapitalize: require('./uncapitalize') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/last.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/last.js deleted file mode 100644 index d5cf46ee5fb863..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/last.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var value = require('../../object/valid-value'); - -module.exports = function () { - var self = String(value(this)), l = self.length; - return l ? self[l - 1] : null; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/_data.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/_data.js deleted file mode 100644 index e4e00a3298120f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/_data.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -module.exports = { 0:{60:[,,{824:8814}],61:[,,{824:8800}],62:[,,{824:8815}],65:[,,{768:192,769:193,770:194,771:195,772:256,774:258,775:550,776:196,777:7842,778:197,780:461,783:512,785:514,803:7840,805:7680,808:260}],66:[,,{775:7682,803:7684,817:7686}],67:[,,{769:262,770:264,775:266,780:268,807:199}],68:[,,{775:7690,780:270,803:7692,807:7696,813:7698,817:7694}],69:[,,{768:200,769:201,770:202,771:7868,772:274,774:276,775:278,776:203,777:7866,780:282,783:516,785:518,803:7864,807:552,808:280,813:7704,816:7706}],70:[,,{775:7710}],71:[,,{769:500,770:284,772:7712,774:286,775:288,780:486,807:290}],72:[,,{770:292,775:7714,776:7718,780:542,803:7716,807:7720,814:7722}],73:[,,{768:204,769:205,770:206,771:296,772:298,774:300,775:304,776:207,777:7880,780:463,783:520,785:522,803:7882,808:302,816:7724}],74:[,,{770:308}],75:[,,{769:7728,780:488,803:7730,807:310,817:7732}],76:[,,{769:313,780:317,803:7734,807:315,813:7740,817:7738}],77:[,,{769:7742,775:7744,803:7746}],78:[,,{768:504,769:323,771:209,775:7748,780:327,803:7750,807:325,813:7754,817:7752}],79:[,,{768:210,769:211,770:212,771:213,772:332,774:334,775:558,776:214,777:7886,779:336,780:465,783:524,785:526,795:416,803:7884,808:490}],80:[,,{769:7764,775:7766}],82:[,,{769:340,775:7768,780:344,783:528,785:530,803:7770,807:342,817:7774}],83:[,,{769:346,770:348,775:7776,780:352,803:7778,806:536,807:350}],84:[,,{775:7786,780:356,803:7788,806:538,807:354,813:7792,817:7790}],85:[,,{768:217,769:218,770:219,771:360,772:362,774:364,776:220,777:7910,778:366,779:368,780:467,783:532,785:534,795:431,803:7908,804:7794,808:370,813:7798,816:7796}],86:[,,{771:7804,803:7806}],87:[,,{768:7808,769:7810,770:372,775:7814,776:7812,803:7816}],88:[,,{775:7818,776:7820}],89:[,,{768:7922,769:221,770:374,771:7928,772:562,775:7822,776:376,777:7926,803:7924}],90:[,,{769:377,770:7824,775:379,780:381,803:7826,817:7828}],97:[,,{768:224,769:225,770:226,771:227,772:257,774:259,775:551,776:228,777:7843,778:229,780:462,783:513,785:515,803:7841,805:7681,808:261}],98:[,,{775:7683,803:7685,817:7687}],99:[,,{769:263,770:265,775:267,780:269,807:231}],100:[,,{775:7691,780:271,803:7693,807:7697,813:7699,817:7695}],101:[,,{768:232,769:233,770:234,771:7869,772:275,774:277,775:279,776:235,777:7867,780:283,783:517,785:519,803:7865,807:553,808:281,813:7705,816:7707}],102:[,,{775:7711}],103:[,,{769:501,770:285,772:7713,774:287,775:289,780:487,807:291}],104:[,,{770:293,775:7715,776:7719,780:543,803:7717,807:7721,814:7723,817:7830}],105:[,,{768:236,769:237,770:238,771:297,772:299,774:301,776:239,777:7881,780:464,783:521,785:523,803:7883,808:303,816:7725}],106:[,,{770:309,780:496}],107:[,,{769:7729,780:489,803:7731,807:311,817:7733}],108:[,,{769:314,780:318,803:7735,807:316,813:7741,817:7739}],109:[,,{769:7743,775:7745,803:7747}],110:[,,{768:505,769:324,771:241,775:7749,780:328,803:7751,807:326,813:7755,817:7753}],111:[,,{768:242,769:243,770:244,771:245,772:333,774:335,775:559,776:246,777:7887,779:337,780:466,783:525,785:527,795:417,803:7885,808:491}],112:[,,{769:7765,775:7767}],114:[,,{769:341,775:7769,780:345,783:529,785:531,803:7771,807:343,817:7775}],115:[,,{769:347,770:349,775:7777,780:353,803:7779,806:537,807:351}],116:[,,{775:7787,776:7831,780:357,803:7789,806:539,807:355,813:7793,817:7791}],117:[,,{768:249,769:250,770:251,771:361,772:363,774:365,776:252,777:7911,778:367,779:369,780:468,783:533,785:535,795:432,803:7909,804:7795,808:371,813:7799,816:7797}],118:[,,{771:7805,803:7807}],119:[,,{768:7809,769:7811,770:373,775:7815,776:7813,778:7832,803:7817}],120:[,,{775:7819,776:7821}],121:[,,{768:7923,769:253,770:375,771:7929,772:563,775:7823,776:255,777:7927,778:7833,803:7925}],122:[,,{769:378,770:7825,775:380,780:382,803:7827,817:7829}],160:[[32],256],168:[[32,776],256,{768:8173,769:901,834:8129}],170:[[97],256],175:[[32,772],256],178:[[50],256],179:[[51],256],180:[[32,769],256],181:[[956],256],184:[[32,807],256],185:[[49],256],186:[[111],256],188:[[49,8260,52],256],189:[[49,8260,50],256],190:[[51,8260,52],256],192:[[65,768]],193:[[65,769]],194:[[65,770],,{768:7846,769:7844,771:7850,777:7848}],195:[[65,771]],196:[[65,776],,{772:478}],197:[[65,778],,{769:506}],198:[,,{769:508,772:482}],199:[[67,807],,{769:7688}],200:[[69,768]],201:[[69,769]],202:[[69,770],,{768:7872,769:7870,771:7876,777:7874}],203:[[69,776]],204:[[73,768]],205:[[73,769]],206:[[73,770]],207:[[73,776],,{769:7726}],209:[[78,771]],210:[[79,768]],211:[[79,769]],212:[[79,770],,{768:7890,769:7888,771:7894,777:7892}],213:[[79,771],,{769:7756,772:556,776:7758}],214:[[79,776],,{772:554}],216:[,,{769:510}],217:[[85,768]],218:[[85,769]],219:[[85,770]],220:[[85,776],,{768:475,769:471,772:469,780:473}],221:[[89,769]],224:[[97,768]],225:[[97,769]],226:[[97,770],,{768:7847,769:7845,771:7851,777:7849}],227:[[97,771]],228:[[97,776],,{772:479}],229:[[97,778],,{769:507}],230:[,,{769:509,772:483}],231:[[99,807],,{769:7689}],232:[[101,768]],233:[[101,769]],234:[[101,770],,{768:7873,769:7871,771:7877,777:7875}],235:[[101,776]],236:[[105,768]],237:[[105,769]],238:[[105,770]],239:[[105,776],,{769:7727}],241:[[110,771]],242:[[111,768]],243:[[111,769]],244:[[111,770],,{768:7891,769:7889,771:7895,777:7893}],245:[[111,771],,{769:7757,772:557,776:7759}],246:[[111,776],,{772:555}],248:[,,{769:511}],249:[[117,768]],250:[[117,769]],251:[[117,770]],252:[[117,776],,{768:476,769:472,772:470,780:474}],253:[[121,769]],255:[[121,776]]}, - 256:{256:[[65,772]],257:[[97,772]],258:[[65,774],,{768:7856,769:7854,771:7860,777:7858}],259:[[97,774],,{768:7857,769:7855,771:7861,777:7859}],260:[[65,808]],261:[[97,808]],262:[[67,769]],263:[[99,769]],264:[[67,770]],265:[[99,770]],266:[[67,775]],267:[[99,775]],268:[[67,780]],269:[[99,780]],270:[[68,780]],271:[[100,780]],274:[[69,772],,{768:7700,769:7702}],275:[[101,772],,{768:7701,769:7703}],276:[[69,774]],277:[[101,774]],278:[[69,775]],279:[[101,775]],280:[[69,808]],281:[[101,808]],282:[[69,780]],283:[[101,780]],284:[[71,770]],285:[[103,770]],286:[[71,774]],287:[[103,774]],288:[[71,775]],289:[[103,775]],290:[[71,807]],291:[[103,807]],292:[[72,770]],293:[[104,770]],296:[[73,771]],297:[[105,771]],298:[[73,772]],299:[[105,772]],300:[[73,774]],301:[[105,774]],302:[[73,808]],303:[[105,808]],304:[[73,775]],306:[[73,74],256],307:[[105,106],256],308:[[74,770]],309:[[106,770]],310:[[75,807]],311:[[107,807]],313:[[76,769]],314:[[108,769]],315:[[76,807]],316:[[108,807]],317:[[76,780]],318:[[108,780]],319:[[76,183],256],320:[[108,183],256],323:[[78,769]],324:[[110,769]],325:[[78,807]],326:[[110,807]],327:[[78,780]],328:[[110,780]],329:[[700,110],256],332:[[79,772],,{768:7760,769:7762}],333:[[111,772],,{768:7761,769:7763}],334:[[79,774]],335:[[111,774]],336:[[79,779]],337:[[111,779]],340:[[82,769]],341:[[114,769]],342:[[82,807]],343:[[114,807]],344:[[82,780]],345:[[114,780]],346:[[83,769],,{775:7780}],347:[[115,769],,{775:7781}],348:[[83,770]],349:[[115,770]],350:[[83,807]],351:[[115,807]],352:[[83,780],,{775:7782}],353:[[115,780],,{775:7783}],354:[[84,807]],355:[[116,807]],356:[[84,780]],357:[[116,780]],360:[[85,771],,{769:7800}],361:[[117,771],,{769:7801}],362:[[85,772],,{776:7802}],363:[[117,772],,{776:7803}],364:[[85,774]],365:[[117,774]],366:[[85,778]],367:[[117,778]],368:[[85,779]],369:[[117,779]],370:[[85,808]],371:[[117,808]],372:[[87,770]],373:[[119,770]],374:[[89,770]],375:[[121,770]],376:[[89,776]],377:[[90,769]],378:[[122,769]],379:[[90,775]],380:[[122,775]],381:[[90,780]],382:[[122,780]],383:[[115],256,{775:7835}],416:[[79,795],,{768:7900,769:7898,771:7904,777:7902,803:7906}],417:[[111,795],,{768:7901,769:7899,771:7905,777:7903,803:7907}],431:[[85,795],,{768:7914,769:7912,771:7918,777:7916,803:7920}],432:[[117,795],,{768:7915,769:7913,771:7919,777:7917,803:7921}],439:[,,{780:494}],452:[[68,381],256],453:[[68,382],256],454:[[100,382],256],455:[[76,74],256],456:[[76,106],256],457:[[108,106],256],458:[[78,74],256],459:[[78,106],256],460:[[110,106],256],461:[[65,780]],462:[[97,780]],463:[[73,780]],464:[[105,780]],465:[[79,780]],466:[[111,780]],467:[[85,780]],468:[[117,780]],469:[[220,772]],470:[[252,772]],471:[[220,769]],472:[[252,769]],473:[[220,780]],474:[[252,780]],475:[[220,768]],476:[[252,768]],478:[[196,772]],479:[[228,772]],480:[[550,772]],481:[[551,772]],482:[[198,772]],483:[[230,772]],486:[[71,780]],487:[[103,780]],488:[[75,780]],489:[[107,780]],490:[[79,808],,{772:492}],491:[[111,808],,{772:493}],492:[[490,772]],493:[[491,772]],494:[[439,780]],495:[[658,780]],496:[[106,780]],497:[[68,90],256],498:[[68,122],256],499:[[100,122],256],500:[[71,769]],501:[[103,769]],504:[[78,768]],505:[[110,768]],506:[[197,769]],507:[[229,769]],508:[[198,769]],509:[[230,769]],510:[[216,769]],511:[[248,769]],66045:[,220]}, - 512:{512:[[65,783]],513:[[97,783]],514:[[65,785]],515:[[97,785]],516:[[69,783]],517:[[101,783]],518:[[69,785]],519:[[101,785]],520:[[73,783]],521:[[105,783]],522:[[73,785]],523:[[105,785]],524:[[79,783]],525:[[111,783]],526:[[79,785]],527:[[111,785]],528:[[82,783]],529:[[114,783]],530:[[82,785]],531:[[114,785]],532:[[85,783]],533:[[117,783]],534:[[85,785]],535:[[117,785]],536:[[83,806]],537:[[115,806]],538:[[84,806]],539:[[116,806]],542:[[72,780]],543:[[104,780]],550:[[65,775],,{772:480}],551:[[97,775],,{772:481}],552:[[69,807],,{774:7708}],553:[[101,807],,{774:7709}],554:[[214,772]],555:[[246,772]],556:[[213,772]],557:[[245,772]],558:[[79,775],,{772:560}],559:[[111,775],,{772:561}],560:[[558,772]],561:[[559,772]],562:[[89,772]],563:[[121,772]],658:[,,{780:495}],688:[[104],256],689:[[614],256],690:[[106],256],691:[[114],256],692:[[633],256],693:[[635],256],694:[[641],256],695:[[119],256],696:[[121],256],728:[[32,774],256],729:[[32,775],256],730:[[32,778],256],731:[[32,808],256],732:[[32,771],256],733:[[32,779],256],736:[[611],256],737:[[108],256],738:[[115],256],739:[[120],256],740:[[661],256]}, - 768:{768:[,230],769:[,230],770:[,230],771:[,230],772:[,230],773:[,230],774:[,230],775:[,230],776:[,230,{769:836}],777:[,230],778:[,230],779:[,230],780:[,230],781:[,230],782:[,230],783:[,230],784:[,230],785:[,230],786:[,230],787:[,230],788:[,230],789:[,232],790:[,220],791:[,220],792:[,220],793:[,220],794:[,232],795:[,216],796:[,220],797:[,220],798:[,220],799:[,220],800:[,220],801:[,202],802:[,202],803:[,220],804:[,220],805:[,220],806:[,220],807:[,202],808:[,202],809:[,220],810:[,220],811:[,220],812:[,220],813:[,220],814:[,220],815:[,220],816:[,220],817:[,220],818:[,220],819:[,220],820:[,1],821:[,1],822:[,1],823:[,1],824:[,1],825:[,220],826:[,220],827:[,220],828:[,220],829:[,230],830:[,230],831:[,230],832:[[768],230],833:[[769],230],834:[,230],835:[[787],230],836:[[776,769],230],837:[,240],838:[,230],839:[,220],840:[,220],841:[,220],842:[,230],843:[,230],844:[,230],845:[,220],846:[,220],848:[,230],849:[,230],850:[,230],851:[,220],852:[,220],853:[,220],854:[,220],855:[,230],856:[,232],857:[,220],858:[,220],859:[,230],860:[,233],861:[,234],862:[,234],863:[,233],864:[,234],865:[,234],866:[,233],867:[,230],868:[,230],869:[,230],870:[,230],871:[,230],872:[,230],873:[,230],874:[,230],875:[,230],876:[,230],877:[,230],878:[,230],879:[,230],884:[[697]],890:[[32,837],256],894:[[59]],900:[[32,769],256],901:[[168,769]],902:[[913,769]],903:[[183]],904:[[917,769]],905:[[919,769]],906:[[921,769]],908:[[927,769]],910:[[933,769]],911:[[937,769]],912:[[970,769]],913:[,,{768:8122,769:902,772:8121,774:8120,787:7944,788:7945,837:8124}],917:[,,{768:8136,769:904,787:7960,788:7961}],919:[,,{768:8138,769:905,787:7976,788:7977,837:8140}],921:[,,{768:8154,769:906,772:8153,774:8152,776:938,787:7992,788:7993}],927:[,,{768:8184,769:908,787:8008,788:8009}],929:[,,{788:8172}],933:[,,{768:8170,769:910,772:8169,774:8168,776:939,788:8025}],937:[,,{768:8186,769:911,787:8040,788:8041,837:8188}],938:[[921,776]],939:[[933,776]],940:[[945,769],,{837:8116}],941:[[949,769]],942:[[951,769],,{837:8132}],943:[[953,769]],944:[[971,769]],945:[,,{768:8048,769:940,772:8113,774:8112,787:7936,788:7937,834:8118,837:8115}],949:[,,{768:8050,769:941,787:7952,788:7953}],951:[,,{768:8052,769:942,787:7968,788:7969,834:8134,837:8131}],953:[,,{768:8054,769:943,772:8145,774:8144,776:970,787:7984,788:7985,834:8150}],959:[,,{768:8056,769:972,787:8000,788:8001}],961:[,,{787:8164,788:8165}],965:[,,{768:8058,769:973,772:8161,774:8160,776:971,787:8016,788:8017,834:8166}],969:[,,{768:8060,769:974,787:8032,788:8033,834:8182,837:8179}],970:[[953,776],,{768:8146,769:912,834:8151}],971:[[965,776],,{768:8162,769:944,834:8167}],972:[[959,769]],973:[[965,769]],974:[[969,769],,{837:8180}],976:[[946],256],977:[[952],256],978:[[933],256,{769:979,776:980}],979:[[978,769]],980:[[978,776]],981:[[966],256],982:[[960],256],1008:[[954],256],1009:[[961],256],1010:[[962],256],1012:[[920],256],1013:[[949],256],1017:[[931],256]}, - 1024:{1024:[[1045,768]],1025:[[1045,776]],1027:[[1043,769]],1030:[,,{776:1031}],1031:[[1030,776]],1036:[[1050,769]],1037:[[1048,768]],1038:[[1059,774]],1040:[,,{774:1232,776:1234}],1043:[,,{769:1027}],1045:[,,{768:1024,774:1238,776:1025}],1046:[,,{774:1217,776:1244}],1047:[,,{776:1246}],1048:[,,{768:1037,772:1250,774:1049,776:1252}],1049:[[1048,774]],1050:[,,{769:1036}],1054:[,,{776:1254}],1059:[,,{772:1262,774:1038,776:1264,779:1266}],1063:[,,{776:1268}],1067:[,,{776:1272}],1069:[,,{776:1260}],1072:[,,{774:1233,776:1235}],1075:[,,{769:1107}],1077:[,,{768:1104,774:1239,776:1105}],1078:[,,{774:1218,776:1245}],1079:[,,{776:1247}],1080:[,,{768:1117,772:1251,774:1081,776:1253}],1081:[[1080,774]],1082:[,,{769:1116}],1086:[,,{776:1255}],1091:[,,{772:1263,774:1118,776:1265,779:1267}],1095:[,,{776:1269}],1099:[,,{776:1273}],1101:[,,{776:1261}],1104:[[1077,768]],1105:[[1077,776]],1107:[[1075,769]],1110:[,,{776:1111}],1111:[[1110,776]],1116:[[1082,769]],1117:[[1080,768]],1118:[[1091,774]],1140:[,,{783:1142}],1141:[,,{783:1143}],1142:[[1140,783]],1143:[[1141,783]],1155:[,230],1156:[,230],1157:[,230],1158:[,230],1159:[,230],1217:[[1046,774]],1218:[[1078,774]],1232:[[1040,774]],1233:[[1072,774]],1234:[[1040,776]],1235:[[1072,776]],1238:[[1045,774]],1239:[[1077,774]],1240:[,,{776:1242}],1241:[,,{776:1243}],1242:[[1240,776]],1243:[[1241,776]],1244:[[1046,776]],1245:[[1078,776]],1246:[[1047,776]],1247:[[1079,776]],1250:[[1048,772]],1251:[[1080,772]],1252:[[1048,776]],1253:[[1080,776]],1254:[[1054,776]],1255:[[1086,776]],1256:[,,{776:1258}],1257:[,,{776:1259}],1258:[[1256,776]],1259:[[1257,776]],1260:[[1069,776]],1261:[[1101,776]],1262:[[1059,772]],1263:[[1091,772]],1264:[[1059,776]],1265:[[1091,776]],1266:[[1059,779]],1267:[[1091,779]],1268:[[1063,776]],1269:[[1095,776]],1272:[[1067,776]],1273:[[1099,776]]}, - 1280:{1415:[[1381,1410],256],1425:[,220],1426:[,230],1427:[,230],1428:[,230],1429:[,230],1430:[,220],1431:[,230],1432:[,230],1433:[,230],1434:[,222],1435:[,220],1436:[,230],1437:[,230],1438:[,230],1439:[,230],1440:[,230],1441:[,230],1442:[,220],1443:[,220],1444:[,220],1445:[,220],1446:[,220],1447:[,220],1448:[,230],1449:[,230],1450:[,220],1451:[,230],1452:[,230],1453:[,222],1454:[,228],1455:[,230],1456:[,10],1457:[,11],1458:[,12],1459:[,13],1460:[,14],1461:[,15],1462:[,16],1463:[,17],1464:[,18],1465:[,19],1466:[,19],1467:[,20],1468:[,21],1469:[,22],1471:[,23],1473:[,24],1474:[,25],1476:[,230],1477:[,220],1479:[,18]}, - 1536:{1552:[,230],1553:[,230],1554:[,230],1555:[,230],1556:[,230],1557:[,230],1558:[,230],1559:[,230],1560:[,30],1561:[,31],1562:[,32],1570:[[1575,1619]],1571:[[1575,1620]],1572:[[1608,1620]],1573:[[1575,1621]],1574:[[1610,1620]],1575:[,,{1619:1570,1620:1571,1621:1573}],1608:[,,{1620:1572}],1610:[,,{1620:1574}],1611:[,27],1612:[,28],1613:[,29],1614:[,30],1615:[,31],1616:[,32],1617:[,33],1618:[,34],1619:[,230],1620:[,230],1621:[,220],1622:[,220],1623:[,230],1624:[,230],1625:[,230],1626:[,230],1627:[,230],1628:[,220],1629:[,230],1630:[,230],1631:[,220],1648:[,35],1653:[[1575,1652],256],1654:[[1608,1652],256],1655:[[1735,1652],256],1656:[[1610,1652],256],1728:[[1749,1620]],1729:[,,{1620:1730}],1730:[[1729,1620]],1746:[,,{1620:1747}],1747:[[1746,1620]],1749:[,,{1620:1728}],1750:[,230],1751:[,230],1752:[,230],1753:[,230],1754:[,230],1755:[,230],1756:[,230],1759:[,230],1760:[,230],1761:[,230],1762:[,230],1763:[,220],1764:[,230],1767:[,230],1768:[,230],1770:[,220],1771:[,230],1772:[,230],1773:[,220]}, - 1792:{1809:[,36],1840:[,230],1841:[,220],1842:[,230],1843:[,230],1844:[,220],1845:[,230],1846:[,230],1847:[,220],1848:[,220],1849:[,220],1850:[,230],1851:[,220],1852:[,220],1853:[,230],1854:[,220],1855:[,230],1856:[,230],1857:[,230],1858:[,220],1859:[,230],1860:[,220],1861:[,230],1862:[,220],1863:[,230],1864:[,220],1865:[,230],1866:[,230],2027:[,230],2028:[,230],2029:[,230],2030:[,230],2031:[,230],2032:[,230],2033:[,230],2034:[,220],2035:[,230]}, - 2048:{2070:[,230],2071:[,230],2072:[,230],2073:[,230],2075:[,230],2076:[,230],2077:[,230],2078:[,230],2079:[,230],2080:[,230],2081:[,230],2082:[,230],2083:[,230],2085:[,230],2086:[,230],2087:[,230],2089:[,230],2090:[,230],2091:[,230],2092:[,230],2093:[,230],2137:[,220],2138:[,220],2139:[,220],2276:[,230],2277:[,230],2278:[,220],2279:[,230],2280:[,230],2281:[,220],2282:[,230],2283:[,230],2284:[,230],2285:[,220],2286:[,220],2287:[,220],2288:[,27],2289:[,28],2290:[,29],2291:[,230],2292:[,230],2293:[,230],2294:[,220],2295:[,230],2296:[,230],2297:[,220],2298:[,220],2299:[,230],2300:[,230],2301:[,230],2302:[,230]}, - 2304:{2344:[,,{2364:2345}],2345:[[2344,2364]],2352:[,,{2364:2353}],2353:[[2352,2364]],2355:[,,{2364:2356}],2356:[[2355,2364]],2364:[,7],2381:[,9],2385:[,230],2386:[,220],2387:[,230],2388:[,230],2392:[[2325,2364],512],2393:[[2326,2364],512],2394:[[2327,2364],512],2395:[[2332,2364],512],2396:[[2337,2364],512],2397:[[2338,2364],512],2398:[[2347,2364],512],2399:[[2351,2364],512],2492:[,7],2503:[,,{2494:2507,2519:2508}],2507:[[2503,2494]],2508:[[2503,2519]],2509:[,9],2524:[[2465,2492],512],2525:[[2466,2492],512],2527:[[2479,2492],512]}, - 2560:{2611:[[2610,2620],512],2614:[[2616,2620],512],2620:[,7],2637:[,9],2649:[[2582,2620],512],2650:[[2583,2620],512],2651:[[2588,2620],512],2654:[[2603,2620],512],2748:[,7],2765:[,9],68109:[,220],68111:[,230],68152:[,230],68153:[,1],68154:[,220],68159:[,9]}, - 2816:{2876:[,7],2887:[,,{2878:2891,2902:2888,2903:2892}],2888:[[2887,2902]],2891:[[2887,2878]],2892:[[2887,2903]],2893:[,9],2908:[[2849,2876],512],2909:[[2850,2876],512],2962:[,,{3031:2964}],2964:[[2962,3031]],3014:[,,{3006:3018,3031:3020}],3015:[,,{3006:3019}],3018:[[3014,3006]],3019:[[3015,3006]],3020:[[3014,3031]],3021:[,9]}, - 3072:{3142:[,,{3158:3144}],3144:[[3142,3158]],3149:[,9],3157:[,84],3158:[,91],3260:[,7],3263:[,,{3285:3264}],3264:[[3263,3285]],3270:[,,{3266:3274,3285:3271,3286:3272}],3271:[[3270,3285]],3272:[[3270,3286]],3274:[[3270,3266],,{3285:3275}],3275:[[3274,3285]],3277:[,9]}, - 3328:{3398:[,,{3390:3402,3415:3404}],3399:[,,{3390:3403}],3402:[[3398,3390]],3403:[[3399,3390]],3404:[[3398,3415]],3405:[,9],3530:[,9],3545:[,,{3530:3546,3535:3548,3551:3550}],3546:[[3545,3530]],3548:[[3545,3535],,{3530:3549}],3549:[[3548,3530]],3550:[[3545,3551]]}, - 3584:{3635:[[3661,3634],256],3640:[,103],3641:[,103],3642:[,9],3656:[,107],3657:[,107],3658:[,107],3659:[,107],3763:[[3789,3762],256],3768:[,118],3769:[,118],3784:[,122],3785:[,122],3786:[,122],3787:[,122],3804:[[3755,3737],256],3805:[[3755,3745],256]}, - 3840:{3852:[[3851],256],3864:[,220],3865:[,220],3893:[,220],3895:[,220],3897:[,216],3907:[[3906,4023],512],3917:[[3916,4023],512],3922:[[3921,4023],512],3927:[[3926,4023],512],3932:[[3931,4023],512],3945:[[3904,4021],512],3953:[,129],3954:[,130],3955:[[3953,3954],512],3956:[,132],3957:[[3953,3956],512],3958:[[4018,3968],512],3959:[[4018,3969],256],3960:[[4019,3968],512],3961:[[4019,3969],256],3962:[,130],3963:[,130],3964:[,130],3965:[,130],3968:[,130],3969:[[3953,3968],512],3970:[,230],3971:[,230],3972:[,9],3974:[,230],3975:[,230],3987:[[3986,4023],512],3997:[[3996,4023],512],4002:[[4001,4023],512],4007:[[4006,4023],512],4012:[[4011,4023],512],4025:[[3984,4021],512],4038:[,220]}, - 4096:{4133:[,,{4142:4134}],4134:[[4133,4142]],4151:[,7],4153:[,9],4154:[,9],4237:[,220],4348:[[4316],256],69702:[,9],69785:[,,{69818:69786}],69786:[[69785,69818]],69787:[,,{69818:69788}],69788:[[69787,69818]],69797:[,,{69818:69803}],69803:[[69797,69818]],69817:[,9],69818:[,7]}, - 4352:{69888:[,230],69889:[,230],69890:[,230],69934:[[69937,69927]],69935:[[69938,69927]],69937:[,,{69927:69934}],69938:[,,{69927:69935}],69939:[,9],69940:[,9],70080:[,9]}, - 4864:{4957:[,230],4958:[,230],4959:[,230]}, - 5632:{71350:[,9],71351:[,7]}, - 5888:{5908:[,9],5940:[,9],6098:[,9],6109:[,230]}, - 6144:{6313:[,228]}, - 6400:{6457:[,222],6458:[,230],6459:[,220]}, - 6656:{6679:[,230],6680:[,220],6752:[,9],6773:[,230],6774:[,230],6775:[,230],6776:[,230],6777:[,230],6778:[,230],6779:[,230],6780:[,230],6783:[,220]}, - 6912:{6917:[,,{6965:6918}],6918:[[6917,6965]],6919:[,,{6965:6920}],6920:[[6919,6965]],6921:[,,{6965:6922}],6922:[[6921,6965]],6923:[,,{6965:6924}],6924:[[6923,6965]],6925:[,,{6965:6926}],6926:[[6925,6965]],6929:[,,{6965:6930}],6930:[[6929,6965]],6964:[,7],6970:[,,{6965:6971}],6971:[[6970,6965]],6972:[,,{6965:6973}],6973:[[6972,6965]],6974:[,,{6965:6976}],6975:[,,{6965:6977}],6976:[[6974,6965]],6977:[[6975,6965]],6978:[,,{6965:6979}],6979:[[6978,6965]],6980:[,9],7019:[,230],7020:[,220],7021:[,230],7022:[,230],7023:[,230],7024:[,230],7025:[,230],7026:[,230],7027:[,230],7082:[,9],7083:[,9],7142:[,7],7154:[,9],7155:[,9]}, - 7168:{7223:[,7],7376:[,230],7377:[,230],7378:[,230],7380:[,1],7381:[,220],7382:[,220],7383:[,220],7384:[,220],7385:[,220],7386:[,230],7387:[,230],7388:[,220],7389:[,220],7390:[,220],7391:[,220],7392:[,230],7394:[,1],7395:[,1],7396:[,1],7397:[,1],7398:[,1],7399:[,1],7400:[,1],7405:[,220],7412:[,230]}, - 7424:{7468:[[65],256],7469:[[198],256],7470:[[66],256],7472:[[68],256],7473:[[69],256],7474:[[398],256],7475:[[71],256],7476:[[72],256],7477:[[73],256],7478:[[74],256],7479:[[75],256],7480:[[76],256],7481:[[77],256],7482:[[78],256],7484:[[79],256],7485:[[546],256],7486:[[80],256],7487:[[82],256],7488:[[84],256],7489:[[85],256],7490:[[87],256],7491:[[97],256],7492:[[592],256],7493:[[593],256],7494:[[7426],256],7495:[[98],256],7496:[[100],256],7497:[[101],256],7498:[[601],256],7499:[[603],256],7500:[[604],256],7501:[[103],256],7503:[[107],256],7504:[[109],256],7505:[[331],256],7506:[[111],256],7507:[[596],256],7508:[[7446],256],7509:[[7447],256],7510:[[112],256],7511:[[116],256],7512:[[117],256],7513:[[7453],256],7514:[[623],256],7515:[[118],256],7516:[[7461],256],7517:[[946],256],7518:[[947],256],7519:[[948],256],7520:[[966],256],7521:[[967],256],7522:[[105],256],7523:[[114],256],7524:[[117],256],7525:[[118],256],7526:[[946],256],7527:[[947],256],7528:[[961],256],7529:[[966],256],7530:[[967],256],7544:[[1085],256],7579:[[594],256],7580:[[99],256],7581:[[597],256],7582:[[240],256],7583:[[604],256],7584:[[102],256],7585:[[607],256],7586:[[609],256],7587:[[613],256],7588:[[616],256],7589:[[617],256],7590:[[618],256],7591:[[7547],256],7592:[[669],256],7593:[[621],256],7594:[[7557],256],7595:[[671],256],7596:[[625],256],7597:[[624],256],7598:[[626],256],7599:[[627],256],7600:[[628],256],7601:[[629],256],7602:[[632],256],7603:[[642],256],7604:[[643],256],7605:[[427],256],7606:[[649],256],7607:[[650],256],7608:[[7452],256],7609:[[651],256],7610:[[652],256],7611:[[122],256],7612:[[656],256],7613:[[657],256],7614:[[658],256],7615:[[952],256],7616:[,230],7617:[,230],7618:[,220],7619:[,230],7620:[,230],7621:[,230],7622:[,230],7623:[,230],7624:[,230],7625:[,230],7626:[,220],7627:[,230],7628:[,230],7629:[,234],7630:[,214],7631:[,220],7632:[,202],7633:[,230],7634:[,230],7635:[,230],7636:[,230],7637:[,230],7638:[,230],7639:[,230],7640:[,230],7641:[,230],7642:[,230],7643:[,230],7644:[,230],7645:[,230],7646:[,230],7647:[,230],7648:[,230],7649:[,230],7650:[,230],7651:[,230],7652:[,230],7653:[,230],7654:[,230],7676:[,233],7677:[,220],7678:[,230],7679:[,220]}, - 7680:{7680:[[65,805]],7681:[[97,805]],7682:[[66,775]],7683:[[98,775]],7684:[[66,803]],7685:[[98,803]],7686:[[66,817]],7687:[[98,817]],7688:[[199,769]],7689:[[231,769]],7690:[[68,775]],7691:[[100,775]],7692:[[68,803]],7693:[[100,803]],7694:[[68,817]],7695:[[100,817]],7696:[[68,807]],7697:[[100,807]],7698:[[68,813]],7699:[[100,813]],7700:[[274,768]],7701:[[275,768]],7702:[[274,769]],7703:[[275,769]],7704:[[69,813]],7705:[[101,813]],7706:[[69,816]],7707:[[101,816]],7708:[[552,774]],7709:[[553,774]],7710:[[70,775]],7711:[[102,775]],7712:[[71,772]],7713:[[103,772]],7714:[[72,775]],7715:[[104,775]],7716:[[72,803]],7717:[[104,803]],7718:[[72,776]],7719:[[104,776]],7720:[[72,807]],7721:[[104,807]],7722:[[72,814]],7723:[[104,814]],7724:[[73,816]],7725:[[105,816]],7726:[[207,769]],7727:[[239,769]],7728:[[75,769]],7729:[[107,769]],7730:[[75,803]],7731:[[107,803]],7732:[[75,817]],7733:[[107,817]],7734:[[76,803],,{772:7736}],7735:[[108,803],,{772:7737}],7736:[[7734,772]],7737:[[7735,772]],7738:[[76,817]],7739:[[108,817]],7740:[[76,813]],7741:[[108,813]],7742:[[77,769]],7743:[[109,769]],7744:[[77,775]],7745:[[109,775]],7746:[[77,803]],7747:[[109,803]],7748:[[78,775]],7749:[[110,775]],7750:[[78,803]],7751:[[110,803]],7752:[[78,817]],7753:[[110,817]],7754:[[78,813]],7755:[[110,813]],7756:[[213,769]],7757:[[245,769]],7758:[[213,776]],7759:[[245,776]],7760:[[332,768]],7761:[[333,768]],7762:[[332,769]],7763:[[333,769]],7764:[[80,769]],7765:[[112,769]],7766:[[80,775]],7767:[[112,775]],7768:[[82,775]],7769:[[114,775]],7770:[[82,803],,{772:7772}],7771:[[114,803],,{772:7773}],7772:[[7770,772]],7773:[[7771,772]],7774:[[82,817]],7775:[[114,817]],7776:[[83,775]],7777:[[115,775]],7778:[[83,803],,{775:7784}],7779:[[115,803],,{775:7785}],7780:[[346,775]],7781:[[347,775]],7782:[[352,775]],7783:[[353,775]],7784:[[7778,775]],7785:[[7779,775]],7786:[[84,775]],7787:[[116,775]],7788:[[84,803]],7789:[[116,803]],7790:[[84,817]],7791:[[116,817]],7792:[[84,813]],7793:[[116,813]],7794:[[85,804]],7795:[[117,804]],7796:[[85,816]],7797:[[117,816]],7798:[[85,813]],7799:[[117,813]],7800:[[360,769]],7801:[[361,769]],7802:[[362,776]],7803:[[363,776]],7804:[[86,771]],7805:[[118,771]],7806:[[86,803]],7807:[[118,803]],7808:[[87,768]],7809:[[119,768]],7810:[[87,769]],7811:[[119,769]],7812:[[87,776]],7813:[[119,776]],7814:[[87,775]],7815:[[119,775]],7816:[[87,803]],7817:[[119,803]],7818:[[88,775]],7819:[[120,775]],7820:[[88,776]],7821:[[120,776]],7822:[[89,775]],7823:[[121,775]],7824:[[90,770]],7825:[[122,770]],7826:[[90,803]],7827:[[122,803]],7828:[[90,817]],7829:[[122,817]],7830:[[104,817]],7831:[[116,776]],7832:[[119,778]],7833:[[121,778]],7834:[[97,702],256],7835:[[383,775]],7840:[[65,803],,{770:7852,774:7862}],7841:[[97,803],,{770:7853,774:7863}],7842:[[65,777]],7843:[[97,777]],7844:[[194,769]],7845:[[226,769]],7846:[[194,768]],7847:[[226,768]],7848:[[194,777]],7849:[[226,777]],7850:[[194,771]],7851:[[226,771]],7852:[[7840,770]],7853:[[7841,770]],7854:[[258,769]],7855:[[259,769]],7856:[[258,768]],7857:[[259,768]],7858:[[258,777]],7859:[[259,777]],7860:[[258,771]],7861:[[259,771]],7862:[[7840,774]],7863:[[7841,774]],7864:[[69,803],,{770:7878}],7865:[[101,803],,{770:7879}],7866:[[69,777]],7867:[[101,777]],7868:[[69,771]],7869:[[101,771]],7870:[[202,769]],7871:[[234,769]],7872:[[202,768]],7873:[[234,768]],7874:[[202,777]],7875:[[234,777]],7876:[[202,771]],7877:[[234,771]],7878:[[7864,770]],7879:[[7865,770]],7880:[[73,777]],7881:[[105,777]],7882:[[73,803]],7883:[[105,803]],7884:[[79,803],,{770:7896}],7885:[[111,803],,{770:7897}],7886:[[79,777]],7887:[[111,777]],7888:[[212,769]],7889:[[244,769]],7890:[[212,768]],7891:[[244,768]],7892:[[212,777]],7893:[[244,777]],7894:[[212,771]],7895:[[244,771]],7896:[[7884,770]],7897:[[7885,770]],7898:[[416,769]],7899:[[417,769]],7900:[[416,768]],7901:[[417,768]],7902:[[416,777]],7903:[[417,777]],7904:[[416,771]],7905:[[417,771]],7906:[[416,803]],7907:[[417,803]],7908:[[85,803]],7909:[[117,803]],7910:[[85,777]],7911:[[117,777]],7912:[[431,769]],7913:[[432,769]],7914:[[431,768]],7915:[[432,768]],7916:[[431,777]],7917:[[432,777]],7918:[[431,771]],7919:[[432,771]],7920:[[431,803]],7921:[[432,803]],7922:[[89,768]],7923:[[121,768]],7924:[[89,803]],7925:[[121,803]],7926:[[89,777]],7927:[[121,777]],7928:[[89,771]],7929:[[121,771]]}, - 7936:{7936:[[945,787],,{768:7938,769:7940,834:7942,837:8064}],7937:[[945,788],,{768:7939,769:7941,834:7943,837:8065}],7938:[[7936,768],,{837:8066}],7939:[[7937,768],,{837:8067}],7940:[[7936,769],,{837:8068}],7941:[[7937,769],,{837:8069}],7942:[[7936,834],,{837:8070}],7943:[[7937,834],,{837:8071}],7944:[[913,787],,{768:7946,769:7948,834:7950,837:8072}],7945:[[913,788],,{768:7947,769:7949,834:7951,837:8073}],7946:[[7944,768],,{837:8074}],7947:[[7945,768],,{837:8075}],7948:[[7944,769],,{837:8076}],7949:[[7945,769],,{837:8077}],7950:[[7944,834],,{837:8078}],7951:[[7945,834],,{837:8079}],7952:[[949,787],,{768:7954,769:7956}],7953:[[949,788],,{768:7955,769:7957}],7954:[[7952,768]],7955:[[7953,768]],7956:[[7952,769]],7957:[[7953,769]],7960:[[917,787],,{768:7962,769:7964}],7961:[[917,788],,{768:7963,769:7965}],7962:[[7960,768]],7963:[[7961,768]],7964:[[7960,769]],7965:[[7961,769]],7968:[[951,787],,{768:7970,769:7972,834:7974,837:8080}],7969:[[951,788],,{768:7971,769:7973,834:7975,837:8081}],7970:[[7968,768],,{837:8082}],7971:[[7969,768],,{837:8083}],7972:[[7968,769],,{837:8084}],7973:[[7969,769],,{837:8085}],7974:[[7968,834],,{837:8086}],7975:[[7969,834],,{837:8087}],7976:[[919,787],,{768:7978,769:7980,834:7982,837:8088}],7977:[[919,788],,{768:7979,769:7981,834:7983,837:8089}],7978:[[7976,768],,{837:8090}],7979:[[7977,768],,{837:8091}],7980:[[7976,769],,{837:8092}],7981:[[7977,769],,{837:8093}],7982:[[7976,834],,{837:8094}],7983:[[7977,834],,{837:8095}],7984:[[953,787],,{768:7986,769:7988,834:7990}],7985:[[953,788],,{768:7987,769:7989,834:7991}],7986:[[7984,768]],7987:[[7985,768]],7988:[[7984,769]],7989:[[7985,769]],7990:[[7984,834]],7991:[[7985,834]],7992:[[921,787],,{768:7994,769:7996,834:7998}],7993:[[921,788],,{768:7995,769:7997,834:7999}],7994:[[7992,768]],7995:[[7993,768]],7996:[[7992,769]],7997:[[7993,769]],7998:[[7992,834]],7999:[[7993,834]],8000:[[959,787],,{768:8002,769:8004}],8001:[[959,788],,{768:8003,769:8005}],8002:[[8000,768]],8003:[[8001,768]],8004:[[8000,769]],8005:[[8001,769]],8008:[[927,787],,{768:8010,769:8012}],8009:[[927,788],,{768:8011,769:8013}],8010:[[8008,768]],8011:[[8009,768]],8012:[[8008,769]],8013:[[8009,769]],8016:[[965,787],,{768:8018,769:8020,834:8022}],8017:[[965,788],,{768:8019,769:8021,834:8023}],8018:[[8016,768]],8019:[[8017,768]],8020:[[8016,769]],8021:[[8017,769]],8022:[[8016,834]],8023:[[8017,834]],8025:[[933,788],,{768:8027,769:8029,834:8031}],8027:[[8025,768]],8029:[[8025,769]],8031:[[8025,834]],8032:[[969,787],,{768:8034,769:8036,834:8038,837:8096}],8033:[[969,788],,{768:8035,769:8037,834:8039,837:8097}],8034:[[8032,768],,{837:8098}],8035:[[8033,768],,{837:8099}],8036:[[8032,769],,{837:8100}],8037:[[8033,769],,{837:8101}],8038:[[8032,834],,{837:8102}],8039:[[8033,834],,{837:8103}],8040:[[937,787],,{768:8042,769:8044,834:8046,837:8104}],8041:[[937,788],,{768:8043,769:8045,834:8047,837:8105}],8042:[[8040,768],,{837:8106}],8043:[[8041,768],,{837:8107}],8044:[[8040,769],,{837:8108}],8045:[[8041,769],,{837:8109}],8046:[[8040,834],,{837:8110}],8047:[[8041,834],,{837:8111}],8048:[[945,768],,{837:8114}],8049:[[940]],8050:[[949,768]],8051:[[941]],8052:[[951,768],,{837:8130}],8053:[[942]],8054:[[953,768]],8055:[[943]],8056:[[959,768]],8057:[[972]],8058:[[965,768]],8059:[[973]],8060:[[969,768],,{837:8178}],8061:[[974]],8064:[[7936,837]],8065:[[7937,837]],8066:[[7938,837]],8067:[[7939,837]],8068:[[7940,837]],8069:[[7941,837]],8070:[[7942,837]],8071:[[7943,837]],8072:[[7944,837]],8073:[[7945,837]],8074:[[7946,837]],8075:[[7947,837]],8076:[[7948,837]],8077:[[7949,837]],8078:[[7950,837]],8079:[[7951,837]],8080:[[7968,837]],8081:[[7969,837]],8082:[[7970,837]],8083:[[7971,837]],8084:[[7972,837]],8085:[[7973,837]],8086:[[7974,837]],8087:[[7975,837]],8088:[[7976,837]],8089:[[7977,837]],8090:[[7978,837]],8091:[[7979,837]],8092:[[7980,837]],8093:[[7981,837]],8094:[[7982,837]],8095:[[7983,837]],8096:[[8032,837]],8097:[[8033,837]],8098:[[8034,837]],8099:[[8035,837]],8100:[[8036,837]],8101:[[8037,837]],8102:[[8038,837]],8103:[[8039,837]],8104:[[8040,837]],8105:[[8041,837]],8106:[[8042,837]],8107:[[8043,837]],8108:[[8044,837]],8109:[[8045,837]],8110:[[8046,837]],8111:[[8047,837]],8112:[[945,774]],8113:[[945,772]],8114:[[8048,837]],8115:[[945,837]],8116:[[940,837]],8118:[[945,834],,{837:8119}],8119:[[8118,837]],8120:[[913,774]],8121:[[913,772]],8122:[[913,768]],8123:[[902]],8124:[[913,837]],8125:[[32,787],256],8126:[[953]],8127:[[32,787],256,{768:8141,769:8142,834:8143}],8128:[[32,834],256],8129:[[168,834]],8130:[[8052,837]],8131:[[951,837]],8132:[[942,837]],8134:[[951,834],,{837:8135}],8135:[[8134,837]],8136:[[917,768]],8137:[[904]],8138:[[919,768]],8139:[[905]],8140:[[919,837]],8141:[[8127,768]],8142:[[8127,769]],8143:[[8127,834]],8144:[[953,774]],8145:[[953,772]],8146:[[970,768]],8147:[[912]],8150:[[953,834]],8151:[[970,834]],8152:[[921,774]],8153:[[921,772]],8154:[[921,768]],8155:[[906]],8157:[[8190,768]],8158:[[8190,769]],8159:[[8190,834]],8160:[[965,774]],8161:[[965,772]],8162:[[971,768]],8163:[[944]],8164:[[961,787]],8165:[[961,788]],8166:[[965,834]],8167:[[971,834]],8168:[[933,774]],8169:[[933,772]],8170:[[933,768]],8171:[[910]],8172:[[929,788]],8173:[[168,768]],8174:[[901]],8175:[[96]],8178:[[8060,837]],8179:[[969,837]],8180:[[974,837]],8182:[[969,834],,{837:8183}],8183:[[8182,837]],8184:[[927,768]],8185:[[908]],8186:[[937,768]],8187:[[911]],8188:[[937,837]],8189:[[180]],8190:[[32,788],256,{768:8157,769:8158,834:8159}]}, - 8192:{8192:[[8194]],8193:[[8195]],8194:[[32],256],8195:[[32],256],8196:[[32],256],8197:[[32],256],8198:[[32],256],8199:[[32],256],8200:[[32],256],8201:[[32],256],8202:[[32],256],8209:[[8208],256],8215:[[32,819],256],8228:[[46],256],8229:[[46,46],256],8230:[[46,46,46],256],8239:[[32],256],8243:[[8242,8242],256],8244:[[8242,8242,8242],256],8246:[[8245,8245],256],8247:[[8245,8245,8245],256],8252:[[33,33],256],8254:[[32,773],256],8263:[[63,63],256],8264:[[63,33],256],8265:[[33,63],256],8279:[[8242,8242,8242,8242],256],8287:[[32],256],8304:[[48],256],8305:[[105],256],8308:[[52],256],8309:[[53],256],8310:[[54],256],8311:[[55],256],8312:[[56],256],8313:[[57],256],8314:[[43],256],8315:[[8722],256],8316:[[61],256],8317:[[40],256],8318:[[41],256],8319:[[110],256],8320:[[48],256],8321:[[49],256],8322:[[50],256],8323:[[51],256],8324:[[52],256],8325:[[53],256],8326:[[54],256],8327:[[55],256],8328:[[56],256],8329:[[57],256],8330:[[43],256],8331:[[8722],256],8332:[[61],256],8333:[[40],256],8334:[[41],256],8336:[[97],256],8337:[[101],256],8338:[[111],256],8339:[[120],256],8340:[[601],256],8341:[[104],256],8342:[[107],256],8343:[[108],256],8344:[[109],256],8345:[[110],256],8346:[[112],256],8347:[[115],256],8348:[[116],256],8360:[[82,115],256],8400:[,230],8401:[,230],8402:[,1],8403:[,1],8404:[,230],8405:[,230],8406:[,230],8407:[,230],8408:[,1],8409:[,1],8410:[,1],8411:[,230],8412:[,230],8417:[,230],8421:[,1],8422:[,1],8423:[,230],8424:[,220],8425:[,230],8426:[,1],8427:[,1],8428:[,220],8429:[,220],8430:[,220],8431:[,220],8432:[,230]}, - 8448:{8448:[[97,47,99],256],8449:[[97,47,115],256],8450:[[67],256],8451:[[176,67],256],8453:[[99,47,111],256],8454:[[99,47,117],256],8455:[[400],256],8457:[[176,70],256],8458:[[103],256],8459:[[72],256],8460:[[72],256],8461:[[72],256],8462:[[104],256],8463:[[295],256],8464:[[73],256],8465:[[73],256],8466:[[76],256],8467:[[108],256],8469:[[78],256],8470:[[78,111],256],8473:[[80],256],8474:[[81],256],8475:[[82],256],8476:[[82],256],8477:[[82],256],8480:[[83,77],256],8481:[[84,69,76],256],8482:[[84,77],256],8484:[[90],256],8486:[[937]],8488:[[90],256],8490:[[75]],8491:[[197]],8492:[[66],256],8493:[[67],256],8495:[[101],256],8496:[[69],256],8497:[[70],256],8499:[[77],256],8500:[[111],256],8501:[[1488],256],8502:[[1489],256],8503:[[1490],256],8504:[[1491],256],8505:[[105],256],8507:[[70,65,88],256],8508:[[960],256],8509:[[947],256],8510:[[915],256],8511:[[928],256],8512:[[8721],256],8517:[[68],256],8518:[[100],256],8519:[[101],256],8520:[[105],256],8521:[[106],256],8528:[[49,8260,55],256],8529:[[49,8260,57],256],8530:[[49,8260,49,48],256],8531:[[49,8260,51],256],8532:[[50,8260,51],256],8533:[[49,8260,53],256],8534:[[50,8260,53],256],8535:[[51,8260,53],256],8536:[[52,8260,53],256],8537:[[49,8260,54],256],8538:[[53,8260,54],256],8539:[[49,8260,56],256],8540:[[51,8260,56],256],8541:[[53,8260,56],256],8542:[[55,8260,56],256],8543:[[49,8260],256],8544:[[73],256],8545:[[73,73],256],8546:[[73,73,73],256],8547:[[73,86],256],8548:[[86],256],8549:[[86,73],256],8550:[[86,73,73],256],8551:[[86,73,73,73],256],8552:[[73,88],256],8553:[[88],256],8554:[[88,73],256],8555:[[88,73,73],256],8556:[[76],256],8557:[[67],256],8558:[[68],256],8559:[[77],256],8560:[[105],256],8561:[[105,105],256],8562:[[105,105,105],256],8563:[[105,118],256],8564:[[118],256],8565:[[118,105],256],8566:[[118,105,105],256],8567:[[118,105,105,105],256],8568:[[105,120],256],8569:[[120],256],8570:[[120,105],256],8571:[[120,105,105],256],8572:[[108],256],8573:[[99],256],8574:[[100],256],8575:[[109],256],8585:[[48,8260,51],256],8592:[,,{824:8602}],8594:[,,{824:8603}],8596:[,,{824:8622}],8602:[[8592,824]],8603:[[8594,824]],8622:[[8596,824]],8653:[[8656,824]],8654:[[8660,824]],8655:[[8658,824]],8656:[,,{824:8653}],8658:[,,{824:8655}],8660:[,,{824:8654}]}, - 8704:{8707:[,,{824:8708}],8708:[[8707,824]],8712:[,,{824:8713}],8713:[[8712,824]],8715:[,,{824:8716}],8716:[[8715,824]],8739:[,,{824:8740}],8740:[[8739,824]],8741:[,,{824:8742}],8742:[[8741,824]],8748:[[8747,8747],256],8749:[[8747,8747,8747],256],8751:[[8750,8750],256],8752:[[8750,8750,8750],256],8764:[,,{824:8769}],8769:[[8764,824]],8771:[,,{824:8772}],8772:[[8771,824]],8773:[,,{824:8775}],8775:[[8773,824]],8776:[,,{824:8777}],8777:[[8776,824]],8781:[,,{824:8813}],8800:[[61,824]],8801:[,,{824:8802}],8802:[[8801,824]],8804:[,,{824:8816}],8805:[,,{824:8817}],8813:[[8781,824]],8814:[[60,824]],8815:[[62,824]],8816:[[8804,824]],8817:[[8805,824]],8818:[,,{824:8820}],8819:[,,{824:8821}],8820:[[8818,824]],8821:[[8819,824]],8822:[,,{824:8824}],8823:[,,{824:8825}],8824:[[8822,824]],8825:[[8823,824]],8826:[,,{824:8832}],8827:[,,{824:8833}],8828:[,,{824:8928}],8829:[,,{824:8929}],8832:[[8826,824]],8833:[[8827,824]],8834:[,,{824:8836}],8835:[,,{824:8837}],8836:[[8834,824]],8837:[[8835,824]],8838:[,,{824:8840}],8839:[,,{824:8841}],8840:[[8838,824]],8841:[[8839,824]],8849:[,,{824:8930}],8850:[,,{824:8931}],8866:[,,{824:8876}],8872:[,,{824:8877}],8873:[,,{824:8878}],8875:[,,{824:8879}],8876:[[8866,824]],8877:[[8872,824]],8878:[[8873,824]],8879:[[8875,824]],8882:[,,{824:8938}],8883:[,,{824:8939}],8884:[,,{824:8940}],8885:[,,{824:8941}],8928:[[8828,824]],8929:[[8829,824]],8930:[[8849,824]],8931:[[8850,824]],8938:[[8882,824]],8939:[[8883,824]],8940:[[8884,824]],8941:[[8885,824]]}, - 8960:{9001:[[12296]],9002:[[12297]]}, - 9216:{9312:[[49],256],9313:[[50],256],9314:[[51],256],9315:[[52],256],9316:[[53],256],9317:[[54],256],9318:[[55],256],9319:[[56],256],9320:[[57],256],9321:[[49,48],256],9322:[[49,49],256],9323:[[49,50],256],9324:[[49,51],256],9325:[[49,52],256],9326:[[49,53],256],9327:[[49,54],256],9328:[[49,55],256],9329:[[49,56],256],9330:[[49,57],256],9331:[[50,48],256],9332:[[40,49,41],256],9333:[[40,50,41],256],9334:[[40,51,41],256],9335:[[40,52,41],256],9336:[[40,53,41],256],9337:[[40,54,41],256],9338:[[40,55,41],256],9339:[[40,56,41],256],9340:[[40,57,41],256],9341:[[40,49,48,41],256],9342:[[40,49,49,41],256],9343:[[40,49,50,41],256],9344:[[40,49,51,41],256],9345:[[40,49,52,41],256],9346:[[40,49,53,41],256],9347:[[40,49,54,41],256],9348:[[40,49,55,41],256],9349:[[40,49,56,41],256],9350:[[40,49,57,41],256],9351:[[40,50,48,41],256],9352:[[49,46],256],9353:[[50,46],256],9354:[[51,46],256],9355:[[52,46],256],9356:[[53,46],256],9357:[[54,46],256],9358:[[55,46],256],9359:[[56,46],256],9360:[[57,46],256],9361:[[49,48,46],256],9362:[[49,49,46],256],9363:[[49,50,46],256],9364:[[49,51,46],256],9365:[[49,52,46],256],9366:[[49,53,46],256],9367:[[49,54,46],256],9368:[[49,55,46],256],9369:[[49,56,46],256],9370:[[49,57,46],256],9371:[[50,48,46],256],9372:[[40,97,41],256],9373:[[40,98,41],256],9374:[[40,99,41],256],9375:[[40,100,41],256],9376:[[40,101,41],256],9377:[[40,102,41],256],9378:[[40,103,41],256],9379:[[40,104,41],256],9380:[[40,105,41],256],9381:[[40,106,41],256],9382:[[40,107,41],256],9383:[[40,108,41],256],9384:[[40,109,41],256],9385:[[40,110,41],256],9386:[[40,111,41],256],9387:[[40,112,41],256],9388:[[40,113,41],256],9389:[[40,114,41],256],9390:[[40,115,41],256],9391:[[40,116,41],256],9392:[[40,117,41],256],9393:[[40,118,41],256],9394:[[40,119,41],256],9395:[[40,120,41],256],9396:[[40,121,41],256],9397:[[40,122,41],256],9398:[[65],256],9399:[[66],256],9400:[[67],256],9401:[[68],256],9402:[[69],256],9403:[[70],256],9404:[[71],256],9405:[[72],256],9406:[[73],256],9407:[[74],256],9408:[[75],256],9409:[[76],256],9410:[[77],256],9411:[[78],256],9412:[[79],256],9413:[[80],256],9414:[[81],256],9415:[[82],256],9416:[[83],256],9417:[[84],256],9418:[[85],256],9419:[[86],256],9420:[[87],256],9421:[[88],256],9422:[[89],256],9423:[[90],256],9424:[[97],256],9425:[[98],256],9426:[[99],256],9427:[[100],256],9428:[[101],256],9429:[[102],256],9430:[[103],256],9431:[[104],256],9432:[[105],256],9433:[[106],256],9434:[[107],256],9435:[[108],256],9436:[[109],256],9437:[[110],256],9438:[[111],256],9439:[[112],256],9440:[[113],256],9441:[[114],256],9442:[[115],256],9443:[[116],256],9444:[[117],256],9445:[[118],256],9446:[[119],256],9447:[[120],256],9448:[[121],256],9449:[[122],256],9450:[[48],256]}, - 10752:{10764:[[8747,8747,8747,8747],256],10868:[[58,58,61],256],10869:[[61,61],256],10870:[[61,61,61],256],10972:[[10973,824],512]}, - 11264:{11388:[[106],256],11389:[[86],256],11503:[,230],11504:[,230],11505:[,230]}, - 11520:{11631:[[11617],256],11647:[,9],11744:[,230],11745:[,230],11746:[,230],11747:[,230],11748:[,230],11749:[,230],11750:[,230],11751:[,230],11752:[,230],11753:[,230],11754:[,230],11755:[,230],11756:[,230],11757:[,230],11758:[,230],11759:[,230],11760:[,230],11761:[,230],11762:[,230],11763:[,230],11764:[,230],11765:[,230],11766:[,230],11767:[,230],11768:[,230],11769:[,230],11770:[,230],11771:[,230],11772:[,230],11773:[,230],11774:[,230],11775:[,230]}, - 11776:{11935:[[27597],256],12019:[[40863],256]}, - 12032:{12032:[[19968],256],12033:[[20008],256],12034:[[20022],256],12035:[[20031],256],12036:[[20057],256],12037:[[20101],256],12038:[[20108],256],12039:[[20128],256],12040:[[20154],256],12041:[[20799],256],12042:[[20837],256],12043:[[20843],256],12044:[[20866],256],12045:[[20886],256],12046:[[20907],256],12047:[[20960],256],12048:[[20981],256],12049:[[20992],256],12050:[[21147],256],12051:[[21241],256],12052:[[21269],256],12053:[[21274],256],12054:[[21304],256],12055:[[21313],256],12056:[[21340],256],12057:[[21353],256],12058:[[21378],256],12059:[[21430],256],12060:[[21448],256],12061:[[21475],256],12062:[[22231],256],12063:[[22303],256],12064:[[22763],256],12065:[[22786],256],12066:[[22794],256],12067:[[22805],256],12068:[[22823],256],12069:[[22899],256],12070:[[23376],256],12071:[[23424],256],12072:[[23544],256],12073:[[23567],256],12074:[[23586],256],12075:[[23608],256],12076:[[23662],256],12077:[[23665],256],12078:[[24027],256],12079:[[24037],256],12080:[[24049],256],12081:[[24062],256],12082:[[24178],256],12083:[[24186],256],12084:[[24191],256],12085:[[24308],256],12086:[[24318],256],12087:[[24331],256],12088:[[24339],256],12089:[[24400],256],12090:[[24417],256],12091:[[24435],256],12092:[[24515],256],12093:[[25096],256],12094:[[25142],256],12095:[[25163],256],12096:[[25903],256],12097:[[25908],256],12098:[[25991],256],12099:[[26007],256],12100:[[26020],256],12101:[[26041],256],12102:[[26080],256],12103:[[26085],256],12104:[[26352],256],12105:[[26376],256],12106:[[26408],256],12107:[[27424],256],12108:[[27490],256],12109:[[27513],256],12110:[[27571],256],12111:[[27595],256],12112:[[27604],256],12113:[[27611],256],12114:[[27663],256],12115:[[27668],256],12116:[[27700],256],12117:[[28779],256],12118:[[29226],256],12119:[[29238],256],12120:[[29243],256],12121:[[29247],256],12122:[[29255],256],12123:[[29273],256],12124:[[29275],256],12125:[[29356],256],12126:[[29572],256],12127:[[29577],256],12128:[[29916],256],12129:[[29926],256],12130:[[29976],256],12131:[[29983],256],12132:[[29992],256],12133:[[30000],256],12134:[[30091],256],12135:[[30098],256],12136:[[30326],256],12137:[[30333],256],12138:[[30382],256],12139:[[30399],256],12140:[[30446],256],12141:[[30683],256],12142:[[30690],256],12143:[[30707],256],12144:[[31034],256],12145:[[31160],256],12146:[[31166],256],12147:[[31348],256],12148:[[31435],256],12149:[[31481],256],12150:[[31859],256],12151:[[31992],256],12152:[[32566],256],12153:[[32593],256],12154:[[32650],256],12155:[[32701],256],12156:[[32769],256],12157:[[32780],256],12158:[[32786],256],12159:[[32819],256],12160:[[32895],256],12161:[[32905],256],12162:[[33251],256],12163:[[33258],256],12164:[[33267],256],12165:[[33276],256],12166:[[33292],256],12167:[[33307],256],12168:[[33311],256],12169:[[33390],256],12170:[[33394],256],12171:[[33400],256],12172:[[34381],256],12173:[[34411],256],12174:[[34880],256],12175:[[34892],256],12176:[[34915],256],12177:[[35198],256],12178:[[35211],256],12179:[[35282],256],12180:[[35328],256],12181:[[35895],256],12182:[[35910],256],12183:[[35925],256],12184:[[35960],256],12185:[[35997],256],12186:[[36196],256],12187:[[36208],256],12188:[[36275],256],12189:[[36523],256],12190:[[36554],256],12191:[[36763],256],12192:[[36784],256],12193:[[36789],256],12194:[[37009],256],12195:[[37193],256],12196:[[37318],256],12197:[[37324],256],12198:[[37329],256],12199:[[38263],256],12200:[[38272],256],12201:[[38428],256],12202:[[38582],256],12203:[[38585],256],12204:[[38632],256],12205:[[38737],256],12206:[[38750],256],12207:[[38754],256],12208:[[38761],256],12209:[[38859],256],12210:[[38893],256],12211:[[38899],256],12212:[[38913],256],12213:[[39080],256],12214:[[39131],256],12215:[[39135],256],12216:[[39318],256],12217:[[39321],256],12218:[[39340],256],12219:[[39592],256],12220:[[39640],256],12221:[[39647],256],12222:[[39717],256],12223:[[39727],256],12224:[[39730],256],12225:[[39740],256],12226:[[39770],256],12227:[[40165],256],12228:[[40565],256],12229:[[40575],256],12230:[[40613],256],12231:[[40635],256],12232:[[40643],256],12233:[[40653],256],12234:[[40657],256],12235:[[40697],256],12236:[[40701],256],12237:[[40718],256],12238:[[40723],256],12239:[[40736],256],12240:[[40763],256],12241:[[40778],256],12242:[[40786],256],12243:[[40845],256],12244:[[40860],256],12245:[[40864],256]}, - 12288:{12288:[[32],256],12330:[,218],12331:[,228],12332:[,232],12333:[,222],12334:[,224],12335:[,224],12342:[[12306],256],12344:[[21313],256],12345:[[21316],256],12346:[[21317],256],12358:[,,{12441:12436}],12363:[,,{12441:12364}],12364:[[12363,12441]],12365:[,,{12441:12366}],12366:[[12365,12441]],12367:[,,{12441:12368}],12368:[[12367,12441]],12369:[,,{12441:12370}],12370:[[12369,12441]],12371:[,,{12441:12372}],12372:[[12371,12441]],12373:[,,{12441:12374}],12374:[[12373,12441]],12375:[,,{12441:12376}],12376:[[12375,12441]],12377:[,,{12441:12378}],12378:[[12377,12441]],12379:[,,{12441:12380}],12380:[[12379,12441]],12381:[,,{12441:12382}],12382:[[12381,12441]],12383:[,,{12441:12384}],12384:[[12383,12441]],12385:[,,{12441:12386}],12386:[[12385,12441]],12388:[,,{12441:12389}],12389:[[12388,12441]],12390:[,,{12441:12391}],12391:[[12390,12441]],12392:[,,{12441:12393}],12393:[[12392,12441]],12399:[,,{12441:12400,12442:12401}],12400:[[12399,12441]],12401:[[12399,12442]],12402:[,,{12441:12403,12442:12404}],12403:[[12402,12441]],12404:[[12402,12442]],12405:[,,{12441:12406,12442:12407}],12406:[[12405,12441]],12407:[[12405,12442]],12408:[,,{12441:12409,12442:12410}],12409:[[12408,12441]],12410:[[12408,12442]],12411:[,,{12441:12412,12442:12413}],12412:[[12411,12441]],12413:[[12411,12442]],12436:[[12358,12441]],12441:[,8],12442:[,8],12443:[[32,12441],256],12444:[[32,12442],256],12445:[,,{12441:12446}],12446:[[12445,12441]],12447:[[12424,12426],256],12454:[,,{12441:12532}],12459:[,,{12441:12460}],12460:[[12459,12441]],12461:[,,{12441:12462}],12462:[[12461,12441]],12463:[,,{12441:12464}],12464:[[12463,12441]],12465:[,,{12441:12466}],12466:[[12465,12441]],12467:[,,{12441:12468}],12468:[[12467,12441]],12469:[,,{12441:12470}],12470:[[12469,12441]],12471:[,,{12441:12472}],12472:[[12471,12441]],12473:[,,{12441:12474}],12474:[[12473,12441]],12475:[,,{12441:12476}],12476:[[12475,12441]],12477:[,,{12441:12478}],12478:[[12477,12441]],12479:[,,{12441:12480}],12480:[[12479,12441]],12481:[,,{12441:12482}],12482:[[12481,12441]],12484:[,,{12441:12485}],12485:[[12484,12441]],12486:[,,{12441:12487}],12487:[[12486,12441]],12488:[,,{12441:12489}],12489:[[12488,12441]],12495:[,,{12441:12496,12442:12497}],12496:[[12495,12441]],12497:[[12495,12442]],12498:[,,{12441:12499,12442:12500}],12499:[[12498,12441]],12500:[[12498,12442]],12501:[,,{12441:12502,12442:12503}],12502:[[12501,12441]],12503:[[12501,12442]],12504:[,,{12441:12505,12442:12506}],12505:[[12504,12441]],12506:[[12504,12442]],12507:[,,{12441:12508,12442:12509}],12508:[[12507,12441]],12509:[[12507,12442]],12527:[,,{12441:12535}],12528:[,,{12441:12536}],12529:[,,{12441:12537}],12530:[,,{12441:12538}],12532:[[12454,12441]],12535:[[12527,12441]],12536:[[12528,12441]],12537:[[12529,12441]],12538:[[12530,12441]],12541:[,,{12441:12542}],12542:[[12541,12441]],12543:[[12467,12488],256]}, - 12544:{12593:[[4352],256],12594:[[4353],256],12595:[[4522],256],12596:[[4354],256],12597:[[4524],256],12598:[[4525],256],12599:[[4355],256],12600:[[4356],256],12601:[[4357],256],12602:[[4528],256],12603:[[4529],256],12604:[[4530],256],12605:[[4531],256],12606:[[4532],256],12607:[[4533],256],12608:[[4378],256],12609:[[4358],256],12610:[[4359],256],12611:[[4360],256],12612:[[4385],256],12613:[[4361],256],12614:[[4362],256],12615:[[4363],256],12616:[[4364],256],12617:[[4365],256],12618:[[4366],256],12619:[[4367],256],12620:[[4368],256],12621:[[4369],256],12622:[[4370],256],12623:[[4449],256],12624:[[4450],256],12625:[[4451],256],12626:[[4452],256],12627:[[4453],256],12628:[[4454],256],12629:[[4455],256],12630:[[4456],256],12631:[[4457],256],12632:[[4458],256],12633:[[4459],256],12634:[[4460],256],12635:[[4461],256],12636:[[4462],256],12637:[[4463],256],12638:[[4464],256],12639:[[4465],256],12640:[[4466],256],12641:[[4467],256],12642:[[4468],256],12643:[[4469],256],12644:[[4448],256],12645:[[4372],256],12646:[[4373],256],12647:[[4551],256],12648:[[4552],256],12649:[[4556],256],12650:[[4558],256],12651:[[4563],256],12652:[[4567],256],12653:[[4569],256],12654:[[4380],256],12655:[[4573],256],12656:[[4575],256],12657:[[4381],256],12658:[[4382],256],12659:[[4384],256],12660:[[4386],256],12661:[[4387],256],12662:[[4391],256],12663:[[4393],256],12664:[[4395],256],12665:[[4396],256],12666:[[4397],256],12667:[[4398],256],12668:[[4399],256],12669:[[4402],256],12670:[[4406],256],12671:[[4416],256],12672:[[4423],256],12673:[[4428],256],12674:[[4593],256],12675:[[4594],256],12676:[[4439],256],12677:[[4440],256],12678:[[4441],256],12679:[[4484],256],12680:[[4485],256],12681:[[4488],256],12682:[[4497],256],12683:[[4498],256],12684:[[4500],256],12685:[[4510],256],12686:[[4513],256],12690:[[19968],256],12691:[[20108],256],12692:[[19977],256],12693:[[22235],256],12694:[[19978],256],12695:[[20013],256],12696:[[19979],256],12697:[[30002],256],12698:[[20057],256],12699:[[19993],256],12700:[[19969],256],12701:[[22825],256],12702:[[22320],256],12703:[[20154],256]}, - 12800:{12800:[[40,4352,41],256],12801:[[40,4354,41],256],12802:[[40,4355,41],256],12803:[[40,4357,41],256],12804:[[40,4358,41],256],12805:[[40,4359,41],256],12806:[[40,4361,41],256],12807:[[40,4363,41],256],12808:[[40,4364,41],256],12809:[[40,4366,41],256],12810:[[40,4367,41],256],12811:[[40,4368,41],256],12812:[[40,4369,41],256],12813:[[40,4370,41],256],12814:[[40,4352,4449,41],256],12815:[[40,4354,4449,41],256],12816:[[40,4355,4449,41],256],12817:[[40,4357,4449,41],256],12818:[[40,4358,4449,41],256],12819:[[40,4359,4449,41],256],12820:[[40,4361,4449,41],256],12821:[[40,4363,4449,41],256],12822:[[40,4364,4449,41],256],12823:[[40,4366,4449,41],256],12824:[[40,4367,4449,41],256],12825:[[40,4368,4449,41],256],12826:[[40,4369,4449,41],256],12827:[[40,4370,4449,41],256],12828:[[40,4364,4462,41],256],12829:[[40,4363,4457,4364,4453,4523,41],256],12830:[[40,4363,4457,4370,4462,41],256],12832:[[40,19968,41],256],12833:[[40,20108,41],256],12834:[[40,19977,41],256],12835:[[40,22235,41],256],12836:[[40,20116,41],256],12837:[[40,20845,41],256],12838:[[40,19971,41],256],12839:[[40,20843,41],256],12840:[[40,20061,41],256],12841:[[40,21313,41],256],12842:[[40,26376,41],256],12843:[[40,28779,41],256],12844:[[40,27700,41],256],12845:[[40,26408,41],256],12846:[[40,37329,41],256],12847:[[40,22303,41],256],12848:[[40,26085,41],256],12849:[[40,26666,41],256],12850:[[40,26377,41],256],12851:[[40,31038,41],256],12852:[[40,21517,41],256],12853:[[40,29305,41],256],12854:[[40,36001,41],256],12855:[[40,31069,41],256],12856:[[40,21172,41],256],12857:[[40,20195,41],256],12858:[[40,21628,41],256],12859:[[40,23398,41],256],12860:[[40,30435,41],256],12861:[[40,20225,41],256],12862:[[40,36039,41],256],12863:[[40,21332,41],256],12864:[[40,31085,41],256],12865:[[40,20241,41],256],12866:[[40,33258,41],256],12867:[[40,33267,41],256],12868:[[21839],256],12869:[[24188],256],12870:[[25991],256],12871:[[31631],256],12880:[[80,84,69],256],12881:[[50,49],256],12882:[[50,50],256],12883:[[50,51],256],12884:[[50,52],256],12885:[[50,53],256],12886:[[50,54],256],12887:[[50,55],256],12888:[[50,56],256],12889:[[50,57],256],12890:[[51,48],256],12891:[[51,49],256],12892:[[51,50],256],12893:[[51,51],256],12894:[[51,52],256],12895:[[51,53],256],12896:[[4352],256],12897:[[4354],256],12898:[[4355],256],12899:[[4357],256],12900:[[4358],256],12901:[[4359],256],12902:[[4361],256],12903:[[4363],256],12904:[[4364],256],12905:[[4366],256],12906:[[4367],256],12907:[[4368],256],12908:[[4369],256],12909:[[4370],256],12910:[[4352,4449],256],12911:[[4354,4449],256],12912:[[4355,4449],256],12913:[[4357,4449],256],12914:[[4358,4449],256],12915:[[4359,4449],256],12916:[[4361,4449],256],12917:[[4363,4449],256],12918:[[4364,4449],256],12919:[[4366,4449],256],12920:[[4367,4449],256],12921:[[4368,4449],256],12922:[[4369,4449],256],12923:[[4370,4449],256],12924:[[4366,4449,4535,4352,4457],256],12925:[[4364,4462,4363,4468],256],12926:[[4363,4462],256],12928:[[19968],256],12929:[[20108],256],12930:[[19977],256],12931:[[22235],256],12932:[[20116],256],12933:[[20845],256],12934:[[19971],256],12935:[[20843],256],12936:[[20061],256],12937:[[21313],256],12938:[[26376],256],12939:[[28779],256],12940:[[27700],256],12941:[[26408],256],12942:[[37329],256],12943:[[22303],256],12944:[[26085],256],12945:[[26666],256],12946:[[26377],256],12947:[[31038],256],12948:[[21517],256],12949:[[29305],256],12950:[[36001],256],12951:[[31069],256],12952:[[21172],256],12953:[[31192],256],12954:[[30007],256],12955:[[22899],256],12956:[[36969],256],12957:[[20778],256],12958:[[21360],256],12959:[[27880],256],12960:[[38917],256],12961:[[20241],256],12962:[[20889],256],12963:[[27491],256],12964:[[19978],256],12965:[[20013],256],12966:[[19979],256],12967:[[24038],256],12968:[[21491],256],12969:[[21307],256],12970:[[23447],256],12971:[[23398],256],12972:[[30435],256],12973:[[20225],256],12974:[[36039],256],12975:[[21332],256],12976:[[22812],256],12977:[[51,54],256],12978:[[51,55],256],12979:[[51,56],256],12980:[[51,57],256],12981:[[52,48],256],12982:[[52,49],256],12983:[[52,50],256],12984:[[52,51],256],12985:[[52,52],256],12986:[[52,53],256],12987:[[52,54],256],12988:[[52,55],256],12989:[[52,56],256],12990:[[52,57],256],12991:[[53,48],256],12992:[[49,26376],256],12993:[[50,26376],256],12994:[[51,26376],256],12995:[[52,26376],256],12996:[[53,26376],256],12997:[[54,26376],256],12998:[[55,26376],256],12999:[[56,26376],256],13000:[[57,26376],256],13001:[[49,48,26376],256],13002:[[49,49,26376],256],13003:[[49,50,26376],256],13004:[[72,103],256],13005:[[101,114,103],256],13006:[[101,86],256],13007:[[76,84,68],256],13008:[[12450],256],13009:[[12452],256],13010:[[12454],256],13011:[[12456],256],13012:[[12458],256],13013:[[12459],256],13014:[[12461],256],13015:[[12463],256],13016:[[12465],256],13017:[[12467],256],13018:[[12469],256],13019:[[12471],256],13020:[[12473],256],13021:[[12475],256],13022:[[12477],256],13023:[[12479],256],13024:[[12481],256],13025:[[12484],256],13026:[[12486],256],13027:[[12488],256],13028:[[12490],256],13029:[[12491],256],13030:[[12492],256],13031:[[12493],256],13032:[[12494],256],13033:[[12495],256],13034:[[12498],256],13035:[[12501],256],13036:[[12504],256],13037:[[12507],256],13038:[[12510],256],13039:[[12511],256],13040:[[12512],256],13041:[[12513],256],13042:[[12514],256],13043:[[12516],256],13044:[[12518],256],13045:[[12520],256],13046:[[12521],256],13047:[[12522],256],13048:[[12523],256],13049:[[12524],256],13050:[[12525],256],13051:[[12527],256],13052:[[12528],256],13053:[[12529],256],13054:[[12530],256]}, - 13056:{13056:[[12450,12497,12540,12488],256],13057:[[12450,12523,12501,12449],256],13058:[[12450,12531,12506,12450],256],13059:[[12450,12540,12523],256],13060:[[12452,12491,12531,12464],256],13061:[[12452,12531,12481],256],13062:[[12454,12457,12531],256],13063:[[12456,12473,12463,12540,12489],256],13064:[[12456,12540,12459,12540],256],13065:[[12458,12531,12473],256],13066:[[12458,12540,12512],256],13067:[[12459,12452,12522],256],13068:[[12459,12521,12483,12488],256],13069:[[12459,12525,12522,12540],256],13070:[[12460,12525,12531],256],13071:[[12460,12531,12510],256],13072:[[12462,12460],256],13073:[[12462,12491,12540],256],13074:[[12461,12517,12522,12540],256],13075:[[12462,12523,12480,12540],256],13076:[[12461,12525],256],13077:[[12461,12525,12464,12521,12512],256],13078:[[12461,12525,12513,12540,12488,12523],256],13079:[[12461,12525,12527,12483,12488],256],13080:[[12464,12521,12512],256],13081:[[12464,12521,12512,12488,12531],256],13082:[[12463,12523,12476,12452,12525],256],13083:[[12463,12525,12540,12493],256],13084:[[12465,12540,12473],256],13085:[[12467,12523,12490],256],13086:[[12467,12540,12509],256],13087:[[12469,12452,12463,12523],256],13088:[[12469,12531,12481,12540,12512],256],13089:[[12471,12522,12531,12464],256],13090:[[12475,12531,12481],256],13091:[[12475,12531,12488],256],13092:[[12480,12540,12473],256],13093:[[12487,12471],256],13094:[[12489,12523],256],13095:[[12488,12531],256],13096:[[12490,12494],256],13097:[[12494,12483,12488],256],13098:[[12495,12452,12484],256],13099:[[12497,12540,12475,12531,12488],256],13100:[[12497,12540,12484],256],13101:[[12496,12540,12524,12523],256],13102:[[12500,12450,12473,12488,12523],256],13103:[[12500,12463,12523],256],13104:[[12500,12467],256],13105:[[12499,12523],256],13106:[[12501,12449,12521,12483,12489],256],13107:[[12501,12451,12540,12488],256],13108:[[12502,12483,12471,12455,12523],256],13109:[[12501,12521,12531],256],13110:[[12504,12463,12479,12540,12523],256],13111:[[12506,12477],256],13112:[[12506,12491,12498],256],13113:[[12504,12523,12484],256],13114:[[12506,12531,12473],256],13115:[[12506,12540,12472],256],13116:[[12505,12540,12479],256],13117:[[12509,12452,12531,12488],256],13118:[[12508,12523,12488],256],13119:[[12507,12531],256],13120:[[12509,12531,12489],256],13121:[[12507,12540,12523],256],13122:[[12507,12540,12531],256],13123:[[12510,12452,12463,12525],256],13124:[[12510,12452,12523],256],13125:[[12510,12483,12495],256],13126:[[12510,12523,12463],256],13127:[[12510,12531,12471,12519,12531],256],13128:[[12511,12463,12525,12531],256],13129:[[12511,12522],256],13130:[[12511,12522,12496,12540,12523],256],13131:[[12513,12460],256],13132:[[12513,12460,12488,12531],256],13133:[[12513,12540,12488,12523],256],13134:[[12516,12540,12489],256],13135:[[12516,12540,12523],256],13136:[[12518,12450,12531],256],13137:[[12522,12483,12488,12523],256],13138:[[12522,12521],256],13139:[[12523,12500,12540],256],13140:[[12523,12540,12502,12523],256],13141:[[12524,12512],256],13142:[[12524,12531,12488,12466,12531],256],13143:[[12527,12483,12488],256],13144:[[48,28857],256],13145:[[49,28857],256],13146:[[50,28857],256],13147:[[51,28857],256],13148:[[52,28857],256],13149:[[53,28857],256],13150:[[54,28857],256],13151:[[55,28857],256],13152:[[56,28857],256],13153:[[57,28857],256],13154:[[49,48,28857],256],13155:[[49,49,28857],256],13156:[[49,50,28857],256],13157:[[49,51,28857],256],13158:[[49,52,28857],256],13159:[[49,53,28857],256],13160:[[49,54,28857],256],13161:[[49,55,28857],256],13162:[[49,56,28857],256],13163:[[49,57,28857],256],13164:[[50,48,28857],256],13165:[[50,49,28857],256],13166:[[50,50,28857],256],13167:[[50,51,28857],256],13168:[[50,52,28857],256],13169:[[104,80,97],256],13170:[[100,97],256],13171:[[65,85],256],13172:[[98,97,114],256],13173:[[111,86],256],13174:[[112,99],256],13175:[[100,109],256],13176:[[100,109,178],256],13177:[[100,109,179],256],13178:[[73,85],256],13179:[[24179,25104],256],13180:[[26157,21644],256],13181:[[22823,27491],256],13182:[[26126,27835],256],13183:[[26666,24335,20250,31038],256],13184:[[112,65],256],13185:[[110,65],256],13186:[[956,65],256],13187:[[109,65],256],13188:[[107,65],256],13189:[[75,66],256],13190:[[77,66],256],13191:[[71,66],256],13192:[[99,97,108],256],13193:[[107,99,97,108],256],13194:[[112,70],256],13195:[[110,70],256],13196:[[956,70],256],13197:[[956,103],256],13198:[[109,103],256],13199:[[107,103],256],13200:[[72,122],256],13201:[[107,72,122],256],13202:[[77,72,122],256],13203:[[71,72,122],256],13204:[[84,72,122],256],13205:[[956,8467],256],13206:[[109,8467],256],13207:[[100,8467],256],13208:[[107,8467],256],13209:[[102,109],256],13210:[[110,109],256],13211:[[956,109],256],13212:[[109,109],256],13213:[[99,109],256],13214:[[107,109],256],13215:[[109,109,178],256],13216:[[99,109,178],256],13217:[[109,178],256],13218:[[107,109,178],256],13219:[[109,109,179],256],13220:[[99,109,179],256],13221:[[109,179],256],13222:[[107,109,179],256],13223:[[109,8725,115],256],13224:[[109,8725,115,178],256],13225:[[80,97],256],13226:[[107,80,97],256],13227:[[77,80,97],256],13228:[[71,80,97],256],13229:[[114,97,100],256],13230:[[114,97,100,8725,115],256],13231:[[114,97,100,8725,115,178],256],13232:[[112,115],256],13233:[[110,115],256],13234:[[956,115],256],13235:[[109,115],256],13236:[[112,86],256],13237:[[110,86],256],13238:[[956,86],256],13239:[[109,86],256],13240:[[107,86],256],13241:[[77,86],256],13242:[[112,87],256],13243:[[110,87],256],13244:[[956,87],256],13245:[[109,87],256],13246:[[107,87],256],13247:[[77,87],256],13248:[[107,937],256],13249:[[77,937],256],13250:[[97,46,109,46],256],13251:[[66,113],256],13252:[[99,99],256],13253:[[99,100],256],13254:[[67,8725,107,103],256],13255:[[67,111,46],256],13256:[[100,66],256],13257:[[71,121],256],13258:[[104,97],256],13259:[[72,80],256],13260:[[105,110],256],13261:[[75,75],256],13262:[[75,77],256],13263:[[107,116],256],13264:[[108,109],256],13265:[[108,110],256],13266:[[108,111,103],256],13267:[[108,120],256],13268:[[109,98],256],13269:[[109,105,108],256],13270:[[109,111,108],256],13271:[[80,72],256],13272:[[112,46,109,46],256],13273:[[80,80,77],256],13274:[[80,82],256],13275:[[115,114],256],13276:[[83,118],256],13277:[[87,98],256],13278:[[86,8725,109],256],13279:[[65,8725,109],256],13280:[[49,26085],256],13281:[[50,26085],256],13282:[[51,26085],256],13283:[[52,26085],256],13284:[[53,26085],256],13285:[[54,26085],256],13286:[[55,26085],256],13287:[[56,26085],256],13288:[[57,26085],256],13289:[[49,48,26085],256],13290:[[49,49,26085],256],13291:[[49,50,26085],256],13292:[[49,51,26085],256],13293:[[49,52,26085],256],13294:[[49,53,26085],256],13295:[[49,54,26085],256],13296:[[49,55,26085],256],13297:[[49,56,26085],256],13298:[[49,57,26085],256],13299:[[50,48,26085],256],13300:[[50,49,26085],256],13301:[[50,50,26085],256],13302:[[50,51,26085],256],13303:[[50,52,26085],256],13304:[[50,53,26085],256],13305:[[50,54,26085],256],13306:[[50,55,26085],256],13307:[[50,56,26085],256],13308:[[50,57,26085],256],13309:[[51,48,26085],256],13310:[[51,49,26085],256],13311:[[103,97,108],256]}, - 42496:{42607:[,230],42612:[,230],42613:[,230],42614:[,230],42615:[,230],42616:[,230],42617:[,230],42618:[,230],42619:[,230],42620:[,230],42621:[,230],42655:[,230],42736:[,230],42737:[,230]}, - 42752:{42864:[[42863],256],43000:[[294],256],43001:[[339],256]}, - 43008:{43014:[,9],43204:[,9],43232:[,230],43233:[,230],43234:[,230],43235:[,230],43236:[,230],43237:[,230],43238:[,230],43239:[,230],43240:[,230],43241:[,230],43242:[,230],43243:[,230],43244:[,230],43245:[,230],43246:[,230],43247:[,230],43248:[,230],43249:[,230]}, - 43264:{43307:[,220],43308:[,220],43309:[,220],43347:[,9],43443:[,7],43456:[,9]}, - 43520:{43696:[,230],43698:[,230],43699:[,230],43700:[,220],43703:[,230],43704:[,230],43710:[,230],43711:[,230],43713:[,230],43766:[,9]}, - 43776:{44013:[,9]}, - 53504:{119134:[[119127,119141],512],119135:[[119128,119141],512],119136:[[119135,119150],512],119137:[[119135,119151],512],119138:[[119135,119152],512],119139:[[119135,119153],512],119140:[[119135,119154],512],119141:[,216],119142:[,216],119143:[,1],119144:[,1],119145:[,1],119149:[,226],119150:[,216],119151:[,216],119152:[,216],119153:[,216],119154:[,216],119163:[,220],119164:[,220],119165:[,220],119166:[,220],119167:[,220],119168:[,220],119169:[,220],119170:[,220],119173:[,230],119174:[,230],119175:[,230],119176:[,230],119177:[,230],119178:[,220],119179:[,220],119210:[,230],119211:[,230],119212:[,230],119213:[,230],119227:[[119225,119141],512],119228:[[119226,119141],512],119229:[[119227,119150],512],119230:[[119228,119150],512],119231:[[119227,119151],512],119232:[[119228,119151],512]}, - 53760:{119362:[,230],119363:[,230],119364:[,230]}, - 54272:{119808:[[65],256],119809:[[66],256],119810:[[67],256],119811:[[68],256],119812:[[69],256],119813:[[70],256],119814:[[71],256],119815:[[72],256],119816:[[73],256],119817:[[74],256],119818:[[75],256],119819:[[76],256],119820:[[77],256],119821:[[78],256],119822:[[79],256],119823:[[80],256],119824:[[81],256],119825:[[82],256],119826:[[83],256],119827:[[84],256],119828:[[85],256],119829:[[86],256],119830:[[87],256],119831:[[88],256],119832:[[89],256],119833:[[90],256],119834:[[97],256],119835:[[98],256],119836:[[99],256],119837:[[100],256],119838:[[101],256],119839:[[102],256],119840:[[103],256],119841:[[104],256],119842:[[105],256],119843:[[106],256],119844:[[107],256],119845:[[108],256],119846:[[109],256],119847:[[110],256],119848:[[111],256],119849:[[112],256],119850:[[113],256],119851:[[114],256],119852:[[115],256],119853:[[116],256],119854:[[117],256],119855:[[118],256],119856:[[119],256],119857:[[120],256],119858:[[121],256],119859:[[122],256],119860:[[65],256],119861:[[66],256],119862:[[67],256],119863:[[68],256],119864:[[69],256],119865:[[70],256],119866:[[71],256],119867:[[72],256],119868:[[73],256],119869:[[74],256],119870:[[75],256],119871:[[76],256],119872:[[77],256],119873:[[78],256],119874:[[79],256],119875:[[80],256],119876:[[81],256],119877:[[82],256],119878:[[83],256],119879:[[84],256],119880:[[85],256],119881:[[86],256],119882:[[87],256],119883:[[88],256],119884:[[89],256],119885:[[90],256],119886:[[97],256],119887:[[98],256],119888:[[99],256],119889:[[100],256],119890:[[101],256],119891:[[102],256],119892:[[103],256],119894:[[105],256],119895:[[106],256],119896:[[107],256],119897:[[108],256],119898:[[109],256],119899:[[110],256],119900:[[111],256],119901:[[112],256],119902:[[113],256],119903:[[114],256],119904:[[115],256],119905:[[116],256],119906:[[117],256],119907:[[118],256],119908:[[119],256],119909:[[120],256],119910:[[121],256],119911:[[122],256],119912:[[65],256],119913:[[66],256],119914:[[67],256],119915:[[68],256],119916:[[69],256],119917:[[70],256],119918:[[71],256],119919:[[72],256],119920:[[73],256],119921:[[74],256],119922:[[75],256],119923:[[76],256],119924:[[77],256],119925:[[78],256],119926:[[79],256],119927:[[80],256],119928:[[81],256],119929:[[82],256],119930:[[83],256],119931:[[84],256],119932:[[85],256],119933:[[86],256],119934:[[87],256],119935:[[88],256],119936:[[89],256],119937:[[90],256],119938:[[97],256],119939:[[98],256],119940:[[99],256],119941:[[100],256],119942:[[101],256],119943:[[102],256],119944:[[103],256],119945:[[104],256],119946:[[105],256],119947:[[106],256],119948:[[107],256],119949:[[108],256],119950:[[109],256],119951:[[110],256],119952:[[111],256],119953:[[112],256],119954:[[113],256],119955:[[114],256],119956:[[115],256],119957:[[116],256],119958:[[117],256],119959:[[118],256],119960:[[119],256],119961:[[120],256],119962:[[121],256],119963:[[122],256],119964:[[65],256],119966:[[67],256],119967:[[68],256],119970:[[71],256],119973:[[74],256],119974:[[75],256],119977:[[78],256],119978:[[79],256],119979:[[80],256],119980:[[81],256],119982:[[83],256],119983:[[84],256],119984:[[85],256],119985:[[86],256],119986:[[87],256],119987:[[88],256],119988:[[89],256],119989:[[90],256],119990:[[97],256],119991:[[98],256],119992:[[99],256],119993:[[100],256],119995:[[102],256],119997:[[104],256],119998:[[105],256],119999:[[106],256],120000:[[107],256],120001:[[108],256],120002:[[109],256],120003:[[110],256],120005:[[112],256],120006:[[113],256],120007:[[114],256],120008:[[115],256],120009:[[116],256],120010:[[117],256],120011:[[118],256],120012:[[119],256],120013:[[120],256],120014:[[121],256],120015:[[122],256],120016:[[65],256],120017:[[66],256],120018:[[67],256],120019:[[68],256],120020:[[69],256],120021:[[70],256],120022:[[71],256],120023:[[72],256],120024:[[73],256],120025:[[74],256],120026:[[75],256],120027:[[76],256],120028:[[77],256],120029:[[78],256],120030:[[79],256],120031:[[80],256],120032:[[81],256],120033:[[82],256],120034:[[83],256],120035:[[84],256],120036:[[85],256],120037:[[86],256],120038:[[87],256],120039:[[88],256],120040:[[89],256],120041:[[90],256],120042:[[97],256],120043:[[98],256],120044:[[99],256],120045:[[100],256],120046:[[101],256],120047:[[102],256],120048:[[103],256],120049:[[104],256],120050:[[105],256],120051:[[106],256],120052:[[107],256],120053:[[108],256],120054:[[109],256],120055:[[110],256],120056:[[111],256],120057:[[112],256],120058:[[113],256],120059:[[114],256],120060:[[115],256],120061:[[116],256],120062:[[117],256],120063:[[118],256]}, - 54528:{120064:[[119],256],120065:[[120],256],120066:[[121],256],120067:[[122],256],120068:[[65],256],120069:[[66],256],120071:[[68],256],120072:[[69],256],120073:[[70],256],120074:[[71],256],120077:[[74],256],120078:[[75],256],120079:[[76],256],120080:[[77],256],120081:[[78],256],120082:[[79],256],120083:[[80],256],120084:[[81],256],120086:[[83],256],120087:[[84],256],120088:[[85],256],120089:[[86],256],120090:[[87],256],120091:[[88],256],120092:[[89],256],120094:[[97],256],120095:[[98],256],120096:[[99],256],120097:[[100],256],120098:[[101],256],120099:[[102],256],120100:[[103],256],120101:[[104],256],120102:[[105],256],120103:[[106],256],120104:[[107],256],120105:[[108],256],120106:[[109],256],120107:[[110],256],120108:[[111],256],120109:[[112],256],120110:[[113],256],120111:[[114],256],120112:[[115],256],120113:[[116],256],120114:[[117],256],120115:[[118],256],120116:[[119],256],120117:[[120],256],120118:[[121],256],120119:[[122],256],120120:[[65],256],120121:[[66],256],120123:[[68],256],120124:[[69],256],120125:[[70],256],120126:[[71],256],120128:[[73],256],120129:[[74],256],120130:[[75],256],120131:[[76],256],120132:[[77],256],120134:[[79],256],120138:[[83],256],120139:[[84],256],120140:[[85],256],120141:[[86],256],120142:[[87],256],120143:[[88],256],120144:[[89],256],120146:[[97],256],120147:[[98],256],120148:[[99],256],120149:[[100],256],120150:[[101],256],120151:[[102],256],120152:[[103],256],120153:[[104],256],120154:[[105],256],120155:[[106],256],120156:[[107],256],120157:[[108],256],120158:[[109],256],120159:[[110],256],120160:[[111],256],120161:[[112],256],120162:[[113],256],120163:[[114],256],120164:[[115],256],120165:[[116],256],120166:[[117],256],120167:[[118],256],120168:[[119],256],120169:[[120],256],120170:[[121],256],120171:[[122],256],120172:[[65],256],120173:[[66],256],120174:[[67],256],120175:[[68],256],120176:[[69],256],120177:[[70],256],120178:[[71],256],120179:[[72],256],120180:[[73],256],120181:[[74],256],120182:[[75],256],120183:[[76],256],120184:[[77],256],120185:[[78],256],120186:[[79],256],120187:[[80],256],120188:[[81],256],120189:[[82],256],120190:[[83],256],120191:[[84],256],120192:[[85],256],120193:[[86],256],120194:[[87],256],120195:[[88],256],120196:[[89],256],120197:[[90],256],120198:[[97],256],120199:[[98],256],120200:[[99],256],120201:[[100],256],120202:[[101],256],120203:[[102],256],120204:[[103],256],120205:[[104],256],120206:[[105],256],120207:[[106],256],120208:[[107],256],120209:[[108],256],120210:[[109],256],120211:[[110],256],120212:[[111],256],120213:[[112],256],120214:[[113],256],120215:[[114],256],120216:[[115],256],120217:[[116],256],120218:[[117],256],120219:[[118],256],120220:[[119],256],120221:[[120],256],120222:[[121],256],120223:[[122],256],120224:[[65],256],120225:[[66],256],120226:[[67],256],120227:[[68],256],120228:[[69],256],120229:[[70],256],120230:[[71],256],120231:[[72],256],120232:[[73],256],120233:[[74],256],120234:[[75],256],120235:[[76],256],120236:[[77],256],120237:[[78],256],120238:[[79],256],120239:[[80],256],120240:[[81],256],120241:[[82],256],120242:[[83],256],120243:[[84],256],120244:[[85],256],120245:[[86],256],120246:[[87],256],120247:[[88],256],120248:[[89],256],120249:[[90],256],120250:[[97],256],120251:[[98],256],120252:[[99],256],120253:[[100],256],120254:[[101],256],120255:[[102],256],120256:[[103],256],120257:[[104],256],120258:[[105],256],120259:[[106],256],120260:[[107],256],120261:[[108],256],120262:[[109],256],120263:[[110],256],120264:[[111],256],120265:[[112],256],120266:[[113],256],120267:[[114],256],120268:[[115],256],120269:[[116],256],120270:[[117],256],120271:[[118],256],120272:[[119],256],120273:[[120],256],120274:[[121],256],120275:[[122],256],120276:[[65],256],120277:[[66],256],120278:[[67],256],120279:[[68],256],120280:[[69],256],120281:[[70],256],120282:[[71],256],120283:[[72],256],120284:[[73],256],120285:[[74],256],120286:[[75],256],120287:[[76],256],120288:[[77],256],120289:[[78],256],120290:[[79],256],120291:[[80],256],120292:[[81],256],120293:[[82],256],120294:[[83],256],120295:[[84],256],120296:[[85],256],120297:[[86],256],120298:[[87],256],120299:[[88],256],120300:[[89],256],120301:[[90],256],120302:[[97],256],120303:[[98],256],120304:[[99],256],120305:[[100],256],120306:[[101],256],120307:[[102],256],120308:[[103],256],120309:[[104],256],120310:[[105],256],120311:[[106],256],120312:[[107],256],120313:[[108],256],120314:[[109],256],120315:[[110],256],120316:[[111],256],120317:[[112],256],120318:[[113],256],120319:[[114],256]}, - 54784:{120320:[[115],256],120321:[[116],256],120322:[[117],256],120323:[[118],256],120324:[[119],256],120325:[[120],256],120326:[[121],256],120327:[[122],256],120328:[[65],256],120329:[[66],256],120330:[[67],256],120331:[[68],256],120332:[[69],256],120333:[[70],256],120334:[[71],256],120335:[[72],256],120336:[[73],256],120337:[[74],256],120338:[[75],256],120339:[[76],256],120340:[[77],256],120341:[[78],256],120342:[[79],256],120343:[[80],256],120344:[[81],256],120345:[[82],256],120346:[[83],256],120347:[[84],256],120348:[[85],256],120349:[[86],256],120350:[[87],256],120351:[[88],256],120352:[[89],256],120353:[[90],256],120354:[[97],256],120355:[[98],256],120356:[[99],256],120357:[[100],256],120358:[[101],256],120359:[[102],256],120360:[[103],256],120361:[[104],256],120362:[[105],256],120363:[[106],256],120364:[[107],256],120365:[[108],256],120366:[[109],256],120367:[[110],256],120368:[[111],256],120369:[[112],256],120370:[[113],256],120371:[[114],256],120372:[[115],256],120373:[[116],256],120374:[[117],256],120375:[[118],256],120376:[[119],256],120377:[[120],256],120378:[[121],256],120379:[[122],256],120380:[[65],256],120381:[[66],256],120382:[[67],256],120383:[[68],256],120384:[[69],256],120385:[[70],256],120386:[[71],256],120387:[[72],256],120388:[[73],256],120389:[[74],256],120390:[[75],256],120391:[[76],256],120392:[[77],256],120393:[[78],256],120394:[[79],256],120395:[[80],256],120396:[[81],256],120397:[[82],256],120398:[[83],256],120399:[[84],256],120400:[[85],256],120401:[[86],256],120402:[[87],256],120403:[[88],256],120404:[[89],256],120405:[[90],256],120406:[[97],256],120407:[[98],256],120408:[[99],256],120409:[[100],256],120410:[[101],256],120411:[[102],256],120412:[[103],256],120413:[[104],256],120414:[[105],256],120415:[[106],256],120416:[[107],256],120417:[[108],256],120418:[[109],256],120419:[[110],256],120420:[[111],256],120421:[[112],256],120422:[[113],256],120423:[[114],256],120424:[[115],256],120425:[[116],256],120426:[[117],256],120427:[[118],256],120428:[[119],256],120429:[[120],256],120430:[[121],256],120431:[[122],256],120432:[[65],256],120433:[[66],256],120434:[[67],256],120435:[[68],256],120436:[[69],256],120437:[[70],256],120438:[[71],256],120439:[[72],256],120440:[[73],256],120441:[[74],256],120442:[[75],256],120443:[[76],256],120444:[[77],256],120445:[[78],256],120446:[[79],256],120447:[[80],256],120448:[[81],256],120449:[[82],256],120450:[[83],256],120451:[[84],256],120452:[[85],256],120453:[[86],256],120454:[[87],256],120455:[[88],256],120456:[[89],256],120457:[[90],256],120458:[[97],256],120459:[[98],256],120460:[[99],256],120461:[[100],256],120462:[[101],256],120463:[[102],256],120464:[[103],256],120465:[[104],256],120466:[[105],256],120467:[[106],256],120468:[[107],256],120469:[[108],256],120470:[[109],256],120471:[[110],256],120472:[[111],256],120473:[[112],256],120474:[[113],256],120475:[[114],256],120476:[[115],256],120477:[[116],256],120478:[[117],256],120479:[[118],256],120480:[[119],256],120481:[[120],256],120482:[[121],256],120483:[[122],256],120484:[[305],256],120485:[[567],256],120488:[[913],256],120489:[[914],256],120490:[[915],256],120491:[[916],256],120492:[[917],256],120493:[[918],256],120494:[[919],256],120495:[[920],256],120496:[[921],256],120497:[[922],256],120498:[[923],256],120499:[[924],256],120500:[[925],256],120501:[[926],256],120502:[[927],256],120503:[[928],256],120504:[[929],256],120505:[[1012],256],120506:[[931],256],120507:[[932],256],120508:[[933],256],120509:[[934],256],120510:[[935],256],120511:[[936],256],120512:[[937],256],120513:[[8711],256],120514:[[945],256],120515:[[946],256],120516:[[947],256],120517:[[948],256],120518:[[949],256],120519:[[950],256],120520:[[951],256],120521:[[952],256],120522:[[953],256],120523:[[954],256],120524:[[955],256],120525:[[956],256],120526:[[957],256],120527:[[958],256],120528:[[959],256],120529:[[960],256],120530:[[961],256],120531:[[962],256],120532:[[963],256],120533:[[964],256],120534:[[965],256],120535:[[966],256],120536:[[967],256],120537:[[968],256],120538:[[969],256],120539:[[8706],256],120540:[[1013],256],120541:[[977],256],120542:[[1008],256],120543:[[981],256],120544:[[1009],256],120545:[[982],256],120546:[[913],256],120547:[[914],256],120548:[[915],256],120549:[[916],256],120550:[[917],256],120551:[[918],256],120552:[[919],256],120553:[[920],256],120554:[[921],256],120555:[[922],256],120556:[[923],256],120557:[[924],256],120558:[[925],256],120559:[[926],256],120560:[[927],256],120561:[[928],256],120562:[[929],256],120563:[[1012],256],120564:[[931],256],120565:[[932],256],120566:[[933],256],120567:[[934],256],120568:[[935],256],120569:[[936],256],120570:[[937],256],120571:[[8711],256],120572:[[945],256],120573:[[946],256],120574:[[947],256],120575:[[948],256]}, - 55040:{120576:[[949],256],120577:[[950],256],120578:[[951],256],120579:[[952],256],120580:[[953],256],120581:[[954],256],120582:[[955],256],120583:[[956],256],120584:[[957],256],120585:[[958],256],120586:[[959],256],120587:[[960],256],120588:[[961],256],120589:[[962],256],120590:[[963],256],120591:[[964],256],120592:[[965],256],120593:[[966],256],120594:[[967],256],120595:[[968],256],120596:[[969],256],120597:[[8706],256],120598:[[1013],256],120599:[[977],256],120600:[[1008],256],120601:[[981],256],120602:[[1009],256],120603:[[982],256],120604:[[913],256],120605:[[914],256],120606:[[915],256],120607:[[916],256],120608:[[917],256],120609:[[918],256],120610:[[919],256],120611:[[920],256],120612:[[921],256],120613:[[922],256],120614:[[923],256],120615:[[924],256],120616:[[925],256],120617:[[926],256],120618:[[927],256],120619:[[928],256],120620:[[929],256],120621:[[1012],256],120622:[[931],256],120623:[[932],256],120624:[[933],256],120625:[[934],256],120626:[[935],256],120627:[[936],256],120628:[[937],256],120629:[[8711],256],120630:[[945],256],120631:[[946],256],120632:[[947],256],120633:[[948],256],120634:[[949],256],120635:[[950],256],120636:[[951],256],120637:[[952],256],120638:[[953],256],120639:[[954],256],120640:[[955],256],120641:[[956],256],120642:[[957],256],120643:[[958],256],120644:[[959],256],120645:[[960],256],120646:[[961],256],120647:[[962],256],120648:[[963],256],120649:[[964],256],120650:[[965],256],120651:[[966],256],120652:[[967],256],120653:[[968],256],120654:[[969],256],120655:[[8706],256],120656:[[1013],256],120657:[[977],256],120658:[[1008],256],120659:[[981],256],120660:[[1009],256],120661:[[982],256],120662:[[913],256],120663:[[914],256],120664:[[915],256],120665:[[916],256],120666:[[917],256],120667:[[918],256],120668:[[919],256],120669:[[920],256],120670:[[921],256],120671:[[922],256],120672:[[923],256],120673:[[924],256],120674:[[925],256],120675:[[926],256],120676:[[927],256],120677:[[928],256],120678:[[929],256],120679:[[1012],256],120680:[[931],256],120681:[[932],256],120682:[[933],256],120683:[[934],256],120684:[[935],256],120685:[[936],256],120686:[[937],256],120687:[[8711],256],120688:[[945],256],120689:[[946],256],120690:[[947],256],120691:[[948],256],120692:[[949],256],120693:[[950],256],120694:[[951],256],120695:[[952],256],120696:[[953],256],120697:[[954],256],120698:[[955],256],120699:[[956],256],120700:[[957],256],120701:[[958],256],120702:[[959],256],120703:[[960],256],120704:[[961],256],120705:[[962],256],120706:[[963],256],120707:[[964],256],120708:[[965],256],120709:[[966],256],120710:[[967],256],120711:[[968],256],120712:[[969],256],120713:[[8706],256],120714:[[1013],256],120715:[[977],256],120716:[[1008],256],120717:[[981],256],120718:[[1009],256],120719:[[982],256],120720:[[913],256],120721:[[914],256],120722:[[915],256],120723:[[916],256],120724:[[917],256],120725:[[918],256],120726:[[919],256],120727:[[920],256],120728:[[921],256],120729:[[922],256],120730:[[923],256],120731:[[924],256],120732:[[925],256],120733:[[926],256],120734:[[927],256],120735:[[928],256],120736:[[929],256],120737:[[1012],256],120738:[[931],256],120739:[[932],256],120740:[[933],256],120741:[[934],256],120742:[[935],256],120743:[[936],256],120744:[[937],256],120745:[[8711],256],120746:[[945],256],120747:[[946],256],120748:[[947],256],120749:[[948],256],120750:[[949],256],120751:[[950],256],120752:[[951],256],120753:[[952],256],120754:[[953],256],120755:[[954],256],120756:[[955],256],120757:[[956],256],120758:[[957],256],120759:[[958],256],120760:[[959],256],120761:[[960],256],120762:[[961],256],120763:[[962],256],120764:[[963],256],120765:[[964],256],120766:[[965],256],120767:[[966],256],120768:[[967],256],120769:[[968],256],120770:[[969],256],120771:[[8706],256],120772:[[1013],256],120773:[[977],256],120774:[[1008],256],120775:[[981],256],120776:[[1009],256],120777:[[982],256],120778:[[988],256],120779:[[989],256],120782:[[48],256],120783:[[49],256],120784:[[50],256],120785:[[51],256],120786:[[52],256],120787:[[53],256],120788:[[54],256],120789:[[55],256],120790:[[56],256],120791:[[57],256],120792:[[48],256],120793:[[49],256],120794:[[50],256],120795:[[51],256],120796:[[52],256],120797:[[53],256],120798:[[54],256],120799:[[55],256],120800:[[56],256],120801:[[57],256],120802:[[48],256],120803:[[49],256],120804:[[50],256],120805:[[51],256],120806:[[52],256],120807:[[53],256],120808:[[54],256],120809:[[55],256],120810:[[56],256],120811:[[57],256],120812:[[48],256],120813:[[49],256],120814:[[50],256],120815:[[51],256],120816:[[52],256],120817:[[53],256],120818:[[54],256],120819:[[55],256],120820:[[56],256],120821:[[57],256],120822:[[48],256],120823:[[49],256],120824:[[50],256],120825:[[51],256],120826:[[52],256],120827:[[53],256],120828:[[54],256],120829:[[55],256],120830:[[56],256],120831:[[57],256]}, - 60928:{126464:[[1575],256],126465:[[1576],256],126466:[[1580],256],126467:[[1583],256],126469:[[1608],256],126470:[[1586],256],126471:[[1581],256],126472:[[1591],256],126473:[[1610],256],126474:[[1603],256],126475:[[1604],256],126476:[[1605],256],126477:[[1606],256],126478:[[1587],256],126479:[[1593],256],126480:[[1601],256],126481:[[1589],256],126482:[[1602],256],126483:[[1585],256],126484:[[1588],256],126485:[[1578],256],126486:[[1579],256],126487:[[1582],256],126488:[[1584],256],126489:[[1590],256],126490:[[1592],256],126491:[[1594],256],126492:[[1646],256],126493:[[1722],256],126494:[[1697],256],126495:[[1647],256],126497:[[1576],256],126498:[[1580],256],126500:[[1607],256],126503:[[1581],256],126505:[[1610],256],126506:[[1603],256],126507:[[1604],256],126508:[[1605],256],126509:[[1606],256],126510:[[1587],256],126511:[[1593],256],126512:[[1601],256],126513:[[1589],256],126514:[[1602],256],126516:[[1588],256],126517:[[1578],256],126518:[[1579],256],126519:[[1582],256],126521:[[1590],256],126523:[[1594],256],126530:[[1580],256],126535:[[1581],256],126537:[[1610],256],126539:[[1604],256],126541:[[1606],256],126542:[[1587],256],126543:[[1593],256],126545:[[1589],256],126546:[[1602],256],126548:[[1588],256],126551:[[1582],256],126553:[[1590],256],126555:[[1594],256],126557:[[1722],256],126559:[[1647],256],126561:[[1576],256],126562:[[1580],256],126564:[[1607],256],126567:[[1581],256],126568:[[1591],256],126569:[[1610],256],126570:[[1603],256],126572:[[1605],256],126573:[[1606],256],126574:[[1587],256],126575:[[1593],256],126576:[[1601],256],126577:[[1589],256],126578:[[1602],256],126580:[[1588],256],126581:[[1578],256],126582:[[1579],256],126583:[[1582],256],126585:[[1590],256],126586:[[1592],256],126587:[[1594],256],126588:[[1646],256],126590:[[1697],256],126592:[[1575],256],126593:[[1576],256],126594:[[1580],256],126595:[[1583],256],126596:[[1607],256],126597:[[1608],256],126598:[[1586],256],126599:[[1581],256],126600:[[1591],256],126601:[[1610],256],126603:[[1604],256],126604:[[1605],256],126605:[[1606],256],126606:[[1587],256],126607:[[1593],256],126608:[[1601],256],126609:[[1589],256],126610:[[1602],256],126611:[[1585],256],126612:[[1588],256],126613:[[1578],256],126614:[[1579],256],126615:[[1582],256],126616:[[1584],256],126617:[[1590],256],126618:[[1592],256],126619:[[1594],256],126625:[[1576],256],126626:[[1580],256],126627:[[1583],256],126629:[[1608],256],126630:[[1586],256],126631:[[1581],256],126632:[[1591],256],126633:[[1610],256],126635:[[1604],256],126636:[[1605],256],126637:[[1606],256],126638:[[1587],256],126639:[[1593],256],126640:[[1601],256],126641:[[1589],256],126642:[[1602],256],126643:[[1585],256],126644:[[1588],256],126645:[[1578],256],126646:[[1579],256],126647:[[1582],256],126648:[[1584],256],126649:[[1590],256],126650:[[1592],256],126651:[[1594],256]}, - 61696:{127232:[[48,46],256],127233:[[48,44],256],127234:[[49,44],256],127235:[[50,44],256],127236:[[51,44],256],127237:[[52,44],256],127238:[[53,44],256],127239:[[54,44],256],127240:[[55,44],256],127241:[[56,44],256],127242:[[57,44],256],127248:[[40,65,41],256],127249:[[40,66,41],256],127250:[[40,67,41],256],127251:[[40,68,41],256],127252:[[40,69,41],256],127253:[[40,70,41],256],127254:[[40,71,41],256],127255:[[40,72,41],256],127256:[[40,73,41],256],127257:[[40,74,41],256],127258:[[40,75,41],256],127259:[[40,76,41],256],127260:[[40,77,41],256],127261:[[40,78,41],256],127262:[[40,79,41],256],127263:[[40,80,41],256],127264:[[40,81,41],256],127265:[[40,82,41],256],127266:[[40,83,41],256],127267:[[40,84,41],256],127268:[[40,85,41],256],127269:[[40,86,41],256],127270:[[40,87,41],256],127271:[[40,88,41],256],127272:[[40,89,41],256],127273:[[40,90,41],256],127274:[[12308,83,12309],256],127275:[[67],256],127276:[[82],256],127277:[[67,68],256],127278:[[87,90],256],127280:[[65],256],127281:[[66],256],127282:[[67],256],127283:[[68],256],127284:[[69],256],127285:[[70],256],127286:[[71],256],127287:[[72],256],127288:[[73],256],127289:[[74],256],127290:[[75],256],127291:[[76],256],127292:[[77],256],127293:[[78],256],127294:[[79],256],127295:[[80],256],127296:[[81],256],127297:[[82],256],127298:[[83],256],127299:[[84],256],127300:[[85],256],127301:[[86],256],127302:[[87],256],127303:[[88],256],127304:[[89],256],127305:[[90],256],127306:[[72,86],256],127307:[[77,86],256],127308:[[83,68],256],127309:[[83,83],256],127310:[[80,80,86],256],127311:[[87,67],256],127338:[[77,67],256],127339:[[77,68],256],127376:[[68,74],256]}, - 61952:{127488:[[12411,12363],256],127489:[[12467,12467],256],127490:[[12469],256],127504:[[25163],256],127505:[[23383],256],127506:[[21452],256],127507:[[12487],256],127508:[[20108],256],127509:[[22810],256],127510:[[35299],256],127511:[[22825],256],127512:[[20132],256],127513:[[26144],256],127514:[[28961],256],127515:[[26009],256],127516:[[21069],256],127517:[[24460],256],127518:[[20877],256],127519:[[26032],256],127520:[[21021],256],127521:[[32066],256],127522:[[29983],256],127523:[[36009],256],127524:[[22768],256],127525:[[21561],256],127526:[[28436],256],127527:[[25237],256],127528:[[25429],256],127529:[[19968],256],127530:[[19977],256],127531:[[36938],256],127532:[[24038],256],127533:[[20013],256],127534:[[21491],256],127535:[[25351],256],127536:[[36208],256],127537:[[25171],256],127538:[[31105],256],127539:[[31354],256],127540:[[21512],256],127541:[[28288],256],127542:[[26377],256],127543:[[26376],256],127544:[[30003],256],127545:[[21106],256],127546:[[21942],256],127552:[[12308,26412,12309],256],127553:[[12308,19977,12309],256],127554:[[12308,20108,12309],256],127555:[[12308,23433,12309],256],127556:[[12308,28857,12309],256],127557:[[12308,25171,12309],256],127558:[[12308,30423,12309],256],127559:[[12308,21213,12309],256],127560:[[12308,25943,12309],256],127568:[[24471],256],127569:[[21487],256]}, - 63488:{194560:[[20029]],194561:[[20024]],194562:[[20033]],194563:[[131362]],194564:[[20320]],194565:[[20398]],194566:[[20411]],194567:[[20482]],194568:[[20602]],194569:[[20633]],194570:[[20711]],194571:[[20687]],194572:[[13470]],194573:[[132666]],194574:[[20813]],194575:[[20820]],194576:[[20836]],194577:[[20855]],194578:[[132380]],194579:[[13497]],194580:[[20839]],194581:[[20877]],194582:[[132427]],194583:[[20887]],194584:[[20900]],194585:[[20172]],194586:[[20908]],194587:[[20917]],194588:[[168415]],194589:[[20981]],194590:[[20995]],194591:[[13535]],194592:[[21051]],194593:[[21062]],194594:[[21106]],194595:[[21111]],194596:[[13589]],194597:[[21191]],194598:[[21193]],194599:[[21220]],194600:[[21242]],194601:[[21253]],194602:[[21254]],194603:[[21271]],194604:[[21321]],194605:[[21329]],194606:[[21338]],194607:[[21363]],194608:[[21373]],194609:[[21375]],194610:[[21375]],194611:[[21375]],194612:[[133676]],194613:[[28784]],194614:[[21450]],194615:[[21471]],194616:[[133987]],194617:[[21483]],194618:[[21489]],194619:[[21510]],194620:[[21662]],194621:[[21560]],194622:[[21576]],194623:[[21608]],194624:[[21666]],194625:[[21750]],194626:[[21776]],194627:[[21843]],194628:[[21859]],194629:[[21892]],194630:[[21892]],194631:[[21913]],194632:[[21931]],194633:[[21939]],194634:[[21954]],194635:[[22294]],194636:[[22022]],194637:[[22295]],194638:[[22097]],194639:[[22132]],194640:[[20999]],194641:[[22766]],194642:[[22478]],194643:[[22516]],194644:[[22541]],194645:[[22411]],194646:[[22578]],194647:[[22577]],194648:[[22700]],194649:[[136420]],194650:[[22770]],194651:[[22775]],194652:[[22790]],194653:[[22810]],194654:[[22818]],194655:[[22882]],194656:[[136872]],194657:[[136938]],194658:[[23020]],194659:[[23067]],194660:[[23079]],194661:[[23000]],194662:[[23142]],194663:[[14062]],194664:[[14076]],194665:[[23304]],194666:[[23358]],194667:[[23358]],194668:[[137672]],194669:[[23491]],194670:[[23512]],194671:[[23527]],194672:[[23539]],194673:[[138008]],194674:[[23551]],194675:[[23558]],194676:[[24403]],194677:[[23586]],194678:[[14209]],194679:[[23648]],194680:[[23662]],194681:[[23744]],194682:[[23693]],194683:[[138724]],194684:[[23875]],194685:[[138726]],194686:[[23918]],194687:[[23915]],194688:[[23932]],194689:[[24033]],194690:[[24034]],194691:[[14383]],194692:[[24061]],194693:[[24104]],194694:[[24125]],194695:[[24169]],194696:[[14434]],194697:[[139651]],194698:[[14460]],194699:[[24240]],194700:[[24243]],194701:[[24246]],194702:[[24266]],194703:[[172946]],194704:[[24318]],194705:[[140081]],194706:[[140081]],194707:[[33281]],194708:[[24354]],194709:[[24354]],194710:[[14535]],194711:[[144056]],194712:[[156122]],194713:[[24418]],194714:[[24427]],194715:[[14563]],194716:[[24474]],194717:[[24525]],194718:[[24535]],194719:[[24569]],194720:[[24705]],194721:[[14650]],194722:[[14620]],194723:[[24724]],194724:[[141012]],194725:[[24775]],194726:[[24904]],194727:[[24908]],194728:[[24910]],194729:[[24908]],194730:[[24954]],194731:[[24974]],194732:[[25010]],194733:[[24996]],194734:[[25007]],194735:[[25054]],194736:[[25074]],194737:[[25078]],194738:[[25104]],194739:[[25115]],194740:[[25181]],194741:[[25265]],194742:[[25300]],194743:[[25424]],194744:[[142092]],194745:[[25405]],194746:[[25340]],194747:[[25448]],194748:[[25475]],194749:[[25572]],194750:[[142321]],194751:[[25634]],194752:[[25541]],194753:[[25513]],194754:[[14894]],194755:[[25705]],194756:[[25726]],194757:[[25757]],194758:[[25719]],194759:[[14956]],194760:[[25935]],194761:[[25964]],194762:[[143370]],194763:[[26083]],194764:[[26360]],194765:[[26185]],194766:[[15129]],194767:[[26257]],194768:[[15112]],194769:[[15076]],194770:[[20882]],194771:[[20885]],194772:[[26368]],194773:[[26268]],194774:[[32941]],194775:[[17369]],194776:[[26391]],194777:[[26395]],194778:[[26401]],194779:[[26462]],194780:[[26451]],194781:[[144323]],194782:[[15177]],194783:[[26618]],194784:[[26501]],194785:[[26706]],194786:[[26757]],194787:[[144493]],194788:[[26766]],194789:[[26655]],194790:[[26900]],194791:[[15261]],194792:[[26946]],194793:[[27043]],194794:[[27114]],194795:[[27304]],194796:[[145059]],194797:[[27355]],194798:[[15384]],194799:[[27425]],194800:[[145575]],194801:[[27476]],194802:[[15438]],194803:[[27506]],194804:[[27551]],194805:[[27578]],194806:[[27579]],194807:[[146061]],194808:[[138507]],194809:[[146170]],194810:[[27726]],194811:[[146620]],194812:[[27839]],194813:[[27853]],194814:[[27751]],194815:[[27926]]}, - 63744:{63744:[[35912]],63745:[[26356]],63746:[[36554]],63747:[[36040]],63748:[[28369]],63749:[[20018]],63750:[[21477]],63751:[[40860]],63752:[[40860]],63753:[[22865]],63754:[[37329]],63755:[[21895]],63756:[[22856]],63757:[[25078]],63758:[[30313]],63759:[[32645]],63760:[[34367]],63761:[[34746]],63762:[[35064]],63763:[[37007]],63764:[[27138]],63765:[[27931]],63766:[[28889]],63767:[[29662]],63768:[[33853]],63769:[[37226]],63770:[[39409]],63771:[[20098]],63772:[[21365]],63773:[[27396]],63774:[[29211]],63775:[[34349]],63776:[[40478]],63777:[[23888]],63778:[[28651]],63779:[[34253]],63780:[[35172]],63781:[[25289]],63782:[[33240]],63783:[[34847]],63784:[[24266]],63785:[[26391]],63786:[[28010]],63787:[[29436]],63788:[[37070]],63789:[[20358]],63790:[[20919]],63791:[[21214]],63792:[[25796]],63793:[[27347]],63794:[[29200]],63795:[[30439]],63796:[[32769]],63797:[[34310]],63798:[[34396]],63799:[[36335]],63800:[[38706]],63801:[[39791]],63802:[[40442]],63803:[[30860]],63804:[[31103]],63805:[[32160]],63806:[[33737]],63807:[[37636]],63808:[[40575]],63809:[[35542]],63810:[[22751]],63811:[[24324]],63812:[[31840]],63813:[[32894]],63814:[[29282]],63815:[[30922]],63816:[[36034]],63817:[[38647]],63818:[[22744]],63819:[[23650]],63820:[[27155]],63821:[[28122]],63822:[[28431]],63823:[[32047]],63824:[[32311]],63825:[[38475]],63826:[[21202]],63827:[[32907]],63828:[[20956]],63829:[[20940]],63830:[[31260]],63831:[[32190]],63832:[[33777]],63833:[[38517]],63834:[[35712]],63835:[[25295]],63836:[[27138]],63837:[[35582]],63838:[[20025]],63839:[[23527]],63840:[[24594]],63841:[[29575]],63842:[[30064]],63843:[[21271]],63844:[[30971]],63845:[[20415]],63846:[[24489]],63847:[[19981]],63848:[[27852]],63849:[[25976]],63850:[[32034]],63851:[[21443]],63852:[[22622]],63853:[[30465]],63854:[[33865]],63855:[[35498]],63856:[[27578]],63857:[[36784]],63858:[[27784]],63859:[[25342]],63860:[[33509]],63861:[[25504]],63862:[[30053]],63863:[[20142]],63864:[[20841]],63865:[[20937]],63866:[[26753]],63867:[[31975]],63868:[[33391]],63869:[[35538]],63870:[[37327]],63871:[[21237]],63872:[[21570]],63873:[[22899]],63874:[[24300]],63875:[[26053]],63876:[[28670]],63877:[[31018]],63878:[[38317]],63879:[[39530]],63880:[[40599]],63881:[[40654]],63882:[[21147]],63883:[[26310]],63884:[[27511]],63885:[[36706]],63886:[[24180]],63887:[[24976]],63888:[[25088]],63889:[[25754]],63890:[[28451]],63891:[[29001]],63892:[[29833]],63893:[[31178]],63894:[[32244]],63895:[[32879]],63896:[[36646]],63897:[[34030]],63898:[[36899]],63899:[[37706]],63900:[[21015]],63901:[[21155]],63902:[[21693]],63903:[[28872]],63904:[[35010]],63905:[[35498]],63906:[[24265]],63907:[[24565]],63908:[[25467]],63909:[[27566]],63910:[[31806]],63911:[[29557]],63912:[[20196]],63913:[[22265]],63914:[[23527]],63915:[[23994]],63916:[[24604]],63917:[[29618]],63918:[[29801]],63919:[[32666]],63920:[[32838]],63921:[[37428]],63922:[[38646]],63923:[[38728]],63924:[[38936]],63925:[[20363]],63926:[[31150]],63927:[[37300]],63928:[[38584]],63929:[[24801]],63930:[[20102]],63931:[[20698]],63932:[[23534]],63933:[[23615]],63934:[[26009]],63935:[[27138]],63936:[[29134]],63937:[[30274]],63938:[[34044]],63939:[[36988]],63940:[[40845]],63941:[[26248]],63942:[[38446]],63943:[[21129]],63944:[[26491]],63945:[[26611]],63946:[[27969]],63947:[[28316]],63948:[[29705]],63949:[[30041]],63950:[[30827]],63951:[[32016]],63952:[[39006]],63953:[[20845]],63954:[[25134]],63955:[[38520]],63956:[[20523]],63957:[[23833]],63958:[[28138]],63959:[[36650]],63960:[[24459]],63961:[[24900]],63962:[[26647]],63963:[[29575]],63964:[[38534]],63965:[[21033]],63966:[[21519]],63967:[[23653]],63968:[[26131]],63969:[[26446]],63970:[[26792]],63971:[[27877]],63972:[[29702]],63973:[[30178]],63974:[[32633]],63975:[[35023]],63976:[[35041]],63977:[[37324]],63978:[[38626]],63979:[[21311]],63980:[[28346]],63981:[[21533]],63982:[[29136]],63983:[[29848]],63984:[[34298]],63985:[[38563]],63986:[[40023]],63987:[[40607]],63988:[[26519]],63989:[[28107]],63990:[[33256]],63991:[[31435]],63992:[[31520]],63993:[[31890]],63994:[[29376]],63995:[[28825]],63996:[[35672]],63997:[[20160]],63998:[[33590]],63999:[[21050]],194816:[[27966]],194817:[[28023]],194818:[[27969]],194819:[[28009]],194820:[[28024]],194821:[[28037]],194822:[[146718]],194823:[[27956]],194824:[[28207]],194825:[[28270]],194826:[[15667]],194827:[[28363]],194828:[[28359]],194829:[[147153]],194830:[[28153]],194831:[[28526]],194832:[[147294]],194833:[[147342]],194834:[[28614]],194835:[[28729]],194836:[[28702]],194837:[[28699]],194838:[[15766]],194839:[[28746]],194840:[[28797]],194841:[[28791]],194842:[[28845]],194843:[[132389]],194844:[[28997]],194845:[[148067]],194846:[[29084]],194847:[[148395]],194848:[[29224]],194849:[[29237]],194850:[[29264]],194851:[[149000]],194852:[[29312]],194853:[[29333]],194854:[[149301]],194855:[[149524]],194856:[[29562]],194857:[[29579]],194858:[[16044]],194859:[[29605]],194860:[[16056]],194861:[[16056]],194862:[[29767]],194863:[[29788]],194864:[[29809]],194865:[[29829]],194866:[[29898]],194867:[[16155]],194868:[[29988]],194869:[[150582]],194870:[[30014]],194871:[[150674]],194872:[[30064]],194873:[[139679]],194874:[[30224]],194875:[[151457]],194876:[[151480]],194877:[[151620]],194878:[[16380]],194879:[[16392]],194880:[[30452]],194881:[[151795]],194882:[[151794]],194883:[[151833]],194884:[[151859]],194885:[[30494]],194886:[[30495]],194887:[[30495]],194888:[[30538]],194889:[[16441]],194890:[[30603]],194891:[[16454]],194892:[[16534]],194893:[[152605]],194894:[[30798]],194895:[[30860]],194896:[[30924]],194897:[[16611]],194898:[[153126]],194899:[[31062]],194900:[[153242]],194901:[[153285]],194902:[[31119]],194903:[[31211]],194904:[[16687]],194905:[[31296]],194906:[[31306]],194907:[[31311]],194908:[[153980]],194909:[[154279]],194910:[[154279]],194911:[[31470]],194912:[[16898]],194913:[[154539]],194914:[[31686]],194915:[[31689]],194916:[[16935]],194917:[[154752]],194918:[[31954]],194919:[[17056]],194920:[[31976]],194921:[[31971]],194922:[[32000]],194923:[[155526]],194924:[[32099]],194925:[[17153]],194926:[[32199]],194927:[[32258]],194928:[[32325]],194929:[[17204]],194930:[[156200]],194931:[[156231]],194932:[[17241]],194933:[[156377]],194934:[[32634]],194935:[[156478]],194936:[[32661]],194937:[[32762]],194938:[[32773]],194939:[[156890]],194940:[[156963]],194941:[[32864]],194942:[[157096]],194943:[[32880]],194944:[[144223]],194945:[[17365]],194946:[[32946]],194947:[[33027]],194948:[[17419]],194949:[[33086]],194950:[[23221]],194951:[[157607]],194952:[[157621]],194953:[[144275]],194954:[[144284]],194955:[[33281]],194956:[[33284]],194957:[[36766]],194958:[[17515]],194959:[[33425]],194960:[[33419]],194961:[[33437]],194962:[[21171]],194963:[[33457]],194964:[[33459]],194965:[[33469]],194966:[[33510]],194967:[[158524]],194968:[[33509]],194969:[[33565]],194970:[[33635]],194971:[[33709]],194972:[[33571]],194973:[[33725]],194974:[[33767]],194975:[[33879]],194976:[[33619]],194977:[[33738]],194978:[[33740]],194979:[[33756]],194980:[[158774]],194981:[[159083]],194982:[[158933]],194983:[[17707]],194984:[[34033]],194985:[[34035]],194986:[[34070]],194987:[[160714]],194988:[[34148]],194989:[[159532]],194990:[[17757]],194991:[[17761]],194992:[[159665]],194993:[[159954]],194994:[[17771]],194995:[[34384]],194996:[[34396]],194997:[[34407]],194998:[[34409]],194999:[[34473]],195000:[[34440]],195001:[[34574]],195002:[[34530]],195003:[[34681]],195004:[[34600]],195005:[[34667]],195006:[[34694]],195007:[[17879]],195008:[[34785]],195009:[[34817]],195010:[[17913]],195011:[[34912]],195012:[[34915]],195013:[[161383]],195014:[[35031]],195015:[[35038]],195016:[[17973]],195017:[[35066]],195018:[[13499]],195019:[[161966]],195020:[[162150]],195021:[[18110]],195022:[[18119]],195023:[[35488]],195024:[[35565]],195025:[[35722]],195026:[[35925]],195027:[[162984]],195028:[[36011]],195029:[[36033]],195030:[[36123]],195031:[[36215]],195032:[[163631]],195033:[[133124]],195034:[[36299]],195035:[[36284]],195036:[[36336]],195037:[[133342]],195038:[[36564]],195039:[[36664]],195040:[[165330]],195041:[[165357]],195042:[[37012]],195043:[[37105]],195044:[[37137]],195045:[[165678]],195046:[[37147]],195047:[[37432]],195048:[[37591]],195049:[[37592]],195050:[[37500]],195051:[[37881]],195052:[[37909]],195053:[[166906]],195054:[[38283]],195055:[[18837]],195056:[[38327]],195057:[[167287]],195058:[[18918]],195059:[[38595]],195060:[[23986]],195061:[[38691]],195062:[[168261]],195063:[[168474]],195064:[[19054]],195065:[[19062]],195066:[[38880]],195067:[[168970]],195068:[[19122]],195069:[[169110]],195070:[[38923]],195071:[[38923]]}, - 64000:{64000:[[20999]],64001:[[24230]],64002:[[25299]],64003:[[31958]],64004:[[23429]],64005:[[27934]],64006:[[26292]],64007:[[36667]],64008:[[34892]],64009:[[38477]],64010:[[35211]],64011:[[24275]],64012:[[20800]],64013:[[21952]],64016:[[22618]],64018:[[26228]],64021:[[20958]],64022:[[29482]],64023:[[30410]],64024:[[31036]],64025:[[31070]],64026:[[31077]],64027:[[31119]],64028:[[38742]],64029:[[31934]],64030:[[32701]],64032:[[34322]],64034:[[35576]],64037:[[36920]],64038:[[37117]],64042:[[39151]],64043:[[39164]],64044:[[39208]],64045:[[40372]],64046:[[37086]],64047:[[38583]],64048:[[20398]],64049:[[20711]],64050:[[20813]],64051:[[21193]],64052:[[21220]],64053:[[21329]],64054:[[21917]],64055:[[22022]],64056:[[22120]],64057:[[22592]],64058:[[22696]],64059:[[23652]],64060:[[23662]],64061:[[24724]],64062:[[24936]],64063:[[24974]],64064:[[25074]],64065:[[25935]],64066:[[26082]],64067:[[26257]],64068:[[26757]],64069:[[28023]],64070:[[28186]],64071:[[28450]],64072:[[29038]],64073:[[29227]],64074:[[29730]],64075:[[30865]],64076:[[31038]],64077:[[31049]],64078:[[31048]],64079:[[31056]],64080:[[31062]],64081:[[31069]],64082:[[31117]],64083:[[31118]],64084:[[31296]],64085:[[31361]],64086:[[31680]],64087:[[32244]],64088:[[32265]],64089:[[32321]],64090:[[32626]],64091:[[32773]],64092:[[33261]],64093:[[33401]],64094:[[33401]],64095:[[33879]],64096:[[35088]],64097:[[35222]],64098:[[35585]],64099:[[35641]],64100:[[36051]],64101:[[36104]],64102:[[36790]],64103:[[36920]],64104:[[38627]],64105:[[38911]],64106:[[38971]],64107:[[24693]],64108:[[148206]],64109:[[33304]],64112:[[20006]],64113:[[20917]],64114:[[20840]],64115:[[20352]],64116:[[20805]],64117:[[20864]],64118:[[21191]],64119:[[21242]],64120:[[21917]],64121:[[21845]],64122:[[21913]],64123:[[21986]],64124:[[22618]],64125:[[22707]],64126:[[22852]],64127:[[22868]],64128:[[23138]],64129:[[23336]],64130:[[24274]],64131:[[24281]],64132:[[24425]],64133:[[24493]],64134:[[24792]],64135:[[24910]],64136:[[24840]],64137:[[24974]],64138:[[24928]],64139:[[25074]],64140:[[25140]],64141:[[25540]],64142:[[25628]],64143:[[25682]],64144:[[25942]],64145:[[26228]],64146:[[26391]],64147:[[26395]],64148:[[26454]],64149:[[27513]],64150:[[27578]],64151:[[27969]],64152:[[28379]],64153:[[28363]],64154:[[28450]],64155:[[28702]],64156:[[29038]],64157:[[30631]],64158:[[29237]],64159:[[29359]],64160:[[29482]],64161:[[29809]],64162:[[29958]],64163:[[30011]],64164:[[30237]],64165:[[30239]],64166:[[30410]],64167:[[30427]],64168:[[30452]],64169:[[30538]],64170:[[30528]],64171:[[30924]],64172:[[31409]],64173:[[31680]],64174:[[31867]],64175:[[32091]],64176:[[32244]],64177:[[32574]],64178:[[32773]],64179:[[33618]],64180:[[33775]],64181:[[34681]],64182:[[35137]],64183:[[35206]],64184:[[35222]],64185:[[35519]],64186:[[35576]],64187:[[35531]],64188:[[35585]],64189:[[35582]],64190:[[35565]],64191:[[35641]],64192:[[35722]],64193:[[36104]],64194:[[36664]],64195:[[36978]],64196:[[37273]],64197:[[37494]],64198:[[38524]],64199:[[38627]],64200:[[38742]],64201:[[38875]],64202:[[38911]],64203:[[38923]],64204:[[38971]],64205:[[39698]],64206:[[40860]],64207:[[141386]],64208:[[141380]],64209:[[144341]],64210:[[15261]],64211:[[16408]],64212:[[16441]],64213:[[152137]],64214:[[154832]],64215:[[163539]],64216:[[40771]],64217:[[40846]],195072:[[38953]],195073:[[169398]],195074:[[39138]],195075:[[19251]],195076:[[39209]],195077:[[39335]],195078:[[39362]],195079:[[39422]],195080:[[19406]],195081:[[170800]],195082:[[39698]],195083:[[40000]],195084:[[40189]],195085:[[19662]],195086:[[19693]],195087:[[40295]],195088:[[172238]],195089:[[19704]],195090:[[172293]],195091:[[172558]],195092:[[172689]],195093:[[40635]],195094:[[19798]],195095:[[40697]],195096:[[40702]],195097:[[40709]],195098:[[40719]],195099:[[40726]],195100:[[40763]],195101:[[173568]]}, - 64256:{64256:[[102,102],256],64257:[[102,105],256],64258:[[102,108],256],64259:[[102,102,105],256],64260:[[102,102,108],256],64261:[[383,116],256],64262:[[115,116],256],64275:[[1396,1398],256],64276:[[1396,1381],256],64277:[[1396,1387],256],64278:[[1406,1398],256],64279:[[1396,1389],256],64285:[[1497,1460],512],64286:[,26],64287:[[1522,1463],512],64288:[[1506],256],64289:[[1488],256],64290:[[1491],256],64291:[[1492],256],64292:[[1499],256],64293:[[1500],256],64294:[[1501],256],64295:[[1512],256],64296:[[1514],256],64297:[[43],256],64298:[[1513,1473],512],64299:[[1513,1474],512],64300:[[64329,1473],512],64301:[[64329,1474],512],64302:[[1488,1463],512],64303:[[1488,1464],512],64304:[[1488,1468],512],64305:[[1489,1468],512],64306:[[1490,1468],512],64307:[[1491,1468],512],64308:[[1492,1468],512],64309:[[1493,1468],512],64310:[[1494,1468],512],64312:[[1496,1468],512],64313:[[1497,1468],512],64314:[[1498,1468],512],64315:[[1499,1468],512],64316:[[1500,1468],512],64318:[[1502,1468],512],64320:[[1504,1468],512],64321:[[1505,1468],512],64323:[[1507,1468],512],64324:[[1508,1468],512],64326:[[1510,1468],512],64327:[[1511,1468],512],64328:[[1512,1468],512],64329:[[1513,1468],512],64330:[[1514,1468],512],64331:[[1493,1465],512],64332:[[1489,1471],512],64333:[[1499,1471],512],64334:[[1508,1471],512],64335:[[1488,1500],256],64336:[[1649],256],64337:[[1649],256],64338:[[1659],256],64339:[[1659],256],64340:[[1659],256],64341:[[1659],256],64342:[[1662],256],64343:[[1662],256],64344:[[1662],256],64345:[[1662],256],64346:[[1664],256],64347:[[1664],256],64348:[[1664],256],64349:[[1664],256],64350:[[1658],256],64351:[[1658],256],64352:[[1658],256],64353:[[1658],256],64354:[[1663],256],64355:[[1663],256],64356:[[1663],256],64357:[[1663],256],64358:[[1657],256],64359:[[1657],256],64360:[[1657],256],64361:[[1657],256],64362:[[1700],256],64363:[[1700],256],64364:[[1700],256],64365:[[1700],256],64366:[[1702],256],64367:[[1702],256],64368:[[1702],256],64369:[[1702],256],64370:[[1668],256],64371:[[1668],256],64372:[[1668],256],64373:[[1668],256],64374:[[1667],256],64375:[[1667],256],64376:[[1667],256],64377:[[1667],256],64378:[[1670],256],64379:[[1670],256],64380:[[1670],256],64381:[[1670],256],64382:[[1671],256],64383:[[1671],256],64384:[[1671],256],64385:[[1671],256],64386:[[1677],256],64387:[[1677],256],64388:[[1676],256],64389:[[1676],256],64390:[[1678],256],64391:[[1678],256],64392:[[1672],256],64393:[[1672],256],64394:[[1688],256],64395:[[1688],256],64396:[[1681],256],64397:[[1681],256],64398:[[1705],256],64399:[[1705],256],64400:[[1705],256],64401:[[1705],256],64402:[[1711],256],64403:[[1711],256],64404:[[1711],256],64405:[[1711],256],64406:[[1715],256],64407:[[1715],256],64408:[[1715],256],64409:[[1715],256],64410:[[1713],256],64411:[[1713],256],64412:[[1713],256],64413:[[1713],256],64414:[[1722],256],64415:[[1722],256],64416:[[1723],256],64417:[[1723],256],64418:[[1723],256],64419:[[1723],256],64420:[[1728],256],64421:[[1728],256],64422:[[1729],256],64423:[[1729],256],64424:[[1729],256],64425:[[1729],256],64426:[[1726],256],64427:[[1726],256],64428:[[1726],256],64429:[[1726],256],64430:[[1746],256],64431:[[1746],256],64432:[[1747],256],64433:[[1747],256],64467:[[1709],256],64468:[[1709],256],64469:[[1709],256],64470:[[1709],256],64471:[[1735],256],64472:[[1735],256],64473:[[1734],256],64474:[[1734],256],64475:[[1736],256],64476:[[1736],256],64477:[[1655],256],64478:[[1739],256],64479:[[1739],256],64480:[[1733],256],64481:[[1733],256],64482:[[1737],256],64483:[[1737],256],64484:[[1744],256],64485:[[1744],256],64486:[[1744],256],64487:[[1744],256],64488:[[1609],256],64489:[[1609],256],64490:[[1574,1575],256],64491:[[1574,1575],256],64492:[[1574,1749],256],64493:[[1574,1749],256],64494:[[1574,1608],256],64495:[[1574,1608],256],64496:[[1574,1735],256],64497:[[1574,1735],256],64498:[[1574,1734],256],64499:[[1574,1734],256],64500:[[1574,1736],256],64501:[[1574,1736],256],64502:[[1574,1744],256],64503:[[1574,1744],256],64504:[[1574,1744],256],64505:[[1574,1609],256],64506:[[1574,1609],256],64507:[[1574,1609],256],64508:[[1740],256],64509:[[1740],256],64510:[[1740],256],64511:[[1740],256]}, - 64512:{64512:[[1574,1580],256],64513:[[1574,1581],256],64514:[[1574,1605],256],64515:[[1574,1609],256],64516:[[1574,1610],256],64517:[[1576,1580],256],64518:[[1576,1581],256],64519:[[1576,1582],256],64520:[[1576,1605],256],64521:[[1576,1609],256],64522:[[1576,1610],256],64523:[[1578,1580],256],64524:[[1578,1581],256],64525:[[1578,1582],256],64526:[[1578,1605],256],64527:[[1578,1609],256],64528:[[1578,1610],256],64529:[[1579,1580],256],64530:[[1579,1605],256],64531:[[1579,1609],256],64532:[[1579,1610],256],64533:[[1580,1581],256],64534:[[1580,1605],256],64535:[[1581,1580],256],64536:[[1581,1605],256],64537:[[1582,1580],256],64538:[[1582,1581],256],64539:[[1582,1605],256],64540:[[1587,1580],256],64541:[[1587,1581],256],64542:[[1587,1582],256],64543:[[1587,1605],256],64544:[[1589,1581],256],64545:[[1589,1605],256],64546:[[1590,1580],256],64547:[[1590,1581],256],64548:[[1590,1582],256],64549:[[1590,1605],256],64550:[[1591,1581],256],64551:[[1591,1605],256],64552:[[1592,1605],256],64553:[[1593,1580],256],64554:[[1593,1605],256],64555:[[1594,1580],256],64556:[[1594,1605],256],64557:[[1601,1580],256],64558:[[1601,1581],256],64559:[[1601,1582],256],64560:[[1601,1605],256],64561:[[1601,1609],256],64562:[[1601,1610],256],64563:[[1602,1581],256],64564:[[1602,1605],256],64565:[[1602,1609],256],64566:[[1602,1610],256],64567:[[1603,1575],256],64568:[[1603,1580],256],64569:[[1603,1581],256],64570:[[1603,1582],256],64571:[[1603,1604],256],64572:[[1603,1605],256],64573:[[1603,1609],256],64574:[[1603,1610],256],64575:[[1604,1580],256],64576:[[1604,1581],256],64577:[[1604,1582],256],64578:[[1604,1605],256],64579:[[1604,1609],256],64580:[[1604,1610],256],64581:[[1605,1580],256],64582:[[1605,1581],256],64583:[[1605,1582],256],64584:[[1605,1605],256],64585:[[1605,1609],256],64586:[[1605,1610],256],64587:[[1606,1580],256],64588:[[1606,1581],256],64589:[[1606,1582],256],64590:[[1606,1605],256],64591:[[1606,1609],256],64592:[[1606,1610],256],64593:[[1607,1580],256],64594:[[1607,1605],256],64595:[[1607,1609],256],64596:[[1607,1610],256],64597:[[1610,1580],256],64598:[[1610,1581],256],64599:[[1610,1582],256],64600:[[1610,1605],256],64601:[[1610,1609],256],64602:[[1610,1610],256],64603:[[1584,1648],256],64604:[[1585,1648],256],64605:[[1609,1648],256],64606:[[32,1612,1617],256],64607:[[32,1613,1617],256],64608:[[32,1614,1617],256],64609:[[32,1615,1617],256],64610:[[32,1616,1617],256],64611:[[32,1617,1648],256],64612:[[1574,1585],256],64613:[[1574,1586],256],64614:[[1574,1605],256],64615:[[1574,1606],256],64616:[[1574,1609],256],64617:[[1574,1610],256],64618:[[1576,1585],256],64619:[[1576,1586],256],64620:[[1576,1605],256],64621:[[1576,1606],256],64622:[[1576,1609],256],64623:[[1576,1610],256],64624:[[1578,1585],256],64625:[[1578,1586],256],64626:[[1578,1605],256],64627:[[1578,1606],256],64628:[[1578,1609],256],64629:[[1578,1610],256],64630:[[1579,1585],256],64631:[[1579,1586],256],64632:[[1579,1605],256],64633:[[1579,1606],256],64634:[[1579,1609],256],64635:[[1579,1610],256],64636:[[1601,1609],256],64637:[[1601,1610],256],64638:[[1602,1609],256],64639:[[1602,1610],256],64640:[[1603,1575],256],64641:[[1603,1604],256],64642:[[1603,1605],256],64643:[[1603,1609],256],64644:[[1603,1610],256],64645:[[1604,1605],256],64646:[[1604,1609],256],64647:[[1604,1610],256],64648:[[1605,1575],256],64649:[[1605,1605],256],64650:[[1606,1585],256],64651:[[1606,1586],256],64652:[[1606,1605],256],64653:[[1606,1606],256],64654:[[1606,1609],256],64655:[[1606,1610],256],64656:[[1609,1648],256],64657:[[1610,1585],256],64658:[[1610,1586],256],64659:[[1610,1605],256],64660:[[1610,1606],256],64661:[[1610,1609],256],64662:[[1610,1610],256],64663:[[1574,1580],256],64664:[[1574,1581],256],64665:[[1574,1582],256],64666:[[1574,1605],256],64667:[[1574,1607],256],64668:[[1576,1580],256],64669:[[1576,1581],256],64670:[[1576,1582],256],64671:[[1576,1605],256],64672:[[1576,1607],256],64673:[[1578,1580],256],64674:[[1578,1581],256],64675:[[1578,1582],256],64676:[[1578,1605],256],64677:[[1578,1607],256],64678:[[1579,1605],256],64679:[[1580,1581],256],64680:[[1580,1605],256],64681:[[1581,1580],256],64682:[[1581,1605],256],64683:[[1582,1580],256],64684:[[1582,1605],256],64685:[[1587,1580],256],64686:[[1587,1581],256],64687:[[1587,1582],256],64688:[[1587,1605],256],64689:[[1589,1581],256],64690:[[1589,1582],256],64691:[[1589,1605],256],64692:[[1590,1580],256],64693:[[1590,1581],256],64694:[[1590,1582],256],64695:[[1590,1605],256],64696:[[1591,1581],256],64697:[[1592,1605],256],64698:[[1593,1580],256],64699:[[1593,1605],256],64700:[[1594,1580],256],64701:[[1594,1605],256],64702:[[1601,1580],256],64703:[[1601,1581],256],64704:[[1601,1582],256],64705:[[1601,1605],256],64706:[[1602,1581],256],64707:[[1602,1605],256],64708:[[1603,1580],256],64709:[[1603,1581],256],64710:[[1603,1582],256],64711:[[1603,1604],256],64712:[[1603,1605],256],64713:[[1604,1580],256],64714:[[1604,1581],256],64715:[[1604,1582],256],64716:[[1604,1605],256],64717:[[1604,1607],256],64718:[[1605,1580],256],64719:[[1605,1581],256],64720:[[1605,1582],256],64721:[[1605,1605],256],64722:[[1606,1580],256],64723:[[1606,1581],256],64724:[[1606,1582],256],64725:[[1606,1605],256],64726:[[1606,1607],256],64727:[[1607,1580],256],64728:[[1607,1605],256],64729:[[1607,1648],256],64730:[[1610,1580],256],64731:[[1610,1581],256],64732:[[1610,1582],256],64733:[[1610,1605],256],64734:[[1610,1607],256],64735:[[1574,1605],256],64736:[[1574,1607],256],64737:[[1576,1605],256],64738:[[1576,1607],256],64739:[[1578,1605],256],64740:[[1578,1607],256],64741:[[1579,1605],256],64742:[[1579,1607],256],64743:[[1587,1605],256],64744:[[1587,1607],256],64745:[[1588,1605],256],64746:[[1588,1607],256],64747:[[1603,1604],256],64748:[[1603,1605],256],64749:[[1604,1605],256],64750:[[1606,1605],256],64751:[[1606,1607],256],64752:[[1610,1605],256],64753:[[1610,1607],256],64754:[[1600,1614,1617],256],64755:[[1600,1615,1617],256],64756:[[1600,1616,1617],256],64757:[[1591,1609],256],64758:[[1591,1610],256],64759:[[1593,1609],256],64760:[[1593,1610],256],64761:[[1594,1609],256],64762:[[1594,1610],256],64763:[[1587,1609],256],64764:[[1587,1610],256],64765:[[1588,1609],256],64766:[[1588,1610],256],64767:[[1581,1609],256]}, - 64768:{64768:[[1581,1610],256],64769:[[1580,1609],256],64770:[[1580,1610],256],64771:[[1582,1609],256],64772:[[1582,1610],256],64773:[[1589,1609],256],64774:[[1589,1610],256],64775:[[1590,1609],256],64776:[[1590,1610],256],64777:[[1588,1580],256],64778:[[1588,1581],256],64779:[[1588,1582],256],64780:[[1588,1605],256],64781:[[1588,1585],256],64782:[[1587,1585],256],64783:[[1589,1585],256],64784:[[1590,1585],256],64785:[[1591,1609],256],64786:[[1591,1610],256],64787:[[1593,1609],256],64788:[[1593,1610],256],64789:[[1594,1609],256],64790:[[1594,1610],256],64791:[[1587,1609],256],64792:[[1587,1610],256],64793:[[1588,1609],256],64794:[[1588,1610],256],64795:[[1581,1609],256],64796:[[1581,1610],256],64797:[[1580,1609],256],64798:[[1580,1610],256],64799:[[1582,1609],256],64800:[[1582,1610],256],64801:[[1589,1609],256],64802:[[1589,1610],256],64803:[[1590,1609],256],64804:[[1590,1610],256],64805:[[1588,1580],256],64806:[[1588,1581],256],64807:[[1588,1582],256],64808:[[1588,1605],256],64809:[[1588,1585],256],64810:[[1587,1585],256],64811:[[1589,1585],256],64812:[[1590,1585],256],64813:[[1588,1580],256],64814:[[1588,1581],256],64815:[[1588,1582],256],64816:[[1588,1605],256],64817:[[1587,1607],256],64818:[[1588,1607],256],64819:[[1591,1605],256],64820:[[1587,1580],256],64821:[[1587,1581],256],64822:[[1587,1582],256],64823:[[1588,1580],256],64824:[[1588,1581],256],64825:[[1588,1582],256],64826:[[1591,1605],256],64827:[[1592,1605],256],64828:[[1575,1611],256],64829:[[1575,1611],256],64848:[[1578,1580,1605],256],64849:[[1578,1581,1580],256],64850:[[1578,1581,1580],256],64851:[[1578,1581,1605],256],64852:[[1578,1582,1605],256],64853:[[1578,1605,1580],256],64854:[[1578,1605,1581],256],64855:[[1578,1605,1582],256],64856:[[1580,1605,1581],256],64857:[[1580,1605,1581],256],64858:[[1581,1605,1610],256],64859:[[1581,1605,1609],256],64860:[[1587,1581,1580],256],64861:[[1587,1580,1581],256],64862:[[1587,1580,1609],256],64863:[[1587,1605,1581],256],64864:[[1587,1605,1581],256],64865:[[1587,1605,1580],256],64866:[[1587,1605,1605],256],64867:[[1587,1605,1605],256],64868:[[1589,1581,1581],256],64869:[[1589,1581,1581],256],64870:[[1589,1605,1605],256],64871:[[1588,1581,1605],256],64872:[[1588,1581,1605],256],64873:[[1588,1580,1610],256],64874:[[1588,1605,1582],256],64875:[[1588,1605,1582],256],64876:[[1588,1605,1605],256],64877:[[1588,1605,1605],256],64878:[[1590,1581,1609],256],64879:[[1590,1582,1605],256],64880:[[1590,1582,1605],256],64881:[[1591,1605,1581],256],64882:[[1591,1605,1581],256],64883:[[1591,1605,1605],256],64884:[[1591,1605,1610],256],64885:[[1593,1580,1605],256],64886:[[1593,1605,1605],256],64887:[[1593,1605,1605],256],64888:[[1593,1605,1609],256],64889:[[1594,1605,1605],256],64890:[[1594,1605,1610],256],64891:[[1594,1605,1609],256],64892:[[1601,1582,1605],256],64893:[[1601,1582,1605],256],64894:[[1602,1605,1581],256],64895:[[1602,1605,1605],256],64896:[[1604,1581,1605],256],64897:[[1604,1581,1610],256],64898:[[1604,1581,1609],256],64899:[[1604,1580,1580],256],64900:[[1604,1580,1580],256],64901:[[1604,1582,1605],256],64902:[[1604,1582,1605],256],64903:[[1604,1605,1581],256],64904:[[1604,1605,1581],256],64905:[[1605,1581,1580],256],64906:[[1605,1581,1605],256],64907:[[1605,1581,1610],256],64908:[[1605,1580,1581],256],64909:[[1605,1580,1605],256],64910:[[1605,1582,1580],256],64911:[[1605,1582,1605],256],64914:[[1605,1580,1582],256],64915:[[1607,1605,1580],256],64916:[[1607,1605,1605],256],64917:[[1606,1581,1605],256],64918:[[1606,1581,1609],256],64919:[[1606,1580,1605],256],64920:[[1606,1580,1605],256],64921:[[1606,1580,1609],256],64922:[[1606,1605,1610],256],64923:[[1606,1605,1609],256],64924:[[1610,1605,1605],256],64925:[[1610,1605,1605],256],64926:[[1576,1582,1610],256],64927:[[1578,1580,1610],256],64928:[[1578,1580,1609],256],64929:[[1578,1582,1610],256],64930:[[1578,1582,1609],256],64931:[[1578,1605,1610],256],64932:[[1578,1605,1609],256],64933:[[1580,1605,1610],256],64934:[[1580,1581,1609],256],64935:[[1580,1605,1609],256],64936:[[1587,1582,1609],256],64937:[[1589,1581,1610],256],64938:[[1588,1581,1610],256],64939:[[1590,1581,1610],256],64940:[[1604,1580,1610],256],64941:[[1604,1605,1610],256],64942:[[1610,1581,1610],256],64943:[[1610,1580,1610],256],64944:[[1610,1605,1610],256],64945:[[1605,1605,1610],256],64946:[[1602,1605,1610],256],64947:[[1606,1581,1610],256],64948:[[1602,1605,1581],256],64949:[[1604,1581,1605],256],64950:[[1593,1605,1610],256],64951:[[1603,1605,1610],256],64952:[[1606,1580,1581],256],64953:[[1605,1582,1610],256],64954:[[1604,1580,1605],256],64955:[[1603,1605,1605],256],64956:[[1604,1580,1605],256],64957:[[1606,1580,1581],256],64958:[[1580,1581,1610],256],64959:[[1581,1580,1610],256],64960:[[1605,1580,1610],256],64961:[[1601,1605,1610],256],64962:[[1576,1581,1610],256],64963:[[1603,1605,1605],256],64964:[[1593,1580,1605],256],64965:[[1589,1605,1605],256],64966:[[1587,1582,1610],256],64967:[[1606,1580,1610],256],65008:[[1589,1604,1746],256],65009:[[1602,1604,1746],256],65010:[[1575,1604,1604,1607],256],65011:[[1575,1603,1576,1585],256],65012:[[1605,1581,1605,1583],256],65013:[[1589,1604,1593,1605],256],65014:[[1585,1587,1608,1604],256],65015:[[1593,1604,1610,1607],256],65016:[[1608,1587,1604,1605],256],65017:[[1589,1604,1609],256],65018:[[1589,1604,1609,32,1575,1604,1604,1607,32,1593,1604,1610,1607,32,1608,1587,1604,1605],256],65019:[[1580,1604,32,1580,1604,1575,1604,1607],256],65020:[[1585,1740,1575,1604],256]}, - 65024:{65040:[[44],256],65041:[[12289],256],65042:[[12290],256],65043:[[58],256],65044:[[59],256],65045:[[33],256],65046:[[63],256],65047:[[12310],256],65048:[[12311],256],65049:[[8230],256],65056:[,230],65057:[,230],65058:[,230],65059:[,230],65060:[,230],65061:[,230],65062:[,230],65072:[[8229],256],65073:[[8212],256],65074:[[8211],256],65075:[[95],256],65076:[[95],256],65077:[[40],256],65078:[[41],256],65079:[[123],256],65080:[[125],256],65081:[[12308],256],65082:[[12309],256],65083:[[12304],256],65084:[[12305],256],65085:[[12298],256],65086:[[12299],256],65087:[[12296],256],65088:[[12297],256],65089:[[12300],256],65090:[[12301],256],65091:[[12302],256],65092:[[12303],256],65095:[[91],256],65096:[[93],256],65097:[[8254],256],65098:[[8254],256],65099:[[8254],256],65100:[[8254],256],65101:[[95],256],65102:[[95],256],65103:[[95],256],65104:[[44],256],65105:[[12289],256],65106:[[46],256],65108:[[59],256],65109:[[58],256],65110:[[63],256],65111:[[33],256],65112:[[8212],256],65113:[[40],256],65114:[[41],256],65115:[[123],256],65116:[[125],256],65117:[[12308],256],65118:[[12309],256],65119:[[35],256],65120:[[38],256],65121:[[42],256],65122:[[43],256],65123:[[45],256],65124:[[60],256],65125:[[62],256],65126:[[61],256],65128:[[92],256],65129:[[36],256],65130:[[37],256],65131:[[64],256],65136:[[32,1611],256],65137:[[1600,1611],256],65138:[[32,1612],256],65140:[[32,1613],256],65142:[[32,1614],256],65143:[[1600,1614],256],65144:[[32,1615],256],65145:[[1600,1615],256],65146:[[32,1616],256],65147:[[1600,1616],256],65148:[[32,1617],256],65149:[[1600,1617],256],65150:[[32,1618],256],65151:[[1600,1618],256],65152:[[1569],256],65153:[[1570],256],65154:[[1570],256],65155:[[1571],256],65156:[[1571],256],65157:[[1572],256],65158:[[1572],256],65159:[[1573],256],65160:[[1573],256],65161:[[1574],256],65162:[[1574],256],65163:[[1574],256],65164:[[1574],256],65165:[[1575],256],65166:[[1575],256],65167:[[1576],256],65168:[[1576],256],65169:[[1576],256],65170:[[1576],256],65171:[[1577],256],65172:[[1577],256],65173:[[1578],256],65174:[[1578],256],65175:[[1578],256],65176:[[1578],256],65177:[[1579],256],65178:[[1579],256],65179:[[1579],256],65180:[[1579],256],65181:[[1580],256],65182:[[1580],256],65183:[[1580],256],65184:[[1580],256],65185:[[1581],256],65186:[[1581],256],65187:[[1581],256],65188:[[1581],256],65189:[[1582],256],65190:[[1582],256],65191:[[1582],256],65192:[[1582],256],65193:[[1583],256],65194:[[1583],256],65195:[[1584],256],65196:[[1584],256],65197:[[1585],256],65198:[[1585],256],65199:[[1586],256],65200:[[1586],256],65201:[[1587],256],65202:[[1587],256],65203:[[1587],256],65204:[[1587],256],65205:[[1588],256],65206:[[1588],256],65207:[[1588],256],65208:[[1588],256],65209:[[1589],256],65210:[[1589],256],65211:[[1589],256],65212:[[1589],256],65213:[[1590],256],65214:[[1590],256],65215:[[1590],256],65216:[[1590],256],65217:[[1591],256],65218:[[1591],256],65219:[[1591],256],65220:[[1591],256],65221:[[1592],256],65222:[[1592],256],65223:[[1592],256],65224:[[1592],256],65225:[[1593],256],65226:[[1593],256],65227:[[1593],256],65228:[[1593],256],65229:[[1594],256],65230:[[1594],256],65231:[[1594],256],65232:[[1594],256],65233:[[1601],256],65234:[[1601],256],65235:[[1601],256],65236:[[1601],256],65237:[[1602],256],65238:[[1602],256],65239:[[1602],256],65240:[[1602],256],65241:[[1603],256],65242:[[1603],256],65243:[[1603],256],65244:[[1603],256],65245:[[1604],256],65246:[[1604],256],65247:[[1604],256],65248:[[1604],256],65249:[[1605],256],65250:[[1605],256],65251:[[1605],256],65252:[[1605],256],65253:[[1606],256],65254:[[1606],256],65255:[[1606],256],65256:[[1606],256],65257:[[1607],256],65258:[[1607],256],65259:[[1607],256],65260:[[1607],256],65261:[[1608],256],65262:[[1608],256],65263:[[1609],256],65264:[[1609],256],65265:[[1610],256],65266:[[1610],256],65267:[[1610],256],65268:[[1610],256],65269:[[1604,1570],256],65270:[[1604,1570],256],65271:[[1604,1571],256],65272:[[1604,1571],256],65273:[[1604,1573],256],65274:[[1604,1573],256],65275:[[1604,1575],256],65276:[[1604,1575],256]}, - 65280:{65281:[[33],256],65282:[[34],256],65283:[[35],256],65284:[[36],256],65285:[[37],256],65286:[[38],256],65287:[[39],256],65288:[[40],256],65289:[[41],256],65290:[[42],256],65291:[[43],256],65292:[[44],256],65293:[[45],256],65294:[[46],256],65295:[[47],256],65296:[[48],256],65297:[[49],256],65298:[[50],256],65299:[[51],256],65300:[[52],256],65301:[[53],256],65302:[[54],256],65303:[[55],256],65304:[[56],256],65305:[[57],256],65306:[[58],256],65307:[[59],256],65308:[[60],256],65309:[[61],256],65310:[[62],256],65311:[[63],256],65312:[[64],256],65313:[[65],256],65314:[[66],256],65315:[[67],256],65316:[[68],256],65317:[[69],256],65318:[[70],256],65319:[[71],256],65320:[[72],256],65321:[[73],256],65322:[[74],256],65323:[[75],256],65324:[[76],256],65325:[[77],256],65326:[[78],256],65327:[[79],256],65328:[[80],256],65329:[[81],256],65330:[[82],256],65331:[[83],256],65332:[[84],256],65333:[[85],256],65334:[[86],256],65335:[[87],256],65336:[[88],256],65337:[[89],256],65338:[[90],256],65339:[[91],256],65340:[[92],256],65341:[[93],256],65342:[[94],256],65343:[[95],256],65344:[[96],256],65345:[[97],256],65346:[[98],256],65347:[[99],256],65348:[[100],256],65349:[[101],256],65350:[[102],256],65351:[[103],256],65352:[[104],256],65353:[[105],256],65354:[[106],256],65355:[[107],256],65356:[[108],256],65357:[[109],256],65358:[[110],256],65359:[[111],256],65360:[[112],256],65361:[[113],256],65362:[[114],256],65363:[[115],256],65364:[[116],256],65365:[[117],256],65366:[[118],256],65367:[[119],256],65368:[[120],256],65369:[[121],256],65370:[[122],256],65371:[[123],256],65372:[[124],256],65373:[[125],256],65374:[[126],256],65375:[[10629],256],65376:[[10630],256],65377:[[12290],256],65378:[[12300],256],65379:[[12301],256],65380:[[12289],256],65381:[[12539],256],65382:[[12530],256],65383:[[12449],256],65384:[[12451],256],65385:[[12453],256],65386:[[12455],256],65387:[[12457],256],65388:[[12515],256],65389:[[12517],256],65390:[[12519],256],65391:[[12483],256],65392:[[12540],256],65393:[[12450],256],65394:[[12452],256],65395:[[12454],256],65396:[[12456],256],65397:[[12458],256],65398:[[12459],256],65399:[[12461],256],65400:[[12463],256],65401:[[12465],256],65402:[[12467],256],65403:[[12469],256],65404:[[12471],256],65405:[[12473],256],65406:[[12475],256],65407:[[12477],256],65408:[[12479],256],65409:[[12481],256],65410:[[12484],256],65411:[[12486],256],65412:[[12488],256],65413:[[12490],256],65414:[[12491],256],65415:[[12492],256],65416:[[12493],256],65417:[[12494],256],65418:[[12495],256],65419:[[12498],256],65420:[[12501],256],65421:[[12504],256],65422:[[12507],256],65423:[[12510],256],65424:[[12511],256],65425:[[12512],256],65426:[[12513],256],65427:[[12514],256],65428:[[12516],256],65429:[[12518],256],65430:[[12520],256],65431:[[12521],256],65432:[[12522],256],65433:[[12523],256],65434:[[12524],256],65435:[[12525],256],65436:[[12527],256],65437:[[12531],256],65438:[[12441],256],65439:[[12442],256],65440:[[12644],256],65441:[[12593],256],65442:[[12594],256],65443:[[12595],256],65444:[[12596],256],65445:[[12597],256],65446:[[12598],256],65447:[[12599],256],65448:[[12600],256],65449:[[12601],256],65450:[[12602],256],65451:[[12603],256],65452:[[12604],256],65453:[[12605],256],65454:[[12606],256],65455:[[12607],256],65456:[[12608],256],65457:[[12609],256],65458:[[12610],256],65459:[[12611],256],65460:[[12612],256],65461:[[12613],256],65462:[[12614],256],65463:[[12615],256],65464:[[12616],256],65465:[[12617],256],65466:[[12618],256],65467:[[12619],256],65468:[[12620],256],65469:[[12621],256],65470:[[12622],256],65474:[[12623],256],65475:[[12624],256],65476:[[12625],256],65477:[[12626],256],65478:[[12627],256],65479:[[12628],256],65482:[[12629],256],65483:[[12630],256],65484:[[12631],256],65485:[[12632],256],65486:[[12633],256],65487:[[12634],256],65490:[[12635],256],65491:[[12636],256],65492:[[12637],256],65493:[[12638],256],65494:[[12639],256],65495:[[12640],256],65498:[[12641],256],65499:[[12642],256],65500:[[12643],256],65504:[[162],256],65505:[[163],256],65506:[[172],256],65507:[[175],256],65508:[[166],256],65509:[[165],256],65510:[[8361],256],65512:[[9474],256],65513:[[8592],256],65514:[[8593],256],65515:[[8594],256],65516:[[8595],256],65517:[[9632],256],65518:[[9675],256]} -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/implement.js deleted file mode 100644 index cfc710ea439174..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/implement.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(String.prototype, 'normalize', - { value: require('./shim'), configurable: true, enumerable: false, - writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/index.js deleted file mode 100644 index 619b0965d69b9e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? String.prototype.normalize - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/is-implemented.js deleted file mode 100644 index 67c8d8da5cad63..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var str = 'æøåäüö'; - -module.exports = function () { - if (typeof str.normalize !== 'function') return false; - return str.normalize('NFKD') === 'æøåäüö'; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/shim.js deleted file mode 100644 index a379989775737a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/normalize/shim.js +++ /dev/null @@ -1,289 +0,0 @@ -// Taken from: https://github.com/walling/unorm/blob/master/lib/unorm.js - -/* - * UnicodeNormalizer 1.0.0 - * Copyright (c) 2008 Matsuza - * Dual licensed under the MIT (MIT-LICENSE.txt) and - * GPL (GPL-LICENSE.txt) licenses. - * $Date: 2008-06-05 16:44:17 +0200 (Thu, 05 Jun 2008) $ - * $Rev: 13309 $ -*/ - -'use strict'; - -var primitiveSet = require('../../../object/primitive-set') - , validValue = require('../../../object/valid-value') - , data = require('./_data') - - , floor = Math.floor - , forms = primitiveSet('NFC', 'NFD', 'NFKC', 'NFKD') - - , DEFAULT_FEATURE = [null, 0, {}], CACHE_THRESHOLD = 10, SBase = 0xAC00 - , LBase = 0x1100, VBase = 0x1161, TBase = 0x11A7, LCount = 19, VCount = 21 - , TCount = 28, NCount = VCount * TCount, SCount = LCount * NCount - , UChar, cache = {}, cacheCounter = [], i, fromCache, fromData, fromCpOnly - , fromRuleBasedJamo, fromCpFilter, strategies, UCharIterator - , RecursDecompIterator, DecompIterator, CompIterator, createIterator - , normalize; - -UChar = function (cp, feature) { - this.codepoint = cp; - this.feature = feature; -}; - -// Strategies -for (i = 0; i <= 0xFF; ++i) cacheCounter[i] = 0; - -fromCache = function (next, cp, needFeature) { - var ret = cache[cp]; - if (!ret) { - ret = next(cp, needFeature); - if (!!ret.feature && ++cacheCounter[(cp >> 8) & 0xFF] > CACHE_THRESHOLD) { - cache[cp] = ret; - } - } - return ret; -}; - -fromData = function (next, cp, needFeature) { - var hash = cp & 0xFF00, dunit = UChar.udata[hash] || {}, f = dunit[cp]; - return f ? new UChar(cp, f) : new UChar(cp, DEFAULT_FEATURE); -}; -fromCpOnly = function (next, cp, needFeature) { - return !!needFeature ? next(cp, needFeature) : new UChar(cp, null); -}; - -fromRuleBasedJamo = function (next, cp, needFeature) { - var c, base, i, arr, SIndex, TIndex, feature, j; - if (cp < LBase || (LBase + LCount <= cp && cp < SBase) || - (SBase + SCount < cp)) { - return next(cp, needFeature); - } - if (LBase <= cp && cp < LBase + LCount) { - c = {}; - base = (cp - LBase) * VCount; - for (i = 0; i < VCount; ++i) { - c[VBase + i] = SBase + TCount * (i + base); - } - arr = new Array(3); - arr[2] = c; - return new UChar(cp, arr); - } - - SIndex = cp - SBase; - TIndex = SIndex % TCount; - feature = []; - if (TIndex !== 0) { - feature[0] = [SBase + SIndex - TIndex, TBase + TIndex]; - } else { - feature[0] = [LBase + floor(SIndex / NCount), VBase + - floor((SIndex % NCount) / TCount)]; - feature[2] = {}; - for (j = 1; j < TCount; ++j) { - feature[2][TBase + j] = cp + j; - } - } - return new UChar(cp, feature); -}; - -fromCpFilter = function (next, cp, needFeature) { - return (cp < 60) || ((13311 < cp) && (cp < 42607)) - ? new UChar(cp, DEFAULT_FEATURE) : next(cp, needFeature); -}; - -strategies = [fromCpFilter, fromCache, fromCpOnly, fromRuleBasedJamo, fromData]; - -UChar.fromCharCode = strategies.reduceRight(function (next, strategy) { - return function (cp, needFeature) { return strategy(next, cp, needFeature); }; -}, null); - -UChar.isHighSurrogate = function (cp) { return cp >= 0xD800 && cp <= 0xDBFF; }; -UChar.isLowSurrogate = function (cp) { return cp >= 0xDC00 && cp <= 0xDFFF; }; - -UChar.prototype.prepFeature = function () { - if (!this.feature) { - this.feature = UChar.fromCharCode(this.codepoint, true).feature; - } -}; - -UChar.prototype.toString = function () { - var x; - if (this.codepoint < 0x10000) return String.fromCharCode(this.codepoint); - x = this.codepoint - 0x10000; - return String.fromCharCode(floor(x / 0x400) + 0xD800, x % 0x400 + 0xDC00); -}; - -UChar.prototype.getDecomp = function () { - this.prepFeature(); - return this.feature[0] || null; -}; - -UChar.prototype.isCompatibility = function () { - this.prepFeature(); - return !!this.feature[1] && (this.feature[1] & (1 << 8)); -}; -UChar.prototype.isExclude = function () { - this.prepFeature(); - return !!this.feature[1] && (this.feature[1] & (1 << 9)); -}; -UChar.prototype.getCanonicalClass = function () { - this.prepFeature(); - return !!this.feature[1] ? (this.feature[1] & 0xff) : 0; -}; -UChar.prototype.getComposite = function (following) { - var cp; - this.prepFeature(); - if (!this.feature[2]) return null; - cp = this.feature[2][following.codepoint]; - return cp ? UChar.fromCharCode(cp) : null; -}; - -UCharIterator = function (str) { - this.str = str; - this.cursor = 0; -}; -UCharIterator.prototype.next = function () { - if (!!this.str && this.cursor < this.str.length) { - var cp = this.str.charCodeAt(this.cursor++), d; - if (UChar.isHighSurrogate(cp) && this.cursor < this.str.length && - UChar.isLowSurrogate((d = this.str.charCodeAt(this.cursor)))) { - cp = (cp - 0xD800) * 0x400 + (d - 0xDC00) + 0x10000; - ++this.cursor; - } - return UChar.fromCharCode(cp); - } - this.str = null; - return null; -}; - -RecursDecompIterator = function (it, cano) { - this.it = it; - this.canonical = cano; - this.resBuf = []; -}; - -RecursDecompIterator.prototype.next = function () { - var recursiveDecomp, uchar; - recursiveDecomp = function (cano, uchar) { - var decomp = uchar.getDecomp(), ret, i, a, j; - if (!!decomp && !(cano && uchar.isCompatibility())) { - ret = []; - for (i = 0; i < decomp.length; ++i) { - a = recursiveDecomp(cano, UChar.fromCharCode(decomp[i])); - //ret.concat(a); //<-why does not this work? - //following block is a workaround. - for (j = 0; j < a.length; ++j) ret.push(a[j]); - } - return ret; - } - return [uchar]; - }; - if (this.resBuf.length === 0) { - uchar = this.it.next(); - if (!uchar) return null; - this.resBuf = recursiveDecomp(this.canonical, uchar); - } - return this.resBuf.shift(); -}; - -DecompIterator = function (it) { - this.it = it; - this.resBuf = []; -}; - -DecompIterator.prototype.next = function () { - var cc, uchar, inspt, uchar2, cc2; - if (this.resBuf.length === 0) { - do { - uchar = this.it.next(); - if (!uchar) break; - cc = uchar.getCanonicalClass(); - inspt = this.resBuf.length; - if (cc !== 0) { - for (inspt; inspt > 0; --inspt) { - uchar2 = this.resBuf[inspt - 1]; - cc2 = uchar2.getCanonicalClass(); - if (cc2 <= cc) break; - } - } - this.resBuf.splice(inspt, 0, uchar); - } while (cc !== 0); - } - return this.resBuf.shift(); -}; - -CompIterator = function (it) { - this.it = it; - this.procBuf = []; - this.resBuf = []; - this.lastClass = null; -}; - -CompIterator.prototype.next = function () { - var uchar, starter, composite, cc; - while (this.resBuf.length === 0) { - uchar = this.it.next(); - if (!uchar) { - this.resBuf = this.procBuf; - this.procBuf = []; - break; - } - if (this.procBuf.length === 0) { - this.lastClass = uchar.getCanonicalClass(); - this.procBuf.push(uchar); - } else { - starter = this.procBuf[0]; - composite = starter.getComposite(uchar); - cc = uchar.getCanonicalClass(); - if (!!composite && (this.lastClass < cc || this.lastClass === 0)) { - this.procBuf[0] = composite; - } else { - if (cc === 0) { - this.resBuf = this.procBuf; - this.procBuf = []; - } - this.lastClass = cc; - this.procBuf.push(uchar); - } - } - } - return this.resBuf.shift(); -}; - -createIterator = function (mode, str) { - switch (mode) { - case "NFD": - return new DecompIterator( - new RecursDecompIterator(new UCharIterator(str), true) - ); - case "NFKD": - return new DecompIterator( - new RecursDecompIterator(new UCharIterator(str), false) - ); - case "NFC": - return new CompIterator(new DecompIterator( - new RecursDecompIterator(new UCharIterator(str), true) - )); - case "NFKC": - return new CompIterator(new DecompIterator( - new RecursDecompIterator(new UCharIterator(str), false) - )); - } - throw mode + " is invalid"; -}; -normalize = function (mode, str) { - var it = createIterator(mode, str), ret = "", uchar; - while (!!(uchar = it.next())) ret += uchar.toString(); - return ret; -}; - -/* Unicode data */ -UChar.udata = data; - -module.exports = function (/*form*/) { - var str = String(validValue(this)), form = arguments[0]; - if (form === undefined) form = 'NFC'; - else form = String(form); - if (!forms[form]) throw new RangeError('Invalid normalization form: ' + form); - return normalize(form, str); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/pad.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/pad.js deleted file mode 100644 index f227f239de98c9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/pad.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var toInteger = require('../../number/to-integer') - , value = require('../../object/valid-value') - , repeat = require('./repeat') - - , abs = Math.abs, max = Math.max; - -module.exports = function (fill/*, length*/) { - var self = String(value(this)) - , sLength = self.length - , length = arguments[1]; - - length = isNaN(length) ? 1 : toInteger(length); - fill = repeat.call(String(fill), abs(length)); - if (length >= 0) return fill.slice(0, max(0, length - sLength)) + self; - return self + (((sLength + length) >= 0) ? '' : fill.slice(length + sLength)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/plain-replace-all.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/plain-replace-all.js deleted file mode 100644 index 678b1cbcff4b8d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/plain-replace-all.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var value = require('../../object/valid-value'); - -module.exports = function (search, replace) { - var index, pos = 0, str = String(value(this)), sl, rl; - search = String(search); - replace = String(replace); - sl = search.length; - rl = replace.length; - while ((index = str.indexOf(search, pos)) !== -1) { - str = str.slice(0, index) + replace + str.slice(index + sl); - pos = index + rl; - } - return str; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/plain-replace.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/plain-replace.js deleted file mode 100644 index 24ce16d3bce6e1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/plain-replace.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var indexOf = String.prototype.indexOf, slice = String.prototype.slice; - -module.exports = function (search, replace) { - var index = indexOf.call(this, search); - if (index === -1) return String(this); - return slice.call(this, 0, index) + replace + - slice.call(this, index + String(search).length); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/implement.js deleted file mode 100644 index 4c39b9fbe66cc6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/implement.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(String.prototype, 'repeat', - { value: require('./shim'), configurable: true, enumerable: false, - writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/index.js deleted file mode 100644 index 15a800e8de9509..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? String.prototype.repeat - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/is-implemented.js deleted file mode 100644 index f7b8750f0fd8be..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/is-implemented.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var str = 'foo'; - -module.exports = function () { - if (typeof str.repeat !== 'function') return false; - return (str.repeat(2) === 'foofoo'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/shim.js deleted file mode 100644 index 0a3928b2c0dd76..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/repeat/shim.js +++ /dev/null @@ -1,22 +0,0 @@ -// Thanks: http://www.2ality.com/2014/01/efficient-string-repeat.html - -'use strict'; - -var value = require('../../../object/valid-value') - , toInteger = require('../../../number/to-integer'); - -module.exports = function (count) { - var str = String(value(this)), result; - count = toInteger(count); - if (count < 0) throw new RangeError("Count must be >= 0"); - if (!isFinite(count)) throw new RangeError("Count must be < ∞"); - result = ''; - if (!count) return result; - while (true) { - if (count & 1) result += str; - count >>>= 1; - if (count <= 0) break; - str += str; - } - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/implement.js deleted file mode 100644 index d4f1eaf547f4a8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/implement.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(String.prototype, 'startsWith', - { value: require('./shim'), configurable: true, enumerable: false, - writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/index.js deleted file mode 100644 index ec66a7c0057878..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? String.prototype.startsWith - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/is-implemented.js deleted file mode 100644 index a0556f196e9afa..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/is-implemented.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var str = 'razdwatrzy'; - -module.exports = function () { - if (typeof str.startsWith !== 'function') return false; - return ((str.startsWith('trzy') === false) && - (str.startsWith('raz') === true)); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/shim.js deleted file mode 100644 index aa5aaf4145ea58..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/starts-with/shim.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var value = require('../../../object/valid-value') - , toInteger = require('../../../number/to-integer') - - , max = Math.max, min = Math.min; - -module.exports = function (searchString/*, position*/) { - var start, self = String(value(this)); - start = min(max(toInteger(arguments[1]), 0), self.length); - return (self.indexOf(searchString, start) === start); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/uncapitalize.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/uncapitalize.js deleted file mode 100644 index bedd7e7b007c5d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/#/uncapitalize.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var ensureStringifiable = require('../../object/validate-stringifiable-value'); - -module.exports = function () { - var str = ensureStringifiable(this); - return str.charAt(0).toLowerCase() + str.slice(1); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/format-method.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/format-method.js deleted file mode 100644 index f1de1e301d4238..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/format-method.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -var isCallable = require('../object/is-callable') - , value = require('../object/valid-value') - - , call = Function.prototype.call; - -module.exports = function (fmap) { - fmap = Object(value(fmap)); - return function (pattern) { - var context = value(this); - pattern = String(pattern); - return pattern.replace(/%([a-zA-Z]+)|\\([\u0000-\uffff])/g, - function (match, token, escape) { - var t, r; - if (escape) return escape; - t = token; - while (t && !(r = fmap[t])) t = t.slice(0, -1); - if (!r) return match; - if (isCallable(r)) r = call.call(r, context); - return r + token.slice(t.length); - }); - }; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/implement.js deleted file mode 100644 index b062331cc597e2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(String, 'fromCodePoint', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/index.js deleted file mode 100644 index 3f3110b6eb1f5a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? String.fromCodePoint - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/is-implemented.js deleted file mode 100644 index 840a20e3f36d87..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/is-implemented.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function () { - var fromCodePoint = String.fromCodePoint; - if (typeof fromCodePoint !== 'function') return false; - return fromCodePoint(0x1D306, 0x61, 0x1D307) === '\ud834\udf06a\ud834\udf07'; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/shim.js deleted file mode 100644 index 41fd7378f81c53..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/from-code-point/shim.js +++ /dev/null @@ -1,30 +0,0 @@ -// Based on: -// http://norbertlindenberg.com/2012/05/ecmascript-supplementary-characters/ -// and: -// https://github.com/mathiasbynens/String.fromCodePoint/blob/master -// /fromcodepoint.js - -'use strict'; - -var floor = Math.floor, fromCharCode = String.fromCharCode; - -module.exports = function (codePoint/*, …codePoints*/) { - var chars = [], l = arguments.length, i, c, result = ''; - for (i = 0; i < l; ++i) { - c = Number(arguments[i]); - if (!isFinite(c) || c < 0 || c > 0x10FFFF || floor(c) !== c) { - throw new RangeError("Invalid code point " + c); - } - - if (c < 0x10000) { - chars.push(c); - } else { - c -= 0x10000; - chars.push((c >> 10) + 0xD800, (c % 0x400) + 0xDC00); - } - if (i + 1 !== l && chars.length <= 0x4000) continue; - result += fromCharCode.apply(null, chars); - chars.length = 0; - } - return result; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/index.js deleted file mode 100644 index dbbcdf61f06cd8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/index.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = { - '#': require('./#'), - formatMethod: require('./format-method'), - fromCodePoint: require('./from-code-point'), - isString: require('./is-string'), - randomUniq: require('./random-uniq'), - raw: require('./raw') -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/is-string.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/is-string.js deleted file mode 100644 index 719aeec16c5aa5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/is-string.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -var toString = Object.prototype.toString - - , id = toString.call(''); - -module.exports = function (x) { - return (typeof x === 'string') || (x && (typeof x === 'object') && - ((x instanceof String) || (toString.call(x) === id))) || false; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/random-uniq.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/random-uniq.js deleted file mode 100644 index 54ae6f8c9fd3c3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/random-uniq.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var generated = Object.create(null) - - , random = Math.random; - -module.exports = function () { - var str; - do { str = random().toString(36).slice(2); } while (generated[str]); - return str; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/implement.js deleted file mode 100644 index c417e659b2086c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -if (!require('./is-implemented')()) { - Object.defineProperty(String, 'raw', { value: require('./shim'), - configurable: true, enumerable: false, writable: true }); -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/index.js deleted file mode 100644 index 504a5de24bf3ce..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = require('./is-implemented')() - ? String.raw - : require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/is-implemented.js deleted file mode 100644 index d7204c0c49e8a9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/is-implemented.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function () { - var raw = String.raw, test; - if (typeof raw !== 'function') return false; - test = ['foo\nbar', 'marko\n']; - test.raw = ['foo\\nbar', 'marko\\n']; - return raw(test, 'INSE\nRT') === 'foo\\nbarINSE\nRTmarko\\n'; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/shim.js deleted file mode 100644 index 7096efbc5671d1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/string/raw/shim.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var toPosInt = require('../../number/to-pos-integer') - , validValue = require('../../object/valid-value') - - , reduce = Array.prototype.reduce; - -module.exports = function (callSite/*, …substitutions*/) { - var args, rawValue = Object(validValue(Object(validValue(callSite)).raw)); - if (!toPosInt(rawValue.length)) return ''; - args = arguments; - return reduce.call(rawValue, function (a, b, i) { - return a + String(args[i]) + b; - }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/__tad.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/__tad.js deleted file mode 100644 index 884577887f5704..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/__tad.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -exports.context = null; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/implement.js deleted file mode 100644 index f0605399e0274e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/@@iterator/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/shim.js deleted file mode 100644 index e590d8f28e7c0e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/@@iterator/shim.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -exports.__generic = function (t, a) { - var iterator = t.call(this); - a.deep(iterator.next(), { value: '1', done: false }); - a.deep(iterator.next(), { value: '2', done: false }); - a.deep(iterator.next(), { value: '3', done: false }); - a.deep(iterator.next(), { value: undefined, done: true }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/_compare-by-length.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/_compare-by-length.js deleted file mode 100644 index e40c305b98fe68..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/_compare-by-length.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = [4, 5, 6], y = { length: 8 }, w = {}, z = { length: 1 }; - - a.deep([x, y, w, z].sort(t), [w, z, x, y]); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/binary-search.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/binary-search.js deleted file mode 100644 index cf3317371b3491..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/binary-search.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var compare = function (value) { return this - value; }; - -module.exports = function (t, a) { - var arr; - arr = [2, 5, 5, 8, 34, 67, 98, 345, 678]; - - // highest, equal match - a(t.call(arr, compare.bind(1)), 0, "All higher"); - a(t.call(arr, compare.bind(679)), arr.length - 1, "All lower"); - a(t.call(arr, compare.bind(4)), 0, "Mid"); - a(t.call(arr, compare.bind(5)), 2, "Match"); - a(t.call(arr, compare.bind(6)), 2, "Above"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/clear.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/clear.js deleted file mode 100644 index a5b1c977ad98cf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/clear.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = [1, 2, {}, 4]; - a(t.call(x), x, "Returns same array"); - a.deep(x, [], "Empties array"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/compact.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/compact.js deleted file mode 100644 index 6390eb26dddf6b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/compact.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = { - __generic: function (t, a) { - a(t.call(this).length, 3); - }, - "": function (t, a) { - var o, x, y, z; - o = {}; - x = [0, 1, "", null, o, false, undefined, true]; - y = x.slice(0); - - a.not(z = t.call(x), x, "Returns different object"); - a.deep(x, y, "Origin not changed"); - a.deep(z, [0, 1, "", o, false, true], "Result"); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/implement.js deleted file mode 100644 index 3bdbe86812aaaa..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/concat/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/shim.js deleted file mode 100644 index c30eb7eab08178..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/concat/shim.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -var SubArray = require('../../../../array/_sub-array-dummy-safe'); - -module.exports = function (t, a) { - var arr = [1, 3, 45], x = {}, subArr, subArr2, result; - - a.deep(t.call(arr, '2d', x, ['ere', 'fe', x], false, null), - [1, 3, 45, '2d', x, 'ere', 'fe', x, false, null], "Plain array"); - - subArr = new SubArray('lol', 'miszko'); - subArr2 = new SubArray('elo', 'fol'); - - result = t.call(subArr, 'df', arr, 'fef', subArr2, null); - a(result instanceof SubArray, true, "Instance of subclass"); - a.deep(result, ['lol', 'miszko', 'df', 1, 3, 45, 'fef', 'elo', 'fol', null], - "Spreable by default"); - - SubArray.prototype['@@isConcatSpreadable'] = false; - - result = t.call(subArr, 'df', arr, 'fef', subArr2, null); - a.deep(result, ['lol', 'miszko', 'df', 1, 3, 45, 'fef', subArr2, null], - "Non spreadable"); - - delete SubArray.prototype['@@isConcatSpreadable']; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/contains.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/contains.js deleted file mode 100644 index 21404a17a61358..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/contains.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -module.exports = { - __generic: function (t, a) { - a(t.call(this, this[1]), true, "Contains"); - a(t.call(this, {}), false, "Does Not contain"); - }, - "": function (t, a) { - var o, x = {}, y = {}; - - o = [1, 'raz', x]; - - a(t.call(o, 1), true, "First"); - a(t.call(o, '1'), false, "Type coercion"); - a(t.call(o, 'raz'), true, "Primitive"); - a(t.call(o, 'foo'), false, "Primitive not found"); - a(t.call(o, x), true, "Object found"); - a(t.call(o, y), false, "Object not found"); - a(t.call(o, 1, 1), false, "Position"); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/implement.js deleted file mode 100644 index 36070477d66802..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/copy-within/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/shim.js deleted file mode 100644 index 93c85ea3114c24..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/copy-within/shim.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var args, x; - - a.h1("2 args"); - x = [1, 2, 3, 4, 5]; - t.call(x, 0, 3); - a.deep(x, [4, 5, 3, 4, 5]); - a.deep(t.call([1, 2, 3, 4, 5], 1, 3), [1, 4, 5, 4, 5]); - a.deep(t.call([1, 2, 3, 4, 5], 1, 2), [1, 3, 4, 5, 5]); - a.deep(t.call([1, 2, 3, 4, 5], 2, 2), [1, 2, 3, 4, 5]); - - a.h1("3 args"); - a.deep(t.call([1, 2, 3, 4, 5], 0, 3, 4), [4, 2, 3, 4, 5]); - a.deep(t.call([1, 2, 3, 4, 5], 1, 3, 4), [1, 4, 3, 4, 5]); - a.deep(t.call([1, 2, 3, 4, 5], 1, 2, 4), [1, 3, 4, 4, 5]); - - a.h1("Negative args"); - a.deep(t.call([1, 2, 3, 4, 5], 0, -2), [4, 5, 3, 4, 5]); - a.deep(t.call([1, 2, 3, 4, 5], 0, -2, -1), [4, 2, 3, 4, 5]); - a.deep(t.call([1, 2, 3, 4, 5], -4, -3, -2), [1, 3, 3, 4, 5]); - a.deep(t.call([1, 2, 3, 4, 5], -4, -3, -1), [1, 3, 4, 4, 5]); - a.deep(t.call([1, 2, 3, 4, 5], -4, -3), [1, 3, 4, 5, 5]); - - a.h1("Array-likes"); - args = { 0: 1, 1: 2, 2: 3, length: 3 }; - a.deep(t.call(args, -2, 0), { '0': 1, '1': 1, '2': 2, length: 3 }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/diff.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/diff.js deleted file mode 100644 index bcfa3a0bd12f84..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/diff.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = { - __generic: function (t, a) { - a.deep(t.call(this, this), []); - }, - "": function (t, a) { - var x = {}, y = {}; - - a.deep(t.call([1, 'raz', x, 2, 'trzy', y], [x, 2, 'trzy']), [1, 'raz', y], - "Scope longer"); - a.deep(t.call([1, 'raz', x], [x, 2, 'trzy', 1, y]), ['raz'], - "Arg longer"); - a.deep(t.call([1, 'raz', x], []), [1, 'raz', x], "Empty arg"); - a.deep(t.call([], [1, y, 'sdfs']), [], "Empty scope"); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/e-index-of.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/e-index-of.js deleted file mode 100644 index 4cf6c6359d44ee..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/e-index-of.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = {}; - a(t.call([3, 'raz', {}, x, {}], x), 3, "Regular"); - a(t.call([3, 'raz', NaN, {}, NaN], NaN), 2, "NaN"); - a(t.call([3, 'raz', 0, {}, -0], -0), 2, "-0"); - a(t.call([3, 'raz', -0, {}, 0], +0), 2, "+0"); - a(t.call([3, 'raz', NaN, {}, NaN], NaN, 3), 4, "fromIndex"); - a(t.call([3, 'raz', NaN, {}, NaN], NaN, -1), 4, "fromIndex negative #1"); - a(t.call([3, 'raz', NaN, {}, NaN], NaN, -2), 4, "fromIndex negative #2"); - a(t.call([3, 'raz', NaN, {}, NaN], NaN, -3), 2, "fromIndex negative #3"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/e-last-index-of.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/e-last-index-of.js deleted file mode 100644 index ed4f700421a8f1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/e-last-index-of.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = {}; - a(t.call([3, 'raz', {}, x, {}, x], x), 5, "Regular"); - a(t.call([3, 'raz', NaN, {}, x], NaN), 2, "NaN"); - a(t.call([3, 'raz', 0, {}, -0], -0), 4, "-0"); - a(t.call([3, 'raz', -0, {}, 0], +0), 4, "+0"); - a(t.call([3, 'raz', NaN, {}, NaN], NaN, 3), 2, "fromIndex"); - a(t.call([3, 'raz', NaN, 2, NaN], NaN, -1), 4, "Negative fromIndex #1"); - a(t.call([3, 'raz', NaN, 2, NaN], NaN, -2), 2, "Negative fromIndex #2"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/implement.js deleted file mode 100644 index 733209a1c80653..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/entries/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/shim.js deleted file mode 100644 index bf40d31005df45..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/entries/shim.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -exports.__generic = function (t, a) { - var iterator = t.call(this); - a.deep(iterator.next(), { value: [0, '1'], done: false }); - a.deep(iterator.next(), { value: [1, '2'], done: false }); - a.deep(iterator.next(), { value: [2, '3'], done: false }); - a.deep(iterator.next(), { value: undefined, done: true }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/exclusion.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/exclusion.js deleted file mode 100644 index 07b32d8e8cbf9b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/exclusion.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = { - __generic: function (t, a) { - var x = {}; - a.deep(t.call(this, this, [this[0], this[2], x]), [x]); - }, - "": function (t, a) { - var x = {}, y = {}; - - a.deep(t.call([x, y]), [x, y], "No arguments"); - a.deep(t.call([x, 1], [], []), [x, 1], "Empty arguments"); - a.deep(t.call([1, 'raz', x], [2, 'raz', y], [2, 'raz', x]), [1, y]); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/implement.js deleted file mode 100644 index 2a01d2850a18a9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/fill/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/shim.js deleted file mode 100644 index d67300fcc23be8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/fill/shim.js +++ /dev/null @@ -1,18 +0,0 @@ -// Taken from https://github.com/paulmillr/es6-shim/blob/master/test/array.js - -'use strict'; - -module.exports = function (t, a) { - var x; - - x = [1, 2, 3, 4, 5, 6]; - a(t.call(x, -1), x, "Returns self object"); - a.deep(x, [-1, -1, -1, -1, -1, -1], "Value"); - - a.deep(t.call([1, 2, 3, 4, 5, 6], -1, 3), [1, 2, 3, -1, -1, -1], - "Positive start"); - a.deep(t.call([1, 2, 3, 4, 5, 6], -1, -3), [1, 2, 3, -1, -1, -1], - "Negative start"); - a.deep(t.call([1, 2, 3, 4, 5, 6], -1, 9), [1, 2, 3, 4, 5, 6], - "Large start"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/implement.js deleted file mode 100644 index 6d6b87cc30a651..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/filter/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/shim.js deleted file mode 100644 index e8b5c39849097f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/filter/shim.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var SubArray = require('../../../../array/_sub-array-dummy-safe'); - -module.exports = function (t, a) { - var arr, x = {}, subArr, result; - - arr = ['foo', undefined, 0, '2d', false, x, null]; - - a.deep(t.call(arr, Boolean), ['foo', '2d', x], "Plain array"); - - subArr = new SubArray('foo', undefined, 0, '2d', false, x, null); - - result = t.call(subArr, Boolean); - a(result instanceof SubArray, true, "Instance of subclass"); - a.deep(result, ['foo', '2d', x], "Result of subclass"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/implement.js deleted file mode 100644 index 8d85e618ccd6bc..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/find-index/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/shim.js deleted file mode 100644 index b5fee463811d49..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find-index/shim.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -exports.__generic = function (t, a) { - var count = 0, o = {}, self = Object(this); - a(t.call(self, function (value, i, scope) { - a(value, this[i], "Value"); - a(i, count++, "Index"); - a(scope, this, "Scope"); - }, self), -1, "Falsy result"); - a(count, 3); - - count = -1; - a(t.call(this, function () { - return ++count ? o : null; - }, this), 1, "Truthy result"); - a(count, 1); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/implement.js deleted file mode 100644 index 29fac41e013353..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/find/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/shim.js deleted file mode 100644 index ad2e645067db5d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/find/shim.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -exports.__generic = function (t, a) { - var count = 0, o = {}, self = Object(this); - a(t.call(self, function (value, i, scope) { - a(value, this[i], "Value"); - a(i, count++, "Index"); - a(scope, this, "Scope"); - }, self), undefined, "Falsy result"); - a(count, 3); - - count = -1; - a(t.call(this, function () { - return ++count ? o : null; - }, this), this[1], "Truthy result"); - a(count, 1); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/first-index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/first-index.js deleted file mode 100644 index 4aebad64b44e51..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/first-index.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x; - a(t.call([]), null, "Empty"); - a(t.call([null]), 0, "One value"); - a(t.call([1, 2, 3]), 0, "Many values"); - a(t.call(new Array(1000)), null, "Sparse empty"); - x = []; - x[883] = undefined; - x[890] = null; - a(t.call(x), 883, "Manual sparse, distant value"); - x = new Array(1000); - x[657] = undefined; - x[700] = null; - a(t.call(x), 657, "Sparse, distant value"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/first.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/first.js deleted file mode 100644 index 87fde0357ef1b0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/first.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -exports.__generic = function (t, a) { - a(t.call(this), this[0]); -}; -exports[''] = function (t, a) { - var x; - a(t.call([]), undefined, "Empty"); - a(t.call(new Array(234), undefined, "Sparse empty")); - x = new Array(2342); - x[434] = {}; - a(t.call(x), x[434], "Sparse"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/flatten.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/flatten.js deleted file mode 100644 index 65f1214b04da93..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/flatten.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var o = [1, 2, [3, 4, [5, 6], 7, 8], 9, 10]; - -module.exports = { - __generic: function (t, a) { - a(t.call(this).length, 3); - }, - "Nested Arrays": function (t, a) { - a(t.call(o).length, 10); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/for-each-right.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/for-each-right.js deleted file mode 100644 index 2d24569d94d86d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/for-each-right.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; - -module.exports = { - __generic: function (t, a) { - var count = 0, first, last, x, icount = this.length; - t.call(this, function (item, index, col) { - ++count; - if (!first) { - first = item; - } - last = item; - x = col; - a(index, --icount, "Index"); - }); - a(count, this.length, "Iterated"); - a(first, this[this.length - 1], "First is last"); - a(last, this[0], "Last is first"); - a.deep(x, Object(this), "Collection as third argument"); //jslint: skip - }, - "": function (t, a) { - var x = {}, y, count; - t.call([1], function () { y = this; }, x); - a(y, x, "Scope"); - y = 0; - t.call([3, 4, 4], function (a, i) { y += i; }); - a(y, 3, "Indexes"); - - x = [1, 3]; - x[5] = 'x'; - y = 0; - count = 0; - t.call(x, function (a, i) { ++count; y += i; }); - a(y, 6, "Misssing Indexes"); - a(count, 3, "Misssing Indexes, count"); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/group.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/group.js deleted file mode 100644 index 32dc8c2dbb68bf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/group.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -module.exports = { - __generic: function (t, a) { - var count = 0, self; - - self = Object(this); - a.deep(t.call(self, function (v, i, scope) { - a(v, this[i], "Value"); - a(i, count++, "Index"); - a(scope, this, "Scope"); - return i; - }, self), { 0: [this[0]], 1: [this[1]], 2: [this[2]] }); - }, - "": function (t, a) { - var r; - r = t.call([2, 3, 3, 4, 5, 6, 7, 7, 23, 45, 34, 56], - function (v) { - return v % 2 ? 'odd' : 'even'; - }); - a.deep(r.odd, [3, 3, 5, 7, 7, 23, 45]); - a.deep(r.even, [2, 4, 6, 34, 56]); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/indexes-of.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/indexes-of.js deleted file mode 100644 index 3364170f1ec4a9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/indexes-of.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = { - __generic: function (t, a) { - a.deep(t.call(this, this[1]), [1]); - }, - "": function (t, a) { - var x = {}; - a.deep(t.call([1, 3, 5, 3, 5], 6), [], "No result"); - a.deep(t.call([1, 3, 5, 1, 3, 5, 1], 1), [0, 3, 6], "Some results"); - a.deep(t.call([], x), [], "Empty array"); - a.deep(t.call([x, 3, {}, x, 3, 5, x], x), [0, 3, 6], "Search for object"); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/intersection.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/intersection.js deleted file mode 100644 index b72b2fb074fc46..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/intersection.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -var toArray = require('../../../array/to-array'); - -module.exports = { - __generic: function (t, a) { - a.deep(t.call(this, this, this), toArray(this)); - }, - "": function (t, a) { - var x = {}, y = {}, p, r; - a.deep(t.call([], [2, 3, 4]), [], "Empty #1"); - a.deep(t.call([2, 3, 4], []), [], "Empty #2"); - a.deep(t.call([2, 3, x], [y, 5, 7]), [], "Different"); - p = t.call([3, 5, 'raz', {}, 'dwa', x], [1, 3, 'raz', 'dwa', 'trzy', x, {}], - [3, 'raz', x, 65]); - r = [3, 'raz', x]; - p.sort(); - r.sort(); - a.deep(p, r, "Same parts"); - a.deep(t.call(r, r), r, "Same"); - a.deep(t.call([1, 2, x, 4, 5, y, 7], [7, y, 5, 4, x, 2, 1]), - [1, 2, x, 4, 5, y, 7], "Long reverse same"); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/is-copy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/is-copy.js deleted file mode 100644 index e7f80e7a8d4ebc..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/is-copy.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = {}; - a(t.call([], []), true, "Empty"); - a(t.call([], {}), true, "Empty lists"); - a(t.call([1, x, 'raz'], [1, x, 'raz']), true, "Same"); - a(t.call([1, x, 'raz'], { 0: 1, 1: x, 2: 'raz', length: 3 }), true, - "Same lists"); - a(t.call([1, x, 'raz'], [x, 1, 'raz']), false, "Diff order"); - a(t.call([1, x], [1, x, 'raz']), false, "Diff length #1"); - a(t.call([1, x, 'raz'], [1, x]), false, "Diff length #2"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/is-uniq.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/is-uniq.js deleted file mode 100644 index 7349ba337135a7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/is-uniq.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = {}; - a(t.call([]), true, "Empty"); - a(t.call({}), true, "Empty lists"); - a(t.call([1, x, 'raz']), true, "Uniq"); - a(t.call([1, x, 1, 'raz']), false, "Not Uniq: primitive"); - a(t.call([1, x, '1', 'raz']), true, "Uniq: primitive"); - a(t.call([1, x, 1, {}, 'raz']), false, "Not Uniq: Obj"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/implement.js deleted file mode 100644 index b0c1aa078f190e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/keys/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/shim.js deleted file mode 100644 index a43c04cac103a6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/keys/shim.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -exports.__generic = function (t, a) { - var iterator = t.call(this); - a.deep(iterator.next(), { value: 0, done: false }); - a.deep(iterator.next(), { value: 1, done: false }); - a.deep(iterator.next(), { value: 2, done: false }); - a.deep(iterator.next(), { value: undefined, done: true }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/last-index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/last-index.js deleted file mode 100644 index a1cac1073f8862..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/last-index.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x; - a(t.call([]), null, "Empty"); - a(t.call([null]), 0, "One value"); - a(t.call([1, 2, 3]), 2, "Many values"); - a(t.call(new Array(1000)), null, "Sparse empty"); - x = []; - x[883] = null; - x[890] = undefined; - a(t.call(x), 890, "Manual sparse, distant value"); - x = new Array(1000); - x[657] = null; - x[700] = undefined; - a(t.call(x), 700, "Sparse, distant value"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/last.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/last.js deleted file mode 100644 index 8d051bc8d2f5df..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/last.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -exports.__generic = function (t, a) { - a(t.call(this), this[this.length - 1]); -}; - -exports[''] = function (t, a) { - var x; - a(t.call([]), undefined, "Empty"); - a(t.call(new Array(234), undefined, "Sparse empty")); - x = new Array(2342); - x[434] = {}; - x[450] = {}; - a(t.call(x), x[450], "Sparse"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/implement.js deleted file mode 100644 index cdcbc8df6206a5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/map/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/shim.js deleted file mode 100644 index bbfefe8e333dc8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/map/shim.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var SubArray = require('../../../../array/_sub-array-dummy-safe'); - -module.exports = function (t, a) { - var arr, x = {}, subArr, result; - - arr = ['foo', undefined, 0, '2d', false, x, null]; - - a.deep(t.call(arr, Boolean), [true, false, false, true, false, true, false], - "Plain array"); - - subArr = new SubArray('foo', undefined, 0, '2d', false, x, null); - - result = t.call(subArr, Boolean); - a(result instanceof SubArray, true, "Instance of subclass"); - a.deep(result, [true, false, false, true, false, true, false], - "Result of subclass"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/remove.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/remove.js deleted file mode 100644 index 3ebdca2d0183df..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/remove.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var y = {}, z = {}, x = [9, z, 5, y, 'foo']; - t.call(x, y); - a.deep(x, [9, z, 5, 'foo']); - t.call(x, {}); - a.deep(x, [9, z, 5, 'foo'], "Not existing"); - t.call(x, 5); - a.deep(x, [9, z, 'foo'], "Primitive"); - x = [9, z, 5, y, 'foo']; - t.call(x, z, 5, 'foo'); - a.deep(x, [9, y], "More than one argument"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/separate.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/separate.js deleted file mode 100644 index 42918b59711e32..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/separate.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = [], y = {}, z = {}; - a.deep(t.call(x, y), [], "Empty"); - a.not(t.call(x), x, "Returns copy"); - a.deep(t.call([1], y), [1], "One"); - a.deep(t.call([1, 'raz'], y), [1, y, 'raz'], "One"); - a.deep(t.call([1, 'raz', x], y), [1, y, 'raz', y, x], "More"); - x = new Array(1000); - x[23] = 2; - x[3453] = 'raz'; - x[500] = z; - a.deep(t.call(x, y), [2, y, z, y, 'raz'], "Sparse"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/implement.js deleted file mode 100644 index 855ae2fa4df88e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/slice/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/shim.js deleted file mode 100644 index f674f3470037f7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/slice/shim.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -var SubArray = require('../../../../array/_sub-array-dummy-safe'); - -module.exports = function (t, a) { - var arr, x = {}, subArr, result; - - arr = ['foo', undefined, 0, '2d', false, x, null]; - - a.deep(t.call(arr, 2, 4), [0, '2d'], "Plain array: result"); - - subArr = new SubArray('foo', undefined, 0, '2d', false, x, null); - - result = t.call(subArr, 2, 4); - a(result instanceof SubArray, true, "Instance of subclass"); - a.deep(result, [0, '2d'], "Subclass: result"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/some-right.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/some-right.js deleted file mode 100644 index 900771a6f818a4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/some-right.js +++ /dev/null @@ -1,43 +0,0 @@ -'use strict'; - -module.exports = { - __generic: function (t, a) { - var count = 0, first, last, x, icount = this.length; - t.call(this, function (item, index, col) { - ++count; - if (!first) { - first = item; - } - last = item; - x = col; - a(index, --icount, "Index"); - }); - a(count, this.length, "Iterated"); - a(first, this[this.length - 1], "First is last"); - a(last, this[0], "Last is first"); - a.deep(x, Object(this), "Collection as third argument"); //jslint: skip - }, - "": function (t, a) { - var x = {}, y, count; - t.call([1], function () { y = this; }, x); - a(y, x, "Scope"); - y = 0; - t.call([3, 4, 4], function (a, i) { y += i; }); - a(y, 3, "Indexes"); - - x = [1, 3]; - x[5] = 'x'; - y = 0; - count = 0; - a(t.call(x, function (a, i) { ++count; y += i; }), false, "Return"); - a(y, 6, "Misssing Indexes"); - a(count, 3, "Misssing Indexes, count"); - - count = 0; - a(t.call([-2, -3, -4, 2, -5], function (item) { - ++count; - return item > 0; - }), true, "Return"); - a(count, 2, "Break after true is returned"); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/implement.js deleted file mode 100644 index 0d9f46188b528b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/splice/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/shim.js deleted file mode 100644 index 2c751e672400e6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/splice/shim.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var SubArray = require('../../../../array/_sub-array-dummy-safe'); - -module.exports = function (t, a) { - var arr, x = {}, subArr, result; - - arr = ['foo', undefined, 0, '2d', false, x, null]; - - a.deep(t.call(arr, 2, 2, 'bar'), [0, '2d'], "Plain array: result"); - a.deep(arr, ["foo", undefined, "bar", false, x, null], "Plain array: change"); - - subArr = new SubArray('foo', undefined, 0, '2d', false, x, null); - - result = t.call(subArr, 2, 2, 'bar'); - a(result instanceof SubArray, true, "Instance of subclass"); - a.deep(result, [0, '2d'], "Subclass: result"); - a.deep(subArr, ["foo", undefined, "bar", false, x, null], "Subclass: change"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/uniq.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/uniq.js deleted file mode 100644 index 2f7e6c4ed1feb5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/uniq.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = { - __generic: function (t, a) { - a(t.call(this).length, 3); - }, - "": function (t, a) { - var o, x = {}, y = {}, z = {}, w; - o = [1, 2, x, 3, 1, 'raz', '1', y, x, 'trzy', z, 'raz']; - - a.not(w = t.call(o), o, "Returns different object"); - a.deep(w, [1, 2, x, 3, 'raz', '1', y, 'trzy', z], "Result"); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/implement.js deleted file mode 100644 index 9f40138c254b30..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../array/#/values/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/shim.js deleted file mode 100644 index e590d8f28e7c0e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/#/values/shim.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -exports.__generic = function (t, a) { - var iterator = t.call(this); - a.deep(iterator.next(), { value: '1', done: false }); - a.deep(iterator.next(), { value: '2', done: false }); - a.deep(iterator.next(), { value: '3', done: false }); - a.deep(iterator.next(), { value: undefined, done: true }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/__scopes.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/__scopes.js deleted file mode 100644 index 6bfdcbc9494a87..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/__scopes.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -exports.Array = ['1', '2', '3']; - -exports.Arguments = (function () { - return arguments; -}('1', '2', '3')); - -exports.String = "123"; - -exports.Object = { 0: '1', 1: '2', 2: '3', 3: '4', length: 3 }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/_is-extensible.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/_is-extensible.js deleted file mode 100644 index d387126fe111ed..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/_is-extensible.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(typeof t, 'boolean'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/_sub-array-dummy-safe.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/_sub-array-dummy-safe.js deleted file mode 100644 index 29d8699d461a85..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/_sub-array-dummy-safe.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var isArray = Array.isArray; - -module.exports = function (t, a) { - t((t === null) || isArray(t.prototype), true); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/_sub-array-dummy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/_sub-array-dummy.js deleted file mode 100644 index 29d8699d461a85..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/_sub-array-dummy.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var isArray = Array.isArray; - -module.exports = function (t, a) { - t((t === null) || isArray(t.prototype), true); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/implement.js deleted file mode 100644 index e0db846f99a0d9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../array/from/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/shim.js deleted file mode 100644 index 310302ac486645..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/from/shim.js +++ /dev/null @@ -1,60 +0,0 @@ -// Some tests taken from: https://github.com/mathiasbynens/Array.from/blob/master/tests/tests.js - -'use strict'; - -module.exports = function (t, a) { - var o = [1, 2, 3], MyType; - a.not(t(o), o, "Array"); - a.deep(t(o), o, "Array: same content"); - a.deep(t('12r3v'), ['1', '2', 'r', '3', 'v'], "String"); - a.deep(t((function () { return arguments; }(3, o, 'raz'))), - [3, o, 'raz'], "Arguments"); - a.deep(t((function () { return arguments; }(3))), [3], - "Arguments with one numeric value"); - - a.deep(t({ 0: 'raz', 1: 'dwa', length: 2 }), ['raz', 'dwa'], "Other"); - - a.deep(t(o, function (val) { return (val + 2) * 10; }, 10), [30, 40, 50], - "Mapping"); - - a.throws(function () { t(); }, TypeError, "Undefined"); - a.deep(t(3), [], "Primitive"); - - a(t.length, 1, "Length"); - a.deep(t({ length: 0 }), [], "No values Array-like"); - a.deep(t({ length: -1 }), [], "Invalid length Array-like"); - a.deep(t({ length: -Infinity }), [], "Invalid length Array-like #2"); - a.throws(function () { t(undefined); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "Null"); - a.deep(t(false), [], "Boolean"); - a.deep(t(-Infinity), [], "Inifity"); - a.deep(t(-0), [], "-0"); - a.deep(t(+0), [], "+0"); - a.deep(t(1), [], "1"); - a.deep(t(+Infinity), [], "+Infinity"); - a.deep(t({}), [], "Plain object"); - a.deep(t({ length: 1 }), [undefined], "Sparse array-like"); - a.deep(t({ '0': 'a', '1': 'b', length: 2 }, function (x) { return x + x; }), ['aa', 'bb'], - "Map"); - a.deep(t({ '0': 'a', '1': 'b', length: 2 }, function (x) { return String(this); }, undefined), - ['undefined', 'undefined'], "Map context"); - a.deep(t({ '0': 'a', '1': 'b', length: 2 }, function (x) { return String(this); }, 'x'), - ['x', 'x'], "Map primitive context"); - a.throws(function () { t({}, 'foo', 'x'); }, TypeError, "Non callable for map"); - - a.deep(t.call(null, { length: 1, '0': 'a' }), ['a'], "Null context"); - - a(t({ __proto__: { '0': 'abc', length: 1 } })[0], 'abc', "Values on prototype"); - - a.throws(function () { t.call(function () { return Object.freeze({}); }, {}); }, - TypeError, "Contructor producing freezed objects"); - - // Ensure no setters are called for the indexes - // Ensure no setters are called for the indexes - MyType = function () {}; - Object.defineProperty(MyType.prototype, '0', { - set: function (x) { throw new Error('Setter called: ' + x); } - }); - a.deep(t.call(MyType, { '0': 'abc', length: 1 }), { '0': 'abc', length: 1 }, - "Defined not set"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/generate.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/generate.js deleted file mode 100644 index d72e056887838b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/generate.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = {}, y = {}; - a.deep(t(3), [undefined, undefined, undefined], "Just length"); - a.deep(t(0, 'x'), [], "No repeat"); - a.deep(t(1, x, y), [x], "Arguments length larger than repeat number"); - a.deep(t(3, x), [x, x, x], "Single argument"); - a.deep(t(5, x, y), [x, y, x, y, x], "Many arguments"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/is-plain-array.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/is-plain-array.js deleted file mode 100644 index 871a08aec21ff9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/is-plain-array.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var SubArray = require('../../array/_sub-array-dummy-safe'); - -module.exports = function (t, a) { - var arr = [1, 2, 3]; - a(t(arr), true, "Array"); - a(t(null), false, "Null"); - a(t(), false, "Undefined"); - a(t('234'), false, "String"); - a(t(23), false, "Number"); - a(t({}), false, "Plain object"); - a(t({ length: 1, 0: 'raz' }), false, "Array-like"); - a(t(Object.create(arr)), false, "Array extension"); - if (!SubArray) return; - a(t(new SubArray(23)), false, "Subclass instance"); - a(t(Array.prototype), false, "Array.prototype"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/implement.js deleted file mode 100644 index 30d53be2d7abbe..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../array/of/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/shim.js deleted file mode 100644 index e6974420c1c274..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/of/shim.js +++ /dev/null @@ -1,68 +0,0 @@ -// Most tests taken from https://github.com/mathiasbynens/Array.of/blob/master/tests/tests.js -// Thanks @mathiasbynens - -'use strict'; - -var defineProperty = Object.defineProperty; - -module.exports = function (t, a) { - var x = {}, testObject, MyType; - - a.deep(t(), [], "No arguments"); - a.deep(t(3), [3], "One numeric argument"); - a.deep(t(3, 'raz', null, x, undefined), [3, 'raz', null, x, undefined], - "Many arguments"); - - a(t.length, 0, "Length"); - - a.deep(t('abc'), ['abc'], "String"); - a.deep(t(undefined), [undefined], "Undefined"); - a.deep(t(null), [null], "Null"); - a.deep(t(false), [false], "Boolean"); - a.deep(t(-Infinity), [-Infinity], "Infinity"); - a.deep(t(-0), [-0], "-0"); - a.deep(t(+0), [+0], "+0"); - a.deep(t(1), [1], "1"); - a.deep(t(1, 2, 3), [1, 2, 3], "Numeric args"); - a.deep(t(+Infinity), [+Infinity], "+Infinity"); - a.deep(t({ '0': 'a', '1': 'b', '2': 'c', length: 3 }), - [{ '0': 'a', '1': 'b', '2': 'c', length: 3 }], "Array like"); - a.deep(t(undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity), - [undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity], "Falsy arguments"); - - a.h1("Null context"); - a.deep(t.call(null, 'abc'), ['abc'], "String"); - a.deep(t.call(null, undefined), [undefined], "Undefined"); - a.deep(t.call(null, null), [null], "Null"); - a.deep(t.call(null, false), [false], "Boolean"); - a.deep(t.call(null, -Infinity), [-Infinity], "-Infinity"); - a.deep(t.call(null, -0), [-0], "-0"); - a.deep(t.call(null, +0), [+0], "+0"); - a.deep(t.call(null, 1), [1], "1"); - a.deep(t.call(null, 1, 2, 3), [1, 2, 3], "Numeric"); - a.deep(t.call(null, +Infinity), [+Infinity], "+Infinity"); - a.deep(t.call(null, { '0': 'a', '1': 'b', '2': 'c', length: 3 }), - [{ '0': 'a', '1': 'b', '2': 'c', length: 3 }], "Array-like"); - a.deep(t.call(null, undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity), - [undefined, null, false, -Infinity, -0, +0, 1, 2, +Infinity], "Falsy"); - - a.h1("Other constructor context"); - a.deep(t.call(Object, 1, 2, 3), { '0': 1, '1': 2, '2': 3, length: 3 }, "Many arguments"); - - testObject = Object(3); - testObject[0] = 1; - testObject[1] = 2; - testObject[2] = 3; - testObject.length = 3; - a.deep(t.call(Object, 1, 2, 3), testObject, "Test object"); - a(t.call(Object).length, 0, "No arguments"); - a.throws(function () { t.call(function () { return Object.freeze({}); }); }, TypeError, - "Frozen instance"); - - // Ensure no setters are called for the indexes - MyType = function () {}; - defineProperty(MyType.prototype, '0', { - set: function (x) { throw new Error('Setter called: ' + x); } - }); - a.deep(t.call(MyType, 'abc'), { '0': 'abc', length: 1 }, "Define, not set"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/to-array.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/to-array.js deleted file mode 100644 index 4985b5eaee9769..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/to-array.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o = [1, 2, 3]; - a(t(o), o, "Array"); - a.deep(t('12r3v'), ['1', '2', 'r', '3', 'v'], "String"); - a.deep(t((function () { return arguments; }(3, o, 'raz'))), - [3, o, 'raz'], "Arguments"); - a.deep(t((function () { return arguments; }(3))), [3], - "Arguments with one numeric value"); - - a.deep(t({ 0: 'raz', 1: 'dwa', length: 2 }), ['raz', 'dwa'], "Other"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/valid-array.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/valid-array.js deleted file mode 100644 index 3732192d1bbd1f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/array/valid-array.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x; - a.throws(function () { t(); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "Null"); - a.throws(function () { t(0); }, TypeError, "Number"); - a.throws(function () { t(true); }, TypeError, "Boolean"); - a.throws(function () { t('raz'); }, TypeError, "String"); - a.throws(function () { t(function () {}); }, TypeError, "Function"); - a.throws(function () { t({}); }, TypeError, "Object"); - a.throws(function () { t({ length: 0 }); }, TypeError, "Array-like"); - a(t(x = []), x, "Array"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/boolean/is-boolean.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/boolean/is-boolean.js deleted file mode 100644 index 4e6b3cb73e4f3b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/boolean/is-boolean.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t('arar'), false, "String"); - a(t(12), false, "Number"); - a(t(false), true, "Boolean"); - a(t(new Boolean(false)), true, "Boolean object"); - a(t(new Date()), false, "Date"); - a(t(new String('raz')), false, "String object"); - a(t({}), false, "Plain object"); - a(t(/a/), false, "Regular expression"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/copy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/copy.js deleted file mode 100644 index 767c5e16a4d053..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/copy.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o = new Date(), o2; - - o2 = t.call(o); - a.not(o, o2, "Different objects"); - a.ok(o2 instanceof Date, "Instance of Date"); - a(o.getTime(), o2.getTime(), "Same time"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/days-in-month.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/days-in-month.js deleted file mode 100644 index 9ddba55f74ac40..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/days-in-month.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call(new Date(2001, 0, 1)), 31, "January"); - a(t.call(new Date(2001, 1, 1)), 28, "February"); - a(t.call(new Date(2000, 1, 1)), 29, "February (leap)"); - a(t.call(new Date(2001, 2, 1)), 31, "March"); - a(t.call(new Date(2001, 3, 1)), 30, "April"); - a(t.call(new Date(2001, 4, 1)), 31, "May"); - a(t.call(new Date(2001, 5, 1)), 30, "June"); - a(t.call(new Date(2001, 6, 1)), 31, "July"); - a(t.call(new Date(2001, 7, 1)), 31, "August"); - a(t.call(new Date(2001, 8, 1)), 30, "September"); - a(t.call(new Date(2001, 9, 1)), 31, "October"); - a(t.call(new Date(2001, 10, 1)), 30, "November"); - a(t.call(new Date(2001, 11, 1)), 31, "December"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/floor-day.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/floor-day.js deleted file mode 100644 index d4f4a9087c059e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/floor-day.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call(new Date(2000, 0, 1, 13, 32, 34, 234)).valueOf(), - new Date(2000, 0, 1).valueOf()); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/floor-month.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/floor-month.js deleted file mode 100644 index b4a81bef6d0850..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/floor-month.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call(new Date(2000, 0, 15, 13, 32, 34, 234)).valueOf(), - new Date(2000, 0, 1).valueOf()); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/floor-year.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/floor-year.js deleted file mode 100644 index aae117e769b52c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/floor-year.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call(new Date(2000, 5, 13, 13, 32, 34, 234)).valueOf(), - new Date(2000, 0, 1).valueOf()); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/format.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/format.js deleted file mode 100644 index e68e4bf782ef30..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/#/format.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var dt = new Date(2011, 2, 3, 3, 5, 5, 32); - a(t.call(dt, ' %Y.%y.%m.%d.%H.%M.%S.%L '), ' 2011.11.03.03.03.05.05.032 '); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/is-date.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/is-date.js deleted file mode 100644 index 109093dfbe32f8..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/is-date.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t('arar'), false, "String"); - a(t(12), false, "Number"); - a(t(true), false, "Boolean"); - a(t(new Date()), true, "Date"); - a(t(new String('raz')), false, "String object"); - a(t({}), false, "Plain object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/valid-date.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/valid-date.js deleted file mode 100644 index 98787e40781687..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/date/valid-date.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var d = new Date(); - a(t(d), d, "Date"); - a.throws(function () { - t({}); - }, "Object"); - a.throws(function () { - t({ valueOf: function () { return 20; } }); - }, "Number object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/#/throw.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/#/throw.js deleted file mode 100644 index 1213cfc3b12791..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/#/throw.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var e = new Error(); - try { - t.call(e); - } catch (e2) { - a(e2, e); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/custom.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/custom.js deleted file mode 100644 index d4ff500c9b30f2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/custom.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var T = t, err = new T('My Error', 'MY_ERROR', { errno: 123 }); - a(err instanceof Error, true, "Instance of error"); - a(err.constructor, Error, "Constructor"); - a(err.name, 'Error', "Name"); - a(String(err), 'Error: My Error', "String representation"); - a(err.code, 'MY_ERROR', "Code"); - a(err.errno, 123, "Errno"); - a(typeof err.stack, 'string', "Stack trace"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/is-error.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/is-error.js deleted file mode 100644 index f8b5e2000eb769..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/is-error.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(), false, "Undefined"); - a(t(1), false, "Primitive"); - a(t({}), false, "Objectt"); - a(t({ toString: function () { return '[object Error]'; } }), false, - "Fake error"); - a(t(new Error()), true, "Error"); - a(t(new EvalError()), true, "EvalError"); - a(t(new RangeError()), true, "RangeError"); - a(t(new ReferenceError()), true, "ReferenceError"); - a(t(new SyntaxError()), true, "SyntaxError"); - a(t(new TypeError()), true, "TypeError"); - a(t(new URIError()), true, "URIError"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/valid-error.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/valid-error.js deleted file mode 100644 index e04cdb33b7cdf4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/error/valid-error.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var e = new Error(); - a(t(e), e, "Error"); - a.throws(function () { - t({}); - }, "Other"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/compose.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/compose.js deleted file mode 100644 index 83de5e844ac87d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/compose.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var f = function (a, b) { return ['a', arguments.length, a, b]; } - , g = function (a) { return ['b', arguments.length].concat(a); } - , h = function (a) { return ['c', arguments.length].concat(a); }; - -module.exports = function (t, a) { - a.deep(t.call(h, g, f)(1, 2), ['c', 1, 'b', 1, 'a', 2, 1, 2]); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/copy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/copy.js deleted file mode 100644 index 7a22e2f249276e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/copy.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var foo = 'raz', bar = 'dwa' - , fn = function marko(a, b) { return this + a + b + foo + bar; } - , result, o = {}; - - fn.prototype = o; - - fn.foo = 'raz'; - - result = t.call(fn); - - a(result.length, fn.length, "Length"); - a(result.name, fn.name, "Length"); - a(result.call('marko', 'el', 'fe'), 'markoelferazdwa', "Body"); - a(result.prototype, fn.prototype, "Prototype"); - a(result.foo, fn.foo, "Custom property"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/curry.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/curry.js deleted file mode 100644 index 18fb0389e79b26..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/curry.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -var toArray = require('../../../array/to-array') - - , f = function () { return toArray(arguments); }; - -module.exports = function (t, a) { - var x, y = {}, z; - a.deep(t.call(f, 0, 1, 2)(3), [], "0 arguments"); - x = t.call(f, 5, {}); - a(x.length, 5, "Length #1"); - z = x(1, 2); - a(z.length, 3, "Length #2"); - z = z(3, 4); - a(z.length, 1, "Length #1"); - a.deep(z(5, 6), [1, 2, 3, 4, 5], "Many arguments"); - a.deep(x(8, 3)(y, 45)('raz', 6), [8, 3, y, 45, 'raz'], "Many arguments #2"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/lock.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/lock.js deleted file mode 100644 index 44a12d7b56c748..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/lock.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call(function () { - return arguments.length; - })(1, 2, 3), 0); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/not.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/not.js deleted file mode 100644 index c0f5e9d4b989a5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/not.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var identity = require('../../../function/identity') - , noop = require('../../../function/noop'); - -module.exports = function (t, a) { - a(t.call(identity)(''), true, "Falsy"); - a(t.call(noop)(), true, "Undefined"); - a(t.call(identity)({}), false, "Any object"); - a(t.call(identity)(true), false, "True"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/partial.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/partial.js deleted file mode 100644 index bd00ce752f5202..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/partial.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var toArray = require('../../../array/to-array') - - , f = function () { return toArray(arguments); }; - -module.exports = function (t, a) { - a.deep(t.call(f, 1)(2, 3), [1, 2, 3]); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/spread.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/spread.js deleted file mode 100644 index b82dfecfe95045..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/spread.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var f = function (a, b) { return this[a] + this[b]; } - , o = { a: 3, b: 4 }; - -module.exports = function (t, a) { - a(t.call(f).call(o, ['a', 'b']), 7); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/to-string-tokens.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/to-string-tokens.js deleted file mode 100644 index 4c54d30354b405..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/#/to-string-tokens.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.deep(t.call(function (a, b) { return this[a] + this[b]; }), - { args: 'a, b', body: ' return this[a] + this[b]; ' }); - a.deep(t.call(function () {}), - { args: '', body: '' }); - a.deep(t.call(function (raz) {}), - { args: 'raz', body: '' }); - a.deep(t.call(function () { Object(); }), - { args: '', body: ' Object(); ' }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/_define-length.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/_define-length.js deleted file mode 100644 index 8f037e857eaa09..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/_define-length.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var foo = 'raz', bar = 'dwa' - , fn = function (a, b) { return this + a + b + foo + bar; } - , result; - - result = t(fn, 3); - a(result.call('marko', 'el', 'fe'), 'markoelferazdwa', "Content"); - a(result.length, 3, "Length"); - a(result.prototype, fn.prototype, "Prototype"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/constant.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/constant.js deleted file mode 100644 index fda52aa43710c1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/constant.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var o = {}; - -module.exports = function (t, a) { - a(t(o)(), o); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/identity.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/identity.js deleted file mode 100644 index 8013e2e5af1288..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/identity.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var o = {}; - -module.exports = function (t, a) { - a(t(o), o); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/invoke.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/invoke.js deleted file mode 100644 index fcce4aaaaafb87..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/invoke.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -var constant = require('../../function/constant') - - , o = { b: constant('c') }; - -module.exports = function (t, a) { - a(t('b')(o), 'c'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/is-arguments.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/is-arguments.js deleted file mode 100644 index f8de8812a5035d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/is-arguments.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var args, dummy; - args = (function () { return arguments; }()); - dummy = { '0': 1, '1': 2 }; - Object.defineProperty(dummy, 'length', { value: 2 }); - a(t(args), true, "Arguments"); - a(t(dummy), false, "Dummy"); - a(t([]), false, "Array"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/is-function.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/is-function.js deleted file mode 100644 index 83acc42f9a6637..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/is-function.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var o = { call: Function.prototype.call, apply: Function.prototype.apply }; - -module.exports = function (t, a) { - a(t(function () {}), true, "Function is function"); - a(t(o), false, "Plain object is not function"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/noop.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/noop.js deleted file mode 100644 index 4305c6fcfd51cd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/noop.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(typeof t(1, 2, 3), 'undefined'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/pluck.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/pluck.js deleted file mode 100644 index 5bf9583ad52b3e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/pluck.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -var o = { foo: 'bar' }; - -module.exports = function (t, a) { - a(t('foo')(o), o.foo); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/valid-function.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/valid-function.js deleted file mode 100644 index 59b16233b37978..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/function/valid-function.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var f = function () {}; - a(t(f), f, "Function"); - f = new Function(); - a(t(f), f, "Function"); - a.throws(function () { - t({}); - }, "Object"); - a.throws(function () { - t(/re/); - }, "RegExp"); - a.throws(function () { - t({ call: function () { return 20; } }); - }, "Plain object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/global.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/global.js deleted file mode 100644 index 1f452aefb09827..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/global.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.ok(t && typeof t === 'object'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/for-each.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/for-each.js deleted file mode 100644 index 0fed8ad898990e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/for-each.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -var ArrayIterator = require('es6-iterator/array') - - , slice = Array.prototype.slice; - -module.exports = function (t, a) { - var i = 0, x = ['raz', 'dwa', 'trzy'], y = {}; - t(x, function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "Array " + i + "#"); - a(this, y, "Array: context: " + (i++) + "#"); - }, y); - i = 0; - t((function () { return arguments; }('raz', 'dwa', 'trzy')), function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "Arguments" + i + "#"); - a(this, y, "Arguments: context: " + (i++) + "#"); - }, y); - i = 0; - t({ 0: 'raz', 1: 'dwa', 2: 'trzy', length: 3 }, function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "Array-like" + i + "#"); - a(this, y, "Array-like: context: " + (i++) + "#"); - }, y); - i = 0; - t(x = 'foo', function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#"); - a(this, y, "Regular String: context: " + (i++) + "#"); - }, y); - i = 0; - x = ['r', '💩', 'z']; - t('r💩z', function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "String " + i + "#"); - a(this, y, "Unicode String: context: " + (i++) + "#"); - }, y); - i = 0; - t(new ArrayIterator(x), function () { - a.deep(slice.call(arguments, 0, 1), [x[i]], "Iterator " + i + "#"); - a(this, y, "Iterator: context: " + (i++) + "#"); - }, y); - -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/is.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/is.js deleted file mode 100644 index c0d2a43ebfe17c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/is.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator; - -module.exports = function (t, a) { - var x; - a(t([]), true, "Array"); - a(t(""), true, "String"); - a(t((function () { return arguments; }())), true, "Arguments"); - a(t({ length: 0 }), true, "List object"); - a(t(function () {}), false, "Function"); - a(t({}), false, "Plain object"); - a(t(/raz/), false, "Regexp"); - a(t(), false, "No argument"); - a(t(null), false, "Null"); - a(t(undefined), false, "Undefined"); - x = {}; - x[iteratorSymbol] = function () {}; - a(t(x), true, "Iterable"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/validate-object.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/validate-object.js deleted file mode 100644 index da12529bc0368c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/validate-object.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator; - -module.exports = function (t, a) { - var x; - a.throws(function () { t(0); }, TypeError, "0"); - a.throws(function () { t(false); }, TypeError, "false"); - a.throws(function () { t(''); }, TypeError, "String"); - a.throws(function () { t({}); }, TypeError, "Plain Object"); - a.throws(function () { t(function () {}); }, TypeError, "Function"); - a(t(x = new String('raz')), x, "String object"); //jslint: ignore - - a(t(x = { length: 1 }), x, "Array like"); - a.throws(function () { t(); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "null"); - x = {}; - x[iteratorSymbol] = function () {}; - a(t(x), x, "Iterable"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/validate.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/validate.js deleted file mode 100644 index bcc2ad3d0aa1c9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/iterable/validate.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -var iteratorSymbol = require('es6-symbol').iterator; - -module.exports = function (t, a) { - var x; - a.throws(function () { t(0); }, TypeError, "0"); - a.throws(function () { t(false); }, TypeError, "false"); - a(t(''), '', "''"); - a.throws(function () { t({}); }, TypeError, "Plain Object"); - a.throws(function () { t(function () {}); }, TypeError, "Function"); - a(t(x = new String('raz')), x, "String object"); //jslint: ignore - - a(t(x = { length: 1 }), x, "Array like"); - a.throws(function () { t(); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "null"); - x = {}; - x[iteratorSymbol] = function () {}; - a(t(x), x, "Iterable"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/_pack-ieee754.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/_pack-ieee754.js deleted file mode 100644 index 9041431d7769c9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/_pack-ieee754.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.deep(t(1.337, 8, 23), [63, 171, 34, 209]); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/_unpack-ieee754.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/_unpack-ieee754.js deleted file mode 100644 index ca30b8208dbb95..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/_unpack-ieee754.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.deep(t([63, 171, 34, 209], 8, 23), 1.3370000123977661); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/implement.js deleted file mode 100644 index 01fb6d08224e2a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/acosh/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/shim.js deleted file mode 100644 index 3d710c7930d454..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/acosh/shim.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(-1), NaN, "Negative"); - a(t(0), NaN, "Zero"); - a(t(0.5), NaN, "Below 1"); - a(t(1), 0, "1"); - a(t(2), 1.3169578969248166, "Other"); - a(t(Infinity), Infinity, "Infinity"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/implement.js deleted file mode 100644 index d1fceceee13449..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/asinh/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/shim.js deleted file mode 100644 index d9fbe49edc2d99..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/asinh/shim.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(0), 0, "Zero"); - a(t(Infinity), Infinity, "Infinity"); - a(t(-Infinity), -Infinity, "-Infinity"); - a(t(-2), -1.4436354751788103, "Negative"); - a(t(2), 1.4436354751788103, "Positive"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/implement.js deleted file mode 100644 index cba8fad83e4082..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/atanh/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/shim.js deleted file mode 100644 index a857b496686048..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/atanh/shim.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(-2), NaN, "Less than -1"); - a(t(2), NaN, "Greater than 1"); - a(t(-1), -Infinity, "-1"); - a(t(1), Infinity, "1"); - a(t(0), 0, "Zero"); - a(t(0.5), 0.5493061443340549, "Ohter"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/implement.js deleted file mode 100644 index 374d4b383f5c5f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/cbrt/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/shim.js deleted file mode 100644 index 43ab68b848f61a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cbrt/shim.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(0), 0, "Zero"); - a(t(Infinity), Infinity, "Infinity"); - a(t(-Infinity), -Infinity, "-Infinity"); - a(t(-1), -1, "-1"); - a(t(1), 1, "1"); - a(t(2), 1.2599210498948732, "Ohter"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/implement.js deleted file mode 100644 index 44f8815526b7ec..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/clz32/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/shim.js deleted file mode 100644 index a769b39b85b644..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/clz32/shim.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(1), 31, "1"); - a(t(1000), 22, "1000"); - a(t(), 32, "No arguments"); - a(t(Infinity), 32, "Infinity"); - a(t(-Infinity), 32, "-Infinity"); - a(t("foo"), 32, "String"); - a(t(true), 31, "Boolean"); - a(t(3.5), 30, "Float"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/implement.js deleted file mode 100644 index f3c712b1dfc977..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/cosh/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/shim.js deleted file mode 100644 index 419c12367dbcd2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/cosh/shim.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(0), 1, "Zero"); - a(t(Infinity), Infinity, "Infinity"); - a(t(-Infinity), Infinity, "-Infinity"); - a(t(1), 1.5430806348152437, "1"); - a(t(Number.MAX_VALUE), Infinity); - a(t(-Number.MAX_VALUE), Infinity); - a(t(Number.MIN_VALUE), 1); - a(t(-Number.MIN_VALUE), 1); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/implement.js deleted file mode 100644 index c21296725dc07b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/expm1/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/shim.js deleted file mode 100644 index 15f0e796ce565b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/expm1/shim.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(0), 0, "Zero"); - a(t(Infinity), Infinity, "Infinity"); - a(t(-Infinity), -1, "-Infinity"); - a(t(1).toFixed(15), '1.718281828459045', "1"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/implement.js deleted file mode 100644 index c909af7c300b22..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/fround/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/shim.js deleted file mode 100644 index 4ef6d4ea9b199b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/fround/shim.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(0), 0, "Zero"); - a(t(Infinity), Infinity, "Infinity"); - a(t(-Infinity), -Infinity, "-Infinity"); - a(t(1.337), 1.3370000123977661, "1"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/implement.js deleted file mode 100644 index 99466464c122bc..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/hypot/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/shim.js deleted file mode 100644 index 91d950a5d32899..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/hypot/shim.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(), 0, "No arguments"); - a(t(0, -0, 0), 0, "Zeros"); - a(t(4, NaN, Infinity), Infinity, "Infinity"); - a(t(4, NaN, -Infinity), Infinity, "Infinity"); - a(t(4, NaN, 34), NaN, "NaN"); - a(t(3, 4), 5, "#1"); - a(t(3, 4, 5), 7.0710678118654755, "#2"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/implement.js deleted file mode 100644 index 7b2a2a61653299..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/imul/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/shim.js deleted file mode 100644 index a2ca7fe78321ce..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/imul/shim.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(), 0, "No arguments"); - a(t(0, 0), 0, "Zeros"); - a(t(2, 4), 8, "#1"); - a(t(-1, 8), -8, "#2"); - a(t(0xfffffffe, 5), -10, "#3"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/implement.js deleted file mode 100644 index 4b3b4a4569fb81..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/log10/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/shim.js deleted file mode 100644 index 5fa0d5be3af861..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log10/shim.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(-0.5), NaN, "Less than 0"); - a(t(0), -Infinity, "0"); - a(t(1), 0, "1"); - a(t(Infinity), Infinity, "Infinity"); - a(t(2), 0.3010299956639812, "Other"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/implement.js deleted file mode 100644 index 5d269bd3eaf09b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/log1p/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/shim.js deleted file mode 100644 index d495ce0496b76d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log1p/shim.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(-1.5), NaN, "Less than -1"); - a(t(-1), -Infinity, "-1"); - a(t(0), 0, "0"); - a(t(Infinity), Infinity, "Infinity"); - a(t(1), 0.6931471805599453, "Other"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/implement.js deleted file mode 100644 index 92b501ac72abed..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/log2/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/shim.js deleted file mode 100644 index faa9c32a8537ab..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/log2/shim.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(-0.5), NaN, "Less than 0"); - a(t(0), -Infinity, "0"); - a(t(1), 0, "1"); - a(t(Infinity), Infinity, "Infinity"); - a(t(3).toFixed(15), '1.584962500721156', "Other"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/implement.js deleted file mode 100644 index 5875c42d608eb4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/sign/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/shim.js deleted file mode 100644 index b6b89c15889dc4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sign/shim.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -var is = require('../../../object/is'); - -module.exports = function (t, a) { - a(is(t(0), +0), true, "+0"); - a(is(t(-0), -0), true, "-0"); - a(t({}), NaN, true, "NaN"); - a(t(-234234234), -1, "Negative"); - a(t(234234234), 1, "Positive"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/implement.js deleted file mode 100644 index e52089e4507156..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/sinh/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/shim.js deleted file mode 100644 index 4f63b59e735bf0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/sinh/shim.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(0), 0, "Zero"); - a(t(Infinity), Infinity, "Infinity"); - a(t(-Infinity), -Infinity, "-Infinity"); - a(t(1), 1.1752011936438014, "1"); - a(t(Number.MAX_VALUE), Infinity); - a(t(-Number.MAX_VALUE), -Infinity); - a(t(Number.MIN_VALUE), 5e-324); - a(t(-Number.MIN_VALUE), -5e-324); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/implement.js deleted file mode 100644 index a96bf193366b30..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/tanh/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/shim.js deleted file mode 100644 index 2c67aaf47049fd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/tanh/shim.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(0), 0, "Zero"); - a(t(Infinity), 1, "Infinity"); - a(t(-Infinity), -1, "-Infinity"); - a(t(1), 0.7615941559557649, "1"); - a(t(Number.MAX_VALUE), 1); - a(t(-Number.MAX_VALUE), -1); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/implement.js deleted file mode 100644 index 1830e61f69794d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../math/trunc/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/shim.js deleted file mode 100644 index 9e5eed7910e13c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/math/trunc/shim.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var is = require('../../../object/is'); - -module.exports = function (t, a) { - a(t({}), NaN, "NaN"); - a(t(0), 0, "Zero"); - a(t(Infinity), Infinity, "Infinity"); - a(t(-Infinity), -Infinity, "-Infinity"); - a(is(t(0.234), 0), true, "0"); - a(is(t(-0.234), -0), true, "-0"); - a(t(13.7), 13, "Positive #1"); - a(t(12.3), 12, "Positive #2"); - a(t(-12.3), -12, "Negative #1"); - a(t(-14.7), -14, "Negative #2"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/#/pad.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/#/pad.js deleted file mode 100644 index e02082353348dc..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/#/pad.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call(78, 4), '0078'); - a(t.call(65.12323, 4, 3), '0065.123', "Precision"); - a(t.call(65, 4, 3), '0065.000', "Precision integer"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/epsilon/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/epsilon/implement.js deleted file mode 100644 index 574da75dcebb7f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/epsilon/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../number/epsilon/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/epsilon/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/epsilon/index.js deleted file mode 100644 index c892fd47d41c16..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/epsilon/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(typeof t, 'number'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/epsilon/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/epsilon/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/epsilon/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/implement.js deleted file mode 100644 index b35345fa6ee762..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../number/is-finite/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/shim.js deleted file mode 100644 index 5205d1c2602520..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-finite/shim.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(2), true, "Number"); - a(t('23'), false, "Not numeric"); - a(t(NaN), false, "NaN"); - a(t(Infinity), false, "Infinity"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/implement.js deleted file mode 100644 index 127149ceeda9b5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../number/is-integer/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/shim.js deleted file mode 100644 index 3f3985c3a05522..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-integer/shim.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(2), true, "Number"); - a(t(2.34), false, "Float"); - a(t('23'), false, "Not numeric"); - a(t(NaN), false, "NaN"); - a(t(Infinity), false, "Infinity"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/implement.js deleted file mode 100644 index 2f01d6d30ad9f6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../number/is-nan/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/shim.js deleted file mode 100644 index 425723e74b07b9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-nan/shim.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(2), false, "Number"); - a(t({}), false, "Not numeric"); - a(t(NaN), true, "NaN"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-natural.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-natural.js deleted file mode 100644 index d56f12042b48f3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-natural.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(2), true, "Number"); - a(t(-2), false, "Negative"); - a(t(2.34), false, "Float"); - a(t('23'), false, "Not numeric"); - a(t(NaN), false, "NaN"); - a(t(Infinity), false, "Infinity"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-number.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-number.js deleted file mode 100644 index 275133476a61ff..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-number.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(0), true, "Zero"); - a(t(NaN), true, "NaN"); - a(t(Infinity), true, "Infinity"); - a(t(12), true, "Number"); - a(t(false), false, "Boolean"); - a(t(new Date()), false, "Date"); - a(t(new Number(2)), true, "Number object"); - a(t('asdfaf'), false, "String"); - a(t(''), false, "Empty String"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/implement.js deleted file mode 100644 index 33667e2e9afb60..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../number/is-safe-integer/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/shim.js deleted file mode 100644 index 77e06674711795..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/is-safe-integer/shim.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(2), true, "Number"); - a(t(2.34), false, "Float"); - a(t(Math.pow(2, 53)), false, "Too large"); - a(t(Math.pow(2, 53) - 1), true, "Maximum"); - a(t('23'), false, "Not numeric"); - a(t(NaN), false, "NaN"); - a(t(Infinity), false, "Infinity"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/max-safe-integer/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/max-safe-integer/implement.js deleted file mode 100644 index bef00ca413d3cb..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/max-safe-integer/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../number/max-safe-integer/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/max-safe-integer/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/max-safe-integer/index.js deleted file mode 100644 index c892fd47d41c16..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/max-safe-integer/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(typeof t, 'number'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/max-safe-integer/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/max-safe-integer/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/max-safe-integer/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/min-safe-integer/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/min-safe-integer/implement.js deleted file mode 100644 index fa440248bf47a6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/min-safe-integer/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../number/min-safe-integer/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/min-safe-integer/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/min-safe-integer/index.js deleted file mode 100644 index c892fd47d41c16..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/min-safe-integer/index.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(typeof t, 'number'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/min-safe-integer/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/min-safe-integer/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/min-safe-integer/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/to-integer.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/to-integer.js deleted file mode 100644 index ff326ba7a95bbb..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/to-integer.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), 0, "NaN"); - a(t(20), 20, "Positive integer"); - a(t('-20'), -20, "String negative integer"); - a(t(Infinity), Infinity, "Infinity"); - a(t(15.343), 15, "Float"); - a(t(-15.343), -15, "Negative float"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/to-pos-integer.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/to-pos-integer.js deleted file mode 100644 index 2f3b4e674ecc4b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/to-pos-integer.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), 0, "NaN"); - a(t(20), 20, "Positive integer"); - a(t(-20), 0, "Negative integer"); - a(t(Infinity), Infinity, "Infinity"); - a(t(15.343), 15, "Float"); - a(t(-15.343), 0, "Negative float"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/to-uint32.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/to-uint32.js deleted file mode 100644 index 00d05bdfe346d7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/number/to-uint32.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), 0, "Not numeric"); - a(t(-4), 4294967292, "Negative"); - a(t(133432), 133432, "Positive"); - a(t(8589934592), 0, "Greater than maximum"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/_iterate.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/_iterate.js deleted file mode 100644 index 179afed88ee845..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/_iterate.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o = { raz: 1, dwa: 2, trzy: 3 } - , o2 = {}, o3 = {}, arr, i = -1; - - t = t('forEach'); - t(o, function (value, name, self, index) { - o2[name] = value; - a(index, ++i, "Index"); - a(self, o, "Self"); - a(this, o3, "Scope"); - }, o3); - a.deep(o2, o); - - arr = []; - o2 = {}; - i = -1; - t(o, function (value, name, self, index) { - arr.push(value); - o2[name] = value; - a(index, ++i, "Index"); - a(self, o, "Self"); - a(this, o3, "Scope"); - }, o3, function (a, b) { - return o[b] - o[a]; - }); - a.deep(o2, o, "Sort by Values: Content"); - a.deep(arr, [3, 2, 1], "Sort by Values: Order"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/implement.js deleted file mode 100644 index 40065594187cb9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../object/assign/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/shim.js deleted file mode 100644 index 9afe5f658c45b7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/assign/shim.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o1 = { a: 1, b: 2 } - , o2 = { b: 3, c: 4 }; - - a(t(o1, o2), o1, "Returns self"); - a.deep(o1, { a: 1, b: 3, c: 4 }, "Single: content"); - - a.deep(t({}, o1, o2), { a: 1, b: 3, c: 4 }, "Multi argument"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/clear.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/clear.js deleted file mode 100644 index bfc08cc208420b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/clear.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -var isEmpty = require('../../object/is-empty'); - -module.exports = function (t, a) { - var x = {}; - a(t(x), x, "Empty: Returns same object"); - a(isEmpty(x), true, "Empty: Not changed"); - x.foo = 'raz'; - x.bar = 'dwa'; - a(t(x), x, "Same object"); - a(isEmpty(x), true, "Emptied"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/compact.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/compact.js deleted file mode 100644 index 9c9064c7886445..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/compact.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = {}, y = {}, z; - z = t(x); - a.not(z, x, "Returns different object"); - a.deep(z, {}, "Empty on empty"); - - x = { foo: 'bar', a: 0, b: false, c: '', d: '0', e: null, bar: y, - elo: undefined }; - z = t(x); - a.deep(z, { foo: 'bar', a: 0, b: false, c: '', d: '0', bar: y }, - "Cleared null values"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/compare.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/compare.js deleted file mode 100644 index cb9424109c334b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/compare.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var d = new Date(); - - a.ok(t(12, 3) > 0, "Numbers"); - a.ok(t(2, 13) < 0, "Numbers #2"); - a.ok(t("aaa", "aa") > 0, "Strings"); - a.ok(t("aa", "ab") < 0, "Strings #2"); - a(t("aa", "aa"), 0, "Strings same"); - a(t(d, new Date(d.getTime())), 0, "Same date"); - a.ok(t(d, new Date(d.getTime() + 1)) < 0, "Different date"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/copy-deep.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/copy-deep.js deleted file mode 100644 index 79e02be49e3c11..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/copy-deep.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -var stringify = JSON.stringify; - -module.exports = function (t, a) { - var o = { 1: 'raz', 2: 'dwa', 3: 'trzy' } - , no = t(o); - - a.not(no, o, "Return different object"); - a(stringify(no), stringify(o), "Match properties and values"); - - o = { foo: 'bar', raz: { dwa: 'dwa', - trzy: { cztery: 'pięć', 'sześć': 'siedem' }, osiem: {}, - 'dziewięć': function () { } }, - 'dziesięć': 10, "jedenaście": ['raz', ['dwa', 'trzy', { elo: "true" }]] }; - o.raz.rec = o; - - no = t(o); - a.not(o.raz, no.raz, "Deep"); - a.not(o.raz.trzy, no.raz.trzy, "Deep #2"); - a(stringify(o.raz.trzy), stringify(no.raz.trzy), "Deep content"); - a(no.raz.rec, no, "Recursive"); - a.not(o.raz.osiem, no.raz.osiem, "Empty object"); - a(o.raz['dziewięć'], no.raz['dziewięć'], "Function"); - a.not(o['jedenaście'], no['jedenaście']); - a.not(o['jedenaście'][1], no['jedenaście'][1]); - a.not(o['jedenaście'][1][2], no['jedenaście'][1][2]); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/copy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/copy.js deleted file mode 100644 index 2f222ef809c6d7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/copy.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var stringify = JSON.stringify; - -module.exports = function (t, a) { - var o = { 1: 'raz', 2: 'dwa', 3: 'trzy' } - , no = t(o); - - a.not(no, o, "Return different object"); - a(stringify(no), stringify(o), "Match properties and values"); - - o = { foo: 'bar', raz: { dwa: 'dwa', - trzy: { cztery: 'pięć', 'sześć': 'siedem' }, osiem: {}, - 'dziewięć': function () { } }, 'dziesięć': 10 }; - o.raz.rec = o; - - no = t(o); - a(o.raz, no.raz, "Shallow"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/count.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/count.js deleted file mode 100644 index 494f4f163515eb..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/count.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), 0, "Empty"); - a(t({ raz: 1, dwa: null, trzy: undefined, cztery: 0 }), 4, - "Some properties"); - a(t(Object.defineProperties({}, { - raz: { value: 'raz' }, - dwa: { value: 'dwa', enumerable: true } - })), 1, "Some properties hidden"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/create.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/create.js deleted file mode 100644 index 8b7be214136d2f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/create.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -var setPrototypeOf = require('../../object/set-prototype-of') - - , getPrototypeOf = Object.getPrototypeOf; - -module.exports = function (t, a) { - var x = {}, obj; - - a(getPrototypeOf(t(x)), x, "Normal object"); - a(getPrototypeOf(t(null)), - (setPrototypeOf && setPrototypeOf.nullPolyfill) || null, "Null"); - - a.h1("Properties"); - a.h2("Normal object"); - a(getPrototypeOf(obj = t(x, { foo: { value: 'bar' } })), x, "Prototype"); - a(obj.foo, 'bar', "Property"); - a.h2("Null"); - a(getPrototypeOf(obj = t(null, { foo: { value: 'bar2' } })), - (setPrototypeOf && setPrototypeOf.nullPolyfill) || null, "Prototype"); - a(obj.foo, 'bar2', "Property"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/ensure-natural-number-value.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/ensure-natural-number-value.js deleted file mode 100644 index dde23986babe18..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/ensure-natural-number-value.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.throws(function () { t(undefined); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "Null"); - a(t(2), 2, "Number"); - a.throws(function () { t(-2); }, TypeError, "Negative"); - a.throws(function () { t(2.34); }, TypeError, "Float"); - a(t('23'), 23, "Numeric string"); - a.throws(function () { t(NaN); }, TypeError, "NaN"); - a.throws(function () { t(Infinity); }, TypeError, "Infinity"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/ensure-natural-number.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/ensure-natural-number.js deleted file mode 100644 index 5ebed1e524fcef..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/ensure-natural-number.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.throws(function () { t(undefined); }, TypeError, "Undefined"); - a(t(null), 0, "Null"); - a(t(2), 2, "Number"); - a.throws(function () { t(-2); }, TypeError, "Negative"); - a.throws(function () { t(2.34); }, TypeError, "Float"); - a(t('23'), 23, "Numeric string"); - a.throws(function () { t(NaN); }, TypeError, "NaN"); - a.throws(function () { t(Infinity); }, TypeError, "Infinity"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/eq.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/eq.js deleted file mode 100644 index 02b3f0027cbf82..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/eq.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o = {}; - a(t(o, {}), false, "Different objects"); - a(t(o, o), true, "Same objects"); - a(t('1', '1'), true, "Same primitive"); - a(t('1', 1), false, "Different primitive types"); - a(t(NaN, NaN), true, "NaN"); - a(t(0, 0), true, "0,0"); - a(t(0, -0), true, "0,-0"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/every.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/every.js deleted file mode 100644 index 07d5bbbd61f7af..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/every.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -var o = { 1: 1, 2: 2, 3: 3 }; - -module.exports = function (t, a) { - var o2 = {}; - t(o, function (value, name) { - o2[name] = value; - return true; - }); - a(JSON.stringify(o2), JSON.stringify(o), "Iterates"); - - a(t(o, function () { - return true; - }), true, "Succeeds"); - - a(t(o, function () { - return false; - }), false, "Fails"); - -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/filter.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/filter.js deleted file mode 100644 index 7307da8640fcd1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/filter.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.deep(t({ 1: 1, 2: 2, 3: 3, 4: 4 }, - function (value) { return Boolean(value % 2); }), { 1: 1, 3: 3 }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/find-key.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/find-key.js deleted file mode 100644 index cca834d9362a29..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/find-key.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var o = { 1: 1, 2: 2, 3: 3 }; - -module.exports = function (t, a) { - var o2 = {}, i = 0; - t(o, function (value, name) { - o2[name] = value; - return false; - }); - a(JSON.stringify(o2), JSON.stringify(o), "Iterates"); - - a(t(o, function () { - ++i; - return true; - }), '1', "Finds"); - a(i, 1, "Stops iteration after condition is met"); - - a(t(o, function () { - return false; - }), undefined, "Fails"); - -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/find.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/find.js deleted file mode 100644 index b6ad60a542b741..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/find.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var o = { 1: 1, 2: 2, 3: 3 }; - -module.exports = function (t, a) { - var o2 = {}, i = 0; - t(o, function (value, name) { - o2[name] = value; - return false; - }); - a(JSON.stringify(o2), JSON.stringify(o), "Iterates"); - - a(t(o, function () { - ++i; - return true; - }), 1, "Finds"); - a(i, 1, "Stops iteration after condition is met"); - - a(t(o, function () { - return false; - }), undefined, "Fails"); - -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/first-key.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/first-key.js deleted file mode 100644 index 8169cd235344d9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/first-key.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = {}, y = Object.create(null); - a(t(x), null, "Normal: Empty"); - a(t(y), null, "Null extension: Empty"); - x.foo = 'raz'; - x.bar = 343; - a(['foo', 'bar'].indexOf(t(x)) !== -1, true, "Normal"); - y.elo = 'foo'; - y.mar = 'wew'; - a(['elo', 'mar'].indexOf(t(y)) !== -1, true, "Null extension"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/flatten.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/flatten.js deleted file mode 100644 index ca342eab9c8ae4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/flatten.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.deep(t({ a: { aa: 1, ab: 2 }, b: { ba: 3, bb: 4 } }), - { aa: 1, ab: 2, ba: 3, bb: 4 }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/for-each.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/for-each.js deleted file mode 100644 index 8690d1e82179aa..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/for-each.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o = { raz: 1, dwa: 2, trzy: 3 } - , o2 = {}; - a(t(o, function (value, name) { - o2[name] = value; - }), undefined, "Return"); - a.deep(o2, o); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/get-property-names.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/get-property-names.js deleted file mode 100644 index b91c3dd50e7bbf..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/get-property-names.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o = { first: 1, second: 4 }, r1, r2; - o = Object.create(o, { - third: { value: null } - }); - o.first = 2; - o = Object.create(o); - o.fourth = 3; - - r1 = t(o); - r1.sort(); - r2 = ['first', 'second', 'third', 'fourth'] - .concat(Object.getOwnPropertyNames(Object.prototype)); - r2.sort(); - a.deep(r1, r2); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-array-like.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-array-like.js deleted file mode 100644 index 6295973ca81acd..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-array-like.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t([]), true, "Array"); - a(t(""), true, "String"); - a(t((function () { return arguments; }())), true, "Arguments"); - a(t({ length: 0 }), true, "List object"); - a(t(function () {}), false, "Function"); - a(t({}), false, "Plain object"); - a(t(/raz/), false, "Regexp"); - a(t(), false, "No argument"); - a(t(null), false, "Null"); - a(t(undefined), false, "Undefined"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-callable.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-callable.js deleted file mode 100644 index 625e221d2c3811..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-callable.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(function () {}), true, "Function"); - a(t({}), false, "Object"); - a(t(), false, "Undefined"); - a(t(null), false, "Null"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-copy-deep.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-copy-deep.js deleted file mode 100644 index 4f14cbbe8108b2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-copy-deep.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x, y; - - a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2, 3: 3 }), true, "Same"); - a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2, 3: 4 }), false, - "Different property value"); - a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2 }), false, - "Property only in source"); - a(t({ 1: 1, 2: 2 }, { 1: 1, 2: 2, 3: 4 }), false, - "Property only in target"); - - a(t("raz", "dwa"), false, "String: diff"); - a(t("raz", "raz"), true, "String: same"); - a(t("32", 32), false, "String & Number"); - - a(t([1, 'raz', true], [1, 'raz', true]), true, "Array: same"); - a(t([1, 'raz', undefined], [1, 'raz']), false, "Array: diff"); - a(t(['foo'], ['one']), false, "Array: One value comparision"); - - x = { foo: { bar: { mar: {} } } }; - y = { foo: { bar: { mar: {} } } }; - a(t(x, y), true, "Deep"); - - a(t({ foo: { bar: { mar: 'foo' } } }, { foo: { bar: { mar: {} } } }), - false, "Deep: false"); - - x = { foo: { bar: { mar: {} } } }; - x.rec = { foo: x }; - - y = { foo: { bar: { mar: {} } } }; - y.rec = { foo: x }; - - a(t(x, y), true, "Object: Infinite Recursion: Same #1"); - - x.rec.foo = y; - a(t(x, y), true, "Object: Infinite Recursion: Same #2"); - - x.rec.foo = x; - y.rec.foo = y; - a(t(x, y), true, "Object: Infinite Recursion: Same #3"); - - y.foo.bar.mar = 'raz'; - a(t(x, y), false, "Object: Infinite Recursion: Diff"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-copy.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-copy.js deleted file mode 100644 index 394e2ed94c09f0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-copy.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2, 3: 3 }), true, "Same"); - a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2, 3: 4 }), false, - "Different property value"); - a(t({ 1: 1, 2: 2, 3: 3 }, { 1: 1, 2: 2 }), false, - "Property only in source"); - a(t({ 1: 1, 2: 2 }, { 1: 1, 2: 2, 3: 4 }), false, - "Property only in target"); - - a(t("raz", "dwa"), false, "String: diff"); - a(t("raz", "raz"), true, "String: same"); - a(t("32", 32), false, "String & Number"); - - a(t([1, 'raz', true], [1, 'raz', true]), true, "Array: same"); - a(t([1, 'raz', undefined], [1, 'raz']), false, "Array: diff"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-empty.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-empty.js deleted file mode 100644 index b560c2c36b0d4b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-empty.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), true, "Empty"); - a(t({ 1: 1 }), false, "Not empty"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-number-value.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-number-value.js deleted file mode 100644 index 21b6b620323b63..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-number-value.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(undefined), false, "Undefined"); - a(t(null), false, "Null"); - a(t(0), true, "Zero"); - a(t(NaN), false, "NaN"); - a(t(Infinity), true, "Infinity"); - a(t(12), true, "Number"); - a(t(false), true, "Boolean"); - a(t(new Date()), true, "Date"); - a(t(new Number(2)), true, "Number object"); - a(t('asdfaf'), false, "String"); - a(t(''), true, "Empty String"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-object.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-object.js deleted file mode 100644 index 72c8aa6daf4a3a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-object.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t('arar'), false, "String"); - a(t(12), false, "Number"); - a(t(true), false, "Boolean"); - a(t(null), false, "Null"); - a(t(new Date()), true, "Date"); - a(t(new String('raz')), true, "String object"); - a(t({}), true, "Plain object"); - a(t(/a/), true, "Regular expression"); - a(t(function () {}), true, "Function"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-plain-object.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-plain-object.js deleted file mode 100644 index e988829d558ad0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is-plain-object.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t({}), true, "Empty {} is plain object"); - a(t({ a: true }), true, "{} with property is plain object"); - a(t({ prototype: 1, constructor: 2, __proto__: 3 }), true, - "{} with any property keys is plain object"); - a(t(null), false, "Null is not plain object"); - a(t('string'), false, "Primitive is not plain object"); - a(t(function () {}), false, "Function is not plain object"); - a(t(Object.create({})), false, - "Object whose prototype is not Object.prototype is not plain object"); - a(t(Object.create(Object.prototype)), true, - "Object whose prototype is Object.prototype is plain object"); - a(t(Object.create(null)), true, - "Object whose prototype is null is plain object"); - a(t(Object.prototype), false, "Object.prototype"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is.js deleted file mode 100644 index 4f8948cbf344e1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/is.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o = {}; - a(t(o, {}), false, "Different objects"); - a(t(o, o), true, "Same objects"); - a(t('1', '1'), true, "Same primitive"); - a(t('1', 1), false, "Different primitive types"); - a(t(NaN, NaN), true, "NaN"); - a(t(0, 0), true, "0,0"); - a(t(0, -0), false, "0,-0"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/key-of.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/key-of.js deleted file mode 100644 index a9225a048c5c91..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/key-of.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x = {}, y = {} - , o = { foo: 'bar', raz: x, trzy: 'cztery', five: '6' }; - - a(t(o, 'bar'), 'foo', "First property"); - a(t(o, 6), null, "Primitive that's not there"); - a(t(o, x), 'raz', "Object"); - a(t(o, y), null, "Object that's not there"); - a(t(o, '6'), 'five', "Last property"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/implement.js deleted file mode 100644 index 179e1e5612ea8f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../object/keys/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/shim.js deleted file mode 100644 index ed29eebcd751f7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/keys/shim.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.deep(t({ foo: 'bar' }), ['foo'], "Object"); - a.deep(t('raz'), ['0', '1', '2'], "Primitive"); - a.throws(function () { t(); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "Undefined"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/map-keys.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/map-keys.js deleted file mode 100644 index be84825b1be711..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/map-keys.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.deep(t({ 1: 1, 2: 2, 3: 3 }, function (key, value) { - return 'x' + (key + value); - }), { x11: 1, x22: 2, x33: 3 }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/map.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/map.js deleted file mode 100644 index f9cc09c01b3933..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/map.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var obj = { 1: 1, 2: 2, 3: 3 }; - a.deep(t(obj, function (value, key, context) { - a(context, obj, "Context argument"); - return (value + 1) + key; - }), { 1: '21', 2: '32', 3: '43' }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/mixin-prototypes.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/mixin-prototypes.js deleted file mode 100644 index d1c727a95a7371..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/mixin-prototypes.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o, o1, o2, x, y = {}, z = {}; - o = { inherited: true, visible: 23 }; - o1 = Object.create(o); - o1.visible = z; - o1.nonremovable = 'raz'; - Object.defineProperty(o1, 'hidden', { value: 'hidden' }); - - o2 = Object.defineProperties({}, { nonremovable: { value: y } }); - o2.other = 'other'; - - try { t(o2, o1); } catch (ignore) {} - - a(o2.visible, z, "Enumerable"); - a(o1.hidden, 'hidden', "Not Enumerable"); - a(o2.propertyIsEnumerable('visible'), true, "Enumerable is enumerable"); - a(o2.propertyIsEnumerable('hidden'), false, - "Not enumerable is not enumerable"); - - a(o2.inherited, true, "Extend deep"); - - a(o2.nonremovable, y, "Do not overwrite non configurable"); - a(o2.other, 'other', "Own kept"); - - x = {}; - t(x, o2); - try { t(x, o1); } catch (ignore) {} - - a(x.visible, z, "Enumerable"); - a(x.hidden, 'hidden', "Not Enumerable"); - a(x.propertyIsEnumerable('visible'), true, "Enumerable is enumerable"); - a(x.propertyIsEnumerable('hidden'), false, - "Not enumerable is not enumerable"); - - a(x.inherited, true, "Extend deep"); - - a(x.nonremovable, y, "Ignored non configurable"); - a(x.other, 'other', "Other"); - - x.visible = 3; - a(x.visible, 3, "Writable is writable"); - - x = {}; - t(x, o1); - a.throws(function () { - x.hidden = 3; - }, "Not writable is not writable"); - - x = {}; - t(x, o1); - delete x.visible; - a.ok(!x.hasOwnProperty('visible'), "Configurable is configurable"); - - x = {}; - t(x, o1); - a.throws(function () { - delete x.hidden; - }, "Not configurable is not configurable"); - - x = Object.defineProperty({}, 'foo', - { configurable: false, writable: true, enumerable: false, value: 'bar' }); - - try { t(x, { foo: 'lorem' }); } catch (ignore) {} - a(x.foo, 'bar', "Writable, not enumerable"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/mixin.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/mixin.js deleted file mode 100644 index 866005b03df29b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/mixin.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o, o1, o2, x, y = {}, z = {}; - o = { inherited: true }; - o1 = Object.create(o); - o1.visible = z; - o1.nonremovable = 'raz'; - Object.defineProperty(o1, 'hidden', { value: 'hidden' }); - - o2 = Object.defineProperties({}, { nonremovable: { value: y } }); - o2.other = 'other'; - - try { t(o2, o1); } catch (ignore) {} - - a(o2.visible, z, "Enumerable"); - a(o1.hidden, 'hidden', "Not Enumerable"); - a(o2.propertyIsEnumerable('visible'), true, "Enumerable is enumerable"); - a(o2.propertyIsEnumerable('hidden'), false, - "Not enumerable is not enumerable"); - - a(o2.hasOwnProperty('inherited'), false, "Extend only own"); - a(o2.inherited, undefined, "Extend ony own: value"); - - a(o2.nonremovable, y, "Do not overwrite non configurable"); - a(o2.other, 'other', "Own kept"); - - x = {}; - t(x, o2); - try { t(x, o1); } catch (ignore) {} - - a(x.visible, z, "Enumerable"); - a(x.hidden, 'hidden', "Not Enumerable"); - a(x.propertyIsEnumerable('visible'), true, "Enumerable is enumerable"); - a(x.propertyIsEnumerable('hidden'), false, - "Not enumerable is not enumerable"); - - a(x.hasOwnProperty('inherited'), false, "Extend only own"); - a(x.inherited, undefined, "Extend ony own: value"); - - a(x.nonremovable, y, "Ignored non configurable"); - a(x.other, 'other', "Other"); - - x.visible = 3; - a(x.visible, 3, "Writable is writable"); - - x = {}; - t(x, o1); - a.throws(function () { - x.hidden = 3; - }, "Not writable is not writable"); - - x = {}; - t(x, o1); - delete x.visible; - a.ok(!x.hasOwnProperty('visible'), "Configurable is configurable"); - - x = {}; - t(x, o1); - a.throws(function () { - delete x.hidden; - }, "Not configurable is not configurable"); - - x = Object.defineProperty({}, 'foo', - { configurable: false, writable: true, enumerable: false, value: 'bar' }); - - try { t(x, { foo: 'lorem' }); } catch (ignore) {} - a(x.foo, 'bar', "Writable, not enumerable"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/normalize-options.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/normalize-options.js deleted file mode 100644 index 0d2d4da04a53b1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/normalize-options.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -var create = Object.create, defineProperty = Object.defineProperty; - -module.exports = function (t, a) { - var x = { foo: 'raz', bar: 'dwa' }, y; - y = t(x); - a.not(y, x, "Returns copy"); - a.deep(y, x, "Plain"); - - x = { raz: 'one', dwa: 'two' }; - defineProperty(x, 'get', { - configurable: true, - enumerable: true, - get: function () { return this.dwa; } - }); - x = create(x); - x.trzy = 'three'; - x.cztery = 'four'; - x = create(x); - x.dwa = 'two!'; - x.trzy = 'three!'; - x.piec = 'five'; - x.szesc = 'six'; - - a.deep(t(x), { raz: 'one', dwa: 'two!', trzy: 'three!', cztery: 'four', - piec: 'five', szesc: 'six', get: 'two!' }, "Deep object"); - - a.deep(t({ marko: 'raz', raz: 'foo' }, x, { szesc: 'elo', siedem: 'bibg' }), - { marko: 'raz', raz: 'one', dwa: 'two!', trzy: 'three!', cztery: 'four', - piec: 'five', szesc: 'elo', siedem: 'bibg', get: 'two!' }, "Multiple options"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/primitive-set.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/primitive-set.js deleted file mode 100644 index 839857eab3dd85..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/primitive-set.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -var getPropertyNames = require('../../object/get-property-names') - , isPlainObject = require('../../object/is-plain-object'); - -module.exports = function (t, a) { - var x = t(); - a(isPlainObject(x), true, "Plain object"); - a.deep(getPropertyNames(x), [], "No properties"); - x.foo = 'bar'; - a.deep(getPropertyNames(x), ['foo'], "Extensible"); - - a.deep(t('raz', 'dwa', 3), { raz: true, dwa: true, 3: true }, - "Arguments handling"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/safe-traverse.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/safe-traverse.js deleted file mode 100644 index d30cdefe68b8b6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/safe-traverse.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var obj = { foo: { bar: { lorem: 12 } } }; - a(t(obj), obj, "No props"); - a(t(obj, 'foo'), obj.foo, "One"); - a(t(obj, 'raz'), undefined, "One: Fail"); - a(t(obj, 'foo', 'bar'), obj.foo.bar, "Two"); - a(t(obj, 'dsd', 'raz'), undefined, "Two: Fail #1"); - a(t(obj, 'foo', 'raz'), undefined, "Two: Fail #2"); - a(t(obj, 'foo', 'bar', 'lorem'), obj.foo.bar.lorem, "Three"); - a(t(obj, 'dsd', 'raz', 'fef'), undefined, "Three: Fail #1"); - a(t(obj, 'foo', 'raz', 'asdf'), undefined, "Three: Fail #2"); - a(t(obj, 'foo', 'bar', 'asd'), undefined, "Three: Fail #3"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/serialize.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/serialize.js deleted file mode 100644 index 43eed6a8616f9a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/serialize.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var fn = function (raz, dwa) { return raz + dwa; }; - a(t(), 'undefined', "Undefined"); - a(t(null), 'null', "Null"); - a(t(null), 'null', "Null"); - a(t('raz'), '"raz"', "String"); - a(t('raz"ddwa\ntrzy'), '"raz\\"ddwa\\ntrzy"', "String with escape"); - a(t(false), 'false', "Booelean"); - a(t(fn), String(fn), "Function"); - - a(t(/raz-dwa/g), '/raz-dwa/g', "RegExp"); - a(t(new Date(1234567)), 'new Date(1234567)', "Date"); - a(t([]), '[]', "Empty array"); - a(t([undefined, false, null, 'raz"ddwa\ntrzy', fn, /raz/g, new Date(1234567), ['foo']]), - '[undefined,false,null,"raz\\"ddwa\\ntrzy",' + String(fn) + - ',/raz/g,new Date(1234567),["foo"]]', "Rich Array"); - a(t({}), '{}', "Empty object"); - a(t({ raz: undefined, dwa: false, trzy: null, cztery: 'raz"ddwa\ntrzy', piec: fn, szesc: /raz/g, - siedem: new Date(1234567), osiem: ['foo', 32], dziewiec: { foo: 'bar', dwa: 343 } }), - '{"raz":undefined,"dwa":false,"trzy":null,"cztery":"raz\\"ddwa\\ntrzy","piec":' + String(fn) + - ',"szesc":/raz/g,"siedem":new Date(1234567),"osiem":["foo",32],' + - '"dziewiec":{"foo":"bar","dwa":343}}', "Rich object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/implement.js deleted file mode 100644 index 30b2ac4b96ba2e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -var create = require('../../../object/create') - , isImplemented = require('../../../object/set-prototype-of/is-implemented'); - -module.exports = function (a) { a(isImplemented(create), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/index.js deleted file mode 100644 index aec2605cc2661a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/index.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var create = require('../../../object/create') - - , getPrototypeOf = Object.getPrototypeOf; - -module.exports = function (t, a) { - var x = {}, y = {}; - - if (t === null) return; - a(t(x, y), x, "Return self object"); - a(getPrototypeOf(x), y, "Object"); - a.throws(function () { t(x); }, TypeError, "Undefined"); - a.throws(function () { t('foo'); }, TypeError, "Primitive"); - a(getPrototypeOf(t(x, null)), t.nullPolyfill || null, "Null"); - x = create(null); - a.h1("Change null prototype"); - a(t(x, y), x, "Result"); - a(getPrototypeOf(x), y, "Prototype"); - a.h1("Set null prototype"); - a(t(y, null), y, "Result"); - a(getPrototypeOf(y), t.nullPolyfill || null, "Prototype"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/shim.js deleted file mode 100644 index aec2605cc2661a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/set-prototype-of/shim.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var create = require('../../../object/create') - - , getPrototypeOf = Object.getPrototypeOf; - -module.exports = function (t, a) { - var x = {}, y = {}; - - if (t === null) return; - a(t(x, y), x, "Return self object"); - a(getPrototypeOf(x), y, "Object"); - a.throws(function () { t(x); }, TypeError, "Undefined"); - a.throws(function () { t('foo'); }, TypeError, "Primitive"); - a(getPrototypeOf(t(x, null)), t.nullPolyfill || null, "Null"); - x = create(null); - a.h1("Change null prototype"); - a(t(x, y), x, "Result"); - a(getPrototypeOf(x), y, "Prototype"); - a.h1("Set null prototype"); - a(t(y, null), y, "Result"); - a(getPrototypeOf(y), t.nullPolyfill || null, "Prototype"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/some.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/some.js deleted file mode 100644 index 490431e7acd543..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/some.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -var o = { 1: 1, 2: 2, 3: 3 }; - -module.exports = function (t, a) { - var o2 = {}, i = 0; - t(o, function (value, name) { - o2[name] = value; - return false; - }); - a(JSON.stringify(o2), JSON.stringify(o), "Iterates"); - - a(t(o, function () { - ++i; - return true; - }), true, "Succeeds"); - a(i, 1, "Stops iteration after condition is met"); - - a(t(o, function () { - return false; - }), false, "Fails"); - -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/to-array.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/to-array.js deleted file mode 100644 index 1f4beef7eae835..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/to-array.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var o = { 1: 1, 2: 2, 3: 3 }, o1 = {} - , o2 = t(o, function (value, name, self) { - a(self, o, "Self"); - a(this, o1, "Scope"); - return value + Number(name); - }, o1); - a.deep(o2, [2, 4, 6]); - - t(o).sort().forEach(function (item) { - a.deep(item, [item[0], o[item[0]]], "Default"); - }); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/unserialize.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/unserialize.js deleted file mode 100644 index 405eef112ff76e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/unserialize.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var fn = function (raz, dwa) { return raz + dwa; }; - a(t('undefined'), undefined, "Undefined"); - a(t('null'), null, "Null"); - a(t('"raz"'), 'raz', "String"); - a(t('"raz\\"ddwa\\ntrzy"'), 'raz"ddwa\ntrzy', "String with escape"); - a(t('false'), false, "Booelean"); - a(String(t(String(fn))), String(fn), "Function"); - - a.deep(t('/raz-dwa/g'), /raz-dwa/g, "RegExp"); - a.deep(t('new Date(1234567)'), new Date(1234567), "Date"); - a.deep(t('[]'), [], "Empty array"); - a.deep(t('[undefined,false,null,"raz\\"ddwa\\ntrzy",/raz/g,new Date(1234567),["foo"]]'), - [undefined, false, null, 'raz"ddwa\ntrzy', /raz/g, new Date(1234567), ['foo']], "Rich Array"); - a.deep(t('{}'), {}, "Empty object"); - a.deep(t('{"raz":undefined,"dwa":false,"trzy":null,"cztery":"raz\\"ddwa\\ntrzy",' + - '"szesc":/raz/g,"siedem":new Date(1234567),"osiem":["foo",32],' + - '"dziewiec":{"foo":"bar","dwa":343}}'), - { raz: undefined, dwa: false, trzy: null, cztery: 'raz"ddwa\ntrzy', szesc: /raz/g, - siedem: new Date(1234567), osiem: ['foo', 32], dziewiec: { foo: 'bar', dwa: 343 } }, - "Rich object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/valid-callable.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/valid-callable.js deleted file mode 100644 index b40540b6ba61b0..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/valid-callable.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var f = function () {}; - a(t(f), f, "Function"); - a.throws(function () { - t({}); - }, "Not Function"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/valid-object.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/valid-object.js deleted file mode 100644 index eaa8e7bcb364b5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/valid-object.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x; - a.throws(function () { t(0); }, TypeError, "0"); - a.throws(function () { t(false); }, TypeError, "false"); - a.throws(function () { t(''); }, TypeError, "''"); - a(t(x = {}), x, "Object"); - a(t(x = function () {}), x, "Function"); - a(t(x = new String('raz')), x, "String object"); //jslint: ignore - a(t(x = new Date()), x, "Date"); - - a.throws(function () { t(); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "null"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/valid-value.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/valid-value.js deleted file mode 100644 index f1eeafa9778863..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/valid-value.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var numIsNaN = require('../../number/is-nan'); - -module.exports = function (t, a) { - var x; - a(t(0), 0, "0"); - a(t(false), false, "false"); - a(t(''), '', "''"); - a(numIsNaN(t(NaN)), true, "NaN"); - a(t(x = {}), x, "{}"); - - a.throws(function () { - t(); - }, "Undefined"); - a.throws(function () { - t(null); - }, "null"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-array-like-object.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-array-like-object.js deleted file mode 100644 index 2f3e31b442ebcb..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-array-like-object.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x; - a.throws(function () { t(0); }, TypeError, "0"); - a.throws(function () { t(false); }, TypeError, "false"); - a.throws(function () { t(''); }, TypeError, "String"); - a.throws(function () { t({}); }, TypeError, "Plain Object"); - a.throws(function () { t(function () {}); }, TypeError, "Function"); - a(t(x = new String('raz')), x, "String object"); //jslint: ignore - - a(t(x = { length: 1 }), x, "Array like"); - a.throws(function () { t(); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "null"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-array-like.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-array-like.js deleted file mode 100644 index 53bd11249e3d04..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-array-like.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x; - a.throws(function () { t(0); }, TypeError, "0"); - a.throws(function () { t(false); }, TypeError, "false"); - a(t(''), '', "''"); - a.throws(function () { t({}); }, TypeError, "Plain Object"); - a.throws(function () { t(function () {}); }, TypeError, "Function"); - a(t(x = new String('raz')), x, "String object"); //jslint: ignore - - a(t(x = { length: 1 }), x, "Array like"); - a.throws(function () { t(); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "null"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-stringifiable-value.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-stringifiable-value.js deleted file mode 100644 index ae9bd17a59a028..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-stringifiable-value.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x; - a.throws(function () { t(); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "Null"); - a(t(0), "0"); - a(t(false), "false"); - a(t(''), ""); - a(t({}), String({}), "Object"); - a(t(x = function () {}), String(x), "Function"); - a(t(x = new String('raz')), String(x), "String object"); //jslint: ignore - a(t(x = new Date()), String(x), "Date"); - - a.throws(function () { t(Object.create(null)); }, TypeError, "Null prototype object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-stringifiable.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-stringifiable.js deleted file mode 100644 index 4a46bb521900db..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/object/validate-stringifiable.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var x; - a(t(), 'undefined', "Undefined"); - a(t(null), 'null', "Null"); - a(t(0), "0"); - a(t(false), "false"); - a(t(''), ""); - a(t({}), String({}), "Object"); - a(t(x = function () {}), String(x), "Function"); - a(t(x = new String('raz')), String(x), "String object"); //jslint: ignore - a(t(x = new Date()), String(x), "Date"); - - a.throws(function () { t(Object.create(null)); }, TypeError, "Null prototype object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/index.js deleted file mode 100644 index ca2bd650615889..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/index.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var indexTest = require('tad/lib/utils/index-test') - - , path = require('path').resolve(__dirname, '../../../reg-exp/#'); - -module.exports = function (t, a, d) { - indexTest(indexTest.readDir(path).aside(function (data) { - delete data.sticky; - delete data.unicode; - }))(t, a, d); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/is-sticky.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/is-sticky.js deleted file mode 100644 index e154ac2916557f..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/is-sticky.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var re; - a(t.call(/raz/), false, "Normal"); - a(t.call(/raz/g), false, "Global"); - try { re = new RegExp('raz', 'y'); } catch (ignore) {} - if (!re) return; - a(t.call(re), true, "Sticky"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/is-unicode.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/is-unicode.js deleted file mode 100644 index 2ffb9e869bd6a3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/is-unicode.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var re; - a(t.call(/raz/), false, "Normal"); - a(t.call(/raz/g), false, "Global"); - try { re = new RegExp('raz', 'u'); } catch (ignore) {} - if (!re) return; - a(t.call(re), true, "Unicode"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/implement.js deleted file mode 100644 index 89825a45f6148d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../reg-exp/#/match/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/shim.js deleted file mode 100644 index 5249139fff2277..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/match/shim.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var result = ['foo']; - result.index = 0; - result.input = 'foobar'; - a.deep(t.call(/foo/, 'foobar'), result); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/implement.js deleted file mode 100644 index c32b23a6d03e79..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../reg-exp/#/replace/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/shim.js deleted file mode 100644 index 2b378fd594e2ef..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/replace/shim.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call(/foo/, 'foobar', 'mar'), 'marbar'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/implement.js deleted file mode 100644 index ff1b8087f2c697..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../reg-exp/#/search/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/shim.js deleted file mode 100644 index 596bcdb92ed203..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/search/shim.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call(/foo/, 'barfoo'), 3); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/implement.js deleted file mode 100644 index 1cee441806c065..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../reg-exp/#/split/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/shim.js deleted file mode 100644 index 6a95cd03d6ce68..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/split/shim.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a.deep(t.call(/\|/, 'bar|foo'), ['bar', 'foo']); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/sticky/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/sticky/implement.js deleted file mode 100644 index d94e7b98d8fe46..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/sticky/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../reg-exp/#/sticky/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/sticky/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/sticky/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/sticky/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/unicode/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/unicode/implement.js deleted file mode 100644 index 9b1aa0f2ab992d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/unicode/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../reg-exp/#/unicode/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/unicode/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/unicode/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/#/unicode/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/escape.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/escape.js deleted file mode 100644 index 5b00f67f28ce45..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/escape.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var str = "(?:^te|er)s{2}t\\[raz]+$"; - a(RegExp('^' + t(str) + '$').test(str), true); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/is-reg-exp.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/is-reg-exp.js deleted file mode 100644 index 785ca28c2ecb2c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/is-reg-exp.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t('arar'), false, "String"); - a(t(12), false, "Number"); - a(t(true), false, "Boolean"); - a(t(new Date()), false, "Date"); - a(t(new String('raz')), false, "String object"); - a(t({}), false, "Plain object"); - a(t(/a/), true, "Regular expression"); - a(t(new RegExp('a')), true, "Regular expression via constructor"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/valid-reg-exp.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/valid-reg-exp.js deleted file mode 100644 index cd12cf126a609a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/reg-exp/valid-reg-exp.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var r = /raz/; - a(t(r), r, "Direct"); - r = new RegExp('foo'); - a(t(r), r, "Constructor"); - a.throws(function () { - t({}); - }, "Object"); - a.throws(function () { - t(function () {}); - }, "Function"); - a.throws(function () { - t({ exec: function () { return 20; } }); - }, "Plain object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/implement.js deleted file mode 100644 index 09bf3361acd6a2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../string/#/@@iterator/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/shim.js deleted file mode 100644 index 3b0e0b7547ece9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/@@iterator/shim.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - var it = t.call('r💩z'); - a.deep(it.next(), { done: false, value: 'r' }, "#1"); - a.deep(it.next(), { done: false, value: '💩' }, "#2"); - a.deep(it.next(), { done: false, value: 'z' }, "#3"); - a.deep(it.next(), { done: true, value: undefined }, "End"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/at.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/at.js deleted file mode 100644 index 2447a9f64d5d83..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/at.js +++ /dev/null @@ -1,97 +0,0 @@ -// See tests at https://github.com/mathiasbynens/String.prototype.at - -'use strict'; - -module.exports = function (t, a) { - a(t.length, 1, "Length"); - - a.h1("BMP"); - a(t.call('abc\uD834\uDF06def', -Infinity), '', "-Infinity"); - a(t.call('abc\uD834\uDF06def', -1), '', "-1"); - a(t.call('abc\uD834\uDF06def', -0), 'a', "-0"); - a(t.call('abc\uD834\uDF06def', +0), 'a', "+0"); - a(t.call('abc\uD834\uDF06def', 1), 'b', "1"); - a(t.call('abc\uD834\uDF06def', 3), '\uD834\uDF06', "3"); - a(t.call('abc\uD834\uDF06def', 4), '\uDF06', "4"); - a(t.call('abc\uD834\uDF06def', 5), 'd', "5"); - a(t.call('abc\uD834\uDF06def', 42), '', "42"); - a(t.call('abc\uD834\uDF06def', +Infinity), '', "+Infinity"); - a(t.call('abc\uD834\uDF06def', null), 'a', "null"); - a(t.call('abc\uD834\uDF06def', undefined), 'a', "undefined"); - a(t.call('abc\uD834\uDF06def'), 'a', "No argument"); - a(t.call('abc\uD834\uDF06def', false), 'a', "false"); - a(t.call('abc\uD834\uDF06def', NaN), 'a', "NaN"); - a(t.call('abc\uD834\uDF06def', ''), 'a', "Empty string"); - a(t.call('abc\uD834\uDF06def', '_'), 'a', "_"); - a(t.call('abc\uD834\uDF06def', '1'), 'b', "'1'"); - a(t.call('abc\uD834\uDF06def', []), 'a', "[]"); - a(t.call('abc\uD834\uDF06def', {}), 'a', "{}"); - a(t.call('abc\uD834\uDF06def', -0.9), 'a', "-0.9"); - a(t.call('abc\uD834\uDF06def', 1.9), 'b', "1.9"); - a(t.call('abc\uD834\uDF06def', 7.9), 'f', "7.9"); - a(t.call('abc\uD834\uDF06def', Math.pow(2, 32)), '', "Big number"); - - a.h1("Astral symbol"); - a(t.call('\uD834\uDF06def', -Infinity), '', "-Infinity"); - a(t.call('\uD834\uDF06def', -1), '', "-1"); - a(t.call('\uD834\uDF06def', -0), '\uD834\uDF06', "-0"); - a(t.call('\uD834\uDF06def', +0), '\uD834\uDF06', "+0"); - a(t.call('\uD834\uDF06def', 1), '\uDF06', "1"); - a(t.call('\uD834\uDF06def', 2), 'd', "2"); - a(t.call('\uD834\uDF06def', 3), 'e', "3"); - a(t.call('\uD834\uDF06def', 4), 'f', "4"); - a(t.call('\uD834\uDF06def', 42), '', "42"); - a(t.call('\uD834\uDF06def', +Infinity), '', "+Infinity"); - a(t.call('\uD834\uDF06def', null), '\uD834\uDF06', "null"); - a(t.call('\uD834\uDF06def', undefined), '\uD834\uDF06', "undefined"); - a(t.call('\uD834\uDF06def'), '\uD834\uDF06', "No arguments"); - a(t.call('\uD834\uDF06def', false), '\uD834\uDF06', "false"); - a(t.call('\uD834\uDF06def', NaN), '\uD834\uDF06', "NaN"); - a(t.call('\uD834\uDF06def', ''), '\uD834\uDF06', "Empty string"); - a(t.call('\uD834\uDF06def', '_'), '\uD834\uDF06', "_"); - a(t.call('\uD834\uDF06def', '1'), '\uDF06', "'1'"); - - a.h1("Lone high surrogates"); - a(t.call('\uD834abc', -Infinity), '', "-Infinity"); - a(t.call('\uD834abc', -1), '', "-1"); - a(t.call('\uD834abc', -0), '\uD834', "-0"); - a(t.call('\uD834abc', +0), '\uD834', "+0"); - a(t.call('\uD834abc', 1), 'a', "1"); - a(t.call('\uD834abc', 42), '', "42"); - a(t.call('\uD834abc', +Infinity), '', "Infinity"); - a(t.call('\uD834abc', null), '\uD834', "null"); - a(t.call('\uD834abc', undefined), '\uD834', "undefined"); - a(t.call('\uD834abc'), '\uD834', "No arguments"); - a(t.call('\uD834abc', false), '\uD834', "false"); - a(t.call('\uD834abc', NaN), '\uD834', "NaN"); - a(t.call('\uD834abc', ''), '\uD834', "Empty string"); - a(t.call('\uD834abc', '_'), '\uD834', "_"); - a(t.call('\uD834abc', '1'), 'a', "'a'"); - - a.h1("Lone low surrogates"); - a(t.call('\uDF06abc', -Infinity), '', "-Infinity"); - a(t.call('\uDF06abc', -1), '', "-1"); - a(t.call('\uDF06abc', -0), '\uDF06', "-0"); - a(t.call('\uDF06abc', +0), '\uDF06', "+0"); - a(t.call('\uDF06abc', 1), 'a', "1"); - a(t.call('\uDF06abc', 42), '', "42"); - a(t.call('\uDF06abc', +Infinity), '', "+Infinity"); - a(t.call('\uDF06abc', null), '\uDF06', "null"); - a(t.call('\uDF06abc', undefined), '\uDF06', "undefined"); - a(t.call('\uDF06abc'), '\uDF06', "No arguments"); - a(t.call('\uDF06abc', false), '\uDF06', "false"); - a(t.call('\uDF06abc', NaN), '\uDF06', "NaN"); - a(t.call('\uDF06abc', ''), '\uDF06', "Empty string"); - a(t.call('\uDF06abc', '_'), '\uDF06', "_"); - a(t.call('\uDF06abc', '1'), 'a', "'1'"); - - a.h1("Context"); - a.throws(function () { t.call(undefined); }, TypeError, "Undefined"); - a.throws(function () { t.call(undefined, 4); }, TypeError, - "Undefined + argument"); - a.throws(function () { t.call(null); }, TypeError, "Null"); - a.throws(function () { t.call(null, 4); }, TypeError, "Null + argument"); - a(t.call(42, 0), '4', "Number #1"); - a(t.call(42, 1), '2', "Number #2"); - a(t.call({ toString: function () { return 'abc'; } }, 2), 'c', "Object"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/camel-to-hyphen.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/camel-to-hyphen.js deleted file mode 100644 index 64e35c03da0e9d..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/camel-to-hyphen.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call('razDwaTRzy4yFoo45My'), 'raz-dwa-t-rzy4y-foo45-my'); - a(t.call('razDwaTRzy4yFoo45My-'), 'raz-dwa-t-rzy4y-foo45-my-'); - a(t.call('razDwaTRzy4yFoo45My--'), 'raz-dwa-t-rzy4y-foo45-my--'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/capitalize.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/capitalize.js deleted file mode 100644 index fa11ff8eeff856..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/capitalize.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call('raz'), 'Raz', "Word"); - a(t.call('BLA'), 'BLA', "Uppercase"); - a(t.call(''), '', "Empty"); - a(t.call('a'), 'A', "One letter"); - a(t.call('this is a test'), 'This is a test', "Sentence"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/case-insensitive-compare.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/case-insensitive-compare.js deleted file mode 100644 index 01a90c39ce8307..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/case-insensitive-compare.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call("AA", "aa"), 0, "Same"); - a.ok(t.call("Amber", "zebra") < 0, "Less"); - a.ok(t.call("Zebra", "amber") > 0, "Greater"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/implement.js deleted file mode 100644 index 5e33cd715ff47b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/implement.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -var isImplemented = - require('../../../../string/#/code-point-at/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/shim.js deleted file mode 100644 index 0df4751c564421..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/code-point-at/shim.js +++ /dev/null @@ -1,81 +0,0 @@ -// Taken from: https://github.com/mathiasbynens/String.prototype.codePointAt -// /blob/master/tests/tests.js - -'use strict'; - -module.exports = function (t, a) { - a(t.length, 1, "Length"); - - // String that starts with a BMP symbol - a(t.call('abc\uD834\uDF06def', ''), 0x61); - a(t.call('abc\uD834\uDF06def', '_'), 0x61); - a(t.call('abc\uD834\uDF06def'), 0x61); - a(t.call('abc\uD834\uDF06def', -Infinity), undefined); - a(t.call('abc\uD834\uDF06def', -1), undefined); - a(t.call('abc\uD834\uDF06def', -0), 0x61); - a(t.call('abc\uD834\uDF06def', 0), 0x61); - a(t.call('abc\uD834\uDF06def', 3), 0x1D306); - a(t.call('abc\uD834\uDF06def', 4), 0xDF06); - a(t.call('abc\uD834\uDF06def', 5), 0x64); - a(t.call('abc\uD834\uDF06def', 42), undefined); - a(t.call('abc\uD834\uDF06def', Infinity), undefined); - a(t.call('abc\uD834\uDF06def', Infinity), undefined); - a(t.call('abc\uD834\uDF06def', NaN), 0x61); - a(t.call('abc\uD834\uDF06def', false), 0x61); - a(t.call('abc\uD834\uDF06def', null), 0x61); - a(t.call('abc\uD834\uDF06def', undefined), 0x61); - - // String that starts with an astral symbol - a(t.call('\uD834\uDF06def', ''), 0x1D306); - a(t.call('\uD834\uDF06def', '1'), 0xDF06); - a(t.call('\uD834\uDF06def', '_'), 0x1D306); - a(t.call('\uD834\uDF06def'), 0x1D306); - a(t.call('\uD834\uDF06def', -1), undefined); - a(t.call('\uD834\uDF06def', -0), 0x1D306); - a(t.call('\uD834\uDF06def', 0), 0x1D306); - a(t.call('\uD834\uDF06def', 1), 0xDF06); - a(t.call('\uD834\uDF06def', 42), undefined); - a(t.call('\uD834\uDF06def', false), 0x1D306); - a(t.call('\uD834\uDF06def', null), 0x1D306); - a(t.call('\uD834\uDF06def', undefined), 0x1D306); - - // Lone high surrogates - a(t.call('\uD834abc', ''), 0xD834); - a(t.call('\uD834abc', '_'), 0xD834); - a(t.call('\uD834abc'), 0xD834); - a(t.call('\uD834abc', -1), undefined); - a(t.call('\uD834abc', -0), 0xD834); - a(t.call('\uD834abc', 0), 0xD834); - a(t.call('\uD834abc', false), 0xD834); - a(t.call('\uD834abc', NaN), 0xD834); - a(t.call('\uD834abc', null), 0xD834); - a(t.call('\uD834abc', undefined), 0xD834); - - // Lone low surrogates - a(t.call('\uDF06abc', ''), 0xDF06); - a(t.call('\uDF06abc', '_'), 0xDF06); - a(t.call('\uDF06abc'), 0xDF06); - a(t.call('\uDF06abc', -1), undefined); - a(t.call('\uDF06abc', -0), 0xDF06); - a(t.call('\uDF06abc', 0), 0xDF06); - a(t.call('\uDF06abc', false), 0xDF06); - a(t.call('\uDF06abc', NaN), 0xDF06); - a(t.call('\uDF06abc', null), 0xDF06); - a(t.call('\uDF06abc', undefined), 0xDF06); - - a.throws(function () { t.call(undefined); }, TypeError); - a.throws(function () { t.call(undefined, 4); }, TypeError); - a.throws(function () { t.call(null); }, TypeError); - a.throws(function () { t.call(null, 4); }, TypeError); - a(t.call(42, 0), 0x34); - a(t.call(42, 1), 0x32); - a(t.call({ toString: function () { return 'abc'; } }, 2), 0x63); - - a.throws(function () { t.apply(undefined); }, TypeError); - a.throws(function () { t.apply(undefined, [4]); }, TypeError); - a.throws(function () { t.apply(null); }, TypeError); - a.throws(function () { t.apply(null, [4]); }, TypeError); - a(t.apply(42, [0]), 0x34); - a(t.apply(42, [1]), 0x32); - a(t.apply({ toString: function () { return 'abc'; } }, [2]), 0x63); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/implement.js deleted file mode 100644 index 220f50d4672f13..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../string/#/contains/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/shim.js deleted file mode 100644 index a0ea4db20812e5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/contains/shim.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call('raz', ''), true, "Empty"); - a(t.call('', ''), true, "Both Empty"); - a(t.call('raz', 'raz'), true, "Same"); - a(t.call('razdwa', 'raz'), true, "Starts with"); - a(t.call('razdwa', 'dwa'), true, "Ends with"); - a(t.call('razdwa', 'zdw'), true, "In middle"); - a(t.call('', 'raz'), false, "Something in empty"); - a(t.call('az', 'raz'), false, "Longer"); - a(t.call('azasdfasdf', 'azff'), false, "Not found"); - a(t.call('razdwa', 'raz', 1), false, "Position"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/implement.js deleted file mode 100644 index 93bd2ddcd6dc20..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../string/#/ends-with/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/shim.js deleted file mode 100644 index e4b93c407bc2b5..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/ends-with/shim.js +++ /dev/null @@ -1,16 +0,0 @@ -// In some parts copied from: -// http://closure-library.googlecode.com/svn/trunk/closure/goog/ -// string/string_test.html - -'use strict'; - -module.exports = function (t, a) { - a(t.call('abc', ''), true, "Empty needle"); - a(t.call('abcd', 'cd'), true, "Ends with needle"); - a(t.call('abcd', 'abcd'), true, "Needle equals haystack"); - a(t.call('abcd', 'ab'), false, "Doesn't end with needle"); - a(t.call('abc', 'defg'), false, "Length trick"); - a(t.call('razdwa', 'zd', 3), false, "Position: false"); - a(t.call('razdwa', 'zd', 4), true, "Position: true"); - a(t.call('razdwa', 'zd', 5), false, "Position: false #2"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/hyphen-to-camel.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/hyphen-to-camel.js deleted file mode 100644 index 0118dd817319b7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/hyphen-to-camel.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call('raz-dwa-t-rzy-4y-rtr4-tiu-45-pa'), 'razDwaTRzy4yRtr4Tiu45Pa'); - a(t.call('raz-dwa-t-rzy-4y-rtr4-tiu-45-pa-'), 'razDwaTRzy4yRtr4Tiu45Pa-'); - a(t.call('raz-dwa-t-rzy-4y-rtr4-tiu-45-pa--'), 'razDwaTRzy4yRtr4Tiu45Pa--'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/indent.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/indent.js deleted file mode 100644 index eb92b36f5438d6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/indent.js +++ /dev/null @@ -1,9 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call('ra\nzz', ''), 'ra\nzz', "Empty"); - a(t.call('ra\nzz', '\t', 3), '\t\t\tra\n\t\t\tzz', "String repeat"); - a(t.call('ra\nzz\nsss\nfff\n', '\t'), '\tra\n\tzz\n\tsss\n\tfff\n', - "Multi-line"); - a(t.call('ra\n\nzz\n', '\t'), '\tra\n\n\tzz\n', "Don't touch empty lines"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/last.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/last.js deleted file mode 100644 index ad36a213c6053e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/last.js +++ /dev/null @@ -1,6 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call(''), null, "Null"); - a(t.call('abcdef'), 'f', "String"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/_data.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/_data.js deleted file mode 100644 index c741addb0055a9..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/_data.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t[0], 'object'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/implement.js deleted file mode 100644 index 4886c9b834285b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../string/#/normalize/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/shim.js deleted file mode 100644 index 28e27f595247be..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/normalize/shim.js +++ /dev/null @@ -1,13 +0,0 @@ -// Taken from: https://github.com/walling/unorm/blob/master/test/es6-shim.js - -'use strict'; - -var str = 'äiti'; - -module.exports = function (t, a) { - a(t.call(str), "\u00e4iti"); - a(t.call(str, "NFC"), "\u00e4iti"); - a(t.call(str, "NFD"), "a\u0308iti"); - a(t.call(str, "NFKC"), "\u00e4iti"); - a(t.call(str, "NFKD"), "a\u0308iti"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/pad.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/pad.js deleted file mode 100644 index 28c3fcaa10c4da..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/pad.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -var partial = require('../../../function/#/partial'); - -module.exports = { - Left: function (t, a) { - t = partial.call(t, 'x', 5); - - a(t.call('yy'), 'xxxyy'); - a(t.call(''), 'xxxxx', "Empty string"); - - a(t.call('yyyyy'), 'yyyyy', 'Equal length'); - a(t.call('yyyyyyy'), 'yyyyyyy', 'Longer'); - }, - Right: function (t, a) { - t = partial.call(t, 'x', -5); - - a(t.call('yy'), 'yyxxx'); - a(t.call(''), 'xxxxx', "Empty string"); - - a(t.call('yyyyy'), 'yyyyy', 'Equal length'); - a(t.call('yyyyyyy'), 'yyyyyyy', 'Longer'); - } -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/plain-replace-all.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/plain-replace-all.js deleted file mode 100644 index a425c87a40553b..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/plain-replace-all.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call('razdwatrzy', 'dwa', 'olera'), 'razoleratrzy', "Basic"); - a(t.call('razdwatrzy', 'dwa', 'ole$&a'), 'razole$&atrzy', "Inserts"); - a(t.call('razdwa', 'ola', 'sdfs'), 'razdwa', "No replace"); - - a(t.call('$raz$$dwa$trzy$', '$', '&&'), '&&raz&&&&dwa&&trzy&&', "Multi"); - a(t.call('$raz$$dwa$$$$trzy$', '$$', '&'), '$raz&dwa&&trzy$', - "Multi many chars"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/plain-replace.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/plain-replace.js deleted file mode 100644 index 54522ed749fe37..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/plain-replace.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call('razdwatrzy', 'dwa', 'olera'), 'razoleratrzy', "Basic"); - a(t.call('razdwatrzy', 'dwa', 'ole$&a'), 'razole$&atrzy', "Inserts"); - a(t.call('razdwa', 'ola', 'sdfs'), 'razdwa', "No replace"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/implement.js deleted file mode 100644 index 7ff65a811068b4..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../string/#/repeat/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/shim.js deleted file mode 100644 index 7e0d077ec4bdb6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/repeat/shim.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call('a', 0), '', "Empty"); - a(t.call('a', 1), 'a', "1"); - a(t.call('\t', 5), '\t\t\t\t\t', "Whitespace"); - a(t.call('raz', 3), 'razrazraz', "Many chars"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/implement.js deleted file mode 100644 index fc8490fc916ac3..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../../string/#/starts-with/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/shim.js deleted file mode 100644 index e0e123b324e115..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/starts-with/shim.js +++ /dev/null @@ -1,14 +0,0 @@ -// Inspired and in some parts copied from: -// http://closure-library.googlecode.com/svn/trunk/closure/goog -// /string/string_test.html - -'use strict'; - -module.exports = function (t, a) { - a(t.call('abc', ''), true, "Empty needle"); - a(t.call('abcd', 'ab'), true, "Starts with needle"); - a(t.call('abcd', 'abcd'), true, "Needle equals haystack"); - a(t.call('abcd', 'bcde', 1), false, "Needle larger than haystack"); - a(!t.call('abcd', 'cd'), true, "Doesn't start with needle"); - a(t.call('abcd', 'bc', 1), true, "Position"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/uncapitalize.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/uncapitalize.js deleted file mode 100644 index 50f35f1fe40a91..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/#/uncapitalize.js +++ /dev/null @@ -1,10 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t.call('raz'), 'raz', "Word"); - a(t.call('BLA'), 'bLA', "Uppercase"); - a(t.call(''), '', "Empty"); - a(t.call('a'), 'a', "One letter"); - a(t.call('this is a test'), 'this is a test', "Sentence"); - a(t.call('This is a test'), 'this is a test', "Capitalized sentence"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/format-method.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/format-method.js deleted file mode 100644 index bb5561ee45bb59..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/format-method.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - t = t({ a: 'A', aa: 'B', ab: 'C', b: 'D', - c: function () { return ++this.a; } }); - a(t.call({ a: 0 }, ' %a%aab%abb%b\\%aa%ab%c%c '), ' ABbCbD%aaC12 '); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/implement.js deleted file mode 100644 index 0aceb97efdcf36..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../string/from-code-point/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/shim.js deleted file mode 100644 index 88cda3d6364719..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/from-code-point/shim.js +++ /dev/null @@ -1,47 +0,0 @@ -// Taken from: https://github.com/mathiasbynens/String.fromCodePoint/blob/master -// /tests/tests.js - -'use strict'; - -var pow = Math.pow; - -module.exports = function (t, a) { - var counter, result; - - a(t.length, 1, "Length"); - a(String.propertyIsEnumerable('fromCodePoint'), false, "Not enumerable"); - - a(t(''), '\0', "Empty string"); - a(t(), '', "No arguments"); - a(t(-0), '\0', "-0"); - a(t(0), '\0', "0"); - a(t(0x1D306), '\uD834\uDF06', "Unicode"); - a(t(0x1D306, 0x61, 0x1D307), '\uD834\uDF06a\uD834\uDF07', "Complex unicode"); - a(t(0x61, 0x62, 0x1D307), 'ab\uD834\uDF07', "Complex"); - a(t(false), '\0', "false"); - a(t(null), '\0', "null"); - - a.throws(function () { t('_'); }, RangeError, "_"); - a.throws(function () { t(Infinity); }, RangeError, "Infinity"); - a.throws(function () { t(-Infinity); }, RangeError, "-Infinity"); - a.throws(function () { t(-1); }, RangeError, "-1"); - a.throws(function () { t(0x10FFFF + 1); }, RangeError, "Range error #1"); - a.throws(function () { t(3.14); }, RangeError, "Range error #2"); - a.throws(function () { t(3e-2); }, RangeError, "Range error #3"); - a.throws(function () { t(-Infinity); }, RangeError, "Range error #4"); - a.throws(function () { t(+Infinity); }, RangeError, "Range error #5"); - a.throws(function () { t(NaN); }, RangeError, "Range error #6"); - a.throws(function () { t(undefined); }, RangeError, "Range error #7"); - a.throws(function () { t({}); }, RangeError, "Range error #8"); - a.throws(function () { t(/re/); }, RangeError, "Range error #9"); - - counter = pow(2, 15) * 3 / 2; - result = []; - while (--counter >= 0) result.push(0); // one code unit per symbol - t.apply(null, result); // must not throw - - counter = pow(2, 15) * 3 / 2; - result = []; - while (--counter >= 0) result.push(0xFFFF + 1); // two code units per symbol - t.apply(null, result); // must not throw -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/is-string.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/is-string.js deleted file mode 100644 index 32f595829168ee..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/is-string.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { - a(t(null), false, "Null"); - a(t(''), true, "Empty string"); - a(t(12), false, "Number"); - a(t(false), false, "Boolean"); - a(t(new Date()), false, "Date"); - a(t(new String('raz')), true, "String object"); - a(t('asdfaf'), true, "String"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/random-uniq.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/random-uniq.js deleted file mode 100644 index 6791ac266e7530..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/random-uniq.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var isValidFormat = RegExp.prototype.test.bind(/^[a-z0-9]+$/); - -module.exports = function (t, a) { - a(typeof t(), 'string'); - a.ok(t().length > 7); - a.not(t(), t()); - a.ok(isValidFormat(t())); - a.ok(isValidFormat(t())); - a.ok(isValidFormat(t())); - a.ok(isValidFormat(t())); - a.ok(isValidFormat(t())); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/implement.js deleted file mode 100644 index 59416de3af53ad..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/implement.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict'; - -var isImplemented = require('../../../string/raw/is-implemented'); - -module.exports = function (a) { a(isImplemented(), true); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/index.js deleted file mode 100644 index 2e0bfa3249d806..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/index.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = require('./shim'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/is-implemented.js deleted file mode 100644 index 1a8832889bf493..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/is-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t(), 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/shim.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/shim.js deleted file mode 100644 index 025ed780455667..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/node_modules/es5-ext/test/string/raw/shim.js +++ /dev/null @@ -1,15 +0,0 @@ -// Partially taken from: -// https://github.com/paulmillr/es6-shim/blob/master/test/string.js - -'use strict'; - -module.exports = function (t, a) { - var callSite = []; - - callSite.raw = ["The total is ", " ($", " with tax)"]; - a(t(callSite, '{total}', '{total * 1.01}'), - 'The total is {total} (${total * 1.01} with tax)'); - - callSite.raw = []; - a(t(callSite, '{total}', '{total * 1.01}'), ''); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/package.json deleted file mode 100644 index 2e12775fc72035..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/package.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "es6-symbol@^3.0.2", - "scope": null, - "escapedName": "es6-symbol", - "name": "es6-symbol", - "rawSpec": "^3.0.2", - "spec": ">=3.0.2 <4.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index" - ] - ], - "_from": "es6-symbol@>=3.0.2 <4.0.0", - "_id": "es6-symbol@3.1.0", - "_inCache": true, - "_installable": true, - "_location": "/node-gyp/path-array/array-index/es6-symbol", - "_nodeVersion": "4.4.5", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/es6-symbol-3.1.0.tgz_1464960261964_0.3645231726113707" - }, - "_npmUser": { - "name": "medikoo", - "email": "medikoo+npm@medikoo.com" - }, - "_npmVersion": "2.15.5", - "_phantomChildren": { - "es6-symbol": "3.1.0" - }, - "_requested": { - "raw": "es6-symbol@^3.0.2", - "scope": null, - "escapedName": "es6-symbol", - "name": "es6-symbol", - "rawSpec": "^3.0.2", - "spec": ">=3.0.2 <4.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/path-array/array-index", - "/node-gyp/path-array/array-index/es6-symbol/es5-ext", - "/node-gyp/path-array/array-index/es6-symbol/es5-ext/es6-iterator" - ], - "_resolved": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.0.tgz", - "_shasum": "94481c655e7a7cad82eba832d97d5433496d7ffa", - "_shrinkwrap": null, - "_spec": "es6-symbol@^3.0.2", - "_where": "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index", - "author": { - "name": "Mariusz Nowak", - "email": "medyk@medikoo.com", - "url": "http://www.medikoo.com/" - }, - "bugs": { - "url": "https://github.com/medikoo/es6-symbol/issues" - }, - "dependencies": { - "d": "~0.1.1", - "es5-ext": "~0.10.11" - }, - "description": "ECMAScript 6 Symbol polyfill", - "devDependencies": { - "tad": "~0.2.4", - "xlint": "~0.2.2", - "xlint-jslint-medikoo": "~0.1.4" - }, - "directories": {}, - "dist": { - "shasum": "94481c655e7a7cad82eba832d97d5433496d7ffa", - "tarball": "https://registry.npmjs.org/es6-symbol/-/es6-symbol-3.1.0.tgz" - }, - "gitHead": "f84175053e9cad6a1230f3b7cc13e078c3fcc12f", - "homepage": "https://github.com/medikoo/es6-symbol#readme", - "keywords": [ - "symbol", - "private", - "property", - "es6", - "ecmascript", - "harmony", - "ponyfill", - "polyfill" - ], - "license": "MIT", - "maintainers": [ - { - "name": "medikoo", - "email": "medikoo+npm@medikoo.com" - } - ], - "name": "es6-symbol", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/medikoo/es6-symbol.git" - }, - "scripts": { - "lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream", - "lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch", - "test": "node ./node_modules/tad/bin/tad" - }, - "version": "3.1.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/polyfill.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/polyfill.js deleted file mode 100644 index 48832a5f36f59e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/polyfill.js +++ /dev/null @@ -1,118 +0,0 @@ -// ES2015 Symbol polyfill for environments that do not support it (or partially support it) - -'use strict'; - -var d = require('d') - , validateSymbol = require('./validate-symbol') - - , create = Object.create, defineProperties = Object.defineProperties - , defineProperty = Object.defineProperty, objPrototype = Object.prototype - , NativeSymbol, SymbolPolyfill, HiddenSymbol, globalSymbols = create(null) - , isNativeSafe; - -if (typeof Symbol === 'function') { - NativeSymbol = Symbol; - try { - String(NativeSymbol()); - isNativeSafe = true; - } catch (ignore) {} -} - -var generateName = (function () { - var created = create(null); - return function (desc) { - var postfix = 0, name, ie11BugWorkaround; - while (created[desc + (postfix || '')]) ++postfix; - desc += (postfix || ''); - created[desc] = true; - name = '@@' + desc; - defineProperty(objPrototype, name, d.gs(null, function (value) { - // For IE11 issue see: - // https://connect.microsoft.com/IE/feedbackdetail/view/1928508/ - // ie11-broken-getters-on-dom-objects - // https://github.com/medikoo/es6-symbol/issues/12 - if (ie11BugWorkaround) return; - ie11BugWorkaround = true; - defineProperty(this, name, d(value)); - ie11BugWorkaround = false; - })); - return name; - }; -}()); - -// Internal constructor (not one exposed) for creating Symbol instances. -// This one is used to ensure that `someSymbol instanceof Symbol` always return false -HiddenSymbol = function Symbol(description) { - if (this instanceof HiddenSymbol) throw new TypeError('TypeError: Symbol is not a constructor'); - return SymbolPolyfill(description); -}; - -// Exposed `Symbol` constructor -// (returns instances of HiddenSymbol) -module.exports = SymbolPolyfill = function Symbol(description) { - var symbol; - if (this instanceof Symbol) throw new TypeError('TypeError: Symbol is not a constructor'); - if (isNativeSafe) return NativeSymbol(description); - symbol = create(HiddenSymbol.prototype); - description = (description === undefined ? '' : String(description)); - return defineProperties(symbol, { - __description__: d('', description), - __name__: d('', generateName(description)) - }); -}; -defineProperties(SymbolPolyfill, { - for: d(function (key) { - if (globalSymbols[key]) return globalSymbols[key]; - return (globalSymbols[key] = SymbolPolyfill(String(key))); - }), - keyFor: d(function (s) { - var key; - validateSymbol(s); - for (key in globalSymbols) if (globalSymbols[key] === s) return key; - }), - - // If there's native implementation of given symbol, let's fallback to it - // to ensure proper interoperability with other native functions e.g. Array.from - hasInstance: d('', (NativeSymbol && NativeSymbol.hasInstance) || SymbolPolyfill('hasInstance')), - isConcatSpreadable: d('', (NativeSymbol && NativeSymbol.isConcatSpreadable) || - SymbolPolyfill('isConcatSpreadable')), - iterator: d('', (NativeSymbol && NativeSymbol.iterator) || SymbolPolyfill('iterator')), - match: d('', (NativeSymbol && NativeSymbol.match) || SymbolPolyfill('match')), - replace: d('', (NativeSymbol && NativeSymbol.replace) || SymbolPolyfill('replace')), - search: d('', (NativeSymbol && NativeSymbol.search) || SymbolPolyfill('search')), - species: d('', (NativeSymbol && NativeSymbol.species) || SymbolPolyfill('species')), - split: d('', (NativeSymbol && NativeSymbol.split) || SymbolPolyfill('split')), - toPrimitive: d('', (NativeSymbol && NativeSymbol.toPrimitive) || SymbolPolyfill('toPrimitive')), - toStringTag: d('', (NativeSymbol && NativeSymbol.toStringTag) || SymbolPolyfill('toStringTag')), - unscopables: d('', (NativeSymbol && NativeSymbol.unscopables) || SymbolPolyfill('unscopables')) -}); - -// Internal tweaks for real symbol producer -defineProperties(HiddenSymbol.prototype, { - constructor: d(SymbolPolyfill), - toString: d('', function () { return this.__name__; }) -}); - -// Proper implementation of methods exposed on Symbol.prototype -// They won't be accessible on produced symbol instances as they derive from HiddenSymbol.prototype -defineProperties(SymbolPolyfill.prototype, { - toString: d(function () { return 'Symbol (' + validateSymbol(this).__description__ + ')'; }), - valueOf: d(function () { return validateSymbol(this); }) -}); -defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toPrimitive, d('', function () { - var symbol = validateSymbol(this); - if (typeof symbol === 'symbol') return symbol; - return symbol.toString(); -})); -defineProperty(SymbolPolyfill.prototype, SymbolPolyfill.toStringTag, d('c', 'Symbol')); - -// Proper implementaton of toPrimitive and toStringTag for returned symbol instances -defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toStringTag, - d('c', SymbolPolyfill.prototype[SymbolPolyfill.toStringTag])); - -// Note: It's important to define `toPrimitive` as last one, as some implementations -// implement `toPrimitive` natively without implementing `toStringTag` (or other specified symbols) -// And that may invoke error in definition flow: -// See: https://github.com/medikoo/es6-symbol/issues/13#issuecomment-164146149 -defineProperty(HiddenSymbol.prototype, SymbolPolyfill.toPrimitive, - d('c', SymbolPolyfill.prototype[SymbolPolyfill.toPrimitive])); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/implement.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/implement.js deleted file mode 100644 index eb35c3018835c7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/implement.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof Symbol, 'function'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/index.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/index.js deleted file mode 100644 index 62b3296df6fc5e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/index.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict'; - -var d = require('d') - - , defineProperty = Object.defineProperty; - -module.exports = function (T, a) { - var symbol = T('test'), x = {}; - defineProperty(x, symbol, d('foo')); - a(x.test, undefined, "Name"); - a(x[symbol], 'foo', "Get"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/is-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/is-implemented.js deleted file mode 100644 index bb0d64536ebbae..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/is-implemented.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -var global = require('es5-ext/global') - , polyfill = require('../polyfill'); - -module.exports = function (t, a) { - var cache; - a(typeof t(), 'boolean'); - cache = global.Symbol; - global.Symbol = polyfill; - a(t(), true); - if (cache === undefined) delete global.Symbol; - else global.Symbol = cache; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/is-native-implemented.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/is-native-implemented.js deleted file mode 100644 index df8ba0323f0cad..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/is-native-implemented.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict'; - -module.exports = function (t, a) { a(typeof t, 'boolean'); }; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/is-symbol.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/is-symbol.js deleted file mode 100644 index ac24b9abbff4e6..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/is-symbol.js +++ /dev/null @@ -1,16 +0,0 @@ -'use strict'; - -var SymbolPoly = require('../polyfill'); - -module.exports = function (t, a) { - a(t(undefined), false, "Undefined"); - a(t(null), false, "Null"); - a(t(true), false, "Primitive"); - a(t('raz'), false, "String"); - a(t({}), false, "Object"); - a(t([]), false, "Array"); - if (typeof Symbol !== 'undefined') { - a(t(Symbol()), true, "Native"); - } - a(t(SymbolPoly()), true, "Polyfill"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/polyfill.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/polyfill.js deleted file mode 100644 index 8b657905de57d7..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/polyfill.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; - -var d = require('d') - , isSymbol = require('../is-symbol') - - , defineProperty = Object.defineProperty; - -module.exports = function (T, a) { - var symbol = T('test'), x = {}; - defineProperty(x, symbol, d('foo')); - a(x.test, undefined, "Name"); - a(x[symbol], 'foo', "Get"); - a(x instanceof T, false); - - a(isSymbol(symbol), true, "Symbol"); - a(isSymbol(T.iterator), true, "iterator"); - a(isSymbol(T.toStringTag), true, "toStringTag"); - - x = {}; - x[symbol] = 'foo'; - if (typeof symbol !== 'symbol') { - a.deep(Object.getOwnPropertyDescriptor(x, symbol), { configurable: true, enumerable: false, - value: 'foo', writable: true }); - } - symbol = T.for('marko'); - a(isSymbol(symbol), true); - a(T.for('marko'), symbol); - a(T.keyFor(symbol), 'marko'); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/validate-symbol.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/validate-symbol.js deleted file mode 100644 index 2c8f84c8239b6e..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/test/validate-symbol.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -var SymbolPoly = require('../polyfill'); - -module.exports = function (t, a) { - var symbol; - a.throws(function () { t(undefined); }, TypeError, "Undefined"); - a.throws(function () { t(null); }, TypeError, "Null"); - a.throws(function () { t(true); }, TypeError, "Primitive"); - a.throws(function () { t('raz'); }, TypeError, "String"); - a.throws(function () { t({}); }, TypeError, "Object"); - a.throws(function () { t([]); }, TypeError, "Array"); - if (typeof Symbol !== 'undefined') { - symbol = Symbol(); - a(t(symbol), symbol, "Native"); - } - symbol = SymbolPoly(); - a(t(symbol), symbol, "Polyfill"); -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/validate-symbol.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/validate-symbol.js deleted file mode 100644 index 42750043d4271c..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/node_modules/es6-symbol/validate-symbol.js +++ /dev/null @@ -1,8 +0,0 @@ -'use strict'; - -var isSymbol = require('./is-symbol'); - -module.exports = function (value) { - if (!isSymbol(value)) throw new TypeError(value + " is not a symbol"); - return value; -}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/package.json deleted file mode 100644 index a4e27587fa7aa1..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/package.json +++ /dev/null @@ -1,95 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "array-index@^1.0.0", - "scope": null, - "escapedName": "array-index", - "name": "array-index", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array" - ] - ], - "_from": "array-index@>=1.0.0 <2.0.0", - "_id": "array-index@1.0.0", - "_inCache": true, - "_installable": true, - "_location": "/node-gyp/path-array/array-index", - "_nodeVersion": "5.3.0", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "_npmVersion": "3.3.12", - "_phantomChildren": {}, - "_requested": { - "raw": "array-index@^1.0.0", - "scope": null, - "escapedName": "array-index", - "name": "array-index", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp/path-array" - ], - "_resolved": "https://registry.npmjs.org/array-index/-/array-index-1.0.0.tgz", - "_shasum": "ec56a749ee103e4e08c790b9c353df16055b97f9", - "_shrinkwrap": null, - "_spec": "array-index@^1.0.0", - "_where": "/Users/rebecca/code/npm/node_modules/node-gyp/node_modules/path-array", - "author": { - "name": "Nathan Rajlich", - "email": "nathan@tootallnate.net", - "url": "http://tootallnate.net" - }, - "bugs": { - "url": "https://github.com/TooTallNate/array-index/issues" - }, - "dependencies": { - "debug": "^2.2.0", - "es6-symbol": "^3.0.2" - }, - "description": "Invoke getter/setter functions on array-like objects", - "devDependencies": {}, - "directories": {}, - "dist": { - "shasum": "ec56a749ee103e4e08c790b9c353df16055b97f9", - "tarball": "https://registry.npmjs.org/array-index/-/array-index-1.0.0.tgz" - }, - "engines": { - "node": "*" - }, - "gitHead": "4b3cc059c70eefd8ef2a0d4213d681b671eb3d11", - "homepage": "https://github.com/TooTallNate/array-index#readme", - "keywords": [ - "index", - "array", - "getter", - "setter", - "proxy" - ], - "license": "MIT", - "main": "index.js", - "maintainers": [ - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } - ], - "name": "array-index", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/TooTallNate/array-index.git" - }, - "scripts": { - "test": "node test" - }, - "version": "1.0.0" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/test.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/test.js deleted file mode 100644 index 65ff607f1c4678..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/node_modules/array-index/test.js +++ /dev/null @@ -1,110 +0,0 @@ -var ArrayIndex = require('./') -var inherits = require('util').inherits -var assert = require('assert') - - -/** - * Create a "subclass". - */ - -function Arrayish (length) { - ArrayIndex.call(this, length) - this.sets = Object.create(null) -} - -// inherit from `ArrayIndex` -inherits(Arrayish, ArrayIndex) - - -// create an instance and run some tests -var a = new Arrayish(11) -assert.equal(a.length, 11); - -assert.throws(function () { - a[0] -}, /you must implement the `ArrayIndex.get` Symbol/) - -assert.throws(function () { - a[0] = 0 -}, /you must implement the `ArrayIndex.set` Symbol/) - - -/** - * This "getter" function checks if the index has previosly been "set", and if so - * returns the index * the value previously set. If the index hasn't been set, - * return the index as-is. - */ - -Arrayish.prototype[ArrayIndex.get] = function get (index) { - if (index in this.sets) { - return +this.sets[index] * index - } else { - return index - } -} - -/** - * Store the last value set for this index. - */ - -Arrayish.prototype[ArrayIndex.set] = function set (index, value) { - this.sets[index] = value -} - - -// test getters without being "set" -assert.equal(0, a[0]) -assert.equal(1, a[1]) -assert.equal(2, a[2]) -assert.equal(3, a[3]) -assert.equal(4, a[4]) - -// test setters, followed by getters -a[10] = 1 -assert.equal(10, a[10]) -a[10] = 2 -assert.equal(20, a[10]) -a[10] = 3 -assert.equal(30, a[10]) - -// test "length" -assert.equal(11, a.length) - -a[4] = 20 -a[6] = 5.55432 -var b = [0, 1, 2, 3, 80, 5, 33.325919999999996, 7, 8, 9, 30] -assert.equal(JSON.stringify(b), JSON.stringify(a)) - - -/** - * It should work when invoking as a Mixin. - */ - -function Foo () { - ArrayIndex.call(this, 5); -} -var f = new Foo(); - -// these throw because there's no __get__ and __set__ function defined -assert.throws(function () { - f[0]; -}); -assert.throws(function () { - f[0] = 0 -}); - -f[ArrayIndex.get] = function (index) { - return index * 2; -}; - -assert.equal(f[0], 0); -assert.equal(f[1], 2); -assert.equal(f[2], 4); -assert.equal(f[3], 6); - -f[ArrayIndex.set] = function (index, value) { - this['foo' + index] = value; -}; - -f[1] = 'bar'; -assert.equal(f.foo1, 'bar'); diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/package.json b/deps/npm/node_modules/node-gyp/node_modules/path-array/package.json deleted file mode 100644 index df328efaf55c3a..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/package.json +++ /dev/null @@ -1,91 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "path-array@^1.0.0", - "scope": null, - "escapedName": "path-array", - "name": "path-array", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm/node_modules/node-gyp" - ] - ], - "_from": "path-array@>=1.0.0 <2.0.0", - "_id": "path-array@1.0.1", - "_inCache": true, - "_installable": true, - "_location": "/node-gyp/path-array", - "_nodeVersion": "5.3.0", - "_npmUser": { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - }, - "_npmVersion": "3.3.12", - "_phantomChildren": {}, - "_requested": { - "raw": "path-array@^1.0.0", - "scope": null, - "escapedName": "path-array", - "name": "path-array", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/node-gyp" - ], - "_resolved": "https://registry.npmjs.org/path-array/-/path-array-1.0.1.tgz", - "_shasum": "7e2f0f35f07a2015122b868b7eac0eb2c4fec271", - "_shrinkwrap": null, - "_spec": "path-array@^1.0.0", - "_where": "/Users/rebecca/code/npm/node_modules/node-gyp", - "author": { - "name": "Nathan Rajlich", - "email": "nathan@tootallnate.net", - "url": "http://n8.io/" - }, - "bugs": { - "url": "https://github.com/TooTallNate/node-path-array/issues" - }, - "dependencies": { - "array-index": "^1.0.0" - }, - "description": "Treat your $PATH like a JavaScript Array", - "devDependencies": { - "mocha": "~1.16.1" - }, - "directories": {}, - "dist": { - "shasum": "7e2f0f35f07a2015122b868b7eac0eb2c4fec271", - "tarball": "https://registry.npmjs.org/path-array/-/path-array-1.0.1.tgz" - }, - "gitHead": "d249bd897661ca60720218edabbfeaa73c67778a", - "homepage": "https://github.com/TooTallNate/node-path-array", - "keywords": [ - "PATH", - "env", - "array" - ], - "license": "MIT", - "main": "index.js", - "maintainers": [ - { - "name": "tootallnate", - "email": "nathan@tootallnate.net" - } - ], - "name": "path-array", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/TooTallNate/node-path-array.git" - }, - "scripts": { - "test": "mocha --reporter spec" - }, - "version": "1.0.1" -} diff --git a/deps/npm/node_modules/node-gyp/node_modules/path-array/test/test.js b/deps/npm/node_modules/node-gyp/node_modules/path-array/test/test.js deleted file mode 100644 index fc1f3736fa6ad2..00000000000000 --- a/deps/npm/node_modules/node-gyp/node_modules/path-array/test/test.js +++ /dev/null @@ -1,68 +0,0 @@ - -/** - * Module dependencies. - */ - -var assert = require('assert'); -var PathArray = require('../'); -var delimiter = require('path').delimiter || ':'; - -describe('PathArray', function () { - it('should use `process.env` by default', function () { - var p = new PathArray(); - assert.equal(p._env, process.env); - }); - it('should return the $PATH string for .toString()', function () { - var p = new PathArray(); - assert.equal(p.toString(), process.env.PATH); - }); - it('should accept an arbitrary `env` object', function () { - var env = { PATH: '/foo' + delimiter + '/bar' }; - var p = new PathArray(env); - assert.equal(p.toString(), env.PATH); - }); - it('should work for [n] getter syntax', function () { - var env = { PATH: '/foo' + delimiter + '/bar' }; - var p = new PathArray(env); - assert.equal('/foo', p[0]); - assert.equal('/bar', p[1]); - }); - it('should work for [n]= setter syntax', function () { - var env = { PATH: '/foo' + delimiter + '/bar' }; - var p = new PathArray(env); - p[0] = '/baz'; - assert.equal('/baz' + delimiter + '/bar', env.PATH); - }); - it('should work with .push()', function () { - var env = { PATH: '/foo' + delimiter + '/bar' }; - var p = new PathArray(env); - p.push('/baz'); - assert.equal('/foo' + delimiter + '/bar' + delimiter + '/baz', env.PATH); - }); - it('should work with .shift()', function () { - var env = { PATH: '/foo' + delimiter + '/bar' }; - var p = new PathArray(env); - assert.equal('/foo', p.shift()); - assert.equal('/bar', env.PATH); - }); - it('should work with .pop()', function () { - var env = { PATH: '/foo' + delimiter + '/bar' }; - var p = new PathArray(env); - assert.equal('/bar', p.pop()); - assert.equal('/foo', env.PATH); - }); - it('should work with .unshift()', function () { - var env = { PATH: '/foo' + delimiter + '/bar' }; - var p = new PathArray(env); - p.unshift('/baz'); - assert.equal('/baz' + delimiter + '/foo' + delimiter + '/bar', env.PATH); - }); - it('should be able to specify property name to use with second argument', function () { - var env = { PYTHONPATH: '/foo' }; - var p = new PathArray(env, 'PYTHONPATH'); - assert.equal(1, p.length); - p.push('/baz'); - assert.equal(2, p.length); - assert.equal('/foo' + delimiter + '/baz', env.PYTHONPATH); - }); -}); diff --git a/deps/npm/node_modules/node-gyp/package.json b/deps/npm/node_modules/node-gyp/package.json index 8b68bc3213db9c..3dedc97e0f188a 100644 --- a/deps/npm/node_modules/node-gyp/package.json +++ b/deps/npm/node_modules/node-gyp/package.json @@ -2,51 +2,52 @@ "_args": [ [ { - "raw": "node-gyp@latest", + "raw": "node-gyp@3.5.0", "scope": null, "escapedName": "node-gyp", "name": "node-gyp", - "rawSpec": "latest", - "spec": "latest", - "type": "tag" + "rawSpec": "3.5.0", + "spec": "3.5.0", + "type": "version" }, - "/Users/zkat/Documents/code/npm" + "/Users/rebecca/code/npm" ] ], - "_from": "node-gyp@latest", - "_id": "node-gyp@3.4.0", + "_from": "node-gyp@3.5.0", + "_id": "node-gyp@3.5.0", "_inCache": true, - "_installable": true, "_location": "/node-gyp", - "_nodeVersion": "6.2.1", + "_nodeVersion": "7.2.1", "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/node-gyp-3.4.0.tgz_1467079381888_0.1804589256644249" + "host": "packages-18-east.internal.npmjs.com", + "tmp": "tmp/node-gyp-3.5.0.tgz_1484012223403_0.9361806979868561" }, "_npmUser": { "name": "rvagg", "email": "rod@vagg.org" }, - "_npmVersion": "3.9.3", - "_phantomChildren": {}, + "_npmVersion": "3.10.10", + "_phantomChildren": { + "abbrev": "1.0.9" + }, "_requested": { - "raw": "node-gyp@latest", + "raw": "node-gyp@3.5.0", "scope": null, "escapedName": "node-gyp", "name": "node-gyp", - "rawSpec": "latest", - "spec": "latest", - "type": "tag" + "rawSpec": "3.5.0", + "spec": "3.5.0", + "type": "version" }, "_requiredBy": [ "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.4.0.tgz", - "_shasum": "dda558393b3ecbbe24c9e6b8703c71194c63fa36", + "_resolved": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.5.0.tgz", + "_shasum": "a8fe5e611d079ec16348a3eb960e78e11c85274a", "_shrinkwrap": null, - "_spec": "node-gyp@latest", - "_where": "/Users/zkat/Documents/code/npm", + "_spec": "node-gyp@3.5.0", + "_where": "/Users/rebecca/code/npm", "author": { "name": "Nathan Rajlich", "email": "nathan@tootallnate.net", @@ -65,9 +66,8 @@ "minimatch": "^3.0.2", "mkdirp": "^0.5.0", "nopt": "2 || 3", - "npmlog": "0 || 1 || 2 || 3", + "npmlog": "0 || 1 || 2 || 3 || 4", "osenv": "0", - "path-array": "^1.0.0", "request": "2", "rimraf": "2", "semver": "2.x || 3.x || 4 || 5", @@ -83,13 +83,13 @@ }, "directories": {}, "dist": { - "shasum": "dda558393b3ecbbe24c9e6b8703c71194c63fa36", - "tarball": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.4.0.tgz" + "shasum": "a8fe5e611d079ec16348a3eb960e78e11c85274a", + "tarball": "https://registry.npmjs.org/node-gyp/-/node-gyp-3.5.0.tgz" }, "engines": { "node": ">= 0.8.0" }, - "gitHead": "d460084b241c427655497a1de4ed351a13ffb47f", + "gitHead": "4793e1dcb8f16182d6292fd2af579082fc11294f", "homepage": "https://github.com/nodejs/node-gyp#readme", "installVersion": 9, "keywords": [ @@ -140,5 +140,5 @@ "scripts": { "test": "tape test/test-*" }, - "version": "3.4.0" + "version": "3.5.0" } diff --git a/deps/npm/node_modules/node-gyp/test/test-configure-python.js b/deps/npm/node_modules/node-gyp/test/test-configure-python.js new file mode 100644 index 00000000000000..2930cacffc9475 --- /dev/null +++ b/deps/npm/node_modules/node-gyp/test/test-configure-python.js @@ -0,0 +1,72 @@ +'use strict' + +var test = require('tape') +var path = require('path') +var gyp = require('../lib/node-gyp') +var requireInject = require('require-inject') +var configure = requireInject('../lib/configure', { + 'graceful-fs': { + 'writeFile': function (file, data, cb) { cb() }, + 'stat': function (file, cb) { cb(null, {}) } + } +}) + +var EXPECTED_PYPATH = path.join(__dirname, '..', 'gyp', 'pylib') +var SEPARATOR = process.platform == 'win32' ? ';' : ':' +var SPAWN_RESULT = { on: function () { } } + +test('configure PYTHONPATH with no existing env', function (t) { + t.plan(1) + + delete process.env.PYTHONPATH + + var prog = gyp() + prog.parseArgv([]) + prog.spawn = function () { + t.equal(process.env.PYTHONPATH, EXPECTED_PYPATH) + return SPAWN_RESULT + } + configure(prog, []) +}) + +test('configure PYTHONPATH with existing env of one dir', function (t) { + t.plan(2) + + var existingPath = path.join('a', 'b') + process.env.PYTHONPATH = existingPath + + var prog = gyp() + prog.parseArgv([]) + prog.spawn = function () { + + t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR)) + + var dirs = process.env.PYTHONPATH.split(SEPARATOR) + t.deepEqual(dirs, [EXPECTED_PYPATH, existingPath]) + + return SPAWN_RESULT + } + configure(prog, []) +}) + +test('configure PYTHONPATH with existing env of multiple dirs', function (t) { + t.plan(2) + + var pythonDir1 = path.join('a', 'b') + var pythonDir2 = path.join('b', 'c') + var existingPath = [pythonDir1, pythonDir2].join(SEPARATOR) + process.env.PYTHONPATH = existingPath + + var prog = gyp() + prog.parseArgv([]) + prog.spawn = function () { + + t.equal(process.env.PYTHONPATH, [EXPECTED_PYPATH, existingPath].join(SEPARATOR)) + + var dirs = process.env.PYTHONPATH.split(SEPARATOR) + t.deepEqual(dirs, [EXPECTED_PYPATH, pythonDir1, pythonDir2]) + + return SPAWN_RESULT + } + configure(prog, []) +}) diff --git a/deps/npm/node_modules/node-gyp/test/test-find-python.js b/deps/npm/node_modules/node-gyp/test/test-find-python.js index 7f5c3946794f20..30ba6df78ba86a 100644 --- a/deps/npm/node_modules/node-gyp/test/test-find-python.js +++ b/deps/npm/node_modules/node-gyp/test/test-find-python.js @@ -3,8 +3,9 @@ var test = require('tape') var configure = require('../lib/configure') var execFile = require('child_process').execFile +var PythonFinder = configure.test.PythonFinder -test('find python executable', function (t) { +test('find python', function (t) { t.plan(4) configure.test.findPython('python', function (err, found) { @@ -18,3 +19,309 @@ test('find python executable', function (t) { proc.stderr.setEncoding('utf-8') }) }) + +function poison(object, property) { + function fail() { + throw new Error('Property ' + property + ' should not have been accessed.') + } + var descriptor = { + configurable: true, + enumerable: false, + writable: true, + getter: fail, + setter: fail, + } + Object.defineProperty(object, property, descriptor) +} + +function TestPythonFinder() { PythonFinder.apply(this, arguments) } +TestPythonFinder.prototype = Object.create(PythonFinder.prototype) +poison(TestPythonFinder.prototype, 'env') +poison(TestPythonFinder.prototype, 'execFile') +poison(TestPythonFinder.prototype, 'stat') +poison(TestPythonFinder.prototype, 'which') +poison(TestPythonFinder.prototype, 'win') + +test('find python - python', function (t) { + t.plan(5) + + var f = new TestPythonFinder('python', done) + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(null, program) + } + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'python') + t.ok(/import platform/.test(args[1])) + cb(null, '2.7.0') + } + f.checkPython() + + function done(err, python) { + t.strictEqual(err, null) + t.strictEqual(python, 'python') + } +}) + +test('find python - python too old', function (t) { + t.plan(4) + + var f = new TestPythonFinder('python', done) + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(null, program) + } + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'python') + t.ok(/import platform/.test(args[1])) + cb(null, '2.3.4') + } + f.checkPython() + + function done(err, python) { + t.ok(/is not supported by gyp/.test(err)) + } +}) + +test('find python - python too new', function (t) { + t.plan(4) + + var f = new TestPythonFinder('python', done) + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(null, program) + } + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'python') + t.ok(/import platform/.test(args[1])) + cb(null, '3.0.0') + } + f.checkPython() + + function done(err, python) { + t.ok(/is not supported by gyp/.test(err)) + } +}) + +test('find python - no python', function (t) { + t.plan(2) + + var f = new TestPythonFinder('python', done) + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(new Error('not found')) + } + f.checkPython() + + function done(err, python) { + t.ok(/Can't find Python executable/.test(err)) + } +}) + +test('find python - no python2', function (t) { + t.plan(6) + + var f = new TestPythonFinder('python2', done) + f.which = function(program, cb) { + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(null, program) + } + t.strictEqual(program, 'python2') + cb(new Error('not found')) + } + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'python') + t.ok(/import platform/.test(args[1])) + cb(null, '2.7.0') + } + f.checkPython() + + function done(err, python) { + t.strictEqual(err, null) + t.strictEqual(python, 'python') + } +}) + +test('find python - no python2, no python, unix', function (t) { + t.plan(3) + + var f = new TestPythonFinder('python2', done) + poison(f, 'checkPythonLauncher') + f.win = false + + f.which = function(program, cb) { + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(new Error('not found')) + } + t.strictEqual(program, 'python2') + cb(new Error('not found')) + } + f.checkPython() + + function done(err, python) { + t.ok(/Can't find Python executable/.test(err)) + } +}) + +test('find python - no python, use python launcher', function (t) { + t.plan(8) + + var f = new TestPythonFinder('python', done) + f.env = {} + f.win = true + + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(new Error('not found')) + } + f.execFile = function(program, args, opts, cb) { + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'Z:\\snake.exe') + t.ok(/import platform/.test(args[1])) + cb(null, '2.7.0') + } + t.strictEqual(program, 'py.exe') + t.notEqual(args.indexOf('-2'), -1) + t.notEqual(args.indexOf('-c'), -1) + cb(null, 'Z:\\snake.exe') + } + f.checkPython() + + function done(err, python) { + t.strictEqual(err, null) + t.strictEqual(python, 'Z:\\snake.exe') + } +}) + +test('find python - python 3, use python launcher', function (t) { + t.plan(10) + + var f = new TestPythonFinder('python', done) + f.env = {} + f.win = true + + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(null, program) + } + f.execFile = function(program, args, opts, cb) { + f.execFile = function(program, args, opts, cb) { + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'Z:\\snake.exe') + t.ok(/import platform/.test(args[1])) + cb(null, '2.7.0') + } + t.strictEqual(program, 'py.exe') + t.notEqual(args.indexOf('-2'), -1) + t.notEqual(args.indexOf('-c'), -1) + cb(null, 'Z:\\snake.exe') + } + t.strictEqual(program, 'python') + t.ok(/import platform/.test(args[1])) + cb(null, '3.0.0') + } + f.checkPython() + + function done(err, python) { + t.strictEqual(err, null) + t.strictEqual(python, 'Z:\\snake.exe') + } +}) + +test('find python - python 3, use python launcher, python 2 too old', + function (t) { + t.plan(9) + + var f = new TestPythonFinder('python', done) + f.checkedPythonLauncher = false + f.env = {} + f.win = true + + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(null, program) + } + f.execFile = function(program, args, opts, cb) { + f.execFile = function(program, args, opts, cb) { + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'Z:\\snake.exe') + t.ok(/import platform/.test(args[1])) + cb(null, '2.3.4') + } + t.strictEqual(program, 'py.exe') + t.notEqual(args.indexOf('-2'), -1) + t.notEqual(args.indexOf('-c'), -1) + cb(null, 'Z:\\snake.exe') + } + t.strictEqual(program, 'python') + t.ok(/import platform/.test(args[1])) + cb(null, '3.0.0') + } + f.checkPython() + + function done(err, python) { + t.ok(/is not supported by gyp/.test(err)) + } +}) + +test('find python - no python, no python launcher, good guess', function (t) { + t.plan(6) + + var re = /C:[\\\/]Python27[\\\/]python[.]exe/ + var f = new TestPythonFinder('python', done) + f.env = {} + f.win = true + + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(new Error('not found')) + } + f.execFile = function(program, args, opts, cb) { + f.execFile = function(program, args, opts, cb) { + t.ok(re.test(program)) + t.ok(/import platform/.test(args[1])) + cb(null, '2.7.0') + } + t.strictEqual(program, 'py.exe') + cb(new Error('not found')) + } + f.stat = function(path, cb) { + t.ok(re.test(path)) + cb(null, {}) + } + f.checkPython() + + function done(err, python) { + t.ok(re.test(python)) + } +}) + +test('find python - no python, no python launcher, bad guess', function (t) { + t.plan(4) + + var f = new TestPythonFinder('python', done) + f.env = { SystemDrive: 'Z:\\' } + f.win = true + + f.which = function(program, cb) { + t.strictEqual(program, 'python') + cb(new Error('not found')) + } + f.execFile = function(program, args, opts, cb) { + t.strictEqual(program, 'py.exe') + cb(new Error('not found')) + } + f.stat = function(path, cb) { + t.ok(/Z:[\\\/]Python27[\\\/]python.exe/.test(path)) + var err = new Error('not found') + err.code = 'ENOENT' + cb(err) + } + f.checkPython() + + function done(err, python) { + t.ok(/Can't find Python executable/.test(err)) + } +}) diff --git a/deps/npm/node_modules/nopt/.travis.yml b/deps/npm/node_modules/nopt/.travis.yml index 99f2bbf5068a8c..a1cef591c3cfd0 100644 --- a/deps/npm/node_modules/nopt/.travis.yml +++ b/deps/npm/node_modules/nopt/.travis.yml @@ -1,9 +1,8 @@ language: node_js -language: node_js node_js: - - '0.8' - - '0.10' - '0.12' - - 'iojs' + - '4' + - '6' + - '7' before_install: - npm install -g npm@latest diff --git a/deps/npm/node_modules/nopt/CHANGELOG.md b/deps/npm/node_modules/nopt/CHANGELOG.md new file mode 100644 index 00000000000000..82a09fb4bf809a --- /dev/null +++ b/deps/npm/node_modules/nopt/CHANGELOG.md @@ -0,0 +1,58 @@ +### v4.0.1 (2016-12-14) + +#### WHOOPS + +* [`fb9b1ce`](https://github.com/npm/nopt/commit/fb9b1ce57b3c69b4f7819015be87719204f77ef6) + Merged so many patches at once that the code fencing + ([@adius](https://github.com/adius)) added got broken. Sorry, + ([@adius](https://github.com/adius))! + ([@othiym23](https://github.com/othiym23)) + +### v4.0.0 (2016-12-13) + +#### BREAKING CHANGES + +* [`651d447`](https://github.com/npm/nopt/commit/651d4473946096d341a480bbe56793de3fc706aa) + When parsing String-typed arguments, if the next value is `""`, don't simply + swallow it. ([@samjonester](https://github.com/samjonester)) + +#### PERFORMANCE TWEAKS + +* [`3370ce8`](https://github.com/npm/nopt/commit/3370ce87a7618ba228883861db84ddbcdff252a9) + Simplify initialization. ([@elidoran](https://github.com/elidoran)) +* [`356e58e`](https://github.com/npm/nopt/commit/356e58e3b3b431a4b1af7fd7bdee44c2c0526a09) + Store `Array.isArray(types[arg])` for reuse. + ([@elidoran](https://github.com/elidoran)) +* [`0d95e90`](https://github.com/npm/nopt/commit/0d95e90515844f266015b56d2c80b94e5d14a07e) + Interpret single-item type arrays as a single type. + ([@samjonester](https://github.com/samjonester)) +* [`07c69d3`](https://github.com/npm/nopt/commit/07c69d38b5186450941fbb505550becb78a0e925) + Simplify key-value extraction. ([@elidoran](https://github.com/elidoran)) +* [`39b6e5c`](https://github.com/npm/nopt/commit/39b6e5c65ac47f60cd43a1fbeece5cd4c834c254) + Only call `Date.parse(val)` once. ([@elidoran](https://github.com/elidoran)) +* [`934943d`](https://github.com/npm/nopt/commit/934943dffecb55123a2b15959fe2a359319a5dbd) + Use `osenv.home()` to find a user's home directory instead of assuming it's + always `$HOME`. ([@othiym23](https://github.com/othiym23)) + +#### TEST & CI IMPROVEMENTS + +* [`326ffff`](https://github.com/npm/nopt/commit/326ffff7f78a00bcd316adecf69075f8a8093619) + Fix `/tmp` test to work on Windows. + ([@elidoran](https://github.com/elidoran)) +* [`c89d31a`](https://github.com/npm/nopt/commit/c89d31a49d14f2238bc6672db08da697bbc57f1b) + Only run Windows tests on Windows, only run Unix tests on a Unix. + ([@elidoran](https://github.com/elidoran)) +* [`affd3d1`](https://github.com/npm/nopt/commit/affd3d1d0addffa93006397b2013b18447339366) + Refresh Travis to run the tests against the currently-supported batch of npm + versions. ([@helio](https://github.com/helio)-frota) +* [`55f9449`](https://github.com/npm/nopt/commit/55f94497d163ed4d16dd55fd6c4fb95cc440e66d) + `tap@8.0.1` ([@othiym23](https://github.com/othiym23)) + +#### DOC TWEAKS + +* [`5271229`](https://github.com/npm/nopt/commit/5271229ee7c810217dd51616c086f5d9ab224581) + Use JavaScript code block for syntax highlighting. + ([@adius](https://github.com/adius)) +* [`c0d156f`](https://github.com/npm/nopt/commit/c0d156f229f9994c5dfcec4a8886eceff7a07682) + The code sample in the README had `many2: [ oneThing ]`, and now it has + `many2: [ two, things ]`. ([@silkentrance](https://github.com/silkentrance)) diff --git a/deps/npm/node_modules/nopt/README.md b/deps/npm/node_modules/nopt/README.md index f21a4b31c5d482..a99531c04655fe 100644 --- a/deps/npm/node_modules/nopt/README.md +++ b/deps/npm/node_modules/nopt/README.md @@ -19,35 +19,37 @@ nice option parser. ## USAGE - // my-program.js - var nopt = require("nopt") - , Stream = require("stream").Stream - , path = require("path") - , knownOpts = { "foo" : [String, null] - , "bar" : [Stream, Number] - , "baz" : path - , "bloo" : [ "big", "medium", "small" ] - , "flag" : Boolean - , "pick" : Boolean - , "many1" : [String, Array] - , "many2" : [path] - } - , shortHands = { "foofoo" : ["--foo", "Mr. Foo"] - , "b7" : ["--bar", "7"] - , "m" : ["--bloo", "medium"] - , "p" : ["--pick"] - , "f" : ["--flag"] - } - // everything is optional. - // knownOpts and shorthands default to {} - // arg list defaults to process.argv - // slice defaults to 2 - , parsed = nopt(knownOpts, shortHands, process.argv, 2) - console.log(parsed) +```javascript +// my-program.js +var nopt = require("nopt") + , Stream = require("stream").Stream + , path = require("path") + , knownOpts = { "foo" : [String, null] + , "bar" : [Stream, Number] + , "baz" : path + , "bloo" : [ "big", "medium", "small" ] + , "flag" : Boolean + , "pick" : Boolean + , "many1" : [String, Array] + , "many2" : [path, Array] + } + , shortHands = { "foofoo" : ["--foo", "Mr. Foo"] + , "b7" : ["--bar", "7"] + , "m" : ["--bloo", "medium"] + , "p" : ["--pick"] + , "f" : ["--flag"] + } + // everything is optional. + // knownOpts and shorthands default to {} + // arg list defaults to process.argv + // slice defaults to 2 + , parsed = nopt(knownOpts, shortHands, process.argv, 2) +console.log(parsed) +``` This would give you support for any of the following: -```bash +```console $ node my-program.js --foo "blerp" --no-flag { "foo" : "blerp", "flag" : false } diff --git a/deps/npm/node_modules/nopt/lib/nopt.js b/deps/npm/node_modules/nopt/lib/nopt.js index 97707e784243bc..1fb113514f3347 100644 --- a/deps/npm/node_modules/nopt/lib/nopt.js +++ b/deps/npm/node_modules/nopt/lib/nopt.js @@ -8,6 +8,7 @@ var url = require("url") , path = require("path") , Stream = require("stream").Stream , abbrev = require("abbrev") + , osenv = require("osenv") module.exports = exports = nopt exports.clean = clean @@ -33,14 +34,16 @@ function nopt (types, shorthands, args, slice) { args = args.slice(slice) var data = {} , key - , remain = [] - , cooked = args - , original = args.slice(0) + , argv = { + remain: [], + cooked: args, + original: args.slice(0) + } - parse(args, data, remain, types, shorthands) + parse(args, data, argv.remain, types, shorthands) // now data is full clean(data, types, exports.typeDefs) - data.argv = {remain:remain,cooked:cooked,original:original} + data.argv = argv Object.defineProperty(data.argv, 'toString', { value: function () { return this.original.map(JSON.stringify).join(" ") }, enumerable: false }) @@ -129,11 +132,16 @@ function validatePath (data, k, val) { if (val === null) return true val = String(val) - var homePattern = process.platform === 'win32' ? /^~(\/|\\)/ : /^~\// - if (val.match(homePattern) && process.env.HOME) { - val = path.resolve(process.env.HOME, val.substr(2)) + + var isWin = process.platform === 'win32' + , homePattern = isWin ? /^~(\/|\\)/ : /^~\// + , home = osenv.home() + + if (home && val.match(homePattern)) { + data[k] = path.resolve(home, val.substr(2)) + } else { + data[k] = path.resolve(val) } - data[k] = path.resolve(String(val)) return true } @@ -144,8 +152,8 @@ function validateNumber (data, k, val) { } function validateDate (data, k, val) { - debug("validate Date %j %j %j", k, val, Date.parse(val)) var s = Date.parse(val) + debug("validate Date %j %j %j", k, val, s) if (isNaN(s)) return false data[k] = new Date(val) } @@ -246,12 +254,12 @@ function parse (args, data, remain, types, shorthands) { } var hadEq = false if (arg.charAt(0) === "-" && arg.length > 1) { - if (arg.indexOf("=") !== -1) { + var at = arg.indexOf('=') + if (at > -1) { hadEq = true - var v = arg.split("=") - arg = v.shift() - v = v.join("=") - args.splice.apply(args, [i, 1].concat([arg, v])) + var v = arg.substr(at + 1) + arg = arg.substr(0, at) + args.splice(i, 1, arg, v) } // see if it's a shorthand @@ -275,8 +283,15 @@ function parse (args, data, remain, types, shorthands) { if (abbrevs[arg]) arg = abbrevs[arg] - var isArray = types[arg] === Array || - Array.isArray(types[arg]) && types[arg].indexOf(Array) !== -1 + var argType = types[arg] + var isTypeArray = Array.isArray(argType) + if (isTypeArray && argType.length === 1) { + isTypeArray = false + argType = argType[0] + } + + var isArray = argType === Array || + isTypeArray && argType.indexOf(Array) !== -1 // allow unknown things to be arrays if specified multiple times. if (!types.hasOwnProperty(arg) && data.hasOwnProperty(arg)) { @@ -289,12 +304,12 @@ function parse (args, data, remain, types, shorthands) { , la = args[i + 1] var isBool = typeof no === 'boolean' || - types[arg] === Boolean || - Array.isArray(types[arg]) && types[arg].indexOf(Boolean) !== -1 || - (typeof types[arg] === 'undefined' && !hadEq) || + argType === Boolean || + isTypeArray && argType.indexOf(Boolean) !== -1 || + (typeof argType === 'undefined' && !hadEq) || (la === "false" && - (types[arg] === null || - Array.isArray(types[arg]) && ~types[arg].indexOf(null))) + (argType === null || + isTypeArray && ~argType.indexOf(null))) if (isBool) { // just set and move along @@ -308,22 +323,22 @@ function parse (args, data, remain, types, shorthands) { } // also support "foo":[Boolean, "bar"] and "--foo bar" - if (Array.isArray(types[arg]) && la) { - if (~types[arg].indexOf(la)) { + if (isTypeArray && la) { + if (~argType.indexOf(la)) { // an explicit type val = la i ++ - } else if ( la === "null" && ~types[arg].indexOf(null) ) { + } else if ( la === "null" && ~argType.indexOf(null) ) { // null allowed val = null i ++ } else if ( !la.match(/^-{2,}[^-]/) && !isNaN(la) && - ~types[arg].indexOf(Number) ) { + ~argType.indexOf(Number) ) { // number val = +la i ++ - } else if ( !la.match(/^-[^-]/) && ~types[arg].indexOf(String) ) { + } else if ( !la.match(/^-[^-]/) && ~argType.indexOf(String) ) { // string val = la i ++ @@ -336,8 +351,14 @@ function parse (args, data, remain, types, shorthands) { continue } - if (types[arg] === String && la === undefined) - la = "" + if (argType === String) { + if (la === undefined) { + la = "" + } else if (la.match(/^-{1,2}[^-]+/)) { + la = "" + i -- + } + } if (la && la.match(/^-{2,}$/)) { la = undefined diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/.npmignore b/deps/npm/node_modules/nopt/node_modules/osenv/.npmignore new file mode 100644 index 00000000000000..8c23deeb34b05e --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/.npmignore @@ -0,0 +1,13 @@ +*.swp +.*.swp + +.DS_Store +*~ +.project +.settings +npm-debug.log +coverage.html +.idea +lib-cov + +node_modules diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/.travis.yml b/deps/npm/node_modules/nopt/node_modules/osenv/.travis.yml new file mode 100644 index 00000000000000..99f2bbf5068a8c --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/.travis.yml @@ -0,0 +1,9 @@ +language: node_js +language: node_js +node_js: + - '0.8' + - '0.10' + - '0.12' + - 'iojs' +before_install: + - npm install -g npm@latest diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/LICENSE b/deps/npm/node_modules/nopt/node_modules/osenv/LICENSE similarity index 100% rename from deps/npm/node_modules/npm-registry-client/node_modules/npmlog/LICENSE rename to deps/npm/node_modules/nopt/node_modules/osenv/LICENSE diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/README.md b/deps/npm/node_modules/nopt/node_modules/osenv/README.md new file mode 100644 index 00000000000000..3935519cc2f1a8 --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/README.md @@ -0,0 +1,63 @@ +# osenv + +Look up environment settings specific to different operating systems. + +## Usage + +```javascript +var osenv = require('osenv') +var path = osenv.path() +var user = osenv.user() +// etc. + +// Some things are not reliably in the env, and have a fallback command: +var h = osenv.hostname(function (er, hostname) { + h = hostname +}) +// This will still cause it to be memoized, so calling osenv.hostname() +// is now an immediate operation. + +// You can always send a cb, which will get called in the nextTick +// if it's been memoized, or wait for the fallback data if it wasn't +// found in the environment. +osenv.hostname(function (er, hostname) { + if (er) console.error('error looking up hostname') + else console.log('this machine calls itself %s', hostname) +}) +``` + +## osenv.hostname() + +The machine name. Calls `hostname` if not found. + +## osenv.user() + +The currently logged-in user. Calls `whoami` if not found. + +## osenv.prompt() + +Either PS1 on unix, or PROMPT on Windows. + +## osenv.tmpdir() + +The place where temporary files should be created. + +## osenv.home() + +No place like it. + +## osenv.path() + +An array of the places that the operating system will search for +executables. + +## osenv.editor() + +Return the executable name of the editor program. This uses the EDITOR +and VISUAL environment variables, and falls back to `vi` on Unix, or +`notepad.exe` on Windows. + +## osenv.shell() + +The SHELL on Unix, which Windows calls the ComSpec. Defaults to 'bash' +or 'cmd'. diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/index.js b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/index.js new file mode 100644 index 00000000000000..33066166fe6692 --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/index.js @@ -0,0 +1,24 @@ +'use strict'; +var os = require('os'); + +function homedir() { + var env = process.env; + var home = env.HOME; + var user = env.LOGNAME || env.USER || env.LNAME || env.USERNAME; + + if (process.platform === 'win32') { + return env.USERPROFILE || env.HOMEDRIVE + env.HOMEPATH || home || null; + } + + if (process.platform === 'darwin') { + return home || (user ? '/Users/' + user : null); + } + + if (process.platform === 'linux') { + return home || (process.getuid() === 0 ? '/root' : (user ? '/home/' + user : null)); + } + + return home || null; +} + +module.exports = typeof os.homedir === 'function' ? os.homedir : homedir; diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/license b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/license similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/license rename to deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/license diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/package.json b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/package.json new file mode 100644 index 00000000000000..e5b18d1c60f17e --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/package.json @@ -0,0 +1,109 @@ +{ + "_args": [ + [ + { + "raw": "os-homedir@^1.0.0", + "scope": null, + "escapedName": "os-homedir", + "name": "os-homedir", + "rawSpec": "^1.0.0", + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "/Users/ogd/Documents/projects/npm/npm/node_modules/nopt/node_modules/osenv" + ] + ], + "_from": "os-homedir@>=1.0.0 <2.0.0", + "_id": "os-homedir@1.0.2", + "_inCache": true, + "_location": "/nopt/osenv/os-homedir", + "_nodeVersion": "6.6.0", + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/os-homedir-1.0.2.tgz_1475211519628_0.7873868853785098" + }, + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "_npmVersion": "3.10.3", + "_phantomChildren": {}, + "_requested": { + "raw": "os-homedir@^1.0.0", + "scope": null, + "escapedName": "os-homedir", + "name": "os-homedir", + "rawSpec": "^1.0.0", + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/nopt/osenv" + ], + "_resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "_shasum": "ffbc4988336e0e833de0c168c7ef152121aa7fb3", + "_shrinkwrap": null, + "_spec": "os-homedir@^1.0.0", + "_where": "/Users/ogd/Documents/projects/npm/npm/node_modules/nopt/node_modules/osenv", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/os-homedir/issues" + }, + "dependencies": {}, + "description": "Node.js 4 `os.homedir()` ponyfill", + "devDependencies": { + "ava": "*", + "path-exists": "^2.0.0", + "xo": "^0.16.0" + }, + "directories": {}, + "dist": { + "shasum": "ffbc4988336e0e833de0c168c7ef152121aa7fb3", + "tarball": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "b1b0ae70a5965fef7005ff6509a5dd1a78c95e36", + "homepage": "https://github.com/sindresorhus/os-homedir#readme", + "keywords": [ + "builtin", + "core", + "ponyfill", + "polyfill", + "shim", + "os", + "homedir", + "home", + "dir", + "directory", + "folder", + "user", + "path" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "os-homedir", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/os-homedir.git" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "1.0.2" +} diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/readme.md b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/readme.md new file mode 100644 index 00000000000000..856ae615b0c0bb --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-homedir/readme.md @@ -0,0 +1,31 @@ +# os-homedir [![Build Status](https://travis-ci.org/sindresorhus/os-homedir.svg?branch=master)](https://travis-ci.org/sindresorhus/os-homedir) + +> Node.js 4 [`os.homedir()`](https://nodejs.org/api/os.html#os_os_homedir) [ponyfill](https://ponyfill.com) + + +## Install + +``` +$ npm install --save os-homedir +``` + + +## Usage + +```js +const osHomedir = require('os-homedir'); + +console.log(osHomedir()); +//=> '/Users/sindresorhus' +``` + + +## Related + +- [user-home](https://github.com/sindresorhus/user-home) - Same as this module but caches the result +- [home-or-tmp](https://github.com/sindresorhus/home-or-tmp) - Get the user home directory with fallback to the system temp directory + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/index.js b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/index.js new file mode 100644 index 00000000000000..2077b1ce747129 --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/index.js @@ -0,0 +1,25 @@ +'use strict'; +var isWindows = process.platform === 'win32'; +var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/; + +// https://github.com/nodejs/node/blob/3e7a14381497a3b73dda68d05b5130563cdab420/lib/os.js#L25-L43 +module.exports = function () { + var path; + + if (isWindows) { + path = process.env.TEMP || + process.env.TMP || + (process.env.SystemRoot || process.env.windir) + '\\temp'; + } else { + path = process.env.TMPDIR || + process.env.TMP || + process.env.TEMP || + '/tmp'; + } + + if (trailingSlashRe.test(path)) { + path = path.slice(0, -1); + } + + return path; +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/license b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/license similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/license rename to deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/license diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/package.json b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/package.json new file mode 100644 index 00000000000000..73ae4a3bd89338 --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/package.json @@ -0,0 +1,109 @@ +{ + "_args": [ + [ + { + "raw": "os-tmpdir@^1.0.0", + "scope": null, + "escapedName": "os-tmpdir", + "name": "os-tmpdir", + "rawSpec": "^1.0.0", + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "/Users/ogd/Documents/projects/npm/npm/node_modules/nopt/node_modules/osenv" + ] + ], + "_from": "os-tmpdir@>=1.0.0 <2.0.0", + "_id": "os-tmpdir@1.0.2", + "_inCache": true, + "_location": "/nopt/osenv/os-tmpdir", + "_nodeVersion": "6.6.0", + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/os-tmpdir-1.0.2.tgz_1475211274587_0.14931037812493742" + }, + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "_npmVersion": "3.10.3", + "_phantomChildren": {}, + "_requested": { + "raw": "os-tmpdir@^1.0.0", + "scope": null, + "escapedName": "os-tmpdir", + "name": "os-tmpdir", + "rawSpec": "^1.0.0", + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/nopt/osenv" + ], + "_resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "_shasum": "bbe67406c79aa85c5cfec766fe5734555dfa1274", + "_shrinkwrap": null, + "_spec": "os-tmpdir@^1.0.0", + "_where": "/Users/ogd/Documents/projects/npm/npm/node_modules/nopt/node_modules/osenv", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/os-tmpdir/issues" + }, + "dependencies": {}, + "description": "Node.js os.tmpdir() ponyfill", + "devDependencies": { + "ava": "*", + "xo": "^0.16.0" + }, + "directories": {}, + "dist": { + "shasum": "bbe67406c79aa85c5cfec766fe5734555dfa1274", + "tarball": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js" + ], + "gitHead": "1abf9cf5611b4be7377060ea67054b45cbf6813c", + "homepage": "https://github.com/sindresorhus/os-tmpdir#readme", + "keywords": [ + "built-in", + "core", + "ponyfill", + "polyfill", + "shim", + "os", + "tmpdir", + "tempdir", + "tmp", + "temp", + "dir", + "directory", + "env", + "environment" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "os-tmpdir", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/os-tmpdir.git" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "1.0.2" +} diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/readme.md b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/readme.md new file mode 100644 index 00000000000000..c09f7ed8d5f4c3 --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/node_modules/os-tmpdir/readme.md @@ -0,0 +1,32 @@ +# os-tmpdir [![Build Status](https://travis-ci.org/sindresorhus/os-tmpdir.svg?branch=master)](https://travis-ci.org/sindresorhus/os-tmpdir) + +> Node.js [`os.tmpdir()`](https://nodejs.org/api/os.html#os_os_tmpdir) [ponyfill](https://ponyfill.com) + +Use this instead of `require('os').tmpdir()` to get a consistent behavior on different Node.js versions (even 0.8). + + +## Install + +``` +$ npm install --save os-tmpdir +``` + + +## Usage + +```js +const osTmpdir = require('os-tmpdir'); + +osTmpdir(); +//=> '/var/folders/m3/5574nnhn0yj488ccryqr7tc80000gn/T' +``` + + +## API + +See the [`os.tmpdir()` docs](https://nodejs.org/api/os.html#os_os_tmpdir). + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/osenv.js b/deps/npm/node_modules/nopt/node_modules/osenv/osenv.js new file mode 100644 index 00000000000000..702a95b98aa45d --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/osenv.js @@ -0,0 +1,72 @@ +var isWindows = process.platform === 'win32' +var path = require('path') +var exec = require('child_process').exec +var osTmpdir = require('os-tmpdir') +var osHomedir = require('os-homedir') + +// looking up envs is a bit costly. +// Also, sometimes we want to have a fallback +// Pass in a callback to wait for the fallback on failures +// After the first lookup, always returns the same thing. +function memo (key, lookup, fallback) { + var fell = false + var falling = false + exports[key] = function (cb) { + var val = lookup() + if (!val && !fell && !falling && fallback) { + fell = true + falling = true + exec(fallback, function (er, output, stderr) { + falling = false + if (er) return // oh well, we tried + val = output.trim() + }) + } + exports[key] = function (cb) { + if (cb) process.nextTick(cb.bind(null, null, val)) + return val + } + if (cb && !falling) process.nextTick(cb.bind(null, null, val)) + return val + } +} + +memo('user', function () { + return ( isWindows + ? process.env.USERDOMAIN + '\\' + process.env.USERNAME + : process.env.USER + ) +}, 'whoami') + +memo('prompt', function () { + return isWindows ? process.env.PROMPT : process.env.PS1 +}) + +memo('hostname', function () { + return isWindows ? process.env.COMPUTERNAME : process.env.HOSTNAME +}, 'hostname') + +memo('tmpdir', function () { + return osTmpdir() +}) + +memo('home', function () { + return osHomedir() +}) + +memo('path', function () { + return (process.env.PATH || + process.env.Path || + process.env.path).split(isWindows ? ';' : ':') +}) + +memo('editor', function () { + return process.env.EDITOR || + process.env.VISUAL || + (isWindows ? 'notepad.exe' : 'vi') +}) + +memo('shell', function () { + return isWindows ? process.env.ComSpec || 'cmd' + : process.env.SHELL || 'bash' +}) diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/package.json b/deps/npm/node_modules/nopt/node_modules/osenv/package.json new file mode 100644 index 00000000000000..002d5ff062f4d3 --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/package.json @@ -0,0 +1,113 @@ +{ + "_args": [ + [ + { + "raw": "osenv@^0.1.4", + "scope": null, + "escapedName": "osenv", + "name": "osenv", + "rawSpec": "^0.1.4", + "spec": ">=0.1.4 <0.2.0", + "type": "range" + }, + "/Users/ogd/Documents/projects/npm/npm/node_modules/nopt" + ] + ], + "_from": "osenv@>=0.1.4 <0.2.0", + "_id": "osenv@0.1.4", + "_inCache": true, + "_location": "/nopt/osenv", + "_nodeVersion": "6.5.0", + "_npmOperationalInternal": { + "host": "packages-18-east.internal.npmjs.com", + "tmp": "tmp/osenv-0.1.4.tgz_1481655889868_0.3980878754518926" + }, + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "_npmVersion": "3.10.9", + "_phantomChildren": {}, + "_requested": { + "raw": "osenv@^0.1.4", + "scope": null, + "escapedName": "osenv", + "name": "osenv", + "rawSpec": "^0.1.4", + "spec": ">=0.1.4 <0.2.0", + "type": "range" + }, + "_requiredBy": [ + "/nopt" + ], + "_resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz", + "_shasum": "42fe6d5953df06c8064be6f176c3d05aaaa34644", + "_shrinkwrap": null, + "_spec": "osenv@^0.1.4", + "_where": "/Users/ogd/Documents/projects/npm/npm/node_modules/nopt", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/npm/osenv/issues" + }, + "dependencies": { + "os-homedir": "^1.0.0", + "os-tmpdir": "^1.0.0" + }, + "description": "Look up environment settings specific to different operating systems", + "devDependencies": { + "tap": "^8.0.1" + }, + "directories": { + "test": "test" + }, + "dist": { + "shasum": "42fe6d5953df06c8064be6f176c3d05aaaa34644", + "tarball": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz" + }, + "gitHead": "ef718f0d20e38d45ec452b7faeefc692d3cd1062", + "homepage": "https://github.com/npm/osenv#readme", + "keywords": [ + "environment", + "variable", + "home", + "tmpdir", + "path", + "prompt", + "ps1" + ], + "license": "ISC", + "main": "osenv.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + }, + { + "name": "robertkowalski", + "email": "rok@kowalski.gd" + }, + { + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" + }, + { + "name": "iarna", + "email": "me@re-becca.org" + } + ], + "name": "osenv", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/osenv.git" + }, + "scripts": { + "test": "tap test/*.js" + }, + "version": "0.1.4" +} diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/test/unix.js b/deps/npm/node_modules/nopt/node_modules/osenv/test/unix.js new file mode 100644 index 00000000000000..94d4aaafb4f80b --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/test/unix.js @@ -0,0 +1,71 @@ +// only run this test on windows +// pretending to be another platform is too hacky, since it breaks +// how the underlying system looks up module paths and runs +// child processes, and all that stuff is cached. +var tap = require('tap') + + +if (process.platform === 'win32') { + tap.plan(0, 'Skip unix tests, this is not unix') + process.exit(0) +} + +// like unix, but funny +process.env.USER = 'sirUser' +process.env.HOME = '/home/sirUser' +process.env.HOSTNAME = 'my-machine' +process.env.TMPDIR = '/tmpdir' +process.env.TMP = '/tmp' +process.env.TEMP = '/temp' +process.env.PATH = '/opt/local/bin:/usr/local/bin:/usr/bin/:bin' +process.env.PS1 = '(o_o) $ ' +process.env.EDITOR = 'edit' +process.env.VISUAL = 'visualedit' +process.env.SHELL = 'zsh' + +tap.test('basic unix sanity test', function (t) { + var osenv = require('../osenv.js') + + t.equal(osenv.user(), process.env.USER) + t.equal(osenv.home(), process.env.HOME) + t.equal(osenv.hostname(), process.env.HOSTNAME) + t.same(osenv.path(), process.env.PATH.split(':')) + t.equal(osenv.prompt(), process.env.PS1) + t.equal(osenv.tmpdir(), process.env.TMPDIR) + + // mildly evil, but it's for a test. + process.env.TMPDIR = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + t.equal(osenv.tmpdir(), process.env.TMP) + + process.env.TMP = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + t.equal(osenv.tmpdir(), process.env.TEMP) + + process.env.TEMP = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + osenv.home = function () { return null } + t.equal(osenv.tmpdir(), '/tmp') + + t.equal(osenv.editor(), 'edit') + process.env.EDITOR = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + t.equal(osenv.editor(), 'visualedit') + + process.env.VISUAL = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + t.equal(osenv.editor(), 'vi') + + t.equal(osenv.shell(), 'zsh') + process.env.SHELL = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + t.equal(osenv.shell(), 'bash') + + t.end() +}) diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/test/windows.js b/deps/npm/node_modules/nopt/node_modules/osenv/test/windows.js new file mode 100644 index 00000000000000..c9d837a32d4c68 --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/test/windows.js @@ -0,0 +1,74 @@ +// only run this test on windows +// pretending to be another platform is too hacky, since it breaks +// how the underlying system looks up module paths and runs +// child processes, and all that stuff is cached. +if (process.platform !== 'win32') { + console.log('TAP version 13\n' + + '1..0 # Skip windows tests, this is not windows\n') + return +} + +// load this before clubbing the platform name. +var tap = require('tap') + +process.env.windir = 'c:\\windows' +process.env.USERDOMAIN = 'some-domain' +process.env.USERNAME = 'sirUser' +process.env.USERPROFILE = 'C:\\Users\\sirUser' +process.env.COMPUTERNAME = 'my-machine' +process.env.TMPDIR = 'C:\\tmpdir' +process.env.TMP = 'C:\\tmp' +process.env.TEMP = 'C:\\temp' +process.env.Path = 'C:\\Program Files\\;C:\\Binary Stuff\\bin' +process.env.PROMPT = '(o_o) $ ' +process.env.EDITOR = 'edit' +process.env.VISUAL = 'visualedit' +process.env.ComSpec = 'some-com' + +tap.test('basic windows sanity test', function (t) { + var osenv = require('../osenv.js') + + t.equal(osenv.user(), + process.env.USERDOMAIN + '\\' + process.env.USERNAME) + t.equal(osenv.home(), process.env.USERPROFILE) + t.equal(osenv.hostname(), process.env.COMPUTERNAME) + t.same(osenv.path(), process.env.Path.split(';')) + t.equal(osenv.prompt(), process.env.PROMPT) + t.equal(osenv.tmpdir(), process.env.TMPDIR) + + // mildly evil, but it's for a test. + process.env.TMPDIR = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + t.equal(osenv.tmpdir(), process.env.TMP) + + process.env.TMP = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + t.equal(osenv.tmpdir(), process.env.TEMP) + + process.env.TEMP = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + osenv.home = function () { return null } + t.equal(osenv.tmpdir(), 'c:\\windows\\temp') + + t.equal(osenv.editor(), 'edit') + process.env.EDITOR = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + t.equal(osenv.editor(), 'visualedit') + + process.env.VISUAL = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + t.equal(osenv.editor(), 'notepad.exe') + + t.equal(osenv.shell(), 'some-com') + process.env.ComSpec = '' + delete require.cache[require.resolve('../osenv.js')] + var osenv = require('../osenv.js') + t.equal(osenv.shell(), 'cmd') + + t.end() +}) diff --git a/deps/npm/node_modules/nopt/node_modules/osenv/x.tap b/deps/npm/node_modules/nopt/node_modules/osenv/x.tap new file mode 100644 index 00000000000000..90d847208712ad --- /dev/null +++ b/deps/npm/node_modules/nopt/node_modules/osenv/x.tap @@ -0,0 +1,39 @@ +TAP version 13 + # Subtest: test/unix.js + TAP version 13 + # Subtest: basic unix sanity test + ok 1 - should be equal + ok 2 - should be equal + ok 3 - should be equal + ok 4 - should be equivalent + ok 5 - should be equal + ok 6 - should be equal + ok 7 - should be equal + ok 8 - should be equal + ok 9 - should be equal + ok 10 - should be equal + ok 11 - should be equal + ok 12 - should be equal + ok 13 - should be equal + ok 14 - should be equal + 1..14 + ok 1 - basic unix sanity test # time=10.712ms + + 1..1 + # time=18.422ms +ok 1 - test/unix.js # time=169.827ms + + # Subtest: test/windows.js + TAP version 13 + 1..0 # Skip windows tests, this is not windows + +ok 2 - test/windows.js # SKIP Skip windows tests, this is not windows + + # Subtest: test/nada.js + TAP version 13 + 1..0 + +ok 2 - test/nada.js + +1..3 +# time=274.247ms diff --git a/deps/npm/node_modules/nopt/package.json b/deps/npm/node_modules/nopt/package.json index ada51ba4bf3211..c29a2ad44cb8de 100644 --- a/deps/npm/node_modules/nopt/package.json +++ b/deps/npm/node_modules/nopt/package.json @@ -1,44 +1,54 @@ { "_args": [ [ - "nopt@~3.0.6", - "/Users/ogd/Documents/projects/npm/npm" + { + "raw": "nopt@4.0.1", + "scope": null, + "escapedName": "nopt", + "name": "nopt", + "rawSpec": "4.0.1", + "spec": "4.0.1", + "type": "version" + }, + "/Users/rebecca/code/npm" ] ], - "_from": "nopt@>=3.0.6 <3.1.0", - "_id": "nopt@3.0.6", + "_from": "nopt@4.0.1", + "_id": "nopt@4.0.1", "_inCache": true, - "_installable": true, "_location": "/nopt", - "_nodeVersion": "4.2.1", + "_nodeVersion": "7.2.0", + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/nopt-4.0.1.tgz_1481739985863_0.18861285015009344" + }, "_npmUser": { - "email": "ogd@aoaioxxysz.net", - "name": "othiym23" + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" }, - "_npmVersion": "2.14.10", + "_npmVersion": "4.0.5", "_phantomChildren": {}, "_requested": { - "name": "nopt", - "raw": "nopt@~3.0.6", - "rawSpec": "~3.0.6", + "raw": "nopt@4.0.1", "scope": null, - "spec": ">=3.0.6 <3.1.0", - "type": "range" + "escapedName": "nopt", + "name": "nopt", + "rawSpec": "4.0.1", + "spec": "4.0.1", + "type": "version" }, "_requiredBy": [ - "/", - "/node-gyp", - "/standard/standard-format/esformatter-jsx/js-beautify", - "/tap/nyc/istanbul" + "#USER", + "/" ], - "_resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "_shasum": "c6465dbf08abcd4db359317f79ac68a646b28ff9", + "_resolved": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz", + "_shasum": "d0d4685afd5415193c8c7505602d0d17cd64474d", "_shrinkwrap": null, - "_spec": "nopt@~3.0.6", - "_where": "/Users/ogd/Documents/projects/npm/npm", + "_spec": "nopt@4.0.1", + "_where": "/Users/rebecca/code/npm", "author": { - "email": "i@izs.me", "name": "Isaac Z. Schlueter", + "email": "i@izs.me", "url": "http://blog.izs.me/" }, "bin": { @@ -48,18 +58,19 @@ "url": "https://github.com/npm/nopt/issues" }, "dependencies": { - "abbrev": "1" + "abbrev": "1", + "osenv": "^0.1.4" }, "description": "Option parsing for Node, supporting types, shorthands, etc. Used by npm.", "devDependencies": { - "tap": "^1.2.0" + "tap": "^8.0.1" }, "directories": {}, "dist": { - "shasum": "c6465dbf08abcd4db359317f79ac68a646b28ff9", - "tarball": "http://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz" + "shasum": "d0d4685afd5415193c8c7505602d0d17cd64474d", + "tarball": "https://registry.npmjs.org/nopt/-/nopt-4.0.1.tgz" }, - "gitHead": "10a750c9bb99c1950160353459e733ac2aa18cb6", + "gitHead": "24921187dc52825d628042c9708bbd8e8734698c", "homepage": "https://github.com/npm/nopt#readme", "license": "ISC", "main": "lib/nopt.js", @@ -87,5 +98,5 @@ "scripts": { "test": "tap test/*.js" }, - "version": "3.0.6" + "version": "4.0.1" } diff --git a/deps/npm/node_modules/nopt/test/basic.js b/deps/npm/node_modules/nopt/test/basic.js index 17fb286951de11..5c18ac0fc6a319 100644 --- a/deps/npm/node_modules/nopt/test/basic.js +++ b/deps/npm/node_modules/nopt/test/basic.js @@ -1,6 +1,6 @@ var nopt = require("../") , test = require('tap').test - + , isWin = process.platform === 'win32' test("passing a string results in a string", function (t) { var parsed = nopt({ key: String }, {}, ["--key", "myvalue"], 0) @@ -15,11 +15,41 @@ test("Empty String results in empty string, not true", function (t) { t.end() }) -test("~ path is resolved to $HOME", function (t) { +// https://github.com/npm/nopt/issues/65 +test("Empty String should not swallow next flag", function (t) { + var parsed = nopt({ empty: String, foo: String }, {}, ["--empty", "--foo"], 0) + t.same(parsed.empty, "") + t.same(parsed.foo, "") + t.end() +}) + +// https://github.com/npm/nopt/issues/66 +test("Empty String should not be true when type is single item Array", function (t) { + var parsed = nopt({ 'foo': [String] }, {}, ["--foo"], 0) + t.same(parsed.foo, "") + t.end() +}) + +test("~ path is resolved to " + (isWin ? '%USERPROFILE%' : '$HOME'), function (t) { var path = require("path") - if (!process.env.HOME) process.env.HOME = "/tmp" - var parsed = nopt({key: path}, {}, ["--key=~/val"], 0) - t.same(parsed.key, path.resolve(process.env.HOME, "val")) + , the + + if (isWin) { + the = { + key: 'USERPROFILE', + dir: 'C:\\temp', + val: '~\\val' + } + } else { + the = { + key: 'HOME', + dir: '/tmp', + val: '~/val' + } + } + if (!process.env[the.key]) process.env[the.key] = v.dir + var parsed = nopt({key: path}, {}, ["--key=" + the.val], 0) + t.same(parsed.key, path.resolve(process.env[the.key], "val")) t.end() }) @@ -106,6 +136,8 @@ test("other tests", function (t) { , loglevel : ["silent","win","error","warn","info","verbose","silly"] , long : Boolean , "node-version" : [false, String] + , npaturl : url + , npat : Boolean , "onload-script" : [false, String] , outfd : [Number, Stream] , parseable : Boolean @@ -146,7 +178,7 @@ test("other tests", function (t) { ,["--color --logfd 7", {logfd:7,color:true}, []] ,["--color=true", {color:true}, []] ,["--logfd=10", {logfd:10}, []] - ,["--tmp=/tmp -tar=gtar",{tmp:"/tmp",tar:"gtar"},[]] + ,["--tmp=/tmp -tar=gtar", {tmp: isWin ? "C:\\tmp" : "/tmp",tar:"gtar"},[]] ,["--tmp=tmp -tar=gtar", {tmp:path.resolve(process.cwd(), "tmp"),tar:"gtar"},[]] ,["--logfd x", {}, []] diff --git a/deps/npm/node_modules/npm-registry-client/.travis.yml b/deps/npm/node_modules/npm-registry-client/.travis.yml index 2993ae58c9afbe..6841bf144330e5 100644 --- a/deps/npm/node_modules/npm-registry-client/.travis.yml +++ b/deps/npm/node_modules/npm-registry-client/.travis.yml @@ -1,8 +1,8 @@ language: node_js node_js: - - "4" - "6" - - "0.10" + - "4" + - "7" - "0.12" script: "npm test" sudo: false diff --git a/deps/npm/node_modules/npm-registry-client/README.md b/deps/npm/node_modules/npm-registry-client/README.md index e14159cd07fdb1..74bd6e1da7817a 100644 --- a/deps/npm/node_modules/npm-registry-client/README.md +++ b/deps/npm/node_modules/npm-registry-client/README.md @@ -38,7 +38,7 @@ Every call to the client follows the same pattern: ### Credentials -Many requests to the registry can by authenticated, and require credentials +Many requests to the registry can be authenticated, and require credentials for authorization. These credentials always look the same: * `username` {String} @@ -183,6 +183,20 @@ Publish a package to the registry. Note that this does not create the tarball from a folder. +### client.sendAnonymousCLIMetrics(uri, params, cb) + +- `uri` {String} Base URL for the registry. +- `params` {Object} Object containing per-request properties. + - `metricId` {String} A uuid unique to this dataset. + - `metrics` {Object} The metrics to share with the registry, with the following properties: + - `from` {Date} When the first data in this report was collected. + - `to` {Date} When the last data in this report was collected. Usually right now. + - `successfulInstalls` {Number} The number of successful installs in this period. + - `failedInstalls` {Number} The number of installs that ended in error in this period. +- `cb` {Function} + +PUT a metrics object to the `/-/npm/anon-metrics/v1/` endpoint on the registry. + ### client.star(uri, params, cb) * `uri` {String} The complete registry URI for the package to star. diff --git a/deps/npm/node_modules/npm-registry-client/index.js b/deps/npm/node_modules/npm-registry-client/index.js index a199801f98da99..8de76f5aaa5432 100644 --- a/deps/npm/node_modules/npm-registry-client/index.js +++ b/deps/npm/node_modules/npm-registry-client/index.js @@ -54,7 +54,7 @@ function RegClient (config) { // lib/group-name/operation.js -> client.groupName.operation var stat = fs.statSync(entry) if (stat.isDirectory()) { - var groupName = f.replace(/-([a-z])/, dashToCamel) + var groupName = f.replace(/-([a-z])/gi, dashToCamel) fs.readdirSync(entry).forEach(function (f) { if (!f.match(/\.js$/)) return @@ -62,14 +62,14 @@ function RegClient (config) { // keep client.groupName.operation from stomping client.operation client[groupName] = Object.create(client) } - var name = f.replace(/\.js$/, '').replace(/-([a-z])/, dashToCamel) + var name = f.replace(/\.js$/, '').replace(/-([a-z])/gi, dashToCamel) client[groupName][name] = require(join(entry, f)) }) return } if (!f.match(/\.js$/)) return - var name = f.replace(/\.js$/, '').replace(/-([a-z])/, dashToCamel) + var name = f.replace(/\.js$/, '').replace(/-([a-z])/gi, dashToCamel) client[name] = require(entry) }) } diff --git a/deps/npm/node_modules/npm-registry-client/lib/adduser.js b/deps/npm/node_modules/npm-registry-client/lib/adduser.js index a6a779d8ca97a5..fd6f5302ae71e6 100644 --- a/deps/npm/node_modules/npm-registry-client/lib/adduser.js +++ b/deps/npm/node_modules/npm-registry-client/lib/adduser.js @@ -2,6 +2,7 @@ module.exports = adduser var url = require('url') var assert = require('assert') +var extend = Object.assign || require('util')._extend function adduser (uri, params, cb) { assert(typeof uri === 'string', 'must pass registry URI to adduser') @@ -67,7 +68,7 @@ function adduser (uri, params, cb) { } this.request( uri, - options, + extend({}, options), function (error, data, json, response) { if (!error || !response || response.statusCode !== 409) { return cb(error, data, json, response) diff --git a/deps/npm/node_modules/npm-registry-client/lib/fetch.js b/deps/npm/node_modules/npm-registry-client/lib/fetch.js index e931d371ee7886..ff3ee216b7f78d 100644 --- a/deps/npm/node_modules/npm-registry-client/lib/fetch.js +++ b/deps/npm/node_modules/npm-registry-client/lib/fetch.js @@ -18,16 +18,19 @@ function fetch (uri, params, cb) { makeRequest.call(client, uri, params, function (er, req) { if (er) return cb(er) - req.on('error', function (er) { + req.once('error', retryOnError) + + function retryOnError (er) { if (operation.retry(er)) { client.log.info('retry', 'will retry, error on last attempt: ' + er) } else { cb(er) } - }) + } req.on('response', function (res) { client.log.http('fetch', '' + res.statusCode, uri) + req.removeListener('error', retryOnError) var er var statusCode = res && res.statusCode @@ -37,6 +40,10 @@ function fetch (uri, params, cb) { res.resume() if (process.version === 'v0.10.0') unstick(res) + req.once('error', function (er) { + res.emit('error', er) + }) + return cb(null, res) // Only retry on 408, 5xx or no `response`. } else if (statusCode === 408) { diff --git a/deps/npm/node_modules/npm-registry-client/lib/request.js b/deps/npm/node_modules/npm-registry-client/lib/request.js index 04be044d6a0e27..8d456259a76a95 100644 --- a/deps/npm/node_modules/npm-registry-client/lib/request.js +++ b/deps/npm/node_modules/npm-registry-client/lib/request.js @@ -42,23 +42,25 @@ function regRequest (uri, params, cb_) { return cb(new Error('trying to change user document without writing(?!)')) } - // new users can *not* use auth, because they don't *have* auth yet - if (isUserChange) { - this.log.verbose('request', 'updating existing user; sending authorization') - params.authed = true - } else if (isNewUser) { - this.log.verbose('request', "new user, so can't send auth") - params.authed = false - } else if (alwaysAuth) { - this.log.verbose('request', 'always-auth set; sending authorization') - params.authed = true - } else if (isWrite) { - this.log.verbose('request', 'sending authorization for write operation') - params.authed = true - } else { - // most of the time we don't want to auth - this.log.verbose('request', 'no auth needed') - params.authed = false + if (params.authed == null) { + // new users can *not* use auth, because they don't *have* auth yet + if (isUserChange) { + this.log.verbose('request', 'updating existing user; sending authorization') + params.authed = true + } else if (isNewUser) { + this.log.verbose('request', "new user, so can't send auth") + params.authed = false + } else if (alwaysAuth) { + this.log.verbose('request', 'always-auth set; sending authorization') + params.authed = true + } else if (isWrite) { + this.log.verbose('request', 'sending authorization for write operation') + params.authed = true + } else { + // most of the time we don't want to auth + this.log.verbose('request', 'no auth needed') + params.authed = false + } } var self = this diff --git a/deps/npm/node_modules/npm-registry-client/lib/send-anonymous-CLI-metrics.js b/deps/npm/node_modules/npm-registry-client/lib/send-anonymous-CLI-metrics.js new file mode 100644 index 00000000000000..b5b7a1dca15e7f --- /dev/null +++ b/deps/npm/node_modules/npm-registry-client/lib/send-anonymous-CLI-metrics.js @@ -0,0 +1,19 @@ +module.exports = send + +var assert = require('assert') +var url = require('url') + +function send (registryUrl, params, cb) { + assert(typeof registryUrl === 'string', 'must pass registry URI') + assert(params && typeof params === 'object', 'must pass params') + assert(typeof cb === 'function', 'must pass callback') + + var uri = url.resolve(registryUrl, '-/npm/anon-metrics/v1/' + + encodeURIComponent(params.metricId)) + + this.request(uri, { + method: 'PUT', + body: JSON.stringify(params.metrics), + authed: false + }, cb) +} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/CHANGELOG.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/CHANGELOG.md deleted file mode 100644 index f549a1f3de81e3..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/CHANGELOG.md +++ /dev/null @@ -1,36 +0,0 @@ -### v3.1.2 - -* Update to `gauge@1.6.0` adding support for default values for template - items. - -### v3.1.1 - -* Update to `gauge@1.5.3` to fix to `1.x` compatibility when it comes to - when a progress bar is enabled. In `1.x` if you didn't have a TTY the - progress bar was never shown. In `2.x` it merely defaults to disabled, - but you can enable it explicitly if you still want progress updates. - -### v3.1.0 - -* Update to `gauge@2.5.2`: - * Updates the `signal-exit` dependency which fixes an incompatibility with - the node profiler. - * Uses externalizes its ansi code generation in `console-control-strings` -* Make the default progress bar include the last line printed, colored as it - would be when printing to a tty. - -### v3.0.0 - -* Switch to `gauge@2.0.0`, for better performance, better look. -* Set stderr/stdout blocking if they're tty's, so that we can hide a - progress bar going to stderr and then safely print to stdout. Without - this the two can end up overlapping producing confusing and sometimes - corrupted output. - -### v2.0.0 - -* Make the `error` event non-fatal so that folks can use it as a prefix. - -### v1.0.0 - -* Add progress bar with `gauge@1.1.0` diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/README.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/README.md deleted file mode 100644 index dba35501614e91..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/README.md +++ /dev/null @@ -1,210 +0,0 @@ -# npmlog - -The logger util that npm uses. - -This logger is very basic. It does the logging for npm. It supports -custom levels and colored output. - -By default, logs are written to stderr. If you want to send log messages -to outputs other than streams, then you can change the `log.stream` -member, or you can just listen to the events that it emits, and do -whatever you want with them. - -# Basic Usage - -``` -var log = require('npmlog') - -// additional stuff ---------------------------+ -// message ----------+ | -// prefix ----+ | | -// level -+ | | | -// v v v v - log.info('fyi', 'I have a kitty cat: %j', myKittyCat) -``` - -## log.level - -* {String} - -The level to display logs at. Any logs at or above this level will be -displayed. The special level `silent` will prevent anything from being -displayed ever. - -## log.record - -* {Array} - -An array of all the log messages that have been entered. - -## log.maxRecordSize - -* {Number} - -The maximum number of records to keep. If log.record gets bigger than -10% over this value, then it is sliced down to 90% of this value. - -The reason for the 10% window is so that it doesn't have to resize a -large array on every log entry. - -## log.prefixStyle - -* {Object} - -A style object that specifies how prefixes are styled. (See below) - -## log.headingStyle - -* {Object} - -A style object that specifies how the heading is styled. (See below) - -## log.heading - -* {String} Default: "" - -If set, a heading that is printed at the start of every line. - -## log.stream - -* {Stream} Default: `process.stderr` - -The stream where output is written. - -## log.enableColor() - -Force colors to be used on all messages, regardless of the output -stream. - -## log.disableColor() - -Disable colors on all messages. - -## log.enableProgress() - -Enable the display of log activity spinner and progress bar - -## log.disableProgress() - -Disable the display of a progress bar - -## log.enableUnicode() - -Force the unicode theme to be used for the progress bar. - -## log.disableUnicode() - -Disable the use of unicode in the progress bar. - -## log.setGaugeTemplate(template) - -Set a template for outputting the progress bar. See the [gauge documentation] for details. - -[gauge documentation]: https://npmjs.com/package/gauge - -## log.setGaugeThemeset(themes) - -Select a themeset to pick themes from for the progress bar. See the [gauge documentation] for details. - -## log.pause() - -Stop emitting messages to the stream, but do not drop them. - -## log.resume() - -Emit all buffered messages that were written while paused. - -## log.log(level, prefix, message, ...) - -* `level` {String} The level to emit the message at -* `prefix` {String} A string prefix. Set to "" to skip. -* `message...` Arguments to `util.format` - -Emit a log message at the specified level. - -## log\[level](prefix, message, ...) - -For example, - -* log.silly(prefix, message, ...) -* log.verbose(prefix, message, ...) -* log.info(prefix, message, ...) -* log.http(prefix, message, ...) -* log.warn(prefix, message, ...) -* log.error(prefix, message, ...) - -Like `log.log(level, prefix, message, ...)`. In this way, each level is -given a shorthand, so you can do `log.info(prefix, message)`. - -## log.addLevel(level, n, style, disp) - -* `level` {String} Level indicator -* `n` {Number} The numeric level -* `style` {Object} Object with fg, bg, inverse, etc. -* `disp` {String} Optional replacement for `level` in the output. - -Sets up a new level with a shorthand function and so forth. - -Note that if the number is `Infinity`, then setting the level to that -will cause all log messages to be suppressed. If the number is -`-Infinity`, then the only way to show it is to enable all log messages. - -## log.newItem(name, todo, weight) - -* `name` {String} Optional; progress item name. -* `todo` {Number} Optional; total amount of work to be done. Default 0. -* `weight` {Number} Optional; the weight of this item relative to others. Default 1. - -This adds a new `are-we-there-yet` item tracker to the progress tracker. The -object returned has the `log[level]` methods but is otherwise an -`are-we-there-yet` `Tracker` object. - -## log.newStream(name, todo, weight) - -This adds a new `are-we-there-yet` stream tracker to the progress tracker. The -object returned has the `log[level]` methods but is otherwise an -`are-we-there-yet` `TrackerStream` object. - -## log.newGroup(name, weight) - -This adds a new `are-we-there-yet` tracker group to the progress tracker. The -object returned has the `log[level]` methods but is otherwise an -`are-we-there-yet` `TrackerGroup` object. - -# Events - -Events are all emitted with the message object. - -* `log` Emitted for all messages -* `log.` Emitted for all messages with the `` level. -* `` Messages with prefixes also emit their prefix as an event. - -# Style Objects - -Style objects can have the following fields: - -* `fg` {String} Color for the foreground text -* `bg` {String} Color for the background -* `bold`, `inverse`, `underline` {Boolean} Set the associated property -* `bell` {Boolean} Make a noise (This is pretty annoying, probably.) - -# Message Objects - -Every log event is emitted with a message object, and the `log.record` -list contains all of them that have been created. They have the -following fields: - -* `id` {Number} -* `level` {String} -* `prefix` {String} -* `message` {String} Result of `util.format()` -* `messageRaw` {Array} Arguments to `util.format()` - -# Blocking TTYs - -We use [`set-blocking`](https://npmjs.com/package/set-blocking) to set -stderr and stdout blocking if they are tty's and have the setBlocking call. -This is a work around for an issue in early versions of Node.js 6.x, which -made stderr and stdout non-blocking on OSX. (They are always blocking -Windows and were never blocking on Linux.) `npmlog` needs them to be blocking -so that it can allow output to stdout and stderr to be interlaced. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/log.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/log.js deleted file mode 100644 index e5b70f1f80b743..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/log.js +++ /dev/null @@ -1,298 +0,0 @@ -'use strict' -var Progress = require('are-we-there-yet') -var Gauge = require('gauge') -var EE = require('events').EventEmitter -var log = exports = module.exports = new EE() -var util = require('util') - -var setBlocking = require('set-blocking') -var consoleControl = require('console-control-strings') - -setBlocking(true) -var stream = process.stderr -Object.defineProperty(log, 'stream', { - set: function (newStream) { - stream = newStream - if (this.gauge) this.gauge.setWriteTo(stream, stream) - }, - get: function () { - return stream - } -}) - -// by default, decide based on tty-ness. -var colorEnabled -log.useColor = function () { - return colorEnabled != null ? colorEnabled : stream.isTTY -} - -log.enableColor = function () { - colorEnabled = true - this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled}) -} -log.disableColor = function () { - colorEnabled = false - this.gauge.setTheme({hasColor: colorEnabled, hasUnicode: unicodeEnabled}) -} - -// default level -log.level = 'info' - -log.gauge = new Gauge(stream, { - theme: {hasColor: log.useColor()}, - template: [ - {type: 'progressbar', length: 20}, - {type: 'activityIndicator', kerning: 1, length: 1}, - {type: 'section', default: ''}, - ':', - {type: 'logline', kerning: 1, default: ''} - ] -}) - -log.tracker = new Progress.TrackerGroup() - -// no progress bars unless asked -log.progressEnabled = false - -var unicodeEnabled - -log.enableUnicode = function () { - unicodeEnabled = true - this.gauge.setTheme({hasColor: this.useColor(), hasUnicode: unicodeEnabled}) -} - -log.disableUnicode = function () { - unicodeEnabled = false - this.gauge.setTheme({hasColor: this.useColor(), hasUnicode: unicodeEnabled}) -} - -log.setGaugeThemeset = function (themes) { - this.gauge.setThemeset(themes) -} - -log.setGaugeTemplate = function (template) { - this.gauge.setTemplate(template) -} - -log.enableProgress = function () { - if (this.progressEnabled) return - this.progressEnabled = true - if (this._pause) return - this.tracker.on('change', this.showProgress) - this.gauge.enable() - this.showProgress() -} - -log.disableProgress = function () { - if (!this.progressEnabled) return - this.clearProgress() - this.progressEnabled = false - this.tracker.removeListener('change', this.showProgress) - this.gauge.disable() -} - -var trackerConstructors = ['newGroup', 'newItem', 'newStream'] - -var mixinLog = function (tracker) { - // mixin the public methods from log into the tracker - // (except: conflicts and one's we handle specially) - Object.keys(log).forEach(function (P) { - if (P[0] === '_') return - if (trackerConstructors.filter(function (C) { return C === P }).length) return - if (tracker[P]) return - if (typeof log[P] !== 'function') return - var func = log[P] - tracker[P] = function () { - return func.apply(log, arguments) - } - }) - // if the new tracker is a group, make sure any subtrackers get - // mixed in too - if (tracker instanceof Progress.TrackerGroup) { - trackerConstructors.forEach(function (C) { - var func = tracker[C] - tracker[C] = function () { return mixinLog(func.apply(tracker, arguments)) } - }) - } - return tracker -} - -// Add tracker constructors to the top level log object -trackerConstructors.forEach(function (C) { - log[C] = function () { return mixinLog(this.tracker[C].apply(this.tracker, arguments)) } -}) - -log.clearProgress = function (cb) { - if (!this.progressEnabled) return cb && process.nextTick(cb) - this.gauge.hide(cb) -} - -log.showProgress = function (name, completed) { - if (!this.progressEnabled) return - var values = {} - if (name) values.section = name - var last = log.record[log.record.length - 1] - if (last) { - values.subsection = last.prefix - var disp = log.disp[last.level] || last.level - var logline = this._format(disp, log.style[last.level]) - if (last.prefix) logline += ' ' + this._format(last.prefix, this.prefixStyle) - logline += ' ' + last.message.split(/\r?\n/)[0] - values.logline = logline - } - values.completed = completed || this.tracker.completed() - this.gauge.show(values) -}.bind(log) // bind for use in tracker's on-change listener - -// temporarily stop emitting, but don't drop -log.pause = function () { - this._paused = true -} - -log.resume = function () { - if (!this._paused) return - this._paused = false - - var b = this._buffer - this._buffer = [] - b.forEach(function (m) { - this.emitLog(m) - }, this) - if (this.progressEnabled) this.enableProgress() -} - -log._buffer = [] - -var id = 0 -log.record = [] -log.maxRecordSize = 10000 -log.log = function (lvl, prefix, message) { - var l = this.levels[lvl] - if (l === undefined) { - return this.emit('error', new Error(util.format( - 'Undefined log level: %j', lvl))) - } - - var a = new Array(arguments.length - 2) - var stack = null - for (var i = 2; i < arguments.length; i++) { - var arg = a[i - 2] = arguments[i] - - // resolve stack traces to a plain string. - if (typeof arg === 'object' && arg && - (arg instanceof Error) && arg.stack) { - arg.stack = stack = arg.stack + '' - } - } - if (stack) a.unshift(stack + '\n') - message = util.format.apply(util, a) - - var m = { id: id++, - level: lvl, - prefix: String(prefix || ''), - message: message, - messageRaw: a } - - this.emit('log', m) - this.emit('log.' + lvl, m) - if (m.prefix) this.emit(m.prefix, m) - - this.record.push(m) - var mrs = this.maxRecordSize - var n = this.record.length - mrs - if (n > mrs / 10) { - var newSize = Math.floor(mrs * 0.9) - this.record = this.record.slice(-1 * newSize) - } - - this.emitLog(m) -}.bind(log) - -log.emitLog = function (m) { - if (this._paused) { - this._buffer.push(m) - return - } - if (this.progressEnabled) this.gauge.pulse(m.prefix) - var l = this.levels[m.level] - if (l === undefined) return - if (l < this.levels[this.level]) return - if (l > 0 && !isFinite(l)) return - - var disp = log.disp[m.level] || m.level - this.clearProgress() - m.message.split(/\r?\n/).forEach(function (line) { - if (this.heading) { - this.write(this.heading, this.headingStyle) - this.write(' ') - } - this.write(disp, log.style[m.level]) - var p = m.prefix || '' - if (p) this.write(' ') - this.write(p, this.prefixStyle) - this.write(' ' + line + '\n') - }, this) - this.showProgress() -} - -log._format = function (msg, style) { - if (!stream) return - - var output = '' - if (this.useColor()) { - style = style || {} - var settings = [] - if (style.fg) settings.push(style.fg) - if (style.bg) settings.push('bg' + style.bg[0].toUpperCase() + style.bg.slice(1)) - if (style.bold) settings.push('bold') - if (style.underline) settings.push('underline') - if (style.inverse) settings.push('inverse') - if (settings.length) output += consoleControl.color(settings) - if (style.beep) output += consoleControl.beep() - } - output += msg - if (this.useColor()) { - output += consoleControl.color('reset') - } - return output -} - -log.write = function (msg, style) { - if (!stream) return - - stream.write(this._format(msg, style)) -} - -log.addLevel = function (lvl, n, style, disp) { - if (!disp) disp = lvl - this.levels[lvl] = n - this.style[lvl] = style - if (!this[lvl]) { - this[lvl] = function () { - var a = new Array(arguments.length + 1) - a[0] = lvl - for (var i = 0; i < arguments.length; i++) { - a[i + 1] = arguments[i] - } - return this.log.apply(this, a) - }.bind(this) - } - this.disp[lvl] = disp -} - -log.prefixStyle = { fg: 'magenta' } -log.headingStyle = { fg: 'white', bg: 'black' } - -log.style = {} -log.levels = {} -log.disp = {} -log.addLevel('silly', -Infinity, { inverse: true }, 'sill') -log.addLevel('verbose', 1000, { fg: 'blue', bg: 'black' }, 'verb') -log.addLevel('info', 2000, { fg: 'green' }) -log.addLevel('http', 3000, { fg: 'green', bg: 'black' }) -log.addLevel('warn', 4000, { fg: 'black', bg: 'yellow' }, 'WARN') -log.addLevel('error', 5000, { fg: 'red', bg: 'black' }, 'ERR!') -log.addLevel('silent', Infinity) - -// allow 'error' prefix -log.on('error', function () {}) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/.npmignore b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/.npmignore deleted file mode 100644 index bc818974f8633f..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -*~ -.#* -node_modules -coverage -.nyc_output diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/CHANGES.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/CHANGES.md deleted file mode 100644 index e990b86ddfb416..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/CHANGES.md +++ /dev/null @@ -1,19 +0,0 @@ -Hi, figured we could actually use a changelog now: - -## 1.1.1 2016-01-29 - -* Fix a typo in stream completion tracker - -## 1.1.0 2016-01-29 - -* Rewrote completion percent computation to be low impact– no more walking a - tree of completion groups every time we need this info. Previously, with - medium sized tree of completion groups, even a relatively modest number of - calls to the top level `completed()` method would result in absurd numbers - of calls overall as it walked down the tree. We now, instead, keep track as - we bubble up changes, so the computation is limited to when data changes and - to the depth of that one branch, instead of _every_ node. (Plus, we were already - incurring _this_ cost, since we already bubbled out changes.) -* Moved different tracker types out to their own files. -* Made tests test for TOO MANY events too. -* Standarized the source code formatting diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE deleted file mode 100644 index af4588069db82d..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/LICENSE +++ /dev/null @@ -1,5 +0,0 @@ -Copyright (c) 2015, Rebecca Turner - -Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/README.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/README.md deleted file mode 100644 index c41d39229244d2..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/README.md +++ /dev/null @@ -1,194 +0,0 @@ -are-we-there-yet ----------------- - -Track complex hiearchies of asynchronous task completion statuses. This is -intended to give you a way of recording and reporting the progress of the big -recursive fan-out and gather type workflows that are so common in async. - -What you do with this completion data is up to you, but the most common use case is to -feed it to one of the many progress bar modules. - -Most progress bar modules include a rudamentary version of this, but my -needs were more complex. - -Usage -===== - -```javascript -var TrackerGroup = require("are-we-there-yet").TrackerGroup - -var top = new TrackerGroup("program") - -var single = top.newItem("one thing", 100) -single.completeWork(20) - -console.log(top.completed()) // 0.2 - -fs.stat("file", function(er, stat) { - if (er) throw er - var stream = top.newStream("file", stat.size) - console.log(top.completed()) // now 0.1 as single is 50% of the job and is 20% complete - // and 50% * 20% == 10% - fs.createReadStream("file").pipe(stream).on("data", function (chunk) { - // do stuff with chunk - }) - top.on("change", function (name) { - // called each time a chunk is read from "file" - // top.completed() will start at 0.1 and fill up to 0.6 as the file is read - }) -}) -``` - -Shared Methods -============== - -All tracker objects described below have the following methods, they, along -with the event comprise the interface for consumers of tracker objects. - -* var completed = tracker.completed() - -Returns the ratio of completed work to work to be done. Range of 0 to 1. - -* tracker.finish() - -Marks the tracker as completed. With a TrackerGroup this marks all of its -components as completed. - -Marks all of the components of this tracker as finished, which in turn means -that `tracker.completed()` for this will now be 1. - -This will result in one or more `change` events being emitted. - -Events -====== - -All tracker objects emit `change` events with the following arguments: - -``` -function (name, completed, tracker) -``` - -`name` is the name of the tracker that originally emitted the event, -or if it didn't have one, the first containing tracker group that had one. - -`completed` is the percent complete (as returned by `tracker.completed()` method). - -`tracker` is the tracker object that you are listening for events on. - -TrackerGroup -============ - -* var tracker = new TrackerGroup(**name**) - - * **name** *(optional)* - The name of this tracker group, used in change - notifications if the component updating didn't have a name. Defaults to undefined. - -Creates a new empty tracker aggregation group. These are trackers whose -completion status is determined by the completion status of other trackers. - -* tracker.addUnit(**otherTracker**, **weight**) - - * **otherTracker** - Any of the other are-we-there-yet tracker objects - * **weight** *(optional)* - The weight to give the tracker, defaults to 1. - -Adds the **otherTracker** to this aggregation group. The weight determines -how long you expect this tracker to take to complete in proportion to other -units. So for instance, if you add one tracker with a weight of 1 and -another with a weight of 2, you're saying the second will take twice as long -to complete as the first. As such, the first will account for 33% of the -completion of this tracker and the second will account for the other 67%. - -Returns **otherTracker**. - -* var subGroup = tracker.newGroup(**name**, **weight**) - -The above is exactly equivalent to: - -```javascript - var subGroup = tracker.addUnit(new TrackerGroup(name), weight) -``` - -* var subItem = tracker.newItem(**name**, **todo**, **weight**) - -The above is exactly equivalent to: - -```javascript - var subItem = tracker.addUnit(new Tracker(name, todo), weight) -``` - -* var subStream = tracker.newStream(**name**, **todo**, **weight**) - -The above is exactly equivalent to: - -```javascript - var subStream = tracker.addUnit(new TrackerStream(name, todo), weight) -``` - -* console.log( tracker.debug() ) - -Returns a tree showing the completion of this tracker group and all of its -children, including recursively entering all of the children. - -Tracker -======= - -* var tracker = new Tracker(**name**, **todo**) - - * **name** *(optional)* The name of this counter to report in change - events. Defaults to undefined. - * **todo** *(optional)* The amount of work todo (a number). Defaults to 0. - -Ordinarily these are constructed as a part of a tracker group (via -`newItem`). - -* var completed = tracker.completed() - -Returns the ratio of completed work to work to be done. Range of 0 to 1. If -total work to be done is 0 then it will return 0. - -* tracker.addWork(**todo**) - - * **todo** A number to add to the amount of work to be done. - -Increases the amount of work to be done, thus decreasing the completion -percentage. Triggers a `change` event. - -* tracker.completeWork(**completed**) - - * **completed** A number to add to the work complete - -Increase the amount of work complete, thus increasing the completion percentage. -Will never increase the work completed past the amount of work todo. That is, -percentages > 100% are not allowed. Triggers a `change` event. - -* tracker.finish() - -Marks this tracker as finished, tracker.completed() will now be 1. Triggers -a `change` event. - -TrackerStream -============= - -* var tracker = new TrackerStream(**name**, **size**, **options**) - - * **name** *(optional)* The name of this counter to report in change - events. Defaults to undefined. - * **size** *(optional)* The number of bytes being sent through this stream. - * **options** *(optional)* A hash of stream options - -The tracker stream object is a pass through stream that updates an internal -tracker object each time a block passes through. It's intended to track -downloads, file extraction and other related activities. You use it by piping -your data source into it and then using it as your data source. - -If your data has a length attribute then that's used as the amount of work -completed when the chunk is passed through. If it does not (eg, object -streams) then each chunk counts as completing 1 unit of work, so your size -should be the total number of objects being streamed. - -* tracker.addWork(**todo**) - - * **todo** Increase the expected overall size by **todo** bytes. - -Increases the amount of work to be done, thus decreasing the completion -percentage. Triggers a `change` event. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/index.js deleted file mode 100644 index 57d8743fdad177..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict' -exports.TrackerGroup = require('./tracker-group.js') -exports.Tracker = require('./tracker.js') -exports.TrackerStream = require('./tracker-stream.js') diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/.npmignore b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/.npmignore deleted file mode 100644 index c2658d7d1b3184..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/.npmignore +++ /dev/null @@ -1 +0,0 @@ -node_modules/ diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/History.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/History.md deleted file mode 100644 index 25959eab67b840..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/History.md +++ /dev/null @@ -1,22 +0,0 @@ - -1.0.0 / 2015-12-14 -================== - - * Merge pull request #12 from kasicka/master - * Add license text - -0.1.0 / 2014-10-17 -================== - - * adds `.fluent()` to api - -0.0.3 / 2014-01-13 -================== - - * fix receiver for .method() - -0.0.2 / 2014-01-13 -================== - - * Object.defineProperty() sucks - * Initial commit diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/License b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/License deleted file mode 100644 index 60de60addbe7e9..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/License +++ /dev/null @@ -1,20 +0,0 @@ -Copyright (c) 2015 TJ Holowaychuk - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Makefile b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Makefile deleted file mode 100644 index a9dcfd50dbdb22..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -test: - @./node_modules/.bin/mocha \ - --require should \ - --reporter spec \ - --bail - -.PHONY: test \ No newline at end of file diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Readme.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Readme.md deleted file mode 100644 index ab8cf4ace15939..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/Readme.md +++ /dev/null @@ -1,94 +0,0 @@ - -# delegates - - Node method and accessor delegation utilty. - -## Installation - -``` -$ npm install delegates -``` - -## Example - -```js -var delegate = require('delegates'); - -... - -delegate(proto, 'request') - .method('acceptsLanguages') - .method('acceptsEncodings') - .method('acceptsCharsets') - .method('accepts') - .method('is') - .access('querystring') - .access('idempotent') - .access('socket') - .access('length') - .access('query') - .access('search') - .access('status') - .access('method') - .access('path') - .access('body') - .access('host') - .access('url') - .getter('subdomains') - .getter('protocol') - .getter('header') - .getter('stale') - .getter('fresh') - .getter('secure') - .getter('ips') - .getter('ip') -``` - -# API - -## Delegate(proto, prop) - -Creates a delegator instance used to configure using the `prop` on the given -`proto` object. (which is usually a prototype) - -## Delegate#method(name) - -Allows the given method `name` to be accessed on the host. - -## Delegate#getter(name) - -Creates a "getter" for the property with the given `name` on the delegated -object. - -## Delegate#setter(name) - -Creates a "setter" for the property with the given `name` on the delegated -object. - -## Delegate#access(name) - -Creates an "accessor" (ie: both getter *and* setter) for the property with the -given `name` on the delegated object. - -## Delegate#fluent(name) - -A unique type of "accessor" that works for a "fluent" API. When called as a -getter, the method returns the expected value. However, if the method is called -with a value, it will return itself so it can be chained. For example: - -```js -delegate(proto, 'request') - .fluent('query') - -// getter -var q = request.query(); - -// setter (chainable) -request - .query({ a: 1 }) - .query({ b: 2 }); -``` - -# License - - MIT diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/index.js deleted file mode 100644 index 17c222d52935c6..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/index.js +++ /dev/null @@ -1,121 +0,0 @@ - -/** - * Expose `Delegator`. - */ - -module.exports = Delegator; - -/** - * Initialize a delegator. - * - * @param {Object} proto - * @param {String} target - * @api public - */ - -function Delegator(proto, target) { - if (!(this instanceof Delegator)) return new Delegator(proto, target); - this.proto = proto; - this.target = target; - this.methods = []; - this.getters = []; - this.setters = []; - this.fluents = []; -} - -/** - * Delegate method `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.method = function(name){ - var proto = this.proto; - var target = this.target; - this.methods.push(name); - - proto[name] = function(){ - return this[target][name].apply(this[target], arguments); - }; - - return this; -}; - -/** - * Delegator accessor `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.access = function(name){ - return this.getter(name).setter(name); -}; - -/** - * Delegator getter `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.getter = function(name){ - var proto = this.proto; - var target = this.target; - this.getters.push(name); - - proto.__defineGetter__(name, function(){ - return this[target][name]; - }); - - return this; -}; - -/** - * Delegator setter `name`. - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.setter = function(name){ - var proto = this.proto; - var target = this.target; - this.setters.push(name); - - proto.__defineSetter__(name, function(val){ - return this[target][name] = val; - }); - - return this; -}; - -/** - * Delegator fluent accessor - * - * @param {String} name - * @return {Delegator} self - * @api public - */ - -Delegator.prototype.fluent = function (name) { - var proto = this.proto; - var target = this.target; - this.fluents.push(name); - - proto[name] = function(val){ - if ('undefined' != typeof val) { - this[target][name] = val; - return this; - } else { - return this[target][name]; - } - }; - - return this; -}; diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/package.json deleted file mode 100644 index 8c2c0ef2c310d3..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/package.json +++ /dev/null @@ -1,96 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "delegates@^1.0.0", - "scope": null, - "escapedName": "delegates", - "name": "delegates", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/are-we-there-yet" - ], - [ - { - "raw": "delegates@^1.0.0", - "scope": null, - "escapedName": "delegates", - "name": "delegates", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet" - ] - ], - "_from": "delegates@^1.0.0", - "_id": "delegates@1.0.0", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/are-we-there-yet/delegates", - "_nodeVersion": "4.2.1", - "_npmUser": { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - "_npmVersion": "3.3.12", - "_phantomChildren": {}, - "_requested": { - "raw": "delegates@^1.0.0", - "scope": null, - "escapedName": "delegates", - "name": "delegates", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog/are-we-there-yet" - ], - "_resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", - "_shasum": "84c6e159b81904fdca59a0ef44cd870d31250f9a", - "_shrinkwrap": null, - "_spec": "delegates@^1.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet", - "bugs": { - "url": "https://github.com/visionmedia/node-delegates/issues" - }, - "dependencies": {}, - "description": "delegate methods and accessors to another property", - "devDependencies": { - "mocha": "*", - "should": "*" - }, - "directories": {}, - "dist": { - "shasum": "84c6e159b81904fdca59a0ef44cd870d31250f9a", - "tarball": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz" - }, - "gitHead": "c4dc07ef1ed51c2b2a63f3585e5ef949ee577a49", - "homepage": "https://github.com/visionmedia/node-delegates#readme", - "keywords": [ - "delegate", - "delegation" - ], - "license": "MIT", - "maintainers": [ - { - "name": "tjholowaychuk", - "email": "tj@vision-media.ca" - }, - { - "name": "dominicbarnes", - "email": "dominic@dbarnes.info" - } - ], - "name": "delegates", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/visionmedia/node-delegates.git" - }, - "scripts": {}, - "version": "1.0.0" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/test/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/test/index.js deleted file mode 100644 index 7b6e3d4df19d90..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates/test/index.js +++ /dev/null @@ -1,94 +0,0 @@ - -var assert = require('assert'); -var delegate = require('..'); - -describe('.method(name)', function(){ - it('should delegate methods', function(){ - var obj = {}; - - obj.request = { - foo: function(bar){ - assert(this == obj.request); - return bar; - } - }; - - delegate(obj, 'request').method('foo'); - - obj.foo('something').should.equal('something'); - }) -}) - -describe('.getter(name)', function(){ - it('should delegate getters', function(){ - var obj = {}; - - obj.request = { - get type() { - return 'text/html'; - } - } - - delegate(obj, 'request').getter('type'); - - obj.type.should.equal('text/html'); - }) -}) - -describe('.setter(name)', function(){ - it('should delegate setters', function(){ - var obj = {}; - - obj.request = { - get type() { - return this._type.toUpperCase(); - }, - - set type(val) { - this._type = val; - } - } - - delegate(obj, 'request').setter('type'); - - obj.type = 'hey'; - obj.request.type.should.equal('HEY'); - }) -}) - -describe('.access(name)', function(){ - it('should delegate getters and setters', function(){ - var obj = {}; - - obj.request = { - get type() { - return this._type.toUpperCase(); - }, - - set type(val) { - this._type = val; - } - } - - delegate(obj, 'request').access('type'); - - obj.type = 'hey'; - obj.type.should.equal('HEY'); - }) -}) - -describe('.fluent(name)', function () { - it('should delegate in a fluent fashion', function () { - var obj = { - settings: { - env: 'development' - } - }; - - delegate(obj, 'settings').fluent('env'); - - obj.env().should.equal('development'); - obj.env('production').should.equal(obj); - obj.settings.env.should.equal('production'); - }) -}) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/package.json deleted file mode 100644 index f4fba2ad433a2c..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/package.json +++ /dev/null @@ -1,102 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "are-we-there-yet@~1.1.2", - "scope": null, - "escapedName": "are-we-there-yet", - "name": "are-we-there-yet", - "rawSpec": "~1.1.2", - "spec": ">=1.1.2 <1.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog" - ], - [ - { - "raw": "are-we-there-yet@~1.1.2", - "scope": null, - "escapedName": "are-we-there-yet", - "name": "are-we-there-yet", - "rawSpec": "~1.1.2", - "spec": ">=1.1.2 <1.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog" - ] - ], - "_from": "are-we-there-yet@~1.1.2", - "_id": "are-we-there-yet@1.1.2", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/are-we-there-yet", - "_nodeVersion": "4.2.2", - "_npmOperationalInternal": { - "host": "packages-13-west.internal.npmjs.com", - "tmp": "tmp/are-we-there-yet-1.1.2.tgz_1458084397358_0.15847722673788667" - }, - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "_npmVersion": "3.8.1", - "_phantomChildren": {}, - "_requested": { - "raw": "are-we-there-yet@~1.1.2", - "scope": null, - "escapedName": "are-we-there-yet", - "name": "are-we-there-yet", - "rawSpec": "~1.1.2", - "spec": ">=1.1.2 <1.2.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog" - ], - "_resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz", - "_shasum": "80e470e95a084794fe1899262c5667c6e88de1b3", - "_shrinkwrap": null, - "_spec": "are-we-there-yet@~1.1.2", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog", - "author": { - "name": "Rebecca Turner", - "url": "http://re-becca.org" - }, - "bugs": { - "url": "https://github.com/iarna/are-we-there-yet/issues" - }, - "dependencies": { - "delegates": "^1.0.0", - "readable-stream": "^2.0.0 || ^1.1.13" - }, - "description": "Keep track of the overall completion of many dispirate processes", - "devDependencies": { - "standard": "^6.0.8", - "tap": "^5.7.0" - }, - "directories": {}, - "dist": { - "shasum": "80e470e95a084794fe1899262c5667c6e88de1b3", - "tarball": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.2.tgz" - }, - "gitHead": "dd5706e2204cb681e78031d0ffe156ed4cc75823", - "homepage": "https://github.com/iarna/are-we-there-yet", - "license": "ISC", - "main": "index.js", - "maintainers": [ - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "name": "are-we-there-yet", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/iarna/are-we-there-yet.git" - }, - "scripts": { - "test": "standard && tap test/*.js" - }, - "version": "1.1.2" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/lib/test-event.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/lib/test-event.js deleted file mode 100644 index 2aa7c05c5864fa..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/lib/test-event.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict' -var util = require('util') - -module.exports = function (obj, event, next) { - var timeout = setTimeout(gotTimeout, 10) - obj.once(event, gotResult) - - function gotTimeout () { - obj.removeListener(event, gotResult) - next(new Error('Timeout listening for ' + event)) - } - var result = [] - function gotResult () { - result = Array.prototype.slice.call(arguments) - clearTimeout(timeout) - timeout = setTimeout(gotNoMoreResults, 10) - obj.once(event, gotTooManyResults) - } - function gotNoMoreResults () { - obj.removeListener(event, gotTooManyResults) - var args = [null].concat(result) - next.apply(null, args) - } - function gotTooManyResults () { - var secondResult = Array.prototype.slice.call(arguments) - clearTimeout(timeout) - next(new Error('Got too many results, first ' + util.inspect(result) + ' and then ' + util.inspect(secondResult))) - } -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/tracker.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/tracker.js deleted file mode 100644 index 374c7739d0c011..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/tracker.js +++ /dev/null @@ -1,57 +0,0 @@ -'use strict' -var test = require('tap').test -var Tracker = require('../index.js').Tracker - -var testEvent = require('./lib/test-event.js') - -var name = 'test' - -test('initialization', function (t) { - var simple = new Tracker(name) - - t.is(simple.completed(), 0, 'Nothing todo is 0 completion') - t.done() -}) - -var track -var todo = 100 -test('completion', function (t) { - track = new Tracker(name, todo) - t.is(track.completed(), 0, 'Nothing done is 0 completion') - - testEvent(track, 'change', afterCompleteWork) - - track.completeWork(todo) - t.is(track.completed(), 1, 'completeWork: 100% completed') - - function afterCompleteWork (er, onChangeName) { - t.is(er, null, 'completeWork: on change event fired') - t.is(onChangeName, name, 'completeWork: on change emits the correct name') - t.done() - } -}) - -test('add more work', function (t) { - testEvent(track, 'change', afterAddWork) - track.addWork(todo) - t.is(track.completed(), 0.5, 'addWork: 50% completed') - function afterAddWork (er, onChangeName) { - t.is(er, null, 'addWork: on change event fired') - t.is(onChangeName, name, 'addWork: on change emits the correct name') - t.done() - } -}) - -test('complete more work', function (t) { - track.completeWork(200) - t.is(track.completed(), 1, 'completeWork: Over completion is still only 100% complete') - t.done() -}) - -test('finish is always 100%', function (t) { - var finishtest = new Tracker(name, todo) - finishtest.completeWork(50) - finishtest.finish() - t.is(finishtest.completed(), 1, 'finish: Explicitly finishing moves to 100%') - t.done() -}) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/trackergroup.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/trackergroup.js deleted file mode 100644 index 799a7670b65934..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/trackergroup.js +++ /dev/null @@ -1,96 +0,0 @@ -'use strict' -var test = require('tap').test -var TrackerGroup = require('../index.js').TrackerGroup -var testEvent = require('./lib/test-event.js') - -test('TrackerGroup', function (t) { - var name = 'test' - - var track = new TrackerGroup(name) - t.is(track.completed(), 0, 'Nothing todo is 0 completion') - testEvent(track, 'change', afterFinishEmpty) - track.finish() - var a, b - function afterFinishEmpty (er, onChangeName, completion) { - t.is(er, null, 'finishEmpty: on change event fired') - t.is(onChangeName, name, 'finishEmpty: on change emits the correct name') - t.is(completion, 1, 'finishEmpty: passed through completion was correct') - t.is(track.completed(), 1, 'finishEmpty: Finishing an empty group actually finishes it') - - track = new TrackerGroup(name) - a = track.newItem('a', 10, 1) - b = track.newItem('b', 10, 1) - t.is(track.completed(), 0, 'Initially empty') - testEvent(track, 'change', afterCompleteWork) - a.completeWork(5) - } - function afterCompleteWork (er, onChangeName, completion) { - t.is(er, null, 'on change event fired') - t.is(onChangeName, 'a', 'on change emits the correct name') - t.is(completion, 0.25, 'Complete half of one is a quarter overall') - t.is(track.completed(), 0.25, 'Complete half of one is a quarter overall') - testEvent(track, 'change', afterFinishAll) - track.finish() - } - function afterFinishAll (er, onChangeName, completion) { - t.is(er, null, 'finishAll: on change event fired') - t.is(onChangeName, name, 'finishAll: on change emits the correct name') - t.is(completion, 1, 'Finishing everything ') - t.is(track.completed(), 1, 'Finishing everything ') - - track = new TrackerGroup(name) - a = track.newItem('a', 10, 2) - b = track.newItem('b', 10, 1) - t.is(track.completed(), 0, 'weighted: Initially empty') - testEvent(track, 'change', afterWeightedCompleteWork) - a.completeWork(5) - } - function afterWeightedCompleteWork (er, onChangeName, completion) { - t.is(er, null, 'weighted: on change event fired') - t.is(onChangeName, 'a', 'weighted: on change emits the correct name') - t.is(Math.floor(completion * 100), 33, 'weighted: Complete half of double weighted') - t.is(Math.floor(track.completed() * 100), 33, 'weighted: Complete half of double weighted') - testEvent(track, 'change', afterWeightedFinishAll) - track.finish() - } - function afterWeightedFinishAll (er, onChangeName, completion) { - t.is(er, null, 'weightedFinishAll: on change event fired') - t.is(onChangeName, name, 'weightedFinishAll: on change emits the correct name') - t.is(completion, 1, 'weightedFinishaAll: Finishing everything ') - t.is(track.completed(), 1, 'weightedFinishaAll: Finishing everything ') - - track = new TrackerGroup(name) - a = track.newGroup('a', 10) - b = track.newGroup('b', 10) - var a1 = a.newItem('a.1', 10) - a1.completeWork(5) - t.is(track.completed(), 0.25, 'nested: Initially quarter done') - testEvent(track, 'change', afterNestedComplete) - b.finish() - } - function afterNestedComplete (er, onChangeName, completion) { - t.is(er, null, 'nestedComplete: on change event fired') - t.is(onChangeName, 'b', 'nestedComplete: on change emits the correct name') - t.is(completion, 0.75, 'nestedComplete: Finishing everything ') - t.is(track.completed(), 0.75, 'nestedComplete: Finishing everything ') - t.end() - } -}) - -test('cycles', function (t) { - var track = new TrackerGroup('top') - testCycle(track, track) - var layer1 = track.newGroup('layer1') - testCycle(layer1, track) - t.end() - - function testCycle (addTo, toAdd) { - try { - addTo.addUnit(toAdd) - t.fail(toAdd.name) - } catch (ex) { - console.log(ex) - t.pass(toAdd.name) - } - } -}) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/trackerstream.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/trackerstream.js deleted file mode 100644 index 65f04b03769190..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/test/trackerstream.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict' -var test = require('tap').test -var util = require('util') -var stream = require('readable-stream') -var TrackerStream = require('../index.js').TrackerStream -var testEvent = require('./lib/test-event.js') - -var Sink = function () { - stream.Writable.apply(this, arguments) -} -util.inherits(Sink, stream.Writable) -Sink.prototype._write = function (data, encoding, cb) { - cb() -} - -test('TrackerStream', function (t) { - t.plan(9) - - var name = 'test' - var track = new TrackerStream(name) - - t.is(track.completed(), 0, 'Nothing todo is 0 completion') - - var todo = 10 - track = new TrackerStream(name, todo) - t.is(track.completed(), 0, 'Nothing done is 0 completion') - - track.pipe(new Sink()) - - testEvent(track, 'change', afterCompleteWork) - track.write('0123456789') - function afterCompleteWork (er, onChangeName) { - t.is(er, null, 'write: on change event fired') - t.is(onChangeName, name, 'write: on change emits the correct name') - t.is(track.completed(), 1, 'write: 100% completed') - - testEvent(track, 'change', afterAddWork) - track.addWork(10) - } - function afterAddWork (er, onChangeName) { - t.is(er, null, 'addWork: on change event fired') - t.is(track.completed(), 0.5, 'addWork: 50% completed') - - testEvent(track, 'change', afterAllWork) - track.write('ABCDEFGHIJKLMNOPQRST') - } - function afterAllWork (er) { - t.is(er, null, 'allWork: on change event fired') - t.is(track.completed(), 1, 'allWork: 100% completed') - } -}) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker-base.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker-base.js deleted file mode 100644 index 6f436875578a7a..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker-base.js +++ /dev/null @@ -1,11 +0,0 @@ -'use strict' -var EventEmitter = require('events').EventEmitter -var util = require('util') - -var trackerId = 0 -var TrackerBase = module.exports = function (name) { - EventEmitter.call(this) - this.id = ++trackerId - this.name = name -} -util.inherits(TrackerBase, EventEmitter) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js deleted file mode 100644 index 9759e1226db046..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker-group.js +++ /dev/null @@ -1,107 +0,0 @@ -'use strict' -var util = require('util') -var TrackerBase = require('./tracker-base.js') -var Tracker = require('./tracker.js') -var TrackerStream = require('./tracker-stream.js') - -var TrackerGroup = module.exports = function (name) { - TrackerBase.call(this, name) - this.parentGroup = null - this.trackers = [] - this.completion = {} - this.weight = {} - this.totalWeight = 0 - this.finished = false - this.bubbleChange = bubbleChange(this) -} -util.inherits(TrackerGroup, TrackerBase) - -function bubbleChange (trackerGroup) { - return function (name, completed, tracker) { - trackerGroup.completion[tracker.id] = completed - if (trackerGroup.finished) return - trackerGroup.emit('change', name || trackerGroup.name, trackerGroup.completed(), trackerGroup) - } -} - -TrackerGroup.prototype.nameInTree = function () { - var names = [] - var from = this - while (from) { - names.unshift(from.name) - from = from.parentGroup - } - return names.join('/') -} - -TrackerGroup.prototype.addUnit = function (unit, weight) { - if (unit.addUnit) { - var toTest = this - while (toTest) { - if (unit === toTest) { - throw new Error( - 'Attempted to add tracker group ' + - unit.name + ' to tree that already includes it ' + - this.nameInTree(this)) - } - toTest = toTest.parentGroup - } - unit.parentGroup = this - } - this.weight[unit.id] = weight || 1 - this.totalWeight += this.weight[unit.id] - this.trackers.push(unit) - this.completion[unit.id] = unit.completed() - unit.on('change', this.bubbleChange) - if (!this.finished) this.emit('change', unit.name, this.completion[unit.id], unit) - return unit -} - -TrackerGroup.prototype.completed = function () { - if (this.trackers.length === 0) return 0 - var valPerWeight = 1 / this.totalWeight - var completed = 0 - for (var ii = 0; ii < this.trackers.length; ii++) { - var trackerId = this.trackers[ii].id - completed += valPerWeight * this.weight[trackerId] * this.completion[trackerId] - } - return completed -} - -TrackerGroup.prototype.newGroup = function (name, weight) { - return this.addUnit(new TrackerGroup(name), weight) -} - -TrackerGroup.prototype.newItem = function (name, todo, weight) { - return this.addUnit(new Tracker(name, todo), weight) -} - -TrackerGroup.prototype.newStream = function (name, todo, weight) { - return this.addUnit(new TrackerStream(name, todo), weight) -} - -TrackerGroup.prototype.finish = function () { - this.finished = true - if (!this.trackers.length) this.addUnit(new Tracker(), 1, true) - for (var ii = 0; ii < this.trackers.length; ii++) { - var tracker = this.trackers[ii] - tracker.finish() - tracker.removeListener('change', this.bubbleChange) - } - this.emit('change', this.name, 1, this) -} - -var buffer = ' ' -TrackerGroup.prototype.debug = function (depth) { - depth = depth || 0 - var indent = depth ? buffer.substr(0, depth) : '' - var output = indent + (this.name || 'top') + ': ' + this.completed() + '\n' - this.trackers.forEach(function (tracker) { - if (tracker instanceof TrackerGroup) { - output += tracker.debug(depth + 1) - } else { - output += indent + ' ' + tracker.name + ': ' + tracker.completed() + '\n' - } - }) - return output -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js deleted file mode 100644 index fb9598ed4e9c31..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker-stream.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict' -var util = require('util') -var stream = require('readable-stream') -var delegate = require('delegates') -var Tracker = require('./tracker.js') - -var TrackerStream = module.exports = function (name, size, options) { - stream.Transform.call(this, options) - this.tracker = new Tracker(name, size) - this.name = name - this.id = this.tracker.id - this.tracker.on('change', delegateChange(this)) -} -util.inherits(TrackerStream, stream.Transform) - -function delegateChange (trackerStream) { - return function (name, completion, tracker) { - trackerStream.emit('change', name, completion, trackerStream) - } -} - -TrackerStream.prototype._transform = function (data, encoding, cb) { - this.tracker.completeWork(data.length ? data.length : 1) - this.push(data) - cb() -} - -TrackerStream.prototype._flush = function (cb) { - this.tracker.finish() - cb() -} - -delegate(TrackerStream.prototype, 'tracker') - .method('completed') - .method('addWork') diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker.js deleted file mode 100644 index 68c2339b45409a..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/are-we-there-yet/tracker.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict' -var util = require('util') -var TrackerBase = require('./tracker-base.js') - -var Tracker = module.exports = function (name, todo) { - TrackerBase.call(this, name) - this.workDone = 0 - this.workTodo = todo || 0 -} -util.inherits(Tracker, TrackerBase) - -Tracker.prototype.completed = function () { - return this.workTodo === 0 ? 0 : this.workDone / this.workTodo -} - -Tracker.prototype.addWork = function (work) { - this.workTodo += work - this.emit('change', this.name, this.completed(), this) -} - -Tracker.prototype.completeWork = function (work) { - this.workDone += work - if (this.workDone > this.workTodo) this.workDone = this.workTodo - this.emit('change', this.name, this.completed(), this) -} - -Tracker.prototype.finish = function () { - this.workTodo = this.workDone = 1 - this.emit('change', this.name, 1, this) -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/LICENSE b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/LICENSE deleted file mode 100644 index e756052969b780..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2014, Rebecca Turner - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/README.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/README.md deleted file mode 100644 index f58cc8d8925060..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/README.md +++ /dev/null @@ -1,145 +0,0 @@ -# Console Control Strings - -A library of cross-platform tested terminal/console command strings for -doing things like color and cursor positioning. This is a subset of both -ansi and vt100. All control codes included work on both Windows & Unix-like -OSes, except where noted. - -## Usage - -```js -var consoleControl = require('console-control-strings') - -console.log(consoleControl.color('blue','bgRed', 'bold') + 'hi there' + consoleControl.color('reset')) -process.stdout.write(consoleControl.goto(75, 10)) -``` - -## Why Another? - -There are tons of libraries similar to this one. I wanted one that was: - -1. Very clear about compatibility goals. -2. Could emit, for instance, a start color code without an end one. -3. Returned strings w/o writing to streams. -4. Was not weighed down with other unrelated baggage. - -## Functions - -### var code = consoleControl.up(_num = 1_) - -Returns the escape sequence to move _num_ lines up. - -### var code = consoleControl.down(_num = 1_) - -Returns the escape sequence to move _num_ lines down. - -### var code = consoleControl.forward(_num = 1_) - -Returns the escape sequence to move _num_ lines righ. - -### var code = consoleControl.back(_num = 1_) - -Returns the escape sequence to move _num_ lines left. - -### var code = consoleControl.nextLine(_num = 1_) - -Returns the escape sequence to move _num_ lines down and to the beginning of -the line. - -### var code = consoleControl.previousLine(_num = 1_) - -Returns the escape sequence to move _num_ lines up and to the beginning of -the line. - -### var code = consoleControl.eraseData() - -Returns the escape sequence to erase everything from the current cursor -position to the bottom right of the screen. This is line based, so it -erases the remainder of the current line and all following lines. - -### var code = consoleControl.eraseLine() - -Returns the escape sequence to erase to the end of the current line. - -### var code = consoleControl.goto(_x_, _y_) - -Returns the escape sequence to move the cursor to the designated position. -Note that the origin is _1, 1_ not _0, 0_. - -### var code = consoleControl.gotoSOL() - -Returns the escape sequence to move the cursor to the beginning of the -current line. (That is, it returns a carriage return, `\r`.) - -### var code = consoleControl.beep() - -Returns the escape sequence to cause the termianl to beep. (That is, it -returns unicode character `\x0007`, a Control-G.) - -### var code = consoleControl.hideCursor() - -Returns the escape sequence to hide the cursor. - -### var code = consoleControl.showCursor() - -Returns the escape sequence to show the cursor. - -### var code = consoleControl.color(_colors = []_) - -### var code = consoleControl.color(_color1_, _color2_, _…_, _colorn_) - -Returns the escape sequence to set the current terminal display attributes -(mostly colors). Arguments can either be a list of attributes or an array -of attributes. The difference between passing in an array or list of colors -and calling `.color` separately for each one, is that in the former case a -single escape sequence will be produced where as in the latter each change -will have its own distinct escape sequence. Each attribute can be one of: - -* Reset: - * **reset** – Reset all attributes to the terminal default. -* Styles: - * **bold** – Display text as bold. In some terminals this means using a - bold font, in others this means changing the color. In some it means - both. - * **italic** – Display text as italic. This is not available in most Windows terminals. - * **underline** – Underline text. This is not available in most Windows Terminals. - * **inverse** – Invert the foreground and background colors. - * **stopBold** – Do not display text as bold. - * **stopItalic** – Do not display text as italic. - * **stopUnderline** – Do not underline text. - * **stopInverse** – Do not invert foreground and background. -* Colors: - * **white** - * **black** - * **blue** - * **cyan** - * **green** - * **magenta** - * **red** - * **yellow** - * **grey** / **brightBlack** - * **brightRed** - * **brightGreen** - * **brightYellow** - * **brightBlue** - * **brightMagenta** - * **brightCyan** - * **brightWhite** -* Background Colors: - * **bgWhite** - * **bgBlack** - * **bgBlue** - * **bgCyan** - * **bgGreen** - * **bgMagenta** - * **bgRed** - * **bgYellow** - * **bgGrey** / **bgBrightBlack** - * **bgBrightRed** - * **bgBrightGreen** - * **bgBrightYellow** - * **bgBrightBlue** - * **bgBrightMagenta** - * **bgBrightCyan** - * **bgBrightWhite** - diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/index.js deleted file mode 100644 index bf890348ec6e35..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/index.js +++ /dev/null @@ -1,125 +0,0 @@ -'use strict' - -// These tables borrowed from `ansi` - -var prefix = '\x1b[' - -exports.up = function up (num) { - return prefix + (num || '') + 'A' -} - -exports.down = function down (num) { - return prefix + (num || '') + 'B' -} - -exports.forward = function forward (num) { - return prefix + (num || '') + 'C' -} - -exports.back = function back (num) { - return prefix + (num || '') + 'D' -} - -exports.nextLine = function nextLine (num) { - return prefix + (num || '') + 'E' -} - -exports.previousLine = function previousLine (num) { - return prefix + (num || '') + 'F' -} - -exports.horizontalAbsolute = function horizontalAbsolute (num) { - if (num == null) throw new Error('horizontalAboslute requires a column to position to') - return prefix + num + 'G' -} - -exports.eraseData = function eraseData () { - return prefix + 'J' -} - -exports.eraseLine = function eraseLine () { - return prefix + 'K' -} - -exports.goto = function (x, y) { - return prefix + y + ';' + x + 'H' -} - -exports.gotoSOL = function () { - return '\r' -} - -exports.beep = function () { - return '\x07' -} - -exports.hideCursor = function hideCursor () { - return prefix + '?25l' -} - -exports.showCursor = function showCursor () { - return prefix + '?25h' -} - -var colors = { - reset: 0, -// styles - bold: 1, - italic: 3, - underline: 4, - inverse: 7, -// resets - stopBold: 22, - stopItalic: 23, - stopUnderline: 24, - stopInverse: 27, -// colors - white: 37, - black: 30, - blue: 34, - cyan: 36, - green: 32, - magenta: 35, - red: 31, - yellow: 33, - bgWhite: 47, - bgBlack: 40, - bgBlue: 44, - bgCyan: 46, - bgGreen: 42, - bgMagenta: 45, - bgRed: 41, - bgYellow: 43, - - grey: 90, - brightBlack: 90, - brightRed: 91, - brightGreen: 92, - brightYellow: 93, - brightBlue: 94, - brightMagenta: 95, - brightCyan: 96, - brightWhite: 97, - - bgGrey: 100, - bgBrightBlack: 100, - bgBrightRed: 101, - bgBrightGreen: 102, - bgBrightYellow: 103, - bgBrightBlue: 104, - bgBrightMagenta: 105, - bgBrightCyan: 106, - bgBrightWhite: 107 -} - -exports.color = function color (colorWith) { - if (arguments.length !== 1 || !Array.isArray(colorWith)) { - colorWith = Array.prototype.slice.call(arguments) - } - return prefix + colorWith.map(colorNameToCode).join(';') + 'm' -} - -function colorNameToCode (color) { - if (colors[color] != null) return colors[color] - throw new Error('Unknown color or style name: ' + color) -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/package.json deleted file mode 100644 index a76eecadec37e9..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/console-control-strings/package.json +++ /dev/null @@ -1,108 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "console-control-strings@~1.1.0", - "scope": null, - "escapedName": "console-control-strings", - "name": "console-control-strings", - "rawSpec": "~1.1.0", - "spec": ">=1.1.0 <1.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog" - ], - [ - { - "raw": "console-control-strings@~1.1.0", - "scope": null, - "escapedName": "console-control-strings", - "name": "console-control-strings", - "rawSpec": "~1.1.0", - "spec": ">=1.1.0 <1.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog" - ] - ], - "_from": "console-control-strings@~1.1.0", - "_id": "console-control-strings@1.1.0", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/console-control-strings", - "_nodeVersion": "4.4.0", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/console-control-strings-1.1.0.tgz_1466033396831_0.9470485949423164" - }, - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "_npmVersion": "3.9.2", - "_phantomChildren": {}, - "_requested": { - "raw": "console-control-strings@~1.1.0", - "scope": null, - "escapedName": "console-control-strings", - "name": "console-control-strings", - "rawSpec": "~1.1.0", - "spec": ">=1.1.0 <1.2.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog", - "/npm-registry-client/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", - "_shasum": "3d7cf4464db6446ea644bf4b39507f9851008e8e", - "_shrinkwrap": null, - "_spec": "console-control-strings@~1.1.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog", - "author": { - "name": "Rebecca Turner", - "email": "me@re-becca.org", - "url": "http://re-becca.org/" - }, - "bugs": { - "url": "https://github.com/iarna/console-control-strings/issues" - }, - "dependencies": {}, - "description": "A library of cross-platform tested terminal/console command strings for doing things like color and cursor positioning. This is a subset of both ansi and vt100. All control codes included work on both Windows & Unix-like OSes, except where noted.", - "devDependencies": { - "standard": "^7.1.2", - "tap": "^5.7.2" - }, - "directories": { - "test": "test" - }, - "dist": { - "shasum": "3d7cf4464db6446ea644bf4b39507f9851008e8e", - "tarball": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz" - }, - "files": [ - "LICENSE", - "index.js" - ], - "gitHead": "722439b4998d2964ac3d3f9ec175c008aa9b7b4b", - "homepage": "https://github.com/iarna/console-control-strings#readme", - "keywords": [], - "license": "ISC", - "main": "index.js", - "maintainers": [ - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "name": "console-control-strings", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/iarna/console-control-strings.git" - }, - "scripts": { - "test": "standard && tap test/*.js" - }, - "version": "1.1.0" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/CHANGELOG.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/CHANGELOG.md deleted file mode 100644 index efd08fc7c19dd7..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/CHANGELOG.md +++ /dev/null @@ -1,131 +0,0 @@ -### v2.6.0 - -* Bug fix: Don't run the code associated with `enable`/`disable` if the gauge - is already enabled or disabled respectively. This prevents leaking event - listeners, amongst other weirdness. -* New feature: Template items can have default values that will be used if no - value was otherwise passed in. - -### v2.5.3 - -* Default to `enabled` only if we have a tty. Users can always override - this by passing in the `enabled` option explicitly or by calling calling - `gauge.enable()`. - -### v2.5.2 - -* Externalized `./console-strings.js` into `console-control-strings`. - -### v2.5.1 - -* Update to `signal-exit@3.0.0`, which fixes a compatibility bug with the - node profiler. -* [#39](https://github.com/iarna/gauge/pull/39) Fix tests on 0.10 and add - a missing devDependency. ([@helloyou2012](https://github.com/helloyou2012)) - -### v2.5.0 - -* Add way to programmatically fetch a list of theme names in a themeset - (`Themeset.getThemeNames`). - -### v2.4.0 - -* Add support for setting themesets on existing gauge objects. -* Add post-IO callback to `gauge.hide()` as it is somtetimes necessary when - your terminal is interleaving output from multiple filehandles (ie, stdout - & stderr). - -### v2.3.1 - -* Fix a refactor bug in setTheme where it wasn't accepting the various types - of args it should. - -### v2.3.0 - -#### FEATURES - -* Add setTemplate & setTheme back in. -* Add support for named themes, you can now ask for things like 'colorASCII' - and 'brailleSpinner'. Of course, you can still pass in theme objects. - Additionally you can now pass in an object with `hasUnicode`, `hasColor` and - `platform` keys in order to override our guesses as to those values when - selecting a default theme from the themeset. -* Make the output stream optional (it defaults to `process.stderr` now). -* Add `setWriteTo(stream[, tty])` to change the output stream and, - optionally, tty. - -#### BUG FIXES & REFACTORING - -* Abort the display phase early if we're supposed to be hidden and we are. -* Stop printing a bunch of spaces at the end of lines, since we're already - using an erase-to-end-of-line code anyway. -* The unicode themes were missing the subsection separator. - -### v2.2.1 - -* Fix image in readme - -### v2.2.0 - -* All new themes API– reference themes by name and pass in custom themes and - themesets (themesets get platform support autodetection done on them to - select the best theme). Theme mixins let you add features to all existing - themes. -* Much, much improved test coverage. - -### v2.1.0 - -* Got rid of ░ in the default platform, noUnicode, hasColor theme. Thanks - to @yongtw123 for pointing out this had snuck in. -* Fiddled with the demo output to make it easier to see the spinner spin. Also - added prints before each platforms test output. -* I forgot to include `signal-exit` in our deps. <.< Thank you @KenanY for - finding this. Then I was lazy and made a new commit instead of using his - PR. Again, thank you for your patience @KenenY. -* Drastically speed up travis testing. -* Add a small javascript demo (demo.js) for showing off the various themes - (and testing them on diff platforms). -* Change: The subsection separator from ⁄ and / (different chars) to >. -* Fix crasher: A show or pulse without a label would cause the template renderer - to complain about a missing value. -* New feature: Add the ability to disable the clean-up-on-exit behavior. - Not something I expect to be widely desirable, but important if you have - multiple distinct gauge instances in your app. -* Use our own color support detection. - The `has-color` module proved too magic for my needs, making assumptions - as to which stream we write to and reading command line arguments. - -### v2.0.0 - -This is a major rewrite of the internals. Externally there are fewer -changes: - -* On node>0.8 gauge object now prints updates at a fixed rate. This means - that when you call `show` it may wate up to `updateInterval` ms before it - actually prints an update. You override this behavior with the - `fixedFramerate` option. -* The gauge object now keeps the cursor hidden as long as it's enabled and - shown. -* The constructor's arguments have changed, now it takes a mandatory output - stream and an optional options object. The stream no longer needs to be - an `ansi`ified stream, although it can be if you want (but we won't make - use of its special features). -* Previously the gauge was disabled by default if `process.stdout` wasn't a - tty. Now it always defaults to enabled. If you want the previous - behavior set the `enabled` option to `process.stdout.isTTY`. -* The constructor's options have changed– see the docs for details. -* Themes are entirely different. If you were using a custom theme, or - referring to one directly (eg via `Gauge.unicode` or `Gauge.ascii`) then - you'll need to change your code. You can get the equivalent of the latter - with: - ``` - var themes = require('gauge/themes') - var unicodeTheme = themes(true, true) // returns the color unicode theme for your platform - ``` - The default themes no longer use any ambiguous width characters, so even - if you choose to display those as wide your progress bar should still - display correctly. -* Templates are entirely different and if you were using a custom one, you - should consult the documentation to learn how to recreate it. If you were - using the default, be aware that it has changed and the result looks quite - a bit different. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/LICENSE b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/LICENSE deleted file mode 100644 index e756052969b780..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/LICENSE +++ /dev/null @@ -1,13 +0,0 @@ -Copyright (c) 2014, Rebecca Turner - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/README.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/README.md deleted file mode 100644 index bf87d189f1b5c1..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/README.md +++ /dev/null @@ -1,395 +0,0 @@ -gauge -===== - -A nearly stateless terminal based horizontal gauge / progress bar. - -```javascript -var Gauge = require("gauge") - -var gauge = new Gauge() - -gauge.show("test", 0.20) - -gauge.pulse("this") - -gauge.hide() -``` - -![](gauge-demo.gif) - - -### CHANGES FROM 1.x - -Gauge 2.x is breaking release, please see the [changelog] for details on -what's changed if you were previously a user of this module. - -[changelog]: CHANGELOG.md - -### THE GAUGE CLASS - -This is the typical interface to the module– it provides a pretty -fire-and-forget interface to displaying your status information. - -``` -var Gauge = require("gauge") - -var gauge = new Gauge([stream], [options]) -``` - -* **stream** – *(optional, default STDERR)* A stream that progress bar - updates are to be written to. Gauge honors backpressure and will pause - most writing if it is indicated. -* **options** – *(optional)* An option object. - -Constructs a new gauge. Gauges are drawn on a single line, and are not drawn -if **stream** isn't a tty and a tty isn't explicitly provided. - -If **stream** is a terminal or if you pass in **tty** to **options** then we -will detect terminal resizes and redraw to fit. We do this by watching for -`resize` events on the tty. (To work around a bug in verisons of Node prior -to 2.5.0, we watch for them on stdout if the tty is stderr.) Resizes to -larger window sizes will be clean, but shrinking the window will always -result in some cruft. - -**IMPORTANT:** If you prevously were passing in a non-tty stream but you still -want output (for example, a stream wrapped by the `ansi` module) then you -need to pass in the **tty** option below, as `gauge` needs access to -the underlying tty in order to do things like terminal resizes and terminal -width detection. - -The **options** object can have the following properties, all of which are -optional: - -* **updateInterval**: How often gauge updates should be drawn, in miliseconds. -* **fixedFramerate**: Defaults to false on node 0.8, true on everything - else. When this is true a timer is created to trigger once every - `updateInterval` ms, when false, updates are printed as soon as they come - in but updates more often than `updateInterval` are ignored. The reason - 0.8 doesn't have this set to true is that it can't `unref` its timer and - so it would stop your program from exiting– if you want to use this - feature with 0.8 just make sure you call `gauge.disable()` before you - expect your program to exit. -* **themes**: A themeset to use when selecting the theme to use. Defaults - to `gauge/themes`, see the [themes] documentation for details. -* **theme**: Select a theme for use, it can be a: - * Theme object, in which case the **themes** is not used. - * The name of a theme, which will be looked up in the current *themes* - object. - * A configuration object with any of `hasUnicode`, `hasColor` or - `platform` keys, which if wlll be used to override our guesses when making - a default theme selection. - - If no theme is selected then a default is picked using a combination of our - best guesses at your OS, color support and unicode support. -* **template**: Describes what you want your gauge to look like. The - default is what npm uses. Detailed [documentation] is later in this - document. -* **hideCursor**: Defaults to true. If true, then the cursor will be hidden - while the gauge is displayed. -* **tty**: The tty that you're ultimately writing to. Defaults to the same - as **stream**. This is used for detecting the width of the terminal and - resizes. The width used is `tty.columns - 1`. If no tty is available then - a width of `79` is assumed. -* **enabled**: Defaults to true if `tty` is a TTY, false otherwise. If true - the gauge starts enabled. If disabled then all update commands are - ignored and no gauge will be printed until you call `.enable()`. -* **Plumbing**: The class to use to actually generate the gauge for - printing. This defaults to `require('gauge/plumbing')` and ordinarly you - shouldn't need to override this. -* **cleanupOnExit**: Defaults to true. Ordinarily we register an exit - handler to make sure your cursor is turned back on and the progress bar - erased when your process exits, even if you Ctrl-C out or otherwise exit - unexpectedly. You can disable this and it won't register the exit handler. - -[has-unicode]: https://www.npmjs.com/package/has-unicode -[themes]: #themes -[documentation]: #templates - -#### `gauge.show(section | status, [completed])` - -The first argument is either the section, the name of the current thing -contributing to progress, or an object with keys like **section**, -**subsection** & **completed** (or any others you have types for in a custom -template). If you don't want to update or set any of these you can pass -`null` and it will be ignored. - -The second argument is the percent completed as a value between 0 and 1. -Without it, completion is just not updated. You'll also note that completion -can be passed in as part of a status object as the first argument. If both -it and the completed argument are passed in, the completed argument wins. - -#### `gauge.hide([cb])` - -Removes the gauge from the terminal. Optionally, callback `cb` after IO has -had an opportunity to happen (currently this just means after `setImmediate` -has called back.) - -It turns out this is important when you're pausing the progress bar on one -filehandle and printing to another– otherwise (with a big enough print) node -can end up printing the "end progress bar" bits to the progress bar filehandle -while other stuff is printing to another filehandle. These getting interleaved -can cause corruption in some terminals. - -#### `gauge.pulse([subsection])` - -* **subsection** – *(optional)* The specific thing that triggered this pulse - -Spins the spinner in the gauge to show output. If **subsection** is -included then it will be combined with the last name passed to `gauge.show`. - -#### `gauge.disable()` - -Hides the gauge and ignores further calls to `show` or `pulse`. - -#### `gauge.enable()` - -Shows the gauge and resumes updating when `show` or `pulse` is called. - -#### `gauge.setThemeset(themes)` - -Change the themeset to select a theme from. The same as the `themes` option -used in the constructor. The theme will be reselected from this themeset. - -#### `gauge.setTheme(theme)` - -Change the active theme, will be displayed with the next show or pulse. This can be: - -* Theme object, in which case the **themes** is not used. -* The name of a theme, which will be looked up in the current *themes* - object. -* A configuration object with any of `hasUnicode`, `hasColor` or - `platform` keys, which if wlll be used to override our guesses when making - a default theme selection. - -If no theme is selected then a default is picked using a combination of our -best guesses at your OS, color support and unicode support. - -#### `gauge.setTemplate(template)` - -Change the active template, will be displayed with the next show or pulse - -### Tracking Completion - -If you have more than one thing going on that you want to track completion -of, you may find the related [are-we-there-yet] helpful. It's `change` -event can be wired up to the `show` method to get a more traditional -progress bar interface. - -[are-we-there-yet]: https://www.npmjs.com/package/are-we-there-yet - -### THEMES - -``` -var themes = require('gauge/themes') - -// fetch the default color unicode theme for this platform -var ourTheme = themes({hasUnicode: true, hasColor: true}) - -// fetch the default non-color unicode theme for osx -var ourTheme = themes({hasUnicode: true, hasColor: false, platform: 'darwin'}) - -// create a new theme based on the color ascii theme for this platform -// that brackets the progress bar with arrows -var ourTheme = themes.newTheme(theme(hasUnicode: false, hasColor: true}), { - preProgressbar: '→', - postProgressbar: '←' -}) -``` - -The object returned by `gauge/themes` is an instance of the `ThemeSet` class. - -``` -var ThemeSet = require('gauge/theme-set') -var themes = new ThemeSet() -// or -var themes = require('gauge/themes') -var mythemes = themes.newThemeset() // creates a new themeset based on the default themes -``` - -#### themes(opts) -#### themes.getDefault(opts) - -Theme objects are a function that fetches the default theme based on -platform, unicode and color support. - -Options is an object with the following properties: - -* **hasUnicode** - If true, fetch a unicode theme, if no unicode theme is - available then a non-unicode theme will be used. -* **hasColor** - If true, fetch a color theme, if no color theme is - available a non-color theme will be used. -* **platform** (optional) - Defaults to `process.platform`. If no - platform match is available then `fallback` is used instead. - -If no compatible theme can be found then an error will be thrown with a -`code` of `EMISSINGTHEME`. - -#### themes.addTheme(themeName, themeObj) -#### themes.addTheme(themeName, [parentTheme], newTheme) - -Adds a named theme to the themeset. You can pass in either a theme object, -as returned by `themes.newTheme` or the arguments you'd pass to -`themes.newTheme`. - -#### themes.getThemeNames() - -Return a list of all of the names of the themes in this themeset. Suitable -for use in `themes.getTheme(…)`. - -#### themes.getTheme(name) - -Returns the theme object from this theme set named `name`. - -If `name` does not exist in this themeset an error will be thrown with -a `code` of `EMISSINGTHEME`. - -#### themes.setDefault([opts], themeName) - -`opts` is an object with the following properties. - -* **platform** - Defaults to `'fallback'`. If your theme is platform - specific, specify that here with the platform from `process.platform`, eg, - `win32`, `darwin`, etc. -* **hasUnicode** - Defaults to `false`. If your theme uses unicode you - should set this to true. -* **hasColor** - Defaults to `false`. If your theme uses color you should - set this to true. - -`themeName` is the name of the theme (as given to `addTheme`) to use for -this set of `opts`. - -#### themes.newTheme([parentTheme,] newTheme) - -Create a new theme object based on `parentTheme`. If no `parentTheme` is -provided then a minimal parentTheme that defines functions for rendering the -activity indicator (spinner) and progress bar will be defined. (This -fallback parent is defined in `gauge/base-theme`.) - -newTheme should be a bare object– we'll start by discussing the properties -defined by the default themes: - -* **preProgressbar** - displayed prior to the progress bar, if the progress - bar is displayed. -* **postProgressbar** - displayed after the progress bar, if the progress bar - is displayed. -* **progressBarTheme** - The subtheme passed through to the progress bar - renderer, it's an object with `complete` and `remaining` properties - that are the strings you want repeated for those sections of the progress - bar. -* **activityIndicatorTheme** - The theme for the activity indicator (spinner), - this can either be a string, in which each character is a different step, or - an array of strings. -* **preSubsection** - Displayed as a separator between the `section` and - `subsection` when the latter is printed. - -More generally, themes can have any value that would be a valid value when rendering -templates. The properties in the theme are used when their name matches a type in -the template. Their values can be: - -* **strings & numbers** - They'll be included as is -* **function (values, theme, width)** - Should return what you want in your output. - *values* is an object with values provided via `gauge.show`, - *theme* is the theme specific to this item (see below) or this theme object, - and *width* is the number of characters wide your result should be. - -There are a couple of special prefixes: - -* **pre** - Is shown prior to the property, if its displayed. -* **post** - Is shown after the property, if its displayed. - -And one special suffix: - -* **Theme** - Its value is passed to a function-type item as the theme. - -#### themes.addToAllThemes(theme) - -This *mixes-in* `theme` into all themes currently defined. It also adds it -to the default parent theme for this themeset, so future themes added to -this themeset will get the values from `theme` by default. - -#### themes.newThemeset() - -Copy the current themeset into a new one. This allows you to easily inherit -one themeset from another. - -### TEMPLATES - -A template is an array of objects and strings that, after being evaluated, -will be turned into the gauge line. The default template is: - -```javascript -[ - {type: 'progressbar', length: 20}, - {type: 'activityIndicator', kerning: 1, length: 1}, - {type: 'section', kerning: 1, default: ''}, - {type: 'subsection', kerning: 1, default: ''} -] -``` - -The various template elements can either be **plain strings**, in which case they will -be be included verbatum in the output, or objects with the following properties: - -* *type* can be any of the following plus any keys you pass into `gauge.show` plus - any keys you have on a custom theme. - * `section` – What big thing you're working on now. - * `subsection` – What component of that thing is currently working. - * `activityIndicator` – Shows a spinner using the `activityIndicatorTheme` - from your active theme. - * `progressbar` – A progress bar representing your current `completed` - using the `progressbarTheme` from your active theme. -* *kerning* – Number of spaces that must be between this item and other - items, if this item is displayed at all. -* *maxLength* – The maximum length for this element. If its value is longer it - will be truncated. -* *minLength* – The minimum length for this element. If its value is shorter it - will be padded according to the *align* value. -* *align* – (Default: left) Possible values "left", "right" and "center". Works - as you'd expect from word processors. -* *length* – Provides a single value for both *minLength* and *maxLength*. If both - *length* and *minLength or *maxLength* are specifed then the latter take precedence. -* *value* – A literal value to use for this template item. -* *default* – A default value to use for this template item if a value - wasn't otherwise passed in. - -### PLUMBING - -This is the super simple, assume nothing, do no magic internals used by gauge to -implement its ordinary interface. - -``` -var Plumbing = require('gauge/plumbing') -var gauge = new Plumbing(theme, template, width) -``` - -* **theme**: The theme to use. -* **template**: The template to use. -* **width**: How wide your gauge should be - -#### `gauge.setTheme(theme)` - -Change the active theme. - -#### `gauge.setTemplate(template)` - -Change the active template. - -#### `gauge.setWidth(width)` - -Change the width to render at. - -#### `gauge.hide()` - -Return the string necessary to hide the progress bar - -#### `gauge.hideCursor()` - -Return a string to hide the cursor. - -#### `gauge.showCursor()` - -Return a string to show the cursor. - -#### `gauge.show(status)` - -Using `status` for values, render the provided template with the theme and return -a string that is suitable for printing to update the gauge. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/base-theme.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/base-theme.js deleted file mode 100644 index 0b67638e0211d0..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/base-theme.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict' -var spin = require('./spin.js') -var progressBar = require('./progress-bar.js') - -module.exports = { - activityIndicator: function (values, theme, width) { - if (values.spun == null) return - return spin(theme, values.spun) - }, - progressbar: function (values, theme, width) { - if (values.completed == null) return - return progressBar(theme, width, values.completed) - } -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/error.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/error.js deleted file mode 100644 index d9914ba5335d25..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/error.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict' -var util = require('util') - -var User = exports.User = function User (msg) { - var err = new Error(msg) - Error.captureStackTrace(err, User) - err.code = 'EGAUGE' - return err -} - -exports.MissingTemplateValue = function MissingTemplateValue (item, values) { - var err = new User(util.format('Missing template value "%s"', item.type)) - Error.captureStackTrace(err, MissingTemplateValue) - err.template = item - err.values = values - return err -} - -exports.Internal = function Internal (msg) { - var err = new Error(msg) - Error.captureStackTrace(err, Internal) - err.code = 'EGAUGEINTERNAL' - return err -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/has-color.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/has-color.js deleted file mode 100644 index e283a256f26b74..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/has-color.js +++ /dev/null @@ -1,12 +0,0 @@ -'use strict' - -module.exports = isWin32() || isColorTerm() - -function isWin32 () { - return process.platform === 'win32' -} - -function isColorTerm () { - var termHasColor = /^screen|^xterm|^vt100|color|ansi|cygwin|linux/i - return !!process.env.COLORTERM || termHasColor.test(process.env.TERM) -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/index.js deleted file mode 100644 index 7eefb9507bb47e..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/index.js +++ /dev/null @@ -1,226 +0,0 @@ -'use strict' -var Plumbing = require('./plumbing.js') -var hasUnicode = require('has-unicode') -var hasColor = require('./has-color.js') -var onExit = require('signal-exit') -var defaultThemes = require('./themes') -var setInterval = require('./set-interval.js') -var process = require('./process.js') -var setImmediate = require('./set-immediate') - -module.exports = Gauge - -function callWith (obj, method) { - return function () { - return method.call(obj) - } -} - -function Gauge (arg1, arg2) { - var options, writeTo - if (arg1 && arg1.write) { - writeTo = arg1 - options = arg2 || {} - } else if (arg2 && arg2.write) { - writeTo = arg2 - options = arg1 || {} - } else { - writeTo = process.stderr - options = arg1 || arg2 || {} - } - - this._status = { - spun: 0, - section: '', - subsection: '' - } - this._paused = false // are we paused for back pressure? - this._disabled = true // are all progress bar updates disabled? - this._showing = false // do we WANT the progress bar on screen - this._onScreen = false // IS the progress bar on screen - this._needsRedraw = false // should we print something at next tick? - this._hideCursor = options.hideCursor == null ? true : options.hideCursor - this._fixedFramerate = options.fixedFramerate == null - ? !(/^v0\.8\./.test(process.version)) - : options.fixedFramerate - this._lastUpdateAt = null - this._updateInterval = options.updateInterval == null ? 50 : options.updateInterval - - this._themes = options.themes || defaultThemes - this._theme = options.theme - var theme = this._computeTheme(options.theme) - var template = options.template || [ - {type: 'progressbar', length: 20}, - {type: 'activityIndicator', kerning: 1, length: 1}, - {type: 'section', kerning: 1, default: ''}, - {type: 'subsection', kerning: 1, default: ''} - ] - this.setWriteTo(writeTo, options.tty) - var PlumbingClass = options.Plumbing || Plumbing - this._gauge = new PlumbingClass(theme, template, this.getWidth()) - - this._$$doRedraw = callWith(this, this._doRedraw) - this._$$handleSizeChange = callWith(this, this._handleSizeChange) - - if (options.cleanupOnExit == null || options.cleanupOnExit) { - onExit(callWith(this, this.disable)) - } - - if (options.enabled || (options.enabled == null && this._tty && this._tty.isTTY)) { - this.enable() - } else { - this.disable() - } -} -Gauge.prototype = {} - -Gauge.prototype.setTemplate = function (template) { - this._gauge.setTemplate(template) - if (this._showing) this._requestRedraw() -} - -Gauge.prototype._computeTheme = function (theme) { - if (!theme) theme = {} - if (theme && (Object.keys(theme).length === 0 || theme.hasUnicode != null || theme.hasColor != null)) { - var useUnicode = theme.hasUnicode == null ? hasUnicode() : theme.hasUnicode - var useColor = theme.hasColor == null ? hasColor : theme.hasColor - theme = this._themes.getDefault({hasUnicode: useUnicode, hasColor: useColor, platform: theme.platform}) - } else if (typeof theme === 'string') { - theme = this._themes.getTheme(theme) - } - return theme -} - -Gauge.prototype.setThemeset = function (themes) { - this._themes = themes - this.setTheme(this._theme) -} - -Gauge.prototype.setTheme = function (theme) { - this._gauge.setTheme(this._computeTheme(theme)) - if (this._showing) this._requestRedraw() - this._theme = theme -} - -Gauge.prototype._requestRedraw = function () { - this._needsRedraw = true - if (!this._fixedFramerate) this._doRedraw() -} - -Gauge.prototype.getWidth = function () { - return ((this._tty && this._tty.columns) || 80) - 1 -} - -Gauge.prototype.setWriteTo = function (writeTo, tty) { - var enabled = !this._disabled - if (enabled) this.disable() - this._writeTo = writeTo - this._tty = tty || - (writeTo === process.stderr && process.stdout.isTTY && process.stdout) || - (writeTo.isTTY && writeTo) || - this._tty - if (this._gauge) this._gauge.setWidth(this.getWidth()) - if (enabled) this.enable() -} - -Gauge.prototype.enable = function () { - if (!this._disabled) return - this._disabled = false - if (this._tty) this._enableEvents() - if (this._showing) this.show() -} - -Gauge.prototype.disable = function () { - if (this._disabled) return - if (this._showing) { - this._lastUpdateAt = null - this._showing = false - this._doRedraw() - this._showing = true - } - this._disabled = true - if (this._tty) this._disableEvents() -} - -Gauge.prototype._enableEvents = function () { - this._tty.on('resize', this._$$handleSizeChange) - if (this._fixedFramerate) { - this.redrawTracker = setInterval(this._$$doRedraw, this._updateInterval) - if (this.redrawTracker.unref) this.redrawTracker.unref() - } -} - -Gauge.prototype._disableEvents = function () { - this._tty.removeListener('resize', this._$$handleSizeChange) - if (this._fixedFramerate) clearInterval(this.redrawTracker) -} - -Gauge.prototype.hide = function (cb) { - if (this._disabled) return cb && process.nextTick(cb) - if (!this._showing) return cb && process.nextTick(cb) - this._showing = false - this._doRedraw() - cb && setImmediate(cb) -} - -Gauge.prototype.show = function (section, completed) { - if (this._disabled) return - this._showing = true - if (typeof section === 'string') { - this._status.section = section - } else if (typeof section === 'object') { - var sectionKeys = Object.keys(section) - for (var ii = 0; ii < sectionKeys.length; ++ii) { - var key = sectionKeys[ii] - this._status[key] = section[key] - } - } - if (completed != null) this._status.completed = completed - this._requestRedraw() -} - -Gauge.prototype.pulse = function (subsection) { - if (this._disabled) return - if (!this._showing) return - this._status.subsection = subsection || '' - this._status.spun ++ - this._requestRedraw() -} - -Gauge.prototype._handleSizeChange = function () { - this._gauge.setWidth(this._tty.columns - 1) - this._requestRedraw() -} - -Gauge.prototype._doRedraw = function () { - if (this._disabled || this._paused) return - if (!this._fixedFramerate) { - var now = Date.now() - if (this._lastUpdateAt && now - this._lastUpdateAt < this._updateInterval) return - this._lastUpdateAt = now - } - if (!this._showing && this._onScreen) { - this._onScreen = false - var result = this._gauge.hide() - if (this._hideCursor) { - result += this._gauge.showCursor() - } - return this._writeTo.write(result) - } - if (!this._showing && !this._onScreen) return - if (this._showing && !this._onScreen) { - this._onScreen = true - this._needsRedraw = true - if (this._hideCursor) { - this._writeTo.write(this._gauge.hideCursor()) - } - } - if (!this._needsRedraw) return - if (!this._writeTo.write(this._gauge.show(this._status))) { - this._paused = true - this._writeTo.on('drain', callWith(this, function () { - this._paused = false - this._doRedraw() - })) - } -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/has-color/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/has-color/index.js deleted file mode 100644 index 092d0baef6698e..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/has-color/index.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; -module.exports = (function () { - if (process.argv.indexOf('--no-color') !== -1) { - return false; - } - - if (process.argv.indexOf('--color') !== -1) { - return true; - } - - if (process.stdout && !process.stdout.isTTY) { - return false; - } - - if (process.platform === 'win32') { - return true; - } - - if ('COLORTERM' in process.env) { - return true; - } - - if (process.env.TERM === 'dumb') { - return false; - } - - if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) { - return true; - } - - return false; -})(); diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/has-color/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/has-color/package.json deleted file mode 100644 index 8e08278c65bea0..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/has-color/package.json +++ /dev/null @@ -1,117 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "has-color@^0.1.7", - "scope": null, - "escapedName": "has-color", - "name": "has-color", - "rawSpec": "^0.1.7", - "spec": ">=0.1.7 <0.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge" - ], - [ - { - "raw": "has-color@^0.1.7", - "scope": null, - "escapedName": "has-color", - "name": "has-color", - "rawSpec": "^0.1.7", - "spec": ">=0.1.7 <0.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "has-color@^0.1.7", - "_id": "has-color@0.1.7", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/gauge/has-color", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "1.4.6", - "_phantomChildren": {}, - "_requested": { - "raw": "has-color@^0.1.7", - "scope": null, - "escapedName": "has-color", - "name": "has-color", - "rawSpec": "^0.1.7", - "spec": ">=0.1.7 <0.2.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz", - "_shasum": "67144a5260c34fc3cca677d041daf52fe7b78b2f", - "_shrinkwrap": null, - "_spec": "has-color@^0.1.7", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "http://sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/has-color/issues" - }, - "dependencies": {}, - "description": "Detect whether a terminal supports color", - "devDependencies": { - "mocha": "*" - }, - "directories": {}, - "dist": { - "shasum": "67144a5260c34fc3cca677d041daf52fe7b78b2f", - "tarball": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "homepage": "https://github.com/sindresorhus/has-color", - "keywords": [ - "color", - "colour", - "colors", - "terminal", - "console", - "cli", - "ansi", - "styles", - "tty", - "rgb", - "256", - "shell", - "xterm", - "command-line", - "support", - "capability", - "detect" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "has-color", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/sindresorhus/has-color.git" - }, - "scripts": { - "test": "mocha" - }, - "version": "0.1.7" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/has-color/readme.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/has-color/readme.md deleted file mode 100644 index 37bbd8991a6423..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/has-color/readme.md +++ /dev/null @@ -1,30 +0,0 @@ -# has-color [![Build Status](https://travis-ci.org/sindresorhus/has-color.svg?branch=master)](https://travis-ci.org/sindresorhus/has-color) - -> Detect whether a terminal supports color. - -Used in the terminal color module [chalk](https://github.com/sindresorhus/chalk). - - -## Install - -```bash -$ npm install --save has-color -``` - - -## Usage - -```js -var hasColor = require('has-color'); - -if (hasColor) { - console.log('Terminal supports color.'); -} -``` - -It obeys the `--color` and `--no-color` CLI flags. - - -## License - -[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/index.js deleted file mode 100644 index 508504840dc61d..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/index.js +++ /dev/null @@ -1,83 +0,0 @@ -'use strict'; -/* eslint-disable no-unused-vars */ -var hasOwnProperty = Object.prototype.hasOwnProperty; -var propIsEnumerable = Object.prototype.propertyIsEnumerable; - -function toObject(val) { - if (val === null || val === undefined) { - throw new TypeError('Object.assign cannot be called with null or undefined'); - } - - return Object(val); -} - -function shouldUseNative() { - try { - if (!Object.assign) { - return false; - } - - // Detect buggy property enumeration order in older V8 versions. - - // https://bugs.chromium.org/p/v8/issues/detail?id=4118 - var test1 = new String('abc'); // eslint-disable-line - test1[5] = 'de'; - if (Object.getOwnPropertyNames(test1)[0] === '5') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test2 = {}; - for (var i = 0; i < 10; i++) { - test2['_' + String.fromCharCode(i)] = i; - } - var order2 = Object.getOwnPropertyNames(test2).map(function (n) { - return test2[n]; - }); - if (order2.join('') !== '0123456789') { - return false; - } - - // https://bugs.chromium.org/p/v8/issues/detail?id=3056 - var test3 = {}; - 'abcdefghijklmnopqrst'.split('').forEach(function (letter) { - test3[letter] = letter; - }); - if (Object.keys(Object.assign({}, test3)).join('') !== - 'abcdefghijklmnopqrst') { - return false; - } - - return true; - } catch (e) { - // We don't expect any of the above to throw, but better to be safe. - return false; - } -} - -module.exports = shouldUseNative() ? Object.assign : function (target, source) { - var from; - var to = toObject(target); - var symbols; - - for (var s = 1; s < arguments.length; s++) { - from = Object(arguments[s]); - - for (var key in from) { - if (hasOwnProperty.call(from, key)) { - to[key] = from[key]; - } - } - - if (Object.getOwnPropertySymbols) { - symbols = Object.getOwnPropertySymbols(from); - for (var i = 0; i < symbols.length; i++) { - if (propIsEnumerable.call(from, symbols[i])) { - to[symbols[i]] = from[symbols[i]]; - } - } - } - } - - return to; -}; diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/license b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/license deleted file mode 100644 index 654d0bfe943437..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/package.json deleted file mode 100644 index 16651a0ab52da2..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/package.json +++ /dev/null @@ -1,126 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "object-assign@^4.1.0", - "scope": null, - "escapedName": "object-assign", - "name": "object-assign", - "rawSpec": "^4.1.0", - "spec": ">=4.1.0 <5.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge" - ], - [ - { - "raw": "object-assign@^4.1.0", - "scope": null, - "escapedName": "object-assign", - "name": "object-assign", - "rawSpec": "^4.1.0", - "spec": ">=4.1.0 <5.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "object-assign@^4.1.0", - "_id": "object-assign@4.1.0", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/gauge/object-assign", - "_nodeVersion": "4.1.0", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/object-assign-4.1.0.tgz_1462212593641_0.3332549517508596" - }, - "_npmUser": { - "name": "spicyj", - "email": "ben@benalpert.com" - }, - "_npmVersion": "2.14.19", - "_phantomChildren": {}, - "_requested": { - "raw": "object-assign@^4.1.0", - "scope": null, - "escapedName": "object-assign", - "name": "object-assign", - "rawSpec": "^4.1.0", - "spec": ">=4.1.0 <5.0.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz", - "_shasum": "7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0", - "_shrinkwrap": null, - "_spec": "object-assign@^4.1.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/object-assign/issues" - }, - "dependencies": {}, - "description": "ES2015 Object.assign() ponyfill", - "devDependencies": { - "lodash": "^4.8.2", - "matcha": "^0.7.0", - "mocha": "*", - "xo": "*" - }, - "directories": {}, - "dist": { - "shasum": "7a3b3d0e98063d43f4c03f2e8ae6cd51a86883a0", - "tarball": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.0.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "72fe21c86911758f3342fdf41c2a57860d5829bc", - "homepage": "https://github.com/sindresorhus/object-assign#readme", - "keywords": [ - "object", - "assign", - "extend", - "properties", - "es2015", - "ecmascript", - "harmony", - "ponyfill", - "prollyfill", - "polyfill", - "shim", - "browser" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - { - "name": "spicyj", - "email": "ben@benalpert.com" - } - ], - "name": "object-assign", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/object-assign.git" - }, - "scripts": { - "bench": "matcha bench.js", - "test": "xo && mocha" - }, - "version": "4.1.0" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/readme.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/readme.md deleted file mode 100644 index 13c097734cfd18..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/object-assign/readme.md +++ /dev/null @@ -1,56 +0,0 @@ -# object-assign [![Build Status](https://travis-ci.org/sindresorhus/object-assign.svg?branch=master)](https://travis-ci.org/sindresorhus/object-assign) - -> ES2015 [`Object.assign()`](http://www.2ality.com/2014/01/object-assign.html) ponyfill - -> Ponyfill: A polyfill that doesn't overwrite the native method - - -## Install - -``` -$ npm install --save object-assign -``` - - -## Usage - -```js -const objectAssign = require('object-assign'); - -objectAssign({foo: 0}, {bar: 1}); -//=> {foo: 0, bar: 1} - -// multiple sources -objectAssign({foo: 0}, {bar: 1}, {baz: 2}); -//=> {foo: 0, bar: 1, baz: 2} - -// overwrites equal keys -objectAssign({foo: 0}, {foo: 1}, {foo: 2}); -//=> {foo: 2} - -// ignores null and undefined sources -objectAssign({foo: 0}, null, {bar: 1}, undefined); -//=> {foo: 0, bar: 1} -``` - - -## API - -### objectAssign(target, source, [source, ...]) - -Assigns enumerable own properties of `source` objects to the `target` object and returns the `target` object. Additional `source` objects will overwrite previous ones. - - -## Resources - -- [ES2015 spec - Object.assign](https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign) - - -## Related - -- [deep-assign](https://github.com/sindresorhus/deep-assign) - Recursive `Object.assign()` - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/CHANGELOG.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/CHANGELOG.md deleted file mode 100644 index e2f70d22503634..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/CHANGELOG.md +++ /dev/null @@ -1,27 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - - -## [3.0.1](https://github.com/tapjs/signal-exit/compare/v3.0.0...v3.0.1) (2016-09-08) - - -### Bug Fixes - -* do not listen on SIGBUS, SIGFPE, SIGSEGV and SIGILL ([#40](https://github.com/tapjs/signal-exit/issues/40)) ([5b105fb](https://github.com/tapjs/signal-exit/commit/5b105fb)) - - - - -# [3.0.0](https://github.com/tapjs/signal-exit/compare/v2.1.2...v3.0.0) (2016-06-13) - - -### Bug Fixes - -* get our test suite running on Windows ([#23](https://github.com/tapjs/signal-exit/issues/23)) ([6f3eda8](https://github.com/tapjs/signal-exit/commit/6f3eda8)) -* hooking SIGPROF was interfering with profilers see [#21](https://github.com/tapjs/signal-exit/issues/21) ([#24](https://github.com/tapjs/signal-exit/issues/24)) ([1248a4c](https://github.com/tapjs/signal-exit/commit/1248a4c)) - - -### BREAKING CHANGES - -* signal-exit no longer wires into SIGPROF diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/LICENSE.txt b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/LICENSE.txt deleted file mode 100644 index eead04a12162dc..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/LICENSE.txt +++ /dev/null @@ -1,16 +0,0 @@ -The ISC License - -Copyright (c) 2015, Contributors - -Permission to use, copy, modify, and/or distribute this software -for any purpose with or without fee is hereby granted, provided -that the above copyright notice and this permission notice -appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE -LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES -OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/README.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/README.md deleted file mode 100644 index 8ebccabecaea4c..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/README.md +++ /dev/null @@ -1,40 +0,0 @@ -# signal-exit - -[![Build Status](https://travis-ci.org/tapjs/signal-exit.png)](https://travis-ci.org/tapjs/signal-exit) -[![Coverage](https://coveralls.io/repos/tapjs/signal-exit/badge.svg?branch=master)](https://coveralls.io/r/tapjs/signal-exit?branch=master) -[![NPM version](https://img.shields.io/npm/v/signal-exit.svg)](https://www.npmjs.com/package/signal-exit) -[![Windows Tests](https://img.shields.io/appveyor/ci/bcoe/signal-exit/master.svg?label=Windows%20Tests)](https://ci.appveyor.com/project/bcoe/signal-exit) -[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version) - -When you want to fire an event no matter how a process exits: - -* reaching the end of execution. -* explicitly having `process.exit(code)` called. -* having `process.kill(pid, sig)` called. -* receiving a fatal signal from outside the process - -Use `signal-exit`. - -```js -var onExit = require('signal-exit') - -onExit(function (code, signal) { - console.log('process exited!') -}) -``` - -## API - -`var remove = onExit(function (code, signal) {}, options)` - -The return value of the function is a function that will remove the -handler. - -Note that the function *only* fires for signals if the signal would -cause the proces to exit. That is, there are no other listeners, and -it is a fatal signal. - -## Options - -* `alwaysLast`: Run this handler after any other signal or exit - handlers. This causes `process.emit` to be monkeypatched. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js deleted file mode 100644 index 7dd8d917dc507b..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js +++ /dev/null @@ -1,148 +0,0 @@ -// Note: since nyc uses this module to output coverage, any lines -// that are in the direct sync flow of nyc's outputCoverage are -// ignored, since we can never get coverage for them. -var assert = require('assert') -var signals = require('./signals.js') - -var EE = require('events') -/* istanbul ignore if */ -if (typeof EE !== 'function') { - EE = EE.EventEmitter -} - -var emitter -if (process.__signal_exit_emitter__) { - emitter = process.__signal_exit_emitter__ -} else { - emitter = process.__signal_exit_emitter__ = new EE() - emitter.count = 0 - emitter.emitted = {} -} - -module.exports = function (cb, opts) { - assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler') - - if (loaded === false) { - load() - } - - var ev = 'exit' - if (opts && opts.alwaysLast) { - ev = 'afterexit' - } - - var remove = function () { - emitter.removeListener(ev, cb) - if (emitter.listeners('exit').length === 0 && - emitter.listeners('afterexit').length === 0) { - unload() - } - } - emitter.on(ev, cb) - - return remove -} - -module.exports.unload = unload -function unload () { - if (!loaded) { - return - } - loaded = false - - signals.forEach(function (sig) { - try { - process.removeListener(sig, sigListeners[sig]) - } catch (er) {} - }) - process.emit = originalProcessEmit - process.reallyExit = originalProcessReallyExit - emitter.count -= 1 -} - -function emit (event, code, signal) { - if (emitter.emitted[event]) { - return - } - emitter.emitted[event] = true - emitter.emit(event, code, signal) -} - -// { : , ... } -var sigListeners = {} -signals.forEach(function (sig) { - sigListeners[sig] = function listener () { - // If there are no other listeners, an exit is coming! - // Simplest way: remove us and then re-send the signal. - // We know that this will kill the process, so we can - // safely emit now. - var listeners = process.listeners(sig) - if (listeners.length === emitter.count) { - unload() - emit('exit', null, sig) - /* istanbul ignore next */ - emit('afterexit', null, sig) - /* istanbul ignore next */ - process.kill(process.pid, sig) - } - } -}) - -module.exports.signals = function () { - return signals -} - -module.exports.load = load - -var loaded = false - -function load () { - if (loaded) { - return - } - loaded = true - - // This is the number of onSignalExit's that are in play. - // It's important so that we can count the correct number of - // listeners on signals, and don't wait for the other one to - // handle it instead of us. - emitter.count += 1 - - signals = signals.filter(function (sig) { - try { - process.on(sig, sigListeners[sig]) - return true - } catch (er) { - return false - } - }) - - process.emit = processEmit - process.reallyExit = processReallyExit -} - -var originalProcessReallyExit = process.reallyExit -function processReallyExit (code) { - process.exitCode = code || 0 - emit('exit', process.exitCode, null) - /* istanbul ignore next */ - emit('afterexit', process.exitCode, null) - /* istanbul ignore next */ - originalProcessReallyExit.call(process, process.exitCode) -} - -var originalProcessEmit = process.emit -function processEmit (ev, arg) { - if (ev === 'exit') { - if (arg !== undefined) { - process.exitCode = arg - } - var ret = originalProcessEmit.apply(this, arguments) - emit('exit', process.exitCode, null) - /* istanbul ignore next */ - emit('afterexit', process.exitCode, null) - return ret - } else { - return originalProcessEmit.apply(this, arguments) - } -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/package.json deleted file mode 100644 index d4ba8c443059d6..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/package.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "signal-exit@^3.0.0", - "scope": null, - "escapedName": "signal-exit", - "name": "signal-exit", - "rawSpec": "^3.0.0", - "spec": ">=3.0.0 <4.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm2/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge" - ], - [ - { - "raw": "signal-exit@^3.0.0", - "scope": null, - "escapedName": "signal-exit", - "name": "signal-exit", - "rawSpec": "^3.0.0", - "spec": ">=3.0.0 <4.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm2/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "signal-exit@^3.0.0", - "_id": "signal-exit@3.0.1", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/gauge/signal-exit", - "_nodeVersion": "6.5.0", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/signal-exit-3.0.1.tgz_1473354783379_0.4592130535747856" - }, - "_npmUser": { - "name": "bcoe", - "email": "ben@npmjs.com" - }, - "_npmVersion": "3.10.3", - "_phantomChildren": {}, - "_requested": { - "raw": "signal-exit@^3.0.0", - "scope": null, - "escapedName": "signal-exit", - "name": "signal-exit", - "rawSpec": "^3.0.0", - "spec": ">=3.0.0 <4.0.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.1.tgz", - "_shasum": "5a4c884992b63a7acd9badb7894c3ee9cfccad81", - "_shrinkwrap": null, - "_spec": "signal-exit@^3.0.0", - "_where": "/Users/rebecca/code/npm2/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge", - "author": { - "name": "Ben Coe", - "email": "ben@npmjs.com" - }, - "bugs": { - "url": "https://github.com/tapjs/signal-exit/issues" - }, - "dependencies": {}, - "description": "when you want to fire an event no matter how a process exits.", - "devDependencies": { - "chai": "^3.5.0", - "coveralls": "^2.11.10", - "nyc": "^8.1.0", - "standard": "^7.1.2", - "standard-version": "^2.3.0", - "tap": "^7.1.0" - }, - "directories": {}, - "dist": { - "shasum": "5a4c884992b63a7acd9badb7894c3ee9cfccad81", - "tarball": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.1.tgz" - }, - "files": [ - "index.js", - "signals.js" - ], - "gitHead": "6859aff54f5198c63fff91baef279b86026bde69", - "homepage": "https://github.com/tapjs/signal-exit", - "keywords": [ - "signal", - "exit" - ], - "license": "ISC", - "main": "index.js", - "maintainers": [ - { - "name": "bcoe", - "email": "ben@npmjs.com" - }, - { - "name": "isaacs", - "email": "isaacs@npmjs.com" - } - ], - "name": "signal-exit", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/tapjs/signal-exit.git" - }, - "scripts": { - "coverage": "nyc report --reporter=text-lcov | coveralls", - "pretest": "standard", - "release": "standard-version", - "test": "tap --timeout=240 ./test/*.js --cov" - }, - "version": "3.0.1" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/signals.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/signals.js deleted file mode 100644 index 3bd67a8a554e30..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/signals.js +++ /dev/null @@ -1,53 +0,0 @@ -// This is not the set of all possible signals. -// -// It IS, however, the set of all signals that trigger -// an exit on either Linux or BSD systems. Linux is a -// superset of the signal names supported on BSD, and -// the unknown signals just fail to register, so we can -// catch that easily enough. -// -// Don't bother with SIGKILL. It's uncatchable, which -// means that we can't fire any callbacks anyway. -// -// If a user does happen to register a handler on a non- -// fatal signal like SIGWINCH or something, and then -// exit, it'll end up firing `process.emit('exit')`, so -// the handler will be fired anyway. -// -// SIGBUS, SIGFPE, SIGSEGV and SIGILL, when not raised -// artificially, inherently leave the process in a -// state from which it is not safe to try and enter JS -// listeners. -module.exports = [ - 'SIGABRT', - 'SIGALRM', - 'SIGHUP', - 'SIGINT', - 'SIGTERM' -] - -if (process.platform !== 'win32') { - module.exports.push( - 'SIGVTALRM', - 'SIGXCPU', - 'SIGXFSZ', - 'SIGUSR2', - 'SIGTRAP', - 'SIGSYS', - 'SIGQUIT', - 'SIGIOT' - // should detect profiler and enable/disable accordingly. - // see #21 - // 'SIGPROF' - ) -} - -if (process.platform === 'linux') { - module.exports.push( - 'SIGIO', - 'SIGPOLL', - 'SIGPWR', - 'SIGSTKFLT', - 'SIGUNUSED' - ) -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/index.js deleted file mode 100644 index b9bec62440a468..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/index.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; -var stripAnsi = require('strip-ansi'); -var codePointAt = require('code-point-at'); -var isFullwidthCodePoint = require('is-fullwidth-code-point'); - -// https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1345 -module.exports = function (str) { - if (typeof str !== 'string' || str.length === 0) { - return 0; - } - - var width = 0; - - str = stripAnsi(str); - - for (var i = 0; i < str.length; i++) { - var code = codePointAt(str, i); - - // ignore control characters - if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) { - continue; - } - - // surrogates - if (code >= 0x10000) { - i++; - } - - if (isFullwidthCodePoint(code)) { - width += 2; - } else { - width++; - } - } - - return width; -}; diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/license b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/license deleted file mode 100644 index 654d0bfe943437..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/index.js deleted file mode 100644 index 0335117977237f..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/index.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; -var numberIsNan = require('number-is-nan'); - -module.exports = function (str, pos) { - if (str === null || str === undefined) { - throw TypeError(); - } - - str = String(str); - - var size = str.length; - var i = pos ? Number(pos) : 0; - - if (numberIsNan(i)) { - i = 0; - } - - if (i < 0 || i >= size) { - return undefined; - } - - var first = str.charCodeAt(i); - - if (first >= 0xD800 && first <= 0xDBFF && size > i + 1) { - var second = str.charCodeAt(i + 1); - - if (second >= 0xDC00 && second <= 0xDFFF) { - return (first - 0xD800) * 0x400 + second - 0xDC00 + 0x10000; - } - } - - return first; -}; diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/license b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/license deleted file mode 100644 index 654d0bfe943437..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/index.js deleted file mode 100644 index 79be4b9cb8c3bc..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; -module.exports = Number.isNaN || function (x) { - return x !== x; -}; diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/license b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/license deleted file mode 100644 index 654d0bfe943437..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/package.json deleted file mode 100644 index 77e053e2f9549e..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/package.json +++ /dev/null @@ -1,103 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at" - ] - ], - "_from": "number-is-nan@>=1.0.0 <2.0.0", - "_id": "number-is-nan@1.0.1", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/gauge/string-width/code-point-at/number-is-nan", - "_nodeVersion": "4.5.0", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/number-is-nan-1.0.1.tgz_1475212313367_0.9480371843092144" - }, - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "2.15.9", - "_phantomChildren": {}, - "_requested": { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog/gauge/string-width/code-point-at" - ], - "_resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "_shasum": "097b602b53422a522c1afb8790318336941a011d", - "_shrinkwrap": null, - "_spec": "number-is-nan@^1.0.0", - "_where": "/Users/rebecca/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/number-is-nan/issues" - }, - "dependencies": {}, - "description": "ES2015 Number.isNaN() ponyfill", - "devDependencies": { - "ava": "*" - }, - "directories": {}, - "dist": { - "shasum": "097b602b53422a522c1afb8790318336941a011d", - "tarball": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "ed9cdac3f428cc929b61bb230da42c87477af4b9", - "homepage": "https://github.com/sindresorhus/number-is-nan#readme", - "keywords": [ - "es2015", - "ecmascript", - "ponyfill", - "polyfill", - "shim", - "number", - "is", - "nan", - "not" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "number-is-nan", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/number-is-nan.git" - }, - "scripts": { - "test": "ava" - }, - "version": "1.0.1" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/readme.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/readme.md deleted file mode 100644 index 24635087120128..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/readme.md +++ /dev/null @@ -1,28 +0,0 @@ -# number-is-nan [![Build Status](https://travis-ci.org/sindresorhus/number-is-nan.svg?branch=master)](https://travis-ci.org/sindresorhus/number-is-nan) - -> ES2015 [`Number.isNaN()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) [ponyfill](https://ponyfill.com) - - -## Install - -``` -$ npm install --save number-is-nan -``` - - -## Usage - -```js -var numberIsNan = require('number-is-nan'); - -numberIsNan(NaN); -//=> true - -numberIsNan('unicorn'); -//=> false -``` - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/package.json deleted file mode 100644 index 59e664346766b9..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/package.json +++ /dev/null @@ -1,107 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "code-point-at@^1.0.0", - "scope": null, - "escapedName": "code-point-at", - "name": "code-point-at", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width" - ] - ], - "_from": "code-point-at@>=1.0.0 <2.0.0", - "_id": "code-point-at@1.0.1", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/gauge/string-width/code-point-at", - "_nodeVersion": "4.5.0", - "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/code-point-at-1.0.1.tgz_1475223183649_0.724906453397125" - }, - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "2.15.9", - "_phantomChildren": {}, - "_requested": { - "raw": "code-point-at@^1.0.0", - "scope": null, - "escapedName": "code-point-at", - "name": "code-point-at", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog/gauge/string-width" - ], - "_resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.0.1.tgz", - "_shasum": "1104cd34f9b5b45d3eba88f1babc1924e1ce35fb", - "_shrinkwrap": null, - "_spec": "code-point-at@^1.0.0", - "_where": "/Users/rebecca/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/code-point-at/issues" - }, - "dependencies": { - "number-is-nan": "^1.0.0" - }, - "description": "ES2015 String#codePointAt() ponyfill", - "devDependencies": { - "ava": "*" - }, - "directories": {}, - "dist": { - "shasum": "1104cd34f9b5b45d3eba88f1babc1924e1ce35fb", - "tarball": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.0.1.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "502d72c5a959275e5d90f9c6641589756af44085", - "homepage": "https://github.com/sindresorhus/code-point-at#readme", - "keywords": [ - "es2015", - "ponyfill", - "polyfill", - "shim", - "string", - "str", - "code", - "point", - "at", - "codepoint", - "unicode" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "code-point-at", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/code-point-at.git" - }, - "scripts": { - "test": "ava" - }, - "version": "1.0.1" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/readme.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/readme.md deleted file mode 100644 index ef9713f1b010c2..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/readme.md +++ /dev/null @@ -1,32 +0,0 @@ -# code-point-at [![Build Status](https://travis-ci.org/sindresorhus/code-point-at.svg?branch=master)](https://travis-ci.org/sindresorhus/code-point-at) - -> ES2015 [`String#codePointAt()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/codePointAt) [ponyfill](https://ponyfill.com) - - -## Install - -``` -$ npm install --save code-point-at -``` - - -## Usage - -```js -var codePointAt = require('code-point-at'); - -codePointAt('🐴'); -//=> 128052 - -codePointAt('abc', 2); -//=> 99 -``` - -## API - -### codePointAt(input, [position]) - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js deleted file mode 100644 index a7d3e3855f1c24..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/index.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; -var numberIsNan = require('number-is-nan'); - -module.exports = function (x) { - if (numberIsNan(x)) { - return false; - } - - // https://github.com/nodejs/io.js/blob/cff7300a578be1b10001f2d967aaedc88aee6402/lib/readline.js#L1369 - - // code points are derived from: - // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt - if (x >= 0x1100 && ( - x <= 0x115f || // Hangul Jamo - 0x2329 === x || // LEFT-POINTING ANGLE BRACKET - 0x232a === x || // RIGHT-POINTING ANGLE BRACKET - // CJK Radicals Supplement .. Enclosed CJK Letters and Months - (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || - // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A - 0x3250 <= x && x <= 0x4dbf || - // CJK Unified Ideographs .. Yi Radicals - 0x4e00 <= x && x <= 0xa4c6 || - // Hangul Jamo Extended-A - 0xa960 <= x && x <= 0xa97c || - // Hangul Syllables - 0xac00 <= x && x <= 0xd7a3 || - // CJK Compatibility Ideographs - 0xf900 <= x && x <= 0xfaff || - // Vertical Forms - 0xfe10 <= x && x <= 0xfe19 || - // CJK Compatibility Forms .. Small Form Variants - 0xfe30 <= x && x <= 0xfe6b || - // Halfwidth and Fullwidth Forms - 0xff01 <= x && x <= 0xff60 || - 0xffe0 <= x && x <= 0xffe6 || - // Kana Supplement - 0x1b000 <= x && x <= 0x1b001 || - // Enclosed Ideographic Supplement - 0x1f200 <= x && x <= 0x1f251 || - // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane - 0x20000 <= x && x <= 0x3fffd)) { - return true; - } - - return false; -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/license b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/license deleted file mode 100644 index 654d0bfe943437..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/index.js deleted file mode 100644 index 79be4b9cb8c3bc..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/index.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; -module.exports = Number.isNaN || function (x) { - return x !== x; -}; diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/license b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/license deleted file mode 100644 index 654d0bfe943437..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/license +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) Sindre Sorhus (sindresorhus.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/package.json deleted file mode 100644 index cf107ae74bd679..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/package.json +++ /dev/null @@ -1,115 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at" - ], - [ - { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point" - ] - ], - "_from": "number-is-nan@^1.0.0", - "_id": "number-is-nan@1.0.1", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/gauge/string-width/is-fullwidth-code-point/number-is-nan", - "_nodeVersion": "4.5.0", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/number-is-nan-1.0.1.tgz_1475212313367_0.9480371843092144" - }, - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "2.15.9", - "_phantomChildren": {}, - "_requested": { - "raw": "number-is-nan@^1.0.0", - "scope": null, - "escapedName": "number-is-nan", - "name": "number-is-nan", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog/gauge/string-width/is-fullwidth-code-point" - ], - "_resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "_shasum": "097b602b53422a522c1afb8790318336941a011d", - "_shrinkwrap": null, - "_spec": "number-is-nan@^1.0.0", - "_where": "/Users/rebecca/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/number-is-nan/issues" - }, - "dependencies": {}, - "description": "ES2015 Number.isNaN() ponyfill", - "devDependencies": { - "ava": "*" - }, - "directories": {}, - "dist": { - "shasum": "097b602b53422a522c1afb8790318336941a011d", - "tarball": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "ed9cdac3f428cc929b61bb230da42c87477af4b9", - "homepage": "https://github.com/sindresorhus/number-is-nan#readme", - "keywords": [ - "es2015", - "ecmascript", - "ponyfill", - "polyfill", - "shim", - "number", - "is", - "nan", - "not" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "number-is-nan", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/number-is-nan.git" - }, - "scripts": { - "test": "ava" - }, - "version": "1.0.1" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/readme.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/readme.md deleted file mode 100644 index 24635087120128..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/node_modules/number-is-nan/readme.md +++ /dev/null @@ -1,28 +0,0 @@ -# number-is-nan [![Build Status](https://travis-ci.org/sindresorhus/number-is-nan.svg?branch=master)](https://travis-ci.org/sindresorhus/number-is-nan) - -> ES2015 [`Number.isNaN()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isNaN) [ponyfill](https://ponyfill.com) - - -## Install - -``` -$ npm install --save number-is-nan -``` - - -## Usage - -```js -var numberIsNan = require('number-is-nan'); - -numberIsNan(NaN); -//=> true - -numberIsNan('unicorn'); -//=> false -``` - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json deleted file mode 100644 index 983c888760840f..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/package.json +++ /dev/null @@ -1,120 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "is-fullwidth-code-point@^1.0.0", - "scope": null, - "escapedName": "is-fullwidth-code-point", - "name": "is-fullwidth-code-point", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge/node_modules/string-width" - ], - [ - { - "raw": "is-fullwidth-code-point@^1.0.0", - "scope": null, - "escapedName": "is-fullwidth-code-point", - "name": "is-fullwidth-code-point", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width" - ] - ], - "_from": "is-fullwidth-code-point@^1.0.0", - "_id": "is-fullwidth-code-point@1.0.0", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/gauge/string-width/is-fullwidth-code-point", - "_nodeVersion": "0.12.5", - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "2.11.2", - "_phantomChildren": {}, - "_requested": { - "raw": "is-fullwidth-code-point@^1.0.0", - "scope": null, - "escapedName": "is-fullwidth-code-point", - "name": "is-fullwidth-code-point", - "rawSpec": "^1.0.0", - "spec": ">=1.0.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog/gauge/string-width" - ], - "_resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz", - "_shasum": "ef9e31386f031a7f0d643af82fde50c457ef00cb", - "_shrinkwrap": null, - "_spec": "is-fullwidth-code-point@^1.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/is-fullwidth-code-point/issues" - }, - "dependencies": { - "number-is-nan": "^1.0.0" - }, - "description": "Check if the character represented by a given Unicode code point is fullwidth", - "devDependencies": { - "ava": "0.0.4", - "code-point-at": "^1.0.0" - }, - "directories": {}, - "dist": { - "shasum": "ef9e31386f031a7f0d643af82fde50c457ef00cb", - "tarball": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "f2152d357f41f82785436d428e4f8ede143b7548", - "homepage": "https://github.com/sindresorhus/is-fullwidth-code-point", - "keywords": [ - "fullwidth", - "full-width", - "full", - "width", - "unicode", - "character", - "char", - "string", - "str", - "codepoint", - "code", - "point", - "is", - "detect", - "check" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "is-fullwidth-code-point", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/is-fullwidth-code-point.git" - }, - "scripts": { - "test": "node test.js" - }, - "version": "1.0.0" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md deleted file mode 100644 index 4936464b1b4155..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/readme.md +++ /dev/null @@ -1,39 +0,0 @@ -# is-fullwidth-code-point [![Build Status](https://travis-ci.org/sindresorhus/is-fullwidth-code-point.svg?branch=master)](https://travis-ci.org/sindresorhus/is-fullwidth-code-point) - -> Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) - - -## Install - -``` -$ npm install --save is-fullwidth-code-point -``` - - -## Usage - -```js -var isFullwidthCodePoint = require('is-fullwidth-code-point'); - -isFullwidthCodePoint('谢'.codePointAt()); -//=> true - -isFullwidthCodePoint('a'.codePointAt()); -//=> false -``` - - -## API - -### isFullwidthCodePoint(input) - -#### input - -Type: `number` - -[Code point](https://en.wikipedia.org/wiki/Code_point) of a character. - - -## License - -MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/package.json deleted file mode 100644 index 3f8334f0294200..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/package.json +++ /dev/null @@ -1,136 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "string-width@^1.0.1", - "scope": null, - "escapedName": "string-width", - "name": "string-width", - "rawSpec": "^1.0.1", - "spec": ">=1.0.1 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge" - ], - [ - { - "raw": "string-width@^1.0.1", - "scope": null, - "escapedName": "string-width", - "name": "string-width", - "rawSpec": "^1.0.1", - "spec": ">=1.0.1 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "string-width@^1.0.1", - "_id": "string-width@1.0.2", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/gauge/string-width", - "_nodeVersion": "4.4.5", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/string-width-1.0.2.tgz_1471188233009_0.6573935742489994" - }, - "_npmUser": { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - }, - "_npmVersion": "2.15.5", - "_phantomChildren": {}, - "_requested": { - "raw": "string-width@^1.0.1", - "scope": null, - "escapedName": "string-width", - "name": "string-width", - "rawSpec": "^1.0.1", - "spec": ">=1.0.1 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog/gauge", - "/npm-registry-client/npmlog/gauge/wide-align" - ], - "_resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", - "_shasum": "118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3", - "_shrinkwrap": null, - "_spec": "string-width@^1.0.1", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge", - "author": { - "name": "Sindre Sorhus", - "email": "sindresorhus@gmail.com", - "url": "sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/string-width/issues" - }, - "dependencies": { - "code-point-at": "^1.0.0", - "is-fullwidth-code-point": "^1.0.0", - "strip-ansi": "^3.0.0" - }, - "description": "Get the visual width of a string - the number of columns required to display it", - "devDependencies": { - "ava": "*", - "xo": "*" - }, - "directories": {}, - "dist": { - "shasum": "118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3", - "tarball": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "gitHead": "282cf3d53918a92cc3ee0778dcf938039bcbc47b", - "homepage": "https://github.com/sindresorhus/string-width#readme", - "keywords": [ - "string", - "str", - "character", - "char", - "unicode", - "width", - "visual", - "column", - "columns", - "fullwidth", - "full-width", - "full", - "ansi", - "escape", - "codes", - "cli", - "command-line", - "terminal", - "console", - "cjk", - "chinese", - "japanese", - "korean", - "fixed-width" - ], - "license": "MIT", - "maintainers": [ - { - "name": "sindresorhus", - "email": "sindresorhus@gmail.com" - } - ], - "name": "string-width", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/string-width.git" - }, - "scripts": { - "test": "xo && ava" - }, - "version": "1.0.2" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/readme.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/readme.md deleted file mode 100644 index 1ab42c93580ecb..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/string-width/readme.md +++ /dev/null @@ -1,42 +0,0 @@ -# string-width [![Build Status](https://travis-ci.org/sindresorhus/string-width.svg?branch=master)](https://travis-ci.org/sindresorhus/string-width) - -> Get the visual width of a string - the number of columns required to display it - -Some Unicode characters are [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) and use double the normal width. [ANSI escape codes](http://en.wikipedia.org/wiki/ANSI_escape_code) are stripped and doesn't affect the width. - -Useful to be able to measure the actual width of command-line output. - - -## Install - -``` -$ npm install --save string-width -``` - - -## Usage - -```js -const stringWidth = require('string-width'); - -stringWidth('古'); -//=> 2 - -stringWidth('\u001b[1m古\u001b[22m'); -//=> 2 - -stringWidth('a'); -//=> 1 -``` - - -## Related - -- [string-width-cli](https://github.com/sindresorhus/string-width-cli) - CLI for this module -- [string-length](https://github.com/sindresorhus/string-length) - Get the real length of a string -- [widest-line](https://github.com/sindresorhus/widest-line) - Get the visual width of the widest line in a string - - -## License - -MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/.npmignore b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/.npmignore deleted file mode 100644 index d1a6b0054bc8f3..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -*~ -/node_modules -.#* -/.nyc_output -/coverage diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/LICENSE b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/LICENSE deleted file mode 100644 index f4be44d881b2d9..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/LICENSE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) 2015, Rebecca Turner - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/README.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/README.md deleted file mode 100644 index 32f1be04f09776..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/README.md +++ /dev/null @@ -1,47 +0,0 @@ -wide-align ----------- - -A wide-character aware text alignment function for use in terminals / on the -console. - -### Usage - -``` -var align = require('wide-align') - -// Note that if you view this on a unicode console, all of the slashes are -// aligned. This is because on a console, all narrow characters are -// an en wide and all wide characters are an em. In browsers, this isn't -// held to and wide characters like "古" can be less than two narrow -// characters even with a fixed width font. - -console.log(align.center('abc', 10)) // ' abc ' -console.log(align.center('古古古', 10)) // ' 古古古 ' -console.log(align.left('abc', 10)) // 'abc ' -console.log(align.left('古古古', 10)) // '古古古 ' -console.log(align.right('abc', 10)) // ' abc' -console.log(align.right('古古古', 10)) // ' 古古古' -``` - -### Functions - -#### `align.center(str, length)` → `str` - -Returns *str* with spaces added to both sides such that that it is *length* -chars long and centered in the spaces. - -#### `align.left(str, length)` → `str` - -Returns *str* with spaces to the right such that it is *length* chars long. - -### `align.right(str, length)` → `str` - -Returns *str* with spaces to the left such that it is *length* chars long. - -### Origins - -These functions were originally taken from -[cliui](https://npmjs.com/package/cliui). Changes include switching to the -MUCH faster pad generation function from -[lodash](https://npmjs.com/package/lodash), making center alignment pad -both sides and adding left alignment. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/align.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/align.js deleted file mode 100644 index 4f94ca4cde19b5..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/align.js +++ /dev/null @@ -1,65 +0,0 @@ -'use strict' -var stringWidth = require('string-width') - -exports.center = alignCenter -exports.left = alignLeft -exports.right = alignRight - -// lodash's way of generating pad characters. - -function createPadding (width) { - var result = '' - var string = ' ' - var n = width - do { - if (n % 2) { - result += string; - } - n = Math.floor(n / 2); - string += string; - } while (n); - - return result; -} - -function alignLeft (str, width) { - var trimmed = str.trimRight() - if (trimmed.length === 0 && str.length >= width) return str - var padding = '' - var strWidth = stringWidth(trimmed) - - if (strWidth < width) { - padding = createPadding(width - strWidth) - } - - return trimmed + padding -} - -function alignRight (str, width) { - var trimmed = str.trimLeft() - if (trimmed.length === 0 && str.length >= width) return str - var padding = '' - var strWidth = stringWidth(trimmed) - - if (strWidth < width) { - padding = createPadding(width - strWidth) - } - - return padding + trimmed -} - -function alignCenter (str, width) { - var trimmed = str.trim() - if (trimmed.length === 0 && str.length >= width) return str - var padLeft = '' - var padRight = '' - var strWidth = stringWidth(trimmed) - - if (strWidth < width) { - var padLeftBy = parseInt((width - strWidth) / 2, 10) - padLeft = createPadding(padLeftBy) - padRight = createPadding(width - (strWidth + padLeftBy)) - } - - return padLeft + trimmed + padRight -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/package.json deleted file mode 100644 index bdc7bfa6a4b7e5..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/package.json +++ /dev/null @@ -1,105 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "wide-align@^1.1.0", - "scope": null, - "escapedName": "wide-align", - "name": "wide-align", - "rawSpec": "^1.1.0", - "spec": ">=1.1.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog/node_modules/gauge" - ], - [ - { - "raw": "wide-align@^1.1.0", - "scope": null, - "escapedName": "wide-align", - "name": "wide-align", - "rawSpec": "^1.1.0", - "spec": ">=1.1.0 <2.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "wide-align@^1.1.0", - "_id": "wide-align@1.1.0", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/gauge/wide-align", - "_nodeVersion": "4.2.2", - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "_npmVersion": "3.5.3", - "_phantomChildren": {}, - "_requested": { - "raw": "wide-align@^1.1.0", - "scope": null, - "escapedName": "wide-align", - "name": "wide-align", - "rawSpec": "^1.1.0", - "spec": ">=1.1.0 <2.0.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.0.tgz", - "_shasum": "40edde802a71fea1f070da3e62dcda2e7add96ad", - "_shrinkwrap": null, - "_spec": "wide-align@^1.1.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge", - "author": { - "name": "Rebecca Turner", - "email": "me@re-becca.org", - "url": "http://re-becca.org/" - }, - "bugs": { - "url": "https://github.com/iarna/wide-align/issues" - }, - "dependencies": { - "string-width": "^1.0.1" - }, - "description": "A wide-character aware text alignment function for use on the console or with fixed width fonts.", - "devDependencies": { - "tap": "^2.3.2" - }, - "directories": {}, - "dist": { - "shasum": "40edde802a71fea1f070da3e62dcda2e7add96ad", - "tarball": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.0.tgz" - }, - "gitHead": "fe3f7f210650913d5bee702d7e19938f6977bc8a", - "homepage": "https://github.com/iarna/wide-align#readme", - "keywords": [ - "wide", - "double", - "unicode", - "cjkv", - "pad", - "align" - ], - "license": "ISC", - "main": "align.js", - "maintainers": [ - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "name": "wide-align", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/iarna/wide-align.git" - }, - "scripts": { - "test": "tap --coverage test/*.js" - }, - "version": "1.1.0" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/test/align.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/test/align.js deleted file mode 100644 index 64e9f9dbda4697..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/node_modules/wide-align/test/align.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict' -var test = require('tap').test -var align = require('..') - -test('align', function (t) { - t.is(align.center('abc', 10), ' abc ', 'center narrow') - t.is(align.center('古古古', 10), ' 古古古 ', 'center wide') - t.is(align.left('abc', 10), 'abc ', 'left narrow') - t.is(align.left('古古古', 10), '古古古 ', 'left wide') - t.is(align.right('abc', 10), ' abc', 'right narrow') - t.is(align.right('古古古', 10), ' 古古古', 'right wide') - - t.is(align.center('abc', 2), 'abc', 'center narrow overflow') - t.is(align.center('古古古', 4), '古古古', 'center wide overflow') - t.is(align.left('abc', 2), 'abc', 'left narrow overflow') - t.is(align.left('古古古', 4), '古古古', 'left wide overflow') - t.is(align.right('abc', 2), 'abc', 'right narrow overflow') - t.is(align.right('古古古', 4), '古古古', 'right wide overflow') - - t.is(align.left('', 5), ' ', 'left align nothing') - t.is(align.center('', 5), ' ', 'center align nothing') - t.is(align.right('', 5), ' ', 'right align nothing') - - t.is(align.left(' ', 5), ' ', 'left align whitespace') - t.is(align.center(' ', 5), ' ', 'center align whitespace') - t.is(align.right(' ', 5), ' ', 'right align whitespace') - - t.is(align.left(' ', 2), ' ', 'left align whitespace overflow') - t.is(align.center(' ', 2), ' ', 'center align whitespace overflow') - t.is(align.right(' ', 2), ' ', 'right align whitespace overflow') - - t.is(align.left('x ', 10), 'x ', 'left align whitespace mix') - t.is(align.center('x ', 10), ' x ', 'center align whitespace mix') - t.is(align.right('x ', 10), ' x', 'right align whitespace mix') - - t.end() -}) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/package.json deleted file mode 100644 index 209c6b4125f198..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/package.json +++ /dev/null @@ -1,140 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "gauge@~2.6.0", - "scope": null, - "escapedName": "gauge", - "name": "gauge", - "rawSpec": "~2.6.0", - "spec": ">=2.6.0 <2.7.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog" - ], - [ - { - "raw": "gauge@~2.6.0", - "scope": null, - "escapedName": "gauge", - "name": "gauge", - "rawSpec": "~2.6.0", - "spec": ">=2.6.0 <2.7.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog" - ] - ], - "_from": "gauge@~2.6.0", - "_id": "gauge@2.6.0", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/gauge", - "_nodeVersion": "4.4.0", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/gauge-2.6.0.tgz_1466067371972_0.20705468393862247" - }, - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "_npmVersion": "3.9.2", - "_phantomChildren": { - "strip-ansi": "3.0.1" - }, - "_requested": { - "raw": "gauge@~2.6.0", - "scope": null, - "escapedName": "gauge", - "name": "gauge", - "rawSpec": "~2.6.0", - "spec": ">=2.6.0 <2.7.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog" - ], - "_resolved": "https://registry.npmjs.org/gauge/-/gauge-2.6.0.tgz", - "_shasum": "d35301ad18e96902b4751dcbbe40f4218b942a46", - "_shrinkwrap": null, - "_spec": "gauge@~2.6.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog", - "author": { - "name": "Rebecca Turner", - "email": "me@re-becca.org" - }, - "bugs": { - "url": "https://github.com/iarna/gauge/issues" - }, - "dependencies": { - "aproba": "^1.0.3", - "console-control-strings": "^1.0.0", - "has-color": "^0.1.7", - "has-unicode": "^2.0.0", - "object-assign": "^4.1.0", - "signal-exit": "^3.0.0", - "string-width": "^1.0.1", - "strip-ansi": "^3.0.1", - "wide-align": "^1.1.0" - }, - "description": "A terminal based horizontal guage", - "devDependencies": { - "readable-stream": "^2.0.6", - "require-inject": "^1.4.0", - "standard": "^7.1.2", - "tap": "^5.7.2", - "through2": "^2.0.0" - }, - "directories": {}, - "dist": { - "shasum": "d35301ad18e96902b4751dcbbe40f4218b942a46", - "tarball": "https://registry.npmjs.org/gauge/-/gauge-2.6.0.tgz" - }, - "files": [ - "base-theme.js", - "CHANGELOG.md", - "error.js", - "has-color.js", - "index.js", - "LICENSE", - "package.json", - "plumbing.js", - "process.js", - "progress-bar.js", - "README.md", - "render-template.js", - "set-immediate.js", - "set-interval.js", - "spin.js", - "template-item.js", - "theme-set.js", - "themes.js", - "wide-truncate.js" - ], - "gitHead": "d51040a71c269432c16cc542143f403a831630e6", - "homepage": "https://github.com/iarna/gauge", - "keywords": [ - "progressbar", - "progress", - "gauge" - ], - "license": "ISC", - "main": "index.js", - "maintainers": [ - { - "name": "iarna", - "email": "me@re-becca.org" - } - ], - "name": "gauge", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/iarna/gauge.git" - }, - "scripts": { - "test": "standard && tap test/*.js --coverage" - }, - "version": "2.6.0" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/plumbing.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/plumbing.js deleted file mode 100644 index 589a9c92878ebf..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/plumbing.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict' -var consoleControl = require('console-control-strings') -var renderTemplate = require('./render-template.js') -var validate = require('aproba') - -var Plumbing = module.exports = function (theme, template, width) { - if (!width) width = 80 - validate('OAN', [theme, template, width]) - this.showing = false - this.theme = theme - this.width = width - this.template = template -} -Plumbing.prototype = {} - -Plumbing.prototype.setTheme = function (theme) { - validate('O', [theme]) - this.theme = theme -} - -Plumbing.prototype.setTemplate = function (template) { - validate('A', [template]) - this.template = template -} - -Plumbing.prototype.setWidth = function (width) { - validate('N', [width]) - this.width = width -} - -Plumbing.prototype.hide = function () { - return consoleControl.gotoSOL() + consoleControl.eraseLine() -} - -Plumbing.prototype.hideCursor = consoleControl.hideCursor - -Plumbing.prototype.showCursor = consoleControl.showCursor - -Plumbing.prototype.show = function (status) { - var values = Object.create(this.theme) - for (var key in status) { - values[key] = status[key] - } - - return renderTemplate(this.width, this.template, values).trim() + - consoleControl.eraseLine() + consoleControl.gotoSOL() -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/process.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/process.js deleted file mode 100644 index 05e85694d755b6..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/process.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict' -// this exists so we can replace it during testing -module.exports = process diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/progress-bar.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/progress-bar.js deleted file mode 100644 index 7f8dd68be24cf0..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/progress-bar.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict' -var validate = require('aproba') -var renderTemplate = require('./render-template.js') -var wideTruncate = require('./wide-truncate') -var stringWidth = require('string-width') - -module.exports = function (theme, width, completed) { - validate('ONN', [theme, width, completed]) - if (completed < 0) completed = 0 - if (completed > 1) completed = 1 - if (width <= 0) return '' - var sofar = Math.round(width * completed) - var rest = width - sofar - var template = [ - {type: 'complete', value: repeat(theme.complete, sofar), length: sofar}, - {type: 'remaining', value: repeat(theme.remaining, rest), length: rest} - ] - return renderTemplate(width, template, theme) -} - -// lodash's way of repeating -function repeat (string, width) { - var result = '' - var n = width - do { - if (n % 2) { - result += string - } - n = Math.floor(n / 2) - /*eslint no-self-assign: 0*/ - string += string - } while (n && stringWidth(result) < width) - - return wideTruncate(result, width) -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/render-template.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/render-template.js deleted file mode 100644 index 3261bfbe6f4be5..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/render-template.js +++ /dev/null @@ -1,181 +0,0 @@ -'use strict' -var align = require('wide-align') -var validate = require('aproba') -var objectAssign = require('object-assign') -var wideTruncate = require('./wide-truncate') -var error = require('./error') -var TemplateItem = require('./template-item') - -function renderValueWithValues (values) { - return function (item) { - return renderValue(item, values) - } -} - -var renderTemplate = module.exports = function (width, template, values) { - var items = prepareItems(width, template, values) - var rendered = items.map(renderValueWithValues(values)).join('') - return align.left(wideTruncate(rendered, width), width) -} - -function preType (item) { - var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1) - return 'pre' + cappedTypeName -} - -function postType (item) { - var cappedTypeName = item.type[0].toUpperCase() + item.type.slice(1) - return 'post' + cappedTypeName -} - -function hasPreOrPost (item, values) { - if (!item.type) return - return values[preType(item)] || values[postType(item)] -} - -function generatePreAndPost (baseItem, parentValues) { - var item = objectAssign({}, baseItem) - var values = Object.create(parentValues) - var template = [] - var pre = preType(item) - var post = postType(item) - if (values[pre]) { - template.push({value: values[pre]}) - values[pre] = null - } - item.minLength = null - item.length = null - item.maxLength = null - template.push(item) - values[item.type] = values[item.type] - if (values[post]) { - template.push({value: values[post]}) - values[post] = null - } - return function ($1, $2, length) { - return renderTemplate(length, template, values) - } -} - -function prepareItems (width, template, values) { - function cloneAndObjectify (item, index, arr) { - var cloned = new TemplateItem(item, width) - var type = cloned.type - if (cloned.value == null) { - if (!(type in values)) { - if (cloned.default == null) { - throw new error.MissingTemplateValue(cloned, values) - } else { - cloned.value = cloned.default - } - } else { - cloned.value = values[type] - } - } - if (cloned.value == null || cloned.value === '') return null - cloned.index = index - cloned.first = index === 0 - cloned.last = index === arr.length - 1 - if (hasPreOrPost(cloned, values)) cloned.value = generatePreAndPost(cloned, values) - return cloned - } - - var output = template.map(cloneAndObjectify).filter(function (item) { return item != null }) - - var outputLength = 0 - var remainingSpace = width - var variableCount = output.length - - function consumeSpace (length) { - if (length > remainingSpace) length = remainingSpace - outputLength += length - remainingSpace -= length - } - - function finishSizing (item, length) { - if (item.finished) throw new error.Internal('Tried to finish template item that was already finished') - if (length === Infinity) throw new error.Internal('Length of template item cannot be infinity') - if (length != null) item.length = length - item.minLength = null - item.maxLength = null - --variableCount - item.finished = true - if (item.length == null) item.length = item.getBaseLength() - if (item.length == null) throw new error.Internal('Finished template items must have a length') - consumeSpace(item.getLength()) - } - - output.forEach(function (item) { - if (!item.kerning) return - var prevPadRight = item.first ? 0 : output[item.index - 1].padRight - if (!item.first && prevPadRight < item.kerning) item.padLeft = item.kerning - prevPadRight - if (!item.last) item.padRight = item.kerning - }) - - // Finish any that have a fixed (literal or intuited) length - output.forEach(function (item) { - if (item.getBaseLength() == null) return - finishSizing(item) - }) - - var resized = 0 - var resizing - var hunkSize - do { - resizing = false - hunkSize = Math.round(remainingSpace / variableCount) - output.forEach(function (item) { - if (item.finished) return - if (!item.maxLength) return - if (item.getMaxLength() < hunkSize) { - finishSizing(item, item.maxLength) - resizing = true - } - }) - } while (resizing && resized++ < output.length) - if (resizing) throw new error.Internal('Resize loop iterated too many times while determining maxLength') - - resized = 0 - do { - resizing = false - hunkSize = Math.round(remainingSpace / variableCount) - output.forEach(function (item) { - if (item.finished) return - if (!item.minLength) return - if (item.getMinLength() >= hunkSize) { - finishSizing(item, item.minLength) - resizing = true - } - }) - } while (resizing && resized++ < output.length) - if (resizing) throw new error.Internal('Resize loop iterated too many times while determining minLength') - - hunkSize = Math.round(remainingSpace / variableCount) - output.forEach(function (item) { - if (item.finished) return - finishSizing(item, hunkSize) - }) - - return output -} - -function renderFunction (item, values, length) { - validate('OON', arguments) - if (item.type) { - return item.value(values, values[item.type + 'Theme'] || {}, length) - } else { - return item.value(values, {}, length) - } -} - -function renderValue (item, values) { - var length = item.getBaseLength() - var value = typeof item.value === 'function' ? renderFunction(item, values, length) : item.value - if (value == null || value === '') return '' - var alignWith = align[item.align] || align.left - var leftPadding = item.padLeft ? align.left('', item.padLeft) : '' - var rightPadding = item.padRight ? align.right('', item.padRight) : '' - var truncated = wideTruncate(String(value), length) - var aligned = alignWith(truncated, length) - return leftPadding + aligned + rightPadding -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/set-immediate.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/set-immediate.js deleted file mode 100644 index 6650a485c49933..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/set-immediate.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict' -var process = require('./process') -try { - module.exports = setImmediate -} catch (ex) { - module.exports = process.nextTick -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/set-interval.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/set-interval.js deleted file mode 100644 index 576198793c5504..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/set-interval.js +++ /dev/null @@ -1,3 +0,0 @@ -'use strict' -// this exists so we can replace it during testing -module.exports = setInterval diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/spin.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/spin.js deleted file mode 100644 index 34142ee31acc7c..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/spin.js +++ /dev/null @@ -1,5 +0,0 @@ -'use strict' - -module.exports = function spin (spinstr, spun) { - return spinstr[spun % spinstr.length] -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/template-item.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/template-item.js deleted file mode 100644 index e46f447c941d38..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/template-item.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict' -var stringWidth = require('string-width') - -module.exports = TemplateItem - -function isPercent (num) { - if (typeof num !== 'string') return false - return num.slice(-1) === '%' -} - -function percent (num) { - return Number(num.slice(0, -1)) / 100 -} - -function TemplateItem (values, outputLength) { - this.overallOutputLength = outputLength - this.finished = false - this.type = null - this.value = null - this.length = null - this.maxLength = null - this.minLength = null - this.kerning = null - this.align = 'left' - this.padLeft = 0 - this.padRight = 0 - this.index = null - this.first = null - this.last = null - if (typeof values === 'string') { - this.value = values - } else { - for (var prop in values) this[prop] = values[prop] - } - // Realize percents - if (isPercent(this.length)) { - this.length = Math.round(this.overallOutputLength * percent(this.length)) - } - if (isPercent(this.minLength)) { - this.minLength = Math.round(this.overallOutputLength * percent(this.minLength)) - } - if (isPercent(this.maxLength)) { - this.maxLength = Math.round(this.overallOutputLength * percent(this.maxLength)) - } - return this -} - -TemplateItem.prototype = {} - -TemplateItem.prototype.getBaseLength = function () { - var length = this.length - if (length == null && typeof this.value === 'string' && this.maxLength == null && this.minLength == null) { - length = stringWidth(this.value) - } - return length -} - -TemplateItem.prototype.getLength = function () { - var length = this.getBaseLength() - if (length == null) return null - return length + this.padLeft + this.padRight -} - -TemplateItem.prototype.getMaxLength = function () { - if (this.maxLength == null) return null - return this.maxLength + this.padLeft + this.padRight -} - -TemplateItem.prototype.getMinLength = function () { - if (this.minLength == null) return null - return this.minLength + this.padLeft + this.padRight -} - diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/theme-set.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/theme-set.js deleted file mode 100644 index 68971d5d231b07..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/theme-set.js +++ /dev/null @@ -1,115 +0,0 @@ -'use strict' -var objectAssign = require('object-assign') - -module.exports = function () { - return ThemeSetProto.newThemeSet() -} - -var ThemeSetProto = {} - -ThemeSetProto.baseTheme = require('./base-theme.js') - -ThemeSetProto.newTheme = function (parent, theme) { - if (!theme) { - theme = parent - parent = this.baseTheme - } - return objectAssign({}, parent, theme) -} - -ThemeSetProto.getThemeNames = function () { - return Object.keys(this.themes) -} - -ThemeSetProto.addTheme = function (name, parent, theme) { - this.themes[name] = this.newTheme(parent, theme) -} - -ThemeSetProto.addToAllThemes = function (theme) { - var themes = this.themes - Object.keys(themes).forEach(function (name) { - objectAssign(themes[name], theme) - }) - objectAssign(this.baseTheme, theme) -} - -ThemeSetProto.getTheme = function (name) { - if (!this.themes[name]) throw this.newMissingThemeError(name) - return this.themes[name] -} - -ThemeSetProto.setDefault = function (opts, name) { - if (name == null) { - name = opts - opts = {} - } - var platform = opts.platform == null ? 'fallback' : opts.platform - var hasUnicode = !!opts.hasUnicode - var hasColor = !!opts.hasColor - if (!this.defaults[platform]) this.defaults[platform] = {true: {}, false: {}} - this.defaults[platform][hasUnicode][hasColor] = name -} - -ThemeSetProto.getDefault = function (opts) { - if (!opts) opts = {} - var platformName = opts.platform || process.platform - var platform = this.defaults[platformName] || this.defaults.fallback - var hasUnicode = !!opts.hasUnicode - var hasColor = !!opts.hasColor - if (!platform) throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor) - if (!platform[hasUnicode][hasColor]) { - if (hasUnicode && hasColor && platform[!hasUnicode][hasColor]) { - hasUnicode = false - } else if (hasUnicode && hasColor && platform[hasUnicode][!hasColor]) { - hasColor = false - } else if (hasUnicode && hasColor && platform[!hasUnicode][!hasColor]) { - hasUnicode = false - hasColor = false - } else if (hasUnicode && !hasColor && platform[!hasUnicode][hasColor]) { - hasUnicode = false - } else if (!hasUnicode && hasColor && platform[hasUnicode][!hasColor]) { - hasColor = false - } else if (platform === this.defaults.fallback) { - throw this.newMissingDefaultThemeError(platformName, hasUnicode, hasColor) - } - } - if (platform[hasUnicode][hasColor]) { - return this.getTheme(platform[hasUnicode][hasColor]) - } else { - return this.getDefault(objectAssign({}, opts, {platform: 'fallback'})) - } -} - -ThemeSetProto.newMissingThemeError = function newMissingThemeError (name) { - var err = new Error('Could not find a gauge theme named "' + name + '"') - Error.captureStackTrace.call(err, newMissingThemeError) - err.theme = name - err.code = 'EMISSINGTHEME' - return err -} - -ThemeSetProto.newMissingDefaultThemeError = function newMissingDefaultThemeError (platformName, hasUnicode, hasColor) { - var err = new Error( - 'Could not find a gauge theme for your platform/unicode/color use combo:\n' + - ' platform = ' + platformName + '\n' + - ' hasUnicode = ' + hasUnicode + '\n' + - ' hasColor = ' + hasColor) - Error.captureStackTrace.call(err, newMissingDefaultThemeError) - err.platform = platformName - err.hasUnicode = hasUnicode - err.hasColor = hasColor - err.code = 'EMISSINGTHEME' - return err -} - -ThemeSetProto.newThemeSet = function () { - var themeset = function (opts) { - return themeset.getDefault(opts) - } - return objectAssign(themeset, ThemeSetProto, { - themes: objectAssign({}, this.themes), - baseTheme: objectAssign({}, this.baseTheme), - defaults: JSON.parse(JSON.stringify(this.defaults || {})) - }) -} - diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/themes.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/themes.js deleted file mode 100644 index eb5a4f5b5e1034..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/themes.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict' -var consoleControl = require('console-control-strings') -var ThemeSet = require('./theme-set.js') - -var themes = module.exports = new ThemeSet() - -themes.addTheme('ASCII', { - preProgressbar: '[', - postProgressbar: ']', - progressbarTheme: { - complete: '#', - remaining: '.' - }, - activityIndicatorTheme: '-\\|/', - preSubsection: '>' -}) - -themes.addTheme('colorASCII', themes.getTheme('ASCII'), { - progressbarTheme: { - preComplete: consoleControl.color('inverse'), - complete: ' ', - postComplete: consoleControl.color('stopInverse'), - preRemaining: consoleControl.color('brightBlack'), - remaining: '.', - postRemaining: consoleControl.color('reset') - } -}) - -themes.addTheme('brailleSpinner', { - preProgressbar: '⸨', - postProgressbar: '⸩', - progressbarTheme: { - complete: '░', - remaining: '⠂' - }, - activityIndicatorTheme: '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏', - preSubsection: '>' -}) - -themes.addTheme('colorBrailleSpinner', themes.getTheme('brailleSpinner'), { - progressbarTheme: { - preComplete: consoleControl.color('inverse'), - complete: ' ', - postComplete: consoleControl.color('stopInverse'), - preRemaining: consoleControl.color('brightBlack'), - remaining: '░', - postRemaining: consoleControl.color('reset') - } -}) - -themes.setDefault({}, 'ASCII') -themes.setDefault({hasColor: true}, 'colorASCII') -themes.setDefault({platform: 'darwin', hasUnicode: true}, 'brailleSpinner') -themes.setDefault({platform: 'darwin', hasUnicode: true, hasColor: true}, 'colorBrailleSpinner') diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/wide-truncate.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/wide-truncate.js deleted file mode 100644 index c531bc491fbb58..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/gauge/wide-truncate.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict' -var stringWidth = require('string-width') -var stripAnsi = require('strip-ansi') - -module.exports = wideTruncate - -function wideTruncate (str, target) { - if (stringWidth(str) === 0) return str - if (target <= 0) return '' - if (stringWidth(str) <= target) return str - - // We compute the number of bytes of ansi sequences here and add - // that to our initial truncation to ensure that we don't slice one - // that we want to keep in half. - var noAnsi = stripAnsi(str) - var ansiSize = str.length + noAnsi.length - var truncated = str.slice(0, target + ansiSize) - - // we have to shrink the result to account for our ansi sequence buffer - // (if an ansi sequence was truncated) and double width characters. - while (stringWidth(truncated) > target) { - truncated = truncated.slice(0, -1) - } - return truncated -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/CHANGELOG.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/CHANGELOG.md deleted file mode 100644 index 03bf591923d782..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/CHANGELOG.md +++ /dev/null @@ -1,26 +0,0 @@ -# Change Log - -All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. - - -# [2.0.0](https://github.com/yargs/set-blocking/compare/v1.0.0...v2.0.0) (2016-05-17) - - -### Features - -* add an isTTY check ([#3](https://github.com/yargs/set-blocking/issues/3)) ([66ce277](https://github.com/yargs/set-blocking/commit/66ce277)) - - -### BREAKING CHANGES - -* stdio/stderr will not be set to blocking if isTTY === false - - - - -# 1.0.0 (2016-05-14) - - -### Features - -* implemented shim for stream._handle.setBlocking ([6bde0c0](https://github.com/yargs/set-blocking/commit/6bde0c0)) diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/LICENSE.txt b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/LICENSE.txt deleted file mode 100644 index 836440bef7cf14..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/LICENSE.txt +++ /dev/null @@ -1,14 +0,0 @@ -Copyright (c) 2016, Contributors - -Permission to use, copy, modify, and/or distribute this software -for any purpose with or without fee is hereby granted, provided -that the above copyright notice and this permission notice -appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE -LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES -OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/README.md b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/README.md deleted file mode 100644 index e93b4202b59d65..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/README.md +++ /dev/null @@ -1,31 +0,0 @@ -# set-blocking - -[![Build Status](https://travis-ci.org/yargs/set-blocking.svg)](https://travis-ci.org/yargs/set-blocking) -[![NPM version](https://img.shields.io/npm/v/set-blocking.svg)](https://www.npmjs.com/package/set-blocking) -[![Coverage Status](https://coveralls.io/repos/yargs/set-blocking/badge.svg?branch=)](https://coveralls.io/r/yargs/set-blocking?branch=master) -[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version) - -set blocking `stdio` and `stderr` ensuring that terminal output does not truncate. - -```js -const setBlocking = require('set-blocking') -setBlocking(true) -console.log(someLargeStringToOutput) -``` - -## Historical Context/Word of Warning - -This was created as a shim to address the bug discussed in [node #6456](https://github.com/nodejs/node/issues/6456). This bug crops up on -newer versions of Node.js (`0.12+`), truncating terminal output. - -You should be mindful of the side-effects caused by using `set-blocking`: - -* if your module sets blocking to `true`, it will effect other modules - consuming your library. In [yargs](https://github.com/yargs/yargs/blob/master/yargs.js#L653) we only call - `setBlocking(true)` once we already know we are about to call `process.exit(code)`. -* this patch will not apply to subprocesses spawned with `isTTY = true`, this is - the [default `spawn()` behavior](https://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options). - -## License - -ISC diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/index.js b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/index.js deleted file mode 100644 index 6f78774bb63ee6..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/index.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = function (blocking) { - [process.stdout, process.stderr].forEach(function (stream) { - if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') { - stream._handle.setBlocking(blocking) - } - }) -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/package.json deleted file mode 100644 index bbfac3e6ca4e90..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/node_modules/set-blocking/package.json +++ /dev/null @@ -1,118 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "set-blocking@~2.0.0", - "scope": null, - "escapedName": "set-blocking", - "name": "set-blocking", - "rawSpec": "~2.0.0", - "spec": ">=2.0.0 <2.1.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npmlog" - ], - [ - { - "raw": "set-blocking@~2.0.0", - "scope": null, - "escapedName": "set-blocking", - "name": "set-blocking", - "rawSpec": "~2.0.0", - "spec": ">=2.0.0 <2.1.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog" - ] - ], - "_from": "set-blocking@~2.0.0", - "_id": "set-blocking@2.0.0", - "_inCache": true, - "_location": "/npm-registry-client/npmlog/set-blocking", - "_nodeVersion": "0.12.7", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/set-blocking-2.0.0.tgz_1463525966987_0.5456729622092098" - }, - "_npmUser": { - "name": "bcoe", - "email": "ben@npmjs.com" - }, - "_npmVersion": "2.11.3", - "_phantomChildren": {}, - "_requested": { - "raw": "set-blocking@~2.0.0", - "scope": null, - "escapedName": "set-blocking", - "name": "set-blocking", - "rawSpec": "~2.0.0", - "spec": ">=2.0.0 <2.1.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client/npmlog" - ], - "_resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", - "_shasum": "045f9782d011ae9a6803ddd382b24392b3d890f7", - "_shrinkwrap": null, - "_spec": "set-blocking@~2.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client/node_modules/npmlog", - "author": { - "name": "Ben Coe", - "email": "ben@npmjs.com" - }, - "bugs": { - "url": "https://github.com/yargs/set-blocking/issues" - }, - "dependencies": {}, - "description": "set blocking stdio and stderr ensuring that terminal output does not truncate", - "devDependencies": { - "chai": "^3.5.0", - "coveralls": "^2.11.9", - "mocha": "^2.4.5", - "nyc": "^6.4.4", - "standard": "^7.0.1", - "standard-version": "^2.2.1" - }, - "directories": {}, - "dist": { - "shasum": "045f9782d011ae9a6803ddd382b24392b3d890f7", - "tarball": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz" - }, - "files": [ - "index.js", - "LICENSE.txt" - ], - "gitHead": "7eec10577b5fff264de477ba3b9d07f404946eff", - "homepage": "https://github.com/yargs/set-blocking#readme", - "keywords": [ - "flush", - "terminal", - "blocking", - "shim", - "stdio", - "stderr" - ], - "license": "ISC", - "main": "index.js", - "maintainers": [ - { - "name": "bcoe", - "email": "ben@npmjs.com" - } - ], - "name": "set-blocking", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/yargs/set-blocking.git" - }, - "scripts": { - "coverage": "nyc report --reporter=text-lcov | coveralls", - "pretest": "standard", - "test": "nyc mocha ./test/*.js", - "version": "standard-version" - }, - "version": "2.0.0" -} diff --git a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/package.json b/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/package.json deleted file mode 100644 index a66e8ce1c4685e..00000000000000 --- a/deps/npm/node_modules/npm-registry-client/node_modules/npmlog/package.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "npmlog@~2.0.0 || ~3.1.0", - "scope": null, - "escapedName": "npmlog", - "name": "npmlog", - "rawSpec": "~2.0.0 || ~3.1.0", - "spec": ">=2.0.0 <2.1.0||>=3.1.0 <3.2.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client" - ] - ], - "_from": "npmlog@>=2.0.0 <2.1.0||>=3.1.0 <3.2.0", - "_id": "npmlog@3.1.2", - "_inCache": true, - "_location": "/npm-registry-client/npmlog", - "_nodeVersion": "4.4.0", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/npmlog-3.1.2.tgz_1466073052641_0.36111341998912394" - }, - "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" - }, - "_npmVersion": "3.9.6", - "_phantomChildren": { - "aproba": "1.0.4", - "has-unicode": "2.0.1", - "readable-stream": "2.1.4", - "strip-ansi": "3.0.1" - }, - "_requested": { - "raw": "npmlog@~2.0.0 || ~3.1.0", - "scope": null, - "escapedName": "npmlog", - "name": "npmlog", - "rawSpec": "~2.0.0 || ~3.1.0", - "spec": ">=2.0.0 <2.1.0||>=3.1.0 <3.2.0", - "type": "range" - }, - "_requiredBy": [ - "/npm-registry-client" - ], - "_resolved": "https://registry.npmjs.org/npmlog/-/npmlog-3.1.2.tgz", - "_shasum": "2d46fa874337af9498a2f12bb43d8d0be4a36873", - "_shrinkwrap": null, - "_spec": "npmlog@~2.0.0 || ~3.1.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/npm-registry-client", - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, - "bugs": { - "url": "https://github.com/npm/npmlog/issues" - }, - "dependencies": { - "are-we-there-yet": "~1.1.2", - "console-control-strings": "~1.1.0", - "gauge": "~2.6.0", - "set-blocking": "~2.0.0" - }, - "description": "logger for npm", - "devDependencies": { - "standard": "~7.1.2", - "tap": "~5.7.0" - }, - "directories": {}, - "dist": { - "shasum": "2d46fa874337af9498a2f12bb43d8d0be4a36873", - "tarball": "https://registry.npmjs.org/npmlog/-/npmlog-3.1.2.tgz" - }, - "files": [ - "log.js" - ], - "gitHead": "444e237743fa1339cb91bea2d3f16f710be56984", - "homepage": "https://github.com/npm/npmlog#readme", - "license": "ISC", - "main": "log.js", - "maintainers": [ - { - "name": "iarna", - "email": "me@re-becca.org" - }, - { - "name": "isaacs", - "email": "i@izs.me" - }, - { - "name": "othiym23", - "email": "ogd@aoaioxxysz.net" - }, - { - "name": "zkat", - "email": "kat@sykosomatic.org" - } - ], - "name": "npmlog", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/npm/npmlog.git" - }, - "scripts": { - "test": "standard && tap test/*.js" - }, - "version": "3.1.2" -} diff --git a/deps/npm/node_modules/npm-registry-client/package.json b/deps/npm/node_modules/npm-registry-client/package.json index f463851a8978b5..e3e6fdd841f5d5 100644 --- a/deps/npm/node_modules/npm-registry-client/package.json +++ b/deps/npm/node_modules/npm-registry-client/package.json @@ -2,55 +2,51 @@ "_args": [ [ { - "raw": "npm-registry-client@7.3.0", + "raw": "npm-registry-client@~7.4.5", "scope": null, "escapedName": "npm-registry-client", "name": "npm-registry-client", - "rawSpec": "7.3.0", - "spec": "7.3.0", - "type": "version" + "rawSpec": "~7.4.5", + "spec": ">=7.4.5 <7.5.0", + "type": "range" }, "/Users/rebecca/code/npm" ] ], - "_from": "npm-registry-client@7.3.0", - "_id": "npm-registry-client@7.3.0", + "_from": "npm-registry-client@>=7.4.5 <7.5.0", + "_id": "npm-registry-client@7.4.5", "_inCache": true, "_location": "/npm-registry-client", - "_nodeVersion": "6.7.0", + "_nodeVersion": "6.9.1", "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/npm-registry-client-7.3.0.tgz_1476956977374_0.8605887587182224" + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/npm-registry-client-7.4.5.tgz_1481241713365_0.3974522119387984" }, "_npmUser": { "name": "iarna", "email": "me@re-becca.org" }, - "_npmVersion": "3.10.9", + "_npmVersion": "4.0.5", "_phantomChildren": { - "aproba": "1.0.4", - "has-unicode": "2.0.1", - "inherits": "2.0.3", - "readable-stream": "2.1.5", - "strip-ansi": "3.0.1" + "inherits": "2.0.3" }, "_requested": { - "raw": "npm-registry-client@7.3.0", + "raw": "npm-registry-client@~7.4.5", "scope": null, "escapedName": "npm-registry-client", "name": "npm-registry-client", - "rawSpec": "7.3.0", - "spec": "7.3.0", - "type": "version" + "rawSpec": "~7.4.5", + "spec": ">=7.4.5 <7.5.0", + "type": "range" }, "_requiredBy": [ "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-7.3.0.tgz", - "_shasum": "f2a390e8b13b78fafe26e9fa9d8bc74e17bcaa50", + "_resolved": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-7.4.5.tgz", + "_shasum": "1ef61851bb7231db53e397aaf76ddf1cb645c3df", "_shrinkwrap": null, - "_spec": "npm-registry-client@7.3.0", + "_spec": "npm-registry-client@~7.4.5", "_where": "/Users/rebecca/code/npm", "author": { "name": "Isaac Z. Schlueter", @@ -65,7 +61,7 @@ "graceful-fs": "^4.1.6", "normalize-package-data": "~1.0.1 || ^2.0.0", "npm-package-arg": "^3.0.0 || ^4.0.0", - "npmlog": "~2.0.0 || ~3.1.0", + "npmlog": "2 || ^3.1.0 || ^4.0.0", "once": "^1.3.3", "request": "^2.74.0", "retry": "^0.10.0", @@ -77,16 +73,17 @@ "negotiator": "^0.6.1", "nock": "^8.0.0", "readable-stream": "^2.1.5", + "require-inject": "^1.4.0", "rimraf": "^2.5.4", - "standard": "^8.0.0", + "standard": "~8.5.0", "tap": "^7.0.0" }, "directories": {}, "dist": { - "shasum": "f2a390e8b13b78fafe26e9fa9d8bc74e17bcaa50", - "tarball": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-7.3.0.tgz" + "shasum": "1ef61851bb7231db53e397aaf76ddf1cb645c3df", + "tarball": "https://registry.npmjs.org/npm-registry-client/-/npm-registry-client-7.4.5.tgz" }, - "gitHead": "0e0a707dcf62e9705ef17b7d471d3657c33e79e6", + "gitHead": "317216fab0684ea642b46890be234ad3e8665ac1", "homepage": "https://github.com/npm/npm-registry-client#readme", "license": "ISC", "main": "index.js", @@ -110,7 +107,7 @@ ], "name": "npm-registry-client", "optionalDependencies": { - "npmlog": "~2.0.0 || ~3.1.0" + "npmlog": "2 || ^3.1.0 || ^4.0.0" }, "readme": "ERROR: No README data found!", "repository": { @@ -119,5 +116,5 @@ "scripts": { "test": "standard && tap test/*.js" }, - "version": "7.3.0" + "version": "7.4.5" } diff --git a/deps/npm/node_modules/npm-registry-client/test/econnreset.js b/deps/npm/node_modules/npm-registry-client/test/econnreset.js new file mode 100644 index 00000000000000..ee0657112bc206 --- /dev/null +++ b/deps/npm/node_modules/npm-registry-client/test/econnreset.js @@ -0,0 +1,95 @@ +'use strict' +var requireInject = require('require-inject') +var test = require('tap').test +var EventEmitter = require('events').EventEmitter +var PassThrough = require('readable-stream').PassThrough + +var content = [ + 'first chunk', + 'second chunk' +] +var requests = 0 +var fetch = requireInject('../lib/fetch.js', { + request: function (opts) { + var req = new EventEmitter() + ++requests + setTimeout(function () { + var res = new PassThrough() + res.statusCode = 200 + + setTimeout(function () { + res.write(content[0]) + }, 50) + + if (requests === 1) { + setTimeout(function () { + var err = new Error('read ECONNRESET') + err.code = 'ECONNRESET' + req.emit('error', err) + }, 100) + } else { + // we allow success on retries, though in practice we won't be + // retrying. + setTimeout(function () { + res.end(content[1]) + }, 100) + } + req.emit('response', res) + }, 50) + return req + } +}) + +function clientMock (t) { + return { + log: { + info: function (section, message) { + t.comment('[info] ' + section + ': ' + [].slice.call(arguments, 1).join(' ')) + }, + http: function (section, message) { + t.comment('[http] ' + section + ': ' + [].slice.call(arguments, 1).join(' ')) + } + }, + authify: function (alwaysAuth, parsed, headers, auth) { + return + }, + initialize: function (parsed, method, accept, headers) { + return {} + }, + attempt: require('../lib/attempt.js'), + config: { + retry: { + retries: 2, + factor: 10, + minTimeout: 10000, + maxTimeout: 60000 + } + } + } +} + +/* +This tests that errors that occur in the REQUEST object AFTER a `response` +event has been emitted will be passed through to the `response` stream. +This means that we won't try to retry these sorts of errors ourselves. +*/ + +test('econnreset', function (t) { + var client = clientMock(t) + fetch.call(client, 'http://example.com/', {}, function (err, res) { + t.ifError(err, 'initial fetch ok') + var data = '' + res.on('data', function (chunk) { + data += chunk + }) + res.on('error', function (err) { + t.comment('ERROR:', err.stack) + t.pass("errored and that's ok") + t.done() + }) + res.on('end', function () { + t.is(data, content.join(''), 'succeeded and got the right data') + t.done() + }) + }) +}) diff --git a/deps/npm/node_modules/npm-registry-client/test/lib/server.js b/deps/npm/node_modules/npm-registry-client/test/lib/server.js index 06bebdc139306d..3a702e67965861 100644 --- a/deps/npm/node_modules/npm-registry-client/test/lib/server.js +++ b/deps/npm/node_modules/npm-registry-client/test/lib/server.js @@ -12,7 +12,6 @@ server._expect = {} function handler (req, res) { req.connection.setTimeout(1000) - // If we got authorization, make sure it's the right password. if (req.headers.authorization && req.headers.authorization.match(/^Basic/)) { var auth = req.headers.authorization.replace(/^Basic /, '') diff --git a/deps/npm/node_modules/npm-registry-client/test/send-anon-metrics.js b/deps/npm/node_modules/npm-registry-client/test/send-anon-metrics.js new file mode 100644 index 00000000000000..7afa0542c434de --- /dev/null +++ b/deps/npm/node_modules/npm-registry-client/test/send-anon-metrics.js @@ -0,0 +1,78 @@ +var test = require('tap').test + +var common = require('./lib/common.js') +var client = common.freshClient() +var server = require('./lib/server.js') + +function nop () {} + +var metricId = 'this-is-a-uuid' +var from = new Date() +var to = new Date() +var metricInfo = { + metricId: metricId, + metrics: [{ + from: from.toISOString(), + to: to.toISOString(), + successfulInstalls: 0, + failedInstalls: 1 + }] +} + +test('sendAnonymousCLIMetrics call contract', function (t) { + t.throws(function () { + client.sendAnonymousCLIMetrics(undefined, metricInfo, nop) + }, 'requires a URI') + + t.throws(function () { + client.sendAnonymousCLIMetrics([], metricInfo, nop) + }, 'requires URI to be a string') + + t.throws(function () { + client.sendAnonymousCLIMetrics(common.registry, undefined, nop) + }, 'requires params object') + + t.throws(function () { + client.sendAnonymousCLIMetrics(common.registry, '', nop) + }, 'params must be object') + + t.throws(function () { + client.sendAnonymousCLIMetrics(common.registry, metricInfo, undefined) + }, 'requires callback') + + t.throws(function () { + client.sendAnonymousCLIMetrics(common.registry, metricInfo, 'callback') + }, 'callback must be function') + + t.end() +}) + +test('sendAnonymousCLIMetrics', function (t) { + server.expect('PUT', '/-/npm/anon-metrics/v1/' + metricId, function (req, res) { + t.is(req.method, 'PUT') + var b = '' + req.setEncoding('utf8') + req.on('data', function (d) { + b += d + }) + + req.on('end', function () { + var d = JSON.parse(b) + t.isDeeply(d, metricInfo.metrics, 'PUT received metrics') + + res.statusCode = 200 + res.json({}) + }) + }) + + client.sendAnonymousCLIMetrics(common.registry, metricInfo, function (err, res) { + t.ifError(err, 'no errors') + t.isDeeply(res, {}, 'result ok') + t.end() + }) +}) + +test('cleanup', function (t) { + server.close() + t.end() +}) diff --git a/deps/npm/node_modules/npmlog/README.md b/deps/npm/node_modules/npmlog/README.md index dba35501614e91..268a4af41d6282 100644 --- a/deps/npm/node_modules/npmlog/README.md +++ b/deps/npm/node_modules/npmlog/README.md @@ -10,9 +10,15 @@ to outputs other than streams, then you can change the `log.stream` member, or you can just listen to the events that it emits, and do whatever you want with them. -# Basic Usage +# Installation +```console +npm install npmlog --save ``` + +# Basic Usage + +```javascript var log = require('npmlog') // additional stuff ---------------------------+ diff --git a/deps/npm/node_modules/npmlog/node_modules/gauge/CHANGELOG.md b/deps/npm/node_modules/npmlog/node_modules/gauge/CHANGELOG.md index e64d969fed28a8..dcd9fe01771284 100644 --- a/deps/npm/node_modules/npmlog/node_modules/gauge/CHANGELOG.md +++ b/deps/npm/node_modules/npmlog/node_modules/gauge/CHANGELOG.md @@ -1,3 +1,7 @@ +### v2.7.2 + +* Use supports-color instead of has-color (as the module has been renamed) + ### v2.7.1 * Bug fix: Calls to show/pulse while the progress bar is disabled should still diff --git a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color/index.js b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color/index.js deleted file mode 100644 index 092d0baef6698e..00000000000000 --- a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color/index.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; -module.exports = (function () { - if (process.argv.indexOf('--no-color') !== -1) { - return false; - } - - if (process.argv.indexOf('--color') !== -1) { - return true; - } - - if (process.stdout && !process.stdout.isTTY) { - return false; - } - - if (process.platform === 'win32') { - return true; - } - - if ('COLORTERM' in process.env) { - return true; - } - - if (process.env.TERM === 'dumb') { - return false; - } - - if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) { - return true; - } - - return false; -})(); diff --git a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color/package.json b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color/package.json deleted file mode 100644 index 2e469520b4255d..00000000000000 --- a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color/package.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "_args": [ - [ - "has-color@^0.1.7", - "/Users/rebecca/code/npm-with-new-gauge/node_modules/npmlog/node_modules/gauge" - ] - ], - "_from": "has-color@>=0.1.7 <0.2.0", - "_id": "has-color@0.1.7", - "_inCache": true, - "_installable": true, - "_location": "/npmlog/gauge/has-color", - "_npmUser": { - "email": "sindresorhus@gmail.com", - "name": "sindresorhus" - }, - "_npmVersion": "1.4.6", - "_phantomChildren": {}, - "_requested": { - "name": "has-color", - "raw": "has-color@^0.1.7", - "rawSpec": "^0.1.7", - "scope": null, - "spec": ">=0.1.7 <0.2.0", - "type": "range" - }, - "_requiredBy": [ - "/npmlog/gauge" - ], - "_resolved": "https://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz", - "_shasum": "67144a5260c34fc3cca677d041daf52fe7b78b2f", - "_shrinkwrap": null, - "_spec": "has-color@^0.1.7", - "_where": "/Users/rebecca/code/npm-with-new-gauge/node_modules/npmlog/node_modules/gauge", - "author": { - "email": "sindresorhus@gmail.com", - "name": "Sindre Sorhus", - "url": "http://sindresorhus.com" - }, - "bugs": { - "url": "https://github.com/sindresorhus/has-color/issues" - }, - "dependencies": {}, - "description": "Detect whether a terminal supports color", - "devDependencies": { - "mocha": "*" - }, - "directories": {}, - "dist": { - "shasum": "67144a5260c34fc3cca677d041daf52fe7b78b2f", - "tarball": "http://registry.npmjs.org/has-color/-/has-color-0.1.7.tgz" - }, - "engines": { - "node": ">=0.10.0" - }, - "files": [ - "index.js" - ], - "homepage": "https://github.com/sindresorhus/has-color", - "keywords": [ - "color", - "colour", - "colors", - "terminal", - "console", - "cli", - "ansi", - "styles", - "tty", - "rgb", - "256", - "shell", - "xterm", - "command-line", - "support", - "capability", - "detect" - ], - "license": "MIT", - "maintainers": [ - { - "email": "sindresorhus@gmail.com", - "name": "sindresorhus" - } - ], - "name": "has-color", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git://github.com/sindresorhus/has-color.git" - }, - "scripts": { - "test": "mocha" - }, - "version": "0.1.7" -} diff --git a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color/readme.md b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color/readme.md deleted file mode 100644 index 37bbd8991a6423..00000000000000 --- a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/has-color/readme.md +++ /dev/null @@ -1,30 +0,0 @@ -# has-color [![Build Status](https://travis-ci.org/sindresorhus/has-color.svg?branch=master)](https://travis-ci.org/sindresorhus/has-color) - -> Detect whether a terminal supports color. - -Used in the terminal color module [chalk](https://github.com/sindresorhus/chalk). - - -## Install - -```bash -$ npm install --save has-color -``` - - -## Usage - -```js -var hasColor = require('has-color'); - -if (hasColor) { - console.log('Terminal supports color.'); -} -``` - -It obeys the `--color` and `--no-color` CLI flags. - - -## License - -[MIT](http://opensource.org/licenses/MIT) © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js index 7dd8d917dc507b..337f691ed23b1c 100644 --- a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js +++ b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/index.js @@ -19,6 +19,15 @@ if (process.__signal_exit_emitter__) { emitter.emitted = {} } +// Because this emitter is a global, we have to check to see if a +// previous version of this library failed to enable infinite listeners. +// I know what you're about to say. But literally everything about +// signal-exit is a compromise with evil. Get used to it. +if (!emitter.infinite) { + emitter.setMaxListeners(Infinity) + emitter.infinite = true +} + module.exports = function (cb, opts) { assert.equal(typeof cb, 'function', 'a callback must be provided for exit handler') diff --git a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/package.json b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/package.json index 84b00e1d11611c..e3792dd72e0650 100644 --- a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/package.json +++ b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/signal-exit/package.json @@ -10,35 +10,23 @@ "spec": ">=3.0.0 <4.0.0", "type": "range" }, - "/Users/rebecca/code/npm2/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge" - ], - [ - { - "raw": "signal-exit@^3.0.0", - "scope": null, - "escapedName": "signal-exit", - "name": "signal-exit", - "rawSpec": "^3.0.0", - "spec": ">=3.0.0 <4.0.0", - "type": "range" - }, - "/Users/rebecca/code/npm2/node_modules/npmlog/node_modules/gauge" + "/Users/rebecca/code/npm/node_modules/npmlog/node_modules/gauge" ] ], - "_from": "signal-exit@^3.0.0", - "_id": "signal-exit@3.0.1", + "_from": "signal-exit@>=3.0.0 <4.0.0", + "_id": "signal-exit@3.0.2", "_inCache": true, "_location": "/npmlog/gauge/signal-exit", "_nodeVersion": "6.5.0", "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/signal-exit-3.0.1.tgz_1473354783379_0.4592130535747856" + "host": "packages-18-east.internal.npmjs.com", + "tmp": "tmp/signal-exit-3.0.2.tgz_1480821660838_0.6809983775019646" }, "_npmUser": { - "name": "bcoe", - "email": "ben@npmjs.com" + "name": "isaacs", + "email": "i@izs.me" }, - "_npmVersion": "3.10.3", + "_npmVersion": "3.10.9", "_phantomChildren": {}, "_requested": { "raw": "signal-exit@^3.0.0", @@ -52,11 +40,11 @@ "_requiredBy": [ "/npmlog/gauge" ], - "_resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.1.tgz", - "_shasum": "5a4c884992b63a7acd9badb7894c3ee9cfccad81", + "_resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", + "_shasum": "b5fdc08f1287ea1178628e415e25132b73646c6d", "_shrinkwrap": null, "_spec": "signal-exit@^3.0.0", - "_where": "/Users/rebecca/code/npm2/node_modules/npmlog/node_modules/gauge", + "_where": "/Users/rebecca/code/npm/node_modules/npmlog/node_modules/gauge", "author": { "name": "Ben Coe", "email": "ben@npmjs.com" @@ -72,18 +60,18 @@ "nyc": "^8.1.0", "standard": "^7.1.2", "standard-version": "^2.3.0", - "tap": "^7.1.0" + "tap": "^8.0.1" }, "directories": {}, "dist": { - "shasum": "5a4c884992b63a7acd9badb7894c3ee9cfccad81", - "tarball": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.1.tgz" + "shasum": "b5fdc08f1287ea1178628e415e25132b73646c6d", + "tarball": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz" }, "files": [ "index.js", "signals.js" ], - "gitHead": "6859aff54f5198c63fff91baef279b86026bde69", + "gitHead": "9c5ad9809fe6135ef22e2623989deaffe2a4fa8a", "homepage": "https://github.com/tapjs/signal-exit", "keywords": [ "signal", @@ -114,5 +102,5 @@ "release": "standard-version", "test": "tap --timeout=240 ./test/*.js --cov" }, - "version": "3.0.1" + "version": "3.0.2" } diff --git a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/cli.js b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/cli.js new file mode 100755 index 00000000000000..0617971e6fdbef --- /dev/null +++ b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/cli.js @@ -0,0 +1,28 @@ +#!/usr/bin/env node +'use strict'; +var pkg = require('./package.json'); +var supportsColor = require('./'); +var input = process.argv[2]; + +function help() { + console.log([ + pkg.description, + '', + 'Usage', + ' $ supports-color', + '', + 'Exits with code 0 if color is supported and 1 if not' + ].join('\n')); +} + +if (!input || process.argv.indexOf('--help') !== -1) { + help(); + return; +} + +if (process.argv.indexOf('--version') !== -1) { + console.log(pkg.version); + return; +} + +process.exit(supportsColor ? 0 : 1); diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-color/index.js b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/index.js similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/has-color/index.js rename to deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/index.js diff --git a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/package.json b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/package.json new file mode 100644 index 00000000000000..4a834e57864d09 --- /dev/null +++ b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/package.json @@ -0,0 +1,112 @@ +{ + "_args": [ + [ + { + "raw": "supports-color@^0.2.0", + "scope": null, + "escapedName": "supports-color", + "name": "supports-color", + "rawSpec": "^0.2.0", + "spec": ">=0.2.0 <0.3.0", + "type": "range" + }, + "/Users/rebecca/code/npm/node_modules/npmlog/node_modules/gauge" + ] + ], + "_from": "supports-color@>=0.2.0 <0.3.0", + "_id": "supports-color@0.2.0", + "_inCache": true, + "_location": "/npmlog/gauge/supports-color", + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "_npmVersion": "1.4.9", + "_phantomChildren": {}, + "_requested": { + "raw": "supports-color@^0.2.0", + "scope": null, + "escapedName": "supports-color", + "name": "supports-color", + "rawSpec": "^0.2.0", + "spec": ">=0.2.0 <0.3.0", + "type": "range" + }, + "_requiredBy": [ + "/npmlog/gauge" + ], + "_resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", + "_shasum": "d92de2694eb3f67323973d7ae3d8b55b4c22190a", + "_shrinkwrap": null, + "_spec": "supports-color@^0.2.0", + "_where": "/Users/rebecca/code/npm/node_modules/npmlog/node_modules/gauge", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "http://sindresorhus.com" + }, + "bin": { + "supports-color": "cli.js" + }, + "bugs": { + "url": "https://github.com/sindresorhus/supports-color/issues" + }, + "dependencies": {}, + "description": "Detect whether a terminal supports color", + "devDependencies": { + "mocha": "*" + }, + "directories": {}, + "dist": { + "shasum": "d92de2694eb3f67323973d7ae3d8b55b4c22190a", + "tarball": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz" + }, + "engines": { + "node": ">=0.10.0" + }, + "files": [ + "index.js", + "cli.js" + ], + "homepage": "https://github.com/sindresorhus/supports-color", + "keywords": [ + "cli", + "bin", + "color", + "colour", + "colors", + "terminal", + "console", + "cli", + "ansi", + "styles", + "tty", + "rgb", + "256", + "shell", + "xterm", + "command-line", + "support", + "supports", + "capability", + "detect" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "supports-color", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git://github.com/sindresorhus/supports-color.git" + }, + "scripts": { + "test": "mocha" + }, + "version": "0.2.0" +} diff --git a/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/readme.md b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/readme.md new file mode 100644 index 00000000000000..7f07e5fb0f5267 --- /dev/null +++ b/deps/npm/node_modules/npmlog/node_modules/gauge/node_modules/supports-color/readme.md @@ -0,0 +1,44 @@ +# supports-color [![Build Status](https://travis-ci.org/sindresorhus/supports-color.svg?branch=master)](https://travis-ci.org/sindresorhus/supports-color) + +> Detect whether a terminal supports color + + +## Install + +```sh +$ npm install --save supports-color +``` + + +## Usage + +```js +var supportsColor = require('supports-color'); + +if (supportsColor) { + console.log('Terminal supports color'); +} +``` + +It obeys the `--color` and `--no-color` CLI flags. + + +## CLI + +```sh +$ npm install --global supports-color +``` + +```sh +$ supports-color --help + +Usage + $ supports-color + +# Exits with code 0 if color is supported and 1 if not +``` + + +## License + +MIT © [Sindre Sorhus](http://sindresorhus.com) diff --git a/deps/npm/node_modules/npmlog/node_modules/gauge/package.json b/deps/npm/node_modules/npmlog/node_modules/gauge/package.json index 9ab6582b5072c9..ed2eb61e985030 100644 --- a/deps/npm/node_modules/npmlog/node_modules/gauge/package.json +++ b/deps/npm/node_modules/npmlog/node_modules/gauge/package.json @@ -10,23 +10,23 @@ "spec": ">=2.7.1 <2.8.0", "type": "range" }, - "/Users/rebecca/code/npm-latest/node_modules/npmlog" + "/Users/rebecca/code/npm/node_modules/npmlog" ] ], "_from": "gauge@>=2.7.1 <2.8.0", - "_id": "gauge@2.7.1", + "_id": "gauge@2.7.2", "_inCache": true, "_location": "/npmlog/gauge", "_nodeVersion": "6.9.1", "_npmOperationalInternal": { - "host": "packages-18-east.internal.npmjs.com", - "tmp": "tmp/gauge-2.7.1.tgz_1478210591065_0.5937802786938846" + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/gauge-2.7.2.tgz_1480851024801_0.17901206784881651" }, "_npmUser": { "name": "iarna", "email": "me@re-becca.org" }, - "_npmVersion": "4.0.0", + "_npmVersion": "4.0.5", "_phantomChildren": { "strip-ansi": "3.0.1" }, @@ -42,11 +42,11 @@ "_requiredBy": [ "/npmlog" ], - "_resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.1.tgz", - "_shasum": "388473894fe8be5e13ffcdb8b93e4ed0616428c7", + "_resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.2.tgz", + "_shasum": "15cecc31b02d05345a5d6b0e171cdb3ad2307774", "_shrinkwrap": null, "_spec": "gauge@~2.7.1", - "_where": "/Users/rebecca/code/npm-latest/node_modules/npmlog", + "_where": "/Users/rebecca/code/npm/node_modules/npmlog", "author": { "name": "Rebecca Turner", "email": "me@re-becca.org" @@ -57,12 +57,12 @@ "dependencies": { "aproba": "^1.0.3", "console-control-strings": "^1.0.0", - "has-color": "^0.1.7", "has-unicode": "^2.0.0", "object-assign": "^4.1.0", "signal-exit": "^3.0.0", "string-width": "^1.0.1", "strip-ansi": "^3.0.1", + "supports-color": "^0.2.0", "wide-align": "^1.1.0" }, "description": "A terminal based horizontal guage", @@ -75,8 +75,8 @@ }, "directories": {}, "dist": { - "shasum": "388473894fe8be5e13ffcdb8b93e4ed0616428c7", - "tarball": "https://registry.npmjs.org/gauge/-/gauge-2.7.1.tgz" + "shasum": "15cecc31b02d05345a5d6b0e171cdb3ad2307774", + "tarball": "https://registry.npmjs.org/gauge/-/gauge-2.7.2.tgz" }, "files": [ "base-theme.js", @@ -99,7 +99,7 @@ "themes.js", "wide-truncate.js" ], - "gitHead": "d7ac37af0a44af2315656fb73f76f6bca03d084e", + "gitHead": "6971e27a577d165cde360ebed86a59dfc18ac55b", "homepage": "https://github.com/iarna/gauge", "keywords": [ "progressbar", @@ -125,5 +125,5 @@ "prepublish": "rm -f *~", "test": "standard && tap test/*.js --coverage" }, - "version": "2.7.1" + "version": "2.7.2" } diff --git a/deps/npm/node_modules/npmlog/package.json b/deps/npm/node_modules/npmlog/package.json index 1a2fd8b0243e68..bab110a08ee825 100644 --- a/deps/npm/node_modules/npmlog/package.json +++ b/deps/npm/node_modules/npmlog/package.json @@ -2,31 +2,31 @@ "_args": [ [ { - "raw": "npmlog@4.0.1", + "raw": "npmlog@4.0.2", "scope": null, "escapedName": "npmlog", "name": "npmlog", - "rawSpec": "4.0.1", - "spec": "4.0.1", + "rawSpec": "4.0.2", + "spec": "4.0.2", "type": "version" }, - "/Users/rebecca/code/npm-latest" + "/Users/rebecca/code/npm" ] ], - "_from": "npmlog@4.0.1", - "_id": "npmlog@4.0.1", + "_from": "npmlog@4.0.2", + "_id": "npmlog@4.0.2", "_inCache": true, "_location": "/npmlog", - "_nodeVersion": "7.1.0", + "_nodeVersion": "7.2.0", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/npmlog-4.0.1.tgz_1479345245313_0.32757814647629857" + "tmp": "tmp/npmlog-4.0.2.tgz_1481572338217_0.2948465726803988" }, "_npmUser": { - "name": "iarna", - "email": "me@re-becca.org" + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" }, - "_npmVersion": "3.10.10", + "_npmVersion": "4.0.5", "_phantomChildren": { "aproba": "1.0.4", "has-unicode": "2.0.1", @@ -34,23 +34,24 @@ "strip-ansi": "3.0.1" }, "_requested": { - "raw": "npmlog@4.0.1", + "raw": "npmlog@4.0.2", "scope": null, "escapedName": "npmlog", "name": "npmlog", - "rawSpec": "4.0.1", - "spec": "4.0.1", + "rawSpec": "4.0.2", + "spec": "4.0.2", "type": "version" }, "_requiredBy": [ "#USER", - "/" + "/", + "/npm-registry-client" ], - "_resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.0.1.tgz", - "_shasum": "d14f503b4cd79710375553004ba96e6662fbc0b8", + "_resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.0.2.tgz", + "_shasum": "d03950e0e78ce1527ba26d2a7592e9348ac3e75f", "_shrinkwrap": null, - "_spec": "npmlog@4.0.1", - "_where": "/Users/rebecca/code/npm-latest", + "_spec": "npmlog@4.0.2", + "_where": "/Users/rebecca/code/npm", "author": { "name": "Isaac Z. Schlueter", "email": "i@izs.me", @@ -72,13 +73,13 @@ }, "directories": {}, "dist": { - "shasum": "d14f503b4cd79710375553004ba96e6662fbc0b8", - "tarball": "https://registry.npmjs.org/npmlog/-/npmlog-4.0.1.tgz" + "shasum": "d03950e0e78ce1527ba26d2a7592e9348ac3e75f", + "tarball": "https://registry.npmjs.org/npmlog/-/npmlog-4.0.2.tgz" }, "files": [ "log.js" ], - "gitHead": "c027c276f6f7e6c8d808767b0d611555e3ef5f61", + "gitHead": "a3b7aed07790b674aa1fecfc81a61481abeaf882", "homepage": "https://github.com/npm/npmlog#readme", "license": "ISC", "main": "log.js", @@ -110,5 +111,5 @@ "scripts": { "test": "standard && tap test/*.js" }, - "version": "4.0.1" + "version": "4.0.2" } diff --git a/deps/npm/node_modules/osenv/node_modules/os-homedir/package.json b/deps/npm/node_modules/osenv/node_modules/os-homedir/package.json index 53c8c6e5e62c4d..c2765cdae36e55 100644 --- a/deps/npm/node_modules/osenv/node_modules/os-homedir/package.json +++ b/deps/npm/node_modules/osenv/node_modules/os-homedir/package.json @@ -1,28 +1,80 @@ { - "name": "os-homedir", - "version": "1.0.1", - "description": "io.js 2.3.0 os.homedir() ponyfill", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/os-homedir.git" + "_args": [ + [ + { + "raw": "os-homedir@^1.0.0", + "scope": null, + "escapedName": "os-homedir", + "name": "os-homedir", + "rawSpec": "^1.0.0", + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "/Users/rebecca/code/npm/node_modules/osenv" + ] + ], + "_from": "os-homedir@>=1.0.0 <2.0.0", + "_id": "os-homedir@1.0.2", + "_inCache": true, + "_location": "/osenv/os-homedir", + "_nodeVersion": "6.6.0", + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/os-homedir-1.0.2.tgz_1475211519628_0.7873868853785098" + }, + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "_npmVersion": "3.10.3", + "_phantomChildren": {}, + "_requested": { + "raw": "os-homedir@^1.0.0", + "scope": null, + "escapedName": "os-homedir", + "name": "os-homedir", + "rawSpec": "^1.0.0", + "spec": ">=1.0.0 <2.0.0", + "type": "range" }, + "_requiredBy": [ + "/osenv" + ], + "_resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "_shasum": "ffbc4988336e0e833de0c168c7ef152121aa7fb3", + "_shrinkwrap": null, + "_spec": "os-homedir@^1.0.0", + "_where": "/Users/rebecca/code/npm/node_modules/osenv", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, + "bugs": { + "url": "https://github.com/sindresorhus/os-homedir/issues" + }, + "dependencies": {}, + "description": "Node.js 4 `os.homedir()` ponyfill", + "devDependencies": { + "ava": "*", + "path-exists": "^2.0.0", + "xo": "^0.16.0" + }, + "directories": {}, + "dist": { + "shasum": "ffbc4988336e0e833de0c168c7ef152121aa7fb3", + "tarball": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz" + }, "engines": { "node": ">=0.10.0" }, - "scripts": { - "test": "node test.js" - }, "files": [ "index.js" ], + "gitHead": "b1b0ae70a5965fef7005ff6509a5dd1a78c95e36", + "homepage": "https://github.com/sindresorhus/os-homedir#readme", "keywords": [ - "built-in", + "builtin", "core", "ponyfill", "polyfill", @@ -36,18 +88,22 @@ "user", "path" ], - "devDependencies": { - "ava": "0.0.4", - "path-exists": "^1.0.0" + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "os-homedir", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/os-homedir.git" }, - "readme": "# os-homedir [![Build Status](https://travis-ci.org/sindresorhus/os-homedir.svg?branch=master)](https://travis-ci.org/sindresorhus/os-homedir)\n\n> io.js 2.3.0 [`os.homedir()`](https://iojs.org/api/os.html#os_os_homedir) ponyfill\n\n> Ponyfill: A polyfill that doesn't overwrite the native method\n\n\n## Install\n\n```\n$ npm install --save os-homedir\n```\n\n\n## Usage\n\n```js\nvar osHomedir = require('os-homedir');\n\nconsole.log(osHomedir());\n//=> /Users/sindresorhus\n```\n\n\n## Related\n\n- [user-home](https://github.com/sindresorhus/user-home) - Same as this module but caches the result\n- [home-or-tmp](https://github.com/sindresorhus/home-or-tmp) - Get the user home directory with fallback to the system temp directory\n\n\n## License\n\nMIT © [Sindre Sorhus](http://sindresorhus.com)\n", - "readmeFilename": "readme.md", - "bugs": { - "url": "https://github.com/sindresorhus/os-homedir/issues" + "scripts": { + "test": "xo && ava" }, - "homepage": "https://github.com/sindresorhus/os-homedir#readme", - "_id": "os-homedir@1.0.1", - "_shasum": "0d62bdf44b916fd3bbdcf2cab191948fb094f007", - "_resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.1.tgz", - "_from": "os-homedir@>=1.0.0 <2.0.0" + "version": "1.0.2" } diff --git a/deps/npm/node_modules/osenv/node_modules/os-homedir/readme.md b/deps/npm/node_modules/osenv/node_modules/os-homedir/readme.md index 4851f104ea7134..856ae615b0c0bb 100644 --- a/deps/npm/node_modules/osenv/node_modules/os-homedir/readme.md +++ b/deps/npm/node_modules/osenv/node_modules/os-homedir/readme.md @@ -1,8 +1,6 @@ # os-homedir [![Build Status](https://travis-ci.org/sindresorhus/os-homedir.svg?branch=master)](https://travis-ci.org/sindresorhus/os-homedir) -> io.js 2.3.0 [`os.homedir()`](https://iojs.org/api/os.html#os_os_homedir) ponyfill - -> Ponyfill: A polyfill that doesn't overwrite the native method +> Node.js 4 [`os.homedir()`](https://nodejs.org/api/os.html#os_os_homedir) [ponyfill](https://ponyfill.com) ## Install @@ -15,10 +13,10 @@ $ npm install --save os-homedir ## Usage ```js -var osHomedir = require('os-homedir'); +const osHomedir = require('os-homedir'); console.log(osHomedir()); -//=> /Users/sindresorhus +//=> '/Users/sindresorhus' ``` @@ -30,4 +28,4 @@ console.log(osHomedir()); ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/deps/npm/node_modules/osenv/node_modules/os-tmpdir/index.js b/deps/npm/node_modules/osenv/node_modules/os-tmpdir/index.js index 52d90bf2698008..2077b1ce747129 100644 --- a/deps/npm/node_modules/osenv/node_modules/os-tmpdir/index.js +++ b/deps/npm/node_modules/osenv/node_modules/os-tmpdir/index.js @@ -2,7 +2,7 @@ var isWindows = process.platform === 'win32'; var trailingSlashRe = isWindows ? /[^:]\\$/ : /.\/$/; -// https://github.com/nodejs/io.js/blob/3e7a14381497a3b73dda68d05b5130563cdab420/lib/os.js#L25-L43 +// https://github.com/nodejs/node/blob/3e7a14381497a3b73dda68d05b5130563cdab420/lib/os.js#L25-L43 module.exports = function () { var path; diff --git a/deps/npm/node_modules/osenv/node_modules/os-tmpdir/package.json b/deps/npm/node_modules/osenv/node_modules/os-tmpdir/package.json index 071ea5ec83fa23..272d9e55329f34 100644 --- a/deps/npm/node_modules/osenv/node_modules/os-tmpdir/package.json +++ b/deps/npm/node_modules/osenv/node_modules/os-tmpdir/package.json @@ -1,26 +1,77 @@ { - "name": "os-tmpdir", - "version": "1.0.1", - "description": "Node.js os.tmpdir() ponyfill", - "license": "MIT", - "repository": { - "type": "git", - "url": "git+https://github.com/sindresorhus/os-tmpdir.git" + "_args": [ + [ + { + "raw": "os-tmpdir@^1.0.0", + "scope": null, + "escapedName": "os-tmpdir", + "name": "os-tmpdir", + "rawSpec": "^1.0.0", + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "/Users/rebecca/code/npm/node_modules/osenv" + ] + ], + "_from": "os-tmpdir@>=1.0.0 <2.0.0", + "_id": "os-tmpdir@1.0.2", + "_inCache": true, + "_location": "/osenv/os-tmpdir", + "_nodeVersion": "6.6.0", + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/os-tmpdir-1.0.2.tgz_1475211274587_0.14931037812493742" + }, + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" }, + "_npmVersion": "3.10.3", + "_phantomChildren": {}, + "_requested": { + "raw": "os-tmpdir@^1.0.0", + "scope": null, + "escapedName": "os-tmpdir", + "name": "os-tmpdir", + "rawSpec": "^1.0.0", + "spec": ">=1.0.0 <2.0.0", + "type": "range" + }, + "_requiredBy": [ + "/osenv" + ], + "_resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", + "_shasum": "bbe67406c79aa85c5cfec766fe5734555dfa1274", + "_shrinkwrap": null, + "_spec": "os-tmpdir@^1.0.0", + "_where": "/Users/rebecca/code/npm/node_modules/osenv", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, + "bugs": { + "url": "https://github.com/sindresorhus/os-tmpdir/issues" + }, + "dependencies": {}, + "description": "Node.js os.tmpdir() ponyfill", + "devDependencies": { + "ava": "*", + "xo": "^0.16.0" + }, + "directories": {}, + "dist": { + "shasum": "bbe67406c79aa85c5cfec766fe5734555dfa1274", + "tarball": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz" + }, "engines": { "node": ">=0.10.0" }, - "scripts": { - "test": "node test.js" - }, "files": [ "index.js" ], + "gitHead": "1abf9cf5611b4be7377060ea67054b45cbf6813c", + "homepage": "https://github.com/sindresorhus/os-tmpdir#readme", "keywords": [ "built-in", "core", @@ -37,17 +88,22 @@ "env", "environment" ], - "devDependencies": { - "ava": "0.0.4" + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "os-tmpdir", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/os-tmpdir.git" }, - "readme": "# os-tmpdir [![Build Status](https://travis-ci.org/sindresorhus/os-tmpdir.svg?branch=master)](https://travis-ci.org/sindresorhus/os-tmpdir)\n\n> Node.js [`os.tmpdir()`](https://nodejs.org/api/os.html#os_os_tmpdir) ponyfill\n\n> Ponyfill: A polyfill that doesn't overwrite the native method\n\nUse this instead of `require('os').tmpdir()` to get a consistent behaviour on different Node.js versions (even 0.8).\n\n*This is actually taken from io.js 2.0.2 as it contains some fixes that haven't bubbled up to Node.js yet.*\n\n\n## Install\n\n```\n$ npm install --save os-tmpdir\n```\n\n\n## Usage\n\n```js\nvar osTmpdir = require('os-tmpdir');\n\nosTmpdir();\n//=> /var/folders/m3/5574nnhn0yj488ccryqr7tc80000gn/T\n```\n\n\n## API\n\nSee the [`os.tmpdir()` docs](https://nodejs.org/api/os.html#os_os_tmpdir).\n\n\n## License\n\nMIT © [Sindre Sorhus](http://sindresorhus.com)\n", - "readmeFilename": "readme.md", - "bugs": { - "url": "https://github.com/sindresorhus/os-tmpdir/issues" + "scripts": { + "test": "xo && ava" }, - "homepage": "https://github.com/sindresorhus/os-tmpdir#readme", - "_id": "os-tmpdir@1.0.1", - "_shasum": "e9b423a1edaf479882562e92ed71d7743a071b6e", - "_resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.1.tgz", - "_from": "os-tmpdir@>=1.0.0 <2.0.0" + "version": "1.0.2" } diff --git a/deps/npm/node_modules/osenv/node_modules/os-tmpdir/readme.md b/deps/npm/node_modules/osenv/node_modules/os-tmpdir/readme.md index 54d4c6ec8e5056..c09f7ed8d5f4c3 100644 --- a/deps/npm/node_modules/osenv/node_modules/os-tmpdir/readme.md +++ b/deps/npm/node_modules/osenv/node_modules/os-tmpdir/readme.md @@ -1,12 +1,8 @@ # os-tmpdir [![Build Status](https://travis-ci.org/sindresorhus/os-tmpdir.svg?branch=master)](https://travis-ci.org/sindresorhus/os-tmpdir) -> Node.js [`os.tmpdir()`](https://nodejs.org/api/os.html#os_os_tmpdir) ponyfill +> Node.js [`os.tmpdir()`](https://nodejs.org/api/os.html#os_os_tmpdir) [ponyfill](https://ponyfill.com) -> Ponyfill: A polyfill that doesn't overwrite the native method - -Use this instead of `require('os').tmpdir()` to get a consistent behaviour on different Node.js versions (even 0.8). - -*This is actually taken from io.js 2.0.2 as it contains some fixes that haven't bubbled up to Node.js yet.* +Use this instead of `require('os').tmpdir()` to get a consistent behavior on different Node.js versions (even 0.8). ## Install @@ -19,10 +15,10 @@ $ npm install --save os-tmpdir ## Usage ```js -var osTmpdir = require('os-tmpdir'); +const osTmpdir = require('os-tmpdir'); osTmpdir(); -//=> /var/folders/m3/5574nnhn0yj488ccryqr7tc80000gn/T +//=> '/var/folders/m3/5574nnhn0yj488ccryqr7tc80000gn/T' ``` @@ -33,4 +29,4 @@ See the [`os.tmpdir()` docs](https://nodejs.org/api/os.html#os_os_tmpdir). ## License -MIT © [Sindre Sorhus](http://sindresorhus.com) +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/deps/npm/node_modules/osenv/package.json b/deps/npm/node_modules/osenv/package.json index ac0c03cda62409..fa2454cc35d1c2 100644 --- a/deps/npm/node_modules/osenv/package.json +++ b/deps/npm/node_modules/osenv/package.json @@ -1,24 +1,77 @@ { - "name": "osenv", - "version": "0.1.3", - "main": "osenv.js", - "directories": { - "test": "test" + "_args": [ + [ + { + "raw": "osenv@0.1.4", + "scope": null, + "escapedName": "osenv", + "name": "osenv", + "rawSpec": "0.1.4", + "spec": "0.1.4", + "type": "version" + }, + "/Users/rebecca/code/npm" + ] + ], + "_from": "osenv@0.1.4", + "_id": "osenv@0.1.4", + "_inCache": true, + "_location": "/osenv", + "_nodeVersion": "6.5.0", + "_npmOperationalInternal": { + "host": "packages-18-east.internal.npmjs.com", + "tmp": "tmp/osenv-0.1.4.tgz_1481655889868_0.3980878754518926" + }, + "_npmUser": { + "name": "isaacs", + "email": "i@izs.me" + }, + "_npmVersion": "3.10.9", + "_phantomChildren": {}, + "_requested": { + "raw": "osenv@0.1.4", + "scope": null, + "escapedName": "osenv", + "name": "osenv", + "rawSpec": "0.1.4", + "spec": "0.1.4", + "type": "version" + }, + "_requiredBy": [ + "#USER", + "/", + "/node-gyp" + ], + "_resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz", + "_shasum": "42fe6d5953df06c8064be6f176c3d05aaaa34644", + "_shrinkwrap": null, + "_spec": "osenv@0.1.4", + "_where": "/Users/rebecca/code/npm", + "author": { + "name": "Isaac Z. Schlueter", + "email": "i@izs.me", + "url": "http://blog.izs.me/" + }, + "bugs": { + "url": "https://github.com/npm/osenv/issues" }, "dependencies": { "os-homedir": "^1.0.0", "os-tmpdir": "^1.0.0" }, + "description": "Look up environment settings specific to different operating systems", "devDependencies": { - "tap": "^1.2.0" + "tap": "^8.0.1" }, - "scripts": { - "test": "tap test/*.js" + "directories": { + "test": "test" }, - "repository": { - "type": "git", - "url": "git+https://github.com/npm/osenv.git" + "dist": { + "shasum": "42fe6d5953df06c8064be6f176c3d05aaaa34644", + "tarball": "https://registry.npmjs.org/osenv/-/osenv-0.1.4.tgz" }, + "gitHead": "ef718f0d20e38d45ec452b7faeefc692d3cd1062", + "homepage": "https://github.com/npm/osenv#readme", "keywords": [ "environment", "variable", @@ -28,21 +81,35 @@ "prompt", "ps1" ], - "author": { - "name": "Isaac Z. Schlueter", - "email": "i@izs.me", - "url": "http://blog.izs.me/" - }, "license": "ISC", - "description": "Look up environment settings specific to different operating systems", - "readme": "# osenv\n\nLook up environment settings specific to different operating systems.\n\n## Usage\n\n```javascript\nvar osenv = require('osenv')\nvar path = osenv.path()\nvar user = osenv.user()\n// etc.\n\n// Some things are not reliably in the env, and have a fallback command:\nvar h = osenv.hostname(function (er, hostname) {\n h = hostname\n})\n// This will still cause it to be memoized, so calling osenv.hostname()\n// is now an immediate operation.\n\n// You can always send a cb, which will get called in the nextTick\n// if it's been memoized, or wait for the fallback data if it wasn't\n// found in the environment.\nosenv.hostname(function (er, hostname) {\n if (er) console.error('error looking up hostname')\n else console.log('this machine calls itself %s', hostname)\n})\n```\n\n## osenv.hostname()\n\nThe machine name. Calls `hostname` if not found.\n\n## osenv.user()\n\nThe currently logged-in user. Calls `whoami` if not found.\n\n## osenv.prompt()\n\nEither PS1 on unix, or PROMPT on Windows.\n\n## osenv.tmpdir()\n\nThe place where temporary files should be created.\n\n## osenv.home()\n\nNo place like it.\n\n## osenv.path()\n\nAn array of the places that the operating system will search for\nexecutables.\n\n## osenv.editor() \n\nReturn the executable name of the editor program. This uses the EDITOR\nand VISUAL environment variables, and falls back to `vi` on Unix, or\n`notepad.exe` on Windows.\n\n## osenv.shell()\n\nThe SHELL on Unix, which Windows calls the ComSpec. Defaults to 'bash'\nor 'cmd'.\n", - "readmeFilename": "README.md", - "bugs": { - "url": "https://github.com/npm/osenv/issues" + "main": "osenv.js", + "maintainers": [ + { + "name": "isaacs", + "email": "i@izs.me" + }, + { + "name": "robertkowalski", + "email": "rok@kowalski.gd" + }, + { + "name": "othiym23", + "email": "ogd@aoaioxxysz.net" + }, + { + "name": "iarna", + "email": "me@re-becca.org" + } + ], + "name": "osenv", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/npm/osenv.git" }, - "homepage": "https://github.com/npm/osenv#readme", - "_id": "osenv@0.1.3", - "_shasum": "83cf05c6d6458fc4d5ac6362ea325d92f2754217", - "_resolved": "https://registry.npmjs.org/osenv/-/osenv-0.1.3.tgz", - "_from": "osenv@>=0.1.3 <0.2.0" + "scripts": { + "test": "tap test/*.js" + }, + "version": "0.1.4" } diff --git a/deps/npm/node_modules/osenv/test/unix.js b/deps/npm/node_modules/osenv/test/unix.js index f87cbfb32955b1..94d4aaafb4f80b 100644 --- a/deps/npm/node_modules/osenv/test/unix.js +++ b/deps/npm/node_modules/osenv/test/unix.js @@ -2,13 +2,13 @@ // pretending to be another platform is too hacky, since it breaks // how the underlying system looks up module paths and runs // child processes, and all that stuff is cached. +var tap = require('tap') + + if (process.platform === 'win32') { - console.log('TAP Version 13\n' + - '1..0\n' + - '# Skip unix tests, this is not unix\n') - return + tap.plan(0, 'Skip unix tests, this is not unix') + process.exit(0) } -var tap = require('tap') // like unix, but funny process.env.USER = 'sirUser' diff --git a/deps/npm/node_modules/request/node_modules/uuid/package.json b/deps/npm/node_modules/request/node_modules/uuid/package.json deleted file mode 100644 index 57626b794d5ebf..00000000000000 --- a/deps/npm/node_modules/request/node_modules/uuid/package.json +++ /dev/null @@ -1,122 +0,0 @@ -{ - "_args": [ - [ - { - "raw": "uuid@^3.0.0", - "scope": null, - "escapedName": "uuid", - "name": "uuid", - "rawSpec": "^3.0.0", - "spec": ">=3.0.0 <4.0.0", - "type": "range" - }, - "/Users/zkat/Documents/code/npm/node_modules/request" - ] - ], - "_from": "uuid@>=3.0.0 <4.0.0", - "_id": "uuid@3.0.1", - "_inCache": true, - "_location": "/request/uuid", - "_nodeVersion": "6.7.0", - "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/uuid-3.0.1.tgz_1480403886767_0.2584113120101392" - }, - "_npmUser": { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - }, - "_npmVersion": "3.10.3", - "_phantomChildren": {}, - "_requested": { - "raw": "uuid@^3.0.0", - "scope": null, - "escapedName": "uuid", - "name": "uuid", - "rawSpec": "^3.0.0", - "spec": ">=3.0.0 <4.0.0", - "type": "range" - }, - "_requiredBy": [ - "/request" - ], - "_resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz", - "_shasum": "6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1", - "_shrinkwrap": null, - "_spec": "uuid@^3.0.0", - "_where": "/Users/zkat/Documents/code/npm/node_modules/request", - "bin": { - "uuid": "./bin/uuid" - }, - "browser": { - "./lib/rng.js": "./lib/rng-browser.js" - }, - "bugs": { - "url": "https://github.com/kelektiv/node-uuid/issues" - }, - "contributors": [ - { - "name": "Robert Kieffer", - "email": "robert@broofa.com" - }, - { - "name": "Christoph Tavan", - "email": "dev@tavan.de" - }, - { - "name": "AJ ONeal", - "email": "coolaj86@gmail.com" - }, - { - "name": "Vincent Voyer", - "email": "vincent@zeroload.net" - }, - { - "name": "Roman Shtylman", - "email": "shtylman@gmail.com" - } - ], - "dependencies": {}, - "description": "RFC4122 (v1 and v4) generator", - "devDependencies": { - "mocha": "3.1.2" - }, - "directories": {}, - "dist": { - "shasum": "6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1", - "tarball": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz" - }, - "gitHead": "374de826de71d8997f71b4641f65552e48956ced", - "homepage": "https://github.com/kelektiv/node-uuid#readme", - "keywords": [ - "uuid", - "guid", - "rfc4122" - ], - "license": "MIT", - "maintainers": [ - { - "name": "broofa", - "email": "robert@broofa.com" - }, - { - "name": "defunctzombie", - "email": "shtylman@gmail.com" - }, - { - "name": "vvo", - "email": "vincent.voyer@gmail.com" - } - ], - "name": "uuid", - "optionalDependencies": {}, - "readme": "ERROR: No README data found!", - "repository": { - "type": "git", - "url": "git+https://github.com/kelektiv/node-uuid.git" - }, - "scripts": { - "test": "mocha test/test.js" - }, - "version": "3.0.1" -} diff --git a/deps/npm/node_modules/retry/package.json b/deps/npm/node_modules/retry/package.json index 73a2819edeeab9..adc1b9e1ef0c60 100644 --- a/deps/npm/node_modules/retry/package.json +++ b/deps/npm/node_modules/retry/package.json @@ -2,50 +2,51 @@ "_args": [ [ { - "raw": "retry@0.10.0", + "raw": "retry@0.10.1", "scope": null, "escapedName": "retry", "name": "retry", - "rawSpec": "0.10.0", - "spec": "0.10.0", + "rawSpec": "0.10.1", + "spec": "0.10.1", "type": "version" }, - "/Users/zkat/Documents/code/npm" + "/Users/rebecca/code/npm" ] ], - "_from": "retry@0.10.0", - "_id": "retry@0.10.0", + "_from": "retry@0.10.1", + "_id": "retry@0.10.1", "_inCache": true, "_location": "/retry", - "_nodeVersion": "4.2.1", + "_nodeVersion": "4.6.0", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/retry-0.10.0.tgz_1471682099847_0.5031970851123333" + "tmp": "tmp/retry-0.10.1.tgz_1481556523726_0.45345148630440235" }, "_npmUser": { "name": "tim-kos", "email": "tim@debuggable.com" }, - "_npmVersion": "2.1.7", + "_npmVersion": "2.15.9", "_phantomChildren": {}, "_requested": { - "raw": "retry@0.10.0", + "raw": "retry@0.10.1", "scope": null, "escapedName": "retry", "name": "retry", - "rawSpec": "0.10.0", - "spec": "0.10.0", + "rawSpec": "0.10.1", + "spec": "0.10.1", "type": "version" }, "_requiredBy": [ "#USER", - "/" + "/", + "/npm-registry-client" ], - "_resolved": "https://registry.npmjs.org/retry/-/retry-0.10.0.tgz", - "_shasum": "649e15ca408422d98318161935e7f7d652d435dd", + "_resolved": "https://registry.npmjs.org/retry/-/retry-0.10.1.tgz", + "_shasum": "e76388d217992c252750241d3d3956fed98d8ff4", "_shrinkwrap": null, - "_spec": "retry@0.10.0", - "_where": "/Users/zkat/Documents/code/npm", + "_spec": "retry@0.10.1", + "_where": "/Users/rebecca/code/npm", "author": { "name": "Tim Koschützki", "email": "tim@debuggable.com", @@ -64,13 +65,13 @@ "lib": "./lib" }, "dist": { - "shasum": "649e15ca408422d98318161935e7f7d652d435dd", - "tarball": "https://registry.npmjs.org/retry/-/retry-0.10.0.tgz" + "shasum": "e76388d217992c252750241d3d3956fed98d8ff4", + "tarball": "https://registry.npmjs.org/retry/-/retry-0.10.1.tgz" }, "engines": { "node": "*" }, - "gitHead": "0616e6a6ebc49b5a36b619c8f7c414ced8c3813b", + "gitHead": "3dbe5189b48786e56d1d1807731adfc53a70eeae", "homepage": "https://github.com/tim-kos/node-retry", "license": "MIT", "main": "index", @@ -88,5 +89,5 @@ "url": "git://github.com/tim-kos/node-retry.git" }, "scripts": {}, - "version": "0.10.0" + "version": "0.10.1" } diff --git a/deps/npm/node_modules/request/node_modules/uuid/.npmignore b/deps/npm/node_modules/uuid/.npmignore similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/.npmignore rename to deps/npm/node_modules/uuid/.npmignore diff --git a/deps/npm/node_modules/request/node_modules/uuid/.travis.yml b/deps/npm/node_modules/uuid/.travis.yml similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/.travis.yml rename to deps/npm/node_modules/uuid/.travis.yml diff --git a/deps/npm/node_modules/request/node_modules/uuid/AUTHORS b/deps/npm/node_modules/uuid/AUTHORS similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/AUTHORS rename to deps/npm/node_modules/uuid/AUTHORS diff --git a/deps/npm/node_modules/request/node_modules/uuid/HISTORY.md b/deps/npm/node_modules/uuid/HISTORY.md similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/HISTORY.md rename to deps/npm/node_modules/uuid/HISTORY.md diff --git a/deps/npm/node_modules/request/node_modules/uuid/LICENSE.md b/deps/npm/node_modules/uuid/LICENSE.md similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/LICENSE.md rename to deps/npm/node_modules/uuid/LICENSE.md diff --git a/deps/npm/node_modules/request/node_modules/uuid/README.md b/deps/npm/node_modules/uuid/README.md similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/README.md rename to deps/npm/node_modules/uuid/README.md diff --git a/deps/npm/node_modules/request/node_modules/uuid/bin/uuid b/deps/npm/node_modules/uuid/bin/uuid similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/bin/uuid rename to deps/npm/node_modules/uuid/bin/uuid diff --git a/deps/npm/node_modules/request/node_modules/uuid/index.js b/deps/npm/node_modules/uuid/index.js similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/index.js rename to deps/npm/node_modules/uuid/index.js diff --git a/deps/npm/node_modules/request/node_modules/uuid/lib/bytesToUuid.js b/deps/npm/node_modules/uuid/lib/bytesToUuid.js similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/lib/bytesToUuid.js rename to deps/npm/node_modules/uuid/lib/bytesToUuid.js diff --git a/deps/npm/node_modules/request/node_modules/uuid/lib/rng-browser.js b/deps/npm/node_modules/uuid/lib/rng-browser.js similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/lib/rng-browser.js rename to deps/npm/node_modules/uuid/lib/rng-browser.js diff --git a/deps/npm/node_modules/request/node_modules/uuid/lib/rng.js b/deps/npm/node_modules/uuid/lib/rng.js similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/lib/rng.js rename to deps/npm/node_modules/uuid/lib/rng.js diff --git a/deps/npm/node_modules/uuid/package.json b/deps/npm/node_modules/uuid/package.json new file mode 100644 index 00000000000000..b2caa580cc09a8 --- /dev/null +++ b/deps/npm/node_modules/uuid/package.json @@ -0,0 +1,124 @@ +{ + "_args": [ + [ + { + "raw": "uuid", + "scope": null, + "escapedName": "uuid", + "name": "uuid", + "rawSpec": "", + "spec": "latest", + "type": "tag" + }, + "/Users/rebecca/code/npm" + ] + ], + "_from": "uuid@latest", + "_id": "uuid@3.0.1", + "_inCache": true, + "_location": "/uuid", + "_nodeVersion": "6.7.0", + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/uuid-3.0.1.tgz_1480403886767_0.2584113120101392" + }, + "_npmUser": { + "name": "defunctzombie", + "email": "shtylman@gmail.com" + }, + "_npmVersion": "3.10.3", + "_phantomChildren": {}, + "_requested": { + "raw": "uuid", + "scope": null, + "escapedName": "uuid", + "name": "uuid", + "rawSpec": "", + "spec": "latest", + "type": "tag" + }, + "_requiredBy": [ + "#USER", + "/", + "/request" + ], + "_resolved": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz", + "_shasum": "6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1", + "_shrinkwrap": null, + "_spec": "uuid", + "_where": "/Users/rebecca/code/npm", + "bin": { + "uuid": "./bin/uuid" + }, + "browser": { + "./lib/rng.js": "./lib/rng-browser.js" + }, + "bugs": { + "url": "https://github.com/kelektiv/node-uuid/issues" + }, + "contributors": [ + { + "name": "Robert Kieffer", + "email": "robert@broofa.com" + }, + { + "name": "Christoph Tavan", + "email": "dev@tavan.de" + }, + { + "name": "AJ ONeal", + "email": "coolaj86@gmail.com" + }, + { + "name": "Vincent Voyer", + "email": "vincent@zeroload.net" + }, + { + "name": "Roman Shtylman", + "email": "shtylman@gmail.com" + } + ], + "dependencies": {}, + "description": "RFC4122 (v1 and v4) generator", + "devDependencies": { + "mocha": "3.1.2" + }, + "directories": {}, + "dist": { + "shasum": "6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1", + "tarball": "https://registry.npmjs.org/uuid/-/uuid-3.0.1.tgz" + }, + "gitHead": "374de826de71d8997f71b4641f65552e48956ced", + "homepage": "https://github.com/kelektiv/node-uuid#readme", + "keywords": [ + "uuid", + "guid", + "rfc4122" + ], + "license": "MIT", + "maintainers": [ + { + "name": "broofa", + "email": "robert@broofa.com" + }, + { + "name": "defunctzombie", + "email": "shtylman@gmail.com" + }, + { + "name": "vvo", + "email": "vincent.voyer@gmail.com" + } + ], + "name": "uuid", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/kelektiv/node-uuid.git" + }, + "scripts": { + "test": "mocha test/test.js" + }, + "version": "3.0.1" +} diff --git a/deps/npm/node_modules/request/node_modules/uuid/test/mocha.opts b/deps/npm/node_modules/uuid/test/mocha.opts similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/test/mocha.opts rename to deps/npm/node_modules/uuid/test/mocha.opts diff --git a/deps/npm/node_modules/request/node_modules/uuid/test/test.js b/deps/npm/node_modules/uuid/test/test.js similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/test/test.js rename to deps/npm/node_modules/uuid/test/test.js diff --git a/deps/npm/node_modules/request/node_modules/uuid/v1.js b/deps/npm/node_modules/uuid/v1.js similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/v1.js rename to deps/npm/node_modules/uuid/v1.js diff --git a/deps/npm/node_modules/request/node_modules/uuid/v4.js b/deps/npm/node_modules/uuid/v4.js similarity index 100% rename from deps/npm/node_modules/request/node_modules/uuid/v4.js rename to deps/npm/node_modules/uuid/v4.js diff --git a/deps/npm/node_modules/write-file-atomic/index.js b/deps/npm/node_modules/write-file-atomic/index.js index 519aacad988057..7939828e5360d7 100644 --- a/deps/npm/node_modules/write-file-atomic/index.js +++ b/deps/npm/node_modules/write-file-atomic/index.js @@ -1,38 +1,48 @@ 'use strict' +module.exports = writeFile +module.exports.sync = writeFileSync +module.exports._getTmpname = getTmpname // for testing + var fs = require('graceful-fs') var chain = require('slide').chain var MurmurHash3 = require('imurmurhash') var extend = Object.assign || require('util')._extend -function murmurhex () { - var hash = new MurmurHash3() - for (var ii = 0; ii < arguments.length; ++ii) hash.hash('' + arguments[ii]) - return hash.result() -} var invocations = 0 -var getTmpname = function (filename) { - return filename + '.' + murmurhex(__filename, process.pid, ++invocations) +function getTmpname (filename) { + return filename + '.' + + MurmurHash3(__filename) + .hash(String(process.pid)) + .hash(String(++invocations)) + .result() } -module.exports = function writeFile (filename, data, options, callback) { +function writeFile (filename, data, options, callback) { if (options instanceof Function) { callback = options options = null } if (!options) options = {} + fs.realpath(filename, function (_, realname) { + _writeFile(realname || filename, data, options, callback) + }) +} +function _writeFile (filename, data, options, callback) { var tmpfile = getTmpname(filename) - if (options.mode && options.chmod) { + if (options.mode && options.chown) { return thenWriteFile() } else { // Either mode or chown is not explicitly set // Default behavior is to copy it from original file return fs.stat(filename, function (err, stats) { + if (err || !stats) return thenWriteFile() + options = extend({}, options) - if (!err && stats && !options.mode) { + if (!options.mode) { options.mode = stats.mode } - if (!err && stats && !options.chown && process.getuid) { + if (!options.chown && process.getuid) { options.chown = { uid: stats.uid, gid: stats.gid } } return thenWriteFile() @@ -52,17 +62,21 @@ module.exports = function writeFile (filename, data, options, callback) { } } -module.exports.sync = function writeFileSync (filename, data, options) { +function writeFileSync (filename, data, options) { if (!options) options = {} + try { + filename = fs.realpathSync(filename) + } catch (ex) { + // it's ok, it'll happen on a not yet existing file + } var tmpfile = getTmpname(filename) try { - if (!options.mode || !options.chmod) { + if (!options.mode || !options.chown) { // Either mode or chown is not explicitly set // Default behavior is to copy it from original file try { var stats = fs.statSync(filename) - options = extend({}, options) if (!options.mode) { options.mode = stats.mode diff --git a/deps/npm/node_modules/write-file-atomic/package.json b/deps/npm/node_modules/write-file-atomic/package.json index 76e9e9bf03159c..2b1db0d6033d6e 100644 --- a/deps/npm/node_modules/write-file-atomic/package.json +++ b/deps/npm/node_modules/write-file-atomic/package.json @@ -2,50 +2,50 @@ "_args": [ [ { - "raw": "write-file-atomic@1.2.0", + "raw": "write-file-atomic@1.3.1", "scope": null, "escapedName": "write-file-atomic", "name": "write-file-atomic", - "rawSpec": "1.2.0", - "spec": "1.2.0", + "rawSpec": "1.3.1", + "spec": "1.3.1", "type": "version" }, - "/Users/zkat/Documents/code/npm" + "/Users/rebecca/code/npm" ] ], - "_from": "write-file-atomic@1.2.0", - "_id": "write-file-atomic@1.2.0", + "_from": "write-file-atomic@1.3.1", + "_id": "write-file-atomic@1.3.1", "_inCache": true, "_location": "/write-file-atomic", - "_nodeVersion": "4.5.0", + "_nodeVersion": "7.3.0", "_npmOperationalInternal": { - "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/write-file-atomic-1.2.0.tgz_1471552371956_0.5829780481290072" + "host": "packages-18-east.internal.npmjs.com", + "tmp": "tmp/write-file-atomic-1.3.1.tgz_1483776142964_0.11427561868913472" }, "_npmUser": { "name": "iarna", "email": "me@re-becca.org" }, - "_npmVersion": "3.10.7", + "_npmVersion": "4.1.1", "_phantomChildren": {}, "_requested": { - "raw": "write-file-atomic@1.2.0", + "raw": "write-file-atomic@1.3.1", "scope": null, "escapedName": "write-file-atomic", "name": "write-file-atomic", - "rawSpec": "1.2.0", - "spec": "1.2.0", + "rawSpec": "1.3.1", + "spec": "1.3.1", "type": "version" }, "_requiredBy": [ "#USER", "/" ], - "_resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.2.0.tgz", - "_shasum": "14c66d4e4cb3ca0565c28cf3b7a6f3e4d5938fab", + "_resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.1.tgz", + "_shasum": "7d45ba32316328dd1ec7d90f60ebc0d845bb759a", "_shrinkwrap": null, - "_spec": "write-file-atomic@1.2.0", - "_where": "/Users/zkat/Documents/code/npm", + "_spec": "write-file-atomic@1.3.1", + "_where": "/Users/rebecca/code/npm", "author": { "name": "Rebecca Turner", "email": "me@re-becca.org", @@ -55,26 +55,27 @@ "url": "https://github.com/iarna/write-file-atomic/issues" }, "dependencies": { - "graceful-fs": "^4.1.2", + "graceful-fs": "^4.1.11", "imurmurhash": "^0.1.4", "slide": "^1.1.5" }, "description": "Write files in an atomic fashion w/configurable ownership", "devDependencies": { - "require-inject": "^1.1.0", + "mkdirp": "^0.5.1", + "require-inject": "^1.4.0", + "rimraf": "^2.5.4", "standard": "^5.4.1", - "tap": "^2.3.1", - "tmp": "0.0.28" + "tap": "^2.3.1" }, "directories": {}, "dist": { - "shasum": "14c66d4e4cb3ca0565c28cf3b7a6f3e4d5938fab", - "tarball": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.2.0.tgz" + "shasum": "7d45ba32316328dd1ec7d90f60ebc0d845bb759a", + "tarball": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-1.3.1.tgz" }, "files": [ "index.js" ], - "gitHead": "c29f37cb5955f597066ad7aedea7aa6f7408a5b7", + "gitHead": "56fef5763513905d7e43aa685adad80002445474", "homepage": "https://github.com/iarna/write-file-atomic", "keywords": [ "writeFile", @@ -102,5 +103,5 @@ "scripts": { "test": "standard && tap --coverage test/*.js" }, - "version": "1.2.0" + "version": "1.3.1" } diff --git a/deps/npm/package.json b/deps/npm/package.json index bc799f360a821f..4a15414a98d6b6 100644 --- a/deps/npm/package.json +++ b/deps/npm/package.json @@ -1,5 +1,5 @@ { - "version": "4.0.5", + "version": "4.1.2", "name": "npm", "description": "a package manager for JavaScript", "keywords": [ @@ -30,7 +30,7 @@ "main": "./lib/npm.js", "bin": "./bin/npm-cli.js", "dependencies": { - "JSONStream": "~1.2.1", + "JSONStream": "~1.3.0", "abbrev": "~1.0.9", "ansicolors": "~0.3.2", "ansistyles": "~0.1.3", @@ -56,7 +56,7 @@ "inherits": "~2.0.3", "ini": "~1.3.4", "init-package-json": "~1.9.4", - "lockfile": "~1.0.2", + "lockfile": "~1.0.3", "lodash._baseuniq": "~4.6.0", "lodash.clonedeep": "~4.5.0", "lodash.union": "~4.6.0", @@ -64,19 +64,19 @@ "lodash.without": "~4.4.0", "mississippi": "~1.2.0", "mkdirp": "~0.5.1", - "node-gyp": "~3.4.0", - "nopt": "~3.0.6", + "node-gyp": "~3.5.0", + "nopt": "~4.0.1", "normalize-git-url": "~3.0.2", "normalize-package-data": "~2.3.5", "npm-cache-filename": "~1.0.2", "npm-install-checks": "~3.0.0", "npm-package-arg": "~4.2.0", - "npm-registry-client": "~7.3.0", + "npm-registry-client": "~7.4.5", "npm-user-validate": "~0.1.5", - "npmlog": "~4.0.1", + "npmlog": "~4.0.2", "once": "~1.4.0", "opener": "~1.4.2", - "osenv": "~0.1.3", + "osenv": "~0.1.4", "path-is-inside": "~1.0.2", "read": "~1.0.7", "read-cmd-shim": "~1.0.1", @@ -86,7 +86,7 @@ "readable-stream": "~2.2.2", "realize-package-specifier": "~3.0.3", "request": "~2.79.0", - "retry": "~0.10.0", + "retry": "~0.10.1", "rimraf": "~2.5.4", "semver": "~5.3.0", "sha": "~2.0.1", @@ -100,10 +100,11 @@ "umask": "~1.1.0", "unique-filename": "~1.1.0", "unpipe": "~1.0.0", + "uuid": "~3.0.1", "validate-npm-package-name": "~2.2.2", "which": "~1.2.12", "wrappy": "~1.0.2", - "write-file-atomic": "~1.2.0" + "write-file-atomic": "~1.3.1" }, "bundleDependencies": [ "abbrev", @@ -190,19 +191,20 @@ "which", "wrappy", "write-file-atomic", - "mississippi" + "mississippi", + "uuid" ], "devDependencies": { "deep-equal": "~1.0.1", "marked": "~0.3.6", - "marked-man": "~0.1.6", + "marked-man": "~0.2.0", "npm-registry-couchapp": "~2.6.12", "npm-registry-mock": "~1.0.1", "require-inject": "~1.4.0", "sprintf-js": "~1.0.3", "standard": "~6.0.8", "tacks": "~1.2.2", - "tap": "~8.0.1" + "tap": "~9.0.3" }, "scripts": { "dumpconf": "env | grep npm | sort | uniq", diff --git a/deps/npm/test/common-tap.js b/deps/npm/test/common-tap.js index 8fe5b78fd9d276..f96f54ebfbb73b 100644 --- a/deps/npm/test/common-tap.js +++ b/deps/npm/test/common-tap.js @@ -29,6 +29,8 @@ process.env.npm_config_legacy_bundling = 'false' process.env.random_env_var = 'foo' // suppress warnings about using a prerelease version of node process.env.npm_config_node_version = process.version.replace(/-.*$/, '') +// disable metrics for the test suite even if the user has enabled them +process.env.npm_config_send_metrics = 'false' var bin = exports.bin = require.resolve('../bin/npm-cli.js') diff --git a/deps/npm/test/tap/anon-cli-metrics.js b/deps/npm/test/tap/anon-cli-metrics.js new file mode 100644 index 00000000000000..deb61846827d02 --- /dev/null +++ b/deps/npm/test/tap/anon-cli-metrics.js @@ -0,0 +1,147 @@ +'use strict' +var path = require('path') +var fs = require('graceful-fs') +var test = require('tap').test +var mr = require('npm-registry-mock') +var Tacks = require('tacks') +var File = Tacks.File +var Dir = Tacks.Dir +var extend = Object.assign || require('util')._extend +var common = require('../common-tap.js') + +var basedir = path.join(__dirname, path.basename(__filename, '.js')) +var testdir = path.join(basedir, 'testdir') +var cachedir = path.join(basedir, 'cache') +var globaldir = path.join(basedir, 'global') +var tmpdir = path.join(basedir, 'tmp') +var metricsFile = path.join(cachedir, 'anonymous-cli-metrics.json') + +var conf = { + cwd: testdir, + env: extend(extend({}, process.env), { + npm_config_cache: cachedir, + npm_config_tmp: tmpdir, + npm_config_prefix: globaldir, + npm_config_registry: common.registry, + npm_config_metrics_registry: common.registry, + npm_config_loglevel: 'warn' + }) +} + +var server +var fixture = new Tacks(Dir({ + cache: Dir(), + global: Dir(), + tmp: Dir(), + testdir: Dir({ + failure: Dir({ + 'package.json': File({ + name: 'failure', + version: '1.0.0', + scripts: { + preinstall: 'false' + } + }) + }), + success: Dir({ + 'package.json': File({ + name: 'success', + version: '1.0.0' + }) + }), + slow: Dir({ + 'package.json': File({ + name: 'slow', + version: '1.0.0', + scripts: { + preinstall: "node -e 'setTimeout(function(){}, 500)'" + } + }) + }), + 'package.json': File({ + name: 'anon-cli-metrics-test', + version: '1.0.0' + }) + }) +})) + +function setup () { + cleanup() + fixture.create(basedir) +} + +function cleanup () { + fixture.remove(basedir) +} + +test('setup', function (t) { + setup() + mr({port: common.port, throwOnUnmatched: true}, function (err, s) { + if (err) throw err + server = s + server.filteringPathRegEx(/([/]-[/]npm[/]anon-metrics[/]v1[/]).*/, '$1:id') + server.filteringRequestBody(function (body) { + var metrics = typeof body === 'string' ? JSON.parse(body) : body + delete metrics.from + delete metrics.to + return JSON.stringify(metrics) + }) + t.done() + }) +}) + +test('record success', function (t) { + common.npm(['install', '--no-send-metrics', 'success'], conf, function (err, code, stdout, stderr) { + if (err) throw err + t.is(code, 0, 'always succeeding install succeeded') + t.comment(stdout.trim()) + t.comment(stderr.trim()) + var data = JSON.parse(fs.readFileSync(metricsFile)) + t.is(data.metrics.successfulInstalls, 1) + t.is(data.metrics.failedInstalls, 0) + t.done() + }) +}) + +test('record failure', function (t) { + server.put('/-/npm/anon-metrics/v1/:id', { + successfulInstalls: 1, + failedInstalls: 0 + }).reply(500, {ok: false}) + common.npm(['install', '--send-metrics', 'failure'], conf, function (err, code, stdout, stderr) { + if (err) throw err + t.notEqual(code, 0, 'always failing install fails') + t.comment(stdout.trim()) + t.comment(stderr.trim()) + var data = JSON.parse(fs.readFileSync(metricsFile)) + t.is(data.metrics.successfulInstalls, 1) + t.is(data.metrics.failedInstalls, 1) + t.done() + }) +}) + +test('report', function (t) { + console.log('setup') + + server.put('/-/npm/anon-metrics/v1/:id', { + successfulInstalls: 1, + failedInstalls: 1 + }).reply(200, {ok: true}) + common.npm(['install', '--send-metrics', 'slow'], conf, function (err, code, stdout, stderr) { + if (err) throw err + t.is(code, 0, 'command ran ok') + t.comment(stdout.trim()) + t.comment(stderr.trim()) + // todo check mock registry for post + var data = JSON.parse(fs.readFileSync(metricsFile)) + t.is(data.metrics.successfulInstalls, 1) + t.is(data.metrics.failedInstalls, 0) + t.done() + }) +}) + +test('cleanup', function (t) { + server.close() + cleanup() + t.done() +}) diff --git a/deps/npm/test/tap/doctor.js b/deps/npm/test/tap/doctor.js new file mode 100644 index 00000000000000..5cdffb2bd84793 --- /dev/null +++ b/deps/npm/test/tap/doctor.js @@ -0,0 +1,69 @@ +'use strict' +var http = require('http') +var which = require('which') +var mr = require('npm-registry-mock') +var test = require('tap').test +var common = require('../common-tap.js') +var npm = require('../../lib/npm.js') +var server +var node_url +var pingResponse = { + host: 'registry.npmjs.org', + ok: true, + username: null, + peer: 'example.com' +} +var npmResponse = { + 'dist-tags': {latest: '0.0.0'}, + 'versions': { + '0.0.0': { + version: '0.0.0', + dist: { + shasum: '', + tarball: '' + } + } + } +} + +test('setup', function (t) { + var port = common.port + 1 + http.createServer(function (q, s) { + s.end(JSON.stringify([{lts: true, version: '0.0.0'}])) + this.close() + }).listen(port, function () { + node_url = 'http://localhost:' + port + mr({port: common.port}, function (e, s) { + t.ifError(e, 'registry mocked successfully') + server = s + server.get('/-/ping?write=true').reply(200, JSON.stringify(pingResponse)) + server.get('/npm').reply(200, JSON.stringify(npmResponse)) + npm.load({registry: common.registry, loglevel: 'silent'}, function (e) { + t.ifError(e, 'npm loaded successfully') + t.pass('all set up') + t.done() + }) + }) + }) +}) + +test('npm doctor', function (t) { + npm.commands.doctor({'node-url': node_url}, true, function (e, list) { + t.ifError(e, 'npm loaded successfully') + t.same(list.length, 9, 'list should have 9 prop') + t.same(list[0][1], 'ok', 'npm ping') + t.same(list[1][1], 'v' + npm.version, 'npm -v') + t.same(list[2][1], process.version, 'node -v') + t.same(list[3][1], common.registry + '/', 'npm config get registry') + t.same(list[5][1], 'ok', 'Perms check on cached files') + t.same(list[6][1], 'ok', 'Perms check on global node_modules') + t.same(list[7][1], 'ok', 'Perms check on local node_modules') + t.same(list[8][1], 'ok', 'Checksum cached files') + which('git', function (e, resolvedPath) { + t.ifError(e, 'git command is installed') + t.same(list[4][1], resolvedPath, 'which git') + server.close() + t.done() + }) + }) +}) diff --git a/deps/npm/test/tap/install-save-local.js b/deps/npm/test/tap/install-save-local.js index 1bc739cb898f39..640ebfef500fe0 100644 --- a/deps/npm/test/tap/install-save-local.js +++ b/deps/npm/test/tap/install-save-local.js @@ -61,6 +61,35 @@ test('\'npm install --save ../local/path\' should save to package.json', functio ) }) +test('\'npm install --save local/path\' should save to package.json', function (t) { + setup() + common.npm( + [ + '--loglevel', 'silent', + '--save', + 'install', 'package-local-dependency' + ], + EXEC_OPTS, + function (err, code) { + t.ifError(err, 'npm install ran without issue') + t.notOk(code, 'npm install exited with code 0') + + var dependencyPackageJson = path.join( + pkg, 'node_modules', 'package-local-dependency', 'package.json' + ) + t.ok(JSON.parse(fs.readFileSync(dependencyPackageJson, 'utf8'))) + + var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8')) + t.is(Object.keys(pkgJson.dependencies).length, 1, 'only one dep') + t.ok( + /file:package-local-dependency$/.test(pkgJson.dependencies['package-local-dependency']), + 'local package saved correctly' + ) + t.end() + } + ) +}) + test('\'npm install --save-dev ../local/path\' should save to package.json', function (t) { setup() common.npm( @@ -90,6 +119,35 @@ test('\'npm install --save-dev ../local/path\' should save to package.json', fun } ) }) +test('\'npm install --save-dev local/path\' should save to package.json', function (t) { + setup() + common.npm( + [ + '--loglevel', 'silent', + '--save-dev', + 'install', 'package-local-dev-dependency' + ], + EXEC_OPTS, + function (err, code) { + t.ifError(err, 'npm install ran without issue') + t.notOk(code, 'npm install exited with code 0') + + var dependencyPackageJson = path.resolve( + pkg, 'node_modules', 'package-local-dev-dependency', 'package.json' + ) + t.ok(JSON.parse(fs.readFileSync(dependencyPackageJson, 'utf8'))) + + var pkgJson = JSON.parse(fs.readFileSync(pkg + '/package.json', 'utf8')) + t.is(Object.keys(pkgJson.devDependencies).length, 1, 'only one dep') + t.ok( + /file:package-local-dev-dependency$/.test(pkgJson.devDependencies['package-local-dev-dependency']), + 'local package saved correctly' + ) + + t.end() + } + ) +}) test('cleanup', function (t) { cleanup() @@ -122,5 +180,16 @@ function setup () { JSON.stringify(localDevDependency, null, 2) ) + mkdirp.sync(path.join(pkg, 'package-local-dependency')) + fs.writeFileSync( + path.join(pkg, 'package-local-dependency', 'package.json'), + JSON.stringify(localDependency, null, 2) + ) + + mkdirp.sync(path.join(pkg, 'package-local-dev-dependency')) + fs.writeFileSync( + path.join(pkg, 'package-local-dev-dependency', 'package.json'), + JSON.stringify(localDevDependency, null, 2) + ) process.chdir(pkg) } diff --git a/deps/npm/test/tap/pick-manifest-from-registry-metadata.js b/deps/npm/test/tap/pick-manifest-from-registry-metadata.js new file mode 100644 index 00000000000000..3af354aed3819c --- /dev/null +++ b/deps/npm/test/tap/pick-manifest-from-registry-metadata.js @@ -0,0 +1,145 @@ +'use strict' +var test = require('tap').test + +var pickManifest = require('../../lib/utils/pick-manifest-from-registry-metadata.js') + +test('basic carat range selection', function (t) { + var metadata = { + 'dist-tags': { + 'example': '1.1.0' + }, + versions: { + '1.0.0': { version: '1.0.0' }, + '1.0.1': { version: '1.0.1' }, + '1.0.2': { version: '1.0.2' }, + '1.1.0': { version: '1.1.0' }, + '2.0.0': { version: '2.0.0' } + } + } + var versions = Object.keys(metadata.versions) + var selected = pickManifest('^1.0.0', 'latest', versions, metadata) + t.equal(selected.manifest.version, '1.1.0', 'picked the right manifest using ^') + t.equal(selected.resolvedTo, '1.1.0', 'resolved using version match') + selected = pickManifest('^1.0.0', 'example', versions, metadata) + t.equal(selected.manifest.version, '1.1.0', 'picked the right manifest using ^') + t.equal(selected.resolvedTo, 'example', 'resolved using tag') + t.end() +}) + +test('basic tilde range selection', function (t) { + var metadata = { + 'dist-tags': { + 'example': '1.1.0' + }, + versions: { + '1.0.0': { version: '1.0.0' }, + '1.0.1': { version: '1.0.1' }, + '1.0.2': { version: '1.0.2' }, + '1.1.0': { version: '1.1.0' }, + '2.0.0': { version: '2.0.0' } + } + } + var versions = Object.keys(metadata.versions) + var selected = pickManifest('~1.0.0', 'latest', versions, metadata) + t.equal(selected.manifest.version, '1.0.2', 'picked the right manifest using ~') + t.equal(selected.resolvedTo, '1.0.2', 'resolved using version match') + t.end() +}) + +test('basic mathematical range selection', function (t) { + var metadata = { + 'dist-tags': {}, + versions: { + '1.0.0': { version: '1.0.0' }, + '1.0.1': { version: '1.0.1' }, + '1.0.2': { version: '1.0.2' }, + '2.0.0': { version: '2.0.0' } + } + } + var versions = Object.keys(metadata.versions) + var selected = pickManifest('>=1.0.0 <2', 'example', versions, metadata) + t.equal(selected.manifest.version, '1.0.2', 'picked the right manifest using mathematical range') + t.equal(selected.resolvedTo, '1.0.2', 'resolved using version match') + t.end() +}) + +test('basic version selection', function (t) { + var metadata = { + 'dist-tags': {}, + versions: { + '1.0.0': { version: '1.0.0' }, + '1.0.1': { version: '1.0.1' }, + '1.0.2': { version: '1.0.2' }, + '2.0.0': { version: '2.0.0' } + } + } + var versions = Object.keys(metadata.versions) + var selected = pickManifest('1.0.0', 'latest', versions, metadata) + t.equal(selected.manifest.version, '1.0.0', 'picked the right manifest using specific version') + t.equal(selected.resolvedTo, '1.0.0', 'resolved using version match') + t.end() +}) + +test('nothing if range does not match anything', function (t) { + var metadata = { + 'dist-tags': {}, + versions: { + '1.0.0': { version: '1.0.0' }, + '2.0.0': { version: '2.0.0' }, + '2.0.5': { version: '2.0.5' } + } + } + var versions = Object.keys(metadata.versions) + var selected = pickManifest('^2.1.0', 'latest', versions, metadata) + t.equal(selected, undefined, 'no manifest matched') + t.end() +}) + +test('if `defaultTag` matches a given range, use it', function (t) { + var metadata = { + 'dist-tags': { + foo: '1.0.1' + }, + versions: { + '1.0.0': { version: '1.0.0' }, + '1.0.1': { version: '1.0.1' }, + '1.0.2': { version: '1.0.2' }, + '2.0.0': { version: '2.0.0' } + } + } + var versions = Object.keys(metadata.versions) + var selected = pickManifest('^1.0.0', 'foo', versions, metadata) + t.equal(selected.manifest.version, '1.0.1', 'picked the version for foo') + t.equal(selected.resolvedTo, 'foo', 'resolved using tag') + + selected = pickManifest('^2.0.0', 'foo', versions, metadata) + t.equal(selected.manifest.version, '2.0.0', 'no match, no foo') + t.equal(selected.resolvedTo, '2.0.0', 'resolved using version match') + + t.end() +}) + +test('* ranges use `defaultTag` if no versions match', function (t) { + var metadata = { + 'dist-tags': { + beta: '2.0.0-beta.0' + }, + versions: { + '1.0.0-pre.0': { version: '1.0.0-pre.0' }, + '1.0.0-pre.1': { version: '1.0.0-pre.1' }, + '2.0.0-beta.0': { version: '2.0.0-beta.0' }, + '2.0.0-beta.1': { version: '2.0.0-beta.1' } + } + } + var versions = Object.keys(metadata.versions) + var selected = pickManifest('*', 'beta', versions, metadata) + t.equal(selected.manifest.version, '2.0.0-beta.0', 'used defaultTag for all-prerelease splat.') + t.equal(selected.resolvedTo, 'beta', 'resolved using tag') + t.end() +}) + +test('no result if metadata has no versions', function (t) { + var selected = pickManifest('^1.0.0', 'latest', [], {'dist-tags': {}, versions: {}}) + t.equal(selected, undefined, 'no versions, no result') + t.end() +}) diff --git a/deps/npm/test/tap/prune.js b/deps/npm/test/tap/prune.js index 23c8548df5332b..ef69dc88b91cb9 100644 --- a/deps/npm/test/tap/prune.js +++ b/deps/npm/test/tap/prune.js @@ -107,7 +107,7 @@ test('npm prune', function (t) { ], EXEC_OPTS, function (err, code, stderr) { t.ifErr(err, 'prune finished successfully') t.notOk(code, 'exit ok') - t.equal(stderr, 'unbuild mkdirp@0.3.5\n') + t.equal(stderr, '- mkdirp@0.3.5 node_modules/mkdirp\n') t.end() }) }) diff --git a/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js b/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js index 2598d5578620f9..73eeee81a66a98 100644 --- a/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js +++ b/deps/npm/test/tap/splat-with-only-prerelease-to-latest.js @@ -7,7 +7,8 @@ var moduleName = 'xyzzy-wibble' var testModule = { name: moduleName, 'dist-tags': { - latest: '1.3.0-a' + latest: '1.3.0-a', + other: '1.2.0-a' }, versions: { '1.0.0-a': { @@ -69,12 +70,19 @@ test('setup', function (t) { }) test('splat', function (t) { - t.plan(4) + t.plan(8) var addNamed = require('../../lib/cache/add-named.js') addNamed('xyzzy-wibble', '*', testModule, function (err, pkg) { t.error(err, 'Succesfully resolved a splat package') t.is(pkg.name, moduleName) t.is(pkg.version, testModule['dist-tags'].latest) t.is(lastFetched, 'https://registry.npmjs.org/aproba/-/xyzzy-wibble-1.3.0-a.tgz') + npm.config.set('tag', 'other') + addNamed('xyzzy-wibble', '*', testModule, function (err, pkg) { + t.error(err, 'Succesfully resolved a splat package') + t.is(pkg.name, moduleName) + t.is(pkg.version, testModule['dist-tags'].other) + t.is(lastFetched, 'https://registry.npmjs.org/aproba/-/xyzzy-wibble-1.2.0-a.tgz') + }) }) }) diff --git a/deps/npm/test/tap/unsupported.js b/deps/npm/test/tap/unsupported.js index dff86a6231ff7e..b0dd8448aa3766 100644 --- a/deps/npm/test/tap/unsupported.js +++ b/deps/npm/test/tap/unsupported.js @@ -15,7 +15,7 @@ var versions = [ ['v0.9.6', false, true], ['v0.10.48', false, true], ['v0.11.16', false, true], - ['v0.12.9', false, false], + ['v0.12.9', false, true], ['v1.0.1', false, true], ['v1.6.0', false, true], ['v2.3.1', false, true], diff --git a/deps/openssl/asm/x64-elf-gas/bn/x86_64-mont.s b/deps/openssl/asm/x64-elf-gas/bn/x86_64-mont.s index 21175f570d09ec..0fd3703ade86ee 100644 --- a/deps/openssl/asm/x64-elf-gas/bn/x86_64-mont.s +++ b/deps/openssl/asm/x64-elf-gas/bn/x86_64-mont.s @@ -995,18 +995,17 @@ bn_mulx4x_mont: mulxq 16(%rsi),%r15,%r13 adoxq -24(%rbx),%r11 adcxq %r15,%r12 - adoxq %rbp,%r12 + adoxq -16(%rbx),%r12 adcxq %rbp,%r13 + adoxq %rbp,%r13 movq %rdi,8(%rsp) -.byte 0x67 movq %r8,%r15 imulq 24(%rsp),%r8 xorl %ebp,%ebp mulxq 24(%rsi),%rax,%r14 movq %r8,%rdx - adoxq -16(%rbx),%r12 adcxq %rax,%r13 adoxq -8(%rbx),%r13 adcxq %rbp,%r14 diff --git a/deps/openssl/asm/x64-elf-gas/bn/x86_64-mont5.s b/deps/openssl/asm/x64-elf-gas/bn/x86_64-mont5.s index 416152560a7ac4..7eac91326f6dd5 100644 --- a/deps/openssl/asm/x64-elf-gas/bn/x86_64-mont5.s +++ b/deps/openssl/asm/x64-elf-gas/bn/x86_64-mont5.s @@ -1889,6 +1889,7 @@ __bn_sqr8x_reduction: .align 32 .L8x_tail_done: + xorq %rax,%rax addq (%rdx),%r8 adcq $0,%r9 adcq $0,%r10 @@ -1897,9 +1898,7 @@ __bn_sqr8x_reduction: adcq $0,%r13 adcq $0,%r14 adcq $0,%r15 - - - xorq %rax,%rax + adcq $0,%rax negq %rsi .L8x_no_tail: @@ -3344,6 +3343,7 @@ __bn_sqrx8x_reduction: .align 32 .Lsqrx8x_tail_done: + xorq %rax,%rax addq 24+8(%rsp),%r8 adcq $0,%r9 adcq $0,%r10 @@ -3352,9 +3352,7 @@ __bn_sqrx8x_reduction: adcq $0,%r13 adcq $0,%r14 adcq $0,%r15 - - - movq %rsi,%rax + adcq $0,%rax subq 16+8(%rsp),%rsi .Lsqrx8x_no_tail: @@ -3369,7 +3367,7 @@ __bn_sqrx8x_reduction: adcq 40(%rdi),%r13 adcq 48(%rdi),%r14 adcq 56(%rdi),%r15 - adcq %rax,%rax + adcq $0,%rax movq 32+8(%rsp),%rbx movq 64(%rdi,%rcx,1),%rdx diff --git a/deps/openssl/asm/x64-macosx-gas/bn/x86_64-mont.s b/deps/openssl/asm/x64-macosx-gas/bn/x86_64-mont.s index 1d5e63892f024f..9fcda4ba3b69fe 100644 --- a/deps/openssl/asm/x64-macosx-gas/bn/x86_64-mont.s +++ b/deps/openssl/asm/x64-macosx-gas/bn/x86_64-mont.s @@ -995,18 +995,17 @@ L$mulx4x_outer: mulxq 16(%rsi),%r15,%r13 adoxq -24(%rbx),%r11 adcxq %r15,%r12 - adoxq %rbp,%r12 + adoxq -16(%rbx),%r12 adcxq %rbp,%r13 + adoxq %rbp,%r13 movq %rdi,8(%rsp) -.byte 0x67 movq %r8,%r15 imulq 24(%rsp),%r8 xorl %ebp,%ebp mulxq 24(%rsi),%rax,%r14 movq %r8,%rdx - adoxq -16(%rbx),%r12 adcxq %rax,%r13 adoxq -8(%rbx),%r13 adcxq %rbp,%r14 diff --git a/deps/openssl/asm/x64-macosx-gas/bn/x86_64-mont5.s b/deps/openssl/asm/x64-macosx-gas/bn/x86_64-mont5.s index 878c31ffac81ab..21416b6f5d720c 100644 --- a/deps/openssl/asm/x64-macosx-gas/bn/x86_64-mont5.s +++ b/deps/openssl/asm/x64-macosx-gas/bn/x86_64-mont5.s @@ -1889,6 +1889,7 @@ L$8x_tail: .p2align 5 L$8x_tail_done: + xorq %rax,%rax addq (%rdx),%r8 adcq $0,%r9 adcq $0,%r10 @@ -1897,9 +1898,7 @@ L$8x_tail_done: adcq $0,%r13 adcq $0,%r14 adcq $0,%r15 - - - xorq %rax,%rax + adcq $0,%rax negq %rsi L$8x_no_tail: @@ -3344,6 +3343,7 @@ L$sqrx8x_tail: .p2align 5 L$sqrx8x_tail_done: + xorq %rax,%rax addq 24+8(%rsp),%r8 adcq $0,%r9 adcq $0,%r10 @@ -3352,9 +3352,7 @@ L$sqrx8x_tail_done: adcq $0,%r13 adcq $0,%r14 adcq $0,%r15 - - - movq %rsi,%rax + adcq $0,%rax subq 16+8(%rsp),%rsi L$sqrx8x_no_tail: @@ -3369,7 +3367,7 @@ L$sqrx8x_no_tail: adcq 40(%rdi),%r13 adcq 48(%rdi),%r14 adcq 56(%rdi),%r15 - adcq %rax,%rax + adcq $0,%rax movq 32+8(%rsp),%rbx movq 64(%rdi,%rcx,1),%rdx diff --git a/deps/openssl/asm/x64-win32-masm/bn/x86_64-mont.asm b/deps/openssl/asm/x64-win32-masm/bn/x86_64-mont.asm index 9693ed97e47c9b..a1efb2f6987991 100644 --- a/deps/openssl/asm/x64-win32-masm/bn/x86_64-mont.asm +++ b/deps/openssl/asm/x64-win32-masm/bn/x86_64-mont.asm @@ -1053,18 +1053,17 @@ $L$mulx4x_outer:: mulx r13,r15,QWORD PTR[16+rsi] adox r11,QWORD PTR[((-24))+rbx] adcx r12,r15 - adox r12,rbp + adox r12,QWORD PTR[((-16))+rbx] adcx r13,rbp + adox r13,rbp mov QWORD PTR[8+rsp],rdi -DB 067h mov r15,r8 imul r8,QWORD PTR[24+rsp] xor ebp,ebp mulx r14,rax,QWORD PTR[24+rsi] mov rdx,r8 - adox r12,QWORD PTR[((-16))+rbx] adcx r13,rax adox r13,QWORD PTR[((-8))+rbx] adcx r14,rbp diff --git a/deps/openssl/asm/x64-win32-masm/bn/x86_64-mont5.asm b/deps/openssl/asm/x64-win32-masm/bn/x86_64-mont5.asm index 6cd4f2d3d8bc3c..837b0bcedcd0c6 100644 --- a/deps/openssl/asm/x64-win32-masm/bn/x86_64-mont5.asm +++ b/deps/openssl/asm/x64-win32-masm/bn/x86_64-mont5.asm @@ -1935,6 +1935,7 @@ $L$8x_tail:: ALIGN 32 $L$8x_tail_done:: + xor rax,rax add r8,QWORD PTR[rdx] adc r9,0 adc r10,0 @@ -1943,9 +1944,7 @@ $L$8x_tail_done:: adc r13,0 adc r14,0 adc r15,0 - - - xor rax,rax + adc rax,0 neg rsi $L$8x_no_tail:: @@ -3435,6 +3434,7 @@ DB 0c4h,062h,0fbh,0f6h,0a5h,020h,000h,000h,000h ALIGN 32 $L$sqrx8x_tail_done:: + xor rax,rax add r8,QWORD PTR[((24+8))+rsp] adc r9,0 adc r10,0 @@ -3443,9 +3443,7 @@ $L$sqrx8x_tail_done:: adc r13,0 adc r14,0 adc r15,0 - - - mov rax,rsi + adc rax,0 sub rsi,QWORD PTR[((16+8))+rsp] $L$sqrx8x_no_tail:: @@ -3460,7 +3458,7 @@ DB 102,72,15,126,213 adc r13,QWORD PTR[40+rdi] adc r14,QWORD PTR[48+rdi] adc r15,QWORD PTR[56+rdi] - adc rax,rax + adc rax,0 mov rbx,QWORD PTR[((32+8))+rsp] mov rdx,QWORD PTR[64+rcx*1+rdi] diff --git a/deps/openssl/asm_obsolete/x64-elf-gas/bn/x86_64-mont5.s b/deps/openssl/asm_obsolete/x64-elf-gas/bn/x86_64-mont5.s index 74ac8ee1595f47..175f5525779d50 100644 --- a/deps/openssl/asm_obsolete/x64-elf-gas/bn/x86_64-mont5.s +++ b/deps/openssl/asm_obsolete/x64-elf-gas/bn/x86_64-mont5.s @@ -1881,6 +1881,7 @@ __bn_sqr8x_reduction: .align 32 .L8x_tail_done: + xorq %rax,%rax addq (%rdx),%r8 adcq $0,%r9 adcq $0,%r10 @@ -1889,9 +1890,7 @@ __bn_sqr8x_reduction: adcq $0,%r13 adcq $0,%r14 adcq $0,%r15 - - - xorq %rax,%rax + adcq $0,%rax negq %rsi .L8x_no_tail: diff --git a/deps/openssl/asm_obsolete/x64-macosx-gas/bn/x86_64-mont5.s b/deps/openssl/asm_obsolete/x64-macosx-gas/bn/x86_64-mont5.s index 527abf57114b25..17036a5abdccee 100644 --- a/deps/openssl/asm_obsolete/x64-macosx-gas/bn/x86_64-mont5.s +++ b/deps/openssl/asm_obsolete/x64-macosx-gas/bn/x86_64-mont5.s @@ -1881,6 +1881,7 @@ L$8x_tail: .p2align 5 L$8x_tail_done: + xorq %rax,%rax addq (%rdx),%r8 adcq $0,%r9 adcq $0,%r10 @@ -1889,9 +1890,7 @@ L$8x_tail_done: adcq $0,%r13 adcq $0,%r14 adcq $0,%r15 - - - xorq %rax,%rax + adcq $0,%rax negq %rsi L$8x_no_tail: diff --git a/deps/openssl/asm_obsolete/x64-win32-masm/bn/x86_64-mont5.asm b/deps/openssl/asm_obsolete/x64-win32-masm/bn/x86_64-mont5.asm index 89f45a49157cba..a1cd3dd1b6606e 100644 --- a/deps/openssl/asm_obsolete/x64-win32-masm/bn/x86_64-mont5.asm +++ b/deps/openssl/asm_obsolete/x64-win32-masm/bn/x86_64-mont5.asm @@ -1927,6 +1927,7 @@ $L$8x_tail:: ALIGN 32 $L$8x_tail_done:: + xor rax,rax add r8,QWORD PTR[rdx] adc r9,0 adc r10,0 @@ -1935,9 +1936,7 @@ $L$8x_tail_done:: adc r13,0 adc r14,0 adc r15,0 - - - xor rax,rax + adc rax,0 neg rsi $L$8x_no_tail:: diff --git a/deps/openssl/openssl/CHANGES b/deps/openssl/openssl/CHANGES index 042afe37246c60..95aabc64d05475 100644 --- a/deps/openssl/openssl/CHANGES +++ b/deps/openssl/openssl/CHANGES @@ -2,6 +2,67 @@ OpenSSL CHANGES _______________ + Changes between 1.0.2j and 1.0.2k [26 Jan 2017] + + *) Truncated packet could crash via OOB read + + If one side of an SSL/TLS path is running on a 32-bit host and a specific + cipher is being used, then a truncated packet can cause that host to + perform an out-of-bounds read, usually resulting in a crash. + + This issue was reported to OpenSSL by Robert Święcki of Google. + (CVE-2017-3731) + [Andy Polyakov] + + *) BN_mod_exp may produce incorrect results on x86_64 + + There is a carry propagating bug in the x86_64 Montgomery squaring + procedure. No EC algorithms are affected. Analysis suggests that attacks + against RSA and DSA as a result of this defect would be very difficult to + perform and are not believed likely. Attacks against DH are considered just + feasible (although very difficult) because most of the work necessary to + deduce information about a private key may be performed offline. The amount + of resources required for such an attack would be very significant and + likely only accessible to a limited number of attackers. An attacker would + additionally need online access to an unpatched system using the target + private key in a scenario with persistent DH parameters and a private + key that is shared between multiple clients. For example this can occur by + default in OpenSSL DHE based SSL/TLS ciphersuites. Note: This issue is very + similar to CVE-2015-3193 but must be treated as a separate problem. + + This issue was reported to OpenSSL by the OSS-Fuzz project. + (CVE-2017-3732) + [Andy Polyakov] + + *) Montgomery multiplication may produce incorrect results + + There is a carry propagating bug in the Broadwell-specific Montgomery + multiplication procedure that handles input lengths divisible by, but + longer than 256 bits. Analysis suggests that attacks against RSA, DSA + and DH private keys are impossible. This is because the subroutine in + question is not used in operations with the private key itself and an input + of the attacker's direct choice. Otherwise the bug can manifest itself as + transient authentication and key negotiation failures or reproducible + erroneous outcome of public-key operations with specially crafted input. + Among EC algorithms only Brainpool P-512 curves are affected and one + presumably can attack ECDH key negotiation. Impact was not analyzed in + detail, because pre-requisites for attack are considered unlikely. Namely + multiple clients have to choose the curve in question and the server has to + share the private key among them, neither of which is default behaviour. + Even then only clients that chose the curve will be affected. + + This issue was publicly reported as transient failures and was not + initially recognized as a security issue. Thanks to Richard Morgan for + providing reproducible case. + (CVE-2016-7055) + [Andy Polyakov] + + *) OpenSSL now fails if it receives an unrecognised record type in TLS1.0 + or TLS1.1. Previously this only happened in SSLv3 and TLS1.2. This is to + prevent issues where no progress is being made and the peer continually + sends unrecognised record types, using up resources processing them. + [Matt Caswell] + Changes between 1.0.2i and 1.0.2j [26 Sep 2016] *) Missing CRL sanity check diff --git a/deps/openssl/openssl/CONTRIBUTING b/deps/openssl/openssl/CONTRIBUTING index 07115e5a758869..f734d77ba76b3b 100644 --- a/deps/openssl/openssl/CONTRIBUTING +++ b/deps/openssl/openssl/CONTRIBUTING @@ -1,4 +1,4 @@ -HOW TO CONTRIBUTE TO PATCHES OpenSSL +HOW TO CONTRIBUTE PATCHES TO OpenSSL ------------------------------------ (Please visit https://www.openssl.org/community/getting-started.html for @@ -11,34 +11,12 @@ OpenSSL community you might want to discuss it on the openssl-dev mailing list first. Someone may be already working on the same thing or there may be a good reason as to why that feature isn't implemented. -The best way to submit a patch is to make a pull request on GitHub. -(It is not necessary to send mail to rt@openssl.org to open a ticket!) -If you think the patch could use feedback from the community, please -start a thread on openssl-dev. +To submit a patch, make a pull request on GitHub. If you think the patch +could use feedback from the community, please start a thread on openssl-dev +to discuss it. -You can also submit patches by sending it as mail to rt@openssl.org. -Please include the word "PATCH" and an explanation of what the patch -does in the subject line. If you do this, our preferred format is "git -format-patch" output. For example to provide a patch file containing the -last commit in your local git repository use the following command: - - % git format-patch --stdout HEAD^ >mydiffs.patch - -Another method of creating an acceptable patch file without using git is as -follows: - - % cd openssl-work - ...make your changes... - % ./Configure dist; make clean - % cd .. - % diff -ur openssl-orig openssl-work >mydiffs.patch - -Note that pull requests are generally easier for the team, and community, to -work with. Pull requests benefit from all of the standard GitHub features, -including code review tools, simpler integration, and CI build support. - -No matter how a patch is submitted, the following items will help make -the acceptance and review process faster: +Having addressed the following items before the PR will help make the +acceptance and review process faster: 1. Anything other than trivial contributions will require a contributor licensing agreement, giving us permission to use your code. See @@ -55,21 +33,22 @@ the acceptance and review process faster: in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html - 3. Patches should be as current as possible. When using GitHub, please - expect to have to rebase and update often. Note that we do not accept merge - commits. You will be asked to remove them before a patch is considered - acceptable. + 3. Patches should be as current as possible; expect to have to rebase + often. We do not accept merge commits; You will be asked to remove + them before a patch is considered acceptable. 4. Patches should follow our coding style (see https://www.openssl.org/policies/codingstyle.html) and compile without warnings. Where gcc or clang is availble you should use the --strict-warnings Configure option. OpenSSL compiles on many varied platforms: try to ensure you only use portable features. + Clean builds via Travis and AppVeyor are expected, and done whenever + a PR is created or updated. - 5. When at all possible, patches should include tests. These can either be - added to an existing test, or completely new. Please see test/README - for information on the test framework. + 5. When at all possible, patches should include tests. These can + either be added to an existing test, or completely new. Please see + test/README for information on the test framework. - 6. New features or changed functionality must include documentation. Please - look at the "pod" files in doc/apps, doc/crypto and doc/ssl for examples of - our style. + 6. New features or changed functionality must include + documentation. Please look at the "pod" files in doc/apps, doc/crypto + and doc/ssl for examples of our style. diff --git a/deps/openssl/openssl/Configure b/deps/openssl/openssl/Configure index c39f71a17910ea..5da7cadbf3326c 100755 --- a/deps/openssl/openssl/Configure +++ b/deps/openssl/openssl/Configure @@ -7,6 +7,7 @@ eval 'exec perl -S $0 ${1+"$@"}' require 5.000; use strict; +use File::Compare; # see INSTALL for instructions. @@ -57,12 +58,13 @@ my $usage="Usage: Configure [no- ...] [enable- ...] [experimenta # zlib-dynamic Like "zlib", but the zlib library is expected to be a shared # library and will be loaded in run-time by the OpenSSL library. # sctp include SCTP support -# 386 generate 80386 code # enable-weak-ssl-ciphers # Enable EXPORT and LOW SSLv3 ciphers that are disabled by # default. Note, weak SSLv2 ciphers are unconditionally # disabled. -# no-sse2 disables IA-32 SSE2 code, above option implies no-sse2 +# 386 generate 80386 code in assembly modules +# no-sse2 disables IA-32 SSE2 code in assembly modules, the above +# mentioned '386' option implies this one # no- build without specified algorithm (rsa, idea, rc5, ...) # - + compiler options are passed through # @@ -1792,8 +1794,16 @@ while () } close(IN); close(OUT); -rename($Makefile,"$Makefile.bak") || die "unable to rename $Makefile\n" if -e $Makefile; -rename("$Makefile.new",$Makefile) || die "unable to rename $Makefile.new\n"; +if ((compare($Makefile, "$Makefile.new")) + or file_newer('Configure', $Makefile) + or file_newer('config', $Makefile) + or file_newer('Makefile.org', $Makefile)) + { + rename($Makefile,"$Makefile.bak") || die "unable to rename $Makefile\n" if -e $Makefile; + rename("$Makefile.new",$Makefile) || die "unable to rename $Makefile.new\n"; + } +else + { unlink("$Makefile.new"); } print "CC =$cc\n"; print "CFLAG =$cflags\n"; @@ -1985,9 +1995,13 @@ print OUT "#ifdef __cplusplus\n"; print OUT "}\n"; print OUT "#endif\n"; close(OUT); -rename("crypto/opensslconf.h","crypto/opensslconf.h.bak") || die "unable to rename crypto/opensslconf.h\n" if -e "crypto/opensslconf.h"; -rename("crypto/opensslconf.h.new","crypto/opensslconf.h") || die "unable to rename crypto/opensslconf.h.new\n"; - +if (compare("crypto/opensslconf.h.new","crypto/opensslconf.h")) + { + rename("crypto/opensslconf.h","crypto/opensslconf.h.bak") || die "unable to rename crypto/opensslconf.h\n" if -e "crypto/opensslconf.h"; + rename("crypto/opensslconf.h.new","crypto/opensslconf.h") || die "unable to rename crypto/opensslconf.h.new\n"; + } +else + { unlink("crypto/opensslconf.h.new"); } # Fix the date @@ -2289,3 +2303,9 @@ sub test_sanity print STDERR "No sanity errors detected!\n" if $errorcnt == 0; return $errorcnt; } + +sub file_newer + { + my ($file1, $file2) = @_; + return (stat($file1))[9] > (stat($file2))[9] + } diff --git a/deps/openssl/openssl/INSTALL b/deps/openssl/openssl/INSTALL index 679b30d4c7900f..aa7e35fa79fea0 100644 --- a/deps/openssl/openssl/INSTALL +++ b/deps/openssl/openssl/INSTALL @@ -74,24 +74,26 @@ no-asm Do not use assembler code. - 386 Use the 80386 instruction set only (the default x86 code is - more efficient, but requires at least a 486). Note: Use - compiler flags for any other CPU specific configuration, - e.g. "-m32" to build x86 code on an x64 system. - - no-sse2 Exclude SSE2 code pathes. Normally SSE2 extention is - detected at run-time, but the decision whether or not the - machine code will be executed is taken solely on CPU - capability vector. This means that if you happen to run OS - kernel which does not support SSE2 extension on Intel P4 - processor, then your application might be exposed to - "illegal instruction" exception. There might be a way - to enable support in kernel, e.g. FreeBSD kernel can be - compiled with CPU_ENABLE_SSE, and there is a way to - disengage SSE2 code pathes upon application start-up, - but if you aim for wider "audience" running such kernel, - consider no-sse2. Both 386 and no-asm options above imply - no-sse2. + 386 In 32-bit x86 builds, when generating assembly modules, + use the 80386 instruction set only (the default x86 code + is more efficient, but requires at least a 486). Note: + This doesn't affect code generated by compiler, you're + likely to complement configuration command line with + suitable compiler-specific option. + + no-sse2 Exclude SSE2 code paths from 32-bit x86 assembly modules. + Normally SSE2 extension is detected at run-time, but the + decision whether or not the machine code will be executed + is taken solely on CPU capability vector. This means that + if you happen to run OS kernel which does not support SSE2 + extension on Intel P4 processor, then your application + might be exposed to "illegal instruction" exception. + There might be a way to enable support in kernel, e.g. + FreeBSD kernel can be compiled with CPU_ENABLE_SSE, and + there is a way to disengage SSE2 code paths upon application + start-up, but if you aim for wider "audience" running + such kernel, consider no-sse2. Both the 386 and + no-asm options imply no-sse2. no- Build without the specified cipher (bf, cast, des, dh, dsa, hmac, md2, md5, mdc2, rc2, rc4, rc5, rsa, sha). @@ -101,7 +103,12 @@ -Dxxx, -lxxx, -Lxxx, -fxxx, -mXXX, -Kxxx These system specific options will be passed through to the compiler to allow you to define preprocessor symbols, specify additional libraries, - library directories or other compiler options. + library directories or other compiler options. It might be + worth noting that some compilers generate code specifically + for processor the compiler currently executes on. This is + not necessarily what you might have in mind, since it might + be unsuitable for execution on other, typically older, + processor. Consult your compiler documentation. -DHAVE_CRYPTODEV Enable the BSD cryptodev engine even if we are not using BSD. Useful if you are running ocf-linux or something @@ -159,18 +166,18 @@ OpenSSL binary ("openssl"). The libraries will be built in the top-level directory, and the binary will be in the "apps" directory. - If "make" fails, look at the output. There may be reasons for - the failure that aren't problems in OpenSSL itself (like missing - standard headers). If it is a problem with OpenSSL itself, please - report the problem to (note that your - message will be recorded in the request tracker publicly readable - at https://www.openssl.org/community/index.html#bugs and will be - forwarded to a public mailing list). Include the output of "make - report" in your message. Please check out the request tracker. Maybe - the bug was already reported or has already been fixed. - - [If you encounter assembler error messages, try the "no-asm" - configuration option as an immediate fix.] + If the build fails, look at the output. There may be reasons + for the failure that aren't problems in OpenSSL itself (like + missing standard headers). If you are having problems you can + get help by sending an email to the openssl-users email list (see + https://www.openssl.org/community/mailinglists.html for details). If + it is a bug with OpenSSL itself, please open an issue on GitHub, at + https://github.com/openssl/openssl/issues. Please review the existing + ones first; maybe the bug was already reported or has already been + fixed. + + (If you encounter assembler error messages, try the "no-asm" + configuration option as an immediate fix.) Compiling parts of OpenSSL with gcc and others with the system compiler will result in unresolved symbols on some systems. diff --git a/deps/openssl/openssl/Makefile b/deps/openssl/openssl/Makefile index 04bfb11a170108..0b894ff47f300b 100644 --- a/deps/openssl/openssl/Makefile +++ b/deps/openssl/openssl/Makefile @@ -4,7 +4,7 @@ ## Makefile for OpenSSL ## -VERSION=1.0.2j +VERSION=1.0.2k MAJOR=1 MINOR=0.2 SHLIB_VERSION_NUMBER=1.0.0 @@ -203,7 +203,8 @@ CLEARENV= TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS} \ $${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \ $${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \ $${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \ - $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS} + $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS} \ + $${APPS+APPS} # LC_ALL=C ensures that error [and other] messages are delivered in # same language for uniform treatment. diff --git a/deps/openssl/openssl/Makefile.bak b/deps/openssl/openssl/Makefile.bak index 7b97fb0dc1989b..402333e809e51a 100644 --- a/deps/openssl/openssl/Makefile.bak +++ b/deps/openssl/openssl/Makefile.bak @@ -4,7 +4,7 @@ ## Makefile for OpenSSL ## -VERSION=1.0.2j +VERSION=1.0.2k MAJOR=1 MINOR=0.2 SHLIB_VERSION_NUMBER=1.0.0 @@ -203,7 +203,8 @@ CLEARENV= TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS} \ $${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \ $${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \ $${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \ - $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS} + $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS} \ + $${APPS+APPS} # LC_ALL=C ensures that error [and other] messages are delivered in # same language for uniform treatment. diff --git a/deps/openssl/openssl/Makefile.org b/deps/openssl/openssl/Makefile.org index 2377f5029187fd..61a329b4f20f6e 100644 --- a/deps/openssl/openssl/Makefile.org +++ b/deps/openssl/openssl/Makefile.org @@ -201,7 +201,8 @@ CLEARENV= TOP= && unset TOP $${LIB+LIB} $${LIBS+LIBS} \ $${ASFLAGS+ASFLAGS} $${AFLAGS+AFLAGS} \ $${LDCMD+LDCMD} $${LDFLAGS+LDFLAGS} $${SCRIPTS+SCRIPTS} \ $${SHAREDCMD+SHAREDCMD} $${SHAREDFLAGS+SHAREDFLAGS} \ - $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS} + $${SHARED_LIB+SHARED_LIB} $${LIBEXTRAS+LIBEXTRAS} \ + $${APPS+APPS} # LC_ALL=C ensures that error [and other] messages are delivered in # same language for uniform treatment. diff --git a/deps/openssl/openssl/NEWS b/deps/openssl/openssl/NEWS index c0579632b2ebdc..be4a266bac13a4 100644 --- a/deps/openssl/openssl/NEWS +++ b/deps/openssl/openssl/NEWS @@ -5,9 +5,15 @@ This file gives a brief overview of the major changes between each OpenSSL release. For more details please read the CHANGES file. + Major changes between OpenSSL 1.0.2j and OpenSSL 1.0.2k [26 Jan 2017] + + o Truncated packet could crash via OOB read (CVE-2017-3731) + o BN_mod_exp may produce incorrect results on x86_64 (CVE-2017-3732) + o Montgomery multiplication may produce incorrect results (CVE-2016-7055) + Major changes between OpenSSL 1.0.2i and OpenSSL 1.0.2j [26 Sep 2016] - o Fix Use After Free for large message sizes (CVE-2016-6309) + o Missing CRL sanity check (CVE-2016-7052) Major changes between OpenSSL 1.0.2h and OpenSSL 1.0.2i [22 Sep 2016] diff --git a/deps/openssl/openssl/README b/deps/openssl/openssl/README index 6dedfc019738c0..615d0c6a5dc8f5 100644 --- a/deps/openssl/openssl/README +++ b/deps/openssl/openssl/README @@ -1,5 +1,5 @@ - OpenSSL 1.0.2j 26 Sep 2016 + OpenSSL 1.0.2k 26 Jan 2017 Copyright (c) 1998-2015 The OpenSSL Project Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson @@ -66,13 +66,13 @@ If you have any problems with OpenSSL then please take the following steps first: - - Download the current snapshot from ftp://ftp.openssl.org/snapshot/ + - Download the latest version from the repository to see if the problem has already been addressed - - Remove ASM versions of libraries + - Configure with no-asm - Remove compiler optimisation flags - If you wish to report a bug then please include the following information in - any bug report: + If you wish to report a bug then please include the following information + and create an issue on GitHub: - On Unix systems: Self-test report generated by 'make report' @@ -84,27 +84,9 @@ - Problem Description (steps that will reproduce the problem, if known) - Stack Traceback (if the application dumps core) - Email the report to: - - rt@openssl.org - - In order to avoid spam, this is a moderated mailing list, and it might - take a day for the ticket to show up. (We also scan posts to make sure - that security disclosures aren't publically posted by mistake.) Mail - to this address is recorded in the public RT (request tracker) database - (see https://www.openssl.org/community/index.html#bugs for details) and - also forwarded the public openssl-dev mailing list. Confidential mail - may be sent to openssl-security@openssl.org (PGP key available from the - key servers). - - Please do NOT use this for general assistance or support queries. Just because something doesn't work the way you expect does not mean it is necessarily a bug in OpenSSL. - You can also make GitHub pull requests. If you do this, please also send - mail to rt@openssl.org with a link to the PR so that we can more easily - keep track of it. - HOW TO CONTRIBUTE TO OpenSSL ---------------------------- @@ -113,7 +95,7 @@ LEGALITIES ---------- - A number of nations, in particular the U.S., restrict the use or export - of cryptography. If you are potentially subject to such restrictions - you should seek competent professional legal advice before attempting to - develop or distribute cryptographic code. + A number of nations restrict the use or export of cryptography. If you + are potentially subject to such restrictions you should seek competent + professional legal advice before attempting to develop or distribute + cryptographic code. diff --git a/deps/openssl/openssl/apps/apps.c b/deps/openssl/openssl/apps/apps.c index 9fdc3e0097c557..c487bd92db2a63 100644 --- a/deps/openssl/openssl/apps/apps.c +++ b/deps/openssl/openssl/apps/apps.c @@ -972,7 +972,10 @@ EVP_PKEY *load_key(BIO *err, const char *file, int format, int maybe_stdin, if (!e) BIO_printf(err, "no engine specified\n"); else { - pkey = ENGINE_load_private_key(e, file, ui_method, &cb_data); + if (ENGINE_init(e)) { + pkey = ENGINE_load_private_key(e, file, ui_method, &cb_data); + ENGINE_finish(e); + } if (!pkey) { BIO_printf(err, "cannot load %s from engine\n", key_descrip); ERR_print_errors(err); @@ -1532,11 +1535,13 @@ static ENGINE *try_load_engine(BIO *err, const char *engine, int debug) } return e; } +#endif ENGINE *setup_engine(BIO *err, const char *engine, int debug) { ENGINE *e = NULL; +#ifndef OPENSSL_NO_ENGINE if (engine) { if (strcmp(engine, "auto") == 0) { BIO_printf(err, "enabling auto ENGINE support\n"); @@ -1561,13 +1566,19 @@ ENGINE *setup_engine(BIO *err, const char *engine, int debug) } BIO_printf(err, "engine \"%s\" set.\n", ENGINE_get_id(e)); - - /* Free our "structural" reference. */ - ENGINE_free(e); } +#endif return e; } + +void release_engine(ENGINE *e) +{ +#ifndef OPENSSL_NO_ENGINE + if (e != NULL) + /* Free our "structural" reference. */ + ENGINE_free(e); #endif +} int load_config(BIO *err, CONF *cnf) { diff --git a/deps/openssl/openssl/apps/apps.h b/deps/openssl/openssl/apps/apps.h index c6c3881f31e1e6..268863c336a4f8 100644 --- a/deps/openssl/openssl/apps/apps.h +++ b/deps/openssl/openssl/apps/apps.h @@ -259,9 +259,9 @@ STACK_OF(X509_CRL) *load_crls(BIO *err, const char *file, int format, const char *pass, ENGINE *e, const char *cert_descrip); X509_STORE *setup_verify(BIO *bp, char *CAfile, char *CApath); -# ifndef OPENSSL_NO_ENGINE + ENGINE *setup_engine(BIO *err, const char *engine, int debug); -# endif +void release_engine(ENGINE *e); # ifndef OPENSSL_NO_OCSP OCSP_RESPONSE *process_responder(BIO *err, OCSP_REQUEST *req, diff --git a/deps/openssl/openssl/apps/ca.c b/deps/openssl/openssl/apps/ca.c index a0ec5838fa7cb3..4cea3cb7b1cea8 100644 --- a/deps/openssl/openssl/apps/ca.c +++ b/deps/openssl/openssl/apps/ca.c @@ -319,9 +319,7 @@ int MAIN(int argc, char **argv) #define BSIZE 256 MS_STATIC char buf[3][BSIZE]; char *randfile = NULL; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif char *tofree = NULL; DB_ATTR db_attr; @@ -595,9 +593,7 @@ int MAIN(int argc, char **argv) if (!load_config(bio_err, conf)) goto err; -#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -#endif /* Lets get the config section we are using */ if (section == NULL) { @@ -1485,6 +1481,7 @@ int MAIN(int argc, char **argv) X509_CRL_free(crl); NCONF_free(conf); NCONF_free(extconf); + release_engine(e); OBJ_cleanup(); apps_shutdown(); OPENSSL_EXIT(ret); @@ -2227,7 +2224,6 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey, sk = CONF_get_section(parms, "default"); if (sk_CONF_VALUE_num(sk) == 0) { BIO_printf(bio_err, "no name/value pairs found in %s\n", infile); - CONF_free(parms); goto err; } diff --git a/deps/openssl/openssl/apps/cms.c b/deps/openssl/openssl/apps/cms.c index 60479374cdf28e..f9a63bc0d0968e 100644 --- a/deps/openssl/openssl/apps/cms.c +++ b/deps/openssl/openssl/apps/cms.c @@ -143,9 +143,7 @@ int MAIN(int argc, char **argv) const EVP_MD *sign_md = NULL; int informat = FORMAT_SMIME, outformat = FORMAT_SMIME; int rctformat = FORMAT_SMIME, keyform = FORMAT_PEM; -# ifndef OPENSSL_NO_ENGINE char *engine = NULL; -# endif unsigned char *secret_key = NULL, *secret_keyid = NULL; unsigned char *pwri_pass = NULL, *pwri_tmp = NULL; size_t secret_keylen = 0, secret_keyidlen = 0; @@ -665,9 +663,7 @@ int MAIN(int argc, char **argv) "cert.pem recipient certificate(s) for encryption\n"); goto end; } -# ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -# endif if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); @@ -1170,6 +1166,7 @@ int MAIN(int argc, char **argv) EVP_PKEY_free(key); CMS_ContentInfo_free(cms); CMS_ContentInfo_free(rcms); + release_engine(e); BIO_free(rctin); BIO_free(in); BIO_free(indata); diff --git a/deps/openssl/openssl/apps/dgst.c b/deps/openssl/openssl/apps/dgst.c index 26afcd7b30baf1..bc2601e452efa3 100644 --- a/deps/openssl/openssl/apps/dgst.c +++ b/deps/openssl/openssl/apps/dgst.c @@ -537,6 +537,7 @@ int MAIN(int argc, char **argv) OPENSSL_free(sigbuf); if (bmd != NULL) BIO_free(bmd); + release_engine(e); apps_shutdown(); OPENSSL_EXIT(err); } diff --git a/deps/openssl/openssl/apps/dh.c b/deps/openssl/openssl/apps/dh.c index 48fecc99603498..bb13fef16e4337 100644 --- a/deps/openssl/openssl/apps/dh.c +++ b/deps/openssl/openssl/apps/dh.c @@ -94,9 +94,7 @@ int MAIN(int argc, char **argv) BIO *in = NULL, *out = NULL; int informat, outformat, check = 0, noout = 0, C = 0, ret = 1; char *infile, *outfile, *prog; -# ifndef OPENSSL_NO_ENGINE char *engine; -# endif apps_startup(); @@ -107,9 +105,7 @@ int MAIN(int argc, char **argv) if (!load_config(bio_err, NULL)) goto end; -# ifndef OPENSSL_NO_ENGINE engine = NULL; -# endif infile = NULL; outfile = NULL; informat = FORMAT_PEM; @@ -183,9 +179,7 @@ int MAIN(int argc, char **argv) ERR_load_crypto_strings(); -# ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, engine, 0); -# endif in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); diff --git a/deps/openssl/openssl/apps/dhparam.c b/deps/openssl/openssl/apps/dhparam.c index 57199a8d2ad867..1210adb104d9f3 100644 --- a/deps/openssl/openssl/apps/dhparam.c +++ b/deps/openssl/openssl/apps/dhparam.c @@ -159,9 +159,8 @@ int MAIN(int argc, char **argv) int informat, outformat, check = 0, noout = 0, C = 0, ret = 1; char *infile, *outfile, *prog; char *inrand = NULL; -# ifndef OPENSSL_NO_ENGINE char *engine = NULL; -# endif + ENGINE *e = NULL; int num = 0, g = 0; apps_startup(); @@ -270,9 +269,7 @@ int MAIN(int argc, char **argv) ERR_load_crypto_strings(); -# ifndef OPENSSL_NO_ENGINE - setup_engine(bio_err, engine, 0); -# endif + e = setup_engine(bio_err, engine, 0); if (g && !num) num = DEFBITS; @@ -512,6 +509,7 @@ int MAIN(int argc, char **argv) BIO_free_all(out); if (dh != NULL) DH_free(dh); + release_engine(e); apps_shutdown(); OPENSSL_EXIT(ret); } diff --git a/deps/openssl/openssl/apps/dsa.c b/deps/openssl/openssl/apps/dsa.c index dedf8e174a04cc..4ed21d891e8698 100644 --- a/deps/openssl/openssl/apps/dsa.c +++ b/deps/openssl/openssl/apps/dsa.c @@ -106,9 +106,7 @@ int MAIN(int argc, char **argv) int informat, outformat, text = 0, noout = 0; int pubin = 0, pubout = 0; char *infile, *outfile, *prog; -# ifndef OPENSSL_NO_ENGINE char *engine; -# endif char *passargin = NULL, *passargout = NULL; char *passin = NULL, *passout = NULL; int modulus = 0; @@ -124,9 +122,7 @@ int MAIN(int argc, char **argv) if (!load_config(bio_err, NULL)) goto end; -# ifndef OPENSSL_NO_ENGINE engine = NULL; -# endif infile = NULL; outfile = NULL; informat = FORMAT_PEM; @@ -239,9 +235,7 @@ int MAIN(int argc, char **argv) ERR_load_crypto_strings(); -# ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -# endif if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); @@ -358,6 +352,7 @@ int MAIN(int argc, char **argv) BIO_free_all(out); if (dsa != NULL) DSA_free(dsa); + release_engine(e); if (passin) OPENSSL_free(passin); if (passout) diff --git a/deps/openssl/openssl/apps/dsaparam.c b/deps/openssl/openssl/apps/dsaparam.c index 824a595c379424..f2cf553db3ff75 100644 --- a/deps/openssl/openssl/apps/dsaparam.c +++ b/deps/openssl/openssl/apps/dsaparam.c @@ -121,9 +121,8 @@ int MAIN(int argc, char **argv) char *infile, *outfile, *prog, *inrand = NULL; int numbits = -1, num, genkey = 0; int need_rand = 0; -# ifndef OPENSSL_NO_ENGINE char *engine = NULL; -# endif + ENGINE *e = NULL; # ifdef GENCB_TEST int timebomb = 0; # endif @@ -263,9 +262,7 @@ int MAIN(int argc, char **argv) } } -# ifndef OPENSSL_NO_ENGINE - setup_engine(bio_err, engine, 0); -# endif + e = setup_engine(bio_err, engine, 0); if (need_rand) { app_RAND_load_file(NULL, bio_err, (inrand != NULL)); @@ -433,6 +430,7 @@ int MAIN(int argc, char **argv) BIO_free_all(out); if (dsa != NULL) DSA_free(dsa); + release_engine(e); apps_shutdown(); OPENSSL_EXIT(ret); } diff --git a/deps/openssl/openssl/apps/ec.c b/deps/openssl/openssl/apps/ec.c index b04dadaf18c0a0..d2263c87392e1c 100644 --- a/deps/openssl/openssl/apps/ec.c +++ b/deps/openssl/openssl/apps/ec.c @@ -95,6 +95,7 @@ int MAIN(int argc, char **argv) int informat, outformat, text = 0, noout = 0; int pubin = 0, pubout = 0, param_out = 0; char *infile, *outfile, *prog, *engine; + ENGINE *e = NULL; char *passargin = NULL, *passargout = NULL; char *passin = NULL, *passout = NULL; point_conversion_form_t form = POINT_CONVERSION_UNCOMPRESSED; @@ -235,9 +236,7 @@ int MAIN(int argc, char **argv) ERR_load_crypto_strings(); -# ifndef OPENSSL_NO_ENGINE - setup_engine(bio_err, engine, 0); -# endif + e = setup_engine(bio_err, engine, 0); if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); @@ -349,6 +348,7 @@ int MAIN(int argc, char **argv) BIO_free_all(out); if (eckey) EC_KEY_free(eckey); + release_engine(e); if (passin) OPENSSL_free(passin); if (passout) diff --git a/deps/openssl/openssl/apps/ecparam.c b/deps/openssl/openssl/apps/ecparam.c index 71b67f435cfd56..a9bf489cdd4c7a 100644 --- a/deps/openssl/openssl/apps/ecparam.c +++ b/deps/openssl/openssl/apps/ecparam.c @@ -131,6 +131,7 @@ int MAIN(int argc, char **argv) BIO *in = NULL, *out = NULL; int informat, outformat, noout = 0, C = 0, ret = 1; char *engine = NULL; + ENGINE *e = NULL; BIGNUM *ec_p = NULL, *ec_a = NULL, *ec_b = NULL, *ec_gen = NULL, *ec_order = NULL, *ec_cofactor = NULL; @@ -311,9 +312,7 @@ int MAIN(int argc, char **argv) } } -# ifndef OPENSSL_NO_ENGINE - setup_engine(bio_err, engine, 0); -# endif + e = setup_engine(bio_err, engine, 0); if (list_curves) { EC_builtin_curve *curves = NULL; @@ -620,12 +619,13 @@ int MAIN(int argc, char **argv) BN_free(ec_cofactor); if (buffer) OPENSSL_free(buffer); + if (group != NULL) + EC_GROUP_free(group); + release_engine(e); if (in != NULL) BIO_free(in); if (out != NULL) BIO_free_all(out); - if (group != NULL) - EC_GROUP_free(group); apps_shutdown(); OPENSSL_EXIT(ret); } diff --git a/deps/openssl/openssl/apps/enc.c b/deps/openssl/openssl/apps/enc.c index 8e2ef27aca34f0..8c8f1ef0f90b21 100644 --- a/deps/openssl/openssl/apps/enc.c +++ b/deps/openssl/openssl/apps/enc.c @@ -126,9 +126,8 @@ int MAIN(int argc, char **argv) NULL, *wbio = NULL; #define PROG_NAME_SIZE 39 char pname[PROG_NAME_SIZE + 1]; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif + ENGINE *e = NULL; const EVP_MD *dgst = NULL; int non_fips_allow = 0; @@ -322,9 +321,7 @@ int MAIN(int argc, char **argv) argv++; } -#ifndef OPENSSL_NO_ENGINE - setup_engine(bio_err, engine, 0); -#endif + e = setup_engine(bio_err, engine, 0); if (cipher && EVP_CIPHER_flags(cipher) & EVP_CIPH_FLAG_AEAD_CIPHER) { BIO_printf(bio_err, @@ -674,6 +671,7 @@ int MAIN(int argc, char **argv) if (bzl != NULL) BIO_free(bzl); #endif + release_engine(e); if (pass) OPENSSL_free(pass); apps_shutdown(); diff --git a/deps/openssl/openssl/apps/gendh.c b/deps/openssl/openssl/apps/gendh.c index fef6f1b1774d15..59484c24460143 100644 --- a/deps/openssl/openssl/apps/gendh.c +++ b/deps/openssl/openssl/apps/gendh.c @@ -96,9 +96,7 @@ int MAIN(int argc, char **argv) int g = 2; char *outfile = NULL; char *inrand = NULL; -# ifndef OPENSSL_NO_ENGINE char *engine = NULL; -# endif BIO *out = NULL; apps_startup(); @@ -162,9 +160,7 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, " the random number generator\n"); goto end; } -# ifndef OPENSSL_NO_ENGINE setup_engine(bio_err, engine, 0); -# endif out = BIO_new(BIO_s_file()); if (out == NULL) { diff --git a/deps/openssl/openssl/apps/gendsa.c b/deps/openssl/openssl/apps/gendsa.c index fd1360acd57f55..31510e6123d7c4 100644 --- a/deps/openssl/openssl/apps/gendsa.c +++ b/deps/openssl/openssl/apps/gendsa.c @@ -85,9 +85,8 @@ int MAIN(int argc, char **argv) char *passargout = NULL, *passout = NULL; BIO *out = NULL, *in = NULL; const EVP_CIPHER *enc = NULL; -# ifndef OPENSSL_NO_ENGINE char *engine = NULL; -# endif + ENGINE *e = NULL; apps_startup(); @@ -206,9 +205,7 @@ int MAIN(int argc, char **argv) " - a DSA parameter file as generated by the dsaparam command\n"); goto end; } -# ifndef OPENSSL_NO_ENGINE - setup_engine(bio_err, engine, 0); -# endif + e = setup_engine(bio_err, engine, 0); if (!app_passwd(bio_err, NULL, passargout, NULL, &passout)) { BIO_printf(bio_err, "Error getting password\n"); @@ -273,6 +270,7 @@ int MAIN(int argc, char **argv) BIO_free_all(out); if (dsa != NULL) DSA_free(dsa); + release_engine(e); if (passout) OPENSSL_free(passout); apps_shutdown(); diff --git a/deps/openssl/openssl/apps/genpkey.c b/deps/openssl/openssl/apps/genpkey.c index fef21dc7ae9104..39dcef9ca0c9e8 100644 --- a/deps/openssl/openssl/apps/genpkey.c +++ b/deps/openssl/openssl/apps/genpkey.c @@ -275,9 +275,9 @@ int MAIN(int argc, char **argv) if (out) BIO_free_all(out); BIO_free(in); + release_engine(e); if (pass) OPENSSL_free(pass); - return ret; } diff --git a/deps/openssl/openssl/apps/genrsa.c b/deps/openssl/openssl/apps/genrsa.c index 91e6550a5767c5..51dcfcaea071c8 100644 --- a/deps/openssl/openssl/apps/genrsa.c +++ b/deps/openssl/openssl/apps/genrsa.c @@ -91,9 +91,7 @@ int MAIN(int, char **); int MAIN(int argc, char **argv) { BN_GENCB cb; -# ifndef OPENSSL_NO_ENGINE ENGINE *e = NULL; -# endif int ret = 1; int i, num = DEFBITS; long l; @@ -101,9 +99,7 @@ int MAIN(int argc, char **argv) unsigned long f4 = RSA_F4; char *outfile = NULL; char *passargout = NULL, *passout = NULL; -# ifndef OPENSSL_NO_ENGINE char *engine = NULL; -# endif char *inrand = NULL; BIO *out = NULL; BIGNUM *bn = BN_new(); @@ -240,9 +236,7 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, "Error getting password\n"); goto err; } -# ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -# endif if (outfile == NULL) { BIO_set_fp(out, stdout, BIO_NOCLOSE); @@ -314,6 +308,7 @@ int MAIN(int argc, char **argv) RSA_free(rsa); if (out) BIO_free_all(out); + release_engine(e); if (passout) OPENSSL_free(passout); if (ret != 0) diff --git a/deps/openssl/openssl/apps/pkcs12.c b/deps/openssl/openssl/apps/pkcs12.c index 82182c29b86d7f..d0bd97af0eee30 100644 --- a/deps/openssl/openssl/apps/pkcs12.c +++ b/deps/openssl/openssl/apps/pkcs12.c @@ -129,9 +129,7 @@ int MAIN(int argc, char **argv) char *inrand = NULL; char *macalg = NULL; char *CApath = NULL, *CAfile = NULL; -# ifndef OPENSSL_NO_ENGINE char *engine = NULL; -# endif apps_startup(); @@ -406,9 +404,7 @@ int MAIN(int argc, char **argv) "-LMK Add local machine keyset attribute to private key\n"); goto end; } -# ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -# endif if (passarg) { if (export_cert) @@ -756,6 +752,7 @@ int MAIN(int argc, char **argv) # ifdef CRYPTO_MDEBUG CRYPTO_remove_all_info(); # endif + release_engine(e); BIO_free(in); BIO_free_all(out); if (canames) @@ -1110,4 +1107,6 @@ static int set_pbe(BIO *err, int *ppbe, const char *str) return 1; } +#else +static void *dummy = &dummy; #endif diff --git a/deps/openssl/openssl/apps/pkcs7.c b/deps/openssl/openssl/apps/pkcs7.c index b6776331839760..c5d51d2b4831fa 100644 --- a/deps/openssl/openssl/apps/pkcs7.c +++ b/deps/openssl/openssl/apps/pkcs7.c @@ -90,9 +90,8 @@ int MAIN(int argc, char **argv) char *infile, *outfile, *prog; int print_certs = 0, text = 0, noout = 0, p7_print = 0; int ret = 1; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif + ENGINE *e = NULL; apps_startup(); @@ -175,9 +174,7 @@ int MAIN(int argc, char **argv) ERR_load_crypto_strings(); -#ifndef OPENSSL_NO_ENGINE - setup_engine(bio_err, engine, 0); -#endif + e = setup_engine(bio_err, engine, 0); in = BIO_new(BIO_s_file()); out = BIO_new(BIO_s_file()); @@ -303,6 +300,7 @@ int MAIN(int argc, char **argv) end: if (p7 != NULL) PKCS7_free(p7); + release_engine(e); if (in != NULL) BIO_free(in); if (out != NULL) diff --git a/deps/openssl/openssl/apps/pkcs8.c b/deps/openssl/openssl/apps/pkcs8.c index 5099e18417e900..71e31689df0892 100644 --- a/deps/openssl/openssl/apps/pkcs8.c +++ b/deps/openssl/openssl/apps/pkcs8.c @@ -87,9 +87,7 @@ int MAIN(int argc, char **argv) char pass[50], *passin = NULL, *passout = NULL, *p8pass = NULL; int badarg = 0; int ret = 1; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif if (bio_err == NULL) bio_err = BIO_new_fp(stderr, BIO_NOCLOSE); @@ -223,9 +221,7 @@ int MAIN(int argc, char **argv) #endif goto end; } -#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -#endif if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); @@ -391,6 +387,7 @@ int MAIN(int argc, char **argv) X509_SIG_free(p8); PKCS8_PRIV_KEY_INFO_free(p8inf); EVP_PKEY_free(pkey); + release_engine(e); BIO_free_all(out); BIO_free(in); if (passin) diff --git a/deps/openssl/openssl/apps/pkey.c b/deps/openssl/openssl/apps/pkey.c index e848049c3a12fa..63d878a293aa16 100644 --- a/deps/openssl/openssl/apps/pkey.c +++ b/deps/openssl/openssl/apps/pkey.c @@ -79,9 +79,7 @@ int MAIN(int argc, char **argv) EVP_PKEY *pkey = NULL; char *passin = NULL, *passout = NULL; int badarg = 0; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif int ret = 1; if (bio_err == NULL) @@ -178,9 +176,7 @@ int MAIN(int argc, char **argv) #endif return 1; } -#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -#endif if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); @@ -240,6 +236,7 @@ int MAIN(int argc, char **argv) end: EVP_PKEY_free(pkey); + release_engine(e); BIO_free_all(out); BIO_free(in); if (passin) diff --git a/deps/openssl/openssl/apps/pkeyparam.c b/deps/openssl/openssl/apps/pkeyparam.c index a148a6621ad85d..1437f03ae9a1cb 100644 --- a/deps/openssl/openssl/apps/pkeyparam.c +++ b/deps/openssl/openssl/apps/pkeyparam.c @@ -74,9 +74,8 @@ int MAIN(int argc, char **argv) int text = 0, noout = 0; EVP_PKEY *pkey = NULL; int badarg = 0; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif + ENGINE *e = NULL; int ret = 1; if (bio_err == NULL) @@ -134,9 +133,7 @@ int MAIN(int argc, char **argv) #endif return 1; } -#ifndef OPENSSL_NO_ENGINE - setup_engine(bio_err, engine, 0); -#endif + e = setup_engine(bio_err, engine, 0); if (infile) { if (!(in = BIO_new_file(infile, "r"))) { @@ -178,6 +175,7 @@ int MAIN(int argc, char **argv) end: EVP_PKEY_free(pkey); + release_engine(e); BIO_free_all(out); BIO_free(in); diff --git a/deps/openssl/openssl/apps/pkeyutl.c b/deps/openssl/openssl/apps/pkeyutl.c index e47206c40a114b..7c62d1c8709bcf 100644 --- a/deps/openssl/openssl/apps/pkeyutl.c +++ b/deps/openssl/openssl/apps/pkeyutl.c @@ -357,6 +357,7 @@ int MAIN(int argc, char **argv) end: if (ctx) EVP_PKEY_CTX_free(ctx); + release_engine(e); BIO_free(in); BIO_free_all(out); if (buf_in != NULL) diff --git a/deps/openssl/openssl/apps/prime.c b/deps/openssl/openssl/apps/prime.c index 1fb1c8d8455aa3..133167f2d4d1e5 100644 --- a/deps/openssl/openssl/apps/prime.c +++ b/deps/openssl/openssl/apps/prime.c @@ -128,16 +128,24 @@ int MAIN(int argc, char **argv) BIO_printf(bio_out, "%s\n", s); OPENSSL_free(s); } else { + int r; + if (hex) - BN_hex2bn(&bn, argv[0]); + r = BN_hex2bn(&bn, argv[0]); else - BN_dec2bn(&bn, argv[0]); + r = BN_dec2bn(&bn, argv[0]); + + if(!r) { + BIO_printf(bio_err, "Failed to process value (%s)\n", argv[0]); + goto end; + } BN_print(bio_out, bn); BIO_printf(bio_out, " is %sprime\n", BN_is_prime_ex(bn, checks, NULL, NULL) ? "" : "not "); } + end: BN_free(bn); BIO_free_all(bio_out); diff --git a/deps/openssl/openssl/apps/rand.c b/deps/openssl/openssl/apps/rand.c index e159da37be18e7..96dcb7273a4dfe 100644 --- a/deps/openssl/openssl/apps/rand.c +++ b/deps/openssl/openssl/apps/rand.c @@ -86,9 +86,8 @@ int MAIN(int argc, char **argv) int hex = 0; BIO *out = NULL; int num = -1; -#ifndef OPENSSL_NO_ENGINE + ENGINE *e = NULL; char *engine = NULL; -#endif apps_startup(); @@ -162,9 +161,7 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, "-hex - hex encode output\n"); goto err; } -#ifndef OPENSSL_NO_ENGINE - setup_engine(bio_err, engine, 0); -#endif + e = setup_engine(bio_err, engine, 0); app_RAND_load_file(NULL, bio_err, (inrand != NULL)); if (inrand != NULL) @@ -222,6 +219,7 @@ int MAIN(int argc, char **argv) err: ERR_print_errors(bio_err); + release_engine(e); if (out) BIO_free_all(out); apps_shutdown(); diff --git a/deps/openssl/openssl/apps/req.c b/deps/openssl/openssl/apps/req.c index d1411c91bbb89e..cdea1f61119472 100644 --- a/deps/openssl/openssl/apps/req.c +++ b/deps/openssl/openssl/apps/req.c @@ -179,9 +179,7 @@ int MAIN(int argc, char **argv) int nodes = 0, kludge = 0, newhdr = 0, subject = 0, pubkey = 0; char *infile, *outfile, *prog, *keyfile = NULL, *template = NULL, *keyout = NULL; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif char *extensions = NULL; char *req_exts = NULL; const EVP_CIPHER *cipher = NULL; @@ -595,9 +593,7 @@ int MAIN(int argc, char **argv) if ((in == NULL) || (out == NULL)) goto end; -#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -#endif if (keyfile != NULL) { pkey = load_key(bio_err, keyfile, keyform, 0, passin, e, @@ -1040,6 +1036,7 @@ int MAIN(int argc, char **argv) X509_REQ_free(req); X509_free(x509ss); ASN1_INTEGER_free(serial); + release_engine(e); if (passargin && passin) OPENSSL_free(passin); if (passargout && passout) diff --git a/deps/openssl/openssl/apps/rsa.c b/deps/openssl/openssl/apps/rsa.c index e13c14fbc830de..ad3af39d468972 100644 --- a/deps/openssl/openssl/apps/rsa.c +++ b/deps/openssl/openssl/apps/rsa.c @@ -111,9 +111,7 @@ int MAIN(int argc, char **argv) char *infile, *outfile, *prog; char *passargin = NULL, *passargout = NULL; char *passin = NULL, *passout = NULL; -# ifndef OPENSSL_NO_ENGINE char *engine = NULL; -# endif int modulus = 0; int pvk_encr = 2; @@ -254,9 +252,7 @@ int MAIN(int argc, char **argv) ERR_load_crypto_strings(); -# ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -# endif if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); @@ -419,6 +415,7 @@ int MAIN(int argc, char **argv) } else ret = 0; end: + release_engine(e); if (out != NULL) BIO_free_all(out); if (rsa != NULL) diff --git a/deps/openssl/openssl/apps/rsautl.c b/deps/openssl/openssl/apps/rsautl.c index 5b6f849ea74d6e..87d18063cc7fec 100644 --- a/deps/openssl/openssl/apps/rsautl.c +++ b/deps/openssl/openssl/apps/rsautl.c @@ -88,9 +88,7 @@ int MAIN(int argc, char **argv) ENGINE *e = NULL; BIO *in = NULL, *out = NULL; char *infile = NULL, *outfile = NULL; -# ifndef OPENSSL_NO_ENGINE char *engine = NULL; -# endif char *keyfile = NULL; char rsa_mode = RSA_VERIFY, key_type = KEY_PRIVKEY; int keyform = FORMAT_PEM; @@ -195,9 +193,7 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, "A private key is needed for this operation\n"); goto end; } -# ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -# endif if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); goto end; @@ -327,6 +323,7 @@ int MAIN(int argc, char **argv) BIO_write(out, rsa_out, rsa_outlen); end: RSA_free(rsa); + release_engine(e); BIO_free(in); BIO_free_all(out); if (rsa_in) diff --git a/deps/openssl/openssl/apps/s_cb.c b/deps/openssl/openssl/apps/s_cb.c index d1a99a7bd605b4..7d719543579fcd 100644 --- a/deps/openssl/openssl/apps/s_cb.c +++ b/deps/openssl/openssl/apps/s_cb.c @@ -548,12 +548,12 @@ long MS_CALLBACK bio_dump_callback(BIO *bio, int cmd, const char *argp, if (cmd == (BIO_CB_READ | BIO_CB_RETURN)) { BIO_printf(out, "read from %p [%p] (%lu bytes => %ld (0x%lX))\n", - (void *)bio, argp, (unsigned long)argi, ret, ret); + (void *)bio, (void *)argp, (unsigned long)argi, ret, ret); BIO_dump(out, argp, (int)ret); return (ret); } else if (cmd == (BIO_CB_WRITE | BIO_CB_RETURN)) { BIO_printf(out, "write to %p [%p] (%lu bytes => %ld (0x%lX))\n", - (void *)bio, argp, (unsigned long)argi, ret, ret); + (void *)bio, (void *)argp, (unsigned long)argi, ret, ret); BIO_dump(out, argp, (int)ret); } return (ret); diff --git a/deps/openssl/openssl/apps/s_client.c b/deps/openssl/openssl/apps/s_client.c index dd474868f46fdd..cdea5ff8d857e2 100644 --- a/deps/openssl/openssl/apps/s_client.c +++ b/deps/openssl/openssl/apps/s_client.c @@ -706,12 +706,12 @@ int MAIN(int argc, char **argv) char *inrand = NULL; int mbuf_len = 0; struct timeval timeout, *timeoutp; -#ifndef OPENSSL_NO_ENGINE char *engine_id = NULL; + ENGINE *e = NULL; +#ifndef OPENSSL_NO_ENGINE char *ssl_client_engine_id = NULL; ENGINE *ssl_client_engine = NULL; #endif - ENGINE *e = NULL; #if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_BEOS_R5) struct timeval tv; # if defined(OPENSSL_SYS_BEOS_R5) @@ -1202,8 +1202,8 @@ int MAIN(int argc, char **argv) next_proto.data = NULL; #endif -#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine_id, 1); +#ifndef OPENSSL_NO_ENGINE if (ssl_client_engine_id) { ssl_client_engine = ENGINE_by_id(ssl_client_engine_id); if (!ssl_client_engine) { @@ -2138,6 +2138,7 @@ int MAIN(int argc, char **argv) OPENSSL_cleanse(mbuf, BUFSIZZ); OPENSSL_free(mbuf); } + release_engine(e); if (bio_c_out != NULL) { BIO_free(bio_c_out); bio_c_out = NULL; diff --git a/deps/openssl/openssl/apps/s_server.c b/deps/openssl/openssl/apps/s_server.c index 857a70e3e4c5c2..b561cf3a362bf9 100644 --- a/deps/openssl/openssl/apps/s_server.c +++ b/deps/openssl/openssl/apps/s_server.c @@ -328,9 +328,7 @@ static char *keymatexportlabel = NULL; static int keymatexportlen = 20; static int hack = 0; -#ifndef OPENSSL_NO_ENGINE static char *engine_id = NULL; -#endif static const char *session_id_prefix = NULL; static int enable_timeouts = 0; @@ -484,9 +482,7 @@ static void s_server_init(void) s_quiet = 0; s_brief = 0; hack = 0; -# ifndef OPENSSL_NO_ENGINE engine_id = NULL; -# endif } #endif @@ -1603,9 +1599,7 @@ int MAIN(int argc, char *argv[]) SSL_load_error_strings(); OpenSSL_add_ssl_algorithms(); -#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine_id, 1); -#endif if (!app_passwd(bio_err, passarg, dpassarg, &pass, &dpass)) { BIO_printf(bio_err, "Error getting password\n"); @@ -2129,6 +2123,7 @@ int MAIN(int argc, char *argv[]) if (jpake_secret && psk_key) OPENSSL_free(psk_key); #endif + release_engine(e); if (bio_s_out != NULL) { BIO_free(bio_s_out); bio_s_out = NULL; diff --git a/deps/openssl/openssl/apps/smime.c b/deps/openssl/openssl/apps/smime.c index 6044ccf5f5905f..17583304e4b439 100644 --- a/deps/openssl/openssl/apps/smime.c +++ b/deps/openssl/openssl/apps/smime.c @@ -114,9 +114,7 @@ int MAIN(int argc, char **argv) const EVP_MD *sign_md = NULL; int informat = FORMAT_SMIME, outformat = FORMAT_SMIME; int keyform = FORMAT_PEM; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif X509_VERIFY_PARAM *vpm = NULL; @@ -461,9 +459,7 @@ int MAIN(int argc, char **argv) "cert.pem recipient certificate(s) for encryption\n"); goto end; } -#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -#endif if (!app_passwd(bio_err, passargin, NULL, &passin, NULL)) { BIO_printf(bio_err, "Error getting password\n"); @@ -736,6 +732,7 @@ int MAIN(int argc, char **argv) X509_free(signer); EVP_PKEY_free(key); PKCS7_free(p7); + release_engine(e); BIO_free(in); BIO_free(indata); BIO_free_all(out); diff --git a/deps/openssl/openssl/apps/speed.c b/deps/openssl/openssl/apps/speed.c index b862868eacc7be..6cd1021525046c 100644 --- a/deps/openssl/openssl/apps/speed.c +++ b/deps/openssl/openssl/apps/speed.c @@ -372,6 +372,7 @@ int MAIN(int, char **); int MAIN(int argc, char **argv) { + ENGINE *e = NULL; unsigned char *buf = NULL, *buf2 = NULL; int mret = 1; long count = 0, save_count = 0; @@ -669,6 +670,10 @@ int MAIN(int argc, char **argv) ecdh_b[i] = NULL; } # endif +# ifndef OPENSSL_NO_RSA + for (i = 0; i < RSA_NUM; i++) + rsa_key[i] = NULL; +# endif if (bio_err == NULL) if ((bio_err = BIO_new(BIO_s_file())) != NULL) @@ -677,12 +682,6 @@ int MAIN(int argc, char **argv) if (!load_config(bio_err, NULL)) goto end; -# ifndef OPENSSL_NO_RSA - memset(rsa_key, 0, sizeof(rsa_key)); - for (i = 0; i < RSA_NUM; i++) - rsa_key[i] = NULL; -# endif - if ((buf = (unsigned char *)OPENSSL_malloc((int)BUFSIZE)) == NULL) { BIO_printf(bio_err, "out of memory\n"); goto end; @@ -749,7 +748,7 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, "no engine given\n"); goto end; } - setup_engine(bio_err, *argv, 0); + e = setup_engine(bio_err, *argv, 0); /* * j will be increased again further down. We just don't want * speed to confuse an engine with an algorithm, especially when @@ -2526,6 +2525,7 @@ int MAIN(int argc, char **argv) } # endif + release_engine(e); apps_shutdown(); OPENSSL_EXIT(mret); } diff --git a/deps/openssl/openssl/apps/spkac.c b/deps/openssl/openssl/apps/spkac.c index 8b06ec4d6e7211..7f5333fe832e99 100644 --- a/deps/openssl/openssl/apps/spkac.c +++ b/deps/openssl/openssl/apps/spkac.c @@ -94,9 +94,7 @@ int MAIN(int argc, char **argv) CONF *conf = NULL; NETSCAPE_SPKI *spki = NULL; EVP_PKEY *pkey = NULL; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif apps_startup(); @@ -185,9 +183,7 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, "Error getting password\n"); goto end; } -#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -#endif if (keyfile) { pkey = load_key(bio_err, @@ -305,6 +301,7 @@ int MAIN(int argc, char **argv) BIO_free(in); BIO_free_all(out); EVP_PKEY_free(pkey); + release_engine(e); if (passin) OPENSSL_free(passin); apps_shutdown(); diff --git a/deps/openssl/openssl/apps/srp.c b/deps/openssl/openssl/apps/srp.c index c75052f38dd454..37341a5d20ed61 100644 --- a/deps/openssl/openssl/apps/srp.c +++ b/deps/openssl/openssl/apps/srp.c @@ -293,9 +293,8 @@ int MAIN(int argc, char **argv) int i; long errorline = -1; char *randfile = NULL; -# ifndef OPENSSL_NO_ENGINE + ENGINE *e = NULL; char *engine = NULL; -# endif char *tofree = NULL; DB_ATTR db_attr; @@ -411,9 +410,7 @@ int MAIN(int argc, char **argv) ERR_load_crypto_strings(); -# ifndef OPENSSL_NO_ENGINE - setup_engine(bio_err, engine, 0); -# endif + e = setup_engine(bio_err, engine, 0); if (!app_passwd(bio_err, passargin, passargout, &passin, &passout)) { BIO_printf(bio_err, "Error getting passwords\n"); @@ -760,6 +757,7 @@ int MAIN(int argc, char **argv) if (db) free_index(db); + release_engine(e); OBJ_cleanup(); apps_shutdown(); OPENSSL_EXIT(ret); diff --git a/deps/openssl/openssl/apps/verify.c b/deps/openssl/openssl/apps/verify.c index b5ae6b370e1e12..c4bd1975764ceb 100644 --- a/deps/openssl/openssl/apps/verify.c +++ b/deps/openssl/openssl/apps/verify.c @@ -89,9 +89,7 @@ int MAIN(int argc, char **argv) X509_LOOKUP *lookup = NULL; X509_VERIFY_PARAM *vpm = NULL; int crl_download = 0; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif cert_ctx = X509_STORE_new(); if (cert_ctx == NULL) @@ -160,9 +158,7 @@ int MAIN(int argc, char **argv) break; } -#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -#endif if (vpm) X509_STORE_set1_param(cert_ctx, vpm); @@ -255,6 +251,7 @@ int MAIN(int argc, char **argv) sk_X509_pop_free(untrusted, X509_free); sk_X509_pop_free(trusted, X509_free); sk_X509_CRL_pop_free(crls, X509_CRL_free); + release_engine(e); apps_shutdown(); OPENSSL_EXIT(ret < 0 ? 2 : ret); } diff --git a/deps/openssl/openssl/apps/x509.c b/deps/openssl/openssl/apps/x509.c index 17cb62da726d07..ad9fc98edfb9c2 100644 --- a/deps/openssl/openssl/apps/x509.c +++ b/deps/openssl/openssl/apps/x509.c @@ -218,9 +218,7 @@ int MAIN(int argc, char **argv) char *checkhost = NULL; char *checkemail = NULL; char *checkip = NULL; -#ifndef OPENSSL_NO_ENGINE char *engine = NULL; -#endif reqfile = 0; @@ -501,9 +499,7 @@ int MAIN(int argc, char **argv) BIO_printf(bio_err, "%s", *pp); goto end; } -#ifndef OPENSSL_NO_ENGINE e = setup_engine(bio_err, engine, 0); -#endif if (need_rand) app_RAND_load_file(NULL, bio_err, 0); @@ -1040,6 +1036,7 @@ int MAIN(int argc, char **argv) ASN1_INTEGER_free(sno); sk_ASN1_OBJECT_pop_free(trust, ASN1_OBJECT_free); sk_ASN1_OBJECT_pop_free(reject, ASN1_OBJECT_free); + release_engine(e); if (passin) OPENSSL_free(passin); apps_shutdown(); diff --git a/deps/openssl/openssl/crypto/aes/asm/aes-s390x.pl b/deps/openssl/openssl/crypto/aes/asm/aes-s390x.pl index 76ca8e52198a06..a8f4d29d1ce586 100644 --- a/deps/openssl/openssl/crypto/aes/asm/aes-s390x.pl +++ b/deps/openssl/openssl/crypto/aes/asm/aes-s390x.pl @@ -1568,8 +1568,8 @@ () } ######################################################################## -# void AES_xts_encrypt(const char *inp,char *out,size_t len, -# const AES_KEY *key1, const AES_KEY *key2, +# void AES_xts_encrypt(const unsigned char *inp, unsigned char *out, +# size_t len, const AES_KEY *key1, const AES_KEY *key2, # const unsigned char iv[16]); # { @@ -1937,8 +1937,8 @@ () br $ra .size AES_xts_encrypt,.-AES_xts_encrypt ___ -# void AES_xts_decrypt(const char *inp,char *out,size_t len, -# const AES_KEY *key1, const AES_KEY *key2, +# void AES_xts_decrypt(const unsigned char *inp, unsigned char *out, +# size_t len, const AES_KEY *key1, const AES_KEY *key2, # const unsigned char iv[16]); # $code.=<<___; diff --git a/deps/openssl/openssl/crypto/asn1/p5_pbev2.c b/deps/openssl/openssl/crypto/asn1/p5_pbev2.c index 388053e0a1bfd5..4c037d3d2cae65 100644 --- a/deps/openssl/openssl/crypto/asn1/p5_pbev2.c +++ b/deps/openssl/openssl/crypto/asn1/p5_pbev2.c @@ -91,12 +91,11 @@ X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, unsigned char *salt, int saltlen, unsigned char *aiv, int prf_nid) { - X509_ALGOR *scheme = NULL, *kalg = NULL, *ret = NULL; + X509_ALGOR *scheme = NULL, *ret = NULL; int alg_nid, keylen; EVP_CIPHER_CTX ctx; unsigned char iv[EVP_MAX_IV_LENGTH]; PBE2PARAM *pbe2 = NULL; - ASN1_OBJECT *obj; alg_nid = EVP_CIPHER_type(cipher); if (alg_nid == NID_undef) { @@ -104,7 +103,6 @@ X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER); goto err; } - obj = OBJ_nid2obj(alg_nid); if (!(pbe2 = PBE2PARAM_new())) goto merr; @@ -112,7 +110,7 @@ X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, /* Setup the AlgorithmIdentifier for the encryption scheme */ scheme = pbe2->encryption; - scheme->algorithm = obj; + scheme->algorithm = OBJ_nid2obj(alg_nid); if (!(scheme->parameter = ASN1_TYPE_new())) goto merr; @@ -188,11 +186,9 @@ X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, err: PBE2PARAM_free(pbe2); /* Note 'scheme' is freed as part of pbe2 */ - X509_ALGOR_free(kalg); X509_ALGOR_free(ret); return NULL; - } X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, diff --git a/deps/openssl/openssl/crypto/asn1/x_crl.c b/deps/openssl/openssl/crypto/asn1/x_crl.c index 027950330d8b67..c78ded89ef12bb 100644 --- a/deps/openssl/openssl/crypto/asn1/x_crl.c +++ b/deps/openssl/openssl/crypto/asn1/x_crl.c @@ -254,6 +254,7 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, for (idx = 0; idx < sk_X509_EXTENSION_num(exts); idx++) { int nid; + ext = sk_X509_EXTENSION_value(exts, idx); nid = OBJ_obj2nid(ext->object); if (nid == NID_freshest_crl) @@ -263,7 +264,7 @@ static int crl_cb(int operation, ASN1_VALUE **pval, const ASN1_ITEM *it, if ((nid == NID_issuing_distribution_point) || (nid == NID_authority_key_identifier) || (nid == NID_delta_crl)) - break;; + continue; crl->flags |= EXFLAG_CRITICAL; break; } diff --git a/deps/openssl/openssl/crypto/bn/asm/x86_64-mont.pl b/deps/openssl/openssl/crypto/bn/asm/x86_64-mont.pl index 044fd7ecc0fdb5..80492d8e638165 100755 --- a/deps/openssl/openssl/crypto/bn/asm/x86_64-mont.pl +++ b/deps/openssl/openssl/crypto/bn/asm/x86_64-mont.pl @@ -1148,18 +1148,17 @@ mulx 2*8($aptr),%r15,%r13 # ... adox -3*8($tptr),%r11 adcx %r15,%r12 - adox $zero,%r12 + adox -2*8($tptr),%r12 adcx $zero,%r13 + adox $zero,%r13 mov $bptr,8(%rsp) # off-load &b[i] - .byte 0x67 mov $mi,%r15 imulq 24(%rsp),$mi # "t[0]"*n0 xor %ebp,%ebp # xor $zero,$zero # cf=0, of=0 mulx 3*8($aptr),%rax,%r14 mov $mi,%rdx - adox -2*8($tptr),%r12 adcx %rax,%r13 adox -1*8($tptr),%r13 adcx $zero,%r14 diff --git a/deps/openssl/openssl/crypto/bn/asm/x86_64-mont5.pl b/deps/openssl/openssl/crypto/bn/asm/x86_64-mont5.pl index f1fbb45b532b27..3bb0cdf5bd391a 100755 --- a/deps/openssl/openssl/crypto/bn/asm/x86_64-mont5.pl +++ b/deps/openssl/openssl/crypto/bn/asm/x86_64-mont5.pl @@ -1925,6 +1925,7 @@ .align 32 .L8x_tail_done: + xor %rax,%rax add (%rdx),%r8 # can this overflow? adc \$0,%r9 adc \$0,%r10 @@ -1932,10 +1933,8 @@ adc \$0,%r12 adc \$0,%r13 adc \$0,%r14 - adc \$0,%r15 # can't overflow, because we - # started with "overhung" part - # of multiplication - xor %rax,%rax + adc \$0,%r15 + adc \$0,%rax neg $carry .L8x_no_tail: @@ -3375,6 +3374,7 @@ .align 32 .Lsqrx8x_tail_done: + xor %rax,%rax add 24+8(%rsp),%r8 # can this overflow? adc \$0,%r9 adc \$0,%r10 @@ -3382,10 +3382,8 @@ adc \$0,%r12 adc \$0,%r13 adc \$0,%r14 - adc \$0,%r15 # can't overflow, because we - # started with "overhung" part - # of multiplication - mov $carry,%rax # xor %rax,%rax + adc \$0,%r15 + adc \$0,%rax sub 16+8(%rsp),$carry # mov 16(%rsp),%cf .Lsqrx8x_no_tail: # %cf is 0 if jumped here @@ -3400,7 +3398,7 @@ adc 8*5($tptr),%r13 adc 8*6($tptr),%r14 adc 8*7($tptr),%r15 - adc %rax,%rax # top-most carry + adc \$0,%rax # top-most carry mov 32+8(%rsp),%rbx # n0 mov 8*8($tptr,%rcx),%rdx # modulo-scheduled "%r8" diff --git a/deps/openssl/openssl/crypto/bn/bn_exp.c b/deps/openssl/openssl/crypto/bn/bn_exp.c index 1670f01d1d8c44..195a7867a46bff 100644 --- a/deps/openssl/openssl/crypto/bn/bn_exp.c +++ b/deps/openssl/openssl/crypto/bn/bn_exp.c @@ -180,8 +180,9 @@ int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) goto err; } } - if (r != rr) - BN_copy(r, rr); + if (r != rr && BN_copy(r, rr) == NULL) + goto err; + ret = 1; err: BN_CTX_end(ctx); diff --git a/deps/openssl/openssl/crypto/bn/bn_mul.c b/deps/openssl/openssl/crypto/bn/bn_mul.c index b174850b6bb1b3..3c618dc3070890 100644 --- a/deps/openssl/openssl/crypto/bn/bn_mul.c +++ b/deps/openssl/openssl/crypto/bn/bn_mul.c @@ -1083,8 +1083,9 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) end: #endif bn_correct_top(rr); - if (r != rr) - BN_copy(r, rr); + if (r != rr && BN_copy(r, rr) == NULL) + goto err; + ret = 1; err: bn_check_top(r); diff --git a/deps/openssl/openssl/crypto/bn/bn_prime.c b/deps/openssl/openssl/crypto/bn/bn_prime.c index 1d256874c9d2cb..8177fd294772f2 100644 --- a/deps/openssl/openssl/crypto/bn/bn_prime.c +++ b/deps/openssl/openssl/crypto/bn/bn_prime.c @@ -283,7 +283,8 @@ int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BIGNUM *t; if ((t = BN_CTX_get(ctx)) == NULL) goto err; - BN_copy(t, a); + if (BN_copy(t, a) == NULL) + goto err; t->neg = 0; A = t; } else diff --git a/deps/openssl/openssl/crypto/bn/bn_sqr.c b/deps/openssl/openssl/crypto/bn/bn_sqr.c index 3ca69879ee2d40..256d26e8dbec72 100644 --- a/deps/openssl/openssl/crypto/bn/bn_sqr.c +++ b/deps/openssl/openssl/crypto/bn/bn_sqr.c @@ -143,8 +143,9 @@ int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) rr->top = max - 1; else rr->top = max; - if (rr != r) - BN_copy(r, rr); + if (r != rr && BN_copy(r, rr) == NULL) + goto err; + ret = 1; err: bn_check_top(rr); diff --git a/deps/openssl/openssl/crypto/cms/cms_kari.c b/deps/openssl/openssl/crypto/cms/cms_kari.c index 2cfcdb29cd50c8..ee283172d3d893 100644 --- a/deps/openssl/openssl/crypto/cms/cms_kari.c +++ b/deps/openssl/openssl/crypto/cms/cms_kari.c @@ -401,9 +401,12 @@ static int cms_wrap_init(CMS_KeyAgreeRecipientInfo *kari, * Pick a cipher based on content encryption cipher. If it is DES3 use * DES3 wrap otherwise use AES wrap similar to key size. */ +#ifndef OPENSSL_NO_DES if (EVP_CIPHER_type(cipher) == NID_des_ede3_cbc) kekcipher = EVP_des_ede3_wrap(); - else if (keylen <= 16) + else +#endif + if (keylen <= 16) kekcipher = EVP_aes_128_wrap(); else if (keylen <= 24) kekcipher = EVP_aes_192_wrap(); diff --git a/deps/openssl/openssl/crypto/dh/dh_key.c b/deps/openssl/openssl/crypto/dh/dh_key.c index 1d80fb2c5f600e..387558f1467c81 100644 --- a/deps/openssl/openssl/crypto/dh/dh_key.c +++ b/deps/openssl/openssl/crypto/dh/dh_key.c @@ -223,6 +223,8 @@ static int compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh) goto err; BN_CTX_start(ctx); tmp = BN_CTX_get(ctx); + if (tmp == NULL) + goto err; if (dh->priv_key == NULL) { DHerr(DH_F_COMPUTE_KEY, DH_R_NO_PRIVATE_VALUE); diff --git a/deps/openssl/openssl/crypto/dsa/dsa_pmeth.c b/deps/openssl/openssl/crypto/dsa/dsa_pmeth.c index 42b8bb0862511d..78724839b5249b 100644 --- a/deps/openssl/openssl/crypto/dsa/dsa_pmeth.c +++ b/deps/openssl/openssl/crypto/dsa/dsa_pmeth.c @@ -180,7 +180,7 @@ static int pkey_dsa_ctrl(EVP_PKEY_CTX *ctx, int type, int p1, void *p2) DSAerr(DSA_F_PKEY_DSA_CTRL, DSA_R_INVALID_DIGEST_TYPE); return 0; } - dctx->md = p2; + dctx->pmd = p2; return 1; case EVP_PKEY_CTRL_MD: diff --git a/deps/openssl/openssl/crypto/ec/ec2_mult.c b/deps/openssl/openssl/crypto/ec/ec2_mult.c index 68cc8771d5ebfe..1f9cc00aead6c3 100644 --- a/deps/openssl/openssl/crypto/ec/ec2_mult.c +++ b/deps/openssl/openssl/crypto/ec/ec2_mult.c @@ -267,7 +267,7 @@ static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, BN_CTX *ctx) { BIGNUM *x1, *x2, *z1, *z2; - int ret = 0, i; + int ret = 0, i, group_top; BN_ULONG mask, word; if (r == point) { @@ -297,10 +297,12 @@ static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, x2 = &r->X; z2 = &r->Y; - bn_wexpand(x1, group->field.top); - bn_wexpand(z1, group->field.top); - bn_wexpand(x2, group->field.top); - bn_wexpand(z2, group->field.top); + group_top = group->field.top; + if (bn_wexpand(x1, group_top) == NULL + || bn_wexpand(z1, group_top) == NULL + || bn_wexpand(x2, group_top) == NULL + || bn_wexpand(z2, group_top) == NULL) + goto err; if (!BN_GF2m_mod_arr(x1, &point->X, group->poly)) goto err; /* x1 = x */ @@ -329,14 +331,14 @@ static int ec_GF2m_montgomery_point_multiply(const EC_GROUP *group, for (; i >= 0; i--) { word = scalar->d[i]; while (mask) { - BN_consttime_swap(word & mask, x1, x2, group->field.top); - BN_consttime_swap(word & mask, z1, z2, group->field.top); + BN_consttime_swap(word & mask, x1, x2, group_top); + BN_consttime_swap(word & mask, z1, z2, group_top); if (!gf2m_Madd(group, &point->X, x2, z2, x1, z1, ctx)) goto err; if (!gf2m_Mdouble(group, x1, z1, ctx)) goto err; - BN_consttime_swap(word & mask, x1, x2, group->field.top); - BN_consttime_swap(word & mask, z1, z2, group->field.top); + BN_consttime_swap(word & mask, x1, x2, group_top); + BN_consttime_swap(word & mask, z1, z2, group_top); mask >>= 1; } mask = BN_TBIT; diff --git a/deps/openssl/openssl/crypto/ecdh/ech_ossl.c b/deps/openssl/openssl/crypto/ecdh/ech_ossl.c index df115cc262e519..d3b05247fe37d0 100644 --- a/deps/openssl/openssl/crypto/ecdh/ech_ossl.c +++ b/deps/openssl/openssl/crypto/ecdh/ech_ossl.c @@ -212,7 +212,9 @@ static int ecdh_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, BN_CTX_end(ctx); if (ctx) BN_CTX_free(ctx); - if (buf) + if (buf) { + OPENSSL_cleanse(buf, buflen); OPENSSL_free(buf); + } return (ret); } diff --git a/deps/openssl/openssl/crypto/err/err.c b/deps/openssl/openssl/crypto/err/err.c index e77d963b6b152d..52dc9a5ddd873c 100644 --- a/deps/openssl/openssl/crypto/err/err.c +++ b/deps/openssl/openssl/crypto/err/err.c @@ -868,6 +868,9 @@ void ERR_error_string_n(unsigned long e, char *buf, size_t len) const char *ls, *fs, *rs; unsigned long l, f, r; + if (len == 0) + return; + l = ERR_GET_LIB(e); f = ERR_GET_FUNC(e); r = ERR_GET_REASON(e); diff --git a/deps/openssl/openssl/crypto/evp/e_aes.c b/deps/openssl/openssl/crypto/evp/e_aes.c index 1734a823c1e5c5..7c62d327a1f613 100644 --- a/deps/openssl/openssl/crypto/evp/e_aes.c +++ b/deps/openssl/openssl/crypto/evp/e_aes.c @@ -155,10 +155,10 @@ void AES_ctr32_encrypt(const unsigned char *in, unsigned char *out, const unsigned char ivec[AES_BLOCK_SIZE]); # endif # ifdef AES_XTS_ASM -void AES_xts_encrypt(const char *inp, char *out, size_t len, +void AES_xts_encrypt(const unsigned char *inp, unsigned char *out, size_t len, const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); -void AES_xts_decrypt(const char *inp, char *out, size_t len, +void AES_xts_decrypt(const unsigned char *inp, unsigned char *out, size_t len, const AES_KEY *key1, const AES_KEY *key2, const unsigned char iv[16]); # endif diff --git a/deps/openssl/openssl/crypto/evp/e_rc4_hmac_md5.c b/deps/openssl/openssl/crypto/evp/e_rc4_hmac_md5.c index 5e92855dfdc01e..93cfe3f1074f7f 100644 --- a/deps/openssl/openssl/crypto/evp/e_rc4_hmac_md5.c +++ b/deps/openssl/openssl/crypto/evp/e_rc4_hmac_md5.c @@ -269,6 +269,8 @@ static int rc4_hmac_md5_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, len = p[arg - 2] << 8 | p[arg - 1]; if (!ctx->encrypt) { + if (len < MD5_DIGEST_LENGTH) + return -1; len -= MD5_DIGEST_LENGTH; p[arg - 2] = len >> 8; p[arg - 1] = len; diff --git a/deps/openssl/openssl/crypto/evp/evp.h b/deps/openssl/openssl/crypto/evp/evp.h index 39ab7937d25672..d258ef870a3604 100644 --- a/deps/openssl/openssl/crypto/evp/evp.h +++ b/deps/openssl/openssl/crypto/evp/evp.h @@ -1370,6 +1370,7 @@ void EVP_add_alg_module(void); * The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. */ + void ERR_load_EVP_strings(void); /* Error codes for the EVP functions. */ @@ -1489,6 +1490,7 @@ void ERR_load_EVP_strings(void); # define EVP_R_INPUT_NOT_INITIALIZED 111 # define EVP_R_INVALID_DIGEST 152 # define EVP_R_INVALID_FIPS_MODE 168 +# define EVP_R_INVALID_KEY 171 # define EVP_R_INVALID_KEY_LENGTH 130 # define EVP_R_INVALID_OPERATION 148 # define EVP_R_IV_TOO_LARGE 102 @@ -1528,7 +1530,7 @@ void ERR_load_EVP_strings(void); # define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 # define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 -#ifdef __cplusplus +# ifdef __cplusplus } -#endif +# endif #endif diff --git a/deps/openssl/openssl/crypto/evp/evp_err.c b/deps/openssl/openssl/crypto/evp/evp_err.c index 15cf5532b3820a..bcd841eb779294 100644 --- a/deps/openssl/openssl/crypto/evp/evp_err.c +++ b/deps/openssl/openssl/crypto/evp/evp_err.c @@ -1,6 +1,6 @@ /* crypto/evp/evp_err.c */ /* ==================================================================== - * Copyright (c) 1999-2013 The OpenSSL Project. All rights reserved. + * Copyright (c) 1999-2016 The OpenSSL Project. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -192,6 +192,7 @@ static ERR_STRING_DATA EVP_str_reasons[] = { {ERR_REASON(EVP_R_INPUT_NOT_INITIALIZED), "input not initialized"}, {ERR_REASON(EVP_R_INVALID_DIGEST), "invalid digest"}, {ERR_REASON(EVP_R_INVALID_FIPS_MODE), "invalid fips mode"}, + {ERR_REASON(EVP_R_INVALID_KEY), "invalid key"}, {ERR_REASON(EVP_R_INVALID_KEY_LENGTH), "invalid key length"}, {ERR_REASON(EVP_R_INVALID_OPERATION), "invalid operation"}, {ERR_REASON(EVP_R_IV_TOO_LARGE), "iv too large"}, diff --git a/deps/openssl/openssl/crypto/evp/pmeth_fn.c b/deps/openssl/openssl/crypto/evp/pmeth_fn.c index a8b7f2f6d579f2..727869e3ee87d0 100644 --- a/deps/openssl/openssl/crypto/evp/pmeth_fn.c +++ b/deps/openssl/openssl/crypto/evp/pmeth_fn.c @@ -65,20 +65,22 @@ #include "evp_locl.h" #define M_check_autoarg(ctx, arg, arglen, err) \ - if (ctx->pmeth->flags & EVP_PKEY_FLAG_AUTOARGLEN) \ - { \ - size_t pksize = (size_t)EVP_PKEY_size(ctx->pkey); \ - if (!arg) \ - { \ - *arglen = pksize; \ - return 1; \ - } \ - else if (*arglen < pksize) \ - { \ - EVPerr(err, EVP_R_BUFFER_TOO_SMALL); /*ckerr_ignore*/\ - return 0; \ - } \ - } + if (ctx->pmeth->flags & EVP_PKEY_FLAG_AUTOARGLEN) { \ + size_t pksize = (size_t)EVP_PKEY_size(ctx->pkey); \ + \ + if (pksize == 0) { \ + EVPerr(err, EVP_R_INVALID_KEY); /*ckerr_ignore*/ \ + return 0; \ + } \ + if (!arg) { \ + *arglen = pksize; \ + return 1; \ + } \ + if (*arglen < pksize) { \ + EVPerr(err, EVP_R_BUFFER_TOO_SMALL); /*ckerr_ignore*/ \ + return 0; \ + } \ + } int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx) { diff --git a/deps/openssl/openssl/crypto/evp/pmeth_lib.c b/deps/openssl/openssl/crypto/evp/pmeth_lib.c index 9668b3a9bcfb9c..d06686290459c7 100644 --- a/deps/openssl/openssl/crypto/evp/pmeth_lib.c +++ b/deps/openssl/openssl/crypto/evp/pmeth_lib.c @@ -199,6 +199,7 @@ static EVP_PKEY_CTX *int_ctx_new(EVP_PKEY *pkey, ENGINE *e, int id) EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags) { EVP_PKEY_METHOD *pmeth; + pmeth = OPENSSL_malloc(sizeof(EVP_PKEY_METHOD)); if (!pmeth) return NULL; @@ -207,33 +208,6 @@ EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags) pmeth->pkey_id = id; pmeth->flags = flags | EVP_PKEY_FLAG_DYNAMIC; - - pmeth->init = 0; - pmeth->copy = 0; - pmeth->cleanup = 0; - pmeth->paramgen_init = 0; - pmeth->paramgen = 0; - pmeth->keygen_init = 0; - pmeth->keygen = 0; - pmeth->sign_init = 0; - pmeth->sign = 0; - pmeth->verify_init = 0; - pmeth->verify = 0; - pmeth->verify_recover_init = 0; - pmeth->verify_recover = 0; - pmeth->signctx_init = 0; - pmeth->signctx = 0; - pmeth->verifyctx_init = 0; - pmeth->verifyctx = 0; - pmeth->encrypt_init = 0; - pmeth->encrypt = 0; - pmeth->decrypt_init = 0; - pmeth->decrypt = 0; - pmeth->derive_init = 0; - pmeth->derive = 0; - pmeth->ctrl = 0; - pmeth->ctrl_str = 0; - return pmeth; } diff --git a/deps/openssl/openssl/crypto/modes/ctr128.c b/deps/openssl/openssl/crypto/modes/ctr128.c index bcafd6b6bfb169..d4b22728e623d7 100644 --- a/deps/openssl/openssl/crypto/modes/ctr128.c +++ b/deps/openssl/openssl/crypto/modes/ctr128.c @@ -100,7 +100,7 @@ static void ctr128_inc_aligned(unsigned char *counter) --n; d = data[n] += c; /* did addition carry? */ - c = ((d - c) ^ d) >> (sizeof(size_t) * 8 - 1); + c = ((d - c) & ~d) >> (sizeof(size_t) * 8 - 1); } while (n); } #endif diff --git a/deps/openssl/openssl/crypto/opensslv.h b/deps/openssl/openssl/crypto/opensslv.h index 88faad652259b4..645dd0793f32e0 100644 --- a/deps/openssl/openssl/crypto/opensslv.h +++ b/deps/openssl/openssl/crypto/opensslv.h @@ -30,11 +30,11 @@ extern "C" { * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for * major minor fix final patch/beta) */ -# define OPENSSL_VERSION_NUMBER 0x100020afL +# define OPENSSL_VERSION_NUMBER 0x100020bfL # ifdef OPENSSL_FIPS -# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2j-fips 26 Sep 2016" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2k-fips 26 Jan 2017" # else -# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2j 26 Sep 2016" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2k 26 Jan 2017" # endif # define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT diff --git a/deps/openssl/openssl/crypto/perlasm/x86_64-xlate.pl b/deps/openssl/openssl/crypto/perlasm/x86_64-xlate.pl index 7a3dd04b0f9d7f..b7ae40b4dbfa98 100755 --- a/deps/openssl/openssl/crypto/perlasm/x86_64-xlate.pl +++ b/deps/openssl/openssl/crypto/perlasm/x86_64-xlate.pl @@ -250,11 +250,18 @@ $self->{base} =~ s/^[er](.?[0-9xpi])[d]?$/r\1/; # Solaris /usr/ccs/bin/as can't handle multiplications - # in $self->{label}, new gas requires sign extension... + # in $self->{label}... use integer; $self->{label} =~ s/(?{label} =~ s/\b([0-9]+\s*[\*\/\%]\s*[0-9]+)\b/eval($1)/eg; - $self->{label} =~ s/\b([0-9]+)\b/$1<<32>>32/eg; + + # Some assemblers insist on signed presentation of 32-bit + # offsets, but sign extension is a tricky business in perl... + if ((1<<31)<<1) { + $self->{label} =~ s/\b([0-9]+)\b/$1<<32>>32/eg; + } else { + $self->{label} =~ s/\b([0-9]+)\b/$1>>0/eg; + } if (!$self->{label} && $self->{index} && $self->{scale}==1 && $self->{base} =~ /(rbp|r13)/) { diff --git a/deps/openssl/openssl/crypto/rsa/rsa_gen.c b/deps/openssl/openssl/crypto/rsa/rsa_gen.c index 7f7dca39fd089b..082c8da2efc2a7 100644 --- a/deps/openssl/openssl/crypto/rsa/rsa_gen.c +++ b/deps/openssl/openssl/crypto/rsa/rsa_gen.c @@ -142,7 +142,8 @@ static int rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, if (!rsa->iqmp && ((rsa->iqmp = BN_new()) == NULL)) goto err; - BN_copy(rsa->e, e_value); + if (BN_copy(rsa->e, e_value) == NULL) + goto err; /* generate p and q */ for (;;) { diff --git a/deps/openssl/openssl/crypto/rsa/rsa_oaep.c b/deps/openssl/openssl/crypto/rsa/rsa_oaep.c index 9c2a943cf7786c..19d28c6f0e6012 100644 --- a/deps/openssl/openssl/crypto/rsa/rsa_oaep.c +++ b/deps/openssl/openssl/crypto/rsa/rsa_oaep.c @@ -89,17 +89,21 @@ int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, } if (PKCS1_MGF1(dbmask, emlen - mdlen, seed, mdlen, mgf1md) < 0) - return 0; + goto err; for (i = 0; i < emlen - mdlen; i++) db[i] ^= dbmask[i]; if (PKCS1_MGF1(seedmask, mdlen, db, emlen - mdlen, mgf1md) < 0) - return 0; + goto err; for (i = 0; i < mdlen; i++) seed[i] ^= seedmask[i]; OPENSSL_free(dbmask); return 1; + + err: + OPENSSL_free(dbmask); + return 0; } int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, diff --git a/deps/openssl/openssl/crypto/rsa/rsa_pmeth.c b/deps/openssl/openssl/crypto/rsa/rsa_pmeth.c index 94db87a0637d1f..ac583bf60b0181 100644 --- a/deps/openssl/openssl/crypto/rsa/rsa_pmeth.c +++ b/deps/openssl/openssl/crypto/rsa/rsa_pmeth.c @@ -373,6 +373,10 @@ static int pkey_rsa_verify(EVP_PKEY_CTX *ctx, if (rctx->pad_mode == RSA_PKCS1_PADDING) return RSA_verify(EVP_MD_type(rctx->md), tbs, tbslen, sig, siglen, rsa); + if (tbslen != (size_t)EVP_MD_size(rctx->md)) { + RSAerr(RSA_F_PKEY_RSA_VERIFY, RSA_R_INVALID_DIGEST_LENGTH); + return -1; + } if (rctx->pad_mode == RSA_X931_PADDING) { if (pkey_rsa_verifyrecover(ctx, NULL, &rslen, sig, siglen) <= 0) return 0; diff --git a/deps/openssl/openssl/crypto/s390xcap.c b/deps/openssl/openssl/crypto/s390xcap.c index 47d6b6ff511c9a..cf8c372c05aaf5 100644 --- a/deps/openssl/openssl/crypto/s390xcap.c +++ b/deps/openssl/openssl/crypto/s390xcap.c @@ -3,6 +3,7 @@ #include #include #include +#include "cryptlib.h" extern unsigned long OPENSSL_s390xcap_P[]; diff --git a/deps/openssl/openssl/crypto/ui/ui_lib.c b/deps/openssl/openssl/crypto/ui/ui_lib.c index d25b4f37bd114c..3cc067c3b7ee80 100644 --- a/deps/openssl/openssl/crypto/ui/ui_lib.c +++ b/deps/openssl/openssl/crypto/ui/ui_lib.c @@ -164,7 +164,7 @@ static int general_allocate_string(UI *ui, const char *prompt, UI_STRING *s = general_allocate_prompt(ui, prompt, prompt_freeable, type, input_flags, result_buf); - if (s) { + if (s != NULL) { if (allocate_string_stack(ui) >= 0) { s->_.string_data.result_minsize = minsize; s->_.string_data.result_maxsize = maxsize; @@ -197,8 +197,8 @@ static int general_allocate_boolean(UI *ui, } else if (cancel_chars == NULL) { UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, ERR_R_PASSED_NULL_PARAMETER); } else { - for (p = ok_chars; *p; p++) { - if (strchr(cancel_chars, *p)) { + for (p = ok_chars; *p != '\0'; p++) { + if (strchr(cancel_chars, *p) != NULL) { UIerr(UI_F_GENERAL_ALLOCATE_BOOLEAN, UI_R_COMMON_OK_AND_CANCEL_CHARACTERS); } @@ -207,7 +207,7 @@ static int general_allocate_boolean(UI *ui, s = general_allocate_prompt(ui, prompt, prompt_freeable, type, input_flags, result_buf); - if (s) { + if (s != NULL) { if (allocate_string_stack(ui) >= 0) { s->_.boolean_data.action_desc = action_desc; s->_.boolean_data.ok_chars = ok_chars; @@ -243,7 +243,7 @@ int UI_dup_input_string(UI *ui, const char *prompt, int flags, { char *prompt_copy = NULL; - if (prompt) { + if (prompt != NULL) { prompt_copy = BUF_strdup(prompt); if (prompt_copy == NULL) { UIerr(UI_F_UI_DUP_INPUT_STRING, ERR_R_MALLOC_FAILURE); @@ -271,7 +271,7 @@ int UI_dup_verify_string(UI *ui, const char *prompt, int flags, { char *prompt_copy = NULL; - if (prompt) { + if (prompt != NULL) { prompt_copy = BUF_strdup(prompt); if (prompt_copy == NULL) { UIerr(UI_F_UI_DUP_VERIFY_STRING, ERR_R_MALLOC_FAILURE); @@ -302,7 +302,7 @@ int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, char *ok_chars_copy = NULL; char *cancel_chars_copy = NULL; - if (prompt) { + if (prompt != NULL) { prompt_copy = BUF_strdup(prompt); if (prompt_copy == NULL) { UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); @@ -310,7 +310,7 @@ int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, } } - if (action_desc) { + if (action_desc != NULL) { action_desc_copy = BUF_strdup(action_desc); if (action_desc_copy == NULL) { UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); @@ -318,7 +318,7 @@ int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, } } - if (ok_chars) { + if (ok_chars != NULL) { ok_chars_copy = BUF_strdup(ok_chars); if (ok_chars_copy == NULL) { UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); @@ -326,7 +326,7 @@ int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, } } - if (cancel_chars) { + if (cancel_chars != NULL) { cancel_chars_copy = BUF_strdup(cancel_chars); if (cancel_chars_copy == NULL) { UIerr(UI_F_UI_DUP_INPUT_BOOLEAN, ERR_R_MALLOC_FAILURE); @@ -359,7 +359,7 @@ int UI_dup_info_string(UI *ui, const char *text) { char *text_copy = NULL; - if (text) { + if (text != NULL) { text_copy = BUF_strdup(text); if (text_copy == NULL) { UIerr(UI_F_UI_DUP_INFO_STRING, ERR_R_MALLOC_FAILURE); @@ -381,7 +381,7 @@ int UI_dup_error_string(UI *ui, const char *text) { char *text_copy = NULL; - if (text) { + if (text != NULL) { text_copy = BUF_strdup(text); if (text_copy == NULL) { UIerr(UI_F_UI_DUP_ERROR_STRING, ERR_R_MALLOC_FAILURE); @@ -397,7 +397,7 @@ char *UI_construct_prompt(UI *ui, const char *object_desc, { char *prompt = NULL; - if (ui->meth->ui_construct_prompt) + if (ui->meth->ui_construct_prompt != NULL) prompt = ui->meth->ui_construct_prompt(ui, object_desc, object_name); else { char prompt1[] = "Enter "; @@ -408,7 +408,7 @@ char *UI_construct_prompt(UI *ui, const char *object_desc, if (object_desc == NULL) return NULL; len = sizeof(prompt1) - 1 + strlen(object_desc); - if (object_name) + if (object_name != NULL) len += sizeof(prompt2) - 1 + strlen(object_name); len += sizeof(prompt3) - 1; @@ -417,7 +417,7 @@ char *UI_construct_prompt(UI *ui, const char *object_desc, return NULL; BUF_strlcpy(prompt, prompt1, len + 1); BUF_strlcat(prompt, object_desc, len + 1); - if (object_name) { + if (object_name != NULL) { BUF_strlcat(prompt, prompt2, len + 1); BUF_strlcat(prompt, object_name, len + 1); } @@ -459,7 +459,8 @@ static int print_error(const char *str, size_t len, UI *ui) uis.type = UIT_ERROR; uis.out_string = str; - if (ui->meth->ui_write_string && !ui->meth->ui_write_string(ui, &uis)) + if (ui->meth->ui_write_string != NULL + && ui->meth->ui_write_string(ui, &uis) <= 0) return -1; return 0; } @@ -468,24 +469,28 @@ int UI_process(UI *ui) { int i, ok = 0; - if (ui->meth->ui_open_session && !ui->meth->ui_open_session(ui)) - return -1; + if (ui->meth->ui_open_session != NULL + && ui->meth->ui_open_session(ui) <= 0) { + ok = -1; + goto err; + } if (ui->flags & UI_FLAG_PRINT_ERRORS) ERR_print_errors_cb((int (*)(const char *, size_t, void *)) print_error, (void *)ui); for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) { - if (ui->meth->ui_write_string - && !ui->meth->ui_write_string(ui, - sk_UI_STRING_value(ui->strings, i))) + if (ui->meth->ui_write_string != NULL + && (ui->meth->ui_write_string(ui, + sk_UI_STRING_value(ui->strings, i)) + <= 0)) { ok = -1; goto err; } } - if (ui->meth->ui_flush) + if (ui->meth->ui_flush != NULL) switch (ui->meth->ui_flush(ui)) { case -1: /* Interrupt/Cancel/something... */ ok = -2; @@ -499,7 +504,7 @@ int UI_process(UI *ui) } for (i = 0; i < sk_UI_STRING_num(ui->strings); i++) { - if (ui->meth->ui_read_string) { + if (ui->meth->ui_read_string != NULL) { switch (ui->meth->ui_read_string(ui, sk_UI_STRING_value(ui->strings, i))) { @@ -516,7 +521,8 @@ int UI_process(UI *ui) } } err: - if (ui->meth->ui_close_session && !ui->meth->ui_close_session(ui)) + if (ui->meth->ui_close_session != NULL + && ui->meth->ui_close_session(ui) <= 0) return -1; return ok; } @@ -612,49 +618,49 @@ void UI_destroy_method(UI_METHOD *ui_method) int UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui)) { - if (method) { + if (method != NULL) { method->ui_open_session = opener; return 0; - } else - return -1; + } + return -1; } int UI_method_set_writer(UI_METHOD *method, int (*writer) (UI *ui, UI_STRING *uis)) { - if (method) { + if (method != NULL) { method->ui_write_string = writer; return 0; - } else - return -1; + } + return -1; } int UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui)) { - if (method) { + if (method != NULL) { method->ui_flush = flusher; return 0; - } else - return -1; + } + return -1; } int UI_method_set_reader(UI_METHOD *method, int (*reader) (UI *ui, UI_STRING *uis)) { - if (method) { + if (method != NULL) { method->ui_read_string = reader; return 0; - } else - return -1; + } + return -1; } int UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui)) { - if (method) { + if (method != NULL) { method->ui_close_session = closer; return 0; - } else - return -1; + } + return -1; } int UI_method_set_prompt_constructor(UI_METHOD *method, @@ -664,55 +670,55 @@ int UI_method_set_prompt_constructor(UI_METHOD *method, const char *object_name)) { - if (method) { + if (method != NULL) { method->ui_construct_prompt = prompt_constructor; return 0; - } else - return -1; + } + return -1; } -int (*UI_method_get_opener(UI_METHOD *method)) (UI *) { - if (method) +int (*UI_method_get_opener(UI_METHOD *method)) (UI *) +{ + if (method != NULL) return method->ui_open_session; - else - return NULL; + return NULL; } -int (*UI_method_get_writer(UI_METHOD *method)) (UI *, UI_STRING *) { - if (method) +int (*UI_method_get_writer(UI_METHOD *method)) (UI *, UI_STRING *) +{ + if (method != NULL) return method->ui_write_string; - else - return NULL; + return NULL; } -int (*UI_method_get_flusher(UI_METHOD *method)) (UI *) { - if (method) +int (*UI_method_get_flusher(UI_METHOD *method)) (UI *) +{ + if (method != NULL) return method->ui_flush; - else - return NULL; + return NULL; } -int (*UI_method_get_reader(UI_METHOD *method)) (UI *, UI_STRING *) { - if (method) +int (*UI_method_get_reader(UI_METHOD *method)) (UI *, UI_STRING *) +{ + if (method != NULL) return method->ui_read_string; - else - return NULL; + return NULL; } -int (*UI_method_get_closer(UI_METHOD *method)) (UI *) { - if (method) +int (*UI_method_get_closer(UI_METHOD *method)) (UI *) +{ + if (method != NULL) return method->ui_close_session; - else - return NULL; + return NULL; } char *(*UI_method_get_prompt_constructor(UI_METHOD *method)) (UI *, const char *, - const char *) { - if (method) + const char *) +{ + if (method != NULL) return method->ui_construct_prompt; - else - return NULL; + return NULL; } enum UI_string_types UI_get_string_type(UI_STRING *uis) diff --git a/deps/openssl/openssl/crypto/ui/ui_openssl.c b/deps/openssl/openssl/crypto/ui/ui_openssl.c index 9ab259b8f605a6..17d14f58427afa 100644 --- a/deps/openssl/openssl/crypto/ui/ui_openssl.c +++ b/deps/openssl/openssl/crypto/ui/ui_openssl.c @@ -440,7 +440,7 @@ static int read_string_inner(UI *ui, UI_STRING *uis, int echo, int strip_nl) # else p = fgets(result, maxsize, tty_in); # endif - if (!p) + if (p == NULL) goto error; if (feof(tty_in)) goto error; @@ -508,19 +508,32 @@ static int open_console(UI *ui) if (errno == EINVAL) is_a_tty = 0; else +# endif +# ifdef ENODEV + /* + * MacOS X returns ENODEV (Operation not supported by device), + * which seems appropriate. + */ + if (errno == ENODEV) + is_a_tty = 0; + else # endif return 0; } #endif #ifdef OPENSSL_SYS_VMS status = sys$assign(&terminal, &channel, 0, 0); + + /* if there isn't a TT device, something is very wrong */ if (status != SS$_NORMAL) return 0; - status = - sys$qiow(0, channel, IO$_SENSEMODE, &iosb, 0, 0, tty_orig, 12, 0, 0, - 0, 0); + + status = sys$qiow(0, channel, IO$_SENSEMODE, &iosb, 0, 0, tty_orig, 12, + 0, 0, 0, 0); + + /* If IO$_SENSEMODE doesn't work, this is not a terminal device */ if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) - return 0; + is_a_tty = 0; #endif return 1; } @@ -537,14 +550,15 @@ static int noecho_console(UI *ui) return 0; #endif #ifdef OPENSSL_SYS_VMS - tty_new[0] = tty_orig[0]; - tty_new[1] = tty_orig[1] | TT$M_NOECHO; - tty_new[2] = tty_orig[2]; - status = - sys$qiow(0, channel, IO$_SETMODE, &iosb, 0, 0, tty_new, 12, 0, 0, 0, - 0); - if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) - return 0; + if (is_a_tty) { + tty_new[0] = tty_orig[0]; + tty_new[1] = tty_orig[1] | TT$M_NOECHO; + tty_new[2] = tty_orig[2]; + status = sys$qiow(0, channel, IO$_SETMODE, &iosb, 0, 0, tty_new, 12, + 0, 0, 0, 0); + if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) + return 0; + } #endif return 1; } @@ -561,14 +575,15 @@ static int echo_console(UI *ui) return 0; #endif #ifdef OPENSSL_SYS_VMS - tty_new[0] = tty_orig[0]; - tty_new[1] = tty_orig[1] & ~TT$M_NOECHO; - tty_new[2] = tty_orig[2]; - status = - sys$qiow(0, channel, IO$_SETMODE, &iosb, 0, 0, tty_new, 12, 0, 0, 0, - 0); - if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) - return 0; + if (is_a_tty) { + tty_new[0] = tty_orig[0]; + tty_new[1] = tty_orig[1] & ~TT$M_NOECHO; + tty_new[2] = tty_orig[2]; + status = sys$qiow(0, channel, IO$_SETMODE, &iosb, 0, 0, tty_new, 12, + 0, 0, 0, 0); + if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) + return 0; + } #endif return 1; } @@ -581,6 +596,8 @@ static int close_console(UI *ui) fclose(tty_out); #ifdef OPENSSL_SYS_VMS status = sys$dassgn(channel); + if (status != SS$_NORMAL) + return 0; #endif CRYPTO_w_unlock(CRYPTO_LOCK_UI); diff --git a/deps/openssl/openssl/demos/easy_tls/easy-tls.c b/deps/openssl/openssl/demos/easy_tls/easy-tls.c index ebcadafa7ba3f1..45063a4896a2a4 100644 --- a/deps/openssl/openssl/demos/easy_tls/easy-tls.c +++ b/deps/openssl/openssl/demos/easy_tls/easy-tls.c @@ -322,6 +322,7 @@ static void tls_errprintf(int flush, void *apparg, const char *fmt, ...) va_start(args, fmt); n = (sizeof errbuf) - errbuf_i; r = vsnprintf(errbuf + errbuf_i, n, fmt, args); + va_end(args); if (r >= n) r = n - 1; if (r >= 0) { diff --git a/deps/openssl/openssl/doc/apps/ocsp.pod b/deps/openssl/openssl/doc/apps/ocsp.pod index 9833f0813ef172..1bb7958d20e5a6 100644 --- a/deps/openssl/openssl/doc/apps/ocsp.pod +++ b/deps/openssl/openssl/doc/apps/ocsp.pod @@ -26,6 +26,7 @@ B B [B<-no_nonce>] [B<-url URL>] [B<-host host:n>] +[B<-header name value>] [B<-path>] [B<-CApath dir>] [B<-CAfile file>] @@ -135,6 +136,14 @@ if the B option is present then the OCSP request is sent to the host B on port B. B specifies the HTTP path name to use or "/" by default. +=item B<-header name value> + +If sending a request to an OCSP server, then the specified header name and +value are added to the HTTP request. Note that the B and B must +be specified as two separate parameters, not as a single quoted string, and +that the header name does not have the trailing colon. +Some OCSP responders require a Host header; use this flag to provide it. + =item B<-timeout seconds> connection timeout to the OCSP responder in seconds diff --git a/deps/openssl/openssl/doc/crypto/EVP_DigestSignInit.pod b/deps/openssl/openssl/doc/crypto/EVP_DigestSignInit.pod index 37d960e3b229ef..83e65894d9d983 100644 --- a/deps/openssl/openssl/doc/crypto/EVP_DigestSignInit.pod +++ b/deps/openssl/openssl/doc/crypto/EVP_DigestSignInit.pod @@ -10,7 +10,7 @@ EVP_DigestSignInit, EVP_DigestSignUpdate, EVP_DigestSignFinal - EVP signing func int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey); - int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); + int EVP_DigestSignUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt); int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sig, size_t *siglen); =head1 DESCRIPTION diff --git a/deps/openssl/openssl/doc/crypto/EVP_DigestVerifyInit.pod b/deps/openssl/openssl/doc/crypto/EVP_DigestVerifyInit.pod index 0ead2d2f8aa185..347c5116630669 100644 --- a/deps/openssl/openssl/doc/crypto/EVP_DigestVerifyInit.pod +++ b/deps/openssl/openssl/doc/crypto/EVP_DigestVerifyInit.pod @@ -10,7 +10,7 @@ EVP_DigestVerifyInit, EVP_DigestVerifyUpdate, EVP_DigestVerifyFinal - EVP signat int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, const EVP_MD *type, ENGINE *e, EVP_PKEY *pkey); - int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *d, unsigned int cnt); + int EVP_DigestVerifyUpdate(EVP_MD_CTX *ctx, const void *d, size_t cnt); int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig, size_t siglen); =head1 DESCRIPTION diff --git a/deps/openssl/openssl/doc/crypto/RSA_generate_key.pod b/deps/openssl/openssl/doc/crypto/RSA_generate_key.pod index 881391a045047a..0882a1a59d7153 100644 --- a/deps/openssl/openssl/doc/crypto/RSA_generate_key.pod +++ b/deps/openssl/openssl/doc/crypto/RSA_generate_key.pod @@ -52,7 +52,7 @@ it is called as B. The process is then repeated for prime q with B. RSA_generate_key is deprecated (new applications should use -RSA_generate_key_ex instead). RSA_generate_key works in the same was as +RSA_generate_key_ex instead). RSA_generate_key works in the same way as RSA_generate_key_ex except it uses "old style" call backs. See L for further details. diff --git a/deps/openssl/openssl/doc/crypto/X509_NAME_get_index_by_NID.pod b/deps/openssl/openssl/doc/crypto/X509_NAME_get_index_by_NID.pod index 109f561324988f..cdec4b1d6db43d 100644 --- a/deps/openssl/openssl/doc/crypto/X509_NAME_get_index_by_NID.pod +++ b/deps/openssl/openssl/doc/crypto/X509_NAME_get_index_by_NID.pod @@ -83,10 +83,9 @@ Process all entries: Process all commonName entries: - int loc; + int lastpos = -1; X509_NAME_ENTRY *e; - loc = -1; for (;;) { lastpos = X509_NAME_get_index_by_NID(nm, NID_commonName, lastpos); diff --git a/deps/openssl/openssl/doc/crypto/X509_NAME_print_ex.pod b/deps/openssl/openssl/doc/crypto/X509_NAME_print_ex.pod index 2579a5dc9dc6fa..d73520f35e894a 100644 --- a/deps/openssl/openssl/doc/crypto/X509_NAME_print_ex.pod +++ b/deps/openssl/openssl/doc/crypto/X509_NAME_print_ex.pod @@ -23,9 +23,11 @@ can be extensively customised by use of the B parameter. X509_NAME_print_ex_fp() is identical to X509_NAME_print_ex() except the output is written to FILE pointer B. -X509_NAME_oneline() prints an ASCII version of B to B. At most B -bytes will be written. If B is B then a buffer is dynamically allocated -and returned, otherwise B is returned. +X509_NAME_oneline() prints an ASCII version of B to B. +If B is B then a buffer is dynamically allocated and returned, and +B is ignored. +Otherwise, at most B bytes will be written, including the ending '\0', +and B is returned. X509_NAME_print() prints out B to B indenting each line by B characters. Multiple lines are used if the output (including indent) exceeds diff --git a/deps/openssl/openssl/doc/ssl/SSL_CTX_set_session_cache_mode.pod b/deps/openssl/openssl/doc/ssl/SSL_CTX_set_session_cache_mode.pod index c5d2f43dff15da..4d71f85cedb28e 100644 --- a/deps/openssl/openssl/doc/ssl/SSL_CTX_set_session_cache_mode.pod +++ b/deps/openssl/openssl/doc/ssl/SSL_CTX_set_session_cache_mode.pod @@ -30,7 +30,7 @@ server. It can only send exactly one id. The server then either agrees to reuse the session or it starts a full handshake (to create a new session). -A server will lookup up the session in its internal session storage. If the +A server will look up the session in its internal session storage. If the session is not found in internal storage or lookups for the internal storage have been deactivated (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP), the server will try the external storage if available. diff --git a/deps/openssl/openssl/doc/ssl/SSL_get_error.pod b/deps/openssl/openssl/doc/ssl/SSL_get_error.pod index 48c6b15db78f94..2a93894096e768 100644 --- a/deps/openssl/openssl/doc/ssl/SSL_get_error.pod +++ b/deps/openssl/openssl/doc/ssl/SSL_get_error.pod @@ -38,12 +38,13 @@ if and only if B 0>. =item SSL_ERROR_ZERO_RETURN -The TLS/SSL connection has been closed. If the protocol version is SSL 3.0 -or TLS 1.0, this result code is returned only if a closure -alert has occurred in the protocol, i.e. if the connection has been -closed cleanly. Note that in this case B -does not necessarily indicate that the underlying transport -has been closed. +The TLS/SSL connection has been closed. +If the protocol version is SSL 3.0 or higher, this result code is returned only +if a closure alert has occurred in the protocol, i.e. if the connection has been +closed cleanly. +Note that in this case B does not necessarily +indicate that the underlying transport has been closed. + =item SSL_ERROR_WANT_READ, SSL_ERROR_WANT_WRITE @@ -89,12 +90,9 @@ Details depend on the application. =item SSL_ERROR_SYSCALL -Some I/O error occurred. The OpenSSL error queue may contain more -information on the error. If the error queue is empty -(i.e. ERR_get_error() returns 0), B can be used to find out more -about the error: If B, an EOF was observed that violates -the protocol. If B, the underlying B reported an -I/O error (for socket I/O on Unix systems, consult B for details). +Some non-recoverable I/O error occurred. +The OpenSSL error queue may contain more information on the error. +For socket I/O on Unix systems, consult B for details. =item SSL_ERROR_SSL diff --git a/deps/openssl/openssl/doc/ssl/SSL_read.pod b/deps/openssl/openssl/doc/ssl/SSL_read.pod index 8ca0ce5058da0e..ef983c9d3f0850 100644 --- a/deps/openssl/openssl/doc/ssl/SSL_read.pod +++ b/deps/openssl/openssl/doc/ssl/SSL_read.pod @@ -81,33 +81,29 @@ The following return values can occur: =over 4 -=item E0 +=item E 0 -The read operation was successful; the return value is the number of -bytes actually read from the TLS/SSL connection. +The read operation was successful. +The return value is the number of bytes actually read from the TLS/SSL +connection. -=item Z<>0 +=item Z<><= 0 -The read operation was not successful. The reason may either be a clean -shutdown due to a "close notify" alert sent by the peer (in which case -the SSL_RECEIVED_SHUTDOWN flag in the ssl shutdown state is set -(see L, -L). It is also possible, that -the peer simply shut down the underlying transport and the shutdown is -incomplete. Call SSL_get_error() with the return value B to find out, -whether an error occurred or the connection was shut down cleanly -(SSL_ERROR_ZERO_RETURN). + +=item E0 + +The read operation was not successful, because either the connection was closed, +an error occurred or action must be taken by the calling process. +Call L with the return value B to find out the reason. SSLv2 (deprecated) does not support a shutdown alert protocol, so it can only be detected, whether the underlying connection was closed. It cannot be checked, whether the closure was initiated by the peer or by something else. -=item E0 - -The read operation was not successful, because either an error occurred -or action must be taken by the calling process. Call SSL_get_error() with the -return value B to find out the reason. +Old documentation indicated a difference between 0 and -1, and that -1 was +retryable. +You should instead call SSL_get_error() to find out if it's retryable. =back diff --git a/deps/openssl/openssl/doc/ssl/SSL_write.pod b/deps/openssl/openssl/doc/ssl/SSL_write.pod index a57617f3ee9aa1..4c1a7ee71f3cce 100644 --- a/deps/openssl/openssl/doc/ssl/SSL_write.pod +++ b/deps/openssl/openssl/doc/ssl/SSL_write.pod @@ -74,27 +74,24 @@ The following return values can occur: =over 4 -=item E0 +=item E 0 The write operation was successful, the return value is the number of bytes actually written to the TLS/SSL connection. -=item Z<>0 +=item Z<><= 0 -The write operation was not successful. Probably the underlying connection -was closed. Call SSL_get_error() with the return value B to find out, -whether an error occurred or the connection was shut down cleanly -(SSL_ERROR_ZERO_RETURN). +The write operation was not successful, because either the connection was +closed, an error occurred or action must be taken by the calling process. +Call SSL_get_error() with the return value B to find out the reason. SSLv2 (deprecated) does not support a shutdown alert protocol, so it can only be detected, whether the underlying connection was closed. It cannot be checked, why the closure happened. -=item E0 - -The write operation was not successful, because either an error occurred -or action must be taken by the calling process. Call SSL_get_error() with the -return value B to find out the reason. +Old documentation indicated a difference between 0 and -1, and that -1 was +retryable. +You should instead call SSL_get_error() to find out if it's retryable. =back diff --git a/deps/openssl/openssl/engines/ccgost/Makefile b/deps/openssl/openssl/engines/ccgost/Makefile index 17e1efbdff3014..f378530c864233 100644 --- a/deps/openssl/openssl/engines/ccgost/Makefile +++ b/deps/openssl/openssl/engines/ccgost/Makefile @@ -32,7 +32,7 @@ lib: $(LIBOBJ) $(MAKE) -f $(TOP)/Makefile.shared -e \ LIBNAME=$(LIBNAME) \ LIBEXTRAS='$(LIBOBJ)' \ - LIBDEPS='-L$(TOP) -lcrypto' \ + LIBDEPS='-L$(TOP) -lcrypto $(EX_LIBS)' \ link_o.$(SHLIB_TARGET); \ else \ $(AR) $(LIB) $(LIBOBJ); \ diff --git a/deps/openssl/openssl/include/openssl/evp.h b/deps/openssl/openssl/include/openssl/evp.h index 39ab7937d25672..d258ef870a3604 100644 --- a/deps/openssl/openssl/include/openssl/evp.h +++ b/deps/openssl/openssl/include/openssl/evp.h @@ -1370,6 +1370,7 @@ void EVP_add_alg_module(void); * The following lines are auto generated by the script mkerr.pl. Any changes * made after this point may be overwritten when the script is next run. */ + void ERR_load_EVP_strings(void); /* Error codes for the EVP functions. */ @@ -1489,6 +1490,7 @@ void ERR_load_EVP_strings(void); # define EVP_R_INPUT_NOT_INITIALIZED 111 # define EVP_R_INVALID_DIGEST 152 # define EVP_R_INVALID_FIPS_MODE 168 +# define EVP_R_INVALID_KEY 171 # define EVP_R_INVALID_KEY_LENGTH 130 # define EVP_R_INVALID_OPERATION 148 # define EVP_R_IV_TOO_LARGE 102 @@ -1528,7 +1530,7 @@ void ERR_load_EVP_strings(void); # define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 # define EVP_R_WRONG_PUBLIC_KEY_TYPE 110 -#ifdef __cplusplus +# ifdef __cplusplus } -#endif +# endif #endif diff --git a/deps/openssl/openssl/include/openssl/opensslv.h b/deps/openssl/openssl/include/openssl/opensslv.h index 88faad652259b4..645dd0793f32e0 100644 --- a/deps/openssl/openssl/include/openssl/opensslv.h +++ b/deps/openssl/openssl/include/openssl/opensslv.h @@ -30,11 +30,11 @@ extern "C" { * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for * major minor fix final patch/beta) */ -# define OPENSSL_VERSION_NUMBER 0x100020afL +# define OPENSSL_VERSION_NUMBER 0x100020bfL # ifdef OPENSSL_FIPS -# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2j-fips 26 Sep 2016" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2k-fips 26 Jan 2017" # else -# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2j 26 Sep 2016" +# define OPENSSL_VERSION_TEXT "OpenSSL 1.0.2k 26 Jan 2017" # endif # define OPENSSL_VERSION_PTEXT " part of " OPENSSL_VERSION_TEXT diff --git a/deps/openssl/openssl/openssl.spec b/deps/openssl/openssl/openssl.spec index 880a5c322fd1ca..7bbcdf69a4310f 100644 --- a/deps/openssl/openssl/openssl.spec +++ b/deps/openssl/openssl/openssl.spec @@ -7,7 +7,7 @@ Release: 1 Summary: Secure Sockets Layer and cryptography libraries and tools Name: openssl -Version: 1.0.2j +Version: 1.0.2k Source0: ftp://ftp.openssl.org/source/%{name}-%{version}.tar.gz License: OpenSSL Group: System Environment/Libraries diff --git a/deps/openssl/openssl/ssl/bad_dtls_test.c b/deps/openssl/openssl/ssl/bad_dtls_test.c index d42817fc329e69..70d8578b588317 100644 --- a/deps/openssl/openssl/ssl/bad_dtls_test.c +++ b/deps/openssl/openssl/ssl/bad_dtls_test.c @@ -756,6 +756,7 @@ int main(int argc, char *argv[]) BIO *rbio; BIO *wbio; BIO *err; + time_t now = 0; int testresult = 0; int ret; int i; @@ -773,7 +774,9 @@ int main(int argc, char *argv[]) RAND_bytes(master_secret, sizeof(master_secret)); RAND_bytes(cookie, sizeof(cookie)); RAND_bytes(server_random + 4, sizeof(server_random) - 4); - time((void *)server_random); + + now = time(NULL); + memcpy(server_random, &now, sizeof(now)); sess = client_session(); if (sess == NULL) { diff --git a/deps/openssl/openssl/ssl/s23_pkt.c b/deps/openssl/openssl/ssl/s23_pkt.c index efc8647841bf21..6544180efe86ab 100644 --- a/deps/openssl/openssl/ssl/s23_pkt.c +++ b/deps/openssl/openssl/ssl/s23_pkt.c @@ -63,6 +63,9 @@ #include #include +/* + * Return values are as per SSL_write() + */ int ssl23_write_bytes(SSL *s) { int i, num, tot; @@ -77,7 +80,7 @@ int ssl23_write_bytes(SSL *s) if (i <= 0) { s->init_off = tot; s->init_num = num; - return (i); + return i; } s->rwstate = SSL_NOTHING; if (i == num) @@ -88,7 +91,10 @@ int ssl23_write_bytes(SSL *s) } } -/* return regularly only when we have read (at least) 'n' bytes */ +/* return regularly only when we have read (at least) 'n' bytes + * + * Return values are as per SSL_read() + */ int ssl23_read_bytes(SSL *s, int n) { unsigned char *p; @@ -102,7 +108,7 @@ int ssl23_read_bytes(SSL *s, int n) j = BIO_read(s->rbio, (char *)&(p[s->packet_length]), n - s->packet_length); if (j <= 0) - return (j); + return j; s->rwstate = SSL_NOTHING; s->packet_length += j; if (s->packet_length >= (unsigned int)n) diff --git a/deps/openssl/openssl/ssl/s2_lib.c b/deps/openssl/openssl/ssl/s2_lib.c index 88e67f083a1bd7..cc1360307b9468 100644 --- a/deps/openssl/openssl/ssl/s2_lib.c +++ b/deps/openssl/openssl/ssl/s2_lib.c @@ -254,7 +254,7 @@ OPENSSL_GLOBAL const SSL_CIPHER ssl2_ciphers[] = { SSL_3DES, SSL_MD5, SSL_SSLV2, - SSL_NOT_DEFAULT | SSL_NOT_EXP | SSL_HIGH, + SSL_NOT_DEFAULT | SSL_NOT_EXP | SSL_MEDIUM, 0, 112, 168, diff --git a/deps/openssl/openssl/ssl/s2_pkt.c b/deps/openssl/openssl/ssl/s2_pkt.c index 7a6188813431f3..e44bc0335af9e6 100644 --- a/deps/openssl/openssl/ssl/s2_pkt.c +++ b/deps/openssl/openssl/ssl/s2_pkt.c @@ -307,6 +307,9 @@ int ssl2_peek(SSL *s, void *buf, int len) return ssl2_read_internal(s, buf, len, 1); } +/* + * Return values are as per SSL_read() + */ static int read_n(SSL *s, unsigned int n, unsigned int max, unsigned int extend) { @@ -374,7 +377,7 @@ static int read_n(SSL *s, unsigned int n, unsigned int max, # endif if (i <= 0) { s->s2->rbuf_left += newb; - return (i); + return i; } newb += i; } @@ -441,6 +444,9 @@ int ssl2_write(SSL *s, const void *_buf, int len) } } +/* + * Return values are as per SSL_write() + */ static int write_pending(SSL *s, const unsigned char *buf, unsigned int len) { int i; @@ -477,7 +483,7 @@ static int write_pending(SSL *s, const unsigned char *buf, unsigned int len) s->rwstate = SSL_NOTHING; return (s->s2->wpend_ret); } else if (i <= 0) - return (i); + return i; s->s2->wpend_off += i; s->s2->wpend_len -= i; } diff --git a/deps/openssl/openssl/ssl/s3_clnt.c b/deps/openssl/openssl/ssl/s3_clnt.c index 218534734dd7e7..32f2f1aeed2b19 100644 --- a/deps/openssl/openssl/ssl/s3_clnt.c +++ b/deps/openssl/openssl/ssl/s3_clnt.c @@ -1710,12 +1710,6 @@ int ssl3_get_key_exchange(SSL *s) } p += i; - if (BN_is_zero(dh->p)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_P_VALUE); - goto f_err; - } - - if (2 > n - param_len) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); goto f_err; @@ -1736,11 +1730,6 @@ int ssl3_get_key_exchange(SSL *s) } p += i; - if (BN_is_zero(dh->g)) { - SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_G_VALUE); - goto f_err; - } - if (2 > n - param_len) { SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_LENGTH_TOO_SHORT); goto f_err; @@ -1767,6 +1756,39 @@ int ssl3_get_key_exchange(SSL *s) goto f_err; } + /*- + * Check that p and g are suitable enough + * + * p is odd + * 1 < g < p - 1 + */ + { + BIGNUM *tmp = NULL; + + if (!BN_is_odd(dh->p)) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_P_VALUE); + goto f_err; + } + if (BN_is_negative(dh->g) || BN_is_zero(dh->g) + || BN_is_one(dh->g)) { + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_G_VALUE); + goto f_err; + } + if ((tmp = BN_new()) == NULL + || BN_copy(tmp, dh->p) == NULL + || !BN_sub_word(tmp, 1)) { + BN_free(tmp); + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, ERR_R_BN_LIB); + goto err; + } + if (BN_cmp(dh->g, tmp) >= 0) { + BN_free(tmp); + SSLerr(SSL_F_SSL3_GET_KEY_EXCHANGE, SSL_R_BAD_DH_G_VALUE); + goto f_err; + } + BN_free(tmp); + } + # ifndef OPENSSL_NO_RSA if (alg_a & SSL_aRSA) pkey = diff --git a/deps/openssl/openssl/ssl/s3_pkt.c b/deps/openssl/openssl/ssl/s3_pkt.c index be37ef0e50d8b0..6ece87d0628c4f 100644 --- a/deps/openssl/openssl/ssl/s3_pkt.c +++ b/deps/openssl/openssl/ssl/s3_pkt.c @@ -136,6 +136,9 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, unsigned int len, int create_empty_fragment); static int ssl3_get_record(SSL *s); +/* + * Return values are as per SSL_read() + */ int ssl3_read_n(SSL *s, int n, int max, int extend) { /* @@ -1082,7 +1085,10 @@ static int do_ssl3_write(SSL *s, int type, const unsigned char *buf, return -1; } -/* if s->s3->wbuf.left != 0, we need to call this */ +/* if s->s3->wbuf.left != 0, we need to call this + * + * Return values are as per SSL_write(), i.e. + */ int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, unsigned int len) { @@ -1122,7 +1128,7 @@ int ssl3_write_pending(SSL *s, int type, const unsigned char *buf, */ wb->left = 0; } - return (i); + return i; } wb->offset += i; wb->left -= i; @@ -1593,16 +1599,13 @@ int ssl3_read_bytes(SSL *s, int type, unsigned char *buf, int len, int peek) switch (rr->type) { default: -#ifndef OPENSSL_NO_TLS /* - * TLS up to v1.1 just ignores unknown message types: TLS v1.2 give - * an unexpected message alert. + * TLS 1.0 and 1.1 say you SHOULD ignore unrecognised record types, but + * TLS 1.2 says you MUST send an unexpected message alert. We use the + * TLS 1.2 behaviour for all protocol versions to prevent issues where + * no progress is being made and the peer continually sends unrecognised + * record types, using up resources processing them. */ - if (s->version >= TLS1_VERSION && s->version <= TLS1_1_VERSION) { - rr->length = 0; - goto start; - } -#endif al = SSL_AD_UNEXPECTED_MESSAGE; SSLerr(SSL_F_SSL3_READ_BYTES, SSL_R_UNEXPECTED_RECORD); goto f_err; diff --git a/deps/openssl/openssl/ssl/s3_srvr.c b/deps/openssl/openssl/ssl/s3_srvr.c index 01ccd5d2ae78d4..ea56f9ca81509b 100644 --- a/deps/openssl/openssl/ssl/s3_srvr.c +++ b/deps/openssl/openssl/ssl/s3_srvr.c @@ -506,7 +506,7 @@ int ssl3_accept(SSL *s) * if SSL_VERIFY_CLIENT_ONCE is set, don't request cert * during re-negotiation: */ - ((s->session->peer != NULL) && + (s->s3->tmp.finish_md_len != 0 && (s->verify_mode & SSL_VERIFY_CLIENT_ONCE)) || /* * never request cert in anonymous ciphersuites (see @@ -1465,9 +1465,9 @@ int ssl3_get_client_hello(SSL *s) /* Handles TLS extensions that we couldn't check earlier */ if (s->version >= SSL3_VERSION) { - if (ssl_check_clienthello_tlsext_late(s) <= 0) { + if (!ssl_check_clienthello_tlsext_late(s, &al)) { SSLerr(SSL_F_SSL3_GET_CLIENT_HELLO, SSL_R_CLIENTHELLO_TLSEXT); - goto err; + goto f_err; } } @@ -1601,6 +1601,9 @@ int ssl3_send_server_key_exchange(SSL *s) unsigned int u; #endif #ifndef OPENSSL_NO_DH +# ifdef OPENSSL_NO_RSA + int j; +# endif DH *dh = NULL, *dhp; #endif #ifndef OPENSSL_NO_ECDH @@ -1861,6 +1864,16 @@ int ssl3_send_server_key_exchange(SSL *s) if ((i == 2) && (type & SSL_kSRP)) n += 1 + nr[i]; else +#endif +#ifndef OPENSSL_NO_DH + /* + * for interoperability with some versions of the Microsoft TLS + * stack, we need to zero pad the DHE pub key to the same length + * as the prime, so use the length of the prime here + */ + if ((i == 2) && (type & (SSL_kEDH))) + n += 2 + nr[0]; + else #endif n += 2 + nr[i]; } @@ -1895,6 +1908,20 @@ int ssl3_send_server_key_exchange(SSL *s) *p = nr[i]; p++; } else +#endif +#ifndef OPENSSL_NO_DH + /* + * for interoperability with some versions of the Microsoft TLS + * stack, we need to zero pad the DHE pub key to the same length + * as the prime + */ + if ((i == 2) && (type & (SSL_kEDH))) { + s2n(nr[0], p); + for (j = 0; j < (nr[0] - nr[2]); ++j) { + *p = 0; + ++p; + } + } else #endif s2n(nr[i], p); BN_bn2bin(r[i], p); diff --git a/deps/openssl/openssl/ssl/ssl_cert.c b/deps/openssl/openssl/ssl/ssl_cert.c index f48ebaecc067da..1be6fb0032e200 100644 --- a/deps/openssl/openssl/ssl/ssl_cert.c +++ b/deps/openssl/openssl/ssl/ssl_cert.c @@ -315,7 +315,7 @@ CERT *ssl_cert_dup(CERT *cert) OPENSSL_malloc(cert->pkeys[i].serverinfo_length); if (ret->pkeys[i].serverinfo == NULL) { SSLerr(SSL_F_SSL_CERT_DUP, ERR_R_MALLOC_FAILURE); - return NULL; + goto err; } ret->pkeys[i].serverinfo_length = cert->pkeys[i].serverinfo_length; @@ -392,9 +392,7 @@ CERT *ssl_cert_dup(CERT *cert) return (ret); -#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_ECDH) err: -#endif #ifndef OPENSSL_NO_RSA if (ret->rsa_tmp != NULL) RSA_free(ret->rsa_tmp); diff --git a/deps/openssl/openssl/ssl/ssl_err.c b/deps/openssl/openssl/ssl/ssl_err.c index 79aaf1a838b71b..a4c17a6bf3bf30 100644 --- a/deps/openssl/openssl/ssl/ssl_err.c +++ b/deps/openssl/openssl/ssl/ssl_err.c @@ -753,6 +753,7 @@ static ERR_STRING_DATA SSL_str_reasons[] = { "tls illegal exporter label"}, {ERR_REASON(SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST), "tls invalid ecpointformat list"}, + {ERR_REASON(SSL_R_TOO_MANY_WARN_ALERTS), "too many warn alerts"}, {ERR_REASON(SSL_R_TLS_PEER_DID_NOT_RESPOND_WITH_CERTIFICATE_LIST), "tls peer did not respond with certificate list"}, {ERR_REASON(SSL_R_TLS_RSA_ENCRYPTED_VALUE_LENGTH_IS_WRONG), diff --git a/deps/openssl/openssl/ssl/ssl_lib.c b/deps/openssl/openssl/ssl/ssl_lib.c index 42b980ac26a05f..f8054dae6b6b10 100644 --- a/deps/openssl/openssl/ssl/ssl_lib.c +++ b/deps/openssl/openssl/ssl/ssl_lib.c @@ -2030,10 +2030,8 @@ SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth) ret->rbuf_freelist->len = 0; ret->rbuf_freelist->head = NULL; ret->wbuf_freelist = OPENSSL_malloc(sizeof(SSL3_BUF_FREELIST)); - if (!ret->wbuf_freelist) { - OPENSSL_free(ret->rbuf_freelist); + if (!ret->wbuf_freelist) goto err; - } ret->wbuf_freelist->chunklen = 0; ret->wbuf_freelist->len = 0; ret->wbuf_freelist->head = NULL; diff --git a/deps/openssl/openssl/ssl/ssl_locl.h b/deps/openssl/openssl/ssl/ssl_locl.h index 6df725f7d73afa..d50edd18c91658 100644 --- a/deps/openssl/openssl/ssl/ssl_locl.h +++ b/deps/openssl/openssl/ssl/ssl_locl.h @@ -1384,7 +1384,7 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, int ssl_parse_clienthello_tlsext(SSL *s, unsigned char **data, unsigned char *limit); int tls1_set_server_sigalgs(SSL *s); -int ssl_check_clienthello_tlsext_late(SSL *s); +int ssl_check_clienthello_tlsext_late(SSL *s, int *al); int ssl_parse_serverhello_tlsext(SSL *s, unsigned char **data, unsigned char *d, int n); int ssl_prepare_clienthello_tlsext(SSL *s); diff --git a/deps/openssl/openssl/ssl/ssl_sess.c b/deps/openssl/openssl/ssl/ssl_sess.c index ed9855f90cf812..c3369a44aea7e2 100644 --- a/deps/openssl/openssl/ssl/ssl_sess.c +++ b/deps/openssl/openssl/ssl/ssl_sess.c @@ -769,6 +769,15 @@ int SSL_CTX_add_session(SSL_CTX *ctx, SSL_SESSION *c) * obtain the same session from an external cache) */ s = NULL; + } else if (s == NULL && + lh_SSL_SESSION_retrieve(ctx->sessions, c) == NULL) { + /* s == NULL can also mean OOM error in lh_SSL_SESSION_insert ... */ + + /* + * ... so take back the extra reference and also don't add + * the session to the SSL_SESSION_list at this time + */ + s = c; } /* Put at the head of the queue unless it is already in the cache */ diff --git a/deps/openssl/openssl/ssl/t1_lib.c b/deps/openssl/openssl/ssl/t1_lib.c index 7831046b926139..e60c88bd5b2766 100644 --- a/deps/openssl/openssl/ssl/t1_lib.c +++ b/deps/openssl/openssl/ssl/t1_lib.c @@ -132,6 +132,9 @@ static int ssl_check_clienthello_tlsext_early(SSL *s); int ssl_check_serverhello_tlsext(SSL *s); #endif +#define CHECKLEN(curr, val, limit) \ + (((curr) >= (limit)) || (size_t)((limit) - (curr)) < (size_t)(val)) + SSL3_ENC_METHOD TLSv1_enc_data = { tls1_enc, tls1_mac, @@ -1263,8 +1266,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, if (s->tlsext_hostname != NULL) { /* Add TLS extension servername to the Client Hello message */ - unsigned long size_str; - long lenmax; + size_t size_str; /*- * check for enough space. @@ -1274,10 +1276,8 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, * 2 for hostname length * + hostname length */ - - if ((lenmax = limit - ret - 9) < 0 - || (size_str = - strlen(s->tlsext_hostname)) > (unsigned long)lenmax) + size_str = strlen(s->tlsext_hostname); + if (CHECKLEN(ret, 9 + size_str, limit)) return NULL; /* extension type and length */ @@ -1321,7 +1321,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, if (s->srp_ctx.login != NULL) { /* Add TLS extension SRP username to the * Client Hello message */ - int login_len = strlen(s->srp_ctx.login); + size_t login_len = strlen(s->srp_ctx.login); if (login_len > 255 || login_len == 0) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; @@ -1333,7 +1333,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, * 1 for the srp user identity * + srp user identity length */ - if ((limit - ret - 5 - login_len) < 0) + if (CHECKLEN(ret, 5 + login_len, limit)) return NULL; /* fill in the extension */ @@ -1350,20 +1350,23 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, /* * Add TLS extension ECPointFormats to the ClientHello message */ - long lenmax; const unsigned char *pcurves, *pformats; size_t num_curves, num_formats, curves_list_len; tls1_get_formatlist(s, &pformats, &num_formats); - if ((lenmax = limit - ret - 5) < 0) - return NULL; - if (num_formats > (size_t)lenmax) - return NULL; if (num_formats > 255) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } + /*- + * check for enough space. + * 4 bytes for the ec point formats type and extension length + * 1 byte for the length of the formats + * + formats length + */ + if (CHECKLEN(ret, 5 + num_formats, limit)) + return NULL; s2n(TLSEXT_TYPE_ec_point_formats, ret); /* The point format list has 1-byte length. */ @@ -1379,15 +1382,20 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, if (!tls1_get_curvelist(s, 0, &pcurves, &num_curves)) return NULL; - if ((lenmax = limit - ret - 6) < 0) - return NULL; - if (num_curves > (size_t)lenmax / 2) - return NULL; if (num_curves > 65532 / 2) { SSLerr(SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } curves_list_len = 2 * num_curves; + /*- + * check for enough space. + * 4 bytes for the ec curves type and extension length + * 2 bytes for the curve list length + * + curve list length + */ + if (CHECKLEN(ret, 6 + curves_list_len, limit)) + return NULL; + s2n(TLSEXT_TYPE_elliptic_curves, ret); s2n(curves_list_len + 2, ret); s2n(curves_list_len, ret); @@ -1397,7 +1405,7 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, # endif /* OPENSSL_NO_EC */ if (!(SSL_get_options(s) & SSL_OP_NO_TICKET)) { - int ticklen; + size_t ticklen; if (!s->new_session && s->session && s->session->tlsext_tick) ticklen = s->session->tlsext_ticklen; else if (s->session && s->tlsext_session_ticket && @@ -1418,11 +1426,11 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, * Check for enough room 2 for extension type, 2 for len rest for * ticket */ - if ((long)(limit - ret - 4 - ticklen) < 0) + if (CHECKLEN(ret, 4 + ticklen, limit)) return NULL; s2n(TLSEXT_TYPE_session_ticket, ret); s2n(ticklen, ret); - if (ticklen) { + if (ticklen > 0) { memcpy(ret, s->session->tlsext_tick, ticklen); ret += ticklen; } @@ -1433,7 +1441,14 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, size_t salglen; const unsigned char *salg; salglen = tls12_get_psigalgs(s, &salg); - if ((size_t)(limit - ret) < salglen + 6) + + /*- + * check for enough space. + * 4 bytes for the sigalgs type and extension length + * 2 bytes for the sigalg list length + * + sigalg list length + */ + if (CHECKLEN(ret, salglen + 6, limit)) return NULL; s2n(TLSEXT_TYPE_signature_algorithms, ret); s2n(salglen + 2, ret); @@ -1460,30 +1475,42 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, if (s->tlsext_status_type == TLSEXT_STATUSTYPE_ocsp) { int i; - long extlen, idlen, itmp; + size_t extlen, idlen; + int lentmp; OCSP_RESPID *id; idlen = 0; for (i = 0; i < sk_OCSP_RESPID_num(s->tlsext_ocsp_ids); i++) { id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i); - itmp = i2d_OCSP_RESPID(id, NULL); - if (itmp <= 0) + lentmp = i2d_OCSP_RESPID(id, NULL); + if (lentmp <= 0) return NULL; - idlen += itmp + 2; + idlen += (size_t)lentmp + 2; } if (s->tlsext_ocsp_exts) { - extlen = i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, NULL); - if (extlen < 0) + lentmp = i2d_X509_EXTENSIONS(s->tlsext_ocsp_exts, NULL); + if (lentmp < 0) return NULL; + extlen = (size_t)lentmp; } else extlen = 0; - if ((long)(limit - ret - 7 - extlen - idlen) < 0) - return NULL; - s2n(TLSEXT_TYPE_status_request, ret); if (extlen + idlen > 0xFFF0) return NULL; + /* + * 2 bytes for status request type + * 2 bytes for status request len + * 1 byte for OCSP request type + * 2 bytes for length of ids + * 2 bytes for length of extensions + * + length of ids + * + length of extensions + */ + if (CHECKLEN(ret, 9 + idlen + extlen, limit)) + return NULL; + + s2n(TLSEXT_TYPE_status_request, ret); s2n(extlen + idlen + 5, ret); *(ret++) = TLSEXT_STATUSTYPE_ocsp; s2n(idlen, ret); @@ -1493,9 +1520,9 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, id = sk_OCSP_RESPID_value(s->tlsext_ocsp_ids, i); /* skip over id len */ ret += 2; - itmp = i2d_OCSP_RESPID(id, &ret); + lentmp = i2d_OCSP_RESPID(id, &ret); /* write id len */ - s2n(itmp, q); + s2n(lentmp, q); } s2n(extlen, ret); if (extlen > 0) @@ -1503,8 +1530,15 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, } # ifndef OPENSSL_NO_HEARTBEATS /* Add Heartbeat extension */ - if ((limit - ret - 4 - 1) < 0) + + /*- + * check for enough space. + * 4 bytes for the heartbeat ext type and extension length + * 1 byte for the mode + */ + if (CHECKLEN(ret, 5, limit)) return NULL; + s2n(TLSEXT_TYPE_heartbeat, ret); s2n(1, ret); /*- @@ -1524,7 +1558,12 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, * The client advertises an emtpy extension to indicate its support * for Next Protocol Negotiation */ - if (limit - ret - 4 < 0) + + /*- + * check for enough space. + * 4 bytes for the NPN ext type and extension length + */ + if (CHECKLEN(ret, 4, limit)) return NULL; s2n(TLSEXT_TYPE_next_proto_neg, ret); s2n(0, ret); @@ -1532,7 +1571,13 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, # endif if (s->alpn_client_proto_list && !s->s3->tmp.finish_md_len) { - if ((size_t)(limit - ret) < 6 + s->alpn_client_proto_list_len) + /*- + * check for enough space. + * 4 bytes for the ALPN type and extension length + * 2 bytes for the ALPN protocol list length + * + ALPN protocol list length + */ + if (CHECKLEN(ret, 6 + s->alpn_client_proto_list_len, limit)) return NULL; s2n(TLSEXT_TYPE_application_layer_protocol_negotiation, ret); s2n(2 + s->alpn_client_proto_list_len, ret); @@ -1547,7 +1592,12 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, ssl_add_clienthello_use_srtp_ext(s, 0, &el, 0); - if ((limit - ret - 4 - el) < 0) + /*- + * check for enough space. + * 4 bytes for the SRTP type and extension length + * + SRTP profiles length + */ + if (CHECKLEN(ret, 4 + el, limit)) return NULL; s2n(TLSEXT_TYPE_use_srtp, ret); @@ -1587,6 +1637,17 @@ unsigned char *ssl_add_clienthello_tlsext(SSL *s, unsigned char *buf, else hlen = 0; + /*- + * check for enough space. Strictly speaking we know we've already + * got enough space because to get here the message size is < 0x200, + * but we know that we've allocated far more than that in the buffer + * - but for consistency and robustness we're going to check anyway. + * + * 4 bytes for the padding type and extension length + * + padding length + */ + if (CHECKLEN(ret, 4 + hlen, limit)) + return NULL; s2n(TLSEXT_TYPE_padding, ret); s2n(hlen, ret); memset(ret, 0, hlen); @@ -1644,7 +1705,12 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, return NULL; } - if ((limit - ret - 4 - el) < 0) + /*- + * check for enough space. + * 4 bytes for the reneg type and extension length + * + reneg data length + */ + if (CHECKLEN(ret, 4 + el, limit)) return NULL; s2n(TLSEXT_TYPE_renegotiate, ret); @@ -1664,19 +1730,23 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, /* * Add TLS extension ECPointFormats to the ServerHello message */ - long lenmax; tls1_get_formatlist(s, &plist, &plistlen); - if ((lenmax = limit - ret - 5) < 0) - return NULL; - if (plistlen > (size_t)lenmax) - return NULL; if (plistlen > 255) { SSLerr(SSL_F_SSL_ADD_SERVERHELLO_TLSEXT, ERR_R_INTERNAL_ERROR); return NULL; } + /*- + * check for enough space. + * 4 bytes for the ec points format type and extension length + * 1 byte for the points format list length + * + length of points format list + */ + if (CHECKLEN(ret, 5 + plistlen, limit)) + return NULL; + s2n(TLSEXT_TYPE_ec_point_formats, ret); s2n(plistlen + 1, ret); *(ret++) = (unsigned char)plistlen; @@ -1691,14 +1761,22 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, # endif /* OPENSSL_NO_EC */ if (s->tlsext_ticket_expected && !(SSL_get_options(s) & SSL_OP_NO_TICKET)) { - if ((long)(limit - ret - 4) < 0) + /*- + * check for enough space. + * 4 bytes for the Ticket type and extension length + */ + if (CHECKLEN(ret, 4, limit)) return NULL; s2n(TLSEXT_TYPE_session_ticket, ret); s2n(0, ret); } if (s->tlsext_status_expected) { - if ((long)(limit - ret - 4) < 0) + /*- + * check for enough space. + * 4 bytes for the Status request type and extension length + */ + if (CHECKLEN(ret, 4, limit)) return NULL; s2n(TLSEXT_TYPE_status_request, ret); s2n(0, ret); @@ -1726,7 +1804,12 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, ssl_add_serverhello_use_srtp_ext(s, 0, &el, 0); - if ((limit - ret - 4 - el) < 0) + /*- + * check for enough space. + * 4 bytes for the SRTP profiles type and extension length + * + length of the SRTP profiles list + */ + if (CHECKLEN(ret, 4 + el, limit)) return NULL; s2n(TLSEXT_TYPE_use_srtp, ret); @@ -1751,16 +1834,23 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x16, 0x30, 0x08, 0x06, 0x06, 0x2a, 0x85, 0x03, 0x02, 0x02, 0x17 }; - if (limit - ret < 36) + + /* check for enough space. */ + if (CHECKLEN(ret, sizeof(cryptopro_ext), limit)) return NULL; - memcpy(ret, cryptopro_ext, 36); - ret += 36; + memcpy(ret, cryptopro_ext, sizeof(cryptopro_ext)); + ret += sizeof(cryptopro_ext); } # ifndef OPENSSL_NO_HEARTBEATS /* Add Heartbeat extension if we've received one */ if (s->tlsext_heartbeat & SSL_TLSEXT_HB_ENABLED) { - if ((limit - ret - 4 - 1) < 0) + /*- + * check for enough space. + * 4 bytes for the Heartbeat type and extension length + * 1 byte for the mode + */ + if (CHECKLEN(ret, 5, limit)) return NULL; s2n(TLSEXT_TYPE_heartbeat, ret); s2n(1, ret); @@ -1789,7 +1879,12 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, s-> ctx->next_protos_advertised_cb_arg); if (r == SSL_TLSEXT_ERR_OK) { - if ((long)(limit - ret - 4 - npalen) < 0) + /*- + * check for enough space. + * 4 bytes for the NPN type and extension length + * + length of protocols list + */ + if (CHECKLEN(ret, 4 + npalen, limit)) return NULL; s2n(TLSEXT_TYPE_next_proto_neg, ret); s2n(npalen, ret); @@ -1804,9 +1899,16 @@ unsigned char *ssl_add_serverhello_tlsext(SSL *s, unsigned char *buf, if (s->s3->alpn_selected) { const unsigned char *selected = s->s3->alpn_selected; - unsigned len = s->s3->alpn_selected_len; + size_t len = s->s3->alpn_selected_len; - if ((long)(limit - ret - 4 - 2 - 1 - len) < 0) + /*- + * check for enough space. + * 4 bytes for the ALPN type and extension length + * 2 bytes for ALPN data length + * 1 byte for selected protocol length + * + length of the selected protocol + */ + if (CHECKLEN(ret, 7 + len, limit)) return NULL; s2n(TLSEXT_TYPE_application_layer_protocol_negotiation, ret); s2n(3 + len, ret); @@ -1966,11 +2068,10 @@ static int tls1_alpn_handle_client_hello(SSL *s, const unsigned char *data, /* * Process the ALPN extension in a ClientHello. - * ret: a pointer to the TLSEXT return value: SSL_TLSEXT_ERR_* * al: a pointer to the alert value to send in the event of a failure. - * returns 1 on success, 0 on failure: al/ret set only on failure + * returns 1 on success, 0 on failure: al set only on failure */ -static int tls1_alpn_handle_client_hello_late(SSL *s, int *ret, int *al) +static int tls1_alpn_handle_client_hello_late(SSL *s, int *al) { const unsigned char *selected = NULL; unsigned char selected_len = 0; @@ -1986,7 +2087,6 @@ static int tls1_alpn_handle_client_hello_late(SSL *s, int *ret, int *al) s->s3->alpn_selected = OPENSSL_malloc(selected_len); if (s->s3->alpn_selected == NULL) { *al = SSL_AD_INTERNAL_ERROR; - *ret = SSL_TLSEXT_ERR_ALERT_FATAL; return 0; } memcpy(s->s3->alpn_selected, selected, selected_len); @@ -3064,10 +3164,12 @@ int tls1_set_server_sigalgs(SSL *s) return 0; } -int ssl_check_clienthello_tlsext_late(SSL *s) +/* + * Upon success, returns 1. + * Upon failure, returns 0 and sets |al| to the appropriate fatal alert. + */ +int ssl_check_clienthello_tlsext_late(SSL *s, int *al) { - int ret = SSL_TLSEXT_ERR_OK; - int al; /* * If status request then ask callback what to do. Note: this must be @@ -3076,58 +3178,41 @@ int ssl_check_clienthello_tlsext_late(SSL *s) * influence which certificate is sent */ if ((s->tlsext_status_type != -1) && s->ctx && s->ctx->tlsext_status_cb) { - int r; + int ret; CERT_PKEY *certpkey; certpkey = ssl_get_server_send_pkey(s); /* If no certificate can't return certificate status */ - if (certpkey == NULL) { - s->tlsext_status_expected = 0; - return 1; - } - /* - * Set current certificate to one we will use so SSL_get_certificate - * et al can pick it up. - */ - s->cert->key = certpkey; - r = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg); - switch (r) { - /* We don't want to send a status request response */ - case SSL_TLSEXT_ERR_NOACK: - s->tlsext_status_expected = 0; - break; - /* status request response should be sent */ - case SSL_TLSEXT_ERR_OK: - if (s->tlsext_ocsp_resp) - s->tlsext_status_expected = 1; - else + if (certpkey != NULL) { + /* + * Set current certificate to one we will use so SSL_get_certificate + * et al can pick it up. + */ + s->cert->key = certpkey; + ret = s->ctx->tlsext_status_cb(s, s->ctx->tlsext_status_arg); + switch (ret) { + /* We don't want to send a status request response */ + case SSL_TLSEXT_ERR_NOACK: s->tlsext_status_expected = 0; - break; - /* something bad happened */ - case SSL_TLSEXT_ERR_ALERT_FATAL: - ret = SSL_TLSEXT_ERR_ALERT_FATAL; - al = SSL_AD_INTERNAL_ERROR; - goto err; + break; + /* status request response should be sent */ + case SSL_TLSEXT_ERR_OK: + if (s->tlsext_ocsp_resp) + s->tlsext_status_expected = 1; + break; + /* something bad happened */ + case SSL_TLSEXT_ERR_ALERT_FATAL: + default: + *al = SSL_AD_INTERNAL_ERROR; + return 0; + } } - } else - s->tlsext_status_expected = 0; - - if (!tls1_alpn_handle_client_hello_late(s, &ret, &al)) { - goto err; } - err: - switch (ret) { - case SSL_TLSEXT_ERR_ALERT_FATAL: - ssl3_send_alert(s, SSL3_AL_FATAL, al); - return -1; - - case SSL_TLSEXT_ERR_ALERT_WARNING: - ssl3_send_alert(s, SSL3_AL_WARNING, al); - return 1; - - default: - return 1; + if (!tls1_alpn_handle_client_hello_late(s, al)) { + return 0; } + + return 1; } int ssl_check_serverhello_tlsext(SSL *s) diff --git a/deps/openssl/openssl/util/domd b/deps/openssl/openssl/util/domd index 95bb1b06e25786..bc2a85f7dd5076 100755 --- a/deps/openssl/openssl/util/domd +++ b/deps/openssl/openssl/util/domd @@ -11,7 +11,9 @@ if [ "$1" = "-MD" ]; then fi if [ "$MAKEDEPEND" = "" ]; then MAKEDEPEND=makedepend; fi -cp Makefile Makefile.save +# Preserve Makefile timestamp by moving instead of copying (cp -p is GNU only) +mv Makefile Makefile.save +cp Makefile.save Makefile # fake the presence of Kerberos touch $TOP/krb5.h if ${MAKEDEPEND} --version 2>&1 | grep "clang" > /dev/null || @@ -32,7 +34,12 @@ else ${PERL} $TOP/util/clean-depend.pl < Makefile > Makefile.new RC=$? fi -mv Makefile.new Makefile +if ! cmp -s Makefile.save Makefile.new; then + mv Makefile.new Makefile +else + mv Makefile.save Makefile + rm -f Makefile.new +fi # unfake the presence of Kerberos rm $TOP/krb5.h diff --git a/deps/openssl/openssl/util/mklink.pl b/deps/openssl/openssl/util/mklink.pl index 61db12c68f3156..a937606ea5c231 100755 --- a/deps/openssl/openssl/util/mklink.pl +++ b/deps/openssl/openssl/util/mklink.pl @@ -55,9 +55,11 @@ foreach $file (@files) { my $err = ""; if ($symlink_exists) { - unlink "$from/$file"; - symlink("$to/$file", "$from/$file") or $err = " [$!]"; - } else { + if (!-l "$from/$file") { + unlink "$from/$file"; + symlink("$to/$file", "$from/$file") or $err = " [$!]"; + } + } elsif (-d "$from" && (!-f "$from/$file" || ((stat("$file"))[9] > (stat("$from/$file"))[9]))) { unlink "$from/$file"; open (OLD, "<$file") or die "Can't open $file: $!"; open (NEW, ">$from/$file") or die "Can't open $from/$file: $!"; diff --git a/deps/uv/AUTHORS b/deps/uv/AUTHORS index 50916c67cdc30a..49c8e17f23b35c 100644 --- a/deps/uv/AUTHORS +++ b/deps/uv/AUTHORS @@ -278,3 +278,4 @@ Brad King Philippe Laferriere Will Speak Hitesh Kanwathirtha +Eric Sciple diff --git a/deps/uv/ChangeLog b/deps/uv/ChangeLog index b6f89af51f40bf..d865f22667ec39 100644 --- a/deps/uv/ChangeLog +++ b/deps/uv/ChangeLog @@ -1,3 +1,31 @@ +2017.01.10, Version 1.10.2 (Stable), cb9f579a454b8db592030ffa274ae58df78dbe20 + +Changes since version 1.10.1: + +* Now working on version 1.10.2 (cjihrig) + +* darwin: fix fsync and fdatasync (Joran Dirk Greef) + +* Revert "Revert "win,tty: add support for ANSI codes in win10 v1511"" + (Santiago Gimeno) + +* win,tty: fix MultiByteToWideChar output buffer (Santiago Gimeno) + +* win: remove dead code related to BACKUP_SEMANTICS (Sam Roberts) + +* win: fix comment in quote_cmd_arg (Eric Sciple) + +* darwin: use clock_gettime in macOS 10.12 (Saúl Ibarra Corretgé) + +* win, tty: fix crash on restarting with pending data (Nicholas Vavilov) + +* fs: fix uv__to_stat on BSD platforms (Santiago Gimeno) + +* win: map ERROR_ELEVATION_REQUIRED to UV_EACCES (Richard Lau) + +* win: fix free() on bad input in uv_getaddrinfo() (Ben Noordhuis) + + 2016.11.17, Version 1.10.1 (Stable), 2e49e332bdede6db7cf17fa784a902e8386d5d86 Changes since version 1.10.0: diff --git a/deps/uv/appveyor.yml b/deps/uv/appveyor.yml index 6b785611536c39..63294137833fb7 100644 --- a/deps/uv/appveyor.yml +++ b/deps/uv/appveyor.yml @@ -1,4 +1,4 @@ -version: v1.10.1.build{build} +version: v1.10.2.build{build} install: - cinst -y nsis diff --git a/deps/uv/configure.ac b/deps/uv/configure.ac index d3787c0d6dd9f7..abaf971772ffe7 100644 --- a/deps/uv/configure.ac +++ b/deps/uv/configure.ac @@ -13,7 +13,7 @@ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. AC_PREREQ(2.57) -AC_INIT([libuv], [1.10.1], [https://github.com/libuv/libuv/issues]) +AC_INIT([libuv], [1.10.2], [https://github.com/libuv/libuv/issues]) AC_CONFIG_MACRO_DIR([m4]) m4_include([m4/libuv-extra-automake-flags.m4]) m4_include([m4/as_case.m4]) diff --git a/deps/uv/include/uv-version.h b/deps/uv/include/uv-version.h index 63454a5d0aee39..99f7eb8c1fae1d 100644 --- a/deps/uv/include/uv-version.h +++ b/deps/uv/include/uv-version.h @@ -32,7 +32,7 @@ #define UV_VERSION_MAJOR 1 #define UV_VERSION_MINOR 10 -#define UV_VERSION_PATCH 1 +#define UV_VERSION_PATCH 2 #define UV_VERSION_IS_RELEASE 1 #define UV_VERSION_SUFFIX "" diff --git a/deps/uv/src/unix/darwin.c b/deps/uv/src/unix/darwin.c index cf95da21693b9a..b1ffbc37b47b78 100644 --- a/deps/uv/src/unix/darwin.c +++ b/deps/uv/src/unix/darwin.c @@ -34,8 +34,12 @@ #include /* _NSGetExecutablePath */ #include #include +#include #include /* sysconf */ +#undef NANOSEC +#define NANOSEC ((uint64_t) 1e9) + int uv__platform_loop_init(uv_loop_t* loop) { loop->cf_state = NULL; @@ -53,6 +57,11 @@ void uv__platform_loop_delete(uv_loop_t* loop) { uint64_t uv__hrtime(uv_clocktype_t type) { +#ifdef MAC_OS_X_VERSION_10_12 + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + return (((uint64_t) ts.tv_sec) * NANOSEC + ts.tv_nsec); +#else static mach_timebase_info_data_t info; if ((ACCESS_ONCE(uint32_t, info.numer) == 0 || @@ -61,6 +70,7 @@ uint64_t uv__hrtime(uv_clocktype_t type) { abort(); return mach_absolute_time() * info.numer / info.denom; +#endif } diff --git a/deps/uv/src/unix/fs.c b/deps/uv/src/unix/fs.c index 3d478b790e6c5a..e047b671651466 100644 --- a/deps/uv/src/unix/fs.c +++ b/deps/uv/src/unix/fs.c @@ -129,8 +129,23 @@ static ssize_t uv__fs_fdatasync(uv_fs_t* req) { #if defined(__linux__) || defined(__sun) || defined(__NetBSD__) return fdatasync(req->file); -#elif defined(__APPLE__) && defined(SYS_fdatasync) - return syscall(SYS_fdatasync, req->file); +#elif defined(__APPLE__) + /* Apple's fdatasync and fsync explicitly do NOT flush the drive write cache + * to the drive platters. This is in contrast to Linux's fdatasync and fsync + * which do, according to recent man pages. F_FULLFSYNC is Apple's equivalent + * for flushing buffered data to permanent storage. + */ + return fcntl(req->file, F_FULLFSYNC); +#else + return fsync(req->file); +#endif +} + + +static ssize_t uv__fs_fsync(uv_fs_t* req) { +#if defined(__APPLE__) + /* See the comment in uv__fs_fdatasync. */ + return fcntl(req->file, F_FULLFSYNC); #else return fsync(req->file); #endif @@ -798,6 +813,10 @@ static void uv__to_stat(struct stat* src, uv_stat_t* dst) { dst->st_flags = 0; dst->st_gen = 0; #elif !defined(_AIX) && ( \ + defined(__DragonFly__) || \ + defined(__FreeBSD__) || \ + defined(__OpenBSD__) || \ + defined(__NetBSD__) || \ defined(_GNU_SOURCE) || \ defined(_BSD_SOURCE) || \ defined(_SVID_SOURCE) || \ @@ -809,9 +828,7 @@ static void uv__to_stat(struct stat* src, uv_stat_t* dst) { dst->st_mtim.tv_nsec = src->st_mtim.tv_nsec; dst->st_ctim.tv_sec = src->st_ctim.tv_sec; dst->st_ctim.tv_nsec = src->st_ctim.tv_nsec; -# if defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__OpenBSD__) || \ +# if defined(__FreeBSD__) || \ defined(__NetBSD__) dst->st_birthtim.tv_sec = src->st_birthtim.tv_sec; dst->st_birthtim.tv_nsec = src->st_birthtim.tv_nsec; @@ -945,7 +962,7 @@ static void uv__fs_work(struct uv__work* w) { X(FCHOWN, fchown(req->file, req->uid, req->gid)); X(FDATASYNC, uv__fs_fdatasync(req)); X(FSTAT, uv__fs_fstat(req->file, &req->statbuf)); - X(FSYNC, fsync(req->file)); + X(FSYNC, uv__fs_fsync(req)); X(FTRUNCATE, ftruncate(req->file, req->off)); X(FUTIME, uv__fs_futime(req)); X(LSTAT, uv__fs_lstat(req->path, &req->statbuf)); diff --git a/deps/uv/src/win/error.c b/deps/uv/src/win/error.c index c512f35af979a3..642d1112e11928 100644 --- a/deps/uv/src/win/error.c +++ b/deps/uv/src/win/error.c @@ -71,6 +71,7 @@ int uv_translate_sys_error(int sys_errno) { switch (sys_errno) { case ERROR_NOACCESS: return UV_EACCES; case WSAEACCES: return UV_EACCES; + case ERROR_ELEVATION_REQUIRED: return UV_EACCES; case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE; case WSAEADDRINUSE: return UV_EADDRINUSE; case WSAEADDRNOTAVAIL: return UV_EADDRNOTAVAIL; diff --git a/deps/uv/src/win/fs.c b/deps/uv/src/win/fs.c index dc0ac89a35293e..6902d4f1a69485 100644 --- a/deps/uv/src/win/fs.c +++ b/deps/uv/src/win/fs.c @@ -403,7 +403,6 @@ void fs__open(uv_fs_t* req) { switch (flags & (_O_RDONLY | _O_WRONLY | _O_RDWR)) { case _O_RDONLY: access = FILE_GENERIC_READ; - attributes |= FILE_FLAG_BACKUP_SEMANTICS; break; case _O_WRONLY: access = FILE_GENERIC_WRITE; @@ -418,7 +417,6 @@ void fs__open(uv_fs_t* req) { if (flags & _O_APPEND) { access &= ~FILE_WRITE_DATA; access |= FILE_APPEND_DATA; - attributes &= ~FILE_FLAG_BACKUP_SEMANTICS; } /* diff --git a/deps/uv/src/win/getaddrinfo.c b/deps/uv/src/win/getaddrinfo.c index 744f8e02629ccd..c13bfec350f27e 100644 --- a/deps/uv/src/win/getaddrinfo.c +++ b/deps/uv/src/win/getaddrinfo.c @@ -262,8 +262,7 @@ int uv_getaddrinfo(uv_loop_t* loop, int err; if (req == NULL || (node == NULL && service == NULL)) { - err = WSAEINVAL; - goto error; + return UV_EINVAL; } uv_req_init(loop, (uv_req_t*)req); diff --git a/deps/uv/src/win/process.c b/deps/uv/src/win/process.c index 855c3740816db2..bdf88d2cdd944c 100644 --- a/deps/uv/src/win/process.c +++ b/deps/uv/src/win/process.c @@ -492,7 +492,7 @@ WCHAR* quote_cmd_arg(const WCHAR *source, WCHAR *target) { * input : hello\\"world * output: "hello\\\\\"world" * input : hello world\ - * output: "hello world\" + * output: "hello world\\" */ *(target++) = L'"'; diff --git a/deps/uv/src/win/tty.c b/deps/uv/src/win/tty.c index 76dc2fab8aa3c7..1b7adf64ffcbdb 100644 --- a/deps/uv/src/win/tty.c +++ b/deps/uv/src/win/tty.c @@ -56,7 +56,11 @@ #define ANSI_BACKSLASH_SEEN 0x80 #define MAX_INPUT_BUFFER_LENGTH 8192 +#define MAX_CONSOLE_CHAR 8192 +#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING +#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004 +#endif static void uv_tty_capture_initial_style(CONSOLE_SCREEN_BUFFER_INFO* info); static void uv_tty_update_virtual_window(CONSOLE_SCREEN_BUFFER_INFO* info); @@ -125,6 +129,14 @@ static char uv_tty_default_fg_bright = 0; static char uv_tty_default_bg_bright = 0; static char uv_tty_default_inverse = 0; +typedef enum { + UV_SUPPORTED, + UV_UNCHECKED, + UV_UNSUPPORTED +} uv_vtermstate_t; +/* Determine whether or not ANSI support is enabled. */ +static uv_vtermstate_t uv__vterm_state = UV_UNCHECKED; +static void uv__determine_vterm_state(HANDLE handle); void uv_console_init() { if (uv_sem_init(&uv_tty_output_lock, 1)) @@ -168,6 +180,9 @@ int uv_tty_init(uv_loop_t* loop, uv_tty_t* tty, uv_file fd, int readable) { /* shared between all uv_tty_t handles. */ uv_sem_wait(&uv_tty_output_lock); + if (uv__vterm_state == UV_UNCHECKED) + uv__determine_vterm_state(handle); + /* Store the global tty output handle. This handle is used by TTY read */ /* streams to update the virtual window when a CONSOLE_BUFFER_SIZE_EVENT */ /* is received. */ @@ -989,6 +1004,9 @@ int uv_tty_read_start(uv_tty_t* handle, uv_alloc_cb alloc_cb, if (handle->tty.rd.last_key_len > 0) { SET_REQ_SUCCESS(&handle->read_req); uv_insert_pending_req(handle->loop, (uv_req_t*) &handle->read_req); + /* Make sure no attempt is made to insert it again until it's handled. */ + handle->flags |= UV_HANDLE_READ_PENDING; + handle->reqs_pending++; return 0; } @@ -1602,17 +1620,29 @@ static int uv_tty_write_bufs(uv_tty_t* handle, DWORD* error) { /* We can only write 8k characters at a time. Windows can't handle */ /* much more characters in a single console write anyway. */ - WCHAR utf16_buf[8192]; + WCHAR utf16_buf[MAX_CONSOLE_CHAR]; + WCHAR* utf16_buffer; DWORD utf16_buf_used = 0; - unsigned int i; - -#define FLUSH_TEXT() \ - do { \ - if (utf16_buf_used > 0) { \ - uv_tty_emit_text(handle, utf16_buf, utf16_buf_used, error); \ - utf16_buf_used = 0; \ - } \ - } while (0) + unsigned int i, len, max_len, pos; + int allocate = 0; + +#define FLUSH_TEXT() \ + do { \ + pos = 0; \ + do { \ + len = utf16_buf_used - pos; \ + if (len > MAX_CONSOLE_CHAR) \ + len = MAX_CONSOLE_CHAR; \ + uv_tty_emit_text(handle, &utf16_buffer[pos], len, error); \ + pos += len; \ + } while (pos < utf16_buf_used); \ + if (allocate) { \ + uv__free(utf16_buffer); \ + allocate = 0; \ + utf16_buffer = utf16_buf; \ + } \ + utf16_buf_used = 0; \ + } while (0) #define ENSURE_BUFFER_SPACE(wchars_needed) \ if (wchars_needed > ARRAY_SIZE(utf16_buf) - utf16_buf_used) { \ @@ -1630,12 +1660,48 @@ static int uv_tty_write_bufs(uv_tty_t* handle, /* state. */ *error = ERROR_SUCCESS; + utf16_buffer = utf16_buf; + uv_sem_wait(&uv_tty_output_lock); for (i = 0; i < nbufs; i++) { uv_buf_t buf = bufs[i]; unsigned int j; + if (uv__vterm_state == UV_SUPPORTED && buf.len > 0) { + utf16_buf_used = MultiByteToWideChar(CP_UTF8, + 0, + buf.base, + buf.len, + NULL, + 0); + + if (utf16_buf_used == 0) { + *error = GetLastError(); + break; + } + + max_len = (utf16_buf_used + 1) * sizeof(WCHAR); + allocate = max_len > MAX_CONSOLE_CHAR; + if (allocate) + utf16_buffer = uv__malloc(max_len); + if (!MultiByteToWideChar(CP_UTF8, + 0, + buf.base, + buf.len, + utf16_buffer, + utf16_buf_used)) { + if (allocate) + uv__free(utf16_buffer); + *error = GetLastError(); + break; + } + + FLUSH_TEXT(); + + continue; + } + for (j = 0; j < buf.len; j++) { unsigned char c = buf.base[j]; @@ -2193,3 +2259,24 @@ int uv_tty_reset_mode(void) { /* Not necessary to do anything. */ return 0; } + +/* Determine whether or not this version of windows supports + * proper ANSI color codes. Should be supported as of windows + * 10 version 1511, build number 10.0.10586. + */ +static void uv__determine_vterm_state(HANDLE handle) { + DWORD dwMode = 0; + + if (!GetConsoleMode(handle, &dwMode)) { + uv__vterm_state = UV_UNSUPPORTED; + return; + } + + dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + if (!SetConsoleMode(handle, dwMode)) { + uv__vterm_state = UV_UNSUPPORTED; + return; + } + + uv__vterm_state = UV_SUPPORTED; +} diff --git a/deps/uv/test/test-error.c b/deps/uv/test/test-error.c index 4c4efa30cddd4b..ff53eb1d777903 100644 --- a/deps/uv/test/test-error.c +++ b/deps/uv/test/test-error.c @@ -53,6 +53,7 @@ TEST_IMPL(error_message) { TEST_IMPL(sys_error) { #if defined(_WIN32) ASSERT(uv_translate_sys_error(ERROR_NOACCESS) == UV_EACCES); + ASSERT(uv_translate_sys_error(ERROR_ELEVATION_REQUIRED) == UV_EACCES); ASSERT(uv_translate_sys_error(WSAEADDRINUSE) == UV_EADDRINUSE); ASSERT(uv_translate_sys_error(ERROR_BAD_PIPE) == UV_EPIPE); #else diff --git a/deps/uv/test/test-fs.c b/deps/uv/test/test-fs.c index 06718f285ed7ae..70a23999624741 100644 --- a/deps/uv/test/test-fs.c +++ b/deps/uv/test/test-fs.c @@ -1141,11 +1141,15 @@ TEST_IMPL(fs_fstat) { ASSERT(s->st_mtim.tv_nsec == t.st_mtimensec); ASSERT(s->st_ctim.tv_sec == t.st_ctime); ASSERT(s->st_ctim.tv_nsec == t.st_ctimensec); -#elif defined(__sun) || \ - defined(_GNU_SOURCE) || \ - defined(_BSD_SOURCE) || \ - defined(_SVID_SOURCE) || \ - defined(_XOPEN_SOURCE) || \ +#elif defined(__sun) || \ + defined(__DragonFly__) || \ + defined(__FreeBSD__) || \ + defined(__OpenBSD__) || \ + defined(__NetBSD__) || \ + defined(_GNU_SOURCE) || \ + defined(_BSD_SOURCE) || \ + defined(_SVID_SOURCE) || \ + defined(_XOPEN_SOURCE) || \ defined(_DEFAULT_SOURCE) ASSERT(s->st_atim.tv_sec == t.st_atim.tv_sec); ASSERT(s->st_atim.tv_nsec == t.st_atim.tv_nsec); @@ -1153,10 +1157,8 @@ TEST_IMPL(fs_fstat) { ASSERT(s->st_mtim.tv_nsec == t.st_mtim.tv_nsec); ASSERT(s->st_ctim.tv_sec == t.st_ctim.tv_sec); ASSERT(s->st_ctim.tv_nsec == t.st_ctim.tv_nsec); -# if defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) +# if defined(__FreeBSD__) || \ + defined(__NetBSD__) ASSERT(s->st_birthtim.tv_sec == t.st_birthtim.tv_sec); ASSERT(s->st_birthtim.tv_nsec == t.st_birthtim.tv_nsec); ASSERT(s->st_flags == t.st_flags); diff --git a/deps/uv/test/test-getaddrinfo.c b/deps/uv/test/test-getaddrinfo.c index 6b644a8d442a3a..03dc126956162c 100644 --- a/deps/uv/test/test-getaddrinfo.c +++ b/deps/uv/test/test-getaddrinfo.c @@ -83,6 +83,13 @@ static void getaddrinfo_cuncurrent_cb(uv_getaddrinfo_t* handle, TEST_IMPL(getaddrinfo_fail) { uv_getaddrinfo_t req; + ASSERT(UV_EINVAL == uv_getaddrinfo(uv_default_loop(), + &req, + (uv_getaddrinfo_cb) abort, + NULL, + NULL, + NULL)); + /* Use a FQDN by ending in a period */ ASSERT(0 == uv_getaddrinfo(uv_default_loop(), &req, diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index 08886a6f4a5b31..be3f9069cc7779 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -47,6 +47,8 @@ TEST_DECLARE (semaphore_3) TEST_DECLARE (tty) #ifdef _WIN32 TEST_DECLARE (tty_raw) +TEST_DECLARE (tty_empty_write) +TEST_DECLARE (tty_large_write) #endif TEST_DECLARE (tty_file) TEST_DECLARE (tty_pty) @@ -404,6 +406,8 @@ TASK_LIST_START TEST_ENTRY (tty) #ifdef _WIN32 TEST_ENTRY (tty_raw) + TEST_ENTRY (tty_empty_write) + TEST_ENTRY (tty_large_write) #endif TEST_ENTRY (tty_file) TEST_ENTRY (tty_pty) diff --git a/deps/uv/test/test-tty.c b/deps/uv/test/test-tty.c index d03f07a4418e49..d1f7deb2319e44 100644 --- a/deps/uv/test/test-tty.c +++ b/deps/uv/test/test-tty.c @@ -212,6 +212,93 @@ TEST_IMPL(tty_raw) { MAKE_VALGRIND_HAPPY(); return 0; } + +TEST_IMPL(tty_empty_write) { + int r; + int ttyout_fd; + uv_tty_t tty_out; + char dummy[1]; + uv_buf_t bufs[1]; + uv_loop_t* loop; + + /* Make sure we have an FD that refers to a tty */ + HANDLE handle; + + loop = uv_default_loop(); + + handle = CreateFileA("conout$", + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + ASSERT(handle != INVALID_HANDLE_VALUE); + ttyout_fd = _open_osfhandle((intptr_t) handle, 0); + + ASSERT(ttyout_fd >= 0); + + ASSERT(UV_TTY == uv_guess_handle(ttyout_fd)); + + r = uv_tty_init(uv_default_loop(), &tty_out, ttyout_fd, 0); /* Writable. */ + ASSERT(r == 0); + + bufs[0].len = 0; + bufs[0].base = &dummy; + + r = uv_try_write((uv_stream_t*) &tty_out, bufs, 1); + ASSERT(r == 0); + + uv_close((uv_handle_t*) &tty_out, NULL); + + uv_run(loop, UV_RUN_DEFAULT); + + MAKE_VALGRIND_HAPPY(); + return 0; +} + +TEST_IMPL(tty_large_write) { + int r; + int ttyout_fd; + uv_tty_t tty_out; + char dummy[10000]; + uv_buf_t bufs[1]; + uv_loop_t* loop; + + /* Make sure we have an FD that refers to a tty */ + HANDLE handle; + + loop = uv_default_loop(); + + handle = CreateFileA("conout$", + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + ASSERT(handle != INVALID_HANDLE_VALUE); + ttyout_fd = _open_osfhandle((intptr_t) handle, 0); + + ASSERT(ttyout_fd >= 0); + + ASSERT(UV_TTY == uv_guess_handle(ttyout_fd)); + + r = uv_tty_init(uv_default_loop(), &tty_out, ttyout_fd, 0); /* Writable. */ + ASSERT(r == 0); + + bufs[0] = uv_buf_init(dummy, sizeof(dummy)); + + r = uv_try_write((uv_stream_t*) &tty_out, bufs, 1); + ASSERT(r == 10000); + + uv_close((uv_handle_t*) &tty_out, NULL); + + uv_run(loop, UV_RUN_DEFAULT); + + MAKE_VALGRIND_HAPPY(); + return 0; +} #endif diff --git a/deps/v8/include/v8-version.h b/deps/v8/include/v8-version.h index 009a3b10425ee4..bb16d9543b8564 100644 --- a/deps/v8/include/v8-version.h +++ b/deps/v8/include/v8-version.h @@ -11,7 +11,7 @@ #define V8_MAJOR_VERSION 5 #define V8_MINOR_VERSION 4 #define V8_BUILD_NUMBER 500 -#define V8_PATCH_LEVEL 45 +#define V8_PATCH_LEVEL 48 // Use 1 for candidates and 0 otherwise. // (Boolean macro values are not supported by all preprocessors.) diff --git a/deps/v8/src/debug/debug.cc b/deps/v8/src/debug/debug.cc index cce167f942934f..ad6cfa02887b02 100644 --- a/deps/v8/src/debug/debug.cc +++ b/deps/v8/src/debug/debug.cc @@ -935,7 +935,7 @@ void Debug::PrepareStepOnThrow() { it.Advance(); } - if (last_step_action() == StepNext) { + if (last_step_action() == StepNext || last_step_action() == StepOut) { while (!it.done()) { Address current_fp = it.frame()->UnpaddedFP(); if (current_fp >= thread_local_.target_fp_) break; diff --git a/deps/v8/src/objects.cc b/deps/v8/src/objects.cc index 00721c2d1bbe1b..2931bd14a9b8de 100644 --- a/deps/v8/src/objects.cc +++ b/deps/v8/src/objects.cc @@ -3449,9 +3449,16 @@ void MigrateFastToSlow(Handle object, Handle new_map, // Ensure that in-object space of slow-mode object does not contain random // garbage. int inobject_properties = new_map->GetInObjectProperties(); - for (int i = 0; i < inobject_properties; i++) { - FieldIndex index = FieldIndex::ForPropertyIndex(*new_map, i); - object->RawFastPropertyAtPut(index, Smi::FromInt(0)); + if (inobject_properties) { + Heap* heap = isolate->heap(); + heap->ClearRecordedSlotRange( + object->address() + map->GetInObjectPropertyOffset(0), + object->address() + new_instance_size); + + for (int i = 0; i < inobject_properties; i++) { + FieldIndex index = FieldIndex::ForPropertyIndex(*new_map, i); + object->RawFastPropertyAtPut(index, Smi::FromInt(0)); + } } isolate->counters()->props_to_dictionary()->Increment(); diff --git a/deps/v8/src/runtime/runtime-i18n.cc b/deps/v8/src/runtime/runtime-i18n.cc index 8b9d92ec006eb5..c5577dadaf651f 100644 --- a/deps/v8/src/runtime/runtime-i18n.cc +++ b/deps/v8/src/runtime/runtime-i18n.cc @@ -931,7 +931,7 @@ inline uint16_t ToASCIIUpper(uint16_t ch) { inline uint16_t ToLatin1Upper(uint16_t ch) { DCHECK(ch != 0xDF && ch != 0xB5 && ch != 0xFF); return ch & - ~(((ch >= 'a' && ch <= 'z') || (((ch & 0xE0) == 0xE0) && ch != 0xE7)) + ~(((ch >= 'a' && ch <= 'z') || (((ch & 0xE0) == 0xE0) && ch != 0xF7)) << 5); } diff --git a/deps/v8/test/intl/general/case-mapping.js b/deps/v8/test/intl/general/case-mapping.js index a73622bf0deb9c..17eb5bae57bf02 100644 --- a/deps/v8/test/intl/general/case-mapping.js +++ b/deps/v8/test/intl/general/case-mapping.js @@ -136,3 +136,29 @@ assertEquals("\u{10CC0}", "\u{10C80}".toLocaleLowerCase()); assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase(["tr"])); assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase(["tr"])); assertEquals("\u{10CC0}", "\u{10C80}".toLocaleLowerCase()); + +// check fast path for Latin-1 supplement (U+00A0 ~ U+00FF) +var latin1Suppl = "\u00A0¡¢£¤¥¦§¨©ª«¬\u00AD®°±²³´µ¶·¸¹º»¼½¾¿" + + "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"; +var latin1SupplLowercased = "\u00A0¡¢£¤¥¦§¨©ª«¬\u00AD®°±²³´µ¶·¸¹º»¼½¾¿" + + "àáâãäåæçèéêëìíîïðñòóôõö×øùúûüýþßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"; +var latin1SupplUppercased = "\u00A0¡¢£¤¥¦§¨©ª«¬\u00AD®°±²³´\u039C¶·¸¹º»¼½¾¿" + + "ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞSSÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ÷ØÙÚÛÜÝÞ\u0178"; + +assertEquals(latin1SupplLowercased, latin1Suppl.toLowerCase()); +assertEquals(latin1SupplUppercased, latin1Suppl.toUpperCase()); +assertEquals(latin1SupplLowercased, latin1Suppl.toLocaleLowerCase("de")); +assertEquals(latin1SupplUppercased, latin1Suppl.toLocaleUpperCase("de")); +assertEquals(latin1SupplLowercased, latin1Suppl.toLocaleLowerCase("el")); +assertEquals(latin1SupplUppercased, latin1Suppl.toLocaleUpperCase("el")); +assertEquals(latin1SupplUppercased, latin1Suppl.toLocaleUpperCase("tr")); +assertEquals(latin1SupplLowercased, latin1Suppl.toLocaleLowerCase("tr")); +assertEquals(latin1SupplUppercased, latin1Suppl.toLocaleUpperCase("az")); +assertEquals(latin1SupplLowercased, latin1Suppl.toLocaleLowerCase("az")); +assertEquals(latin1SupplUppercased, latin1Suppl.toLocaleUpperCase("lt")); +// Lithuanian need to have a dot-above for U+00CC(Ì) and U+00CD(Í) when +// lowercasing. +assertEquals("\u00A0¡¢£¤¥¦§¨©ª«¬\u00AD®°±²³´µ¶·¸¹º»¼½¾¿" + + "àáâãäåæçèéêëi\u0307\u0300i\u0307\u0301îïðñòóôõö×øùúûüýþß" + + "àáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ", + latin1Suppl.toLocaleLowerCase("lt")); diff --git a/deps/v8/test/mjsunit/mjsunit.status b/deps/v8/test/mjsunit/mjsunit.status index d610fce4303363..c30ed3d0a6bb44 100644 --- a/deps/v8/test/mjsunit/mjsunit.status +++ b/deps/v8/test/mjsunit/mjsunit.status @@ -835,4 +835,13 @@ 'regress/regress-crbug-514081': [PASS, NO_VARIANTS], }], # ALWAYS +############################################################################## +# This test allocates a 2G block of memory and if there are multiple +# varients this leads kills by the OOM killer, crashes or messages +# indicating the OS cannot allocate memory, exclude for Node.js runs +# re-evalute when we move up to v8 5.1 +[ALWAYS, { +'regress/regress-crbug-514081': [PASS, NO_VARIANTS], +}], # ALWAYS + ] diff --git a/deps/v8/test/mjsunit/regress/regress-5559.js b/deps/v8/test/mjsunit/regress/regress-5559.js new file mode 100644 index 00000000000000..c6f32575f55b9b --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-5559.js @@ -0,0 +1,38 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-debug-as debug + +Debug = debug.Debug + +var exception = null; +var break_count = 0; + +function listener(event, exec_state, event_data, data) { + if (event != Debug.DebugEvent.Break) return; + try { + print(event_data.sourceLineText()); + assertTrue( + event_data.sourceLineText().indexOf(`Break ${break_count++}.`) > 0); + exec_state.prepareStep(Debug.StepAction.StepOut); + } catch (e) { + exception = e; + } +}; + +function thrower() { + try { + debugger; // Break 0. + throw 'error'; + } catch (err) { + } +} + + +Debug.setListener(listener); +thrower(); +Debug.setListener(null); // Break 1. + +assertNull(exception); +assertEquals(2, break_count); diff --git a/deps/v8/test/mjsunit/regress/regress-666046.js b/deps/v8/test/mjsunit/regress/regress-666046.js new file mode 100644 index 00000000000000..b4615383e0bdae --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-666046.js @@ -0,0 +1,57 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --allow-natives-syntax --expose-gc + +function P() { + this.a0 = {}; + this.a1 = {}; + this.a2 = {}; + this.a3 = {}; + this.a4 = {}; +} + +function A() { +} + +var proto = new P(); +A.prototype = proto; + +function foo(o) { + return o.a0; +} + +// Ensure |proto| is in old space. +gc(); +gc(); +gc(); + +// Ensure |proto| is marked as "should be fast". +var o = new A(); +foo(o); +foo(o); +foo(o); +assertTrue(%HasFastProperties(proto)); + +// Contruct a double value that looks like a tagged pointer. +var buffer = new ArrayBuffer(8); +var int32view = new Int32Array(buffer); +var float64view = new Float64Array(buffer); +int32view[0] = int32view[1] = 0x40000001; +var boom = float64view[0]; + + +// Write new space object. +proto.a4 = {a: 0}; +// Immediately delete the field. +delete proto.a4; + +// |proto| must sill be fast. +assertTrue(%HasFastProperties(proto)); + +// Add a double field instead of deleted a4 that looks like a tagged pointer. +proto.boom = boom; + +// Boom! +gc(); diff --git a/doc/api/buffer.md b/doc/api/buffer.md index b9f8369335a0d6..c9f15b14476083 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -348,15 +348,16 @@ deprecated: v6.0.0 > [`Buffer.from(arrayBuffer[, byteOffset [, length]])`][`Buffer.from(arrayBuffer)`] > instead. -* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a [`TypedArray`] or - [`ArrayBuffer`] -* `byteOffset` {Integer} Where to start copying from `arrayBuffer`. **Default:** `0` -* `length` {Integer} How many bytes to copy from `arrayBuffer`. +* `arrayBuffer` {ArrayBuffer} An [`ArrayBuffer`] or the `.buffer` property of a + [`TypedArray`]. +* `byteOffset` {Integer} Index of first byte to expose. **Default:** `0` +* `length` {Integer} Number of bytes to expose. **Default:** `arrayBuffer.length - byteOffset` -When passed a reference to the `.buffer` property of a [`TypedArray`] instance, -the newly created `Buffer` will share the same allocated memory as the -[`TypedArray`]. +This creates a view of the [`ArrayBuffer`] without copying the underlying +memory. For example, when passed a reference to the `.buffer` property of a +[`TypedArray`] instance, the newly created `Buffer` will share the same +allocated memory as the [`TypedArray`]. The optional `byteOffset` and `length` arguments specify a memory range within the `arrayBuffer` that will be shared by the `Buffer`. @@ -719,15 +720,16 @@ A `TypeError` will be thrown if `array` is not an `Array`. added: v5.10.0 --> -* `arrayBuffer` {ArrayBuffer} The `.buffer` property of a [`TypedArray`] or - [`ArrayBuffer`] -* `byteOffset` {Integer} Where to start copying from `arrayBuffer`. **Default:** `0` -* `length` {Integer} How many bytes to copy from `arrayBuffer`. +* `arrayBuffer` {ArrayBuffer} An [`ArrayBuffer`] or the `.buffer` property of a + [`TypedArray`]. +* `byteOffset` {Integer} Index of first byte to expose. **Default:** `0` +* `length` {Integer} Number of bytes to expose. **Default:** `arrayBuffer.length - byteOffset` -When passed a reference to the `.buffer` property of a [`TypedArray`] instance, -the newly created `Buffer` will share the same allocated memory as the -[`TypedArray`]. +This creates a view of the [`ArrayBuffer`] without copying the underlying +memory. For example, when passed a reference to the `.buffer` property of a +[`TypedArray`] instance, the newly created `Buffer` will share the same +allocated memory as the [`TypedArray`]. Example: @@ -1149,6 +1151,30 @@ console.log(utf16Buffer.indexOf('\u03a3', 0, 'ucs2')); console.log(utf16Buffer.indexOf('\u03a3', -4, 'ucs2')); ``` +If `value` is not a string, number, or `Buffer`, this method will throw a +`TypeError`. If `value` is a number, it will be coerced to a valid byte value, +an integer between 0 and 255. + +If `byteOffset` is not a number, it will be coerced to a number. Any arguments +that coerce to `NaN` or 0, like `{}`, `[]`, `null` or `undefined`, will search +the whole buffer. This behavior matches [`String#indexOf()`]. + +```js +const b = Buffer.from('abcdef'); + +// Passing a value that's a number, but not a valid byte +// Prints: 2, equivalent to searching for 99 or 'c' +console.log(b.indexOf(99.9)); +console.log(b.indexOf(256 + 99)); + +// Passing a byteOffset that coerces to NaN or 0 +// Prints: 1, searching the whole buffer +console.log(b.indexOf('b', undefined)); +console.log(b.indexOf('b', {})); +console.log(b.indexOf('b', null)); +console.log(b.indexOf('b', [])); +``` + ### buf.includes(value[, byteOffset][, encoding]) Process v8 profiler output generated using the v8 option `--prof`. @@ -243,6 +243,24 @@ Load an OpenSSL configuration file on startup. Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is built with `./configure --openssl-fips`. +### `--use-openssl-ca`, `--use-bundled-ca` + + +Use OpenSSL's default CA store or use bundled Mozilla CA store as supplied by +current NodeJS version. The default store is selectable at build-time. + +Using OpenSSL store allows for external modifications of the store. For most +Linux and BSD distributions, this store is maintained by the distribution +maintainers and system administrators. OpenSSL CA store location is dependent on +configuration of the OpenSSL library but this can be altered at runtime using +environmental variables. + +The bundled CA store, as supplied by NodeJS, is a snapshot of Mozilla CA store +that is fixed at release time. It is identical on all supported platforms. + +See `SSL_CERT_DIR` and `SSL_CERT_FILE`. ### `--icu-data-dir=file` + +Indicate the end of node options. Pass the rest of the arguments to the script. +If no script filename or eval/print script is supplied prior to this, then +the next argument will be used as a script filename. + ## Environment Variables ### `NODE_DEBUG=module[,…]` @@ -287,6 +314,13 @@ added: v0.11.15 Data path for ICU (Intl object) data. Will extend linked-in data when compiled with small-icu support. +### `NODE_NO_WARNINGS=1` + + +When set to `1`, process warnings are silenced. + ### `NODE_PRESERVE_SYMLINKS=1` When set to `1`, writes to `stdout` and `stderr` will be non-blocking and @@ -316,6 +350,9 @@ Setting this will void any guarantee that stdio will not be interleaved or dropped at program exit. **Use of this mode is not recommended.** ### `NODE_EXTRA_CA_CERTS=file` + When set, the well known "root" CAs (like VeriSign) will be extended with the extra certificates in `file`. The file should consist of one or more trusted @@ -326,6 +363,24 @@ misformatted, but any errors are otherwise ignored. Note that neither the well known nor extra certificates are used when the `ca` options property is explicitly specified for a TLS or HTTPS client or server. +### `SSL_CERT_DIR=dir` + +If `--use-openssl-ca` is enabled, this overrides and sets OpenSSL's directory +containing trusted certificates. + +Note: Be aware that unless the child environment is explicitly set, this +evironment variable will be inherited by any child processes, and if they use +OpenSSL, it may cause them to trust the same CAs as node. + +### `SSL_CERT_FILE=file` + +If `--use-openssl-ca` is enabled, this overrides and sets OpenSSL's file +containing trusted certificates. + +Note: Be aware that unless the child environment is explicitly set, this +evironment variable will be inherited by any child processes, and if they use +OpenSSL, it may cause them to trust the same CAs as node. + [emit_warning]: process.html#process_process_emitwarning_warning_name_ctor [Buffer]: buffer.html#buffer_buffer [debugger]: debugger.html diff --git a/doc/api/console.md b/doc/api/console.md index 70b452bd84070f..7315ca5192be64 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -79,7 +79,7 @@ const Console = console.Console; Creates a new `Console` by passing one or two writable stream instances. `stdout` is a writable stream to print log or info output. `stderr` -is used for warning or error output. If `stderr` isn't passed, warning and error +is used for warning or error output. If `stderr` is not passed, warning and error output will be sent to `stdout`. ```js diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 7f77d3f940768c..9102f2e89c03c4 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -26,7 +26,7 @@ It is possible for Node.js to be built without including support for the error being thrown. ```js -var crypto; +let crypto; try { crypto = require('crypto'); } catch (err) { @@ -132,9 +132,9 @@ Example: Using `Cipher` objects as streams: const crypto = require('crypto'); const cipher = crypto.createCipher('aes192', 'a password'); -var encrypted = ''; +let encrypted = ''; cipher.on('readable', () => { - var data = cipher.read(); + const data = cipher.read(); if (data) encrypted += data.toString('hex'); }); @@ -166,7 +166,7 @@ Example: Using the [`cipher.update()`][] and [`cipher.final()`][] methods: const crypto = require('crypto'); const cipher = crypto.createCipher('aes192', 'a password'); -var encrypted = cipher.update('some clear text data', 'utf8', 'hex'); +let encrypted = cipher.update('some clear text data', 'utf8', 'hex'); encrypted += cipher.final('hex'); console.log(encrypted); // Prints: ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504 @@ -269,9 +269,9 @@ Example: Using `Decipher` objects as streams: const crypto = require('crypto'); const decipher = crypto.createDecipher('aes192', 'a password'); -var decrypted = ''; +let decrypted = ''; decipher.on('readable', () => { - var data = decipher.read(); + const data = decipher.read(); if (data) decrypted += data.toString('utf8'); }); @@ -280,7 +280,7 @@ decipher.on('end', () => { // Prints: some clear text data }); -var encrypted = 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; +const encrypted = 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; decipher.write(encrypted, 'hex'); decipher.end(); ``` @@ -304,8 +304,8 @@ Example: Using the [`decipher.update()`][] and [`decipher.final()`][] methods: const crypto = require('crypto'); const decipher = crypto.createDecipher('aes192', 'a password'); -var encrypted = 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; -var decrypted = decipher.update(encrypted, 'hex', 'utf8'); +const encrypted = 'ca981be48e90867604588e75d04feabb63cc007a8f8ad89b10616ed84d815504'; +let decrypted = decipher.update(encrypted, 'hex', 'utf8'); decrypted += decipher.final('utf8'); console.log(decrypted); // Prints: some clear text data @@ -402,18 +402,18 @@ const assert = require('assert'); // Generate Alice's keys... const alice = crypto.createDiffieHellman(2048); -const alice_key = alice.generateKeys(); +const aliceKey = alice.generateKeys(); // Generate Bob's keys... const bob = crypto.createDiffieHellman(alice.getPrime(), alice.getGenerator()); -const bob_key = bob.generateKeys(); +const bobKey = bob.generateKeys(); // Exchange and generate the secret... -const alice_secret = alice.computeSecret(bob_key); -const bob_secret = bob.computeSecret(alice_key); +const aliceSecret = alice.computeSecret(bobKey); +const bobSecret = bob.computeSecret(aliceKey); // OK -assert.equal(alice_secret.toString('hex'), bob_secret.toString('hex')); +assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); ``` ### diffieHellman.computeSecret(other_public_key[, input_encoding][, output_encoding]) @@ -531,17 +531,17 @@ const assert = require('assert'); // Generate Alice's keys... const alice = crypto.createECDH('secp521r1'); -const alice_key = alice.generateKeys(); +const aliceKey = alice.generateKeys(); // Generate Bob's keys... const bob = crypto.createECDH('secp521r1'); -const bob_key = bob.generateKeys(); +const bobKey = bob.generateKeys(); // Exchange and generate the secret... -const alice_secret = alice.computeSecret(bob_key); -const bob_secret = bob.computeSecret(alice_key); +const aliceSecret = alice.computeSecret(bobKey); +const bobSecret = bob.computeSecret(aliceKey); -assert(alice_secret, bob_secret); +assert.strictEqual(aliceSecret.toString('hex'), bobSecret.toString('hex')); // OK ``` @@ -648,13 +648,14 @@ alice.setPrivateKey( ); // Bob uses a newly generated cryptographically strong -// pseudorandom key pair bob.generateKeys(); +// pseudorandom key pair +bob.generateKeys(); -const alice_secret = alice.computeSecret(bob.getPublicKey(), null, 'hex'); -const bob_secret = bob.computeSecret(alice.getPublicKey(), null, 'hex'); +const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex'); +const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex'); -// alice_secret and bob_secret should be the same shared secret value -console.log(alice_secret === bob_secret); +// aliceSecret and bobSecret should be the same shared secret value +console.log(aliceSecret === bobSecret); ``` ## Class: Hash @@ -680,7 +681,7 @@ const crypto = require('crypto'); const hash = crypto.createHash('sha256'); hash.on('readable', () => { - var data = hash.read(); + const data = hash.read(); if (data) console.log(data.toString('hex')); // Prints: @@ -763,7 +764,7 @@ const crypto = require('crypto'); const hmac = crypto.createHmac('sha256', 'a secret'); hmac.on('readable', () => { - var data = hmac.read(); + const data = hmac.read(); if (data) console.log(data.toString('hex')); // Prints: @@ -847,8 +848,8 @@ const sign = crypto.createSign('RSA-SHA256'); sign.write('some data to sign'); sign.end(); -const private_key = getPrivateKeySomehow(); -console.log(sign.sign(private_key, 'hex')); +const privateKey = getPrivateKeySomehow(); +console.log(sign.sign(privateKey, 'hex')); // Prints: the calculated signature ``` @@ -860,8 +861,8 @@ const sign = crypto.createSign('RSA-SHA256'); sign.update('some data to sign'); -const private_key = getPrivateKeySomehow(); -console.log(sign.sign(private_key, 'hex')); +const privateKey = getPrivateKeySomehow(); +console.log(sign.sign(privateKey, 'hex')); // Prints: the calculated signature ``` @@ -878,13 +879,14 @@ const sign = crypto.createSign('sha256'); sign.update('some data to sign'); -const private_key = '-----BEGIN EC PRIVATE KEY-----\n' + - 'MHcCAQEEIF+jnWY1D5kbVYDNvxxo/Y+ku2uJPDwS0r/VuPZQrjjVoAoGCCqGSM49\n' + - 'AwEHoUQDQgAEurOxfSxmqIRYzJVagdZfMMSjRNNhB8i3mXyIMq704m2m52FdfKZ2\n' + - 'pQhByd5eyj3lgZ7m7jbchtdgyOF8Io/1ng==\n' + - '-----END EC PRIVATE KEY-----\n'; +const privateKey = +`-----BEGIN EC PRIVATE KEY----- +MHcCAQEEIF+jnWY1D5kbVYDNvxxo/Y+ku2uJPDwS0r/VuPZQrjjVoAoGCCqGSM49 +AwEHoUQDQgAEurOxfSxmqIRYzJVagdZfMMSjRNNhB8i3mXyIMq704m2m52FdfKZ2 +pQhByd5eyj3lgZ7m7jbchtdgyOF8Io/1ng== +-----END EC PRIVATE KEY-----`; -console.log(sign.sign(private_key).toString('hex')); +console.log(sign.sign(privateKey).toString('hex')); ``` ### sign.sign(private_key[, output_format]) @@ -947,9 +949,9 @@ const verify = crypto.createVerify('RSA-SHA256'); verify.write('some data to sign'); verify.end(); -const public_key = getPublicKeySomehow(); +const publicKey = getPublicKeySomehow(); const signature = getSignatureToVerify(); -console.log(verify.verify(public_key, signature)); +console.log(verify.verify(publicKey, signature)); // Prints: true or false ``` @@ -961,9 +963,9 @@ const verify = crypto.createVerify('RSA-SHA256'); verify.update('some data to sign'); -const public_key = getPublicKeySomehow(); +const publicKey = getPublicKeySomehow(); const signature = getSignatureToVerify(); -console.log(verify.verify(public_key, signature)); +console.log(verify.verify(publicKey, signature)); // Prints: true or false ``` @@ -1192,7 +1194,7 @@ const hash = crypto.createHash('sha256'); const input = fs.createReadStream(filename); input.on('readable', () => { - var data = input.read(); + const data = input.read(); if (data) hash.update(data); else { @@ -1226,7 +1228,7 @@ const hmac = crypto.createHmac('sha256', 'a secret'); const input = fs.createReadStream(filename); input.on('readable', () => { - var data = input.read(); + const data = input.read(); if (data) hmac.update(data); else { @@ -1278,7 +1280,7 @@ Example: ```js const curves = crypto.getCurves(); -console.log(curves); // ['secp256k1', 'secp384r1', ...] +console.log(curves); // ['Oakley-EC2N-3', 'Oakley-EC2N-4', ...] ``` ### crypto.getDiffieHellman(group_name) @@ -1307,11 +1309,11 @@ const bob = crypto.getDiffieHellman('modp14'); alice.generateKeys(); bob.generateKeys(); -const alice_secret = alice.computeSecret(bob.getPublicKey(), null, 'hex'); -const bob_secret = bob.computeSecret(alice.getPublicKey(), null, 'hex'); +const aliceSecret = alice.computeSecret(bob.getPublicKey(), null, 'hex'); +const bobSecret = bob.computeSecret(alice.getPublicKey(), null, 'hex'); -/* alice_secret and bob_secret should be the same */ -console.log(alice_secret == bob_secret); +/* aliceSecret and bobSecret should be the same */ +console.log(aliceSecret === bobSecret); ``` ### crypto.getHashes() @@ -1326,7 +1328,7 @@ Example: ```js const hashes = crypto.getHashes(); -console.log(hashes); // ['sha', 'sha1', 'sha1WithRSAEncryption', ...] +console.log(hashes); // ['DSA', 'DSA-SHA', 'DSA-SHA1', ...] ``` ### crypto.pbkdf2(password, salt, iterations, keylen, digest, callback) @@ -1357,7 +1359,7 @@ Example: const crypto = require('crypto'); crypto.pbkdf2('secret', 'salt', 100000, 512, 'sha512', (err, key) => { if (err) throw err; - console.log(key.toString('hex')); // 'c5e478d...1469e50' + console.log(key.toString('hex')); // '3745e48...aa39b34' }); ``` @@ -1390,7 +1392,7 @@ Example: ```js const crypto = require('crypto'); const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 512, 'sha512'); -console.log(key.toString('hex')); // 'c5e478d...1469e50' +console.log(key.toString('hex')); // '3745e48...aa39b34' ``` An array of supported digest functions can be retrieved using @@ -1938,6 +1940,7 @@ the `crypto`, `tls`, and `https` modules and are generally specific to OpenSSL. [`crypto.createHash()`]: #crypto_crypto_createhash_algorithm [`crypto.createHmac()`]: #crypto_crypto_createhmac_algorithm_key [`crypto.createSign()`]: #crypto_crypto_createsign_algorithm +[`crypto.createVerify()`]: #crypto_crypto_createverify_algorithm [`crypto.getCurves()`]: #crypto_crypto_getcurves [`crypto.getHashes()`]: #crypto_crypto_gethashes [`crypto.pbkdf2()`]: #crypto_crypto_pbkdf2_password_salt_iterations_keylen_digest_callback diff --git a/doc/api/debugger.md b/doc/api/debugger.md index c8a61d2ce742f8..7112b403fe35f3 100644 --- a/doc/api/debugger.md +++ b/doc/api/debugger.md @@ -117,7 +117,7 @@ script.js on line 1 It is also possible to set a breakpoint in a file (module) that -isn't loaded yet: +is not loaded yet: ```txt $ node debug test/fixtures/break-in-module/main.js diff --git a/doc/api/dgram.md b/doc/api/dgram.md index c059b6dc2ba4ff..65a89913ba1bdf 100644 --- a/doc/api/dgram.md +++ b/doc/api/dgram.md @@ -112,12 +112,13 @@ added: v0.1.99 * `callback` {Function} with no parameters, Optional. Called when binding is complete. -For UDP sockets, causes the `dgram.Socket` to listen for datagram messages on a -named `port` and optional `address`. If `port` is not specified, the operating -system will attempt to bind to a random port. If `address` is not specified, -the operating system will attempt to listen on all addresses. Once binding is -complete, a `'listening'` event is emitted and the optional `callback` function -is called. +For UDP sockets, causes the `dgram.Socket` to listen for datagram +messages on a named `port` and optional `address`. If `port` is not +specified or is `0`, the operating system will attempt to bind to a +random port. If `address` is not specified, the operating system will +attempt to listen on all addresses. Once binding is complete, a +`'listening'` event is emitted and the optional `callback` function is +called. Note that specifying both a `'listening'` event listener and passing a `callback` to the `socket.bind()` method is not harmful but not very @@ -159,18 +160,23 @@ added: v0.11.14 --> * `options` {Object} - Required. Supports the following properties: - * `port` {Number} - Required. + * `port` {Number} - Optional. * `address` {String} - Optional. * `exclusive` {Boolean} - Optional. * `callback` {Function} - Optional. -For UDP sockets, causes the `dgram.Socket` to listen for datagram messages on a -named `port` and optional `address` that are passed as properties of an -`options` object passed as the first argument. If `port` is not specified, the -operating system will attempt to bind to a random port. If `address` is not -specified, the operating system will attempt to listen on all addresses. Once -binding is complete, a `'listening'` event is emitted and the optional -`callback` function is called. +For UDP sockets, causes the `dgram.Socket` to listen for datagram +messages on a named `port` and optional `address` that are passed as +properties of an `options` object passed as the first argument. If +`port` is not specified or is `0`, the operating system will attempt +to bind to a random port. If `address` is not specified, the operating +system will attempt to listen on all addresses. Once binding is +complete, a `'listening'` event is emitted and the optional `callback` +function is called. + +Note that specifying both a `'listening'` event listener and passing a +`callback` to the `socket.bind()` method is not harmful but not very +useful. The `options` object may contain an additional `exclusive` property that is use when using `dgram.Socket` objects with the [`cluster`] module. When @@ -179,6 +185,12 @@ underlying socket handle allowing connection handling duties to be shared. When `exclusive` is `true`, however, the handle is not shared and attempted port sharing results in an error. +A bound datagram socket keeps the Node.js process running to receive +datagram messages. + +If binding fails, an `'error'` event is generated. In rare case (e.g. +attempting to bind with a closed socket), an [`Error`][] may be thrown. + An example socket listening on an exclusive port is shown below. ```js diff --git a/doc/api/dns.md b/doc/api/dns.md index e253039b687ef0..d3af3c3429faae 100644 --- a/doc/api/dns.md +++ b/doc/api/dns.md @@ -77,7 +77,7 @@ Alternatively, `options` can be an object containing these properties: `4` or `6`. If not provided, both IP v4 and v6 addresses are accepted. * `hints`: {Number} - If present, it should be one or more of the supported `getaddrinfo` flags. If `hints` is not provided, then no flags are passed to - `getaddrinfo`. Multiple flags can be passed through `hints` by logically + `getaddrinfo`. Multiple flags can be passed through `hints` by bitwise `OR`ing their values. See [supported `getaddrinfo` flags][] for more information on supported flags. diff --git a/doc/api/domain.md b/doc/api/domain.md index 86f5226d69e370..cfea9ddeff81f8 100644 --- a/doc/api/domain.md +++ b/doc/api/domain.md @@ -153,7 +153,7 @@ if (cluster.isMaster) { server.listen(PORT); } -// This part isn't important. Just an example routing thing. +// This part is not important. Just an example routing thing. // You'd put your fancy application logic here. function handleRequest(req, res) { switch(req.url) { diff --git a/doc/api/fs.md b/doc/api/fs.md index 4651e08672dda5..638e8261e36af1 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -1832,7 +1832,8 @@ added: v0.0.2 Write `buffer` to the file specified by `fd`. -`offset` and `length` determine the part of the buffer to be written. +`offset` determines the part of the buffer to be written, and `length` is +an integer specifying the number of bytes to write. `position` refers to the offset from the beginning of the file where this data should be written. If `typeof position !== 'number'`, the data will be written diff --git a/doc/api/globals.md b/doc/api/globals.md index 9154e54beb3675..4ce4f479f6c89f 100644 --- a/doc/api/globals.md +++ b/doc/api/globals.md @@ -32,7 +32,7 @@ added: v0.1.27 The directory name of the current module. This the same as the [`path.dirname()`][] of the [`__filename`][]. -`__dirname` isn't actually a global but rather local to each module. +`__dirname` is not actually a global but rather local to each module. Example: running `node example.js` from `/Users/mjr` @@ -60,7 +60,7 @@ command line. See [`__dirname`][] for the directory name of the current module. -`__filename` isn't actually a global but rather local to each module. +`__filename` is not actually a global but rather local to each module. Examples: @@ -132,7 +132,7 @@ A reference to the `module.exports` that is shorter to type. See [module system documentation][] for details on when to use `exports` and when to use `module.exports`. -`exports` isn't actually a global but rather local to each module. +`exports` is not actually a global but rather local to each module. See the [module system documentation][] for more information. @@ -163,7 +163,7 @@ A reference to the current module. In particular `module.exports` is used for defining what a module exports and makes available through `require()`. -`module` isn't actually a global but rather local to each module. +`module` is not actually a global but rather local to each module. See the [module system documentation][] for more information. @@ -187,7 +187,7 @@ added: v0.1.13 * {Function} -To require modules. See the [Modules][] section. `require` isn't actually a +To require modules. See the [Modules][] section. `require` is not actually a global but rather local to each module. ### require.cache diff --git a/doc/api/http.md b/doc/api/http.md index fb90123330458c..aa5198214242a2 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -48,26 +48,32 @@ list like the following: added: v0.3.4 --> -The HTTP Agent is used for pooling sockets used in HTTP client -requests. - -The HTTP Agent also defaults client requests to using -`Connection: keep-alive`. If no pending HTTP requests are waiting on a -socket to become free the socket is closed. This means that Node.js's -pool has the benefit of keep-alive when under load but still does not -require developers to manually close the HTTP clients using -KeepAlive. - -If you opt into using HTTP KeepAlive, you can create an Agent object -with that flag set to `true`. (See the [constructor options][].) -Then, the Agent will keep unused sockets in a pool for later use. They -will be explicitly marked so as to not keep the Node.js process running. -However, it is still a good idea to explicitly [`destroy()`][] KeepAlive -agents when they are no longer in use, so that the Sockets will be shut -down. - -Sockets are removed from the agent's pool when the socket emits either -a `'close'` event or a special `'agentRemove'` event. This means that if +An `Agent` is responsible for managing connection persistence +and reuse for HTTP clients. It maintains a queue of pending requests +for a given host and port, reusing a single socket connection for each +until the queue is empty, at which time the socket is either destroyed +or put into a pool where it is kept to be used again for requests to the +same host and port. Whether it is destroyed or pooled depends on the +`keepAlive` [option](#http_new_agent_options). + +Pooled connections have TCP Keep-Alive enabled for them, but servers may +still close idle connections, in which case they will be removed from the +pool and a new connection will be made when a new HTTP request is made for +that host and port. Servers may also refuse to allow multiple requests +over the same connection, in which case the connection will have to be +remade for every request and cannot be pooled. The `Agent` will still make +the requests to that server, but each one will occur over a new connection. + +When a connection is closed by the client or the server, it is removed +from the pool. Any unused sockets in the pool will be unrefed so as not +to keep the Node.js process running when there are no outstanding requests. +(see [socket.unref()]). + +It is good practice, to [`destroy()`][] an `Agent` instance when it is no +longer in use, because unused sockets consume OS resources. + +Sockets are removed from an agent's pool when the socket emits either +a `'close'` event or an `'agentRemove'` event. This means that if you intend to keep one HTTP request open for a long time and don't want it to stay in the pool you can do something along the lines of: @@ -79,7 +85,11 @@ http.get(options, (res) => { }); ``` -Alternatively, you could just opt out of pooling entirely using +You may also use an agent for an individual request. By providing +`{agent: false}` as an option to the `http.get()` or `http.request()` +functions, a one-time use `Agent` with default options will be used +for the client connection. + `agent:false`: ```js @@ -100,11 +110,13 @@ added: v0.3.4 * `options` {Object} Set of configurable options to set on the agent. Can have the following fields: - * `keepAlive` {Boolean} Keep sockets around in a pool to be used by - other requests in the future. Default = `false` - * `keepAliveMsecs` {Integer} When using HTTP KeepAlive, how often - to send TCP KeepAlive packets over sockets being kept alive. - Default = `1000`. Only relevant if `keepAlive` is set to `true`. + * `keepAlive` {Boolean} Keep sockets around even when there are no + outstanding requests, so they can be used for future requests without + having to reestablish a TCP connection. Default = `false` + * `keepAliveMsecs` {Integer} When using the `keepAlive` option, specifies + the [initial delay](#net_socket_setkeepalive_enable_initialdelay) + for TCP Keep-Alive packets. Ignored when the + `keepAlive` option is `false` or `undefined`. Default = `1000`. * `maxSockets` {Number} Maximum number of sockets to allow per host. Default = `Infinity`. * `maxFreeSockets` {Number} Maximum number of sockets to leave open @@ -114,7 +126,7 @@ added: v0.3.4 The default [`http.globalAgent`][] that is used by [`http.request()`][] has all of these values set to their respective defaults. -To configure any of them, you must create your own [`http.Agent`][] object. +To configure any of them, you must create your own [`http.Agent`][] instance. ```js const http = require('http'); @@ -136,7 +148,7 @@ added: v0.11.4 Produces a socket/stream to be used for HTTP requests. By default, this function is the same as [`net.createConnection()`][]. However, -custom Agents may override this method in case greater flexibility is desired. +custom agents may override this method in case greater flexibility is desired. A socket/stream can be supplied in one of two ways: by returning the socket/stream from this function, or by passing the socket/stream to `callback`. @@ -151,7 +163,7 @@ added: v0.11.4 Destroy any sockets that are currently in use by the agent. It is usually not necessary to do this. However, if you are using an -agent with KeepAlive enabled, then it is best to explicitly shut down +agent with `keepAlive` enabled, then it is best to explicitly shut down the agent when you know that it will no longer be used. Otherwise, sockets may hang open for quite a long time before the server terminates them. @@ -164,7 +176,7 @@ added: v0.11.4 * {Object} An object which contains arrays of sockets currently awaiting use by -the Agent when HTTP KeepAlive is used. Do not modify. +the agent when `keepAlive` is enabled. Do not modify. ### agent.getName(options) +* Returns: {String} + The `os.arch()` method returns a string identifying the operating system CPU architecture *for which the Node.js binary was compiled*. @@ -36,6 +38,9 @@ The current possible values are: `'arm'`, `'arm64'`, `'ia32'`, `'mips'`, Equivalent to [`process.arch`][]. ## os.constants + * {Object} diff --git a/doc/api/process.md b/doc/api/process.md index 3e0414e59effc4..4e20399d41fade 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -1651,9 +1651,9 @@ added: v0.2.0 * {Object} The `process.versions` property returns an object listing the version strings of -Node.js and its dependencies. In addition, `process.versions.modules` indicates -the current ABI version, which is increased whenever a C++ API changes. Node.js -will refuse to load native modules built for an older `modules` value. +Node.js and its dependencies. `process.versions.modules` indicates the current +ABI version, which is increased whenever a C++ API changes. Node.js will refuse +to load modules that were compiled against a different module ABI version. ```js console.log(process.versions); @@ -1754,5 +1754,5 @@ cases: [Readable]: stream.html [Child Process]: child_process.html [Cluster]: cluster.html -[`process.exitCode`]: #processexitcode-1 +[`process.exitCode`]: #process_process_exitcode [LTS]: https://github.com/nodejs/LTS/ diff --git a/doc/api/repl.md b/doc/api/repl.md index eb32f2c2b2755b..1b03ba47a25d99 100644 --- a/doc/api/repl.md +++ b/doc/api/repl.md @@ -418,6 +418,15 @@ added: v0.1.91 The `repl.start()` method creates and starts a `repl.REPLServer` instance. +If `options` is a string, then it specifies the input prompt: + +```js +const repl = require('repl'); + +// a Unix style prompt +repl.start('$ '); +``` + ## The Node.js REPL Node.js itself uses the `repl` module to provide its own interactive interface diff --git a/doc/api/stream.md b/doc/api/stream.md index 291cda735aee3d..1095d8e6ecb5f8 100644 --- a/doc/api/stream.md +++ b/doc/api/stream.md @@ -440,12 +440,49 @@ occurs, the `callback` *may or may not* be called with the error as its first argument. To reliably detect write errors, add a listener for the `'error'` event. -The return value is `true` if the internal buffer does not exceed +The return value is `true` if the internal buffer is less than the `highWaterMark` configured when the stream was created after admitting `chunk`. If `false` is returned, further attempts to write data to the stream should -stop until the [`'drain'`][] event is emitted. However, the `false` return -value is only advisory and the writable stream will unconditionally accept and -buffer `chunk` even if it has not not been allowed to drain. +stop until the [`'drain'`][] event is emitted. + +While a stream is not draining, calls to `write()` will buffer `chunk`, and +return false. Once all currently buffered chunks are drained (accepted for +delivery by the operating system), the `'drain'` event will be emitted. +It is recommended that once write() returns false, no more chunks be written +until the `'drain'` event is emitted. While calling `write()` on a stream that +is not draining is allowed, Node.js will buffer all written chunks until +maximum memory usage occurs, at which point it will abort unconditionally. +Even before it aborts, high memory usage will cause poor garbage collector +performance and high RSS (which is not typically released back to the system, +even after the memory is no longer required). Since TCP sockets may never +drain if the remote peer does not read the data, writing a socket that is +not draining may lead to a remotely exploitable vulnerability. + +Writing data while the stream is not draining is particularly +problematic for a [Transform][], because the `Transform` streams are paused +by default until they are piped or an `'data'` or `'readable'` event handler +is added. + +If the data to be written can be generated or fetched on demand, it is +recommended to encapsulate the logic into a [Readable][] and use +[`stream.pipe()`][]. However, if calling `write()` is preferred, it is +possible to respect backpressure and avoid memory issues using the +the [`'drain'`][] event: + +```js +function write (data, cb) { + if (!stream.write(data)) { + stream.once('drain', cb) + } else { + process.nextTick(cb) + } +} + +// Wait for cb to be called before doing any other write. +write('hello', () => { + console.log('write completed, do more writes now') +}) +``` A Writable stream in object mode will always ignore the `encoding` argument. @@ -1306,7 +1343,7 @@ It is recommended that errors occurring during the processing of the `writable._write()` and `writable._writev()` methods are reported by invoking the callback and passing the error as the first argument. This will cause an `'error'` event to be emitted by the Writable. Throwing an Error from within -`writable._write()` can result in expected and inconsistent behavior depending +`writable._write()` can result in unexpected and inconsistent behavior depending on how the stream is being used. Using the callback ensures consistent and predictable handling of errors. diff --git a/doc/api/tls.md b/doc/api/tls.md index c33174f250479a..f83ed1df3e449f 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -483,12 +483,8 @@ added: v0.11.4 will be emitted on the socket before establishing a secure communication * `secureContext`: Optional TLS context object created with [`tls.createSecureContext()`][]. If a `secureContext` is _not_ provided, one - will be created by passing the entire `options` object to - `tls.createSecureContext()`. *Note*: In effect, all - [`tls.createSecureContext()`][] options can be provided, but they will be - _completely ignored_ unless the `secureContext` option is missing. - * ...: Optional [`tls.createSecureContext()`][] options can be provided, see - the `secureContext` option for more information. + will be created by calling [`tls.createSecureContext()`][] with no options. + Construct a new `tls.TLSSocket` object from an existing TCP socket. ### Event: 'OCSPResponse' @@ -587,13 +583,16 @@ For Example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }` added: v0.11.4 --> -* `detailed` {boolean} Specify `true` to request that the full certificate - chain with the `issuer` property be returned; `false` to return only the - top certificate without the `issuer` property. +* `detailed` {boolean} Include the full certificate chain if `true`, otherwise + include just the peer's certificate. Returns an object representing the peer's certificate. The returned object has some properties corresponding to the fields of the certificate. +If the full certificate chain was requested, each certificate will include a +`issuerCertificate` property containing an object representing its issuer's +certificate. + For example: ```text @@ -604,15 +603,15 @@ For example: O: 'node.js', OU: 'Test TLS Certificate', CN: 'localhost' }, - issuerInfo: + issuer: { C: 'UK', ST: 'Acknack Ltd', L: 'Rhys Jones', O: 'node.js', OU: 'Test TLS Certificate', CN: 'localhost' }, - issuer: - { ... another certificate ... }, + issuerCertificate: + { ... another certificate, possibly with a .issuerCertificate ... }, raw: < RAW DER buffer >, valid_from: 'Nov 11 09:52:22 2009 GMT', valid_to: 'Nov 6 09:52:22 2029 GMT', @@ -620,8 +619,7 @@ For example: serialNumber: 'B9B0D332A1AA5635' } ``` -If the peer does not provide a certificate, `null` or an empty object will be -returned. +If the peer does not provide a certificate, an empty object will be returned. ### tlsSocket.getProtocol() The default curve name to use for ECDH key agreement in a tls server. The default value is `'prime256v1'` (NIST P-256). Consult [RFC 4492] and diff --git a/doc/api/url.md b/doc/api/url.md old mode 100644 new mode 100755 index 40a3440195e69a..50e7433e6110e5 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -250,7 +250,465 @@ properties of URL objects: For example, the ASCII space character (`' '`) is encoded as `%20`. The ASCII forward slash (`/`) character is encoded as `%3C`. +## The WHATWG URL API + +> Stability: 1 - Experimental + +The `url` module provides an *experimental* implementation of the +[WHATWG URL Standard][] as an alternative to the existing `url.parse()` API. + +```js +const URL = require('url').URL; +const myURL = new URL('https://example.org/foo'); + +console.log(myURL.href); // https://example.org/foo +console.log(myURL.protocol); // https: +console.log(myURL.hostname); // example.org +console.log(myURL.pathname); // /foo +``` + +*Note*: Using the `delete` keyword (e.g. `delete myURL.protocol`, +`delete myURL.pathname`, etc) has no effect but will still return `true`. + +### Class: URL +#### Constructor: new URL(input[, base]) + +* `input` {String} The input URL to parse +* `base` {String | URL} The base URL to resolve against if the `input` is not + absolute. + +Creates a new `URL` object by parsing the `input` relative to the `base`. If +`base` is passed as a string, it will be parsed equivalent to `new URL(base)`. + +```js +const myURL = new URL('/foo', 'https://example.org/'); + // https://example.org/foo +``` + +A `TypeError` will be thrown if the `input` or `base` are not valid URLs. Note +that an effort will be made to coerce the given values into strings. For +instance: + +```js +const myURL = new URL({toString: () => 'https://example.org/'}); + // https://example.org/ +``` + +Unicode characters appearing within the hostname of `input` will be +automatically converted to ASCII using the [Punycode][] algorithm. + +```js +const myURL = new URL('https://你好你好'); + // https://xn--6qqa088eba +``` + +Additional [examples of parsed URLs][] may be found in the WHATWG URL Standard. + +#### url.hash + +Gets and sets the fragment portion of the URL. + +```js +const myURL = new URL('https://example.org/foo#bar'); +console.log(myURL.hash); + // Prints #bar + +myURL.hash = 'baz'; +console.log(myURL.href); + // Prints https://example.org/foo#baz +``` + +Invalid URL characters included in the value assigned to the `hash` property +are [percent-encoded](#whatwg-percent-encoding). Note that the selection of +which characters to percent-encode may vary somewhat from what the +[`url.parse()`][] and [`url.format()`][] methods would produce. + +#### url.host + +Gets and sets the host portion of the URL. + +```js +const myURL = new URL('https://example.org:81/foo'); +console.log(myURL.host); + // Prints example.org:81 + +myURL.host = 'example.com:82'; +console.log(myURL.href); + // Prints https://example.com:82/foo +``` + +Invalid host values assigned to the `host` property are ignored. + +#### url.hostname + +Gets and sets the hostname portion of the URL. The key difference between +`url.host` and `url.hostname` is that `url.hostname` does *not* include the +port. + +```js +const myURL = new URL('https://example.org:81/foo'); +console.log(myURL.hostname); + // Prints example.org + +myURL.hostname = 'example.com:82'; +console.log(myURL.href); + // Prints https://example.com:81/foo +``` + +Invalid hostname values assigned to the `hostname` property are ignored. + +#### url.href + +Gets and sets the serialized URL. + +```js +const myURL = new URL('https://example.org/foo'); +console.log(myURL.href); + // Prints https://example.org/foo + +myURL.href = 'https://example.com/bar' + // Prints https://example.com/bar +``` + +Setting the value of the `href` property to a new value is equivalent to +creating a new `URL` object using `new URL(value)`. Each of the `URL` object's +properties will be modified. + +If the value assigned to the `href` property is not a valid URL, a `TypeError` +will be thrown. + +#### url.origin + +Gets the read-only serialization of the URL's origin. Unicode characters that +may be contained within the hostname will be encoded as-is without [Punycode][] +encoding. + +```js +const myURL = new URL('https://example.org/foo/bar?baz'); +console.log(myURL.origin); + // Prints https://example.org +``` + +```js +const idnURL = new URL('https://你好你好'); +console.log(idnURL.origin); + // Prints https://你好你好 + +console.log(idnURL.hostname); + // Prints xn--6qqa088eba +``` + +#### url.password + +Gets and sets the password portion of the URL. + +```js +const myURL = new URL('https://abc:xyz@example.com'); +console.log(myURL.password); + // Prints xyz + +myURL.password = '123'; +console.log(myURL.href); + // Prints https://abc:123@example.com +``` + +Invalid URL characters included in the value assigned to the `password` property +are [percent-encoded](#whatwg-percent-encoding). Note that the selection of +which characters to percent-encode may vary somewhat from what the +[`url.parse()`][] and [`url.format()`][] methods would produce. + +#### url.pathname + +Gets and sets the path portion of the URL. + +```js +const myURL = new URL('https://example.org/abc/xyz?123'); +console.log(myURL.pathname); + // Prints /abc/xyz + +myURL.pathname = '/abcdef'; +console.log(myURL.href); + // Prints https://example.org/abcdef?123 +``` + +Invalid URL characters included in the value assigned to the `pathname` +property are [percent-encoded](#whatwg-percent-encoding). Note that the +selection of which characters to percent-encode may vary somewhat from what the +[`url.parse()`][] and [`url.format()`][] methods would produce. + +#### url.port + +Gets and sets the port portion of the URL. When getting the port, the value +is returned as a String. + +```js +const myURL = new URL('https://example.org:8888'); +console.log(myURL.port); + // Prints 8888 + +myURL.port = 1234; +console.log(myURL.href); + // Prints https://example.org:1234 +``` + +The port value may be set as either a number or as a String containing a number +in the range `0` to `65535` (inclusive). Setting the value to the default port +of the `URL` objects given `protocol` will result in the `port` value becoming +the empty string (`''`). + +Invalid URL port values assigned to the `port` property are ignored. + +#### url.protocol + +Gets and sets the protocol portion of the URL. + +```js +const myURL = new URL('https://example.org'); +console.log(myURL.protocol); + // Prints http: + +myURL.protocol = 'ftp'; +console.log(myURL.href); + // Prints ftp://example.org +``` + +Invalid URL protocol values assigned to the `protocol` property are ignored. + +#### url.search + +Gets and sets the serialized query portion of the URL. + +```js +const myURL = new URL('https://example.org/abc?123'); +console.log(myURL.search); + // Prints ?123 + +myURL.search = 'abc=xyz'; +console.log(myURL.href); + // Prints https://example.org/abc?abc=xyz +``` + +Any invalid URL characters appearing in the value assigned the `search` +property will be [percent-encoded](#whatwg-percent-encoding). Note that the +selection of which characters to percent-encode may vary somewhat from what the +[`url.parse()`][] and [`url.format()`][] methods would produce. + +#### url.searchParams + +Gets a [`URLSearchParams`](#url_class_urlsearchparams) object representing the +query parameters of the URL. + +#### url.username + +Gets and sets the username portion of the URL. + +```js +const myURL = new URL('https://abc:xyz@example.com'); +console.log(myURL.username); + // Prints abc + +myURL.username = '123'; +console.log(myURL.href); + // Prints https://123:xyz@example.com +``` + +Any invalid URL characters appearing in the value assigned the `username` +property will be [percent-encoded](#whatwg-percent-encoding). Note that the +selection of which characters to percent-encode may vary somewhat from what the +[`url.parse()`][] and [`url.format()`][] methods would produce. + +#### url.toString() + +The `toString()` method on the `URL` object returns the serialized URL. The +value returned is equivalent to that of `url.href`. + +### Class: URLSearchParams + +The `URLSearchParams` object provides read and write access to the query of a +`URL`. + +```js +const URL = require('url').URL; +const myURL = new URL('https://example.org/?abc=123'); +console.log(myURL.searchParams.get('abc')); + // Prints 123 + +myURL.searchParams.append('abc', 'xyz'); +console.log(myURL.href); + // Prints https://example.org/?abc=123&abc=xyz + +myURL.searchParams.delete('abc'); +myURL.searchParams.set('a', 'b'); +console.log(myURL.href); + // Prints https://example.org/?a=b +``` + +#### Constructor: new URLSearchParams([init]) + +* `init` {String} The URL query + +#### urlSearchParams.append(name, value) + +* `name` {String} +* `value` {String} + +Append a new name-value pair to the query string. + +#### urlSearchParams.delete(name) + +* `name` {String} + +Remove all name-value pairs whose name is `name`. + +#### urlSearchParams.entries() + +* Returns: {Iterator} + +Returns an ES6 Iterator over each of the name-value pairs in the query. +Each item of the iterator is a JavaScript Array. The first item of the Array +is the `name`, the second item of the Array is the `value`. + +Alias for `urlSearchParams\[\@\@iterator\]()`. + +#### urlSearchParams.forEach(fn) + +* `fn` {Function} Function invoked for each name-value pair in the query. + +Iterates over each name-value pair in the query and invokes the given function. + +```js +const URL = require('url').URL; +const myURL = new URL('https://example.org/?a=b&c=d'); +myURL.searchParams.forEach((value, name) => { + console.log(name, value); +}); +``` + +#### urlSearchParams.get(name) + +* `name` {String} +* Returns: {String} or `null` if there is no name-value pair with the given + `name`. + +Returns the value of the first name-value pair whose name is `name`. + +#### urlSearchParams.getAll(name) + +* `name` {String} +* Returns: {Array} + +Returns the values of all name-value pairs whose name is `name`. + +#### urlSearchParams.has(name) + +* `name` {String} +* Returns: {Boolean} + +Returns `true` if there is at least one name-value pair whose name is `name`. + +#### urlSearchParams.keys() + +* Returns: {Iterator} + +Returns an ES6 Iterator over the names of each name-value pair. + +#### urlSearchParams.set(name, value) + +* `name` {String} +* `value` {String} + +Remove any existing name-value pairs whose name is `name` and append a new +name-value pair. + +#### urlSearchParams.toString() + +* Returns: {String} + +Returns the search parameters serialized as a URL-encoded string. + +#### urlSearchParams.values() + +* Returns: {Iterator} + +Returns an ES6 Iterator over the values of each name-value pair. + +#### urlSearchParams\[\@\@iterator\]() + +* Returns: {Iterator} + +Returns an ES6 Iterator over each of the name-value pairs in the query string. +Each item of the iterator is a JavaScript Array. The first item of the Array +is the `name`, the second item of the Array is the `value`. + +Alias for `urlSearchParams.entries()`. + +### require('url').domainToAscii(domain) + +* `domain` {String} +* Returns: {String} + +Returns the [Punycode][] ASCII serialization of the `domain`. + +*Note*: The `require('url').domainToAscii()` method is introduced as part of +the new `URL` implementation but is not part of the WHATWG URL standard. + +### require('url').domainToUnicode(domain) + +* `domain` {String} +* Returns: {String} + +Returns the Unicode serialization of the `domain`. + +*Note*: The `require('url').domainToUnicode()` API is introduced as part of the +the new `URL` implementation but is not part of the WHATWG URL standard. + + +### Percent-Encoding in the WHATWG URL Standard + +URLs are permitted to only contain a certain range of characters. Any character +falling outside of that range must be encoded. How such characters are encoded, +and which characters to encode depends entirely on where the character is +located within the structure of the URL. The WHATWG URL Standard uses a more +selective and fine grained approach to selecting encoded characters than that +used by the older [`url.parse()`][] and [`url.format()`][] methods. + +The WHATWG algorithm defines three "encoding sets" that describe ranges of +characters that must be percent-encoded: + +* The *simple encode set* includes code points in range U+0000 to U+001F + (inclusive) and all code points greater than U+007E. + +* The *default encode set* includes the *simple encode set* and code points + U+0020, U+0022, U+0023, U+003C, U+003E, U+003F, U+0060, U+007B, and U+007D. + +* The *userinfo encode set* includes the *default encode set* and code points + U+002F, U+003A, U+003B, U+003D, U+0040, U+005B, U+005C, U+005D, U+005E, and + U+007C. + +The *simple encode set* is used primary for URL fragments and certain specific +conditions for the path. The *userinfo encode set* is used specifically for +username and passwords encoded within the URL. The *default encode set* is used +for all other cases. + +When non-ASCII characters appear within a hostname, the hostname is encoded +using the [Punycode][] algorithm. Note, however, that a hostname *may* contain +*both* Punycode encoded and percent-encoded characters. For example: + +```js +const URL = require('url').URL; +const myURL = new URL('https://%CF%80.com/foo'); +console.log(myURL.href); + // Prints https://xn--1xa.com/foo +console.log(myURL.origin); + // Prints https://π.com +``` + [`Error`]: errors.html#errors_class_error [`querystring`]: querystring.html [`TypeError`]: errors.html#errors_class_typeerror +[WHATWG URL Standard]: https://url.spec.whatwg.org/ +[examples of parsed URLs]: https://url.spec.whatwg.org/#example-url-parsing +[`url.parse()`]: #url_url_parse_urlstring_parsequerystring_slashesdenotehost +[`url.format()`]: #url_url_format_urlobject +[Punycode]: https://tools.ietf.org/html/rfc5891#section-4.4 diff --git a/doc/api/vm.md b/doc/api/vm.md index 8c49cfb7c31f24..cb0e2fbb76e25d 100644 --- a/doc/api/vm.md +++ b/doc/api/vm.md @@ -439,9 +439,9 @@ let code = vm.runInThisContext(code)(require); ``` -*Note*: The `require()` in the above case shares the state with context it is -passed from. This may introduce risks when untrusted code is executed, e.g. -altering objects from the calling thread's context in unwanted ways. +*Note*: The `require()` in the above case shares the state with the context it +is passed from. This may introduce risks when untrusted code is executed, e.g. +altering objects in the context in unwanted ways. ## What does it mean to "contextify" an object? diff --git a/doc/api/zlib.md b/doc/api/zlib.md index 73bcf8e0179366..0d79c084acd565 100644 --- a/doc/api/zlib.md +++ b/doc/api/zlib.md @@ -388,6 +388,9 @@ Reset the compressor/decompressor to factory defaults. Only applicable to the inflate and deflate algorithms. ## zlib.constants + Provides an object enumerating Zlib-related constants. @@ -460,7 +463,7 @@ added: v0.6.0 added: v0.11.12 --> -Compress a Buffer or string with Deflate. +Compress a [Buffer][] or string with [Deflate][]. ### zlib.deflateRaw(buf[, options], callback) -Compress a Buffer or string with DeflateRaw. +Compress a [Buffer][] or string with [DeflateRaw][]. ### zlib.gunzip(buf[, options], callback) -Decompress a Buffer or string with Gunzip. +Decompress a [Buffer][] or string with [Gunzip][]. ### zlib.gzip(buf[, options], callback) -Compress a Buffer or string with Gzip. +Compress a [Buffer][] or string with [Gzip][]. ### zlib.inflate(buf[, options], callback) -Decompress a Buffer or string with Inflate. +Decompress a [Buffer][] or string with [Inflate][]. ### zlib.inflateRaw(buf[, options], callback) -Decompress a Buffer or string with InflateRaw. +Decompress a [Buffer][] or string with [InflateRaw][]. ### zlib.unzip(buf[, options], callback) -Decompress a Buffer or string with Unzip. +Decompress a [Buffer][] or string with [Unzip][]. [`Accept-Encoding`]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.3 [`Content-Encoding`]: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.11 diff --git a/doc/api_assets/dnt_helper.js b/doc/api_assets/dnt_helper.js new file mode 100644 index 00000000000000..f255d916c2df32 --- /dev/null +++ b/doc/api_assets/dnt_helper.js @@ -0,0 +1,49 @@ +/** + * http://schalkneethling.github.io/blog/2015/11/06/respect-user-choice-do-not-track/ + * https://github.com/schalkneethling/dnt-helper/blob/master/js/dnt-helper.js + * + * Returns true or false based on whether doNotTack is enabled. It also takes into account the + * anomalies, such as !bugzilla 887703, which effect versions of Fx 31 and lower. It also handles + * IE versions on Windows 7, 8 and 8.1, where the DNT implementation does not honor the spec. + * @see https://bugzilla.mozilla.org/show_bug.cgi?id=1217896 for more details + * @params {string} [dnt] - An optional mock doNotTrack string to ease unit testing. + * @params {string} [userAgent] - An optional mock userAgent string to ease unit testing. + * @returns {boolean} true if enabled else false + */ +function _dntEnabled(dnt, userAgent) { + + 'use strict'; + + // for old version of IE we need to use the msDoNotTrack property of navigator + // on newer versions, and newer platforms, this is doNotTrack but, on the window object + // Safari also exposes the property on the window object. + var dntStatus = dnt || navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack; + var ua = userAgent || navigator.userAgent; + + // List of Windows versions known to not implement DNT according to the standard. + var anomalousWinVersions = ['Windows NT 6.1', 'Windows NT 6.2', 'Windows NT 6.3']; + + var fxMatch = ua.match(/Firefox\/(\d+)/); + var ieRegEx = /MSIE|Trident/i; + var isIE = ieRegEx.test(ua); + // Matches from Windows up to the first occurance of ; un-greedily + // http://www.regexr.com/3c2el + var platform = ua.match(/Windows.+?(?=;)/g); + + // With old versions of IE, DNT did not exist so we simply return false; + if (isIE && typeof Array.prototype.indexOf !== 'function') { + return false; + } else if (fxMatch && parseInt(fxMatch[1], 10) < 32) { + // Can't say for sure if it is 1 or 0, due to Fx bug 887703 + dntStatus = 'Unspecified'; + } else if (isIE && platform && anomalousWinVersions.indexOf(platform.toString()) !== -1) { + // default is on, which does not honor the specification + dntStatus = 'Unspecified'; + } else { + // sets dntStatus to Disabled or Enabled based on the value returned by the browser. + // If dntStatus is undefined, it will be set to Unspecified + dntStatus = { '0': 'Disabled', '1': 'Enabled' }[dntStatus] || 'Unspecified'; + } + + return dntStatus === 'Enabled' ? true : false; +} diff --git a/doc/changelogs/CHANGELOG_V7.md b/doc/changelogs/CHANGELOG_V7.md index 1f476b8eae4649..8122c9e6aea8d7 100644 --- a/doc/changelogs/CHANGELOG_V7.md +++ b/doc/changelogs/CHANGELOG_V7.md @@ -6,6 +6,7 @@ +7.5.0
    7.4.0
    7.3.0
    7.2.1
    @@ -25,6 +26,323 @@ * [io.js](CHANGELOG_IOJS.md) * [Archive](CHANGELOG_ARCHIVE.md) + +## 2017-01-31, Version 7.5.0 (Current), @evanlucas + +Thank you to @italoacasas for preparing the majority of this release. + +This release contains security fixes to upgrade OpenSSL to version 1.0.2k. + +Although the OpenSSL team have determined a maximum severity rating of "moderate", the Node.js +crypto team (Ben Noordhuis, Shigeki Ohtsu and Fedor Indutny) have determined the impact to Node +users is "low". Details on this determination can be found +[on the Nodejs.org website](https://nodejs.org/en/blog/vulnerability/openssl-january-2017/). + +### Notable changes + +* **crypto**: + * ability to select cert store at runtime (Adam Majer) [#8334](https://github.com/nodejs/node/pull/8334) + * Use system CAs instead of using bundled ones (Adam Majer) [#8334](https://github.com/nodejs/node/pull/8334) +* **deps**: + * upgrade npm to 4.1.2 (Kat Marchán) [#11020](https://github.com/nodejs/node/pull/11020) + * upgrade openssl sources to 1.0.2k (Shigeki Ohtsu) [#11021](https://github.com/nodejs/node/pull/11021) +* **doc**: add basic documentation for WHATWG URL API (James M Snell) [#10620](https://github.com/nodejs/node/pull/10620) +* **process**: add NODE_NO_WARNINGS environment variable (cjihrig) [#10842](https://github.com/nodejs/node/pull/10842) +* **url**: allow use of URL with http.request and https.request (James M Snell) [#10638](https://github.com/nodejs/node/pull/10638) + +### Commits + +* [[`61f6f1260d`](https://github.com/nodejs/node/commit/61f6f1260d)] - **(SEMVER-MINOR)** src/doc: improve man page and --help (Roman Reiss) [#10157](https://github.com/nodejs/node/pull/10157) +* [[`b2d0c44fb1`](https://github.com/nodejs/node/commit/b2d0c44fb1)] - **assert**: update comments (Kai Cataldo) [#10579](https://github.com/nodejs/node/pull/10579) +* [[`c217b438f2`](https://github.com/nodejs/node/commit/c217b438f2)] - **assert, tools**: enforce strict (not)equal in eslint (Gibson Fahnestock) [#10698](https://github.com/nodejs/node/pull/10698) +* [[`94c4323d56`](https://github.com/nodejs/node/commit/94c4323d56)] - **async_wrap**: close the destroy_ids_idle_handle_ (René Schünemann) [#10385](https://github.com/nodejs/node/pull/10385) +* [[`f61c71b533`](https://github.com/nodejs/node/commit/f61c71b533)] - **benchmark**: add progress indicator to compare.js (Joyee Cheung) [#10823](https://github.com/nodejs/node/pull/10823) +* [[`ccdc922ada`](https://github.com/nodejs/node/commit/ccdc922ada)] - **benchmark**: move setImmediate benchmarks to timers (Joshua Colvin) [#11010](https://github.com/nodejs/node/pull/11010) +* [[`062c8513ad`](https://github.com/nodejs/node/commit/062c8513ad)] - **benchmark**: add more thorough timers benchmarks (Jeremiah Senkpiel) [#10925](https://github.com/nodejs/node/pull/10925) +* [[`1e0294ccc9`](https://github.com/nodejs/node/commit/1e0294ccc9)] - **benchmark**: add benchmark for object properties (Michaël Zasso) [#10949](https://github.com/nodejs/node/pull/10949) +* [[`47c0953b12`](https://github.com/nodejs/node/commit/47c0953b12)] - **benchmark**: add benchmark for vm.runIn*() (Rich Trott) [#10816](https://github.com/nodejs/node/pull/10816) +* [[`2f339e7200`](https://github.com/nodejs/node/commit/2f339e7200)] - **benchmark**: cleanup child_process IPC benchmark (Yuya Tanaka) [#10557](https://github.com/nodejs/node/pull/10557) +* [[`eac1871c45`](https://github.com/nodejs/node/commit/eac1871c45)] - **benchmark**: improve WHATWG URL benchmarks (Joyee Cheung) [#10678](https://github.com/nodejs/node/pull/10678) +* [[`ecf72d8b54`](https://github.com/nodejs/node/commit/ecf72d8b54)] - **benchmark**: use "confidence" in output of compare.R (Joyee Cheung) [#10737](https://github.com/nodejs/node/pull/10737) +* [[`35334273b9`](https://github.com/nodejs/node/commit/35334273b9)] - **benchmark**: don't lint autogenerated modules (Brian White) [#10756](https://github.com/nodejs/node/pull/10756) +* [[`4f96272f12`](https://github.com/nodejs/node/commit/4f96272f12)] - **benchmark**: fix typo "categoty" -> "category" (Victor Felder) [#10568](https://github.com/nodejs/node/pull/10568) +* [[`2f4577c07d`](https://github.com/nodejs/node/commit/2f4577c07d)] - **benchmark**: keep decimals in results (Brian White) [#10559](https://github.com/nodejs/node/pull/10559) +* [[`372e3eeb4b`](https://github.com/nodejs/node/commit/372e3eeb4b)] - **benchmark**: improve readability of net benchmarks (Brian White) [#10446](https://github.com/nodejs/node/pull/10446) +* [[`d19136da84`](https://github.com/nodejs/node/commit/d19136da84)] - **benchmark**: move punycode benchmark out of net (Brian White) [#10446](https://github.com/nodejs/node/pull/10446) +* [[`be24cc0187`](https://github.com/nodejs/node/commit/be24cc0187)] - **benchmark**: add ClientRequest creation benchmark (Brian White) [#10654](https://github.com/nodejs/node/pull/10654) +* [[`1438d00119`](https://github.com/nodejs/node/commit/1438d00119)] - **benchmark,lib,test**: adjust for linting (Rich Trott) [#10561](https://github.com/nodejs/node/pull/10561) +* [[`d13aba8499`](https://github.com/nodejs/node/commit/d13aba8499)] - **buffer**: improve compare() performance (Brian White) [#10927](https://github.com/nodejs/node/pull/10927) +* [[`6549bc2a35`](https://github.com/nodejs/node/commit/6549bc2a35)] - **buffer**: fix comments in bidirectionalIndexOf (dcposch@dcpos.ch) [#10162](https://github.com/nodejs/node/pull/10162) +* [[`a114f63627`](https://github.com/nodejs/node/commit/a114f63627)] - **buffer**: improve toJSON() performance (Brian White) [#10895](https://github.com/nodejs/node/pull/10895) +* [[`9c2f686f7e`](https://github.com/nodejs/node/commit/9c2f686f7e)] - **build**: don't build deps/zlib if --shared-zlib set (Gibson Fahnestock) [#10657](https://github.com/nodejs/node/pull/10657) +* [[`659428fe1d`](https://github.com/nodejs/node/commit/659428fe1d)] - **build**: sort sources alphabetically (Daniel Bevenius) [#10892](https://github.com/nodejs/node/pull/10892) +* [[`74f9cc9f0a`](https://github.com/nodejs/node/commit/74f9cc9f0a)] - **build**: move source files from headers section (Daniel Bevenius) [#10850](https://github.com/nodejs/node/pull/10850) +* [[`a408ba6454`](https://github.com/nodejs/node/commit/a408ba6454)] - **build**: don't squash signal handlers with --shared (Stewart X Addison) [#10539](https://github.com/nodejs/node/pull/10539) +* [[`ddcd1a202f`](https://github.com/nodejs/node/commit/ddcd1a202f)] - **child_process**: optimize IPC for large data (Yuya Tanaka) [#10557](https://github.com/nodejs/node/pull/10557) +* [[`d751afae0f`](https://github.com/nodejs/node/commit/d751afae0f)] - **cluster**: refactor module into multiple files (cjihrig) [#10746](https://github.com/nodejs/node/pull/10746) +* [[`6687b95263`](https://github.com/nodejs/node/commit/6687b95263)] - **crypto**: return the retval of HMAC_Update (Travis Meisenheimer) [#10891](https://github.com/nodejs/node/pull/10891) +* [[`a1897c1445`](https://github.com/nodejs/node/commit/a1897c1445)] - **(SEMVER-MINOR)** **crypto**: ability to select cert store at runtime (Adam Majer) [#8334](https://github.com/nodejs/node/pull/8334) +* [[`aeea13b6f6`](https://github.com/nodejs/node/commit/aeea13b6f6)] - **(SEMVER-MINOR)** **crypto**: Use system CAs instead of using bundled ones (Adam Majer) [#8334](https://github.com/nodejs/node/pull/8334) +* [[`ac2b059500`](https://github.com/nodejs/node/commit/ac2b059500)] - **(SEMVER-MINOR)** **crypto**: do not use pointers to std::vector (Adam Majer) [#8334](https://github.com/nodejs/node/pull/8334) +* [[`5fd0f9ae63`](https://github.com/nodejs/node/commit/5fd0f9ae63)] - **crypto**: freelist_max_len is gone in OpenSSL 1.1.0 (Adam Langley) [#10859](https://github.com/nodejs/node/pull/10859) +* [[`4e7a31b3a0`](https://github.com/nodejs/node/commit/4e7a31b3a0)] - **crypto,tls**: fix mutability of return values (Rich Trott) [#10795](https://github.com/nodejs/node/pull/10795) +* [[`84a9c158ef`](https://github.com/nodejs/node/commit/84a9c158ef)] - **deps**: fix npm files from upgrade to 4.1.2 (João Reis) [#11085](https://github.com/nodejs/node/pull/11085) +* [[`9e60af893c`](https://github.com/nodejs/node/commit/9e60af893c)] - **deps**: upgrade npm to 4.1.2 (Kat Marchán) [#11020](https://github.com/nodejs/node/pull/11020) +* [[`da59a57d60`](https://github.com/nodejs/node/commit/da59a57d60)] - **deps**: limit regress/regress-crbug-514081 v8 test (Michael Dawson) [#6678](https://github.com/nodejs/node/pull/6678) +* [[`edd20720ac`](https://github.com/nodejs/node/commit/edd20720ac)] - **deps**: update openssl asm and asm_obsolete files (Shigeki Ohtsu) [#11021](https://github.com/nodejs/node/pull/11021) +* [[`ce20ad76ec`](https://github.com/nodejs/node/commit/ce20ad76ec)] - **deps**: add -no_rand_screen to openssl s_client (Shigeki Ohtsu) [nodejs/io.js#1836](https://github.com/nodejs/io.js/pull/1836) +* [[`06f87c3e0a`](https://github.com/nodejs/node/commit/06f87c3e0a)] - **deps**: fix asm build error of openssl in x86_win32 (Shigeki Ohtsu) [iojs/io.js#1389](https://github.com/iojs/io.js/pull/1389) +* [[`093cacf61b`](https://github.com/nodejs/node/commit/093cacf61b)] - **deps**: fix openssl assembly error on ia32 win32 (Fedor Indutny) [iojs/io.js#1389](https://github.com/iojs/io.js/pull/1389) +* [[`a3b3b35c53`](https://github.com/nodejs/node/commit/a3b3b35c53)] - **deps**: copy all openssl header files to include dir (Shigeki Ohtsu) [#11021](https://github.com/nodejs/node/pull/11021) +* [[`6a0f1fabb1`](https://github.com/nodejs/node/commit/6a0f1fabb1)] - **deps**: upgrade openssl sources to 1.0.2k (Shigeki Ohtsu) [#11021](https://github.com/nodejs/node/pull/11021) +* [[`1fae98b833`](https://github.com/nodejs/node/commit/1fae98b833)] - **deps**: upgrade npm to 4.1.1 (Rebecca Turner) [#10781](https://github.com/nodejs/node/pull/10781) +* [[`6e0888ad9e`](https://github.com/nodejs/node/commit/6e0888ad9e)] - **deps**: add test for v8 bug in toUpper('ç') (Steven R. Loomis) [#9828](https://github.com/nodejs/node/pull/9828) +* [[`1c4bf9e8ff`](https://github.com/nodejs/node/commit/1c4bf9e8ff)] - **deps**: cherry-pick 2f5da9a from V8 upstream (Steven R. Loomis) [#9828](https://github.com/nodejs/node/pull/9828) +* [[`ffd938a694`](https://github.com/nodejs/node/commit/ffd938a694)] - **deps**: upgrade libuv to 1.10.2 (cjihrig) [#10717](https://github.com/nodejs/node/pull/10717) +* [[`aa6b9f979e`](https://github.com/nodejs/node/commit/aa6b9f979e)] - **deps**: cherry-pick baba152 from V8 upstream (Michaël Zasso) [#10688](https://github.com/nodejs/node/pull/10688) +* [[`5887396150`](https://github.com/nodejs/node/commit/5887396150)] - **deps**: cherry-pick a814b8a from upstream V8 (ishell@chromium.org) [#10733](https://github.com/nodejs/node/pull/10733) +* [[`cfc4c62249`](https://github.com/nodejs/node/commit/cfc4c62249)] - **doc**: correct and complete dgram's Socket.bind docs (Alex Jordan) [#11025](https://github.com/nodejs/node/pull/11025) +* [[`55e98c66c0`](https://github.com/nodejs/node/commit/55e98c66c0)] - **doc**: add abouthiroppy to collaborators (Yuta Hiroto) [#11080](https://github.com/nodejs/node/pull/11080) +* [[`722ae8700f`](https://github.com/nodejs/node/commit/722ae8700f)] - **doc**: add who to CC list for dgram (cjihrig) [#11035](https://github.com/nodejs/node/pull/11035) +* [[`a8533acee6`](https://github.com/nodejs/node/commit/a8533acee6)] - **doc**: change logical to bitwise OR in dns lookup (Sakthipriyan Vairamani (thefourtheye)) [#11037](https://github.com/nodejs/node/pull/11037) +* [[`ac36d78d56`](https://github.com/nodejs/node/commit/ac36d78d56)] - **doc**: fix typo in http.md (Peter Mescalchin) [#10975](https://github.com/nodejs/node/pull/10975) +* [[`0bf3b24771`](https://github.com/nodejs/node/commit/0bf3b24771)] - **doc**: remove Chris Dickinson from active releasers (Ben Noordhuis) [#11011](https://github.com/nodejs/node/pull/11011) +* [[`9ca404ed25`](https://github.com/nodejs/node/commit/9ca404ed25)] - **doc**: for style, remove "isn't" contraction (Sam Roberts) [#10981](https://github.com/nodejs/node/pull/10981) +* [[`4be9e98448`](https://github.com/nodejs/node/commit/4be9e98448)] - **doc**: make os api doc more consistent (Evan Lucas) [#10994](https://github.com/nodejs/node/pull/10994) +* [[`7dff6aa67f`](https://github.com/nodejs/node/commit/7dff6aa67f)] - **doc**: update http.md for consistency and clarity (Lance Ball) [#10715](https://github.com/nodejs/node/pull/10715) +* [[`dd608591a8`](https://github.com/nodejs/node/commit/dd608591a8)] - **doc**: clarify Buffer.indexOf/lastIndexOf edge cases (dcposch@dcpos.ch) [#10162](https://github.com/nodejs/node/pull/10162) +* [[`5250b3358e`](https://github.com/nodejs/node/commit/5250b3358e)] - **doc**: document argument variant in the repl.md (Vse Mozhet Byt) [#10221](https://github.com/nodejs/node/pull/10221) +* [[`c4b9f0a75e`](https://github.com/nodejs/node/commit/c4b9f0a75e)] - **doc**: DEFAULT_ECDH_CURVE was added in 0.11.13 (Sam Roberts) [#10983](https://github.com/nodejs/node/pull/10983) +* [[`84e2ff3738`](https://github.com/nodejs/node/commit/84e2ff3738)] - **(SEMVER-MINOR)** **doc**: add basic documentation for WHATWG URL API (James M Snell) [#10620](https://github.com/nodejs/node/pull/10620) +* [[`9d91bf9788`](https://github.com/nodejs/node/commit/9d91bf9788)] - **doc**: HTTP response getHeader doc fix (Faiz Halde) [#10817](https://github.com/nodejs/node/pull/10817) +* [[`06acf88117`](https://github.com/nodejs/node/commit/06acf88117)] - **doc**: remove duplicate properties bullet in readme (Javis Sullivan) [#10741](https://github.com/nodejs/node/pull/10741) +* [[`09ac2a2cb7`](https://github.com/nodejs/node/commit/09ac2a2cb7)] - **doc**: specify sorted requires in tests (Sam Roberts) [#10716](https://github.com/nodejs/node/pull/10716) +* [[`f380a5fb5a`](https://github.com/nodejs/node/commit/f380a5fb5a)] - **doc**: mention cc-ing nodejs/python team for reviews (Anna Henningsen) [#10637](https://github.com/nodejs/node/pull/10637) +* [[`58bb263438`](https://github.com/nodejs/node/commit/58bb263438)] - **doc**: update TheAlphaNerd to MylesBorins (Myles Borins) [#10586](https://github.com/nodejs/node/pull/10586) +* [[`1253650cf4`](https://github.com/nodejs/node/commit/1253650cf4)] - **doc**: update examples in api/crypto.md (Vse Mozhet Byt) [#10909](https://github.com/nodejs/node/pull/10909) +* [[`3177d6557a`](https://github.com/nodejs/node/commit/3177d6557a)] - **doc**: move topics/guides to website (Evan Lucas) [#10896](https://github.com/nodejs/node/pull/10896) +* [[`d2896d92a7`](https://github.com/nodejs/node/commit/d2896d92a7)] - **doc**: update AUTHORS list to fix name (Noah Rose Ledesma) [#10945](https://github.com/nodejs/node/pull/10945) +* [[`4ffcefdc09`](https://github.com/nodejs/node/commit/4ffcefdc09)] - **doc**: add TimothyGu to collaborators (Timothy Gu) [#10954](https://github.com/nodejs/node/pull/10954) +* [[`3fcf0aed4a`](https://github.com/nodejs/node/commit/3fcf0aed4a)] - **doc**: mention moderation repo in onboarding doc (Anna Henningsen) [#10869](https://github.com/nodejs/node/pull/10869) +* [[`79d8db0fef`](https://github.com/nodejs/node/commit/79d8db0fef)] - **doc**: add edsadr to collaborators (Adrian Estrada) [#10883](https://github.com/nodejs/node/pull/10883) +* [[`520b1f7853`](https://github.com/nodejs/node/commit/520b1f7853)] - **doc**: clarifying variables in fs.write() (Jessica Quynh Tran) [#9792](https://github.com/nodejs/node/pull/9792) +* [[`daf1bf588b`](https://github.com/nodejs/node/commit/daf1bf588b)] - **doc**: add links for zlib convenience methods (Anna Henningsen) [#10829](https://github.com/nodejs/node/pull/10829) +* [[`aeaf887700`](https://github.com/nodejs/node/commit/aeaf887700)] - **doc**: fix markdown escaping in CHANGELOG_V7.md (Anna Henningsen) [#10827](https://github.com/nodejs/node/pull/10827) +* [[`c8b0fc6d8b`](https://github.com/nodejs/node/commit/c8b0fc6d8b)] - **doc**: remove duplicate PR link from changelog (Anna Henningsen) [#10827](https://github.com/nodejs/node/pull/10827) +* [[`049258b062`](https://github.com/nodejs/node/commit/049258b062)] - **doc**: fixup `added` tags in cli.md (Anna Henningsen) [#10826](https://github.com/nodejs/node/pull/10826) +* [[`61798d1fa4`](https://github.com/nodejs/node/commit/61798d1fa4)] - **doc**: add missing `added:` tag for `zlib.constants` (Anna Henningsen) [#10826](https://github.com/nodejs/node/pull/10826) +* [[`73939ec701`](https://github.com/nodejs/node/commit/73939ec701)] - **doc**: clarify memory sharing behavior of buffer ctor (Zach Bjornson) [#10778](https://github.com/nodejs/node/pull/10778) +* [[`f8b081b519`](https://github.com/nodejs/node/commit/f8b081b519)] - **doc**: fix broken internal link in process.md (Anna Henningsen) [#10828](https://github.com/nodejs/node/pull/10828) +* [[`a53f881f57`](https://github.com/nodejs/node/commit/a53f881f57)] - **doc**: update writable.write return value (Nathan Phillip Brink) [#10582](https://github.com/nodejs/node/pull/10582) +* [[`6e1a3d1e57`](https://github.com/nodejs/node/commit/6e1a3d1e57)] - **doc**: use correct tls certificate property name (Sam Roberts) [#10389](https://github.com/nodejs/node/pull/10389) +* [[`23edfe00b3`](https://github.com/nodejs/node/commit/23edfe00b3)] - **doc**: edit writing-tests.md (Rich Trott) [#10585](https://github.com/nodejs/node/pull/10585) +* [[`9b73a8524f`](https://github.com/nodejs/node/commit/9b73a8524f)] - **doc**: fix misleading language in vm docs (Alexey Orlenko) [#10708](https://github.com/nodejs/node/pull/10708) +* [[`56ea7eb9a7`](https://github.com/nodejs/node/commit/56ea7eb9a7)] - **doc**: mention cc-ing nodejs/url team for reviews (Anna Henningsen) [#10652](https://github.com/nodejs/node/pull/10652) +* [[`66b34eac2f`](https://github.com/nodejs/node/commit/66b34eac2f)] - **doc**: sort require statements in tests (Sam Roberts) [#10616](https://github.com/nodejs/node/pull/10616) +* [[`238466bcf0`](https://github.com/nodejs/node/commit/238466bcf0)] - **doc**: handle backpressure when write() return false (Matteo Collina) [#10631](https://github.com/nodejs/node/pull/10631) +* [[`ec226a2a3b`](https://github.com/nodejs/node/commit/ec226a2a3b)] - **doc**: add test naming information to guide (Rich Trott) [#10584](https://github.com/nodejs/node/pull/10584) +* [[`b73e98bf48`](https://github.com/nodejs/node/commit/b73e98bf48)] - **doc**: fix missing negation in stream.md (Johannes Rieken) [#10712](https://github.com/nodejs/node/pull/10712) +* [[`bf95b074cd`](https://github.com/nodejs/node/commit/bf95b074cd)] - **doc**: "s/git apply/git am -3" in V8 guide (Myles Borins) [#10665](https://github.com/nodejs/node/pull/10665) +* [[`9c89b2f704`](https://github.com/nodejs/node/commit/9c89b2f704)] - **doc**: update LTS info for current releases (Evan Lucas) [#10720](https://github.com/nodejs/node/pull/10720) +* [[`3f1775707e`](https://github.com/nodejs/node/commit/3f1775707e)] - **doc**: correct vcbuild options for windows testing (Jonathan Boarman) [#10686](https://github.com/nodejs/node/pull/10686) +* [[`8314d9ee73`](https://github.com/nodejs/node/commit/8314d9ee73)] - **doc**: killSignal option accepts integer values (Sakthipriyan Vairamani (thefourtheye)) [#10424](https://github.com/nodejs/node/pull/10424) +* [[`736a7f3dd3`](https://github.com/nodejs/node/commit/736a7f3dd3)] - **doc**: update BUILDING.md (Lukasz Gasior) [#10669](https://github.com/nodejs/node/pull/10669) +* [[`f81bd48818`](https://github.com/nodejs/node/commit/f81bd48818)] - **doc**: document use of Refs: for references (Gibson Fahnestock) [#10670](https://github.com/nodejs/node/pull/10670) +* [[`b70dde0050`](https://github.com/nodejs/node/commit/b70dde0050)] - **doc**: new TLSSocket has no secure context options (Sam Roberts) [#10545](https://github.com/nodejs/node/pull/10545) +* [[`d3628d9e47`](https://github.com/nodejs/node/commit/d3628d9e47)] - **doc**: modernize child_process example code (Vse Mozhet Byt) [#10102](https://github.com/nodejs/node/pull/10102) +* [[`3270d4c89b`](https://github.com/nodejs/node/commit/3270d4c89b)] - **doc**: clarify information about ABI version (Rich Trott) [#10419](https://github.com/nodejs/node/pull/10419) +* [[`1fca69c263`](https://github.com/nodejs/node/commit/1fca69c263)] - **doc,test**: tls .ca option supports multi-PEM files (Sam Roberts) [#10389](https://github.com/nodejs/node/pull/10389) +* [[`78a495e1a4`](https://github.com/nodejs/node/commit/78a495e1a4)] - **eslint**: remove dangling eslint symlink (Sam Roberts) [#10771](https://github.com/nodejs/node/pull/10771) +* [[`5cca69320f`](https://github.com/nodejs/node/commit/5cca69320f)] - **events**: avoid emit() eager deopt (Victor Felder) [#10568](https://github.com/nodejs/node/pull/10568) +* [[`ded17579e5`](https://github.com/nodejs/node/commit/ded17579e5)] - **events**: improve removeListener() performance (Brian White) [#10572](https://github.com/nodejs/node/pull/10572) +* [[`d047f8e8f8`](https://github.com/nodejs/node/commit/d047f8e8f8)] - **fs**: remove unused parameter for encodeRealpathResult (Jackson Tian) [#10862](https://github.com/nodejs/node/pull/10862) +* [[`4c0f29723c`](https://github.com/nodejs/node/commit/4c0f29723c)] - **http**: use direct parameters instead (Jackson Tian) [#10833](https://github.com/nodejs/node/pull/10833) +* [[`c32984361a`](https://github.com/nodejs/node/commit/c32984361a)] - **http**: make request.abort() destroy the socket (Luigi Pinca) [#10818](https://github.com/nodejs/node/pull/10818) +* [[`8ba2cf9c51`](https://github.com/nodejs/node/commit/8ba2cf9c51)] - **http**: define all used properties in constructors (vitkarpov) [#9116](https://github.com/nodejs/node/pull/9116) +* [[`75aa6050ab`](https://github.com/nodejs/node/commit/75aa6050ab)] - **http**: eliminate capture of ClientRequest in Agent (Evan Torrie) [#10134](https://github.com/nodejs/node/pull/10134) +* [[`5059b76cbc`](https://github.com/nodejs/node/commit/5059b76cbc)] - **http**: misc ClientRequest cleanup (Brian White) [#10654](https://github.com/nodejs/node/pull/10654) +* [[`44c0e4f1ad`](https://github.com/nodejs/node/commit/44c0e4f1ad)] - **http**: avoid duplicate isArray() (Brian White) [#10654](https://github.com/nodejs/node/pull/10654) +* [[`e7859c217f`](https://github.com/nodejs/node/commit/e7859c217f)] - **http**: optimize default method case (Brian White) [#10654](https://github.com/nodejs/node/pull/10654) +* [[`c9bff043c7`](https://github.com/nodejs/node/commit/c9bff043c7)] - **http**: optimize short path validation (Brian White) [#10654](https://github.com/nodejs/node/pull/10654) +* [[`c012dd79dc`](https://github.com/nodejs/node/commit/c012dd79dc)] - **https**: Use secureProtocol in Agent#getName (Andreas Lind) [#9452](https://github.com/nodejs/node/pull/9452) +* [[`9a111e701e`](https://github.com/nodejs/node/commit/9a111e701e)] - **inspector**: no crash when WS server can't start (Eugene Ostroukhov) [#10878](https://github.com/nodejs/node/pull/10878) +* [[`2d08bbadd6`](https://github.com/nodejs/node/commit/2d08bbadd6)] - **inspector**: stop relying on magic strings (Eugene Ostroukhov) [#10159](https://github.com/nodejs/node/pull/10159) +* [[`e30e307a70`](https://github.com/nodejs/node/commit/e30e307a70)] - **inspector**: move options parsing (Eugene Ostroukhov) [#9691](https://github.com/nodejs/node/pull/9691) +* [[`60f27f91e4`](https://github.com/nodejs/node/commit/60f27f91e4)] - **inspector**: remove unused uv_async_t (Eugene Ostroukhov) [#10392](https://github.com/nodejs/node/pull/10392) +* [[`a3abba0b1a`](https://github.com/nodejs/node/commit/a3abba0b1a)] - **lib**: remove unnecessary parameter for assertCrypto() (Jackson Tian) [#10834](https://github.com/nodejs/node/pull/10834) +* [[`4de7b03a7d`](https://github.com/nodejs/node/commit/4de7b03a7d)] - **lib**: refactor bootstrap_node.js regular expression (Rich Trott) [#10749](https://github.com/nodejs/node/pull/10749) +* [[`a6c93af244`](https://github.com/nodejs/node/commit/a6c93af244)] - **lib**: refactor crypto cipher/hash/curve getters (Rich Trott) [#10682](https://github.com/nodejs/node/pull/10682) +* [[`6e8d627217`](https://github.com/nodejs/node/commit/6e8d627217)] - **lib,src**: support values > 4GB in heap statistics (Ben Noordhuis) [#10186](https://github.com/nodejs/node/pull/10186) +* [[`de8eee6b16`](https://github.com/nodejs/node/commit/de8eee6b16)] - **meta**: decharter the http working group (James M Snell) [#10604](https://github.com/nodejs/node/pull/10604) +* [[`4caa0126aa`](https://github.com/nodejs/node/commit/4caa0126aa)] - **openssl**: fix keypress requirement in apps on win32 (Shigeki Ohtsu) [iojs/io.js#1389](https://github.com/iojs/io.js/pull/1389) +* [[`d24491c6a7`](https://github.com/nodejs/node/commit/d24491c6a7)] - **(SEMVER-MINOR)** **process**: add NODE_NO_WARNINGS environment variable (cjihrig) [#10842](https://github.com/nodejs/node/pull/10842) +* [[`97ff43232b`](https://github.com/nodejs/node/commit/97ff43232b)] - **querystring**: improve unescapeBuffer performance (Brian White) [#10837](https://github.com/nodejs/node/pull/10837) +* [[`f4796d5f6e`](https://github.com/nodejs/node/commit/f4796d5f6e)] - **querystring**: improve stringify() performance (Brian White) [#10852](https://github.com/nodejs/node/pull/10852) +* [[`53421b174c`](https://github.com/nodejs/node/commit/53421b174c)] - **querystring**: improve parse() performance (Brian White) [#10874](https://github.com/nodejs/node/pull/10874) +* [[`d64e2371f6`](https://github.com/nodejs/node/commit/d64e2371f6)] - **readline**: refactor construct Interface (Jackson Tian) [#4740](https://github.com/nodejs/node/pull/4740) +* [[`e7b656db6e`](https://github.com/nodejs/node/commit/e7b656db6e)] - ***Revert*** "**repl**: disable Ctrl+C support on win32 for now" (Anna Henningsen) [#8645](https://github.com/nodejs/node/pull/8645) +* [[`a24264eb18`](https://github.com/nodejs/node/commit/a24264eb18)] - **src**: fix v8 local handling in node_url.cc (Anna Henningsen) [#11064](https://github.com/nodejs/node/pull/11064) +* [[`8a6367cb20`](https://github.com/nodejs/node/commit/8a6367cb20)] - ***Revert*** "**src**: don't overwrite non-writable vm globals" (Anna Henningsen) [#10920](https://github.com/nodejs/node/pull/10920) +* [[`978acd138f`](https://github.com/nodejs/node/commit/978acd138f)] - **(SEMVER-MINOR)** **src**: support "--" after "-e" as end-of-options (John Barboza) [#10651](https://github.com/nodejs/node/pull/10651) +* [[`cd94642356`](https://github.com/nodejs/node/commit/cd94642356)] - **src**: add NODE_NO_WARNINGS to --help output (cjihrig) [#10918](https://github.com/nodejs/node/pull/10918) +* [[`63f43021b0`](https://github.com/nodejs/node/commit/63f43021b0)] - **src**: remove unused PROTOCOL_JSON array (Ben Noordhuis) [#10407](https://github.com/nodejs/node/pull/10407) +* [[`5a976decf7`](https://github.com/nodejs/node/commit/5a976decf7)] - **src**: remove unnecessary req_wrap_obj (Daniel Bevenius) [#10942](https://github.com/nodejs/node/pull/10942) +* [[`0c0334f7a4`](https://github.com/nodejs/node/commit/0c0334f7a4)] - **src**: add a missing space in node_os.cc (Alexey Orlenko) [#10931](https://github.com/nodejs/node/pull/10931) +* [[`b89d848b36`](https://github.com/nodejs/node/commit/b89d848b36)] - **src**: enable writev for pipe handles on Unix (Alexey Orlenko) [#10677](https://github.com/nodejs/node/pull/10677) +* [[`f0de955220`](https://github.com/nodejs/node/commit/f0de955220)] - **src**: reduce test_inspector_socket_server output (Daniel Bevenius) [#10537](https://github.com/nodejs/node/pull/10537) +* [[`59196af646`](https://github.com/nodejs/node/commit/59196af646)] - **stream**: avoid additional validation for Buffers (Brian White) [#10580](https://github.com/nodejs/node/pull/10580) +* [[`fe80bd9600`](https://github.com/nodejs/node/commit/fe80bd9600)] - **test**: add 2nd argument to throws in test-assert (Marlena Compton) [#11061](https://github.com/nodejs/node/pull/11061) +* [[`8ef4add4c3`](https://github.com/nodejs/node/commit/8ef4add4c3)] - **test**: require handler to be run in sigwinch test (Rich Trott) [#11068](https://github.com/nodejs/node/pull/11068) +* [[`e367b74c4f`](https://github.com/nodejs/node/commit/e367b74c4f)] - **test**: add an exception test to http-write-head (Yuta Hiroto) [#11034](https://github.com/nodejs/node/pull/11034) +* [[`65691d68d5`](https://github.com/nodejs/node/commit/65691d68d5)] - **test**: increase coverage of internal/util (DavidCai) [#10964](https://github.com/nodejs/node/pull/10964) +* [[`0753bc17b6`](https://github.com/nodejs/node/commit/0753bc17b6)] - **test**: increase timeout in break-on-uncaught (Sakthipriyan Vairamani (thefourtheye)) [#10822](https://github.com/nodejs/node/pull/10822) +* [[`eff3a48e63`](https://github.com/nodejs/node/commit/eff3a48e63)] - **test**: add known_issues test for #10223 (AnnaMag) [#11024](https://github.com/nodejs/node/pull/11024) +* [[`72a97b66dc`](https://github.com/nodejs/node/commit/72a97b66dc)] - **test**: guarantee test runs in test-readline-keys (Rich Trott) [#11023](https://github.com/nodejs/node/pull/11023) +* [[`e3a316f3e6`](https://github.com/nodejs/node/commit/e3a316f3e6)] - **test**: check error message in test-http-outgoing-proto (Alex Ling) [#10943](https://github.com/nodejs/node/pull/10943) +* [[`fcd08b8a1e`](https://github.com/nodejs/node/commit/fcd08b8a1e)] - **test**: add tests for searchParams (abouthiroppy) [#10952](https://github.com/nodejs/node/pull/10952) +* [[`f3efaeed35`](https://github.com/nodejs/node/commit/f3efaeed35)] - **test**: increase coverage for stream's duplex (abouthiroppy) [#10963](https://github.com/nodejs/node/pull/10963) +* [[`b5e8413c3f`](https://github.com/nodejs/node/commit/b5e8413c3f)] - **test**: allow for slow hosts in spawnSync() test (Rich Trott) [#10998](https://github.com/nodejs/node/pull/10998) +* [[`cfd1b19c34`](https://github.com/nodejs/node/commit/cfd1b19c34)] - **test**: expand test coverage of fs.js (Vinícius do Carmo) [#10947](https://github.com/nodejs/node/pull/10947) +* [[`4aedde8d82`](https://github.com/nodejs/node/commit/4aedde8d82)] - **test**: expand test coverage of events.js (Vinícius do Carmo) [#10947](https://github.com/nodejs/node/pull/10947) +* [[`c1e166a168`](https://github.com/nodejs/node/commit/c1e166a168)] - **test**: check noAssert option in buf.write*() (larissayvette) [#10790](https://github.com/nodejs/node/pull/10790) +* [[`580a453fcf`](https://github.com/nodejs/node/commit/580a453fcf)] - **test**: expand test coverage of fs.js (Vinícius do Carmo) [#10972](https://github.com/nodejs/node/pull/10972) +* [[`fa8baa2aa1`](https://github.com/nodejs/node/commit/fa8baa2aa1)] - **test**: enhance test-timers (Rich Trott) [#10960](https://github.com/nodejs/node/pull/10960) +* [[`74ff804dbd`](https://github.com/nodejs/node/commit/74ff804dbd)] - **test**: add regression tests for vm bugs (Anna Henningsen) [#10920](https://github.com/nodejs/node/pull/10920) +* [[`1a39bfb7e2`](https://github.com/nodejs/node/commit/1a39bfb7e2)] - **test**: increase coverage for exec() functions (cjihrig) [#10919](https://github.com/nodejs/node/pull/10919) +* [[`4b38744e9b`](https://github.com/nodejs/node/commit/4b38744e9b)] - **test**: add process.assert's test (abouthiroppy) [#10911](https://github.com/nodejs/node/pull/10911) +* [[`e7c953a5f9`](https://github.com/nodejs/node/commit/e7c953a5f9)] - **test**: update Buffer.lastIndexOf (dcposch@dcpos.ch) [#10162](https://github.com/nodejs/node/pull/10162) +* [[`eb7ee50717`](https://github.com/nodejs/node/commit/eb7ee50717)] - **test**: improve code in test-crypto-verify (Adrian Estrada) [#10845](https://github.com/nodejs/node/pull/10845) +* [[`efa9845946`](https://github.com/nodejs/node/commit/efa9845946)] - **test**: refactor test-cli-eval.js (cjihrig) [#10898](https://github.com/nodejs/node/pull/10898) +* [[`b7bf43aa2b`](https://github.com/nodejs/node/commit/b7bf43aa2b)] - **test**: use common.fail() instead of assert(false) (cjihrig) [#10899](https://github.com/nodejs/node/pull/10899) +* [[`90a99177a3`](https://github.com/nodejs/node/commit/90a99177a3)] - **test**: add dgram.Socket.prototype.bind's test (abouthiroppy) [#10894](https://github.com/nodejs/node/pull/10894) +* [[`dc826caed2`](https://github.com/nodejs/node/commit/dc826caed2)] - **test**: update V8 flag in test (Franziska Hinkelmann) [#10917](https://github.com/nodejs/node/pull/10917) +* [[`537d954ed2`](https://github.com/nodejs/node/commit/537d954ed2)] - **test**: increase coverage of string-decoder (abouthiroppy) [#10863](https://github.com/nodejs/node/pull/10863) +* [[`3cd9833eff`](https://github.com/nodejs/node/commit/3cd9833eff)] - **test**: add tests for rs+, sr+ to test-fs-open-flags.js (abouthiroppy) [#10780](https://github.com/nodejs/node/pull/10780) +* [[`c8a069e544`](https://github.com/nodejs/node/commit/c8a069e544)] - **test**: improving coverage of dns-lookup (abouthiroppy) [#10844](https://github.com/nodejs/node/pull/10844) +* [[`939517abfd`](https://github.com/nodejs/node/commit/939517abfd)] - **test**: refactor test-fs-read-zero-length.js (abouthiroppy) [#10729](https://github.com/nodejs/node/pull/10729) +* [[`ffdf605f14`](https://github.com/nodejs/node/commit/ffdf605f14)] - **test**: improving coverage for dgram (abouthiroppy) [#10783](https://github.com/nodejs/node/pull/10783) +* [[`1666600f16`](https://github.com/nodejs/node/commit/1666600f16)] - **test**: improve code in test-console-instance (Adrian Estrada) [#10813](https://github.com/nodejs/node/pull/10813) +* [[`b496374363`](https://github.com/nodejs/node/commit/b496374363)] - **test**: improve code in test-domain-multi (Adrian Estrada) [#10798](https://github.com/nodejs/node/pull/10798) +* [[`46bbabe6c2`](https://github.com/nodejs/node/commit/46bbabe6c2)] - **test**: improve test-stream2-large-read-stall (stefan judis) [#10725](https://github.com/nodejs/node/pull/10725) +* [[`7f043779eb`](https://github.com/nodejs/node/commit/7f043779eb)] - **test**: improve code in test-http-host-headers (Adrian Estrada) [#10830](https://github.com/nodejs/node/pull/10830) +* [[`66c57a24c2`](https://github.com/nodejs/node/commit/66c57a24c2)] - **test**: add test case to test-http-response-statuscode.js (abouthiroppy) [#10808](https://github.com/nodejs/node/pull/10808) +* [[`4a7bb5b4d1`](https://github.com/nodejs/node/commit/4a7bb5b4d1)] - **test**: improve the code in test-crypto-dh (Adrian Estrada) [#10734](https://github.com/nodejs/node/pull/10734) +* [[`825842c185`](https://github.com/nodejs/node/commit/825842c185)] - **test**: getgroups() may contain duplicate GIDs (Sam Roberts) [#10389](https://github.com/nodejs/node/pull/10389) +* [[`c6618df2cc`](https://github.com/nodejs/node/commit/c6618df2cc)] - **test**: improve test stream transform constructor (Adrian Estrada) [#10699](https://github.com/nodejs/node/pull/10699) +* [[`51f4c8bf5c`](https://github.com/nodejs/node/commit/51f4c8bf5c)] - **test**: s/assert.equal/assert.strictEqual/ (Gibson Fahnestock) [#10698](https://github.com/nodejs/node/pull/10698) +* [[`a6bd287724`](https://github.com/nodejs/node/commit/a6bd287724)] - **test**: use eslint to fix var->const/let (Gibson Fahnestock) [#10685](https://github.com/nodejs/node/pull/10685) +* [[`e6b6ce429c`](https://github.com/nodejs/node/commit/e6b6ce429c)] - **test**: refactor test-http-mutable-headers.js (cjihrig) [#10664](https://github.com/nodejs/node/pull/10664) +* [[`8262d49a44`](https://github.com/nodejs/node/commit/8262d49a44)] - **test**: refactor cluster-preload.js (abouthiroppy) [#10701](https://github.com/nodejs/node/pull/10701) +* [[`fc0551072b`](https://github.com/nodejs/node/commit/fc0551072b)] - **test**: improve test-crypto-rsa-dsa (Adrian Estrada) [#10681](https://github.com/nodejs/node/pull/10681) +* [[`727c5e3c96`](https://github.com/nodejs/node/commit/727c5e3c96)] - **test**: improve test-fs-write-file-sync (Adrian Estrada) [#10624](https://github.com/nodejs/node/pull/10624) +* [[`50130220dc`](https://github.com/nodejs/node/commit/50130220dc)] - **test**: s/assert.notEqual()/assert.notStrictEqual()/ (cjihrig) [#10541](https://github.com/nodejs/node/pull/10541) +* [[`44174a52a6`](https://github.com/nodejs/node/commit/44174a52a6)] - **test**: refactor the code in test-util-debug.js (sivaprasanna) [#10531](https://github.com/nodejs/node/pull/10531) +* [[`b1c742e107`](https://github.com/nodejs/node/commit/b1c742e107)] - **test**: improve test-fs-access (Adrian Estrada) [#10542](https://github.com/nodejs/node/pull/10542) +* [[`db7b27abb9`](https://github.com/nodejs/node/commit/db7b27abb9)] - **test**: refactor beforeExit tests (Rich Trott) [#10581](https://github.com/nodejs/node/pull/10581) +* [[`33851d1e2c`](https://github.com/nodejs/node/commit/33851d1e2c)] - **test**: fix process.title expectation (Sakthipriyan Vairamani (thefourtheye)) [#10597](https://github.com/nodejs/node/pull/10597) +* [[`af2bea70e0`](https://github.com/nodejs/node/commit/af2bea70e0)] - **test**: refactor test-beforeexit-event-exit.js (cjihrig) [#10577](https://github.com/nodejs/node/pull/10577) +* [[`0a2fb0d3e1`](https://github.com/nodejs/node/commit/0a2fb0d3e1)] - **test**: refactor several parallel/test-timer tests (Beth Griggs) [#10524](https://github.com/nodejs/node/pull/10524) +* [[`dba8d20ccc`](https://github.com/nodejs/node/commit/dba8d20ccc)] - **test**: improve the code in test-fs-read-stream (Adrian Estrada) [#10556](https://github.com/nodejs/node/pull/10556) +* [[`eba9add48e`](https://github.com/nodejs/node/commit/eba9add48e)] - **test**: refactor test-timer-close (BethGriggs) [#10517](https://github.com/nodejs/node/pull/10517) +* [[`dd9aefde69`](https://github.com/nodejs/node/commit/dd9aefde69)] - **test**: use const for all require() calls (cjihrig) [#10550](https://github.com/nodejs/node/pull/10550) +* [[`807e99b81d`](https://github.com/nodejs/node/commit/807e99b81d)] - **test**: validate errors in test-buffer-indexof (Adrian Estrada) [#10752](https://github.com/nodejs/node/pull/10752) +* [[`32da59ab18`](https://github.com/nodejs/node/commit/32da59ab18)] - **test**: fix broken assertion (cjihrig) [#10840](https://github.com/nodejs/node/pull/10840) +* [[`29a4d354bc`](https://github.com/nodejs/node/commit/29a4d354bc)] - **test**: refactor test-cli-eval.js (Sumit Goel) [#10759](https://github.com/nodejs/node/pull/10759) +* [[`a06419b045`](https://github.com/nodejs/node/commit/a06419b045)] - **test**: refactor test-stream2-readable-wrap.js (David Goussev) [#10551](https://github.com/nodejs/node/pull/10551) +* [[`55377db9b0`](https://github.com/nodejs/node/commit/55377db9b0)] - **test**: refactor test-stream-transform-object (Rich Trott) [#10588](https://github.com/nodejs/node/pull/10588) +* [[`fb35ca3598`](https://github.com/nodejs/node/commit/fb35ca3598)] - **test**: test hmac binding robustness (Sam Roberts) [#10923](https://github.com/nodejs/node/pull/10923) +* [[`94a266e1ef`](https://github.com/nodejs/node/commit/94a266e1ef)] - **test**: refactor the code in test-fs-watch.js (sivaprasanna) [#10357](https://github.com/nodejs/node/pull/10357) +* [[`3575f5159e`](https://github.com/nodejs/node/commit/3575f5159e)] - **test**: reduce unmanaged parallelism in domain test (Joyee Cheung) [#10329](https://github.com/nodejs/node/pull/10329) +* [[`7822d86ee6`](https://github.com/nodejs/node/commit/7822d86ee6)] - **test**: increase usage of assert.ifError() (cjihrig) [#10543](https://github.com/nodejs/node/pull/10543) +* [[`e161dcf1fc`](https://github.com/nodejs/node/commit/e161dcf1fc)] - **test**: add dgram.Socket.prototype.sendto's test (abouthiroppy) [#10901](https://github.com/nodejs/node/pull/10901) +* [[`be3e82dbbb`](https://github.com/nodejs/node/commit/be3e82dbbb)] - **test**: check error message in test-fs-make-callback (legalcodes) [#10914](https://github.com/nodejs/node/pull/10914) +* [[`67d97bce5a`](https://github.com/nodejs/node/commit/67d97bce5a)] - **test**: improve test-assert (richnologies) [#10916](https://github.com/nodejs/node/pull/10916) +* [[`69a04a9c7b`](https://github.com/nodejs/node/commit/69a04a9c7b)] - **test**: increase coverage for punycode's decode (abouthiroppy) [#10940](https://github.com/nodejs/node/pull/10940) +* [[`8778fca82b`](https://github.com/nodejs/node/commit/8778fca82b)] - **test**: check fd 0,1,2 are used, not access mode (John Barboza) [#10339](https://github.com/nodejs/node/pull/10339) +* [[`e80f35c973`](https://github.com/nodejs/node/commit/e80f35c973)] - **test**: verify shell option internals (cjihrig) [#10924](https://github.com/nodejs/node/pull/10924) +* [[`9d5170f850`](https://github.com/nodejs/node/commit/9d5170f850)] - **test**: fix flaky test-regress-GH-897 (Rich Trott) [#10903](https://github.com/nodejs/node/pull/10903) +* [[`c60d87b1ad`](https://github.com/nodejs/node/commit/c60d87b1ad)] - **test**: don't connect to :: (use localhost instead) (Gibson Fahnestock) [#10854](https://github.com/nodejs/node/pull/10854) +* [[`aa4b028523`](https://github.com/nodejs/node/commit/aa4b028523)] - **test**: improve test-fs-open-flags (Vinícius do Carmo) +* [[`35d665958e`](https://github.com/nodejs/node/commit/35d665958e)] - **test**: increase coverage of _http_outgoing (abouthiroppy) [#10820](https://github.com/nodejs/node/pull/10820) +* [[`c4f16949b8`](https://github.com/nodejs/node/commit/c4f16949b8)] - **test**: add message verification on assert.throws (Travis Meisenheimer) [#10890](https://github.com/nodejs/node/pull/10890) +* [[`5ce2ac800b`](https://github.com/nodejs/node/commit/5ce2ac800b)] - **test**: refactor test-repl-tab-complete (Rich Trott) [#10879](https://github.com/nodejs/node/pull/10879) +* [[`999f685a69`](https://github.com/nodejs/node/commit/999f685a69)] - **test**: simplify array initialization (Rich Trott) [#10860](https://github.com/nodejs/node/pull/10860) +* [[`c77078f29f`](https://github.com/nodejs/node/commit/c77078f29f)] - **test**: have inspector test pick an open port (Eugene Ostroukhov) [#10861](https://github.com/nodejs/node/pull/10861) +* [[`aa8771f842`](https://github.com/nodejs/node/commit/aa8771f842)] - **test**: use common.hasIntl in tests related to ICU (Daijiro Wachi) [#10841](https://github.com/nodejs/node/pull/10841) +* [[`5b38776243`](https://github.com/nodejs/node/commit/5b38776243)] - **test**: add http-common's test (abouthiroppy) [#10832](https://github.com/nodejs/node/pull/10832) +* [[`96babb2090`](https://github.com/nodejs/node/commit/96babb2090)] - **test**: tests for _readableStream.awaitDrain (Mark) [#8914](https://github.com/nodejs/node/pull/8914) +* [[`7165f1d409`](https://github.com/nodejs/node/commit/7165f1d409)] - **test**: improve the code in test-process-cpuUsage (Adrian Estrada) [#10714](https://github.com/nodejs/node/pull/10714) +* [[`b5c0b43efa`](https://github.com/nodejs/node/commit/b5c0b43efa)] - **test**: increase test-crypto.js strictness (Rich Trott) [#10784](https://github.com/nodejs/node/pull/10784) +* [[`d818cfaaad`](https://github.com/nodejs/node/commit/d818cfaaad)] - **test**: improve test-fs-write-stream-throw-type (Adrian Estrada) [#10779](https://github.com/nodejs/node/pull/10779) +* [[`77cbc26a96`](https://github.com/nodejs/node/commit/77cbc26a96)] - **test**: delete duplicate test of noAssert in readUInt* (larissayvette) [#10791](https://github.com/nodejs/node/pull/10791) +* [[`36db5a663a`](https://github.com/nodejs/node/commit/36db5a663a)] - **test**: add http_incoming's matchKnownFields test (abouthiroppy) [#10811](https://github.com/nodejs/node/pull/10811) +* [[`31d3a22989`](https://github.com/nodejs/node/commit/31d3a22989)] - **test**: skip test-icu-transcode if Intl is not present (Daijiro Wachi) [#10707](https://github.com/nodejs/node/pull/10707) +* [[`8b02b4ebb4`](https://github.com/nodejs/node/commit/8b02b4ebb4)] - **test**: check error msg test-writeint.js (Irene Li) [#10755](https://github.com/nodejs/node/pull/10755) +* [[`5aad0ccefe`](https://github.com/nodejs/node/commit/5aad0ccefe)] - **test**: no unused args test-fs-watch-file.js (istinson) [#10758](https://github.com/nodejs/node/pull/10758) +* [[`fca0da711d`](https://github.com/nodejs/node/commit/fca0da711d)] - **test**: improve tests in pummel/test-exec (Chase Starr) [#10757](https://github.com/nodejs/node/pull/10757) +* [[`7d917dcb27`](https://github.com/nodejs/node/commit/7d917dcb27)] - **test**: fix temp-dir option in tools/test.py (Gibson Fahnestock) [#10723](https://github.com/nodejs/node/pull/10723) +* [[`6b54024324`](https://github.com/nodejs/node/commit/6b54024324)] - **test**: use realpath for NODE_TEST_DIR in common.js (Gibson Fahnestock) [#10723](https://github.com/nodejs/node/pull/10723) +* [[`c6aeb4491b`](https://github.com/nodejs/node/commit/c6aeb4491b)] - **test**: fix linting for test-tls-add-ca-cert.js (Sam Roberts) [#10771](https://github.com/nodejs/node/pull/10771) +* [[`542f65c66b`](https://github.com/nodejs/node/commit/542f65c66b)] - **test**: tls cert chain completion scenarios (Sam Roberts) [#10389](https://github.com/nodejs/node/pull/10389) +* [[`97a8bd20c6`](https://github.com/nodejs/node/commit/97a8bd20c6)] - **test**: check tls server verification with addCACert (Sam Roberts) [#10389](https://github.com/nodejs/node/pull/10389) +* [[`ebcf834c14`](https://github.com/nodejs/node/commit/ebcf834c14)] - **test**: move common tls connect setup into fixtures (Sam Roberts) [#10389](https://github.com/nodejs/node/pull/10389) +* [[`30926ac6d6`](https://github.com/nodejs/node/commit/30926ac6d6)] - **test**: move resource intensive test to sequential (Rich Trott) [#10744](https://github.com/nodejs/node/pull/10744) +* [[`06a1e9eb7b`](https://github.com/nodejs/node/commit/06a1e9eb7b)] - **test**: add test for noAssert option in buf.read*() (larissayvette) [#10713](https://github.com/nodejs/node/pull/10713) +* [[`160d0381d2`](https://github.com/nodejs/node/commit/160d0381d2)] - **test**: refactor test-crypto-padding-aes256 (adelmann) [#10622](https://github.com/nodejs/node/pull/10622) +* [[`cb111c96cc`](https://github.com/nodejs/node/commit/cb111c96cc)] - **test**: refactor the code of test-keep-alive.js (sivaprasanna) [#10684](https://github.com/nodejs/node/pull/10684) +* [[`dbb7727320`](https://github.com/nodejs/node/commit/dbb7727320)] - **test**: validate 'expected' argument to mustCall() (Nathan Friedly) [#10692](https://github.com/nodejs/node/pull/10692) +* [[`e408f0a1f5`](https://github.com/nodejs/node/commit/e408f0a1f5)] - **test**: fix misplaced ) in http response statuscode test (Nathan Friedly) [#10692](https://github.com/nodejs/node/pull/10692) +* [[`4c8676bc26`](https://github.com/nodejs/node/commit/4c8676bc26)] - **test**: refactor test-doctool-html.js (abouthiroppy) [#10696](https://github.com/nodejs/node/pull/10696) +* [[`da572131db`](https://github.com/nodejs/node/commit/da572131db)] - **test**: improve the code in test-process-hrtime (Adrian Estrada) [#10667](https://github.com/nodejs/node/pull/10667) +* [[`17d9a739c1`](https://github.com/nodejs/node/commit/17d9a739c1)] - **test**: refactor test-watch-file.js (sivaprasanna) [#10679](https://github.com/nodejs/node/pull/10679) +* [[`cf5579d746`](https://github.com/nodejs/node/commit/cf5579d746)] - **test**: improve zlib-from-gzip-with-trailing-garbage (Michael Lefkowitz) [#10674](https://github.com/nodejs/node/pull/10674) +* [[`2d856097b3`](https://github.com/nodejs/node/commit/2d856097b3)] - **test**: refactor the code in test-child-process-spawn-loop.js (sivaprasanna) [#10605](https://github.com/nodejs/node/pull/10605) +* [[`1329eb47f0`](https://github.com/nodejs/node/commit/1329eb47f0)] - **test**: allow testing uid and gid separately (cjihrig) [#10647](https://github.com/nodejs/node/pull/10647) +* [[`4aa32c196a`](https://github.com/nodejs/node/commit/4aa32c196a)] - **test**: improve code in test-https-strict (Adrian Estrada) [#10648](https://github.com/nodejs/node/pull/10648) +* [[`e78de99bcb`](https://github.com/nodejs/node/commit/e78de99bcb)] - **test**: improve test-http-chunked-304 (Adrian Estrada) [#10462](https://github.com/nodejs/node/pull/10462) +* [[`ff23d8112a`](https://github.com/nodejs/node/commit/ff23d8112a)] - **test**: improve test-fs-readfile-zero-byte-liar (Adrian Estrada) [#10570](https://github.com/nodejs/node/pull/10570) +* [[`38bdfb0b8e`](https://github.com/nodejs/node/commit/38bdfb0b8e)] - **test**: refactor test-fs-utimes (Junshu Okamoto) [#9290](https://github.com/nodejs/node/pull/9290) +* [[`09f35a49e3`](https://github.com/nodejs/node/commit/09f35a49e3)] - **test**: provide duration/interval to timers (Rich Trott) [#9472](https://github.com/nodejs/node/pull/9472) +* [[`06a82436c2`](https://github.com/nodejs/node/commit/06a82436c2)] - **test**: improve test-event-emitter-modify-in-emit (Adrian Estrada) [#10600](https://github.com/nodejs/node/pull/10600) +* [[`736b95a617`](https://github.com/nodejs/node/commit/736b95a617)] - **test**: check error and cleanups in test-fs-read-buffer (Anna Henningsen) [#10611](https://github.com/nodejs/node/pull/10611) +* [[`a77940c2d5`](https://github.com/nodejs/node/commit/a77940c2d5)] - **test**: mark test-tty-wrap as flaky for AIX (Michael Dawson) [#10618](https://github.com/nodejs/node/pull/10618) +* [[`cf875d17f3`](https://github.com/nodejs/node/commit/cf875d17f3)] - **test**: improve test-fs-null-bytes (Adrian Estrada) [#10521](https://github.com/nodejs/node/pull/10521) +* [[`656ba86a27`](https://github.com/nodejs/node/commit/656ba86a27)] - **test**: fix Coverity warning in inspector test (Eugene Ostroukhov) [#10510](https://github.com/nodejs/node/pull/10510) +* [[`9916ee8c36`](https://github.com/nodejs/node/commit/9916ee8c36)] - **test**: refactor test-https-truncate (Rich Trott) [#10225](https://github.com/nodejs/node/pull/10225) +* [[`4ff1d3107f`](https://github.com/nodejs/node/commit/4ff1d3107f)] - **test**: add http.ClientRequest defaults test (Brian White) [#10654](https://github.com/nodejs/node/pull/10654) +* [[`1555ced404`](https://github.com/nodejs/node/commit/1555ced404)] - **test, win**: fix up symlink tests (Hitesh Kanwathirtha) [#10477](https://github.com/nodejs/node/pull/10477) +* [[`4323c8018e`](https://github.com/nodejs/node/commit/4323c8018e)] - **test,cluster**: add test-cluster-worker-deprecated (Rich Trott) [#10675](https://github.com/nodejs/node/pull/10675) +* [[`33af09fe6a`](https://github.com/nodejs/node/commit/33af09fe6a)] - **test,net**: add tests for server.connections (Rich Trott) [#10762](https://github.com/nodejs/node/pull/10762) +* [[`fc2db50021`](https://github.com/nodejs/node/commit/fc2db50021)] - **test,repl**: add coverage for repl .clear+useGlobal (Rich Trott) [#10777](https://github.com/nodejs/node/pull/10777) +* [[`84bf04b0c1`](https://github.com/nodejs/node/commit/84bf04b0c1)] - **test,util**: remove lint workarounds (Rich Trott) [#10785](https://github.com/nodejs/node/pull/10785) +* [[`c6af766ad9`](https://github.com/nodejs/node/commit/c6af766ad9)] - **test-console**: streamline arrow fn and refine regex (John Maguire) [#11039](https://github.com/nodejs/node/pull/11039) +* [[`8fae9d4cfb`](https://github.com/nodejs/node/commit/8fae9d4cfb)] - **tools**: rename eslintrc to an undeprecated format (Sakthipriyan Vairamani) [#7699](https://github.com/nodejs/node/pull/7699) +* [[`dd5a4e1d75`](https://github.com/nodejs/node/commit/dd5a4e1d75)] - **tools**: update ESLint to current version (Rich Trott) [#10561](https://github.com/nodejs/node/pull/10561) +* [[`c92b8ecd81`](https://github.com/nodejs/node/commit/c92b8ecd81)] - **(SEMVER-MINOR)** **tools**: add mdn link for Iterator (James M Snell) [#10620](https://github.com/nodejs/node/pull/10620) +* [[`dec5900c42`](https://github.com/nodejs/node/commit/dec5900c42)] - **tools**: add lint rule to enforce timer arguments (Rich Trott) [#9472](https://github.com/nodejs/node/pull/9472) +* [[`891874406a`](https://github.com/nodejs/node/commit/891874406a)] - **tools**: remove no-useless-regex-char-class-escape (Rich Trott) [#10561](https://github.com/nodejs/node/pull/10561) +* [[`1634a7017e`](https://github.com/nodejs/node/commit/1634a7017e)] - **tools**: remove custom align-function-arguments rule (Rich Trott) [#10561](https://github.com/nodejs/node/pull/10561) +* [[`31f8f6f768`](https://github.com/nodejs/node/commit/31f8f6f768)] - **tools, test**: require const/let in test (Gibson Fahnestock) [#10685](https://github.com/nodejs/node/pull/10685) +* [[`d39543e73d`](https://github.com/nodejs/node/commit/d39543e73d)] - **tools,doc**: add Google Analytics tracking. (Phillip Johnsen) [#6601](https://github.com/nodejs/node/pull/6601) +* [[`3adda4b2ad`](https://github.com/nodejs/node/commit/3adda4b2ad)] - **tools,test**: enforce assert.ifError with lint rule (Teddy Katz) [#10671](https://github.com/nodejs/node/pull/10671) +* [[`438a98ca95`](https://github.com/nodejs/node/commit/438a98ca95)] - **url**: make URLSearchParams/Iterator match spec (Timothy Gu) [#11057](https://github.com/nodejs/node/pull/11057) +* [[`2bfd58adb1`](https://github.com/nodejs/node/commit/2bfd58adb1)] - **url**: define @@toStringTag as a data property (Timothy Gu) [#10906](https://github.com/nodejs/node/pull/10906) +* [[`f1851cb8e4`](https://github.com/nodejs/node/commit/f1851cb8e4)] - **url**: do not public expose inspect methods on URL (Timothy Gu) [#10906](https://github.com/nodejs/node/pull/10906) +* [[`b48b80f630`](https://github.com/nodejs/node/commit/b48b80f630)] - **url**: stop exporting originFor() (Timothy Gu) [#10955](https://github.com/nodejs/node/pull/10955) +* [[`c0c1a4c029`](https://github.com/nodejs/node/commit/c0c1a4c029)] - **url**: refactor lib/internal/url.js (Rich Trott) [#10912](https://github.com/nodejs/node/pull/10912) +* [[`2f9fdc454f`](https://github.com/nodejs/node/commit/2f9fdc454f)] - **(SEMVER-MINOR)** **url**: allow use of URL with http.request and https.request (James M Snell) [#10638](https://github.com/nodejs/node/pull/10638) +* [[`95faa55ab9`](https://github.com/nodejs/node/commit/95faa55ab9)] - **url**: check forEach callback is a function (Timothy Gu) [#10905](https://github.com/nodejs/node/pull/10905) +* [[`3642f35d09`](https://github.com/nodejs/node/commit/3642f35d09)] - **url**: add return value to ToUnicode/ToAscii stubs (Birunthan Mohanathas) [#10893](https://github.com/nodejs/node/pull/10893) +* [[`021338dc6d`](https://github.com/nodejs/node/commit/021338dc6d)] - **url**: export URLSearchParams (Timothy Gu) +* [[`5d33c96679`](https://github.com/nodejs/node/commit/5d33c96679)] - **url**: improving URLSearchParams (Timothy Gu) [#10399](https://github.com/nodejs/node/pull/10399) +* [[`824978e337`](https://github.com/nodejs/node/commit/824978e337)] - **url**: do not decode arbitrary %2e sequences in paths (James M Snell) [#10602](https://github.com/nodejs/node/pull/10602) +* [[`e46bdcf2bb`](https://github.com/nodejs/node/commit/e46bdcf2bb)] - **url**: change null password handling (James M Snell) [#10601](https://github.com/nodejs/node/pull/10601) +* [[`2b01138451`](https://github.com/nodejs/node/commit/2b01138451)] - **url**: TupleOrigin#toString use unicode by default (Joyee Cheung) [#10552](https://github.com/nodejs/node/pull/10552) +* [[`9f6d1f6fc2`](https://github.com/nodejs/node/commit/9f6d1f6fc2)] - **util**: improve readability of normalizeEncoding (Joyee Cheung) [#10439](https://github.com/nodejs/node/pull/10439) +* [[`d628f3a227`](https://github.com/nodejs/node/commit/d628f3a227)] - **util**: avoid out-of-bounds arguments index access (Teddy Katz) [#10569](https://github.com/nodejs/node/pull/10569) +* [[`2641cd496d`](https://github.com/nodejs/node/commit/2641cd496d)] - **vm**: improve performance of vm.runIn*() (Rich Trott) [#10816](https://github.com/nodejs/node/pull/10816) + + ## 2017-01-04, Version 7.4.0 (Current), @evanlucas @@ -553,7 +871,7 @@ _This is a security release impacting Windows 10 users._ ### Notable changes * **crypto**: The `Decipher` methods `setAuthTag()` and `setAAD` now return `this`. (Kirill Fomichev) [#9398](https://github.com/nodejs/node/pull/9398) -* **dns**: Implemented `{ttl: true}` for `resolve4()` and `resolve6()`. (Ben Noordhuis) [#9296](https://github.com/nodejs/node/pull/9296) & [#9296](https://github.com/nodejs/node/pull/9296) +* **dns**: Implemented `{ttl: true}` for `resolve4()` and `resolve6()`. (Ben Noordhuis) [#9296](https://github.com/nodejs/node/pull/9296) * **libuv**: Upgrade to v1.10.1 (cjihrig) [#9647](https://github.com/nodejs/node/pull/9647) - Fixed a potential buffer overflow when writing data to console on Windows 10. (CVE-2016-9551) * **process**: Added a new `external` property to the data returned by `memoryUsage()`. (Fedor Indutny) [#9587](https://github.com/nodejs/node/pull/9587) @@ -986,8 +1304,8 @@ _This is a security release impacting Windows 10 users._ * [[`0301ce9f55`](https://github.com/nodejs/node/commit/0301ce9f55)] - **src**: move IsolateData out of Environment (Ben Noordhuis) [#7082](https://github.com/nodejs/node/pull/7082) * [[`a3c5567eb4`](https://github.com/nodejs/node/commit/a3c5567eb4)] - **(SEMVER-MAJOR)** **src,win**: use correct exit code in old versions (yorkie) [#8204](https://github.com/nodejs/node/pull/8204) * [[`2f05af4c06`](https://github.com/nodejs/node/commit/2f05af4c06)] - **(SEMVER-MAJOR)** **stream**: improve stream error messages (Italo A. Casas) [#8801](https://github.com/nodejs/node/pull/8801) -* [[`9983af0347`](https://github.com/nodejs/node/commit/9983af0347)] - **(SEMVER-MAJOR)** **stream**: improve unimplemented _write() error (ratikesh9) [#7671](https://github.com/nodejs/node/pull/7671) -* [[`0cd0118334`](https://github.com/nodejs/node/commit/0cd0118334)] - **(SEMVER-MAJOR)** **stream**: 'data' argument on callback of Transform._flush() (Jesús Leganés Combarro "piranna) [#3708](https://github.com/nodejs/node/pull/3708) +* [[`9983af0347`](https://github.com/nodejs/node/commit/9983af0347)] - **(SEMVER-MAJOR)** **stream**: improve unimplemented \_write() error (ratikesh9) [#7671](https://github.com/nodejs/node/pull/7671) +* [[`0cd0118334`](https://github.com/nodejs/node/commit/0cd0118334)] - **(SEMVER-MAJOR)** **stream**: 'data' argument on callback of Transform.\_flush() (Jesús Leganés Combarro "piranna) [#3708](https://github.com/nodejs/node/pull/3708) * [[`a717be87a3`](https://github.com/nodejs/node/commit/a717be87a3)] - **test**: fix flaky test-timers-blocking-callback (Rich Trott) [#9198](https://github.com/nodejs/node/pull/9198) * [[`5ba02bf5db`](https://github.com/nodejs/node/commit/5ba02bf5db)] - **test**: remove arbitrary timer (Rich Trott) [#9197](https://github.com/nodejs/node/pull/9197) * [[`1518cc1e70`](https://github.com/nodejs/node/commit/1518cc1e70)] - **test**: remove duplicate required module (Rich Trott) [#9169](https://github.com/nodejs/node/pull/9169) diff --git a/doc/guides/maintaining-V8.md b/doc/guides/maintaining-V8.md index 19ee61fe20c5d7..4bfed3790f5185 100644 --- a/doc/guides/maintaining-V8.md +++ b/doc/guides/maintaining-V8.md @@ -177,8 +177,8 @@ https://crbug.com/v8/5199. From the bug we can see that it was merged by V8 into `v6.x` uses V8 5.1, the fix needed to cherry-picked. To cherry-pick, here's an example workflow: -* Download and apply the commit linked-to in the issue (in this case a51f429). `curl -L https://github.com/v8/v8/commit/a51f429.patch | git apply --directory=deps/v8`. If the branches have diverged significantly, this may not apply cleanly. It may help to try to cherry-pick the merge to the oldest branch that was done upstream in V8. In this example, this would be the patch from the merge to 5.2. The hope is that this would be closer to the V8 5.1, and has a better chance of applying cleanly. If you're stuck, feel free to ping @ofrobots for help. -* Modify the commit message to match the format we use for V8 backports. You may want to add extra description if necessary to indicate the impact of the fix on Node.js. In this case the original issue was descriptive enough. Example: +* Download and apply the commit linked-to in the issue (in this case a51f429). `curl -L https://github.com/v8/v8/commit/a51f429.patch | git am -3 --directory=deps/v8`. If the branches have diverged significantly, this may not apply cleanly. It may help to try to cherry-pick the merge to the oldest branch that was done upstream in V8. In this example, this would be the patch from the merge to 5.2. The hope is that this would be closer to the V8 5.1, and has a better chance of applying cleanly. If you're stuck, feel free to ping @ofrobots for help. +* Modify the commit message to match the format we use for V8 backports and replace yourself as the author. `git commit --amend --reset-author`. You may want to add extra description if necessary to indicate the impact of the fix on Node.js. In this case the original issue was descriptive enough. Example: ``` deps: cherry-pick a51f429 from V8 upstream diff --git a/doc/guides/timers-in-node.md b/doc/guides/timers-in-node.md deleted file mode 100644 index 818cc793437cad..00000000000000 --- a/doc/guides/timers-in-node.md +++ /dev/null @@ -1,192 +0,0 @@ ---- -title: Timers in Node.js -layout: docs.hbs ---- - -# Timers in Node.js and beyond - -The Timers module in Node.js contains functions that execute code after a set -period of time. Timers do not need to be imported via `require()`, since -all the methods are available globally to emulate the browser JavaScript API. -To fully understand when timer functions will be executed, it's a good idea to -read up on the the Node.js -[Event Loop](../topics/event-loop-timers-and-nexttick.md). - -## Controlling the Time Continuum with Node.js - -The Node.js API provides several ways of scheduling code to execute at -some point after the present moment. The functions below may seem familiar, -since they are available in most browsers, but Node.js actually provides -its own implementation of these methods. Timers integrate very closely -with the system, and despite the fact that the API mirrors the browser -API, there are some differences in implementation. - -### "When I say so" Execution ~ *`setTimeout()`* - -`setTimeout()` can be used to schedule code execution after a designated -amount of milliseconds. This function is similar to -[`window.setTimeout()`](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setTimeout) -from the browser JavaScript API, however a string of code cannot be passed -to be executed. - -`setTimeout()` accepts a function to execute as its first argument and the -millisecond delay defined as a number as the second argument. Additional -arguments may also be included and these will be passed on to the function. Here -is an example of that: - -```js -function myFunc (arg) { - console.log('arg was => ' + arg); -} - -setTimeout(myFunc, 1500, 'funky'); -``` - -The above function `myFunc()` will execute as close to 1500 -milliseconds (or 1.5 seconds) as possible due to the call of `setTimeout()`. - -The timeout interval that is set cannot be relied upon to execute after -that *exact* number of milliseconds. This is because other executing code that -blocks or holds onto the event loop will push the execution of the timeout -back. The *only* guarantee is that the timeout will not execute *sooner* than -the declared timeout interval. - -`setTimeout()` returns a `Timeout` object that can be used to reference the -timeout that was set. This returned object can be used to cancel the timeout ( -see `clearTimeout()` below) as well as change the execution behavior (see -`unref()` below). - -### "Right after this" Execution ~ *`setImmediate()`* - -`setImmediate()` will execute code at the end of the current event loop cycle. -This code will execute *after* any I/O operations in the current event loop and -*before* any timers scheduled for the next event loop. This code execution -could be thought of as happening "right after this", meaning any code following -the `setImmediate()` function call will execute before the `setImmediate()` -function argument. - -The first argument to `setImmediate()` will be the function to execute. Any -subsequent arguments will be passed to the function when it is executed. -Here's an example: - -```js -console.log('before immediate'); - -setImmediate((arg) => { - console.log(`executing immediate: ${arg}`); -}, 'so immediate'); - -console.log('after immediate'); -``` - -The above function passed to `setImmediate()` will execute after all runnable -code has executed, and the console output will be: - -```console -before immediate -after immediate -executing immediate: so immediate -``` - -`setImmediate()` returns and `Immediate` object, which can be used to cancel -the scheduled immediate (see `clearImmediate()` below). - -Note: Don't get `setImmediate()` confused with `process.nextTick()`. There are -some major ways they differ. The first is that `process.nextTick()` will run -*before* any `Immediate`s that are set as well as before any scheduled I/O. -The second is that `process.nextTick()` is non-clearable, meaning once -code has been scheduled to execute with `process.nextTick()`, the execution -cannot be stopped, just like with a normal function. Refer to [this guide](../topics/event-loop-timers-and-nexttick.md#processnexttick) -to better understand the operation of `process.nextTick()`. - -### "Infinite Loop" Execution ~ *`setInterval()`* - -If there is a block of code that should execute multiple times, `setInterval()` -can be used to execute that code. `setInterval()` takes a function -argument that will run an infinite number of times with a given millisecond -delay as the second argument. Just like `setTimeout()`, additional arguments -can be added beyond the delay, and these will be passed on to the function call. -Also like `setTimeout()`, the delay cannot be guaranteed because of operations -that may hold on to the event loop, and therefore should be treated as an -approximate delay. See the below example: - -```js -function intervalFunc () { - console.log('Cant stop me now!'); -} - -setInterval(intervalFunc, 1500); -``` -In the above example, `intervalFunc()` will execute about every 1500 -milliseconds, or 1.5 seconds, until it is stopped (see below). - -Just like `setTimeout()`, `setInterval()` also returns a `Timeout` object which -can be used to reference and modify the interval that was set. - -## Clearing the Future - -What can be done if a `Timeout` or `Immediate` object needs to be cancelled? -`setTimeout()`, `setImmediate()`, and `setInterval()` return a timer object -that can be used to reference the set `Timeout` or `Immediate` object. -By passing said object into the respective `clear` function, execution of -that object will be halted completely. The respective functions are -`clearTimeout()`, `clearImmediate()`, and `clearInterval()`. See the example -below for an example of each: - -```js -let timeoutObj = setTimeout(() => { - console.log('timeout beyond time'); -}, 1500); - -let immediateObj = setImmediate(() => { - console.log('immediately executing immediate'); -}); - -let intervalObj = setInterval(() => { - console.log('interviewing the interval'); -}, 500); - -clearTimeout(timeoutObj); -clearImmediate(immediateObj); -clearInterval(intervalObj); -``` - -## Leaving Timeouts Behind - -Remember that `Timeout` objects are returned by `setTimeout` and `setInterval`. -The `Timeout` object provides two functions intended to augment `Timeout` -behavior with `unref()` and `ref()`. If there is a `Timeout` object scheduled -using a `set` function, `unref()` can be called on that object. This will change -the behavior slightly, and not call the `Timeout` object *if it is the last -code to execute*. The `Timeout` object will not keep the process alive, waiting -to execute. - -In similar fashion, a `Timeout` object that has had `unref()` called on it -can remove that behavior by calling `ref()` on that same `Timeout` object, -which will then ensure its execution. Be aware, however, that this does -not *exactly* restore the initial behavior for performance reasons. See -below for examples of both: - -```js -let timerObj = setTimeout(() => { - console.log('will i run?'); -}); - -// if left alone, this statement will keep the above -// timeout from running, since the timeout will be the only -// thing keeping the program from exiting -timerObj.unref(); - -// we can bring it back to life by calling ref() inside -// an immediate -setImmediate(() => { - timerObj.ref(); -}); -``` -## Further Down the Event Loop - -There's much more to the Event Loop and Timers than this guide -has covered. To learn more about the internals of the Node.js -Event Loop and how Timers operate during execution, check out -this Node.js guide: [The Node.js Event Loop, Timers, and -process.nextTick()](../topics/event-loop-timers-and-nexttick.md). diff --git a/doc/guides/writing-tests.md b/doc/guides/writing-tests.md index d628e3f6f5873c..f27c076590e513 100644 --- a/doc/guides/writing-tests.md +++ b/doc/guides/writing-tests.md @@ -2,26 +2,25 @@ ## What is a test? -A test must be a node script that exercises a specific functionality provided -by node and checks that it behaves as expected. It should exit with code `0` on success, -otherwise it will fail. A test will fail if: +Most tests in Node.js core are JavaScript programs that exercise a functionality +provided by Node.js and check that it behaves as expected. Tests should exit +with code `0` on success. A test will fail if: - It exits by setting `process.exitCode` to a non-zero number. - - This is most often done by having an assertion throw an uncaught - Error. + - This is usually done by having an assertion throw an uncaught Error. - Occasionally, using `process.exit(code)` may be appropriate. - It never exits. In this case, the test runner will terminate the test because it sets a maximum time limit. -Tests can be added for multiple reasons: +Add tests when: -- When adding new functionality. -- When fixing regressions and bugs. -- When expanding test coverage. +- Adding new functionality. +- Fixing regressions and bugs. +- Expanding test coverage. ## Test structure -Let's analyze this very basic test from the Node.js test suite: +Let's analyze this basic test from the Node.js test suite: ```javascript 1 'use strict'; @@ -30,8 +29,8 @@ Let's analyze this very basic test from the Node.js test suite: 4 // This test ensures that the http-parser can handle UTF-8 characters 5 // in the http header. 6 -7 const http = require('http'); -8 const assert = require('assert'); +7 const assert = require('assert'); +8 const http = require('http'); 9 10 const server = http.createServer(common.mustCall((req, res) => { 11 res.end('ok'); @@ -47,7 +46,7 @@ Let's analyze this very basic test from the Node.js test suite: 21 }); ``` -**Lines 1-2** +### **Lines 1-2** ```javascript 'use strict'; @@ -60,17 +59,18 @@ the nature of the test requires that the test run without it. The second line loads the `common` module. The `common` module is a helper module that provides useful tools for the tests. -Even if no functions or other properties exported by `common` are used in a -test, the `common` module should still be included. This is because the `common` -module includes code that will cause tests to fail if variables are leaked into -the global space. In situations where no functions or other properties exported -by `common` are used, it can be included without assigning it to an identifier: +Even if a test uses no functions or other properties exported by `common`, +the test should still include the `common` module before any other modules. This +is because the `common` module includes code that will cause a test to fail if +the test leaks variables into the global space. In situations where a test uses +no functions or other properties exported by `common`, include it without +assigning it to an identifier: ```javascript require('../common'); ``` -**Lines 4-5** +### **Lines 4-5** ```javascript // This test ensures that the http-parser can handle UTF-8 characters @@ -80,32 +80,35 @@ require('../common'); A test should start with a comment containing a brief description of what it is designed to test. -**Lines 7-8** +### **Lines 7-8** ```javascript -const http = require('http'); const assert = require('assert'); +const http = require('http'); ``` -These modules are required for the test to run. Except for special cases, these -modules should only include core modules. -The `assert` module is used by most of the tests to check that the assumptions -for the test are met. +The test checks functionality in the `http` module. + +Most tests use the `assert` module to confirm expectations of the test. + +The require statements are sorted in +[ASCII](http://man7.org/linux/man-pages/man7/ascii.7.html) order (digits, upper +case, `_`, lower case). -**Lines 10-21** +### **Lines 10-21** -This is the body of the test. This test is quite simple, it just tests that an +This is the body of the test. This test is simple, it just tests that an HTTP server accepts `non-ASCII` characters in the headers of an incoming request. Interesting things to notice: -- If the test doesn't depend on a specific port number then always use 0 instead - of an arbitrary value, as it allows tests to be run in parallel safely, as the - operating system will assign a random port. If the test requires a specific - port, for example if the test checks that assigning a specific port works as - expected, then it is ok to assign a specific port number. +- If the test doesn't depend on a specific port number, then always use 0 + instead of an arbitrary value, as it allows tests to run in parallel safely, + as the operating system will assign a random port. If the test requires a + specific port, for example if the test checks that assigning a specific port + works as expected, then it is ok to assign a specific port number. - The use of `common.mustCall` to check that some callbacks/listeners are called. -- The HTTP server is closed once all the checks have run. This way, the test can +- The HTTP server closes once all the checks have run. This way, the test can exit gracefully. Remember that for a test to succeed, it must exit with a status code of 0. @@ -113,20 +116,20 @@ request. Interesting things to notice: ### Timers -The use of timers is discouraged, unless timers are being tested. There are -multiple reasons for this. Mainly, they are a source of flakiness. For a thorough +Avoid timers unless the test is specifically testing timers. There are multiple +reasons for this. Mainly, they are a source of flakiness. For a thorough explanation go [here](https://github.com/nodejs/testing/issues/27). -In the event a timer is needed, it's recommended using the -`common.platformTimeout()` method, that allows setting specific timeouts +In the event a test needs a timer, consider using the +`common.platformTimeout()` method. It allows setting specific timeouts depending on the platform. For example: ```javascript const timer = setTimeout(fail, common.platformTimeout(4000)); ``` -will create a 4-seconds timeout, except for some platforms where the delay will -be multiplied for some factor. +will create a 4-second timeout on most platforms but a longer timeout on slower +platforms. ### The *common* API @@ -191,9 +194,9 @@ var server = http.createServer(common.mustCall(function(req, res) { ### Flags Some tests will require running Node.js with specific command line flags set. To -accomplish this, a `// Flags: ` comment should be added in the preamble of the +accomplish this, add a `// Flags: ` comment in the preamble of the test followed by the flags. For example, to allow a test to require some of the -`internal/*` modules, the `--expose-internals` flag should be added. +`internal/*` modules, add the `--expose-internals` flag. A test that would require `internal/freelist` could start like this: ```javascript @@ -205,3 +208,15 @@ require('../common'); const assert = require('assert'); const freelist = require('internal/freelist'); ``` + +## Naming Test Files + +Test files are named using kebab casing. The first component of the name is +`test`. The second is the module or subsystem being tested. The third is usually +the method or event name being tested. Subsequent components of the name add +more information about what is being tested. + +For example, a test for the `beforeExit` event on the `process` object might be +named `test-process-before-exit.js`. If the test specifically checked that arrow +functions worked correctly with the `beforeExit` event, then it might be named +`test-process-before-exit-arrow-functions.js`. diff --git a/doc/node.1 b/doc/node.1 index ec41a44c7598c3..ffe72e1d022aa6 100644 --- a/doc/node.1 +++ b/doc/node.1 @@ -37,6 +37,7 @@ node \- Server-side JavaScript runtime .RI [ script.js \ | .B -e .RI \&" script \&"] +.B [--] .RI [ arguments ] .br .B node debug @@ -171,10 +172,33 @@ Load an OpenSSL configuration file on startup. Among other uses, this can be used to enable FIPS-compliant crypto if Node.js is built with \fB./configure \-\-openssl\-fips\fR. +.TP +.BR \-\-use\-openssl\-ca,\-\-use\-bundled\-ca +Use OpenSSL's default CA store or use bundled Mozilla CA store as supplied by +current NodeJS version. The default store is selectable at build-time. + +Using OpenSSL store allows for external modifications of the store. For most +Linux and BSD distributions, this store is maintained by the distribution +maintainers and system administrators. OpenSSL CA store location is dependent on +configuration of the OpenSSL library but this can be altered at runtime using +environmental variables. + +The bundled CA store, as supplied by NodeJS, is a snapshot of Mozilla CA store +that is fixed at release time. It is identical on all supported platforms. + +See \fBSSL_CERT_DIR\fR and \fBSSL_CERT_FILE\fR. + .TP .BR \-\-icu\-data\-dir =\fIfile\fR Specify ICU data load path. (overrides \fBNODE_ICU_DATA\fR) +.TP +.BR \-\-\fR +Indicate the end of node options. Pass the rest of the arguments to the script. + +If no script filename or eval/print script is supplied prior to this, then +the next argument will be used as a script filename. + .SH ENVIRONMENT VARIABLES .TP @@ -182,31 +206,52 @@ Specify ICU data load path. (overrides \fBNODE_ICU_DATA\fR) \',\'\-separated list of core modules that should print debug information. .TP -.BR NODE_PATH =\fIpath\fR[:\fI...\fR] -\':\'\-separated list of directories prefixed to the module search path. +.BR NODE_DISABLE_COLORS =\fI1\fR +When set to \fI1\fR, colors will not be used in the REPL. .TP -.BR NODE_DISABLE_COLORS=1 -When set to 1 colors will not be used in the REPL. +.BR NODE_EXTRA_CA_CERTS =\fIfile\fR +When set, the well known "root" CAs (like VeriSign) will be extended with the +extra certificates in \fIfile\fR. The file should consist of one or more +trusted certificates in PEM format. A message will be emitted (once) with +\fBprocess.emitWarning()\fR if the file is missing or misformatted, but any +errors are otherwise ignored. .TP .BR NODE_ICU_DATA =\fIfile\fR Data path for ICU (Intl object) data. Will extend linked-in data when compiled with small\-icu support. +.TP +.BR NODE_NO_WARNINGS =\fI1\fR +When set to \fI1\fR, process warnings are silenced. + +.TP +.BR NODE_PATH =\fIpath\fR[:\fI...\fR] +\':\'\-separated list of directories prefixed to the module search path. + .TP .BR NODE_REPL_HISTORY =\fIfile\fR Path to the file used to store the persistent REPL history. The default path -is ~/.node_repl_history, which is overridden by this variable. Setting the +is \fB~/.node_repl_history\fR, which is overridden by this variable. Setting the value to an empty string ("" or " ") disables persistent REPL history. .TP -.BR NODE_TTY_UNSAFE_ASYNC=1 -When set to 1, writes to stdout and stderr will be non-blocking and asynchronous -when outputting to a TTY on platforms which support async stdio. +.BR NODE_TTY_UNSAFE_ASYNC =\fI1\fR +When set to \fI1\fR, writes to stdout and stderr will be non-blocking and +asynchronous when outputting to a TTY on platforms which support async stdio. Setting this will void any guarantee that stdio will not be interleaved or dropped at program exit. \fBAvoid use.\fR +.TP +.BR SSL_CERT_DIR = \fIdir\fR +If \fB\-\-use\-openssl\-ca\fR is enabled, this overrides and sets OpenSSL's directory +containing trusted certificates. + +.TP +.BR SSL_CERT_FILE = \fIfile\fR +If \fB\-\-use\-openssl\-ca\fR is enabled, this overrides and sets OpenSSL's +file containing trusted certificates. .SH BUGS Bugs are tracked in GitHub Issues: diff --git a/doc/onboarding-extras.md b/doc/onboarding-extras.md index 9e1a4a7ed7b14b..1ba1f195f68e15 100644 --- a/doc/onboarding-extras.md +++ b/doc/onboarding-extras.md @@ -11,8 +11,10 @@ | `lib/child_process` | @bnoordhuis, @cjihrig | | `lib/cluster` | @bnoordhuis, @cjihrig, @mcollina | | `lib/{crypto,tls,https}` | @nodejs/crypto | +| `lib/dgram` | @cjihrig, @mcollina | | `lib/domains` | @misterdjules | | `lib/fs`, `src/{fs|file}` | @nodejs/fs | +| `lib/internal/url`, `src/node_url` | @nodejs/url | | `lib/{_}http{*}` | @nodejs/http | | `lib/net` | @bnoordhuis, @indutny, @nodejs/streams | | `lib/{_}stream{s|*}` | @nodejs/streams | @@ -26,10 +28,11 @@ | `tools/eslint`, `.eslintrc` | @silverwind, @trott | | async_hooks | @nodejs/diagnostics | | upgrading V8 | @nodejs/v8, @nodejs/post-mortem | -| upgrading npm | @fishrock123, @thealphanerd | +| upgrading npm | @fishrock123, @MylesBorins | | upgrading c-ares | @jbergstroem | | upgrading http-parser | @jbergstroem, @nodejs/http | | upgrading libuv | @saghul | +| python code | @nodejs/python | | platform specific | @nodejs/platform-{aix,arm,freebsd,macos,ppc,smartos,s390,windows} | diff --git a/doc/onboarding.md b/doc/onboarding.md index dbe3dfd569b7ae..14e4572890dbbe 100644 --- a/doc/onboarding.md +++ b/doc/onboarding.md @@ -71,6 +71,10 @@ onboarding session. * [**See "Who to CC in issues"**](./onboarding-extras.md#who-to-cc-in-issues) * will also come more naturally over time + * When a discussion gets heated, you can request that other collaborators keep an eye on it by opening an issue at the private [nodejs/moderation](https://github.com/nodejs/moderation) repository. + * This is a repository to which all members of the `nodejs` GitHub organization (not just Collaborators on Node.js core) have access. Its contents should not be shared externally. + * You can find the full moderation policy [here](https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md). + ## Reviewing PRs * The primary goal is for the codebase to improve. * Secondary (but not far off) is for the person submitting code to succeed. diff --git a/doc/template.html b/doc/template.html index af680645d15080..572197beff44fe 100644 --- a/doc/template.html +++ b/doc/template.html @@ -45,5 +45,6 @@

    Table of Contents

    + diff --git a/doc/topics/blocking-vs-non-blocking.md b/doc/topics/blocking-vs-non-blocking.md deleted file mode 100644 index ffdbcfc918e0e7..00000000000000 --- a/doc/topics/blocking-vs-non-blocking.md +++ /dev/null @@ -1,143 +0,0 @@ -# Overview of Blocking vs Non-Blocking - -This overview covers the difference between **blocking** and **non-blocking** -calls in Node.js. This overview will refer to the event loop and libuv but no -prior knowledge of those topics is required. Readers are assumed to have a -basic understanding of the JavaScript language and Node.js callback pattern. - -> "I/O" refers primarily to interaction with the system's disk and -> network supported by [libuv](http://libuv.org/). - - -## Blocking - -**Blocking** is when the execution of additional JavaScript in the Node.js -process must wait until a non-JavaScript operation completes. This happens -because the event loop is unable to continue running JavaScript while a -**blocking** operation is occurring. - -In Node.js, JavaScript that exhibits poor performance due to being CPU intensive -rather than waiting on a non-JavaScript operation, such as I/O, isn't typically -referred to as **blocking**. Synchronous methods in the Node.js standard library -that use libuv are the most commonly used **blocking** operations. Native -modules may also have **blocking** methods. - -All of the I/O methods in the Node.js standard library provide asynchronous -versions, which are **non-blocking**, and accept callback functions. Some -methods also have **blocking** counterparts, which have names that end with -`Sync`. - - -## Comparing Code - -**Blocking** methods execute **synchronously** and **non-blocking** methods -execute **asynchronously**. - -Using the File System module as an example, this is a **synchronous** file read: - -```js -const fs = require('fs'); -const data = fs.readFileSync('/file.md'); // blocks here until file is read -``` - -And here is an equivalent **asynchronous** example: - -```js -const fs = require('fs'); -fs.readFile('/file.md', (err, data) => { - if (err) throw err; -}); -``` - -The first example appears simpler than the second but has the disadvantage of -the second line **blocking** the execution of any additional JavaScript until -the entire file is read. Note that in the synchronous version if an error is -thrown it will need to be caught or the process will crash. In the asynchronous -version, it is up to the author to decide whether an error should throw as -shown. - -Let's expand our example a little bit: - -```js -const fs = require('fs'); -const data = fs.readFileSync('/file.md'); // blocks here until file is read -console.log(data); -// moreWork(); will run after console.log -``` - -And here is a similar, but not equivalent asynchronous example: - -```js -const fs = require('fs'); -fs.readFile('/file.md', (err, data) => { - if (err) throw err; - console.log(data); -}); -// moreWork(); will run before console.log -``` - -In the first example above, `console.log` will be called before `moreWork()`. In -the second example `fs.readFile()` is **non-blocking** so JavaScript execution -can continue and `moreWork()` will be called first. The ability to run -`moreWork()` without waiting for the file read to complete is a key design -choice that allows for higher throughput. - - -## Concurrency and Throughput - -JavaScript execution in Node.js is single threaded, so concurrency refers to the -event loop's capacity to execute JavaScript callback functions after completing -other work. Any code that is expected to run in a concurrent manner must allow -the event loop to continue running as non-JavaScript operations, like I/O, are -occurring. - -As an example, let's consider a case where each request to a web server takes -50ms to complete and 45ms of that 50ms is database I/O that can be done -asynchronously. Choosing **non-blocking** asynchronous operations frees up that -45ms per request to handle other requests. This is a significant difference in -capacity just by choosing to use **non-blocking** methods instead of -**blocking** methods. - -The event loop is different than models in many other languages where additional -threads may be created to handle concurrent work. - - -## Dangers of Mixing Blocking and Non-Blocking Code - -There are some patterns that should be avoided when dealing with I/O. Let's look -at an example: - -```js -const fs = require('fs'); -fs.readFile('/file.md', (err, data) => { - if (err) throw err; - console.log(data); -}); -fs.unlinkSync('/file.md'); -``` - -In the above example, `fs.unlinkSync()` is likely to be run before -`fs.readFile()`, which would delete `file.md` before it is actually read. A -better way to write this that is completely **non-blocking** and guaranteed to -execute in the correct order is: - - -```js -const fs = require('fs'); -fs.readFile('/file.md', (err, data) => { - if (err) throw err; - console.log(data); - fs.unlink('/file.md', (err) => { - if (err) throw err; - }); -}); -``` - -The above places a **non-blocking** call to `fs.unlink()` within the callback of -`fs.readFile()` which guarantees the correct order of operations. - - -## Additional Resources - -- [libuv](http://libuv.org/) -- [About Node.js](https://nodejs.org/en/about/) diff --git a/doc/topics/domain-postmortem.md b/doc/topics/domain-postmortem.md deleted file mode 100644 index e03012db926b08..00000000000000 --- a/doc/topics/domain-postmortem.md +++ /dev/null @@ -1,301 +0,0 @@ -# Domain Module Postmortem - -## Usability Issues - -### Implicit Behavior - -It's possible for a developer to create a new domain and then simply run -`domain.enter()`. Which then acts as a catch-all for any exception in the -future that couldn't be observed by the thrower. Allowing a module author to -intercept the exceptions of unrelated code in a different module. Preventing -the originator of the code from knowing about its own exceptions. - -Here's an example of how one indirectly linked modules can affect another: - -```js -// module a.js -const b = require('./b'); -const c = require('./c'); - - -// module b.js -const d = require('domain').create(); -d.on('error', () => { /* silence everything */ }); -d.enter(); - - -// module c.js -const dep = require('some-dep'); -dep.method(); // Uh-oh! This method doesn't actually exist. -``` - -Since module `b` enters the domain but never exits any uncaught exception will -be swallowed. Leaving module `c` in the dark as to why it didn't run the entire -script. Leaving a potentially partially populated `module.exports`. Doing this -is not the same as listening for `'uncaughtException'`. As the latter is -explicitly meant to globally catch errors. The other issue is that domains are -processed prior to any `'uncaughtException'` handlers, and prevent them from -running. - -Another issue is that domains route errors automatically if no `'error'` -handler was set on the event emitter. There is no opt-in mechanism for this, -and automatically propagates across the entire asynchronous chain. This may -seem useful at first, but once asynchronous calls are two or more modules deep -and one of them doesn't include an error handler the creator of the domain will -suddenly be catching unexpected exceptions, and the thrower's exception will go -unnoticed by the author. - -The following is a simple example of how a missing `'error'` handler allows -the active domain to hijack the error: - -```js -const domain = require('domain'); -const net = require('net'); -const d = domain.create(); -d.on('error', (err) => console.error(err.message)); - -d.run(() => net.createServer((c) => { - c.end(); - c.write('bye'); -}).listen(8000)); -``` - -Even manually removing the connection via `d.remove(c)` does not prevent the -connection's error from being automatically intercepted. - -Failures that plagues both error routing and exception handling are the -inconsistencies in how errors are bubbled. The following is an example of how -nested domains will and won't bubble the exception based on when they happen: - -```js -const domain = require('domain'); -const net = require('net'); -const d = domain.create(); -d.on('error', () => console.error('d intercepted an error')); - -d.run(() => { - const server = net.createServer((c) => { - const e = domain.create(); // No 'error' handler being set. - e.run(() => { - // This will not be caught by d's error handler. - setImmediate(() => { - throw new Error('thrown from setImmediate'); - }); - // Though this one will bubble to d's error handler. - throw new Error('immediately thrown'); - }); - }).listen(8080); -}); -``` - -It may be expected that nested domains always remain nested, and will always -propagate the exception up the domain stack. Or that exceptions will never -automatically bubble. Unfortunately both these situations occur, leading to -potentially confusing behavior that may even be prone to difficult to debug -timing conflicts. - - -### API Gaps - -While APIs based on using `EventEmitter` can use `bind()` and errback style -callbacks can use `intercept()`, alternative APIs that implicitly bind to the -active domain must be executed inside of `run()`. Meaning if module authors -wanted to support domains using a mechanism alternative to those mentioned they -must manually implement domain support themselves. Instead of being able to -leverage the implicit mechanisms already in place. - - -### Error Propagation - -Propagating errors across nested domains is not straight forward, if even -possible. Existing documentation shows a simple example of how to `close()` an -`http` server if there is an error in the request handler. What it does not -explain is how to close the server if the request handler creates another -domain instance for another async request. Using the following as a simple -example of the failing of error propagation: - -```js -const d1 = domain.create(); -d1.foo = true; // custom member to make more visible in console -d1.on('error', (er) => { /* handle error */ }); - -d1.run(() => setTimeout(() => { - const d2 = domain.create(); - d2.bar = 43; - d2.on('error', (er) => console.error(er.message, domain._stack)); - d2.run(() => { - setTimeout(() => { - setTimeout(() => { - throw new Error('outer'); - }); - throw new Error('inner') - }); - }); -})); -``` - -Even in the case that the domain instances are being used for local storage so -access to resources are made available there is still no way to allow the error -to continue propagating from `d2` back to `d1`. Quick inspection may tell us -that simply throwing from `d2`'s domain `'error'` handler would allow `d1` to -then catch the exception and execute its own error handler. Though that is not -the case. Upon inspection of `domain._stack` you'll see that the stack only -contains `d2`. - -This may be considered a failing of the API, but even if it did operate in this -way there is still the issue of transmitting the fact that a branch in the -asynchronous execution has failed, and that all further operations in that -branch must cease. In the example of the http request handler, if we fire off -several asynchronous requests and each one then `write()`'s data back to the -client many more errors will arise from attempting to `write()` to a closed -handle. More on this in _Resource Cleanup on Exception_. - - -### Resource Cleanup on Exception - -The script [`domain-resource-cleanup-example.js`][] -contains a more complex example of properly cleaning up in a small resource -dependency tree in the case that an exception occurs in a given connection or -any of its dependencies. Breaking down the script into its basic operations: - -- When a new connection happens, concurrently: - - Open a file on the file system - - Open Pipe to unique socket -- Read a chunk of the file asynchronously -- Write chunk to both the TCP connection and any listening sockets -- If any of these resources error, notify all other attached resources that - they need to clean up and shutdown - -As we can see from this example a lot more must be done to properly clean up -resources when something fails than what can be done strictly through the -domain API. All that domains offer is an exception aggregation mechanism. Even -the potentially useful ability to propagate data with the domain is easily -countered, in this example, by passing the needed resources as a function -argument. - -One problem domains perpetuated was the supposed simplicity of being able to -continue execution, contrary to what the documentation stated, of the -application despite an unexpected exception. This example demonstrates the -fallacy behind that idea. - -Attempting proper resource cleanup on unexpected exception becomes more complex -as the application itself grows in complexity. This example only has 3 basic -resources in play, and all of them with a clear dependency path. If an -application uses something like shared resources or resource reuse the ability -to cleanup, and properly test that cleanup has been done, grows greatly. - -In the end, in terms of handling errors, domains aren't much more than a -glorified `'uncaughtException'` handler. Except with more implicit and -unobservable behavior by third-parties. - - -### Resource Propagation - -Another use case for domains was to use it to propagate data along asynchronous -data paths. One problematic point is the ambiguity of when to expect the -correct domain when there are multiple in the stack (which must be assumed if -the async stack works with other modules). Also the conflict between being -able to depend on a domain for error handling while also having it available to -retrieve the necessary data. - -The following is a involved example demonstrating the failing using domains to -propagate data along asynchronous stacks: - -```js -const domain = require('domain'); -const net = require('net'); - -const server = net.createServer((c) => { - // Use a domain to propagate data across events within the - // connection so that we don't have to pass arguments - // everywhere. - const d = domain.create(); - d.data = { connection: c }; - d.add(c); - // Mock class that does some useless async data transformation - // for demonstration purposes. - const ds = new DataStream(dataTransformed); - c.on('data', (chunk) => ds.data(chunk)); -}).listen(8080, () => console.log(`listening on 8080`)); - -function dataTransformed(chunk) { - // FAIL! Because the DataStream instance also created a - // domain we have now lost the active domain we had - // hoped to use. - domain.active.data.connection.write(chunk); -} - -function DataStream(cb) { - this.cb = cb; - // DataStream wants to use domains for data propagation too! - // Unfortunately this will conflict with any domain that - // already exists. - this.domain = domain.create(); - this.domain.data = { inst: this }; -} - -DataStream.prototype.data = function data(chunk) { - // This code is self contained, but pretend it's a complex - // operation that crosses at least one other module. So - // passing along "this", etc., is not easy. - this.domain.run(function() { - // Simulate an async operation that does the data transform. - setImmediate(() => { - for (var i = 0; i < chunk.length; i++) - chunk[i] = ((chunk[i] + Math.random() * 100) % 96) + 33; - // Grab the instance from the active domain and use that - // to call the user's callback. - const self = domain.active.data.inst; - self.cb.call(self, chunk); - }); - }); -}; -``` - -The above shows that it is difficult to have more than one asynchronous API -attempt to use domains to propagate data. This example could possibly be fixed -by assigning `parent: domain.active` in the `DataStream` constructor. Then -restoring it via `domain.active = domain.active.data.parent` just before the -user's callback is called. Also the instantiation of `DataStream` in the -`'connection'` callback must be run inside `d.run()`, instead of simply using -`d.add(c)`, otherwise there will be no active domain. - -In short, for this to have a prayer of a chance usage would need to strictly -adhere to a set of guidelines that would be difficult to enforce or test. - - -## Performance Issues - -A significant deterrent from using domains is the overhead. Using node's -built-in http benchmark, `http_simple.js`, without domains it can handle over -22,000 requests/second. Whereas if it's run with `NODE_USE_DOMAINS=1` that -number drops down to under 17,000 requests/second. In this case there is only -a single global domain. If we edit the benchmark so the http request callback -creates a new domain instance performance drops further to 15,000 -requests/second. - -While this probably wouldn't affect a server only serving a few hundred or even -a thousand requests per second, the amount of overhead is directly proportional -to the number of asynchronous requests made. So if a single connection needs to -connect to several other services all of those will contribute to the overall -latency of delivering the final product to the client. - -Using `AsyncWrap` and tracking the number of times -`init`/`pre`/`post`/`destroy` are called in the mentioned benchmark we find -that the sum of all events called is over 170,000 times per second. This means -even adding 1 microsecond overhead per call for any type of setup or tear down -will result in a 17% performance loss. Granted, this is for the optimized -scenario of the benchmark, but I believe this demonstrates the necessity for a -mechanism such as domain to be as cheap to run as possible. - - -## Looking Ahead - -The domain module has been soft deprecated since Dec 2014, but has not yet been -removed because node offers no alternative functionality at the moment. As of -this writing there is ongoing work building out the `AsyncWrap` API and a -proposal for Zones being prepared for the TC39. At such time there is suitable -functionality to replace domains it will undergo the full deprecation cycle and -eventually be removed from core. - -[`domain-resource-cleanup-example.js`]: ./domain-resource-cleanup-example.js diff --git a/doc/topics/domain-resource-cleanup-example.js b/doc/topics/domain-resource-cleanup-example.js deleted file mode 100644 index d379d1a00e6695..00000000000000 --- a/doc/topics/domain-resource-cleanup-example.js +++ /dev/null @@ -1,136 +0,0 @@ -'use strict'; - -const domain = require('domain'); -const EE = require('events'); -const fs = require('fs'); -const net = require('net'); -const util = require('util'); -const print = process._rawDebug; - -const pipeList = []; -const FILENAME = '/tmp/tmp.tmp'; -const PIPENAME = '/tmp/node-domain-example-'; -const FILESIZE = 1024; -var uid = 0; - -// Setting up temporary resources -const buf = Buffer(FILESIZE); -for (var i = 0; i < buf.length; i++) - buf[i] = ((Math.random() * 1e3) % 78) + 48; // Basic ASCII -fs.writeFileSync(FILENAME, buf); - -function ConnectionResource(c) { - EE.call(this); - this._connection = c; - this._alive = true; - this._domain = domain.create(); - this._id = Math.random().toString(32).substr(2).substr(0, 8) + (++uid); - - this._domain.add(c); - this._domain.on('error', () => { - this._alive = false; - }); -} -util.inherits(ConnectionResource, EE); - -ConnectionResource.prototype.end = function end(chunk) { - this._alive = false; - this._connection.end(chunk); - this.emit('end'); -}; - -ConnectionResource.prototype.isAlive = function isAlive() { - return this._alive; -}; - -ConnectionResource.prototype.id = function id() { - return this._id; -}; - -ConnectionResource.prototype.write = function write(chunk) { - this.emit('data', chunk); - return this._connection.write(chunk); -}; - -// Example begin -net.createServer((c) => { - const cr = new ConnectionResource(c); - - const d1 = domain.create(); - fs.open(FILENAME, 'r', d1.intercept((fd) => { - streamInParts(fd, cr, 0); - })); - - pipeData(cr); - - c.on('close', () => cr.end()); -}).listen(8080); - -function streamInParts(fd, cr, pos) { - const d2 = domain.create(); - var alive = true; - d2.on('error', (er) => { - print('d2 error:', er.message) - cr.end(); - }); - fs.read(fd, new Buffer(10), 0, 10, pos, d2.intercept((bRead, buf) => { - if (!cr.isAlive()) { - return fs.close(fd); - } - if (cr._connection.bytesWritten < FILESIZE) { - // Documentation says callback is optional, but doesn't mention that if - // the write fails an exception will be thrown. - const goodtogo = cr.write(buf); - if (goodtogo) { - setTimeout(() => streamInParts(fd, cr, pos + bRead), 1000); - } else { - cr._connection.once('drain', () => streamInParts(fd, cr, pos + bRead)); - } - return; - } - cr.end(buf); - fs.close(fd); - })); -} - -function pipeData(cr) { - const pname = PIPENAME + cr.id(); - const ps = net.createServer(); - const d3 = domain.create(); - const connectionList = []; - d3.on('error', (er) => { - print('d3 error:', er.message); - cr.end(); - }); - d3.add(ps); - ps.on('connection', (conn) => { - connectionList.push(conn); - conn.on('data', () => {}); // don't care about incoming data. - conn.on('close', () => { - connectionList.splice(connectionList.indexOf(conn), 1); - }); - }); - cr.on('data', (chunk) => { - for (var i = 0; i < connectionList.length; i++) { - connectionList[i].write(chunk); - } - }); - cr.on('end', () => { - for (var i = 0; i < connectionList.length; i++) { - connectionList[i].end(); - } - ps.close(); - }); - pipeList.push(pname); - ps.listen(pname); -} - -process.on('SIGINT', () => process.exit()); -process.on('exit', () => { - try { - for (var i = 0; i < pipeList.length; i++) { - fs.unlinkSync(pipeList[i]); - } - fs.unlinkSync(FILENAME); - } catch (e) { } -}); diff --git a/doc/topics/event-loop-timers-and-nexttick.md b/doc/topics/event-loop-timers-and-nexttick.md deleted file mode 100644 index d7d0ee96e9c438..00000000000000 --- a/doc/topics/event-loop-timers-and-nexttick.md +++ /dev/null @@ -1,486 +0,0 @@ -# The Node.js Event Loop, Timers, and `process.nextTick()` - -## What is the Event Loop? - -The event loop is what allows Node.js to perform non-blocking I/O -operations — despite the fact that JavaScript is single-threaded — by -offloading operations to the system kernel whenever possible. - -Since most modern kernels are multi-threaded, they can handle multiple -operations executing in the background. When one of these operations -completes, the kernel tells Node.js so that the appropriate callback -may be added to the **poll** queue to eventually be executed. We'll explain -this in further detail later in this topic. - -## Event Loop Explained - -When Node.js starts, it initializes the event loop, processes the -provided input script (or drops into the [REPL][], which is not covered in -this document) which may make async API calls, schedule timers, or call -`process.nextTick()`, then begins processing the event loop. - -The following diagram shows a simplified overview of the event loop's -order of operations. - -```txt - ┌───────────────────────┐ -┌─>│ timers │ -│ └──────────┬────────────┘ -│ ┌──────────┴────────────┐ -│ │ I/O callbacks │ -│ └──────────┬────────────┘ -│ ┌──────────┴────────────┐ -│ │ idle, prepare │ -│ └──────────┬────────────┘ ┌───────────────┐ -│ ┌──────────┴────────────┐ │ incoming: │ -│ │ poll │<─────┤ connections, │ -│ └──────────┬────────────┘ │ data, etc. │ -│ ┌──────────┴────────────┐ └───────────────┘ -│ │ check │ -│ └──────────┬────────────┘ -│ ┌──────────┴────────────┐ -└──┤ close callbacks │ - └───────────────────────┘ -``` - -*note: each box will be referred to as a "phase" of the event loop.* - -Each phase has a FIFO queue of callbacks to execute. While each phase is -special in its own way, generally, when the event loop enters a given -phase, it will perform any operations specific to that phase, then -execute callbacks in that phase's queue until the queue has been -exhausted or the maximum number of callbacks has executed. When the -queue has been exhausted or the callback limit is reached, the event -loop will move to the next phase, and so on. - -Since any of these operations may schedule _more_ operations and new -events processed in the **poll** phase are queued by the kernel, poll -events can be queued while polling events are being processed. As a -result, long running callbacks can allow the poll phase to run much -longer than a timer's threshold. See the [**timers**](#timers) and -[**poll**](#poll) sections for more details. - -_**NOTE:** There is a slight discrepancy between the Windows and the -Unix/Linux implementation, but that's not important for this -demonstration. The most important parts are here. There are actually -seven or eight steps, but the ones we care about — ones that Node.js -actually uses - are those above._ - - -## Phases Overview - -* **timers**: this phase executes callbacks scheduled by `setTimeout()` - and `setInterval()`. -* **I/O callbacks**: executes almost all callbacks with the exception of - close callbacks, the ones scheduled by timers, and `setImmediate()`. -* **idle, prepare**: only used internally. -* **poll**: retrieve new I/O events; node will block here when appropriate. -* **check**: `setImmediate()` callbacks are invoked here. -* **close callbacks**: e.g. `socket.on('close', ...)`. - -Between each run of the event loop, Node.js checks if it is waiting for -any asynchronous I/O or timers and shuts down cleanly if there are not -any. - -## Phases in Detail - -### timers - -A timer specifies the **threshold** _after which_ a provided callback -_may be executed_ rather than the **exact** time a person _wants it to -be executed_. Timers callbacks will run as early as they can be -scheduled after the specified amount of time has passed; however, -Operating System scheduling or the running of other callbacks may delay -them. - -_**Note**: Technically, the [**poll** phase](#poll) controls when timers -are executed._ - -For example, say you schedule a timeout to execute after a 100 ms -threshold, then your script starts asynchronously reading a file which -takes 95 ms: - -```js - -var fs = require('fs'); - -function someAsyncOperation (callback) { - // Assume this takes 95ms to complete - fs.readFile('/path/to/file', callback); -} - -var timeoutScheduled = Date.now(); - -setTimeout(function () { - - var delay = Date.now() - timeoutScheduled; - - console.log(delay + "ms have passed since I was scheduled"); -}, 100); - - -// do someAsyncOperation which takes 95 ms to complete -someAsyncOperation(function () { - - var startCallback = Date.now(); - - // do something that will take 10ms... - while (Date.now() - startCallback < 10) { - ; // do nothing - } - -}); -``` - -When the event loop enters the **poll** phase, it has an empty queue -(`fs.readFile()` has not completed), so it will wait for the number of ms -remaining until the soonest timer's threshold is reached. While it is -waiting 95 ms pass, `fs.readFile()` finishes reading the file and its -callback which takes 10 ms to complete is added to the **poll** queue and -executed. When the callback finishes, there are no more callbacks in the -queue, so the event loop will see that the threshold of the soonest -timer has been reached then wrap back to the **timers** phase to execute -the timer's callback. In this example, you will see that the total delay -between the timer being scheduled and its callback being executed will -be 105ms. - -Note: To prevent the **poll** phase from starving the event loop, [libuv] -(http://libuv.org/) (the C library that implements the Node.js -event loop and all of the asynchronous behaviors of the platform) -also has a hard maximum (system dependent) before it stops polling for -more events. - -### I/O callbacks - -This phase executes callbacks for some system operations such as types -of TCP errors. For example if a TCP socket receives `ECONNREFUSED` when -attempting to connect, some \*nix systems want to wait to report the -error. This will be queued to execute in the **I/O callbacks** phase. - -### poll - -The **poll** phase has two main functions: - -1. Executing scripts for timers whose threshold has elapsed, then -2. Processing events in the **poll** queue. - -When the event loop enters the **poll** phase _and there are no timers -scheduled_, one of two things will happen: - -* _If the **poll** queue **is not empty**_, the event loop will iterate -through its queue of callbacks executing them synchronously until -either the queue has been exhausted, or the system-dependent hard limit -is reached. - -* _If the **poll** queue **is empty**_, one of two more things will -happen: - * If scripts have been scheduled by `setImmediate()`, the event loop - will end the **poll** phase and continue to the **check** phase to - execute those scheduled scripts. - - * If scripts **have not** been scheduled by `setImmediate()`, the - event loop will wait for callbacks to be added to the queue, then - execute them immediately. - -Once the **poll** queue is empty the event loop will check for timers -_whose time thresholds have been reached_. If one or more timers are -ready, the event loop will wrap back to the **timers** phase to execute -those timers' callbacks. - -### check - -This phase allows a person to execute callbacks immediately after the -**poll** phase has completed. If the **poll** phase becomes idle and -scripts have been queued with `setImmediate()`, the event loop may -continue to the **check** phase rather than waiting. - -`setImmediate()` is actually a special timer that runs in a separate -phase of the event loop. It uses a libuv API that schedules callbacks to -execute after the **poll** phase has completed. - -Generally, as the code is executed, the event loop will eventually hit -the **poll** phase where it will wait for an incoming connection, request, -etc. However, if a callback has been scheduled with `setImmediate()` -and the **poll** phase becomes idle, it will end and continue to the -**check** phase rather than waiting for **poll** events. - -### close callbacks - -If a socket or handle is closed abruptly (e.g. `socket.destroy()`), the -`'close'` event will be emitted in this phase. Otherwise it will be -emitted via `process.nextTick()`. - -## `setImmediate()` vs `setTimeout()` - -`setImmediate` and `setTimeout()` are similar, but behave in different -ways depending on when they are called. - -* `setImmediate()` is designed to execute a script once the current -**poll** phase completes. -* `setTimeout()` schedules a script to be run after a minimum threshold -in ms has elapsed. - -The order in which the timers are executed will vary depending on the -context in which they are called. If both are called from within the -main module, then timing will be bound by the performance of the process -(which can be impacted by other applications running on the machine). - -For example, if we run the following script which is not within an I/O -cycle (i.e. the main module), the order in which the two timers are -executed is non-deterministic, as it is bound by the performance of the -process: - - -```js -// timeout_vs_immediate.js -setTimeout(function timeout () { - console.log('timeout'); -},0); - -setImmediate(function immediate () { - console.log('immediate'); -}); -``` - -```console -$ node timeout_vs_immediate.js -timeout -immediate - -$ node timeout_vs_immediate.js -immediate -timeout -``` - -However, if you move the two calls within an I/O cycle, the immediate -callback is always executed first: - -```js -// timeout_vs_immediate.js -var fs = require('fs') - -fs.readFile(__filename, () => { - setTimeout(() => { - console.log('timeout') - }, 0) - setImmediate(() => { - console.log('immediate') - }) -}) -``` - -```console -$ node timeout_vs_immediate.js -immediate -timeout - -$ node timeout_vs_immediate.js -immediate -timeout -``` - -The main advantage to using `setImmediate()` over `setTimeout()` is -`setImmediate()` will always be executed before any timers if scheduled -within an I/O cycle, independently of how many timers are present. - -## `process.nextTick()` - -### Understanding `process.nextTick()` - -You may have noticed that `process.nextTick()` was not displayed in the -diagram, even though it's a part of the asynchronous API. This is because -`process.nextTick()` is not technically part of the event loop. Instead, -the `nextTickQueue` will be processed after the current operation -completes, regardless of the current phase of the event loop. - -Looking back at our diagram, any time you call `process.nextTick()` in a -given phase, all callbacks passed to `process.nextTick()` will be -resolved before the event loop continues. This can create some bad -situations because **it allows you to "starve" your I/O by making -recursive `process.nextTick()` calls**, which prevents the event loop -from reaching the **poll** phase. - -### Why would that be allowed? - -Why would something like this be included in Node.js? Part of it is a -design philosophy where an API should always be asynchronous even where -it doesn't have to be. Take this code snippet for example: - -```js -function apiCall (arg, callback) { - if (typeof arg !== 'string') - return process.nextTick(callback, - new TypeError('argument should be string')); -} -``` - -The snippet does an argument check and if it's not correct, it will pass -the error to the callback. The API updated fairly recently to allow -passing arguments to `process.nextTick()` allowing it to take any -arguments passed after the callback to be propagated as the arguments to -the callback so you don't have to nest functions. - -What we're doing is passing an error back to the user but only *after* -we have allowed the rest of the user's code to execute. By using -`process.nextTick()` we guarantee that `apiCall()` always runs its -callback *after* the rest of the user's code and *before* the event loop -is allowed to proceed. To achieve this, the JS call stack is allowed to -unwind then immediately execute the provided callback which allows a -person to make recursive calls to `process.nextTick()` without reaching a -`RangeError: Maximum call stack size exceeded from v8`. - -This philosophy can lead to some potentially problematic situations. -Take this snippet for example: - -```js -// this has an asynchronous signature, but calls callback synchronously -function someAsyncApiCall (callback) { callback(); }; - -// the callback is called before `someAsyncApiCall` completes. -someAsyncApiCall(() => { - - // since someAsyncApiCall has completed, bar hasn't been assigned any value - console.log('bar', bar); // undefined - -}); - -var bar = 1; -``` - -The user defines `someAsyncApiCall()` to have an asynchronous signature, -but it actually operates synchronously. When it is called, the callback -provided to `someAsyncApiCall()` is called in the same phase of the -event loop because `someAsyncApiCall()` doesn't actually do anything -asynchronously. As a result, the callback tries to reference `bar` even -though it may not have that variable in scope yet, because the script has not -been able to run to completion. - -By placing the callback in a `process.nextTick()`, the script still has the -ability to run to completion, allowing all the variables, functions, -etc., to be initialized prior to the callback being called. It also has -the advantage of not allowing the event loop to continue. It may be -useful for the user to be alerted to an error before the event loop is -allowed to continue. Here is the previous example using `process.nextTick()`: - -```js -function someAsyncApiCall (callback) { - process.nextTick(callback); -}; - -someAsyncApiCall(() => { - console.log('bar', bar); // 1 -}); - -var bar = 1; -``` - -Here's another real world example: - -```js -const server = net.createServer(() => {}).listen(8080); - -server.on('listening', () => {}); -``` - -When only a port is passed the port is bound immediately. So the -`'listening'` callback could be called immediately. Problem is that the -`.on('listening')` will not have been set by that time. - -To get around this the `'listening'` event is queued in a `nextTick()` -to allow the script to run to completion. Which allows the user to set -any event handlers they want. - -## `process.nextTick()` vs `setImmediate()` - -We have two calls that are similar as far as users are concerned, but -their names are confusing. - -* `process.nextTick()` fires immediately on the same phase -* `setImmediate()` fires on the following iteration or 'tick' of the -event loop - -In essence, the names should be swapped. `process.nextTick()` fires more -immediately than `setImmediate()` but this is an artifact of the past -which is unlikely to change. Making this switch would break a large -percentage of the packages on npm. Every day more new modules are being -added, which mean every day we wait, more potential breakages occur. -While they are confusing, the names themselves won't change. - -*We recommend developers use `setImmediate()` in all cases because it's -easier to reason about (and it leads to code that's compatible with a -wider variety of environments, like browser JS.)* - -## Why use `process.nextTick()`? - -There are two main reasons: - -1. Allow users to handle errors, cleanup any then unneeded resources, or -perhaps try the request again before the event loop continues. - -2. At times it's necessary to allow a callback to run after the call -stack has unwound but before the event loop continues. - -One example is to match the user's expectations. Simple example: - -```js -var server = net.createServer(); -server.on('connection', function(conn) { }); - -server.listen(8080); -server.on('listening', function() { }); -``` - -Say that `listen()` is run at the beginning of the event loop, but the -listening callback is placed in a `setImmediate()`. Now, unless a -hostname is passed binding to the port will happen immediately. Now for -the event loop to proceed it must hit the **poll** phase, which means -there is a non-zero chance that a connection could have been received -allowing the connection event to be fired before the listening event. - -Another example is running a function constructor that was to, say, -inherit from `EventEmitter` and it wanted to call an event within the -constructor: - -```js -const EventEmitter = require('events'); -const util = require('util'); - -function MyEmitter() { - EventEmitter.call(this); - this.emit('event'); -} -util.inherits(MyEmitter, EventEmitter); - -const myEmitter = new MyEmitter(); -myEmitter.on('event', function() { - console.log('an event occurred!'); -}); -``` - -You can't emit an event from the constructor immediately -because the script will not have processed to the point where the user -assigns a callback to that event. So, within the constructor itself, -you can use `process.nextTick()` to set a callback to emit the event -after the constructor has finished, which provides the expected results: - -```js -const EventEmitter = require('events'); -const util = require('util'); - -function MyEmitter() { - EventEmitter.call(this); - - // use nextTick to emit the event once a handler is assigned - process.nextTick(function () { - this.emit('event'); - }.bind(this)); -} -util.inherits(MyEmitter, EventEmitter); - -const myEmitter = new MyEmitter(); -myEmitter.on('event', function() { - console.log('an event occurred!'); -}); -``` - -[REPL]: https://nodejs.org/api/repl.html#repl_repl diff --git a/lib/.eslintrc b/lib/.eslintrc.yaml similarity index 100% rename from lib/.eslintrc rename to lib/.eslintrc.yaml diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 2a07cd25e26dd9..eebdb242463b5d 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -206,36 +206,40 @@ Agent.prototype.createSocket = function createSocket(req, options, cb) { } self.sockets[name].push(s); debug('sockets', name, self.sockets[name].length); - - function onFree() { - self.emit('free', s, options); - } - s.on('free', onFree); - - function onClose(err) { - debug('CLIENT socket onClose'); - // This is the only place where sockets get removed from the Agent. - // If you want to remove a socket from the pool, just close it. - // All socket errors end in a close event anyway. - self.removeSocket(s, options); - } - s.on('close', onClose); - - function onRemove() { - // We need this function for cases like HTTP 'upgrade' - // (defined by WebSockets) where we need to remove a socket from the - // pool because it'll be locked up indefinitely - debug('CLIENT socket onRemove'); - self.removeSocket(s, options); - s.removeListener('close', onClose); - s.removeListener('free', onFree); - s.removeListener('agentRemove', onRemove); - } - s.on('agentRemove', onRemove); + installListeners(self, s, options); cb(null, s); } }; +function installListeners(agent, s, options) { + function onFree() { + debug('CLIENT socket onFree'); + agent.emit('free', s, options); + } + s.on('free', onFree); + + function onClose(err) { + debug('CLIENT socket onClose'); + // This is the only place where sockets get removed from the Agent. + // If you want to remove a socket from the pool, just close it. + // All socket errors end in a close event anyway. + agent.removeSocket(s, options); + } + s.on('close', onClose); + + function onRemove() { + // We need this function for cases like HTTP 'upgrade' + // (defined by WebSockets) where we need to remove a socket from the + // pool because it'll be locked up indefinitely + debug('CLIENT socket onRemove'); + agent.removeSocket(s, options); + s.removeListener('close', onClose); + s.removeListener('free', onFree); + s.removeListener('agentRemove', onRemove); + } + s.on('agentRemove', onRemove); +} + Agent.prototype.removeSocket = function removeSocket(s, options) { var name = this.getName(options); debug('removeSocket', name, 'writable:', s.writable); diff --git a/lib/_http_client.js b/lib/_http_client.js index 1846e36e12bf88..bf99c440e92c88 100644 --- a/lib/_http_client.js +++ b/lib/_http_client.js @@ -13,7 +13,35 @@ const debug = common.debug; const OutgoingMessage = require('_http_outgoing').OutgoingMessage; const Agent = require('_http_agent'); const Buffer = require('buffer').Buffer; - +const urlToOptions = require('internal/url').urlToOptions; + +// The actual list of disallowed characters in regexp form is more like: +// /[^A-Za-z0-9\-._~!$&'()*+,;=/:@]/ +// with an additional rule for ignoring percentage-escaped characters, but +// that's a) hard to capture in a regular expression that performs well, and +// b) possibly too restrictive for real-world usage. So instead we restrict the +// filter to just control characters and spaces. +// +// This function is used in the case of small paths, where manual character code +// checks can greatly outperform the equivalent regexp (tested in V8 5.4). +function isInvalidPath(s) { + var i = 0; + if (s.charCodeAt(0) <= 32) return true; + if (++i >= s.length) return false; + if (s.charCodeAt(1) <= 32) return true; + if (++i >= s.length) return false; + if (s.charCodeAt(2) <= 32) return true; + if (++i >= s.length) return false; + if (s.charCodeAt(3) <= 32) return true; + if (++i >= s.length) return false; + if (s.charCodeAt(4) <= 32) return true; + if (++i >= s.length) return false; + if (s.charCodeAt(5) <= 32) return true; + ++i; + for (; i < s.length; ++i) + if (s.charCodeAt(i) <= 32) return true; + return false; +} function ClientRequest(options, cb) { var self = this; @@ -24,6 +52,8 @@ function ClientRequest(options, cb) { if (!options.hostname) { throw new Error('Unable to determine the domain name'); } + } else if (options instanceof url.URL) { + options = urlToOptions(options); } else { options = util._extend({}, options); } @@ -43,14 +73,20 @@ function ClientRequest(options, cb) { if (self.agent && self.agent.protocol) expectedProtocol = self.agent.protocol; - if (options.path && /[\u0000-\u0020]/.test(options.path)) { - // The actual regex is more like /[^A-Za-z0-9\-._~!$&'()*+,;=/:@]/ - // with an additional rule for ignoring percentage-escaped characters - // but that's a) hard to capture in a regular expression that performs - // well, and b) possibly too restrictive for real-world usage. - // Restrict the filter to control characters and spaces. - throw new TypeError('Request path contains unescaped characters'); - } else if (protocol !== expectedProtocol) { + var path; + if (options.path) { + path = '' + options.path; + var invalidPath; + if (path.length <= 39) { // Determined experimentally in V8 5.4 + invalidPath = isInvalidPath(path); + } else { + invalidPath = /[\u0000-\u0020]/.test(path); + } + if (invalidPath) + throw new TypeError('Request path contains unescaped characters'); + } + + if (protocol !== expectedProtocol) { throw new Error('Protocol "' + protocol + '" not supported. ' + 'Expected "' + expectedProtocol + '"'); } @@ -61,26 +97,36 @@ function ClientRequest(options, cb) { var port = options.port = options.port || defaultPort || 80; var host = options.host = options.hostname || options.host || 'localhost'; - if (options.setHost === undefined) { - var setHost = true; - } + var setHost = (options.setHost === undefined); self.socketPath = options.socketPath; self.timeout = options.timeout; - var method = self.method = (options.method || 'GET').toUpperCase(); - if (!common._checkIsHttpToken(method)) { - throw new TypeError('Method must be a valid HTTP token'); + var method = options.method; + var methodIsString = (typeof method === 'string'); + if (method != null && !methodIsString) { + throw new TypeError('Method must be a string'); + } + + if (methodIsString && method) { + if (!common._checkIsHttpToken(method)) { + throw new TypeError('Method must be a valid HTTP token'); + } + method = self.method = method.toUpperCase(); + } else { + method = self.method = 'GET'; } + self.path = options.path || '/'; if (cb) { self.once('response', cb); } - if (!Array.isArray(options.headers)) { + var headersArray = Array.isArray(options.headers); + if (!headersArray) { if (options.headers) { var keys = Object.keys(options.headers); - for (var i = 0, l = keys.length; i < l; i++) { + for (var i = 0; i < keys.length; i++) { var key = keys[i]; self.setHeader(key, options.headers[key]); } @@ -106,7 +152,6 @@ function ClientRequest(options, cb) { } if (options.auth && !this.getHeader('Authorization')) { - //basic auth this.setHeader('Authorization', 'Basic ' + Buffer.from(options.auth).toString('base64')); } @@ -121,7 +166,7 @@ function ClientRequest(options, cb) { self.useChunkedEncodingByDefault = true; } - if (Array.isArray(options.headers)) { + if (headersArray) { self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n', options.headers); } else if (self.getHeader('expect')) { @@ -129,6 +174,14 @@ function ClientRequest(options, cb) { self._renderHeaders()); } + this._ended = false; + this.res = null; + this.aborted = undefined; + this.timeoutCb = null; + this.upgradeOrConnect = false; + this.parser = null; + this.maxHeadersCount = null; + var called = false; if (self.socketPath) { self._last = true; @@ -196,16 +249,12 @@ function ClientRequest(options, cb) { self._flush(); self = null; }); - - this._ended = false; } util.inherits(ClientRequest, OutgoingMessage); exports.ClientRequest = ClientRequest; -ClientRequest.prototype.aborted = undefined; - ClientRequest.prototype._finish = function _finish() { DTRACE_HTTP_CLIENT_REQUEST(this, this.connection); LTTNG_HTTP_CLIENT_REQUEST(this, this.connection); @@ -219,7 +268,7 @@ ClientRequest.prototype._implicitHeader = function _implicitHeader() { }; ClientRequest.prototype.abort = function abort() { - if (this.aborted === undefined) { + if (!this.aborted) { process.nextTick(emitAbortNT, this); } // Mark as aborting so we can avoid sending queued request data @@ -448,7 +497,7 @@ function parserOnIncomingClient(res, shouldKeepAlive) { if (res.statusCode === 100) { // restart the parser, as this is a continue message. - delete req.res; // Clear res so that we don't hit double-responses. + req.res = null; // Clear res so that we don't hit double-responses. req.emit('continue'); return true; } @@ -580,7 +629,11 @@ ClientRequest.prototype.onSocket = function onSocket(socket) { function onSocketNT(req, socket) { if (req.aborted) { // If we were aborted while waiting for a socket, skip the whole thing. - socket.emit('free'); + if (req.socketPath || !req.agent) { + socket.destroy(); + } else { + socket.emit('free'); + } } else { tickOnSocket(req, socket); } @@ -651,21 +704,15 @@ ClientRequest.prototype.setTimeout = function setTimeout(msecs, callback) { return this; }; -ClientRequest.prototype.setNoDelay = function setNoDelay() { - const argsLen = arguments.length; - const args = new Array(argsLen); - for (var i = 0; i < argsLen; i++) - args[i] = arguments[i]; - this._deferToConnect('setNoDelay', args); -}; -ClientRequest.prototype.setSocketKeepAlive = function setSocketKeepAlive() { - const argsLen = arguments.length; - const args = new Array(argsLen); - for (var i = 0; i < argsLen; i++) - args[i] = arguments[i]; - this._deferToConnect('setKeepAlive', args); +ClientRequest.prototype.setNoDelay = function setNoDelay(noDelay) { + this._deferToConnect('setNoDelay', [noDelay]); }; +ClientRequest.prototype.setSocketKeepAlive = + function setSocketKeepAlive(enable, initialDelay) { + this._deferToConnect('setKeepAlive', [enable, initialDelay]); + }; + ClientRequest.prototype.clearTimeout = function clearTimeout(cb) { this.setTimeout(0, cb); }; diff --git a/lib/_http_common.js b/lib/_http_common.js index 2ce523fe6298bd..df21a7526b2e71 100644 --- a/lib/_http_common.js +++ b/lib/_http_common.js @@ -265,8 +265,6 @@ var validTokens = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 // ... 255 ]; function checkIsHttpToken(val) { - if (typeof val !== 'string' || val.length === 0) - return false; if (!validTokens[val.charCodeAt(0)]) return false; if (val.length < 2) diff --git a/lib/_http_outgoing.js b/lib/_http_outgoing.js index 67a8d6f8bb8233..163a00ff9878f4 100644 --- a/lib/_http_outgoing.js +++ b/lib/_http_outgoing.js @@ -319,18 +319,18 @@ function _storeHeader(firstLine, headers) { if (state.sentExpect) this._send(''); } -function storeHeader(self, state, field, value) { - if (!checkIsHttpToken(field)) { +function storeHeader(self, state, key, value) { + if (typeof key !== 'string' || !key || !checkIsHttpToken(key)) { throw new TypeError( - 'Header name must be a valid HTTP Token ["' + field + '"]'); + 'Header name must be a valid HTTP Token ["' + key + '"]'); } if (checkInvalidHeaderChar(value)) { - debug('Header "%s" contains invalid characters', field); + debug('Header "%s" contains invalid characters', key); throw new TypeError('The header content contains invalid characters'); } - state.messageHeader += field + ': ' + escapeHeaderValue(value) + CRLF; + state.messageHeader += key + ': ' + escapeHeaderValue(value) + CRLF; - if (connectionExpression.test(field)) { + if (connectionExpression.test(key)) { state.sentConnectionHeader = true; if (connCloseExpression.test(value)) { self._last = true; @@ -339,26 +339,26 @@ function storeHeader(self, state, field, value) { } if (connUpgradeExpression.test(value)) state.sentConnectionUpgrade = true; - } else if (transferEncodingExpression.test(field)) { + } else if (transferEncodingExpression.test(key)) { state.sentTransferEncodingHeader = true; if (trfrEncChunkExpression.test(value)) self.chunkedEncoding = true; - } else if (contentLengthExpression.test(field)) { + } else if (contentLengthExpression.test(key)) { state.sentContentLengthHeader = true; - } else if (dateExpression.test(field)) { + } else if (dateExpression.test(key)) { state.sentDateHeader = true; - } else if (expectExpression.test(field)) { + } else if (expectExpression.test(key)) { state.sentExpect = true; - } else if (trailerExpression.test(field)) { + } else if (trailerExpression.test(key)) { state.sentTrailer = true; - } else if (upgradeExpression.test(field)) { + } else if (upgradeExpression.test(key)) { state.sentUpgrade = true; } } OutgoingMessage.prototype.setHeader = function setHeader(name, value) { - if (!checkIsHttpToken(name)) + if (typeof name !== 'string' || !name || !checkIsHttpToken(name)) throw new TypeError( 'Header name must be a valid HTTP Token ["' + name + '"]'); if (value === undefined) @@ -538,7 +538,7 @@ OutgoingMessage.prototype.addTrailers = function addTrailers(headers) { field = key; value = headers[key]; } - if (!checkIsHttpToken(field)) { + if (typeof field !== 'string' || !field || !checkIsHttpToken(field)) { throw new TypeError( 'Trailer name must be a valid HTTP Token ["' + field + '"]'); } diff --git a/lib/_http_server.js b/lib/_http_server.js index 21113fc37a9f5b..bd726f83e3e638 100644 --- a/lib/_http_server.js +++ b/lib/_http_server.js @@ -248,6 +248,7 @@ function Server(requestListener) { this.timeout = 2 * 60 * 1000; this._pendingResponseData = 0; + this.maxHeadersCount = null; } util.inherits(Server, net.Server); diff --git a/lib/_stream_writable.js b/lib/_stream_writable.js index b20fe8d2ea91ed..ba56225d974fe9 100644 --- a/lib/_stream_writable.js +++ b/lib/_stream_writable.js @@ -194,23 +194,18 @@ function writeAfterEnd(stream, cb) { process.nextTick(cb, er); } -// If we get something that is not a buffer, string, null, or undefined, -// and we're not in objectMode, then that's an error. -// Otherwise stream chunks are all considered to be of length=1, and the -// watermarks determine how many objects to keep in the buffer, rather than -// how many bytes or characters. +// Checks that a user-supplied chunk is valid, especially for the particular +// mode the stream is in. Currently this means that `null` is never accepted +// and undefined/non-string values are only allowed in object mode. function validChunk(stream, state, chunk, cb) { var valid = true; var er = false; - // Always throw error if a null is written - // if we are not in object mode then throw - // if it is not a buffer, string, or undefined. + if (chunk === null) { er = new TypeError('May not write null values to stream'); - } else if (!(chunk instanceof Buffer) && - typeof chunk !== 'string' && - chunk !== undefined && - !state.objectMode) { + } else if (typeof chunk !== 'string' && + chunk !== undefined && + !state.objectMode) { er = new TypeError('Invalid non-string/buffer chunk'); } if (er) { @@ -224,13 +219,14 @@ function validChunk(stream, state, chunk, cb) { Writable.prototype.write = function(chunk, encoding, cb) { var state = this._writableState; var ret = false; + var isBuf = (chunk instanceof Buffer); if (typeof encoding === 'function') { cb = encoding; encoding = null; } - if (chunk instanceof Buffer) + if (isBuf) encoding = 'buffer'; else if (!encoding) encoding = state.defaultEncoding; @@ -240,9 +236,9 @@ Writable.prototype.write = function(chunk, encoding, cb) { if (state.ended) writeAfterEnd(this, cb); - else if (validChunk(this, state, chunk, cb)) { + else if (isBuf || validChunk(this, state, chunk, cb)) { state.pendingcb++; - ret = writeOrBuffer(this, state, chunk, encoding, cb); + ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb); } return ret; @@ -291,11 +287,12 @@ function decodeChunk(state, chunk, encoding) { // if we're already writing something, then just put this // in the queue, and wait our turn. Otherwise, call _write // If we return false, then we need a drain event, so set that flag. -function writeOrBuffer(stream, state, chunk, encoding, cb) { - chunk = decodeChunk(state, chunk, encoding); - - if (chunk instanceof Buffer) - encoding = 'buffer'; +function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) { + if (!isBuf) { + chunk = decodeChunk(state, chunk, encoding); + if (chunk instanceof Buffer) + encoding = 'buffer'; + } var len = state.objectMode ? 1 : chunk.length; state.length += len; diff --git a/lib/_tls_common.js b/lib/_tls_common.js index 85ae71f8d15cc1..107c3bb2ea7c67 100644 --- a/lib/_tls_common.js +++ b/lib/_tls_common.js @@ -134,7 +134,9 @@ exports.createSecureContext = function createSecureContext(options, context) { } } - // Do not keep read/write buffers in free list + // Do not keep read/write buffers in free list for OpenSSL < 1.1.0. (For + // OpenSSL 1.1.0, buffers are malloced and freed without the use of a + // freelist.) if (options.singleUse) { c.singleUse = true; c.context.setFreeListLength(0); diff --git a/lib/_tls_legacy.js b/lib/_tls_legacy.js index f974b0cfc05575..e765b2507e7502 100644 --- a/lib/_tls_legacy.js +++ b/lib/_tls_legacy.js @@ -1,6 +1,6 @@ 'use strict'; -require('internal/util').assertCrypto(exports); +require('internal/util').assertCrypto(); const assert = require('assert'); const EventEmitter = require('events'); diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index 434384cec81595..721cdde142519c 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -1,6 +1,6 @@ 'use strict'; -require('internal/util').assertCrypto(exports); +require('internal/util').assertCrypto(); const assert = require('assert'); const crypto = require('crypto'); diff --git a/lib/assert.js b/lib/assert.js index 04c5cb5ad436e1..7f69ba0c60e476 100644 --- a/lib/assert.js +++ b/lib/assert.js @@ -30,16 +30,16 @@ const util = require('util'); const Buffer = require('buffer').Buffer; const pToString = (obj) => Object.prototype.toString.call(obj); -// 1. The assert module provides functions that throw +// The assert module provides functions that throw // AssertionError's when particular conditions are not met. The // assert module must conform to the following interface. const assert = module.exports = ok; -// 2. The AssertionError is defined in assert. +// The AssertionError is defined in assert. // new assert.AssertionError({ message: message, // actual: actual, -// expected: expected }) +// expected: expected }); assert.AssertionError = function AssertionError(options) { this.name = 'AssertionError'; @@ -75,7 +75,7 @@ function getMessage(self) { // other keys to the AssertionError's constructor - they will be // ignored. -// 3. All of the following functions must throw an AssertionError +// All of the following functions must throw an AssertionError // when a corresponding condition is not met, with a message that // may be undefined if not provided. All assertion methods provide // both the actual and expected values to the assertion error for @@ -94,7 +94,7 @@ function fail(actual, expected, message, operator, stackStartFunction) { // EXTENSION! allows for well behaved errors defined elsewhere. assert.fail = fail; -// 4. Pure assertion tests whether a value is truthy, as determined +// Pure assertion tests whether a value is truthy, as determined // by !!guard. // assert.ok(guard, message_opt); // This statement is equivalent to assert.equal(true, !!guard, @@ -106,16 +106,17 @@ function ok(value, message) { } assert.ok = ok; -// 5. The equality assertion tests shallow, coercive equality with +// The equality assertion tests shallow, coercive equality with // ==. // assert.equal(actual, expected, message_opt); - +/* eslint-disable no-restricted-properties */ assert.equal = function equal(actual, expected, message) { if (actual != expected) fail(actual, expected, message, '==', assert.equal); }; -// 6. The non-equality assertion tests for whether two objects are not equal -// with != assert.notEqual(actual, expected, message_opt); +// The non-equality assertion tests for whether two objects are not +// equal with !=. +// assert.notEqual(actual, expected, message_opt); assert.notEqual = function notEqual(actual, expected, message) { if (actual == expected) { @@ -123,10 +124,9 @@ assert.notEqual = function notEqual(actual, expected, message) { } }; -// 7. The equivalence assertion tests a deep equality relation. +// The equivalence assertion tests a deep equality relation. // assert.deepEqual(actual, expected, message_opt); -/* eslint-disable no-restricted-properties */ assert.deepEqual = function deepEqual(actual, expected, message) { if (!_deepEqual(actual, expected, false)) { fail(actual, expected, message, 'deepEqual', assert.deepEqual); @@ -141,18 +141,22 @@ assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { }; function _deepEqual(actual, expected, strict, memos) { - // 7.1. All identical values are equivalent, as determined by ===. + // All identical values are equivalent, as determined by ===. if (actual === expected) { return true; + + // If both values are instances of buffers, equivalence is + // determined by comparing the values and ensuring the result + // === 0. } else if (actual instanceof Buffer && expected instanceof Buffer) { return compare(actual, expected) === 0; - // 7.2. If the expected value is a Date object, the actual value is + // If the expected value is a Date object, the actual value is // equivalent if it is also a Date object that refers to the same time. } else if (util.isDate(actual) && util.isDate(expected)) { return actual.getTime() === expected.getTime(); - // 7.3 If the expected value is a RegExp object, the actual value is + // If the expected value is a RegExp object, the actual value is // equivalent if it is also a RegExp object with the same source and // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`). } else if (util.isRegExp(actual) && util.isRegExp(expected)) { @@ -162,18 +166,18 @@ function _deepEqual(actual, expected, strict, memos) { actual.lastIndex === expected.lastIndex && actual.ignoreCase === expected.ignoreCase; - // 7.4. Other pairs that do not both pass typeof value == 'object', - // equivalence is determined by ==. + // If both values are primitives, equivalence is determined by + // == or, if checking for strict equivalence, ===. } else if ((actual === null || typeof actual !== 'object') && (expected === null || typeof expected !== 'object')) { return strict ? actual === expected : actual == expected; // If both values are instances of typed arrays, wrap their underlying - // ArrayBuffers in a Buffer each to increase performance + // ArrayBuffers in a Buffer to increase performance. // This optimization requires the arrays to have the same type as checked by - // Object.prototype.toString (aka pToString). Never perform binary - // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their - // bit patterns are not identical. + // Object.prototype.toString (pToString). Never perform binary + // comparisons for Float*Arrays, though, since +0 === -0 is true despite the + // two values' bit patterns not being identical. } else if (ArrayBuffer.isView(actual) && ArrayBuffer.isView(expected) && pToString(actual) === pToString(expected) && !(actual instanceof Float32Array || @@ -185,7 +189,7 @@ function _deepEqual(actual, expected, strict, memos) { expected.byteOffset, expected.byteLength)) === 0; - // 7.5 For all other Object pairs, including Array objects, equivalence is + // For all other Object pairs, including Array objects, equivalence is // determined by having the same number of owned properties (as verified // with Object.prototype.hasOwnProperty.call), the same set of keys // (although not necessarily the same order), equivalent values for every @@ -215,7 +219,8 @@ function isArguments(object) { function objEquiv(a, b, strict, actualVisitedObjects) { if (a === null || a === undefined || b === null || b === undefined) return false; - // if one is a primitive, the other must be same + + // If one is a primitive, the other must be the same. if (util.isPrimitive(a) || util.isPrimitive(b)) return a === b; if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) @@ -227,20 +232,23 @@ function objEquiv(a, b, strict, actualVisitedObjects) { const ka = Object.keys(a); const kb = Object.keys(b); var key, i; - // having the same number of owned properties (keys incorporates - // hasOwnProperty) + + // The pair must have the same number of owned properties (keys + // incorporates hasOwnProperty). if (ka.length !== kb.length) return false; - //the same set of keys (although not necessarily the same order), + + // The pair must have the same set of keys (although not + // necessarily in the same order). ka.sort(); kb.sort(); - //~~~cheap key test + // Cheap key test: for (i = ka.length - 1; i >= 0; i--) { if (ka[i] !== kb[i]) return false; } - //equivalent values for every corresponding key, and - //~~~possibly expensive deep test + // The pair must have equivalent values for every corresponding key. + // Possibly expensive deep test: for (i = ka.length - 1; i >= 0; i--) { key = ka[i]; if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects)) @@ -249,7 +257,7 @@ function objEquiv(a, b, strict, actualVisitedObjects) { return true; } -// 8. The non-equivalence assertion tests for any deep inequality. +// The non-equivalence assertion tests for any deep inequality. // assert.notDeepEqual(actual, expected, message_opt); assert.notDeepEqual = function notDeepEqual(actual, expected, message) { @@ -266,7 +274,7 @@ function notDeepStrictEqual(actual, expected, message) { } -// 9. The strict equality assertion tests strict equality, as determined by ===. +// The strict equality assertion tests strict equality, as determined by ===. // assert.strictEqual(actual, expected, message_opt); assert.strictEqual = function strictEqual(actual, expected, message) { @@ -275,8 +283,9 @@ assert.strictEqual = function strictEqual(actual, expected, message) { } }; -// 10. The strict non-equality assertion tests for strict inequality, as -// determined by !==. assert.notStrictEqual(actual, expected, message_opt); +// The strict non-equality assertion tests for strict inequality, as +// determined by !==. +// assert.notStrictEqual(actual, expected, message_opt); assert.notStrictEqual = function notStrictEqual(actual, expected, message) { if (actual === expected) { @@ -298,7 +307,7 @@ function expectedException(actual, expected) { return true; } } catch (e) { - // Ignore. The instanceof check doesn't work for arrow functions. + // Ignore. The instanceof check doesn't work for arrow functions. } if (Error.isPrototypeOf(expected)) { @@ -356,7 +365,7 @@ function _throws(shouldThrow, block, expected, message) { } } -// 11. Expected to throw an error: +// Expected to throw an error. // assert.throws(block, Error_opt, message_opt); assert.throws = function throws(block, /*optional*/error, /*optional*/message) { diff --git a/lib/buffer.js b/lib/buffer.js index a6a0d59f74f52f..299b9bc01177be 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -2,6 +2,7 @@ 'use strict'; const binding = process.binding('buffer'); +const { compare: compare_, compareOffset } = binding; const { isArrayBuffer, isSharedArrayBuffer } = process.binding('util'); const bindingObj = {}; const internalUtil = require('internal/util'); @@ -537,36 +538,43 @@ Buffer.prototype.compare = function compare(target, if (!(target instanceof Buffer)) throw new TypeError('Argument must be a Buffer'); + if (arguments.length === 1) + return compare_(this, target); if (start === undefined) start = 0; + else if (start < 0) + throw new RangeError('out of range index'); + else + start >>>= 0; + if (end === undefined) end = target.length; + else if (end > target.length) + throw new RangeError('out of range index'); + else + end >>>= 0; + if (thisStart === undefined) thisStart = 0; + else if (thisStart < 0) + throw new RangeError('out of range index'); + else + thisStart >>>= 0; + if (thisEnd === undefined) thisEnd = this.length; - - if (start < 0 || - end > target.length || - thisStart < 0 || - thisEnd > this.length) { + else if (thisEnd > this.length) throw new RangeError('out of range index'); - } + else + thisEnd >>>= 0; - if (thisStart >= thisEnd && start >= end) - return 0; if (thisStart >= thisEnd) - return -1; - if (start >= end) + return (start >= end ? 0 : -1); + else if (start >= end) return 1; - start >>>= 0; - end >>>= 0; - thisStart >>>= 0; - thisEnd >>>= 0; - - return binding.compareOffset(this, target, start, thisStart, end, thisEnd); + return compareOffset(this, target, start, thisStart, end, thisEnd); }; @@ -588,9 +596,10 @@ function bidirectionalIndexOf(buffer, val, byteOffset, encoding, dir) { } else if (byteOffset < -0x80000000) { byteOffset = -0x80000000; } - byteOffset = +byteOffset; // Coerce to Number. - if (isNaN(byteOffset)) { - // If the offset is undefined, null, NaN, "foo", etc, search whole buffer. + // Coerce to Number. Values like null and [] become 0. + byteOffset = +byteOffset; + // If the offset is undefined, "foo", {}, coerces to NaN, search whole buffer. + if (Number.isNaN(byteOffset)) { byteOffset = dir ? 0 : (buffer.length - 1); } dir = !!dir; // Cast to bool. @@ -793,10 +802,14 @@ Buffer.prototype.write = function(string, offset, length, encoding) { Buffer.prototype.toJSON = function() { - return { - type: 'Buffer', - data: Array.prototype.slice.call(this, 0) - }; + if (this.length) { + const data = []; + for (var i = 0; i < this.length; ++i) + data[i] = this[i]; + return { type: 'Buffer', data }; + } else { + return { type: 'Buffer', data: [] }; + } }; diff --git a/lib/cluster.js b/lib/cluster.js index e95e19bcc672d4..02bf3d8f600776 100644 --- a/lib/cluster.js +++ b/lib/cluster.js @@ -1,770 +1,5 @@ 'use strict'; -const EventEmitter = require('events'); -const assert = require('assert'); -const dgram = require('dgram'); -const fork = require('child_process').fork; -const net = require('net'); -const util = require('util'); -const internalUtil = require('internal/util'); -const SCHED_NONE = 1; -const SCHED_RR = 2; - -const uv = process.binding('uv'); - -const cluster = new EventEmitter(); -module.exports = cluster; -cluster.Worker = Worker; -cluster.isWorker = ('NODE_UNIQUE_ID' in process.env); -cluster.isMaster = (cluster.isWorker === false); - - -function Worker(options) { - if (!(this instanceof Worker)) - return new Worker(options); - - EventEmitter.call(this); - - if (options === null || typeof options !== 'object') - options = {}; - - this.exitedAfterDisconnect = undefined; - - Object.defineProperty(this, 'suicide', { - get: internalUtil.deprecate(() => { - return this.exitedAfterDisconnect; - }, 'worker.suicide is deprecated. ' + - 'Please use worker.exitedAfterDisconnect.'), - set: internalUtil.deprecate((val) => { - this.exitedAfterDisconnect = val; - }, 'worker.suicide is deprecated. ' + - 'Please use worker.exitedAfterDisconnect.'), - enumerable: true - }); - - this.state = options.state || 'none'; - this.id = options.id | 0; - - if (options.process) { - this.process = options.process; - this.process.on('error', (code, signal) => - this.emit('error', code, signal) - ); - this.process.on('message', (message, handle) => - this.emit('message', message, handle) - ); - } -} -util.inherits(Worker, EventEmitter); - -Worker.prototype.kill = function() { - this.destroy.apply(this, arguments); -}; - -Worker.prototype.send = function() { - return this.process.send.apply(this.process, arguments); -}; - -Worker.prototype.isDead = function isDead() { - return this.process.exitCode != null || this.process.signalCode != null; -}; - -Worker.prototype.isConnected = function isConnected() { - return this.process.connected; -}; - -// Master/worker specific methods are defined in the *Init() functions. - -function SharedHandle(key, address, port, addressType, fd, flags) { - this.key = key; - this.workers = []; - this.handle = null; - this.errno = 0; - - // FIXME(bnoordhuis) Polymorphic return type for lack of a better solution. - var rval; - if (addressType === 'udp4' || addressType === 'udp6') - rval = dgram._createSocketHandle(address, port, addressType, fd, flags); - else - rval = net._createServerHandle(address, port, addressType, fd); - - if (typeof rval === 'number') - this.errno = rval; - else - this.handle = rval; -} - -SharedHandle.prototype.add = function(worker, send) { - assert(this.workers.indexOf(worker) === -1); - this.workers.push(worker); - send(this.errno, null, this.handle); -}; - -SharedHandle.prototype.remove = function(worker) { - var index = this.workers.indexOf(worker); - if (index === -1) return false; // The worker wasn't sharing this handle. - this.workers.splice(index, 1); - if (this.workers.length !== 0) return false; - this.handle.close(); - this.handle = null; - return true; -}; - - -// Start a round-robin server. Master accepts connections and distributes -// them over the workers. -function RoundRobinHandle(key, address, port, addressType, fd) { - this.key = key; - this.all = {}; - this.free = []; - this.handles = []; - this.handle = null; - this.server = net.createServer(assert.fail); - - if (fd >= 0) - this.server.listen({ fd: fd }); - else if (port >= 0) - this.server.listen(port, address); - else - this.server.listen(address); // UNIX socket path. - - this.server.once('listening', () => { - this.handle = this.server._handle; - this.handle.onconnection = (err, handle) => this.distribute(err, handle); - this.server._handle = null; - this.server = null; - }); -} - -RoundRobinHandle.prototype.add = function(worker, send) { - assert(worker.id in this.all === false); - this.all[worker.id] = worker; - - const done = () => { - if (this.handle.getsockname) { - var out = {}; - this.handle.getsockname(out); - // TODO(bnoordhuis) Check err. - send(null, { sockname: out }, null); - } else { - send(null, null, null); // UNIX socket. - } - this.handoff(worker); // In case there are connections pending. - }; - - if (this.server === null) return done(); - // Still busy binding. - this.server.once('listening', done); - this.server.once('error', function(err) { - // Hack: translate 'EADDRINUSE' error string back to numeric error code. - // It works but ideally we'd have some backchannel between the net and - // cluster modules for stuff like this. - var errno = uv['UV_' + err.errno]; - send(errno, null); - }); -}; - -RoundRobinHandle.prototype.remove = function(worker) { - if (worker.id in this.all === false) return false; - delete this.all[worker.id]; - var index = this.free.indexOf(worker); - if (index !== -1) this.free.splice(index, 1); - if (Object.getOwnPropertyNames(this.all).length !== 0) return false; - for (var handle; handle = this.handles.shift(); handle.close()); - this.handle.close(); - this.handle = null; - return true; -}; - -RoundRobinHandle.prototype.distribute = function(err, handle) { - this.handles.push(handle); - var worker = this.free.shift(); - if (worker) this.handoff(worker); -}; - -RoundRobinHandle.prototype.handoff = function(worker) { - if (worker.id in this.all === false) { - return; // Worker is closing (or has closed) the server. - } - var handle = this.handles.shift(); - if (handle === undefined) { - this.free.push(worker); // Add to ready queue again. - return; - } - var message = { act: 'newconn', key: this.key }; - - sendHelper(worker.process, message, handle, (reply) => { - if (reply.accepted) - handle.close(); - else - this.distribute(0, handle); // Worker is shutting down. Send to another. - this.handoff(worker); - }); -}; - - -if (cluster.isMaster) - masterInit(); -else - workerInit(); - -function masterInit() { - cluster.workers = {}; - - var intercom = new EventEmitter(); - cluster.settings = {}; - - // XXX(bnoordhuis) Fold cluster.schedulingPolicy into cluster.settings? - var schedulingPolicy = { - 'none': SCHED_NONE, - 'rr': SCHED_RR - }[process.env.NODE_CLUSTER_SCHED_POLICY]; - - if (schedulingPolicy === undefined) { - // FIXME Round-robin doesn't perform well on Windows right now due to the - // way IOCP is wired up. Bert is going to fix that, eventually. - schedulingPolicy = (process.platform === 'win32') ? SCHED_NONE : SCHED_RR; - } - - cluster.schedulingPolicy = schedulingPolicy; - cluster.SCHED_NONE = SCHED_NONE; // Leave it to the operating system. - cluster.SCHED_RR = SCHED_RR; // Master distributes connections. - - // Keyed on address:port:etc. When a worker dies, we walk over the handles - // and remove() the worker from each one. remove() may do a linear scan - // itself so we might end up with an O(n*m) operation. Ergo, FIXME. - const handles = require('internal/cluster').handles; - - var initialized = false; - cluster.setupMaster = function(options) { - var settings = { - args: process.argv.slice(2), - exec: process.argv[1], - execArgv: process.execArgv, - silent: false - }; - settings = util._extend(settings, cluster.settings); - settings = util._extend(settings, options || {}); - // Tell V8 to write profile data for each process to a separate file. - // Without --logfile=v8-%p.log, everything ends up in a single, unusable - // file. (Unusable because what V8 logs are memory addresses and each - // process has its own memory mappings.) - if (settings.execArgv.some((s) => s.startsWith('--prof')) && - !settings.execArgv.some((s) => s.startsWith('--logfile='))) { - settings.execArgv = settings.execArgv.concat(['--logfile=v8-%p.log']); - } - cluster.settings = settings; - if (initialized === true) - return process.nextTick(setupSettingsNT, settings); - initialized = true; - schedulingPolicy = cluster.schedulingPolicy; // Freeze policy. - assert(schedulingPolicy === SCHED_NONE || schedulingPolicy === SCHED_RR, - 'Bad cluster.schedulingPolicy: ' + schedulingPolicy); - - var hasDebugArg = process.execArgv.some(function(argv) { - return /^(--debug|--debug-brk)(=\d+)?$/.test(argv); - }); - - process.nextTick(setupSettingsNT, settings); - - // Send debug signal only if not started in debug mode, this helps a lot - // on windows, because RegisterDebugHandler is not called when node starts - // with --debug.* arg. - if (hasDebugArg) - return; - - process.on('internalMessage', function(message) { - if (message.cmd !== 'NODE_DEBUG_ENABLED') return; - var key; - for (key in cluster.workers) { - var worker = cluster.workers[key]; - if (worker.state === 'online' || worker.state === 'listening') { - process._debugProcess(worker.process.pid); - } else { - worker.once('online', function() { - process._debugProcess(this.process.pid); - }); - } - } - }); - }; - - function setupSettingsNT(settings) { - cluster.emit('setup', settings); - } - - var debugPortOffset = 1; - - function createWorkerProcess(id, env) { - var workerEnv = util._extend({}, process.env); - var execArgv = cluster.settings.execArgv.slice(); - var debugPort = 0; - - workerEnv = util._extend(workerEnv, env); - workerEnv.NODE_UNIQUE_ID = '' + id; - - for (var i = 0; i < execArgv.length; i++) { - var match = execArgv[i].match( - /^(--inspect|--debug|--debug-(brk|port))(=\d+)?$/ - ); - - if (match) { - if (debugPort === 0) { - debugPort = process.debugPort + debugPortOffset; - ++debugPortOffset; - } - - execArgv[i] = match[1] + '=' + debugPort; - } - } - - return fork(cluster.settings.exec, cluster.settings.args, { - env: workerEnv, - silent: cluster.settings.silent, - execArgv: execArgv, - stdio: cluster.settings.stdio, - gid: cluster.settings.gid, - uid: cluster.settings.uid - }); - } - - var ids = 0; - - function removeWorker(worker) { - assert(worker); - - delete cluster.workers[worker.id]; - - if (Object.keys(cluster.workers).length === 0) { - assert(Object.keys(handles).length === 0, 'Resource leak detected.'); - intercom.emit('disconnect'); - } - } - - function removeHandlesForWorker(worker) { - assert(worker); - - for (var key in handles) { - var handle = handles[key]; - if (handle.remove(worker)) delete handles[key]; - } - } - - cluster.fork = function(env) { - cluster.setupMaster(); - const id = ++ids; - const workerProcess = createWorkerProcess(id, env); - const worker = new Worker({ - id: id, - process: workerProcess - }); - - worker.on('message', function(message, handle) { - cluster.emit('message', this, message, handle); - }); - - worker.process.once('exit', function(exitCode, signalCode) { - /* - * Remove the worker from the workers list only - * if it has disconnected, otherwise we might - * still want to access it. - */ - if (!worker.isConnected()) { - removeHandlesForWorker(worker); - removeWorker(worker); - } - - worker.exitedAfterDisconnect = !!worker.exitedAfterDisconnect; - worker.state = 'dead'; - worker.emit('exit', exitCode, signalCode); - cluster.emit('exit', worker, exitCode, signalCode); - }); - - worker.process.once('disconnect', function() { - /* - * Now is a good time to remove the handles - * associated with this worker because it is - * not connected to the master anymore. - */ - removeHandlesForWorker(worker); - - /* - * Remove the worker from the workers list only - * if its process has exited. Otherwise, we might - * still want to access it. - */ - if (worker.isDead()) removeWorker(worker); - - worker.exitedAfterDisconnect = !!worker.exitedAfterDisconnect; - worker.state = 'disconnected'; - worker.emit('disconnect'); - cluster.emit('disconnect', worker); - }); - - worker.process.on('internalMessage', internal(worker, onmessage)); - process.nextTick(emitForkNT, worker); - cluster.workers[worker.id] = worker; - return worker; - }; - - function emitForkNT(worker) { - cluster.emit('fork', worker); - } - - cluster.disconnect = function(cb) { - var workers = Object.keys(cluster.workers); - if (workers.length === 0) { - process.nextTick(() => intercom.emit('disconnect')); - } else { - for (var key in workers) { - key = workers[key]; - if (cluster.workers[key].isConnected()) - cluster.workers[key].disconnect(); - } - } - if (cb) intercom.once('disconnect', cb); - }; - - Worker.prototype.disconnect = function() { - this.exitedAfterDisconnect = true; - send(this, { act: 'disconnect' }); - removeHandlesForWorker(this); - removeWorker(this); - return this; - }; - - Worker.prototype.destroy = function(signo) { - signo = signo || 'SIGTERM'; - var proc = this.process; - if (this.isConnected()) { - this.once('disconnect', () => proc.kill(signo)); - this.disconnect(); - return; - } - proc.kill(signo); - }; - - function onmessage(message, handle) { - var worker = this; - if (message.act === 'online') - online(worker); - else if (message.act === 'queryServer') - queryServer(worker, message); - else if (message.act === 'listening') - listening(worker, message); - else if (message.act === 'exitedAfterDisconnect') - exitedAfterDisconnect(worker, message); - else if (message.act === 'close') - close(worker, message); - } - - function online(worker) { - worker.state = 'online'; - worker.emit('online'); - cluster.emit('online', worker); - } - - function exitedAfterDisconnect(worker, message) { - worker.exitedAfterDisconnect = true; - send(worker, { ack: message.seq }); - } - - function queryServer(worker, message) { - // Stop processing if worker already disconnecting - if (worker.exitedAfterDisconnect) - return; - var args = [message.address, - message.port, - message.addressType, - message.fd, - message.index]; - var key = args.join(':'); - var handle = handles[key]; - if (handle === undefined) { - var constructor = RoundRobinHandle; - // UDP is exempt from round-robin connection balancing for what should - // be obvious reasons: it's connectionless. There is nothing to send to - // the workers except raw datagrams and that's pointless. - if (schedulingPolicy !== SCHED_RR || - message.addressType === 'udp4' || - message.addressType === 'udp6') { - constructor = SharedHandle; - } - handles[key] = handle = new constructor(key, - message.address, - message.port, - message.addressType, - message.fd, - message.flags); - } - if (!handle.data) handle.data = message.data; - - // Set custom server data - handle.add(worker, function(errno, reply, handle) { - reply = util._extend({ - errno: errno, - key: key, - ack: message.seq, - data: handles[key].data - }, reply); - if (errno) delete handles[key]; // Gives other workers a chance to retry. - send(worker, reply, handle); - }); - } - - function listening(worker, message) { - var info = { - addressType: message.addressType, - address: message.address, - port: message.port, - fd: message.fd - }; - worker.state = 'listening'; - worker.emit('listening', info); - cluster.emit('listening', worker, info); - } - - // Server in worker is closing, remove from list. The handle may have been - // removed by a prior call to removeHandlesForWorker() so guard against that. - function close(worker, message) { - var key = message.key; - var handle = handles[key]; - if (handle && handle.remove(worker)) delete handles[key]; - } - - function send(worker, message, handle, cb) { - return sendHelper(worker.process, message, handle, cb); - } -} - - -function workerInit() { - var handles = {}; - var indexes = {}; - - // Called from src/node.js - cluster._setupWorker = function() { - var worker = new Worker({ - id: +process.env.NODE_UNIQUE_ID | 0, - process: process, - state: 'online' - }); - cluster.worker = worker; - process.once('disconnect', function() { - worker.emit('disconnect'); - if (!worker.exitedAfterDisconnect) { - // Unexpected disconnect, master exited, or some such nastiness, so - // worker exits immediately. - process.exit(0); - } - }); - process.on('internalMessage', internal(worker, onmessage)); - send({ act: 'online' }); - function onmessage(message, handle) { - if (message.act === 'newconn') - onconnection(message, handle); - else if (message.act === 'disconnect') - _disconnect.call(worker, true); - } - }; - - // obj is a net#Server or a dgram#Socket object. - cluster._getServer = function(obj, options, cb) { - const indexesKey = [ options.address, - options.port, - options.addressType, - options.fd ].join(':'); - if (indexes[indexesKey] === undefined) - indexes[indexesKey] = 0; - else - indexes[indexesKey]++; - - const message = util._extend({ - act: 'queryServer', - index: indexes[indexesKey], - data: null - }, options); - - // Set custom data on handle (i.e. tls tickets key) - if (obj._getServerData) message.data = obj._getServerData(); - send(message, function(reply, handle) { - if (obj._setServerData) obj._setServerData(reply.data); - - if (handle) - shared(reply, handle, indexesKey, cb); // Shared listen socket. - else - rr(reply, indexesKey, cb); // Round-robin. - }); - obj.once('listening', function() { - cluster.worker.state = 'listening'; - const address = obj.address(); - message.act = 'listening'; - message.port = address && address.port || options.port; - send(message); - }); - }; - - // Shared listen socket. - function shared(message, handle, indexesKey, cb) { - var key = message.key; - // Monkey-patch the close() method so we can keep track of when it's - // closed. Avoids resource leaks when the handle is short-lived. - var close = handle.close; - handle.close = function() { - send({ act: 'close', key: key }); - delete handles[key]; - delete indexes[indexesKey]; - return close.apply(this, arguments); - }; - assert(handles[key] === undefined); - handles[key] = handle; - cb(message.errno, handle); - } - - // Round-robin. Master distributes handles across workers. - function rr(message, indexesKey, cb) { - if (message.errno) - return cb(message.errno, null); - - var key = message.key; - function listen(backlog) { - // TODO(bnoordhuis) Send a message to the master that tells it to - // update the backlog size. The actual backlog should probably be - // the largest requested size by any worker. - return 0; - } - - function close() { - // lib/net.js treats server._handle.close() as effectively synchronous. - // That means there is a time window between the call to close() and - // the ack by the master process in which we can still receive handles. - // onconnection() below handles that by sending those handles back to - // the master. - if (key === undefined) return; - send({ act: 'close', key: key }); - delete handles[key]; - delete indexes[indexesKey]; - key = undefined; - } - - function getsockname(out) { - if (key) util._extend(out, message.sockname); - return 0; - } - - // XXX(bnoordhuis) Probably no point in implementing ref() and unref() - // because the control channel is going to keep the worker alive anyway. - function ref() { - } - - function unref() { - } - - // Faux handle. Mimics a TCPWrap with just enough fidelity to get away - // with it. Fools net.Server into thinking that it's backed by a real - // handle. - var handle = { - close: close, - listen: listen, - ref: ref, - unref: unref, - }; - if (message.sockname) { - handle.getsockname = getsockname; // TCP handles only. - } - assert(handles[key] === undefined); - handles[key] = handle; - cb(0, handle); - } - - // Round-robin connection. - function onconnection(message, handle) { - var key = message.key; - var server = handles[key]; - var accepted = server !== undefined; - send({ ack: message.seq, accepted: accepted }); - if (accepted) server.onconnection(0, handle); - } - - Worker.prototype.disconnect = function() { - _disconnect.call(this); - return this; - }; - - Worker.prototype.destroy = function() { - this.exitedAfterDisconnect = true; - if (!this.isConnected()) { - process.exit(0); - } else { - send({ act: 'exitedAfterDisconnect' }, () => process.disconnect()); - process.once('disconnect', () => process.exit(0)); - } - }; - - function send(message, cb) { - return sendHelper(process, message, null, cb); - } - - function _disconnect(masterInitiated) { - this.exitedAfterDisconnect = true; - let waitingCount = 1; - - function checkWaitingCount() { - waitingCount--; - if (waitingCount === 0) { - // If disconnect is worker initiated, wait for ack to be sure - // exitedAfterDisconnect is properly set in the master, otherwise, if - // it's master initiated there's no need to send the - // exitedAfterDisconnect message - if (masterInitiated) { - process.disconnect(); - } else { - send({ act: 'exitedAfterDisconnect' }, () => process.disconnect()); - } - } - } - - for (const key in handles) { - const handle = handles[key]; - delete handles[key]; - waitingCount++; - - if (handle.owner) - handle.owner.close(checkWaitingCount); - else - handle.close(checkWaitingCount); - } - - checkWaitingCount(); - } -} - - -var seq = 0; -var callbacks = {}; -function sendHelper(proc, message, handle, cb) { - if (!proc.connected) - return false; - - // Mark message as internal. See INTERNAL_PREFIX in lib/child_process.js - message = util._extend({ cmd: 'NODE_CLUSTER' }, message); - if (cb) callbacks[seq] = cb; - message.seq = seq; - seq += 1; - return proc.send(message, handle); -} - - -// Returns an internalMessage listener that hands off normal messages -// to the callback but intercepts and redirects ACK messages. -function internal(worker, cb) { - return function(message, handle) { - if (message.cmd !== 'NODE_CLUSTER') return; - var fn = cb; - if (message.ack !== undefined && callbacks[message.ack] !== undefined) { - fn = callbacks[message.ack]; - delete callbacks[message.ack]; - } - fn.apply(worker, arguments); - }; -} +module.exports = ('NODE_UNIQUE_ID' in process.env) ? + require('internal/cluster/child') : + require('internal/cluster/master'); diff --git a/lib/crypto.js b/lib/crypto.js index 6b2a04711a868a..9180ce70dce12e 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -4,7 +4,7 @@ 'use strict'; const internalUtil = require('internal/util'); -internalUtil.assertCrypto(exports); +internalUtil.assertCrypto(); exports.DEFAULT_ENCODING = 'buffer'; @@ -637,17 +637,17 @@ exports.randomBytes = exports.pseudoRandomBytes = randomBytes; exports.rng = exports.prng = randomBytes; -exports.getCiphers = internalUtil.cachedResult(() => { - return internalUtil.filterDuplicateStrings(getCiphers()); -}); +exports.getCiphers = internalUtil.cachedResult( + () => internalUtil.filterDuplicateStrings(getCiphers()) +); -exports.getHashes = internalUtil.cachedResult(() => { - return internalUtil.filterDuplicateStrings(getHashes()); -}); +exports.getHashes = internalUtil.cachedResult( + () => internalUtil.filterDuplicateStrings(getHashes()) +); -exports.getCurves = internalUtil.cachedResult(() => { - return internalUtil.filterDuplicateStrings(getCurves()); -}); +exports.getCurves = internalUtil.cachedResult( + () => internalUtil.filterDuplicateStrings(getCurves()) +); Object.defineProperty(exports, 'fips', { get: getFipsCrypto, diff --git a/lib/events.js b/lib/events.js index 6a8345ab7bc516..000fa98d5a88c5 100644 --- a/lib/events.js +++ b/lib/events.js @@ -148,7 +148,8 @@ EventEmitter.prototype.emit = function emit(type) { // If there is no 'error' event listener then throw. if (doError) { - er = arguments[1]; + if (arguments.length > 1) + er = arguments[1]; if (domain) { if (!er) er = new Error('Uncaught, unspecified "error" event'); @@ -360,6 +361,8 @@ EventEmitter.prototype.removeListener = } else { delete events[type]; } + } else if (position === 0) { + list.shift(); } else { spliceOne(list, position); } diff --git a/lib/fs.js b/lib/fs.js index d407cf1479eac0..da67f2742cb892 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -1453,8 +1453,8 @@ const splitRootRe = isWindows ? /^(?:[a-zA-Z]:|[\\/]{2}[^\\/]+[\\/][^\\/]+)?[\\/]*/ : /^[/]*/; -function encodeRealpathResult(result, options, err) { - if (!options || !options.encoding || options.encoding === 'utf8' || err) +function encodeRealpathResult(result, options) { + if (!options || !options.encoding || options.encoding === 'utf8') return result; const asBuffer = Buffer.from(result); if (options.encoding === 'buffer') { diff --git a/lib/https.js b/lib/https.js index 26b6cbf279a15f..e59e7dfcb6beeb 100644 --- a/lib/https.js +++ b/lib/https.js @@ -1,6 +1,6 @@ 'use strict'; -require('internal/util').assertCrypto(exports); +require('internal/util').assertCrypto(); const tls = require('tls'); const url = require('url'); @@ -8,6 +8,7 @@ const http = require('http'); const util = require('util'); const inherits = util.inherits; const debug = util.debuglog('https'); +const urlToOptions = require('internal/url').urlToOptions; function Server(opts, requestListener) { if (!(this instanceof Server)) return new Server(opts, requestListener); @@ -143,6 +144,10 @@ Agent.prototype.getName = function getName(options) { if (options.servername && options.servername !== options.host) name += options.servername; + name += ':'; + if (options.secureProtocol) + name += options.secureProtocol; + return name; }; @@ -192,6 +197,8 @@ exports.request = function request(options, cb) { if (!options.hostname) { throw new Error('Unable to determine the domain name'); } + } else if (options instanceof url.URL) { + options = urlToOptions(options); } else { options = util._extend({}, options); } diff --git a/lib/internal/bootstrap_node.js b/lib/internal/bootstrap_node.js index 4e1e2aa9018b5a..71a6c529041b47 100644 --- a/lib/internal/bootstrap_node.js +++ b/lib/internal/bootstrap_node.js @@ -393,9 +393,7 @@ } function isDebugBreak() { - return process.execArgv.some((arg) => { - return arg.match(/^--debug-brk(=[0-9]*)?$/); - }); + return process.execArgv.some((arg) => /^--debug-brk(=[0-9]+)?$/.test(arg)); } function run(entryFunction) { diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index 5bdc53fd192073..3017cd5889a037 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -446,14 +446,20 @@ function setupChannel(target, channel) { channel.onread = function(nread, pool, recvHandle) { // TODO(bnoordhuis) Check that nread > 0. if (pool) { - jsonBuffer += decoder.write(pool); - - var i, start = 0; + // Linebreak is used as a message end sign + var chunks = decoder.write(pool).split('\n'); + var numCompleteChunks = chunks.length - 1; + // Last line does not have trailing linebreak + var incompleteChunk = chunks[numCompleteChunks]; + if (numCompleteChunks === 0) { + jsonBuffer += incompleteChunk; + this.buffering = jsonBuffer.length !== 0; + return; + } + chunks[0] = jsonBuffer + chunks[0]; - //Linebreak is used as a message end sign - while ((i = jsonBuffer.indexOf('\n', start)) >= 0) { - var json = jsonBuffer.slice(start, i); - var message = JSON.parse(json); + for (var i = 0; i < numCompleteChunks; i++) { + var message = JSON.parse(chunks[i]); // There will be at most one NODE_HANDLE message in every chunk we // read because SCM_RIGHTS messages don't get coalesced. Make sure @@ -462,10 +468,8 @@ function setupChannel(target, channel) { handleMessage(target, message, recvHandle); else handleMessage(target, message, undefined); - - start = i + 1; } - jsonBuffer = jsonBuffer.slice(start); + jsonBuffer = incompleteChunk; this.buffering = jsonBuffer.length !== 0; } else { @@ -494,9 +498,10 @@ function setupChannel(target, channel) { var queue = target._handleQueue; target._handleQueue = null; - queue.forEach(function(args) { + for (var i = 0; i < queue.length; i++) { + var args = queue[i]; target._send(args.message, args.handle, args.options, args.callback); - }); + } // Process a pending disconnect (if any). if (!target.connected && target.channel && !target._handleQueue) diff --git a/lib/internal/cluster.js b/lib/internal/cluster.js deleted file mode 100644 index 8380ea7482c670..00000000000000 --- a/lib/internal/cluster.js +++ /dev/null @@ -1,4 +0,0 @@ -'use strict'; - -// Used in tests. -exports.handles = {}; diff --git a/lib/internal/cluster/child.js b/lib/internal/cluster/child.js new file mode 100644 index 00000000000000..3275eec720c738 --- /dev/null +++ b/lib/internal/cluster/child.js @@ -0,0 +1,224 @@ +'use strict'; +const assert = require('assert'); +const util = require('util'); +const EventEmitter = require('events'); +const Worker = require('internal/cluster/worker'); +const { internal, sendHelper } = require('internal/cluster/utils'); +const cluster = new EventEmitter(); +const handles = {}; +const indexes = {}; +const noop = () => {}; + +module.exports = cluster; + +cluster.isWorker = true; +cluster.isMaster = false; +cluster.worker = null; +cluster.Worker = Worker; + +cluster._setupWorker = function() { + const worker = new Worker({ + id: +process.env.NODE_UNIQUE_ID | 0, + process: process, + state: 'online' + }); + + cluster.worker = worker; + + process.once('disconnect', () => { + worker.emit('disconnect'); + + if (!worker.exitedAfterDisconnect) { + // Unexpected disconnect, master exited, or some such nastiness, so + // worker exits immediately. + process.exit(0); + } + }); + + process.on('internalMessage', internal(worker, onmessage)); + send({ act: 'online' }); + + function onmessage(message, handle) { + if (message.act === 'newconn') + onconnection(message, handle); + else if (message.act === 'disconnect') + _disconnect.call(worker, true); + } +}; + +// obj is a net#Server or a dgram#Socket object. +cluster._getServer = function(obj, options, cb) { + const indexesKey = [options.address, + options.port, + options.addressType, + options.fd ].join(':'); + + if (indexes[indexesKey] === undefined) + indexes[indexesKey] = 0; + else + indexes[indexesKey]++; + + const message = util._extend({ + act: 'queryServer', + index: indexes[indexesKey], + data: null + }, options); + + // Set custom data on handle (i.e. tls tickets key) + if (obj._getServerData) + message.data = obj._getServerData(); + + send(message, (reply, handle) => { + if (typeof obj._setServerData === 'function') + obj._setServerData(reply.data); + + if (handle) + shared(reply, handle, indexesKey, cb); // Shared listen socket. + else + rr(reply, indexesKey, cb); // Round-robin. + }); + + obj.once('listening', () => { + cluster.worker.state = 'listening'; + const address = obj.address(); + message.act = 'listening'; + message.port = address && address.port || options.port; + send(message); + }); +}; + +// Shared listen socket. +function shared(message, handle, indexesKey, cb) { + const key = message.key; + // Monkey-patch the close() method so we can keep track of when it's + // closed. Avoids resource leaks when the handle is short-lived. + const close = handle.close; + + handle.close = function() { + send({ act: 'close', key }); + delete handles[key]; + delete indexes[indexesKey]; + return close.apply(this, arguments); + }; + assert(handles[key] === undefined); + handles[key] = handle; + cb(message.errno, handle); +} + +// Round-robin. Master distributes handles across workers. +function rr(message, indexesKey, cb) { + if (message.errno) + return cb(message.errno, null); + + var key = message.key; + + function listen(backlog) { + // TODO(bnoordhuis) Send a message to the master that tells it to + // update the backlog size. The actual backlog should probably be + // the largest requested size by any worker. + return 0; + } + + function close() { + // lib/net.js treats server._handle.close() as effectively synchronous. + // That means there is a time window between the call to close() and + // the ack by the master process in which we can still receive handles. + // onconnection() below handles that by sending those handles back to + // the master. + if (key === undefined) + return; + + send({ act: 'close', key }); + delete handles[key]; + delete indexes[indexesKey]; + key = undefined; + } + + function getsockname(out) { + if (key) + util._extend(out, message.sockname); + + return 0; + } + + // Faux handle. Mimics a TCPWrap with just enough fidelity to get away + // with it. Fools net.Server into thinking that it's backed by a real + // handle. Use a noop function for ref() and unref() because the control + // channel is going to keep the worker alive anyway. + const handle = { close, listen, ref: noop, unref: noop }; + + if (message.sockname) { + handle.getsockname = getsockname; // TCP handles only. + } + + assert(handles[key] === undefined); + handles[key] = handle; + cb(0, handle); +} + +// Round-robin connection. +function onconnection(message, handle) { + const key = message.key; + const server = handles[key]; + const accepted = server !== undefined; + + send({ ack: message.seq, accepted }); + + if (accepted) + server.onconnection(0, handle); +} + +function send(message, cb) { + return sendHelper(process, message, null, cb); +} + +function _disconnect(masterInitiated) { + this.exitedAfterDisconnect = true; + let waitingCount = 1; + + function checkWaitingCount() { + waitingCount--; + + if (waitingCount === 0) { + // If disconnect is worker initiated, wait for ack to be sure + // exitedAfterDisconnect is properly set in the master, otherwise, if + // it's master initiated there's no need to send the + // exitedAfterDisconnect message + if (masterInitiated) { + process.disconnect(); + } else { + send({ act: 'exitedAfterDisconnect' }, () => process.disconnect()); + } + } + } + + for (const key in handles) { + const handle = handles[key]; + delete handles[key]; + waitingCount++; + + if (handle.owner) + handle.owner.close(checkWaitingCount); + else + handle.close(checkWaitingCount); + } + + checkWaitingCount(); +} + +// Extend generic Worker with methods specific to worker processes. +Worker.prototype.disconnect = function() { + _disconnect.call(this); + return this; +}; + +Worker.prototype.destroy = function() { + this.exitedAfterDisconnect = true; + + if (!this.isConnected()) { + process.exit(0); + } else { + send({ act: 'exitedAfterDisconnect' }, () => process.disconnect()); + process.once('disconnect', () => process.exit(0)); + } +}; diff --git a/lib/internal/cluster/master.js b/lib/internal/cluster/master.js new file mode 100644 index 00000000000000..9d5062f5427ffa --- /dev/null +++ b/lib/internal/cluster/master.js @@ -0,0 +1,367 @@ +'use strict'; +const assert = require('assert'); +const fork = require('child_process').fork; +const util = require('util'); +const EventEmitter = require('events'); +const RoundRobinHandle = require('internal/cluster/round_robin_handle'); +const SharedHandle = require('internal/cluster/shared_handle'); +const Worker = require('internal/cluster/worker'); +const { internal, sendHelper, handles } = require('internal/cluster/utils'); +const keys = Object.keys; +const cluster = new EventEmitter(); +const intercom = new EventEmitter(); +const SCHED_NONE = 1; +const SCHED_RR = 2; + +module.exports = cluster; + +cluster.isWorker = false; +cluster.isMaster = true; +cluster.Worker = Worker; +cluster.workers = {}; +cluster.settings = {}; +cluster.SCHED_NONE = SCHED_NONE; // Leave it to the operating system. +cluster.SCHED_RR = SCHED_RR; // Master distributes connections. + +var ids = 0; +var debugPortOffset = 1; +var initialized = false; + +// XXX(bnoordhuis) Fold cluster.schedulingPolicy into cluster.settings? +var schedulingPolicy = { + 'none': SCHED_NONE, + 'rr': SCHED_RR +}[process.env.NODE_CLUSTER_SCHED_POLICY]; + +if (schedulingPolicy === undefined) { + // FIXME Round-robin doesn't perform well on Windows right now due to the + // way IOCP is wired up. + schedulingPolicy = (process.platform === 'win32') ? SCHED_NONE : SCHED_RR; +} + +cluster.schedulingPolicy = schedulingPolicy; + +cluster.setupMaster = function(options) { + var settings = { + args: process.argv.slice(2), + exec: process.argv[1], + execArgv: process.execArgv, + silent: false + }; + settings = util._extend(settings, cluster.settings); + settings = util._extend(settings, options || {}); + + // Tell V8 to write profile data for each process to a separate file. + // Without --logfile=v8-%p.log, everything ends up in a single, unusable + // file. (Unusable because what V8 logs are memory addresses and each + // process has its own memory mappings.) + if (settings.execArgv.some((s) => s.startsWith('--prof')) && + !settings.execArgv.some((s) => s.startsWith('--logfile='))) { + settings.execArgv = settings.execArgv.concat(['--logfile=v8-%p.log']); + } + + cluster.settings = settings; + + if (initialized === true) + return process.nextTick(setupSettingsNT, settings); + + initialized = true; + schedulingPolicy = cluster.schedulingPolicy; // Freeze policy. + assert(schedulingPolicy === SCHED_NONE || schedulingPolicy === SCHED_RR, + `Bad cluster.schedulingPolicy: ${schedulingPolicy}`); + + const hasDebugArg = process.execArgv.some((argv) => { + return /^(--debug|--debug-brk)(=\d+)?$/.test(argv); + }); + + process.nextTick(setupSettingsNT, settings); + + // Send debug signal only if not started in debug mode, this helps a lot + // on windows, because RegisterDebugHandler is not called when node starts + // with --debug.* arg. + if (hasDebugArg) + return; + + process.on('internalMessage', (message) => { + if (message.cmd !== 'NODE_DEBUG_ENABLED') + return; + + var key; + for (key in cluster.workers) { + const worker = cluster.workers[key]; + + if (worker.state === 'online' || worker.state === 'listening') { + process._debugProcess(worker.process.pid); + } else { + worker.once('online', function() { + process._debugProcess(this.process.pid); + }); + } + } + }); +}; + +function setupSettingsNT(settings) { + cluster.emit('setup', settings); +} + +function createWorkerProcess(id, env) { + var workerEnv = util._extend({}, process.env); + var execArgv = cluster.settings.execArgv.slice(); + var debugPort = 0; + + workerEnv = util._extend(workerEnv, env); + workerEnv.NODE_UNIQUE_ID = '' + id; + + for (var i = 0; i < execArgv.length; i++) { + const match = execArgv[i].match( + /^(--inspect|--debug|--debug-(brk|port))(=\d+)?$/ + ); + + if (match) { + if (debugPort === 0) { + debugPort = process.debugPort + debugPortOffset; + ++debugPortOffset; + } + + execArgv[i] = match[1] + '=' + debugPort; + } + } + + return fork(cluster.settings.exec, cluster.settings.args, { + env: workerEnv, + silent: cluster.settings.silent, + execArgv: execArgv, + stdio: cluster.settings.stdio, + gid: cluster.settings.gid, + uid: cluster.settings.uid + }); +} + +function removeWorker(worker) { + assert(worker); + delete cluster.workers[worker.id]; + + if (keys(cluster.workers).length === 0) { + assert(keys(handles).length === 0, 'Resource leak detected.'); + intercom.emit('disconnect'); + } +} + +function removeHandlesForWorker(worker) { + assert(worker); + + for (var key in handles) { + const handle = handles[key]; + + if (handle.remove(worker)) + delete handles[key]; + } +} + +cluster.fork = function(env) { + cluster.setupMaster(); + const id = ++ids; + const workerProcess = createWorkerProcess(id, env); + const worker = new Worker({ + id: id, + process: workerProcess + }); + + worker.on('message', function(message, handle) { + cluster.emit('message', this, message, handle); + }); + + worker.process.once('exit', (exitCode, signalCode) => { + /* + * Remove the worker from the workers list only + * if it has disconnected, otherwise we might + * still want to access it. + */ + if (!worker.isConnected()) { + removeHandlesForWorker(worker); + removeWorker(worker); + } + + worker.exitedAfterDisconnect = !!worker.exitedAfterDisconnect; + worker.state = 'dead'; + worker.emit('exit', exitCode, signalCode); + cluster.emit('exit', worker, exitCode, signalCode); + }); + + worker.process.once('disconnect', () => { + /* + * Now is a good time to remove the handles + * associated with this worker because it is + * not connected to the master anymore. + */ + removeHandlesForWorker(worker); + + /* + * Remove the worker from the workers list only + * if its process has exited. Otherwise, we might + * still want to access it. + */ + if (worker.isDead()) + removeWorker(worker); + + worker.exitedAfterDisconnect = !!worker.exitedAfterDisconnect; + worker.state = 'disconnected'; + worker.emit('disconnect'); + cluster.emit('disconnect', worker); + }); + + worker.process.on('internalMessage', internal(worker, onmessage)); + process.nextTick(emitForkNT, worker); + cluster.workers[worker.id] = worker; + return worker; +}; + +function emitForkNT(worker) { + cluster.emit('fork', worker); +} + +cluster.disconnect = function(cb) { + const workers = keys(cluster.workers); + + if (workers.length === 0) { + process.nextTick(() => intercom.emit('disconnect')); + } else { + for (var key in workers) { + key = workers[key]; + + if (cluster.workers[key].isConnected()) + cluster.workers[key].disconnect(); + } + } + + if (typeof cb === 'function') + intercom.once('disconnect', cb); +}; + +function onmessage(message, handle) { + const worker = this; + + if (message.act === 'online') + online(worker); + else if (message.act === 'queryServer') + queryServer(worker, message); + else if (message.act === 'listening') + listening(worker, message); + else if (message.act === 'exitedAfterDisconnect') + exitedAfterDisconnect(worker, message); + else if (message.act === 'close') + close(worker, message); +} + +function online(worker) { + worker.state = 'online'; + worker.emit('online'); + cluster.emit('online', worker); +} + +function exitedAfterDisconnect(worker, message) { + worker.exitedAfterDisconnect = true; + send(worker, { ack: message.seq }); +} + +function queryServer(worker, message) { + // Stop processing if worker already disconnecting + if (worker.exitedAfterDisconnect) + return; + + const args = [message.address, + message.port, + message.addressType, + message.fd, + message.index]; + const key = args.join(':'); + var handle = handles[key]; + + if (handle === undefined) { + var constructor = RoundRobinHandle; + // UDP is exempt from round-robin connection balancing for what should + // be obvious reasons: it's connectionless. There is nothing to send to + // the workers except raw datagrams and that's pointless. + if (schedulingPolicy !== SCHED_RR || + message.addressType === 'udp4' || + message.addressType === 'udp6') { + constructor = SharedHandle; + } + + handles[key] = handle = new constructor(key, + message.address, + message.port, + message.addressType, + message.fd, + message.flags); + } + + if (!handle.data) + handle.data = message.data; + + // Set custom server data + handle.add(worker, (errno, reply, handle) => { + reply = util._extend({ + errno: errno, + key: key, + ack: message.seq, + data: handles[key].data + }, reply); + + if (errno) + delete handles[key]; // Gives other workers a chance to retry. + + send(worker, reply, handle); + }); +} + +function listening(worker, message) { + const info = { + addressType: message.addressType, + address: message.address, + port: message.port, + fd: message.fd + }; + + worker.state = 'listening'; + worker.emit('listening', info); + cluster.emit('listening', worker, info); +} + +// Server in worker is closing, remove from list. The handle may have been +// removed by a prior call to removeHandlesForWorker() so guard against that. +function close(worker, message) { + const key = message.key; + const handle = handles[key]; + + if (handle && handle.remove(worker)) + delete handles[key]; +} + +function send(worker, message, handle, cb) { + return sendHelper(worker.process, message, handle, cb); +} + +// Extend generic Worker with methods specific to the master process. +Worker.prototype.disconnect = function() { + this.exitedAfterDisconnect = true; + send(this, { act: 'disconnect' }); + removeHandlesForWorker(this); + removeWorker(this); + return this; +}; + +Worker.prototype.destroy = function(signo) { + const proc = this.process; + + signo = signo || 'SIGTERM'; + + if (this.isConnected()) { + this.once('disconnect', () => proc.kill(signo)); + this.disconnect(); + return; + } + + proc.kill(signo); +}; diff --git a/lib/internal/cluster/round_robin_handle.js b/lib/internal/cluster/round_robin_handle.js new file mode 100644 index 00000000000000..5dbc205426b1db --- /dev/null +++ b/lib/internal/cluster/round_robin_handle.js @@ -0,0 +1,115 @@ +'use strict'; +const assert = require('assert'); +const net = require('net'); +const { sendHelper } = require('internal/cluster/utils'); +const getOwnPropertyNames = Object.getOwnPropertyNames; +const uv = process.binding('uv'); + +module.exports = RoundRobinHandle; + +function RoundRobinHandle(key, address, port, addressType, fd) { + this.key = key; + this.all = {}; + this.free = []; + this.handles = []; + this.handle = null; + this.server = net.createServer(assert.fail); + + if (fd >= 0) + this.server.listen({ fd }); + else if (port >= 0) + this.server.listen(port, address); + else + this.server.listen(address); // UNIX socket path. + + this.server.once('listening', () => { + this.handle = this.server._handle; + this.handle.onconnection = (err, handle) => this.distribute(err, handle); + this.server._handle = null; + this.server = null; + }); +} + +RoundRobinHandle.prototype.add = function(worker, send) { + assert(worker.id in this.all === false); + this.all[worker.id] = worker; + + const done = () => { + if (this.handle.getsockname) { + const out = {}; + this.handle.getsockname(out); + // TODO(bnoordhuis) Check err. + send(null, { sockname: out }, null); + } else { + send(null, null, null); // UNIX socket. + } + + this.handoff(worker); // In case there are connections pending. + }; + + if (this.server === null) + return done(); + + // Still busy binding. + this.server.once('listening', done); + this.server.once('error', (err) => { + // Hack: translate 'EADDRINUSE' error string back to numeric error code. + // It works but ideally we'd have some backchannel between the net and + // cluster modules for stuff like this. + const errno = uv['UV_' + err.errno]; + send(errno, null); + }); +}; + +RoundRobinHandle.prototype.remove = function(worker) { + if (worker.id in this.all === false) + return false; + + delete this.all[worker.id]; + const index = this.free.indexOf(worker); + + if (index !== -1) + this.free.splice(index, 1); + + if (getOwnPropertyNames(this.all).length !== 0) + return false; + + for (var handle; handle = this.handles.shift(); handle.close()) + ; + + this.handle.close(); + this.handle = null; + return true; +}; + +RoundRobinHandle.prototype.distribute = function(err, handle) { + this.handles.push(handle); + const worker = this.free.shift(); + + if (worker) + this.handoff(worker); +}; + +RoundRobinHandle.prototype.handoff = function(worker) { + if (worker.id in this.all === false) { + return; // Worker is closing (or has closed) the server. + } + + const handle = this.handles.shift(); + + if (handle === undefined) { + this.free.push(worker); // Add to ready queue again. + return; + } + + const message = { act: 'newconn', key: this.key }; + + sendHelper(worker.process, message, handle, (reply) => { + if (reply.accepted) + handle.close(); + else + this.distribute(0, handle); // Worker is shutting down. Send to another. + + this.handoff(worker); + }); +}; diff --git a/lib/internal/cluster/shared_handle.js b/lib/internal/cluster/shared_handle.js new file mode 100644 index 00000000000000..c0663772426213 --- /dev/null +++ b/lib/internal/cluster/shared_handle.js @@ -0,0 +1,48 @@ +'use strict'; +const assert = require('assert'); +const dgram = require('dgram'); +const net = require('net'); + +module.exports = SharedHandle; + +function SharedHandle(key, address, port, addressType, fd, flags) { + this.key = key; + this.workers = []; + this.handle = null; + this.errno = 0; + + // FIXME(bnoordhuis) Polymorphic return type for lack of a better solution. + var rval; + + if (addressType === 'udp4' || addressType === 'udp6') + rval = dgram._createSocketHandle(address, port, addressType, fd, flags); + else + rval = net._createServerHandle(address, port, addressType, fd); + + if (typeof rval === 'number') + this.errno = rval; + else + this.handle = rval; +} + +SharedHandle.prototype.add = function(worker, send) { + assert(this.workers.indexOf(worker) === -1); + this.workers.push(worker); + send(this.errno, null, this.handle); +}; + +SharedHandle.prototype.remove = function(worker) { + const index = this.workers.indexOf(worker); + + if (index === -1) + return false; // The worker wasn't sharing this handle. + + this.workers.splice(index, 1); + + if (this.workers.length !== 0) + return false; + + this.handle.close(); + this.handle = null; + return true; +}; diff --git a/lib/internal/cluster/utils.js b/lib/internal/cluster/utils.js new file mode 100644 index 00000000000000..ba72ff90945d3c --- /dev/null +++ b/lib/internal/cluster/utils.js @@ -0,0 +1,44 @@ +'use strict'; +const util = require('util'); + +module.exports = { + sendHelper, + internal, + handles: {} // Used in tests. +}; + +const callbacks = {}; +var seq = 0; + +function sendHelper(proc, message, handle, cb) { + if (!proc.connected) + return false; + + // Mark message as internal. See INTERNAL_PREFIX in lib/child_process.js + message = util._extend({ cmd: 'NODE_CLUSTER' }, message); + + if (typeof cb === 'function') + callbacks[seq] = cb; + + message.seq = seq; + seq += 1; + return proc.send(message, handle); +} + +// Returns an internalMessage listener that hands off normal messages +// to the callback but intercepts and redirects ACK messages. +function internal(worker, cb) { + return function onInternalMessage(message, handle) { + if (message.cmd !== 'NODE_CLUSTER') + return; + + var fn = cb; + + if (message.ack !== undefined && callbacks[message.ack] !== undefined) { + fn = callbacks[message.ack]; + delete callbacks[message.ack]; + } + + fn.apply(worker, arguments); + }; +} diff --git a/lib/internal/cluster/worker.js b/lib/internal/cluster/worker.js new file mode 100644 index 00000000000000..fd46ed571076d5 --- /dev/null +++ b/lib/internal/cluster/worker.js @@ -0,0 +1,63 @@ +'use strict'; +const EventEmitter = require('events'); +const internalUtil = require('internal/util'); +const util = require('util'); +const defineProperty = Object.defineProperty; +const suicideDeprecationMessage = + 'worker.suicide is deprecated. Please use worker.exitedAfterDisconnect.'; + +module.exports = Worker; + +// Common Worker implementation shared between the cluster master and workers. +function Worker(options) { + if (!(this instanceof Worker)) + return new Worker(options); + + EventEmitter.call(this); + + if (options === null || typeof options !== 'object') + options = {}; + + this.exitedAfterDisconnect = undefined; + + defineProperty(this, 'suicide', { + get: internalUtil.deprecate( + () => this.exitedAfterDisconnect, + suicideDeprecationMessage), + set: internalUtil.deprecate( + (val) => { this.exitedAfterDisconnect = val; }, + suicideDeprecationMessage), + enumerable: true + }); + + this.state = options.state || 'none'; + this.id = options.id | 0; + + if (options.process) { + this.process = options.process; + this.process.on('error', (code, signal) => + this.emit('error', code, signal) + ); + this.process.on('message', (message, handle) => + this.emit('message', message, handle) + ); + } +} + +util.inherits(Worker, EventEmitter); + +Worker.prototype.kill = function() { + this.destroy.apply(this, arguments); +}; + +Worker.prototype.send = function() { + return this.process.send.apply(this.process, arguments); +}; + +Worker.prototype.isDead = function() { + return this.process.exitCode != null || this.process.signalCode != null; +}; + +Worker.prototype.isConnected = function() { + return this.process.connected; +}; diff --git a/lib/internal/module.js b/lib/internal/module.js index a12af12f3e3d7e..2f38618daac5f7 100644 --- a/lib/internal/module.js +++ b/lib/internal/module.js @@ -51,10 +51,12 @@ function stripBOM(content) { return content; } -exports.builtinLibs = ['assert', 'buffer', 'child_process', 'cluster', - 'crypto', 'dgram', 'dns', 'domain', 'events', 'fs', 'http', 'https', 'net', - 'os', 'path', 'punycode', 'querystring', 'readline', 'repl', 'stream', - 'string_decoder', 'tls', 'tty', 'url', 'util', 'v8', 'vm', 'zlib']; +exports.builtinLibs = [ + 'assert', 'buffer', 'child_process', 'cluster', 'crypto', 'dgram', 'dns', + 'domain', 'events', 'fs', 'http', 'https', 'net', 'os', 'path', 'punycode', + 'querystring', 'readline', 'repl', 'stream', 'string_decoder', 'tls', 'tty', + 'url', 'util', 'v8', 'vm', 'zlib' +]; function addBuiltinLibsToObject(object) { // Make built-in modules available directly (loaded lazily). diff --git a/lib/internal/process/warning.js b/lib/internal/process/warning.js index 74a74aa916dd91..f98f7f69ddae23 100644 --- a/lib/internal/process/warning.js +++ b/lib/internal/process/warning.js @@ -5,7 +5,7 @@ const prefix = `(${process.release.name}:${process.pid}) `; exports.setup = setupProcessWarnings; function setupProcessWarnings() { - if (!process.noProcessWarnings) { + if (!process.noProcessWarnings && process.env.NODE_NO_WARNINGS !== '1') { process.on('warning', (warning) => { if (!(warning instanceof Error)) return; const isDeprecation = warning.name === 'DeprecationWarning'; diff --git a/lib/internal/url.js b/lib/internal/url.js index e1e1c515f842d2..113746a24d5edc 100644 --- a/lib/internal/url.js +++ b/lib/internal/url.js @@ -8,6 +8,7 @@ function getPunycode() { } } const punycode = getPunycode(); +const util = require('util'); const binding = process.binding('url'); const context = Symbol('context'); const cannotBeBase = Symbol('cannot-be-base'); @@ -66,7 +67,8 @@ class TupleOrigin { return this[kDomain] || this[kHost]; } - toString(unicode = false) { + // https://url.spec.whatwg.org/#dom-url-origin + toString(unicode = true) { var result = this[kScheme]; result += '://'; result += unicode ? domainToUnicode(this[kHost]) : this[kHost]; @@ -75,7 +77,7 @@ class TupleOrigin { return result; } - inspect() { + [util.inspect.custom]() { return `TupleOrigin { scheme: ${this[kScheme]}, host: ${this[kHost]}, @@ -221,10 +223,6 @@ class URL { parse(this, input, base); } - get [Symbol.toStringTag]() { - return this instanceof URL ? 'URL' : 'URLPrototype'; - } - get [special]() { return (this[context].flags & binding.URL_FLAGS_SPECIAL) !== 0; } @@ -233,7 +231,7 @@ class URL { return (this[context].flags & binding.URL_FLAGS_CANNOT_BE_BASE) !== 0; } - inspect(depth, opts) { + [util.inspect.custom](depth, opts) { const ctx = this[context]; var ret = 'URL {\n'; ret += ` href: ${this.href}\n`; @@ -284,7 +282,8 @@ Object.defineProperties(URL.prototype, { if (ctx.host !== undefined) { ret += '//'; const has_username = typeof ctx.username === 'string'; - const has_password = typeof ctx.password === 'string'; + const has_password = typeof ctx.password === 'string' && + ctx.password !== ''; if (has_username || has_password) { if (has_username) ret += ctx.username; @@ -311,6 +310,10 @@ Object.defineProperties(URL.prototype, { return ret; } }, + [Symbol.toStringTag]: { + configurable: true, + value: 'URL' + }, href: { enumerable: true, configurable: true, @@ -325,7 +328,7 @@ Object.defineProperties(URL.prototype, { enumerable: true, configurable: true, get() { - return originFor(this).toString(true); + return originFor(this).toString(); } }, protocol: { @@ -491,7 +494,7 @@ Object.defineProperties(URL.prototype, { ctx.query = ''; binding.parse(search, binding.kQuery, null, ctx, onParseSearchComplete.bind(this)); - this[searchParams][searchParams] = querystring.parse(search); + initSearchParams(this[searchParams], search); } }, searchParams: { // readonly @@ -608,8 +611,13 @@ function update(url, params) { } } -function getSearchParamPairs(target) { - const obj = target[searchParams]; +// Reused by the URL parse function invoked by +// the href setter, and the URLSearchParams constructor +function initSearchParams(url, init) { + url[searchParams] = getParamsFromObject(querystring.parse(init)); +} + +function getParamsFromObject(obj) { const keys = Object.keys(obj); const values = []; for (var i = 0; i < keys.length; i++) { @@ -617,25 +625,62 @@ function getSearchParamPairs(target) { const value = obj[name]; if (Array.isArray(value)) { for (const item of value) - values.push([name, item]); + values.push(name, item); } else { - values.push([name, value]); + values.push(name, value); } } return values; } -// Reused by the URL parse function invoked by -// the href setter, and the URLSearchParams constructor -function initSearchParams(url, init) { - url[searchParams] = querystring.parse(init); +function getObjectFromParams(array) { + const obj = new StorageObject(); + for (var i = 0; i < array.length; i += 2) { + const name = array[i]; + const value = array[i + 1]; + if (obj[name]) { + obj[name].push(value); + } else { + obj[name] = [value]; + } + } + return obj; +} + +// Mainly to mitigate func-name-matching ESLint rule +function defineIDLClass(proto, classStr, obj) { + // https://heycam.github.io/webidl/#dfn-class-string + Object.defineProperty(proto, Symbol.toStringTag, { + writable: false, + enumerable: false, + configurable: true, + value: classStr + }); + + // https://heycam.github.io/webidl/#es-operations + for (const key of Object.keys(obj)) { + Object.defineProperty(proto, key, { + writable: true, + enumerable: true, + configurable: true, + value: obj[key] + }); + } + for (const key of Object.getOwnPropertySymbols(obj)) { + Object.defineProperty(proto, key, { + writable: true, + enumerable: false, + configurable: true, + value: obj[key] + }); + } } class URLSearchParams { constructor(init = '') { if (init instanceof URLSearchParams) { const childParams = init[searchParams]; - this[searchParams] = Object.assign(Object.create(null), childParams); + this[searchParams] = childParams.slice(); } else { init = String(init); if (init[0] === '?') init = init.slice(1); @@ -646,104 +691,168 @@ class URLSearchParams { this[context] = null; } - get [Symbol.toStringTag]() { - return this instanceof URLSearchParams ? - 'URLSearchParams' : 'URLSearchParamsPrototype'; + [util.inspect.custom](recurseTimes, ctx) { + if (!this || !(this instanceof URLSearchParams)) { + throw new TypeError('Value of `this` is not a URLSearchParams'); + } + + const separator = ', '; + const innerOpts = Object.assign({}, ctx); + if (recurseTimes !== null) { + innerOpts.depth = recurseTimes - 1; + } + const innerInspect = (v) => util.inspect(v, innerOpts); + + const list = this[searchParams]; + const output = []; + for (var i = 0; i < list.length; i += 2) + output.push(`${innerInspect(list[i])} => ${innerInspect(list[i + 1])}`); + + const colorRe = /\u001b\[\d\d?m/g; + const length = output.reduce( + (prev, cur) => prev + cur.replace(colorRe, '').length + separator.length, + -separator.length + ); + if (length > ctx.breakLength) { + return `${this.constructor.name} {\n ${output.join(',\n ')} }`; + } else if (output.length) { + return `${this.constructor.name} { ${output.join(separator)} }`; + } else { + return `${this.constructor.name} {}`; + } } +} +defineIDLClass(URLSearchParams.prototype, 'URLSearchParams', { append(name, value) { if (!this || !(this instanceof URLSearchParams)) { throw new TypeError('Value of `this` is not a URLSearchParams'); } if (arguments.length < 2) { - throw new TypeError( - 'Both `name` and `value` arguments need to be specified'); + throw new TypeError('"name" and "value" arguments must be specified'); } - const obj = this[searchParams]; name = String(name); value = String(value); - var existing = obj[name]; - if (existing === undefined) { - obj[name] = value; - } else if (Array.isArray(existing)) { - existing.push(value); - } else { - obj[name] = [existing, value]; - } + this[searchParams].push(name, value); update(this[context], this); - } + }, delete(name) { if (!this || !(this instanceof URLSearchParams)) { throw new TypeError('Value of `this` is not a URLSearchParams'); } if (arguments.length < 1) { - throw new TypeError('The `name` argument needs to be specified'); + throw new TypeError('"name" argument must be specified'); } - const obj = this[searchParams]; + const list = this[searchParams]; name = String(name); - delete obj[name]; + for (var i = 0; i < list.length;) { + const cur = list[i]; + if (cur === name) { + list.splice(i, 2); + } else { + i += 2; + } + } update(this[context], this); - } + }, - set(name, value) { + get(name) { if (!this || !(this instanceof URLSearchParams)) { throw new TypeError('Value of `this` is not a URLSearchParams'); } - if (arguments.length < 2) { - throw new TypeError( - 'Both `name` and `value` arguments need to be specified'); + if (arguments.length < 1) { + throw new TypeError('"name" argument must be specified'); } - const obj = this[searchParams]; + const list = this[searchParams]; name = String(name); - value = String(value); - obj[name] = value; - update(this[context], this); - } + for (var i = 0; i < list.length; i += 2) { + if (list[i] === name) { + return list[i + 1]; + } + } + return null; + }, - get(name) { + getAll(name) { if (!this || !(this instanceof URLSearchParams)) { throw new TypeError('Value of `this` is not a URLSearchParams'); } if (arguments.length < 1) { - throw new TypeError('The `name` argument needs to be specified'); + throw new TypeError('"name" argument must be specified'); } - const obj = this[searchParams]; + const list = this[searchParams]; + const values = []; name = String(name); - var value = obj[name]; - return value === undefined ? null : Array.isArray(value) ? value[0] : value; - } + for (var i = 0; i < list.length; i += 2) { + if (list[i] === name) { + values.push(list[i + 1]); + } + } + return values; + }, - getAll(name) { + has(name) { if (!this || !(this instanceof URLSearchParams)) { throw new TypeError('Value of `this` is not a URLSearchParams'); } if (arguments.length < 1) { - throw new TypeError('The `name` argument needs to be specified'); + throw new TypeError('"name" argument must be specified'); } - const obj = this[searchParams]; + const list = this[searchParams]; name = String(name); - var value = obj[name]; - return value === undefined ? [] : Array.isArray(value) ? value : [value]; - } + for (var i = 0; i < list.length; i += 2) { + if (list[i] === name) { + return true; + } + } + return false; + }, - has(name) { + set(name, value) { if (!this || !(this instanceof URLSearchParams)) { throw new TypeError('Value of `this` is not a URLSearchParams'); } - if (arguments.length < 1) { - throw new TypeError('The `name` argument needs to be specified'); + if (arguments.length < 2) { + throw new TypeError('"name" and "value" arguments must be specified'); } - const obj = this[searchParams]; + const list = this[searchParams]; name = String(name); - return name in obj; - } + value = String(value); + + // If there are any name-value pairs whose name is `name`, in `list`, set + // the value of the first such name-value pair to `value` and remove the + // others. + var found = false; + for (var i = 0; i < list.length;) { + const cur = list[i]; + if (cur === name) { + if (!found) { + list[i + 1] = value; + found = true; + i += 2; + } else { + list.splice(i, 2); + } + } else { + i += 2; + } + } + + // Otherwise, append a new name-value pair whose name is `name` and value + // is `value`, to `list`. + if (!found) { + list.push(name, value); + } + + update(this[context], this); + }, // https://heycam.github.io/webidl/#es-iterators // Define entries here rather than [Symbol.iterator] as the function name @@ -754,26 +863,28 @@ class URLSearchParams { } return createSearchParamsIterator(this, 'key+value'); - } + }, forEach(callback, thisArg = undefined) { if (!this || !(this instanceof URLSearchParams)) { throw new TypeError('Value of `this` is not a URLSearchParams'); } - if (arguments.length < 1) { - throw new TypeError('The `callback` argument needs to be specified'); + if (typeof callback !== 'function') { + throw new TypeError('"callback" argument must be a function'); } - let pairs = getSearchParamPairs(this); + let list = this[searchParams]; var i = 0; - while (i < pairs.length) { - const [key, value] = pairs[i]; + while (i < list.length) { + const key = list[i]; + const value = list[i + 1]; callback.call(thisArg, value, key, this); - pairs = getSearchParamPairs(this); - i++; + // in case the URL object's `search` is updated + list = this[searchParams]; + i += 2; } - } + }, // https://heycam.github.io/webidl/#es-iterable keys() { @@ -782,7 +893,7 @@ class URLSearchParams { } return createSearchParamsIterator(this, 'key'); - } + }, values() { if (!this || !(this instanceof URLSearchParams)) { @@ -790,19 +901,25 @@ class URLSearchParams { } return createSearchParamsIterator(this, 'value'); - } + }, + // https://heycam.github.io/webidl/#es-stringifier // https://url.spec.whatwg.org/#urlsearchparams-stringification-behavior toString() { if (!this || !(this instanceof URLSearchParams)) { throw new TypeError('Value of `this` is not a URLSearchParams'); } - return querystring.stringify(this[searchParams]); + return querystring.stringify(getObjectFromParams(this[searchParams])); } -} +}); + // https://heycam.github.io/webidl/#es-iterable-entries -URLSearchParams.prototype[Symbol.iterator] = URLSearchParams.prototype.entries; +Object.defineProperty(URLSearchParams.prototype, Symbol.iterator, { + writable: true, + configurable: true, + value: URLSearchParams.prototype.entries +}); // https://heycam.github.io/webidl/#dfn-default-iterator-object function createSearchParamsIterator(target, kind) { @@ -816,7 +933,9 @@ function createSearchParamsIterator(target, kind) { } // https://heycam.github.io/webidl/#dfn-iterator-prototype-object -const URLSearchParamsIteratorPrototype = Object.setPrototypeOf({ +const URLSearchParamsIteratorPrototype = Object.create(IteratorPrototype); + +defineIDLClass(URLSearchParamsIteratorPrototype, 'URLSearchParamsIterator', { next() { if (!this || Object.getPrototypeOf(this) !== URLSearchParamsIteratorPrototype) { @@ -828,7 +947,7 @@ const URLSearchParamsIteratorPrototype = Object.setPrototypeOf({ kind, index } = this[context]; - const values = getSearchParamPairs(target); + const values = target[searchParams]; const len = values.length; if (index >= len) { return { @@ -837,32 +956,55 @@ const URLSearchParamsIteratorPrototype = Object.setPrototypeOf({ }; } - const pair = values[index]; - this[context].index = index + 1; + const name = values[index]; + const value = values[index + 1]; + this[context].index = index + 2; let result; if (kind === 'key') { - result = pair[0]; + result = name; } else if (kind === 'value') { - result = pair[1]; + result = value; } else { - result = pair; + result = [name, value]; } return { value: result, done: false }; + }, + [util.inspect.custom](recurseTimes, ctx) { + const innerOpts = Object.assign({}, ctx); + if (recurseTimes !== null) { + innerOpts.depth = recurseTimes - 1; + } + const { + target, + kind, + index + } = this[context]; + const output = target[searchParams].slice(index).reduce((prev, cur, i) => { + const key = i % 2 === 0; + if (kind === 'key' && key) { + prev.push(cur); + } else if (kind === 'value' && !key) { + prev.push(cur); + } else if (kind === 'key+value' && !key) { + prev.push([target[searchParams][index + i - 1], cur]); + } + return prev; + }, []); + const breakLn = util.inspect(output, innerOpts).includes('\n'); + const outputStrs = output.map((p) => util.inspect(p, innerOpts)); + let outputStr; + if (breakLn) { + outputStr = `\n ${outputStrs.join(',\n ')}`; + } else { + outputStr = ` ${outputStrs.join(', ')}`; + } + return `${this[Symbol.toStringTag]} {${outputStr} }`; } -}, IteratorPrototype); - -// Unlike interface and its prototype object, both default iterator object and -// iterator prototype object of an interface have the same class string. -Object.defineProperty(URLSearchParamsIteratorPrototype, Symbol.toStringTag, { - value: 'URLSearchParamsIterator', - writable: false, - enumerable: false, - configurable: true }); function originFor(url, base) { @@ -907,8 +1049,32 @@ function domainToUnicode(domain) { return binding.domainToUnicode(String(domain)); } +// Utility function that converts a URL object into an ordinary +// options object as expected by the http.request and https.request +// APIs. +function urlToOptions(url) { + var options = { + protocol: url.protocol, + host: url.host, + hostname: url.hostname, + hash: url.hash, + search: url.search, + pathname: url.pathname, + path: `${url.pathname}${url.search}`, + href: url.href + }; + if (url.port !== '') { + options.port = Number(url.port); + } + if (url.username || url.password) { + options.auth = `${url.username}:${url.password}`; + } + return options; +} + exports.URL = URL; -exports.originFor = originFor; +exports.URLSearchParams = URLSearchParams; exports.domainToASCII = domainToASCII; exports.domainToUnicode = domainToUnicode; exports.encodeAuth = encodeAuth; +exports.urlToOptions = urlToOptions; diff --git a/lib/internal/util.js b/lib/internal/util.js index 238eb65891365c..42a0922d304970 100644 --- a/lib/internal/util.js +++ b/lib/internal/util.js @@ -97,16 +97,22 @@ exports.objectToString = function objectToString(o) { }; const noCrypto = !process.versions.openssl; -exports.assertCrypto = function(exports) { +exports.assertCrypto = function() { if (noCrypto) throw new Error('Node.js is not compiled with openssl crypto support'); }; exports.kIsEncodingSymbol = Symbol('node.isEncoding'); + +// The loop should only run at most twice, retrying with lowercased enc +// if there is no match in the first pass. +// We use a loop instead of branching to retry with a helper +// function in order to avoid the performance hit. +// Return undefined if there is no match. exports.normalizeEncoding = function normalizeEncoding(enc) { if (!enc) return 'utf8'; - var low; - for (;;) { + var retried; + while (true) { switch (enc) { case 'utf8': case 'utf-8': @@ -124,9 +130,9 @@ exports.normalizeEncoding = function normalizeEncoding(enc) { case 'hex': return enc; default: - if (low) return; // undefined + if (retried) return; // undefined enc = ('' + enc).toLowerCase(); - low = true; + retried = true; } } }; @@ -134,20 +140,14 @@ exports.normalizeEncoding = function normalizeEncoding(enc) { // Filters duplicate strings. Used to support functions in crypto and tls // modules. Implemented specifically to maintain existing behaviors in each. exports.filterDuplicateStrings = function filterDuplicateStrings(items, low) { - if (!Array.isArray(items)) - return []; - const len = items.length; - if (len <= 1) - return items; const map = new Map(); - for (var i = 0; i < len; i++) { + for (var i = 0; i < items.length; i++) { const item = items[i]; const key = item.toLowerCase(); if (low) { map.set(key, key); } else { - if (!map.has(key) || map.get(key) <= item) - map.set(key, item); + map.set(key, item); } } return Array.from(map.values()).sort(); @@ -158,7 +158,7 @@ exports.cachedResult = function cachedResult(fn) { return () => { if (result === undefined) result = fn(); - return result; + return result.slice(); }; }; diff --git a/lib/net.js b/lib/net.js index ce60d2f3521317..e4f97ab80debd5 100644 --- a/lib/net.js +++ b/lib/net.js @@ -1132,9 +1132,8 @@ function Server(options, connectionListener) { return this._connections; }, 'Server.connections property is deprecated. ' + 'Use Server.getConnections method instead.'), - set: internalUtil.deprecate((val) => { - return (this._connections = val); - }, 'Server.connections property is deprecated.'), + set: internalUtil.deprecate((val) => (this._connections = val), + 'Server.connections property is deprecated.'), configurable: true, enumerable: false }); diff --git a/lib/os.js b/lib/os.js index cab148581a9db3..a59cc49bae8c51 100644 --- a/lib/os.js +++ b/lib/os.js @@ -51,8 +51,9 @@ exports.tmpdir = function() { return path; }; -exports.tmpDir = internalUtil.deprecate(exports.tmpdir, - 'os.tmpDir() is deprecated. Use os.tmpdir() instead.'); +const tmpDirDeprecationMsg = + 'os.tmpDir() is deprecated. Use os.tmpdir() instead.'; +exports.tmpDir = internalUtil.deprecate(exports.tmpdir, tmpDirDeprecationMsg); exports.getNetworkInterfaces = internalUtil.deprecate(function() { return exports.networkInterfaces(); diff --git a/lib/querystring.js b/lib/querystring.js index ff1b47fb51c614..5ccb5fa77b320f 100644 --- a/lib/querystring.js +++ b/lib/querystring.js @@ -1,8 +1,19 @@ -// Query String Utilities - 'use strict'; -const QueryString = exports; +const QueryString = module.exports = { + unescapeBuffer, + // `unescape()` is a JS global, so we need to use a different local name + unescape: qsUnescape, + + // `escape()` is a JS global, so we need to use a different local name + escape: qsEscape, + + stringify, + encode: stringify, + + parse, + decode: parse +}; const Buffer = require('buffer').Buffer; // This constructor is used to store parsed query string values. Instantiating @@ -11,15 +22,41 @@ const Buffer = require('buffer').Buffer; function ParsedQueryString() {} ParsedQueryString.prototype = Object.create(null); - +const unhexTable = [ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0 - 15 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 16 - 31 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 32 - 47 + +0, +1, +2, +3, +4, +5, +6, +7, +8, +9, -1, -1, -1, -1, -1, -1, // 48 - 63 + -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 64 - 79 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 80 - 95 + -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 96 - 111 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 112 - 127 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 128 ... + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // ... 255 +]; // a safe fast alternative to decodeURIComponent -QueryString.unescapeBuffer = function(s, decodeSpaces) { +function unescapeBuffer(s, decodeSpaces) { var out = Buffer.allocUnsafe(s.length); var state = 0; - var n, m, hexchar; + var n, m, hexchar, c; - for (var inIndex = 0, outIndex = 0; inIndex <= s.length; inIndex++) { - var c = inIndex < s.length ? s.charCodeAt(inIndex) : NaN; + for (var inIndex = 0, outIndex = 0; ; inIndex++) { + if (inIndex < s.length) { + c = s.charCodeAt(inIndex); + } else { + if (state > 0) { + out[outIndex++] = 37/*%*/; + if (state === 2) + out[outIndex++] = hexchar; + } + break; + } switch (state) { case 0: // Any character switch (c) { @@ -40,13 +77,8 @@ QueryString.unescapeBuffer = function(s, decodeSpaces) { case 1: // First hex digit hexchar = c; - if (c >= 48/*0*/ && c <= 57/*9*/) { - n = c - 48/*0*/; - } else if (c >= 65/*A*/ && c <= 70/*F*/) { - n = c - 65/*A*/ + 10; - } else if (c >= 97/*a*/ && c <= 102/*f*/) { - n = c - 97/*a*/ + 10; - } else { + n = unhexTable[c]; + if (!(n >= 0)) { out[outIndex++] = 37/*%*/; out[outIndex++] = c; state = 0; @@ -57,13 +89,8 @@ QueryString.unescapeBuffer = function(s, decodeSpaces) { case 2: // Second hex digit state = 0; - if (c >= 48/*0*/ && c <= 57/*9*/) { - m = c - 48/*0*/; - } else if (c >= 65/*A*/ && c <= 70/*F*/) { - m = c - 65/*A*/ + 10; - } else if (c >= 97/*a*/ && c <= 102/*f*/) { - m = c - 97/*a*/ + 10; - } else { + m = unhexTable[c]; + if (!(m >= 0)) { out[outIndex++] = 37/*%*/; out[outIndex++] = hexchar; out[outIndex++] = c; @@ -76,8 +103,8 @@ QueryString.unescapeBuffer = function(s, decodeSpaces) { // TODO support returning arbitrary buffers. - return out.slice(0, outIndex - 1); -}; + return out.slice(0, outIndex); +} function qsUnescape(s, decodeSpaces) { @@ -87,15 +114,31 @@ function qsUnescape(s, decodeSpaces) { return QueryString.unescapeBuffer(s, decodeSpaces).toString(); } } -QueryString.unescape = qsUnescape; -var hexTable = new Array(256); +const hexTable = []; for (var i = 0; i < 256; ++i) hexTable[i] = '%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase(); -QueryString.escape = function(str) { - // replaces encodeURIComponent - // http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.4 + +// These characters do not need escaping when generating query strings: +// ! - . _ ~ +// ' ( ) * +// digits +// alpha (uppercase) +// alpha (lowercase) +const noEscape = [ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0 - 15 + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 16 - 31 + 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, // 32 - 47 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // 48 - 63 + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 64 - 79 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 80 - 95 + 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 96 - 111 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0 // 112 - 127 +]; +// QueryString.escape() replaces encodeURIComponent() +// http://www.ecma-international.org/ecma-262/5.1/#sec-15.1.3.4 +function qsEscape(str) { if (typeof str !== 'string') { if (typeof str === 'object') str = String(str); @@ -108,30 +151,20 @@ QueryString.escape = function(str) { for (var i = 0; i < str.length; ++i) { var c = str.charCodeAt(i); - // These characters do not need escaping (in order): - // ! - . _ ~ - // ' ( ) * - // digits - // alpha (uppercase) - // alpha (lowercase) - if (c === 0x21 || c === 0x2D || c === 0x2E || c === 0x5F || c === 0x7E || - (c >= 0x27 && c <= 0x2A) || - (c >= 0x30 && c <= 0x39) || - (c >= 0x41 && c <= 0x5A) || - (c >= 0x61 && c <= 0x7A)) { - continue; - } - - if (i - lastPos > 0) - out += str.slice(lastPos, i); - - // Other ASCII characters + // ASCII if (c < 0x80) { + if (noEscape[c] === 1) + continue; + if (lastPos < i) + out += str.slice(lastPos, i); lastPos = i + 1; out += hexTable[c]; continue; } + if (lastPos < i) + out += str.slice(lastPos, i); + // Multi-byte characters ... if (c < 0x800) { lastPos = i + 1; @@ -164,9 +197,9 @@ QueryString.escape = function(str) { if (lastPos < str.length) return out + str.slice(lastPos); return out; -}; +} -var stringifyPrimitive = function(v) { +function stringifyPrimitive(v) { if (typeof v === 'string') return v; if (typeof v === 'number' && isFinite(v)) @@ -174,10 +207,10 @@ var stringifyPrimitive = function(v) { if (typeof v === 'boolean') return v ? 'true' : 'false'; return ''; -}; +} -QueryString.stringify = QueryString.encode = function(obj, sep, eq, options) { +function stringify(obj, sep, eq, options) { sep = sep || '&'; eq = eq || '='; @@ -215,34 +248,43 @@ QueryString.stringify = QueryString.encode = function(obj, sep, eq, options) { return fields; } return ''; -}; +} -// Parse a key/val string. -QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { - sep = sep || '&'; - eq = eq || '='; +function charCodes(str) { + if (str.length === 0) return []; + if (str.length === 1) return [str.charCodeAt(0)]; + const ret = []; + for (var i = 0; i < str.length; ++i) + ret[ret.length] = str.charCodeAt(i); + return ret; +} +const defSepCodes = [38]; // & +const defEqCodes = [61]; // = +// Parse a key/val string. +function parse(qs, sep, eq, options) { const obj = new ParsedQueryString(); if (typeof qs !== 'string' || qs.length === 0) { return obj; } - if (typeof sep !== 'string') - sep += ''; + var sepCodes = (!sep ? defSepCodes : charCodes(sep + '')); + var eqCodes = (!eq ? defEqCodes : charCodes(eq + '')); + const sepLen = sepCodes.length; + const eqLen = eqCodes.length; - const eqLen = eq.length; - const sepLen = sep.length; - - var maxKeys = 1000; + var pairs = 1000; if (options && typeof options.maxKeys === 'number') { - maxKeys = options.maxKeys; + // -1 is used in place of a value like Infinity for meaning + // "unlimited pairs" because of additional checks V8 (at least as of v5.4) + // has to do when using variables that contain values like Infinity. Since + // `pairs` is always decremented and checked explicitly for 0, -1 works + // effectively the same as Infinity, while providing a significant + // performance boost. + pairs = (options.maxKeys > 0 ? options.maxKeys : -1); } - var pairs = Infinity; - if (maxKeys > 0) - pairs = maxKeys; - var decode = QueryString.unescape; if (options && typeof options.decodeURIComponent === 'function') { decode = options.decodeURIComponent; @@ -262,7 +304,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { const code = qs.charCodeAt(i); // Try matching key/value pair separator (e.g. '&') - if (code === sep.charCodeAt(sepIdx)) { + if (code === sepCodes[sepIdx]) { if (++sepIdx === sepLen) { // Key/value pair separator match! const end = i - sepIdx + 1; @@ -284,10 +326,10 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { keys[keys.length] = key; } else { const curValue = obj[key]; - // `instanceof Array` is used instead of Array.isArray() because it - // is ~15-20% faster with v8 4.7 and is safe to use because we are - // using it with values being created within this function - if (curValue instanceof Array) + // A simple Array-specific property check is enough here to + // distinguish from a string value and is faster and still safe since + // we are generating all of the values being assigned. + if (curValue.pop) curValue[curValue.length] = value; else obj[key] = [curValue, value]; @@ -322,7 +364,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { // Try matching key/value separator (e.g. '=') if we haven't already if (eqIdx < eqLen) { - if (code === eq.charCodeAt(eqIdx)) { + if (code === eqCodes[eqIdx]) { if (++eqIdx === eqLen) { // Key/value separator match! const end = i - eqIdx + 1; @@ -354,12 +396,12 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { if (code === 43/*+*/) { if (eqIdx < eqLen) { - if (i - lastPos > 0) + if (lastPos < i) key += qs.slice(lastPos, i); key += '%20'; keyEncoded = true; } else { - if (i - lastPos > 0) + if (lastPos < i) value += qs.slice(lastPos, i); value += '%20'; valEncoded = true; @@ -369,7 +411,7 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { } // Check if we have leftover key or value data - if (pairs > 0 && (lastPos < qs.length || eqIdx > 0)) { + if (pairs !== 0 && (lastPos < qs.length || eqIdx > 0)) { if (lastPos < qs.length) { if (eqIdx < eqLen) key += qs.slice(lastPos); @@ -387,10 +429,10 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { keys[keys.length] = key; } else { const curValue = obj[key]; - // `instanceof Array` is used instead of Array.isArray() because it - // is ~15-20% faster with v8 4.7 and is safe to use because we are - // using it with values being created within this function - if (curValue instanceof Array) + // A simple Array-specific property check is enough here to + // distinguish from a string value and is faster and still safe since + // we are generating all of the values being assigned. + if (curValue.pop) curValue[curValue.length] = value; else obj[key] = [curValue, value]; @@ -398,11 +440,12 @@ QueryString.parse = QueryString.decode = function(qs, sep, eq, options) { } return obj; -}; +} // v8 does not optimize functions with try-catch blocks, so we isolate them here -// to minimize the damage +// to minimize the damage (Note: no longer true as of V8 5.4 -- but still will +// not be inlined). function decodeStr(s, decoder) { try { return decoder(s); diff --git a/lib/readline.js b/lib/readline.js index 9b925a6d990d8b..8200771ec4b39f 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -23,22 +23,13 @@ const stripVTControlCharacters = internalReadline.stripVTControlCharacters; exports.createInterface = function(input, output, completer, terminal) { - var rl; - if (arguments.length === 1) { - rl = new Interface(input); - } else { - rl = new Interface(input, output, completer, terminal); - } - return rl; + return new Interface(input, output, completer, terminal); }; function Interface(input, output, completer, terminal) { if (!(this instanceof Interface)) { - // call the constructor preserving original number of arguments - const self = Object.create(Interface.prototype); - Interface.apply(self, arguments); - return self; + return new Interface(input, output, completer, terminal); } this._sawReturnAt = 0; @@ -51,7 +42,7 @@ function Interface(input, output, completer, terminal) { let crlfDelay; let prompt = '> '; - if (arguments.length === 1) { + if (input && input.input) { // an options object was given output = input.output; completer = input.completer; diff --git a/lib/repl.js b/lib/repl.js index 858ccd883850d3..302e79f9a2752c 100644 --- a/lib/repl.js +++ b/lib/repl.js @@ -39,13 +39,13 @@ const debug = util.debuglog('repl'); const parentModule = module; const replMap = new WeakMap(); -const GLOBAL_OBJECT_PROPERTIES = ['NaN', 'Infinity', 'undefined', - 'eval', 'parseInt', 'parseFloat', 'isNaN', 'isFinite', 'decodeURI', - 'decodeURIComponent', 'encodeURI', 'encodeURIComponent', - 'Object', 'Function', 'Array', 'String', 'Boolean', 'Number', - 'Date', 'RegExp', 'Error', 'EvalError', 'RangeError', - 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', - 'Math', 'JSON']; +const GLOBAL_OBJECT_PROPERTIES = [ + 'NaN', 'Infinity', 'undefined', 'eval', 'parseInt', 'parseFloat', 'isNaN', + 'isFinite', 'decodeURI', 'decodeURIComponent', 'encodeURI', + 'encodeURIComponent', 'Object', 'Function', 'Array', 'String', 'Boolean', + 'Number', 'Date', 'RegExp', 'Error', 'EvalError', 'RangeError', + 'ReferenceError', 'SyntaxError', 'TypeError', 'URIError', 'Math', 'JSON' +]; const GLOBAL_OBJECT_PROPERTY_MAP = {}; GLOBAL_OBJECT_PROPERTIES.forEach((p) => GLOBAL_OBJECT_PROPERTY_MAP[p] = p); @@ -322,13 +322,7 @@ function REPLServer(prompt, if (!err) { // Unset raw mode during evaluation so that Ctrl+C raises a signal. let previouslyInRawMode; - - // Temporarily disabled on Windows due to output problems that likely - // result from the raw mode switches here, see - // https://github.com/nodejs/node/issues/7837 - // Setting NODE_REPL_CTRLC is meant as a temporary opt-in for debugging. - if (self.breakEvalOnSigint && - (process.platform !== 'win32' || process.env.NODE_REPL_CTRLC)) { + if (self.breakEvalOnSigint) { // Start the SIGINT watchdog before entering raw mode so that a very // quick Ctrl+C doesn’t lead to aborting the process completely. utilBinding.startSigintWatchdog(); @@ -348,8 +342,7 @@ function REPLServer(prompt, result = script.runInContext(context, scriptOptions); } } finally { - if (self.breakEvalOnSigint && - (process.platform !== 'win32' || process.env.NODE_REPL_CTRLC)) { + if (self.breakEvalOnSigint) { // Reset terminal mode to its previous value. self._setRawMode(previouslyInRawMode); @@ -728,9 +721,7 @@ REPLServer.prototype.createContext = function() { Object.defineProperty(context, '_', { configurable: true, - get: () => { - return this.last; - }, + get: () => this.last, set: (value) => { this.last = value; if (!this.underscoreAssigned) { @@ -1223,12 +1214,13 @@ function addStandardGlobals(completionGroups, filter) { // Common keywords. Exclude for completion on the empty string, b/c // they just get in the way. if (filter) { - completionGroups.push(['break', 'case', 'catch', 'const', - 'continue', 'debugger', 'default', 'delete', 'do', 'else', - 'export', 'false', 'finally', 'for', 'function', 'if', - 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return', - 'switch', 'this', 'throw', 'true', 'try', 'typeof', 'undefined', - 'var', 'void', 'while', 'with', 'yield']); + completionGroups.push([ + 'break', 'case', 'catch', 'const', 'continue', 'debugger', 'default', + 'delete', 'do', 'else', 'export', 'false', 'finally', 'for', 'function', + 'if', 'import', 'in', 'instanceof', 'let', 'new', 'null', 'return', + 'switch', 'this', 'throw', 'true', 'try', 'typeof', 'undefined', 'var', + 'void', 'while', 'with', 'yield' + ]); } } @@ -1272,9 +1264,10 @@ function defineDefaultCommands(repl) { help: 'Print this help message', action: function() { const names = Object.keys(this.commands).sort(); - const longestNameLength = names.reduce((max, name) => { - return Math.max(max, name.length); - }, 0); + const longestNameLength = names.reduce( + (max, name) => Math.max(max, name.length), + 0 + ); names.forEach((name) => { const cmd = this.commands[name]; const spaces = ' '.repeat(longestNameLength - name.length + 3); diff --git a/lib/tls.js b/lib/tls.js index 32c0319754be2a..bb4719d9b02c93 100644 --- a/lib/tls.js +++ b/lib/tls.js @@ -1,7 +1,7 @@ 'use strict'; const internalUtil = require('internal/util'); -internalUtil.assertCrypto(exports); +internalUtil.assertCrypto(); const net = require('net'); const url = require('url'); @@ -22,9 +22,9 @@ exports.DEFAULT_CIPHERS = exports.DEFAULT_ECDH_CURVE = 'prime256v1'; -exports.getCiphers = internalUtil.cachedResult(() => { - return internalUtil.filterDuplicateStrings(binding.getSSLCiphers(), true); -}); +exports.getCiphers = internalUtil.cachedResult( + () => internalUtil.filterDuplicateStrings(binding.getSSLCiphers(), true) +); // Convert protocols array into valid OpenSSL protocols list // ("\x06spdy/2\x08http/1.1\x08http/1.0") diff --git a/lib/url.js b/lib/url.js index 1dfab2eaaf7fca..2f05cc6648ab48 100644 --- a/lib/url.js +++ b/lib/url.js @@ -17,7 +17,7 @@ exports.resolve = urlResolve; exports.resolveObject = urlResolveObject; exports.format = urlFormat; exports.URL = internalUrl.URL; -exports.originFor = internalUrl.originFor; +exports.URLSearchParams = internalUrl.URLSearchParams; exports.domainToASCII = internalUrl.domainToASCII; exports.domainToUnicode = internalUrl.domainToUnicode; diff --git a/lib/util.js b/lib/util.js index 37008b2d176062..9d5909cdc7ce30 100644 --- a/lib/util.js +++ b/lib/util.js @@ -27,16 +27,13 @@ var simdFormatters; if (typeof global.SIMD === 'object' && global.SIMD !== null) { simdFormatters = new Map(); - const make = (extractLane, count) => { - return (ctx, value, recurseTimes, visibleKeys, keys) => { + const make = + (extractLane, count) => (ctx, value, recurseTimes, visibleKeys, keys) => { const output = new Array(count); for (var i = 0; i < count; i += 1) output[i] = formatPrimitive(ctx, extractLane(value, i)); return output; }; - }; - - const SIMD = global.SIMD; // Pacify eslint. const countPerType = { Bool16x8: 8, @@ -52,7 +49,7 @@ if (typeof global.SIMD === 'object' && global.SIMD !== null) { }; for (const key in countPerType) { - const type = SIMD[key]; + const type = global.SIMD[key]; simdFormatters.set(type, make(type.extractLane, countPerType[key])); } } @@ -173,8 +170,12 @@ function inspect(obj, opts) { stylize: stylizeNoColor }; // legacy... - if (arguments[2] !== undefined) ctx.depth = arguments[2]; - if (arguments[3] !== undefined) ctx.colors = arguments[3]; + if (arguments.length >= 3 && arguments[2] !== undefined) { + ctx.depth = arguments[2]; + } + if (arguments.length >= 4 && arguments[3] !== undefined) { + ctx.colors = arguments[3]; + } if (typeof opts === 'boolean') { // legacy... ctx.showHidden = opts; @@ -403,7 +404,7 @@ function formatValue(ctx, value, recurseTimes) { if (keys.length === 0) { if (typeof value === 'function') { return ctx.stylize(`[Function${value.name ? `: ${value.name}` : ''}]`, - 'special'); + 'special'); } if (isRegExp(value)) { return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); @@ -663,7 +664,7 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { for (var i = 0; i < maxLength; ++i) { if (hasOwnProperty(value, String(i))) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - String(i), true)); + String(i), true)); } else { output.push(''); } @@ -674,7 +675,7 @@ function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { keys.forEach(function(key) { if (typeof key === 'symbol' || !key.match(/^\d+$/)) { output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, - key, true)); + key, true)); } }); return output; diff --git a/lib/v8.js b/lib/v8.js index 90abc627a45af0..415aed593eb799 100644 --- a/lib/v8.js +++ b/lib/v8.js @@ -18,7 +18,7 @@ const v8binding = process.binding('v8'); // Properties for heap statistics buffer extraction. const heapStatisticsBuffer = - new Uint32Array(v8binding.heapStatisticsArrayBuffer); + new Float64Array(v8binding.heapStatisticsArrayBuffer); const kTotalHeapSizeIndex = v8binding.kTotalHeapSizeIndex; const kTotalHeapSizeExecutableIndex = v8binding.kTotalHeapSizeExecutableIndex; const kTotalPhysicalSizeIndex = v8binding.kTotalPhysicalSizeIndex; @@ -31,7 +31,7 @@ const kPeakMallocedMemoryIndex = v8binding.kPeakMallocedMemoryIndex; // Properties for heap space statistics buffer extraction. const heapSpaceStatisticsBuffer = - new Uint32Array(v8binding.heapSpaceStatisticsArrayBuffer); + new Float64Array(v8binding.heapSpaceStatisticsArrayBuffer); const kHeapSpaces = v8binding.kHeapSpaces; const kNumberOfHeapSpaces = kHeapSpaces.length; const kHeapSpaceStatisticsPropertiesCount = diff --git a/lib/vm.js b/lib/vm.js index 4869d368807665..cf672fbbc14871 100644 --- a/lib/vm.js +++ b/lib/vm.js @@ -17,22 +17,17 @@ const realRunInThisContext = Script.prototype.runInThisContext; const realRunInContext = Script.prototype.runInContext; Script.prototype.runInThisContext = function(options) { - if (options && options.breakOnSigint) { - const realRunInThisContextScript = () => { - return realRunInThisContext.call(this, options); - }; - return sigintHandlersWrap(realRunInThisContextScript); + if (options && options.breakOnSigint && process._events.SIGINT) { + return sigintHandlersWrap(realRunInThisContext, this, [options]); } else { return realRunInThisContext.call(this, options); } }; Script.prototype.runInContext = function(contextifiedSandbox, options) { - if (options && options.breakOnSigint) { - const realRunInContextScript = () => { - return realRunInContext.call(this, contextifiedSandbox, options); - }; - return sigintHandlersWrap(realRunInContextScript); + if (options && options.breakOnSigint && process._events.SIGINT) { + return sigintHandlersWrap(realRunInContext, this, + [contextifiedSandbox, options]); } else { return realRunInContext.call(this, contextifiedSandbox, options); } @@ -83,19 +78,20 @@ exports.isContext = binding.isContext; // Remove all SIGINT listeners and re-attach them after the wrapped function // has executed, so that caught SIGINT are handled by the listeners again. -function sigintHandlersWrap(fn) { +function sigintHandlersWrap(fn, thisArg, argsArray) { // Using the internal list here to make sure `.once()` wrappers are used, // not the original ones. let sigintListeners = process._events.SIGINT; - if (!Array.isArray(sigintListeners)) - sigintListeners = sigintListeners ? [sigintListeners] : []; - else + + if (Array.isArray(sigintListeners)) sigintListeners = sigintListeners.slice(); + else + sigintListeners = [sigintListeners]; process.removeAllListeners('SIGINT'); try { - return fn(); + return fn.apply(thisArg, argsArray); } finally { // Add using the public methods so that the `newListener` handler of // process can re-attach the listeners. diff --git a/node.gyp b/node.gyp index 2b720a46791b73..3fa9277d859ea8 100644 --- a/node.gyp +++ b/node.gyp @@ -76,7 +76,12 @@ 'lib/zlib.js', 'lib/internal/buffer.js', 'lib/internal/child_process.js', - 'lib/internal/cluster.js', + 'lib/internal/cluster/child.js', + 'lib/internal/cluster/master.js', + 'lib/internal/cluster/round_robin_handle.js', + 'lib/internal/cluster/shared_handle.js', + 'lib/internal/cluster/utils.js', + 'lib/internal/cluster/worker.js', 'lib/internal/freelist.js', 'lib/internal/fs.js', 'lib/internal/linkedlist.js', @@ -140,13 +145,13 @@ ], 'sources': [ - 'src/debug-agent.cc', 'src/async-wrap.cc', - 'src/env.cc', - 'src/fs_event_wrap.cc', 'src/cares_wrap.cc', 'src/connection_wrap.cc', 'src/connect_wrap.cc', + 'src/debug-agent.cc', + 'src/env.cc', + 'src/fs_event_wrap.cc', 'src/handle_wrap.cc', 'src/js_stream.cc', 'src/node.cc', @@ -154,6 +159,7 @@ 'src/node_config.cc', 'src/node_constants.cc', 'src/node_contextify.cc', + 'src/node_debug_options.cc', 'src/node_file.cc', 'src/node_http_parser.cc', 'src/node_javascript.cc', @@ -168,16 +174,18 @@ 'src/node_zlib.cc', 'src/node_i18n.cc', 'src/pipe_wrap.cc', + 'src/process_wrap.cc', 'src/signal_wrap.cc', 'src/spawn_sync.cc', 'src/string_bytes.cc', + 'src/string_search.cc', 'src/stream_base.cc', 'src/stream_wrap.cc', 'src/tcp_wrap.cc', 'src/timer_wrap.cc', 'src/tty_wrap.cc', - 'src/process_wrap.cc', 'src/udp_wrap.cc', + 'src/util.cc', 'src/uv.cc', # headers to make for a more pleasant IDE experience 'src/async-wrap.h', @@ -194,6 +202,7 @@ 'src/node.h', 'src/node_buffer.h', 'src/node_constants.h', + 'src/node_debug_options.h', 'src/node_file.h', 'src/node_http_parser.h', 'src/node_internals.h', @@ -218,8 +227,6 @@ 'src/tree.h', 'src/util.h', 'src/util-inl.h', - 'src/util.cc', - 'src/string_search.cc', 'deps/http_parser/http_parser.h', 'deps/v8/include/v8.h', 'deps/v8/include/v8-debug.h', @@ -893,7 +900,6 @@ 'HAVE_INSPECTOR=1', ], 'dependencies': [ - 'deps/zlib/zlib.gyp:zlib', 'v8_inspector_compress_protocol_json#host' ], 'include_dirs': [ @@ -906,6 +912,11 @@ 'test/cctest/test_inspector_socket_server.cc' ], 'conditions': [ + [ 'node_shared_zlib=="false"', { + 'dependencies': [ + 'deps/zlib/zlib.gyp:zlib', + ] + }], [ 'node_shared_openssl=="false"', { 'dependencies': [ 'deps/openssl/openssl.gyp:openssl' diff --git a/src/connection_wrap.cc b/src/connection_wrap.cc index 41571946b22e4f..020fe8b4c9508c 100644 --- a/src/connection_wrap.cc +++ b/src/connection_wrap.cc @@ -99,11 +99,10 @@ void ConnectionWrap::AfterConnect(uv_connect_t* req, writable = uv_is_writable(req->handle) != 0; } - Local req_wrap_obj = req_wrap->object(); Local argv[5] = { Integer::New(env->isolate(), status), wrap->object(), - req_wrap_obj, + req_wrap->object(), Boolean::New(env->isolate(), readable), Boolean::New(env->isolate(), writable) }; diff --git a/src/debug-agent.cc b/src/debug-agent.cc index 2766702525d088..2d8ed8afc980ec 100644 --- a/src/debug-agent.cc +++ b/src/debug-agent.cc @@ -50,7 +50,6 @@ using v8::Value; Agent::Agent(Environment* env) : state_(kNone), - port_(5858), wait_(false), parent_env_(env), child_env_(nullptr), @@ -69,7 +68,7 @@ Agent::~Agent() { } -bool Agent::Start(const char* host, int port, bool wait) { +bool Agent::Start(const DebugOptions& options) { int err; if (state_ == kRunning) @@ -85,9 +84,8 @@ bool Agent::Start(const char* host, int port, bool wait) { goto async_init_failed; uv_unref(reinterpret_cast(&child_signal_)); - host_ = host; - port_ = port; - wait_ = wait; + options_ = options; + wait_ = options_.wait_for_connect(); err = uv_thread_create(&thread_, reinterpret_cast(ThreadCb), @@ -210,9 +208,11 @@ void Agent::InitAdaptor(Environment* env) { api->Set(String::NewFromUtf8(isolate, "host", NewStringType::kNormal).ToLocalChecked(), - String::NewFromUtf8(isolate, host_.data(), NewStringType::kNormal, - host_.size()).ToLocalChecked()); - api->Set(String::NewFromUtf8(isolate, "port"), Integer::New(isolate, port_)); + String::NewFromUtf8(isolate, options_.host_name().data(), + NewStringType::kNormal, + options_.host_name().size()).ToLocalChecked()); + api->Set(String::NewFromUtf8(isolate, "port"), + Integer::New(isolate, options_.port())); env->process_object()->Set(String::NewFromUtf8(isolate, "_debugAPI"), api); api_.Reset(env->isolate(), api); diff --git a/src/debug-agent.h b/src/debug-agent.h index 783403cf0920d1..0faa25f12470a9 100644 --- a/src/debug-agent.h +++ b/src/debug-agent.h @@ -25,6 +25,7 @@ #if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS #include "node_mutex.h" +#include "node_debug_options.h" #include "util.h" #include "util-inl.h" #include "uv.h" @@ -76,7 +77,7 @@ class Agent { typedef void (*DispatchHandler)(node::Environment* env); // Start the debugger agent thread - bool Start(const char* host, int port, bool wait); + bool Start(const DebugOptions& options); // Listen for debug events void Enable(); // Stop the debugger agent @@ -114,9 +115,8 @@ class Agent { }; State state_; + DebugOptions options_; - std::string host_; - int port_; bool wait_; uv_sem_t start_sem_; diff --git a/src/env-inl.h b/src/env-inl.h index 83db3d33b6d18f..1a17e2947d0597 100644 --- a/src/env-inl.h +++ b/src/env-inl.h @@ -207,6 +207,19 @@ inline Environment::~Environment() { delete hc; } + while (handle_cleanup_waiting_ != 0) + uv_run(event_loop(), UV_RUN_ONCE); + + // Closing the destroy_ids_idle_handle_ within the handle cleanup queue + // prevents the async wrap destroy hook from being called. + uv_handle_t* handle = + reinterpret_cast(&destroy_ids_idle_handle_); + handle->data = this; + handle_cleanup_waiting_ = 1; + uv_close(handle, [](uv_handle_t* handle) { + static_cast(handle->data)->FinishHandleCleanup(handle); + }); + while (handle_cleanup_waiting_ != 0) uv_run(event_loop(), UV_RUN_ONCE); @@ -316,22 +329,22 @@ inline std::vector* Environment::destroy_ids_list() { return &destroy_ids_list_; } -inline uint32_t* Environment::heap_statistics_buffer() const { +inline double* Environment::heap_statistics_buffer() const { CHECK_NE(heap_statistics_buffer_, nullptr); return heap_statistics_buffer_; } -inline void Environment::set_heap_statistics_buffer(uint32_t* pointer) { +inline void Environment::set_heap_statistics_buffer(double* pointer) { CHECK_EQ(heap_statistics_buffer_, nullptr); // Should be set only once. heap_statistics_buffer_ = pointer; } -inline uint32_t* Environment::heap_space_statistics_buffer() const { +inline double* Environment::heap_space_statistics_buffer() const { CHECK_NE(heap_space_statistics_buffer_, nullptr); return heap_space_statistics_buffer_; } -inline void Environment::set_heap_space_statistics_buffer(uint32_t* pointer) { +inline void Environment::set_heap_space_statistics_buffer(double* pointer) { CHECK_EQ(heap_space_statistics_buffer_, nullptr); // Should be set only once. heap_space_statistics_buffer_ = pointer; } diff --git a/src/env.h b/src/env.h index b99bb45f819e59..8c256ca9c7faa4 100644 --- a/src/env.h +++ b/src/env.h @@ -469,11 +469,11 @@ class Environment { // List of id's that have been destroyed and need the destroy() cb called. inline std::vector* destroy_ids_list(); - inline uint32_t* heap_statistics_buffer() const; - inline void set_heap_statistics_buffer(uint32_t* pointer); + inline double* heap_statistics_buffer() const; + inline void set_heap_statistics_buffer(double* pointer); - inline uint32_t* heap_space_statistics_buffer() const; - inline void set_heap_space_statistics_buffer(uint32_t* pointer); + inline double* heap_space_statistics_buffer() const; + inline void set_heap_space_statistics_buffer(double* pointer); inline char* http_parser_buffer() const; inline void set_http_parser_buffer(char* buffer); @@ -581,8 +581,8 @@ class Environment { &HandleCleanup::handle_cleanup_queue_> handle_cleanup_queue_; int handle_cleanup_waiting_; - uint32_t* heap_statistics_buffer_ = nullptr; - uint32_t* heap_space_statistics_buffer_ = nullptr; + double* heap_statistics_buffer_ = nullptr; + double* heap_space_statistics_buffer_ = nullptr; char* http_parser_buffer_; diff --git a/src/inspector_agent.cc b/src/inspector_agent.cc index fc478c49a09d61..ae2e666384b5af 100644 --- a/src/inspector_agent.cc +++ b/src/inspector_agent.cc @@ -16,6 +16,7 @@ #include #include +#include #include #include @@ -30,13 +31,6 @@ namespace { using v8_inspector::StringBuffer; using v8_inspector::StringView; -const char TAG_CONNECT[] = "#connect"; -const char TAG_DISCONNECT[] = "#disconnect"; - -static const uint8_t PROTOCOL_JSON[] = { -#include "v8_inspector_protocol_json.h" // NOLINT(build/include_order) -}; - std::string GetProcessTitle() { // uv_get_process_title will trim the title if it is too long. char title[2048]; @@ -105,6 +99,14 @@ std::unique_ptr Utf8ToStringView(const std::string& message) { class V8NodeInspector; +enum class InspectorAction { + kStartSession, kEndSession, kSendMessage +}; + +enum class TransportAction { + kSendMessage, kStop +}; + class InspectorAgentDelegate: public node::inspector::SocketServerDelegate { public: InspectorAgentDelegate(AgentImpl* agent, const std::string& script_path, @@ -129,10 +131,10 @@ class InspectorAgentDelegate: public node::inspector::SocketServerDelegate { class AgentImpl { public: explicit AgentImpl(node::Environment* env); - ~AgentImpl(); // Start the inspector agent thread - bool Start(v8::Platform* platform, const char* path, int port, bool wait); + bool Start(v8::Platform* platform, const char* path, + const DebugOptions& options); // Stop the inspector agent void Stop(); @@ -143,14 +145,16 @@ class AgentImpl { void FatalException(v8::Local error, v8::Local message); - void PostIncomingMessage(int session_id, const std::string& message); + void PostIncomingMessage(InspectorAction action, int session_id, + const std::string& message); void ResumeStartup() { uv_sem_post(&start_sem_); } private: + template using MessageQueue = - std::vector>>; + std::vector>>; enum class State { kNew, kAccepting, kConnected, kDone, kError }; static void ThreadCbIO(void* agent); @@ -161,14 +165,18 @@ class AgentImpl { void WorkerRunIO(); void SetConnected(bool connected); void DispatchMessages(); - void Write(int session_id, const StringView& message); - bool AppendMessage(MessageQueue* vector, int session_id, - std::unique_ptr buffer); - void SwapBehindLock(MessageQueue* vector1, MessageQueue* vector2); + void Write(TransportAction action, int session_id, const StringView& message); + template + bool AppendMessage(MessageQueue* vector, ActionType action, + int session_id, std::unique_ptr buffer); + template + void SwapBehindLock(MessageQueue* vector1, + MessageQueue* vector2); void WaitForFrontendMessage(); void NotifyMessageReceived(); State ToState(State state); + DebugOptions options_; uv_sem_t start_sem_; ConditionVariable incoming_message_cond_; Mutex state_lock_; @@ -176,24 +184,23 @@ class AgentImpl { uv_loop_t child_loop_; InspectorAgentDelegate* delegate_; - - int port_; bool wait_; bool shutting_down_; State state_; node::Environment* parent_env_; - uv_async_t* data_written_; uv_async_t io_thread_req_; V8NodeInspector* inspector_; v8::Platform* platform_; - MessageQueue incoming_message_queue_; - MessageQueue outgoing_message_queue_; + MessageQueue incoming_message_queue_; + MessageQueue outgoing_message_queue_; bool dispatching_messages_; int session_id_; InspectorSocketServer* server_; std::string script_name_; + std::string script_path_; + const std::string id_; friend class ChannelImpl; friend class DispatchOnInspectorBackendTask; @@ -236,7 +243,7 @@ class ChannelImpl final : public v8_inspector::V8Inspector::Channel { void flushProtocolNotifications() override { } void sendMessageToFrontend(const StringView& message) { - agent_->Write(agent_->session_id_, message); + agent_->Write(TransportAction::kSendMessage, agent_->session_id_, message); } AgentImpl* const agent_; @@ -318,12 +325,10 @@ class V8NodeInspector : public v8_inspector::V8InspectorClient { }; AgentImpl::AgentImpl(Environment* env) : delegate_(nullptr), - port_(0), wait_(false), shutting_down_(false), state_(State::kNew), parent_env_(env), - data_written_(new uv_async_t()), inspector_(nullptr), platform_(nullptr), dispatching_messages_(false), @@ -331,16 +336,6 @@ AgentImpl::AgentImpl(Environment* env) : delegate_(nullptr), server_(nullptr) { CHECK_EQ(0, uv_sem_init(&start_sem_, 0)); memset(&io_thread_req_, 0, sizeof(io_thread_req_)); - CHECK_EQ(0, uv_async_init(env->event_loop(), data_written_, nullptr)); - uv_unref(reinterpret_cast(data_written_)); -} - -AgentImpl::~AgentImpl() { - auto close_cb = [](uv_handle_t* handle) { - delete reinterpret_cast(handle); - }; - uv_close(reinterpret_cast(data_written_), close_cb); - data_written_ = nullptr; } void InspectorConsoleCall(const v8::FunctionCallbackInfo& info) { @@ -409,7 +404,10 @@ void InspectorWrapConsoleCall(const v8::FunctionCallbackInfo& args) { } bool AgentImpl::Start(v8::Platform* platform, const char* path, - int port, bool wait) { + const DebugOptions& options) { + options_ = options; + wait_ = options.wait_for_connect(); + auto env = parent_env_; inspector_ = new V8NodeInspector(this, env, platform); platform_ = platform; @@ -421,9 +419,6 @@ bool AgentImpl::Start(v8::Platform* platform, const char* path, int err = uv_loop_init(&child_loop_); CHECK_EQ(err, 0); - port_ = port; - wait_ = wait; - err = uv_thread_create(&thread_, AgentImpl::ThreadCbIO, this); CHECK_EQ(err, 0); uv_sem_wait(&start_sem_); @@ -433,7 +428,7 @@ bool AgentImpl::Start(v8::Platform* platform, const char* path, return false; } state_ = State::kAccepting; - if (wait) { + if (options_.wait_for_connect()) { DispatchMessages(); } return true; @@ -456,9 +451,7 @@ bool AgentImpl::IsStarted() { void AgentImpl::WaitForDisconnect() { if (state_ == State::kConnected) { shutting_down_ = true; - // Gives a signal to stop accepting new connections - // TODO(eugeneo): Introduce an API with explicit request names. - Write(0, StringView()); + Write(TransportAction::kStop, 0, StringView()); fprintf(stderr, "Waiting for the debugger to disconnect...\n"); fflush(stderr); inspector_->runMessageLoopOnPause(0); @@ -533,15 +526,17 @@ void AgentImpl::ThreadCbIO(void* agent) { // static void AgentImpl::WriteCbIO(uv_async_t* async) { AgentImpl* agent = static_cast(async->data); - MessageQueue outgoing_messages; + MessageQueue outgoing_messages; agent->SwapBehindLock(&agent->outgoing_message_queue_, &outgoing_messages); - for (const MessageQueue::value_type& outgoing : outgoing_messages) { - StringView view = outgoing.second->string(); - if (view.length() == 0) { + for (const auto& outgoing : outgoing_messages) { + switch (std::get<0>(outgoing)) { + case TransportAction::kStop: agent->server_->Stop(nullptr); - } else { - agent->server_->Send(outgoing.first, - StringViewToUtf8(outgoing.second->string())); + break; + case TransportAction::kSendMessage: + std::string message = StringViewToUtf8(std::get<2>(outgoing)->string()); + agent->server_->Send(std::get<1>(outgoing), message); + break; } } } @@ -561,9 +556,10 @@ void AgentImpl::WorkerRunIO() { } InspectorAgentDelegate delegate(this, script_path, script_name_, wait_); delegate_ = &delegate; - InspectorSocketServer server(&delegate, port_); + InspectorSocketServer server(&delegate, + options_.host_name(), + options_.port()); if (!server.Start(&child_loop_)) { - fprintf(stderr, "Unable to open devtools socket: %s\n", uv_strerror(err)); state_ = State::kError; // Safe, main thread is waiting on semaphore uv_close(reinterpret_cast(&io_thread_req_), nullptr); uv_loop_close(&child_loop_); @@ -585,28 +581,31 @@ void AgentImpl::WorkerRunIO() { server_ = nullptr; } -bool AgentImpl::AppendMessage(MessageQueue* queue, int session_id, +template +bool AgentImpl::AppendMessage(MessageQueue* queue, + ActionType action, int session_id, std::unique_ptr buffer) { Mutex::ScopedLock scoped_lock(state_lock_); bool trigger_pumping = queue->empty(); - queue->push_back(std::make_pair(session_id, std::move(buffer))); + queue->push_back(std::make_tuple(action, session_id, std::move(buffer))); return trigger_pumping; } -void AgentImpl::SwapBehindLock(MessageQueue* vector1, MessageQueue* vector2) { +template +void AgentImpl::SwapBehindLock(MessageQueue* vector1, + MessageQueue* vector2) { Mutex::ScopedLock scoped_lock(state_lock_); vector1->swap(*vector2); } -void AgentImpl::PostIncomingMessage(int session_id, +void AgentImpl::PostIncomingMessage(InspectorAction action, int session_id, const std::string& message) { - if (AppendMessage(&incoming_message_queue_, session_id, + if (AppendMessage(&incoming_message_queue_, action, session_id, Utf8ToStringView(message))) { v8::Isolate* isolate = parent_env_->isolate(); platform_->CallOnForegroundThread(isolate, new DispatchOnInspectorBackendTask(this)); isolate->RequestInterrupt(InterruptCallback, this); - uv_async_send(data_written_); } NotifyMessageReceived(); } @@ -630,25 +629,21 @@ void AgentImpl::DispatchMessages() { if (dispatching_messages_) return; dispatching_messages_ = true; - MessageQueue tasks; + MessageQueue tasks; do { tasks.clear(); SwapBehindLock(&incoming_message_queue_, &tasks); - for (const MessageQueue::value_type& pair : tasks) { - StringView message = pair.second->string(); - std::string tag; - if (message.length() == sizeof(TAG_CONNECT) - 1 || - message.length() == sizeof(TAG_DISCONNECT) - 1) { - tag = StringViewToUtf8(message); - } - - if (tag == TAG_CONNECT) { + for (const auto& task : tasks) { + StringView message = std::get<2>(task)->string(); + switch (std::get<0>(task)) { + case InspectorAction::kStartSession: CHECK_EQ(State::kAccepting, state_); - session_id_ = pair.first; + session_id_ = std::get<1>(task); state_ = State::kConnected; fprintf(stderr, "Debugger attached.\n"); inspector_->connectFrontend(); - } else if (tag == TAG_DISCONNECT) { + break; + case InspectorAction::kEndSession: CHECK_EQ(State::kConnected, state_); if (shutting_down_) { state_ = State::kDone; @@ -657,17 +652,19 @@ void AgentImpl::DispatchMessages() { } inspector_->quitMessageLoopOnPause(); inspector_->disconnectFrontend(); - } else { + break; + case InspectorAction::kSendMessage: inspector_->dispatchMessageFromFrontend(message); + break; } } } while (!tasks.empty()); - uv_async_send(data_written_); dispatching_messages_ = false; } -void AgentImpl::Write(int session_id, const StringView& inspector_message) { - AppendMessage(&outgoing_message_queue_, session_id, +void AgentImpl::Write(TransportAction action, int session_id, + const StringView& inspector_message) { + AppendMessage(&outgoing_message_queue_, action, session_id, StringBuffer::create(inspector_message)); int err = uv_async_send(&io_thread_req_); CHECK_EQ(0, err); @@ -681,8 +678,8 @@ Agent::~Agent() { } bool Agent::Start(v8::Platform* platform, const char* path, - int port, bool wait) { - return impl->Start(platform, path, port, wait); + const DebugOptions& options) { + return impl->Start(platform, path, options); } void Agent::Stop() { @@ -724,7 +721,8 @@ bool InspectorAgentDelegate::StartSession(int session_id, if (connected_) return false; connected_ = true; - agent_->PostIncomingMessage(session_id, TAG_CONNECT); + session_id_++; + agent_->PostIncomingMessage(InspectorAction::kStartSession, session_id, ""); return true; } @@ -741,12 +739,13 @@ void InspectorAgentDelegate::MessageReceived(int session_id, agent_->ResumeStartup(); } } - agent_->PostIncomingMessage(session_id, message); + agent_->PostIncomingMessage(InspectorAction::kSendMessage, session_id, + message); } void InspectorAgentDelegate::EndSession(int session_id) { connected_ = false; - agent_->PostIncomingMessage(session_id, TAG_DISCONNECT); + agent_->PostIncomingMessage(InspectorAction::kEndSession, session_id, ""); } std::vector InspectorAgentDelegate::GetTargetIds() { diff --git a/src/inspector_agent.h b/src/inspector_agent.h index b31c77496b3d70..9cc2fa676d4d13 100644 --- a/src/inspector_agent.h +++ b/src/inspector_agent.h @@ -7,6 +7,8 @@ #error("This header can only be used when inspector is enabled") #endif +#include "node_debug_options.h" + // Forward declaration to break recursive dependency chain with src/env.h. namespace node { class Environment; @@ -31,7 +33,8 @@ class Agent { ~Agent(); // Start the inspector agent thread - bool Start(v8::Platform* platform, const char* path, int port, bool wait); + bool Start(v8::Platform* platform, const char* path, + const DebugOptions& options); // Stop the inspector agent void Stop(); diff --git a/src/inspector_socket_server.cc b/src/inspector_socket_server.cc index 4bd35ae8bed4fb..ee44a69a683690 100644 --- a/src/inspector_socket_server.cc +++ b/src/inspector_socket_server.cc @@ -24,9 +24,9 @@ void Escape(std::string* string) { } } -std::string GetWsUrl(int port, const std::string& id) { +std::string GetWsUrl(const std::string& host, int port, const std::string& id) { char buf[1024]; - snprintf(buf, sizeof(buf), "127.0.0.1:%d/%s", port, id.c_str()); + snprintf(buf, sizeof(buf), "%s:%d/%s", host.c_str(), port, id.c_str()); return buf; } @@ -74,22 +74,29 @@ void OnBufferAlloc(uv_handle_t* handle, size_t len, uv_buf_t* buf) { buf->len = len; } -void PrintDebuggerReadyMessage(int port, const std::vector& ids) { - fprintf(stderr, +void PrintDebuggerReadyMessage(const std::string& host, + int port, + const std::vector& ids, + FILE* out) { + if (out == NULL) { + return; + } + fprintf(out, "Debugger listening on port %d.\n" "Warning: This is an experimental feature " "and could change at any time.\n", port); if (ids.size() == 1) - fprintf(stderr, "To start debugging, open the following URL in Chrome:\n"); + fprintf(out, "To start debugging, open the following URL in Chrome:\n"); if (ids.size() > 1) - fprintf(stderr, "To start debugging, open the following URLs in Chrome:\n"); + fprintf(out, "To start debugging, open the following URLs in Chrome:\n"); for (const std::string& id : ids) { - fprintf(stderr, + fprintf(out, " chrome-devtools://devtools/bundled/inspector.html?" - "experiments=true&v8only=true&ws=%s\n", GetWsUrl(port, id).c_str()); + "experiments=true&v8only=true&ws=%s\n", + GetWsUrl(host, port, id).c_str()); } - fflush(stderr); + fflush(out); } void SendHttpResponse(InspectorSocket* socket, const std::string& response) { @@ -132,6 +139,23 @@ void SendProtocolJson(InspectorSocket* socket) { SendHttpResponse(socket, data); } +int GetPort(uv_tcp_t* socket, int* out_port) { + sockaddr_storage addr; + int len = sizeof(addr); + int err = uv_tcp_getsockname(socket, + reinterpret_cast(&addr), + &len); + if (err != 0) + return err; + int port; + if (addr.ss_family == AF_INET6) + port = reinterpret_cast(&addr)->sin6_port; + else + port = reinterpret_cast(&addr)->sin_port; + *out_port = ntohs(port); + return err; +} + } // namespace @@ -207,12 +231,16 @@ class SocketSession { }; InspectorSocketServer::InspectorSocketServer(SocketServerDelegate* delegate, - int port) : loop_(nullptr), - delegate_(delegate), - port_(port), - server_(uv_tcp_t()), - closer_(nullptr), - next_session_id_(0) { } + const std::string& host, + int port, + FILE* out) : loop_(nullptr), + delegate_(delegate), + host_(host), + port_(port), + server_(uv_tcp_t()), + closer_(nullptr), + next_session_id_(0), + out_(out) { } // static @@ -260,7 +288,7 @@ void InspectorSocketServer::SessionTerminated(int session_id) { delegate_->EndSession(session_id); if (connected_sessions_.empty() && uv_is_active(reinterpret_cast(&server_))) { - PrintDebuggerReadyMessage(port_, delegate_->GetTargetIds()); + PrintDebuggerReadyMessage(host_, port_, delegate_->GetTargetIds(), out_); } } @@ -313,7 +341,7 @@ void InspectorSocketServer::SendListResponse(InspectorSocket* socket) { } } if (!connected) { - std::string address = GetWsUrl(port_, id); + std::string address = GetWsUrl(host_, port_, id); std::ostringstream frontend_url; frontend_url << "chrome-devtools://devtools/bundled"; frontend_url << "/inspector.html?experiments=true&v8only=true&ws="; @@ -329,18 +357,24 @@ bool InspectorSocketServer::Start(uv_loop_t* loop) { loop_ = loop; sockaddr_in addr; uv_tcp_init(loop_, &server_); - uv_ip4_addr("0.0.0.0", port_, &addr); + uv_ip4_addr(host_.c_str(), port_, &addr); int err = uv_tcp_bind(&server_, reinterpret_cast(&addr), 0); + if (err == 0) + err = GetPort(&server_, &port_); if (err == 0) { err = uv_listen(reinterpret_cast(&server_), 1, SocketConnectedCallback); } if (err == 0 && connected_sessions_.empty()) { - PrintDebuggerReadyMessage(port_, delegate_->GetTargetIds()); + PrintDebuggerReadyMessage(host_, port_, delegate_->GetTargetIds(), out_); } if (err != 0 && connected_sessions_.empty()) { - fprintf(stderr, "Unable to open devtools socket: %s\n", uv_strerror(err)); + if (out_ != NULL) { + fprintf(out_, "Starting inspector on %s:%d failed: %s\n", + host_.c_str(), port_, uv_strerror(err)); + fflush(out_); + } uv_close(reinterpret_cast(&server_), nullptr); return false; } diff --git a/src/inspector_socket_server.h b/src/inspector_socket_server.h index 4c139e138f7547..b82d9ee6013a40 100644 --- a/src/inspector_socket_server.h +++ b/src/inspector_socket_server.h @@ -32,11 +32,17 @@ class SocketServerDelegate { class InspectorSocketServer { public: using ServerCallback = void (*)(InspectorSocketServer*); - InspectorSocketServer(SocketServerDelegate* delegate, int port); + InspectorSocketServer(SocketServerDelegate* delegate, + const std::string& host, + int port, + FILE* out = stderr); bool Start(uv_loop_t* loop); void Stop(ServerCallback callback); void Send(int session_id, const std::string& message); void TerminateConnections(ServerCallback callback); + int port() { + return port_; + } private: static bool HandshakeCallback(InspectorSocket* socket, @@ -60,12 +66,14 @@ class InspectorSocketServer { uv_loop_t* loop_; SocketServerDelegate* const delegate_; - const int port_; + const std::string host_; + int port_; std::string path_; uv_tcp_t server_; Closer* closer_; std::map connected_sessions_; int next_session_id_; + FILE* out_; friend class SocketSession; friend class Closer; diff --git a/src/node.cc b/src/node.cc index bd8248b2e3c9b4..3c6b9a731dc2b1 100644 --- a/src/node.cc +++ b/src/node.cc @@ -7,6 +7,7 @@ #include "node_version.h" #include "node_internals.h" #include "node_revert.h" +#include "node_debug_options.h" #if defined HAVE_PERFCTR #include "node_counters.h" @@ -141,17 +142,6 @@ static bool track_heap_objects = false; static const char* eval_string = nullptr; static unsigned int preload_module_count = 0; static const char** preload_modules = nullptr; -#if HAVE_INSPECTOR -static bool use_inspector = false; -#else -static const bool use_inspector = false; -#endif -static bool use_debug_agent = false; -static bool debug_wait_connect = false; -static std::string* debug_host; // coverity[leaked_storage] -static const int default_debugger_port = 5858; -static const int default_inspector_port = 9229; -static int debug_port = -1; static const int v8_default_thread_pool_size = 4; static int v8_thread_pool_size = v8_default_thread_pool_size; static bool prof_process = false; @@ -171,6 +161,14 @@ static const char* icu_data_dir = nullptr; bool no_deprecation = false; #if HAVE_OPENSSL +// use OpenSSL's cert store instead of bundled certs +bool ssl_openssl_cert_store = +#if defined(NODE_OPENSSL_CERT_STORE) + true; +#else + false; +#endif + # if NODE_FIPS_MODE // used by crypto module bool enable_fips_crypto = false; @@ -198,6 +196,8 @@ static uv_async_t dispatch_debug_messages_async; static Mutex node_isolate_mutex; static v8::Isolate* node_isolate; +static node::DebugOptions debug_options; + static struct { #if NODE_USE_V8_PLATFORM void Initialize(int thread_pool_size) { @@ -214,14 +214,12 @@ static struct { platform_ = nullptr; } - bool StartInspector(Environment *env, const char* script_path, - int port, bool wait) { #if HAVE_INSPECTOR - return env->inspector_agent()->Start(platform_, script_path, port, wait); -#else - return true; -#endif // HAVE_INSPECTOR + bool StartInspector(Environment *env, const char* script_path, + const node::DebugOptions& options) { + return env->inspector_agent()->Start(platform_, script_path, options); } +#endif // HAVE_INSPECTOR v8::Platform* platform_; #else // !NODE_USE_V8_PLATFORM @@ -2198,7 +2196,7 @@ static void WaitForInspectorDisconnect(Environment* env) { if (env->inspector_agent()->IsConnected()) { // Restore signal dispositions, the app is done and is no longer // capable of handling signals. -#ifdef __POSIX__ +#if defined(__POSIX__) && !defined(NODE_SHARED_MODE) struct sigaction act; memset(&act, 0, sizeof(act)); for (unsigned nr = 1; nr < kMaxSignal; nr += 1) { @@ -2522,7 +2520,7 @@ void FatalException(Isolate* isolate, if (exit_code) { #if HAVE_INSPECTOR - if (use_inspector) { + if (debug_options.inspector_enabled()) { env->inspector_agent()->FatalException(error, message); } #endif @@ -2923,17 +2921,14 @@ static Local GetFeatures(Environment* env) { static void DebugPortGetter(Local property, const PropertyCallbackInfo& info) { - int port = debug_port; - if (port < 0) - port = use_inspector ? default_inspector_port : default_debugger_port; - info.GetReturnValue().Set(port); + info.GetReturnValue().Set(debug_options.port()); } static void DebugPortSetter(Local property, Local value, const PropertyCallbackInfo& info) { - debug_port = value->Int32Value(); + debug_options.set_port(value->Int32Value()); } @@ -3277,7 +3272,7 @@ void SetupProcessObject(Environment* env, } // --debug-brk - if (debug_wait_connect) { + if (debug_options.wait_for_connect()) { READONLY_PROPERTY(process, "_debugWaitConnect", True(env->isolate())); } @@ -3469,90 +3464,6 @@ void LoadEnvironment(Environment* env) { f->Call(Null(env->isolate()), 1, &arg); } - -static void PrintHelp(); - -static bool ParseDebugOpt(const char* arg) { - const char* port = nullptr; - - if (!strcmp(arg, "--debug")) { - use_debug_agent = true; - } else if (!strncmp(arg, "--debug=", sizeof("--debug=") - 1)) { - use_debug_agent = true; - port = arg + sizeof("--debug=") - 1; - } else if (!strcmp(arg, "--debug-brk")) { - use_debug_agent = true; - debug_wait_connect = true; - } else if (!strncmp(arg, "--debug-brk=", sizeof("--debug-brk=") - 1)) { - use_debug_agent = true; - debug_wait_connect = true; - port = arg + sizeof("--debug-brk=") - 1; - } else if (!strncmp(arg, "--debug-port=", sizeof("--debug-port=") - 1)) { - // XXX(bnoordhuis) Misnomer, configures port and listen address. - port = arg + sizeof("--debug-port=") - 1; -#if HAVE_INSPECTOR - // Specifying both --inspect and --debug means debugging is on, using Chromium - // inspector. - } else if (!strcmp(arg, "--inspect")) { - use_debug_agent = true; - use_inspector = true; - } else if (!strncmp(arg, "--inspect=", sizeof("--inspect=") - 1)) { - use_debug_agent = true; - use_inspector = true; - port = arg + sizeof("--inspect=") - 1; -#else - } else if (!strncmp(arg, "--inspect", sizeof("--inspect") - 1)) { - fprintf(stderr, - "Inspector support is not available with this Node.js build\n"); - return false; -#endif - } else { - return false; - } - - if (port == nullptr) { - return true; - } - - // FIXME(bnoordhuis) Move IPv6 address parsing logic to lib/net.js. - // It seems reasonable to support [address]:port notation - // in net.Server#listen() and net.Socket#connect(). - const size_t port_len = strlen(port); - if (port[0] == '[' && port[port_len - 1] == ']') { - debug_host = new std::string(port + 1, port_len - 2); - return true; - } - - const char* const colon = strrchr(port, ':'); - if (colon == nullptr) { - // Either a port number or a host name. Assume that - // if it's not all decimal digits, it's a host name. - for (size_t n = 0; port[n] != '\0'; n += 1) { - if (port[n] < '0' || port[n] > '9') { - debug_host = new std::string(port); - return true; - } - } - } else { - const bool skip = (colon > port && port[0] == '[' && colon[-1] == ']'); - debug_host = new std::string(port + skip, colon - skip); - } - - char* endptr; - errno = 0; - const char* const digits = colon != nullptr ? colon + 1 : port; - const long result = strtol(digits, &endptr, 10); // NOLINT(runtime/int) - if (errno != 0 || *endptr != '\0' || result < 1024 || result > 65535) { - fprintf(stderr, "Debug port must be in range 1024 to 65535.\n"); - PrintHelp(); - exit(12); - } - - debug_port = static_cast(result); - - return true; -} - static void PrintHelp() { // XXX: If you add an option here, please also add it to doc/node.1 and // doc/api/cli.md @@ -3569,8 +3480,7 @@ static void PrintHelp() { " -r, --require module to preload (option can be repeated)\n" " --no-deprecation silence deprecation warnings\n" " --trace-deprecation show stack traces on deprecations\n" - " --throw-deprecation throw an exception anytime a deprecated " - "function is used\n" + " --throw-deprecation throw an exception on deprecations\n" " --no-warnings silence all process warnings\n" " --trace-warnings show stack traces on process warnings\n" " --trace-sync-io show stack trace when use of sync IO\n" @@ -3585,6 +3495,16 @@ static void PrintHelp() { " --v8-pool-size=num set v8's thread pool size\n" #if HAVE_OPENSSL " --tls-cipher-list=val use an alternative default TLS cipher list\n" + " --use-bundled-ca use bundled CA store" +#if !defined(NODE_OPENSSL_CERT_STORE) + " (default)" +#endif + "\n" + " --use-openssl-ca use OpenSSL's default CA store" +#if defined(NODE_OPENSSL_CERT_STORE) + " (default)" +#endif + "\n" #if NODE_FIPS_MODE " --enable-fips enable FIPS crypto at startup\n" " --force-fips force FIPS crypto (cannot be disabled)\n" @@ -3596,28 +3516,31 @@ static void PrintHelp() { " --icu-data-dir=dir set ICU data load path to dir\n" " (overrides NODE_ICU_DATA)\n" #if !defined(NODE_HAVE_SMALL_ICU) - " note: linked-in ICU data is\n" - " present.\n" + " note: linked-in ICU data is present\n" #endif " --preserve-symlinks preserve symbolic links when resolving\n" - " and caching modules.\n" + " and caching modules\n" #endif "\n" "Environment variables:\n" -#ifdef _WIN32 - "NODE_PATH ';'-separated list of directories\n" -#else - "NODE_PATH ':'-separated list of directories\n" -#endif - " prefixed to the module search path.\n" - "NODE_DISABLE_COLORS set to 1 to disable colors in the REPL\n" + "NODE_DEBUG ','-separated list of core modules that\n" + " should print debug information\n" + "NODE_DISABLE_COLORS set to 1 to disable colors in the REPL\n" + "NODE_EXTRA_CA_CERTS path to additional CA certificates file\n" #if defined(NODE_HAVE_I18N_SUPPORT) - "NODE_ICU_DATA data path for ICU (Intl object) data\n" + "NODE_ICU_DATA data path for ICU (Intl object) data\n" #if !defined(NODE_HAVE_SMALL_ICU) - " (will extend linked-in data)\n" + " (will extend linked-in data)\n" #endif #endif - "NODE_REPL_HISTORY path to the persistent REPL history file\n" + "NODE_NO_WARNINGS set to 1 to silence process warnings\n" +#ifdef _WIN32 + "NODE_PATH ';'-separated list of directories\n" +#else + "NODE_PATH ':'-separated list of directories\n" +#endif + " prefixed to the module search path\n" + "NODE_REPL_HISTORY path to the persistent REPL history file\n" "\n" "Documentation can be found at https://nodejs.org/\n"); } @@ -3666,8 +3589,8 @@ static void ParseArgs(int* argc, const char* const arg = argv[index]; unsigned int args_consumed = 1; - if (ParseDebugOpt(arg)) { - // Done, consumed by ParseDebugOpt(). + if (debug_options.ParseOption(arg)) { + // Done, consumed by DebugOptions::ParseOption(). } else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) { printf("%s\n", NODE_VERSION); exit(0); @@ -3745,6 +3668,10 @@ static void ParseArgs(int* argc, #if HAVE_OPENSSL } else if (strncmp(arg, "--tls-cipher-list=", 18) == 0) { default_cipher_list = arg + 18; + } else if (strncmp(arg, "--use-openssl-ca", 16) == 0) { + ssl_openssl_cert_store = true; + } else if (strncmp(arg, "--use-bundled-ca", 16) == 0) { + ssl_openssl_cert_store = false; #if NODE_FIPS_MODE } else if (strcmp(arg, "--enable-fips") == 0) { enable_fips_crypto = true; @@ -3761,6 +3688,9 @@ static void ParseArgs(int* argc, } else if (strcmp(arg, "--expose-internals") == 0 || strcmp(arg, "--expose_internals") == 0) { // consumed in js + } else if (strcmp(arg, "--") == 0) { + index += 1; + break; } else { // V8 option. Pass through as-is. new_v8_argv[new_v8_argc] = arg; @@ -3809,22 +3739,21 @@ static void DispatchMessagesDebugAgentCallback(Environment* env) { } -static void StartDebug(Environment* env, const char* path, bool wait) { +static void StartDebug(Environment* env, const char* path, + DebugOptions debug_options) { CHECK(!debugger_running); - if (use_inspector) { - debugger_running = v8_platform.StartInspector(env, path, - debug_port >= 0 ? debug_port : default_inspector_port, wait); - } else { +#if HAVE_INSPECTOR + if (debug_options.inspector_enabled()) + debugger_running = v8_platform.StartInspector(env, path, debug_options); +#endif // HAVE_INSPECTOR + if (debug_options.debugger_enabled()) { env->debugger_agent()->set_dispatch_handler( DispatchMessagesDebugAgentCallback); - const char* host = debug_host ? debug_host->c_str() : "127.0.0.1"; - int port = debug_port >= 0 ? debug_port : default_debugger_port; - debugger_running = - env->debugger_agent()->Start(host, port, wait); + debugger_running = env->debugger_agent()->Start(debug_options); if (debugger_running == false) { - fprintf(stderr, "Starting debugger on %s:%d failed\n", host, port); + fprintf(stderr, "Starting debugger on %s:%d failed\n", + debug_options.host_name().c_str(), debug_options.port()); fflush(stderr); - return; } } } @@ -3834,7 +3763,7 @@ static void StartDebug(Environment* env, const char* path, bool wait) { static void EnableDebug(Environment* env) { CHECK(debugger_running); - if (use_inspector) { + if (!debug_options.debugger_enabled()) { return; } @@ -3875,8 +3804,8 @@ static void DispatchDebugMessagesAsyncCallback(uv_async_t* handle) { HandleScope scope(isolate); Environment* env = Environment::GetCurrent(isolate); Context::Scope context_scope(env->context()); - - StartDebug(env, nullptr, false); + debug_options.EnableDebugAgent(DebugAgentType::kDebugger); + StartDebug(env, nullptr, debug_options); EnableDebug(env); } @@ -4130,7 +4059,7 @@ static void DebugEnd(const FunctionCallbackInfo& args) { if (debugger_running) { Environment* env = Environment::GetCurrent(args); #if HAVE_INSPECTOR - if (use_inspector) { + if (debug_options.inspector_enabled()) { env->inspector_agent()->Stop(); } else { #endif @@ -4165,6 +4094,7 @@ inline void PlatformInit() { CHECK_EQ(err, 0); +#ifndef NODE_SHARED_MODE // Restore signal dispositions, the parent process may have changed them. struct sigaction act; memset(&act, 0, sizeof(act)); @@ -4178,6 +4108,7 @@ inline void PlatformInit() { act.sa_handler = (nr == SIGPIPE) ? SIG_IGN : SIG_DFL; CHECK_EQ(0, sigaction(nr, &act, nullptr)); } +#endif // !NODE_SHARED_MODE RegisterSignalHandler(SIGINT, SignalExit, true); RegisterSignalHandler(SIGTERM, SignalExit, true); @@ -4302,7 +4233,7 @@ void Init(int* argc, const char no_typed_array_heap[] = "--typed_array_max_size_in_heap=0"; V8::SetFlagsFromString(no_typed_array_heap, sizeof(no_typed_array_heap) - 1); - if (!use_debug_agent) { + if (!debug_options.debugger_enabled() && !debug_options.inspector_enabled()) { RegisterDebugSignalHandler(); } @@ -4419,11 +4350,14 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data, Environment env(isolate_data, context); env.Start(argc, argv, exec_argc, exec_argv, v8_is_profiling); + bool debug_enabled = + debug_options.debugger_enabled() || debug_options.inspector_enabled(); + // Start debug agent when argv has --debug - if (use_debug_agent) { + if (debug_enabled) { const char* path = argc > 1 ? argv[1] : nullptr; - StartDebug(&env, path, debug_wait_connect); - if (use_inspector && !debugger_running) + StartDebug(&env, path, debug_options); + if (!debugger_running) return 12; // Signal internal error. } @@ -4435,7 +4369,7 @@ inline int Start(Isolate* isolate, IsolateData* isolate_data, env.set_trace_sync_io(trace_sync_io); // Enable debugger - if (use_debug_agent) + if (debug_enabled) EnableDebug(&env); { diff --git a/src/node.h b/src/node.h index 873551fa338a97..1255a4af7f11ce 100644 --- a/src/node.h +++ b/src/node.h @@ -179,9 +179,12 @@ typedef intptr_t ssize_t; namespace node { NODE_EXTERN extern bool no_deprecation; -#if HAVE_OPENSSL && NODE_FIPS_MODE +#if HAVE_OPENSSL +NODE_EXTERN extern bool ssl_openssl_cert_store; +# if NODE_FIPS_MODE NODE_EXTERN extern bool enable_fips_crypto; NODE_EXTERN extern bool force_fips_crypto; +# endif #endif NODE_EXTERN int Start(int argc, char *argv[]); diff --git a/src/node_contextify.cc b/src/node_contextify.cc index fc8aa451347b94..d74b01ea0da371 100644 --- a/src/node_contextify.cc +++ b/src/node_contextify.cc @@ -383,22 +383,19 @@ class ContextifyContext { if (ctx->context_.IsEmpty()) return; - auto attributes = PropertyAttribute::None; bool is_declared = - ctx->global_proxy()->GetRealNamedPropertyAttributes(ctx->context(), - property) - .To(&attributes); - bool read_only = - static_cast(attributes) & - static_cast(PropertyAttribute::ReadOnly); - - if (is_declared && read_only) - return; + ctx->global_proxy()->HasRealNamedProperty(ctx->context(), + property).FromJust(); + bool is_contextual_store = ctx->global_proxy() != args.This(); - if (!is_declared && args.ShouldThrowOnError()) - return; + bool set_property_will_throw = + args.ShouldThrowOnError() && + !is_declared && + is_contextual_store; - ctx->sandbox()->Set(property, value); + if (!set_property_will_throw) { + ctx->sandbox()->Set(property, value); + } } diff --git a/src/node_crypto.cc b/src/node_crypto.cc index 8e1319269e8ed7..fc540923e06b05 100644 --- a/src/node_crypto.cc +++ b/src/node_crypto.cc @@ -123,7 +123,7 @@ const char* const root_certs[] = { std::string extra_root_certs_file; // NOLINT(runtime/string) X509_STORE* root_cert_store; -std::vector* root_certs_vector; +std::vector root_certs_vector; // Just to generate static methods template class SSLWrap; @@ -693,9 +693,7 @@ static int X509_up_ref(X509* cert) { static X509_STORE* NewRootCertStore() { - if (!root_certs_vector) { - root_certs_vector = new std::vector; - + if (root_certs_vector.empty()) { for (size_t i = 0; i < arraysize(root_certs); i++) { BIO* bp = NodeBIO::NewFixed(root_certs[i], strlen(root_certs[i])); X509 *x509 = PEM_read_bio_X509(bp, nullptr, CryptoPemCallback, nullptr); @@ -704,14 +702,18 @@ static X509_STORE* NewRootCertStore() { // Parse errors from the built-in roots are fatal. CHECK_NE(x509, nullptr); - root_certs_vector->push_back(x509); + root_certs_vector.push_back(x509); } } X509_STORE* store = X509_STORE_new(); - for (auto& cert : *root_certs_vector) { - X509_up_ref(cert); - X509_STORE_add_cert(store, cert); + if (ssl_openssl_cert_store) { + X509_STORE_set_default_paths(store); + } else { + for (X509 *cert : root_certs_vector) { + X509_up_ref(cert); + X509_STORE_add_cert(store, cert); + } } return store; @@ -1147,10 +1149,14 @@ void SecureContext::SetTicketKeys(const FunctionCallbackInfo& args) { void SecureContext::SetFreeListLength(const FunctionCallbackInfo& args) { +#if OPENSSL_VERSION_NUMBER < 0x10100000L && !defined(OPENSSL_IS_BORINGSSL) + // |freelist_max_len| was removed in OpenSSL 1.1.0. In that version OpenSSL + // mallocs and frees buffers directly, without the use of a freelist. SecureContext* wrap; ASSIGN_OR_RETURN_UNWRAP(&wrap, args.Holder()); wrap->ctx_->freelist_max_len = args[0]->Int32Value(); +#endif } @@ -3687,8 +3693,8 @@ void Hmac::HmacInit(const FunctionCallbackInfo& args) { bool Hmac::HmacUpdate(const char* data, int len) { if (!initialised_) return false; - HMAC_Update(&ctx_, reinterpret_cast(data), len); - return true; + int r = HMAC_Update(&ctx_, reinterpret_cast(data), len); + return r == 1; } diff --git a/src/node_debug_options.cc b/src/node_debug_options.cc new file mode 100644 index 00000000000000..5681e3d46edaca --- /dev/null +++ b/src/node_debug_options.cc @@ -0,0 +1,144 @@ +#include "node_debug_options.h" + +#include +#include +#include +#include "util.h" + +namespace node { + +namespace { +const int default_debugger_port = 5858; +const int default_inspector_port = 9229; + +inline std::string remove_brackets(const std::string& host) { + if (!host.empty() && host.front() == '[' && host.back() == ']') + return host.substr(1, host.size() - 2); + else + return host; +} + +int parse_and_validate_port(const std::string& port) { + char* endptr; + errno = 0; + const long result = strtol(port.c_str(), &endptr, 10); // NOLINT(runtime/int) + if (errno != 0 || *endptr != '\0'|| result < 1024 || result > 65535) { + fprintf(stderr, "Debug port must be in range 1024 to 65535.\n"); + exit(12); + } + return static_cast(result); +} + +std::pair split_host_port(const std::string& arg) { + // IPv6, no port + std::string host = remove_brackets(arg); + if (host.length() < arg.length()) + return {host, -1}; + + size_t colon = arg.rfind(':'); + if (colon == std::string::npos) { + // Either a port number or a host name. Assume that + // if it's not all decimal digits, it's a host name. + for (char c : arg) { + if (c < '0' || c > '9') { + return {arg, -1}; + } + } + return {"", parse_and_validate_port(arg)}; + } + return std::make_pair(remove_brackets(arg.substr(0, colon)), + parse_and_validate_port(arg.substr(colon + 1))); +} + +} // namespace + +DebugOptions::DebugOptions() : debugger_enabled_(false), +#if HAVE_INSPECTOR + inspector_enabled_(false), +#endif // HAVE_INSPECTOR + wait_connect_(false), http_enabled_(false), + host_name_("127.0.0.1"), port_(-1) { } + +void DebugOptions::EnableDebugAgent(DebugAgentType tool) { + switch (tool) { +#if HAVE_INSPECTOR + case DebugAgentType::kInspector: + inspector_enabled_ = true; + debugger_enabled_ = true; + break; +#endif // HAVE_INSPECTOR + case DebugAgentType::kDebugger: + debugger_enabled_ = true; + break; + case DebugAgentType::kNone: + break; + } +} + +bool DebugOptions::ParseOption(const std::string& option) { + bool enable_inspector = false; + bool has_argument = false; + std::string option_name; + std::string argument; + + auto pos = option.find("="); + if (pos == std::string::npos) { + option_name = option; + } else { + has_argument = true; + option_name = option.substr(0, pos); + argument = option.substr(pos + 1); + } + + if (option_name == "--debug") { + debugger_enabled_ = true; + } else if (option_name == "--debug-brk") { + debugger_enabled_ = true; + wait_connect_ = true; + } else if (option_name == "--inspect") { + debugger_enabled_ = true; + enable_inspector = true; + } else if (option_name != "--debug-port" || !has_argument) { + return false; + } + + if (enable_inspector) { +#if HAVE_INSPECTOR + inspector_enabled_ = true; +#else + fprintf(stderr, + "Inspector support is not available with this Node.js build\n"); + return false; +#endif + } + + if (!has_argument) { + return true; + } + + // FIXME(bnoordhuis) Move IPv6 address parsing logic to lib/net.js. + // It seems reasonable to support [address]:port notation + // in net.Server#listen() and net.Socket#connect(). + std::pair host_port = split_host_port(argument); + if (!host_port.first.empty()) { + host_name_ = host_port.first; + } + if (host_port.second >= 0) { + port_ = host_port.second; + } + return true; +} + +int DebugOptions::port() const { + int port = port_; + if (port < 0) { +#if HAVE_INSPECTOR + port = inspector_enabled_ ? default_inspector_port : default_debugger_port; +#else + port = default_debugger_port; +#endif // HAVE_INSPECTOR + } + return port; +} + +} // namespace node diff --git a/src/node_debug_options.h b/src/node_debug_options.h new file mode 100644 index 00000000000000..d03bdb15497bbf --- /dev/null +++ b/src/node_debug_options.h @@ -0,0 +1,51 @@ +#ifndef SRC_NODE_DEBUG_OPTIONS_H_ +#define SRC_NODE_DEBUG_OPTIONS_H_ + +#include + +// Forward declaration to break recursive dependency chain with src/env.h. +namespace node { + +enum class DebugAgentType { + kNone, + kDebugger, +#if HAVE_INSPECTOR + kInspector +#endif // HAVE_INSPECTOR +}; + +class DebugOptions { + public: + DebugOptions(); + bool ParseOption(const std::string& option); + bool debugger_enabled() const { + return debugger_enabled_ && !inspector_enabled(); + } + bool inspector_enabled() const { +#if HAVE_INSPECTOR + return inspector_enabled_; +#else + return false; +#endif // HAVE_INSPECTOR + } + void EnableDebugAgent(DebugAgentType type); + bool ToolsServerEnabled(); + bool wait_for_connect() const { return wait_connect_; } + std::string host_name() const { return host_name_; } + int port() const; + void set_port(int port) { port_ = port; } + + private: + bool debugger_enabled_; +#if HAVE_INSPECTOR + bool inspector_enabled_; +#endif // HAVE_INSPECTOR + bool wait_connect_; + bool http_enabled_; + std::string host_name_; + int port_; +}; + +} // namespace node + +#endif // SRC_NODE_DEBUG_OPTIONS_H_ diff --git a/src/node_os.cc b/src/node_os.cc index f8b53e45d8e669..97b1a1d08da6ed 100644 --- a/src/node_os.cc +++ b/src/node_os.cc @@ -69,7 +69,7 @@ static void GetOSType(const FunctionCallbackInfo& args) { } rval = info.sysname; #else // __MINGW32__ - rval ="Windows_NT"; + rval = "Windows_NT"; #endif // __POSIX__ args.GetReturnValue().Set(OneByteString(env->isolate(), rval)); diff --git a/src/node_url.cc b/src/node_url.cc index 11a03ea5211a89..7f21051c54e5ac 100644 --- a/src/node_url.cc +++ b/src/node_url.cc @@ -96,50 +96,50 @@ using v8::Value; namespace url { #if defined(NODE_HAVE_I18N_SUPPORT) - static int ToUnicode(std::string* input, std::string* output) { + static bool ToUnicode(std::string* input, std::string* output) { MaybeStackBuffer buf; if (i18n::ToUnicode(&buf, input->c_str(), input->length()) < 0) - return -1; + return false; output->assign(*buf, buf.length()); - return 0; + return true; } - static int ToASCII(std::string* input, std::string* output) { + static bool ToASCII(std::string* input, std::string* output) { MaybeStackBuffer buf; if (i18n::ToASCII(&buf, input->c_str(), input->length()) < 0) - return -1; + return false; output->assign(*buf, buf.length()); - return 0; + return true; } // Unfortunately there's not really a better way to do this. // Iterate through each encoded codepoint and verify that // it is a valid unicode codepoint. - static int IsValidUTF8(std::string* input) { + static bool IsValidUTF8(std::string* input) { const char* p = input->c_str(); int32_t len = input->length(); for (int32_t i = 0; i < len;) { UChar32 c; U8_NEXT_UNSAFE(p, i, c); if (!U_IS_UNICODE_CHAR(c)) - return -1; + return false; } - return 0; + return true; } #else // Intentional non-ops if ICU is not present. - static int ToUnicode(std::string* input, std::string* output) { - output->reserve(input->length()); - *output = input->c_str(); + static bool ToUnicode(std::string* input, std::string* output) { + *output = *input; + return true; } - static int ToASCII(std::string* input, std::string* output) { - output->reserve(input->length()); - *output = input->c_str(); + static bool ToASCII(std::string* input, std::string* output) { + *output = *input; + return true; } - static int IsValidUTF8(std::string* input) { - return 0; + static bool IsValidUTF8(std::string* input) { + return true; } #endif @@ -381,11 +381,11 @@ namespace url { // If there are any invalid UTF8 byte sequences, we have to fail. // Unfortunately this means iterating through the string and checking // each decoded codepoint. - if (IsValidUTF8(&decoded) < 0) + if (!IsValidUTF8(&decoded)) goto end; // Then we have to punycode toASCII - if (ToASCII(&decoded, &decoded) < 0) + if (!ToASCII(&decoded, &decoded)) goto end; // If any of the following characters are still present, we have to fail @@ -405,7 +405,7 @@ namespace url { goto end; // If the unicode flag is set, run the result through punycode ToUnicode - if (unicode && ToUnicode(&decoded, &decoded) < 0) + if (unicode && !ToUnicode(&decoded, &decoded)) goto end; // It's not an IPv4 or IPv6 address, it must be a domain @@ -499,17 +499,17 @@ namespace url { return host->type; } - static int ParseHost(std::string* input, - std::string* output, - bool unicode = false) { + static bool ParseHost(std::string* input, + std::string* output, + bool unicode = false) { if (input->length() == 0) - return 0; + return true; url_host host{{""}, HOST_TYPE_DOMAIN}; ParseHost(&host, input->c_str(), input->length(), unicode); if (host.type == HOST_TYPE_FAILED) - return -1; + return false; WriteHost(&host, output); - return 0; + return true; } static inline void Copy(Isolate* isolate, @@ -636,8 +636,8 @@ namespace url { const char* input, const size_t len, enum url_parse_state override, - Local base_obj, - Local context_obj, + Local base_obj, + Local context_obj, Local cb) { Isolate* isolate = env->isolate(); Local context = env->context(); @@ -654,9 +654,9 @@ namespace url { struct url_data base; struct url_data url; if (context_obj->IsObject()) - HarvestContext(env, &url, context_obj); + HarvestContext(env, &url, context_obj.As()); if (has_base) - HarvestBase(env, &base, base_obj); + HarvestBase(env, &base, base_obj.As()); std::string buffer; url.scheme.reserve(len); @@ -996,7 +996,7 @@ namespace url { if (special && buffer.size() == 0) URL_FAILED() SET_HAVE_HOST() - if (ParseHost(&buffer, &url.host) < 0) + if (!ParseHost(&buffer, &url.host)) URL_FAILED() buffer.clear(); state = kPort; @@ -1011,7 +1011,7 @@ namespace url { if (special && buffer.size() == 0) URL_FAILED() SET_HAVE_HOST() - if (ParseHost(&buffer, &url.host) < 0) + if (!ParseHost(&buffer, &url.host)) URL_FAILED() buffer.clear(); state = kPathStart; @@ -1161,7 +1161,7 @@ namespace url { } else { if (buffer != "localhost") { SET_HAVE_HOST() - if (ParseHost(&buffer, &url.host) < 0) + if (!ParseHost(&buffer, &url.host)) URL_FAILED() } buffer.clear(); @@ -1214,12 +1214,7 @@ namespace url { state = kFragment; } } else { - if (ch == '%' && p[1] == '2' && TO_LOWER(p[2]) == 'e') { - buffer += '.'; - p += 2; - } else { - AppendOrEscape(&buffer, ch, DefaultEncodeSet); - } + AppendOrEscape(&buffer, ch, DefaultEncodeSet); } break; case kCannotBeBase: @@ -1326,8 +1321,8 @@ namespace url { Parse(env, args.This(), *input, input.length(), override, - args[2].As(), - args[3].As(), + args[2], + args[3], args[4].As()); } diff --git a/src/node_v8.cc b/src/node_v8.cc index a033c48a7c98be..7059922607089d 100644 --- a/src/node_v8.cc +++ b/src/node_v8.cc @@ -57,8 +57,8 @@ void UpdateHeapStatisticsArrayBuffer(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); HeapStatistics s; env->isolate()->GetHeapStatistics(&s); - uint32_t* const buffer = env->heap_statistics_buffer(); -#define V(index, name, _) buffer[index] = static_cast(s.name()); + double* const buffer = env->heap_statistics_buffer(); +#define V(index, name, _) buffer[index] = static_cast(s.name()); HEAP_STATISTICS_PROPERTIES(V) #undef V } @@ -68,13 +68,13 @@ void UpdateHeapSpaceStatisticsBuffer(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); HeapSpaceStatistics s; Isolate* const isolate = env->isolate(); - uint32_t* buffer = env->heap_space_statistics_buffer(); + double* buffer = env->heap_space_statistics_buffer(); for (size_t i = 0; i < number_of_heap_spaces; i++) { isolate->GetHeapSpaceStatistics(&s, i); size_t const property_offset = i * kHeapSpaceStatisticsPropertiesCount; #define V(index, name, _) buffer[property_offset + index] = \ - static_cast(s.name()); + static_cast(s.name()); HEAP_SPACE_STATISTICS_PROPERTIES(V) #undef V } @@ -103,7 +103,7 @@ void InitializeV8Bindings(Local target, "updateHeapStatisticsArrayBuffer", UpdateHeapStatisticsArrayBuffer); - env->set_heap_statistics_buffer(new uint32_t[kHeapStatisticsPropertiesCount]); + env->set_heap_statistics_buffer(new double[kHeapStatisticsPropertiesCount]); const size_t heap_statistics_buffer_byte_length = sizeof(*env->heap_statistics_buffer()) * kHeapStatisticsPropertiesCount; @@ -149,7 +149,7 @@ void InitializeV8Bindings(Local target, UpdateHeapSpaceStatisticsBuffer); env->set_heap_space_statistics_buffer( - new uint32_t[kHeapSpaceStatisticsPropertiesCount * number_of_heap_spaces]); + new double[kHeapSpaceStatisticsPropertiesCount * number_of_heap_spaces]); const size_t heap_space_statistics_buffer_byte_length = sizeof(*env->heap_space_statistics_buffer()) * diff --git a/src/node_version.h b/src/node_version.h index 843096c34cb9c0..4eb86e8f1f2da7 100644 --- a/src/node_version.h +++ b/src/node_version.h @@ -2,7 +2,7 @@ #define SRC_NODE_VERSION_H_ #define NODE_MAJOR_VERSION 7 -#define NODE_MINOR_VERSION 4 +#define NODE_MINOR_VERSION 5 #define NODE_PATCH_VERSION 1 #define NODE_VERSION_IS_RELEASE 0 diff --git a/src/pipe_wrap.cc b/src/pipe_wrap.cc index 8fd2f8f5f3bbce..5f47dadddb4d96 100644 --- a/src/pipe_wrap.cc +++ b/src/pipe_wrap.cc @@ -53,7 +53,11 @@ void PipeWrap::Initialize(Local target, env->SetProtoMethod(t, "ref", HandleWrap::Ref); env->SetProtoMethod(t, "hasRef", HandleWrap::HasRef); +#ifdef _WIN32 StreamWrap::AddMethods(env, t); +#else + StreamWrap::AddMethods(env, t, StreamBase::kFlagHasWritev); +#endif env->SetProtoMethod(t, "bind", Bind); env->SetProtoMethod(t, "listen", Listen); diff --git a/test/.eslintrc b/test/.eslintrc deleted file mode 100644 index 90bf5f6d88d4e5..00000000000000 --- a/test/.eslintrc +++ /dev/null @@ -1,6 +0,0 @@ -## Test-specific linter rules - -rules: - ## common module is mandatory in tests - required-modules: [2, common] - prefer-assert-methods: 2 diff --git a/test/.eslintrc.yaml b/test/.eslintrc.yaml new file mode 100644 index 00000000000000..e76bd632e6927c --- /dev/null +++ b/test/.eslintrc.yaml @@ -0,0 +1,13 @@ +## Test-specific linter rules + +rules: + # ECMAScript 6 + # http://eslint.org/docs/rules/#ecmascript-6 + no-var: 2 + prefer-const: 2 + + # Custom rules in tools/eslint-rules + prefer-assert-iferror: 2 + prefer-assert-methods: 2 + ## common module is mandatory in tests + required-modules: [2, common] diff --git a/test/README.md b/test/README.md index 8d8cec44919720..94f77eda5148f2 100644 --- a/test/README.md +++ b/test/README.md @@ -163,6 +163,13 @@ A stream to push an array into a REPL Blocks for `time` amount of time. +### canCreateSymLink +API to indicate whether the current running process can create +symlinks. On Windows, this returns false if the process running +doesn't have privileges to create symlinks (specifically +[SeCreateSymbolicLinkPrivilege](https://msdn.microsoft.com/en-us/library/windows/desktop/bb530716(v=vs.85).aspx)). +On non-Windows platforms, this currently returns true. + ### ddCommand(filename, kilobytes) * return [<Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) @@ -366,7 +373,7 @@ Synchronous version of `spawnPwd`. ### tmpDir * return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) -Path to the 'tmp' directory. +The realpath of the 'tmp' directory. ### tmpDirName * return [<String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) diff --git a/test/addons/async-hello-world/test.js b/test/addons/async-hello-world/test.js index 7c27382c1c60f4..a6aa8aa20fffbc 100644 --- a/test/addons/async-hello-world/test.js +++ b/test/addons/async-hello-world/test.js @@ -1,6 +1,6 @@ 'use strict'; const common = require('../../common'); -var assert = require('assert'); +const assert = require('assert'); const binding = require(`./build/${common.buildType}/binding`); binding(5, common.mustCall(function(err, val) { diff --git a/test/addons/buffer-free-callback/test.js b/test/addons/buffer-free-callback/test.js index 8dbc2d57725c56..d25130a905ac90 100644 --- a/test/addons/buffer-free-callback/test.js +++ b/test/addons/buffer-free-callback/test.js @@ -5,8 +5,8 @@ const common = require('../../common'); const binding = require(`./build/${common.buildType}/binding`); function check(size, alignment, offset) { - var buf = binding.alloc(size, alignment, offset); - var slice = buf.slice(size >>> 1); + let buf = binding.alloc(size, alignment, offset); + let slice = buf.slice(size >>> 1); buf = null; binding.check(slice); diff --git a/test/addons/hello-world-function-export/test.js b/test/addons/hello-world-function-export/test.js index 74ea66c79c548c..173cf5428e086f 100644 --- a/test/addons/hello-world-function-export/test.js +++ b/test/addons/hello-world-function-export/test.js @@ -1,6 +1,6 @@ 'use strict'; const common = require('../../common'); -var assert = require('assert'); +const assert = require('assert'); const binding = require(`./build/${common.buildType}/binding`); assert.strictEqual(binding(), 'world'); console.log('binding.hello() =', binding()); diff --git a/test/addons/hello-world/test.js b/test/addons/hello-world/test.js index 32066388efe6cb..b0148e9d9e9014 100644 --- a/test/addons/hello-world/test.js +++ b/test/addons/hello-world/test.js @@ -1,6 +1,6 @@ 'use strict'; const common = require('../../common'); -var assert = require('assert'); +const assert = require('assert'); const binding = require(`./build/${common.buildType}/binding`); assert.strictEqual(binding.hello(), 'world'); console.log('binding.hello() =', binding.hello()); diff --git a/test/addons/load-long-path/test.js b/test/addons/load-long-path/test.js index b17942b45a6f34..73d85a75a097a2 100644 --- a/test/addons/load-long-path/test.js +++ b/test/addons/load-long-path/test.js @@ -14,9 +14,9 @@ common.refreshTmpDir(); // make a path that is more than 260 chars long. // Any given folder cannot have a name longer than 260 characters, // so create 10 nested folders each with 30 character long names. -var addonDestinationDir = path.resolve(common.tmpDir); +let addonDestinationDir = path.resolve(common.tmpDir); -for (var i = 0; i < 10; i++) { +for (let i = 0; i < 10; i++) { addonDestinationDir = path.join(addonDestinationDir, 'x'.repeat(30)); fs.mkdirSync(addonDestinationDir); } @@ -28,10 +28,10 @@ const addonPath = path.join(__dirname, const addonDestinationPath = path.join(addonDestinationDir, 'binding.node'); // Copy binary to long path destination -var contents = fs.readFileSync(addonPath); +const contents = fs.readFileSync(addonPath); fs.writeFileSync(addonDestinationPath, contents); // Attempt to load at long path destination -var addon = require(addonDestinationPath); -assert.notEqual(addon, null); +const addon = require(addonDestinationPath); +assert.notStrictEqual(addon, null); assert.strictEqual(addon.hello(), 'world'); diff --git a/test/addons/make-callback-recurse/test.js b/test/addons/make-callback-recurse/test.js index 0145a142e40f09..46b1327d7dedac 100644 --- a/test/addons/make-callback-recurse/test.js +++ b/test/addons/make-callback-recurse/test.js @@ -65,7 +65,7 @@ assert.throws(function() { results.push(2); setImmediate(common.mustCall(function() { - for (var i = 0; i < results.length; i++) { + for (let i = 0; i < results.length; i++) { assert.strictEqual(results[i], i, `verifyExecutionOrder(${arg}) results: ${results}`); } diff --git a/test/addons/repl-domain-abort/test.js b/test/addons/repl-domain-abort/test.js index 5591b4f2b38e90..95536f99711324 100644 --- a/test/addons/repl-domain-abort/test.js +++ b/test/addons/repl-domain-abort/test.js @@ -1,30 +1,30 @@ 'use strict'; -var common = require('../../common'); -var assert = require('assert'); -var repl = require('repl'); -var stream = require('stream'); -var path = require('path'); -var buildType = process.config.target_defaults.default_configuration; -var buildPath = path.join(__dirname, 'build', buildType, 'binding'); +const common = require('../../common'); +const assert = require('assert'); +const repl = require('repl'); +const stream = require('stream'); +const path = require('path'); +const buildType = process.config.target_defaults.default_configuration; +let buildPath = path.join(__dirname, 'build', buildType, 'binding'); // On Windows, escape backslashes in the path before passing it to REPL. if (common.isWindows) buildPath = buildPath.replace(/\\/g, '/'); -var cb_ran = false; +let cb_ran = false; process.on('exit', function() { assert(cb_ran); console.log('ok'); }); -var lines = [ +const lines = [ // This line shouldn't cause an assertion error. 'require(\'' + buildPath + '\')' + // Log output to double check callback ran. '.method(function() { console.log(\'cb_ran\'); });', ]; -var dInput = new stream.Readable(); -var dOutput = new stream.Writable(); +const dInput = new stream.Readable(); +const dOutput = new stream.Writable(); dInput._read = function _read(size) { while (lines.length > 0 && this.push(lines.shift())); @@ -38,7 +38,7 @@ dOutput._write = function _write(chunk, encoding, cb) { cb(); }; -var options = { +const options = { input: dInput, output: dOutput, terminal: false, diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js index 2ce695852e25ae..5dd727f8ffddd3 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-at-max.js @@ -14,8 +14,9 @@ if (!common.enoughTestMem) { return; } +let buf; try { - var buf = Buffer.allocUnsafe(kStringMaxLength); + buf = Buffer.allocUnsafe(kStringMaxLength); } catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Array buffer allocation failed') throw (e); diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js index 4be525d79fa39e..2466c8ec42ed57 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-ascii.js @@ -14,8 +14,9 @@ if (!common.enoughTestMem) { // v8::String::kMaxLength defined in v8.h const kStringMaxLength = process.binding('buffer').kStringMaxLength; +let buf; try { - var buf = Buffer.allocUnsafe(kStringMaxLength + 1); + buf = Buffer.allocUnsafe(kStringMaxLength + 1); } catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Array buffer allocation failed') throw (e); diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js index 47426bf6352bbb..16f0f5392e5206 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-base64.js @@ -14,8 +14,9 @@ if (!common.enoughTestMem) { // v8::String::kMaxLength defined in v8.h const kStringMaxLength = process.binding('buffer').kStringMaxLength; +let buf; try { - var buf = Buffer.allocUnsafe(kStringMaxLength + 1); + buf = Buffer.allocUnsafe(kStringMaxLength + 1); } catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Array buffer allocation failed') throw (e); diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js index 51324a3f337731..1028706b1d1aa9 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-binary.js @@ -14,8 +14,9 @@ if (!common.enoughTestMem) { // v8::String::kMaxLength defined in v8.h const kStringMaxLength = process.binding('buffer').kStringMaxLength; +let buf; try { - var buf = Buffer.allocUnsafe(kStringMaxLength + 1); + buf = Buffer.allocUnsafe(kStringMaxLength + 1); } catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Array buffer allocation failed') throw (e); @@ -33,7 +34,7 @@ assert.throws(function() { buf.toString('latin1'); }, /"toString\(\)" failed/); -var maxString = buf.toString('latin1', 1); +let maxString = buf.toString('latin1', 1); assert.strictEqual(maxString.length, kStringMaxLength); // Free the memory early instead of at the end of the next assignment maxString = undefined; diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js index ae6966d0545194..caf6112011e2a8 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-hex.js @@ -14,8 +14,9 @@ if (!common.enoughTestMem) { // v8::String::kMaxLength defined in v8.h const kStringMaxLength = process.binding('buffer').kStringMaxLength; +let buf; try { - var buf = Buffer.allocUnsafe(kStringMaxLength + 1); + buf = Buffer.allocUnsafe(kStringMaxLength + 1); } catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Array buffer allocation failed') throw (e); diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js index cea175aa93ab5c..4d3199a033e6d5 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-1-utf8.js @@ -14,8 +14,9 @@ if (!common.enoughTestMem) { // v8::String::kMaxLength defined in v8.h const kStringMaxLength = process.binding('buffer').kStringMaxLength; +let buf; try { - var buf = Buffer.allocUnsafe(kStringMaxLength + 1); + buf = Buffer.allocUnsafe(kStringMaxLength + 1); } catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Array buffer allocation failed') throw (e); diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js index 0fab606e4663ec..786d0b679895e1 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max-by-2.js @@ -14,8 +14,9 @@ if (!common.enoughTestMem) { // v8::String::kMaxLength defined in v8.h const kStringMaxLength = process.binding('buffer').kStringMaxLength; +let buf; try { - var buf = Buffer.allocUnsafe(kStringMaxLength + 2); + buf = Buffer.allocUnsafe(kStringMaxLength + 2); } catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Array buffer allocation failed') throw (e); diff --git a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js index f984179525abeb..36b0d4174a030b 100644 --- a/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js +++ b/test/addons/stringbytes-external-exceed-max/test-stringbytes-external-exceed-max.js @@ -14,8 +14,9 @@ if (!common.enoughTestMem) { // v8::String::kMaxLength defined in v8.h const kStringMaxLength = process.binding('buffer').kStringMaxLength; +let buf; try { - var buf = Buffer.allocUnsafe(kStringMaxLength * 2 + 2); + buf = Buffer.allocUnsafe(kStringMaxLength * 2 + 2); } catch (e) { // If the exception is not due to memory confinement then rethrow it. if (e.message !== 'Array buffer allocation failed') throw (e); diff --git a/test/cctest/test_inspector_socket_server.cc b/test/cctest/test_inspector_socket_server.cc index 2bbc3811390fe6..6fe8a7548fd4a5 100644 --- a/test/cctest/test_inspector_socket_server.cc +++ b/test/cctest/test_inspector_socket_server.cc @@ -6,9 +6,10 @@ #include #include -static const int PORT = 9229; static uv_loop_t loop; +static const char HOST[] = "127.0.0.1"; + static const char CLIENT_CLOSE_FRAME[] = "\x88\x80\x2D\x0E\x1E\xFA"; static const char SERVER_CLOSE_FRAME[] = "\x88\x00"; @@ -70,7 +71,7 @@ class Timeout { class InspectorSocketServerTest : public ::testing::Test { protected: void SetUp() override { - uv_loop_init(&loop); + EXPECT_EQ(0, uv_loop_init(&loop)); } void TearDown() override { @@ -165,7 +166,7 @@ class SocketWrapper { contents_.clear(); uv_tcp_init(loop_, &socket_); sockaddr_in addr; - uv_ip4_addr(host.c_str(), PORT, &addr); + uv_ip4_addr(host.c_str(), port, &addr); int err = uv_tcp_connect(&connect_, &socket_, reinterpret_cast(&addr), Connected_); @@ -183,7 +184,7 @@ class SocketWrapper { contents_.clear(); uv_tcp_init(loop_, &socket_); sockaddr_in addr; - uv_ip4_addr(host.c_str(), PORT, &addr); + uv_ip4_addr(host.c_str(), port, &addr); int err = uv_tcp_connect(&connect_, &socket_, reinterpret_cast(&addr), ConnectionMustFail_); @@ -250,7 +251,7 @@ class SocketWrapper { } static void Connected_(uv_connect_t* connect, int status) { - EXPECT_EQ(0, status); + EXPECT_EQ(0, status) << "Unable to connect: " << uv_strerror(status); SocketWrapper* wrapper = node::ContainerOf(&SocketWrapper::connect_, connect); wrapper->connected_ = true; @@ -300,9 +301,9 @@ class SocketWrapper { class ServerHolder { public: template - ServerHolder(Delegate* delegate, int port) + ServerHolder(Delegate* delegate, int port, FILE* out = NULL) : closed(false), paused(false), sessions_terminated(false), - server_(delegate, port) { + server_(delegate, HOST, port, out) { delegate->Connect(&server_); } @@ -310,6 +311,10 @@ class ServerHolder { return &server_; } + int port() { + return server_.port(); + } + static void CloseCallback(InspectorSocketServer* server) { ServerHolder* holder = node::ContainerOf(&ServerHolder::server_, server); holder->closed = true; @@ -359,7 +364,7 @@ class ServerDelegateNoTargets : public SocketServerDelegate { static void TestHttpRequest(int port, const std::string& path, const std::string& expected_body) { SocketWrapper socket(&loop); - socket.Connect("0.0.0.0", port); + socket.Connect(HOST, port); socket.TestHttpRequest(path, expected_body); socket.Close(); } @@ -377,12 +382,12 @@ static const std::string WsHandshakeRequest(const std::string& target_id) { TEST_F(InspectorSocketServerTest, InspectorSessions) { TestInspectorServerDelegate delegate; - ServerHolder server(&delegate, PORT); + ServerHolder server(&delegate, 0); ASSERT_TRUE(server->Start(&loop)); SocketWrapper well_behaved_socket(&loop); // Regular connection - well_behaved_socket.Connect("0.0.0.0", PORT); + well_behaved_socket.Connect(HOST, server.port()); well_behaved_socket.Write(WsHandshakeRequest(MAIN_TARGET_ID)); well_behaved_socket.Expect(WS_HANDSHAKE_RESPONSE); @@ -405,7 +410,7 @@ TEST_F(InspectorSocketServerTest, InspectorSessions) { // Declined connection SocketWrapper declined_target_socket(&loop); - declined_target_socket.Connect("127.0.0.1", PORT); + declined_target_socket.Connect(HOST, server.port()); declined_target_socket.Write(WsHandshakeRequest(UNCONNECTABLE_TARGET_ID)); declined_target_socket.Expect("HTTP/1.0 400 Bad Request"); declined_target_socket.ExpectEOF(); @@ -414,7 +419,7 @@ TEST_F(InspectorSocketServerTest, InspectorSessions) { // Bogus target - start session callback should not even be invoked SocketWrapper bogus_target_socket(&loop); - bogus_target_socket.Connect("127.0.0.1", PORT); + bogus_target_socket.Connect(HOST, server.port()); bogus_target_socket.Write(WsHandshakeRequest("bogus_target")); bogus_target_socket.Expect("HTTP/1.0 400 Bad Request"); bogus_target_socket.ExpectEOF(); @@ -423,7 +428,7 @@ TEST_F(InspectorSocketServerTest, InspectorSessions) { // Drop connection (no proper close frames) SocketWrapper dropped_connection_socket(&loop); - dropped_connection_socket.Connect("127.0.0.1", PORT); + dropped_connection_socket.Connect(HOST, server.port()); dropped_connection_socket.Write(WsHandshakeRequest(MAIN_TARGET_ID)); dropped_connection_socket.Expect(WS_HANDSHAKE_RESPONSE); @@ -437,7 +442,7 @@ TEST_F(InspectorSocketServerTest, InspectorSessions) { // Reconnect regular connection SocketWrapper stays_till_termination_socket(&loop); - stays_till_termination_socket.Connect("127.0.0.1", PORT); + stays_till_termination_socket.Connect(HOST, server.port()); stays_till_termination_socket.Write(WsHandshakeRequest(MAIN_TARGET_ID)); stays_till_termination_socket.Expect(WS_HANDSHAKE_RESPONSE); @@ -464,7 +469,7 @@ TEST_F(InspectorSocketServerTest, InspectorSessions) { TEST_F(InspectorSocketServerTest, ServerDoesNothing) { TestInspectorServerDelegate delegate; - ServerHolder server(&delegate, PORT); + ServerHolder server(&delegate, 0); ASSERT_TRUE(server->Start(&loop)); server->Stop(ServerHolder::CloseCallback); @@ -474,14 +479,14 @@ TEST_F(InspectorSocketServerTest, ServerDoesNothing) { TEST_F(InspectorSocketServerTest, ServerWithoutTargets) { ServerDelegateNoTargets delegate; - ServerHolder server(&delegate, PORT); + ServerHolder server(&delegate, 0); ASSERT_TRUE(server->Start(&loop)); - TestHttpRequest(PORT, "/json/list", "[ ]"); - TestHttpRequest(PORT, "/json", "[ ]"); + TestHttpRequest(server.port(), "/json/list", "[ ]"); + TestHttpRequest(server.port(), "/json", "[ ]"); // Declined connection SocketWrapper socket(&loop); - socket.Connect("0.0.0.0", PORT); + socket.Connect(HOST, server.port()); socket.Write(WsHandshakeRequest(UNCONNECTABLE_TARGET_ID)); socket.Expect("HTTP/1.0 400 Bad Request"); socket.ExpectEOF(); @@ -492,9 +497,9 @@ TEST_F(InspectorSocketServerTest, ServerWithoutTargets) { TEST_F(InspectorSocketServerTest, ServerCannotStart) { ServerDelegateNoTargets delegate1, delegate2; - ServerHolder server1(&delegate1, PORT); + ServerHolder server1(&delegate1, 0); ASSERT_TRUE(server1->Start(&loop)); - ServerHolder server2(&delegate2, PORT); + ServerHolder server2(&delegate2, server1.port()); ASSERT_FALSE(server2->Start(&loop)); server1->Stop(ServerHolder::CloseCallback); server1->TerminateConnections(ServerHolder::ConnectionsTerminated); @@ -506,10 +511,10 @@ TEST_F(InspectorSocketServerTest, ServerCannotStart) { TEST_F(InspectorSocketServerTest, StoppingServerDoesNotKillConnections) { ServerDelegateNoTargets delegate; - ServerHolder server(&delegate, PORT); + ServerHolder server(&delegate, 0); ASSERT_TRUE(server->Start(&loop)); SocketWrapper socket1(&loop); - socket1.Connect("0.0.0.0", PORT); + socket1.Connect(HOST, server.port()); socket1.TestHttpRequest("/json/list", "[ ]"); server->Stop(ServerHolder::CloseCallback); SPIN_WHILE(!server.closed); diff --git a/test/common.js b/test/common.js index 0fff06bfc0944d..05ef4c9d682c0d 100644 --- a/test/common.js +++ b/test/common.js @@ -8,9 +8,10 @@ const child_process = require('child_process'); const stream = require('stream'); const util = require('util'); const Timer = process.binding('timer_wrap').Timer; +const execSync = require('child_process').execSync; const testRoot = process.env.NODE_TEST_DIR ? - path.resolve(process.env.NODE_TEST_DIR) : __dirname; + fs.realpathSync(process.env.NODE_TEST_DIR) : __dirname; exports.fixturesDir = path.join(__dirname, 'fixtures'); exports.tmpDirName = 'tmp'; @@ -202,6 +203,28 @@ exports.hasIPv6 = Object.keys(ifaces).some(function(name) { }); }); +/* + * Check that when running a test with + * `$node --abort-on-uncaught-exception $file child` + * the process aborts. + */ +exports.childShouldThrowAndAbort = function() { + let testCmd = ''; + if (!exports.isWindows) { + // Do not create core files, as it can take a lot of disk space on + // continuous testing and developers' machines + testCmd += 'ulimit -c 0 && '; + } + testCmd += `${process.argv[0]} --abort-on-uncaught-exception `; + testCmd += `${process.argv[1]} child`; + const child = child_process.exec(testCmd); + child.on('exit', function onExit(exitCode, signal) { + const errMsg = 'Test should have aborted ' + + `but instead exited with exit code ${exitCode}` + + ` and signal ${signal}`; + assert(exports.nodeProcessAborted(exitCode, signal), errMsg); + }); +}; exports.ddCommand = function(filename, kilobytes) { if (exports.isWindows) { @@ -398,7 +421,10 @@ function runCallChecks(exitCode) { exports.mustCall = function(fn, expected) { - if (typeof expected !== 'number') expected = 1; + if (expected === undefined) + expected = 1; + else if (typeof expected !== 'number') + throw new TypeError(`Invalid expected value: ${expected}`); const context = { expected: expected, @@ -435,6 +461,34 @@ exports.fileExists = function(pathname) { } }; +exports.canCreateSymLink = function() { + // On Windows, creating symlinks requires admin privileges. + // We'll only try to run symlink test if we have enough privileges. + // On other platforms, creating symlinks shouldn't need admin privileges + if (exports.isWindows) { + // whoami.exe needs to be the one from System32 + // If unix tools are in the path, they can shadow the one we want, + // so use the full path while executing whoami + const whoamiPath = path.join(process.env['SystemRoot'], + 'System32', 'whoami.exe'); + + let err = false; + let output = ''; + + try { + output = execSync(whoamiPath + ' /priv', { timout: 1000 }); + } catch (e) { + err = true; + } finally { + if (err || !output.includes('SeCreateSymbolicLinkPrivilege')) { + return false; + } + } + } + + return true; +}; + function fail(msg) { assert.fail(null, null, msg); } diff --git a/test/debugger/helper-debugger-repl.js b/test/debugger/helper-debugger-repl.js index 602ab1c05e53d6..38c65a03fa590d 100644 --- a/test/debugger/helper-debugger-repl.js +++ b/test/debugger/helper-debugger-repl.js @@ -1,15 +1,15 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const assert = require('assert'); +const spawn = require('child_process').spawn; process.env.NODE_DEBUGGER_TIMEOUT = 2000; -var port = common.PORT; +const port = common.PORT; -var child; -var buffer = ''; -var expected = []; -var quit; +let child; +let buffer = ''; +const expected = []; +let quit; function startDebugger(scriptToDebug) { scriptToDebug = process.env.NODE_DEBUGGER_TEST_SCRIPT || @@ -34,23 +34,23 @@ function startDebugger(scriptToDebug) { console.log(line); assert.ok(expected.length > 0, 'Got unexpected line: ' + line); - var expectedLine = expected[0].lines.shift(); + const expectedLine = expected[0].lines.shift(); assert.ok(line.match(expectedLine) !== null, line + ' != ' + expectedLine); if (expected[0].lines.length === 0) { - var callback = expected[0].callback; + const callback = expected[0].callback; expected.shift(); callback && callback(); } }); - var childClosed = false; + let childClosed = false; child.on('close', function(code) { assert(!code); childClosed = true; }); - var quitCalled = false; + let quitCalled = false; quit = function() { if (quitCalled || childClosed) return; quitCalled = true; @@ -60,7 +60,7 @@ function startDebugger(scriptToDebug) { setTimeout(function() { console.error('dying badly buffer=%j', buffer); - var err = 'Timeout'; + let err = 'Timeout'; if (expected.length > 0 && expected[0].lines) { err = err + '. Expected: ' + expected[0].lines.shift(); } @@ -95,7 +95,7 @@ function addTest(input, output) { child.stdin.write(expected[0].input + '\n'); if (!expected[0].lines) { - var callback = expected[0].callback; + const callback = expected[0].callback; expected.shift(); callback && callback(); @@ -107,17 +107,17 @@ function addTest(input, output) { expected.push({input: input, lines: output, callback: next}); } -var handshakeLines = [ +const handshakeLines = [ /listening on /, /connecting.* ok/ ]; -var initialBreakLines = [ +const initialBreakLines = [ /break in .*:1/, /1/, /2/, /3/ ]; -var initialLines = handshakeLines.concat(initialBreakLines); +const initialLines = handshakeLines.concat(initialBreakLines); // Process initial lines addTest(null, initialLines); diff --git a/test/debugger/test-debug-break-on-uncaught.js b/test/debugger/test-debug-break-on-uncaught.js index 2d1deb20bccac8..cfe72bb67b4f02 100644 --- a/test/debugger/test-debug-break-on-uncaught.js +++ b/test/debugger/test-debug-break-on-uncaught.js @@ -73,6 +73,7 @@ function runScenario(scriptName, throwsOnLine, next) { client.connect(port); } + let interval; function runTest(client) { client.req( { @@ -91,14 +92,15 @@ function runScenario(scriptName, throwsOnLine, next) { client.reqContinue(function(error) { assert.ifError(error); - setTimeout(assertHasPaused.bind(null, client), 100); + interval = setInterval(assertHasPaused.bind(null, client), 10); }); } ); } function assertHasPaused(client) { - assert(exceptions.length, 'no exceptions thrown, race condition in test?'); + if (!exceptions.length) return; + assert.strictEqual(exceptions.length, 1, 'debugger did not pause on exception'); assert.strictEqual(exceptions[0].uncaught, true); @@ -106,5 +108,6 @@ function runScenario(scriptName, throwsOnLine, next) { assert.strictEqual(exceptions[0].sourceLine + 1, throwsOnLine); asserted = true; client.reqContinue(assert.ifError); + clearInterval(interval); } } diff --git a/test/debugger/test-debugger-repl-break-in-module.js b/test/debugger/test-debugger-repl-break-in-module.js index 91782ae6e3ef28..2e7b9a58aacb0e 100644 --- a/test/debugger/test-debugger-repl-break-in-module.js +++ b/test/debugger/test-debugger-repl-break-in-module.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var repl = require('./helper-debugger-repl.js'); +const repl = require('./helper-debugger-repl.js'); repl.startDebugger('break-in-module/main.js'); diff --git a/test/debugger/test-debugger-repl-restart.js b/test/debugger/test-debugger-repl-restart.js index 206cd2e7417627..f5de9f5ee95778 100644 --- a/test/debugger/test-debugger-repl-restart.js +++ b/test/debugger/test-debugger-repl-restart.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var repl = require('./helper-debugger-repl.js'); +const repl = require('./helper-debugger-repl.js'); repl.startDebugger('breakpoints.js'); -var linesWithBreakpoint = [ +const linesWithBreakpoint = [ /1/, /2/, /3/, /4/, /5/, /\* 6/ ]; // We slice here, because addTest will change the given array. repl.addTest('sb(6)', linesWithBreakpoint.slice()); -var initialLines = repl.initialLines.slice(); +const initialLines = repl.initialLines.slice(); initialLines.splice(2, 0, /Restoring/, /Warning/); // Restart the debugged script diff --git a/test/debugger/test-debugger-repl-term.js b/test/debugger/test-debugger-repl-term.js index 6872f6ce2f9c72..4932df12e713bb 100644 --- a/test/debugger/test-debugger-repl-term.js +++ b/test/debugger/test-debugger-repl-term.js @@ -2,11 +2,11 @@ require('../common'); process.env.NODE_FORCE_READLINE = 1; -var repl = require('./helper-debugger-repl.js'); +const repl = require('./helper-debugger-repl.js'); repl.startDebugger('breakpoints.js'); -var addTest = repl.addTest; +const addTest = repl.addTest; // next addTest('n', [ diff --git a/test/debugger/test-debugger-repl-utf8.js b/test/debugger/test-debugger-repl-utf8.js index 6654a498219859..90214158884371 100644 --- a/test/debugger/test-debugger-repl-utf8.js +++ b/test/debugger/test-debugger-repl-utf8.js @@ -1,6 +1,6 @@ 'use strict'; -var common = require('../common'); -var script = common.fixturesDir + '/breakpoints_utf8.js'; +const common = require('../common'); +const script = common.fixturesDir + '/breakpoints_utf8.js'; process.env.NODE_DEBUGGER_TEST_SCRIPT = script; require('./test-debugger-repl.js'); diff --git a/test/debugger/test-debugger-repl.js b/test/debugger/test-debugger-repl.js index 8a87d40d163af7..32dbfa22c0d3a9 100644 --- a/test/debugger/test-debugger-repl.js +++ b/test/debugger/test-debugger-repl.js @@ -1,10 +1,10 @@ 'use strict'; -require('../common'); -var repl = require('./helper-debugger-repl.js'); +const common = require('../common'); +const repl = require('./helper-debugger-repl.js'); repl.startDebugger('breakpoints.js'); -var addTest = repl.addTest; +const addTest = repl.addTest; // Next addTest('n', [ @@ -57,7 +57,7 @@ addTest('c', [ // Execute addTest('exec process.title', [ - /node/ + common.isFreeBSD || common.isOSX || common.isLinux ? /node/ : '' ]); // Execute diff --git a/test/disabled/test-debug-brk-file.js b/test/disabled/test-debug-brk-file.js index ee20577ded6145..d697de87d06eff 100644 --- a/test/disabled/test-debug-brk-file.js +++ b/test/disabled/test-debug-brk-file.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; -var path = require('path'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; +const path = require('path'); +const net = require('net'); var isDone = false; var targetPath = path.resolve(common.fixturesDir, 'debug-target.js'); diff --git a/test/disabled/test-dgram-send-error.js b/test/disabled/test-dgram-send-error.js index 271e6689046a00..d7ec016540044c 100644 --- a/test/disabled/test-dgram-send-error.js +++ b/test/disabled/test-dgram-send-error.js @@ -10,7 +10,7 @@ const common = require('../common'); var ITERATIONS = 1000; -var assert = require('assert'), +const assert = require('assert'), dgram = require('dgram'); var buf = Buffer.alloc(1024, 42); @@ -34,7 +34,7 @@ function onMessage(message, info) { } function afterSend(err) { - if (err) throw err; + assert.ifError(err); packetsSent++; } diff --git a/test/disabled/test-fs-largefile.js b/test/disabled/test-fs-largefile.js index fb0058b358a5c3..365cdec188d5c7 100644 --- a/test/disabled/test-fs-largefile.js +++ b/test/disabled/test-fs-largefile.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'), +const common = require('../common'); +const assert = require('assert'); +const path = require('path'), fs = require('fs'), filepath = path.join(common.tmpDir, 'large.txt'), fd = fs.openSync(filepath, 'w+'), @@ -9,14 +9,14 @@ var path = require('path'), message = 'Large File'; fs.truncateSync(fd, offset); -assert.equal(fs.statSync(filepath).size, offset); +assert.strictEqual(fs.statSync(filepath).size, offset); var writeBuf = Buffer.from(message); fs.writeSync(fd, writeBuf, 0, writeBuf.length, offset); var readBuf = Buffer.allocUnsafe(writeBuf.length); fs.readSync(fd, readBuf, 0, readBuf.length, offset); -assert.equal(readBuf.toString(), message); +assert.strictEqual(readBuf.toString(), message); fs.readSync(fd, readBuf, 0, 1, 0); -assert.equal(readBuf[0], 0); +assert.strictEqual(readBuf[0], 0); var exceptionRaised = false; try { @@ -24,7 +24,7 @@ try { } catch (err) { console.log(err); exceptionRaised = true; - assert.equal(err.message, 'Not an integer'); + assert.strictEqual(err.message, 'Not an integer'); } assert.ok(exceptionRaised); fs.close(fd); diff --git a/test/disabled/test-http-abort-stream-end.js b/test/disabled/test-http-abort-stream-end.js index cfa531cedf5523..5dc51d9eee911f 100644 --- a/test/disabled/test-http-abort-stream-end.js +++ b/test/disabled/test-http-abort-stream-end.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); var maxSize = 1024; var size = 0; @@ -36,6 +36,6 @@ s.listen(common.PORT, function() { process.on('exit', function() { assert(aborted); - assert.equal(size, maxSize); + assert.strictEqual(size, maxSize); console.log('ok'); }); diff --git a/test/disabled/test-https-loop-to-google.js b/test/disabled/test-https-loop-to-google.js index e498895ed23be0..2c307f3d1732cd 100644 --- a/test/disabled/test-https-loop-to-google.js +++ b/test/disabled/test-https-loop-to-google.js @@ -5,8 +5,8 @@ // Tested on node 0.5.0-pre commit 9851574 -var common = require('../common'); -var https = require('https'); +const common = require('../common'); +const https = require('https'); for (var i = 0; i < 10; ++i) { https.get({ diff --git a/test/disabled/test-readline.js b/test/disabled/test-readline.js index 9bb9943bd2a403..4273f1013415e4 100644 --- a/test/disabled/test-readline.js +++ b/test/disabled/test-readline.js @@ -1,9 +1,9 @@ 'use strict'; // Can't test this when 'make test' doesn't assign a tty to the stdout. // Yet another use-case for require('tty').spawn ? -var common = require('../common'); -var assert = require('assert'); -var readline = require('readline'); +const common = require('../common'); +const assert = require('assert'); +const readline = require('readline'); var key = { xterm: { @@ -49,12 +49,12 @@ var rl = readlineFakeStream(); var written_bytes_length, refreshed; rl.write('foo'); -assert.equal(3, rl.cursor); +assert.strictEqual(3, rl.cursor); [key.xterm, key.rxvt, key.gnome, key.putty].forEach(function(key) { rl.write.apply(rl, key.home); - assert.equal(0, rl.cursor); + assert.strictEqual(0, rl.cursor); rl.write.apply(rl, key.end); - assert.equal(3, rl.cursor); + assert.strictEqual(3, rl.cursor); }); rl = readlineFakeStream(); @@ -76,9 +76,9 @@ rl.write.apply(rl, key.xterm.home); ].forEach(function(action) { written_bytes_length = rl.written_bytes.length; rl.write.apply(rl, action.key); - assert.equal(action.cursor, rl.cursor); + assert.strictEqual(action.cursor, rl.cursor); refreshed = written_bytes_length !== rl.written_bytes.length; - assert.equal(true, refreshed); + assert.strictEqual(true, refreshed); }); rl = readlineFakeStream(); @@ -93,7 +93,7 @@ rl.write.apply(rl, key.xterm.home); '' ].forEach(function(expectedLine) { rl.write.apply(rl, key.xterm.metad); - assert.equal(0, rl.cursor); - assert.equal(expectedLine, rl.line); + assert.strictEqual(0, rl.cursor); + assert.strictEqual(expectedLine, rl.line); }); rl.close(); diff --git a/test/disabled/test-sendfd.js b/test/disabled/test-sendfd.js index d473cd93c33153..9f1159e30a401c 100644 --- a/test/disabled/test-sendfd.js +++ b/test/disabled/test-sendfd.js @@ -26,15 +26,15 @@ // seen in a response yet. This is intended to ensure that all blobs // sent out have been relayed back to us. -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var buffer = require('buffer'); -var child_process = require('child_process'); -var fs = require('fs'); -var net = require('net'); +const buffer = require('buffer'); +const child_process = require('child_process'); +const fs = require('fs'); +const net = require('net'); var netBinding = process.binding('net'); -var path = require('path'); +const path = require('path'); var DATA = { 'ppid' : process.pid, @@ -63,7 +63,7 @@ var logChild = function(d) { // validate any data sent back by the child. We send the write end of the // pipe to the child and close it off in our process. var pipeFDs = netBinding.pipe(); -assert.equal(pipeFDs.length, 2); +assert.strictEqual(pipeFDs.length, 2); var seenOrdinals = []; @@ -72,8 +72,8 @@ pipeReadStream.on('data', function(data) { data.toString('utf8').trim().split('\n').forEach(function(d) { var rd = JSON.parse(d); - assert.equal(rd.pid, cpp); - assert.equal(seenOrdinals.indexOf(rd.ord), -1); + assert.strictEqual(rd.pid, cpp); + assert.strictEqual(seenOrdinals.indexOf(rd.ord), -1); seenOrdinals.unshift(rd.ord); }); @@ -119,8 +119,8 @@ cp.on('exit', function(code, signal) { srv.close(); // fs.unlinkSync(SOCK_PATH); - assert.equal(code, 0); - assert.equal(seenOrdinals.length, 2); + assert.strictEqual(code, 0); + assert.strictEqual(seenOrdinals.length, 2); }); // vim:ts=2 sw=2 et diff --git a/test/disabled/test-setuidgid.js b/test/disabled/test-setuidgid.js index bf3726ab006d36..14a480fd958923 100644 --- a/test/disabled/test-setuidgid.js +++ b/test/disabled/test-setuidgid.js @@ -1,22 +1,22 @@ 'use strict'; // Requires special privileges -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); var oldgid = process.getgid(); process.setgid('nobody'); var newgid = process.getgid(); -assert.notEqual(newgid, oldgid, 'gids expected to be different'); +assert.notStrictEqual(newgid, oldgid, 'gids expected to be different'); var olduid = process.getuid(); process.setuid('nobody'); var newuid = process.getuid(); -assert.notEqual(newuid, olduid, 'uids expected to be different'); +assert.notStrictEqual(newuid, olduid, 'uids expected to be different'); try { process.setuid('nobody1234'); } catch (e) { - assert.equal(e.message, + assert.strictEqual(e.message, 'failed to resolve group', 'unexpected error message' ); diff --git a/test/disabled/tls_server.js b/test/disabled/tls_server.js index 1e72809a8a04ad..2347ab44103946 100644 --- a/test/disabled/tls_server.js +++ b/test/disabled/tls_server.js @@ -1,11 +1,11 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var util = require('util'); -var net = require('net'); -var fs = require('fs'); -var crypto = require('crypto'); +const util = require('util'); +const net = require('net'); +const fs = require('fs'); +const crypto = require('crypto'); var keyPem = fs.readFileSync(common.fixturesDir + '/cert.pem'); var certPem = fs.readFileSync(common.fixturesDir + '/cert.pem'); diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index bd21e21d9563d2..442381b54d7b72 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -72,11 +72,18 @@ const testData = [ '

    I exist and am being linked to.

    ' + '' }, + { + file: path.join(common.fixturesDir, 'sample_document.md'), + html: '
    1. fish
    2. fish

    3. Redfish

    4. ' + + '
    5. Bluefish
    ', + analyticsId: 'UA-67020396-1' + }, ]; -testData.forEach(function(item) { +testData.forEach((item) => { // Normalize expected data by stripping whitespace const expected = item.html.replace(/\s/g, ''); + const includeAnalytics = typeof item.analyticsId !== 'undefined'; fs.readFile(item.file, 'utf8', common.mustCall((err, input) => { assert.ifError(err); @@ -89,6 +96,7 @@ testData.forEach(function(item) { filename: 'foo', template: 'doc/template.html', nodeVersion: process.version, + analytics: item.analyticsId, }, common.mustCall((err, output) => { assert.ifError(err); @@ -96,7 +104,17 @@ testData.forEach(function(item) { const actual = output.replace(/\s/g, ''); // Assert that the input stripped of all whitespace contains the // expected list - assert.notEqual(actual.indexOf(expected), -1); + assert.notStrictEqual(actual.indexOf(expected), -1); + + // Testing the insertion of Google Analytics script when + // an analytics id is provided. Should not be present by default + if (includeAnalytics) { + assert.notStrictEqual(actual.indexOf('google-analytics.com'), -1, + 'Google Analytics script was not present'); + } else { + assert.strictEqual(actual.indexOf('google-analytics.com'), -1, + 'Google Analytics script was present'); + } })); })); })); diff --git a/test/doctool/test-doctool-json.js b/test/doctool/test-doctool-json.js index 520c79bef8bcda..ae7b2007b7d2ef 100644 --- a/test/doctool/test-doctool-json.js +++ b/test/doctool/test-doctool-json.js @@ -18,7 +18,7 @@ const json = require('../../tools/doc/json.js'); // Test data is a list of objects with two properties. // The file property is the file path. // The json property is some json which will be generated by the doctool. -var testData = [ +const testData = [ { file: path.join(common.fixturesDir, 'sample_document.md'), json: { @@ -136,10 +136,10 @@ var testData = [ } ]; -testData.forEach(function(item) { - fs.readFile(item.file, 'utf8', common.mustCall(function(err, input) { +testData.forEach((item) => { + fs.readFile(item.file, 'utf8', common.mustCall((err, input) => { assert.ifError(err); - json(input, 'foo', common.mustCall(function(err, output) { + json(input, 'foo', common.mustCall((err, output) => { assert.ifError(err); assert.deepStrictEqual(output, item.json); })); diff --git a/test/fixtures/GH-892-request.js b/test/fixtures/GH-892-request.js index 96c355857fea4c..d0db3e29ff5023 100644 --- a/test/fixtures/GH-892-request.js +++ b/test/fixtures/GH-892-request.js @@ -1,8 +1,8 @@ // Called by test/pummel/test-regress-GH-892.js -var https = require('https'); -var fs = require('fs'); -var assert = require('assert'); +const https = require('https'); +const fs = require('fs'); +const assert = require('assert'); var PORT = parseInt(process.argv[2]); var bytesExpected = parseInt(process.argv[3]); @@ -16,7 +16,7 @@ var options = { }; var req = https.request(options, function(res) { - assert.equal(200, res.statusCode); + assert.strictEqual(200, res.statusCode); gotResponse = true; console.error('DONE'); res.resume(); diff --git a/test/fixtures/a.js b/test/fixtures/a.js index 990a78534a68c9..1e8bbcf210b8b6 100644 --- a/test/fixtures/a.js +++ b/test/fixtures/a.js @@ -1,4 +1,4 @@ -var c = require('./b/c'); +const c = require('./b/c'); console.error('load fixtures/a.js'); diff --git a/test/fixtures/a1.js b/test/fixtures/a1.js index 990a78534a68c9..1e8bbcf210b8b6 100644 --- a/test/fixtures/a1.js +++ b/test/fixtures/a1.js @@ -1,4 +1,4 @@ -var c = require('./b/c'); +const c = require('./b/c'); console.error('load fixtures/a.js'); diff --git a/test/fixtures/b/c.js b/test/fixtures/b/c.js index 1b568c2fc9a66e..2305e5b28635bc 100644 --- a/test/fixtures/b/c.js +++ b/test/fixtures/b/c.js @@ -1,10 +1,10 @@ -var d = require('./d'); +const d = require('./d'); -var assert = require('assert'); +const assert = require('assert'); -var package = require('./package'); +const package = require('./package'); -assert.equal('world', package.hello); +assert.strictEqual('world', package.hello); console.error('load fixtures/b/c.js'); diff --git a/test/fixtures/break-in-module/main.js b/test/fixtures/break-in-module/main.js index cb7074ed2a3659..cfb44c766abac3 100644 --- a/test/fixtures/break-in-module/main.js +++ b/test/fixtures/break-in-module/main.js @@ -1,4 +1,4 @@ -var mod = require('./mod.js'); +const mod = require('./mod.js'); mod.hello(); mod.hello(); debugger; diff --git a/test/fixtures/child-process-spawn-node.js b/test/fixtures/child-process-spawn-node.js index 01a494ee596c8e..f93fd998fe0e37 100644 --- a/test/fixtures/child-process-spawn-node.js +++ b/test/fixtures/child-process-spawn-node.js @@ -1,4 +1,4 @@ -var assert = require('assert'); +const assert = require('assert'); function onmessage(m) { console.log('CHILD got message:', m); diff --git a/test/fixtures/child_process_should_emit_error.js b/test/fixtures/child_process_should_emit_error.js index 9f7b2bb80ffcbb..34d23fc58347ac 100644 --- a/test/fixtures/child_process_should_emit_error.js +++ b/test/fixtures/child_process_should_emit_error.js @@ -1,4 +1,4 @@ -var exec = require('child_process').exec; +const exec = require('child_process').exec; [0, 1].forEach(function(i) { exec('ls', function(err, stdout, stderr) { diff --git a/test/fixtures/cluster-preload-test.js b/test/fixtures/cluster-preload-test.js index 43d3887b0daf01..0094fe6657fd7c 100644 --- a/test/fixtures/cluster-preload-test.js +++ b/test/fixtures/cluster-preload-test.js @@ -1,4 +1,4 @@ -var cluster = require('cluster'); +const cluster = require('cluster'); if (cluster.isMaster) { cluster.fork(); // one child cluster.on('exit', function(worker, code, signal) { diff --git a/test/fixtures/cluster-preload.js b/test/fixtures/cluster-preload.js index 6637b418babb0d..bb38793b65d7de 100644 --- a/test/fixtures/cluster-preload.js +++ b/test/fixtures/cluster-preload.js @@ -1,12 +1,12 @@ -var assert = require('assert'); +const assert = require('assert'); // https://github.com/nodejs/node/issues/1803 // this module is used as a preload module. It should have a parent with the // module search paths initialized from the current working directory assert.ok(module.parent); -var expectedPaths = require('module')._nodeModulePaths(process.cwd()); -assert.deepEqual(module.parent.paths, expectedPaths); +const expectedPaths = require('module')._nodeModulePaths(process.cwd()); +assert.deepStrictEqual(module.parent.paths, expectedPaths); -var cluster = require('cluster'); +const cluster = require('cluster'); cluster.isMaster || process.exit(42 + cluster.worker.id); // +42 to distinguish // from exit(1) for other random reasons diff --git a/test/fixtures/create-file.js b/test/fixtures/create-file.js index d6f731b784d6d5..1cf417616e1636 100644 --- a/test/fixtures/create-file.js +++ b/test/fixtures/create-file.js @@ -1,4 +1,4 @@ -var fs = require('fs'); +const fs = require('fs'); var file_name = process.argv[2]; var file_size = parseInt(process.argv[3]); diff --git a/test/fixtures/cycles/folder/foo.js b/test/fixtures/cycles/folder/foo.js index a6b284dd56e1b9..573f885f4e4090 100644 --- a/test/fixtures/cycles/folder/foo.js +++ b/test/fixtures/cycles/folder/foo.js @@ -1,4 +1,4 @@ -var root = require('./../root'); +const root = require('./../root'); exports.hello = function() { return root.calledFromFoo(); diff --git a/test/fixtures/cycles/root.js b/test/fixtures/cycles/root.js index 9b8b2459e6743f..5e3504e2a643e1 100644 --- a/test/fixtures/cycles/root.js +++ b/test/fixtures/cycles/root.js @@ -1,4 +1,4 @@ -var foo = exports.foo = require('./folder/foo'); +const foo = exports.foo = require('./folder/foo'); exports.hello = 'hello'; exports.sayHello = function() { diff --git a/test/fixtures/echo-close-check.js b/test/fixtures/echo-close-check.js index 57b2af95672a24..720bcc9de458ba 100644 --- a/test/fixtures/echo-close-check.js +++ b/test/fixtures/echo-close-check.js @@ -1,7 +1,7 @@ -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); +const fs = require('fs'); process.stdout.write('hello world\r\n'); diff --git a/test/fixtures/echo.js b/test/fixtures/echo.js index c03e661d1c5704..429541b5849bd4 100644 --- a/test/fixtures/echo.js +++ b/test/fixtures/echo.js @@ -1,5 +1,5 @@ -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); process.stdout.write('hello world\r\n'); diff --git a/test/fixtures/listen-on-socket-and-exit.js b/test/fixtures/listen-on-socket-and-exit.js index 7fb0d970de7e0d..8627625965e87d 100644 --- a/test/fixtures/listen-on-socket-and-exit.js +++ b/test/fixtures/listen-on-socket-and-exit.js @@ -1,7 +1,7 @@ // child process that listens on a socket, allows testing of an EADDRINUSE condition -var common = require('../common'); -var net = require('net'); +const common = require('../common'); +const net = require('net'); common.refreshTmpDir(); diff --git a/test/fixtures/module-require/parent/index.js b/test/fixtures/module-require/parent/index.js index e174cba6fffc88..52e650bbdbd2cc 100644 --- a/test/fixtures/module-require/parent/index.js +++ b/test/fixtures/module-require/parent/index.js @@ -1,4 +1,4 @@ -var child = require('../child'); +const child = require('../child'); //console.log(child.module.require, child.module); console.log(child.module.require('target')); console.log(child.loaded); diff --git a/test/fixtures/node_modules/baz/index.js b/test/fixtures/node_modules/baz/index.js index 859ea0924d6fb7..939f0351699195 100644 --- a/test/fixtures/node_modules/baz/index.js +++ b/test/fixtures/node_modules/baz/index.js @@ -1,10 +1,10 @@ console.error(__filename); console.error(module.paths.join('\n') + '\n'); // this should work, and get the one that doesn't throw -var assert = require('assert'); -assert.equal(require('bar'), require('../bar.js')); +const assert = require('assert'); +assert.strictEqual(require('bar'), require('../bar.js')); // this should work, and get the one in ./node_modules/asdf.js -assert.equal(require('asdf'), require('./node_modules/asdf.js')); +assert.strictEqual(require('asdf'), require('./node_modules/asdf.js')); module.exports = 'eye catcher'; diff --git a/test/fixtures/node_modules/foo.js b/test/fixtures/node_modules/foo.js index f69ac7b00e5a4b..4d4cc9fe12fbc8 100644 --- a/test/fixtures/node_modules/foo.js +++ b/test/fixtures/node_modules/foo.js @@ -1,4 +1,4 @@ console.error(__filename); console.error(module.paths.join('\n') + '\n'); -var assert = require('assert'); -assert.equal(require('baz'), require('./baz/index.js')); +const assert = require('assert'); +assert.strictEqual(require('baz'), require('./baz/index.js')); diff --git a/test/fixtures/not-main-module.js b/test/fixtures/not-main-module.js index 3da57f44285910..4897a294eacb73 100644 --- a/test/fixtures/not-main-module.js +++ b/test/fixtures/not-main-module.js @@ -1,4 +1,4 @@ -var assert = require('assert'); -assert.notEqual(module, require.main, 'require.main should not == module'); -assert.notEqual(module, process.mainModule, - 'process.mainModule should not === module'); +const assert = require('assert'); +assert.notStrictEqual(module, require.main, 'require.main should not == module'); +assert.notStrictEqual(module, process.mainModule, + 'process.mainModule should not === module'); diff --git a/test/fixtures/parent-process-nonpersistent.js b/test/fixtures/parent-process-nonpersistent.js index a71d1a3882de27..e55c7bf896d4d3 100644 --- a/test/fixtures/parent-process-nonpersistent.js +++ b/test/fixtures/parent-process-nonpersistent.js @@ -1,5 +1,5 @@ -var spawn = require('child_process').spawn, +const spawn = require('child_process').spawn, path = require('path'), childPath = path.join(__dirname, 'child-process-persistent.js'); diff --git a/test/fixtures/path-resolve.js b/test/fixtures/path-resolve.js index 00eb3d3691ea3c..883d14b73e6791 100644 --- a/test/fixtures/path-resolve.js +++ b/test/fixtures/path-resolve.js @@ -1,4 +1,4 @@ // Tests resolving a path in the context of a spawned process. // See https://github.com/nodejs/node/issues/7215 -var path = require('path'); +const path = require('path'); console.log(path.resolve(process.argv[2])); diff --git a/test/fixtures/path.js b/test/fixtures/path.js index cdfcec876159df..b6323ff059f963 100644 --- a/test/fixtures/path.js +++ b/test/fixtures/path.js @@ -1,5 +1,5 @@ // This is actually more a fixture than a test. It is used to make -var common = require('../common'); +const common = require('../common'); // sure that require('./path') and require('path') do different things. // It has to be in the same directory as the test 'test-module-loading.js' // and it has to have the same name as an internal module. diff --git a/test/fixtures/print-chars-from-buffer.js b/test/fixtures/print-chars-from-buffer.js index fc902a896fe54f..b2f4ac43584c59 100644 --- a/test/fixtures/print-chars-from-buffer.js +++ b/test/fixtures/print-chars-from-buffer.js @@ -1,4 +1,4 @@ -var assert = require('assert'); +const assert = require('assert'); var n = parseInt(process.argv[2]); diff --git a/test/fixtures/print-chars.js b/test/fixtures/print-chars.js index b9707fbf75fa67..e350a025a54723 100644 --- a/test/fixtures/print-chars.js +++ b/test/fixtures/print-chars.js @@ -1,4 +1,4 @@ -var assert = require('assert'); +const assert = require('assert'); var n = parseInt(process.argv[2]); diff --git a/test/fixtures/recvfd.js b/test/fixtures/recvfd.js index 75df69a3dc3954..4c9d96ffe07612 100644 --- a/test/fixtures/recvfd.js +++ b/test/fixtures/recvfd.js @@ -1,7 +1,7 @@ // See test/simple/test-sendfd.js for a complete description of what this // script is doing and how it fits into the test as a whole. -var net = require('net'); +const net = require('net'); var receivedData = []; var receivedFDs = []; diff --git a/test/fixtures/stdio-filter.js b/test/fixtures/stdio-filter.js index 8e4f50305131f4..cc0e53c39d0353 100644 --- a/test/fixtures/stdio-filter.js +++ b/test/fixtures/stdio-filter.js @@ -1,4 +1,4 @@ -var util = require('util'); +const util = require('util'); var regexIn = process.argv[2]; var replacement = process.argv[3]; diff --git a/test/fixtures/test-init-native/fs.js b/test/fixtures/test-init-native/fs.js index 6b47b418f44561..6481485d22918c 100644 --- a/test/fixtures/test-init-native/fs.js +++ b/test/fixtures/test-init-native/fs.js @@ -1,5 +1,5 @@ (function() { - var fs = require('fs'); + const fs = require('fs'); if (fs.readFile) { require('util').print('fs loaded successfully'); } diff --git a/test/fixtures/test-regress-GH-4015.js b/test/fixtures/test-regress-GH-4015.js index 0d9c05d6d71638..9f947fa091a5f5 100644 --- a/test/fixtures/test-regress-GH-4015.js +++ b/test/fixtures/test-regress-GH-4015.js @@ -1,4 +1,4 @@ -var fs = require('fs'); +const fs = require('fs'); function load() { fs.statSync('.'); diff --git a/test/fixtures/tls-connect.js b/test/fixtures/tls-connect.js new file mode 100644 index 00000000000000..72f83736bf370e --- /dev/null +++ b/test/fixtures/tls-connect.js @@ -0,0 +1,101 @@ +// One shot call to connect a TLS client and server based on options to +// tls.createServer() and tls.connect(), so assertions can be made on both ends +// of the connection. +'use strict'; + +const common = require('../common'); +const fs = require('fs'); +const join = require('path').join; +const tls = require('tls'); +const util = require('util'); + +module.exports = exports = checkCrypto; + +function checkCrypto() { + if (!common.hasCrypto) { + common.skip('missing crypto'); + process.exit(0); + } + return exports; +} + +exports.assert = require('assert'); +exports.debug = util.debuglog('test'); +exports.tls = tls; + +// Pre-load keys from common fixtures for ease of use by tests. +const keys = exports.keys = { + agent1: load('agent1', 'ca1'), + agent2: load('agent2', 'agent2'), + agent3: load('agent3', 'ca2'), + agent4: load('agent4', 'ca2'), + agent5: load('agent5', 'ca2'), + agent6: load('agent6', 'ca1'), + agent7: load('agent7', 'fake-cnnic-root'), + ec: load('ec', 'ec'), +}; + +function load(cert, issuer) { + issuer = issuer || cert; // Assume self-signed if no issuer + const id = { + key: read(cert + '-key.pem'), + cert: read(cert + '-cert.pem'), + ca: read(issuer + '-cert.pem'), + }; + return id; +} + +function read(file) { + return fs.readFileSync(join(common.fixturesDir, 'keys', file), 'binary'); +} + +exports.connect = function connect(options, callback) { + callback = common.mustCall(callback); + + const server = {}; + const client = {}; + const pair = { + server: server, + client: client, + }; + + tls.createServer(options.server, function(conn) { + server.conn = conn; + conn.pipe(conn); + maybeCallback() + }).listen(0, function() { + server.server = this; + + const optClient = util._extend({ + port: this.address().port, + }, options.client); + + tls.connect(optClient) + .on('secureConnect', function() { + client.conn = this; + maybeCallback(); + }) + .on('error', function(err) { + client.err = err; + client.conn = this; + maybeCallback(); + }); + }); + + function maybeCallback() { + if (!callback) + return; + if (server.conn && (client.conn || client.err)) { + const err = pair.client.err || pair.server.err; + callback(err, pair, cleanup); + callback = null; + + function cleanup() { + if (server.server) + server.server.close(); + if (client.conn) + client.conn.end(); + } + } + } +} diff --git a/test/fixtures/uncaught-exceptions/domain.js b/test/fixtures/uncaught-exceptions/domain.js index c00b22dbb9c86d..9ede6993a7331b 100644 --- a/test/fixtures/uncaught-exceptions/domain.js +++ b/test/fixtures/uncaught-exceptions/domain.js @@ -1,4 +1,4 @@ -var domain = require('domain'); +const domain = require('domain'); var d = domain.create(); d.on('error', function(err) { diff --git a/test/fixtures/url-setter-tests.json b/test/fixtures/url-setter-tests.json index e3a163e788301e..56a1c00a86fd45 100644 --- a/test/fixtures/url-setter-tests.json +++ b/test/fixtures/url-setter-tests.json @@ -953,8 +953,8 @@ "href": "view-source+http://example.net/home?lang=fr#nav", "new_value": "\\a\\%2E\\b\\%2e.\\c", "expected": { - "href": "view-source+http://example.net/\\a\\.\\b\\..\\c?lang=fr#nav", - "pathname": "/\\a\\.\\b\\..\\c" + "href": "view-source+http://example.net/\\a\\%2E\\b\\%2e.\\c?lang=fr#nav", + "pathname": "/\\a\\%2E\\b\\%2e.\\c" } }, { @@ -967,12 +967,12 @@ } }, { - "comment": "Bytes already percent-encoded are left as-is, except %2E.", + "comment": "Bytes already percent-encoded are left as-is, including %2E outside dotted segments.", "href": "http://example.net", "new_value": "%2e%2E%c3%89té", "expected": { - "href": "http://example.net/..%c3%89t%C3%A9", - "pathname": "/..%c3%89t%C3%A9" + "href": "http://example.net/%2e%2E%c3%89t%C3%A9", + "pathname": "/%2e%2E%c3%89t%C3%A9" } }, { diff --git a/test/fixtures/url-tests.json b/test/fixtures/url-tests.json index 44d665b99f5bb6..634a8e3f663985 100644 --- a/test/fixtures/url-tests.json +++ b/test/fixtures/url-tests.json @@ -32,6 +32,66 @@ "search": "?b", "hash": "#c" }, + { + "input": "https://test:@test", + "base": "about:blank", + "href": "https://test@test/", + "origin": "https://test", + "protocol": "https:", + "username": "test", + "password": "", + "host": "test", + "hostname": "test", + "port": "", + "pathname": "/", + "search": "", + "hash": "" + }, + { + "input": "https://:@test", + "base": "about:blank", + "href": "https://test/", + "origin": "https://test", + "protocol": "https:", + "username": "", + "password": "", + "host": "test", + "hostname": "test", + "port": "", + "pathname": "/", + "search": "", + "hash": "" + }, + { + "input": "non-special://test:@test/x", + "base": "about:blank", + "href": "non-special://test@test/x", + "origin": "null", + "protocol": "non-special:", + "username": "test", + "password": "", + "host": "test", + "hostname": "test", + "port": "", + "pathname": "/x", + "search": "", + "hash": "" + }, + { + "input": "non-special://:@test/x", + "base": "about:blank", + "href": "non-special://test/x", + "origin": "null", + "protocol": "non-special:", + "username": "", + "password": "", + "host": "test", + "hostname": "test", + "port": "", + "pathname": "/x", + "search": "", + "hash": "" + }, { "input": "http:foo.com", "base": "http://example.org/foo/bar", @@ -1787,7 +1847,7 @@ { "input": "http://example.com/foo/%2e%2", "base": "about:blank", - "href": "http://example.com/foo/.%2", + "href": "http://example.com/foo/%2e%2", "origin": "http://example.com", "protocol": "http:", "username": "", @@ -1795,14 +1855,14 @@ "host": "example.com", "hostname": "example.com", "port": "", - "pathname": "/foo/.%2", + "pathname": "/foo/%2e%2", "search": "", "hash": "" }, { "input": "http://example.com/foo/%2e./%2e%2e/.%2e/%2e.bar", "base": "about:blank", - "href": "http://example.com/..bar", + "href": "http://example.com/%2e.bar", "origin": "http://example.com", "protocol": "http:", "username": "", @@ -1810,7 +1870,7 @@ "host": "example.com", "hostname": "example.com", "port": "", - "pathname": "/..bar", + "pathname": "/%2e.bar", "search": "", "hash": "" }, @@ -2228,7 +2288,7 @@ { "input": "http://www/foo%2Ehtml", "base": "about:blank", - "href": "http://www/foo.html", + "href": "http://www/foo%2Ehtml", "origin": "http://www", "protocol": "http:", "username": "", @@ -2236,7 +2296,7 @@ "host": "www", "hostname": "www", "port": "", - "pathname": "/foo.html", + "pathname": "/foo%2Ehtml", "search": "", "hash": "" }, @@ -3098,7 +3158,7 @@ { "input": "http:a:@www.example.com", "base": "about:blank", - "href": "http://a:@www.example.com/", + "href": "http://a@www.example.com/", "origin": "http://www.example.com", "protocol": "http:", "username": "a", @@ -3113,7 +3173,7 @@ { "input": "http:/a:@www.example.com", "base": "about:blank", - "href": "http://a:@www.example.com/", + "href": "http://a@www.example.com/", "origin": "http://www.example.com", "protocol": "http:", "username": "a", @@ -3128,7 +3188,7 @@ { "input": "http://a:@www.example.com", "base": "about:blank", - "href": "http://a:@www.example.com/", + "href": "http://a@www.example.com/", "origin": "http://www.example.com", "protocol": "http:", "username": "a", @@ -3173,7 +3233,7 @@ { "input": "http://:@www.example.com", "base": "about:blank", - "href": "http://:@www.example.com/", + "href": "http://www.example.com/", "origin": "http://www.example.com", "protocol": "http:", "username": "", diff --git a/test/gc/node_modules/bindings/README.md b/test/gc/node_modules/bindings/README.md index 585cf512b9b1f6..2dc83f5d85e5cc 100644 --- a/test/gc/node_modules/bindings/README.md +++ b/test/gc/node_modules/bindings/README.md @@ -35,7 +35,7 @@ Example and architecture is as simple as: ``` js -var bindings = require('bindings')('binding.node') +const bindings = require('bindings')('binding.node') // Use your bindings defined in your C files bindings.your_c_function() diff --git a/test/gc/node_modules/bindings/bindings.js b/test/gc/node_modules/bindings/bindings.js index 93dcf85a187afe..b60ff631cc9f06 100644 --- a/test/gc/node_modules/bindings/bindings.js +++ b/test/gc/node_modules/bindings/bindings.js @@ -3,7 +3,7 @@ * Module dependencies. */ -var fs = require('fs') +const fs = require('fs') , path = require('path') , join = path.join , dirname = path.dirname diff --git a/test/gc/node_modules/nan/tools/1to2.js b/test/gc/node_modules/nan/tools/1to2.js index b7498e438ccd83..3464857ace54be 100755 --- a/test/gc/node_modules/nan/tools/1to2.js +++ b/test/gc/node_modules/nan/tools/1to2.js @@ -7,7 +7,7 @@ * MIT License ********************************************************************/ -var commander = require('commander'), +const commander = require('commander'), fs = require('fs'), glob = require('glob'), groups = [], @@ -57,7 +57,7 @@ groups.push([1, ['(', [ /* replace TryCatch with NanTryCatch once, gobbling possible namespace, key group 2 */ groups.push([2, '(?:(?:v8\\:\\:)?|(Nan)?)(TryCatch)']); -/* NanNew("string") will likely not fail a ToLocalChecked(), key group 1 */ +/* NanNew("string") will likely not fail a ToLocalChecked(), key group 1 */ groups.push([1, ['(NanNew)', '(\\("[^\\"]*"[^\\)]*\\))(?!\\.ToLocalChecked\\(\\))'].join('')]); /* Removed v8 APIs, warn that the code needs rewriting using node::Buffer, key group 2 */ diff --git a/test/gc/node_modules/weak/README.md b/test/gc/node_modules/weak/README.md index c153bb509c737a..1dad235ce180df 100644 --- a/test/gc/node_modules/weak/README.md +++ b/test/gc/node_modules/weak/README.md @@ -36,7 +36,7 @@ Here's an example of calling a `cleanup()` function on a Object before it gets garbage collected: ``` js -var weak = require('weak') +const weak = require('weak') // we are going to "monitor" this Object and invoke "cleanup" // before the object is garbage collected @@ -80,7 +80,7 @@ at the highest scope possible (top-level being the best). Named functions work really well for this: ``` js -var http = require('http') +const http = require('http') , weak = require('weak') http.createServer(function (req, res) { diff --git a/test/gc/node_modules/weak/build/Makefile b/test/gc/node_modules/weak/build/Makefile index ab2f0190ef9c5f..0fd5a88f9d3c7d 100644 --- a/test/gc/node_modules/weak/build/Makefile +++ b/test/gc/node_modules/weak/build/Makefile @@ -326,7 +326,7 @@ ifeq ($(strip $(foreach prefix,$(NO_LOAD),\ endif quiet_cmd_regen_makefile = ACTION Regenerating $@ -cmd_regen_makefile = cd $(srcdir); /Users/trott/io.js/deps/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/trott/io.js/test/gc/node_modules/weak/build/config.gypi -I/Users/trott/io.js/deps/npm/node_modules/node-gyp/addon.gypi -I/Users/trott/io.js/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/trott/io.js" "-Dnode_gyp_dir=/Users/trott/io.js/deps/npm/node_modules/node-gyp" "-Dnode_lib_file=node.lib" "-Dmodule_root_dir=/Users/trott/io.js/test/gc/node_modules/weak" binding.gyp +cmd_regen_makefile = cd $(srcdir); /Users/cjihrig/iojs/node/deps/npm/node_modules/node-gyp/gyp/gyp_main.py -fmake --ignore-environment "--toplevel-dir=." -I/Users/cjihrig/iojs/node/test/gc/node_modules/weak/build/config.gypi -I/Users/cjihrig/iojs/node/deps/npm/node_modules/node-gyp/addon.gypi -I/Users/cjihrig/iojs/node/common.gypi "--depth=." "-Goutput_dir=." "--generator-output=build" "-Dlibrary=shared_library" "-Dvisibility=default" "-Dnode_root_dir=/Users/cjihrig/iojs/node" "-Dnode_gyp_dir=/Users/cjihrig/iojs/node/deps/npm/node_modules/node-gyp" "-Dnode_lib_file=node.lib" "-Dmodule_root_dir=/Users/cjihrig/iojs/node/test/gc/node_modules/weak" binding.gyp Makefile: $(srcdir)/../../../../deps/npm/node_modules/node-gyp/addon.gypi $(srcdir)/build/config.gypi $(srcdir)/binding.gyp $(srcdir)/../../../../common.gypi $(call do_cmd,regen_makefile) diff --git a/test/gc/node_modules/weak/build/config.gypi b/test/gc/node_modules/weak/build/config.gypi index 9354987d41ab17..ce322bc5f3961a 100644 --- a/test/gc/node_modules/weak/build/config.gypi +++ b/test/gc/node_modules/weak/build/config.gypi @@ -9,47 +9,58 @@ }, "variables": { "asan": 0, + "coverage": "false", + "debug_devtools": "node", + "force_dynamic_crt": 0, "host_arch": "x64", - "icu_data_file": "icudt57l.dat", - "icu_data_in": "../../deps/icu-small/source/data/in/icudt57l.dat", + "icu_data_file": "icudt58l.dat", + "icu_data_in": "../../deps/icu-small/source/data/in/icudt58l.dat", "icu_endianness": "l", "icu_gyp_path": "tools/icu/icu-generic.gyp", "icu_locales": "en,root", "icu_path": "deps/icu-small", "icu_small": "true", - "icu_ver_major": "57", + "icu_ver_major": "58", "llvm_version": 0, "node_byteorder": "little", + "node_enable_d8": "false", "node_enable_v8_vtunejit": "false", "node_install_npm": "true", + "node_module_version": 51, "node_no_browser_globals": "false", "node_prefix": "/usr/local", "node_release_urlbase": "", + "node_shared": "false", "node_shared_cares": "false", "node_shared_http_parser": "false", "node_shared_libuv": "false", "node_shared_openssl": "false", "node_shared_zlib": "false", "node_tag": "", + "node_use_bundled_v8": "true", "node_use_dtrace": "true", "node_use_etw": "false", "node_use_lttng": "false", "node_use_openssl": "true", "node_use_perfctr": "false", + "node_use_v8_platform": "true", "openssl_fips": "", "openssl_no_asm": 0, + "shlib_suffix": "51.dylib", "target_arch": "x64", "uv_parent_path": "/deps/uv/", "uv_use_dtrace": "true", "v8_enable_gdbjit": 0, "v8_enable_i18n_support": 1, + "v8_inspector": "true", "v8_no_strict_aliasing": 1, "v8_optimized_debug": 0, "v8_random_seed": 0, "v8_use_snapshot": "true", "want_separate_host_toolset": 0, - "xcode_version": "7.0", - "nodedir": "/Users/trott/io.js", + "want_separate_host_toolset_mkpeephole": 0, + "xcode_version": "8.0", + "nodedir": "/Users/cjihrig/iojs/node", "copy_dev_lib": "false", "standalone_static_library": 1 } diff --git a/test/gc/node_modules/weak/build/weakref.target.mk b/test/gc/node_modules/weak/build/weakref.target.mk index 8572d7412ffd34..bb8d2bd72fffab 100644 --- a/test/gc/node_modules/weak/build/weakref.target.mk +++ b/test/gc/node_modules/weak/build/weakref.target.mk @@ -4,6 +4,9 @@ TOOLSET := target TARGET := weakref DEFS_Debug := \ '-DNODE_GYP_MODULE_NAME=weakref' \ + '-DUSING_UV_SHARED=1' \ + '-DUSING_V8_SHARED=1' \ + '-DV8_DEPRECATION_WARNINGS=1' \ '-D_DARWIN_USE_64_BIT_INODE=1' \ '-D_LARGEFILE_SOURCE' \ '-D_FILE_OFFSET_BITS=64' \ @@ -29,6 +32,7 @@ CFLAGS_C_Debug := \ # Flags passed to only C++ files. CFLAGS_CC_Debug := \ -std=gnu++0x \ + -stdlib=libc++ \ -fno-rtti \ -fno-exceptions \ -fno-threadsafe-statics \ @@ -41,14 +45,17 @@ CFLAGS_OBJC_Debug := CFLAGS_OBJCC_Debug := INCS_Debug := \ - -I/Users/trott/io.js/include/node \ - -I/Users/trott/io.js/src \ - -I/Users/trott/io.js/deps/uv/include \ - -I/Users/trott/io.js/deps/v8/include \ + -I/Users/cjihrig/iojs/node/include/node \ + -I/Users/cjihrig/iojs/node/src \ + -I/Users/cjihrig/iojs/node/deps/uv/include \ + -I/Users/cjihrig/iojs/node/deps/v8/include \ -I$(srcdir)/../nan DEFS_Release := \ '-DNODE_GYP_MODULE_NAME=weakref' \ + '-DUSING_UV_SHARED=1' \ + '-DUSING_V8_SHARED=1' \ + '-DV8_DEPRECATION_WARNINGS=1' \ '-D_DARWIN_USE_64_BIT_INODE=1' \ '-D_LARGEFILE_SOURCE' \ '-D_FILE_OFFSET_BITS=64' \ @@ -72,6 +79,7 @@ CFLAGS_C_Release := \ # Flags passed to only C++ files. CFLAGS_CC_Release := \ -std=gnu++0x \ + -stdlib=libc++ \ -fno-rtti \ -fno-exceptions \ -fno-threadsafe-statics \ @@ -84,10 +92,10 @@ CFLAGS_OBJC_Release := CFLAGS_OBJCC_Release := INCS_Release := \ - -I/Users/trott/io.js/include/node \ - -I/Users/trott/io.js/src \ - -I/Users/trott/io.js/deps/uv/include \ - -I/Users/trott/io.js/deps/v8/include \ + -I/Users/cjihrig/iojs/node/include/node \ + -I/Users/cjihrig/iojs/node/src \ + -I/Users/cjihrig/iojs/node/deps/uv/include \ + -I/Users/cjihrig/iojs/node/deps/v8/include \ -I$(srcdir)/../nan OBJS := \ @@ -125,7 +133,8 @@ LDFLAGS_Debug := \ -Wl,-search_paths_first \ -mmacosx-version-min=10.7 \ -arch x86_64 \ - -L$(builddir) + -L$(builddir) \ + -stdlib=libc++ LIBTOOLFLAGS_Debug := \ -undefined dynamic_lookup \ @@ -138,7 +147,8 @@ LDFLAGS_Release := \ -Wl,-search_paths_first \ -mmacosx-version-min=10.7 \ -arch x86_64 \ - -L$(builddir) + -L$(builddir) \ + -stdlib=libc++ LIBTOOLFLAGS_Release := \ -undefined dynamic_lookup \ diff --git a/test/gc/node_modules/weak/lib/weak.js b/test/gc/node_modules/weak/lib/weak.js index 5502b0de201372..66ba2e71388c59 100644 --- a/test/gc/node_modules/weak/lib/weak.js +++ b/test/gc/node_modules/weak/lib/weak.js @@ -3,8 +3,8 @@ * Module dependencies. */ -var Emitter = require('events').EventEmitter; -var bindings = require('bindings')('weakref.node'); +const Emitter = require('events').EventEmitter; +const bindings = require('bindings')('weakref.node'); /** * Set global weak callback function. diff --git a/test/gc/test-http-client-connaborted.js b/test/gc/test-http-client-connaborted.js index 071baf738ee9d3..6ff2a282d89c98 100644 --- a/test/gc/test-http-client-connaborted.js +++ b/test/gc/test-http-client-connaborted.js @@ -18,7 +18,7 @@ let countGC = 0; console.log('We should do ' + todo + ' requests'); -var server = http.createServer(serverHandler); +const server = http.createServer(serverHandler); server.listen(0, getall); function getall() { @@ -31,7 +31,7 @@ function getall() { statusLater(); } - var req = http.get({ + const req = http.get({ hostname: 'localhost', pathname: '/', port: server.address().port @@ -44,14 +44,14 @@ function getall() { setImmediate(getall); } -for (var i = 0; i < 10; i++) +for (let i = 0; i < 10; i++) getall(); function afterGC() { countGC++; } -var timer; +let timer; function statusLater() { global.gc(); if (timer) clearTimeout(timer); diff --git a/test/gc/test-http-client-onerror.js b/test/gc/test-http-client-onerror.js index a2ef0fa4bee9b7..b17ab428a2ccd7 100644 --- a/test/gc/test-http-client-onerror.js +++ b/test/gc/test-http-client-onerror.js @@ -20,7 +20,7 @@ let countGC = 0; console.log('We should do ' + todo + ' requests'); -var server = http.createServer(serverHandler); +const server = http.createServer(serverHandler); server.listen(0, runTest); function getall() { @@ -37,7 +37,7 @@ function getall() { throw er; } - var req = http.get({ + const req = http.get({ hostname: 'localhost', pathname: '/', port: server.address().port @@ -51,7 +51,7 @@ function getall() { } function runTest() { - for (var i = 0; i < 10; i++) + for (let i = 0; i < 10; i++) getall(); } @@ -59,7 +59,7 @@ function afterGC() { countGC++; } -var timer; +let timer; function statusLater() { global.gc(); if (timer) clearTimeout(timer); diff --git a/test/gc/test-http-client-timeout.js b/test/gc/test-http-client-timeout.js index 27baf837ca8282..fb4e8ba0f7058d 100644 --- a/test/gc/test-http-client-timeout.js +++ b/test/gc/test-http-client-timeout.js @@ -22,7 +22,7 @@ let countGC = 0; console.log('We should do ' + todo + ' requests'); -var server = http.createServer(serverHandler); +const server = http.createServer(serverHandler); server.listen(0, getall); function getall() { @@ -36,7 +36,7 @@ function getall() { statusLater(); } - var req = http.get({ + const req = http.get({ hostname: 'localhost', pathname: '/', port: server.address().port @@ -53,14 +53,14 @@ function getall() { setImmediate(getall); } -for (var i = 0; i < 10; i++) +for (let i = 0; i < 10; i++) getall(); function afterGC() { countGC++; } -var timer; +let timer; function statusLater() { global.gc(); if (timer) clearTimeout(timer); diff --git a/test/gc/test-http-client.js b/test/gc/test-http-client.js index 06bd08b2651d1b..f81cab0b09d2c2 100644 --- a/test/gc/test-http-client.js +++ b/test/gc/test-http-client.js @@ -18,7 +18,7 @@ let countGC = 0; console.log('We should do ' + todo + ' requests'); -var server = http.createServer(serverHandler); +const server = http.createServer(serverHandler); server.listen(0, getall); @@ -34,7 +34,7 @@ function getall() { res.on('end', global.gc); } - var req = http.get({ + const req = http.get({ hostname: 'localhost', pathname: '/', port: server.address().port @@ -47,7 +47,7 @@ function getall() { setImmediate(getall); } -for (var i = 0; i < 10; i++) +for (let i = 0; i < 10; i++) getall(); function afterGC() { diff --git a/test/gc/test-net-timeout.js b/test/gc/test-net-timeout.js index 2d9bc134a30347..b8ea8e2089c439 100644 --- a/test/gc/test-net-timeout.js +++ b/test/gc/test-net-timeout.js @@ -7,14 +7,13 @@ require('../common'); function serverHandler(sock) { sock.setTimeout(120000); sock.resume(); - var timer; sock.on('close', function() { clearTimeout(timer); }); sock.on('error', function(err) { assert.strictEqual(err.code, 'ECONNRESET'); }); - timer = setTimeout(function() { + const timer = setTimeout(function() { sock.end('hello\n'); }, 100); } @@ -29,14 +28,14 @@ let countGC = 0; console.log('We should do ' + todo + ' requests'); -var server = net.createServer(serverHandler); +const server = net.createServer(serverHandler); server.listen(0, getall); function getall() { if (count >= todo) return; - const req = net.connect(server.address().port, server.address().address); + const req = net.connect(server.address().port); req.resume(); req.setTimeout(10, function() { req.destroy(); @@ -50,7 +49,7 @@ function getall() { setImmediate(getall); } -for (var i = 0; i < 10; i++) +for (let i = 0; i < 10; i++) getall(); function afterGC() { diff --git a/test/inspector/inspector-helper.js b/test/inspector/inspector-helper.js index 3e517123fe27f9..e22ca87dff7858 100644 --- a/test/inspector/inspector-helper.js +++ b/test/inspector/inspector-helper.js @@ -110,7 +110,7 @@ function makeBufferingDataCallback(dataCallback) { buffer = Buffer.alloc(0); else buffer = Buffer.from(lines.pop(), 'utf8'); - for (var line of lines) + for (const line of lines) dataCallback(line); }; } @@ -222,7 +222,7 @@ TestSession.prototype.sendInspectorCommands = function(commands) { }; TestSession.prototype.createCallbackWithTimeout_ = function(message) { - var promise = new Promise((resolve) => { + const promise = new Promise((resolve) => { this.enqueue((callback) => { const timeoutId = timeout(message); resolve(() => { diff --git a/test/inspector/test-inspector.js b/test/inspector/test-inspector.js index 7e53eaa55fffb7..a1c69cb6fbb2fe 100644 --- a/test/inspector/test-inspector.js +++ b/test/inspector/test-inspector.js @@ -114,10 +114,10 @@ function testSetBreakpointAndResume(session) { const commands = [ { 'method': 'Debugger.setBreakpointByUrl', 'params': { 'lineNumber': 5, - 'url': session.mainScriptPath, - 'columnNumber': 0, - 'condition': '' - } + 'url': session.mainScriptPath, + 'columnNumber': 0, + 'condition': '' + } }, { 'method': 'Debugger.resume'}, [ { 'method': 'Debugger.getScriptSource', diff --git a/test/internet/test-dgram-broadcast-multi-process.js b/test/internet/test-dgram-broadcast-multi-process.js index c05d0cf5b9512e..da3bd8cceb74e3 100644 --- a/test/internet/test-dgram-broadcast-multi-process.js +++ b/test/internet/test-dgram-broadcast-multi-process.js @@ -179,7 +179,7 @@ if (process.argv[2] !== 'child') { common.PORT, LOCAL_BROADCAST_HOST, function(err) { - if (err) throw err; + assert.ifError(err); console.error('[PARENT] sent %s to %s:%s', util.inspect(buf.toString()), LOCAL_BROADCAST_HOST, common.PORT); diff --git a/test/internet/test-dgram-multicast-multi-process.js b/test/internet/test-dgram-multicast-multi-process.js index 307549bba870b6..46f47a5982977e 100644 --- a/test/internet/test-dgram-multicast-multi-process.js +++ b/test/internet/test-dgram-multicast-multi-process.js @@ -13,6 +13,7 @@ const messages = [ ]; const workers = {}; const listeners = 3; +let listening, sendSocket, done, timer, dead; // Skip test in FreeBSD jails. @@ -76,10 +77,10 @@ function launchChildProcess(index) { Object.keys(workers).forEach(function(pid) { const worker = workers[pid]; - var count = 0; + let count = 0; worker.messagesReceived.forEach(function(buf) { - for (var i = 0; i < messages.length; ++i) { + for (let i = 0; i < messages.length; ++i) { if (buf.toString() === messages[i].toString()) { count++; break; @@ -110,13 +111,13 @@ function killChildren(children) { } if (process.argv[2] !== 'child') { - var listening = 0; - var dead = 0; - var i = 0; - var done = 0; + listening = 0; + dead = 0; + let i = 0; + done = 0; // Exit the test if it doesn't succeed within TIMEOUT. - var timer = setTimeout(function() { + timer = setTimeout(function() { console.error('[PARENT] Responses were not received within %d ms.', TIMEOUT); console.error('[PARENT] Fail'); @@ -127,11 +128,11 @@ if (process.argv[2] !== 'child') { }, TIMEOUT); // Launch child processes. - for (var x = 0; x < listeners; x++) { + for (let x = 0; x < listeners; x++) { launchChildProcess(x); } - var sendSocket = dgram.createSocket('udp4'); + sendSocket = dgram.createSocket('udp4'); // The socket is actually created async now. sendSocket.on('listening', function() { @@ -160,7 +161,7 @@ if (process.argv[2] !== 'child') { common.PORT, LOCAL_BROADCAST_HOST, function(err) { - if (err) throw err; + assert.ifError(err); console.error('[PARENT] sent "%s" to %s:%s', buf.toString(), LOCAL_BROADCAST_HOST, common.PORT); diff --git a/test/internet/test-dgram-send-cb-quelches-error.js b/test/internet/test-dgram-send-cb-quelches-error.js index 56612edead4fd2..abcc36859b96d9 100644 --- a/test/internet/test-dgram-send-cb-quelches-error.js +++ b/test/internet/test-dgram-send-cb-quelches-error.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var mustCall = common.mustCall; -var assert = require('assert'); -var dgram = require('dgram'); -var dns = require('dns'); +const common = require('../common'); +const mustCall = common.mustCall; +const assert = require('assert'); +const dgram = require('dgram'); +const dns = require('dns'); -var socket = dgram.createSocket('udp4'); -var buffer = Buffer.from('gary busey'); +const socket = dgram.createSocket('udp4'); +const buffer = Buffer.from('gary busey'); dns.setServers([]); diff --git a/test/internet/test-dns-cares-domains.js b/test/internet/test-dns-cares-domains.js index 76ebf0d628b1c4..5328d7e3d97925 100644 --- a/test/internet/test-dns-cares-domains.js +++ b/test/internet/test-dns-cares-domains.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var dns = require('dns'); -var domain = require('domain'); +const assert = require('assert'); +const dns = require('dns'); +const domain = require('domain'); -var methods = [ +const methods = [ 'resolve4', 'resolve6', 'resolveCname', @@ -18,7 +18,7 @@ var methods = [ ]; methods.forEach(function(method) { - var d = domain.create(); + const d = domain.create(); d.run(function() { dns[method]('google.com', function() { assert.strictEqual(process.domain, d, method + ' retains domain'); diff --git a/test/internet/test-dns-ipv4.js b/test/internet/test-dns-ipv4.js index a86c863cc443c9..c4f2d00df886d9 100644 --- a/test/internet/test-dns-ipv4.js +++ b/test/internet/test-dns-ipv4.js @@ -36,61 +36,61 @@ function checkWrap(req) { TEST(function test_resolve4(done) { const req = dns.resolve4('www.google.com', - common.mustCall((err, ips) => { - assert.ifError(err); + common.mustCall((err, ips) => { + assert.ifError(err); - assert.ok(ips.length > 0); + assert.ok(ips.length > 0); - for (let i = 0; i < ips.length; i++) { - assert.ok(isIPv4(ips[i])); - } + for (let i = 0; i < ips.length; i++) { + assert.ok(isIPv4(ips[i])); + } - done(); - })); + done(); + })); checkWrap(req); }); TEST(function test_reverse_ipv4(done) { const req = dns.reverse('8.8.8.8', - common.mustCall((err, domains) => { - assert.ifError(err); + common.mustCall((err, domains) => { + assert.ifError(err); - assert.ok(domains.length > 0); + assert.ok(domains.length > 0); - for (let i = 0; i < domains.length; i++) { - assert.ok(domains[i]); - assert.ok(typeof domains[i] === 'string'); - } + for (let i = 0; i < domains.length; i++) { + assert.ok(domains[i]); + assert.ok(typeof domains[i] === 'string'); + } - done(); - })); + done(); + })); checkWrap(req); }); TEST(function test_lookup_ipv4_explicit(done) { const req = dns.lookup('www.google.com', 4, - common.mustCall((err, ip, family) => { - assert.ifError(err); - assert.ok(net.isIPv4(ip)); - assert.strictEqual(family, 4); + common.mustCall((err, ip, family) => { + assert.ifError(err); + assert.ok(net.isIPv4(ip)); + assert.strictEqual(family, 4); - done(); - })); + done(); + })); checkWrap(req); }); TEST(function test_lookup_ipv4_implicit(done) { const req = dns.lookup('www.google.com', - common.mustCall((err, ip, family) => { - assert.ifError(err); - assert.ok(net.isIPv4(ip)); - assert.strictEqual(family, 4); + common.mustCall((err, ip, family) => { + assert.ifError(err); + assert.ok(net.isIPv4(ip)); + assert.strictEqual(family, 4); - done(); - })); + done(); + })); checkWrap(req); }); @@ -125,26 +125,26 @@ TEST(function test_lookup_ipv4_hint_addrconfig(done) { TEST(function test_lookup_ip_ipv4(done) { const req = dns.lookup('127.0.0.1', - common.mustCall((err, ip, family) => { - assert.ifError(err); - assert.strictEqual(ip, '127.0.0.1'); - assert.strictEqual(family, 4); + common.mustCall((err, ip, family) => { + assert.ifError(err); + assert.strictEqual(ip, '127.0.0.1'); + assert.strictEqual(family, 4); - done(); - })); + done(); + })); checkWrap(req); }); TEST(function test_lookup_localhost_ipv4(done) { const req = dns.lookup('localhost', 4, - common.mustCall((err, ip, family) => { - assert.ifError(err); - assert.strictEqual(ip, '127.0.0.1'); - assert.strictEqual(family, 4); + common.mustCall((err, ip, family) => { + assert.ifError(err); + assert.strictEqual(ip, '127.0.0.1'); + assert.strictEqual(family, 4); - done(); - })); + done(); + })); checkWrap(req); }); @@ -164,21 +164,23 @@ TEST(function test_lookup_all_ipv4(done) { }); done(); - } - )); + }) + ); checkWrap(req); }); TEST(function test_lookupservice_ip_ipv4(done) { - const req = dns.lookupService('127.0.0.1', 80, + const req = dns.lookupService( + '127.0.0.1', 80, common.mustCall((err, host, service) => { assert.ifError(err); assert.strictEqual(typeof host, 'string'); assert(host); assert(['http', 'www', '80'].includes(service)); done(); - })); + }) + ); checkWrap(req); }); diff --git a/test/internet/test-dns-ipv6.js b/test/internet/test-dns-ipv6.js index b2cdd14c53a60c..34382660f24423 100644 --- a/test/internet/test-dns-ipv6.js +++ b/test/internet/test-dns-ipv6.js @@ -41,45 +41,45 @@ function checkWrap(req) { TEST(function test_resolve6(done) { const req = dns.resolve6('ipv6.google.com', - common.mustCall((err, ips) => { - assert.ifError(err); + common.mustCall((err, ips) => { + assert.ifError(err); - assert.ok(ips.length > 0); + assert.ok(ips.length > 0); - for (let i = 0; i < ips.length; i++) - assert.ok(isIPv6(ips[i])); + for (let i = 0; i < ips.length; i++) + assert.ok(isIPv6(ips[i])); - done(); - })); + done(); + })); checkWrap(req); }); TEST(function test_reverse_ipv6(done) { const req = dns.reverse('2001:4860:4860::8888', - common.mustCall((err, domains) => { - assert.ifError(err); + common.mustCall((err, domains) => { + assert.ifError(err); - assert.ok(domains.length > 0); + assert.ok(domains.length > 0); - for (let i = 0; i < domains.length; i++) - assert.ok(typeof domains[i] === 'string'); + for (let i = 0; i < domains.length; i++) + assert.ok(typeof domains[i] === 'string'); - done(); - })); + done(); + })); checkWrap(req); }); TEST(function test_lookup_ipv6_explicit(done) { const req = dns.lookup('ipv6.google.com', 6, - common.mustCall((err, ip, family) => { - assert.ifError(err); - assert.ok(isIPv6(ip)); - assert.strictEqual(family, 6); + common.mustCall((err, ip, family) => { + assert.ifError(err); + assert.ok(isIPv6(ip)); + assert.strictEqual(family, 6); - done(); - })); + done(); + })); checkWrap(req); }); @@ -87,7 +87,7 @@ TEST(function test_lookup_ipv6_explicit(done) { /* This ends up just being too problematic to test TEST(function test_lookup_ipv6_implicit(done) { var req = dns.lookup('ipv6.google.com', function(err, ip, family) { - if (err) throw err; + assert.ifError(err); assert.ok(net.isIPv6(ip)); assert.strictEqual(family, 6); @@ -142,13 +142,13 @@ TEST(function test_lookup_ipv6_hint(done) { TEST(function test_lookup_ip_ipv6(done) { const req = dns.lookup('::1', - common.mustCall((err, ip, family) => { - assert.ifError(err); - assert.ok(isIPv6(ip)); - assert.strictEqual(family, 6); + common.mustCall((err, ip, family) => { + assert.ifError(err); + assert.ok(isIPv6(ip)); + assert.strictEqual(family, 6); - done(); - })); + done(); + })); checkWrap(req); }); @@ -169,14 +169,15 @@ TEST(function test_lookup_all_ipv6(done) { }); done(); - } - )); + }) + ); checkWrap(req); }); TEST(function test_lookupservice_ip_ipv6(done) { - const req = dns.lookupService('::1', 80, + const req = dns.lookupService( + '::1', 80, common.mustCall((err, host, service) => { if (err) { // Not skipping the test, rather checking an alternative result, @@ -188,7 +189,8 @@ TEST(function test_lookupservice_ip_ipv6(done) { assert(host); assert(['http', 'www', '80'].includes(service)); done(); - })); + }) + ); checkWrap(req); }); @@ -196,7 +198,7 @@ TEST(function test_lookupservice_ip_ipv6(done) { /* Disabled because it appears to be not working on linux. */ /* TEST(function test_lookup_localhost_ipv6(done) { var req = dns.lookup('localhost', 6, function(err, ip, family) { - if (err) throw err; + assert.ifError(err); assert.ok(net.isIPv6(ip)); assert.strictEqual(family, 6); diff --git a/test/internet/test-dns-txt-sigsegv.js b/test/internet/test-dns-txt-sigsegv.js index 4c2f12f7a97c28..54cc4648510ed7 100644 --- a/test/internet/test-dns-txt-sigsegv.js +++ b/test/internet/test-dns-txt-sigsegv.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var dns = require('dns'); +const assert = require('assert'); +const dns = require('dns'); dns.resolveTxt('www.microsoft.com', function(err, records) { - assert.equal(err, null); - assert.equal(records.length, 0); + assert.strictEqual(err, null); + assert.strictEqual(records.length, 0); }); diff --git a/test/internet/test-dns.js b/test/internet/test-dns.js index db3449dc727516..3e154a5afad3fa 100644 --- a/test/internet/test-dns.js +++ b/test/internet/test-dns.js @@ -1,5 +1,5 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const dns = require('dns'); const net = require('net'); @@ -15,7 +15,7 @@ const queue = []; function TEST(f) { function next() { - var f = queue.shift(); + const f = queue.shift(); if (f) { running = true; console.log(f.name); @@ -44,29 +44,19 @@ function checkWrap(req) { TEST(function test_reverse_bogus(done) { - var error; - - try { - dns.reverse('bogus ip', function() { - assert.ok(false); - }); - } catch (e) { - error = e; - } - - assert.ok(error instanceof Error); - assert.strictEqual(error.errno, 'EINVAL'); - + assert.throws(() => { + dns.reverse('bogus ip', common.fail); + }, /^Error: getHostByAddr EINVAL$/); done(); }); TEST(function test_resolve4_ttl(done) { - var req = dns.resolve4('google.com', { ttl: true }, function(err, result) { + const req = dns.resolve4('google.com', { ttl: true }, function(err, result) { assert.ifError(err); assert.ok(result.length > 0); - for (var i = 0; i < result.length; i++) { - var item = result[i]; + for (let i = 0; i < result.length; i++) { + const item = result[i]; assert.ok(item); assert.strictEqual(typeof item, 'object'); assert.strictEqual(typeof item.ttl, 'number'); @@ -82,12 +72,12 @@ TEST(function test_resolve4_ttl(done) { }); TEST(function test_resolve6_ttl(done) { - var req = dns.resolve6('google.com', { ttl: true }, function(err, result) { + const req = dns.resolve6('google.com', { ttl: true }, function(err, result) { assert.ifError(err); assert.ok(result.length > 0); - for (var i = 0; i < result.length; i++) { - var item = result[i]; + for (let i = 0; i < result.length; i++) { + const item = result[i]; assert.ok(item); assert.strictEqual(typeof item, 'object'); assert.strictEqual(typeof item.ttl, 'number'); @@ -103,13 +93,12 @@ TEST(function test_resolve6_ttl(done) { }); TEST(function test_resolveMx(done) { - var req = dns.resolveMx('gmail.com', function(err, result) { - if (err) throw err; - + const req = dns.resolveMx('gmail.com', function(err, result) { + assert.ifError(err); assert.ok(result.length > 0); - for (var i = 0; i < result.length; i++) { - var item = result[i]; + for (let i = 0; i < result.length; i++) { + const item = result[i]; assert.ok(item); assert.strictEqual(typeof item, 'object'); @@ -126,7 +115,7 @@ TEST(function test_resolveMx(done) { }); TEST(function test_resolveMx_failure(done) { - var req = dns.resolveMx('something.invalid', function(err, result) { + const req = dns.resolveMx('something.invalid', function(err, result) { assert.ok(err instanceof Error); assert.strictEqual(err.errno, 'ENOTFOUND'); @@ -139,13 +128,12 @@ TEST(function test_resolveMx_failure(done) { }); TEST(function test_resolveNs(done) { - var req = dns.resolveNs('rackspace.com', function(err, names) { - if (err) throw err; - + const req = dns.resolveNs('rackspace.com', function(err, names) { + assert.ifError(err); assert.ok(names.length > 0); - for (var i = 0; i < names.length; i++) { - var name = names[i]; + for (let i = 0; i < names.length; i++) { + const name = names[i]; assert.ok(name); assert.strictEqual(typeof name, 'string'); } @@ -157,7 +145,7 @@ TEST(function test_resolveNs(done) { }); TEST(function test_resolveNs_failure(done) { - var req = dns.resolveNs('something.invalid', function(err, result) { + const req = dns.resolveNs('something.invalid', function(err, result) { assert.ok(err instanceof Error); assert.strictEqual(err.errno, 'ENOTFOUND'); @@ -170,13 +158,12 @@ TEST(function test_resolveNs_failure(done) { }); TEST(function test_resolveSrv(done) { - var req = dns.resolveSrv('_jabber._tcp.google.com', function(err, result) { - if (err) throw err; - + const req = dns.resolveSrv('_jabber._tcp.google.com', function(err, result) { + assert.ifError(err); assert.ok(result.length > 0); - for (var i = 0; i < result.length; i++) { - var item = result[i]; + for (let i = 0; i < result.length; i++) { + const item = result[i]; assert.ok(item); assert.strictEqual(typeof item, 'object'); @@ -195,7 +182,7 @@ TEST(function test_resolveSrv(done) { }); TEST(function test_resolveSrv_failure(done) { - var req = dns.resolveSrv('something.invalid', function(err, result) { + const req = dns.resolveSrv('something.invalid', function(err, result) { assert.ok(err instanceof Error); assert.strictEqual(err.errno, 'ENOTFOUND'); @@ -208,13 +195,12 @@ TEST(function test_resolveSrv_failure(done) { }); TEST(function test_resolvePtr(done) { - var req = dns.resolvePtr('8.8.8.8.in-addr.arpa', function(err, result) { - if (err) throw err; - + const req = dns.resolvePtr('8.8.8.8.in-addr.arpa', function(err, result) { + assert.ifError(err); assert.ok(result.length > 0); - for (var i = 0; i < result.length; i++) { - var item = result[i]; + for (let i = 0; i < result.length; i++) { + const item = result[i]; assert.ok(item); assert.strictEqual(typeof item, 'string'); } @@ -226,7 +212,7 @@ TEST(function test_resolvePtr(done) { }); TEST(function test_resolvePtr_failure(done) { - var req = dns.resolvePtr('something.invalid', function(err, result) { + const req = dns.resolvePtr('something.invalid', function(err, result) { assert.ok(err instanceof Error); assert.strictEqual(err.errno, 'ENOTFOUND'); @@ -239,13 +225,12 @@ TEST(function test_resolvePtr_failure(done) { }); TEST(function test_resolveNaptr(done) { - var req = dns.resolveNaptr('sip2sip.info', function(err, result) { - if (err) throw err; - + const req = dns.resolveNaptr('sip2sip.info', function(err, result) { + assert.ifError(err); assert.ok(result.length > 0); - for (var i = 0; i < result.length; i++) { - var item = result[i]; + for (let i = 0; i < result.length; i++) { + const item = result[i]; assert.ok(item); assert.strictEqual(typeof item, 'object'); @@ -264,7 +249,7 @@ TEST(function test_resolveNaptr(done) { }); TEST(function test_resolveNaptr_failure(done) { - var req = dns.resolveNaptr('something.invalid', function(err, result) { + const req = dns.resolveNaptr('something.invalid', function(err, result) { assert.ok(err instanceof Error); assert.strictEqual(err.errno, 'ENOTFOUND'); @@ -277,9 +262,8 @@ TEST(function test_resolveNaptr_failure(done) { }); TEST(function test_resolveSoa(done) { - var req = dns.resolveSoa('nodejs.org', function(err, result) { - if (err) throw err; - + const req = dns.resolveSoa('nodejs.org', function(err, result) { + assert.ifError(err); assert.ok(result); assert.strictEqual(typeof result, 'object'); @@ -311,7 +295,7 @@ TEST(function test_resolveSoa(done) { }); TEST(function test_resolveSoa_failure(done) { - var req = dns.resolveSoa('something.invalid', function(err, result) { + const req = dns.resolveSoa('something.invalid', function(err, result) { assert.ok(err instanceof Error); assert.strictEqual(err.errno, 'ENOTFOUND'); @@ -324,13 +308,12 @@ TEST(function test_resolveSoa_failure(done) { }); TEST(function test_resolveCname(done) { - var req = dns.resolveCname('www.microsoft.com', function(err, names) { - if (err) throw err; - + const req = dns.resolveCname('www.microsoft.com', function(err, names) { + assert.ifError(err); assert.ok(names.length > 0); - for (var i = 0; i < names.length; i++) { - var name = names[i]; + for (let i = 0; i < names.length; i++) { + const name = names[i]; assert.ok(name); assert.strictEqual(typeof name, 'string'); } @@ -342,7 +325,7 @@ TEST(function test_resolveCname(done) { }); TEST(function test_resolveCname_failure(done) { - var req = dns.resolveCname('something.invalid', function(err, result) { + const req = dns.resolveCname('something.invalid', function(err, result) { assert.ok(err instanceof Error); assert.strictEqual(err.errno, 'ENOTFOUND'); @@ -356,8 +339,8 @@ TEST(function test_resolveCname_failure(done) { TEST(function test_resolveTxt(done) { - var req = dns.resolveTxt('google.com', function(err, records) { - if (err) throw err; + const req = dns.resolveTxt('google.com', function(err, records) { + assert.ifError(err); assert.strictEqual(records.length, 1); assert.ok(util.isArray(records[0])); assert.strictEqual(records[0][0].indexOf('v=spf1'), 0); @@ -368,7 +351,7 @@ TEST(function test_resolveTxt(done) { }); TEST(function test_resolveTxt_failure(done) { - var req = dns.resolveTxt('something.invalid', function(err, result) { + const req = dns.resolveTxt('something.invalid', function(err, result) { assert.ok(err instanceof Error); assert.strictEqual(err.errno, 'ENOTFOUND'); @@ -382,7 +365,7 @@ TEST(function test_resolveTxt_failure(done) { TEST(function test_lookup_failure(done) { - var req = dns.lookup('does.not.exist', 4, function(err, ip, family) { + const req = dns.lookup('does.not.exist', 4, function(err, ip, family) { assert.ok(err instanceof Error); assert.strictEqual(err.errno, dns.NOTFOUND); assert.strictEqual(err.errno, 'ENOTFOUND'); @@ -397,8 +380,8 @@ TEST(function test_lookup_failure(done) { TEST(function test_lookup_null(done) { - var req = dns.lookup(null, function(err, ip, family) { - if (err) throw err; + const req = dns.lookup(null, function(err, ip, family) { + assert.ifError(err); assert.strictEqual(ip, null); assert.strictEqual(family, 4); @@ -410,8 +393,8 @@ TEST(function test_lookup_null(done) { TEST(function test_lookup_ip_all(done) { - var req = dns.lookup('127.0.0.1', {all: true}, function(err, ips, family) { - if (err) throw err; + const req = dns.lookup('127.0.0.1', {all: true}, function(err, ips, family) { + assert.ifError(err); assert.ok(Array.isArray(ips)); assert.ok(ips.length > 0); assert.strictEqual(ips[0].address, '127.0.0.1'); @@ -425,8 +408,8 @@ TEST(function test_lookup_ip_all(done) { TEST(function test_lookup_null_all(done) { - var req = dns.lookup(null, {all: true}, function(err, ips, family) { - if (err) throw err; + const req = dns.lookup(null, {all: true}, function(err, ips, family) { + assert.ifError(err); assert.ok(Array.isArray(ips)); assert.strictEqual(ips.length, 0); @@ -438,8 +421,8 @@ TEST(function test_lookup_null_all(done) { TEST(function test_lookup_all_mixed(done) { - var req = dns.lookup('www.google.com', {all: true}, function(err, ips) { - if (err) throw err; + const req = dns.lookup('www.google.com', {all: true}, function(err, ips) { + assert.ifError(err); assert.ok(Array.isArray(ips)); assert.ok(ips.length > 0); @@ -449,7 +432,7 @@ TEST(function test_lookup_all_mixed(done) { else if (isIPv6(ip.address)) assert.strictEqual(ip.family, 6); else - assert(false); + common.fail('unexpected IP address'); }); done(); @@ -460,7 +443,7 @@ TEST(function test_lookup_all_mixed(done) { TEST(function test_lookupservice_invalid(done) { - var req = dns.lookupService('1.2.3.4', 80, function(err, host, service) { + const req = dns.lookupService('1.2.3.4', 80, function(err, host, service) { assert(err instanceof Error); assert.strictEqual(err.code, 'ENOTFOUND'); assert.ok(/1\.2\.3\.4/.test(err.message)); @@ -473,7 +456,7 @@ TEST(function test_lookupservice_invalid(done) { TEST(function test_reverse_failure(done) { - var req = dns.reverse('0.0.0.0', function(err) { + const req = dns.reverse('0.0.0.0', function(err) { assert(err instanceof Error); assert.strictEqual(err.code, 'ENOTFOUND'); // Silly error code... assert.strictEqual(err.hostname, '0.0.0.0'); @@ -487,7 +470,7 @@ TEST(function test_reverse_failure(done) { TEST(function test_lookup_failure(done) { - var req = dns.lookup('nosuchhostimsure', function(err) { + const req = dns.lookup('nosuchhostimsure', function(err) { assert(err instanceof Error); assert.strictEqual(err.code, 'ENOTFOUND'); // Silly error code... assert.strictEqual(err.hostname, 'nosuchhostimsure'); @@ -501,7 +484,7 @@ TEST(function test_lookup_failure(done) { TEST(function test_resolve_failure(done) { - var req = dns.resolve4('nosuchhostimsure', function(err) { + const req = dns.resolve4('nosuchhostimsure', function(err) { assert(err instanceof Error); switch (err.code) { @@ -523,12 +506,12 @@ TEST(function test_resolve_failure(done) { }); -var getaddrinfoCallbackCalled = false; +let getaddrinfoCallbackCalled = false; console.log('looking up nodejs.org...'); -var cares = process.binding('cares_wrap'); -var req = new cares.GetAddrInfoReqWrap(); +const cares = process.binding('cares_wrap'); +const req = new cares.GetAddrInfoReqWrap(); cares.getaddrinfo(req, 'nodejs.org', 4); req.oncomplete = function(err, domains) { diff --git a/test/internet/test-http-https-default-ports.js b/test/internet/test-http-https-default-ports.js index 8b00e434e9cba6..c7e6b3baf7ccdc 100644 --- a/test/internet/test-http-https-default-ports.js +++ b/test/internet/test-http-https-default-ports.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var http = require('http'); +const http = require('http'); https.get('https://www.google.com/', common.mustCall(function(res) { res.resume(); diff --git a/test/internet/test-net-connect-timeout.js b/test/internet/test-net-connect-timeout.js index 0f58622aa19912..95e25614ffa2b7 100644 --- a/test/internet/test-net-connect-timeout.js +++ b/test/internet/test-net-connect-timeout.js @@ -4,24 +4,24 @@ // https://groups.google.com/forum/#!topic/nodejs-dev/jR7-5UDqXkw const common = require('../common'); -var net = require('net'); -var assert = require('assert'); +const net = require('net'); +const assert = require('assert'); -var start = new Date(); +const start = new Date(); -var T = 100; +const T = 100; // 192.0.2.1 is part of subnet assigned as "TEST-NET" in RFC 5737. // For use solely in documentation and example source code. // In short, it should be unreachable. // In practice, it's a network black hole. -var socket = net.createConnection(9999, '192.0.2.1'); +const socket = net.createConnection(9999, '192.0.2.1'); socket.setTimeout(T); socket.on('timeout', common.mustCall(function() { console.error('timeout'); - var now = new Date(); + const now = new Date(); assert.ok(now - start < T + 500); socket.destroy(); })); diff --git a/test/internet/test-net-connect-unref.js b/test/internet/test-net-connect-unref.js index 52929d2152774d..f3be8409844702 100644 --- a/test/internet/test-net-connect-unref.js +++ b/test/internet/test-net-connect-unref.js @@ -1,11 +1,10 @@ 'use strict'; const common = require('../common'); -var net = require('net'); +const net = require('net'); -var client; -var TIMEOUT = 10 * 1000; +const TIMEOUT = 10 * 1000; -client = net.createConnection(53, '8.8.8.8', function() { +const client = net.createConnection(53, '8.8.8.8', function() { client.unref(); }); diff --git a/test/internet/test-tls-add-ca-cert.js b/test/internet/test-tls-add-ca-cert.js new file mode 100644 index 00000000000000..135b9215feaa4f --- /dev/null +++ b/test/internet/test-tls-add-ca-cert.js @@ -0,0 +1,55 @@ +'use strict'; +const common = require('../common'); + +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + +// Test interaction of compiled-in CAs with user-provided CAs. + +const assert = require('assert'); +const fs = require('fs'); +const tls = require('tls'); + +function filenamePEM(n) { + return require('path').join(common.fixturesDir, 'keys', n + '.pem'); +} + +function loadPEM(n) { + return fs.readFileSync(filenamePEM(n)); +} + +const caCert = loadPEM('ca1-cert'); + +const opts = { + host: 'www.nodejs.org', + port: 443, + rejectUnauthorized: true +}; + +// Success relies on the compiled in well-known root CAs +tls.connect(opts, common.mustCall(end)); + +// The .ca option replaces the well-known roots, so connection fails. +opts.ca = caCert; +tls.connect(opts, fail).on('error', common.mustCall((err) => { + assert.strictEqual(err.message, 'unable to get local issuer certificate'); +})); + +function fail() { + common.fail('should fail to connect'); +} + +// New secure contexts have the well-known root CAs. +opts.secureContext = tls.createSecureContext(); +tls.connect(opts, common.mustCall(end)); + +// Explicit calls to addCACert() add to the default well-known roots, instead +// of replacing, so connection still succeeds. +opts.secureContext.context.addCACert(caCert); +tls.connect(opts, common.mustCall(end)); + +function end() { + this.end(); +} diff --git a/test/internet/test-tls-connnect-melissadata.js b/test/internet/test-tls-connnect-melissadata.js index 7ab7f2aa7a7895..f57b897099fc2d 100644 --- a/test/internet/test-tls-connnect-melissadata.js +++ b/test/internet/test-tls-connnect-melissadata.js @@ -2,14 +2,14 @@ // Test for authorized access to the server which has a cross root // certification between Starfield Class 2 and ValiCert Class 2 -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var socket = tls.connect(443, 'address.melissadata.net', function() { +const tls = require('tls'); +const socket = tls.connect(443, 'address.melissadata.net', function() { socket.resume(); socket.destroy(); }); diff --git a/test/known_issues/test-url-parse-conformance.js b/test/known_issues/test-url-parse-conformance.js index d70a322d6b7455..f7fcec821c8e50 100644 --- a/test/known_issues/test-url-parse-conformance.js +++ b/test/known_issues/test-url-parse-conformance.js @@ -9,14 +9,14 @@ const path = require('path'); const tests = require(path.join(common.fixturesDir, 'url-tests.json')); -var failed = 0; -var attempted = 0; +let failed = 0; +let attempted = 0; tests.forEach((test) => { attempted++; // Skip comments if (typeof test === 'string') return; - var parsed; + let parsed; try { // Attempt to parse @@ -28,7 +28,7 @@ tests.forEach((test) => { } else { // Test was not supposed to fail, so we're good so far. Now // check the results of the parse. - var username, password; + let username, password; try { assert.strictEqual(test.href, parsed.href); assert.strictEqual(test.protocol, parsed.protocol); diff --git a/test/known_issues/test-vm-data-property-writable.js b/test/known_issues/test-vm-data-property-writable.js new file mode 100644 index 00000000000000..f29052a73a7b6b --- /dev/null +++ b/test/known_issues/test-vm-data-property-writable.js @@ -0,0 +1,17 @@ +'use strict'; +// Refs: https://github.com/nodejs/node/issues/10223 + +require('../common'); +const vm = require('vm'); +const assert = require('assert'); + +const context = vm.createContext({}); + +const code = ` + Object.defineProperty(this, 'foo', {value: 5}); + Object.getOwnPropertyDescriptor(this, 'foo'); +`; + +const desc = vm.runInContext(code, context); + +assert.strictEqual(desc.writable, false); diff --git a/test/known_issues/test-vm-global-non-writable-properties.js b/test/known_issues/test-vm-global-non-writable-properties.js new file mode 100644 index 00000000000000..8d7dfce55e3d81 --- /dev/null +++ b/test/known_issues/test-vm-global-non-writable-properties.js @@ -0,0 +1,16 @@ +'use strict'; +// https://github.com/nodejs/node/issues/10223 + +require('../common'); +const assert = require('assert'); +const vm = require('vm'); + +const ctx = vm.createContext(); +vm.runInContext('Object.defineProperty(this, "x", { value: 42 })', ctx); +assert.strictEqual(ctx.x, undefined); // Not copied out by cloneProperty(). +assert.strictEqual(vm.runInContext('x', ctx), 42); +vm.runInContext('x = 0', ctx); // Does not throw but x... +assert.strictEqual(vm.runInContext('x', ctx), 42); // ...should be unaltered. +assert.throws(() => vm.runInContext('"use strict"; x = 0', ctx), + /Cannot assign to read only property 'x'/); +assert.strictEqual(vm.runInContext('x', ctx), 42); diff --git a/test/message/error_exit.js b/test/message/error_exit.js index 18d9dfb4ee998c..1cb785a1b543a6 100644 --- a/test/message/error_exit.js +++ b/test/message/error_exit.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); process.on('exit', function(code) { console.error('Exiting with code=%d', code); }); -assert.equal(1, 2); +assert.strictEqual(1, 2); diff --git a/test/message/error_exit.out b/test/message/error_exit.out index e25af05861b5ce..e2a29ab42dbbd2 100644 --- a/test/message/error_exit.out +++ b/test/message/error_exit.out @@ -3,7 +3,7 @@ Exiting with code=1 assert.js:* throw new assert.AssertionError({ ^ -AssertionError: 1 == 2 +AssertionError: 1 === 2 at Object. (*test*message*error_exit.js:*:*) at Module._compile (module.js:*:*) at Object.Module._extensions..js (module.js:*:*) diff --git a/test/message/eval_messages.js b/test/message/eval_messages.js index bb1569601c889f..d50df9081b2d25 100644 --- a/test/message/eval_messages.js +++ b/test/message/eval_messages.js @@ -2,19 +2,19 @@ require('../common'); -var spawn = require('child_process').spawn; +const spawn = require('child_process').spawn; function run(cmd, strict, cb) { - var args = []; + const args = []; if (strict) args.push('--use_strict'); args.push('-pe', cmd); - var child = spawn(process.execPath, args); + const child = spawn(process.execPath, args); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stdout); child.on('close', cb); } -var queue = +const queue = [ 'with(this){__filename}', '42', 'throw new Error("hello")', @@ -22,7 +22,7 @@ var queue = 'var ______________________________________________; throw 10' ]; function go() { - var c = queue.shift(); + const c = queue.shift(); if (!c) return console.log('done'); run(c, false, function() { run(c, true, go); diff --git a/test/message/max_tick_depth.js b/test/message/max_tick_depth.js index 1d2ec175c5d957..c433c0bab3f100 100644 --- a/test/message/max_tick_depth.js +++ b/test/message/max_tick_depth.js @@ -2,7 +2,7 @@ require('../common'); process.maxTickDepth = 10; -var i = 20; +let i = 20; process.nextTick(function f() { console.error('tick %d', i); if (i-- > 0) diff --git a/test/message/stdin_messages.js b/test/message/stdin_messages.js index 6e1ced4124f2a6..b32004c329dead 100644 --- a/test/message/stdin_messages.js +++ b/test/message/stdin_messages.js @@ -2,20 +2,20 @@ require('../common'); -var spawn = require('child_process').spawn; +const spawn = require('child_process').spawn; function run(cmd, strict, cb) { - var args = []; + const args = []; if (strict) args.push('--use_strict'); args.push('-p'); - var child = spawn(process.execPath, args); + const child = spawn(process.execPath, args); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stdout); child.stdin.end(cmd); child.on('close', cb); } -var queue = +const queue = [ 'with(this){__filename}', '42', 'throw new Error("hello")', @@ -23,7 +23,7 @@ var queue = 'var ______________________________________________; throw 10' ]; function go() { - var c = queue.shift(); + const c = queue.shift(); if (!c) return console.log('done'); run(c, false, function() { run(c, true, go); diff --git a/test/message/timeout_throw.js b/test/message/timeout_throw.js index 14291fabd12565..4008f306fe58be 100644 --- a/test/message/timeout_throw.js +++ b/test/message/timeout_throw.js @@ -4,4 +4,4 @@ require('../common'); setTimeout(function() { // eslint-disable-next-line no-undef undefined_reference_error_maker; -}); +}, 1); diff --git a/test/message/undefined_reference_in_new_context.js b/test/message/undefined_reference_in_new_context.js index 73821ae53d4f5f..77c5e1e29111b9 100644 --- a/test/message/undefined_reference_in_new_context.js +++ b/test/message/undefined_reference_in_new_context.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var vm = require('vm'); +const vm = require('vm'); console.error('before'); diff --git a/test/message/vm_display_runtime_error.js b/test/message/vm_display_runtime_error.js index a7ca9907444181..861e87f2f2bb93 100644 --- a/test/message/vm_display_runtime_error.js +++ b/test/message/vm_display_runtime_error.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var vm = require('vm'); +const vm = require('vm'); console.error('beginning'); diff --git a/test/message/vm_display_syntax_error.js b/test/message/vm_display_syntax_error.js index 62bbd432a2f98a..02612fb92d9a22 100644 --- a/test/message/vm_display_syntax_error.js +++ b/test/message/vm_display_syntax_error.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var vm = require('vm'); +const vm = require('vm'); console.error('beginning'); diff --git a/test/message/vm_dont_display_runtime_error.js b/test/message/vm_dont_display_runtime_error.js index 19d0120a90abfd..6a96243a83cf4a 100644 --- a/test/message/vm_dont_display_runtime_error.js +++ b/test/message/vm_dont_display_runtime_error.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var vm = require('vm'); +const vm = require('vm'); console.error('beginning'); diff --git a/test/message/vm_dont_display_syntax_error.js b/test/message/vm_dont_display_syntax_error.js index bff0433a144b09..76c3043330946d 100644 --- a/test/message/vm_dont_display_syntax_error.js +++ b/test/message/vm_dont_display_syntax_error.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var vm = require('vm'); +const vm = require('vm'); console.error('beginning'); diff --git a/test/parallel/test-assert-typedarray-deepequal.js b/test/parallel/test-assert-typedarray-deepequal.js index 2e6c88848a809f..f5ecb274a86a32 100644 --- a/test/parallel/test-assert-typedarray-deepequal.js +++ b/test/parallel/test-assert-typedarray-deepequal.js @@ -5,7 +5,7 @@ const assert = require('assert'); const a = require('assert'); function makeBlock(f) { - var args = Array.prototype.slice.call(arguments, 1); + const args = Array.prototype.slice.call(arguments, 1); return function() { return f.apply(this, args); }; diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index eb983345418637..f9e82c758a6509 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var a = require('assert'); +const assert = require('assert'); +const a = require('assert'); function makeBlock(f) { - var args = Array.prototype.slice.call(arguments, 1); + const args = Array.prototype.slice.call(arguments, 1); return function() { return f.apply(this, args); }; @@ -64,7 +64,7 @@ assert.doesNotThrow(makeBlock(a.notStrictEqual, 2, '2'), // deepEqual joy! // 7.2 assert.doesNotThrow(makeBlock(a.deepEqual, new Date(2000, 3, 14), - new Date(2000, 3, 14)), + new Date(2000, 3, 14)), 'deepEqual(new Date(2000, 3, 14), new Date(2000, 3, 14))'); assert.throws(makeBlock(a.deepEqual, new Date(), new Date(2000, 3, 14)), @@ -81,7 +81,7 @@ assert.doesNotThrow(makeBlock( a.notDeepEqual, new Date(), new Date(2000, 3, 14)), - 'notDeepEqual(new Date(), new Date(2000, 3, 14))' + 'notDeepEqual(new Date(), new Date(2000, 3, 14))' ); // 7.3 @@ -90,16 +90,23 @@ assert.doesNotThrow(makeBlock(a.deepEqual, /a/g, /a/g)); assert.doesNotThrow(makeBlock(a.deepEqual, /a/i, /a/i)); assert.doesNotThrow(makeBlock(a.deepEqual, /a/m, /a/m)); assert.doesNotThrow(makeBlock(a.deepEqual, /a/igm, /a/igm)); -assert.throws(makeBlock(a.deepEqual, /ab/, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/g, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/i, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/m, /a/)); -assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im)); +assert.throws(makeBlock(a.deepEqual, /ab/, /a/), + /^AssertionError: \/ab\/ deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/g, /a/), + /^AssertionError: \/a\/g deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/i, /a/), + /^AssertionError: \/a\/i deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/m, /a/), + /^AssertionError: \/a\/m deepEqual \/a\/$/); +assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im), + /^AssertionError: \/a\/gim deepEqual \/a\/im$/); { - const re1 = /a/; + const re1 = /a/g; re1.lastIndex = 3; - assert.throws(makeBlock(a.deepEqual, re1, /a/)); + + assert.throws(makeBlock(a.deepEqual, re1, /a/g), + /^AssertionError: \/a\/g deepEqual \/a\/g$/); } @@ -120,8 +127,8 @@ assert.throws(makeBlock(a.deepEqual, {a: 4}, {a: 4, b: true}), assert.doesNotThrow(makeBlock(a.deepEqual, ['a'], {0: 'a'})); //(although not necessarily the same order), assert.doesNotThrow(makeBlock(a.deepEqual, {a: 4, b: '1'}, {b: '1', a: 4})); -var a1 = [1, 2, 3]; -var a2 = [1, 2, 3]; +const a1 = [1, 2, 3]; +const a2 = [1, 2, 3]; a1.a = 'test'; a1.b = true; a2.b = true; @@ -131,7 +138,7 @@ assert.throws(makeBlock(a.deepEqual, Object.keys(a1), Object.keys(a2)), assert.doesNotThrow(makeBlock(a.deepEqual, a1, a2)); // having an identical prototype property -var nbRoot = { +const nbRoot = { toString: function() { return this.first + ' ' + this.last; } }; @@ -149,8 +156,8 @@ function nameBuilder2(first, last) { } nameBuilder2.prototype = nbRoot; -var nb1 = new nameBuilder('Ryan', 'Dahl'); -var nb2 = new nameBuilder2('Ryan', 'Dahl'); +const nb1 = new nameBuilder('Ryan', 'Dahl'); +let nb2 = new nameBuilder2('Ryan', 'Dahl'); assert.doesNotThrow(makeBlock(a.deepEqual, nb1, nb2)); @@ -209,11 +216,26 @@ assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/g, /a/g)); assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/i, /a/i)); assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/m, /a/m)); assert.doesNotThrow(makeBlock(a.deepStrictEqual, /a/igm, /a/igm)); -assert.throws(makeBlock(a.deepStrictEqual, /ab/, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/g, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/i, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/m, /a/)); -assert.throws(makeBlock(a.deepStrictEqual, /a/igm, /a/im)); +assert.throws( + makeBlock(a.deepStrictEqual, /ab/, /a/), + /^AssertionError: \/ab\/ deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/g, /a/), + /^AssertionError: \/a\/g deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/i, /a/), + /^AssertionError: \/a\/i deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/m, /a/), + /^AssertionError: \/a\/m deepStrictEqual \/a\/$/ +); +assert.throws( + makeBlock(a.deepStrictEqual, /a/igm, /a/im), + /^AssertionError: \/a\/gim deepStrictEqual \/a\/im$/ +); { const re1 = /a/; @@ -267,8 +289,8 @@ function Constructor2(first, last) { this.last = last; } -var obj1 = new Constructor1('Ryan', 'Dahl'); -var obj2 = new Constructor2('Ryan', 'Dahl'); +const obj1 = new Constructor1('Ryan', 'Dahl'); +let obj2 = new Constructor2('Ryan', 'Dahl'); assert.throws(makeBlock(a.deepStrictEqual, obj1, obj2), a.AssertionError); @@ -285,7 +307,7 @@ assert.throws(makeBlock(assert.deepStrictEqual, true, 1), assert.throws(makeBlock(assert.deepStrictEqual, Symbol(), Symbol()), a.AssertionError); -var s = Symbol(); +const s = Symbol(); assert.doesNotThrow(makeBlock(assert.deepStrictEqual, s, s)); @@ -326,16 +348,16 @@ assert.throws(makeBlock(thrower, a.AssertionError)); assert.throws(makeBlock(thrower, TypeError)); // when passing a type, only catch errors of the appropriate type -var threw = false; +let threw = false; try { a.throws(makeBlock(thrower, TypeError), a.AssertionError); } catch (e) { threw = true; assert.ok(e instanceof TypeError, 'type'); } -assert.equal(true, threw, - 'a.throws with an explicit error is eating extra errors', - a.AssertionError); +assert.strictEqual(true, threw, + 'a.throws with an explicit error is eating extra errors', + a.AssertionError); threw = false; // doesNotThrow should pass through all errors @@ -345,8 +367,8 @@ try { threw = true; assert.ok(e instanceof TypeError); } -assert.equal(true, threw, - 'a.doesNotThrow with an explicit error is eating extra errors'); +assert.strictEqual(true, threw, 'a.doesNotThrow with an explicit error is ' + + 'eating extra errors'); // key difference is that throwing our correct error makes an assertion error try { @@ -355,8 +377,8 @@ try { threw = true; assert.ok(e instanceof a.AssertionError); } -assert.equal(true, threw, - 'a.doesNotThrow is not catching type matching errors'); +assert.strictEqual(true, threw, + 'a.doesNotThrow is not catching type matching errors'); assert.throws(function() { assert.ifError(new Error('test error')); }); assert.doesNotThrow(function() { assert.ifError(null); }); @@ -365,7 +387,7 @@ assert.doesNotThrow(function() { assert.ifError(); }); assert.throws(() => { assert.doesNotThrow(makeBlock(thrower, Error), 'user message'); }, /Got unwanted exception. user message/, - 'a.doesNotThrow ignores user message'); + 'a.doesNotThrow ignores user message'); // make sure that validating using constructor really works threw = false; @@ -394,10 +416,11 @@ a.throws(makeBlock(thrower, TypeError), function(err) { // https://github.com/nodejs/node/issues/3188 threw = false; +let AnotherErrorType; try { - var ES6Error = class extends Error {}; + const ES6Error = class extends Error {}; - var AnotherErrorType = class extends Error {}; + AnotherErrorType = class extends Error {}; const functionThatThrows = function() { throw new AnotherErrorType('foo'); @@ -436,7 +459,7 @@ assert.ok(threw); a.throws(makeBlock(a.deepStrictEqual, d, e), /AssertionError/); } // GH-7178. Ensure reflexivity of deepEqual with `arguments` objects. -var args = (function() { return arguments; })(); +const args = (function() { return arguments; })(); a.throws(makeBlock(a.deepEqual, [], args)); a.throws(makeBlock(a.deepEqual, args, [])); @@ -455,15 +478,15 @@ a.throws(makeBlock(a.deepEqual, args, [])); a.doesNotThrow(makeBlock(a.deepEqual, someArgs, sameArgs)); } -var circular = {y: 1}; +const circular = {y: 1}; circular.x = circular; function testAssertionMessage(actual, expected) { try { - assert.equal(actual, ''); + assert.strictEqual(actual, ''); } catch (e) { - assert.equal(e.toString(), - ['AssertionError:', expected, '==', '\'\''].join(' ')); + assert.strictEqual(e.toString(), + ['AssertionError:', expected, '===', '\'\''].join(' ')); assert.ok(e.generatedMessage, 'Message not marked as generated'); } } @@ -489,7 +512,7 @@ testAssertionMessage({}, '{}'); testAssertionMessage(circular, '{ y: 1, x: [Circular] }'); testAssertionMessage({a: undefined, b: null}, '{ a: undefined, b: null }'); testAssertionMessage({a: NaN, b: Infinity, c: -Infinity}, - '{ a: NaN, b: Infinity, c: -Infinity }'); + '{ a: NaN, b: Infinity, c: -Infinity }'); // #2893 try { @@ -498,36 +521,36 @@ try { }); } catch (e) { threw = true; - assert.equal(e.message, 'Missing expected exception..'); + assert.strictEqual(e.message, 'Missing expected exception..'); } assert.ok(threw); // #5292 try { - assert.equal(1, 2); + assert.strictEqual(1, 2); } catch (e) { - assert.equal(e.toString().split('\n')[0], 'AssertionError: 1 == 2'); + assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: 1 === 2'); assert.ok(e.generatedMessage, 'Message not marked as generated'); } try { - assert.equal(1, 2, 'oh no'); + assert.strictEqual(1, 2, 'oh no'); } catch (e) { - assert.equal(e.toString().split('\n')[0], 'AssertionError: oh no'); - assert.equal(e.generatedMessage, false, - 'Message incorrectly marked as generated'); + assert.strictEqual(e.toString().split('\n')[0], 'AssertionError: oh no'); + assert.strictEqual(e.generatedMessage, false, + 'Message incorrectly marked as generated'); } // Verify that throws() and doesNotThrow() throw on non-function block function testBlockTypeError(method, block) { - var threw = true; + let threw = true; try { method(block); threw = false; } catch (e) { - assert.equal(e.toString(), - 'TypeError: "block" argument must be a function'); + assert.strictEqual(e.toString(), + 'TypeError: "block" argument must be a function'); } assert.ok(threw); diff --git a/test/parallel/test-async-wrap-check-providers.js b/test/parallel/test-async-wrap-check-providers.js index c574403eaecffa..354534a6b30a5a 100644 --- a/test/parallel/test-async-wrap-check-providers.js +++ b/test/parallel/test-async-wrap-check-providers.js @@ -28,7 +28,7 @@ keyList.splice(0, 1); // want to improve under https://github.com/nodejs/node/issues/5085. // strip out fs watch related parts for now if (common.isAix) { - for (var i = 0; i < keyList.length; i++) { + for (let i = 0; i < keyList.length; i++) { if ((keyList[i] === 'FSEVENTWRAP') || (keyList[i] === 'STATWATCHER')) { keyList.splice(i, 1); } diff --git a/test/parallel/test-async-wrap-throw-from-callback.js b/test/parallel/test-async-wrap-throw-from-callback.js index adc92c69d978d5..c4a6a9bdaddd1c 100644 --- a/test/parallel/test-async-wrap-throw-from-callback.js +++ b/test/parallel/test-async-wrap-throw-from-callback.js @@ -13,8 +13,8 @@ const domain = require('domain'); const spawn = require('child_process').spawn; const callbacks = [ 'init', 'pre', 'post', 'destroy' ]; const toCall = process.argv[2]; -var msgCalled = 0; -var msgReceived = 0; +let msgCalled = 0; +let msgReceived = 0; function init() { if (toCall === 'init') @@ -37,10 +37,10 @@ if (typeof process.argv[2] === 'string') { async_wrap.setupHooks({ init, pre, post, destroy }); async_wrap.enable(); - process.on('uncaughtException', () => assert.ok(0, 'UNREACHABLE')); + process.on('uncaughtException', common.fail); const d = domain.create(); - d.on('error', () => assert.ok(0, 'UNREACHABLE')); + d.on('error', common.fail); d.run(() => { // Using randomBytes because timers are not yet supported. crypto.randomBytes(0, () => { }); @@ -57,7 +57,7 @@ if (typeof process.argv[2] === 'string') { msgCalled++; const child = spawn(process.execPath, [__filename, item]); - var errstring = ''; + let errstring = ''; child.stderr.on('data', (data) => { errstring += data.toString(); diff --git a/test/parallel/test-async-wrap-uid.js b/test/parallel/test-async-wrap-uid.js index 19cb01cfa83c7a..f16388cfe766f0 100644 --- a/test/parallel/test-async-wrap-uid.js +++ b/test/parallel/test-async-wrap-uid.js @@ -6,7 +6,7 @@ const assert = require('assert'); const async_wrap = process.binding('async_wrap'); // Give the event loop time to clear out the final uv_close(). -var si_cntr = 3; +let si_cntr = 3; process.on('beforeExit', () => { if (--si_cntr > 0) setImmediate(() => {}); }); diff --git a/test/parallel/test-beforeexit-event-exit.js b/test/parallel/test-beforeexit-event-exit.js index 67676a7990041f..bd6162a46804bf 100644 --- a/test/parallel/test-beforeexit-event-exit.js +++ b/test/parallel/test-beforeexit-event-exit.js @@ -1,9 +1,8 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); process.on('beforeExit', function() { - assert(false, 'exit should not allow this to occur'); + common.fail('exit should not allow this to occur'); }); process.exit(); diff --git a/test/parallel/test-beforeexit-event.js b/test/parallel/test-beforeexit-event.js deleted file mode 100644 index ef94da76af3883..00000000000000 --- a/test/parallel/test-beforeexit-event.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; -const common = require('../common'); -const net = require('net'); - -process.once('beforeExit', common.mustCall(tryImmediate)); - -function tryImmediate() { - setImmediate(common.mustCall(() => { - process.once('beforeExit', common.mustCall(tryTimer)); - })); -} - -function tryTimer() { - setTimeout(common.mustCall(() => { - process.once('beforeExit', common.mustCall(tryListen)); - }), 1); -} - -function tryListen() { - net.createServer() - .listen(0) - .on('listening', common.mustCall(function() { - this.close(); - process.on('beforeExit', common.mustCall(() => {})); - })); -} diff --git a/test/parallel/test-buffer-alloc.js b/test/parallel/test-buffer-alloc.js index 2245c9843a5edd..1426bd80ebc4ab 100644 --- a/test/parallel/test-buffer-alloc.js +++ b/test/parallel/test-buffer-alloc.js @@ -988,9 +988,7 @@ assert.throws(() => Buffer.from('', 'buffer'), TypeError); // Regression test for #6111. Constructing a buffer from another buffer // should a) work, and b) not corrupt the source buffer. { - let a = [0]; - for (let i = 0; i < 7; ++i) a = a.concat(a); - a = a.map((_, i) => { return i; }); + const a = [...Array(128).keys()]; // [0, 1, 2, 3, ... 126, 127] const b = Buffer.from(a); const c = Buffer.from(b); assert.strictEqual(b.length, a.length); diff --git a/test/parallel/test-buffer-ascii.js b/test/parallel/test-buffer-ascii.js index ea125283f23f93..cf5b529183cabf 100644 --- a/test/parallel/test-buffer-ascii.js +++ b/test/parallel/test-buffer-ascii.js @@ -16,7 +16,7 @@ const expected = 'Cb\u0000\u0019est, graphiquement, la rC)union ' + const buf = Buffer.from(input); -for (var i = 0; i < expected.length; ++i) { +for (let i = 0; i < expected.length; ++i) { assert.strictEqual(buf.slice(i).toString('ascii'), expected.slice(i)); // Skip remainder of multi-byte sequence. diff --git a/test/parallel/test-buffer-bytelength.js b/test/parallel/test-buffer-bytelength.js index e31e514ffa1182..c30e06cc73690d 100644 --- a/test/parallel/test-buffer-bytelength.js +++ b/test/parallel/test-buffer-bytelength.js @@ -24,37 +24,37 @@ assert(ArrayBuffer.isView(Buffer.allocUnsafeSlow(10))); assert(ArrayBuffer.isView(Buffer.from(''))); // buffer -var incomplete = Buffer.from([0xe4, 0xb8, 0xad, 0xe6, 0x96]); +const incomplete = Buffer.from([0xe4, 0xb8, 0xad, 0xe6, 0x96]); assert.strictEqual(Buffer.byteLength(incomplete), 5); -var ascii = Buffer.from('abc'); +const ascii = Buffer.from('abc'); assert.strictEqual(Buffer.byteLength(ascii), 3); // ArrayBuffer -var buffer = new ArrayBuffer(8); +const buffer = new ArrayBuffer(8); assert.strictEqual(Buffer.byteLength(buffer), 8); // TypedArray -var int8 = new Int8Array(8); +const int8 = new Int8Array(8); assert.strictEqual(Buffer.byteLength(int8), 8); -var uint8 = new Uint8Array(8); +const uint8 = new Uint8Array(8); assert.strictEqual(Buffer.byteLength(uint8), 8); -var uintc8 = new Uint8ClampedArray(2); +const uintc8 = new Uint8ClampedArray(2); assert.strictEqual(Buffer.byteLength(uintc8), 2); -var int16 = new Int16Array(8); +const int16 = new Int16Array(8); assert.strictEqual(Buffer.byteLength(int16), 16); -var uint16 = new Uint16Array(8); +const uint16 = new Uint16Array(8); assert.strictEqual(Buffer.byteLength(uint16), 16); -var int32 = new Int32Array(8); +const int32 = new Int32Array(8); assert.strictEqual(Buffer.byteLength(int32), 32); -var uint32 = new Uint32Array(8); +const uint32 = new Uint32Array(8); assert.strictEqual(Buffer.byteLength(uint32), 32); -var float32 = new Float32Array(8); +const float32 = new Float32Array(8); assert.strictEqual(Buffer.byteLength(float32), 32); -var float64 = new Float64Array(8); +const float64 = new Float64Array(8); assert.strictEqual(Buffer.byteLength(float64), 64); // DataView -var dv = new DataView(new ArrayBuffer(2)); +const dv = new DataView(new ArrayBuffer(2)); assert.strictEqual(Buffer.byteLength(dv), 2); // special case: zero length string diff --git a/test/parallel/test-buffer-concat.js b/test/parallel/test-buffer-concat.js index b29e00682c114b..5d558835b7db83 100644 --- a/test/parallel/test-buffer-concat.js +++ b/test/parallel/test-buffer-concat.js @@ -5,7 +5,7 @@ const assert = require('assert'); const zero = []; const one = [ Buffer.from('asdf') ]; const long = []; -for (var i = 0; i < 10; i++) long.push(Buffer.from('asdf')); +for (let i = 0; i < 10; i++) long.push(Buffer.from('asdf')); const flatZero = Buffer.concat(zero); const flatOne = Buffer.concat(one); diff --git a/test/parallel/test-buffer-copy.js b/test/parallel/test-buffer-copy.js index fef4acf7df286b..5737ed748058ef 100644 --- a/test/parallel/test-buffer-copy.js +++ b/test/parallel/test-buffer-copy.js @@ -5,7 +5,7 @@ const assert = require('assert'); const b = Buffer.allocUnsafe(1024); const c = Buffer.allocUnsafe(512); -var cntr = 0; +let cntr = 0; { // copy 512 bytes, from 0 to 512. diff --git a/test/parallel/test-buffer-fill.js b/test/parallel/test-buffer-fill.js index eecb14abb06001..06a9044bec3103 100644 --- a/test/parallel/test-buffer-fill.js +++ b/test/parallel/test-buffer-fill.js @@ -184,20 +184,20 @@ deepStrictEqualValues(genBuffer(4, [hexBufFill, 1, -1]), [0, 0, 0, 0]); assert.throws(() => buf1.fill(0, -1), /^RangeError: Out of range index$/); assert.throws(() => buf1.fill(0, 0, buf1.length + 1), - /^RangeError: Out of range index$/); + /^RangeError: Out of range index$/); assert.throws(() => buf1.fill('', -1), /^RangeError: Out of range index$/); assert.throws(() => buf1.fill('', 0, buf1.length + 1), - /^RangeError: Out of range index$/); + /^RangeError: Out of range index$/); assert.throws(() => buf1.fill('a', 0, buf1.length, 'node rocks!'), - /^TypeError: Unknown encoding: node rocks!$/); + /^TypeError: Unknown encoding: node rocks!$/); assert.throws(() => buf1.fill('a', 0, 0, NaN), - /^TypeError: encoding must be a string$/); + /^TypeError: encoding must be a string$/); assert.throws(() => buf1.fill('a', 0, 0, null), - /^TypeError: encoding must be a string$/); + /^TypeError: encoding must be a string$/); assert.throws(() => buf1.fill('a', 0, 0, 'foo'), /^TypeError: Unknown encoding: foo$/); @@ -243,7 +243,7 @@ function writeToFill(string, offset, end, encoding) { // Convert "end" to "length" (which write understands). const length = end - offset < 0 ? 0 : end - offset; - var wasZero = false; + let wasZero = false; do { const written = buf2.write(string, offset, length, encoding); offset += written; @@ -271,10 +271,10 @@ function testBufs(string, offset, length, encoding) { // Make sure these throw. assert.throws(() => Buffer.allocUnsafe(8).fill('a', -1), - /^RangeError: Out of range index$/); + /^RangeError: Out of range index$/); assert.throws(() => Buffer.allocUnsafe(8).fill('a', 0, 9), - /^RangeError: Out of range index$/); + /^RangeError: Out of range index$/); // Make sure this doesn't hang indefinitely. Buffer.allocUnsafe(8).fill(''); @@ -324,7 +324,7 @@ Buffer.alloc(8, ''); { let elseWasLast = false; assert.throws(() => { - var ctr = 0; + let ctr = 0; const start = { [Symbol.toPrimitive]() { // We use this condition to get around the check in lib/buffer.js @@ -357,7 +357,7 @@ assert.throws(() => { { let elseWasLast = false; assert.throws(() => { - var ctr = 0; + let ctr = 0; const end = { [Symbol.toPrimitive]() { // We use this condition to get around the check in lib/buffer.js diff --git a/test/parallel/test-buffer-includes.js b/test/parallel/test-buffer-includes.js index 22ba1e6b7e1735..9b0aef0ad7652d 100644 --- a/test/parallel/test-buffer-includes.js +++ b/test/parallel/test-buffer-includes.js @@ -140,7 +140,7 @@ assert.strictEqual( // test usc2 encoding -var twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2'); +let twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2'); assert(twoByteString.includes('\u0395', 4, 'ucs2')); assert(twoByteString.includes('\u03a3', -4, 'ucs2')); @@ -159,10 +159,10 @@ assert( 6, mixedByteStringUcs2.includes(Buffer.from('bc', 'ucs2'), 0, 'ucs2')); assert( 10, mixedByteStringUcs2.includes(Buffer.from('\u03a3', 'ucs2'), - 0, 'ucs2')); + 0, 'ucs2')); assert( -1, mixedByteStringUcs2.includes(Buffer.from('\u0396', 'ucs2'), - 0, 'ucs2')); + 0, 'ucs2')); twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2'); @@ -190,7 +190,7 @@ assert(!mixedByteStringUtf8.includes('\u0396')); // Test complex string includes algorithms. Only trigger for long strings. // Long string that isn't a simple repeat of a shorter string. -var longString = 'A'; +let longString = 'A'; for (let i = 66; i < 76; i++) { // from 'B' to 'K' longString = longString + String.fromCharCode(i) + longString; } @@ -198,7 +198,7 @@ for (let i = 66; i < 76; i++) { // from 'B' to 'K' const longBufferString = Buffer.from(longString); // pattern of 15 chars, repeated every 16 chars in long -var pattern = 'ABACABADABACABA'; +let pattern = 'ABACABADABACABA'; for (let i = 0; i < longBufferString.length - pattern.length; i += 7) { const includes = longBufferString.includes(pattern, i); assert(includes, 'Long ABACABA...-string at index ' + i); @@ -229,8 +229,8 @@ assert(!allCharsBufferUtf8.includes('notfound')); assert(!allCharsBufferUcs2.includes('notfound')); // Find substrings in Utf8. -var lengths = [1, 3, 15]; // Single char, simple and complex. -var indices = [0x5, 0x60, 0x400, 0x680, 0x7ee, 0xFF02, 0x16610, 0x2f77b]; +let lengths = [1, 3, 15]; // Single char, simple and complex. +let indices = [0x5, 0x60, 0x400, 0x680, 0x7ee, 0xFF02, 0x16610, 0x2f77b]; for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) { for (let i = 0; i < indices.length; i++) { const index = indices[i]; diff --git a/test/parallel/test-buffer-indexof.js b/test/parallel/test-buffer-indexof.js index 746a2723167a60..977d44ba3d8f05 100644 --- a/test/parallel/test-buffer-indexof.js +++ b/test/parallel/test-buffer-indexof.js @@ -11,6 +11,8 @@ const buf_f = Buffer.from('f'); const buf_z = Buffer.from('z'); const buf_empty = Buffer.from(''); +const s = 'abcdef'; + assert.strictEqual(b.indexOf('a'), 0); assert.strictEqual(b.indexOf('a', 1), -1); assert.strictEqual(b.indexOf('a', -1), -1); @@ -71,12 +73,12 @@ assert.strictEqual(b.indexOf('f', 5), 5); assert.strictEqual(b.indexOf('f', -1), 5); assert.strictEqual(b.indexOf('f', 6), -1); -assert.equal(b.indexOf(Buffer.from('d'), 2), 3); -assert.equal(b.indexOf(Buffer.from('f'), 5), 5); -assert.equal(b.indexOf(Buffer.from('f'), -1), 5); -assert.equal(b.indexOf(Buffer.from('f'), 6), -1); +assert.strictEqual(b.indexOf(Buffer.from('d'), 2), 3); +assert.strictEqual(b.indexOf(Buffer.from('f'), 5), 5); +assert.strictEqual(b.indexOf(Buffer.from('f'), -1), 5); +assert.strictEqual(b.indexOf(Buffer.from('f'), 6), -1); -assert.equal(Buffer.from('ff').indexOf(Buffer.from('f'), 1, 'ucs2'), -1); +assert.strictEqual(Buffer.from('ff').indexOf(Buffer.from('f'), 1, 'ucs2'), -1); // test invalid and uppercase encoding assert.strictEqual(b.indexOf('b', 'utf8'), 1); @@ -176,106 +178,113 @@ assert.strictEqual( // test optional offset with passed encoding -assert.equal(Buffer.from('aaaa0').indexOf('30', 'hex'), 4); -assert.equal(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4); +assert.strictEqual(Buffer.from('aaaa0').indexOf('30', 'hex'), 4); +assert.strictEqual(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4); { // test usc2 encoding const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2'); - assert.equal(8, twoByteString.indexOf('\u0395', 4, 'ucs2')); - assert.equal(6, twoByteString.indexOf('\u03a3', -4, 'ucs2')); - assert.equal(4, twoByteString.indexOf('\u03a3', -6, 'ucs2')); - assert.equal(4, twoByteString.indexOf( + assert.strictEqual(8, twoByteString.indexOf('\u0395', 4, 'ucs2')); + assert.strictEqual(6, twoByteString.indexOf('\u03a3', -4, 'ucs2')); + assert.strictEqual(4, twoByteString.indexOf('\u03a3', -6, 'ucs2')); + assert.strictEqual(4, twoByteString.indexOf( Buffer.from('\u03a3', 'ucs2'), -6, 'ucs2')); - assert.equal(-1, twoByteString.indexOf('\u03a3', -2, 'ucs2')); + assert.strictEqual(-1, twoByteString.indexOf('\u03a3', -2, 'ucs2')); } -var mixedByteStringUcs2 = +const mixedByteStringUcs2 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395', 'ucs2'); -assert.equal(6, mixedByteStringUcs2.indexOf('bc', 0, 'ucs2')); -assert.equal(10, mixedByteStringUcs2.indexOf('\u03a3', 0, 'ucs2')); -assert.equal(-1, mixedByteStringUcs2.indexOf('\u0396', 0, 'ucs2')); +assert.strictEqual(6, mixedByteStringUcs2.indexOf('bc', 0, 'ucs2')); +assert.strictEqual(10, mixedByteStringUcs2.indexOf('\u03a3', 0, 'ucs2')); +assert.strictEqual(-1, mixedByteStringUcs2.indexOf('\u0396', 0, 'ucs2')); -assert.equal( +assert.strictEqual( 6, mixedByteStringUcs2.indexOf(Buffer.from('bc', 'ucs2'), 0, 'ucs2')); -assert.equal( +assert.strictEqual( 10, mixedByteStringUcs2.indexOf(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2')); -assert.equal( +assert.strictEqual( -1, mixedByteStringUcs2.indexOf(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2')); { const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2'); // Test single char pattern - assert.equal(0, twoByteString.indexOf('\u039a', 0, 'ucs2')); - assert.equal(2, twoByteString.indexOf('\u0391', 0, 'ucs2'), 'Alpha'); - assert.equal(4, twoByteString.indexOf('\u03a3', 0, 'ucs2'), 'First Sigma'); - assert.equal(6, twoByteString.indexOf('\u03a3', 6, 'ucs2'), 'Second Sigma'); - assert.equal(8, twoByteString.indexOf('\u0395', 0, 'ucs2'), 'Epsilon'); - assert.equal(-1, twoByteString.indexOf('\u0392', 0, 'ucs2'), 'Not beta'); + assert.strictEqual(0, twoByteString.indexOf('\u039a', 0, 'ucs2')); + assert.strictEqual(2, twoByteString.indexOf('\u0391', 0, 'ucs2'), + 'Alpha'); + assert.strictEqual(4, twoByteString.indexOf('\u03a3', 0, 'ucs2'), + 'First Sigma'); + assert.strictEqual(6, twoByteString.indexOf('\u03a3', 6, 'ucs2'), + 'Second Sigma'); + assert.strictEqual(8, twoByteString.indexOf('\u0395', 0, 'ucs2'), + 'Epsilon'); + assert.strictEqual(-1, twoByteString.indexOf('\u0392', 0, 'ucs2'), + 'Not beta'); // Test multi-char pattern - assert.equal( + assert.strictEqual( 0, twoByteString.indexOf('\u039a\u0391', 0, 'ucs2'), 'Lambda Alpha'); - assert.equal( + assert.strictEqual( 2, twoByteString.indexOf('\u0391\u03a3', 0, 'ucs2'), 'Alpha Sigma'); - assert.equal( + assert.strictEqual( 4, twoByteString.indexOf('\u03a3\u03a3', 0, 'ucs2'), 'Sigma Sigma'); - assert.equal( + assert.strictEqual( 6, twoByteString.indexOf('\u03a3\u0395', 0, 'ucs2'), 'Sigma Epsilon'); } -var mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395'); -assert.equal(5, mixedByteStringUtf8.indexOf('bc')); -assert.equal(5, mixedByteStringUtf8.indexOf('bc', 5)); -assert.equal(5, mixedByteStringUtf8.indexOf('bc', -8)); -assert.equal(7, mixedByteStringUtf8.indexOf('\u03a3')); -assert.equal(-1, mixedByteStringUtf8.indexOf('\u0396')); +const mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395'); +assert.strictEqual(5, mixedByteStringUtf8.indexOf('bc')); +assert.strictEqual(5, mixedByteStringUtf8.indexOf('bc', 5)); +assert.strictEqual(5, mixedByteStringUtf8.indexOf('bc', -8)); +assert.strictEqual(7, mixedByteStringUtf8.indexOf('\u03a3')); +assert.strictEqual(-1, mixedByteStringUtf8.indexOf('\u0396')); // Test complex string indexOf algorithms. Only trigger for long strings. // Long string that isn't a simple repeat of a shorter string. -var longString = 'A'; +let longString = 'A'; for (let i = 66; i < 76; i++) { // from 'B' to 'K' longString = longString + String.fromCharCode(i) + longString; } -var longBufferString = Buffer.from(longString); +const longBufferString = Buffer.from(longString); // pattern of 15 chars, repeated every 16 chars in long -var pattern = 'ABACABADABACABA'; +let pattern = 'ABACABADABACABA'; for (let i = 0; i < longBufferString.length - pattern.length; i += 7) { const index = longBufferString.indexOf(pattern, i); - assert.equal((i + 15) & ~0xf, index, 'Long ABACABA...-string at index ' + i); + assert.strictEqual((i + 15) & ~0xf, index, + 'Long ABACABA...-string at index ' + i); } -assert.equal(510, longBufferString.indexOf('AJABACA'), 'Long AJABACA, First J'); -assert.equal( +assert.strictEqual(510, longBufferString.indexOf('AJABACA'), + 'Long AJABACA, First J'); +assert.strictEqual( 1534, longBufferString.indexOf('AJABACA', 511), 'Long AJABACA, Second J'); pattern = 'JABACABADABACABA'; -assert.equal( +assert.strictEqual( 511, longBufferString.indexOf(pattern), 'Long JABACABA..., First J'); -assert.equal( +assert.strictEqual( 1535, longBufferString.indexOf(pattern, 512), 'Long JABACABA..., Second J'); // Search for a non-ASCII string in a pure ASCII string. -var asciiString = Buffer.from( +const asciiString = Buffer.from( 'arglebargleglopglyfarglebargleglopglyfarglebargleglopglyf'); -assert.equal(-1, asciiString.indexOf('\x2061')); -assert.equal(3, asciiString.indexOf('leb', 0)); +assert.strictEqual(-1, asciiString.indexOf('\x2061')); +assert.strictEqual(3, asciiString.indexOf('leb', 0)); // Search in string containing many non-ASCII chars. -var allCodePoints = []; +const allCodePoints = []; for (let i = 0; i < 65536; i++) allCodePoints[i] = i; -var allCharsString = String.fromCharCode.apply(String, allCodePoints); -var allCharsBufferUtf8 = Buffer.from(allCharsString); -var allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2'); +const allCharsString = String.fromCharCode.apply(String, allCodePoints); +const allCharsBufferUtf8 = Buffer.from(allCharsString); +const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2'); // Search for string long enough to trigger complex search with ASCII pattern // and UC16 subject. -assert.equal(-1, allCharsBufferUtf8.indexOf('notfound')); -assert.equal(-1, allCharsBufferUcs2.indexOf('notfound')); +assert.strictEqual(-1, allCharsBufferUtf8.indexOf('notfound')); +assert.strictEqual(-1, allCharsBufferUcs2.indexOf('notfound')); // Needle is longer than haystack, but only because it's encoded as UTF-16 assert.strictEqual(Buffer.from('aaaa').indexOf('a'.repeat(4), 'ucs2'), -1); @@ -307,11 +316,11 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1); length = 4 * length; } - var patternBufferUtf8 = allCharsBufferUtf8.slice(index, index + length); - assert.equal(index, allCharsBufferUtf8.indexOf(patternBufferUtf8)); + const patternBufferUtf8 = allCharsBufferUtf8.slice(index, index + length); + assert.strictEqual(index, allCharsBufferUtf8.indexOf(patternBufferUtf8)); - var patternStringUtf8 = patternBufferUtf8.toString(); - assert.equal(index, allCharsBufferUtf8.indexOf(patternStringUtf8)); + const patternStringUtf8 = patternBufferUtf8.toString(); + assert.strictEqual(index, allCharsBufferUtf8.indexOf(patternStringUtf8)); } } } @@ -325,89 +334,149 @@ assert.strictEqual(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1); const index = indices[i] * 2; const length = lengths[lengthIndex]; - var patternBufferUcs2 = + const patternBufferUcs2 = allCharsBufferUcs2.slice(index, index + length); - assert.equal( + assert.strictEqual( index, allCharsBufferUcs2.indexOf(patternBufferUcs2, 0, 'ucs2')); - var patternStringUcs2 = patternBufferUcs2.toString('ucs2'); - assert.equal( + const patternStringUcs2 = patternBufferUcs2.toString('ucs2'); + assert.strictEqual( index, allCharsBufferUcs2.indexOf(patternStringUcs2, 0, 'ucs2')); } } } -assert.throws(function() { - b.indexOf(function() { }); -}); -assert.throws(function() { +const argumentExpected = + /^TypeError: "val" argument must be string, number or Buffer$/; + +assert.throws(() => { + b.indexOf(() => { }); +}, argumentExpected); + +assert.throws(() => { b.indexOf({}); -}); -assert.throws(function() { +}, argumentExpected); + +assert.throws(() => { b.indexOf([]); -}); +}, argumentExpected); + +// Test weird offset arguments. +// The following offsets coerce to NaN or 0, searching the whole Buffer +assert.strictEqual(b.indexOf('b', undefined), 1); +assert.strictEqual(b.indexOf('b', {}), 1); +assert.strictEqual(b.indexOf('b', 0), 1); +assert.strictEqual(b.indexOf('b', null), 1); +assert.strictEqual(b.indexOf('b', []), 1); + +// The following offset coerces to 2, in other words +[2] === 2 +assert.strictEqual(b.indexOf('b', [2]), -1); + +// Behavior should match String.indexOf() +assert.strictEqual( + b.indexOf('b', undefined), + s.indexOf('b', undefined)); +assert.strictEqual( + b.indexOf('b', {}), + s.indexOf('b', {})); +assert.strictEqual( + b.indexOf('b', 0), + s.indexOf('b', 0)); +assert.strictEqual( + b.indexOf('b', null), + s.indexOf('b', null)); +assert.strictEqual( + b.indexOf('b', []), + s.indexOf('b', [])); +assert.strictEqual( + b.indexOf('b', [2]), + s.indexOf('b', [2])); // All code for handling encodings is shared between Buffer.indexOf and // Buffer.lastIndexOf, so only testing the separate lastIndexOf semantics. // Test lastIndexOf basic functionality; Buffer b contains 'abcdef'. // lastIndexOf string: -assert.equal(b.lastIndexOf('a'), 0); -assert.equal(b.lastIndexOf('a', 1), 0); -assert.equal(b.lastIndexOf('b', 1), 1); -assert.equal(b.lastIndexOf('c', 1), -1); -assert.equal(b.lastIndexOf('a', -1), 0); -assert.equal(b.lastIndexOf('a', -4), 0); -assert.equal(b.lastIndexOf('a', -b.length), 0); -assert.equal(b.lastIndexOf('a', -b.length - 1), -1); -assert.equal(b.lastIndexOf('a', NaN), 0); -assert.equal(b.lastIndexOf('a', -Infinity), -1); -assert.equal(b.lastIndexOf('a', Infinity), 0); +assert.strictEqual(b.lastIndexOf('a'), 0); +assert.strictEqual(b.lastIndexOf('a', 1), 0); +assert.strictEqual(b.lastIndexOf('b', 1), 1); +assert.strictEqual(b.lastIndexOf('c', 1), -1); +assert.strictEqual(b.lastIndexOf('a', -1), 0); +assert.strictEqual(b.lastIndexOf('a', -4), 0); +assert.strictEqual(b.lastIndexOf('a', -b.length), 0); +assert.strictEqual(b.lastIndexOf('a', -b.length - 1), -1); +assert.strictEqual(b.lastIndexOf('a', NaN), 0); +assert.strictEqual(b.lastIndexOf('a', -Infinity), -1); +assert.strictEqual(b.lastIndexOf('a', Infinity), 0); // lastIndexOf Buffer: -assert.equal(b.lastIndexOf(buf_a), 0); -assert.equal(b.lastIndexOf(buf_a, 1), 0); -assert.equal(b.lastIndexOf(buf_a, -1), 0); -assert.equal(b.lastIndexOf(buf_a, -4), 0); -assert.equal(b.lastIndexOf(buf_a, -b.length), 0); -assert.equal(b.lastIndexOf(buf_a, -b.length - 1), -1); -assert.equal(b.lastIndexOf(buf_a, NaN), 0); -assert.equal(b.lastIndexOf(buf_a, -Infinity), -1); -assert.equal(b.lastIndexOf(buf_a, Infinity), 0); -assert.equal(b.lastIndexOf(buf_bc), 1); -assert.equal(b.lastIndexOf(buf_bc, 2), 1); -assert.equal(b.lastIndexOf(buf_bc, -1), 1); -assert.equal(b.lastIndexOf(buf_bc, -3), 1); -assert.equal(b.lastIndexOf(buf_bc, -5), 1); -assert.equal(b.lastIndexOf(buf_bc, -6), -1); -assert.equal(b.lastIndexOf(buf_bc, NaN), 1); -assert.equal(b.lastIndexOf(buf_bc, -Infinity), -1); -assert.equal(b.lastIndexOf(buf_bc, Infinity), 1); -assert.equal(b.lastIndexOf(buf_f), b.length - 1); -assert.equal(b.lastIndexOf(buf_z), -1); -assert.equal(b.lastIndexOf(buf_empty), -1); -assert.equal(b.lastIndexOf(buf_empty, 1), -1); -assert.equal(b.lastIndexOf(buf_empty, b.length + 1), -1); -assert.equal(b.lastIndexOf(buf_empty, Infinity), -1); +assert.strictEqual(b.lastIndexOf(buf_a), 0); +assert.strictEqual(b.lastIndexOf(buf_a, 1), 0); +assert.strictEqual(b.lastIndexOf(buf_a, -1), 0); +assert.strictEqual(b.lastIndexOf(buf_a, -4), 0); +assert.strictEqual(b.lastIndexOf(buf_a, -b.length), 0); +assert.strictEqual(b.lastIndexOf(buf_a, -b.length - 1), -1); +assert.strictEqual(b.lastIndexOf(buf_a, NaN), 0); +assert.strictEqual(b.lastIndexOf(buf_a, -Infinity), -1); +assert.strictEqual(b.lastIndexOf(buf_a, Infinity), 0); +assert.strictEqual(b.lastIndexOf(buf_bc), 1); +assert.strictEqual(b.lastIndexOf(buf_bc, 2), 1); +assert.strictEqual(b.lastIndexOf(buf_bc, -1), 1); +assert.strictEqual(b.lastIndexOf(buf_bc, -3), 1); +assert.strictEqual(b.lastIndexOf(buf_bc, -5), 1); +assert.strictEqual(b.lastIndexOf(buf_bc, -6), -1); +assert.strictEqual(b.lastIndexOf(buf_bc, NaN), 1); +assert.strictEqual(b.lastIndexOf(buf_bc, -Infinity), -1); +assert.strictEqual(b.lastIndexOf(buf_bc, Infinity), 1); +assert.strictEqual(b.lastIndexOf(buf_f), b.length - 1); +assert.strictEqual(b.lastIndexOf(buf_z), -1); +assert.strictEqual(b.lastIndexOf(buf_empty), -1); +assert.strictEqual(b.lastIndexOf(buf_empty, 1), -1); +assert.strictEqual(b.lastIndexOf(buf_empty, b.length + 1), -1); +assert.strictEqual(b.lastIndexOf(buf_empty, Infinity), -1); // lastIndexOf number: -assert.equal(b.lastIndexOf(0x61), 0); -assert.equal(b.lastIndexOf(0x61, 1), 0); -assert.equal(b.lastIndexOf(0x61, -1), 0); -assert.equal(b.lastIndexOf(0x61, -4), 0); -assert.equal(b.lastIndexOf(0x61, -b.length), 0); -assert.equal(b.lastIndexOf(0x61, -b.length - 1), -1); -assert.equal(b.lastIndexOf(0x61, NaN), 0); -assert.equal(b.lastIndexOf(0x61, -Infinity), -1); -assert.equal(b.lastIndexOf(0x61, Infinity), 0); -assert.equal(b.lastIndexOf(0x0), -1); +assert.strictEqual(b.lastIndexOf(0x61), 0); +assert.strictEqual(b.lastIndexOf(0x61, 1), 0); +assert.strictEqual(b.lastIndexOf(0x61, -1), 0); +assert.strictEqual(b.lastIndexOf(0x61, -4), 0); +assert.strictEqual(b.lastIndexOf(0x61, -b.length), 0); +assert.strictEqual(b.lastIndexOf(0x61, -b.length - 1), -1); +assert.strictEqual(b.lastIndexOf(0x61, NaN), 0); +assert.strictEqual(b.lastIndexOf(0x61, -Infinity), -1); +assert.strictEqual(b.lastIndexOf(0x61, Infinity), 0); +assert.strictEqual(b.lastIndexOf(0x0), -1); // Test weird offset arguments. -// Behaviour should match String.lastIndexOf: -assert.equal(b.lastIndexOf('b', 0), -1); -assert.equal(b.lastIndexOf('b', undefined), 1); -assert.equal(b.lastIndexOf('b', null), -1); -assert.equal(b.lastIndexOf('b', {}), 1); -assert.equal(b.lastIndexOf('b', []), -1); -assert.equal(b.lastIndexOf('b', [2]), 1); +// The following offsets coerce to NaN, searching the whole Buffer +assert.strictEqual(b.lastIndexOf('b', undefined), 1); +assert.strictEqual(b.lastIndexOf('b', {}), 1); + +// The following offsets coerce to 0 +assert.strictEqual(b.lastIndexOf('b', 0), -1); +assert.strictEqual(b.lastIndexOf('b', null), -1); +assert.strictEqual(b.lastIndexOf('b', []), -1); + +// The following offset coerces to 2, in other words +[2] === 2 +assert.strictEqual(b.lastIndexOf('b', [2]), 1); + +// Behavior should match String.lastIndexOf() +assert.strictEqual( + b.lastIndexOf('b', undefined), + s.lastIndexOf('b', undefined)); +assert.strictEqual( + b.lastIndexOf('b', {}), + s.lastIndexOf('b', {})); +assert.strictEqual( + b.lastIndexOf('b', 0), + s.lastIndexOf('b', 0)); +assert.strictEqual( + b.lastIndexOf('b', null), + s.lastIndexOf('b', null)); +assert.strictEqual( + b.lastIndexOf('b', []), + s.lastIndexOf('b', [])); +assert.strictEqual( + b.lastIndexOf('b', [2]), + s.lastIndexOf('b', [2])); // Test needles longer than the haystack. assert.strictEqual(b.lastIndexOf('aaaaaaaaaaaaaaa', 'ucs2'), -1); @@ -434,21 +503,22 @@ assert.strictEqual(buf_bc.lastIndexOf('你好', 5, 'binary'), -1); assert.strictEqual(buf_bc.lastIndexOf(Buffer.from('你好'), 7), -1); // Test lastIndexOf on a longer buffer: -var bufferString = new Buffer('a man a plan a canal panama'); -assert.equal(15, bufferString.lastIndexOf('canal')); -assert.equal(21, bufferString.lastIndexOf('panama')); -assert.equal(0, bufferString.lastIndexOf('a man a plan a canal panama')); -assert.equal(-1, bufferString.lastIndexOf('a man a plan a canal mexico')); -assert.equal(-1, bufferString.lastIndexOf('a man a plan a canal mexico city')); -assert.equal(-1, bufferString.lastIndexOf(Buffer.from('a'.repeat(1000)))); -assert.equal(0, bufferString.lastIndexOf('a man a plan', 4)); -assert.equal(13, bufferString.lastIndexOf('a ')); -assert.equal(13, bufferString.lastIndexOf('a ', 13)); -assert.equal(6, bufferString.lastIndexOf('a ', 12)); -assert.equal(0, bufferString.lastIndexOf('a ', 5)); -assert.equal(13, bufferString.lastIndexOf('a ', -1)); -assert.equal(0, bufferString.lastIndexOf('a ', -27)); -assert.equal(-1, bufferString.lastIndexOf('a ', -28)); +const bufferString = new Buffer('a man a plan a canal panama'); +assert.strictEqual(15, bufferString.lastIndexOf('canal')); +assert.strictEqual(21, bufferString.lastIndexOf('panama')); +assert.strictEqual(0, bufferString.lastIndexOf('a man a plan a canal panama')); +assert.strictEqual(-1, bufferString.lastIndexOf('a man a plan a canal mexico')); +assert.strictEqual(-1, bufferString + .lastIndexOf('a man a plan a canal mexico city')); +assert.strictEqual(-1, bufferString.lastIndexOf(Buffer.from('a'.repeat(1000)))); +assert.strictEqual(0, bufferString.lastIndexOf('a man a plan', 4)); +assert.strictEqual(13, bufferString.lastIndexOf('a ')); +assert.strictEqual(13, bufferString.lastIndexOf('a ', 13)); +assert.strictEqual(6, bufferString.lastIndexOf('a ', 12)); +assert.strictEqual(0, bufferString.lastIndexOf('a ', 5)); +assert.strictEqual(13, bufferString.lastIndexOf('a ', -1)); +assert.strictEqual(0, bufferString.lastIndexOf('a ', -27)); +assert.strictEqual(-1, bufferString.lastIndexOf('a ', -28)); // Test lastIndexOf for the case that the first character can be found, // but in a part of the buffer that does not make search to search @@ -472,9 +542,9 @@ assert.strictEqual(0, Buffer.from('abc').lastIndexOf('ab', 3)); // Now, we test the BOYER-MOORE-HORSPOOL strategy. // Test lastIndexOf on a long buffer w multiple matches: pattern = 'JABACABADABACABA'; -assert.equal(1535, longBufferString.lastIndexOf(pattern)); -assert.equal(1535, longBufferString.lastIndexOf(pattern, 1535)); -assert.equal(511, longBufferString.lastIndexOf(pattern, 1534)); +assert.strictEqual(1535, longBufferString.lastIndexOf(pattern)); +assert.strictEqual(1535, longBufferString.lastIndexOf(pattern, 1535)); +assert.strictEqual(511, longBufferString.lastIndexOf(pattern, 1534)); // Finally, give it a really long input to trigger fallback from BMH to // regular BOYER-MOORE (which has better worst-case complexity). @@ -485,29 +555,30 @@ assert.equal(511, longBufferString.lastIndexOf(pattern, 1534)); // countBits returns the number of bits in the binary reprsentation of n. function countBits(n) { - for (var count = 0; n > 0; count++) { + let count; + for (count = 0; n > 0; count++) { n = n & (n - 1); // remove top bit } return count; } -var parts = []; -for (var i = 0; i < 1000000; i++) { +const parts = []; +for (let i = 0; i < 1000000; i++) { parts.push((countBits(i) % 2 === 0) ? 'yolo' : 'swag'); } -var reallyLong = new Buffer(parts.join(' ')); -assert.equal('yolo swag swag yolo', reallyLong.slice(0, 19).toString()); +const reallyLong = new Buffer(parts.join(' ')); +assert.strictEqual('yolo swag swag yolo', reallyLong.slice(0, 19).toString()); // Expensive reverse searches. Stress test lastIndexOf: pattern = reallyLong.slice(0, 100000); // First 1/50th of the pattern. -assert.equal(4751360, reallyLong.lastIndexOf(pattern)); -assert.equal(3932160, reallyLong.lastIndexOf(pattern, 4000000)); -assert.equal(2949120, reallyLong.lastIndexOf(pattern, 3000000)); +assert.strictEqual(4751360, reallyLong.lastIndexOf(pattern)); +assert.strictEqual(3932160, reallyLong.lastIndexOf(pattern, 4000000)); +assert.strictEqual(2949120, reallyLong.lastIndexOf(pattern, 3000000)); pattern = reallyLong.slice(100000, 200000); // Second 1/50th. -assert.equal(4728480, reallyLong.lastIndexOf(pattern)); +assert.strictEqual(4728480, reallyLong.lastIndexOf(pattern)); pattern = reallyLong.slice(0, 1000000); // First 1/5th. -assert.equal(3932160, reallyLong.lastIndexOf(pattern)); +assert.strictEqual(3932160, reallyLong.lastIndexOf(pattern)); pattern = reallyLong.slice(0, 2000000); // first 2/5ths. -assert.equal(0, reallyLong.lastIndexOf(pattern)); +assert.strictEqual(0, reallyLong.lastIndexOf(pattern)); // test truncation of Number arguments to uint8 { diff --git a/test/parallel/test-buffer-inspect.js b/test/parallel/test-buffer-inspect.js index 4fed249207611b..41e8197da6a38a 100644 --- a/test/parallel/test-buffer-inspect.js +++ b/test/parallel/test-buffer-inspect.js @@ -6,13 +6,13 @@ const buffer = require('buffer'); buffer.INSPECT_MAX_BYTES = 2; -var b = Buffer.allocUnsafe(4); +let b = Buffer.allocUnsafe(4); b.fill('1234'); -var s = buffer.SlowBuffer(4); +let s = buffer.SlowBuffer(4); s.fill('1234'); -var expected = ''; +let expected = ''; assert.strictEqual(util.inspect(b), expected); assert.strictEqual(util.inspect(s), expected); diff --git a/test/parallel/test-buffer-iterator.js b/test/parallel/test-buffer-iterator.js index 7a25682ebc27d9..3120ff1d2ab457 100644 --- a/test/parallel/test-buffer-iterator.js +++ b/test/parallel/test-buffer-iterator.js @@ -3,8 +3,8 @@ require('../common'); const assert = require('assert'); const buffer = Buffer.from([1, 2, 3, 4, 5]); -var arr; -var b; +let arr; +let b; // buffers should be iterable diff --git a/test/parallel/test-buffer-read-noassert.js b/test/parallel/test-buffer-read-noassert.js new file mode 100644 index 00000000000000..83d533a32031cb --- /dev/null +++ b/test/parallel/test-buffer-read-noassert.js @@ -0,0 +1,59 @@ +'use strict'; +require('../common'); +const assert = require('assert'); + +// testing basic buffer read functions +const buf = Buffer.from([0xa4, 0xfd, 0x48, 0xea, 0xcf, 0xff, 0xd9, 0x01, 0xde]); + +function read(buff, funx, args, expected) { + + assert.strictEqual(buff[funx](...args), expected); + assert.throws( + () => buff[funx](-1), + /^RangeError: Index out of range$/ + ); + + assert.doesNotThrow( + () => assert.strictEqual(buff[funx](...args, true), expected), + 'noAssert does not change return value for valid ranges' +); + +} + +// testing basic functionality of readDoubleBE() and readDOubleLE() +read(buf, 'readDoubleBE', [1], -3.1827727774563287e+295); +read(buf, 'readDoubleLE', [1], -6.966010051009108e+144); + +// testing basic functionality of readFLoatBE() and readFloatLE() +read(buf, 'readFloatBE', [1], -1.6691549692541768e+37); +read(buf, 'readFloatLE', [1], -7861303808); + +// testing basic functionality of readInt8() +read(buf, 'readInt8', [1], -3); + +// testing basic functionality of readInt16BE() and readInt16LE() +read(buf, 'readInt16BE', [1], -696); +read(buf, 'readInt16LE', [1], 0x48fd); + +// testing basic functionality of readInt32BE() and readInt32LE() +read(buf, 'readInt32BE', [1], -45552945); +read(buf, 'readInt32LE', [1], -806729475); + +// testing basic functionality of readIntBE() and readIntLE() +read(buf, 'readIntBE', [1, 1], -3); +read(buf, 'readIntLE', [2, 1], 0x48); + +// testing basic functionality of readUInt8() +read(buf, 'readUInt8', [1], 0xfd); + +// testing basic functionality of readUInt16BE() and readUInt16LE() +read(buf, 'readUInt16BE', [2], 0x48ea); +read(buf, 'readUInt16LE', [2], 0xea48); + +// testing basic functionality of readUInt32BE() and readUInt32LE() +read(buf, 'readUInt32BE', [1], 0xfd48eacf); +read(buf, 'readUInt32LE', [1], 0xcfea48fd); + +// testing basic functionality of readUIntBE() and readUIntLE() +read(buf, 'readUIntBE', [2, 0], 0xfd); +read(buf, 'readUIntLE', [2, 0], 0x48); diff --git a/test/parallel/test-buffer-readuintbe.js b/test/parallel/test-buffer-readuintbe.js deleted file mode 100644 index 162e9fea27a14f..00000000000000 --- a/test/parallel/test-buffer-readuintbe.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -require('../common'); -const assert = require('assert'); - -// testing basic functionality of readUIntBE() - -const buf = Buffer.from([42, 84, 168, 127]); -const result = buf.readUIntBE(2); - -assert.strictEqual(result, 84); - -assert.throws( - () => { - buf.readUIntBE(5); - }, - /Index out of range/ -); - -assert.doesNotThrow( - () => { - buf.readUIntBE(5, 0, true); - }, - 'readUIntBE() should not throw if noAssert is true' -); diff --git a/test/parallel/test-buffer-readuintle.js b/test/parallel/test-buffer-readuintle.js deleted file mode 100644 index 982adb8607eaa1..00000000000000 --- a/test/parallel/test-buffer-readuintle.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -require('../common'); -const assert = require('assert'); - -// testing basic functionality of readUIntLE() - -const buf = Buffer.from([42, 84, 168, 127]); -const result = buf.readUIntLE(2); - -assert.strictEqual(result, 168); - -assert.throws( - () => { - buf.readUIntLE(5); - }, - /Index out of range/ -); - -assert.doesNotThrow( - () => { - buf.readUIntLE(5, 0, true); - }, - 'readUIntLE() should not throw if noAssert is true' -); diff --git a/test/parallel/test-buffer-slice.js b/test/parallel/test-buffer-slice.js index 2489420c33e6e9..b43654b952de0b 100644 --- a/test/parallel/test-buffer-slice.js +++ b/test/parallel/test-buffer-slice.js @@ -8,54 +8,54 @@ assert.strictEqual(0, Buffer('hello', 'utf8').slice(0, 0).length); const buf = Buffer.from('0123456789', 'utf8'); assert.strictEqual(0, Buffer.compare(buf.slice(-10, 10), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(-20, 10), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(-20, -10), - Buffer.from('', 'utf8'))); + Buffer.from('', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(0), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(0, 0), - Buffer.from('', 'utf8'))); + Buffer.from('', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(undefined), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice('foobar'), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(undefined, undefined), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(2), - Buffer.from('23456789', 'utf8'))); + Buffer.from('23456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(5), - Buffer.from('56789', 'utf8'))); + Buffer.from('56789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(10), - Buffer.from('', 'utf8'))); + Buffer.from('', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(5, 8), - Buffer.from('567', 'utf8'))); + Buffer.from('567', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(8, -1), - Buffer.from('8', 'utf8'))); + Buffer.from('8', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(-10), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(0, -9), - Buffer.from('0', 'utf8'))); + Buffer.from('0', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(0, -10), - Buffer.from('', 'utf8'))); + Buffer.from('', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(0, -1), - Buffer.from('012345678', 'utf8'))); + Buffer.from('012345678', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(2, -2), - Buffer.from('234567', 'utf8'))); + Buffer.from('234567', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(0, 65536), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(65536, 0), - Buffer.from('', 'utf8'))); + Buffer.from('', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(-5, -8), - Buffer.from('', 'utf8'))); + Buffer.from('', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(-5, -3), - Buffer.from('56', 'utf8'))); + Buffer.from('56', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice(-10, 10), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); for (let i = 0, s = buf; i < buf.length; ++i) { assert.strictEqual(0, Buffer.compare(buf.slice(i), s.slice(i))); assert.strictEqual(0, Buffer.compare(buf.slice(0, i), s.slice(0, i))); @@ -67,19 +67,19 @@ const utf16Buf = Buffer.from('0123456789', 'utf16le'); assert.deepStrictEqual(utf16Buf.slice(0, 6), Buffer.from('012', 'utf16le')); assert.strictEqual(0, Buffer.compare(buf.slice('0', '1'), - Buffer.from('0', 'utf8'))); + Buffer.from('0', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice('-5', '10'), - Buffer.from('56789', 'utf8'))); + Buffer.from('56789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice('-10', '10'), - Buffer.from('0123456789', 'utf8'))); + Buffer.from('0123456789', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice('-10', '-5'), - Buffer.from('01234', 'utf8'))); + Buffer.from('01234', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice('-10', '-0'), - Buffer.from('', 'utf8'))); + Buffer.from('', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice('111'), - Buffer.from('', 'utf8'))); + Buffer.from('', 'utf8'))); assert.strictEqual(0, Buffer.compare(buf.slice('0', '-111'), - Buffer.from('', 'utf8'))); + Buffer.from('', 'utf8'))); // try to slice a zero length Buffer // see https://github.com/joyent/node/issues/5881 diff --git a/test/parallel/test-buffer-swap.js b/test/parallel/test-buffer-swap.js index f72b638f75a30b..bcb636edb1733f 100644 --- a/test/parallel/test-buffer-swap.js +++ b/test/parallel/test-buffer-swap.js @@ -45,80 +45,80 @@ assert.deepStrictEqual(buf3_64, Buffer.from([0x01, 0x02, 0x0a, 0x09, 0x08, 0x07, 0x0f, 0x10])); // Force use of native code (Buffer size above threshold limit for js impl) -var buf4A = new Uint32Array(256).fill(0x04030201); -var buf4 = Buffer.from(buf4A.buffer, buf4A.byteOffset); -var buf5A = new Uint32Array(256).fill(0x03040102); -var buf5 = Buffer.from(buf5A.buffer, buf5A.byteOffset); +const buf4A = new Uint32Array(256).fill(0x04030201); +const buf4 = Buffer.from(buf4A.buffer, buf4A.byteOffset); +const buf5A = new Uint32Array(256).fill(0x03040102); +const buf5 = Buffer.from(buf5A.buffer, buf5A.byteOffset); buf4.swap16(); assert.deepStrictEqual(buf4, buf5); -var buf6A = new Uint32Array(256).fill(0x04030201); -var buf6 = Buffer.from(buf6A.buffer); -var bu7A = new Uint32Array(256).fill(0x01020304); -var buf7 = Buffer.from(bu7A.buffer, bu7A.byteOffset); +const buf6A = new Uint32Array(256).fill(0x04030201); +const buf6 = Buffer.from(buf6A.buffer); +const bu7A = new Uint32Array(256).fill(0x01020304); +const buf7 = Buffer.from(bu7A.buffer, bu7A.byteOffset); buf6.swap32(); assert.deepStrictEqual(buf6, buf7); -var buf8A = new Uint8Array(256 * 8); -var buf9A = new Uint8Array(256 * 8); +const buf8A = new Uint8Array(256 * 8); +const buf9A = new Uint8Array(256 * 8); for (let i = 0; i < buf8A.length; i++) { buf8A[i] = i % 8; buf9A[buf9A.length - i - 1] = i % 8; } -var buf8 = Buffer.from(buf8A.buffer, buf8A.byteOffset); -var buf9 = Buffer.from(buf9A.buffer, buf9A.byteOffset); +const buf8 = Buffer.from(buf8A.buffer, buf8A.byteOffset); +const buf9 = Buffer.from(buf9A.buffer, buf9A.byteOffset); buf8.swap64(); assert.deepStrictEqual(buf8, buf9); // Test native code with buffers that are not memory-aligned -var buf10A = new Uint8Array(256 * 8); -var buf11A = new Uint8Array(256 * 8 - 2); +const buf10A = new Uint8Array(256 * 8); +const buf11A = new Uint8Array(256 * 8 - 2); for (let i = 0; i < buf10A.length; i++) { buf10A[i] = i % 2; } for (let i = 1; i < buf11A.length; i++) { buf11A[buf11A.length - i] = (i + 1) % 2; } -var buf10 = Buffer.from(buf10A.buffer, buf10A.byteOffset); +const buf10 = Buffer.from(buf10A.buffer, buf10A.byteOffset); // 0|1 0|1 0|1... -var buf11 = Buffer.from(buf11A.buffer, buf11A.byteOffset); +const buf11 = Buffer.from(buf11A.buffer, buf11A.byteOffset); // 0|0 1|0 1|0... buf10.slice(1, buf10.length - 1).swap16(); assert.deepStrictEqual(buf10.slice(0, buf11.length), buf11); -var buf12A = new Uint8Array(256 * 8); -var buf13A = new Uint8Array(256 * 8 - 4); +const buf12A = new Uint8Array(256 * 8); +const buf13A = new Uint8Array(256 * 8 - 4); for (let i = 0; i < buf12A.length; i++) { buf12A[i] = i % 4; } for (let i = 1; i < buf13A.length; i++) { buf13A[buf13A.length - i] = (i + 1) % 4; } -var buf12 = Buffer.from(buf12A.buffer, buf12A.byteOffset); +const buf12 = Buffer.from(buf12A.buffer, buf12A.byteOffset); // 0|1 2 3 0|1 2 3... -var buf13 = Buffer.from(buf13A.buffer, buf13A.byteOffset); +const buf13 = Buffer.from(buf13A.buffer, buf13A.byteOffset); // 0|0 3 2 1|0 3 2... buf12.slice(1, buf12.length - 3).swap32(); assert.deepStrictEqual(buf12.slice(0, buf13.length), buf13); -var buf14A = new Uint8Array(256 * 8); -var buf15A = new Uint8Array(256 * 8 - 8); +const buf14A = new Uint8Array(256 * 8); +const buf15A = new Uint8Array(256 * 8 - 8); for (let i = 0; i < buf14A.length; i++) { buf14A[i] = i % 8; } for (let i = 1; i < buf15A.length; i++) { buf15A[buf15A.length - i] = (i + 1) % 8; } -var buf14 = Buffer.from(buf14A.buffer, buf14A.byteOffset); +const buf14 = Buffer.from(buf14A.buffer, buf14A.byteOffset); // 0|1 2 3 4 5 6 7 0|1 2 3 4... -var buf15 = Buffer.from(buf15A.buffer, buf15A.byteOffset); +const buf15 = Buffer.from(buf15A.buffer, buf15A.byteOffset); // 0|0 7 6 5 4 3 2 1|0 7 6 5... buf14.slice(1, buf14.length - 7).swap64(); diff --git a/test/parallel/test-buffer-write-noassert.js b/test/parallel/test-buffer-write-noassert.js new file mode 100644 index 00000000000000..c0054733b85bb2 --- /dev/null +++ b/test/parallel/test-buffer-write-noassert.js @@ -0,0 +1,48 @@ +'use strict'; +require('../common'); +const assert = require('assert'); + +// testing buffer write functions + +function write(funx, args, result, res) { + { + const buf = Buffer.alloc(9); + assert.strictEqual(buf[funx](...args), result); + assert.deepStrictEqual(buf, res); + } + + { + const invalidArgs = Array.from(args); + invalidArgs[1] = -1; + assert.throws( + () => Buffer.alloc(9)[funx](...invalidArgs), + /^RangeError: (?:Index )?out of range(?: index)?$/ + ); + } + + { + const buf2 = Buffer.alloc(9); + assert.strictEqual(buf2[funx](...args, true), result); + assert.deepStrictEqual(buf2, res); + } + +} + +write('writeInt8', [1, 0], 1, Buffer.from([1, 0, 0, 0, 0, 0, 0, 0, 0])); +write('writeIntBE', [1, 1, 4], 5, Buffer.from([0, 0, 0, 0, 1, 0, 0, 0, 0])); +write('writeIntLE', [1, 1, 4], 5, Buffer.from([0, 1, 0, 0, 0, 0, 0, 0, 0])); +write('writeInt16LE', [1, 1], 3, Buffer.from([0, 1, 0, 0, 0, 0, 0, 0, 0])); +write('writeInt16BE', [1, 1], 3, Buffer.from([0, 0, 1, 0, 0, 0, 0, 0, 0])); +write('writeInt32LE', [1, 1], 5, Buffer.from([0, 1, 0, 0, 0, 0, 0, 0, 0])); +write('writeInt32BE', [1, 1], 5, Buffer.from([0, 0, 0, 0, 1, 0, 0, 0, 0])); +write('writeUInt8', [1, 0], 1, Buffer.from([1, 0, 0, 0, 0, 0, 0, 0, 0])); +write('writeUIntLE', [1, 1, 4], 5, Buffer.from([0, 1, 0, 0, 0, 0, 0, 0, 0])); +write('writeUIntBE', [1, 1, 4], 5, Buffer.from([0, 0, 0, 0, 1, 0, 0, 0, 0])); +write('writeUInt16LE', [1, 1], 3, Buffer.from([0, 1, 0, 0, 0, 0, 0, 0, 0])); +write('writeUInt16BE', [1, 1], 3, Buffer.from([0, 0, 1, 0, 0, 0, 0, 0, 0])); +write('writeUInt32LE', [1, 1], 5, Buffer.from([0, 1, 0, 0, 0, 0, 0, 0, 0])); +write('writeUInt32BE', [1, 1], 5, Buffer.from([0, 0, 0, 0, 1, 0, 0, 0, 0])); +write('writeDoubleBE', [1, 1], 9, Buffer.from([0, 63, 240, 0, 0, 0, 0, 0, 0])); +write('writeDoubleLE', [1, 1], 9, Buffer.from([0, 0, 0, 0, 0, 0, 0, 240, 63])); +write('writeFloatBE', [1, 1], 5, Buffer.from([0, 63, 128, 0, 0, 0, 0, 0, 0])); +write('writeFloatLE', [1, 1], 5, Buffer.from([0, 0, 0, 128, 63, 0, 0, 0, 0])); diff --git a/test/parallel/test-child-process-constructor.js b/test/parallel/test-child-process-constructor.js index 0abf1289f0737d..d33c7ae3acf626 100644 --- a/test/parallel/test-child-process-constructor.js +++ b/test/parallel/test-child-process-constructor.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var child_process = require('child_process'); -var ChildProcess = child_process.ChildProcess; +const assert = require('assert'); +const child_process = require('child_process'); +const ChildProcess = child_process.ChildProcess; assert.strictEqual(typeof ChildProcess, 'function'); // test that we can call spawn -var child = new ChildProcess(); +const child = new ChildProcess(); child.spawn({ file: process.execPath, args: ['--interactive'], diff --git a/test/parallel/test-child-process-default-options.js b/test/parallel/test-child-process-default-options.js index 38a1b291b9967c..37e7ea7494670e 100644 --- a/test/parallel/test-child-process-default-options.js +++ b/test/parallel/test-child-process-default-options.js @@ -1,19 +1,19 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var spawn = require('child_process').spawn; +const spawn = require('child_process').spawn; process.env.HELLO = 'WORLD'; -var child; +let child; if (common.isWindows) { child = spawn('cmd.exe', ['/c', 'set'], {}); } else { child = spawn('/usr/bin/env', [], {}); } -var response = ''; +let response = ''; child.stdout.setEncoding('utf8'); diff --git a/test/parallel/test-child-process-double-pipe.js b/test/parallel/test-child-process-double-pipe.js index c5b7c093af8a4a..dac48a2db7212a 100644 --- a/test/parallel/test-child-process-double-pipe.js +++ b/test/parallel/test-child-process-double-pipe.js @@ -8,7 +8,7 @@ const spawn = require('child_process').spawn; // We're trying to reproduce: // $ echo "hello\nnode\nand\nworld" | grep o | sed s/o/a/ -var grep, sed, echo; +let grep, sed, echo; if (common.isWindows) { grep = spawn('grep', ['--binary', 'o']), @@ -82,7 +82,7 @@ grep.stdout.on('end', function(code) { }); -var result = ''; +let result = ''; // print sed's output sed.stdout.on('data', function(data) { diff --git a/test/parallel/test-child-process-env.js b/test/parallel/test-child-process-env.js index 2ebc653e9a067d..ad41f978e21768 100644 --- a/test/parallel/test-child-process-env.js +++ b/test/parallel/test-child-process-env.js @@ -1,17 +1,17 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var spawn = require('child_process').spawn; +const spawn = require('child_process').spawn; -var env = { +const env = { 'HELLO': 'WORLD' }; Object.setPrototypeOf(env, { 'FOO': 'BAR' }); -var child; +let child; if (common.isWindows) { child = spawn('cmd.exe', ['/c', 'set'], {env: env}); } else { @@ -19,7 +19,7 @@ if (common.isWindows) { } -var response = ''; +let response = ''; child.stdout.setEncoding('utf8'); diff --git a/test/parallel/test-child-process-exec-buffer.js b/test/parallel/test-child-process-exec-buffer.js deleted file mode 100644 index 092304879ec48c..00000000000000 --- a/test/parallel/test-child-process-exec-buffer.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -const common = require('../common'); -const assert = require('assert'); -const exec = require('child_process').exec; -const os = require('os'); -const str = 'hello'; - -// default encoding -exec('echo ' + str, common.mustCall(function(err, stdout, stderr) { - assert.strictEqual(typeof stdout, 'string', 'Expected stdout to be a string'); - assert.strictEqual(typeof stderr, 'string', 'Expected stderr to be a string'); - assert.strictEqual(str + os.EOL, stdout); -})); - -// no encoding (Buffers expected) -exec('echo ' + str, { - encoding: null -}, common.mustCall(function(err, stdout, stderr) { - assert.strictEqual(stdout instanceof Buffer, true, - 'Expected stdout to be a Buffer'); - assert.strictEqual(stderr instanceof Buffer, true, - 'Expected stderr to be a Buffer'); - assert.strictEqual(str + os.EOL, stdout.toString()); -})); diff --git a/test/parallel/test-child-process-exec-cwd.js b/test/parallel/test-child-process-exec-cwd.js index 3b6e428a4aca65..95feb42314fc8d 100644 --- a/test/parallel/test-child-process-exec-cwd.js +++ b/test/parallel/test-child-process-exec-cwd.js @@ -3,7 +3,7 @@ const common = require('../common'); const assert = require('assert'); const exec = require('child_process').exec; -var pwdcommand, dir; +let pwdcommand, dir; if (common.isWindows) { pwdcommand = 'echo %cd%'; diff --git a/test/parallel/test-child-process-exec-encoding.js b/test/parallel/test-child-process-exec-encoding.js new file mode 100644 index 00000000000000..ba80ccda8c6aee --- /dev/null +++ b/test/parallel/test-child-process-exec-encoding.js @@ -0,0 +1,49 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cp = require('child_process'); +const stdoutData = 'foo'; +const stderrData = 'bar'; +const expectedStdout = `${stdoutData}\n`; +const expectedStderr = `${stderrData}\n`; + +if (process.argv[2] === 'child') { + // The following console calls are part of the test. + console.log(stdoutData); + console.error(stderrData); +} else { + function run(options, callback) { + const cmd = `${process.execPath} ${__filename} child`; + + cp.exec(cmd, options, common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + callback(stdout, stderr); + })); + } + + // Test default encoding, which should be utf8. + run({}, (stdout, stderr) => { + assert.strictEqual(typeof stdout, 'string'); + assert.strictEqual(typeof stderr, 'string'); + assert.strictEqual(stdout, expectedStdout); + assert.strictEqual(stderr, expectedStderr); + }); + + // Test explicit utf8 encoding. + run({ encoding: 'utf8' }, (stdout, stderr) => { + assert.strictEqual(typeof stdout, 'string'); + assert.strictEqual(typeof stderr, 'string'); + assert.strictEqual(stdout, expectedStdout); + assert.strictEqual(stderr, expectedStderr); + }); + + // Test cases that result in buffer encodings. + [undefined, null, 'buffer', 'invalid'].forEach((encoding) => { + run({ encoding }, (stdout, stderr) => { + assert(stdout instanceof Buffer); + assert(stdout instanceof Buffer); + assert.strictEqual(stdout.toString(), expectedStdout); + assert.strictEqual(stderr.toString(), expectedStderr); + }); + }); +} diff --git a/test/parallel/test-child-process-exec-stdout-stderr-data-string.js b/test/parallel/test-child-process-exec-stdout-stderr-data-string.js index 8ab834c98f8d79..472d31f16ac920 100644 --- a/test/parallel/test-child-process-exec-stdout-stderr-data-string.js +++ b/test/parallel/test-child-process-exec-stdout-stderr-data-string.js @@ -4,8 +4,8 @@ const common = require('../common'); const assert = require('assert'); const exec = require('child_process').exec; -var stdoutCalls = 0; -var stderrCalls = 0; +let stdoutCalls = 0; +let stderrCalls = 0; const command = common.isWindows ? 'dir' : 'ls'; exec(command).stdout.on('data', (data) => { diff --git a/test/parallel/test-child-process-exit-code.js b/test/parallel/test-child-process-exit-code.js index 3a393f126fbe13..9596a202223993 100644 --- a/test/parallel/test-child-process-exit-code.js +++ b/test/parallel/test-child-process-exit-code.js @@ -1,20 +1,20 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; -var path = require('path'); +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; +const path = require('path'); -var exitScript = path.join(common.fixturesDir, 'exit.js'); -var exitChild = spawn(process.argv[0], [exitScript, 23]); +const exitScript = path.join(common.fixturesDir, 'exit.js'); +const exitChild = spawn(process.argv[0], [exitScript, 23]); exitChild.on('exit', common.mustCall(function(code, signal) { assert.strictEqual(code, 23); assert.strictEqual(signal, null); })); -var errorScript = path.join(common.fixturesDir, - 'child_process_should_emit_error.js'); -var errorChild = spawn(process.argv[0], [errorScript]); +const errorScript = path.join(common.fixturesDir, + 'child_process_should_emit_error.js'); +const errorChild = spawn(process.argv[0], [errorScript]); errorChild.on('exit', common.mustCall(function(code, signal) { assert.ok(code !== 0); assert.strictEqual(signal, null); diff --git a/test/parallel/test-child-process-fork-close.js b/test/parallel/test-child-process-fork-close.js index d6e9675ba82012..d8b1aa0bf3267c 100644 --- a/test/parallel/test-child-process-fork-close.js +++ b/test/parallel/test-child-process-fork-close.js @@ -3,7 +3,7 @@ const common = require('../common'); const assert = require('assert'); const fork = require('child_process').fork; -var cp = fork(common.fixturesDir + '/child-process-message-and-exit.js'); +const cp = fork(common.fixturesDir + '/child-process-message-and-exit.js'); let gotMessage = false; let gotExit = false; diff --git a/test/parallel/test-child-process-fork-dgram.js b/test/parallel/test-child-process-fork-dgram.js index 8bdf006a743e0d..4447c54cae8f0c 100644 --- a/test/parallel/test-child-process-fork-dgram.js +++ b/test/parallel/test-child-process-fork-dgram.js @@ -37,8 +37,8 @@ if (process.argv[2] === 'child') { const msg = Buffer.from('Some bytes'); - var childGotMessage = false; - var parentGotMessage = false; + let childGotMessage = false; + let parentGotMessage = false; parentServer.once('message', function(msg, rinfo) { parentGotMessage = true; @@ -76,7 +76,7 @@ if (process.argv[2] === 'child') { serverPort, '127.0.0.1', function(err) { - if (err) throw err; + assert.ifError(err); } ); } diff --git a/test/parallel/test-child-process-fork-exec-argv.js b/test/parallel/test-child-process-fork-exec-argv.js index 5ccc17fb3fc7c4..97d1e21a2f6d7a 100644 --- a/test/parallel/test-child-process-fork-exec-argv.js +++ b/test/parallel/test-child-process-fork-exec-argv.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var child_process = require('child_process'); -var spawn = child_process.spawn; -var fork = child_process.fork; +const assert = require('assert'); +const child_process = require('child_process'); +const spawn = child_process.spawn; +const fork = child_process.fork; if (process.argv[2] === 'fork') { process.stdout.write(JSON.stringify(process.execArgv), function() { @@ -12,11 +12,11 @@ if (process.argv[2] === 'fork') { } else if (process.argv[2] === 'child') { fork(__filename, ['fork']); } else { - var execArgv = ['--stack-size=256']; - var args = [__filename, 'child', 'arg0']; + const execArgv = ['--stack-size=256']; + const args = [__filename, 'child', 'arg0']; - var child = spawn(process.execPath, execArgv.concat(args)); - var out = ''; + const child = spawn(process.execPath, execArgv.concat(args)); + let out = ''; child.stdout.on('data', function(chunk) { out += chunk; diff --git a/test/parallel/test-child-process-fork-exec-path.js b/test/parallel/test-child-process-fork-exec-path.js index e2f7e4b4d20eef..5af0184a21f55d 100644 --- a/test/parallel/test-child-process-fork-exec-path.js +++ b/test/parallel/test-child-process-fork-exec-path.js @@ -1,11 +1,11 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); -var path = require('path'); -var msg = {test: 'this'}; -var nodePath = process.execPath; -var copyPath = path.join(common.tmpDir, 'node-copy.exe'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); +const msg = {test: 'this'}; +const nodePath = process.execPath; +const copyPath = path.join(common.tmpDir, 'node-copy.exe'); if (process.env.FORK) { assert(process.send); @@ -23,9 +23,9 @@ if (process.env.FORK) { fs.chmodSync(copyPath, '0755'); // slow but simple - var envCopy = JSON.parse(JSON.stringify(process.env)); + const envCopy = JSON.parse(JSON.stringify(process.env)); envCopy.FORK = 'true'; - var child = require('child_process').fork(__filename, { + const child = require('child_process').fork(__filename, { execPath: copyPath, env: envCopy }); diff --git a/test/parallel/test-child-process-fork-net.js b/test/parallel/test-child-process-fork-net.js index cbafcb13fbb068..157704a9ccf9c9 100644 --- a/test/parallel/test-child-process-fork-net.js +++ b/test/parallel/test-child-process-fork-net.js @@ -19,7 +19,7 @@ ProgressTracker.prototype.check = function() { if (process.argv[2] === 'child') { - var serverScope; + let serverScope; process.on('message', function onServer(msg, server) { if (msg.what !== 'server') return; @@ -58,17 +58,17 @@ if (process.argv[2] === 'child') { process.send({what: 'ready'}); } else { - var child = fork(process.argv[1], ['child']); + const child = fork(process.argv[1], ['child']); child.on('exit', function() { console.log('CHILD: died'); }); // send net.Server to child and test by connecting - var testServer = function(callback) { + const testServer = function(callback) { // destroy server execute callback when done - var progress = new ProgressTracker(2, function() { + const progress = new ProgressTracker(2, function() { server.on('close', function() { console.log('PARENT: server closed'); child.send({what: 'close'}); @@ -77,11 +77,11 @@ if (process.argv[2] === 'child') { }); // we expect 4 connections and close events - var connections = new ProgressTracker(4, progress.done.bind(progress)); - var closed = new ProgressTracker(4, progress.done.bind(progress)); + const connections = new ProgressTracker(4, progress.done.bind(progress)); + const closed = new ProgressTracker(4, progress.done.bind(progress)); // create server and send it to child - var server = net.createServer(); + const server = net.createServer(); server.on('connection', function(socket) { console.log('PARENT: got connection'); socket.destroy(); @@ -94,12 +94,12 @@ if (process.argv[2] === 'child') { server.listen(0); // handle client messages - var messageHandlers = function(msg) { + const messageHandlers = function(msg) { if (msg.what === 'listening') { // make connections - var socket; - for (var i = 0; i < 4; i++) { + let socket; + for (let i = 0; i < 4; i++) { socket = net.connect(server.address().port, function() { console.log('CLIENT: connected'); }); @@ -122,11 +122,11 @@ if (process.argv[2] === 'child') { }; // send net.Socket to child - var testSocket = function(callback) { + const testSocket = function(callback) { // create a new server and connect to it, // but the socket will be handled by the child - var server = net.createServer(); + const server = net.createServer(); server.on('connection', function(socket) { socket.on('close', function() { console.log('CLIENT: socket closed'); @@ -145,23 +145,23 @@ if (process.argv[2] === 'child') { // will have to do. server.listen(0, function() { console.error('testSocket, listening'); - var connect = net.connect(server.address().port); - var store = ''; + const connect = net.connect(server.address().port); + let store = ''; connect.on('data', function(chunk) { store += chunk; console.log('CLIENT: got data'); }); connect.on('close', function() { console.log('CLIENT: closed'); - assert.equal(store, 'echo'); + assert.strictEqual(store, 'echo'); server.close(); }); }); }; // create server and send it to child - var serverSuccess = false; - var socketSuccess = false; + let serverSuccess = false; + let socketSuccess = false; child.on('message', function onReady(msg) { if (msg.what !== 'ready') return; child.removeListener('message', onReady); diff --git a/test/parallel/test-child-process-fork-net2.js b/test/parallel/test-child-process-fork-net2.js index be1ee5d3a4145a..ef8575385a42fd 100644 --- a/test/parallel/test-child-process-fork-net2.js +++ b/test/parallel/test-child-process-fork-net2.js @@ -1,13 +1,13 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var fork = require('child_process').fork; -var net = require('net'); -var count = 12; +const assert = require('assert'); +const fork = require('child_process').fork; +const net = require('net'); +const count = 12; if (process.argv[2] === 'child') { - var needEnd = []; - var id = process.argv[3]; + const needEnd = []; + const id = process.argv[3]; process.on('message', function(m, socket) { if (!socket) return; @@ -60,11 +60,11 @@ if (process.argv[2] === 'child') { } else { - var child1 = fork(process.argv[1], ['child', '1']); - var child2 = fork(process.argv[1], ['child', '2']); - var child3 = fork(process.argv[1], ['child', '3']); + const child1 = fork(process.argv[1], ['child', '1']); + const child2 = fork(process.argv[1], ['child', '2']); + const child3 = fork(process.argv[1], ['child', '3']); - var server = net.createServer(); + const server = net.createServer(); let connected = 0; let closed = 0; @@ -94,10 +94,10 @@ if (process.argv[2] === 'child') { } }); - var disconnected = 0; + let disconnected = 0; server.on('listening', function() { - var j = count, client; + let j = count, client; while (j--) { client = net.connect(this.address().port, '127.0.0.1'); client.on('error', function() { @@ -112,7 +112,7 @@ if (process.argv[2] === 'child') { } }); - var closeEmitted = false; + let closeEmitted = false; server.on('close', common.mustCall(function() { closeEmitted = true; @@ -123,7 +123,7 @@ if (process.argv[2] === 'child') { server.listen(0, '127.0.0.1'); - var closeServer = function() { + const closeServer = function() { server.close(); setTimeout(function() { @@ -135,7 +135,7 @@ if (process.argv[2] === 'child') { }; process.on('exit', function() { - assert.equal(disconnected, count); - assert.equal(connected, count); + assert.strictEqual(disconnected, count); + assert.strictEqual(connected, count); }); } diff --git a/test/parallel/test-child-process-fork-ref.js b/test/parallel/test-child-process-fork-ref.js index 50a944e71ba83c..a7ff8c04cbab25 100644 --- a/test/parallel/test-child-process-fork-ref.js +++ b/test/parallel/test-child-process-fork-ref.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var fork = require('child_process').fork; +const assert = require('assert'); +const fork = require('child_process').fork; if (process.argv[2] === 'child') { process.send('1'); @@ -16,9 +16,10 @@ if (process.argv[2] === 'child') { }); } else { - var child = fork(__filename, ['child'], {silent: true}); + const child = fork(__filename, ['child'], {silent: true}); - var ipc = [], stdout = ''; + const ipc = []; + let stdout = ''; child.on('message', function(msg) { ipc.push(msg); @@ -32,6 +33,6 @@ if (process.argv[2] === 'child') { child.once('exit', function() { assert.deepStrictEqual(ipc, ['1', '2']); - assert.equal(stdout, '3'); + assert.strictEqual(stdout, '3'); }); } diff --git a/test/parallel/test-child-process-fork-ref2.js b/test/parallel/test-child-process-fork-ref2.js index 42c43ed8882b78..9f59aa344aa2c9 100644 --- a/test/parallel/test-child-process-fork-ref2.js +++ b/test/parallel/test-child-process-fork-ref2.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var fork = require('child_process').fork; +const fork = require('child_process').fork; if (process.argv[2] === 'child') { console.log('child -> call disconnect'); @@ -12,7 +12,7 @@ if (process.argv[2] === 'child') { }, 400); } else { - var child = fork(__filename, ['child']); + const child = fork(__filename, ['child']); child.on('disconnect', function() { console.log('parent -> disconnect'); diff --git a/test/parallel/test-child-process-fork-regr-gh-2847.js b/test/parallel/test-child-process-fork-regr-gh-2847.js index d985b8b4acaf19..0bcf4bf9a1c88f 100644 --- a/test/parallel/test-child-process-fork-regr-gh-2847.js +++ b/test/parallel/test-child-process-fork-regr-gh-2847.js @@ -14,7 +14,7 @@ if (!cluster.isMaster) { return; } -var server = net.createServer(function(s) { +const server = net.createServer(function(s) { if (common.isWindows) { s.on('error', function(err) { // Prevent possible ECONNRESET errors from popping up @@ -26,10 +26,10 @@ var server = net.createServer(function(s) { s.destroy(); }, 100); }).listen(0, function() { - var worker = cluster.fork(); + const worker = cluster.fork(); function send(callback) { - var s = net.connect(server.address().port, function() { + const s = net.connect(server.address().port, function() { worker.send({}, s, callback); }); diff --git a/test/parallel/test-child-process-fork.js b/test/parallel/test-child-process-fork.js index a7d4a995a33700..bfc68e41dc95fb 100644 --- a/test/parallel/test-child-process-fork.js +++ b/test/parallel/test-child-process-fork.js @@ -1,10 +1,10 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var fork = require('child_process').fork; -var args = ['foo', 'bar']; +const assert = require('assert'); +const fork = require('child_process').fork; +const args = ['foo', 'bar']; -var n = fork(common.fixturesDir + '/child-process-spawn-node.js', args); +const n = fork(common.fixturesDir + '/child-process-spawn-node.js', args); assert.strictEqual(n.channel, n._channel); assert.deepStrictEqual(args, ['foo', 'bar']); diff --git a/test/parallel/test-child-process-fork3.js b/test/parallel/test-child-process-fork3.js index fe0e68b6a6436e..5588c41422e21b 100644 --- a/test/parallel/test-child-process-fork3.js +++ b/test/parallel/test-child-process-fork3.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); -var child_process = require('child_process'); +const common = require('../common'); +const child_process = require('child_process'); child_process.fork(common.fixturesDir + '/empty.js'); // should not hang diff --git a/test/parallel/test-child-process-internal.js b/test/parallel/test-child-process-internal.js index f3e452ef87ea76..d795b69d7ee0e5 100644 --- a/test/parallel/test-child-process-internal.js +++ b/test/parallel/test-child-process-internal.js @@ -1,11 +1,11 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); //messages -var PREFIX = 'NODE_'; -var normal = {cmd: 'foo' + PREFIX}; -var internal = {cmd: PREFIX + 'bar'}; +const PREFIX = 'NODE_'; +const normal = {cmd: 'foo' + PREFIX}; +const internal = {cmd: PREFIX + 'bar'}; if (process.argv[2] === 'child') { //send non-internal message containing PREFIX at a non prefix position @@ -18,8 +18,8 @@ if (process.argv[2] === 'child') { } else { - var fork = require('child_process').fork; - var child = fork(process.argv[1], ['child']); + const fork = require('child_process').fork; + const child = fork(process.argv[1], ['child']); child.once('message', common.mustCall(function(data) { assert.deepStrictEqual(data, normal); diff --git a/test/parallel/test-child-process-ipc.js b/test/parallel/test-child-process-ipc.js index cbaa270f5e8440..da952e6c9bf1ae 100644 --- a/test/parallel/test-child-process-ipc.js +++ b/test/parallel/test-child-process-ipc.js @@ -30,7 +30,7 @@ child.stdout.on('data', function(data) { child.stdin.write('echo me\r\n'); } else { console.error('testing for echo me'); - assert.equal('echo me\r\n', data); + assert.strictEqual('echo me\r\n', data); gotEcho = true; child.stdin.end(); } diff --git a/test/parallel/test-child-process-send-returns-boolean.js b/test/parallel/test-child-process-send-returns-boolean.js index 941a2da645f958..460c2b0022fc6b 100644 --- a/test/parallel/test-child-process-send-returns-boolean.js +++ b/test/parallel/test-child-process-send-returns-boolean.js @@ -15,7 +15,7 @@ assert.strictEqual(rv, true); const spawnOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] }; const s = spawn(process.execPath, [emptyFile], spawnOptions); -var handle = null; +let handle = null; s.on('exit', function() { handle.close(); }); diff --git a/test/parallel/test-child-process-set-blocking.js b/test/parallel/test-child-process-set-blocking.js index fb0b11f433130a..d6a044619b6479 100644 --- a/test/parallel/test-child-process-set-blocking.js +++ b/test/parallel/test-child-process-set-blocking.js @@ -1,14 +1,14 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var ch = require('child_process'); +const assert = require('assert'); +const ch = require('child_process'); -var SIZE = 100000; +const SIZE = 100000; -var cp = ch.spawn('python', ['-c', 'print ' + SIZE + ' * "C"'], { +const cp = ch.spawn('python', ['-c', 'print ' + SIZE + ' * "C"'], { stdio: 'inherit' }); cp.on('exit', common.mustCall(function(code) { - assert.equal(0, code); + assert.strictEqual(0, code); })); diff --git a/test/parallel/test-child-process-silent.js b/test/parallel/test-child-process-silent.js index 50d4ae881ad880..3bfa9f5f7d5235 100644 --- a/test/parallel/test-child-process-silent.js +++ b/test/parallel/test-child-process-silent.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var childProcess = require('child_process'); +const assert = require('assert'); +const childProcess = require('child_process'); // Child pipe test if (process.argv[2] === 'pipe') { @@ -32,15 +32,15 @@ if (process.argv[2] === 'pipe') { // testcase | start parent && child IPC test // testing: is stderr and stdout piped to parent - var args = [process.argv[1], 'parent']; - var parent = childProcess.spawn(process.execPath, args); + const args = [process.argv[1], 'parent']; + const parent = childProcess.spawn(process.execPath, args); //got any stderr or std data - var stdoutData = false; + let stdoutData = false; parent.stdout.on('data', function() { stdoutData = true; }); - var stderrData = false; + let stderrData = false; parent.stdout.on('data', function() { stderrData = true; }); @@ -52,8 +52,8 @@ if (process.argv[2] === 'pipe') { child.stderr.pipe(process.stderr, {end: false}); child.stdout.pipe(process.stdout, {end: false}); - var childSending = false; - var childReciveing = false; + let childSending = false; + let childReciveing = false; child.on('message', function(message) { if (childSending === false) { childSending = (message === 'message from child'); diff --git a/test/parallel/test-child-process-spawn-shell.js b/test/parallel/test-child-process-spawn-shell.js index 591fb409cb4cea..01411144bdc48f 100644 --- a/test/parallel/test-child-process-spawn-shell.js +++ b/test/parallel/test-child-process-spawn-shell.js @@ -6,7 +6,7 @@ const cp = require('child_process'); // Verify that a shell is, in fact, executed const doesNotExist = cp.spawn('does-not-exist', {shell: true}); -assert.notEqual(doesNotExist.spawnfile, 'does-not-exist'); +assert.notStrictEqual(doesNotExist.spawnfile, 'does-not-exist'); doesNotExist.on('error', common.fail); doesNotExist.on('exit', common.mustCall((code, signal) => { assert.strictEqual(signal, null); diff --git a/test/parallel/test-child-process-spawn-typeerror.js b/test/parallel/test-child-process-spawn-typeerror.js index 7b98cedf8ba117..756d61931a68f3 100644 --- a/test/parallel/test-child-process-spawn-typeerror.js +++ b/test/parallel/test-child-process-spawn-typeerror.js @@ -12,7 +12,7 @@ const invalidOptionsMsg = /"options" argument must be an object/; const empty = common.fixturesDir + '/empty.js'; assert.throws(function() { - var child = spawn(invalidcmd, 'this is not an array'); + const child = spawn(invalidcmd, 'this is not an array'); child.on('error', common.fail); }, TypeError); diff --git a/test/parallel/test-child-process-spawnsync-env.js b/test/parallel/test-child-process-spawnsync-env.js index 4455b867e30108..b5a1c723660faa 100644 --- a/test/parallel/test-child-process-spawnsync-env.js +++ b/test/parallel/test-child-process-spawnsync-env.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var cp = require('child_process'); +const assert = require('assert'); +const cp = require('child_process'); if (process.argv[2] === 'child') { console.log(process.env.foo); } else { - var expected = 'bar'; - var child = cp.spawnSync(process.execPath, [__filename, 'child'], { + const expected = 'bar'; + const child = cp.spawnSync(process.execPath, [__filename, 'child'], { env: Object.assign(process.env, { foo: expected }) }); - assert.equal(child.stdout.toString().trim(), expected); + assert.strictEqual(child.stdout.toString().trim(), expected); } diff --git a/test/parallel/test-child-process-spawnsync-input.js b/test/parallel/test-child-process-spawnsync-input.js index fdd29aa7d0cc50..1bda3d5dcf9da2 100644 --- a/test/parallel/test-child-process-spawnsync-input.js +++ b/test/parallel/test-child-process-spawnsync-input.js @@ -17,7 +17,7 @@ const args = [ `console.log("${msgOut}"); console.error("${msgErr}");` ]; -var ret; +let ret; function checkSpawnSyncRet(ret) { @@ -51,7 +51,7 @@ if (process.argv.indexOf('spawnchild') !== -1) { verifyBufOutput(spawnSync(process.execPath, [__filename, 'spawnchild', 1])); verifyBufOutput(spawnSync(process.execPath, [__filename, 'spawnchild', 2])); -var options = { +let options = { input: 1234 }; diff --git a/test/parallel/test-child-process-spawnsync-shell.js b/test/parallel/test-child-process-spawnsync-shell.js index 620a01c4532203..1d92767a8b5ba5 100644 --- a/test/parallel/test-child-process-spawnsync-shell.js +++ b/test/parallel/test-child-process-spawnsync-shell.js @@ -6,7 +6,7 @@ const cp = require('child_process'); // Verify that a shell is, in fact, executed const doesNotExist = cp.spawnSync('does-not-exist', {shell: true}); -assert.notEqual(doesNotExist.file, 'does-not-exist'); +assert.notStrictEqual(doesNotExist.file, 'does-not-exist'); assert.strictEqual(doesNotExist.error, undefined); assert.strictEqual(doesNotExist.signal, null); @@ -35,3 +35,59 @@ const env = cp.spawnSync(`"${process.execPath}" -pe process.env.BAZ`, { }); assert.strictEqual(env.stdout.toString().trim(), 'buzz'); + +// Verify that the shell internals work properly across platforms. +{ + const originalComspec = process.env.comspec; + + // Enable monkey patching process.platform. + const originalPlatform = process.platform; + let platform = null; + Object.defineProperty(process, 'platform', { get: () => platform }); + + function test(testPlatform, shell, shellOutput) { + platform = testPlatform; + + const cmd = 'not_a_real_command'; + const shellFlags = platform === 'win32' ? ['/d', '/s', '/c'] : ['-c']; + const outputCmd = platform === 'win32' ? `"${cmd}"` : cmd; + const windowsVerbatim = platform === 'win32' ? true : undefined; + const result = cp.spawnSync(cmd, { shell }); + + assert.strictEqual(result.file, shellOutput); + assert.deepStrictEqual(result.args, + [shellOutput, ...shellFlags, outputCmd]); + assert.strictEqual(result.options.shell, shell); + assert.strictEqual(result.options.file, result.file); + assert.deepStrictEqual(result.options.args, result.args); + assert.strictEqual(result.options.windowsVerbatimArguments, + windowsVerbatim); + } + + // Test Unix platforms with the default shell. + test('darwin', true, '/bin/sh'); + + // Test Unix platforms with a user specified shell. + test('darwin', '/bin/csh', '/bin/csh'); + + // Test Android platforms. + test('android', true, '/system/bin/sh'); + + // Test Windows platforms with a user specified shell. + test('win32', 'powershell.exe', 'powershell.exe'); + + // Test Windows platforms with the default shell and no comspec. + delete process.env.comspec; + test('win32', true, 'cmd.exe'); + + // Test Windows platforms with the default shell and a comspec value. + process.env.comspec = 'powershell.exe'; + test('win32', true, process.env.comspec); + + // Restore the original value of process.platform. + platform = originalPlatform; + + // Restore the original comspec environment variable if necessary. + if (originalComspec) + process.env.comspec = originalComspec; +} diff --git a/test/parallel/test-child-process-spawnsync-timeout.js b/test/parallel/test-child-process-spawnsync-timeout.js index 122a65825949df..38f22deef26ae7 100644 --- a/test/parallel/test-child-process-spawnsync-timeout.js +++ b/test/parallel/test-child-process-spawnsync-timeout.js @@ -1,11 +1,11 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var spawnSync = require('child_process').spawnSync; +const spawnSync = require('child_process').spawnSync; -var TIMER = 200; -var SLEEP = 5000; +const TIMER = 200; +const SLEEP = common.platformTimeout(5000); switch (process.argv[2]) { case 'child': @@ -15,12 +15,11 @@ switch (process.argv[2]) { }, SLEEP); break; default: - var start = Date.now(); - var ret = spawnSync(process.execPath, [__filename, 'child'], + const start = Date.now(); + const ret = spawnSync(process.execPath, [__filename, 'child'], {timeout: TIMER}); assert.strictEqual(ret.error.errno, 'ETIMEDOUT'); - console.log(ret); - var end = Date.now() - start; + const end = Date.now() - start; assert(end < SLEEP); assert(ret.status > 128 || ret.signal); break; diff --git a/test/parallel/test-child-process-stdin-ipc.js b/test/parallel/test-child-process-stdin-ipc.js index 2ce7c66c2053e0..2623e2deeeee8a 100644 --- a/test/parallel/test-child-process-stdin-ipc.js +++ b/test/parallel/test-child-process-stdin-ipc.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var spawn = require('child_process').spawn; +const spawn = require('child_process').spawn; if (process.argv[2] === 'child') { // Just reference stdin, it should start it @@ -10,7 +10,7 @@ if (process.argv[2] === 'child') { return; } -var proc = spawn(process.execPath, [__filename, 'child'], { +const proc = spawn(process.execPath, [__filename, 'child'], { stdio: ['ipc', 'inherit', 'inherit'] }); diff --git a/test/parallel/test-child-process-stdio-big-write-end.js b/test/parallel/test-child-process-stdio-big-write-end.js index 4c9f4159d0d8bc..24991492f63d32 100644 --- a/test/parallel/test-child-process-stdio-big-write-end.js +++ b/test/parallel/test-child-process-stdio-big-write-end.js @@ -28,8 +28,9 @@ function parent() { }); // Write until the buffer fills up. + let buf; do { - var buf = Buffer.alloc(BUFSIZE, '.'); + buf = Buffer.alloc(BUFSIZE, '.'); sent += BUFSIZE; } while (child.stdin.write(buf)); diff --git a/test/parallel/test-child-process-stdio-inherit.js b/test/parallel/test-child-process-stdio-inherit.js index dc3bb3e9aa9391..d2b64aeb30dd31 100644 --- a/test/parallel/test-child-process-stdio-inherit.js +++ b/test/parallel/test-child-process-stdio-inherit.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; if (process.argv[2] === 'parent') parent(); @@ -9,10 +9,10 @@ else grandparent(); function grandparent() { - var child = spawn(process.execPath, [__filename, 'parent']); + const child = spawn(process.execPath, [__filename, 'parent']); child.stderr.pipe(process.stderr); - var output = ''; - var input = 'asdfasdf'; + let output = ''; + const input = 'asdfasdf'; child.stdout.on('data', function(chunk) { output += chunk; diff --git a/test/parallel/test-child-process-stdout-flush-exit.js b/test/parallel/test-child-process-stdout-flush-exit.js index 9db74b51ce5864..682d382b9a1034 100644 --- a/test/parallel/test-child-process-stdout-flush-exit.js +++ b/test/parallel/test-child-process-stdout-flush-exit.js @@ -21,8 +21,7 @@ if (process.argv[2] === 'child') { child.stderr.setEncoding('utf8'); child.stderr.on('data', function(data) { - console.log('parent stderr: ' + data); - assert.ok(false); + common.fail(`Unexpected parent stderr: ${data}`); }); // check if we receive both 'hello' at start and 'goodbye' at end diff --git a/test/parallel/test-child-process-uid-gid.js b/test/parallel/test-child-process-uid-gid.js index 1ee7661227701e..ec2cb9a31956c1 100644 --- a/test/parallel/test-child-process-uid-gid.js +++ b/test/parallel/test-child-process-uid-gid.js @@ -2,18 +2,16 @@ const common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; - -if (!common.isWindows && process.getuid() === 0) { - common.skip('as this test should not be run as `root`'); - return; -} - const expectedError = common.isWindows ? /\bENOTSUP\b/ : /\bEPERM\b/; -assert.throws(() => { - spawn('echo', ['fhqwhgads'], {uid: 0}); -}, expectedError); +if (common.isWindows || process.getuid() !== 0) { + assert.throws(() => { + spawn('echo', ['fhqwhgads'], {uid: 0}); + }, expectedError); +} -assert.throws(() => { - spawn('echo', ['fhqwhgads'], {gid: 0}); -}, expectedError); +if (common.isWindows || !process.getgroups().some((gid) => gid === 0)) { + assert.throws(() => { + spawn('echo', ['fhqwhgads'], {gid: 0}); + }, expectedError); +} diff --git a/test/parallel/test-cli-eval.js b/test/parallel/test-cli-eval.js index 0198a0f1beda48..260acdb0d6f90a 100644 --- a/test/parallel/test-cli-eval.js +++ b/test/parallel/test-cli-eval.js @@ -1,6 +1,7 @@ 'use strict'; if (module.parent) { - // signal we've been loaded as a module + // Signal we've been loaded as a module. + // The following console.log() is part of the test. console.log('Loaded as a module, exiting with status code 42.'); process.exit(42); } @@ -9,95 +10,119 @@ const common = require('../common'); const assert = require('assert'); const child = require('child_process'); const path = require('path'); -const nodejs = '"' + process.execPath + '"'; - - -// replace \ by / because windows uses backslashes in paths, but they're still -// interpreted as the escape character when put between quotes. -var filename = __filename.replace(/\\/g, '/'); - -// assert that nothing is written to stdout -child.exec(nodejs + ' --eval 42', - function(err, stdout, stderr) { - assert.strictEqual(stdout, ''); - assert.strictEqual(stderr, ''); - }); - -// assert that "42\n" is written to stderr -child.exec(nodejs + ' --eval "console.error(42)"', - function(err, stdout, stderr) { - assert.strictEqual(stdout, ''); - assert.strictEqual(stderr, '42\n'); - }); - -// assert that the expected output is written to stdout -['--print', '-p -e', '-pe', '-p'].forEach(function(s) { - var cmd = nodejs + ' ' + s + ' '; - - child.exec(cmd + '42', - function(err, stdout, stderr) { - assert.strictEqual(stdout, '42\n'); - assert.strictEqual(stderr, ''); - }); - - child.exec(cmd + "'[]'", common.mustCall( - function(err, stdout, stderr) { - assert.strictEqual(stdout, '[]\n'); - assert.strictEqual(stderr, ''); - })); +const nodejs = `"${process.execPath}"`; + +if (process.argv.length > 2) { + console.log(process.argv.slice(2).join(' ')); + process.exit(0); +} + +// Assert that nothing is written to stdout. +child.exec(`${nodejs} --eval 42`, common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); +})); + +// Assert that "42\n" is written to stderr. +child.exec(`${nodejs} --eval "console.error(42)"`, + common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, '42\n'); + })); + +// Assert that the expected output is written to stdout. +['--print', '-p -e', '-pe', '-p'].forEach((s) => { + const cmd = `${nodejs} ${s} `; + + child.exec(`${cmd}42`, common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + assert.strictEqual(stdout, '42\n'); + assert.strictEqual(stderr, ''); + })); + + child.exec(`${cmd} '[]'`, common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + assert.strictEqual(stdout, '[]\n'); + assert.strictEqual(stderr, ''); + })); }); -// assert that module loading works -child.exec(nodejs + ' --eval "require(\'' + filename + '\')"', - function(status, stdout, stderr) { - assert.strictEqual(status.code, 42); - }); +// Assert that module loading works. +{ + // Replace \ by / because Windows uses backslashes in paths, but they're still + // interpreted as the escape character when put between quotes. + const filename = __filename.replace(/\\/g, '/'); + + child.exec(`${nodejs} --eval "require('${filename}')"`, + common.mustCall((err, stdout, stderr) => { + assert.strictEqual(err.code, 42); + assert.strictEqual( + stdout, 'Loaded as a module, exiting with status code 42.\n'); + assert.strictEqual(stderr, ''); + })); +} // Check that builtin modules are pre-defined. -child.exec(nodejs + ' --print "os.platform()"', - function(status, stdout, stderr) { - assert.strictEqual(stderr, ''); - assert.strictEqual(stdout.trim(), require('os').platform()); - }); - -// module path resolve bug, regression test -child.exec(nodejs + ' --eval "require(\'./test/parallel/test-cli-eval.js\')"', - function(status, stdout, stderr) { - assert.strictEqual(status.code, 42); - }); - -// Missing argument should not crash -child.exec(nodejs + ' -e', common.mustCall(function(status, stdout, stderr) { - assert.notStrictEqual(status, null); - assert.strictEqual(status.code, 9); +child.exec(`${nodejs} --print "os.platform()"`, + common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + assert.strictEqual(stderr, ''); + assert.strictEqual(stdout.trim(), require('os').platform()); + })); + +// Module path resolve bug regression test. +child.exec(`${nodejs} --eval "require('./test/parallel/test-cli-eval.js')"`, + common.mustCall((err, stdout, stderr) => { + assert.strictEqual(err.code, 42); + assert.strictEqual( + stdout, 'Loaded as a module, exiting with status code 42.\n'); + assert.strictEqual(stderr, ''); + })); + +// Missing argument should not crash. +child.exec(`${nodejs} -e`, common.mustCall((err, stdout, stderr) => { + assert.strictEqual(err.code, 9); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr.trim(), + `${process.execPath}: -e requires an argument`); })); -// empty program should do nothing -child.exec(nodejs + ' -e ""', function(status, stdout, stderr) { +// Empty program should do nothing. +child.exec(`${nodejs} -e ""`, common.mustCall((err, stdout, stderr) => { + assert.ifError(err); assert.strictEqual(stdout, ''); assert.strictEqual(stderr, ''); -}); +})); + +// "\\-42" should be interpreted as an escaped expression, not a switch. +child.exec(`${nodejs} -p "\\-42"`, common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + assert.strictEqual(stdout, '-42\n'); + assert.strictEqual(stderr, ''); +})); -// "\\-42" should be interpreted as an escaped expression, not a switch -child.exec(nodejs + ' -p "\\-42"', - function(err, stdout, stderr) { - assert.strictEqual(stdout, '-42\n'); - assert.strictEqual(stderr, ''); - }); - -child.exec(nodejs + ' --use-strict -p process.execArgv', - function(status, stdout, stderr) { - assert.strictEqual(stdout, - "[ '--use-strict', '-p', 'process.execArgv' ]\n"); - }); - -// Regression test for https://github.com/nodejs/node/issues/3574 -const emptyFile = path.join(common.fixturesDir, 'empty.js'); -child.exec(nodejs + ` -e 'require("child_process").fork("${emptyFile}")'`, - function(status, stdout, stderr) { - assert.strictEqual(stdout, ''); - assert.strictEqual(stderr, ''); - }); +child.exec(`${nodejs} --use-strict -p process.execArgv`, + common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + assert.strictEqual( + stdout, "[ '--use-strict', '-p', 'process.execArgv' ]\n" + ); + assert.strictEqual(stderr, ''); + })); + +// Regression test for https://github.com/nodejs/node/issues/3574. +{ + const emptyFile = path.join(common.fixturesDir, 'empty.js'); + + child.exec(`${nodejs} -e 'require("child_process").fork("${emptyFile}")'`, + common.mustCall((err, stdout, stderr) => { + assert.ifError(err); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); + })); +} // Regression test for https://github.com/nodejs/node/issues/8534. { @@ -113,3 +138,38 @@ child.exec(nodejs + ` -e 'require("child_process").fork("${emptyFile}")'`, assert.strictEqual(proc.stderr, ''); assert.strictEqual(proc.stdout, 'start\nbeforeExit\nexit\n'); } + +[ '-arg1', + '-arg1 arg2 --arg3', + '--', + 'arg1 -- arg2', +].forEach(function(args) { + + // Ensure that arguments are successfully passed to eval. + const opt = ' --eval "console.log(process.argv.slice(1).join(\' \'))"'; + const cmd = `${nodejs}${opt} -- ${args}`; + child.exec(cmd, common.mustCall(function(err, stdout, stderr) { + assert.strictEqual(stdout, args + '\n'); + assert.strictEqual(stderr, ''); + assert.strictEqual(err, null); + })); + + // Ensure that arguments are successfully passed to print. + const popt = ' --print "process.argv.slice(1).join(\' \')"'; + const pcmd = `${nodejs}${popt} -- ${args}`; + child.exec(pcmd, common.mustCall(function(err, stdout, stderr) { + assert.strictEqual(stdout, args + '\n'); + assert.strictEqual(stderr, ''); + assert.strictEqual(err, null); + })); + + // Ensure that arguments are successfully passed to a script. + // The first argument after '--' should be interpreted as a script + // filename. + const filecmd = `${nodejs} -- ${__filename} ${args}`; + child.exec(filecmd, common.mustCall(function(err, stdout, stderr) { + assert.strictEqual(stdout, args + '\n'); + assert.strictEqual(stderr, ''); + assert.strictEqual(err, null); + })); +}); diff --git a/test/parallel/test-cli-syntax.js b/test/parallel/test-cli-syntax.js index 839e50d7d94b40..d7781eddffbb42 100644 --- a/test/parallel/test-cli-syntax.js +++ b/test/parallel/test-cli-syntax.js @@ -5,10 +5,10 @@ const assert = require('assert'); const spawnSync = require('child_process').spawnSync; const path = require('path'); -var node = process.execPath; +const node = process.execPath; // test both sets of arguments that check syntax -var syntaxArgs = [ +const syntaxArgs = [ ['-c'], ['--check'] ]; @@ -25,8 +25,8 @@ var syntaxArgs = [ // loop each possible option, `-c` or `--check` syntaxArgs.forEach(function(args) { - var _args = args.concat(file); - var c = spawnSync(node, _args, {encoding: 'utf8'}); + const _args = args.concat(file); + const c = spawnSync(node, _args, {encoding: 'utf8'}); // no output should be produced assert.strictEqual(c.stdout, '', 'stdout produced'); @@ -46,14 +46,14 @@ var syntaxArgs = [ // loop each possible option, `-c` or `--check` syntaxArgs.forEach(function(args) { - var _args = args.concat(file); - var c = spawnSync(node, _args, {encoding: 'utf8'}); + const _args = args.concat(file); + const c = spawnSync(node, _args, {encoding: 'utf8'}); // no stdout should be produced assert.strictEqual(c.stdout, '', 'stdout produced'); // stderr should have a syntax error message - var match = c.stderr.match(/^SyntaxError: Unexpected identifier$/m); + const match = c.stderr.match(/^SyntaxError: Unexpected identifier$/m); assert(match, 'stderr incorrect'); assert.strictEqual(c.status, 1, 'code == ' + c.status); @@ -69,14 +69,14 @@ var syntaxArgs = [ // loop each possible option, `-c` or `--check` syntaxArgs.forEach(function(args) { - var _args = args.concat(file); - var c = spawnSync(node, _args, {encoding: 'utf8'}); + const _args = args.concat(file); + const c = spawnSync(node, _args, {encoding: 'utf8'}); // no stdout should be produced assert.strictEqual(c.stdout, '', 'stdout produced'); // stderr should have a module not found error message - var match = c.stderr.match(/^Error: Cannot find module/m); + const match = c.stderr.match(/^Error: Cannot find module/m); assert(match, 'stderr incorrect'); assert.strictEqual(c.status, 1, 'code == ' + c.status); diff --git a/test/parallel/test-cluster-basic.js b/test/parallel/test-cluster-basic.js index 0ffdcf180bd8a8..92251b7324bf5f 100644 --- a/test/parallel/test-cluster-basic.js +++ b/test/parallel/test-cluster-basic.js @@ -56,7 +56,6 @@ if (cluster.isWorker) { } }; - var worker; const stateNames = Object.keys(checks.worker.states); //Check events, states, and emit arguments @@ -72,7 +71,7 @@ if (cluster.isWorker) { checks.cluster.equal[name] = worker === arguments[0]; //Check state - var state = stateNames[index]; + const state = stateNames[index]; checks.worker.states[state] = (state === worker.state); })); }); @@ -86,7 +85,7 @@ if (cluster.isWorker) { cluster.on('exit', common.mustCall(() => {})); //Create worker - worker = cluster.fork(); + const worker = cluster.fork(); assert.strictEqual(worker.id, 1); assert(worker instanceof cluster.Worker, 'the worker is not a instance of the Worker constructor'); diff --git a/test/parallel/test-cluster-bind-privileged-port.js b/test/parallel/test-cluster-bind-privileged-port.js index 228e1f0f1eaab0..3e062697fd2fea 100644 --- a/test/parallel/test-cluster-bind-privileged-port.js +++ b/test/parallel/test-cluster-bind-privileged-port.js @@ -19,7 +19,7 @@ if (cluster.isMaster) { assert.strictEqual(exitCode, 0); })); } else { - var s = net.createServer(common.fail); + const s = net.createServer(common.fail); s.listen(42, common.fail.bind(null, 'listen should have failed')); s.on('error', common.mustCall((err) => { assert.strictEqual(err.code, 'EACCES'); diff --git a/test/parallel/test-cluster-dgram-1.js b/test/parallel/test-cluster-dgram-1.js index 3b27fa8e20cb6c..25391997755f6b 100644 --- a/test/parallel/test-cluster-dgram-1.js +++ b/test/parallel/test-cluster-dgram-1.js @@ -21,10 +21,10 @@ else function master() { - var listening = 0; + let listening = 0; // Fork 4 workers. - for (var i = 0; i < NUM_WORKERS; i++) + for (let i = 0; i < NUM_WORKERS; i++) cluster.fork(); // Wait until all workers are listening. @@ -35,7 +35,7 @@ function master() { // Start sending messages. const buf = Buffer.from('hello world'); const socket = dgram.createSocket('udp4'); - var sent = 0; + let sent = 0; doSend(); function doSend() { @@ -60,7 +60,7 @@ function master() { } function setupWorker(worker) { - var received = 0; + let received = 0; worker.on('message', common.mustCall((msg) => { received = msg.received; @@ -75,10 +75,10 @@ function master() { function worker() { - var received = 0; + let received = 0; // Create udp socket and start listening. - var socket = dgram.createSocket('udp4'); + const socket = dgram.createSocket('udp4'); socket.on('message', common.mustCall((data, info) => { received++; diff --git a/test/parallel/test-cluster-dgram-2.js b/test/parallel/test-cluster-dgram-2.js index 863e0fa358c73e..37aea29e1a4263 100644 --- a/test/parallel/test-cluster-dgram-2.js +++ b/test/parallel/test-cluster-dgram-2.js @@ -20,10 +20,10 @@ else function master() { - var received = 0; + let received = 0; // Start listening on a socket. - var socket = dgram.createSocket('udp4'); + const socket = dgram.createSocket('udp4'); socket.bind(common.PORT); // Disconnect workers when the expected number of messages have been @@ -42,7 +42,7 @@ function master() { }, NUM_WORKERS * PACKETS_PER_WORKER)); // Fork workers. - for (var i = 0; i < NUM_WORKERS; i++) + for (let i = 0; i < NUM_WORKERS; i++) cluster.fork(); } diff --git a/test/parallel/test-cluster-dgram-reuse.js b/test/parallel/test-cluster-dgram-reuse.js index 27fc1be985d4b7..aed565a3806e97 100644 --- a/test/parallel/test-cluster-dgram-reuse.js +++ b/test/parallel/test-cluster-dgram-reuse.js @@ -25,16 +25,16 @@ function next() { // Work around health check issue process.nextTick(() => { - for (var i = 0; i < sockets.length; i++) + for (let i = 0; i < sockets.length; i++) sockets[i].close(close); }); } -var waiting = 2; +let waiting = 2; function close() { if (--waiting === 0) cluster.worker.disconnect(); } -for (var i = 0; i < 2; i++) +for (let i = 0; i < 2; i++) dgram.createSocket({ type: 'udp4', reuseAddr: true }).bind(common.PORT, next); diff --git a/test/parallel/test-cluster-disconnect-handles.js b/test/parallel/test-cluster-disconnect-handles.js index 680e316cf0ba92..4b481f0a7b1751 100644 --- a/test/parallel/test-cluster-disconnect-handles.js +++ b/test/parallel/test-cluster-disconnect-handles.js @@ -24,7 +24,7 @@ cluster.schedulingPolicy = cluster.SCHED_RR; // pending handle queue. if (cluster.isMaster) { let isKilling = false; - const handles = require('internal/cluster').handles; + const handles = require('internal/cluster/utils').handles; const address = common.hasIPv6 ? '[::1]' : common.localhostIPv4; cluster.setupMaster({ execArgv: [`--debug=${address}:${common.PORT}`] }); const worker = cluster.fork(); diff --git a/test/parallel/test-cluster-disconnect-race.js b/test/parallel/test-cluster-disconnect-race.js index e89b9e134fa83f..09966cbab84496 100644 --- a/test/parallel/test-cluster-disconnect-race.js +++ b/test/parallel/test-cluster-disconnect-race.js @@ -16,9 +16,9 @@ if (common.isWindows) { cluster.schedulingPolicy = cluster.SCHED_NONE; if (cluster.isMaster) { - var worker1, worker2; + let worker2; - worker1 = cluster.fork(); + const worker1 = cluster.fork(); worker1.on('message', common.mustCall(function() { worker2 = cluster.fork(); worker1.disconnect(); @@ -32,7 +32,7 @@ if (cluster.isMaster) { return; } -var server = net.createServer(); +const server = net.createServer(); server.listen(common.PORT, function() { process.send('listening'); diff --git a/test/parallel/test-cluster-disconnect-suicide-race.js b/test/parallel/test-cluster-disconnect-suicide-race.js index 6f23b23fd2d4ff..15d07002252ee9 100644 --- a/test/parallel/test-cluster-disconnect-suicide-race.js +++ b/test/parallel/test-cluster-disconnect-suicide-race.js @@ -14,7 +14,7 @@ if (cluster.isMaster) { return cluster.fork(); } -var eventFired = false; +let eventFired = false; cluster.worker.disconnect(); diff --git a/test/parallel/test-cluster-disconnect-with-no-workers.js b/test/parallel/test-cluster-disconnect-with-no-workers.js index 4c2425d82d656b..15c5898a7d6f69 100644 --- a/test/parallel/test-cluster-disconnect-with-no-workers.js +++ b/test/parallel/test-cluster-disconnect-with-no-workers.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); +const assert = require('assert'); +const cluster = require('cluster'); -var disconnected; +let disconnected; process.on('exit', function() { assert(disconnected); diff --git a/test/parallel/test-cluster-disconnect.js b/test/parallel/test-cluster-disconnect.js index 4609724130f2ec..0fc1611e2d9577 100644 --- a/test/parallel/test-cluster-disconnect.js +++ b/test/parallel/test-cluster-disconnect.js @@ -14,13 +14,13 @@ if (cluster.isWorker) { }).listen(common.PORT + 1, '127.0.0.1'); } else if (cluster.isMaster) { - var servers = 2; + const servers = 2; // test a single TCP server const testConnection = function(port, cb) { - var socket = net.connect(port, '127.0.0.1', () => { + const socket = net.connect(port, '127.0.0.1', () => { // buffer result - var result = ''; + let result = ''; socket.on('data', common.mustCall((chunk) => { result += chunk; })); // check result @@ -32,9 +32,9 @@ if (cluster.isWorker) { // test both servers created in the cluster const testCluster = function(cb) { - var done = 0; + let done = 0; - for (var i = 0, l = servers; i < l; i++) { + for (let i = 0, l = servers; i < l; i++) { testConnection(common.PORT + i, (success) => { assert.ok(success); done += 1; @@ -47,10 +47,10 @@ if (cluster.isWorker) { // start two workers and execute callback when both is listening const startCluster = function(cb) { - var workers = 8; - var online = 0; + const workers = 8; + let online = 0; - for (var i = 0, l = workers; i < l; i++) { + for (let i = 0, l = workers; i < l; i++) { cluster.fork().on('listening', common.mustCall(() => { online += 1; if (online === workers * servers) { diff --git a/test/parallel/test-cluster-eaccess.js b/test/parallel/test-cluster-eaccess.js index 2de4af8b1a108b..75b60248a22381 100644 --- a/test/parallel/test-cluster-eaccess.js +++ b/test/parallel/test-cluster-eaccess.js @@ -37,7 +37,7 @@ if (cluster.isMaster) { } else { common.refreshTmpDir(); - var cp = fork(common.fixturesDir + '/listen-on-socket-and-exit.js', + const cp = fork(common.fixturesDir + '/listen-on-socket-and-exit.js', { stdio: 'inherit' }); // message from the child indicates it's ready and listening diff --git a/test/parallel/test-cluster-eaddrinuse.js b/test/parallel/test-cluster-eaddrinuse.js index 88b6de2dde4230..a0936ef4b9d471 100644 --- a/test/parallel/test-cluster-eaddrinuse.js +++ b/test/parallel/test-cluster-eaddrinuse.js @@ -3,17 +3,17 @@ // leave the master process in a confused state. Releasing the port and // trying again should Just Work[TM]. -var common = require('../common'); -var assert = require('assert'); -var fork = require('child_process').fork; -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const fork = require('child_process').fork; +const net = require('net'); -var id = '' + process.argv[2]; +const id = '' + process.argv[2]; if (id === 'undefined') { const server = net.createServer(common.fail); server.listen(common.PORT, function() { - var worker = fork(__filename, ['worker']); + const worker = fork(__filename, ['worker']); worker.on('message', function(msg) { if (msg !== 'stop-listening') return; server.close(function() { diff --git a/test/parallel/test-cluster-fork-env.js b/test/parallel/test-cluster-fork-env.js index 17b7af3d061926..55ea684f3b4ce3 100644 --- a/test/parallel/test-cluster-fork-env.js +++ b/test/parallel/test-cluster-fork-env.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); +const assert = require('assert'); +const cluster = require('cluster'); if (cluster.isWorker) { const result = cluster.worker.send({ @@ -12,7 +12,7 @@ if (cluster.isWorker) { assert.strictEqual(result, true); } else if (cluster.isMaster) { - var checks = { + const checks = { using: false, overwrite: false }; @@ -22,7 +22,7 @@ if (cluster.isWorker) { process.env['cluster_test_overwrite'] = 'old'; // Fork worker - var worker = cluster.fork({ + const worker = cluster.fork({ 'cluster_test_prop': 'custom', 'cluster_test_overwrite': 'new' }); diff --git a/test/parallel/test-cluster-listening-port.js b/test/parallel/test-cluster-listening-port.js index b0fbf9499041d2..ce86205c1e792a 100644 --- a/test/parallel/test-cluster-listening-port.js +++ b/test/parallel/test-cluster-listening-port.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); +const net = require('net'); if (cluster.isMaster) { cluster.fork(); diff --git a/test/parallel/test-cluster-master-error.js b/test/parallel/test-cluster-master-error.js index 6f9c78a7ba601f..11ed09c64ed04e 100644 --- a/test/parallel/test-cluster-master-error.js +++ b/test/parallel/test-cluster-master-error.js @@ -15,7 +15,7 @@ if (cluster.isWorker) { } else if (process.argv[2] === 'cluster') { // Send PID to testcase process - var forkNum = 0; + let forkNum = 0; cluster.on('fork', common.mustCall(function forkEvent(worker) { // Send PID @@ -31,7 +31,7 @@ if (cluster.isWorker) { })); // Throw accidental error when all workers are listening - var listeningNum = 0; + let listeningNum = 0; cluster.on('listening', common.mustCall(function listeningEvent() { // When all workers are listening @@ -56,8 +56,8 @@ if (cluster.isWorker) { const fork = require('child_process').fork; - var masterExited = false; - var workersExited = false; + let masterExited = false; + let workersExited = false; // List all workers const workers = []; @@ -82,7 +82,7 @@ if (cluster.isWorker) { const pollWorkers = function() { // When master is dead all workers should be dead too - var alive = false; + let alive = false; workers.forEach((pid) => alive = common.isAlive(pid)); if (alive) { setTimeout(pollWorkers, 50); diff --git a/test/parallel/test-cluster-master-kill.js b/test/parallel/test-cluster-master-kill.js index 44eedec47b58e5..094e5ad256de7d 100644 --- a/test/parallel/test-cluster-master-kill.js +++ b/test/parallel/test-cluster-master-kill.js @@ -34,13 +34,13 @@ if (cluster.isWorker) { const master = fork(process.argv[1], ['cluster']); // get pid info - var pid = null; + let pid = null; master.once('message', (data) => { pid = data.pid; }); // When master is dead - var alive = true; + let alive = true; master.on('exit', common.mustCall((code) => { // make sure that the master died on purpose diff --git a/test/parallel/test-cluster-message.js b/test/parallel/test-cluster-message.js index 0587eecb4dd4b5..5b537bbe73a755 100644 --- a/test/parallel/test-cluster-message.js +++ b/test/parallel/test-cluster-message.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); +const net = require('net'); function forEach(obj, fn) { Object.keys(obj).forEach(function(name, index) { @@ -13,8 +13,8 @@ function forEach(obj, fn) { if (cluster.isWorker) { // Create a tcp server. This will be used as cluster-shared-server and as an // alternative IPC channel. - var server = net.Server(); - var socket, message; + const server = net.Server(); + let socket, message; function maybeReply() { if (!socket || !message) return; @@ -42,7 +42,7 @@ if (cluster.isWorker) { server.listen(common.PORT, '127.0.0.1'); } else if (cluster.isMaster) { - var checks = { + const checks = { global: { 'receive': false, 'correct': false @@ -58,13 +58,13 @@ if (cluster.isWorker) { }; - var client; - var check = function(type, result) { + let client; + const check = function(type, result) { checks[type].receive = true; checks[type].correct = result; console.error('check', checks); - var missing = false; + let missing = false; forEach(checks, function(type) { if (type.receive === false) missing = true; }); @@ -76,7 +76,7 @@ if (cluster.isWorker) { }; // Spawn worker - var worker = cluster.fork(); + const worker = cluster.fork(); // When a IPC message is received from the worker worker.on('message', function(message) { diff --git a/test/parallel/test-cluster-rr-domain-listen.js b/test/parallel/test-cluster-rr-domain-listen.js index 1328483abb72df..10b0530b505a95 100644 --- a/test/parallel/test-cluster-rr-domain-listen.js +++ b/test/parallel/test-cluster-rr-domain-listen.js @@ -1,20 +1,19 @@ 'use strict'; -var common = require('../common'); -var cluster = require('cluster'); -var domain = require('domain'); +const common = require('../common'); +const cluster = require('cluster'); +const domain = require('domain'); // RR is the default for v0.11.9+ so the following line is redundant: // cluster.schedulingPolicy = cluster.SCHED_RR; if (cluster.isWorker) { - var d = domain.create(); + const d = domain.create(); d.run(function() { }); - var http = require('http'); + const http = require('http'); http.Server(function() { }).listen(common.PORT, '127.0.0.1'); } else if (cluster.isMaster) { - var worker; //Kill worker when listening cluster.on('listening', function() { @@ -27,5 +26,5 @@ if (cluster.isWorker) { }); //Create worker - worker = cluster.fork(); + const worker = cluster.fork(); } diff --git a/test/parallel/test-cluster-send-deadlock.js b/test/parallel/test-cluster-send-deadlock.js index fa3e1138248221..3fa64ac0b5d4d0 100644 --- a/test/parallel/test-cluster-send-deadlock.js +++ b/test/parallel/test-cluster-send-deadlock.js @@ -2,20 +2,20 @@ // Testing mutual send of handles: from master to worker, and from worker to // master. -var common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); +const net = require('net'); if (cluster.isMaster) { - var worker = cluster.fork(); + const worker = cluster.fork(); worker.on('exit', function(code, signal) { assert.strictEqual(code, 0, 'Worker exited with an error code'); assert(!signal, 'Worker exited by a signal'); server.close(); }); - var server = net.createServer(function(socket) { + const server = net.createServer(function(socket) { worker.send('handle', socket); }); @@ -25,9 +25,9 @@ if (cluster.isMaster) { } else { process.on('message', function(msg, handle) { if (msg === 'listen') { - var client1 = net.connect({ host: 'localhost', port: common.PORT }); - var client2 = net.connect({ host: 'localhost', port: common.PORT }); - var waiting = 2; + const client1 = net.connect({ host: 'localhost', port: common.PORT }); + const client2 = net.connect({ host: 'localhost', port: common.PORT }); + let waiting = 2; client1.on('close', onclose); client2.on('close', onclose); function onclose() { diff --git a/test/parallel/test-cluster-setup-master-argv.js b/test/parallel/test-cluster-setup-master-argv.js index 32c5a91b3caab4..72211918eff0cb 100644 --- a/test/parallel/test-cluster-setup-master-argv.js +++ b/test/parallel/test-cluster-setup-master-argv.js @@ -6,8 +6,8 @@ const cluster = require('cluster'); setTimeout(common.fail.bind(assert, 'setup not emitted'), 1000).unref(); cluster.on('setup', common.mustCall(function() { - var clusterArgs = cluster.settings.args; - var realArgs = process.argv; + const clusterArgs = cluster.settings.args; + const realArgs = process.argv; assert.strictEqual(clusterArgs[clusterArgs.length - 1], realArgs[realArgs.length - 1]); })); diff --git a/test/parallel/test-cluster-setup-master-cumulative.js b/test/parallel/test-cluster-setup-master-cumulative.js index 6a55df29d4411f..977c89a56aa573 100644 --- a/test/parallel/test-cluster-setup-master-cumulative.js +++ b/test/parallel/test-cluster-setup-master-cumulative.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); +const assert = require('assert'); +const cluster = require('cluster'); assert(cluster.isMaster); diff --git a/test/parallel/test-cluster-setup-master-emit.js b/test/parallel/test-cluster-setup-master-emit.js index aad1cea75eda97..5b828e7b8e360f 100644 --- a/test/parallel/test-cluster-setup-master-emit.js +++ b/test/parallel/test-cluster-setup-master-emit.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); +const assert = require('assert'); +const cluster = require('cluster'); assert(cluster.isMaster); diff --git a/test/parallel/test-cluster-setup-master-multiple.js b/test/parallel/test-cluster-setup-master-multiple.js index 5ceff2bddfaf9d..25cff7cb33e0c1 100644 --- a/test/parallel/test-cluster-setup-master-multiple.js +++ b/test/parallel/test-cluster-setup-master-multiple.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); +const assert = require('assert'); +const cluster = require('cluster'); assert(cluster.isMaster); @@ -13,7 +13,7 @@ function cheapClone(obj) { return JSON.parse(JSON.stringify(obj)); } -var configs = []; +const configs = []; // Capture changes cluster.on('setup', function() { @@ -21,7 +21,7 @@ cluster.on('setup', function() { configs.push(cheapClone(cluster.settings)); }); -var execs = [ +const execs = [ 'node-next', 'node-next-2', 'node-next-3', diff --git a/test/parallel/test-cluster-setup-master.js b/test/parallel/test-cluster-setup-master.js index 66193203fdc665..5a92b988e61e5e 100644 --- a/test/parallel/test-cluster-setup-master.js +++ b/test/parallel/test-cluster-setup-master.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); +const assert = require('assert'); +const cluster = require('cluster'); if (cluster.isWorker) { @@ -10,14 +10,14 @@ if (cluster.isWorker) { } else if (cluster.isMaster) { - var checks = { + const checks = { args: false, setupEvent: false, settingsObject: false }; - var totalWorkers = 2; - var onlineWorkers = 0; + const totalWorkers = 2; + let onlineWorkers = 0; // Setup master cluster.setupMaster({ @@ -28,7 +28,7 @@ if (cluster.isWorker) { cluster.once('setup', function() { checks.setupEvent = true; - var settings = cluster.settings; + const settings = cluster.settings; if (settings && settings.args && settings.args[0] === 'custom argument' && settings.silent === true && @@ -37,7 +37,7 @@ if (cluster.isWorker) { } }); - var correctIn = 0; + let correctIn = 0; cluster.on('online', function lisenter(worker) { @@ -66,7 +66,7 @@ if (cluster.isWorker) { assert.ok(checks.workers, 'Not all workers went online'); assert.ok(checks.args, 'The arguments was noy send to the worker'); assert.ok(checks.setupEvent, 'The setup event was never emitted'); - var m = 'The settingsObject do not have correct properties'; + const m = 'The settingsObject do not have correct properties'; assert.ok(checks.settingsObject, m); }); diff --git a/test/parallel/test-cluster-shared-leak.js b/test/parallel/test-cluster-shared-leak.js index ad13a869b2b8e0..d578ee6373f3b6 100644 --- a/test/parallel/test-cluster-shared-leak.js +++ b/test/parallel/test-cluster-shared-leak.js @@ -10,9 +10,9 @@ const cluster = require('cluster'); cluster.schedulingPolicy = cluster.SCHED_NONE; if (cluster.isMaster) { - var conn, worker1, worker2; + let conn, worker2; - worker1 = cluster.fork(); + const worker1 = cluster.fork(); worker1.on('message', common.mustCall(function() { worker2 = cluster.fork(); worker2.on('online', function() { diff --git a/test/parallel/test-cluster-worker-death.js b/test/parallel/test-cluster-worker-death.js index ac32705106e03c..7a33721a9aba17 100644 --- a/test/parallel/test-cluster-worker-death.js +++ b/test/parallel/test-cluster-worker-death.js @@ -1,12 +1,12 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); +const assert = require('assert'); +const cluster = require('cluster'); if (!cluster.isMaster) { process.exit(42); } else { - var worker = cluster.fork(); + const worker = cluster.fork(); worker.on('exit', common.mustCall(function(exitCode, signalCode) { assert.strictEqual(exitCode, 42); assert.strictEqual(signalCode, null); diff --git a/test/parallel/test-cluster-worker-deprecated.js b/test/parallel/test-cluster-worker-deprecated.js new file mode 100644 index 00000000000000..2f433aae797ccc --- /dev/null +++ b/test/parallel/test-cluster-worker-deprecated.js @@ -0,0 +1,18 @@ +'use strict'; +require('../common'); + +const assert = require('assert'); +const cluster = require('cluster'); + +const worker = new cluster.Worker(); + +assert.strictEqual(worker.exitedAfterDisconnect, undefined); +assert.strictEqual(worker.suicide, undefined); + +worker.exitedAfterDisconnect = 'recommended'; +assert.strictEqual(worker.exitedAfterDisconnect, 'recommended'); +assert.strictEqual(worker.suicide, 'recommended'); + +worker.suicide = 'deprecated'; +assert.strictEqual(worker.exitedAfterDisconnect, 'deprecated'); +assert.strictEqual(worker.suicide, 'deprecated'); diff --git a/test/parallel/test-cluster-worker-destroy.js b/test/parallel/test-cluster-worker-destroy.js index ca3ac77e7b25cc..62000254247a1f 100644 --- a/test/parallel/test-cluster-worker-destroy.js +++ b/test/parallel/test-cluster-worker-destroy.js @@ -9,8 +9,8 @@ const common = require('../common'); const assert = require('assert'); -var cluster = require('cluster'); -var worker1, worker2; +const cluster = require('cluster'); +let worker1, worker2; if (cluster.isMaster) { worker1 = cluster.fork(); diff --git a/test/parallel/test-cluster-worker-events.js b/test/parallel/test-cluster-worker-events.js index 08bf456a735b7d..6c2e278f5e4639 100644 --- a/test/parallel/test-cluster-worker-events.js +++ b/test/parallel/test-cluster-worker-events.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); +const assert = require('assert'); +const cluster = require('cluster'); -var OK = 2; +const OK = 2; if (cluster.isMaster) { - var worker = cluster.fork(); + const worker = cluster.fork(); worker.on('exit', function(code) { assert.strictEqual(code, OK); @@ -25,8 +25,8 @@ if (cluster.isMaster) { assert(cluster.isWorker); -var sawProcess; -var sawWorker; +let sawProcess; +let sawWorker; process.on('message', function(m) { assert(!sawProcess); @@ -40,7 +40,7 @@ cluster.worker.on('message', function(m) { check(m); }); -var messages = []; +const messages = []; function check(m) { messages.push(m); diff --git a/test/parallel/test-cluster-worker-exit.js b/test/parallel/test-cluster-worker-exit.js index 1c0ec509c468ad..1cd7b1d0f222c7 100644 --- a/test/parallel/test-cluster-worker-exit.js +++ b/test/parallel/test-cluster-worker-exit.js @@ -32,8 +32,9 @@ if (cluster.isWorker) { worker_emitExit: [1, "the worker did not emit 'exit'"], worker_state: ['disconnected', 'the worker state is incorrect'], worker_suicideMode: [false, 'the worker.suicide flag is incorrect'], - worker_exitedAfterDisconnect: [false, - 'the .exitedAfterDisconnect flag is incorrect'], + worker_exitedAfterDisconnect: [ + false, 'the .exitedAfterDisconnect flag is incorrect' + ], worker_died: [true, 'the worker is still running'], worker_exitCode: [EXIT_CODE, 'the worker exited w/ incorrect exitCode'], worker_signalCode: [null, 'the worker exited w/ incorrect signalCode'] diff --git a/test/parallel/test-cluster-worker-forced-exit.js b/test/parallel/test-cluster-worker-forced-exit.js index 3e1f7905ee50d1..828188254724ae 100644 --- a/test/parallel/test-cluster-worker-forced-exit.js +++ b/test/parallel/test-cluster-worker-forced-exit.js @@ -1,9 +1,9 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); +const assert = require('assert'); +const cluster = require('cluster'); -var SENTINEL = 42; +const SENTINEL = 42; // workers forcibly exit when control channel is disconnected, if // their .exitedAfterDisconnect flag isn't set diff --git a/test/parallel/test-cluster-worker-isconnected.js b/test/parallel/test-cluster-worker-isconnected.js index 985d15ce6475e6..8b2ad865899c60 100644 --- a/test/parallel/test-cluster-worker-isconnected.js +++ b/test/parallel/test-cluster-worker-isconnected.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var cluster = require('cluster'); -var assert = require('assert'); +const cluster = require('cluster'); +const assert = require('assert'); if (cluster.isMaster) { - var worker = cluster.fork(); + const worker = cluster.fork(); assert.ok(worker.isConnected(), 'isConnected() should return true as soon as the worker has ' + diff --git a/test/parallel/test-cluster-worker-isdead.js b/test/parallel/test-cluster-worker-isdead.js index 90454cb86089a7..cd360ff248aa13 100644 --- a/test/parallel/test-cluster-worker-isdead.js +++ b/test/parallel/test-cluster-worker-isdead.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var cluster = require('cluster'); -var assert = require('assert'); +const cluster = require('cluster'); +const assert = require('assert'); if (cluster.isMaster) { - var worker = cluster.fork(); + const worker = cluster.fork(); assert.ok(!worker.isDead(), 'isDead() should return false right after the worker has been ' + 'created.'); diff --git a/test/parallel/test-cluster-worker-no-exit.js b/test/parallel/test-cluster-worker-no-exit.js index 0cec652b68648c..9cfd8401a0c678 100644 --- a/test/parallel/test-cluster-worker-no-exit.js +++ b/test/parallel/test-cluster-worker-no-exit.js @@ -1,13 +1,13 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var net = require('net'); +const assert = require('assert'); +const cluster = require('cluster'); +const net = require('net'); -var destroyed; -var success; -var worker; -var server; +let destroyed; +let success; +let worker; +let server; // workers do not exit on disconnect, they exit under normal node rules: when // they have nothing keeping their loop alive, like an active connection @@ -35,7 +35,7 @@ if (cluster.isMaster) { }); }).listen(common.PORT, function() { - var port = this.address().port; + const port = this.address().port; worker = cluster.fork() .on('online', function() { diff --git a/test/parallel/test-cluster-worker-wait-server-close.js b/test/parallel/test-cluster-worker-wait-server-close.js index bdf60971fee5c1..d1a0d73678d67a 100644 --- a/test/parallel/test-cluster-worker-wait-server-close.js +++ b/test/parallel/test-cluster-worker-wait-server-close.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); +const net = require('net'); -var serverClosed = false; +let serverClosed = false; if (cluster.isWorker) { - var server = net.createServer(function(socket) { + const server = net.createServer(function(socket) { // Wait for any data, then close connection socket.write('.'); socket.on('data', function discard() {}); @@ -20,7 +20,7 @@ if (cluster.isWorker) { // Although not typical, the worker process can exit before the disconnect // event fires. Use this to keep the process open until the event has fired. - var keepOpen = setInterval(function() {}, 9999); + const keepOpen = setInterval(function() {}, 9999); // Check worker events and properties process.once('disconnect', function() { @@ -30,7 +30,7 @@ if (cluster.isWorker) { }); } else if (cluster.isMaster) { // start worker - var worker = cluster.fork(); + const worker = cluster.fork(); // Disconnect worker when it is ready worker.once('listening', function() { diff --git a/test/parallel/test-common.js b/test/parallel/test-common.js index 5ffe2c351503c1..17f41840e4ffa5 100644 --- a/test/parallel/test-common.js +++ b/test/parallel/test-common.js @@ -1,7 +1,15 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); common.globalCheck = false; global.gc = 42; // Not a valid global unless --expose_gc is set. assert.deepStrictEqual(common.leakedGlobals(), ['gc']); + +assert.throws(function() { + common.mustCall(function() {}, 'foo'); +}, /^TypeError: Invalid expected value: foo$/); + +assert.throws(function() { + common.mustCall(function() {}, /foo/); +}, /^TypeError: Invalid expected value: \/foo\/$/); diff --git a/test/parallel/test-console-instance.js b/test/parallel/test-console-instance.js index 4d2727d96b1a55..328adfde0ed803 100644 --- a/test/parallel/test-console-instance.js +++ b/test/parallel/test-console-instance.js @@ -1,71 +1,59 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const Stream = require('stream'); const Console = require('console').Console; -var called = false; const out = new Stream(); const err = new Stream(); // ensure the Console instance doesn't write to the // process' "stdout" or "stderr" streams -process.stdout.write = process.stderr.write = function() { - throw new Error('write() should not be called!'); -}; +process.stdout.write = process.stderr.write = common.fail; // make sure that the "Console" function exists assert.strictEqual('function', typeof Console); // make sure that the Console constructor throws // when not given a writable stream instance -assert.throws(function() { +assert.throws(() => { new Console(); -}, /Console expects a writable stream/); +}, /^TypeError: Console expects a writable stream instance$/); // Console constructor should throw if stderr exists but is not writable -assert.throws(function() { - out.write = function() {}; +assert.throws(() => { + out.write = () => {}; err.write = undefined; new Console(out, err); -}, /Console expects writable stream instances/); +}, /^TypeError: Console expects writable stream instances$/); -out.write = err.write = function(d) {}; +out.write = err.write = (d) => {}; -var c = new Console(out, err); +const c = new Console(out, err); -out.write = err.write = function(d) { +out.write = err.write = common.mustCall((d) => { assert.strictEqual(d, 'test\n'); - called = true; -}; +}, 2); -assert(!called); c.log('test'); -assert(called); - -called = false; c.error('test'); -assert(called); -out.write = function(d) { +out.write = common.mustCall((d) => { assert.strictEqual('{ foo: 1 }\n', d); - called = true; -}; +}); -called = false; c.dir({ foo: 1 }); -assert(called); // ensure that the console functions are bound to the console instance -called = 0; -out.write = function(d) { +let called = 0; +out.write = common.mustCall((d) => { called++; - assert.strictEqual(d, called + ' ' + (called - 1) + ' [ 1, 2, 3 ]\n'); -}; + assert.strictEqual(d, `${called} ${called - 1} [ 1, 2, 3 ]\n`); +}, 3); + [1, 2, 3].forEach(c.log); -assert.strictEqual(3, called); // Console() detects if it is called without `new` keyword -assert.doesNotThrow(function() { +assert.doesNotThrow(() => { Console(out, err); }); diff --git a/test/parallel/test-console-not-call-toString.js b/test/parallel/test-console-not-call-toString.js index f152e33e98f087..0c1c209374ac17 100644 --- a/test/parallel/test-console-not-call-toString.js +++ b/test/parallel/test-console-not-call-toString.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var func = function() {}; -var toStringCalled = false; +const func = function() {}; +let toStringCalled = false; func.toString = function() { toStringCalled = true; }; diff --git a/test/parallel/test-console.js b/test/parallel/test-console.js index ee7170bd9101ac..7bf1a5215f89e8 100644 --- a/test/parallel/test-console.js +++ b/test/parallel/test-console.js @@ -22,7 +22,7 @@ assert.doesNotThrow(function() { }); // an Object with a custom .inspect() function -const custom_inspect = { foo: 'bar', inspect: () => { return 'inspect'; } }; +const custom_inspect = { foo: 'bar', inspect: () => 'inspect' }; const stdout_write = global.process.stdout.write; const stderr_write = global.process.stderr.write; @@ -115,7 +115,7 @@ assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n", strings.shift()); assert.strictEqual("{ foo: 'bar', inspect: [Function: inspect] }\n", strings.shift()); -assert.notEqual(-1, strings.shift().indexOf('foo: [Object]')); +assert.ok(strings.shift().includes('foo: [Object]')); assert.strictEqual(-1, strings.shift().indexOf('baz')); assert.ok(/^label: \d+\.\d{3}ms$/.test(strings.shift().trim())); assert.ok(/^__proto__: \d+\.\d{3}ms$/.test(strings.shift().trim())); @@ -130,7 +130,7 @@ assert.strictEqual(errStrings.length, 0); assert.throws(() => { console.assert(false, 'should throw'); -}, /should throw/); +}, /^AssertionError: should throw$/); assert.doesNotThrow(() => { console.assert(true, 'this should not throw'); diff --git a/test/parallel/test-crypto-authenticated.js b/test/parallel/test-crypto-authenticated.js index 4bed5aa665b64d..245783fb1b4275 100644 --- a/test/parallel/test-crypto-authenticated.js +++ b/test/parallel/test-crypto-authenticated.js @@ -312,7 +312,7 @@ const ciphers = crypto.getCiphers(); for (const i in TEST_CASES) { const test = TEST_CASES[i]; - if (ciphers.indexOf(test.algo) === -1) { + if (!ciphers.includes(test.algo)) { common.skip('unsupported ' + test.algo + ' test'); continue; } @@ -324,7 +324,8 @@ for (const i in TEST_CASES) { { const encrypt = crypto.createCipheriv(test.algo, - Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex')); + Buffer.from(test.key, 'hex'), + Buffer.from(test.iv, 'hex')); if (test.aad) encrypt.setAAD(Buffer.from(test.aad, 'hex')); @@ -342,7 +343,8 @@ for (const i in TEST_CASES) { { const decrypt = crypto.createDecipheriv(test.algo, - Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex')); + Buffer.from(test.key, 'hex'), + Buffer.from(test.iv, 'hex')); decrypt.setAuthTag(Buffer.from(test.tag, 'hex')); if (test.aad) decrypt.setAAD(Buffer.from(test.aad, 'hex')); @@ -401,7 +403,8 @@ for (const i in TEST_CASES) { { // trying to get tag before inputting all data: const encrypt = crypto.createCipheriv(test.algo, - Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex')); + Buffer.from(test.key, 'hex'), + Buffer.from(test.iv, 'hex')); encrypt.update('blah', 'ascii'); assert.throws(function() { encrypt.getAuthTag(); }, / state/); } @@ -409,7 +412,8 @@ for (const i in TEST_CASES) { { // trying to set tag on encryption object: const encrypt = crypto.createCipheriv(test.algo, - Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex')); + Buffer.from(test.key, 'hex'), + Buffer.from(test.iv, 'hex')); assert.throws(() => { encrypt.setAuthTag(Buffer.from(test.tag, 'hex')); }, / state/); } @@ -417,7 +421,8 @@ for (const i in TEST_CASES) { { // trying to read tag from decryption object: const decrypt = crypto.createDecipheriv(test.algo, - Buffer.from(test.key, 'hex'), Buffer.from(test.iv, 'hex')); + Buffer.from(test.key, 'hex'), + Buffer.from(test.iv, 'hex')); assert.throws(function() { decrypt.getAuthTag(); }, / state/); } diff --git a/test/parallel/test-crypto-binary-default.js b/test/parallel/test-crypto-binary-default.js index 33a0783fe99963..6ee3aeac36dd89 100644 --- a/test/parallel/test-crypto-binary-default.js +++ b/test/parallel/test-crypto-binary-default.js @@ -53,7 +53,7 @@ const hmacHash = crypto.createHmac('sha1', 'Node') assert.strictEqual(hmacHash, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892'); // Test HMAC-SHA-* (rfc 4231 Test Cases) -var rfc4231 = [ +const rfc4231 = [ { key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), data: Buffer.from('4869205468657265', 'hex'), // 'Hi There' @@ -200,8 +200,8 @@ var rfc4231 = [ ]; for (let i = 0, l = rfc4231.length; i < l; i++) { - for (var hash in rfc4231[i]['hmac']) { - var result = crypto.createHmac(hash, rfc4231[i]['key']) + for (const hash in rfc4231[i]['hmac']) { + let result = crypto.createHmac(hash, rfc4231[i]['key']) .update(rfc4231[i]['data']) .digest('hex'); if (rfc4231[i]['truncate']) { @@ -216,7 +216,7 @@ for (let i = 0, l = rfc4231.length; i < l; i++) { } // Test HMAC-MD5/SHA1 (rfc 2202 Test Cases) -var rfc2202_md5 = [ +const rfc2202_md5 = [ { key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), data: 'Hi There', @@ -269,7 +269,7 @@ var rfc2202_md5 = [ hmac: '6f630fad67cda0ee1fb1f562db3aa53e' } ]; -var rfc2202_sha1 = [ +const rfc2202_sha1 = [ { key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), data: 'Hi There', @@ -346,13 +346,13 @@ for (let i = 0, l = rfc2202_sha1.length; i < l; i++) { } // Test hashing -var a1 = crypto.createHash('sha1').update('Test123').digest('hex'); -var a2 = crypto.createHash('sha256').update('Test123').digest('base64'); -var a3 = crypto.createHash('sha512').update('Test123').digest(); // binary -var a4 = crypto.createHash('sha1').update('Test123').digest('buffer'); +const a1 = crypto.createHash('sha1').update('Test123').digest('hex'); +const a2 = crypto.createHash('sha256').update('Test123').digest('base64'); +const a3 = crypto.createHash('sha512').update('Test123').digest(); // binary +const a4 = crypto.createHash('sha1').update('Test123').digest('buffer'); if (!common.hasFipsCrypto) { - var a0 = crypto.createHash('md5').update('Test123').digest('latin1'); + const a0 = crypto.createHash('md5').update('Test123').digest('latin1'); assert.strictEqual( a0, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c', @@ -382,14 +382,14 @@ assert.deepStrictEqual( ); // Test multiple updates to same hash -var h1 = crypto.createHash('sha1').update('Test123').digest('hex'); -var h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex'); +const h1 = crypto.createHash('sha1').update('Test123').digest('hex'); +const h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex'); assert.strictEqual(h1, h2, 'multipled updates'); // Test hashing for binary files -var fn = path.join(common.fixturesDir, 'sample.png'); -var sha1Hash = crypto.createHash('sha1'); -var fileStream = fs.createReadStream(fn); +const fn = path.join(common.fixturesDir, 'sample.png'); +const sha1Hash = crypto.createHash('sha1'); +const fileStream = fs.createReadStream(fn); fileStream.on('data', function(data) { sha1Hash.update(data); }); @@ -407,28 +407,28 @@ assert.throws(function() { }, /^Error: Digest method not supported$/); // Test signing and verifying -var s1 = crypto.createSign('RSA-SHA1') +const s1 = crypto.createSign('RSA-SHA1') .update('Test123') .sign(keyPem, 'base64'); -var s1Verified = crypto.createVerify('RSA-SHA1') +const s1Verified = crypto.createVerify('RSA-SHA1') .update('Test') .update('123') .verify(certPem, s1, 'base64'); assert.strictEqual(s1Verified, true, 'sign and verify (base 64)'); -var s2 = crypto.createSign('RSA-SHA256') +const s2 = crypto.createSign('RSA-SHA256') .update('Test123') .sign(keyPem); // binary -var s2Verified = crypto.createVerify('RSA-SHA256') +const s2Verified = crypto.createVerify('RSA-SHA256') .update('Test') .update('123') .verify(certPem, s2); // binary assert.strictEqual(s2Verified, true, 'sign and verify (binary)'); -var s3 = crypto.createSign('RSA-SHA1') +const s3 = crypto.createSign('RSA-SHA1') .update('Test123') .sign(keyPem, 'buffer'); -var s3Verified = crypto.createVerify('RSA-SHA1') +const s3Verified = crypto.createVerify('RSA-SHA1') .update('Test') .update('123') .verify(certPem, s3); @@ -437,17 +437,17 @@ assert.strictEqual(s3Verified, true, 'sign and verify (buffer)'); function testCipher1(key) { // Test encryption and decryption - var plaintext = 'Keep this a secret? No! Tell everyone about node.js!'; - var cipher = crypto.createCipher('aes192', key); + const plaintext = 'Keep this a secret? No! Tell everyone about node.js!'; + const cipher = crypto.createCipher('aes192', key); // encrypt plaintext which is in utf8 format // to a ciphertext which will be in hex - var ciph = cipher.update(plaintext, 'utf8', 'hex'); + let ciph = cipher.update(plaintext, 'utf8', 'hex'); // Only use binary or hex, not base64. ciph += cipher.final('hex'); - var decipher = crypto.createDecipher('aes192', key); - var txt = decipher.update(ciph, 'hex', 'utf8'); + const decipher = crypto.createDecipher('aes192', key); + let txt = decipher.update(ciph, 'hex', 'utf8'); txt += decipher.final('utf8'); assert.strictEqual(txt, plaintext, 'encryption and decryption'); @@ -457,19 +457,19 @@ function testCipher1(key) { function testCipher2(key) { // encryption and decryption with Base64 // reported in https://github.com/joyent/node/issues/738 - var plaintext = + const plaintext = '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' + 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' + 'jAfaFg**'; - var cipher = crypto.createCipher('aes256', key); + const cipher = crypto.createCipher('aes256', key); // encrypt plaintext which is in utf8 format // to a ciphertext which will be in Base64 - var ciph = cipher.update(plaintext, 'utf8', 'base64'); + let ciph = cipher.update(plaintext, 'utf8', 'base64'); ciph += cipher.final('base64'); - var decipher = crypto.createDecipher('aes256', key); - var txt = decipher.update(ciph, 'base64', 'utf8'); + const decipher = crypto.createDecipher('aes256', key); + let txt = decipher.update(ciph, 'base64', 'utf8'); txt += decipher.final('utf8'); assert.strictEqual(txt, plaintext, 'encryption and decryption with Base64'); @@ -478,16 +478,16 @@ function testCipher2(key) { function testCipher3(key, iv) { // Test encyrption and decryption with explicit key and iv - var plaintext = + const plaintext = '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' + 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' + 'jAfaFg**'; - var cipher = crypto.createCipheriv('des-ede3-cbc', key, iv); - var ciph = cipher.update(plaintext, 'utf8', 'hex'); + const cipher = crypto.createCipheriv('des-ede3-cbc', key, iv); + let ciph = cipher.update(plaintext, 'utf8', 'hex'); ciph += cipher.final('hex'); - var decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv); - var txt = decipher.update(ciph, 'hex', 'utf8'); + const decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv); + let txt = decipher.update(ciph, 'hex', 'utf8'); txt += decipher.final('utf8'); assert.strictEqual(txt, plaintext, @@ -497,16 +497,16 @@ function testCipher3(key, iv) { function testCipher4(key, iv) { // Test encyrption and decryption with explicit key and iv - var plaintext = + const plaintext = '32|RmVZZkFUVmpRRkp0TmJaUm56ZU9qcnJkaXNNWVNpTTU*|iXmckfRWZBGWWELw' + 'eCBsThSsfUHLeRe0KCsK8ooHgxie0zOINpXxfZi/oNG7uq9JWFVCk70gfzQH8ZUJ' + 'jAfaFg**'; - var cipher = crypto.createCipheriv('des-ede3-cbc', key, iv); - var ciph = cipher.update(plaintext, 'utf8', 'buffer'); + const cipher = crypto.createCipheriv('des-ede3-cbc', key, iv); + let ciph = cipher.update(plaintext, 'utf8', 'buffer'); ciph = Buffer.concat([ciph, cipher.final('buffer')]); - var decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv); - var txt = decipher.update(ciph, 'buffer', 'utf8'); + const decipher = crypto.createDecipheriv('des-ede3-cbc', key, iv); + let txt = decipher.update(ciph, 'buffer', 'utf8'); txt += decipher.final('utf8'); assert.strictEqual(txt, plaintext, @@ -537,20 +537,20 @@ assert.throws(function() { // Test Diffie-Hellman with two parties sharing a secret, // using various encodings as we go along -var dh1 = crypto.createDiffieHellman(common.hasFipsCrypto ? 1024 : 256); -var p1 = dh1.getPrime('buffer'); -var dh2 = crypto.createDiffieHellman(p1, 'base64'); -var key1 = dh1.generateKeys(); -var key2 = dh2.generateKeys('hex'); -var secret1 = dh1.computeSecret(key2, 'hex', 'base64'); -var secret2 = dh2.computeSecret(key1, 'latin1', 'buffer'); +const dh1 = crypto.createDiffieHellman(common.hasFipsCrypto ? 1024 : 256); +const p1 = dh1.getPrime('buffer'); +const dh2 = crypto.createDiffieHellman(p1, 'base64'); +const key1 = dh1.generateKeys(); +const key2 = dh2.generateKeys('hex'); +const secret1 = dh1.computeSecret(key2, 'hex', 'base64'); +const secret2 = dh2.computeSecret(key1, 'latin1', 'buffer'); assert.strictEqual(secret1, secret2.toString('base64')); // Create "another dh1" using generated keys from dh1, // and compute secret again -var dh3 = crypto.createDiffieHellman(p1, 'buffer'); -var privkey1 = dh1.getPrivateKey(); +const dh3 = crypto.createDiffieHellman(p1, 'buffer'); +const privkey1 = dh1.getPrivateKey(); dh3.setPublicKey(key1); dh3.setPrivateKey(privkey1); @@ -559,26 +559,26 @@ assert.strictEqual(dh1.getGenerator(), dh3.getGenerator()); assert.strictEqual(dh1.getPublicKey(), dh3.getPublicKey()); assert.strictEqual(dh1.getPrivateKey(), dh3.getPrivateKey()); -var secret3 = dh3.computeSecret(key2, 'hex', 'base64'); +const secret3 = dh3.computeSecret(key2, 'hex', 'base64'); assert.strictEqual(secret1, secret3); // https://github.com/joyent/node/issues/2338 -var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' + - '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' + - '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' + - 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; -var d = crypto.createDiffieHellman(p, 'hex'); +const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' + + '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' + + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' + + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; +const d = crypto.createDiffieHellman(p, 'hex'); assert.strictEqual(d.verifyError, DH_NOT_SUITABLE_GENERATOR); // Test RSA key signing/verification -var rsaSign = crypto.createSign('RSA-SHA1'); -var rsaVerify = crypto.createVerify('RSA-SHA1'); +const rsaSign = crypto.createSign('RSA-SHA1'); +const rsaVerify = crypto.createVerify('RSA-SHA1'); assert.ok(rsaSign instanceof crypto.Sign); assert.ok(rsaVerify instanceof crypto.Verify); rsaSign.update(rsaPubPem); -var rsaSignature = rsaSign.sign(rsaKeyPem, 'hex'); +const rsaSignature = rsaSign.sign(rsaKeyPem, 'hex'); assert.strictEqual( rsaSignature, '5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' + diff --git a/test/parallel/test-crypto-certificate.js b/test/parallel/test-crypto-certificate.js index 1dfb2c73b0eca5..ebd83b019ba146 100644 --- a/test/parallel/test-crypto-certificate.js +++ b/test/parallel/test-crypto-certificate.js @@ -1,23 +1,23 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); crypto.DEFAULT_ENCODING = 'buffer'; -var fs = require('fs'); +const fs = require('fs'); // Test Certificates -var spkacValid = fs.readFileSync(common.fixturesDir + '/spkac.valid'); -var spkacFail = fs.readFileSync(common.fixturesDir + '/spkac.fail'); -var spkacPem = fs.readFileSync(common.fixturesDir + '/spkac.pem'); +const spkacValid = fs.readFileSync(common.fixturesDir + '/spkac.valid'); +const spkacFail = fs.readFileSync(common.fixturesDir + '/spkac.fail'); +const spkacPem = fs.readFileSync(common.fixturesDir + '/spkac.pem'); -var certificate = new crypto.Certificate(); +const certificate = new crypto.Certificate(); assert.strictEqual(certificate.verifySpkac(spkacValid), true); assert.strictEqual(certificate.verifySpkac(spkacFail), false); diff --git a/test/parallel/test-crypto-dh-odd-key.js b/test/parallel/test-crypto-dh-odd-key.js index cb8757efff0bde..f6bfcf72c0fd7e 100644 --- a/test/parallel/test-crypto-dh-odd-key.js +++ b/test/parallel/test-crypto-dh-odd-key.js @@ -1,17 +1,17 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); function test() { - var odd = Buffer.alloc(39, 'A'); + const odd = Buffer.alloc(39, 'A'); - var c = crypto.createDiffieHellman(32); + const c = crypto.createDiffieHellman(32); c.setPrivateKey(odd); c.generateKeys(); } diff --git a/test/parallel/test-crypto-dh.js b/test/parallel/test-crypto-dh.js index 6a067bef1be066..95a6df6fee58bb 100644 --- a/test/parallel/test-crypto-dh.js +++ b/test/parallel/test-crypto-dh.js @@ -11,38 +11,41 @@ const DH_NOT_SUITABLE_GENERATOR = crypto.constants.DH_NOT_SUITABLE_GENERATOR; // Test Diffie-Hellman with two parties sharing a secret, // using various encodings as we go along -var dh1 = crypto.createDiffieHellman(common.hasFipsCrypto ? 1024 : 256); -var p1 = dh1.getPrime('buffer'); -var dh2 = crypto.createDiffieHellman(p1, 'buffer'); -var key1 = dh1.generateKeys(); -var key2 = dh2.generateKeys('hex'); -var secret1 = dh1.computeSecret(key2, 'hex', 'base64'); -var secret2 = dh2.computeSecret(key1, 'latin1', 'buffer'); - -assert.equal(secret1, secret2.toString('base64')); -assert.equal(dh1.verifyError, 0); -assert.equal(dh2.verifyError, 0); - -assert.throws(function() { +const dh1 = crypto.createDiffieHellman(common.hasFipsCrypto ? 1024 : 256); +const p1 = dh1.getPrime('buffer'); +const dh2 = crypto.createDiffieHellman(p1, 'buffer'); +let key1 = dh1.generateKeys(); +let key2 = dh2.generateKeys('hex'); +let secret1 = dh1.computeSecret(key2, 'hex', 'base64'); +let secret2 = dh2.computeSecret(key1, 'latin1', 'buffer'); + +assert.strictEqual(secret2.toString('base64'), secret1); +assert.strictEqual(dh1.verifyError, 0); +assert.strictEqual(dh2.verifyError, 0); + +const argumentsError = + /^TypeError: First argument should be number, string or Buffer$/; + +assert.throws(() => { crypto.createDiffieHellman([0x1, 0x2]); -}); +}, argumentsError); -assert.throws(function() { - crypto.createDiffieHellman(function() { }); -}); +assert.throws(() => { + crypto.createDiffieHellman(() => { }); +}, argumentsError); -assert.throws(function() { +assert.throws(() => { crypto.createDiffieHellman(/abc/); -}); +}, argumentsError); -assert.throws(function() { +assert.throws(() => { crypto.createDiffieHellman({}); -}); +}, argumentsError); // Create "another dh1" using generated keys from dh1, // and compute secret again -var dh3 = crypto.createDiffieHellman(p1, 'buffer'); -var privkey1 = dh1.getPrivateKey(); +const dh3 = crypto.createDiffieHellman(p1, 'buffer'); +const privkey1 = dh1.getPrivateKey(); dh3.setPublicKey(key1); dh3.setPrivateKey(privkey1); @@ -50,43 +53,51 @@ assert.deepStrictEqual(dh1.getPrime(), dh3.getPrime()); assert.deepStrictEqual(dh1.getGenerator(), dh3.getGenerator()); assert.deepStrictEqual(dh1.getPublicKey(), dh3.getPublicKey()); assert.deepStrictEqual(dh1.getPrivateKey(), dh3.getPrivateKey()); -assert.equal(dh3.verifyError, 0); +assert.strictEqual(dh3.verifyError, 0); + +const secret3 = dh3.computeSecret(key2, 'hex', 'base64'); -var secret3 = dh3.computeSecret(key2, 'hex', 'base64'); +assert.strictEqual(secret1, secret3); -assert.equal(secret1, secret3); +const wrongBlockLength = + new RegExp('^Error: error:0606506D:digital envelope' + + ' routines:EVP_DecryptFinal_ex:wrong final block length$'); // Run this one twice to make sure that the dh3 clears its error properly { const c = crypto.createDecipheriv('aes-128-ecb', crypto.randomBytes(16), ''); - assert.throws(function() { c.final('utf8'); }, /wrong final block length/); + assert.throws(() => { + c.final('utf8'); + }, wrongBlockLength); } -assert.throws(function() { - dh3.computeSecret(''); -}, /key is too small/i); - { const c = crypto.createDecipheriv('aes-128-ecb', crypto.randomBytes(16), ''); - assert.throws(function() { c.final('utf8'); }, /wrong final block length/); + assert.throws(() => { + c.final('utf8'); + }, wrongBlockLength); } +assert.throws(() => { + dh3.computeSecret(''); +}, /^Error: Supplied key is too small$/); + // Create a shared using a DH group. -var alice = crypto.createDiffieHellmanGroup('modp5'); -var bob = crypto.createDiffieHellmanGroup('modp5'); +const alice = crypto.createDiffieHellmanGroup('modp5'); +const bob = crypto.createDiffieHellmanGroup('modp5'); alice.generateKeys(); bob.generateKeys(); -var aSecret = alice.computeSecret(bob.getPublicKey()).toString('hex'); -var bSecret = bob.computeSecret(alice.getPublicKey()).toString('hex'); -assert.equal(aSecret, bSecret); -assert.equal(alice.verifyError, DH_NOT_SUITABLE_GENERATOR); -assert.equal(bob.verifyError, DH_NOT_SUITABLE_GENERATOR); +const aSecret = alice.computeSecret(bob.getPublicKey()).toString('hex'); +const bSecret = bob.computeSecret(alice.getPublicKey()).toString('hex'); +assert.strictEqual(aSecret, bSecret); +assert.strictEqual(alice.verifyError, DH_NOT_SUITABLE_GENERATOR); +assert.strictEqual(bob.verifyError, DH_NOT_SUITABLE_GENERATOR); /* Ensure specific generator (buffer) works as expected. * The values below (modp2/modp2buf) are for a 1024 bits long prime from * RFC 2412 E.2, see https://tools.ietf.org/html/rfc2412. */ -var modp2 = crypto.createDiffieHellmanGroup('modp2'); -var modp2buf = Buffer.from([ +const modp2 = crypto.createDiffieHellmanGroup('modp2'); +const modp2buf = Buffer.from([ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc9, 0x0f, 0xda, 0xa2, 0x21, 0x68, 0xc2, 0x34, 0xc4, 0xc6, 0x62, 0x8b, 0x80, 0xdc, 0x1c, 0xd1, 0x29, 0x02, 0x4e, 0x08, 0x8a, 0x67, @@ -101,52 +112,53 @@ var modp2buf = Buffer.from([ 0x1f, 0xe6, 0x49, 0x28, 0x66, 0x51, 0xec, 0xe6, 0x53, 0x81, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ]); -var exmodp2 = crypto.createDiffieHellman(modp2buf, Buffer.from([2])); +const exmodp2 = crypto.createDiffieHellman(modp2buf, Buffer.from([2])); modp2.generateKeys(); exmodp2.generateKeys(); -var modp2Secret = modp2.computeSecret(exmodp2.getPublicKey()).toString('hex'); -var exmodp2Secret = exmodp2.computeSecret(modp2.getPublicKey()).toString('hex'); -assert.equal(modp2Secret, exmodp2Secret); -assert.equal(modp2.verifyError, DH_NOT_SUITABLE_GENERATOR); -assert.equal(exmodp2.verifyError, DH_NOT_SUITABLE_GENERATOR); +let modp2Secret = modp2.computeSecret(exmodp2.getPublicKey()).toString('hex'); +const exmodp2Secret = exmodp2.computeSecret(modp2.getPublicKey()) + .toString('hex'); +assert.strictEqual(modp2Secret, exmodp2Secret); +assert.strictEqual(modp2.verifyError, DH_NOT_SUITABLE_GENERATOR); +assert.strictEqual(exmodp2.verifyError, DH_NOT_SUITABLE_GENERATOR); // Ensure specific generator (string with encoding) works as expected. -var exmodp2_2 = crypto.createDiffieHellman(modp2buf, '02', 'hex'); +const exmodp2_2 = crypto.createDiffieHellman(modp2buf, '02', 'hex'); exmodp2_2.generateKeys(); modp2Secret = modp2.computeSecret(exmodp2_2.getPublicKey()).toString('hex'); -var exmodp2_2Secret = exmodp2_2.computeSecret(modp2.getPublicKey()) - .toString('hex'); -assert.equal(modp2Secret, exmodp2_2Secret); -assert.equal(exmodp2_2.verifyError, DH_NOT_SUITABLE_GENERATOR); +const exmodp2_2Secret = exmodp2_2.computeSecret(modp2.getPublicKey()) + .toString('hex'); +assert.strictEqual(modp2Secret, exmodp2_2Secret); +assert.strictEqual(exmodp2_2.verifyError, DH_NOT_SUITABLE_GENERATOR); // Ensure specific generator (string without encoding) works as expected. -var exmodp2_3 = crypto.createDiffieHellman(modp2buf, '\x02'); +const exmodp2_3 = crypto.createDiffieHellman(modp2buf, '\x02'); exmodp2_3.generateKeys(); modp2Secret = modp2.computeSecret(exmodp2_3.getPublicKey()).toString('hex'); -var exmodp2_3Secret = exmodp2_3.computeSecret(modp2.getPublicKey()) +const exmodp2_3Secret = exmodp2_3.computeSecret(modp2.getPublicKey()) .toString('hex'); -assert.equal(modp2Secret, exmodp2_3Secret); -assert.equal(exmodp2_3.verifyError, DH_NOT_SUITABLE_GENERATOR); +assert.strictEqual(modp2Secret, exmodp2_3Secret); +assert.strictEqual(exmodp2_3.verifyError, DH_NOT_SUITABLE_GENERATOR); // Ensure specific generator (numeric) works as expected. -var exmodp2_4 = crypto.createDiffieHellman(modp2buf, 2); +const exmodp2_4 = crypto.createDiffieHellman(modp2buf, 2); exmodp2_4.generateKeys(); modp2Secret = modp2.computeSecret(exmodp2_4.getPublicKey()).toString('hex'); -var exmodp2_4Secret = exmodp2_4.computeSecret(modp2.getPublicKey()) +const exmodp2_4Secret = exmodp2_4.computeSecret(modp2.getPublicKey()) .toString('hex'); -assert.equal(modp2Secret, exmodp2_4Secret); -assert.equal(exmodp2_4.verifyError, DH_NOT_SUITABLE_GENERATOR); +assert.strictEqual(modp2Secret, exmodp2_4Secret); +assert.strictEqual(exmodp2_4.verifyError, DH_NOT_SUITABLE_GENERATOR); -var p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' + - '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' + - '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' + - 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; -var bad_dh = crypto.createDiffieHellman(p, 'hex'); -assert.equal(bad_dh.verifyError, DH_NOT_SUITABLE_GENERATOR); +const p = 'FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74' + + '020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F1437' + + '4FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7ED' + + 'EE386BFB5A899FA5AE9F24117C4B1FE649286651ECE65381FFFFFFFFFFFFFFFF'; +const bad_dh = crypto.createDiffieHellman(p, 'hex'); +assert.strictEqual(bad_dh.verifyError, DH_NOT_SUITABLE_GENERATOR); // Test ECDH @@ -157,7 +169,7 @@ key2 = ecdh2.generateKeys('hex'); secret1 = ecdh1.computeSecret(key2, 'hex', 'base64'); secret2 = ecdh2.computeSecret(key1, 'latin1', 'buffer'); -assert.equal(secret1, secret2.toString('base64')); +assert.strictEqual(secret1, secret2.toString('base64')); // Oakley curves do not clean up ERR stack, it was causing unexpected failure // when accessing other OpenSSL APIs afterwards. @@ -165,7 +177,7 @@ crypto.createECDH('Oakley-EC2N-3'); crypto.createHash('sha256'); // Point formats -assert.equal(ecdh1.getPublicKey('buffer', 'uncompressed')[0], 4); +assert.strictEqual(ecdh1.getPublicKey('buffer', 'uncompressed')[0], 4); let firstByte = ecdh1.getPublicKey('buffer', 'compressed')[0]; assert(firstByte === 2 || firstByte === 3); firstByte = ecdh1.getPublicKey('buffer', 'hybrid')[0]; @@ -175,9 +187,9 @@ assert(firstByte === 6 || firstByte === 7); const ecdh3 = crypto.createECDH('secp256k1'); const key3 = ecdh3.generateKeys(); -assert.throws(function() { +assert.throws(() => { ecdh2.computeSecret(key3, 'latin1', 'buffer'); -}); +}, /^Error: Failed to translate Buffer to a EC_POINT$/); // ECDH should allow .setPrivateKey()/.setPublicKey() const ecdh4 = crypto.createECDH('prime256v1'); @@ -185,20 +197,21 @@ const ecdh4 = crypto.createECDH('prime256v1'); ecdh4.setPrivateKey(ecdh1.getPrivateKey()); ecdh4.setPublicKey(ecdh1.getPublicKey()); -assert.throws(function() { +assert.throws(() => { ecdh4.setPublicKey(ecdh3.getPublicKey()); -}, /Failed to convert Buffer to EC_POINT/); +}, /^Error: Failed to convert Buffer to EC_POINT$/); // Verify that we can use ECDH without having to use newly generated keys. const ecdh5 = crypto.createECDH('secp256k1'); // Verify errors are thrown when retrieving keys from an uninitialized object. -assert.throws(function() { +assert.throws(() => { ecdh5.getPublicKey(); -}, /Failed to get ECDH public key/); -assert.throws(function() { +}, /^Error: Failed to get ECDH public key$/); + +assert.throws(() => { ecdh5.getPrivateKey(); -}, /Failed to get ECDH private key/); +}, /^Error: Failed to get ECDH private key$/); // A valid private key for the secp256k1 curve. const cafebabeKey = 'cafebabe'.repeat(8); @@ -209,9 +222,9 @@ const cafebabePubPtUnComp = '04672a31bfc59d3f04548ec9b7daeeba2f61814e8ccc40448045007f5479f693a3' + '2e02c7f93d13dc2732b760ca377a5897b9dd41a1c1b29dc0442fdce6d0a04d1d'; ecdh5.setPrivateKey(cafebabeKey, 'hex'); -assert.equal(ecdh5.getPrivateKey('hex'), cafebabeKey); +assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey); // Show that the public point (key) is generated while setting the private key. -assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); +assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); // Compressed and uncompressed public points/keys for other party's private key // 0xDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEFDEADBEEF @@ -224,28 +237,30 @@ const peerPubPtUnComp = const sharedSecret = '1da220b5329bbe8bfd19ceef5a5898593f411a6f12ea40f2a8eead9a5cf59970'; -assert.equal(ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex'), sharedSecret); -assert.equal(ecdh5.computeSecret(peerPubPtUnComp, 'hex', 'hex'), sharedSecret); +assert.strictEqual(ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex'), + sharedSecret); +assert.strictEqual(ecdh5.computeSecret(peerPubPtUnComp, 'hex', 'hex'), + sharedSecret); // Verify that we still have the same key pair as before the computation. -assert.equal(ecdh5.getPrivateKey('hex'), cafebabeKey); -assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); +assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey); +assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); // Verify setting and getting compressed and non-compressed serializations. ecdh5.setPublicKey(cafebabePubPtComp, 'hex'); -assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); -assert.equal(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp); +assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); +assert.strictEqual(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp); ecdh5.setPublicKey(cafebabePubPtUnComp, 'hex'); -assert.equal(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); -assert.equal(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp); +assert.strictEqual(ecdh5.getPublicKey('hex'), cafebabePubPtUnComp); +assert.strictEqual(ecdh5.getPublicKey('hex', 'compressed'), cafebabePubPtComp); // Show why allowing the public key to be set on this type does not make sense. ecdh5.setPublicKey(peerPubPtComp, 'hex'); -assert.equal(ecdh5.getPublicKey('hex'), peerPubPtUnComp); -assert.throws(function() { +assert.strictEqual(ecdh5.getPublicKey('hex'), peerPubPtUnComp); +assert.throws(() => { // Error because the public key does not match the private key anymore. ecdh5.computeSecret(peerPubPtComp, 'hex', 'hex'); -}, /Invalid key pair/); +}, /^Error: Invalid key pair$/); // Set to a valid key to show that later attempts to set an invalid key are // rejected. @@ -255,10 +270,10 @@ ecdh5.setPrivateKey(cafebabeKey, 'hex'); '0000000000000000000000000000000000000000000000000000000000000000', 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141', 'FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', -].forEach(function(element, index, object) { - assert.throws(function() { +].forEach((element) => { + assert.throws(() => { ecdh5.setPrivateKey(element, 'hex'); - }, /Private key is not valid for specified curve/); + }, /^Error: Private key is not valid for specified curve.$/); // Verify object state did not change. - assert.equal(ecdh5.getPrivateKey('hex'), cafebabeKey); + assert.strictEqual(ecdh5.getPrivateKey('hex'), cafebabeKey); }); diff --git a/test/parallel/test-crypto-domain.js b/test/parallel/test-crypto-domain.js index ec9985719933d3..6586f7d48a94ce 100644 --- a/test/parallel/test-crypto-domain.js +++ b/test/parallel/test-crypto-domain.js @@ -1,21 +1,21 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var domain = require('domain'); +const common = require('../common'); +const assert = require('assert'); +const domain = require('domain'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); function test(fn) { - var ex = new Error('BAM'); - var d = domain.create(); + const ex = new Error('BAM'); + const d = domain.create(); d.on('error', common.mustCall(function(err) { assert.strictEqual(err, ex); })); - var cb = common.mustCall(function() { + const cb = common.mustCall(function() { throw ex; }); d.run(cb); diff --git a/test/parallel/test-crypto-domains.js b/test/parallel/test-crypto-domains.js index 5d8caf37ee2f41..d0dcf7f2107f77 100644 --- a/test/parallel/test-crypto-domains.js +++ b/test/parallel/test-crypto-domains.js @@ -1,18 +1,18 @@ 'use strict'; -var common = require('../common'); -var domain = require('domain'); -var assert = require('assert'); -var d = domain.create(); -var expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes']; +const common = require('../common'); +const domain = require('domain'); +const assert = require('assert'); +const d = domain.create(); +const expect = ['pbkdf2', 'randomBytes', 'pseudoRandomBytes']; if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); d.on('error', common.mustCall(function(e) { - assert.equal(e.message, expect.shift()); + assert.strictEqual(e.message, expect.shift()); }, 3)); d.run(function() { diff --git a/test/parallel/test-crypto-fips.js b/test/parallel/test-crypto-fips.js index 24b1af70b70329..6fd3352740c8c3 100644 --- a/test/parallel/test-crypto-fips.js +++ b/test/parallel/test-crypto-fips.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawnSync = require('child_process').spawnSync; -var path = require('path'); +const common = require('../common'); +const assert = require('assert'); +const spawnSync = require('child_process').spawnSync; +const path = require('path'); if (!common.hasCrypto) { common.skip('missing crypto'); @@ -15,14 +15,14 @@ const FIPS_ERROR_STRING = 'Error: Cannot set FIPS mode'; const OPTION_ERROR_STRING = 'bad option'; const CNF_FIPS_ON = path.join(common.fixturesDir, 'openssl_fips_enabled.cnf'); const CNF_FIPS_OFF = path.join(common.fixturesDir, 'openssl_fips_disabled.cnf'); -var num_children_ok = 0; +let num_children_ok = 0; function compiledWithFips() { return process.config.variables.openssl_fips ? true : false; } function addToEnv(newVar, value) { - var envCopy = {}; + const envCopy = {}; for (const e in process.env) { envCopy[e] = process.env[e]; } @@ -47,10 +47,10 @@ function testHelper(stream, args, expectedOutput, cmd, env) { function responseHandler(buffer, expectedOutput) { const response = buffer.toString(); - assert.notEqual(0, response.length); + assert.notStrictEqual(response.length, 0); if (FIPS_ENABLED !== expectedOutput && FIPS_DISABLED !== expectedOutput) { // In the case of expected errors just look for a substring. - assert.notEqual(-1, response.indexOf(expectedOutput)); + assert.ok(response.includes(expectedOutput)); } else { // Normal path where we expect either FIPS enabled or disabled. assert.strictEqual(expectedOutput, Number(response)); diff --git a/test/parallel/test-crypto-from-binary.js b/test/parallel/test-crypto-from-binary.js index 0889541ef6e144..485735e83ce5cc 100644 --- a/test/parallel/test-crypto-from-binary.js +++ b/test/parallel/test-crypto-from-binary.js @@ -3,19 +3,19 @@ // to use buffers by default. -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); -var EXTERN_APEX = 0xFBEE9; +const EXTERN_APEX = 0xFBEE9; // manually controlled string for checking binary output -var ucs2_control = 'a\u0000'; +let ucs2_control = 'a\u0000'; // grow the strings to proper length while (ucs2_control.length <= EXTERN_APEX) { @@ -24,7 +24,7 @@ while (ucs2_control.length <= EXTERN_APEX) { // check resultant buffer and output string -var b = Buffer.from(ucs2_control + ucs2_control, 'ucs2'); +const b = Buffer.from(ucs2_control + ucs2_control, 'ucs2'); // // Test updating from birant data diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js index 9e212443453203..0d55d4236a656e 100644 --- a/test/parallel/test-crypto-hash.js +++ b/test/parallel/test-crypto-hash.js @@ -1,44 +1,44 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); -var path = require('path'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); // Test hashing -var a1 = crypto.createHash('sha1').update('Test123').digest('hex'); -var a2 = crypto.createHash('sha256').update('Test123').digest('base64'); -var a3 = crypto.createHash('sha512').update('Test123').digest(); // buffer -var a4 = crypto.createHash('sha1').update('Test123').digest('buffer'); +const a1 = crypto.createHash('sha1').update('Test123').digest('hex'); +const a2 = crypto.createHash('sha256').update('Test123').digest('base64'); +const a3 = crypto.createHash('sha512').update('Test123').digest(); // buffer +const a4 = crypto.createHash('sha1').update('Test123').digest('buffer'); // stream interface -var a5 = crypto.createHash('sha512'); +let a5 = crypto.createHash('sha512'); a5.end('Test123'); a5 = a5.read(); -var a6 = crypto.createHash('sha512'); +let a6 = crypto.createHash('sha512'); a6.write('Te'); a6.write('st'); a6.write('123'); a6.end(); a6 = a6.read(); -var a7 = crypto.createHash('sha512'); +let a7 = crypto.createHash('sha512'); a7.end(); a7 = a7.read(); -var a8 = crypto.createHash('sha512'); +let a8 = crypto.createHash('sha512'); a8.write(''); a8.end(); a8 = a8.read(); if (!common.hasFipsCrypto) { - var a0 = crypto.createHash('md5').update('Test123').digest('latin1'); + const a0 = crypto.createHash('md5').update('Test123').digest('latin1'); assert.strictEqual( a0, 'h\u00ea\u00cb\u0097\u00d8o\fF!\u00fa+\u000e\u0017\u00ca\u00bd\u008c', @@ -67,18 +67,18 @@ assert.deepStrictEqual( // stream interface should produce the same result. assert.deepStrictEqual(a5, a3, 'stream interface is consistent'); assert.deepStrictEqual(a6, a3, 'stream interface is consistent'); -assert.notEqual(a7, undefined, 'no data should return data'); -assert.notEqual(a8, undefined, 'empty string should generate data'); +assert.notStrictEqual(a7, undefined, 'no data should return data'); +assert.notStrictEqual(a8, undefined, 'empty string should generate data'); // Test multiple updates to same hash -var h1 = crypto.createHash('sha1').update('Test123').digest('hex'); -var h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex'); +const h1 = crypto.createHash('sha1').update('Test123').digest('hex'); +const h2 = crypto.createHash('sha1').update('Test').update('123').digest('hex'); assert.strictEqual(h1, h2, 'multipled updates'); // Test hashing for binary files -var fn = path.join(common.fixturesDir, 'sample.png'); -var sha1Hash = crypto.createHash('sha1'); -var fileStream = fs.createReadStream(fn); +const fn = path.join(common.fixturesDir, 'sample.png'); +const sha1Hash = crypto.createHash('sha1'); +const fileStream = fs.createReadStream(fn); fileStream.on('data', function(data) { sha1Hash.update(data); }); @@ -94,24 +94,24 @@ assert.throws(function() { }, /Digest method not supported/); // Default UTF-8 encoding -var hutf8 = crypto.createHash('sha512').update('УТФ-8 text').digest('hex'); +const hutf8 = crypto.createHash('sha512').update('УТФ-8 text').digest('hex'); assert.strictEqual( hutf8, '4b21bbd1a68e690a730ddcb5a8bc94ead9879ffe82580767ad7ec6fa8ba2dea6' + '43a821af66afa9a45b6a78c712fecf0e56dc7f43aef4bcfc8eb5b4d8dca6ea5b'); -assert.notEqual( +assert.notStrictEqual( hutf8, crypto.createHash('sha512').update('УТФ-8 text', 'latin1').digest('hex')); -var h3 = crypto.createHash('sha256'); +const h3 = crypto.createHash('sha256'); h3.digest(); assert.throws(function() { h3.digest(); }, - /Digest already called/); + /Digest already called/); assert.throws(function() { h3.update('foo'); }, - /Digest already called/); + /Digest already called/); diff --git a/test/parallel/test-crypto-hmac.js b/test/parallel/test-crypto-hmac.js index 5307ea4f6f9e05..a3372bcb7242b9 100644 --- a/test/parallel/test-crypto-hmac.js +++ b/test/parallel/test-crypto-hmac.js @@ -1,22 +1,30 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); + +// Test for binding layer robustness +{ + const binding = process.binding('crypto'); + const h = new binding.Hmac(); + // Fail to init the Hmac with an algorithm. + assert.throws(() => h.update('hello'), /^TypeError: HmacUpdate fail$/); +} // Test HMAC -var h1 = crypto.createHmac('sha1', 'Node') +const h1 = crypto.createHmac('sha1', 'Node') .update('some data') .update('to hmac') .digest('hex'); assert.strictEqual(h1, '19fd6e1ba73d9ed2224dd5094a71babe85d9a892', 'test HMAC'); // Test HMAC (Wikipedia Test Cases) -var wikipedia = [ +const wikipedia = [ { key: 'key', data: 'The quick brown fox jumps over the lazy dog', hmac: { // HMACs lifted from Wikipedia. @@ -75,7 +83,7 @@ for (let i = 0, l = wikipedia.length; i < l; i++) { // Test HMAC-SHA-* (rfc 4231 Test Cases) -var rfc4231 = [ +const rfc4231 = [ { key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), data: Buffer.from('4869205468657265', 'hex'), // 'Hi There' @@ -115,7 +123,7 @@ var rfc4231 = [ key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddddddd' + 'ddddddddddddddddddddddddddddddddddddddddddddddddddd', - 'hex'), + 'hex'), hmac: { sha224: '7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333ea', sha256: @@ -132,10 +140,10 @@ var rfc4231 = [ }, { key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819', - 'hex'), + 'hex'), data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' + 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd', - 'hex'), + 'hex'), hmac: { sha224: '6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5a', sha256: @@ -241,7 +249,7 @@ for (let i = 0, l = rfc4231.length; i < l; i++) { } // Test HMAC-MD5/SHA1 (rfc 2202 Test Cases) -var rfc2202_md5 = [ +const rfc2202_md5 = [ { key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), data: 'Hi There', @@ -256,16 +264,16 @@ var rfc2202_md5 = [ key: Buffer.from('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa', 'hex'), data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddddddd' + 'ddddddddddddddddddddddddddddddddddddddddddddddddddd', - 'hex'), + 'hex'), hmac: '56be34521d144c88dbb8c733f0e8b3f6' }, { key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819', - 'hex'), + 'hex'), data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' + 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' + 'cdcdcdcdcd', - 'hex'), + 'hex'), hmac: '697eaf0aca3a3aea3a75164746ffaa79' }, { @@ -278,7 +286,7 @@ var rfc2202_md5 = [ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaa', - 'hex'), + 'hex'), data: 'Test Using Larger Than Block-Size Key - Hash Key First', hmac: '6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd' }, @@ -287,14 +295,14 @@ var rfc2202_md5 = [ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaa', - 'hex'), + 'hex'), data: 'Test Using Larger Than Block-Size Key and Larger Than One ' + 'Block-Size Data', hmac: '6f630fad67cda0ee1fb1f562db3aa53e' } ]; -var rfc2202_sha1 = [ +const rfc2202_sha1 = [ { key: Buffer.from('0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b', 'hex'), data: 'Hi There', @@ -310,16 +318,16 @@ var rfc2202_sha1 = [ data: Buffer.from('ddddddddddddddddddddddddddddddddddddddddddddd' + 'ddddddddddddddddddddddddddddddddddddddddddddd' + 'dddddddddd', - 'hex'), + 'hex'), hmac: '125d7342b9ac11cd91a39af48aa17b4f63f175d3' }, { key: Buffer.from('0102030405060708090a0b0c0d0e0f10111213141516171819', - 'hex'), + 'hex'), data: Buffer.from('cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdc' + 'dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd' + 'cdcdcdcdcd', - 'hex'), + 'hex'), hmac: '4c9007f4026250c6bc8414f9bf50c86c2d7235da' }, { @@ -332,7 +340,7 @@ var rfc2202_sha1 = [ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaa', - 'hex'), + 'hex'), data: 'Test Using Larger Than Block-Size Key - Hash Key First', hmac: 'aa4ae5e15272d00e95705637ce8a3b55ed402112' }, @@ -341,7 +349,7 @@ var rfc2202_sha1 = [ 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' + 'aaaaaaaaaaaaaaaaaaaaaa', - 'hex'), + 'hex'), data: 'Test Using Larger Than Block-Size Key and Larger Than One ' + 'Block-Size Data', diff --git a/test/parallel/test-crypto-padding-aes256.js b/test/parallel/test-crypto-padding-aes256.js index e835867d61d005..40bbfed0f2824f 100644 --- a/test/parallel/test-crypto-padding-aes256.js +++ b/test/parallel/test-crypto-padding-aes256.js @@ -1,28 +1,28 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); crypto.DEFAULT_ENCODING = 'buffer'; function aes256(decipherFinal) { - var iv = Buffer.from('00000000000000000000000000000000', 'hex'); - var key = Buffer.from('0123456789abcdef0123456789abcdef' + - '0123456789abcdef0123456789abcdef', 'hex'); + const iv = Buffer.from('00000000000000000000000000000000', 'hex'); + const key = Buffer.from('0123456789abcdef0123456789abcdef' + + '0123456789abcdef0123456789abcdef', 'hex'); function encrypt(val, pad) { - var c = crypto.createCipheriv('aes256', key, iv); + const c = crypto.createCipheriv('aes256', key, iv); c.setAutoPadding(pad); return c.update(val, 'utf8', 'latin1') + c.final('latin1'); } function decrypt(val, pad) { - var c = crypto.createDecipheriv('aes256', key, iv); + const c = crypto.createDecipheriv('aes256', key, iv); c.setAutoPadding(pad); return c.update(val, 'latin1', 'utf8') + c[decipherFinal]('utf8'); } @@ -30,10 +30,10 @@ function aes256(decipherFinal) { // echo 0123456789abcdef0123456789abcdef \ // | openssl enc -e -aes256 -nopad -K -iv \ // | openssl enc -d -aes256 -nopad -K -iv - var plaintext = '0123456789abcdef0123456789abcdef'; // multiple of block size - var encrypted = encrypt(plaintext, false); - var decrypted = decrypt(encrypted, false); - assert.equal(decrypted, plaintext); + let plaintext = '0123456789abcdef0123456789abcdef'; // multiple of block size + let encrypted = encrypt(plaintext, false); + let decrypted = decrypt(encrypted, false); + assert.strictEqual(decrypted, plaintext); // echo 0123456789abcdef0123456789abcde \ // | openssl enc -e -aes256 -K -iv \ @@ -41,7 +41,7 @@ function aes256(decipherFinal) { plaintext = '0123456789abcdef0123456789abcde'; // not a multiple encrypted = encrypt(plaintext, true); decrypted = decrypt(encrypted, true); - assert.equal(decrypted, plaintext); + assert.strictEqual(decrypted, plaintext); } aes256('final'); diff --git a/test/parallel/test-crypto-pbkdf2.js b/test/parallel/test-crypto-pbkdf2.js index 20ea5c7298199a..9bac769a5cab83 100644 --- a/test/parallel/test-crypto-pbkdf2.js +++ b/test/parallel/test-crypto-pbkdf2.js @@ -52,7 +52,7 @@ assert.strictEqual(key.toString('hex'), expected); crypto.pbkdf2('password', 'salt', 32, 32, 'sha256', common.mustCall(ondone)); function ondone(err, key) { - if (err) throw err; + assert.ifError(err); assert.strictEqual(key.toString('hex'), expected); } diff --git a/test/parallel/test-crypto-rsa-dsa.js b/test/parallel/test-crypto-rsa-dsa.js index 396717ef742a95..bb529f2454dbc8 100644 --- a/test/parallel/test-crypto-rsa-dsa.js +++ b/test/parallel/test-crypto-rsa-dsa.js @@ -1,31 +1,34 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var constants = require('crypto').constants; -var crypto = require('crypto'); +const constants = require('crypto').constants; +const crypto = require('crypto'); // Test certificates -var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii'); -var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii'); -var rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem', - 'ascii'); -var rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem', - 'ascii'); -var rsaKeyPemEncrypted = fs.readFileSync( +const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii'); +const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii'); +const rsaPubPem = fs.readFileSync(common.fixturesDir + '/test_rsa_pubkey.pem', + 'ascii'); +const rsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_rsa_privkey.pem', + 'ascii'); +const rsaKeyPemEncrypted = fs.readFileSync( common.fixturesDir + '/test_rsa_privkey_encrypted.pem', 'ascii'); -var dsaPubPem = fs.readFileSync(common.fixturesDir + '/test_dsa_pubkey.pem', - 'ascii'); -var dsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_dsa_privkey.pem', - 'ascii'); -var dsaKeyPemEncrypted = fs.readFileSync( +const dsaPubPem = fs.readFileSync(common.fixturesDir + '/test_dsa_pubkey.pem', + 'ascii'); +const dsaKeyPem = fs.readFileSync(common.fixturesDir + '/test_dsa_privkey.pem', + 'ascii'); +const dsaKeyPemEncrypted = fs.readFileSync( common.fixturesDir + '/test_dsa_privkey_encrypted.pem', 'ascii'); +const decryptError = new RegExp('^Error: error:06065064:digital envelope ' + + 'routines:EVP_DecryptFinal_ex:bad decrypt$'); + // Test RSA encryption/decryption { const input = 'I AM THE WALRUS'; @@ -34,13 +37,13 @@ var dsaKeyPemEncrypted = fs.readFileSync( let encryptedBuffer = crypto.publicEncrypt(rsaPubPem, bufferToEncrypt); let decryptedBuffer = crypto.privateDecrypt(rsaKeyPem, encryptedBuffer); - assert.strictEqual(input, decryptedBuffer.toString()); + assert.strictEqual(decryptedBuffer.toString(), input); let decryptedBufferWithPassword = crypto.privateDecrypt({ key: rsaKeyPemEncrypted, passphrase: 'password' }, encryptedBuffer); - assert.strictEqual(input, decryptedBufferWithPassword.toString()); + assert.strictEqual(decryptedBufferWithPassword.toString(), input); encryptedBuffer = crypto.publicEncrypt({ key: rsaKeyPemEncrypted, @@ -51,7 +54,7 @@ var dsaKeyPemEncrypted = fs.readFileSync( key: rsaKeyPemEncrypted, passphrase: 'password' }, encryptedBuffer); - assert.strictEqual(input, decryptedBufferWithPassword.toString()); + assert.strictEqual(decryptedBufferWithPassword.toString(), input); encryptedBuffer = crypto.privateEncrypt({ key: rsaKeyPemEncrypted, @@ -62,68 +65,69 @@ var dsaKeyPemEncrypted = fs.readFileSync( key: rsaKeyPemEncrypted, passphrase: Buffer.from('password') }, encryptedBuffer); - assert.strictEqual(input, decryptedBufferWithPassword.toString()); + assert.strictEqual(decryptedBufferWithPassword.toString(), input); encryptedBuffer = crypto.publicEncrypt(certPem, bufferToEncrypt); decryptedBuffer = crypto.privateDecrypt(keyPem, encryptedBuffer); - assert.strictEqual(input, decryptedBuffer.toString()); + assert.strictEqual(decryptedBuffer.toString(), input); encryptedBuffer = crypto.publicEncrypt(keyPem, bufferToEncrypt); decryptedBuffer = crypto.privateDecrypt(keyPem, encryptedBuffer); - assert.strictEqual(input, decryptedBuffer.toString()); + assert.strictEqual(decryptedBuffer.toString(), input); encryptedBuffer = crypto.privateEncrypt(keyPem, bufferToEncrypt); decryptedBuffer = crypto.publicDecrypt(keyPem, encryptedBuffer); - assert.strictEqual(input, decryptedBuffer.toString()); + assert.strictEqual(decryptedBuffer.toString(), input); - assert.throws(function() { + assert.throws(() => { crypto.privateDecrypt({ key: rsaKeyPemEncrypted, passphrase: 'wrong' }, bufferToEncrypt); - }); + }, decryptError); - assert.throws(function() { + assert.throws(() => { crypto.publicEncrypt({ key: rsaKeyPemEncrypted, passphrase: 'wrong' }, encryptedBuffer); - }); + }, decryptError); encryptedBuffer = crypto.privateEncrypt({ key: rsaKeyPemEncrypted, passphrase: Buffer.from('password') }, bufferToEncrypt); - assert.throws(function() { + assert.throws(() => { crypto.publicDecrypt({ key: rsaKeyPemEncrypted, passphrase: [].concat.apply([], Buffer.from('password')) }, encryptedBuffer); - }); + }, decryptError); } function test_rsa(padding) { - var input = Buffer.allocUnsafe(padding === 'RSA_NO_PADDING' ? 1024 / 8 : 32); - for (var i = 0; i < input.length; i++) + const size = (padding === 'RSA_NO_PADDING') ? 1024 / 8 : 32; + const input = Buffer.allocUnsafe(size); + for (let i = 0; i < input.length; i++) input[i] = (i * 7 + 11) & 0xff; - var bufferToEncrypt = Buffer.from(input); + const bufferToEncrypt = Buffer.from(input); padding = constants[padding]; - var encryptedBuffer = crypto.publicEncrypt({ + const encryptedBuffer = crypto.publicEncrypt({ key: rsaPubPem, padding: padding }, bufferToEncrypt); - var decryptedBuffer = crypto.privateDecrypt({ + const decryptedBuffer = crypto.privateDecrypt({ key: rsaKeyPem, padding: padding }, encryptedBuffer); - assert.equal(input, decryptedBuffer.toString()); + assert.deepStrictEqual(decryptedBuffer, input); } test_rsa('RSA_NO_PADDING'); @@ -131,19 +135,21 @@ test_rsa('RSA_PKCS1_PADDING'); test_rsa('RSA_PKCS1_OAEP_PADDING'); // Test RSA key signing/verification -var rsaSign = crypto.createSign('RSA-SHA1'); -var rsaVerify = crypto.createVerify('RSA-SHA1'); +let rsaSign = crypto.createSign('RSA-SHA1'); +let rsaVerify = crypto.createVerify('RSA-SHA1'); assert.ok(rsaSign); assert.ok(rsaVerify); +const expectedSignature = + '5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' + + '8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' + + 'e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f' + + '60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f' + + '40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6'; + rsaSign.update(rsaPubPem); -var rsaSignature = rsaSign.sign(rsaKeyPem, 'hex'); -assert.equal(rsaSignature, - '5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' + - '8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' + - 'e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f' + - '60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f' + - '40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6'); +let rsaSignature = rsaSign.sign(rsaKeyPem, 'hex'); +assert.strictEqual(rsaSignature, expectedSignature); rsaVerify.update(rsaPubPem); assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true); @@ -151,16 +157,11 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true); // Test RSA key signing/verification with encrypted key rsaSign = crypto.createSign('RSA-SHA1'); rsaSign.update(rsaPubPem); -assert.doesNotThrow(function() { - var signOptions = { key: rsaKeyPemEncrypted, passphrase: 'password' }; +assert.doesNotThrow(() => { + const signOptions = { key: rsaKeyPemEncrypted, passphrase: 'password' }; rsaSignature = rsaSign.sign(signOptions, 'hex'); }); -assert.equal(rsaSignature, - '5c50e3145c4e2497aadb0eabc83b342d0b0021ece0d4c4a064b7c' + - '8f020d7e2688b122bfb54c724ac9ee169f83f66d2fe90abeb95e8' + - 'e1290e7e177152a4de3d944cf7d4883114a20ed0f78e70e25ef0f' + - '60f06b858e6af42a2f276ede95bbc6bc9a9bbdda15bd663186a6f' + - '40819a7af19e577bb2efa5e579a1f5ce8a0d4ca8b8f6'); +assert.strictEqual(rsaSignature, expectedSignature); rsaVerify = crypto.createVerify('RSA-SHA1'); rsaVerify.update(rsaPubPem); @@ -168,10 +169,10 @@ assert.strictEqual(rsaVerify.verify(rsaPubPem, rsaSignature, 'hex'), true); rsaSign = crypto.createSign('RSA-SHA1'); rsaSign.update(rsaPubPem); -assert.throws(function() { - var signOptions = { key: rsaKeyPemEncrypted, passphrase: 'wrong' }; +assert.throws(() => { + const signOptions = { key: rsaKeyPemEncrypted, passphrase: 'wrong' }; rsaSign.sign(signOptions, 'hex'); -}); +}, decryptError); // // Test RSA signing and verification @@ -196,7 +197,7 @@ assert.throws(function() { sign.update(input); const output = sign.sign(privateKey, 'hex'); - assert.strictEqual(output, signature); + assert.strictEqual(signature, output); const verify = crypto.createVerify('RSA-SHA256'); verify.update(input); @@ -232,9 +233,9 @@ const input = 'I AM THE WALRUS'; { const sign = crypto.createSign('DSS1'); sign.update(input); - assert.throws(function() { + assert.throws(() => { sign.sign({ key: dsaKeyPemEncrypted, passphrase: 'wrong' }, 'hex'); - }); + }, decryptError); } { @@ -244,7 +245,7 @@ const input = 'I AM THE WALRUS'; sign.update(input); let signature; - assert.doesNotThrow(function() { + assert.doesNotThrow(() => { const signOptions = { key: dsaKeyPemEncrypted, passphrase: 'password' }; signature = sign.sign(signOptions, 'hex'); }); diff --git a/test/parallel/test-crypto-sign-verify.js b/test/parallel/test-crypto-sign-verify.js index 6df41409f0e6c1..ae78cd9d8b3420 100644 --- a/test/parallel/test-crypto-sign-verify.js +++ b/test/parallel/test-crypto-sign-verify.js @@ -1,17 +1,17 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); // Test certificates -var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii'); -var keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii'); +const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii'); +const keyPem = fs.readFileSync(common.fixturesDir + '/test_key.pem', 'ascii'); // Test signing and verifying { diff --git a/test/parallel/test-crypto-stream.js b/test/parallel/test-crypto-stream.js index 1720cc7c4e0aea..f558851b7940a0 100644 --- a/test/parallel/test-crypto-stream.js +++ b/test/parallel/test-crypto-stream.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var stream = require('stream'); -var util = require('util'); +const common = require('../common'); +const assert = require('assert'); +const stream = require('stream'); +const util = require('util'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); // Small stream to buffer converter function Stream2buffer(callback) { @@ -28,7 +28,7 @@ Stream2buffer.prototype._write = function(data, encodeing, done) { if (!common.hasFipsCrypto) { // Create an md5 hash of "Hallo world" - var hasher1 = crypto.createHash('md5'); + const hasher1 = crypto.createHash('md5'); hasher1.pipe(new Stream2buffer(common.mustCall(function end(err, hash) { assert.strictEqual(err, null); assert.strictEqual( diff --git a/test/parallel/test-crypto-verify-failure.js b/test/parallel/test-crypto-verify-failure.js index fdc27215027414..fdf0d6f6456dac 100644 --- a/test/parallel/test-crypto-verify-failure.js +++ b/test/parallel/test-crypto-verify-failure.js @@ -1,54 +1,50 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); -var tls = require('tls'); +const crypto = require('crypto'); +const tls = require('tls'); crypto.DEFAULT_ENCODING = 'buffer'; -var fs = require('fs'); +const fs = require('fs'); -var certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii'); +const certPem = fs.readFileSync(common.fixturesDir + '/test_cert.pem', 'ascii'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = tls.Server(options, function(socket) { - setImmediate(function() { - console.log('sending'); +const server = tls.Server(options, (socket) => { + setImmediate(() => { verify(); - setImmediate(function() { + setImmediate(() => { socket.destroy(); }); }); }); function verify() { - console.log('verify'); crypto.createVerify('RSA-SHA1') .update('Test') .verify(certPem, 'asdfasdfas', 'base64'); } -server.listen(0, function() { +server.listen(0, common.mustCall(() => { tls.connect({ - port: this.address().port, + port: server.address().port, rejectUnauthorized: false - }, function() { + }, common.mustCall(() => { verify(); - }).on('data', function(data) { - console.log(data); - }).on('error', function(err) { - throw err; - }).on('close', function() { - server.close(); - }).resume(); -}); + })) + .on('error', common.fail) + .on('close', common.mustCall(() => { + server.close(); + })).resume(); +})); server.unref(); diff --git a/test/parallel/test-crypto.js b/test/parallel/test-crypto.js index 13401e4ac594ab..2e94397c8f22f9 100644 --- a/test/parallel/test-crypto.js +++ b/test/parallel/test-crypto.js @@ -53,23 +53,33 @@ assert.throws(function() { }, /^TypeError: Data must be a string or a buffer$/); -function assertSorted(list) { +function validateList(list) { + // The list must not be empty + assert(list.length > 0); + + // The list should be sorted. // Array#sort() modifies the list in place so make a copy. - const sorted = list.slice().sort(); + const sorted = [...list].sort(); assert.deepStrictEqual(list, sorted); + + // Each element should be unique. + assert.strictEqual([...new Set(list)].length, list.length); + + // Each element should be a string. + assert(list.every((value) => typeof value === 'string')); } // Assume that we have at least AES-128-CBC. -assert.notStrictEqual(0, crypto.getCiphers().length); +const cryptoCiphers = crypto.getCiphers(); assert(crypto.getCiphers().includes('aes-128-cbc')); -assert(!crypto.getCiphers().includes('AES-128-CBC')); -assertSorted(crypto.getCiphers()); +validateList(cryptoCiphers); // Assume that we have at least AES256-SHA. -assert.notStrictEqual(0, tls.getCiphers().length); +const tlsCiphers = tls.getCiphers(); assert(tls.getCiphers().includes('aes256-sha')); -assert(!tls.getCiphers().includes('AES256-SHA')); -assertSorted(tls.getCiphers()); +// There should be no capital letters in any element. +assert(tlsCiphers.every((value) => /^[^A-Z]+$/.test(value))); +validateList(tlsCiphers); // Assert that we have sha and sha1 but not SHA and SHA1. assert.notStrictEqual(0, crypto.getHashes().length); @@ -79,13 +89,27 @@ assert(!crypto.getHashes().includes('SHA1')); assert(!crypto.getHashes().includes('SHA')); assert(crypto.getHashes().includes('RSA-SHA1')); assert(!crypto.getHashes().includes('rsa-sha1')); -assertSorted(crypto.getHashes()); +validateList(crypto.getHashes()); // Assume that we have at least secp384r1. assert.notStrictEqual(0, crypto.getCurves().length); assert(crypto.getCurves().includes('secp384r1')); assert(!crypto.getCurves().includes('SECP384R1')); -assertSorted(crypto.getCurves()); +validateList(crypto.getCurves()); + +// Modifying return value from get* functions should not mutate subsequent +// return values. +function testImmutability(fn) { + const list = fn(); + const copy = [...list]; + list.push('some-arbitrary-value'); + assert.deepStrictEqual(fn(), copy); +} + +testImmutability(crypto.getCiphers); +testImmutability(tls.getCiphers); +testImmutability(crypto.getHashes); +testImmutability(crypto.getCurves); // Regression tests for #5725: hex input that's not a power of two should // throw, not assert in C++ land. diff --git a/test/parallel/test-cwd-enoent-repl.js b/test/parallel/test-cwd-enoent-repl.js index 1d03bd3e9112c1..942fc07b64a90b 100644 --- a/test/parallel/test-cwd-enoent-repl.js +++ b/test/parallel/test-cwd-enoent-repl.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const spawn = require('child_process').spawn; // Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX. if (common.isSunOS || common.isWindows || common.isAix) { @@ -10,13 +10,13 @@ if (common.isSunOS || common.isWindows || common.isAix) { return; } -var dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid; +const dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid; common.refreshTmpDir(); fs.mkdirSync(dirname); process.chdir(dirname); fs.rmdirSync(dirname); -var proc = spawn(process.execPath, ['--interactive']); +const proc = spawn(process.execPath, ['--interactive']); proc.stdout.pipe(process.stdout); proc.stderr.pipe(process.stderr); proc.stdin.write('require("path");\n'); diff --git a/test/parallel/test-cwd-enoent.js b/test/parallel/test-cwd-enoent.js index c671ef2be4619e..736121a7c89d6e 100644 --- a/test/parallel/test-cwd-enoent.js +++ b/test/parallel/test-cwd-enoent.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const spawn = require('child_process').spawn; // Fails with EINVAL on SmartOS, EBUSY on Windows, EBUSY on AIX. if (common.isSunOS || common.isWindows || common.isAix) { @@ -10,13 +10,13 @@ if (common.isSunOS || common.isWindows || common.isAix) { return; } -var dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid; +const dirname = common.tmpDir + '/cwd-does-not-exist-' + process.pid; common.refreshTmpDir(); fs.mkdirSync(dirname); process.chdir(dirname); fs.rmdirSync(dirname); -var proc = spawn(process.execPath, ['-e', '0']); +const proc = spawn(process.execPath, ['-e', '0']); proc.stdout.pipe(process.stdout); proc.stderr.pipe(process.stderr); diff --git a/test/parallel/test-debug-brk.js b/test/parallel/test-debug-brk.js index 89d9c892145676..769e3a6c5b504e 100644 --- a/test/parallel/test-debug-brk.js +++ b/test/parallel/test-debug-brk.js @@ -7,13 +7,13 @@ let run = () => {}; function test(extraArgs, stdoutPattern) { const next = run; run = () => { - var procStdout = ''; - var procStderr = ''; - var agentStdout = ''; - var debuggerListening = false; - var outputMatched = false; - var needToSpawnAgent = true; - var needToExit = true; + let procStdout = ''; + let procStderr = ''; + let agentStdout = ''; + let debuggerListening = false; + let outputMatched = false; + let needToSpawnAgent = true; + let needToExit = true; const procArgs = [`--debug-brk=${common.PORT}`].concat(extraArgs); const proc = spawn(process.execPath, procArgs); diff --git a/test/parallel/test-debug-port-from-cmdline.js b/test/parallel/test-debug-port-from-cmdline.js index abec53cbd3c83a..53f35877a2f382 100644 --- a/test/parallel/test-debug-port-from-cmdline.js +++ b/test/parallel/test-debug-port-from-cmdline.js @@ -1,17 +1,17 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; -var debugPort = common.PORT; -var args = ['--interactive', '--debug-port=' + debugPort]; -var childOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] }; -var child = spawn(process.execPath, args, childOptions); +const debugPort = common.PORT; +const args = ['--interactive', '--debug-port=' + debugPort]; +const childOptions = { stdio: ['pipe', 'pipe', 'pipe', 'ipc'] }; +const child = spawn(process.execPath, args, childOptions); child.stdin.write("process.send({ msg: 'childready' });\n"); child.stderr.on('data', function(data) { - var lines = data.toString().replace(/\r/g, '').trim().split('\n'); + const lines = data.toString().replace(/\r/g, '').trim().split('\n'); lines.forEach(processStderrLine); }); @@ -26,7 +26,7 @@ process.on('exit', function() { assertOutputLines(); }); -var outputLines = []; +const outputLines = []; function processStderrLine(line) { console.log('> ' + line); outputLines.push(line); @@ -37,12 +37,12 @@ function processStderrLine(line) { } function assertOutputLines() { - var expectedLines = [ + const expectedLines = [ 'Starting debugger agent.', 'Debugger listening on 127.0.0.1:' + debugPort, ]; assert.strictEqual(outputLines.length, expectedLines.length); - for (var i = 0; i < expectedLines.length; i++) + for (let i = 0; i < expectedLines.length; i++) assert(expectedLines[i].includes(outputLines[i])); } diff --git a/test/parallel/test-debug-signal-cluster.js b/test/parallel/test-debug-signal-cluster.js index 24b362a687988a..89b3ca456d3248 100644 --- a/test/parallel/test-debug-signal-cluster.js +++ b/test/parallel/test-debug-signal-cluster.js @@ -12,7 +12,7 @@ const args = [`--debug-port=${port}`, serverPath]; const options = { stdio: ['inherit', 'inherit', 'pipe', 'ipc'] }; const child = spawn(process.execPath, args, options); -var expectedContent = [ +let expectedContent = [ 'Starting debugger agent.', 'Debugger listening on 127.0.0.1:' + (port + 0), 'Starting debugger agent.', @@ -22,10 +22,10 @@ var expectedContent = [ ].join(os.EOL); expectedContent += os.EOL; // the last line also contains an EOL character -var debuggerAgentsOutput = ''; -var debuggerAgentsStarted = false; +let debuggerAgentsOutput = ''; +let debuggerAgentsStarted = false; -var pids; +let pids; child.stderr.on('data', function(data) { const childStderrOutputString = data.toString(); diff --git a/test/parallel/test-debug-uncaught-exception-async.js b/test/parallel/test-debug-uncaught-exception-async.js index 29947cfd92fbb9..8d0d7957c22e12 100644 --- a/test/parallel/test-debug-uncaught-exception-async.js +++ b/test/parallel/test-debug-uncaught-exception-async.js @@ -7,7 +7,7 @@ const spawn = require('child_process').spawn; const emitUncaught = path.join(common.fixturesDir, 'debug-uncaught-async.js'); const result = spawn(process.execPath, [emitUncaught], {encoding: 'utf8'}); -var stderr = ''; +let stderr = ''; result.stderr.on('data', (data) => { stderr += data; }); diff --git a/test/parallel/test-debug-usage.js b/test/parallel/test-debug-usage.js index 5406a82cc8d229..67ee08ce729431 100644 --- a/test/parallel/test-debug-usage.js +++ b/test/parallel/test-debug-usage.js @@ -10,7 +10,7 @@ const expectedUsageMessage = `Usage: node debug script.js node debug : node debug -p `; -var actualUsageMessage = ''; +let actualUsageMessage = ''; child.stderr.on('data', function(data) { actualUsageMessage += data.toString(); }); diff --git a/test/parallel/test-debugger-pid.js b/test/parallel/test-debugger-pid.js index 2b81da700f50a0..e8ba516bfc0f9e 100644 --- a/test/parallel/test-debugger-pid.js +++ b/test/parallel/test-debugger-pid.js @@ -3,15 +3,15 @@ const common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; -var buffer = ''; +let buffer = ''; // connect to debug agent -var interfacer = spawn(process.execPath, ['debug', '-p', '655555']); +const interfacer = spawn(process.execPath, ['debug', '-p', '655555']); console.error(process.execPath, 'debug', '-p', '655555'); interfacer.stdout.setEncoding('utf-8'); interfacer.stderr.setEncoding('utf-8'); -var onData = function(data) { +const onData = function(data) { data = (buffer + data).split('\n'); buffer = data.pop(); data.forEach(function(line) { @@ -21,9 +21,9 @@ var onData = function(data) { interfacer.stdout.on('data', onData); interfacer.stderr.on('data', onData); -var lineCount = 0; +let lineCount = 0; interfacer.on('line', function(line) { - var expected; + let expected; const pid = interfacer.pid; if (common.isWindows) { switch (++lineCount) { diff --git a/test/parallel/test-debugger-repeat-last.js b/test/parallel/test-debugger-repeat-last.js index 7a43bbb6c767ae..cacedbbd7c6e99 100644 --- a/test/parallel/test-debugger-repeat-last.js +++ b/test/parallel/test-debugger-repeat-last.js @@ -17,11 +17,11 @@ const args = [ const proc = spawn(process.execPath, args, { stdio: 'pipe' }); proc.stdout.setEncoding('utf8'); -var stdout = ''; +let stdout = ''; -var sentCommand = false; -var sentEmpty = false; -var sentExit = false; +let sentCommand = false; +let sentEmpty = false; +let sentExit = false; proc.stdout.on('data', (data) => { stdout += data; diff --git a/test/parallel/test-delayed-require.js b/test/parallel/test-delayed-require.js index bc110388fc0380..8e07367eb47366 100644 --- a/test/parallel/test-delayed-require.js +++ b/test/parallel/test-delayed-require.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'); -var path = require('path'); -var assert = require('assert'); +const common = require('../common'); +const path = require('path'); +const assert = require('assert'); setTimeout(common.mustCall(function() { const a = require(path.join(common.fixturesDir, 'a')); diff --git a/test/parallel/test-dgram-address.js b/test/parallel/test-dgram-address.js index 38729de67098da..09c5ba31f6c5b5 100644 --- a/test/parallel/test-dgram-address.js +++ b/test/parallel/test-dgram-address.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var dgram = require('dgram'); +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); // IPv4 Test -var socket_ipv4 = dgram.createSocket('udp4'); -var family_ipv4 = 'IPv4'; +const socket_ipv4 = dgram.createSocket('udp4'); +const family_ipv4 = 'IPv4'; socket_ipv4.on('listening', function() { - var address_ipv4 = socket_ipv4.address(); + const address_ipv4 = socket_ipv4.address(); assert.strictEqual(address_ipv4.address, common.localhostIPv4); assert.strictEqual(typeof address_ipv4.port, 'number'); assert.ok(isFinite(address_ipv4.port)); @@ -25,12 +25,12 @@ socket_ipv4.on('error', function(e) { socket_ipv4.bind(0, common.localhostIPv4); // IPv6 Test -var localhost_ipv6 = '::1'; -var socket_ipv6 = dgram.createSocket('udp6'); -var family_ipv6 = 'IPv6'; +const localhost_ipv6 = '::1'; +const socket_ipv6 = dgram.createSocket('udp6'); +const family_ipv6 = 'IPv6'; socket_ipv6.on('listening', function() { - var address_ipv6 = socket_ipv6.address(); + const address_ipv6 = socket_ipv6.address(); assert.strictEqual(address_ipv6.address, localhost_ipv6); assert.strictEqual(typeof address_ipv6.port, 'number'); assert.ok(isFinite(address_ipv6.port)); diff --git a/test/parallel/test-dgram-bind.js b/test/parallel/test-dgram-bind.js index 0bca97fb294f79..f4624358a4fab4 100644 --- a/test/parallel/test-dgram-bind.js +++ b/test/parallel/test-dgram-bind.js @@ -1,14 +1,18 @@ 'use strict'; -require('../common'); -var assert = require('assert'); -var dgram = require('dgram'); +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); -var socket = dgram.createSocket('udp4'); +const socket = dgram.createSocket('udp4'); + +socket.on('listening', common.mustCall(() => { + assert.throws(() => { + socket.bind(); + }, /^Error: Socket is already bound$/); -socket.on('listening', function() { socket.close(); -}); +})); -var result = socket.bind(); // should not throw +const result = socket.bind(); // should not throw assert.strictEqual(result, socket); // should have returned itself diff --git a/test/parallel/test-dgram-bytes-length.js b/test/parallel/test-dgram-bytes-length.js index 8e2233e9c4daad..07a8bb0e43452b 100644 --- a/test/parallel/test-dgram-bytes-length.js +++ b/test/parallel/test-dgram-bytes-length.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var dgram = require('dgram'); +const assert = require('assert'); +const dgram = require('dgram'); -var message = Buffer.from('Some bytes'); -var client = dgram.createSocket('udp4'); +const message = Buffer.from('Some bytes'); +const client = dgram.createSocket('udp4'); client.send( message, 0, diff --git a/test/parallel/test-dgram-close-is-not-callback.js b/test/parallel/test-dgram-close-is-not-callback.js index 61e08200360452..d0f23d5808c7b7 100644 --- a/test/parallel/test-dgram-close-is-not-callback.js +++ b/test/parallel/test-dgram-close-is-not-callback.js @@ -1,10 +1,10 @@ 'use strict'; -var common = require('../common'); -var dgram = require('dgram'); +const common = require('../common'); +const dgram = require('dgram'); -var buf = Buffer.alloc(1024, 42); +const buf = Buffer.alloc(1024, 42); -var socket = dgram.createSocket('udp4'); +const socket = dgram.createSocket('udp4'); socket.send(buf, 0, buf.length, common.PORT, 'localhost'); diff --git a/test/parallel/test-dgram-close.js b/test/parallel/test-dgram-close.js index 41d28553ca8cb7..43047db697a2eb 100644 --- a/test/parallel/test-dgram-close.js +++ b/test/parallel/test-dgram-close.js @@ -6,10 +6,10 @@ const common = require('../common'); const assert = require('assert'); const dgram = require('dgram'); -var buf = Buffer.alloc(1024, 42); +const buf = Buffer.alloc(1024, 42); -var socket = dgram.createSocket('udp4'); -var handle = socket._handle; +let socket = dgram.createSocket('udp4'); +const handle = socket._handle; socket.send(buf, 0, buf.length, common.PORT, 'localhost'); assert.strictEqual(socket.close(common.mustCall(function() {})), socket); diff --git a/test/parallel/test-dgram-exclusive-implicit-bind.js b/test/parallel/test-dgram-exclusive-implicit-bind.js index 97fd6bed5d6e33..927c9f815fc046 100644 --- a/test/parallel/test-dgram-exclusive-implicit-bind.js +++ b/test/parallel/test-dgram-exclusive-implicit-bind.js @@ -40,11 +40,11 @@ const dgram = require('dgram'); // with ENOTSUP. if (cluster.isMaster) { - var messages = 0; + let messages = 0; const ports = {}; const pids = []; - var target = dgram.createSocket('udp4'); + const target = dgram.createSocket('udp4'); const done = common.mustCall(function() { cluster.disconnect(); @@ -84,7 +84,6 @@ if (cluster.isMaster) { } const source = dgram.createSocket('udp4'); -var interval; source.on('close', function() { clearInterval(interval); @@ -100,6 +99,6 @@ if (process.env.BOUND === 'y') { } const buf = Buffer.from(process.pid.toString()); -interval = setInterval(() => { +const interval = setInterval(() => { source.send(buf, common.PORT, '127.0.0.1'); }, 1).unref(); diff --git a/test/parallel/test-dgram-implicit-bind.js b/test/parallel/test-dgram-implicit-bind.js index 8cbb3f771e2d47..bfc86803b463f1 100644 --- a/test/parallel/test-dgram-implicit-bind.js +++ b/test/parallel/test-dgram-implicit-bind.js @@ -1,10 +1,10 @@ 'use strict'; const common = require('../common'); -var dgram = require('dgram'); +const dgram = require('dgram'); -var source = dgram.createSocket('udp4'); -var target = dgram.createSocket('udp4'); -var messages = 0; +const source = dgram.createSocket('udp4'); +const target = dgram.createSocket('udp4'); +let messages = 0; target.on('message', common.mustCall(function(buf) { if (buf.toString() === 'abc') ++messages; diff --git a/test/parallel/test-dgram-listen-after-bind.js b/test/parallel/test-dgram-listen-after-bind.js index 498a17a0e5b053..e60687649cda30 100644 --- a/test/parallel/test-dgram-listen-after-bind.js +++ b/test/parallel/test-dgram-listen-after-bind.js @@ -1,14 +1,14 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var dgram = require('dgram'); +const assert = require('assert'); +const dgram = require('dgram'); -var socket = dgram.createSocket('udp4'); +const socket = dgram.createSocket('udp4'); socket.bind(); -var fired = false; -var timer = setTimeout(function() { +let fired = false; +const timer = setTimeout(function() { socket.close(); }, 100); diff --git a/test/parallel/test-dgram-multicast-loopback.js b/test/parallel/test-dgram-multicast-loopback.js new file mode 100644 index 00000000000000..01def7e28160cd --- /dev/null +++ b/test/parallel/test-dgram-multicast-loopback.js @@ -0,0 +1,12 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); +const socket = dgram.createSocket('udp4'); + +socket.bind(0); +socket.on('listening', common.mustCall(() => { + const result = socket.setMulticastLoopback(16); + assert.strictEqual(result, 16); + socket.close(); +})); diff --git a/test/parallel/test-dgram-multicast-setTTL.js b/test/parallel/test-dgram-multicast-setTTL.js index 83d482f426bcd4..11b5a0a7635857 100644 --- a/test/parallel/test-dgram-multicast-setTTL.js +++ b/test/parallel/test-dgram-multicast-setTTL.js @@ -1,23 +1,23 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const dgram = require('dgram'); const socket = dgram.createSocket('udp4'); -let thrown = false; socket.bind(0); -socket.on('listening', function() { - socket.setMulticastTTL(16); +socket.on('listening', common.mustCall(() => { + const result = socket.setMulticastTTL(16); + assert.strictEqual(result, 16); //Try to set an invalid TTL (valid ttl is > 0 and < 256) - try { + assert.throws(() => { socket.setMulticastTTL(1000); - } catch (e) { - thrown = true; - } + }, /^Error: setMulticastTTL EINVAL$/); - assert(thrown, 'Setting an invalid multicast TTL should throw some error'); + assert.throws(() => { + socket.setMulticastTTL('foo'); + }, /^TypeError: Argument must be a number$/); //close the socket socket.close(); -}); +})); diff --git a/test/parallel/test-dgram-oob-buffer.js b/test/parallel/test-dgram-oob-buffer.js index e52bf7d69b3c6f..247a35588c3ff7 100644 --- a/test/parallel/test-dgram-oob-buffer.js +++ b/test/parallel/test-dgram-oob-buffer.js @@ -3,11 +3,11 @@ // unreachable host. This error can be reported by sendto() and even by // recvfrom(). Node should not propagate this error to the user. -var common = require('../common'); -var dgram = require('dgram'); +const common = require('../common'); +const dgram = require('dgram'); -var socket = dgram.createSocket('udp4'); -var buf = Buffer.from([1, 2, 3, 4]); +const socket = dgram.createSocket('udp4'); +const buf = Buffer.from([1, 2, 3, 4]); function ok() {} socket.send(buf, 0, 0, common.PORT, '127.0.0.1', ok); // useful? no diff --git a/test/parallel/test-dgram-ref.js b/test/parallel/test-dgram-ref.js index 6505ce9b1ec886..d8981c0b8ad1db 100644 --- a/test/parallel/test-dgram-ref.js +++ b/test/parallel/test-dgram-ref.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var dgram = require('dgram'); +const dgram = require('dgram'); // should not hang, see #1282 dgram.createSocket('udp4'); diff --git a/test/parallel/test-dgram-regress-4496.js b/test/parallel/test-dgram-regress-4496.js index 4bdd0d6520d7dc..b4ec8195d7e7f0 100644 --- a/test/parallel/test-dgram-regress-4496.js +++ b/test/parallel/test-dgram-regress-4496.js @@ -2,11 +2,11 @@ // Remove this test once we support sending strings. require('../common'); -var assert = require('assert'); -var dgram = require('dgram'); +const assert = require('assert'); +const dgram = require('dgram'); // Should throw but not crash. -var socket = dgram.createSocket('udp4'); +const socket = dgram.createSocket('udp4'); assert.throws(function() { socket.send(true, 0, 1, 1, 'host'); }, TypeError); assert.throws(function() { socket.sendto(5, 0, 1, 1, 'host'); }, TypeError); socket.close(); diff --git a/test/parallel/test-dgram-send-bad-arguments.js b/test/parallel/test-dgram-send-bad-arguments.js index a3918697addc4e..c7ec6b51eecfa8 100644 --- a/test/parallel/test-dgram-send-bad-arguments.js +++ b/test/parallel/test-dgram-send-bad-arguments.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var dgram = require('dgram'); +const assert = require('assert'); +const dgram = require('dgram'); -var buf = Buffer.from('test'); -var host = '127.0.0.1'; -var sock = dgram.createSocket('udp4'); +const buf = Buffer.from('test'); +const host = '127.0.0.1'; +const sock = dgram.createSocket('udp4'); assert.throws(function() { sock.send(); diff --git a/test/parallel/test-dgram-send-empty-array.js b/test/parallel/test-dgram-send-empty-array.js index 442803e6db8632..1bfcacd9a40497 100644 --- a/test/parallel/test-dgram-send-empty-array.js +++ b/test/parallel/test-dgram-send-empty-array.js @@ -12,7 +12,7 @@ const dgram = require('dgram'); const client = dgram.createSocket('udp4'); -var interval; +let interval; client.on('message', common.mustCall(function onMessage(buf, info) { const expected = Buffer.alloc(0); diff --git a/test/parallel/test-dgram-send-empty-buffer.js b/test/parallel/test-dgram-send-empty-buffer.js index 70e7e46e0a327e..d612dbc7e56c83 100644 --- a/test/parallel/test-dgram-send-empty-buffer.js +++ b/test/parallel/test-dgram-send-empty-buffer.js @@ -21,7 +21,7 @@ client.bind(0, common.mustCall(function() { })); const buf = Buffer.alloc(0); - var interval = setInterval(function() { + const interval = setInterval(function() { client.send(buf, 0, 0, port, '127.0.0.1', common.mustCall(function() {})); }, 10); })); diff --git a/test/parallel/test-dgram-sendto.js b/test/parallel/test-dgram-sendto.js new file mode 100644 index 00000000000000..350f488f12af0d --- /dev/null +++ b/test/parallel/test-dgram-sendto.js @@ -0,0 +1,24 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const dgram = require('dgram'); +const socket = dgram.createSocket('udp4'); + +const errorMessage = + /^Error: Send takes "offset" and "length" as args 2 and 3$/; + +assert.throws(() => { + socket.sendto(); +}, errorMessage); + +assert.throws(() => { + socket.sendto('buffer', 1, 'offset', 'port', 'address', 'cb'); +}, errorMessage); + +assert.throws(() => { + socket.sendto('buffer', 'offset', 1, 'port', 'address', 'cb'); +}, errorMessage); + +assert.throws(() => { + socket.sendto('buffer', 1, 1, 10, false, 'cb'); +}, /^Error: udp4 sockets must send to port, address$/); diff --git a/test/parallel/test-dgram-setTTL.js b/test/parallel/test-dgram-setTTL.js index 9393e53c7f1912..7da3975ad4c3fd 100644 --- a/test/parallel/test-dgram-setTTL.js +++ b/test/parallel/test-dgram-setTTL.js @@ -1,17 +1,22 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const dgram = require('dgram'); const socket = dgram.createSocket('udp4'); socket.bind(0); -socket.on('listening', function() { - var result = socket.setTTL(16); +socket.on('listening', common.mustCall(() => { + const result = socket.setTTL(16); assert.strictEqual(result, 16); - assert.throws(function() { + assert.throws(() => { socket.setTTL('foo'); - }, /Argument must be a number/); + }, /^TypeError: Argument must be a number$/); + + // TTL must be a number from > 0 to < 256 + assert.throws(() => { + socket.setTTL(1000); + }, /^Error: setTTL EINVAL$/); socket.close(); -}); +})); diff --git a/test/parallel/test-dgram-unref.js b/test/parallel/test-dgram-unref.js index e5f26b6f3387b8..ee463d7ab8da77 100644 --- a/test/parallel/test-dgram-unref.js +++ b/test/parallel/test-dgram-unref.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var dgram = require('dgram'); +const dgram = require('dgram'); -var s = dgram.createSocket('udp4'); +const s = dgram.createSocket('udp4'); s.bind(); s.unref(); diff --git a/test/parallel/test-dh-padding.js b/test/parallel/test-dh-padding.js index a9cd95225abedb..4744d204739a5d 100644 --- a/test/parallel/test-dh-padding.js +++ b/test/parallel/test-dh-padding.js @@ -1,14 +1,14 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -try { - var crypto = require('crypto'); -} catch (e) { +if (!common.hasCrypto) { common.skip('node compiled without OpenSSL.'); return; } +const assert = require('assert'); +const crypto = require('crypto'); + /* This test verifies padding with leading zeroes for shared * secrets that are strictly smaller than the modulus (prime). * See: @@ -45,7 +45,7 @@ try { * } */ -var apub = +const apub = '5484455905d3eff34c70980e871f27f05448e66f5a6efbb97cbcba4e927196c2bd9ea272cded91\ 10a4977afa8d9b16c9139a444ed2d954a794650e5d7cb525204f385e1af81530518563822ecd0f9\ 524a958d02b3c269e79d6d69850f0968ad567a4404fbb0b19efc8bc73e267b6136b88cafb33299f\ @@ -53,7 +53,7 @@ f7c7cace3ffab1a88c2c9ee841f88b4c3679b4efc465f5c93cca11d487be57373e4c5926f634c4e\ efee6721d01db91cd66321615b2522f96368dbc818875d422140d0edf30bdb97d9721feddcb9ff6\ 453741a4f687ee46fc54bf1198801f1210ac789879a5ee123f79e2d2ce1209df2445d32166bc9e4\ 8f89e944ec9c3b2e16c8066cd8eebd4e33eb941'; -var bpub = +const bpub = '3fca64510e36bc7da8a3a901c7b74c2eabfa25deaf7cbe1d0c50235866136ad677317279e1fb0\ 06e9c0a07f63e14a3363c8e016fbbde2b2c7e79fed1cc3e08e95f7459f547a8cd0523ee9dc744d\ e5a956d92b937db4448917e1f6829437f05e408ee7aea70c0362b37370c7c75d14449d8b2d2133\ @@ -61,7 +61,7 @@ e5a956d92b937db4448917e1f6829437f05e408ee7aea70c0362b37370c7c75d14449d8b2d2133\ 788a1fdc6cdf17f5fffaf024ce8711a2ebde0b52e9f1cb56224483826d6e5ac6ecfaae07b75d20\ 6e8ac97f5be1a5b68f20382f2a7dac189cf169325c4cf845b26a0cd616c31fec905c5d9035e5f7\ 8e9880c812374ac0f3ca3d365f06e4be526b5affd4b79'; -var apriv = +const apriv = '62411e34704637d99c6c958a7db32ac22fcafafbe1c33d2cfdb76e12ded41f38fc16b792b9041\ 2e4c82755a3815ba52f780f0ee296ad46e348fc4d1dcd6b64f4eea1b231b2b7d95c5b1c2e26d34\ 83520558b9860a6eb668f01422a54e6604aa7702b4e67511397ef3ecb912bff1a83899c5a5bfb2\ @@ -69,7 +69,7 @@ var apriv = 08c3b3e6fc60668f7be81cce6784482af228dd7f489005253a165e292802cfd0399924f6c56827\ 7012f68255207722355634290acc7fddeefbba75650a85ece95b6a12de67eac016ba78960108dd\ 5dbadfaa43cc9fed515a1f307b7d90ae0623bc7b8cefb'; -var secret = +const secret = '00c37b1e06a436d6717816a40e6d72907a6f255638b93032267dcb9a5f0b4a9aa0236f3dce63b\ 1c418c60978a00acd1617dfeecf1661d8a3fafb4d0d8824386750f4853313400e7e4afd22847e4\ fa56bc9713872021265111906673b38db83d10cbfa1dea3b6b4c97c8655f4ae82125281af7f234\ @@ -79,13 +79,13 @@ dc8fe984ddaf532fc1531ce43155fa0ab32532bf1ece5356b8a3447b5267798a904f16f3f4e635\ 8612314311231f905f91c63a1aea52e0b60cead8b57df'; /* FIPS-friendly 2048 bit prime */ -var p = crypto.createDiffieHellman( +const p = crypto.createDiffieHellman( crypto.getDiffieHellman('modp14').getPrime()); p.setPublicKey(apub, 'hex'); p.setPrivateKey(apriv, 'hex'); -assert.equal( +assert.strictEqual( p.computeSecret(bpub, 'hex', 'hex').toString('hex'), secret ); diff --git a/test/parallel/test-dns-lookup-cb-error.js b/test/parallel/test-dns-lookup-cb-error.js deleted file mode 100644 index 212f037868309e..00000000000000 --- a/test/parallel/test-dns-lookup-cb-error.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; -const common = require('../common'); -const assert = require('assert'); -const cares = process.binding('cares_wrap'); - -const dns = require('dns'); - -// Stub `getaddrinfo` to *always* error. -cares.getaddrinfo = function() { - return process.binding('uv').UV_ENOENT; -}; - -assert.doesNotThrow(() => { - var tickValue = 0; - - dns.lookup('example.com', common.mustCall((error, result, addressType) => { - assert(error); - assert.strictEqual(tickValue, 1); - assert.strictEqual(error.code, 'ENOENT'); - })); - - // Make sure that the error callback is called - // on next tick. - tickValue = 1; -}); diff --git a/test/parallel/test-dns-lookup.js b/test/parallel/test-dns-lookup.js new file mode 100644 index 00000000000000..a720c46e02a630 --- /dev/null +++ b/test/parallel/test-dns-lookup.js @@ -0,0 +1,89 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cares = process.binding('cares_wrap'); +const dns = require('dns'); + +// Stub `getaddrinfo` to *always* error. +cares.getaddrinfo = () => process.binding('uv').UV_ENOENT; + +assert.throws(() => { + dns.lookup(1, {}); +}, /^TypeError: Invalid arguments: hostname must be a string or falsey$/); + +assert.throws(() => { + dns.lookup(false, 'cb'); +}, /^TypeError: Invalid arguments: callback must be passed$/); + +assert.throws(() => { + dns.lookup(false, 'options', 'cb'); +}, /^TypeError: Invalid arguments: callback must be passed$/); + +assert.throws(() => { + dns.lookup(false, { + hints: 100, + family: 0, + all: false + }, () => {}); +}, /^TypeError: Invalid argument: hints must use valid flags$/); + +assert.throws(() => { + dns.lookup(false, { + hints: 0, + family: 20, + all: false + }, () => {}); +}, /^TypeError: Invalid argument: family must be 4 or 6$/); + +assert.doesNotThrow(() => { + dns.lookup(false, { + hints: 0, + family: 0, + all: true + }, common.mustCall((error, result, addressType) => { + assert.ifError(error); + assert.deepStrictEqual(result, []); + assert.strictEqual(addressType, undefined); + })); +}); + +assert.doesNotThrow(() => { + dns.lookup('127.0.0.1', { + hints: 0, + family: 4, + all: true + }, common.mustCall((error, result, addressType) => { + assert.ifError(error); + assert.deepStrictEqual(result, [{ + address: '127.0.0.1', + family: 4 + }]); + assert.strictEqual(addressType, undefined); + })); +}); + +assert.doesNotThrow(() => { + dns.lookup('127.0.0.1', { + hints: 0, + family: 4, + all: false + }, common.mustCall((error, result, addressType) => { + assert.ifError(error); + assert.deepStrictEqual(result, '127.0.0.1'); + assert.strictEqual(addressType, 4); + })); +}); + +assert.doesNotThrow(() => { + let tickValue = 0; + + dns.lookup('example.com', common.mustCall((error, result, addressType) => { + assert(error); + assert.strictEqual(tickValue, 1); + assert.strictEqual(error.code, 'ENOENT'); + })); + + // Make sure that the error callback is called + // on next tick. + tickValue = 1; +}); diff --git a/test/parallel/test-dns.js b/test/parallel/test-dns.js index 9ee2e9f974f625..27b9b81d7d14a2 100644 --- a/test/parallel/test-dns.js +++ b/test/parallel/test-dns.js @@ -112,7 +112,7 @@ assert.doesNotThrow(() => dns.lookup(NaN, noop)); */ assert.throws(() => { dns.lookup('www.google.com', { hints: (dns.V4MAPPED | dns.ADDRCONFIG) + 1 }, - noop); + noop); }, /^TypeError: Invalid argument: hints must use valid flags$/); assert.throws(() => dns.lookup('www.google.com'), diff --git a/test/parallel/test-domain-abort-on-uncaught.js b/test/parallel/test-domain-abort-on-uncaught.js index d61debc06067f6..f754541f37462b 100644 --- a/test/parallel/test-domain-abort-on-uncaught.js +++ b/test/parallel/test-domain-abort-on-uncaught.js @@ -9,7 +9,7 @@ const assert = require('assert'); const domain = require('domain'); const child_process = require('child_process'); -var errorHandlerCalled = false; +let errorHandlerCalled = false; const tests = [ function nextTick() { @@ -90,7 +90,7 @@ const tests = [ }); d.run(function() { - var fs = require('fs'); + const fs = require('fs'); fs.exists('/non/existing/file', function onExists(exists) { throw new Error('boom!'); }); @@ -212,7 +212,7 @@ const tests = [ d.run(function() { d2.run(function() { - var fs = require('fs'); + const fs = require('fs'); fs.exists('/non/existing/file', function onExists(exists) { throw new Error('boom!'); }); @@ -232,7 +232,7 @@ if (process.argv[2] === 'child') { } else { tests.forEach(function(test, testIndex) { - var testCmd = ''; + let testCmd = ''; if (!common.isWindows) { // Do not create core files, as it can take a lot of disk space on // continuous testing and developers' machines @@ -245,7 +245,7 @@ if (process.argv[2] === 'child') { testCmd += ' ' + 'child'; testCmd += ' ' + testIndex; - var child = child_process.exec(testCmd); + const child = child_process.exec(testCmd); child.on('exit', function onExit(code, signal) { assert.strictEqual(code, 0, 'Test at index ' + testIndex + diff --git a/test/parallel/test-domain-crypto.js b/test/parallel/test-domain-crypto.js index 1109591fee9631..8293eb82d2bc2c 100644 --- a/test/parallel/test-domain-crypto.js +++ b/test/parallel/test-domain-crypto.js @@ -2,13 +2,13 @@ const common = require('../common'); -try { - var crypto = require('crypto'); -} catch (e) { +if (!common.hasCrypto) { common.skip('node compiled without OpenSSL.'); return; } +const crypto = require('crypto'); + // Pollution of global is intentional as part of test. common.globalCheck = false; // See https://github.com/nodejs/node/commit/d1eff9ab diff --git a/test/parallel/test-domain-enter-exit.js b/test/parallel/test-domain-enter-exit.js index 2973e833f3a1b9..4a11c3a206a5fe 100644 --- a/test/parallel/test-domain-enter-exit.js +++ b/test/parallel/test-domain-enter-exit.js @@ -2,8 +2,8 @@ // Make sure the domain stack is a stack require('../common'); -var assert = require('assert'); -var domain = require('domain'); +const assert = require('assert'); +const domain = require('domain'); function names(array) { return array.map(function(d) { @@ -11,11 +11,11 @@ function names(array) { }).join(', '); } -var a = domain.create(); +const a = domain.create(); a.name = 'a'; -var b = domain.create(); +const b = domain.create(); b.name = 'b'; -var c = domain.create(); +const c = domain.create(); c.name = 'c'; a.enter(); // push diff --git a/test/parallel/test-domain-exit-dispose-again.js b/test/parallel/test-domain-exit-dispose-again.js index b1911bb40e0c93..542950f8af428e 100644 --- a/test/parallel/test-domain-exit-dispose-again.js +++ b/test/parallel/test-domain-exit-dispose-again.js @@ -6,22 +6,22 @@ // the same invocation of listOnTimeout, _are_ called. require('../common'); -var assert = require('assert'); -var domain = require('domain'); -var disposalFailed = false; +const assert = require('assert'); +const domain = require('domain'); +let disposalFailed = false; // Repeatedly schedule a timer with a delay different than the timers attached // to a domain that will eventually be disposed to make sure that they are // called, regardless of what happens with those timers attached to domains // that will eventually be disposed. -var a = 0; +let a = 0; log(); function log() { console.log(a++, process.domain); if (a < 10) setTimeout(log, 20); } -var secondTimerRan = false; +let secondTimerRan = false; // Use the same timeout duration for both "firstTimer" and "secondTimer" // callbacks so that they are called during the same invocation of the diff --git a/test/parallel/test-domain-exit-dispose.js b/test/parallel/test-domain-exit-dispose.js index 508cec18dccb7d..e1797cb660a0c0 100644 --- a/test/parallel/test-domain-exit-dispose.js +++ b/test/parallel/test-domain-exit-dispose.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var common = require('../common'); -var assert = require('assert'); -var domain = require('domain'); +const common = require('../common'); +const assert = require('assert'); +const domain = require('domain'); // no matter what happens, we should increment a 10 times. -var a = 0; +let a = 0; log(); function log() { console.log(a++, process.domain); @@ -15,7 +15,7 @@ function log() { // in 50ms we'll throw an error. setTimeout(err, 50); function err() { - var d = domain.create(); + const d = domain.create(); d.on('error', handle); d.run(err2); diff --git a/test/parallel/test-domain-http-server.js b/test/parallel/test-domain-http-server.js index 26264e8ec987d8..d8bb5c843662b8 100644 --- a/test/parallel/test-domain-http-server.js +++ b/test/parallel/test-domain-http-server.js @@ -1,17 +1,17 @@ 'use strict'; require('../common'); -var domain = require('domain'); -var http = require('http'); -var assert = require('assert'); +const domain = require('domain'); +const http = require('http'); +const assert = require('assert'); -var objects = { foo: 'bar', baz: {}, num: 42, arr: [1, 2, 3] }; +const objects = { foo: 'bar', baz: {}, num: 42, arr: [1, 2, 3] }; objects.baz.asdf = objects; -var serverCaught = 0; -var clientCaught = 0; +let serverCaught = 0; +let clientCaught = 0; -var server = http.createServer(function(req, res) { - var dom = domain.create(); +const server = http.createServer(function(req, res) { + const dom = domain.create(); req.resume(); dom.add(req); dom.add(res); @@ -27,7 +27,7 @@ var server = http.createServer(function(req, res) { dom.run(function() { // Now, an action that has the potential to fail! // if you request 'baz', then it'll throw a JSON circular ref error. - var data = JSON.stringify(objects[req.url.replace(/[^a-z]/g, '')]); + const data = JSON.stringify(objects[req.url.replace(/[^a-z]/g, '')]); // this line will throw if you pick an unknown key assert.notStrictEqual(data, undefined, 'Data should not be undefined'); @@ -43,8 +43,8 @@ function next() { const port = this.address().port; console.log('listening on localhost:%d', port); - var requests = 0; - var responses = 0; + let requests = 0; + let responses = 0; makeReq('/'); makeReq('/foo'); @@ -55,14 +55,14 @@ function next() { function makeReq(p) { requests++; - var dom = domain.create(); + const dom = domain.create(); dom.on('error', function(er) { clientCaught++; console.log('client error', er); req.socket.destroy(); }); - var req = http.get({ host: 'localhost', port: port, path: p }); + const req = http.get({ host: 'localhost', port: port, path: p }); dom.add(req); req.on('response', function(res) { responses++; @@ -74,7 +74,7 @@ function next() { } dom.add(res); - var d = ''; + let d = ''; res.on('data', function(c) { d += c; }); diff --git a/test/parallel/test-domain-implicit-fs.js b/test/parallel/test-domain-implicit-fs.js index a92653aff1de1c..265d291f61941b 100644 --- a/test/parallel/test-domain-implicit-fs.js +++ b/test/parallel/test-domain-implicit-fs.js @@ -2,10 +2,10 @@ // Simple tests of most basic domain functionality. const common = require('../common'); -var assert = require('assert'); -var domain = require('domain'); +const assert = require('assert'); +const domain = require('domain'); -var d = new domain.Domain(); +const d = new domain.Domain(); d.on('error', common.mustCall(function(er) { console.error('caught', er); @@ -28,10 +28,10 @@ d.on('error', common.mustCall(function(er) { // handles are created. d.run(function() { setTimeout(function() { - var fs = require('fs'); + const fs = require('fs'); fs.readdir(__dirname, function() { fs.open('this file does not exist', 'r', function(er) { - if (er) throw er; + assert.ifError(er); throw new Error('should not get here!'); }); }); diff --git a/test/parallel/test-domain-multi.js b/test/parallel/test-domain-multi.js index cf85dbca460146..a38b6a2bc42bdf 100644 --- a/test/parallel/test-domain-multi.js +++ b/test/parallel/test-domain-multi.js @@ -1,28 +1,18 @@ 'use strict'; // Tests of multiple domains happening at once. -require('../common'); -var assert = require('assert'); -var domain = require('domain'); +const common = require('../common'); +const domain = require('domain'); +const http = require('http'); -var caughtA = false; -var caughtB = false; -var caughtC = false; - - -var a = domain.create(); +const a = domain.create(); a.enter(); // this will be our "root" domain -a.on('error', function(er) { - caughtA = true; - console.log('This should not happen'); - throw er; -}); +a.on('error', common.fail); -var http = require('http'); -var server = http.createServer(function(req, res) { +const server = http.createServer((req, res) => { // child domain of a. - var b = domain.create(); + const b = domain.create(); a.add(b); // treat these EE objects as if they are a part of the b domain @@ -31,47 +21,34 @@ var server = http.createServer(function(req, res) { b.add(req); b.add(res); - b.on('error', function(er) { - caughtB = true; - console.error('Error encountered', er); + b.on('error', common.mustCall((er) => { if (res) { res.writeHead(500); res.end('An error occurred'); } // res.writeHead(500), res.destroy, etc. server.close(); - }); + })); // XXX this bind should not be necessary. // the write cb behavior in http/net should use an // event so that it picks up the domain handling. - res.write('HELLO\n', b.bind(function() { + res.write('HELLO\n', b.bind(() => { throw new Error('this kills domain B, not A'); })); -}).listen(0, function() { - var c = domain.create(); - var req = http.get({ host: 'localhost', port: this.address().port }); +}).listen(0, () => { + const c = domain.create(); + const req = http.get({ host: 'localhost', port: server.address().port }); // add the request to the C domain c.add(req); - req.on('response', function(res) { - console.error('got response'); + req.on('response', (res) => { // add the response object to the C domain c.add(res); res.pipe(process.stdout); }); - c.on('error', function(er) { - caughtC = true; - console.error('Error on c', er.message); - }); -}); - -process.on('exit', function() { - assert.strictEqual(caughtA, false); - assert.strictEqual(caughtB, true); - assert.strictEqual(caughtC, true); - console.log('ok - Errors went where they were supposed to go'); + c.on('error', common.mustCall((er) => { })); }); diff --git a/test/parallel/test-domain-nested-throw.js b/test/parallel/test-domain-nested-throw.js index 69a80b7ab104d0..39507446a3acfc 100644 --- a/test/parallel/test-domain-nested-throw.js +++ b/test/parallel/test-domain-nested-throw.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var domain = require('domain'); +const domain = require('domain'); -var dispose; +let dispose; switch (process.argv[2]) { case 'true': dispose = true; @@ -18,10 +18,10 @@ switch (process.argv[2]) { } function parent() { - var node = process.execPath; - var spawn = require('child_process').spawn; - var opt = { stdio: 'inherit' }; - var child = spawn(node, [__filename, 'true'], opt); + const node = process.execPath; + const spawn = require('child_process').spawn; + const opt = { stdio: 'inherit' }; + let child = spawn(node, [__filename, 'true'], opt); child.on('exit', function(c) { assert(!c); child = spawn(node, [__filename, 'false'], opt); @@ -32,11 +32,11 @@ function parent() { }); } -var gotDomain1Error = false; -var gotDomain2Error = false; +let gotDomain1Error = false; +let gotDomain2Error = false; -var threw1 = false; -var threw2 = false; +let threw1 = false; +let threw2 = false; function throw1() { threw1 = true; @@ -49,7 +49,7 @@ function throw2() { } function inner(throw1, throw2) { - var domain1 = domain.createDomain(); + const domain1 = domain.createDomain(); domain1.on('error', function(err) { if (gotDomain1Error) { @@ -67,7 +67,7 @@ function inner(throw1, throw2) { } function outer() { - var domain2 = domain.createDomain(); + const domain2 = domain.createDomain(); domain2.on('error', function(err) { if (gotDomain2Error) { diff --git a/test/parallel/test-domain-nested.js b/test/parallel/test-domain-nested.js index 68c56d0c3c8b2c..6d673adc7e6387 100644 --- a/test/parallel/test-domain-nested.js +++ b/test/parallel/test-domain-nested.js @@ -2,11 +2,11 @@ // Make sure that the nested domains don't cause the domain stack to grow require('../common'); -var assert = require('assert'); -var domain = require('domain'); +const assert = require('assert'); +const domain = require('domain'); process.on('exit', function(c) { - assert.equal(domain._stack.length, 0); + assert.strictEqual(domain._stack.length, 0); }); domain.create().run(function() { diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-0.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-0.js new file mode 100644 index 00000000000000..6a3a670b9204c2 --- /dev/null +++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-0.js @@ -0,0 +1,18 @@ +'use strict'; + +const common = require('../common'); +const domain = require('domain'); + +function test() { + const d = domain.create(); + + d.run(function() { + throw new Error('boom!'); + }); +} + +if (process.argv[2] === 'child') { + test(); +} else { + common.childShouldThrowAndAbort(); +} diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-1.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-1.js new file mode 100644 index 00000000000000..e32245176571ef --- /dev/null +++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-1.js @@ -0,0 +1,21 @@ +'use strict'; + +const common = require('../common'); +const domain = require('domain'); + +function test() { + const d = domain.create(); + const d2 = domain.create(); + + d.run(function() { + d2.run(function() { + throw new Error('boom!'); + }); + }); +} + +if (process.argv[2] === 'child') { + test(); +} else { + common.childShouldThrowAndAbort(); +} diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-2.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-2.js new file mode 100644 index 00000000000000..ff0fd5eec35f6b --- /dev/null +++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-2.js @@ -0,0 +1,20 @@ +'use strict'; + +const common = require('../common'); +const domain = require('domain'); + +function test() { + const d = domain.create(); + + d.run(function() { + setTimeout(function() { + throw new Error('boom!'); + }, 1); + }); +} + +if (process.argv[2] === 'child') { + test(); +} else { + common.childShouldThrowAndAbort(); +} diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-3.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-3.js new file mode 100644 index 00000000000000..cbe5f3ed8dc4a1 --- /dev/null +++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-3.js @@ -0,0 +1,20 @@ +'use strict'; + +const common = require('../common'); +const domain = require('domain'); + +function test() { + const d = domain.create(); + + d.run(function() { + setImmediate(function() { + throw new Error('boom!'); + }); + }); +} + +if (process.argv[2] === 'child') { + test(); +} else { + common.childShouldThrowAndAbort(); +} diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-4.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-4.js new file mode 100644 index 00000000000000..4d0dd39454d2b2 --- /dev/null +++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-4.js @@ -0,0 +1,20 @@ +'use strict'; + +const common = require('../common'); +const domain = require('domain'); + +function test() { + const d = domain.create(); + + d.run(function() { + process.nextTick(function() { + throw new Error('boom!'); + }); + }); +} + +if (process.argv[2] === 'child') { + test(); +} else { + common.childShouldThrowAndAbort(); +} diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js new file mode 100644 index 00000000000000..ade72147e148e7 --- /dev/null +++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-5.js @@ -0,0 +1,21 @@ +'use strict'; + +const common = require('../common'); +const domain = require('domain'); + +function test() { + const d = domain.create(); + + d.run(function() { + const fs = require('fs'); + fs.exists('/non/existing/file', function onExists() { + throw new Error('boom!'); + }); + }); +} + +if (process.argv[2] === 'child') { + test(); +} else { + common.childShouldThrowAndAbort(); +} diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-6.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-6.js new file mode 100644 index 00000000000000..c3a91379319db5 --- /dev/null +++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-6.js @@ -0,0 +1,26 @@ +'use strict'; + +const common = require('../common'); +const domain = require('domain'); + +function test() { + const d = domain.create(); + const d2 = domain.create(); + + d.on('error', function errorHandler() { + }); + + d.run(function() { + d2.run(function() { + setTimeout(function() { + throw new Error('boom!'); + }, 1); + }); + }); +} + +if (process.argv[2] === 'child') { + test(); +} else { + common.childShouldThrowAndAbort(); +} diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-7.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-7.js new file mode 100644 index 00000000000000..9debc754cea3d1 --- /dev/null +++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-7.js @@ -0,0 +1,26 @@ +'use strict'; + +const common = require('../common'); +const domain = require('domain'); + +function test() { + const d = domain.create(); + const d2 = domain.create(); + + d.on('error', function errorHandler() { + }); + + d.run(function() { + d2.run(function() { + setImmediate(function() { + throw new Error('boom!'); + }); + }); + }); +} + +if (process.argv[2] === 'child') { + test(); +} else { + common.childShouldThrowAndAbort(); +} diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-8.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-8.js new file mode 100644 index 00000000000000..f1670cbd300bdf --- /dev/null +++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-8.js @@ -0,0 +1,26 @@ +'use strict'; + +const common = require('../common'); +const domain = require('domain'); + +function test() { + const d = domain.create(); + const d2 = domain.create(); + + d.on('error', function errorHandler() { + }); + + d.run(function() { + d2.run(function() { + process.nextTick(function() { + throw new Error('boom!'); + }); + }); + }); +} + +if (process.argv[2] === 'child') { + test(); +} else { + common.childShouldThrowAndAbort(); +} diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js new file mode 100644 index 00000000000000..2e86a2125e86ee --- /dev/null +++ b/test/parallel/test-domain-no-error-handler-abort-on-uncaught-9.js @@ -0,0 +1,27 @@ +'use strict'; + +const common = require('../common'); +const domain = require('domain'); + +function test() { + const d = domain.create(); + const d2 = domain.create(); + + d.on('error', function errorHandler() { + }); + + d.run(function() { + d2.run(function() { + const fs = require('fs'); + fs.exists('/non/existing/file', function onExists() { + throw new Error('boom!'); + }); + }); + }); +} + +if (process.argv[2] === 'child') { + test(); +} else { + common.childShouldThrowAndAbort(); +} diff --git a/test/parallel/test-domain-no-error-handler-abort-on-uncaught.js b/test/parallel/test-domain-no-error-handler-abort-on-uncaught.js deleted file mode 100644 index 833e7374d7f2ab..00000000000000 --- a/test/parallel/test-domain-no-error-handler-abort-on-uncaught.js +++ /dev/null @@ -1,168 +0,0 @@ -'use strict'; - -/* - * This test makes sure that when using --abort-on-uncaught-exception and - * when throwing an error from within a domain that does not have an error - * handler setup, the process aborts. - */ -const common = require('../common'); -const assert = require('assert'); -const domain = require('domain'); -const child_process = require('child_process'); - -const tests = [ - function() { - const d = domain.create(); - - d.run(function() { - throw new Error('boom!'); - }); - }, - - function() { - const d = domain.create(); - const d2 = domain.create(); - - d.run(function() { - d2.run(function() { - throw new Error('boom!'); - }); - }); - }, - - function() { - const d = domain.create(); - - d.run(function() { - setTimeout(function() { - throw new Error('boom!'); - }, 1); - }); - }, - - function() { - const d = domain.create(); - - d.run(function() { - setImmediate(function() { - throw new Error('boom!'); - }); - }); - }, - - function() { - const d = domain.create(); - - d.run(function() { - process.nextTick(function() { - throw new Error('boom!'); - }); - }); - }, - - function() { - const d = domain.create(); - - d.run(function() { - var fs = require('fs'); - fs.exists('/non/existing/file', function onExists() { - throw new Error('boom!'); - }); - }); - }, - - function() { - const d = domain.create(); - const d2 = domain.create(); - - d.on('error', function errorHandler() { - }); - - d.run(function() { - d2.run(function() { - setTimeout(function() { - throw new Error('boom!'); - }, 1); - }); - }); - }, - - function() { - const d = domain.create(); - const d2 = domain.create(); - - d.on('error', function errorHandler() { - }); - - d.run(function() { - d2.run(function() { - setImmediate(function() { - throw new Error('boom!'); - }); - }); - }); - }, - - function() { - const d = domain.create(); - const d2 = domain.create(); - - d.on('error', function errorHandler() { - }); - - d.run(function() { - d2.run(function() { - process.nextTick(function() { - throw new Error('boom!'); - }); - }); - }); - }, - - function() { - const d = domain.create(); - const d2 = domain.create(); - - d.on('error', function errorHandler() { - }); - - d.run(function() { - d2.run(function() { - var fs = require('fs'); - fs.exists('/non/existing/file', function onExists() { - throw new Error('boom!'); - }); - }); - }); - }, -]; - -if (process.argv[2] === 'child') { - const testIndex = +process.argv[3]; - tests[testIndex](); -} else { - - tests.forEach(function(test, testIndex) { - var testCmd = ''; - if (!common.isWindows) { - // Do not create core files, as it can take a lot of disk space on - // continuous testing and developers' machines - testCmd += 'ulimit -c 0 && '; - } - - testCmd += process.argv[0]; - testCmd += ' ' + '--abort-on-uncaught-exception'; - testCmd += ' ' + process.argv[1]; - testCmd += ' ' + 'child'; - testCmd += ' ' + testIndex; - - var child = child_process.exec(testCmd); - - child.on('exit', function onExit(exitCode, signal) { - const errMsg = 'Test at index ' + testIndex + ' should have aborted ' + - 'but instead exited with exit code ' + exitCode + - ' and signal ' + signal; - assert(common.nodeProcessAborted(exitCode, signal), errMsg); - }); - }); -} diff --git a/test/parallel/test-domain-safe-exit.js b/test/parallel/test-domain-safe-exit.js index 399ae37bcd94c5..bbc3b2fe22cae8 100644 --- a/test/parallel/test-domain-safe-exit.js +++ b/test/parallel/test-domain-safe-exit.js @@ -2,11 +2,11 @@ // Make sure the domain stack doesn't get clobbered by un-matched .exit() require('../common'); -var assert = require('assert'); -var domain = require('domain'); +const assert = require('assert'); +const domain = require('domain'); -var a = domain.create(); -var b = domain.create(); +const a = domain.create(); +const b = domain.create(); a.enter(); // push b.enter(); // push diff --git a/test/parallel/test-domain-stack.js b/test/parallel/test-domain-stack.js index e30d3b21f3af57..43152a4a3bb1c9 100644 --- a/test/parallel/test-domain-stack.js +++ b/test/parallel/test-domain-stack.js @@ -2,9 +2,9 @@ // Make sure that the domain stack doesn't get out of hand. require('../common'); -var domain = require('domain'); +const domain = require('domain'); -var a = domain.create(); +const a = domain.create(); a.name = 'a'; a.on('error', function() { @@ -14,11 +14,11 @@ a.on('error', function() { } }); -var foo = a.bind(function() { +const foo = a.bind(function() { throw new Error('error from foo'); }); -for (var i = 0; i < 1000; i++) { +for (let i = 0; i < 1000; i++) { process.nextTick(foo); } diff --git a/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js b/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js index fc6a93ccdca8ef..e35d247c3a8a34 100644 --- a/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js +++ b/test/parallel/test-domain-throw-error-then-throw-from-uncaught-exception-handler.js @@ -49,38 +49,39 @@ if (process.argv[2] === 'child') { } function runTestWithoutAbortOnUncaughtException() { - child_process.exec(createTestCmdLine(), - function onTestDone(err, stdout, stderr) { - // When _not_ passing --abort-on-uncaught-exception, the process' - // uncaughtException handler _must_ be called, and thus the error - // message must include only the message of the error thrown from the - // process' uncaughtException handler. - assert(stderr.includes(uncaughtExceptionHandlerErrMsg), - 'stderr output must include proper uncaughtException ' + - 'handler\'s error\'s message'); - assert(!stderr.includes(domainErrMsg), 'stderr output must not ' + - 'include domain\'s error\'s message'); - - assert.notEqual(err.code, 0, - 'child process should have exited with a non-zero ' + - 'exit code, but did not'); - }); + child_process.exec( + createTestCmdLine(), + function onTestDone(err, stdout, stderr) { + // When _not_ passing --abort-on-uncaught-exception, the process' + // uncaughtException handler _must_ be called, and thus the error + // message must include only the message of the error thrown from the + // process' uncaughtException handler. + assert(stderr.includes(uncaughtExceptionHandlerErrMsg), + 'stderr output must include proper uncaughtException ' + + 'handler\'s error\'s message'); + assert(!stderr.includes(domainErrMsg), + 'stderr output must not include domain\'s error\'s message'); + assert.notStrictEqual(err.code, 0, + 'child process should have exited with a ' + + 'non-zero exit code, but did not'); + } + ); } function runTestWithAbortOnUncaughtException() { child_process.exec(createTestCmdLine({ withAbortOnUncaughtException: true }), function onTestDone(err, stdout, stderr) { - assert.notEqual(err.code, RAN_UNCAUGHT_EXCEPTION_HANDLER_EXIT_CODE, - 'child process should not have run its uncaughtException ' + - 'event handler'); + assert.notStrictEqual(err.code, RAN_UNCAUGHT_EXCEPTION_HANDLER_EXIT_CODE, + 'child process should not have run its ' + + 'uncaughtException event handler'); assert(common.nodeProcessAborted(err.code, err.signal), 'process should have aborted, but did not'); }); } function createTestCmdLine(options) { - var testCmd = ''; + let testCmd = ''; if (!common.isWindows) { // Do not create core files, as it can take a lot of disk space on diff --git a/test/parallel/test-domain-timers.js b/test/parallel/test-domain-timers.js index d42afa7471791a..79bd300545bf96 100644 --- a/test/parallel/test-domain-timers.js +++ b/test/parallel/test-domain-timers.js @@ -1,11 +1,9 @@ 'use strict'; const common = require('../common'); -var domain = require('domain'); -var assert = require('assert'); +const domain = require('domain'); +const assert = require('assert'); -var timeout; - -var timeoutd = domain.create(); +const timeoutd = domain.create(); timeoutd.on('error', common.mustCall(function(e) { assert.strictEqual(e.message, 'Timeout UNREFd', @@ -19,7 +17,7 @@ timeoutd.run(function() { }, 0).unref(); }); -var immediated = domain.create(); +const immediated = domain.create(); immediated.on('error', common.mustCall(function(e) { assert.strictEqual(e.message, 'Immediate Error', @@ -32,4 +30,4 @@ immediated.run(function() { }); }); -timeout = setTimeout(function() {}, 10 * 1000); +const timeout = setTimeout(function() {}, 10 * 1000); diff --git a/test/parallel/test-domain-top-level-error-handler-throw.js b/test/parallel/test-domain-top-level-error-handler-throw.js index b65b94012393c6..53a73eac426232 100644 --- a/test/parallel/test-domain-top-level-error-handler-throw.js +++ b/test/parallel/test-domain-top-level-error-handler-throw.js @@ -13,8 +13,8 @@ const domainErrHandlerExMessage = 'exception from domain error handler'; const internalExMessage = 'You should NOT see me'; if (process.argv[2] === 'child') { - var domain = require('domain'); - var d = domain.create(); + const domain = require('domain'); + const d = domain.create(); d.on('error', function() { throw new Error(domainErrHandlerExMessage); @@ -26,11 +26,11 @@ if (process.argv[2] === 'child') { }); }); } else { - var fork = require('child_process').fork; - var assert = require('assert'); + const fork = require('child_process').fork; + const assert = require('assert'); - var child = fork(process.argv[1], ['child'], {silent: true}); - var stderrOutput = ''; + const child = fork(process.argv[1], ['child'], {silent: true}); + let stderrOutput = ''; if (child) { child.stderr.on('data', function onStderrData(data) { stderrOutput += data.toString(); @@ -45,8 +45,8 @@ if (process.argv[2] === 'child') { }); child.on('exit', function onChildExited(exitCode, signal) { - var expectedExitCode = 7; - var expectedSignal = null; + const expectedExitCode = 7; + const expectedSignal = null; assert.strictEqual(exitCode, expectedExitCode); assert.strictEqual(signal, expectedSignal); diff --git a/test/parallel/test-domain-uncaught-exception.js b/test/parallel/test-domain-uncaught-exception.js index 58df4ac59a7818..b13bf79b1a034b 100644 --- a/test/parallel/test-domain-uncaught-exception.js +++ b/test/parallel/test-domain-uncaught-exception.js @@ -9,7 +9,6 @@ */ const common = require('../common'); -const assert = require('assert'); const domain = require('domain'); const child_process = require('child_process'); @@ -184,17 +183,16 @@ if (process.argv[2] === 'child') { test.expectedMessages.forEach(function(expectedMessage) { if (test.messagesReceived === undefined || test.messagesReceived.indexOf(expectedMessage) === -1) - assert(false, 'test ' + test.fn.name + - ' should have sent message: ' + expectedMessage + - ' but didn\'t'); + common.fail('test ' + test.fn.name + ' should have sent message: ' + + expectedMessage + ' but didn\'t'); }); if (test.messagesReceived) { test.messagesReceived.forEach(function(receivedMessage) { if (test.expectedMessages.indexOf(receivedMessage) === -1) { - assert(false, 'test ' + test.fn.name + - ' should not have sent message: ' + receivedMessage + - ' but did'); + common.fail('test ' + test.fn.name + + ' should not have sent message: ' + receivedMessage + + ' but did'); } }); } diff --git a/test/parallel/test-domain-with-abort-on-uncaught-exception.js b/test/parallel/test-domain-with-abort-on-uncaught-exception.js index 6fb3912e5b8d9c..0da8f1368f7c98 100644 --- a/test/parallel/test-domain-with-abort-on-uncaught-exception.js +++ b/test/parallel/test-domain-with-abort-on-uncaught-exception.js @@ -29,8 +29,8 @@ const fs = require('fs'); const domainErrHandlerExMessage = 'exception from domain error handler'; if (process.argv[2] === 'child') { - var domain = require('domain'); - var d = domain.create(); + const domain = require('domain'); + const d = domain.create(); process.on('uncaughtException', function onUncaughtException() { // The process' uncaughtException event must not be emitted when @@ -80,7 +80,7 @@ if (process.argv[2] === 'child') { throw new Error('Error from domain.run callback'); }); } else { - var exec = require('child_process').exec; + const exec = require('child_process').exec; function testDomainExceptionHandling(cmdLineOption, options) { if (typeof cmdLineOption === 'object') { @@ -88,18 +88,18 @@ if (process.argv[2] === 'child') { cmdLineOption = undefined; } - var throwInDomainErrHandlerOpt; + let throwInDomainErrHandlerOpt; if (options.throwInDomainErrHandler) throwInDomainErrHandlerOpt = 'throwInDomainErrHandler'; - var cmdToExec = ''; + let cmdToExec = ''; if (!common.isWindows) { // Do not create core files, as it can take a lot of disk space on // continuous testing and developers' machines cmdToExec += 'ulimit -c 0 && '; } - var useTryCatchOpt; + let useTryCatchOpt; if (options.useTryCatch) useTryCatchOpt = 'useTryCatch'; @@ -112,7 +112,7 @@ if (process.argv[2] === 'child') { useTryCatchOpt ].join(' '); - var child = exec(cmdToExec); + const child = exec(cmdToExec); if (child) { child.on('exit', function onChildExited(exitCode, signal) { diff --git a/test/parallel/test-domain.js b/test/parallel/test-domain.js index 73ab3b96168930..11c14f3c011eb7 100644 --- a/test/parallel/test-domain.js +++ b/test/parallel/test-domain.js @@ -6,24 +6,24 @@ const assert = require('assert'); const domain = require('domain'); const events = require('events'); const fs = require('fs'); -var caught = 0; -var expectCaught = 0; +let caught = 0; +let expectCaught = 0; -var d = new domain.Domain(); -var e = new events.EventEmitter(); +const d = new domain.Domain(); +const e = new events.EventEmitter(); d.on('error', function(er) { console.error('caught', er && (er.message || er)); - var er_message = er.message; - var er_path = er.path; + let er_message = er.message; + let er_path = er.path; // On windows, error messages can contain full path names. If this is the // case, remove the directory part. if (typeof er_path === 'string') { - var slash = er_path.lastIndexOf('\\'); + const slash = er_path.lastIndexOf('\\'); if (slash !== -1) { - var dir = er_path.slice(0, slash + 1); + const dir = er_path.slice(0, slash + 1); er_path = er_path.replace(dir, ''); er_message = er_message.replace(dir, ''); } @@ -129,7 +129,7 @@ expectCaught++; // set up while in the scope of the d domain. d.run(function() { process.nextTick(function() { - var i = setInterval(function() { + const i = setInterval(function() { clearInterval(i); setTimeout(function() { fs.stat('this file does not exist', function(er, stat) { @@ -166,7 +166,7 @@ function fn() { throw new Error('This function should never be called!'); } -var bound = d.intercept(fn); +let bound = d.intercept(fn); bound(new Error('bound')); expectCaught++; @@ -210,7 +210,7 @@ expectCaught++; // implicit addition by being created within a domain-bound context. -var implicit; +let implicit; d.run(function() { implicit = new events.EventEmitter(); @@ -223,7 +223,7 @@ setTimeout(function() { expectCaught++; -var result = d.run(function() { +let result = d.run(function() { return 'return value'; }); assert.strictEqual(result, 'return value'); @@ -236,12 +236,12 @@ result = d.run(function(a, b) { assert.strictEqual(result, 'return value'); -var fst = fs.createReadStream('stream for nonexistent file'); +const fst = fs.createReadStream('stream for nonexistent file'); d.add(fst); expectCaught++; [42, null, , false, function() {}, 'string'].forEach(function(something) { - var d = new domain.Domain(); + const d = new domain.Domain(); d.run(function() { process.nextTick(function() { throw something; diff --git a/test/parallel/test-dsa-fips-invalid-key.js b/test/parallel/test-dsa-fips-invalid-key.js index ede3adab66c527..6055a9b4c47862 100644 --- a/test/parallel/test-dsa-fips-invalid-key.js +++ b/test/parallel/test-dsa-fips-invalid-key.js @@ -1,20 +1,20 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasFipsCrypto) { common.skip('node compiled without FIPS OpenSSL.'); return; } -var crypto = require('crypto'); -var fs = require('fs'); +const crypto = require('crypto'); +const fs = require('fs'); -var input = 'hello'; +const input = 'hello'; -var dsapri = fs.readFileSync(common.fixturesDir + +const dsapri = fs.readFileSync(common.fixturesDir + '/keys/dsa_private_1025.pem'); -var sign = crypto.createSign('DSS1'); +const sign = crypto.createSign('DSS1'); sign.update(input); assert.throws(function() { diff --git a/test/parallel/test-env-var-no-warnings.js b/test/parallel/test-env-var-no-warnings.js new file mode 100644 index 00000000000000..53b7d302683cf4 --- /dev/null +++ b/test/parallel/test-env-var-no-warnings.js @@ -0,0 +1,41 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const cp = require('child_process'); + +if (process.argv[2] === 'child') { + process.emitWarning('foo'); +} else { + function test(env) { + const cmd = `${process.execPath} ${__filename} child`; + + cp.exec(cmd, { env }, common.mustCall((err, stdout, stderr) => { + assert.strictEqual(err, null); + assert.strictEqual(stdout, ''); + + if (env.NODE_NO_WARNINGS === '1') + assert.strictEqual(stderr, ''); + else + assert(/Warning: foo$/.test(stderr.trim())); + })); + } + + test({}); + test(process.env); + test({ NODE_NO_WARNINGS: undefined }); + test({ NODE_NO_WARNINGS: null }); + test({ NODE_NO_WARNINGS: 'foo' }); + test({ NODE_NO_WARNINGS: true }); + test({ NODE_NO_WARNINGS: false }); + test({ NODE_NO_WARNINGS: {} }); + test({ NODE_NO_WARNINGS: [] }); + test({ NODE_NO_WARNINGS: function() {} }); + test({ NODE_NO_WARNINGS: 0 }); + test({ NODE_NO_WARNINGS: -1 }); + test({ NODE_NO_WARNINGS: '0' }); + test({ NODE_NO_WARNINGS: '01' }); + test({ NODE_NO_WARNINGS: '2' }); + // Don't test the number 1 because it will come through as a string in the + // the child process environment. + test({ NODE_NO_WARNINGS: '1' }); +} diff --git a/test/parallel/test-error-reporting.js b/test/parallel/test-error-reporting.js index 62525a5494d5a0..fa7332a67a482b 100644 --- a/test/parallel/test-error-reporting.js +++ b/test/parallel/test-error-reporting.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var exec = require('child_process').exec; -var path = require('path'); +const common = require('../common'); +const assert = require('assert'); +const exec = require('child_process').exec; +const path = require('path'); function errExec(script, callback) { - var cmd = '"' + process.argv[0] + '" "' + - path.join(common.fixturesDir, script) + '"'; + const cmd = '"' + process.argv[0] + '" "' + + path.join(common.fixturesDir, script) + '"'; return exec(cmd, function(err, stdout, stderr) { // There was some error assert.ok(err); diff --git a/test/parallel/test-event-emitter-check-listener-leaks.js b/test/parallel/test-event-emitter-check-listener-leaks.js index 18d2d065b8b1f4..5b9787f1b83bba 100644 --- a/test/parallel/test-event-emitter-check-listener-leaks.js +++ b/test/parallel/test-event-emitter-check-listener-leaks.js @@ -3,7 +3,7 @@ require('../common'); const assert = require('assert'); const events = require('events'); -var e = new events.EventEmitter(); +let e = new events.EventEmitter(); // default for (let i = 0; i < 10; i++) { diff --git a/test/parallel/test-event-emitter-errors.js b/test/parallel/test-event-emitter-errors.js index 3effb999b37e8c..2b4a93ae9808df 100644 --- a/test/parallel/test-event-emitter-errors.js +++ b/test/parallel/test-event-emitter-errors.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var EventEmitter = require('events'); -var assert = require('assert'); +const EventEmitter = require('events'); +const assert = require('assert'); -var EE = new EventEmitter(); +const EE = new EventEmitter(); assert.throws(function() { EE.emit('error', 'Accepts a string'); diff --git a/test/parallel/test-event-emitter-get-max-listeners.js b/test/parallel/test-event-emitter-get-max-listeners.js index 34ffee3600e5e9..9acc71fd7920e3 100644 --- a/test/parallel/test-event-emitter-get-max-listeners.js +++ b/test/parallel/test-event-emitter-get-max-listeners.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var EventEmitter = require('events'); +const assert = require('assert'); +const EventEmitter = require('events'); -var emitter = new EventEmitter(); +const emitter = new EventEmitter(); assert.strictEqual(emitter.getMaxListeners(), EventEmitter.defaultMaxListeners); @@ -14,6 +14,6 @@ emitter.setMaxListeners(3); assert.strictEqual(emitter.getMaxListeners(), 3); // https://github.com/nodejs/node/issues/523 - second call should not throw. -var recv = {}; +const recv = {}; EventEmitter.prototype.on.call(recv, 'event', function() {}); EventEmitter.prototype.on.call(recv, 'event', function() {}); diff --git a/test/parallel/test-event-emitter-listeners-side-effects.js b/test/parallel/test-event-emitter-listeners-side-effects.js index 906138af2367c3..022750da406500 100644 --- a/test/parallel/test-event-emitter-listeners-side-effects.js +++ b/test/parallel/test-event-emitter-listeners-side-effects.js @@ -1,12 +1,12 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var EventEmitter = require('events').EventEmitter; +const EventEmitter = require('events').EventEmitter; -var e = new EventEmitter(); -var fl; // foo listeners +const e = new EventEmitter(); +let fl; // foo listeners fl = e.listeners('foo'); assert(Array.isArray(fl)); diff --git a/test/parallel/test-event-emitter-method-names.js b/test/parallel/test-event-emitter-method-names.js index e268e229b06b5b..d0464b80a44fe1 100644 --- a/test/parallel/test-event-emitter-method-names.js +++ b/test/parallel/test-event-emitter-method-names.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var events = require('events'); +const assert = require('assert'); +const events = require('events'); -var E = events.EventEmitter.prototype; +const E = events.EventEmitter.prototype; assert.strictEqual(E.constructor.name, 'EventEmitter'); assert.strictEqual(E.on, E.addListener); // Same method. Object.getOwnPropertyNames(E).forEach(function(name) { diff --git a/test/parallel/test-event-emitter-modify-in-emit.js b/test/parallel/test-event-emitter-modify-in-emit.js index 7864438fff4df6..c13fad4347d617 100644 --- a/test/parallel/test-event-emitter-modify-in-emit.js +++ b/test/parallel/test-event-emitter-modify-in-emit.js @@ -3,7 +3,7 @@ require('../common'); const assert = require('assert'); const events = require('events'); -var callbacks_called = []; +let callbacks_called = []; const e = new events.EventEmitter(); @@ -25,27 +25,27 @@ function callback3() { } e.on('foo', callback1); -assert.equal(1, e.listeners('foo').length); +assert.strictEqual(e.listeners('foo').length, 1); e.emit('foo'); -assert.equal(2, e.listeners('foo').length); +assert.strictEqual(e.listeners('foo').length, 2); assert.deepStrictEqual(['callback1'], callbacks_called); e.emit('foo'); -assert.equal(0, e.listeners('foo').length); +assert.strictEqual(e.listeners('foo').length, 0); assert.deepStrictEqual(['callback1', 'callback2', 'callback3'], callbacks_called); e.emit('foo'); -assert.equal(0, e.listeners('foo').length); +assert.strictEqual(e.listeners('foo').length, 0); assert.deepStrictEqual(['callback1', 'callback2', 'callback3'], callbacks_called); e.on('foo', callback1); e.on('foo', callback2); -assert.equal(2, e.listeners('foo').length); +assert.strictEqual(e.listeners('foo').length, 2); e.removeAllListeners('foo'); -assert.equal(0, e.listeners('foo').length); +assert.strictEqual(e.listeners('foo').length, 0); // Verify that removing callbacks while in emit allows emits to propagate to // all listeners @@ -53,7 +53,7 @@ callbacks_called = []; e.on('foo', callback2); e.on('foo', callback3); -assert.equal(2, e.listeners('foo').length); +assert.strictEqual(2, e.listeners('foo').length); e.emit('foo'); assert.deepStrictEqual(['callback2', 'callback3'], callbacks_called); -assert.equal(0, e.listeners('foo').length); +assert.strictEqual(0, e.listeners('foo').length); diff --git a/test/parallel/test-event-emitter-no-error-provided-to-error-event.js b/test/parallel/test-event-emitter-no-error-provided-to-error-event.js index 0a3ecb33d6e697..3e7242915e1854 100644 --- a/test/parallel/test-event-emitter-no-error-provided-to-error-event.js +++ b/test/parallel/test-event-emitter-no-error-provided-to-error-event.js @@ -1,11 +1,11 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var events = require('events'); -var domain = require('domain'); -var e = new events.EventEmitter(); +const assert = require('assert'); +const events = require('events'); +const domain = require('domain'); +const e = new events.EventEmitter(); -var d = domain.create(); +const d = domain.create(); d.add(e); d.on('error', common.mustCall(function(er) { assert(er instanceof Error, 'error created'); diff --git a/test/parallel/test-event-emitter-num-args.js b/test/parallel/test-event-emitter-num-args.js index d858692aad338e..53ac0f79c20333 100644 --- a/test/parallel/test-event-emitter-num-args.js +++ b/test/parallel/test-event-emitter-num-args.js @@ -1,18 +1,23 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var events = require('events'); +const assert = require('assert'); +const events = require('events'); const e = new events.EventEmitter(); -const num_args_emited = []; +const num_args_emitted = []; e.on('numArgs', function() { - var numArgs = arguments.length; - console.log('numArgs: ' + numArgs); - num_args_emited.push(numArgs); + const numArgs = arguments.length; + num_args_emitted.push(numArgs); }); -console.log('start'); +e.on('foo', function() { + num_args_emitted.push(arguments.length); +}); + +e.on('foo', function() { + num_args_emitted.push(arguments.length); +}); e.emit('numArgs'); e.emit('numArgs', null); @@ -21,6 +26,8 @@ e.emit('numArgs', null, null, null); e.emit('numArgs', null, null, null, null); e.emit('numArgs', null, null, null, null, null); +e.emit('foo', null, null, null, null); + process.on('exit', function() { - assert.deepStrictEqual([0, 1, 2, 3, 4, 5], num_args_emited); + assert.deepStrictEqual([0, 1, 2, 3, 4, 5, 4, 4], num_args_emitted); }); diff --git a/test/parallel/test-event-emitter-once.js b/test/parallel/test-event-emitter-once.js index cca21a454b43bc..724b2ffd16aad1 100644 --- a/test/parallel/test-event-emitter-once.js +++ b/test/parallel/test-event-emitter-once.js @@ -12,7 +12,7 @@ e.emit('hello', 'a', 'b'); e.emit('hello', 'a', 'b'); e.emit('hello', 'a', 'b'); -var remove = function() { +const remove = function() { common.fail('once->foo should not be emitted'); }; diff --git a/test/parallel/test-event-emitter-prepend.js b/test/parallel/test-event-emitter-prepend.js index aa755a723c583e..b511af9ae3691d 100644 --- a/test/parallel/test-event-emitter-prepend.js +++ b/test/parallel/test-event-emitter-prepend.js @@ -5,15 +5,16 @@ const EventEmitter = require('events'); const assert = require('assert'); const myEE = new EventEmitter(); -var m = 0; +let m = 0; // This one comes last. -myEE.on('foo', common.mustCall(() => assert.equal(m, 2))); +myEE.on('foo', common.mustCall(() => assert.strictEqual(m, 2))); // This one comes second. -myEE.prependListener('foo', common.mustCall(() => assert.equal(m++, 1))); +myEE.prependListener('foo', common.mustCall(() => assert.strictEqual(m++, 1))); // This one comes first. -myEE.prependOnceListener('foo', common.mustCall(() => assert.equal(m++, 0))); +myEE.prependOnceListener('foo', + common.mustCall(() => assert.strictEqual(m++, 0))); myEE.emit('foo'); diff --git a/test/parallel/test-event-emitter-remove-all-listeners.js b/test/parallel/test-event-emitter-remove-all-listeners.js index e32a0e3f94f5b4..d7865b09abe9f5 100644 --- a/test/parallel/test-event-emitter-remove-all-listeners.js +++ b/test/parallel/test-event-emitter-remove-all-listeners.js @@ -39,8 +39,8 @@ function listener() {} assert.deepStrictEqual(bazListeners, [listener, listener]); // After calling removeAllListeners(), // new listeners arrays is different from the old. - assert.notEqual(ee.listeners('bar'), barListeners); - assert.notEqual(ee.listeners('baz'), bazListeners); + assert.notStrictEqual(ee.listeners('bar'), barListeners); + assert.notStrictEqual(ee.listeners('baz'), bazListeners); } { @@ -66,7 +66,7 @@ function listener() {} { const ee = new events.EventEmitter(); - var expectLength = 2; + let expectLength = 2; ee.on('removeListener', function(name, listener) { assert.strictEqual(expectLength--, this.listeners('baz').length); }); @@ -77,3 +77,8 @@ function listener() {} ee.removeAllListeners('baz'); assert.strictEqual(ee.listeners('baz').length, 0); } + +{ + const ee = new events.EventEmitter(); + assert.deepStrictEqual(ee, ee.removeAllListeners()); +} diff --git a/test/parallel/test-event-emitter-remove-listeners.js b/test/parallel/test-event-emitter-remove-listeners.js index ff5ee5dc242e0f..03bde6c3d7c4c9 100644 --- a/test/parallel/test-event-emitter-remove-listeners.js +++ b/test/parallel/test-event-emitter-remove-listeners.js @@ -116,6 +116,12 @@ function listener2() {} ee.emit('hello'); } +{ + const ee = new EventEmitter(); + + assert.deepStrictEqual(ee, ee.removeListener('foo', () => {})); +} + // Verify that the removed listener must be a function assert.throws(() => { const ee = new EventEmitter(); diff --git a/test/parallel/test-event-emitter-set-max-listeners-side-effects.js b/test/parallel/test-event-emitter-set-max-listeners-side-effects.js index cadaf3adc36014..5235d05638441b 100644 --- a/test/parallel/test-event-emitter-set-max-listeners-side-effects.js +++ b/test/parallel/test-event-emitter-set-max-listeners-side-effects.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var events = require('events'); +const assert = require('assert'); +const events = require('events'); -var e = new events.EventEmitter(); +const e = new events.EventEmitter(); assert(!(e._events instanceof Object)); assert.deepStrictEqual(Object.keys(e._events), []); diff --git a/test/parallel/test-event-emitter-special-event-names.js b/test/parallel/test-event-emitter-special-event-names.js index d71d819d3031b2..7ff781f0f90c5a 100644 --- a/test/parallel/test-event-emitter-special-event-names.js +++ b/test/parallel/test-event-emitter-special-event-names.js @@ -7,6 +7,8 @@ const assert = require('assert'); const ee = new EventEmitter(); const handler = () => {}; +assert.deepStrictEqual(ee.eventNames(), []); + assert.strictEqual(ee._events.hasOwnProperty, undefined); assert.strictEqual(ee._events.toString, undefined); diff --git a/test/parallel/test-event-emitter-subclass.js b/test/parallel/test-event-emitter-subclass.js index d2651defeeaa23..eb2018e78e4b85 100644 --- a/test/parallel/test-event-emitter-subclass.js +++ b/test/parallel/test-event-emitter-subclass.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var EventEmitter = require('events').EventEmitter; -var util = require('util'); +const assert = require('assert'); +const EventEmitter = require('events').EventEmitter; +const util = require('util'); util.inherits(MyEE, EventEmitter); @@ -13,7 +13,7 @@ function MyEE(cb) { EventEmitter.call(this); } -var myee = new MyEE(common.mustCall(function() {})); +const myee = new MyEE(common.mustCall(function() {})); util.inherits(ErrorEE, EventEmitter); @@ -38,9 +38,9 @@ function MyEE2() { MyEE2.prototype = new EventEmitter(); -var ee1 = new MyEE2(); -var ee2 = new MyEE2(); +const ee1 = new MyEE2(); +const ee2 = new MyEE2(); ee1.on('x', function() {}); -assert.equal(ee2.listenerCount('x'), 0); +assert.strictEqual(ee2.listenerCount('x'), 0); diff --git a/test/parallel/test-exception-handler.js b/test/parallel/test-exception-handler.js index e0e1b0086d9a7f..506fbaed0ebf63 100644 --- a/test/parallel/test-exception-handler.js +++ b/test/parallel/test-exception-handler.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var MESSAGE = 'catch me if you can'; +const MESSAGE = 'catch me if you can'; process.on('uncaughtException', common.mustCall(function(e) { console.log('uncaught exception! 1'); diff --git a/test/parallel/test-file-write-stream2.js b/test/parallel/test-file-write-stream2.js index 77e8119d25b8a7..504a572dde67d7 100644 --- a/test/parallel/test-file-write-stream2.js +++ b/test/parallel/test-file-write-stream2.js @@ -7,14 +7,13 @@ const fs = require('fs'); const filepath = path.join(common.tmpDir, 'write.txt'); -var file; const EXPECTED = '012345678910'; const cb_expected = 'write open drain write drain close error '; -var cb_occurred = ''; +let cb_occurred = ''; -var countDrains = 0; +let countDrains = 0; process.on('exit', function() { @@ -41,7 +40,7 @@ function removeTestFile() { common.refreshTmpDir(); // drain at 0, return false at 10. -file = fs.createWriteStream(filepath, { +const file = fs.createWriteStream(filepath, { highWaterMark: 11 }); @@ -80,7 +79,7 @@ file.on('error', function(err) { }); -for (var i = 0; i < 11; i++) { +for (let i = 0; i < 11; i++) { const ret = file.write(i + ''); console.error('%d %j', i, ret); diff --git a/test/parallel/test-force-repl-with-eval.js b/test/parallel/test-force-repl-with-eval.js index e5044ba59df4d5..8c75818508d17e 100644 --- a/test/parallel/test-force-repl-with-eval.js +++ b/test/parallel/test-force-repl-with-eval.js @@ -5,11 +5,11 @@ const spawn = require('child_process').spawn; // spawn a node child process in "interactive" mode (force the repl) and eval const cp = spawn(process.execPath, ['-i', '-e', 'console.log("42")']); -var gotToEnd = false; +let gotToEnd = false; cp.stdout.setEncoding('utf8'); -var output = ''; +let output = ''; cp.stdout.on('data', function(b) { output += b; if (output === '> 42\n') { diff --git a/test/parallel/test-force-repl.js b/test/parallel/test-force-repl.js index 37f2f603342a1c..5507d7401b72d3 100644 --- a/test/parallel/test-force-repl.js +++ b/test/parallel/test-force-repl.js @@ -5,7 +5,7 @@ const spawn = require('child_process').spawn; // spawn a node child process in "interactive" mode (force the repl) const cp = spawn(process.execPath, ['-i']); -var timeoutId = setTimeout(function() { +const timeoutId = setTimeout(function() { common.fail('timeout!'); }, common.platformTimeout(5000)); // give node + the repl 5 seconds to start diff --git a/test/parallel/test-freelist.js b/test/parallel/test-freelist.js index 65758bd7114de8..8ec7134dad0eb5 100644 --- a/test/parallel/test-freelist.js +++ b/test/parallel/test-freelist.js @@ -12,7 +12,7 @@ assert.strictEqual(typeof freelist.FreeList, 'function'); const flist1 = new freelist.FreeList('flist1', 3, String); // Allocating when empty, should not change the list size -var result = flist1.alloc('test'); +const result = flist1.alloc('test'); assert.strictEqual(typeof result, 'string'); assert.strictEqual(result, 'test'); assert.strictEqual(flist1.list.length, 0); diff --git a/test/parallel/test-fs-access.js b/test/parallel/test-fs-access.js index 6da26fe47beb92..4157f92f8b9021 100644 --- a/test/parallel/test-fs-access.js +++ b/test/parallel/test-fs-access.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); -var path = require('path'); -var doesNotExist = path.join(common.tmpDir, '__this_should_not_exist'); -var readOnlyFile = path.join(common.tmpDir, 'read_only_file'); -var readWriteFile = path.join(common.tmpDir, 'read_write_file'); - -var removeFile = function(file) { +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); +const doesNotExist = path.join(common.tmpDir, '__this_should_not_exist'); +const readOnlyFile = path.join(common.tmpDir, 'read_only_file'); +const readWriteFile = path.join(common.tmpDir, 'read_write_file'); + +const removeFile = function(file) { try { fs.unlinkSync(file); } catch (err) { @@ -15,7 +15,7 @@ var removeFile = function(file) { } }; -var createFileWithPerms = function(file, mode) { +const createFileWithPerms = function(file, mode) { removeFile(file); fs.writeFileSync(file, ''); fs.chmodSync(file, mode); @@ -48,7 +48,7 @@ createFileWithPerms(readWriteFile, 0o666); * id, but that's fine. In this case, it is the responsability of the * continuous integration platform to take care of that. */ -var hasWriteAccessForReadonlyFile = false; +let hasWriteAccessForReadonlyFile = false; if (!common.isWindows && process.getuid() === 0) { hasWriteAccessForReadonlyFile = true; try { @@ -63,62 +63,62 @@ assert.strictEqual(typeof fs.R_OK, 'number'); assert.strictEqual(typeof fs.W_OK, 'number'); assert.strictEqual(typeof fs.X_OK, 'number'); -fs.access(__filename, function(err) { - assert.strictEqual(err, null, 'error should not exist'); -}); +fs.access(__filename, common.mustCall((err) => { + assert.ifError(err); +})); -fs.access(__filename, fs.R_OK, function(err) { - assert.strictEqual(err, null, 'error should not exist'); -}); +fs.access(__filename, fs.R_OK, common.mustCall((err) => { + assert.ifError(err); +})); -fs.access(doesNotExist, function(err) { - assert.notEqual(err, null, 'error should exist'); +fs.access(doesNotExist, common.mustCall((err) => { + assert.notStrictEqual(err, null, 'error should exist'); assert.strictEqual(err.code, 'ENOENT'); assert.strictEqual(err.path, doesNotExist); -}); +})); -fs.access(readOnlyFile, fs.F_OK | fs.R_OK, function(err) { - assert.strictEqual(err, null, 'error should not exist'); -}); +fs.access(readOnlyFile, fs.F_OK | fs.R_OK, common.mustCall((err) => { + assert.ifError(err); +})); -fs.access(readOnlyFile, fs.W_OK, function(err) { +fs.access(readOnlyFile, fs.W_OK, common.mustCall((err) => { if (hasWriteAccessForReadonlyFile) { - assert.equal(err, null, 'error should not exist'); + assert.ifError(err); } else { - assert.notEqual(err, null, 'error should exist'); + assert.notStrictEqual(err, null, 'error should exist'); assert.strictEqual(err.path, readOnlyFile); } -}); +})); -assert.throws(function() { - fs.access(100, fs.F_OK, function(err) {}); +assert.throws(() => { + fs.access(100, fs.F_OK, (err) => {}); }, /path must be a string or Buffer/); -assert.throws(function() { +assert.throws(() => { fs.access(__filename, fs.F_OK); }, /"callback" argument must be a function/); -assert.throws(function() { +assert.throws(() => { fs.access(__filename, fs.F_OK, {}); }, /"callback" argument must be a function/); -assert.doesNotThrow(function() { +assert.doesNotThrow(() => { fs.accessSync(__filename); }); -assert.doesNotThrow(function() { - var mode = fs.F_OK | fs.R_OK | fs.W_OK; +assert.doesNotThrow(() => { + const mode = fs.F_OK | fs.R_OK | fs.W_OK; fs.accessSync(readWriteFile, mode); }); -assert.throws(function() { +assert.throws(() => { fs.accessSync(doesNotExist); -}, function(err) { +}, (err) => { return err.code === 'ENOENT' && err.path === doesNotExist; }); -process.on('exit', function() { +process.on('exit', () => { removeFile(readOnlyFile); removeFile(readWriteFile); }); diff --git a/test/parallel/test-fs-buffer.js b/test/parallel/test-fs-buffer.js index 6f142310f5e418..1452143a91c238 100644 --- a/test/parallel/test-fs-buffer.js +++ b/test/parallel/test-fs-buffer.js @@ -9,14 +9,14 @@ common.refreshTmpDir(); assert.doesNotThrow(() => { fs.access(Buffer.from(common.tmpDir), common.mustCall((err) => { - if (err) throw err; + assert.ifError(err); })); }); assert.doesNotThrow(() => { const buf = Buffer.from(path.join(common.tmpDir, 'a.txt')); fs.open(buf, 'w+', common.mustCall((err, fd) => { - if (err) throw err; + assert.ifError(err); assert(fd); fs.close(fd, common.mustCall(() => { fs.unlinkSync(buf); @@ -30,12 +30,12 @@ assert.throws(() => { const dir = Buffer.from(common.fixturesDir); fs.readdir(dir, 'hex', common.mustCall((err, list) => { - if (err) throw err; + assert.ifError(err); list = list.map((i) => { return Buffer.from(i, 'hex').toString(); }); fs.readdir(dir, common.mustCall((err, list2) => { - if (err) throw err; + assert.ifError(err); assert.deepStrictEqual(list, list2); })); })); diff --git a/test/parallel/test-fs-chmod.js b/test/parallel/test-fs-chmod.js index 2e5d839ae97720..5121fd89f99466 100644 --- a/test/parallel/test-fs-chmod.js +++ b/test/parallel/test-fs-chmod.js @@ -99,7 +99,7 @@ fs.open(file2, 'a', common.mustCall((err, fd) => { // lchmod if (fs.lchmod) { - var link = path.join(common.tmpDir, 'symbolic-link'); + const link = path.join(common.tmpDir, 'symbolic-link'); common.refreshTmpDir(); fs.symlinkSync(file2, link); diff --git a/test/parallel/test-fs-error-messages.js b/test/parallel/test-fs-error-messages.js index 1a05ef80a44a5c..f2ea85531bf463 100644 --- a/test/parallel/test-fs-error-messages.js +++ b/test/parallel/test-fs-error-messages.js @@ -12,7 +12,7 @@ const existingDir2 = path.join(common.fixturesDir, 'keys'); // ASYNC_CALL fs.stat(fn, function(err) { - assert.equal(fn, err.path); + assert.strictEqual(fn, err.path); assert.ok(0 <= err.message.indexOf(fn)); }); @@ -204,7 +204,7 @@ try { } process.on('exit', function() { - assert.equal(expected, errors.length, - 'Test fs sync exceptions raised, got ' + errors.length + + assert.strictEqual(expected, errors.length, + 'Test fs sync exceptions raised, got ' + errors.length + ' expected ' + expected); }); diff --git a/test/parallel/test-fs-exists.js b/test/parallel/test-fs-exists.js index 83e6adaf1100f7..14e1446f5a6d3d 100644 --- a/test/parallel/test-fs-exists.js +++ b/test/parallel/test-fs-exists.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); -var f = __filename; +const assert = require('assert'); +const fs = require('fs'); +const f = __filename; fs.exists(f, common.mustCall(function(y) { assert.strictEqual(y, true); diff --git a/test/parallel/test-fs-link.js b/test/parallel/test-fs-link.js index 2cba47bfec83df..d110ff80fe0341 100644 --- a/test/parallel/test-fs-link.js +++ b/test/parallel/test-fs-link.js @@ -12,7 +12,7 @@ const dstPath = path.join(common.tmpDir, 'link1.js'); fs.writeFileSync(srcPath, 'hello world'); const callback = function(err) { - if (err) throw err; + assert.ifError(err); const dstContent = fs.readFileSync(dstPath, 'utf8'); assert.strictEqual('hello world', dstContent); }; diff --git a/test/parallel/test-fs-long-path.js b/test/parallel/test-fs-long-path.js index 64585467ed6a77..8d22159e24bd79 100644 --- a/test/parallel/test-fs-long-path.js +++ b/test/parallel/test-fs-long-path.js @@ -1,7 +1,8 @@ 'use strict'; -var common = require('../common'); -var fs = require('fs'); -var path = require('path'); +const common = require('../common'); +const fs = require('fs'); +const path = require('path'); +const assert = require('assert'); if (!common.isWindows) { common.skip('this test is Windows-specific.'); @@ -9,9 +10,9 @@ if (!common.isWindows) { } // make a path that will be at least 260 chars long. -var fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1); -var fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x')); -var fullPath = path.resolve(fileName); +const fileNameLen = Math.max(260 - common.tmpDir.length - 1, 1); +const fileName = path.join(common.tmpDir, new Array(fileNameLen + 1).join('x')); +const fullPath = path.resolve(fileName); common.refreshTmpDir(); @@ -21,10 +22,10 @@ console.log({ }); fs.writeFile(fullPath, 'ok', common.mustCall(function(err) { - if (err) throw err; + assert.ifError(err); fs.stat(fullPath, common.mustCall(function(err, stats) { - if (err) throw err; + assert.ifError(err); })); })); diff --git a/test/parallel/test-fs-make-callback.js b/test/parallel/test-fs-make-callback.js index 6e4572ee352197..40c9aa42995f9a 100644 --- a/test/parallel/test-fs-make-callback.js +++ b/test/parallel/test-fs-make-callback.js @@ -2,6 +2,7 @@ const common = require('../common'); const assert = require('assert'); const fs = require('fs'); +const cbTypeError = /^TypeError: "callback" argument must be a function$/; function test(cb) { return function() { @@ -26,13 +27,13 @@ process.once('warning', common.mustCall((warning) => { assert.doesNotThrow(test()); function invalidArgumentsTests() { - assert.throws(test(null)); - assert.throws(test(true)); - assert.throws(test(false)); - assert.throws(test(1)); - assert.throws(test(0)); - assert.throws(test('foo')); - assert.throws(test(/foo/)); - assert.throws(test([])); - assert.throws(test({})); + assert.throws(test(null), cbTypeError); + assert.throws(test(true), cbTypeError); + assert.throws(test(false), cbTypeError); + assert.throws(test(1), cbTypeError); + assert.throws(test(0), cbTypeError); + assert.throws(test('foo'), cbTypeError); + assert.throws(test(/foo/), cbTypeError); + assert.throws(test([]), cbTypeError); + assert.throws(test({}), cbTypeError); } diff --git a/test/parallel/test-fs-mkdir-rmdir.js b/test/parallel/test-fs-mkdir-rmdir.js index 0bddf673ecb107..bac18fc027931d 100644 --- a/test/parallel/test-fs-mkdir-rmdir.js +++ b/test/parallel/test-fs-mkdir-rmdir.js @@ -29,8 +29,8 @@ fs.mkdir(d, 0o666, function(err) { fs.mkdir(d, 0o666, function(err) { assert.ok(err.message.match(/^EEXIST/), 'got EEXIST message'); - assert.equal(err.code, 'EEXIST', 'got EEXIST code'); - assert.equal(err.path, d, 'got proper path for EEXIST'); + assert.strictEqual(err.code, 'EEXIST', 'got EEXIST code'); + assert.strictEqual(err.path, d, 'got proper path for EEXIST'); fs.rmdir(d, assert.ifError); }); diff --git a/test/parallel/test-fs-mkdir.js b/test/parallel/test-fs-mkdir.js index 2b8e8b8f026637..73fc899ce57597 100644 --- a/test/parallel/test-fs-mkdir.js +++ b/test/parallel/test-fs-mkdir.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); function unlink(pathname) { try { @@ -33,8 +33,8 @@ common.refreshTmpDir(); unlink(pathname); fs.mkdir(pathname, 0o777, common.mustCall(function(err) { - assert.equal(err, null); - assert.equal(common.fileExists(pathname), true); + assert.strictEqual(err, null); + assert.strictEqual(common.fileExists(pathname), true); })); process.on('exit', function() { diff --git a/test/parallel/test-fs-mkdtemp.js b/test/parallel/test-fs-mkdtemp.js index c387090989c882..d4773aa37b7bf5 100644 --- a/test/parallel/test-fs-mkdtemp.js +++ b/test/parallel/test-fs-mkdtemp.js @@ -14,8 +14,8 @@ assert.strictEqual(path.basename(tmpFolder).length, 'foo.XXXXXX'.length); assert(common.fileExists(tmpFolder)); const utf8 = fs.mkdtempSync(path.join(common.tmpDir, '\u0222abc.')); -assert.equal(Buffer.byteLength(path.basename(utf8)), - Buffer.byteLength('\u0222abc.XXXXXX')); +assert.strictEqual(Buffer.byteLength(path.basename(utf8)), + Buffer.byteLength('\u0222abc.XXXXXX')); assert(common.fileExists(utf8)); function handler(err, folder) { diff --git a/test/parallel/test-fs-non-number-arguments-throw.js b/test/parallel/test-fs-non-number-arguments-throw.js index b13041ca3eecb6..3e40a5fd41be38 100644 --- a/test/parallel/test-fs-non-number-arguments-throw.js +++ b/test/parallel/test-fs-non-number-arguments-throw.js @@ -16,17 +16,17 @@ const saneEmitter = fs.createReadStream(tempFile, { start: 4, end: 6 }); assert.throws(function() { fs.createReadStream(tempFile, { start: '4', end: 6 }); }, /^TypeError: "start" option must be a Number$/, - "start as string didn't throw an error for createReadStream"); + "start as string didn't throw an error for createReadStream"); assert.throws(function() { fs.createReadStream(tempFile, { start: 4, end: '6' }); }, /^TypeError: "end" option must be a Number$/, - "end as string didn't throw an error for createReadStream"); + "end as string didn't throw an error for createReadStream"); assert.throws(function() { fs.createWriteStream(tempFile, { start: '4' }); }, /^TypeError: "start" option must be a Number$/, - "start as string didn't throw an error for createWriteStream"); + "start as string didn't throw an error for createWriteStream"); saneEmitter.on('data', common.mustCall(function(data) { assert.strictEqual(sanity, data.toString('utf8'), 'read ' + diff --git a/test/parallel/test-fs-null-bytes.js b/test/parallel/test-fs-null-bytes.js index 3c70d2953ca0f4..fa29e64c9b2382 100644 --- a/test/parallel/test-fs-null-bytes.js +++ b/test/parallel/test-fs-null-bytes.js @@ -1,19 +1,18 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); function check(async, sync) { - var expected = /Path must be a string without null bytes/; - var argsSync = Array.prototype.slice.call(arguments, 2); - var argsAsync = argsSync.concat(function(er) { + const expected = /Path must be a string without null bytes/; + const argsSync = Array.prototype.slice.call(arguments, 2); + const argsAsync = argsSync.concat((er) => { assert(er && er.message.match(expected)); - assert.equal(er.code, 'ENOENT'); + assert.strictEqual(er.code, 'ENOENT'); }); if (sync) - assert.throws(function() { - console.error(sync.name, argsSync); + assert.throws(() => { sync.apply(null, argsSync); }, expected); @@ -51,7 +50,7 @@ check(fs.writeFile, fs.writeFileSync, 'foo\u0000bar'); // an 'error' for exists means that it doesn't exist. // one of many reasons why this file is the absolute worst. -fs.exists('foo\u0000bar', function(exists) { +fs.exists('foo\u0000bar', common.mustCall((exists) => { assert(!exists); -}); +})); assert(!fs.existsSync('foo\u0000bar')); diff --git a/test/parallel/test-fs-open-flags.js b/test/parallel/test-fs-open-flags.js index ce7eaad580c008..ee3380691104a4 100644 --- a/test/parallel/test-fs-open-flags.js +++ b/test/parallel/test-fs-open-flags.js @@ -1,53 +1,63 @@ // Flags: --expose_internals 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var fs = require('fs'); +const fs = require('fs'); -var O_APPEND = fs.constants.O_APPEND || 0; -var O_CREAT = fs.constants.O_CREAT || 0; -var O_EXCL = fs.constants.O_EXCL || 0; -var O_RDONLY = fs.constants.O_RDONLY || 0; -var O_RDWR = fs.constants.O_RDWR || 0; -var O_TRUNC = fs.constants.O_TRUNC || 0; -var O_WRONLY = fs.constants.O_WRONLY || 0; +const O_APPEND = fs.constants.O_APPEND || 0; +const O_CREAT = fs.constants.O_CREAT || 0; +const O_EXCL = fs.constants.O_EXCL || 0; +const O_RDONLY = fs.constants.O_RDONLY || 0; +const O_RDWR = fs.constants.O_RDWR || 0; +const O_SYNC = fs.constants.O_SYNC || 0; +const O_TRUNC = fs.constants.O_TRUNC || 0; +const O_WRONLY = fs.constants.O_WRONLY || 0; const { stringToFlags } = require('internal/fs'); -assert.equal(stringToFlags('r'), O_RDONLY); -assert.equal(stringToFlags('r+'), O_RDWR); -assert.equal(stringToFlags('w'), O_TRUNC | O_CREAT | O_WRONLY); -assert.equal(stringToFlags('w+'), O_TRUNC | O_CREAT | O_RDWR); -assert.equal(stringToFlags('a'), O_APPEND | O_CREAT | O_WRONLY); -assert.equal(stringToFlags('a+'), O_APPEND | O_CREAT | O_RDWR); - -assert.equal(stringToFlags('wx'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL); -assert.equal(stringToFlags('xw'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL); -assert.equal(stringToFlags('wx+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL); -assert.equal(stringToFlags('xw+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL); -assert.equal(stringToFlags('ax'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL); -assert.equal(stringToFlags('xa'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL); -assert.equal(stringToFlags('ax+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL); -assert.equal(stringToFlags('xa+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL); +assert.strictEqual(stringToFlags('r'), O_RDONLY); +assert.strictEqual(stringToFlags('r+'), O_RDWR); +assert.strictEqual(stringToFlags('rs+'), O_RDWR | O_SYNC); +assert.strictEqual(stringToFlags('sr+'), O_RDWR | O_SYNC); +assert.strictEqual(stringToFlags('w'), O_TRUNC | O_CREAT | O_WRONLY); +assert.strictEqual(stringToFlags('w+'), O_TRUNC | O_CREAT | O_RDWR); +assert.strictEqual(stringToFlags('a'), O_APPEND | O_CREAT | O_WRONLY); +assert.strictEqual(stringToFlags('a+'), O_APPEND | O_CREAT | O_RDWR); + +assert.strictEqual(stringToFlags('wx'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL); +assert.strictEqual(stringToFlags('xw'), O_TRUNC | O_CREAT | O_WRONLY | O_EXCL); +assert.strictEqual(stringToFlags('wx+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL); +assert.strictEqual(stringToFlags('xw+'), O_TRUNC | O_CREAT | O_RDWR | O_EXCL); +assert.strictEqual(stringToFlags('ax'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL); +assert.strictEqual(stringToFlags('xa'), O_APPEND | O_CREAT | O_WRONLY | O_EXCL); +assert.strictEqual(stringToFlags('ax+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL); +assert.strictEqual(stringToFlags('xa+'), O_APPEND | O_CREAT | O_RDWR | O_EXCL); ('+ +a +r +w rw wa war raw r++ a++ w++ x +x x+ rx rx+ wxx wax xwx xxx') .split(' ') .forEach(function(flags) { - assert.throws(function() { stringToFlags(flags); }); + assert.throws( + () => stringToFlags(flags), + new RegExp(`^Error: Unknown file open flag: ${escapeRegExp(flags)}`) + ); }); assert.throws( () => stringToFlags({}), - /Unknown file open flag: \[object Object\]/ + /^Error: Unknown file open flag: \[object Object\]$/ ); assert.throws( () => stringToFlags(true), - /Unknown file open flag: true/ + /^Error: Unknown file open flag: true$/ ); assert.throws( () => stringToFlags(null), - /Unknown file open flag: null/ + /^Error: Unknown file open flag: null$/ ); + +function escapeRegExp(string) { + return string.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&'); +} diff --git a/test/parallel/test-fs-options-immutable.js b/test/parallel/test-fs-options-immutable.js index 47796a94a5e79e..185d14c4721d74 100644 --- a/test/parallel/test-fs-options-immutable.js +++ b/test/parallel/test-fs-options-immutable.js @@ -29,7 +29,7 @@ common.refreshTmpDir(); assert.doesNotThrow(() => fs.readdirSync(__dirname, options)); } -{ +if (common.canCreateSymLink()) { const sourceFile = path.resolve(common.tmpDir, 'test-readlink'); const linkFile = path.resolve(common.tmpDir, 'test-readlink-link'); diff --git a/test/parallel/test-fs-read-buffer-tostring-fail.js b/test/parallel/test-fs-read-buffer-tostring-fail.js index cce33edf4e6947..3ef058e4aa031e 100644 --- a/test/parallel/test-fs-read-buffer-tostring-fail.js +++ b/test/parallel/test-fs-read-buffer-tostring-fail.js @@ -14,7 +14,7 @@ const path = require('path'); const Buffer = require('buffer').Buffer; const kStringMaxLength = process.binding('buffer').kStringMaxLength; -var fd; +let fd; common.refreshTmpDir(); @@ -26,7 +26,7 @@ const stream = fs.createWriteStream(file, { const size = kStringMaxLength / 200; const a = Buffer.alloc(size, 'a'); -for (var i = 0; i < 201; i++) { +for (let i = 0; i < 201; i++) { stream.write(a); } diff --git a/test/parallel/test-fs-read-buffer-zero-length.js b/test/parallel/test-fs-read-buffer-zero-length.js index 35b1f7b566f685..4c7dd73f60ebb1 100644 --- a/test/parallel/test-fs-read-buffer-zero-length.js +++ b/test/parallel/test-fs-read-buffer-zero-length.js @@ -10,10 +10,10 @@ const bufferAsync = Buffer.alloc(0); const bufferSync = Buffer.alloc(0); fs.read(fd, bufferAsync, 0, 0, 0, common.mustCall(function(err, bytesRead) { - assert.equal(bytesRead, 0); + assert.strictEqual(bytesRead, 0); assert.deepStrictEqual(bufferAsync, Buffer.alloc(0)); })); const r = fs.readSync(fd, bufferSync, 0, 0, 0); assert.deepStrictEqual(bufferSync, Buffer.alloc(0)); -assert.equal(r, 0); +assert.strictEqual(r, 0); diff --git a/test/parallel/test-fs-read-buffer.js b/test/parallel/test-fs-read-buffer.js index 82fb3c284fb98a..733be5ba0db4c6 100644 --- a/test/parallel/test-fs-read-buffer.js +++ b/test/parallel/test-fs-read-buffer.js @@ -16,6 +16,7 @@ function test(bufferAsync, bufferSync, expected) { expected.length, 0, common.mustCall((err, bytesRead) => { + assert.ifError(err); assert.strictEqual(bytesRead, expected.length); assert.deepStrictEqual(bufferAsync, Buffer.from(expected)); })); diff --git a/test/parallel/test-fs-read-file-assert-encoding.js b/test/parallel/test-fs-read-file-assert-encoding.js new file mode 100644 index 00000000000000..897bcd3bc98795 --- /dev/null +++ b/test/parallel/test-fs-read-file-assert-encoding.js @@ -0,0 +1,13 @@ +'use strict'; +require('../common'); + +const assert = require('assert'); +const fs = require('fs'); + +const encoding = 'foo-8'; +const filename = 'bar.txt'; + +assert.throws( + fs.readFile.bind(fs, filename, { encoding }, () => {}), + new RegExp(`Error: Unknown encoding: ${encoding}$`) +); diff --git a/test/parallel/test-fs-read-stream-fd-leak.js b/test/parallel/test-fs-read-stream-fd-leak.js index 45847270097348..0a7a42a3bab3c1 100644 --- a/test/parallel/test-fs-read-stream-fd-leak.js +++ b/test/parallel/test-fs-read-stream-fd-leak.js @@ -5,7 +5,7 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); -var openCount = 0; +let openCount = 0; const _fsopen = fs.open; const _fsclose = fs.close; @@ -26,8 +26,8 @@ fs.close = function() { function testLeak(endFn, callback) { console.log('testing for leaks from fs.createReadStream().%s()...', endFn); - var i = 0; - var check = 0; + let i = 0; + let check = 0; const checkFunction = function() { if (openCount !== 0 && check < totalCheck) { diff --git a/test/parallel/test-fs-read-stream-fd.js b/test/parallel/test-fs-read-stream-fd.js index 5af5200e30eb68..a9ff56ee93fd91 100644 --- a/test/parallel/test-fs-read-stream-fd.js +++ b/test/parallel/test-fs-read-stream-fd.js @@ -1,23 +1,22 @@ 'use strict'; const common = require('../common'); -var fs = require('fs'); -var assert = require('assert'); -var path = require('path'); -var file = path.join(common.tmpDir, '/read_stream_fd_test.txt'); -var input = 'hello world'; -var output = ''; -var fd, stream; +const fs = require('fs'); +const assert = require('assert'); +const path = require('path'); +const file = path.join(common.tmpDir, '/read_stream_fd_test.txt'); +const input = 'hello world'; +let output = ''; common.refreshTmpDir(); fs.writeFileSync(file, input); -fd = fs.openSync(file, 'r'); -stream = fs.createReadStream(null, { fd: fd, encoding: 'utf8' }); -stream.on('data', function(data) { +const fd = fs.openSync(file, 'r'); +const stream = fs.createReadStream(null, { fd: fd, encoding: 'utf8' }); + +stream.on('data', (data) => { output += data; }); -process.on('exit', function() { - fs.unlinkSync(file); - assert.equal(output, input); +process.on('exit', () => { + assert.strictEqual(output, input); }); diff --git a/test/parallel/test-fs-read-stream-resume.js b/test/parallel/test-fs-read-stream-resume.js index 3ff89644e5c018..6c8b2c2421c8e3 100644 --- a/test/parallel/test-fs-read-stream-resume.js +++ b/test/parallel/test-fs-read-stream-resume.js @@ -9,7 +9,7 @@ const file = path.join(common.fixturesDir, 'x.txt'); let data = ''; let first = true; -var stream = fs.createReadStream(file); +const stream = fs.createReadStream(file); stream.setEncoding('utf8'); stream.on('data', function(chunk) { data += chunk; diff --git a/test/parallel/test-fs-read-stream.js b/test/parallel/test-fs-read-stream.js index c8da0275c53c9b..d17703fabe6a27 100644 --- a/test/parallel/test-fs-read-stream.js +++ b/test/parallel/test-fs-read-stream.js @@ -7,13 +7,13 @@ const fs = require('fs'); const fn = path.join(common.fixturesDir, 'elipses.txt'); const rangeFile = path.join(common.fixturesDir, 'x.txt'); -var callbacks = { open: 0, end: 0, close: 0 }; +const callbacks = { open: 0, end: 0, close: 0 }; -var paused = false; -var bytesRead = 0; +let paused = false; +let bytesRead = 0; -var file = fs.ReadStream(fn); -var fileSize = fs.statSync(fn).size; +const file = fs.ReadStream(fn); +const fileSize = fs.statSync(fn).size; assert.strictEqual(file.bytesRead, 0); @@ -61,16 +61,16 @@ file.on('close', function() { assert.strictEqual(file.bytesRead, fileSize); callbacks.close++; - //assert.equal(fs.readFileSync(fn), fileContent); + //assert.strictEqual(fs.readFileSync(fn), fileContent); }); -var file3 = fs.createReadStream(fn, {encoding: 'utf8'}); +const file3 = fs.createReadStream(fn, {encoding: 'utf8'}); file3.length = 0; file3.on('data', function(data) { assert.strictEqual('string', typeof data); file3.length += data.length; - for (var i = 0; i < data.length; i++) { + for (let i = 0; i < data.length; i++) { // http://www.fileformat.info/info/unicode/char/2026/index.htm assert.strictEqual('\u2026', data[i]); } @@ -89,8 +89,8 @@ process.on('exit', function() { console.error('ok'); }); -var file4 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1, end: 2}); -var contentRead = ''; +const file4 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1, end: 2}); +let contentRead = ''; file4.on('data', function(data) { contentRead += data.toString('utf-8'); }); @@ -98,7 +98,7 @@ file4.on('end', function(data) { assert.strictEqual(contentRead, 'yz'); }); -var file5 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1}); +const file5 = fs.createReadStream(rangeFile, {bufferSize: 1, start: 1}); file5.data = ''; file5.on('data', function(data) { file5.data += data.toString('utf-8'); @@ -108,7 +108,7 @@ file5.on('end', function() { }); // https://github.com/joyent/node/issues/2320 -var file6 = fs.createReadStream(rangeFile, {bufferSize: 1.23, start: 1}); +const file6 = fs.createReadStream(rangeFile, {bufferSize: 1.23, start: 1}); file6.data = ''; file6.on('data', function(data) { file6.data += data.toString('utf-8'); @@ -121,7 +121,7 @@ assert.throws(function() { fs.createReadStream(rangeFile, {start: 10, end: 2}); }, /"start" option must be <= "end" option/); -var stream = fs.createReadStream(rangeFile, { start: 0, end: 0 }); +const stream = fs.createReadStream(rangeFile, { start: 0, end: 0 }); stream.data = ''; stream.on('data', function(chunk) { @@ -133,11 +133,11 @@ stream.on('end', function() { }); // pause and then resume immediately. -var pauseRes = fs.createReadStream(rangeFile); +const pauseRes = fs.createReadStream(rangeFile); pauseRes.pause(); pauseRes.resume(); -var file7 = fs.createReadStream(rangeFile, {autoClose: false }); +let file7 = fs.createReadStream(rangeFile, {autoClose: false }); file7.on('data', function() {}); file7.on('end', function() { process.nextTick(function() { @@ -160,12 +160,12 @@ function file7Next() { } // Just to make sure autoClose won't close the stream because of error. -var file8 = fs.createReadStream(null, {fd: 13337, autoClose: false }); +const file8 = fs.createReadStream(null, {fd: 13337, autoClose: false }); file8.on('data', function() {}); file8.on('error', common.mustCall(function() {})); // Make sure stream is destroyed when file does not exist. -var file9 = fs.createReadStream('/path/to/file/that/does/not/exist'); +const file9 = fs.createReadStream('/path/to/file/that/does/not/exist'); file9.on('data', function() {}); file9.on('error', common.mustCall(function() {})); diff --git a/test/parallel/test-fs-read-zero-length.js b/test/parallel/test-fs-read-zero-length.js index 9c4cde52362ccc..a3e98f540a4151 100644 --- a/test/parallel/test-fs-read-zero-length.js +++ b/test/parallel/test-fs-read-zero-length.js @@ -7,12 +7,12 @@ const filepath = path.join(common.fixturesDir, 'x.txt'); const fd = fs.openSync(filepath, 'r'); const expected = ''; -fs.read(fd, 0, 0, 'utf-8', common.mustCall(function(err, str, bytesRead) { +fs.read(fd, 0, 0, 'utf-8', common.mustCall((err, str, bytesRead) => { assert.ok(!err); - assert.equal(str, expected); - assert.equal(bytesRead, 0); + assert.strictEqual(str, expected); + assert.strictEqual(bytesRead, 0); })); const r = fs.readSync(fd, 0, 0, 'utf-8'); -assert.equal(r[0], expected); -assert.equal(r[1], 0); +assert.strictEqual(r[0], expected); +assert.strictEqual(r[1], 0); diff --git a/test/parallel/test-fs-read.js b/test/parallel/test-fs-read.js index 41957c228ea944..06755c0d6e050f 100644 --- a/test/parallel/test-fs-read.js +++ b/test/parallel/test-fs-read.js @@ -17,6 +17,6 @@ fs.read(fd, assert.strictEqual(bytesRead, expected.length); })); -var r = fs.readSync(fd, expected.length, 0, 'utf-8'); +const r = fs.readSync(fd, expected.length, 0, 'utf-8'); assert.strictEqual(r[0], expected); assert.strictEqual(r[1], expected.length); diff --git a/test/parallel/test-fs-readdir-ucs2.js b/test/parallel/test-fs-readdir-ucs2.js index 916758fe943f86..4d5f53abd8ead9 100644 --- a/test/parallel/test-fs-readdir-ucs2.js +++ b/test/parallel/test-fs-readdir-ucs2.js @@ -19,8 +19,8 @@ const fullpath = Buffer.concat([root, filebuff]); fs.closeSync(fs.openSync(fullpath, 'w+')); fs.readdir(common.tmpDir, 'ucs2', (err, list) => { - if (err) throw err; - assert.equal(1, list.length); + assert.ifError(err); + assert.strictEqual(1, list.length); const fn = list[0]; assert.deepStrictEqual(filebuff, Buffer.from(fn, 'ucs2')); assert.strictEqual(fn, filename); diff --git a/test/parallel/test-fs-readdir.js b/test/parallel/test-fs-readdir.js index f38ae49c90a18f..57612f3e26b183 100644 --- a/test/parallel/test-fs-readdir.js +++ b/test/parallel/test-fs-readdir.js @@ -31,5 +31,5 @@ assert.throws(function() { }, /Error: ENOTDIR: not a directory/); fs.readdir(__filename, common.mustCall(function(e) { - assert.equal(e.code, 'ENOTDIR'); + assert.strictEqual(e.code, 'ENOTDIR'); })); diff --git a/test/parallel/test-fs-readfile-fd.js b/test/parallel/test-fs-readfile-fd.js index 6420dbfdd004e5..85fc6ebef5235d 100644 --- a/test/parallel/test-fs-readfile-fd.js +++ b/test/parallel/test-fs-readfile-fd.js @@ -29,18 +29,17 @@ tempFdSync(function(fd) { function tempFd(callback) { fs.open(fn, 'r', function(err, fd) { - if (err) throw err; - + assert.ifError(err); callback(fd, function() { fs.close(fd, function(err) { - if (err) throw err; + assert.ifError(err); }); }); }); } function tempFdSync(callback) { - var fd = fs.openSync(fn, 'r'); + const fd = fs.openSync(fn, 'r'); callback(fd); fs.closeSync(fd); } diff --git a/test/parallel/test-fs-readfile-pipe-large.js b/test/parallel/test-fs-readfile-pipe-large.js index 1b1523cb132e4c..926cc318c4f63a 100644 --- a/test/parallel/test-fs-readfile-pipe-large.js +++ b/test/parallel/test-fs-readfile-pipe-large.js @@ -14,7 +14,7 @@ const fs = require('fs'); if (process.argv[2] === 'child') { fs.readFile('/dev/stdin', function(er, data) { - if (er) throw er; + assert.ifError(er); process.stdout.write(data); }); return; @@ -30,8 +30,7 @@ const f = JSON.stringify(__filename); const node = JSON.stringify(process.execPath); const cmd = `cat ${filename} | ${node} ${f} child`; exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) { - if (err) console.error(err); - assert(!err, 'it exits normally'); + assert.ifError(err); assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it'); assert.strictEqual(stderr, '', 'it does not write to stderr'); console.log('ok'); diff --git a/test/parallel/test-fs-readfile-pipe.js b/test/parallel/test-fs-readfile-pipe.js index 54fb1fbe104fae..566dbbe4c84929 100644 --- a/test/parallel/test-fs-readfile-pipe.js +++ b/test/parallel/test-fs-readfile-pipe.js @@ -15,7 +15,7 @@ const dataExpected = fs.readFileSync(__filename, 'utf8'); if (process.argv[2] === 'child') { fs.readFile('/dev/stdin', function(er, data) { - if (er) throw er; + assert.ifError(er); process.stdout.write(data); }); return; @@ -26,8 +26,7 @@ const f = JSON.stringify(__filename); const node = JSON.stringify(process.execPath); const cmd = `cat ${f} | ${node} ${f} child`; exec(cmd, function(err, stdout, stderr) { - if (err) console.error(err); - assert(!err, 'it exits normally'); + assert.ifError(err); assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it'); assert.strictEqual(stderr, '', 'it does not write to stderr'); console.log('ok'); diff --git a/test/parallel/test-fs-readfile-zero-byte-liar.js b/test/parallel/test-fs-readfile-zero-byte-liar.js index 283a986f8a038a..82037a77e62122 100644 --- a/test/parallel/test-fs-readfile-zero-byte-liar.js +++ b/test/parallel/test-fs-readfile-zero-byte-liar.js @@ -1,31 +1,31 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const assert = require('assert'); +const fs = require('fs'); -var dataExpected = fs.readFileSync(__filename, 'utf8'); +const dataExpected = fs.readFileSync(__filename, 'utf8'); // sometimes stat returns size=0, but it's a lie. fs._fstat = fs.fstat; fs._fstatSync = fs.fstatSync; -fs.fstat = function(fd, cb) { - fs._fstat(fd, function(er, st) { +fs.fstat = (fd, cb) => { + fs._fstat(fd, (er, st) => { if (er) return cb(er); st.size = 0; return cb(er, st); }); }; -fs.fstatSync = function(fd) { - var st = fs._fstatSync(fd); +fs.fstatSync = (fd) => { + const st = fs._fstatSync(fd); st.size = 0; return st; }; -var d = fs.readFileSync(__filename, 'utf8'); -assert.equal(d, dataExpected); +const d = fs.readFileSync(__filename, 'utf8'); +assert.strictEqual(d, dataExpected); -fs.readFile(__filename, 'utf8', common.mustCall(function(er, d) { - assert.equal(d, dataExpected); +fs.readFile(__filename, 'utf8', common.mustCall((er, d) => { + assert.strictEqual(d, dataExpected); })); diff --git a/test/parallel/test-fs-readfilesync-pipe-large.js b/test/parallel/test-fs-readfilesync-pipe-large.js index 9108118b87e2e6..e791618b4999fe 100644 --- a/test/parallel/test-fs-readfilesync-pipe-large.js +++ b/test/parallel/test-fs-readfilesync-pipe-large.js @@ -27,8 +27,7 @@ const f = JSON.stringify(__filename); const node = JSON.stringify(process.execPath); const cmd = `cat ${filename} | ${node} ${f} child`; exec(cmd, { maxBuffer: 1000000 }, function(err, stdout, stderr) { - if (err) console.error(err); - assert(!err, 'it exits normally'); + assert.ifError(err); assert.strictEqual(stdout, dataExpected, 'it reads the file and outputs it'); assert.strictEqual(stderr, '', 'it does not write to stderr'); console.log('ok'); diff --git a/test/parallel/test-fs-realpath-buffer-encoding.js b/test/parallel/test-fs-realpath-buffer-encoding.js index 78ec02549bbd27..0ce6ec576dac69 100644 --- a/test/parallel/test-fs-realpath-buffer-encoding.js +++ b/test/parallel/test-fs-realpath-buffer-encoding.js @@ -8,14 +8,15 @@ const buffer_dir = Buffer.from(string_dir); const encodings = ['ascii', 'utf8', 'utf16le', 'ucs2', 'base64', 'binary', 'hex']; -var expected = {}; +const expected = {}; encodings.forEach((encoding) => { expected[encoding] = buffer_dir.toString(encoding); }); // test sync version -for (var encoding in expected) { +let encoding; +for (encoding in expected) { const expected_value = expected[encoding]; let result; @@ -50,39 +51,39 @@ for (encoding in expected) { const expected_value = expected[encoding]; fs.realpath(string_dir, {encoding: encoding}, common.mustCall((err, res) => { - assert(!err); + assert.ifError(err); assert.strictEqual(res, expected_value); })); fs.realpath(string_dir, encoding, common.mustCall((err, res) => { - assert(!err); + assert.ifError(err); assert.strictEqual(res, expected_value); })); fs.realpath(buffer_dir, {encoding: encoding}, common.mustCall((err, res) => { - assert(!err); + assert.ifError(err); assert.strictEqual(res, expected_value); })); fs.realpath(buffer_dir, encoding, common.mustCall((err, res) => { - assert(!err); + assert.ifError(err); assert.strictEqual(res, expected_value); })); } fs.realpath(string_dir, {encoding: 'buffer'}, common.mustCall((err, res) => { - assert(!err); + assert.ifError(err); assert.deepStrictEqual(res, buffer_dir); })); fs.realpath(string_dir, 'buffer', common.mustCall((err, res) => { - assert(!err); + assert.ifError(err); assert.deepStrictEqual(res, buffer_dir); })); fs.realpath(buffer_dir, {encoding: 'buffer'}, common.mustCall((err, res) => { - assert(!err); + assert.ifError(err); assert.deepStrictEqual(res, buffer_dir); })); fs.realpath(buffer_dir, 'buffer', common.mustCall((err, res) => { - assert(!err); + assert.ifError(err); assert.deepStrictEqual(res, buffer_dir); })); diff --git a/test/parallel/test-fs-realpath-on-substed-drive.js b/test/parallel/test-fs-realpath-on-substed-drive.js index c9109362691845..f8d9e86de5e618 100644 --- a/test/parallel/test-fs-realpath-on-substed-drive.js +++ b/test/parallel/test-fs-realpath-on-substed-drive.js @@ -14,7 +14,8 @@ let result; // create a subst drive const driveLetters = 'ABCDEFGHIJKLMNOPQRSTUWXYZ'; let drive; -for (var i = 0; i < driveLetters.length; ++i) { +let i; +for (i = 0; i < driveLetters.length; ++i) { drive = `${driveLetters[i]}:`; result = spawnSync('subst', [drive, common.fixturesDir]); if (result.status === 0) @@ -42,12 +43,12 @@ assert(Buffer.isBuffer(result)); assert(result.equals(filenameBuffer)); fs.realpath(filename, common.mustCall(function(err, result) { - assert(!err); + assert.ifError(err); assert.strictEqual(result, filename); })); fs.realpath(filename, 'buffer', common.mustCall(function(err, result) { - assert(!err); + assert.ifError(err); assert(Buffer.isBuffer(result)); assert(result.equals(filenameBuffer)); })); diff --git a/test/parallel/test-fs-realpath.js b/test/parallel/test-fs-realpath.js index dcaf8177c9499c..aeb48e1edb9d75 100644 --- a/test/parallel/test-fs-realpath.js +++ b/test/parallel/test-fs-realpath.js @@ -4,13 +4,14 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); const exec = require('child_process').exec; -var async_completed = 0, async_expected = 0, unlink = []; -var skipSymlinks = false; +let async_completed = 0, async_expected = 0; +const unlink = []; +let skipSymlinks = false; common.refreshTmpDir(); -var root = '/'; -var assertEqualPath = assert.strictEqual; +let root = '/'; +let assertEqualPath = assert.strictEqual; if (common.isWindows) { // something like "C:\\" root = process.cwd().substr(0, 3); @@ -54,7 +55,7 @@ fs.mkdirSync(path.join(targetsAbsDir, 'nested-index', 'two')); function asynctest(testBlock, args, callback, assertBlock) { async_expected++; testBlock.apply(testBlock, args.concat(function(err) { - var ignoreError = false; + let ignoreError = false; if (assertBlock) { try { ignoreError = assertBlock.apply(assertBlock, arguments); @@ -137,13 +138,13 @@ function test_deep_relative_file_symlink(callback) { .relative(path.join(targetsAbsDir, 'nested-index', 'one'), expected); const linkPath1 = path.join(targetsAbsDir, - 'nested-index', 'one', 'symlink1.js'); + 'nested-index', 'one', 'symlink1.js'); try { fs.unlinkSync(linkPath1); } catch (e) {} fs.symlinkSync(linkData1, linkPath1, 'file'); const linkData2 = '../one/symlink1.js'; const entry = path.join(targetsAbsDir, - 'nested-index', 'two', 'symlink1-b.js'); + 'nested-index', 'two', 'symlink1-b.js'); try { fs.unlinkSync(entry); } catch (e) {} fs.symlinkSync(linkData2, entry, 'file'); unlink.push(linkPath1); @@ -170,7 +171,7 @@ function test_deep_relative_dir_symlink(callback) { const linkData2b = '../one/symlink1-dir'; const entry = path.join(targetsAbsDir, - 'nested-index', 'two', 'symlink12-dir'); + 'nested-index', 'two', 'symlink12-dir'); try { fs.unlinkSync(entry); } catch (e) {} fs.symlinkSync(linkData2b, entry, 'dir'); unlink.push(linkPath1b); @@ -216,7 +217,7 @@ function test_cyclic_link_overprotection(callback) { const expected = fs.realpathSync(cycles); const folder = cycles + '/folder'; const link = folder + '/cycles'; - var testPath = cycles; + let testPath = cycles; testPath += '/folder/cycles'.repeat(10); try { fs.unlinkSync(link); } catch (ex) {} fs.symlinkSync(cycles, link, 'dir'); @@ -237,7 +238,7 @@ function test_relative_input_cwd(callback) { // we need to calculate the relative path to the tmp dir from cwd const entrydir = process.cwd(); const entry = path.relative(entrydir, - path.join(common.tmpDir + '/cycles/realpath-3a')); + path.join(common.tmpDir + '/cycles/realpath-3a')); const expected = common.tmpDir + '/cycles/root.js'; [ [entry, '../cycles/realpath-3b'], @@ -292,14 +293,14 @@ function test_deep_symlink_mix(callback) { [ [entry, common.tmpDir + '/node-test-realpath-d1/foo'], [tmp('node-test-realpath-d1'), - common.tmpDir + '/node-test-realpath-d2'], + common.tmpDir + '/node-test-realpath-d2'], [tmp('node-test-realpath-d2/foo'), '../node-test-realpath-f2'], [tmp('node-test-realpath-f2'), targetsAbsDir + '/nested-index/one/realpath-c'], [targetsAbsDir + '/nested-index/one/realpath-c', targetsAbsDir + '/nested-index/two/realpath-c'], [targetsAbsDir + '/nested-index/two/realpath-c', - common.tmpDir + '/cycles/root.js'] + common.tmpDir + '/cycles/root.js'] ].forEach(function(t) { try { fs.unlinkSync(t[0]); } catch (e) {} fs.symlinkSync(t[1], t[0]); @@ -361,7 +362,7 @@ function test_up_multiple(cb) { } function cleanup() { ['a/b', - 'a' + 'a' ].forEach(function(folder) { try { fs.rmdirSync(tmp(folder)); } catch (ex) {} }); @@ -386,10 +387,10 @@ function test_up_multiple(cb) { assertEqualPath(fs.realpathSync(abedabeda), abedabeda_real); assertEqualPath(fs.realpathSync(abedabed), abedabed_real); fs.realpath(abedabeda, function(er, real) { - if (er) throw er; + assert.ifError(er); assertEqualPath(abedabeda_real, real); fs.realpath(abedabed, function(er, real) { - if (er) throw er; + assert.ifError(er); assertEqualPath(abedabed_real, real); cb(); cleanup(); @@ -418,14 +419,14 @@ function test_abs_with_kids(cb) { const root = tmpAbsDir + '/node-test-realpath-abs-kids'; function cleanup() { ['/a/b/c/x.txt', - '/a/link' + '/a/link' ].forEach(function(file) { try { fs.unlinkSync(root + file); } catch (ex) {} }); ['/a/b/c', - '/a/b', - '/a', - '' + '/a/b', + '/a', + '' ].forEach(function(folder) { try { fs.rmdirSync(root + folder); } catch (ex) {} }); @@ -433,9 +434,9 @@ function test_abs_with_kids(cb) { function setup() { cleanup(); ['', - '/a', - '/a/b', - '/a/b/c' + '/a', + '/a/b', + '/a/b/c' ].forEach(function(folder) { console.log('mkdir ' + root + folder); fs.mkdirSync(root + folder, 0o700); @@ -474,9 +475,9 @@ const tests = [ test_up_multiple ]; const numtests = tests.length; -var testsRun = 0; +let testsRun = 0; function runNextTest(err) { - if (err) throw err; + assert.ifError(err); const test = tests.shift(); if (!test) { return console.log(numtests + @@ -507,6 +508,6 @@ function runTest() { process.on('exit', function() { - assert.equal(numtests, testsRun); - assert.equal(async_completed, async_expected); + assert.strictEqual(numtests, testsRun); + assert.strictEqual(async_completed, async_expected); }); diff --git a/test/parallel/test-fs-sir-writes-alot.js b/test/parallel/test-fs-sir-writes-alot.js index 8e1385ed4da2a0..7bf97ff1d5cba3 100644 --- a/test/parallel/test-fs-sir-writes-alot.js +++ b/test/parallel/test-fs-sir-writes-alot.js @@ -1,36 +1,38 @@ 'use strict'; -var common = require('../common'); -var fs = require('fs'); -var assert = require('assert'); -var join = require('path').join; +const common = require('../common'); +const fs = require('fs'); +const assert = require('assert'); +const join = require('path').join; -var filename = join(common.tmpDir, 'out.txt'); +const filename = join(common.tmpDir, 'out.txt'); common.refreshTmpDir(); -var fd = fs.openSync(filename, 'w'); +const fd = fs.openSync(filename, 'w'); -var line = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa\n'; +const line = 'aaaaaaaaaaaaaaaaaaaaaaaaaaaa\n'; -var N = 10240, complete = 0; -for (var i = 0; i < N; i++) { +const N = 10240; +let complete = 0; + +for (let i = 0; i < N; i++) { // Create a new buffer for each write. Before the write is actually // executed by the thread pool, the buffer will be collected. - var buffer = Buffer.from(line); + const buffer = Buffer.from(line); fs.write(fd, buffer, 0, buffer.length, null, function(er, written) { complete++; if (complete === N) { fs.closeSync(fd); - var s = fs.createReadStream(filename); + const s = fs.createReadStream(filename); s.on('data', testBuffer); } }); } -var bytesChecked = 0; +let bytesChecked = 0; function testBuffer(b) { - for (var i = 0; i < b.length; i++) { + for (let i = 0; i < b.length; i++) { bytesChecked++; if (b[i] !== 'a'.charCodeAt(0) && b[i] !== '\n'.charCodeAt(0)) { throw new Error('invalid char ' + i + ',' + b[i]); diff --git a/test/parallel/test-fs-stat.js b/test/parallel/test-fs-stat.js index 2c844452f05540..00fcc1df21c586 100644 --- a/test/parallel/test-fs-stat.js +++ b/test/parallel/test-fs-stat.js @@ -1,7 +1,7 @@ /* eslint-disable strict */ const common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const assert = require('assert'); +const fs = require('fs'); fs.stat('.', common.mustCall(function(err, stats) { assert.ifError(err); @@ -37,7 +37,7 @@ fs.open('.', 'r', undefined, common.mustCall(function(err, fd) { // fstatSync fs.open('.', 'r', undefined, common.mustCall(function(err, fd) { - var stats; + let stats; try { stats = fs.fstatSync(fd); } catch (err) { @@ -57,25 +57,25 @@ fs.stat(__filename, common.mustCall(function(err, s) { console.dir(s); console.log('isDirectory: ' + JSON.stringify(s.isDirectory())); - assert.equal(false, s.isDirectory()); + assert.strictEqual(false, s.isDirectory()); console.log('isFile: ' + JSON.stringify(s.isFile())); - assert.equal(true, s.isFile()); + assert.strictEqual(true, s.isFile()); console.log('isSocket: ' + JSON.stringify(s.isSocket())); - assert.equal(false, s.isSocket()); + assert.strictEqual(false, s.isSocket()); console.log('isBlockDevice: ' + JSON.stringify(s.isBlockDevice())); - assert.equal(false, s.isBlockDevice()); + assert.strictEqual(false, s.isBlockDevice()); console.log('isCharacterDevice: ' + JSON.stringify(s.isCharacterDevice())); - assert.equal(false, s.isCharacterDevice()); + assert.strictEqual(false, s.isCharacterDevice()); console.log('isFIFO: ' + JSON.stringify(s.isFIFO())); - assert.equal(false, s.isFIFO()); + assert.strictEqual(false, s.isFIFO()); console.log('isSymbolicLink: ' + JSON.stringify(s.isSymbolicLink())); - assert.equal(false, s.isSymbolicLink()); + assert.strictEqual(false, s.isSymbolicLink()); assert.ok(s.mtime instanceof Date); })); diff --git a/test/parallel/test-fs-stream-double-close.js b/test/parallel/test-fs-stream-double-close.js index df5010293729a3..ae6429a62b4f3c 100644 --- a/test/parallel/test-fs-stream-double-close.js +++ b/test/parallel/test-fs-stream-double-close.js @@ -1,6 +1,6 @@ 'use strict'; -var common = require('../common'); -var fs = require('fs'); +const common = require('../common'); +const fs = require('fs'); common.refreshTmpDir(); diff --git a/test/parallel/test-fs-symlink-dir-junction-relative.js b/test/parallel/test-fs-symlink-dir-junction-relative.js index d4e32c4b7eeb5a..3a2ba1a06c78db 100644 --- a/test/parallel/test-fs-symlink-dir-junction-relative.js +++ b/test/parallel/test-fs-symlink-dir-junction-relative.js @@ -1,21 +1,21 @@ 'use strict'; // Test creating and resolving relative junction or symbolic link -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); -var linkPath1 = path.join(common.tmpDir, 'junction1'); -var linkPath2 = path.join(common.tmpDir, 'junction2'); -var linkTarget = path.join(common.fixturesDir); -var linkData = path.join(common.fixturesDir); +const linkPath1 = path.join(common.tmpDir, 'junction1'); +const linkPath2 = path.join(common.tmpDir, 'junction2'); +const linkTarget = path.join(common.fixturesDir); +const linkData = path.join(common.fixturesDir); common.refreshTmpDir(); // Test fs.symlink() fs.symlink(linkData, linkPath1, 'junction', common.mustCall(function(err) { - if (err) throw err; + assert.ifError(err); verifyLink(linkPath1); })); @@ -24,11 +24,11 @@ fs.symlinkSync(linkData, linkPath2, 'junction'); verifyLink(linkPath2); function verifyLink(linkPath) { - var stats = fs.lstatSync(linkPath); + const stats = fs.lstatSync(linkPath); assert.ok(stats.isSymbolicLink()); - var data1 = fs.readFileSync(linkPath + '/x.txt', 'ascii'); - var data2 = fs.readFileSync(linkTarget + '/x.txt', 'ascii'); + const data1 = fs.readFileSync(linkPath + '/x.txt', 'ascii'); + const data2 = fs.readFileSync(linkTarget + '/x.txt', 'ascii'); assert.strictEqual(data1, data2); // Clean up. diff --git a/test/parallel/test-fs-symlink-dir-junction.js b/test/parallel/test-fs-symlink-dir-junction.js index 58ddb7ca38ae1c..ed0430b947ba0c 100644 --- a/test/parallel/test-fs-symlink-dir-junction.js +++ b/test/parallel/test-fs-symlink-dir-junction.js @@ -14,18 +14,18 @@ console.log('linkData: ' + linkData); console.log('linkPath: ' + linkPath); fs.symlink(linkData, linkPath, 'junction', common.mustCall(function(err) { - if (err) throw err; + assert.ifError(err); fs.lstat(linkPath, common.mustCall(function(err, stats) { - if (err) throw err; + assert.ifError(err); assert.ok(stats.isSymbolicLink()); fs.readlink(linkPath, common.mustCall(function(err, destination) { - if (err) throw err; + assert.ifError(err); assert.strictEqual(destination, linkData); fs.unlink(linkPath, common.mustCall(function(err) { - if (err) throw err; + assert.ifError(err); assert(!common.fileExists(linkPath)); assert(common.fileExists(linkData)); })); diff --git a/test/parallel/test-fs-symlink.js b/test/parallel/test-fs-symlink.js index ab52ba22923f3d..c8c6fc933d367b 100644 --- a/test/parallel/test-fs-symlink.js +++ b/test/parallel/test-fs-symlink.js @@ -3,20 +3,13 @@ const common = require('../common'); const assert = require('assert'); const path = require('path'); const fs = require('fs'); -const exec = require('child_process').exec; - -var linkTime; -var fileTime; - -if (common.isWindows) { - // On Windows, creating symlinks requires admin privileges. - // We'll only try to run symlink test if we have enough privileges. - exec('whoami /priv', function(err, o) { - if (err || !o.includes('SeCreateSymbolicLinkPrivilege')) { - common.skip('insufficient privileges'); - return; - } - }); + +let linkTime; +let fileTime; + +if (!common.canCreateSymLink()) { + common.skip('insufficient privileges'); + return; } common.refreshTmpDir(); diff --git a/test/parallel/test-fs-sync-fd-leak.js b/test/parallel/test-fs-sync-fd-leak.js index f7cfd25f4b9b4c..75125d6c679784 100644 --- a/test/parallel/test-fs-sync-fd-leak.js +++ b/test/parallel/test-fs-sync-fd-leak.js @@ -1,14 +1,14 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const assert = require('assert'); +const fs = require('fs'); // ensure that (read|write|append)FileSync() closes the file descriptor fs.openSync = function() { return 42; }; fs.closeSync = function(fd) { - assert.equal(fd, 42); + assert.strictEqual(fd, 42); close_called++; }; fs.readSync = function() { @@ -22,6 +22,7 @@ fs.fstatSync = function() { throw new Error('BAM'); }; +let close_called = 0; ensureThrows(function() { fs.readFileSync('dummy'); }); @@ -32,18 +33,17 @@ ensureThrows(function() { fs.appendFileSync('dummy', 'xxx'); }); -var close_called = 0; function ensureThrows(cb) { - var got_exception = false; + let got_exception = false; close_called = 0; try { cb(); } catch (e) { - assert.equal(e.message, 'BAM'); + assert.strictEqual(e.message, 'BAM'); got_exception = true; } - assert.equal(close_called, 1); - assert.equal(got_exception, true); + assert.strictEqual(close_called, 1); + assert.strictEqual(got_exception, true); } diff --git a/test/parallel/test-fs-truncate-GH-6233.js b/test/parallel/test-fs-truncate-GH-6233.js index acfdd1ccae1259..95eaf12cbb77f9 100644 --- a/test/parallel/test-fs-truncate-GH-6233.js +++ b/test/parallel/test-fs-truncate-GH-6233.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); -var filename = common.tmpDir + '/truncate-file.txt'; +const filename = common.tmpDir + '/truncate-file.txt'; common.refreshTmpDir(); diff --git a/test/parallel/test-fs-truncate-sync.js b/test/parallel/test-fs-truncate-sync.js new file mode 100644 index 00000000000000..a7ce2f4d97f3fe --- /dev/null +++ b/test/parallel/test-fs-truncate-sync.js @@ -0,0 +1,20 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); +const tmp = common.tmpDir; + +common.refreshTmpDir(); + +const filename = path.resolve(tmp, 'truncate-sync-file.txt'); + +fs.writeFileSync(filename, 'hello world', 'utf8'); + +const fd = fs.openSync(filename, 'r+'); + +fs.truncateSync(fd, 5); +assert(fs.readFileSync(fd).equals(Buffer.from('hello'))); + +fs.closeSync(fd); +fs.unlinkSync(filename); diff --git a/test/parallel/test-fs-truncate.js b/test/parallel/test-fs-truncate.js index 1ba0db7f012fe4..57d706bddbf8f6 100644 --- a/test/parallel/test-fs-truncate.js +++ b/test/parallel/test-fs-truncate.js @@ -43,9 +43,9 @@ fs.closeSync(fd); // async tests testTruncate(common.mustCall(function(er) { - if (er) throw er; + assert.ifError(er); testFtruncate(common.mustCall(function(er) { - if (er) throw er; + assert.ifError(er); })); })); @@ -146,3 +146,14 @@ function testFtruncate(cb) { assert(fs.readFileSync(file4).equals(Buffer.from('Hi\u0000\u0000'))); })); } + +{ + const file5 = path.resolve(tmp, 'truncate-file-5.txt'); + fs.writeFileSync(file5, 'Hi'); + const fd = fs.openSync(file5, 'r+'); + process.on('exit', () => fs.closeSync(fd)); + fs.ftruncate(fd, undefined, common.mustCall(function(err) { + assert.ifError(err); + assert(fs.readFileSync(file5).equals(Buffer.from(''))); + })); +} diff --git a/test/parallel/test-fs-utimes.js b/test/parallel/test-fs-utimes.js index f245a7962da0f4..b28a2b96e2075e 100644 --- a/test/parallel/test-fs-utimes.js +++ b/test/parallel/test-fs-utimes.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var util = require('util'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const util = require('util'); +const fs = require('fs'); -var tests_ok = 0; -var tests_run = 0; +let tests_ok = 0; +let tests_run = 0; function stat_resource(resource) { - if (typeof resource == 'string') { + if (typeof resource === 'string') { return fs.statSync(resource); } else { // ensure mtime has been written to disk @@ -19,8 +19,8 @@ function stat_resource(resource) { function check_mtime(resource, mtime) { mtime = fs._toUnixTimestamp(mtime); - var stats = stat_resource(resource); - var real_mtime = fs._toUnixTimestamp(stats.mtime); + const stats = stat_resource(resource); + const real_mtime = fs._toUnixTimestamp(stats.mtime); // check up to single-second precision // sub-second precision is OS and fs dependant return mtime - real_mtime < 2; @@ -46,9 +46,9 @@ function expect_ok(syscall, resource, err, atime, mtime) { // the tests assume that __filename belongs to the user running the tests // this should be a fairly safe assumption; testing against a temp file // would be even better though (node doesn't have such functionality yet) -function runTest(atime, mtime, callback) { +function testIt(atime, mtime, callback) { - var fd; + let fd; // // test synchronized code paths, these functions throw on failure // @@ -67,8 +67,7 @@ function runTest(atime, mtime, callback) { expect_errno('futimesSync', fd, ex, 'ENOSYS'); } - var err; - err = undefined; + let err = undefined; try { fs.utimesSync('foobarbaz', atime, mtime); } catch (ex) { @@ -90,10 +89,10 @@ function runTest(atime, mtime, callback) { // // test async code paths // - fs.utimes(__filename, atime, mtime, function(err) { + fs.utimes(__filename, atime, mtime, common.mustCall(function(err) { expect_ok('utimes', __filename, err, atime, mtime); - fs.utimes('foobarbaz', atime, mtime, function(err) { + fs.utimes('foobarbaz', atime, mtime, common.mustCall(function(err) { expect_errno('utimes', 'foobarbaz', err, 'ENOENT'); // don't close this fd @@ -103,34 +102,36 @@ function runTest(atime, mtime, callback) { fd = fs.openSync(__filename, 'r'); } - fs.futimes(fd, atime, mtime, function(err) { + fs.futimes(fd, atime, mtime, common.mustCall(function(err) { expect_ok('futimes', fd, err, atime, mtime); - fs.futimes(-1, atime, mtime, function(err) { + fs.futimes(-1, atime, mtime, common.mustCall(function(err) { expect_errno('futimes', -1, err, 'EBADF'); syncTests(); callback(); - }); + })); tests_run++; - }); + })); tests_run++; - }); + })); tests_run++; - }); + })); tests_run++; } -var stats = fs.statSync(__filename); +const stats = fs.statSync(__filename); // run tests +const runTest = common.mustCall(testIt, 6); + runTest(new Date('1982-09-10 13:37'), new Date('1982-09-10 13:37'), function() { runTest(new Date(), new Date(), function() { runTest(123456.789, 123456.789, function() { runTest(stats.mtime, stats.mtime, function() { runTest(NaN, Infinity, function() { - runTest('123456', -1, function() { + runTest('123456', -1, common.mustCall(function() { // done - }); + })); }); }); }); @@ -140,5 +141,5 @@ runTest(new Date('1982-09-10 13:37'), new Date('1982-09-10 13:37'), function() { process.on('exit', function() { console.log('Tests run / ok:', tests_run, '/', tests_ok); - assert.equal(tests_ok, tests_run); + assert.strictEqual(tests_ok, tests_run); }); diff --git a/test/parallel/test-fs-watch-enoent.js b/test/parallel/test-fs-watch-enoent.js index f9aa58c3d522cc..38f10e1430a360 100644 --- a/test/parallel/test-fs-watch-enoent.js +++ b/test/parallel/test-fs-watch-enoent.js @@ -8,7 +8,7 @@ assert.throws(function() { }, function(err) { assert(err); assert(/non-existent-file/.test(err)); - assert.equal(err.filename, 'non-existent-file'); + assert.strictEqual(err.filename, 'non-existent-file'); return true; }); @@ -16,6 +16,6 @@ const watcher = fs.watch(__filename); watcher.on('error', common.mustCall(function(err) { assert(err); assert(/non-existent-file/.test(err)); - assert.equal(err.filename, 'non-existent-file'); + assert.strictEqual(err.filename, 'non-existent-file'); })); watcher._handle.onchange(-1, 'ENOENT', 'non-existent-file'); diff --git a/test/parallel/test-fs-watch-recursive.js b/test/parallel/test-fs-watch-recursive.js index 97c65fccf4a1fb..5fb13623dff543 100644 --- a/test/parallel/test-fs-watch-recursive.js +++ b/test/parallel/test-fs-watch-recursive.js @@ -22,7 +22,7 @@ const filepathOne = path.join(testsubdir, filenameOne); const watcher = fs.watch(testDir, {recursive: true}); -var watcherClosed = false; +let watcherClosed = false; watcher.on('change', function(event, filename) { assert.ok('change' === event || 'rename' === event); @@ -37,8 +37,9 @@ watcher.on('change', function(event, filename) { watcherClosed = true; }); +let interval; if (common.isOSX) { - var interval = setInterval(function() { + interval = setInterval(function() { fs.writeFileSync(filepathOne, 'world'); }, 10); } else { diff --git a/test/parallel/test-fs-watch-stop-async.js b/test/parallel/test-fs-watch-stop-async.js index 5cbfd58418024a..56350430bc7912 100644 --- a/test/parallel/test-fs-watch-stop-async.js +++ b/test/parallel/test-fs-watch-stop-async.js @@ -12,8 +12,8 @@ const listener = common.mustCall(() => { triggered = false; watch.once('stop', listener); // Should trigger. watch.stop(); -assert.equal(triggered, false); +assert.strictEqual(triggered, false); setImmediate(() => { - assert.equal(triggered, true); + assert.strictEqual(triggered, true); watch.removeListener('stop', listener); }); diff --git a/test/parallel/test-fs-watchfile.js b/test/parallel/test-fs-watchfile.js index d30261859c39b7..fcd28be0c1f126 100644 --- a/test/parallel/test-fs-watchfile.js +++ b/test/parallel/test-fs-watchfile.js @@ -40,7 +40,7 @@ common.refreshTmpDir(); // If the file initially didn't exist, and gets created at a later point of // time, the callback should be invoked again with proper values in stat object -var fileExists = false; +let fileExists = false; fs.watchFile(enoentFile, {interval: 0}, common.mustCall(function(curr, prev) { if (!fileExists) { diff --git a/test/parallel/test-fs-write-buffer.js b/test/parallel/test-fs-write-buffer.js index 0e24f33872825f..89570314cc504c 100644 --- a/test/parallel/test-fs-write-buffer.js +++ b/test/parallel/test-fs-write-buffer.js @@ -10,17 +10,17 @@ common.refreshTmpDir(); // fs.write with all parameters provided: { const filename = path.join(common.tmpDir, 'write1.txt'); - fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) { + fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => { assert.ifError(err); - const cb = common.mustCall(function(err, written) { + const cb = common.mustCall((err, written) => { assert.ifError(err); assert.strictEqual(expected.length, written); fs.closeSync(fd); - var found = fs.readFileSync(filename, 'utf8'); - assert.deepStrictEqual(expected.toString(), found); + const found = fs.readFileSync(filename, 'utf8'); + assert.strictEqual(expected.toString(), found); }); fs.write(fd, expected, 0, expected.length, null, cb); @@ -30,17 +30,17 @@ common.refreshTmpDir(); // fs.write with a buffer, without the length parameter: { const filename = path.join(common.tmpDir, 'write2.txt'); - fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) { + fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => { assert.ifError(err); - const cb = common.mustCall(function(err, written) { + const cb = common.mustCall((err, written) => { assert.ifError(err); assert.strictEqual(2, written); fs.closeSync(fd); const found = fs.readFileSync(filename, 'utf8'); - assert.deepStrictEqual('lo', found); + assert.strictEqual('lo', found); }); fs.write(fd, Buffer.from('hello'), 3, cb); @@ -90,17 +90,17 @@ common.refreshTmpDir(); // fs.write with offset and length passed as undefined followed by the callback: { const filename = path.join(common.tmpDir, 'write5.txt'); - fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) { + fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => { assert.ifError(err); - const cb = common.mustCall(function(err, written) { + const cb = common.mustCall((err, written) => { assert.ifError(err); assert.strictEqual(expected.length, written); fs.closeSync(fd); const found = fs.readFileSync(filename, 'utf8'); - assert.deepStrictEqual(expected.toString(), found); + assert.strictEqual(expected.toString(), found); }); fs.write(fd, expected, undefined, undefined, cb); @@ -110,17 +110,17 @@ common.refreshTmpDir(); // fs.write with a Uint8Array, without the offset and length parameters: { const filename = path.join(common.tmpDir, 'write6.txt'); - fs.open(filename, 'w', 0o644, common.mustCall(function(err, fd) { + fs.open(filename, 'w', 0o644, common.mustCall((err, fd) => { assert.ifError(err); - const cb = common.mustCall(function(err, written) { + const cb = common.mustCall((err, written) => { assert.ifError(err); assert.strictEqual(expected.length, written); fs.closeSync(fd); const found = fs.readFileSync(filename, 'utf8'); - assert.deepStrictEqual(expected.toString(), found); + assert.strictEqual(expected.toString(), found); }); fs.write(fd, Uint8Array.from(expected), cb); diff --git a/test/parallel/test-fs-write-file-buffer.js b/test/parallel/test-fs-write-file-buffer.js index a23ccc21336976..409ddf1d51f557 100644 --- a/test/parallel/test-fs-write-file-buffer.js +++ b/test/parallel/test-fs-write-file-buffer.js @@ -1,10 +1,10 @@ 'use strict'; -var common = require('../common'); -var join = require('path').join; -var util = require('util'); -var fs = require('fs'); +const common = require('../common'); +const join = require('path').join; +const util = require('util'); +const fs = require('fs'); -var data = [ +let data = [ '/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcH', 'Bw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/', '2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4e', @@ -27,7 +27,7 @@ data = data.join('\n'); common.refreshTmpDir(); -var buf = Buffer.from(data, 'base64'); +const buf = Buffer.from(data, 'base64'); fs.writeFileSync(join(common.tmpDir, 'test.jpg'), buf); util.log('Done!'); diff --git a/test/parallel/test-fs-write-file-sync.js b/test/parallel/test-fs-write-file-sync.js index 7ae9e122cae8be..ca6324ac1ff789 100644 --- a/test/parallel/test-fs-write-file-sync.js +++ b/test/parallel/test-fs-write-file-sync.js @@ -1,11 +1,11 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); -var openCount = 0; -var mode; -var content; +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); +let openCount = 0; +let mode; +let content; // Need to hijack fs.open/close to make sure that things // get closed once they're opened. @@ -28,39 +28,39 @@ if (common.isWindows) { common.refreshTmpDir(); // Test writeFileSync -var file1 = path.join(common.tmpDir, 'testWriteFileSync.txt'); +const file1 = path.join(common.tmpDir, 'testWriteFileSync.txt'); fs.writeFileSync(file1, '123', {mode: mode}); content = fs.readFileSync(file1, {encoding: 'utf8'}); -assert.equal('123', content); +assert.strictEqual(content, '123'); -assert.equal(mode, fs.statSync(file1).mode & 0o777); +assert.strictEqual(fs.statSync(file1).mode & 0o777, mode); // Test appendFileSync -var file2 = path.join(common.tmpDir, 'testAppendFileSync.txt'); +const file2 = path.join(common.tmpDir, 'testAppendFileSync.txt'); fs.appendFileSync(file2, 'abc', {mode: mode}); content = fs.readFileSync(file2, {encoding: 'utf8'}); -assert.equal('abc', content); +assert.strictEqual(content, 'abc'); -assert.equal(mode, fs.statSync(file2).mode & mode); +assert.strictEqual(fs.statSync(file2).mode & mode, mode); // Test writeFileSync with file descriptor -var file3 = path.join(common.tmpDir, 'testWriteFileSyncFd.txt'); +const file3 = path.join(common.tmpDir, 'testWriteFileSyncFd.txt'); -var fd = fs.openSync(file3, 'w+', mode); +const fd = fs.openSync(file3, 'w+', mode); fs.writeFileSync(fd, '123'); fs.closeSync(fd); content = fs.readFileSync(file3, {encoding: 'utf8'}); -assert.equal('123', content); +assert.strictEqual(content, '123'); -assert.equal(mode, fs.statSync(file3).mode & 0o777); +assert.strictEqual(fs.statSync(file3).mode & 0o777, mode); // Verify that all opened files were closed. -assert.equal(0, openCount); +assert.strictEqual(openCount, 0); function openSync() { openCount++; diff --git a/test/parallel/test-fs-write-stream-autoclose-option.js b/test/parallel/test-fs-write-stream-autoclose-option.js index c7d21db2b4b531..4bfa4ba5341e1e 100644 --- a/test/parallel/test-fs-write-stream-autoclose-option.js +++ b/test/parallel/test-fs-write-stream-autoclose-option.js @@ -32,7 +32,7 @@ function next() { function next2() { // This will test if after reusing the fd data is written properly fs.readFile(file, function(err, data) { - assert(!err); + assert.ifError(err); assert.strictEqual(data.toString(), 'Test2'); process.nextTick(common.mustCall(next3)); }); diff --git a/test/parallel/test-fs-write-stream-change-open.js b/test/parallel/test-fs-write-stream-change-open.js index a9d31a3074dcd6..146b507a48ac61 100644 --- a/test/parallel/test-fs-write-stream-change-open.js +++ b/test/parallel/test-fs-write-stream-change-open.js @@ -4,7 +4,7 @@ const assert = require('assert'); const path = require('path'); const fs = require('fs'); -var file = path.join(common.tmpDir, 'write.txt'); +const file = path.join(common.tmpDir, 'write.txt'); common.refreshTmpDir(); @@ -29,5 +29,5 @@ stream.write('foo'); stream.end(); process.on('exit', function() { - assert.equal(fs.open, _fs_open); + assert.strictEqual(fs.open, _fs_open); }); diff --git a/test/parallel/test-fs-write-stream-end.js b/test/parallel/test-fs-write-stream-end.js index ade6777d5f68ac..6329aee4167d7b 100644 --- a/test/parallel/test-fs-write-stream-end.js +++ b/test/parallel/test-fs-write-stream-end.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); common.refreshTmpDir(); diff --git a/test/parallel/test-fs-write-stream-err.js b/test/parallel/test-fs-write-stream-err.js index c1151b12531f92..4a2b3cd130b4c4 100644 --- a/test/parallel/test-fs-write-stream-err.js +++ b/test/parallel/test-fs-write-stream-err.js @@ -1,17 +1,17 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); common.refreshTmpDir(); -var stream = fs.createWriteStream(common.tmpDir + '/out', { +const stream = fs.createWriteStream(common.tmpDir + '/out', { highWaterMark: 10 }); -var err = new Error('BAM'); +const err = new Error('BAM'); -var write = fs.write; -var writeCalls = 0; +const write = fs.write; +let writeCalls = 0; fs.write = function() { switch (writeCalls++) { case 0: @@ -21,7 +21,7 @@ fs.write = function() { case 1: // then it breaks console.error('second write'); - var cb = arguments[arguments.length - 1]; + const cb = arguments[arguments.length - 1]; return process.nextTick(function() { cb(err); }); @@ -33,14 +33,14 @@ fs.write = function() { fs.close = common.mustCall(function(fd_, cb) { console.error('fs.close', fd_, stream.fd); - assert.equal(fd_, stream.fd); + assert.strictEqual(fd_, stream.fd); process.nextTick(cb); }); stream.on('error', common.mustCall(function(err_) { console.error('error handler'); - assert.equal(stream.fd, null); - assert.equal(err_, err); + assert.strictEqual(stream.fd, null); + assert.strictEqual(err_, err); })); @@ -48,6 +48,6 @@ stream.write(Buffer.allocUnsafe(256), function() { console.error('first cb'); stream.write(Buffer.allocUnsafe(256), common.mustCall(function(err_) { console.error('second cb'); - assert.equal(err_, err); + assert.strictEqual(err_, err); })); }); diff --git a/test/parallel/test-fs-write-stream-throw-type-error.js b/test/parallel/test-fs-write-stream-throw-type-error.js index 996b22119cda5e..940def65b30b01 100644 --- a/test/parallel/test-fs-write-stream-throw-type-error.js +++ b/test/parallel/test-fs-write-stream-throw-type-error.js @@ -4,32 +4,44 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); +const numberError = new RegExp('^TypeError: "options" must be a string ' + + 'or an object, got number instead.$'); + +const booleanError = new RegExp('^TypeError: "options" must be a string ' + + 'or an object, got boolean instead.$'); + const example = path.join(common.tmpDir, 'dummy'); common.refreshTmpDir(); -assert.doesNotThrow(function() { +assert.doesNotThrow(() => { fs.createWriteStream(example, undefined); }); -assert.doesNotThrow(function() { + +assert.doesNotThrow(() => { fs.createWriteStream(example, null); }); -assert.doesNotThrow(function() { + +assert.doesNotThrow(() => { fs.createWriteStream(example, 'utf8'); }); -assert.doesNotThrow(function() { + +assert.doesNotThrow(() => { fs.createWriteStream(example, {encoding: 'utf8'}); }); -assert.throws(function() { +assert.throws(() => { fs.createWriteStream(example, 123); -}, /"options" must be a string or an object/); -assert.throws(function() { +}, numberError); + +assert.throws(() => { fs.createWriteStream(example, 0); -}, /"options" must be a string or an object/); -assert.throws(function() { +}, numberError); + +assert.throws(() => { fs.createWriteStream(example, true); -}, /"options" must be a string or an object/); -assert.throws(function() { +}, booleanError); + +assert.throws(() => { fs.createWriteStream(example, false); -}, /"options" must be a string or an object/); +}, booleanError); diff --git a/test/parallel/test-fs-write-stream.js b/test/parallel/test-fs-write-stream.js index 71aaaa75dd5845..a3ba0377e2e26e 100644 --- a/test/parallel/test-fs-write-stream.js +++ b/test/parallel/test-fs-write-stream.js @@ -4,7 +4,7 @@ const assert = require('assert'); const path = require('path'); const fs = require('fs'); -var file = path.join(common.tmpDir, 'write.txt'); +const file = path.join(common.tmpDir, 'write.txt'); common.refreshTmpDir(); diff --git a/test/parallel/test-fs-write-string-coerce.js b/test/parallel/test-fs-write-string-coerce.js index 5c7999e9b1158c..8251a45766f918 100644 --- a/test/parallel/test-fs-write-string-coerce.js +++ b/test/parallel/test-fs-write-string-coerce.js @@ -1,23 +1,23 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var Buffer = require('buffer').Buffer; -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const Buffer = require('buffer').Buffer; +const fs = require('fs'); common.refreshTmpDir(); -var fn = path.join(common.tmpDir, 'write-string-coerce.txt'); -var data = true; -var expected = data + ''; +const fn = path.join(common.tmpDir, 'write-string-coerce.txt'); +const data = true; +const expected = data + ''; fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) { - if (err) throw err; + assert.ifError(err); console.log('open done'); fs.write(fd, data, 0, 'utf8', common.mustCall(function(err, written) { console.log('write done'); - if (err) throw err; - assert.equal(Buffer.byteLength(expected), written); + assert.ifError(err); + assert.strictEqual(Buffer.byteLength(expected), written); fs.closeSync(fd); const found = fs.readFileSync(fn, 'utf8'); console.log('expected: "%s"', expected); diff --git a/test/parallel/test-fs-write.js b/test/parallel/test-fs-write.js index 9960a91a4f7515..81f5cf707bf00a 100644 --- a/test/parallel/test-fs-write.js +++ b/test/parallel/test-fs-write.js @@ -12,14 +12,14 @@ const constants = fs.constants; common.refreshTmpDir(); fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) { - if (err) throw err; + assert.ifError(err); console.log('open done'); fs.write(fd, '', 0, 'utf8', function(err, written) { assert.strictEqual(0, written); }); fs.write(fd, expected, 0, 'utf8', common.mustCall(function(err, written) { console.log('write done'); - if (err) throw err; + assert.ifError(err); assert.strictEqual(Buffer.byteLength(expected), written); fs.closeSync(fd); const found = fs.readFileSync(fn, 'utf8'); @@ -33,14 +33,14 @@ fs.open(fn, 'w', 0o644, common.mustCall(function(err, fd) { fs.open(fn2, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644, common.mustCall((err, fd) => { - if (err) throw err; + assert.ifError(err); console.log('open done'); fs.write(fd, '', 0, 'utf8', (err, written) => { assert.strictEqual(0, written); }); fs.write(fd, expected, 0, 'utf8', common.mustCall((err, written) => { console.log('write done'); - if (err) throw err; + assert.ifError(err); assert.strictEqual(Buffer.byteLength(expected), written); fs.closeSync(fd); const found = fs.readFileSync(fn2, 'utf8'); diff --git a/test/parallel/test-global-console-exists.js b/test/parallel/test-global-console-exists.js index 32e640cc52f7fc..d4a7c21222b807 100644 --- a/test/parallel/test-global-console-exists.js +++ b/test/parallel/test-global-console-exists.js @@ -9,7 +9,7 @@ const assert = require('assert'); const EventEmitter = require('events'); const leak_warning = /EventEmitter memory leak detected\. 2 hello listeners/; -var write_calls = 0; +let write_calls = 0; process.on('warning', (warning) => { // This will be called after the default internal diff --git a/test/parallel/test-global.js b/test/parallel/test-global.js index 270faf1b7768a6..d88f0895869997 100644 --- a/test/parallel/test-global.js +++ b/test/parallel/test-global.js @@ -15,8 +15,8 @@ assert.strictEqual('bar', baseBar, // eslint-disable-line no-undef 'global.x -> x in base level not working'); -var module = require(path.join(common.fixturesDir, 'global', 'plain')); -const fooBar = module.fooBar; +const mod = require(path.join(common.fixturesDir, 'global', 'plain')); +const fooBar = mod.fooBar; assert.strictEqual('foo', fooBar.foo, 'x -> global.x in sub level not working'); diff --git a/test/parallel/test-handle-wrap-close-abort.js b/test/parallel/test-handle-wrap-close-abort.js index 5355e65df60821..e9f69195ad29cd 100644 --- a/test/parallel/test-handle-wrap-close-abort.js +++ b/test/parallel/test-handle-wrap-close-abort.js @@ -13,4 +13,4 @@ setTimeout(function() { setTimeout(function() { throw new Error('setTimeout'); }, 1); -}); +}, 1); diff --git a/test/parallel/test-http-1.0-keep-alive.js b/test/parallel/test-http-1.0-keep-alive.js index 383f67c90a31b5..dea5f65c54184d 100644 --- a/test/parallel/test-http-1.0-keep-alive.js +++ b/test/parallel/test-http-1.0-keep-alive.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var http = require('http'); -var net = require('net'); +const http = require('http'); +const net = require('net'); // Check that our HTTP server correctly handles HTTP/1.0 keep-alive requests. check([{ @@ -83,12 +83,12 @@ check([{ }]); function check(tests) { - var test = tests[0]; - var server; + const test = tests[0]; + let server; if (test) { server = http.createServer(serverHandler).listen(0, '127.0.0.1', client); } - var current = 0; + let current = 0; function next() { check(tests.slice(1)); @@ -96,7 +96,7 @@ function check(tests) { function serverHandler(req, res) { if (current + 1 === test.responses.length) this.close(); - var ctx = test.responses[current]; + const ctx = test.responses[current]; console.error('< SERVER SENDING RESPONSE', ctx); res.writeHead(200, ctx.headers); ctx.chunks.slice(0, -1).forEach(function(chunk) { res.write(chunk); }); @@ -106,10 +106,10 @@ function check(tests) { function client() { if (current === test.requests.length) return next(); const port = server.address().port; - var conn = net.createConnection(port, '127.0.0.1', connected); + const conn = net.createConnection(port, '127.0.0.1', connected); function connected() { - var ctx = test.requests[current]; + const ctx = test.requests[current]; console.error(' > CLIENT SENDING REQUEST', ctx); conn.setEncoding('utf8'); conn.write(ctx.data); diff --git a/test/parallel/test-http-1.0.js b/test/parallel/test-http-1.0.js index d01613de45452d..d98da182a9fee5 100644 --- a/test/parallel/test-http-1.0.js +++ b/test/parallel/test-http-1.0.js @@ -1,20 +1,20 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); -var http = require('http'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); +const http = require('http'); -var body = 'hello world\n'; +const body = 'hello world\n'; function test(handler, request_generator, response_validator) { - var server = http.createServer(handler); + const server = http.createServer(handler); - var client_got_eof = false; - var server_response = ''; + let client_got_eof = false; + let server_response = ''; server.listen(0); server.on('listening', function() { - var c = net.createConnection(this.address().port); + const c = net.createConnection(this.address().port); c.setEncoding('utf8'); diff --git a/test/parallel/test-http-abort-before-end.js b/test/parallel/test-http-abort-before-end.js index ee22dc847b5882..046f439cb33195 100644 --- a/test/parallel/test-http-abort-before-end.js +++ b/test/parallel/test-http-abort-before-end.js @@ -1,12 +1,12 @@ 'use strict'; const common = require('../common'); -var http = require('http'); -var assert = require('assert'); +const http = require('http'); +const assert = require('assert'); -var server = http.createServer(common.fail); +const server = http.createServer(common.fail); server.listen(0, function() { - var req = http.request({ + const req = http.request({ method: 'GET', host: '127.0.0.1', port: this.address().port diff --git a/test/parallel/test-http-abort-client.js b/test/parallel/test-http-abort-client.js index addcec1ef3e9f9..6c00a1e6c64328 100644 --- a/test/parallel/test-http-abort-client.js +++ b/test/parallel/test-http-abort-client.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var http = require('http'); +const http = require('http'); -var server = http.Server(function(req, res) { +const server = http.Server(function(req, res) { console.log('Server accepted request.'); res.writeHead(200); res.write('Part of my res.'); diff --git a/test/parallel/test-http-abort-queued-2.js b/test/parallel/test-http-abort-queued-2.js new file mode 100644 index 00000000000000..77dc2a535b0e4f --- /dev/null +++ b/test/parallel/test-http-abort-queued-2.js @@ -0,0 +1,36 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); + +let socketsCreated = 0; + +class Agent extends http.Agent { + createConnection(options, oncreate) { + const socket = super.createConnection(options, oncreate); + socketsCreated++; + return socket; + } +} + +const server = http.createServer((req, res) => res.end()); + +server.listen(0, common.mustCall(() => { + const port = server.address().port; + const agent = new Agent({ + keepAlive: true, + maxSockets: 1 + }); + + http.get({agent, port}, (res) => res.resume()); + + const req = http.get({agent, port}, common.fail); + req.abort(); + + http.get({agent, port}, common.mustCall((res) => { + res.resume(); + assert.strictEqual(socketsCreated, 1); + agent.destroy(); + server.close(); + })); +})); diff --git a/test/parallel/test-http-abort-queued.js b/test/parallel/test-http-abort-queued.js index 0a993a2658ca11..60dde248df542c 100644 --- a/test/parallel/test-http-abort-queued.js +++ b/test/parallel/test-http-abort-queued.js @@ -3,12 +3,12 @@ require('../common'); const assert = require('assert'); const http = require('http'); -var complete; +let complete; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { // We should not see the queued /thatotherone request within the server // as it should be aborted before it is sent. - assert.equal(req.url, '/'); + assert.strictEqual(req.url, '/'); res.writeHead(200); res.write('foo'); @@ -22,10 +22,10 @@ var server = http.createServer(function(req, res) { server.listen(0, function() { console.log('listen', server.address().port); - var agent = new http.Agent({maxSockets: 1}); - assert.equal(Object.keys(agent.sockets).length, 0); + const agent = new http.Agent({maxSockets: 1}); + assert.strictEqual(Object.keys(agent.sockets).length, 0); - var options = { + const options = { hostname: 'localhost', port: server.address().port, method: 'GET', @@ -33,31 +33,31 @@ server.listen(0, function() { agent: agent }; - var req1 = http.request(options); + const req1 = http.request(options); req1.on('response', function(res1) { - assert.equal(Object.keys(agent.sockets).length, 1); - assert.equal(Object.keys(agent.requests).length, 0); + assert.strictEqual(Object.keys(agent.sockets).length, 1); + assert.strictEqual(Object.keys(agent.requests).length, 0); - var req2 = http.request({ + const req2 = http.request({ method: 'GET', host: 'localhost', port: server.address().port, path: '/thatotherone', agent: agent }); - assert.equal(Object.keys(agent.sockets).length, 1); - assert.equal(Object.keys(agent.requests).length, 1); + assert.strictEqual(Object.keys(agent.sockets).length, 1); + assert.strictEqual(Object.keys(agent.requests).length, 1); req2.on('error', function(err) { // This is expected in response to our explicit abort call - assert.equal(err.code, 'ECONNRESET'); + assert.strictEqual(err.code, 'ECONNRESET'); }); req2.end(); req2.abort(); - assert.equal(Object.keys(agent.sockets).length, 1); - assert.equal(Object.keys(agent.requests).length, 1); + assert.strictEqual(Object.keys(agent.sockets).length, 1); + assert.strictEqual(Object.keys(agent.requests).length, 1); console.log('Got res: ' + res1.statusCode); console.dir(res1.headers); @@ -72,8 +72,8 @@ server.listen(0, function() { console.log('Response ended.'); setTimeout(function() { - assert.equal(Object.keys(agent.sockets).length, 0); - assert.equal(Object.keys(agent.requests).length, 0); + assert.strictEqual(Object.keys(agent.sockets).length, 0); + assert.strictEqual(Object.keys(agent.requests).length, 0); server.close(); }, 100); diff --git a/test/parallel/test-http-after-connect.js b/test/parallel/test-http-after-connect.js index 0580f428ed70f5..a93d0b83aa6f4f 100644 --- a/test/parallel/test-http-after-connect.js +++ b/test/parallel/test-http-after-connect.js @@ -3,7 +3,7 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); -var clientResponses = 0; +let clientResponses = 0; const server = http.createServer(common.mustCall(function(req, res) { console.error('Server got GET request'); @@ -46,7 +46,7 @@ function doRequest(i) { path: '/request' + i }, common.mustCall(function(res) { console.error('Client got GET response'); - var data = ''; + let data = ''; res.setEncoding('utf8'); res.on('data', function(chunk) { data += chunk; diff --git a/test/parallel/test-http-agent-destroyed-socket.js b/test/parallel/test-http-agent-destroyed-socket.js index a2693637728439..d983d447934e41 100644 --- a/test/parallel/test-http-agent-destroyed-socket.js +++ b/test/parallel/test-http-agent-destroyed-socket.js @@ -1,28 +1,28 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(0, function() { - var agent = new http.Agent({maxSockets: 1}); + const agent = new http.Agent({maxSockets: 1}); agent.on('free', function(socket, host, port) { console.log('freeing socket. destroyed? ', socket.destroyed); }); - var requestOptions = { + const requestOptions = { agent: agent, host: 'localhost', port: this.address().port, path: '/' }; - var request1 = http.get(requestOptions, function(response) { + const request1 = http.get(requestOptions, function(response) { // assert request2 is queued in the agent - var key = agent.getName(requestOptions); + const key = agent.getName(requestOptions); assert.strictEqual(agent.requests[key].length, 1); console.log('got response1'); request1.socket.on('close', function() { @@ -58,14 +58,14 @@ var server = http.createServer(function(req, res) { }); }); - var request2 = http.get(requestOptions, function(response) { + const request2 = http.get(requestOptions, function(response) { assert(!request2.socket.destroyed); assert(request1.socket.destroyed); // assert not reusing the same socket, since it was destroyed. assert.notStrictEqual(request1.socket, request2.socket); console.log('got response2'); - var gotClose = false; - var gotResponseEnd = false; + let gotClose = false; + let gotResponseEnd = false; request2.socket.on('close', function() { console.log('request2 socket closed'); gotClose = true; diff --git a/test/parallel/test-http-agent-error-on-idle.js b/test/parallel/test-http-agent-error-on-idle.js index 59b0109ef1c398..23fa4dddfab57c 100644 --- a/test/parallel/test-http-agent-error-on-idle.js +++ b/test/parallel/test-http-agent-error-on-idle.js @@ -1,38 +1,38 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var Agent = http.Agent; +const assert = require('assert'); +const http = require('http'); +const Agent = http.Agent; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.end('hello world'); }); server.listen(0, function() { - var agent = new Agent({ + const agent = new Agent({ keepAlive: true, }); - var requestParams = { + const requestParams = { host: 'localhost', port: this.address().port, agent: agent, path: '/' }; - var socketKey = agent.getName(requestParams); + const socketKey = agent.getName(requestParams); get(function(res) { - assert.equal(res.statusCode, 200); + assert.strictEqual(res.statusCode, 200); res.resume(); res.on('end', function() { process.nextTick(function() { - var freeSockets = agent.freeSockets[socketKey]; - assert.equal(freeSockets.length, 1, - 'expect a free socket on ' + socketKey); + const freeSockets = agent.freeSockets[socketKey]; + assert.strictEqual(freeSockets.length, 1, + 'expect a free socket on ' + socketKey); //generate a random error on the free socket - var freeSocket = freeSockets[0]; + const freeSocket = freeSockets[0]; freeSocket.emit('error', new Error('ECONNRESET: test')); get(done); @@ -45,8 +45,8 @@ server.listen(0, function() { } function done() { - assert.equal(Object.keys(agent.freeSockets).length, 0, - 'expect the freeSockets pool to be empty'); + assert.strictEqual(Object.keys(agent.freeSockets).length, 0, + 'expect the freeSockets pool to be empty'); agent.destroy(); server.close(); diff --git a/test/parallel/test-http-agent-false.js b/test/parallel/test-http-agent-false.js index 96606028bf7a45..5c9907bb706d32 100644 --- a/test/parallel/test-http-agent-false.js +++ b/test/parallel/test-http-agent-false.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); // sending `agent: false` when `port: null` is also passed in (i.e. the result // of a `url.parse()` call with the default port used, 80 or 443), should not // result in an assertion error... -var opts = { +const opts = { host: '127.0.0.1', port: null, path: '/', @@ -14,7 +14,7 @@ var opts = { agent: false }; -var good = false; +let good = false; process.on('exit', function() { assert(good, 'expected either an "error" or "response" event'); }); @@ -22,7 +22,7 @@ process.on('exit', function() { // we just want an "error" (no local HTTP server on port 80) or "response" // to happen (user happens ot have HTTP server running on port 80). // As long as the process doesn't crash from a C++ assertion then we're good. -var req = http.request(opts); +const req = http.request(opts); req.on('response', function(res) { good = true; }); diff --git a/test/parallel/test-http-agent-keepalive.js b/test/parallel/test-http-agent-keepalive.js index a78f97edec1fdc..9ea3fd7677aebe 100644 --- a/test/parallel/test-http-agent-keepalive.js +++ b/test/parallel/test-http-agent-keepalive.js @@ -37,22 +37,22 @@ function get(path, callback) { } function checkDataAndSockets(body) { - assert.equal(body.toString(), 'hello world'); - assert.equal(agent.sockets[name].length, 1); - assert.equal(agent.freeSockets[name], undefined); + assert.strictEqual(body.toString(), 'hello world'); + assert.strictEqual(agent.sockets[name].length, 1); + assert.strictEqual(agent.freeSockets[name], undefined); } function second() { // request second, use the same socket get('/second', function(res) { - assert.equal(res.statusCode, 200); + assert.strictEqual(res.statusCode, 200); res.on('data', checkDataAndSockets); res.on('end', function() { - assert.equal(agent.sockets[name].length, 1); - assert.equal(agent.freeSockets[name], undefined); + assert.strictEqual(agent.sockets[name].length, 1); + assert.strictEqual(agent.freeSockets[name], undefined); process.nextTick(function() { - assert.equal(agent.sockets[name], undefined); - assert.equal(agent.freeSockets[name].length, 1); + assert.strictEqual(agent.sockets[name], undefined); + assert.strictEqual(agent.freeSockets[name].length, 1); remoteClose(); }); }); @@ -65,16 +65,16 @@ function remoteClose() { assert.deepStrictEqual(res.statusCode, 200); res.on('data', checkDataAndSockets); res.on('end', function() { - assert.equal(agent.sockets[name].length, 1); - assert.equal(agent.freeSockets[name], undefined); + assert.strictEqual(agent.sockets[name].length, 1); + assert.strictEqual(agent.freeSockets[name], undefined); process.nextTick(function() { - assert.equal(agent.sockets[name], undefined); - assert.equal(agent.freeSockets[name].length, 1); + assert.strictEqual(agent.sockets[name], undefined); + assert.strictEqual(agent.freeSockets[name].length, 1); // waitting remote server close the socket setTimeout(function() { - assert.equal(agent.sockets[name], undefined); - assert.equal(agent.freeSockets[name], undefined, - 'freeSockets is not empty'); + assert.strictEqual(agent.sockets[name], undefined); + assert.strictEqual(agent.freeSockets[name], undefined, + 'freeSockets is not empty'); remoteError(); }, common.platformTimeout(200)); }); @@ -89,13 +89,13 @@ function remoteError() { }); req.on('error', function(err) { assert.ok(err); - assert.equal(err.message, 'socket hang up'); - assert.equal(agent.sockets[name].length, 1); - assert.equal(agent.freeSockets[name], undefined); + assert.strictEqual(err.message, 'socket hang up'); + assert.strictEqual(agent.sockets[name].length, 1); + assert.strictEqual(agent.freeSockets[name], undefined); // Wait socket 'close' event emit setTimeout(function() { - assert.equal(agent.sockets[name], undefined); - assert.equal(agent.freeSockets[name], undefined); + assert.strictEqual(agent.sockets[name], undefined); + assert.strictEqual(agent.freeSockets[name], undefined); done(); }, common.platformTimeout(1)); }); @@ -110,14 +110,14 @@ server.listen(0, function() { name = `localhost:${server.address().port}:`; // request first, and keep alive get('/first', function(res) { - assert.equal(res.statusCode, 200); + assert.strictEqual(res.statusCode, 200); res.on('data', checkDataAndSockets); res.on('end', function() { - assert.equal(agent.sockets[name].length, 1); - assert.equal(agent.freeSockets[name], undefined); + assert.strictEqual(agent.sockets[name].length, 1); + assert.strictEqual(agent.freeSockets[name], undefined); process.nextTick(function() { - assert.equal(agent.sockets[name], undefined); - assert.equal(agent.freeSockets[name].length, 1); + assert.strictEqual(agent.sockets[name], undefined); + assert.strictEqual(agent.freeSockets[name].length, 1); second(); }); }); diff --git a/test/parallel/test-http-agent-maxsockets-regress-4050.js b/test/parallel/test-http-agent-maxsockets-regress-4050.js index 0ba3d1304f0d68..fd3a8c33f3e39a 100644 --- a/test/parallel/test-http-agent-maxsockets-regress-4050.js +++ b/test/parallel/test-http-agent-maxsockets-regress-4050.js @@ -26,9 +26,9 @@ function get(path, callback) { } server.listen(0, function() { - var finished = 0; + let finished = 0; const num_requests = 6; - for (var i = 0; i < num_requests; i++) { + for (let i = 0; i < num_requests; i++) { const request = get('/1', function() { }); request.on('response', function() { diff --git a/test/parallel/test-http-agent-maxsockets.js b/test/parallel/test-http-agent-maxsockets.js index ea443ff9bd1107..fc7618c5c02fe7 100644 --- a/test/parallel/test-http-agent-maxsockets.js +++ b/test/parallel/test-http-agent-maxsockets.js @@ -1,16 +1,16 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var agent = new http.Agent({ +const agent = new http.Agent({ keepAlive: true, keepAliveMsecs: 1000, maxSockets: 2, maxFreeSockets: 2 }); -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.end('hello world'); }); @@ -23,21 +23,21 @@ function get(path, callback) { }, callback); } -var count = 0; +let count = 0; function done() { if (++count !== 2) { return; } - var freepool = agent.freeSockets[Object.keys(agent.freeSockets)[0]]; - assert.equal(freepool.length, 2, - 'expect keep 2 free sockets, but got ' + freepool.length); + const freepool = agent.freeSockets[Object.keys(agent.freeSockets)[0]]; + assert.strictEqual(freepool.length, 2, + 'expect keep 2 free sockets, but got ' + freepool.length); agent.destroy(); server.close(); } server.listen(0, function() { get('/1', function(res) { - assert.equal(res.statusCode, 200); + assert.strictEqual(res.statusCode, 200); res.resume(); res.on('end', function() { process.nextTick(done); @@ -45,7 +45,7 @@ server.listen(0, function() { }); get('/2', function(res) { - assert.equal(res.statusCode, 200); + assert.strictEqual(res.statusCode, 200); res.resume(); res.on('end', function() { process.nextTick(done); diff --git a/test/parallel/test-http-agent-no-protocol.js b/test/parallel/test-http-agent-no-protocol.js index 94fd525b908c30..a11489b6c5bc2b 100644 --- a/test/parallel/test-http-agent-no-protocol.js +++ b/test/parallel/test-http-agent-no-protocol.js @@ -1,12 +1,12 @@ 'use strict'; const common = require('../common'); -var http = require('http'); -var url = require('url'); +const http = require('http'); +const url = require('url'); -var server = http.createServer(common.mustCall(function(req, res) { +const server = http.createServer(common.mustCall(function(req, res) { res.end(); })).listen(0, '127.0.0.1', common.mustCall(function() { - var opts = url.parse(`http://127.0.0.1:${this.address().port}/`); + const opts = url.parse(`http://127.0.0.1:${this.address().port}/`); // remove the `protocol` field… the `http` module should fall back // to "http:", as defined by the global, default `http.Agent` instance. diff --git a/test/parallel/test-http-agent-null.js b/test/parallel/test-http-agent-null.js index f1dfeddea8b0e3..9071b88b98997a 100644 --- a/test/parallel/test-http-agent-null.js +++ b/test/parallel/test-http-agent-null.js @@ -1,11 +1,11 @@ 'use strict'; const common = require('../common'); -var http = require('http'); +const http = require('http'); -var server = http.createServer(common.mustCall(function(req, res) { +const server = http.createServer(common.mustCall(function(req, res) { res.end(); })).listen(0, common.mustCall(function() { - var options = { + const options = { agent: null, port: this.address().port }; diff --git a/test/parallel/test-http-agent.js b/test/parallel/test-http-agent.js index dae982ed51a302..cfb37539ede878 100644 --- a/test/parallel/test-http-agent.js +++ b/test/parallel/test-http-agent.js @@ -1,22 +1,22 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var server = http.Server(function(req, res) { +const server = http.Server(function(req, res) { res.writeHead(200); res.end('hello world\n'); }); -var responses = 0; -var N = 4; -var M = 4; +let responses = 0; +const N = 4; +const M = 4; server.listen(0, function() { const port = this.address().port; - for (var i = 0; i < N; i++) { + for (let i = 0; i < N; i++) { setTimeout(function() { - for (var j = 0; j < M; j++) { + for (let j = 0; j < M; j++) { http.get({ port: port, path: '/' }, function(res) { console.log('%d %d', responses, res.statusCode); if (++responses === N * M) { @@ -35,5 +35,5 @@ server.listen(0, function() { process.on('exit', function() { - assert.equal(N * M, responses); + assert.strictEqual(N * M, responses); }); diff --git a/test/parallel/test-http-automatic-headers.js b/test/parallel/test-http-automatic-headers.js index 600be8e43ee23c..37a5c43901c33d 100644 --- a/test/parallel/test-http-automatic-headers.js +++ b/test/parallel/test-http-automatic-headers.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.setHeader('X-Date', 'foo'); res.setHeader('X-Connection', 'bar'); res.setHeader('X-Content-Length', 'baz'); @@ -12,19 +12,19 @@ var server = http.createServer(function(req, res) { server.listen(0); server.on('listening', function() { - var agent = new http.Agent({ port: this.address().port, maxSockets: 1 }); + const agent = new http.Agent({ port: this.address().port, maxSockets: 1 }); http.get({ port: this.address().port, path: '/hello', agent: agent }, function(res) { - assert.equal(res.statusCode, 200); - assert.equal(res.headers['x-date'], 'foo'); - assert.equal(res.headers['x-connection'], 'bar'); - assert.equal(res.headers['x-content-length'], 'baz'); + assert.strictEqual(res.statusCode, 200); + assert.strictEqual(res.headers['x-date'], 'foo'); + assert.strictEqual(res.headers['x-connection'], 'bar'); + assert.strictEqual(res.headers['x-content-length'], 'baz'); assert(res.headers['date']); - assert.equal(res.headers['connection'], 'keep-alive'); - assert.equal(res.headers['content-length'], '0'); + assert.strictEqual(res.headers['connection'], 'keep-alive'); + assert.strictEqual(res.headers['content-length'], '0'); server.close(); agent.destroy(); }); diff --git a/test/parallel/test-http-blank-header.js b/test/parallel/test-http-blank-header.js index 13b1a2f3b0d449..edd8923fa8e2f7 100644 --- a/test/parallel/test-http-blank-header.js +++ b/test/parallel/test-http-blank-header.js @@ -1,12 +1,12 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); -var server = http.createServer(common.mustCall(function(req, res) { - assert.equal('GET', req.method); - assert.equal('/blah', req.url); +const server = http.createServer(common.mustCall(function(req, res) { + assert.strictEqual('GET', req.method); + assert.strictEqual('/blah', req.url); assert.deepStrictEqual({ host: 'mapdevel.trolologames.ru:443', origin: 'http://mapdevel.trolologames.ru', @@ -16,7 +16,7 @@ var server = http.createServer(common.mustCall(function(req, res) { server.listen(0, function() { - var c = net.createConnection(this.address().port); + const c = net.createConnection(this.address().port); c.on('connect', function() { c.write('GET /blah HTTP/1.1\r\n' + diff --git a/test/parallel/test-http-buffer-sanity.js b/test/parallel/test-http-buffer-sanity.js index 542d4ad5af2cbc..4226f1c65237fa 100644 --- a/test/parallel/test-http-buffer-sanity.js +++ b/test/parallel/test-http-buffer-sanity.js @@ -1,29 +1,29 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var bufferSize = 5 * 1024 * 1024; -var measuredSize = 0; +const bufferSize = 5 * 1024 * 1024; +let measuredSize = 0; -var buffer = Buffer.allocUnsafe(bufferSize); -for (var i = 0; i < buffer.length; i++) { +const buffer = Buffer.allocUnsafe(bufferSize); +for (let i = 0; i < buffer.length; i++) { buffer[i] = i % 256; } -var web = http.Server(function(req, res) { +const web = http.Server(function(req, res) { web.close(); console.log(req.headers); - var i = 0; + let i = 0; req.on('data', function(d) { process.stdout.write(','); measuredSize += d.length; - for (var j = 0; j < d.length; j++) { - assert.equal(buffer[i], d[j]); + for (let j = 0; j < d.length; j++) { + assert.strictEqual(buffer[i], d[j]); i++; } }); @@ -45,7 +45,7 @@ var web = http.Server(function(req, res) { web.listen(0, common.mustCall(function() { console.log('Making request'); - var req = http.request({ + const req = http.request({ port: this.address().port, method: 'GET', path: '/', @@ -54,7 +54,7 @@ web.listen(0, common.mustCall(function() { console.log('Got response'); res.setEncoding('utf8'); res.on('data', common.mustCall(function(string) { - assert.equal('thanks', string); + assert.strictEqual('thanks', string); })); })); req.end(buffer); @@ -62,5 +62,5 @@ web.listen(0, common.mustCall(function() { process.on('exit', function() { - assert.equal(bufferSize, measuredSize); + assert.strictEqual(bufferSize, measuredSize); }); diff --git a/test/parallel/test-http-byteswritten.js b/test/parallel/test-http-byteswritten.js index bb914439a76b78..3b295ebdcc1c49 100644 --- a/test/parallel/test-http-byteswritten.js +++ b/test/parallel/test-http-byteswritten.js @@ -1,11 +1,11 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var body = 'hello world\n'; +const body = 'hello world\n'; -var httpServer = http.createServer(common.mustCall(function(req, res) { +const httpServer = http.createServer(common.mustCall(function(req, res) { httpServer.close(); res.on('finish', common.mustCall(function() { @@ -16,9 +16,9 @@ var httpServer = http.createServer(common.mustCall(function(req, res) { // Write 1.5mb to cause some requests to buffer // Also, mix up the encodings a bit. - var chunk = new Array(1024 + 1).join('7'); - var bchunk = Buffer.from(chunk); - for (var i = 0; i < 1024; i++) { + const chunk = new Array(1024 + 1).join('7'); + const bchunk = Buffer.from(chunk); + for (let i = 0; i < 1024; i++) { res.write(chunk); res.write(bchunk); res.write(chunk, 'hex'); diff --git a/test/parallel/test-http-catch-uncaughtexception.js b/test/parallel/test-http-catch-uncaughtexception.js index 06d9b9a6e5d4e0..1366b6e26ea37f 100644 --- a/test/parallel/test-http-catch-uncaughtexception.js +++ b/test/parallel/test-http-catch-uncaughtexception.js @@ -5,7 +5,7 @@ const assert = require('assert'); const http = require('http'); const uncaughtCallback = common.mustCall(function(er) { - assert.equal(er.message, 'get did fail'); + assert.strictEqual(er.message, 'get did fail'); }); process.on('uncaughtException', uncaughtCallback); diff --git a/test/parallel/test-http-chunk-problem.js b/test/parallel/test-http-chunk-problem.js index 9bb004dc973f5c..0ffd71813e7108 100644 --- a/test/parallel/test-http-chunk-problem.js +++ b/test/parallel/test-http-chunk-problem.js @@ -51,9 +51,9 @@ function executeRequest(cb) { __filename, 'shasum' ].join(' '), (err, stdout, stderr) => { - if (err) throw err; - assert.equal('8c206a1a87599f532ce68675536f0b1546900d7a', - stdout.slice(0, 40)); + assert.ifError(err); + assert.strictEqual('8c206a1a87599f532ce68675536f0b1546900d7a', + stdout.slice(0, 40)); cb(); } ); @@ -65,7 +65,7 @@ common.refreshTmpDir(); const ddcmd = common.ddCommand(filename, 10240); cp.exec(ddcmd, function(err, stdout, stderr) { - if (err) throw err; + assert.ifError(err); server = http.createServer(function(req, res) { res.writeHead(200); diff --git a/test/parallel/test-http-chunked-304.js b/test/parallel/test-http-chunked-304.js index 5ea1912b72dfee..b130004d1a83e7 100644 --- a/test/parallel/test-http-chunked-304.js +++ b/test/parallel/test-http-chunked-304.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); // RFC 2616, section 10.2.5: // @@ -12,32 +12,35 @@ var net = require('net'); // Likewise for 304 responses. Verify that no empty chunk is sent when // the user explicitly sets a Transfer-Encoding header. -test(204, function() { - test(304); -}); +test(204); +test(304); -function test(statusCode, next) { - var server = http.createServer(function(req, res) { +function test(statusCode) { + const server = http.createServer(common.mustCall((req, res) => { res.writeHead(statusCode, { 'Transfer-Encoding': 'chunked' }); res.end(); server.close(); - }); + })); - server.listen(0, function() { - var conn = net.createConnection(this.address().port, function() { - conn.write('GET / HTTP/1.1\r\n\r\n'); + server.listen(0, common.mustCall(() => { + const conn = net.createConnection( + server.address().port, + common.mustCall(() => { + conn.write('GET / HTTP/1.1\r\n\r\n'); - var resp = ''; - conn.setEncoding('utf8'); - conn.on('data', function(data) { - resp += data; - }); + let resp = ''; + conn.setEncoding('utf8'); + conn.on('data', common.mustCall((data) => { + resp += data; + })); - conn.on('end', common.mustCall(function() { - assert.equal(/^Connection: close\r\n$/m.test(resp), true); - assert.equal(/^0\r\n$/m.test(resp), false); - if (next) process.nextTick(next); - })); - }); - }); + conn.on('end', common.mustCall(() => { + // Connection: close should be in the response + assert.strictEqual(/^Connection: close\r\n$/m.test(resp), true); + // Make sure this doesn't end with 0\r\n\r\n + assert.strictEqual(/^0\r\n$/m.test(resp), false); + })); + }) + ); + })); } diff --git a/test/parallel/test-http-chunked.js b/test/parallel/test-http-chunked.js index bb91dadd159de5..b70a704bb7fce4 100644 --- a/test/parallel/test-http-chunked.js +++ b/test/parallel/test-http-chunked.js @@ -1,25 +1,25 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var UTF8_STRING = '南越国是前203年至前111年存在于岭南地区的一个国家,' + - '国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、' + - '贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,' + - '由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,' + - '南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' + - '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。' + - '南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,' + - '采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,' + - '有效的改善了岭南地区落后的政治、经济现状。'; +const UTF8_STRING = '南越国是前203年至前111年存在于岭南地区的一个国家,' + + '国都位于番禺,疆域包括今天中国的广东、广西两省区的大部份地区,福建省、湖南、' + + '贵州、云南的一小部份地区和越南的北部。南越国是秦朝灭亡后,' + + '由南海郡尉赵佗于前203年起兵兼并桂林郡和象郡后建立。前196年和前179年,' + + '南越国曾先后两次名义上臣属于西汉,成为西汉的“外臣”。前112年,' + + '南越国末代君主赵建德与西汉发生战争,被汉武帝于前111年所灭。' + + '南越国共存在93年,历经五代君主。南越国是岭南地区的第一个有记载的政权国家,' + + '采用封建制和郡县制并存的制度,它的建立保证了秦末乱世岭南地区社会秩序的稳定,' + + '有效的改善了岭南地区落后的政治、经济现状。'; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain; charset=utf8'}); res.end(UTF8_STRING, 'utf8'); }); server.listen(0, function() { - var data = ''; - var get = http.get({ + let data = ''; + const get = http.get({ path: '/', host: 'localhost', port: this.address().port @@ -30,9 +30,9 @@ server.listen(0, function() { throw e; }); x.on('end', function() { - assert.equal('string', typeof data); + assert.strictEqual('string', typeof data); console.log('here is the response:'); - assert.equal(UTF8_STRING, data); + assert.strictEqual(UTF8_STRING, data); console.log(data); server.close(); }); diff --git a/test/parallel/test-http-client-abort-event.js b/test/parallel/test-http-client-abort-event.js index c0c1f9e4c73c92..b62186e724d919 100644 --- a/test/parallel/test-http-client-abort-event.js +++ b/test/parallel/test-http-client-abort-event.js @@ -1,12 +1,12 @@ 'use strict'; const common = require('../common'); -var http = require('http'); -var server = http.createServer(function(req, res) { +const http = require('http'); +const server = http.createServer(function(req, res) { res.end(); }); server.listen(0, common.mustCall(function() { - var req = http.request({ + const req = http.request({ port: this.address().port }, common.fail); diff --git a/test/parallel/test-http-client-abort-no-agent.js b/test/parallel/test-http-client-abort-no-agent.js new file mode 100644 index 00000000000000..875d2ce6469d46 --- /dev/null +++ b/test/parallel/test-http-client-abort-no-agent.js @@ -0,0 +1,19 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); +const net = require('net'); + +const server = http.createServer(common.fail); + +server.listen(0, common.mustCall(() => { + const req = http.get({ + createConnection(options, oncreate) { + const socket = net.createConnection(options, oncreate); + socket.once('close', () => server.close()); + return socket; + }, + port: server.address().port + }); + + req.abort(); +})); diff --git a/test/parallel/test-http-client-abort-unix-socket.js b/test/parallel/test-http-client-abort-unix-socket.js new file mode 100644 index 00000000000000..0b7c5e5ddea6dd --- /dev/null +++ b/test/parallel/test-http-client-abort-unix-socket.js @@ -0,0 +1,24 @@ +'use strict'; +const common = require('../common'); +const http = require('http'); + +const server = http.createServer(common.fail); + +class Agent extends http.Agent { + createConnection(options, oncreate) { + const socket = super.createConnection(options, oncreate); + socket.once('close', () => server.close()); + return socket; + } +} + +common.refreshTmpDir(); + +server.listen(common.PIPE, common.mustCall(() => { + const req = http.get({ + agent: new Agent(), + socketPath: common.PIPE + }); + + req.abort(); +})); diff --git a/test/parallel/test-http-client-abort.js b/test/parallel/test-http-client-abort.js index 4f46128f0e804a..5c5b319bfa4f5f 100644 --- a/test/parallel/test-http-client-abort.js +++ b/test/parallel/test-http-client-abort.js @@ -3,7 +3,7 @@ require('../common'); const assert = require('assert'); const http = require('http'); -var clientAborts = 0; +let clientAborts = 0; const server = http.Server(function(req, res) { console.log('Got connection'); @@ -23,17 +23,17 @@ const server = http.Server(function(req, res) { }); }); -var responses = 0; +let responses = 0; const N = 8; const requests = []; server.listen(0, function() { console.log('Server listening.'); - for (var i = 0; i < N; i++) { + for (let i = 0; i < N; i++) { console.log('Making client ' + i); - var options = { port: this.address().port, path: '/?id=' + i }; - var req = http.get(options, function(res) { + const options = { port: this.address().port, path: '/?id=' + i }; + const req = http.get(options, function(res) { console.log('Client response code ' + res.statusCode); res.resume(); @@ -51,5 +51,5 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.equal(N, clientAborts); + assert.strictEqual(N, clientAborts); }); diff --git a/test/parallel/test-http-client-abort2.js b/test/parallel/test-http-client-abort2.js index 30269a193f0eab..7c7be9b530e2d2 100644 --- a/test/parallel/test-http-client-abort2.js +++ b/test/parallel/test-http-client-abort2.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var http = require('http'); +const http = require('http'); -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.end('Hello'); }); server.listen(0, function() { - var req = http.get({port: this.address().port}, function(res) { + const req = http.get({port: this.address().port}, function(res) { res.on('data', function(data) { req.abort(); server.close(); diff --git a/test/parallel/test-http-client-agent.js b/test/parallel/test-http-client-agent.js index 36ed24ec526255..277c7a33ae586a 100644 --- a/test/parallel/test-http-client-agent.js +++ b/test/parallel/test-http-client-agent.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var name; -var max = 3; -var count = 0; +let name; +const max = 3; +let count = 0; -var server = http.Server(function(req, res) { +const server = http.Server(function(req, res) { if (req.url === '/0') { setTimeout(function() { res.writeHead(200); @@ -20,21 +20,21 @@ var server = http.Server(function(req, res) { }); server.listen(0, function() { name = http.globalAgent.getName({ port: this.address().port }); - for (var i = 0; i < max; ++i) { + for (let i = 0; i < max; ++i) { request(i); } }); function request(i) { - var req = http.get({ + const req = http.get({ port: server.address().port, path: '/' + i }, function(res) { - var socket = req.socket; + const socket = req.socket; socket.on('close', function() { ++count; if (count < max) { - assert.equal(http.globalAgent.sockets[name].indexOf(socket), -1); + assert.strictEqual(http.globalAgent.sockets[name].indexOf(socket), -1); } else { assert(!http.globalAgent.sockets.hasOwnProperty(name)); assert(!http.globalAgent.requests.hasOwnProperty(name)); @@ -46,5 +46,5 @@ function request(i) { } process.on('exit', function() { - assert.equal(count, max); + assert.strictEqual(count, max); }); diff --git a/test/parallel/test-http-client-default-headers-exist.js b/test/parallel/test-http-client-default-headers-exist.js index 9b73f2db32aad6..2271944773d9db 100644 --- a/test/parallel/test-http-client-default-headers-exist.js +++ b/test/parallel/test-http-client-default-headers-exist.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var expectedHeaders = { +const expectedHeaders = { 'DELETE': ['host', 'connection'], 'GET': ['host', 'connection'], 'HEAD': ['host', 'connection'], @@ -12,18 +12,18 @@ var expectedHeaders = { 'PUT': ['host', 'connection', 'content-length'] }; -var expectedMethods = Object.keys(expectedHeaders); +const expectedMethods = Object.keys(expectedHeaders); -var requestCount = 0; +let requestCount = 0; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { requestCount++; res.end(); assert(expectedHeaders.hasOwnProperty(req.method), req.method + ' was an unexpected method'); - var requestHeaders = Object.keys(req.headers); + const requestHeaders = Object.keys(req.headers); requestHeaders.forEach(function(header) { assert.notStrictEqual( expectedHeaders[req.method].indexOf(header.toLowerCase()), diff --git a/test/parallel/test-http-client-defaults.js b/test/parallel/test-http-client-defaults.js new file mode 100644 index 00000000000000..d277a60e3df55e --- /dev/null +++ b/test/parallel/test-http-client-defaults.js @@ -0,0 +1,24 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const ClientRequest = require('http').ClientRequest; + +function noop() {} + +{ + const req = new ClientRequest({ createConnection: noop }); + assert.strictEqual(req.path, '/'); + assert.strictEqual(req.method, 'GET'); +} + +{ + const req = new ClientRequest({ method: '', createConnection: noop }); + assert.strictEqual(req.path, '/'); + assert.strictEqual(req.method, 'GET'); +} + +{ + const req = new ClientRequest({ path: '', createConnection: noop }); + assert.strictEqual(req.path, '/'); + assert.strictEqual(req.method, 'GET'); +} diff --git a/test/parallel/test-http-client-encoding.js b/test/parallel/test-http-client-encoding.js index b02463aa5188d5..d2aa8fdcbbac46 100644 --- a/test/parallel/test-http-client-encoding.js +++ b/test/parallel/test-http-client-encoding.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var http = require('http'); +const http = require('http'); http.createServer(function(req, res) { res.end('ok\n'); diff --git a/test/parallel/test-http-client-get-url.js b/test/parallel/test-http-client-get-url.js index 51f8413b675244..aa37055050c952 100644 --- a/test/parallel/test-http-client-get-url.js +++ b/test/parallel/test-http-client-get-url.js @@ -1,17 +1,22 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); +const URL = url.URL; -var server = http.createServer(common.mustCall(function(req, res) { - assert.equal('GET', req.method); - assert.equal('/foo?bar', req.url); +const server = http.createServer(common.mustCall(function(req, res) { + assert.strictEqual('GET', req.method); + assert.strictEqual('/foo?bar', req.url); res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('hello\n'); res.end(); server.close(); -})); +}, 3)); server.listen(0, function() { - http.get(`http://127.0.0.1:${this.address().port}/foo?bar`); + const u = `http://127.0.0.1:${this.address().port}/foo?bar`; + http.get(u); + http.get(url.parse(u)); + http.get(new URL(u)); }); diff --git a/test/parallel/test-http-client-parse-error.js b/test/parallel/test-http-client-parse-error.js index cd6f135d889534..e649f983a51626 100644 --- a/test/parallel/test-http-client-parse-error.js +++ b/test/parallel/test-http-client-parse-error.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); -var net = require('net'); +const http = require('http'); +const net = require('net'); -var connects = 0; -var parseErrors = 0; +let connects = 0; +let parseErrors = 0; // Create a TCP server net.createServer(function(c) { @@ -18,7 +18,7 @@ net.createServer(function(c) { this.close(); } }).listen(0, '127.0.0.1', function() { - for (var i = 0; i < 2; i++) { + for (let i = 0; i < 2; i++) { http.request({ host: '127.0.0.1', port: this.address().port, @@ -27,13 +27,13 @@ net.createServer(function(c) { }).on('error', function(e) { console.log('got error from client'); assert.ok(e.message.indexOf('Parse Error') >= 0); - assert.equal(e.code, 'HPE_INVALID_CONSTANT'); + assert.strictEqual(e.code, 'HPE_INVALID_CONSTANT'); parseErrors++; }).end(); } }); process.on('exit', function() { - assert.equal(connects, 2); - assert.equal(parseErrors, 2); + assert.strictEqual(connects, 2); + assert.strictEqual(parseErrors, 2); }); diff --git a/test/parallel/test-http-client-pipe-end.js b/test/parallel/test-http-client-pipe-end.js index 5b2db49435a1b6..d4ccba8d55b036 100644 --- a/test/parallel/test-http-client-pipe-end.js +++ b/test/parallel/test-http-client-pipe-end.js @@ -1,10 +1,10 @@ 'use strict'; // see https://github.com/joyent/node/issues/3257 -var common = require('../common'); -var http = require('http'); +const common = require('../common'); +const http = require('http'); -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { req.resume(); req.once('end', function() { res.writeHead(200); @@ -16,7 +16,7 @@ var server = http.createServer(function(req, res) { common.refreshTmpDir(); server.listen(common.PIPE, function() { - var req = http.request({ + const req = http.request({ socketPath: common.PIPE, headers: {'Content-Length': '1'}, method: 'POST', diff --git a/test/parallel/test-http-client-race-2.js b/test/parallel/test-http-client-race-2.js index 632b9f4a219a92..24475059c55688 100644 --- a/test/parallel/test-http-client-race-2.js +++ b/test/parallel/test-http-client-race-2.js @@ -1,22 +1,22 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); // // Slight variation on test-http-client-race to test for another race // condition involving the parsers FreeList used internally by http.Client. // -var body1_s = '1111111111111111'; -var body2_s = '22222'; -var body3_s = '3333333333333333333'; +const body1_s = '1111111111111111'; +const body2_s = '22222'; +const body3_s = '3333333333333333333'; -var server = http.createServer(function(req, res) { - var pathname = url.parse(req.url).pathname; +const server = http.createServer(function(req, res) { + const pathname = url.parse(req.url).pathname; - var body; + let body; switch (pathname) { case '/1': body = body1_s; break; case '/2': body = body2_s; break; @@ -29,15 +29,15 @@ var server = http.createServer(function(req, res) { }); server.listen(0); -var body1 = ''; -var body2 = ''; -var body3 = ''; +let body1 = ''; +let body2 = ''; +let body3 = ''; server.on('listening', function() { // // Client #1 is assigned Parser #1 // - var req1 = http.get({ port: this.address().port, path: '/1' }); + const req1 = http.get({ port: this.address().port, path: '/1' }); req1.on('response', function(res1) { res1.setEncoding('utf8'); @@ -59,7 +59,7 @@ server.on('listening', function() { // At this point, the bug would manifest itself and crash because the // internal state of the parser was no longer valid for use by Client #1 // - var req2 = http.get({ port: server.address().port, path: '/2' }); + const req2 = http.get({ port: server.address().port, path: '/2' }); req2.on('response', function(res2) { res2.setEncoding('utf8'); res2.on('data', function(chunk) { body2 += chunk; }); @@ -69,7 +69,7 @@ server.on('listening', function() { // Just to be really sure we've covered all our bases, execute a // request using client2. // - var req3 = http.get({ port: server.address().port, path: '/3' }); + const req3 = http.get({ port: server.address().port, path: '/3' }); req3.on('response', function(res3) { res3.setEncoding('utf8'); res3.on('data', function(chunk) { body3 += chunk; }); @@ -83,7 +83,7 @@ server.on('listening', function() { }); process.on('exit', function() { - assert.equal(body1_s, body1); - assert.equal(body2_s, body2); - assert.equal(body3_s, body3); + assert.strictEqual(body1_s, body1); + assert.strictEqual(body2_s, body2); + assert.strictEqual(body3_s, body3); }); diff --git a/test/parallel/test-http-client-race.js b/test/parallel/test-http-client-race.js index 30ebb34fc7fcff..f7610507378921 100644 --- a/test/parallel/test-http-client-race.js +++ b/test/parallel/test-http-client-race.js @@ -1,25 +1,25 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); -var body1_s = '1111111111111111'; -var body2_s = '22222'; +const body1_s = '1111111111111111'; +const body2_s = '22222'; -var server = http.createServer(function(req, res) { - var body = url.parse(req.url).pathname === '/1' ? body1_s : body2_s; +const server = http.createServer(function(req, res) { + const body = url.parse(req.url).pathname === '/1' ? body1_s : body2_s; res.writeHead(200, {'Content-Type': 'text/plain', 'Content-Length': body.length}); res.end(body); }); server.listen(0); -var body1 = ''; -var body2 = ''; +let body1 = ''; +let body2 = ''; server.on('listening', function() { - var req1 = http.request({ port: this.address().port, path: '/1' }); + const req1 = http.request({ port: this.address().port, path: '/1' }); req1.end(); req1.on('response', function(res1) { res1.setEncoding('utf8'); @@ -29,7 +29,7 @@ server.on('listening', function() { }); res1.on('end', function() { - var req2 = http.request({ port: server.address().port, path: '/2' }); + const req2 = http.request({ port: server.address().port, path: '/2' }); req2.end(); req2.on('response', function(res2) { res2.setEncoding('utf8'); @@ -41,6 +41,6 @@ server.on('listening', function() { }); process.on('exit', function() { - assert.equal(body1_s, body1); - assert.equal(body2_s, body2); + assert.strictEqual(body1_s, body1); + assert.strictEqual(body2_s, body2); }); diff --git a/test/parallel/test-http-client-read-in-error.js b/test/parallel/test-http-client-read-in-error.js index 142c0ee3715aed..69b24f73771d41 100644 --- a/test/parallel/test-http-client-read-in-error.js +++ b/test/parallel/test-http-client-read-in-error.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var net = require('net'); -var http = require('http'); -var util = require('util'); +const net = require('net'); +const http = require('http'); +const util = require('util'); function Agent() { http.Agent.call(this); @@ -10,8 +10,8 @@ function Agent() { util.inherits(Agent, http.Agent); Agent.prototype.createConnection = function() { - var self = this; - var socket = new net.Socket(); + const self = this; + const socket = new net.Socket(); socket.on('error', function() { socket.push('HTTP/1.1 200\r\n\r\n'); @@ -35,7 +35,7 @@ Agent.prototype.breakSocket = function breakSocket(socket) { socket.emit('error', new Error('Intentional error')); }; -var agent = new Agent(); +const agent = new Agent(); http.request({ agent: agent diff --git a/test/parallel/test-http-client-readable.js b/test/parallel/test-http-client-readable.js index e49181cedf63d6..bc6421692b305b 100644 --- a/test/parallel/test-http-client-readable.js +++ b/test/parallel/test-http-client-readable.js @@ -13,7 +13,7 @@ util.inherits(FakeAgent, http.Agent); FakeAgent.prototype.createConnection = function() { const s = new Duplex(); - var once = false; + let once = false; s._read = function() { if (once) @@ -38,7 +38,7 @@ FakeAgent.prototype.createConnection = function() { return s; }; -var received = ''; +let received = ''; const req = http.request({ agent: new FakeAgent() diff --git a/test/parallel/test-http-client-reject-chunked-with-content-length.js b/test/parallel/test-http-client-reject-chunked-with-content-length.js index daa0591cd75506..3d99f6ef406b1b 100644 --- a/test/parallel/test-http-client-reject-chunked-with-content-length.js +++ b/test/parallel/test-http-client-reject-chunked-with-content-length.js @@ -22,7 +22,7 @@ server.listen(0, () => { }); req.on('error', common.mustCall((err) => { assert(/^Parse Error/.test(err.message)); - assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); + assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); server.close(); })); }); diff --git a/test/parallel/test-http-client-reject-cr-no-lf.js b/test/parallel/test-http-client-reject-cr-no-lf.js index 4cabfa0107bbc8..23530cbc7ae74c 100644 --- a/test/parallel/test-http-client-reject-cr-no-lf.js +++ b/test/parallel/test-http-client-reject-cr-no-lf.js @@ -21,7 +21,7 @@ server.listen(0, () => { }); req.on('error', common.mustCall((err) => { assert(/^Parse Error/.test(err.message)); - assert.equal(err.code, 'HPE_LF_EXPECTED'); + assert.strictEqual(err.code, 'HPE_LF_EXPECTED'); server.close(); })); }); diff --git a/test/parallel/test-http-client-response-domain.js b/test/parallel/test-http-client-response-domain.js index 5355a301e8031d..20babf51a9178a 100644 --- a/test/parallel/test-http-client-response-domain.js +++ b/test/parallel/test-http-client-response-domain.js @@ -4,12 +4,12 @@ const assert = require('assert'); const http = require('http'); const domain = require('domain'); -var d; +let d; common.refreshTmpDir(); // first fire up a simple HTTP server -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200); res.end(); server.close(); @@ -23,10 +23,10 @@ server.listen(common.PIPE, function() { function test() { d.on('error', common.mustCall(function(err) { - assert.equal('should be caught by domain', err.message); + assert.strictEqual('should be caught by domain', err.message); })); - var req = http.get({ + const req = http.get({ socketPath: common.PIPE, headers: {'Content-Length': '1'}, method: 'POST', diff --git a/test/parallel/test-http-client-timeout-agent.js b/test/parallel/test-http-client-timeout-agent.js index 4ed217c171f28a..16a18342468f94 100644 --- a/test/parallel/test-http-client-timeout-agent.js +++ b/test/parallel/test-http-client-timeout-agent.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var requests_sent = 0; -var requests_done = 0; -var options = { +let requests_sent = 0; +let requests_done = 0; +const options = { method: 'GET', port: undefined, host: '127.0.0.1', @@ -13,7 +13,7 @@ var options = { //http.globalAgent.maxSockets = 15; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { const m = /\/(.*)/.exec(req.url); const reqid = parseInt(m[1], 10); if (reqid % 2) { @@ -27,7 +27,7 @@ var server = http.createServer(function(req, res) { server.listen(0, options.host, function() { options.port = this.address().port; - var req; + let req; for (requests_sent = 0; requests_sent < 30; requests_sent += 1) { options.path = '/' + requests_sent; diff --git a/test/parallel/test-http-client-timeout-option.js b/test/parallel/test-http-client-timeout-option.js index 79aa6ba46b6579..6741fbe0bd1e35 100644 --- a/test/parallel/test-http-client-timeout-option.js +++ b/test/parallel/test-http-client-timeout-option.js @@ -3,7 +3,7 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); -var options = { +const options = { method: 'GET', port: undefined, host: '127.0.0.1', @@ -11,17 +11,17 @@ var options = { timeout: 1 }; -var server = http.createServer(); +const server = http.createServer(); server.listen(0, options.host, function() { options.port = this.address().port; - var req = http.request(options); + const req = http.request(options); req.on('error', function() { // this space is intentionally left blank }); req.on('close', common.mustCall(() => server.close())); - var timeout_events = 0; + let timeout_events = 0; req.on('timeout', common.mustCall(() => timeout_events += 1)); setTimeout(function() { req.destroy(); diff --git a/test/parallel/test-http-client-timeout-with-data.js b/test/parallel/test-http-client-timeout-with-data.js index c82327beb295da..a21a2181752701 100644 --- a/test/parallel/test-http-client-timeout-with-data.js +++ b/test/parallel/test-http-client-timeout-with-data.js @@ -3,7 +3,7 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); -var nchunks = 0; +let nchunks = 0; const options = { method: 'GET', diff --git a/test/parallel/test-http-client-timeout.js b/test/parallel/test-http-client-timeout.js index 402736e9b7d47c..0caae0d04c333c 100644 --- a/test/parallel/test-http-client-timeout.js +++ b/test/parallel/test-http-client-timeout.js @@ -1,22 +1,22 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var options = { +const options = { method: 'GET', port: undefined, host: '127.0.0.1', path: '/' }; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { // this space intentionally left blank }); server.listen(0, options.host, function() { options.port = this.address().port; - var req = http.request(options, function(res) { + const req = http.request(options, function(res) { // this space intentionally left blank }); req.on('close', function() { @@ -25,7 +25,7 @@ server.listen(0, options.host, function() { function destroy() { req.destroy(); } - var s = req.setTimeout(1, destroy); + const s = req.setTimeout(1, destroy); assert.ok(s instanceof http.ClientRequest); req.on('error', destroy); req.end(); diff --git a/test/parallel/test-http-client-upload-buf.js b/test/parallel/test-http-client-upload-buf.js index 512a438ef82115..208de06e8ebcd5 100644 --- a/test/parallel/test-http-client-upload-buf.js +++ b/test/parallel/test-http-client-upload-buf.js @@ -1,14 +1,14 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var N = 1024; +const N = 1024; -var server = http.createServer(common.mustCall(function(req, res) { - assert.equal('POST', req.method); +const server = http.createServer(common.mustCall(function(req, res) { + assert.strictEqual('POST', req.method); - var bytesReceived = 0; + let bytesReceived = 0; req.on('data', function(chunk) { bytesReceived += chunk.length; @@ -25,7 +25,7 @@ var server = http.createServer(common.mustCall(function(req, res) { server.listen(0); server.on('listening', common.mustCall(function() { - var req = http.request({ + const req = http.request({ port: this.address().port, method: 'POST', path: '/' diff --git a/test/parallel/test-http-client-upload.js b/test/parallel/test-http-client-upload.js index a5c8f5b92bc761..474dc333d142cd 100644 --- a/test/parallel/test-http-client-upload.js +++ b/test/parallel/test-http-client-upload.js @@ -1,13 +1,13 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var server = http.createServer(common.mustCall(function(req, res) { - assert.equal('POST', req.method); +const server = http.createServer(common.mustCall(function(req, res) { + assert.strictEqual('POST', req.method); req.setEncoding('utf8'); - var sent_body = ''; + let sent_body = ''; req.on('data', function(chunk) { console.log('server got: ' + JSON.stringify(chunk)); @@ -25,7 +25,7 @@ var server = http.createServer(common.mustCall(function(req, res) { server.listen(0); server.on('listening', common.mustCall(function() { - var req = http.request({ + const req = http.request({ port: this.address().port, method: 'POST', path: '/' diff --git a/test/parallel/test-http-common.js b/test/parallel/test-http-common.js new file mode 100644 index 00000000000000..1629856ce57d09 --- /dev/null +++ b/test/parallel/test-http-common.js @@ -0,0 +1,33 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const httpCommon = require('_http_common'); +const checkIsHttpToken = httpCommon._checkIsHttpToken; +const checkInvalidHeaderChar = httpCommon._checkInvalidHeaderChar; + +// checkIsHttpToken +assert(checkIsHttpToken('t')); +assert(checkIsHttpToken('tt')); +assert(checkIsHttpToken('ttt')); +assert(checkIsHttpToken('tttt')); +assert(checkIsHttpToken('ttttt')); + +assert.strictEqual(checkIsHttpToken(''), false); +assert.strictEqual(checkIsHttpToken(' '), false); +assert.strictEqual(checkIsHttpToken('あ'), false); +assert.strictEqual(checkIsHttpToken('あa'), false); +assert.strictEqual(checkIsHttpToken('aaaaあaaaa'), false); + +// checkInvalidHeaderChar +assert(checkInvalidHeaderChar('あ')); +assert(checkInvalidHeaderChar('aaaaあaaaa')); + +assert.strictEqual(checkInvalidHeaderChar(''), false); +assert.strictEqual(checkInvalidHeaderChar(1), false); +assert.strictEqual(checkInvalidHeaderChar(' '), false); +assert.strictEqual(checkInvalidHeaderChar(false), false); +assert.strictEqual(checkInvalidHeaderChar('t'), false); +assert.strictEqual(checkInvalidHeaderChar('tt'), false); +assert.strictEqual(checkInvalidHeaderChar('ttt'), false); +assert.strictEqual(checkInvalidHeaderChar('tttt'), false); +assert.strictEqual(checkInvalidHeaderChar('ttttt'), false); diff --git a/test/parallel/test-http-conn-reset.js b/test/parallel/test-http-conn-reset.js index d7852bf32c9ec3..161e0e5c2bc830 100644 --- a/test/parallel/test-http-conn-reset.js +++ b/test/parallel/test-http-conn-reset.js @@ -1,16 +1,16 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); -var options = { +const options = { host: '127.0.0.1', port: undefined }; // start a tcp server that closes incoming connections immediately -var server = net.createServer(function(client) { +const server = net.createServer(function(client) { client.destroy(); server.close(); }); @@ -19,11 +19,9 @@ server.listen(0, options.host, common.mustCall(onListen)); // do a GET request, expect it to fail function onListen() { options.port = this.address().port; - var req = http.request(options, function(res) { - assert.ok(false, 'this should never run'); - }); + const req = http.request(options, common.fail); req.on('error', common.mustCall(function(err) { - assert.equal(err.code, 'ECONNRESET'); + assert.strictEqual(err.code, 'ECONNRESET'); })); req.end(); } diff --git a/test/parallel/test-http-connect-req-res.js b/test/parallel/test-http-connect-req-res.js index 1cee61e4c2fb37..45881f0d7d7395 100644 --- a/test/parallel/test-http-connect-req-res.js +++ b/test/parallel/test-http-connect-req-res.js @@ -5,8 +5,8 @@ const http = require('http'); const server = http.createServer(common.fail); server.on('connect', common.mustCall(function(req, socket, firstBodyChunk) { - assert.equal(req.method, 'CONNECT'); - assert.equal(req.url, 'example.com:443'); + assert.strictEqual(req.method, 'CONNECT'); + assert.strictEqual(req.url, 'example.com:443'); console.error('Server got CONNECT request'); // It is legal for the server to send some data intended for the client @@ -18,7 +18,7 @@ server.on('connect', common.mustCall(function(req, socket, firstBodyChunk) { 'Head' ); - var data = firstBodyChunk.toString(); + let data = firstBodyChunk.toString(); socket.on('data', function(buf) { data += buf.toString(); }); @@ -46,19 +46,19 @@ server.listen(0, common.mustCall(function() { // Make sure this socket has detached. assert(!socket.ondata); assert(!socket.onend); - assert.equal(socket.listeners('connect').length, 0); - assert.equal(socket.listeners('data').length, 0); + assert.strictEqual(socket.listeners('connect').length, 0); + assert.strictEqual(socket.listeners('data').length, 0); - var data = firstBodyChunk.toString(); + let data = firstBodyChunk.toString(); // test that the firstBodyChunk was not parsed as HTTP - assert.equal(data, 'Head'); + assert.strictEqual(data, 'Head'); socket.on('data', function(buf) { data += buf.toString(); }); socket.on('end', function() { - assert.equal(data, 'HeadRequestEnd'); + assert.strictEqual(data, 'HeadRequestEnd'); server.close(); }); socket.end('End'); diff --git a/test/parallel/test-http-content-length.js b/test/parallel/test-http-content-length.js index 9104e5ba0d74cb..3d6882d92f04b3 100644 --- a/test/parallel/test-http-content-length.js +++ b/test/parallel/test-http-content-length.js @@ -1,27 +1,27 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var expectedHeadersMultipleWrites = { +const expectedHeadersMultipleWrites = { 'connection': 'close', 'transfer-encoding': 'chunked', }; -var expectedHeadersEndWithData = { +const expectedHeadersEndWithData = { 'connection': 'close', 'content-length': String('hello world'.length) }; -var expectedHeadersEndNoData = { +const expectedHeadersEndNoData = { 'connection': 'close', 'content-length': '0', }; -var receivedRequests = 0; -var totalRequests = 3; +let receivedRequests = 0; +const totalRequests = 3; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.removeHeader('Date'); switch (req.url.substr(1)) { @@ -47,7 +47,7 @@ var server = http.createServer(function(req, res) { }); server.listen(0, function() { - var req; + let req; req = http.request({ port: this.address().port, diff --git a/test/parallel/test-http-contentLength0.js b/test/parallel/test-http-contentLength0.js index 19e90e151382be..46eec45ed2757f 100644 --- a/test/parallel/test-http-contentLength0.js +++ b/test/parallel/test-http-contentLength0.js @@ -1,19 +1,19 @@ 'use strict'; require('../common'); -var http = require('http'); +const http = require('http'); // Simple test of Node's HTTP Client choking on a response // with a 'Content-Length: 0 ' response header. // I.E. a space character after the 'Content-Length' throws an `error` event. -var s = http.createServer(function(req, res) { +const s = http.createServer(function(req, res) { res.writeHead(200, {'Content-Length': '0 '}); res.end(); }); s.listen(0, function() { - var request = http.request({ port: this.address().port }, function(response) { + const request = http.request({ port: this.address().port }, (response) => { console.log('STATUS: ' + response.statusCode); s.close(); response.resume(); diff --git a/test/parallel/test-http-createConnection.js b/test/parallel/test-http-createConnection.js index 69592eb09ff487..279d7022795318 100644 --- a/test/parallel/test-http-createConnection.js +++ b/test/parallel/test-http-createConnection.js @@ -23,7 +23,7 @@ const server = http.createServer(common.mustCall(function(req, res) { http.get({ createConnection: fn }, function(res) { common.fail('Unexpected response callback'); }).on('error', common.mustCall(function(err) { - assert.equal(err.message, 'Could not create socket'); + assert.strictEqual(err.message, 'Could not create socket'); server.close(); })); }); diff --git a/test/parallel/test-http-date-header.js b/test/parallel/test-http-date-header.js index e0b93c1f8718f5..e14a92b310f2d1 100644 --- a/test/parallel/test-http-date-header.js +++ b/test/parallel/test-http-date-header.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var testResBody = 'other stuff!\n'; +const testResBody = 'other stuff!\n'; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { assert.ok(!('date' in req.headers), 'Request headers contained a Date.'); res.writeHead(200, { @@ -17,12 +17,12 @@ server.listen(0); server.addListener('listening', function() { - var options = { + const options = { port: this.address().port, path: '/', method: 'GET' }; - var req = http.request(options, function(res) { + const req = http.request(options, function(res) { assert.ok('date' in res.headers, 'Response headers didn\'t contain a Date.'); res.addListener('end', function() { diff --git a/test/parallel/test-http-default-encoding.js b/test/parallel/test-http-default-encoding.js index 4fb386bf4bb0e8..2c41328749f027 100644 --- a/test/parallel/test-http-default-encoding.js +++ b/test/parallel/test-http-default-encoding.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var expected = 'This is a unicode text: سلام'; -var result = ''; +const expected = 'This is a unicode text: سلام'; +let result = ''; -var server = http.Server(function(req, res) { +const server = http.Server(function(req, res) { req.setEncoding('utf8'); req.on('data', function(chunk) { result += chunk; @@ -33,5 +33,5 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.equal(expected, result); + assert.strictEqual(expected, result); }); diff --git a/test/parallel/test-http-default-port.js b/test/parallel/test-http-default-port.js index fcea5aac7b156b..146e5846c107b6 100644 --- a/test/parallel/test-http-default-port.js +++ b/test/parallel/test-http-default-port.js @@ -1,6 +1,13 @@ 'use strict'; const common = require('../common'); + +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + const http = require('http'); +const https = require('https'); const assert = require('assert'); const hostExpect = 'localhost'; const fs = require('fs'); @@ -13,12 +20,6 @@ const options = { let gotHttpsResp = false; let gotHttpResp = false; -if (common.hasCrypto) { - var https = require('https'); -} else { - common.skip('missing crypto'); -} - process.on('exit', function() { if (common.hasCrypto) { assert(gotHttpsResp); @@ -28,8 +29,8 @@ process.on('exit', function() { }); http.createServer(function(req, res) { - assert.equal(req.headers.host, hostExpect); - assert.equal(req.headers['x-port'], this.address().port); + assert.strictEqual(req.headers.host, hostExpect); + assert.strictEqual(req.headers['x-port'], this.address().port.toString()); res.writeHead(200); res.end('ok'); this.close(); @@ -48,8 +49,8 @@ http.createServer(function(req, res) { if (common.hasCrypto) { https.createServer(options, function(req, res) { - assert.equal(req.headers.host, hostExpect); - assert.equal(req.headers['x-port'], this.address().port); + assert.strictEqual(req.headers.host, hostExpect); + assert.strictEqual(req.headers['x-port'], this.address().port.toString()); res.writeHead(200); res.end('ok'); this.close(); diff --git a/test/parallel/test-http-destroyed-socket-write2.js b/test/parallel/test-http-destroyed-socket-write2.js index 7d2f235a27f7fb..59e0eeecfc8a7a 100644 --- a/test/parallel/test-http-destroyed-socket-write2.js +++ b/test/parallel/test-http-destroyed-socket-write2.js @@ -1,19 +1,19 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); // Verify that ECONNRESET is raised when writing to a http request // where the server has ended the socket. -var http = require('http'); -var server = http.createServer(function(req, res) { +const http = require('http'); +const server = http.createServer(function(req, res) { setImmediate(function() { res.destroy(); }); }); server.listen(0, function() { - var req = http.request({ + const req = http.request({ port: this.address().port, path: '/', method: 'POST' @@ -47,8 +47,8 @@ server.listen(0, function() { break; } - assert.equal(req.output.length, 0); - assert.equal(req.outputEncodings.length, 0); + assert.strictEqual(req.output.length, 0); + assert.strictEqual(req.outputEncodings.length, 0); server.close(); })); diff --git a/test/parallel/test-http-dns-error.js b/test/parallel/test-http-dns-error.js index 5e15ab9a3fa0da..25224902513049 100644 --- a/test/parallel/test-http-dns-error.js +++ b/test/parallel/test-http-dns-error.js @@ -1,15 +1,15 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); - -const http = require('http'); -if (common.hasCrypto) { - var https = require('https'); -} else { +if (!common.hasCrypto) { common.skip('missing crypto'); + return; } +const assert = require('assert'); +const http = require('http'); +const https = require('https'); + const host = '*'.repeat(256); function do_not_call() { diff --git a/test/parallel/test-http-double-content-length.js b/test/parallel/test-http-double-content-length.js index a73cf49854ed35..0427d8edb8ae38 100644 --- a/test/parallel/test-http-double-content-length.js +++ b/test/parallel/test-http-double-content-length.js @@ -7,13 +7,10 @@ const assert = require('assert'); // The callback should never be invoked because the server // should respond with a 400 Client Error when a double // Content-Length header is received. -const server = http.createServer((req, res) => { - assert(false, 'callback should not have been invoked'); - res.end(); -}); +const server = http.createServer(common.fail); server.on('clientError', common.mustCall((err, socket) => { assert(/^Parse Error/.test(err.message)); - assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); + assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); socket.destroy(); })); @@ -22,9 +19,9 @@ server.listen(0, () => { port: server.address().port, // Send two content-length header values. headers: {'Content-Length': [1, 2]}}, - (res) => { - common.fail('an error should have occurred'); - } + (res) => { + common.fail('an error should have occurred'); + } ); req.on('error', common.mustCall(() => { server.close(); diff --git a/test/parallel/test-http-eof-on-connect.js b/test/parallel/test-http-eof-on-connect.js index 6f70dc239172ee..f67e45ed403225 100644 --- a/test/parallel/test-http-eof-on-connect.js +++ b/test/parallel/test-http-eof-on-connect.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var net = require('net'); -var http = require('http'); +const net = require('net'); +const http = require('http'); // This is a regression test for https://github.com/joyent/node/issues/44 // It is separate from test-http-malformed-request.js because it is only // reproduceable on the first packet on the first connection to a server. -var server = http.createServer(function(req, res) {}); +const server = http.createServer(function(req, res) {}); server.listen(0); server.on('listening', function() { diff --git a/test/parallel/test-http-exceptions.js b/test/parallel/test-http-exceptions.js index b9958007609fd0..c003db131065a3 100644 --- a/test/parallel/test-http-exceptions.js +++ b/test/parallel/test-http-exceptions.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var http = require('http'); +const http = require('http'); -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { intentionally_not_defined(); // eslint-disable-line no-undef res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('Thank you, come again.'); @@ -10,12 +10,12 @@ var server = http.createServer(function(req, res) { }); server.listen(0, function() { - for (var i = 0; i < 4; i += 1) { + for (let i = 0; i < 4; i += 1) { http.get({ port: this.address().port, path: '/busy/' + i }); } }); -var exception_count = 0; +let exception_count = 0; process.on('uncaughtException', function(err) { console.log('Caught an exception: ' + err); diff --git a/test/parallel/test-http-expect-continue.js b/test/parallel/test-http-expect-continue.js index a0ebf83b3301a5..01f285d29e54fb 100644 --- a/test/parallel/test-http-expect-continue.js +++ b/test/parallel/test-http-expect-continue.js @@ -1,16 +1,17 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var outstanding_reqs = 0; -var test_req_body = 'some stuff...\n'; -var test_res_body = 'other stuff!\n'; -var sent_continue = false; -var got_continue = false; +let outstanding_reqs = 0; +const test_req_body = 'some stuff...\n'; +const test_res_body = 'other stuff!\n'; +let sent_continue = false; +let got_continue = false; function handler(req, res) { - assert.equal(sent_continue, true, 'Full response sent before 100 Continue'); + assert.strictEqual(sent_continue, true, 'Full response sent before ' + + '100 Continue'); console.error('Server sending full response...'); res.writeHead(200, { 'Content-Type': 'text/plain', @@ -19,7 +20,7 @@ function handler(req, res) { res.end(test_res_body); } -var server = http.createServer(handler); +const server = http.createServer(handler); server.on('checkContinue', function(req, res) { console.error('Server got Expect: 100-continue...'); res.writeContinue(); @@ -32,7 +33,7 @@ server.listen(0); server.on('listening', function() { - var req = http.request({ + const req = http.request({ port: this.address().port, method: 'POST', path: '/world', @@ -40,22 +41,22 @@ server.on('listening', function() { }); console.error('Client sending request...'); outstanding_reqs++; - var body = ''; + let body = ''; req.on('continue', function() { console.error('Client got 100 Continue...'); got_continue = true; req.end(test_req_body); }); req.on('response', function(res) { - assert.equal(got_continue, true, - 'Full response received before 100 Continue'); - assert.equal(200, res.statusCode, - 'Final status code was ' + res.statusCode + ', not 200.'); + assert.strictEqual(got_continue, true, + 'Full response received before 100 Continue'); + assert.strictEqual(200, res.statusCode, 'Final status code was ' + + res.statusCode + ', not 200.'); res.setEncoding('utf8'); res.on('data', function(chunk) { body += chunk; }); res.on('end', function() { console.error('Got full response.'); - assert.equal(body, test_res_body, 'Response body doesn\'t match.'); + assert.strictEqual(body, test_res_body, 'Response body doesn\'t match.'); assert.ok('abcd' in res.headers, 'Response headers missing.'); outstanding_reqs--; if (outstanding_reqs === 0) { diff --git a/test/parallel/test-http-expect-handling.js b/test/parallel/test-http-expect-handling.js index f1f12847315a22..fed715bc2ace7d 100644 --- a/test/parallel/test-http-expect-handling.js +++ b/test/parallel/test-http-expect-handling.js @@ -37,8 +37,8 @@ function nextTest() { http.get(options, function(response) { console.log('client: expected status: ' + test); console.log('client: statusCode: ' + response.statusCode); - assert.equal(response.statusCode, test); - assert.equal(response.statusMessage, 'Expectation Failed'); + assert.strictEqual(response.statusCode, test); + assert.strictEqual(response.statusMessage, 'Expectation Failed'); response.on('end', function() { testsComplete++; @@ -51,5 +51,5 @@ function nextTest() { process.on('exit', function() { - assert.equal(2, testsComplete); + assert.strictEqual(2, testsComplete); }); diff --git a/test/parallel/test-http-extra-response.js b/test/parallel/test-http-extra-response.js index 8364684a1ec23f..5e994134c2e2ad 100644 --- a/test/parallel/test-http-extra-response.js +++ b/test/parallel/test-http-extra-response.js @@ -1,15 +1,15 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); // If an HTTP server is broken and sends data after the end of the response, // node should ignore it and drop the connection. // Demos this bug: https://github.com/joyent/node/issues/680 -var body = 'hello world\r\n'; -var fullResponse = +const body = 'hello world\r\n'; +const fullResponse = 'HTTP/1.1 500 Internal Server Error\r\n' + 'Content-Length: ' + body.length + '\r\n' + 'Content-Type: text/plain\r\n' + @@ -20,8 +20,8 @@ var fullResponse = '\r\n' + body; -var server = net.createServer(function(socket) { - var postBody = ''; +const server = net.createServer(function(socket) { + let postBody = ''; socket.setEncoding('utf8'); @@ -36,14 +36,14 @@ var server = net.createServer(function(socket) { }); socket.on('error', function(err) { - assert.equal(err.code, 'ECONNRESET'); + assert.strictEqual(err.code, 'ECONNRESET'); }); }); server.listen(0, common.mustCall(function() { http.get({ port: this.address().port }, common.mustCall(function(res) { - var buffer = ''; + let buffer = ''; console.log('Got res code: ' + res.statusCode); res.setEncoding('utf8'); @@ -53,7 +53,7 @@ server.listen(0, common.mustCall(function() { res.on('end', common.mustCall(function() { console.log('Response ended, read ' + buffer.length + ' bytes'); - assert.equal(body, buffer); + assert.strictEqual(body, buffer); server.close(); })); })); diff --git a/test/parallel/test-http-flush-headers.js b/test/parallel/test-http-flush-headers.js index c2b382188a14c1..8ca5e92e5e02bc 100644 --- a/test/parallel/test-http-flush-headers.js +++ b/test/parallel/test-http-flush-headers.js @@ -5,7 +5,7 @@ const http = require('http'); const server = http.createServer(); server.on('request', function(req, res) { - assert.equal(req.headers['foo'], 'bar'); + assert.strictEqual(req.headers['foo'], 'bar'); res.end('ok'); server.close(); }); diff --git a/test/parallel/test-http-flush-response-headers.js b/test/parallel/test-http-flush-response-headers.js index 1cd8402df361b0..bfc43a602b7018 100644 --- a/test/parallel/test-http-flush-response-headers.js +++ b/test/parallel/test-http-flush-response-headers.js @@ -11,7 +11,7 @@ server.on('request', function(req, res) { res.flushHeaders(); // Should be idempotent. }); server.listen(0, common.localhostIPv4, function() { - var req = http.request({ + const req = http.request({ method: 'GET', host: common.localhostIPv4, port: this.address().port, @@ -20,7 +20,7 @@ server.listen(0, common.localhostIPv4, function() { req.end(); function onResponse(res) { - assert.equal(res.headers['foo'], 'bar'); + assert.strictEqual(res.headers['foo'], 'bar'); res.destroy(); server.close(); } diff --git a/test/parallel/test-http-flush.js b/test/parallel/test-http-flush.js index 8b3dacb803d9bd..e8f5782c2f7857 100644 --- a/test/parallel/test-http-flush.js +++ b/test/parallel/test-http-flush.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var http = require('http'); +const http = require('http'); http.createServer(function(req, res) { res.end('ok'); this.close(); }).listen(0, '127.0.0.1', function() { - var req = http.request({ + const req = http.request({ method: 'POST', host: '127.0.0.1', port: this.address().port, diff --git a/test/parallel/test-http-full-response.js b/test/parallel/test-http-full-response.js index e59456a710aac3..881734ceb1af6f 100644 --- a/test/parallel/test-http-full-response.js +++ b/test/parallel/test-http-full-response.js @@ -1,15 +1,15 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); // This test requires the program 'ab' -var http = require('http'); -var exec = require('child_process').exec; +const http = require('http'); +const exec = require('child_process').exec; -var bodyLength = 12345; +const bodyLength = 12345; -var body = 'c'.repeat(bodyLength); +const body = 'c'.repeat(bodyLength); -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200, { 'Content-Length': bodyLength, 'Content-Type': 'text/plain' @@ -18,7 +18,7 @@ var server = http.createServer(function(req, res) { }); function runAb(opts, callback) { - var command = `ab ${opts} http://127.0.0.1:${server.address().port}/`; + const command = `ab ${opts} http://127.0.0.1:${server.address().port}/`; exec(command, function(err, stdout, stderr) { if (err) { if (/ab|apr/mi.test(stderr)) { @@ -29,17 +29,17 @@ function runAb(opts, callback) { return; } - var m = /Document Length:\s*(\d+) bytes/mi.exec(stdout); - var documentLength = parseInt(m[1]); + let m = /Document Length:\s*(\d+) bytes/mi.exec(stdout); + const documentLength = parseInt(m[1]); m = /Complete requests:\s*(\d+)/mi.exec(stdout); - var completeRequests = parseInt(m[1]); + const completeRequests = parseInt(m[1]); m = /HTML transferred:\s*(\d+) bytes/mi.exec(stdout); - var htmlTransfered = parseInt(m[1]); + const htmlTransfered = parseInt(m[1]); - assert.equal(bodyLength, documentLength); - assert.equal(completeRequests * documentLength, htmlTransfered); + assert.strictEqual(bodyLength, documentLength); + assert.strictEqual(completeRequests * documentLength, htmlTransfered); if (callback) callback(); }); diff --git a/test/parallel/test-http-get-pipeline-problem.js b/test/parallel/test-http-get-pipeline-problem.js index cc681f675a791e..56bfb33456dff7 100644 --- a/test/parallel/test-http-get-pipeline-problem.js +++ b/test/parallel/test-http-get-pipeline-problem.js @@ -2,23 +2,23 @@ // In previous versions of Node.js (e.g., 0.6.0), this sort of thing would halt // after http.globalAgent.maxSockets number of files. // See https://groups.google.com/forum/#!topic/nodejs-dev/V5fB69hFa9o -var common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); +const fs = require('fs'); http.globalAgent.maxSockets = 1; common.refreshTmpDir(); -var image = fs.readFileSync(common.fixturesDir + '/person.jpg'); +const image = fs.readFileSync(common.fixturesDir + '/person.jpg'); console.log('image.length = ' + image.length); -var total = 10; -var requests = 0, responses = 0; +const total = 10; +let requests = 0, responses = 0; -var server = http.Server(function(req, res) { +const server = http.Server(function(req, res) { if (++requests === total) { server.close(); } @@ -35,18 +35,18 @@ var server = http.Server(function(req, res) { server.listen(0, function() { - for (var i = 0; i < total; i++) { + for (let i = 0; i < total; i++) { (function() { - var x = i; + const x = i; - var opts = { + const opts = { port: server.address().port, headers: { connection: 'close' } }; http.get(opts, function(res) { console.error('recv ' + x); - var s = fs.createWriteStream(common.tmpDir + '/' + x + '.jpg'); + const s = fs.createWriteStream(common.tmpDir + '/' + x + '.jpg'); res.pipe(s); s.on('finish', function() { @@ -64,18 +64,18 @@ server.listen(0, function() { }); -var checkedFiles = false; +let checkedFiles = false; function checkFiles() { // Should see 1.jpg, 2.jpg, ..., 100.jpg in tmpDir - var files = fs.readdirSync(common.tmpDir); + const files = fs.readdirSync(common.tmpDir); assert(total <= files.length); - for (var i = 0; i < total; i++) { - var fn = i + '.jpg'; + for (let i = 0; i < total; i++) { + const fn = i + '.jpg'; assert.ok(files.indexOf(fn) >= 0, "couldn't find '" + fn + "'"); - var stat = fs.statSync(common.tmpDir + '/' + fn); - assert.equal(image.length, stat.size, - "size doesn't match on '" + fn + + const stat = fs.statSync(common.tmpDir + '/' + fn); + assert.strictEqual(image.length, stat.size, + "size doesn't match on '" + fn + "'. Got " + stat.size + ' bytes'); } @@ -84,7 +84,7 @@ function checkFiles() { process.on('exit', function() { - assert.equal(total, requests); - assert.equal(total, responses); + assert.strictEqual(total, requests); + assert.strictEqual(total, responses); assert.ok(checkedFiles); }); diff --git a/test/parallel/test-http-head-request.js b/test/parallel/test-http-head-request.js index e8626b18811bda..de94dfb8b7d6e7 100644 --- a/test/parallel/test-http-head-request.js +++ b/test/parallel/test-http-head-request.js @@ -1,11 +1,11 @@ 'use strict'; const common = require('../common'); -var http = require('http'); +const http = require('http'); -var body = 'hello world\n'; +const body = 'hello world\n'; function test(headers) { - var server = http.createServer(function(req, res) { + const server = http.createServer(function(req, res) { console.error('req: %s headers: %j', req.method, headers); res.writeHead(200, headers); res.end(); @@ -13,7 +13,7 @@ function test(headers) { }); server.listen(0, common.mustCall(function() { - var request = http.request({ + const request = http.request({ port: this.address().port, method: 'HEAD', path: '/' diff --git a/test/parallel/test-http-head-response-has-no-body-end.js b/test/parallel/test-http-head-response-has-no-body-end.js index 87ce957df3499f..de5ca976fc47b0 100644 --- a/test/parallel/test-http-head-response-has-no-body-end.js +++ b/test/parallel/test-http-head-response-has-no-body-end.js @@ -1,19 +1,19 @@ 'use strict'; const common = require('../common'); -var http = require('http'); +const http = require('http'); // This test is to make sure that when the HTTP server // responds to a HEAD request with data to res.end, // it does not send any body. -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200); res.end('FAIL'); // broken: sends FAIL from hot path. }); server.listen(0); server.on('listening', common.mustCall(function() { - var req = http.request({ + const req = http.request({ port: this.address().port, method: 'HEAD', path: '/' diff --git a/test/parallel/test-http-head-response-has-no-body.js b/test/parallel/test-http-head-response-has-no-body.js index 445b522b8dea51..b2eb98b1eea06c 100644 --- a/test/parallel/test-http-head-response-has-no-body.js +++ b/test/parallel/test-http-head-response-has-no-body.js @@ -1,19 +1,19 @@ 'use strict'; const common = require('../common'); -var http = require('http'); +const http = require('http'); // This test is to make sure that when the HTTP server // responds to a HEAD request, it does not send any body. // In this case it was sending '0\r\n\r\n' -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200); // broken: defaults to TE chunked res.end(); }); server.listen(0); server.on('listening', common.mustCall(function() { - var req = http.request({ + const req = http.request({ port: this.address().port, method: 'HEAD', path: '/' diff --git a/test/parallel/test-http-header-read.js b/test/parallel/test-http-header-read.js index b726fe130f0ee4..5465fd30f272be 100644 --- a/test/parallel/test-http-header-read.js +++ b/test/parallel/test-http-header-read.js @@ -1,14 +1,14 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); // Verify that ServerResponse.getHeader() works correctly even after // the response header has been sent. Issue 752 on github. -var s = http.createServer(function(req, res) { - var contentType = 'Content-Type'; - var plain = 'text/plain'; +const s = http.createServer(function(req, res) { + const contentType = 'Content-Type'; + const plain = 'text/plain'; res.setHeader(contentType, plain); assert.ok(!res.headersSent); res.writeHead(200); @@ -18,7 +18,7 @@ var s = http.createServer(function(req, res) { // and does not throw an exception (Issue 752) assert.doesNotThrow( function() { - assert.equal(plain, res.getHeader(contentType)); + assert.strictEqual(plain, res.getHeader(contentType)); } ); }); diff --git a/test/parallel/test-http-hex-write.js b/test/parallel/test-http-hex-write.js index adfe18077a8259..211f818e566699 100644 --- a/test/parallel/test-http-hex-write.js +++ b/test/parallel/test-http-hex-write.js @@ -1,10 +1,10 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); -var expect = 'hex\nutf8\n'; +const expect = 'hex\nutf8\n'; http.createServer(function(q, s) { s.setHeader('content-length', expect.length); @@ -15,7 +15,7 @@ http.createServer(function(q, s) { }).listen(0, common.mustCall(function() { http.request({ port: this.address().port }) .on('response', common.mustCall(function(res) { - var data = ''; + let data = ''; res.setEncoding('ascii'); res.on('data', function(c) { diff --git a/test/parallel/test-http-host-header-ipv6-fail.js b/test/parallel/test-http-host-header-ipv6-fail.js index 5f81234edba352..94351bc5c167e4 100644 --- a/test/parallel/test-http-host-header-ipv6-fail.js +++ b/test/parallel/test-http-host-header-ipv6-fail.js @@ -16,7 +16,7 @@ const http = require('http'); const hostname = '::1'; function httpreq() { - var req = http.request({ + const req = http.request({ host: hostname, port: server.address().port, path: '/', diff --git a/test/parallel/test-http-host-headers.js b/test/parallel/test-http-host-headers.js index a9f12d6819314e..79a2833f7df148 100644 --- a/test/parallel/test-http-host-headers.js +++ b/test/parallel/test-http-host-headers.js @@ -1,90 +1,75 @@ 'use strict'; -require('../common'); +const common = require('../common'); const http = require('http'); const assert = require('assert'); const httpServer = http.createServer(reqHandler); function reqHandler(req, res) { - console.log('Got request: ' + req.headers.host + ' ' + req.url); if (req.url === '/setHostFalse5') { - assert.equal(req.headers.host, undefined); + assert.strictEqual(req.headers.host, undefined); } else { - assert.equal(req.headers.host, `localhost:${this.address().port}`, - 'Wrong host header for req[' + req.url + ']: ' + + assert.strictEqual(req.headers.host, `localhost:${this.address().port}`, + 'Wrong host header for req[' + req.url + ']: ' + req.headers.host); } res.writeHead(200, {}); - //process.nextTick(function() { res.end('ok'); }); res.end('ok'); } -function thrower(er) { - throw er; -} - testHttp(); function testHttp() { - var counter = 0; + let counter = 0; function cb(res) { counter--; - console.log('back from http request. counter = ' + counter); if (counter === 0) { httpServer.close(); } res.resume(); } - httpServer.listen(0, function(er) { - console.error(`test http server listening on ${this.address().port}`); - - if (er) throw er; - + httpServer.listen(0, (er) => { + assert.ifError(er); http.get({ method: 'GET', path: '/' + (counter++), host: 'localhost', - //agent: false, - port: this.address().port, + port: httpServer.address().port, rejectUnauthorized: false - }, cb).on('error', thrower); + }, cb).on('error', common.fail); http.request({ method: 'GET', path: '/' + (counter++), host: 'localhost', - //agent: false, - port: this.address().port, + port: httpServer.address().port, rejectUnauthorized: false - }, cb).on('error', thrower).end(); + }, cb).on('error', common.fail).end(); http.request({ method: 'POST', path: '/' + (counter++), host: 'localhost', - //agent: false, - port: this.address().port, + port: httpServer.address().port, rejectUnauthorized: false - }, cb).on('error', thrower).end(); + }, cb).on('error', common.fail).end(); http.request({ method: 'PUT', path: '/' + (counter++), host: 'localhost', - //agent: false, - port: this.address().port, + port: httpServer.address().port, rejectUnauthorized: false - }, cb).on('error', thrower).end(); + }, cb).on('error', common.fail).end(); http.request({ method: 'DELETE', path: '/' + (counter++), host: 'localhost', - //agent: false, - port: this.address().port, + port: httpServer.address().port, rejectUnauthorized: false - }, cb).on('error', thrower).end(); + }, cb).on('error', common.fail).end(); }); } diff --git a/test/parallel/test-http-incoming-matchKnownFields.js b/test/parallel/test-http-incoming-matchKnownFields.js new file mode 100644 index 00000000000000..7411be4e847d73 --- /dev/null +++ b/test/parallel/test-http-incoming-matchKnownFields.js @@ -0,0 +1,90 @@ +'use strict'; +require('../common'); +const assert = require('assert'); +const IncomingMessage = require('http').IncomingMessage; + +function checkDest(field, result, value) { + const dest = {}; + + if (value) dest[field] = 'test'; + const incomingMessage = new IncomingMessage(field); + // dest is changed by IncomingMessage._addHeaderLine + incomingMessage._addHeaderLine(field, value, dest); + assert.deepStrictEqual(dest, result); +} + +checkDest('', {'': undefined}); +checkDest('Content-Type', {'content-type': undefined}); +checkDest('content-type', {'content-type': 'test'}, 'value'); +checkDest('User-Agent', {'user-agent': undefined}); +checkDest('user-agent', {'user-agent': 'test'}, 'value'); +checkDest('Referer', {referer: undefined}); +checkDest('referer', {referer: 'test'}, 'value'); +checkDest('Host', {host: undefined}); +checkDest('host', {host: 'test'}, 'value'); +checkDest('Authorization', {authorization: undefined}, undefined); +checkDest('authorization', {authorization: 'test'}, 'value'); +checkDest('Proxy-Authorization', {'proxy-authorization': undefined}); +checkDest('proxy-authorization', {'proxy-authorization': 'test'}, 'value'); +checkDest('If-Modified-Since', {'if-modified-since': undefined}); +checkDest('if-modified-since', {'if-modified-since': 'test'}, 'value'); +checkDest('If-Unmodified-Since', {'if-unmodified-since': undefined}); +checkDest('if-unmodified-since', {'if-unmodified-since': 'test'}, 'value'); +checkDest('Form', {form: undefined}); +checkDest('form', {form: 'test, value'}, 'value'); +checkDest('Location', {location: undefined}); +checkDest('location', {location: 'test'}, 'value'); +checkDest('Max-Forwards', {'max-forwards': undefined}); +checkDest('max-forwards', {'max-forwards': 'test'}, 'value'); +checkDest('Retry-After', {'retry-after': undefined}); +checkDest('retry-after', {'retry-after': 'test'}, 'value'); +checkDest('Etag', {etag: undefined}); +checkDest('etag', {etag: 'test'}, 'value'); +checkDest('Last-Modified', {'last-modified': undefined}); +checkDest('last-modified', {'last-modified': 'test'}, 'value'); +checkDest('Server', {server: undefined}); +checkDest('server', {server: 'test'}, 'value'); +checkDest('Age', {age: undefined}); +checkDest('age', {age: 'test'}, 'value'); +checkDest('Expires', {expires: undefined}); +checkDest('expires', {expires: 'test'}, 'value'); +checkDest('Set-Cookie', {'set-cookie': [undefined]}); +checkDest('set-cookie', {'set-cookie': [undefined]}); +checkDest('Transfer-Encoding', {'transfer-encoding': undefined}); +checkDest('transfer-encoding', {'transfer-encoding': 'test, value'}, 'value'); +checkDest('Date', {date: undefined}); +checkDest('date', {date: 'test, value'}, 'value'); +checkDest('Connection', {connection: undefined}); +checkDest('connection', {connection: 'test, value'}, 'value'); +checkDest('Cache-Control', {'cache-control': undefined}); +checkDest('cache-control', {'cache-control': 'test, value'}, 'value'); +checkDest('Transfer-Encoding', {'transfer-encoding': undefined}); +checkDest('transfer-encoding', {'transfer-encoding': 'test, value'}, 'value'); +checkDest('Vary', {vary: undefined}); +checkDest('vary', {vary: 'test, value'}, 'value'); +checkDest('Content-Encoding', {'content-encoding': undefined}, undefined); +checkDest('content-encoding', {'content-encoding': 'test, value'}, 'value'); +checkDest('Cookies', {cookies: undefined}); +checkDest('cookies', {cookies: 'test, value'}, 'value'); +checkDest('Origin', {origin: undefined}); +checkDest('origin', {origin: 'test, value'}, 'value'); +checkDest('Upgrade', {upgrade: undefined}); +checkDest('upgrade', {upgrade: 'test, value'}, 'value'); +checkDest('Expect', {expect: undefined}); +checkDest('expect', {expect: 'test, value'}, 'value'); +checkDest('If-Match', {'if-match': undefined}); +checkDest('if-match', {'if-match': 'test, value'}, 'value'); +checkDest('If-None-Match', {'if-none-match': undefined}); +checkDest('if-none-match', {'if-none-match': 'test, value'}, 'value'); +checkDest('Accept', {accept: undefined}); +checkDest('accept', {accept: 'test, value'}, 'value'); +checkDest('Accept-Encoding', {'accept-encoding': undefined}); +checkDest('accept-encoding', {'accept-encoding': 'test, value'}, 'value'); +checkDest('Accept-Language', {'accept-language': undefined}); +checkDest('accept-language', {'accept-language': 'test, value'}, 'value'); +checkDest('X-Forwarded-For', {'x-forwarded-for': undefined}); +checkDest('x-forwarded-for', {'x-forwarded-for': 'test, value'}, 'value'); +checkDest('X-Forwarded-Host', {'x-forwarded-host': undefined}); +checkDest('x-forwarded-host', {'x-forwarded-host': 'test, value'}, 'value'); +checkDest('X-Forwarded-Proto', {'x-forwarded-proto': undefined}); +checkDest('x-forwarded-proto', {'x-forwarded-proto': 'test, value'}, 'value'); diff --git a/test/parallel/test-http-invalidheaderfield.js b/test/parallel/test-http-invalidheaderfield.js index 9d4a12a952a838..aaed46c69cd592 100644 --- a/test/parallel/test-http-invalidheaderfield.js +++ b/test/parallel/test-http-invalidheaderfield.js @@ -5,7 +5,7 @@ const EventEmitter = require('events'); const http = require('http'); const ee = new EventEmitter(); -var count = 3; +let count = 3; const server = http.createServer(function(req, res) { assert.doesNotThrow(function() { @@ -24,7 +24,7 @@ server.listen(0, function() { assert.throws( function() { - var options = { + const options = { port: server.address().port, headers: {'testing 123': 123} }; @@ -38,7 +38,7 @@ server.listen(0, function() { assert.doesNotThrow( function() { - var options = { + const options = { port: server.address().port, headers: {'testing_123': 123} }; diff --git a/test/parallel/test-http-keep-alive-close-on-header.js b/test/parallel/test-http-keep-alive-close-on-header.js index d9396b258e7515..b36fb2e8db9a5a 100644 --- a/test/parallel/test-http-keep-alive-close-on-header.js +++ b/test/parallel/test-http-keep-alive-close-on-header.js @@ -1,31 +1,31 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var body = 'hello world\n'; -var headers = {'connection': 'keep-alive'}; +const body = 'hello world\n'; +const headers = {'connection': 'keep-alive'}; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Length': body.length, 'Connection': 'close'}); res.write(body); res.end(); }); -var connectCount = 0; +let connectCount = 0; server.listen(0, function() { - var agent = new http.Agent({ maxSockets: 1 }); - var name = agent.getName({ port: this.address().port }); - var request = http.request({ + const agent = new http.Agent({ maxSockets: 1 }); + const name = agent.getName({ port: this.address().port }); + let request = http.request({ method: 'GET', path: '/', headers: headers, port: this.address().port, agent: agent }, function(res) { - assert.equal(1, agent.sockets[name].length); + assert.strictEqual(1, agent.sockets[name].length); res.resume(); }); request.on('socket', function(s) { @@ -42,7 +42,7 @@ server.listen(0, function() { port: this.address().port, agent: agent }, function(res) { - assert.equal(1, agent.sockets[name].length); + assert.strictEqual(1, agent.sockets[name].length); res.resume(); }); request.on('socket', function(s) { @@ -59,7 +59,7 @@ server.listen(0, function() { agent: agent }, function(response) { response.on('end', function() { - assert.equal(1, agent.sockets[name].length); + assert.strictEqual(1, agent.sockets[name].length); server.close(); }); response.resume(); @@ -73,5 +73,5 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.equal(3, connectCount); + assert.strictEqual(3, connectCount); }); diff --git a/test/parallel/test-http-keepalive-client.js b/test/parallel/test-http-keepalive-client.js index 955fc006e22d58..eaefa3887c395d 100644 --- a/test/parallel/test-http-keepalive-client.js +++ b/test/parallel/test-http-keepalive-client.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); -var serverSocket = null; -var server = http.createServer(function(req, res) { +let serverSocket = null; +const server = http.createServer(function(req, res) { // They should all come in on the same server socket. if (serverSocket) { - assert.equal(req.socket, serverSocket); + assert.strictEqual(req.socket, serverSocket); } else { serverSocket = req.socket; } @@ -20,12 +20,12 @@ server.listen(0, function() { makeRequest(expectRequests); }); -var agent = http.Agent({ keepAlive: true }); +const agent = http.Agent({ keepAlive: true }); -var clientSocket = null; -var expectRequests = 10; -var actualRequests = 0; +let clientSocket = null; +const expectRequests = 10; +let actualRequests = 0; function makeRequest(n) { @@ -35,7 +35,7 @@ function makeRequest(n) { return; } - var req = http.request({ + const req = http.request({ port: server.address().port, agent: agent, path: '/' + n @@ -45,20 +45,20 @@ function makeRequest(n) { req.on('socket', function(sock) { if (clientSocket) { - assert.equal(sock, clientSocket); + assert.strictEqual(sock, clientSocket); } else { clientSocket = sock; } }); req.on('response', function(res) { - var data = ''; + let data = ''; res.setEncoding('utf8'); res.on('data', function(c) { data += c; }); res.on('end', function() { - assert.equal(data, '/' + n); + assert.strictEqual(data, '/' + n); setTimeout(function() { actualRequests++; makeRequest(n - 1); @@ -68,6 +68,6 @@ function makeRequest(n) { } process.on('exit', function() { - assert.equal(actualRequests, expectRequests); + assert.strictEqual(actualRequests, expectRequests); console.log('ok'); }); diff --git a/test/parallel/test-http-keepalive-maxsockets.js b/test/parallel/test-http-keepalive-maxsockets.js index 6f1476d0ce3aed..0d684a43f778f9 100644 --- a/test/parallel/test-http-keepalive-maxsockets.js +++ b/test/parallel/test-http-keepalive-maxsockets.js @@ -1,38 +1,38 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); -var serverSockets = []; -var server = http.createServer(function(req, res) { +const serverSockets = []; +const server = http.createServer(function(req, res) { if (serverSockets.indexOf(req.socket) === -1) { serverSockets.push(req.socket); } res.end(req.url); }); server.listen(0, function() { - var agent = http.Agent({ + const agent = http.Agent({ keepAlive: true, maxSockets: 5, maxFreeSockets: 2 }); - var closed = false; + let closed = false; makeReqs(10, function(er) { assert.ifError(er); - assert.equal(count(agent.freeSockets), 2); - assert.equal(count(agent.sockets), 0); - assert.equal(serverSockets.length, 5); + assert.strictEqual(count(agent.freeSockets), 2); + assert.strictEqual(count(agent.sockets), 0); + assert.strictEqual(serverSockets.length, 5); // now make 10 more reqs. // should use the 2 free reqs from the pool first. makeReqs(10, function(er) { assert.ifError(er); - assert.equal(count(agent.freeSockets), 2); - assert.equal(count(agent.sockets), 0); - assert.equal(serverSockets.length, 8); + assert.strictEqual(count(agent.freeSockets), 2); + assert.strictEqual(count(agent.sockets), 0); + assert.strictEqual(serverSockets.length, 8); agent.destroy(); server.close(function() { @@ -49,7 +49,7 @@ server.listen(0, function() { // make 10 requests in parallel, // then 10 more when they all finish. function makeReqs(n, cb) { - for (var i = 0; i < n; i++) + for (let i = 0; i < n; i++) makeReq(i, then); function then(er) { @@ -66,13 +66,13 @@ server.listen(0, function() { path: '/' + i, agent: agent }, function(res) { - var data = ''; + let data = ''; res.setEncoding('ascii'); res.on('data', function(c) { data += c; }); res.on('end', function() { - assert.equal(data, '/' + i); + assert.strictEqual(data, '/' + i); cb(); }); }).end(); diff --git a/test/parallel/test-http-keepalive-request.js b/test/parallel/test-http-keepalive-request.js index daae5aa9944294..5f53f6d999f38d 100644 --- a/test/parallel/test-http-keepalive-request.js +++ b/test/parallel/test-http-keepalive-request.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); -var serverSocket = null; -var server = http.createServer(function(req, res) { +let serverSocket = null; +const server = http.createServer(function(req, res) { // They should all come in on the same server socket. if (serverSocket) { - assert.equal(req.socket, serverSocket); + assert.strictEqual(req.socket, serverSocket); } else { serverSocket = req.socket; } @@ -20,12 +20,12 @@ server.listen(0, function() { makeRequest(expectRequests); }); -var agent = http.Agent({ keepAlive: true }); +const agent = http.Agent({ keepAlive: true }); -var clientSocket = null; -var expectRequests = 10; -var actualRequests = 0; +let clientSocket = null; +const expectRequests = 10; +let actualRequests = 0; function makeRequest(n) { @@ -35,7 +35,7 @@ function makeRequest(n) { return; } - var req = http.request({ + const req = http.request({ port: server.address().port, path: '/' + n, agent: agent @@ -45,20 +45,20 @@ function makeRequest(n) { req.on('socket', function(sock) { if (clientSocket) { - assert.equal(sock, clientSocket); + assert.strictEqual(sock, clientSocket); } else { clientSocket = sock; } }); req.on('response', function(res) { - var data = ''; + let data = ''; res.setEncoding('utf8'); res.on('data', function(c) { data += c; }); res.on('end', function() { - assert.equal(data, '/' + n); + assert.strictEqual(data, '/' + n); setTimeout(function() { actualRequests++; makeRequest(n - 1); @@ -68,6 +68,6 @@ function makeRequest(n) { } process.on('exit', function() { - assert.equal(actualRequests, expectRequests); + assert.strictEqual(actualRequests, expectRequests); console.log('ok'); }); diff --git a/test/parallel/test-http-localaddress-bind-error.js b/test/parallel/test-http-localaddress-bind-error.js index 0b828910f12873..a23c6f2a4452a6 100644 --- a/test/parallel/test-http-localaddress-bind-error.js +++ b/test/parallel/test-http-localaddress-bind-error.js @@ -1,10 +1,10 @@ 'use strict'; const common = require('../common'); -var http = require('http'); +const http = require('http'); -var invalidLocalAddress = '1.2.3.4'; +const invalidLocalAddress = '1.2.3.4'; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { console.log('Connect from: ' + req.connection.remoteAddress); req.on('end', function() { diff --git a/test/parallel/test-http-localaddress.js b/test/parallel/test-http-localaddress.js index fd38f8a901fe81..d48a4ec8f5b0ee 100644 --- a/test/parallel/test-http-localaddress.js +++ b/test/parallel/test-http-localaddress.js @@ -8,9 +8,9 @@ if (!common.hasMultiLocalhost()) { return; } -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { console.log('Connect from: ' + req.connection.remoteAddress); - assert.equal('127.0.0.2', req.connection.remoteAddress); + assert.strictEqual('127.0.0.2', req.connection.remoteAddress); req.on('end', function() { res.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -20,13 +20,13 @@ var server = http.createServer(function(req, res) { }); server.listen(0, '127.0.0.1', function() { - var options = { host: 'localhost', - port: this.address().port, - path: '/', - method: 'GET', - localAddress: '127.0.0.2' }; + const options = { host: 'localhost', + port: this.address().port, + path: '/', + method: 'GET', + localAddress: '127.0.0.2' }; - var req = http.request(options, function(res) { + const req = http.request(options, function(res) { res.on('end', function() { server.close(); process.exit(); diff --git a/test/parallel/test-http-malformed-request.js b/test/parallel/test-http-malformed-request.js index 647b67bcd3ff78..93aff802c7afbd 100644 --- a/test/parallel/test-http-malformed-request.js +++ b/test/parallel/test-http-malformed-request.js @@ -1,17 +1,17 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const net = require('net'); +const http = require('http'); +const url = require('url'); // Make sure no exceptions are thrown when receiving malformed HTTP // requests. -var nrequests_completed = 0; -var nrequests_expected = 1; +let nrequests_completed = 0; +const nrequests_expected = 1; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { console.log('req: ' + JSON.stringify(url.parse(req.url))); res.writeHead(200, {'Content-Type': 'text/plain'}); @@ -23,7 +23,7 @@ var server = http.createServer(function(req, res) { server.listen(0); server.on('listening', function() { - var c = net.createConnection(this.address().port); + const c = net.createConnection(this.address().port); c.on('connect', function() { c.write('GET /hello?foo=%99bar HTTP/1.1\r\n\r\n'); c.end(); @@ -31,5 +31,5 @@ server.on('listening', function() { }); process.on('exit', function() { - assert.equal(nrequests_expected, nrequests_completed); + assert.strictEqual(nrequests_expected, nrequests_completed); }); diff --git a/test/parallel/test-http-many-ended-pipelines.js b/test/parallel/test-http-many-ended-pipelines.js index 7966f47a9efa19..b4af99ef00a9d4 100644 --- a/test/parallel/test-http-many-ended-pipelines.js +++ b/test/parallel/test-http-many-ended-pipelines.js @@ -2,19 +2,19 @@ require('../common'); // no warnings should happen! -var trace = console.trace; +const trace = console.trace; console.trace = function() { trace.apply(console, arguments); throw new Error('no tracing should happen here'); }; -var http = require('http'); -var net = require('net'); +const http = require('http'); +const net = require('net'); -var numRequests = 20; -var first = false; +const numRequests = 20; +let first = false; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { if (!first) { first = true; req.socket.on('close', function() { @@ -28,8 +28,9 @@ var server = http.createServer(function(req, res) { }); server.listen(0, function() { - var client = net.connect({ port: this.address().port, allowHalfOpen: true }); - for (var i = 0; i < numRequests; i++) { + const client = net.connect({ port: this.address().port, + allowHalfOpen: true }); + for (let i = 0; i < numRequests; i++) { client.write('GET / HTTP/1.1\r\n' + 'Host: some.host.name\r\n' + '\r\n\r\n'); diff --git a/test/parallel/test-http-max-headers-count.js b/test/parallel/test-http-max-headers-count.js index 2d68ead110fc6c..fd92637f7ac10b 100644 --- a/test/parallel/test-http-max-headers-count.js +++ b/test/parallel/test-http-max-headers-count.js @@ -1,27 +1,27 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var requests = 0; -var responses = 0; +let requests = 0; +let responses = 0; -var headers = {}; -var N = 2000; -for (var i = 0; i < N; ++i) { +const headers = {}; +const N = 2000; +for (let i = 0; i < N; ++i) { headers['key' + i] = i; } -var maxAndExpected = [ // for server +const maxAndExpected = [ // for server [50, 50], [1500, 1500], [0, N + 2] // Host and Connection ]; -var max = maxAndExpected[requests][0]; -var expected = maxAndExpected[requests][1]; +let max = maxAndExpected[requests][0]; +let expected = maxAndExpected[requests][1]; -var server = http.createServer(function(req, res) { - assert.equal(Object.keys(req.headers).length, expected); +const server = http.createServer(function(req, res) { + assert.strictEqual(Object.keys(req.headers).length, expected); if (++requests < maxAndExpected.length) { max = maxAndExpected[requests][0]; expected = maxAndExpected[requests][1]; @@ -33,7 +33,7 @@ var server = http.createServer(function(req, res) { server.maxHeadersCount = max; server.listen(0, function() { - var maxAndExpected = [ // for client + const maxAndExpected = [ // for client [20, 20], [1200, 1200], [0, N + 3] // Connection, Date and Transfer-Encoding @@ -41,13 +41,13 @@ server.listen(0, function() { doRequest(); function doRequest() { - var max = maxAndExpected[responses][0]; - var expected = maxAndExpected[responses][1]; - var req = http.request({ + const max = maxAndExpected[responses][0]; + const expected = maxAndExpected[responses][1]; + const req = http.request({ port: server.address().port, headers: headers }, function(res) { - assert.equal(Object.keys(res.headers).length, expected); + assert.strictEqual(Object.keys(res.headers).length, expected); res.on('end', function() { if (++responses < maxAndExpected.length) { doRequest(); @@ -63,6 +63,6 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.equal(requests, maxAndExpected.length); - assert.equal(responses, maxAndExpected.length); + assert.strictEqual(requests, maxAndExpected.length); + assert.strictEqual(responses, maxAndExpected.length); }); diff --git a/test/parallel/test-http-methods.js b/test/parallel/test-http-methods.js index d3d4fedd46361b..6ba02807f8706b 100644 --- a/test/parallel/test-http-methods.js +++ b/test/parallel/test-http-methods.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var util = require('util'); +const assert = require('assert'); +const http = require('http'); +const util = require('util'); assert(Array.isArray(http.METHODS)); assert(http.METHODS.length > 0); diff --git a/test/parallel/test-http-multi-line-headers.js b/test/parallel/test-http-multi-line-headers.js index df333cdd62bf9b..f7998c254870d5 100644 --- a/test/parallel/test-http-multi-line-headers.js +++ b/test/parallel/test-http-multi-line-headers.js @@ -1,14 +1,14 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); -var net = require('net'); +const http = require('http'); +const net = require('net'); -var server = net.createServer(function(conn) { - var body = 'Yet another node.js server.'; +const server = net.createServer(function(conn) { + const body = 'Yet another node.js server.'; - var response = + const response = 'HTTP/1.1 200 OK\r\n' + 'Connection: close\r\n' + 'Content-Length: ' + body.length + '\r\n' + @@ -27,8 +27,8 @@ server.listen(0, common.mustCall(function() { host: '127.0.0.1', port: this.address().port }, common.mustCall(function(res) { - assert.equal(res.headers['content-type'], - 'text/plain; x-unix-mode=0600; name="hello.txt"'); + assert.strictEqual(res.headers['content-type'], + 'text/plain; x-unix-mode=0600; name="hello.txt"'); res.destroy(); })); })); diff --git a/test/parallel/test-http-mutable-headers.js b/test/parallel/test-http-mutable-headers.js index 0228a4e216ec46..072dd97076fe1a 100644 --- a/test/parallel/test-http-mutable-headers.js +++ b/test/parallel/test-http-mutable-headers.js @@ -1,7 +1,7 @@ 'use strict'; -require('../common'); -var assert = require('assert'); -var http = require('http'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); // Simple test of Node's HTTP Client mutable headers // OutgoingMessage.prototype.setHeader(name, value) @@ -11,43 +11,48 @@ var http = require('http'); // .method // .path -var testsComplete = 0; -var test = 'headers'; -var content = 'hello world\n'; -var cookies = [ +let test = 'headers'; +const content = 'hello world\n'; +const cookies = [ 'session_token=; path=/; expires=Sun, 15-Sep-2030 13:48:52 GMT', 'prefers_open_id=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT' ]; -var s = http.createServer(function(req, res) { +const s = http.createServer(common.mustCall((req, res) => { switch (test) { case 'headers': - assert.throws(function() { res.setHeader(); }); - assert.throws(function() { res.setHeader('someHeader'); }); - assert.throws(function() { res.getHeader(); }); - assert.throws(function() { res.removeHeader(); }); + assert.throws(() => { + res.setHeader(); + }, /^TypeError: Header name must be a valid HTTP Token \["undefined"\]$/); + assert.throws(() => { + res.setHeader('someHeader'); + }, /^Error: "value" required in setHeader\("someHeader", value\)$/); + assert.throws(() => { + res.getHeader(); + }, /^Error: "name" argument is required for getHeader\(name\)$/); + assert.throws(() => { + res.removeHeader(); + }, /^Error: "name" argument is required for removeHeader\(name\)$/); res.setHeader('x-test-header', 'testing'); res.setHeader('X-TEST-HEADER2', 'testing'); res.setHeader('set-cookie', cookies); res.setHeader('x-test-array-header', [1, 2, 3]); - var val1 = res.getHeader('x-test-header'); - var val2 = res.getHeader('x-test-header2'); - assert.equal(val1, 'testing'); - assert.equal(val2, 'testing'); + assert.strictEqual(res.getHeader('x-test-header'), 'testing'); + assert.strictEqual(res.getHeader('x-test-header2'), 'testing'); res.removeHeader('x-test-header2'); break; case 'contentLength': res.setHeader('content-length', content.length); - assert.equal(content.length, res.getHeader('Content-Length')); + assert.strictEqual(res.getHeader('Content-Length'), content.length); break; case 'transferEncoding': res.setHeader('transfer-encoding', 'chunked'); - assert.equal(res.getHeader('Transfer-Encoding'), 'chunked'); + assert.strictEqual(res.getHeader('Transfer-Encoding'), 'chunked'); break; case 'writeHead': @@ -55,11 +60,14 @@ var s = http.createServer(function(req, res) { res.setHeader('x-foo', 'keyboard cat'); res.writeHead(200, { 'x-foo': 'bar', 'x-bar': 'baz' }); break; + + default: + common.fail('Unknown test'); } res.statusCode = 201; res.end(content); -}); +}, 4)); s.listen(0, nextTest); @@ -69,64 +77,49 @@ function nextTest() { return s.close(); } - var bufferedResponse = ''; - - http.get({ port: s.address().port }, function(response) { - console.log('TEST: ' + test); - console.log('STATUS: ' + response.statusCode); - console.log('HEADERS: '); - console.dir(response.headers); + let bufferedResponse = ''; + http.get({ port: s.address().port }, common.mustCall((response) => { switch (test) { case 'headers': - assert.equal(response.statusCode, 201); - assert.equal(response.headers['x-test-header'], - 'testing'); - assert.equal(response.headers['x-test-array-header'], - [1, 2, 3].join(', ')); - assert.deepStrictEqual(cookies, - response.headers['set-cookie']); - assert.equal(response.headers['x-test-header2'] !== undefined, false); - // Make the next request + assert.strictEqual(response.statusCode, 201); + assert.strictEqual(response.headers['x-test-header'], 'testing'); + assert.strictEqual(response.headers['x-test-array-header'], + [1, 2, 3].join(', ')); + assert.deepStrictEqual(cookies, response.headers['set-cookie']); + assert.strictEqual(response.headers['x-test-header2'], undefined); test = 'contentLength'; - console.log('foobar'); break; case 'contentLength': - assert.equal(response.headers['content-length'], content.length); + assert.strictEqual(+response.headers['content-length'], content.length); test = 'transferEncoding'; break; case 'transferEncoding': - assert.equal(response.headers['transfer-encoding'], 'chunked'); + assert.strictEqual(response.headers['transfer-encoding'], 'chunked'); test = 'writeHead'; break; case 'writeHead': - assert.equal(response.headers['x-foo'], 'bar'); - assert.equal(response.headers['x-bar'], 'baz'); - assert.equal(200, response.statusCode); + assert.strictEqual(response.headers['x-foo'], 'bar'); + assert.strictEqual(response.headers['x-bar'], 'baz'); + assert.strictEqual(response.statusCode, 200); test = 'end'; break; default: - throw new Error('?'); + common.fail('Unknown test'); } response.setEncoding('utf8'); - response.on('data', function(s) { + response.on('data', (s) => { bufferedResponse += s; }); - response.on('end', function() { - assert.equal(content, bufferedResponse); - testsComplete++; - nextTest(); - }); - }); + response.on('end', common.mustCall(() => { + assert.strictEqual(bufferedResponse, content); + common.mustCall(nextTest)(); + })); + })); } - - -process.on('exit', function() { - assert.equal(4, testsComplete); -}); diff --git a/test/parallel/test-http-no-content-length.js b/test/parallel/test-http-no-content-length.js index b27ffda727129e..a6cfad13aa2b44 100644 --- a/test/parallel/test-http-no-content-length.js +++ b/test/parallel/test-http-no-content-length.js @@ -1,15 +1,15 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); -var http = require('http'); +const assert = require('assert'); +const net = require('net'); +const http = require('http'); -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { // Neither Content-Length nor Connection socket.end('HTTP/1.1 200 ok\r\n\r\nHello'); }).listen(0, common.mustCall(function() { http.get({port: this.address().port}, common.mustCall(function(res) { - var body = ''; + let body = ''; res.setEncoding('utf8'); res.on('data', function(chunk) { diff --git a/test/parallel/test-http-outgoing-finish.js b/test/parallel/test-http-outgoing-finish.js index 56ce777cb3eaaf..73654909d88e1b 100644 --- a/test/parallel/test-http-outgoing-finish.js +++ b/test/parallel/test-http-outgoing-finish.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); http.createServer(function(req, res) { req.resume(); @@ -11,7 +11,7 @@ http.createServer(function(req, res) { }); this.close(); }).listen(0, function() { - var req = http.request({ + const req = http.request({ port: this.address().port, method: 'PUT' }); @@ -21,11 +21,11 @@ http.createServer(function(req, res) { }); }); -var buf = Buffer.alloc(1024 * 16, 'x'); +const buf = Buffer.alloc(1024 * 16, 'x'); function write(out) { - var name = out.constructor.name; - var finishEvent = false; - var endCb = false; + const name = out.constructor.name; + let finishEvent = false; + let endCb = false; // first, write until it gets some backpressure while (out.write(buf)) {} diff --git a/test/parallel/test-http-outgoing-proto.js b/test/parallel/test-http-outgoing-proto.js index 738e1d2c8cfe4e..dac93638673082 100644 --- a/test/parallel/test-http-outgoing-proto.js +++ b/test/parallel/test-http-outgoing-proto.js @@ -7,8 +7,69 @@ const OutgoingMessage = http.OutgoingMessage; const ClientRequest = http.ClientRequest; const ServerResponse = http.ServerResponse; -assert.throws(OutgoingMessage.prototype._implicitHeader); +assert.throws(OutgoingMessage.prototype._implicitHeader, + /^Error: _implicitHeader\(\) method is not implemented$/); assert.strictEqual( typeof ClientRequest.prototype._implicitHeader, 'function'); assert.strictEqual( typeof ServerResponse.prototype._implicitHeader, 'function'); + +// validateHeader +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.setHeader(); +}, /^TypeError: Header name must be a valid HTTP Token \["undefined"\]$/); + +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.setHeader('test'); +}, /^Error: "value" required in setHeader\("test", value\)$/); + +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.setHeader(404); +}, /^TypeError: Header name must be a valid HTTP Token \["404"\]$/); + +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.setHeader.call({_header: 'test'}, 'test', 'value'); +}, /^Error: Can't set headers after they are sent.$/); + +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.setHeader('200', 'あ'); +}, /^TypeError: The header content contains invalid characters$/); + +// write +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.write(); +}, /^Error: _implicitHeader\(\) method is not implemented$/); + +assert(OutgoingMessage.prototype.write.call({_header: 'test'})); + +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.write.call({_header: 'test', _hasBody: 'test'}); +}, /^TypeError: First argument must be a string or Buffer$/); + +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.write.call({_header: 'test', _hasBody: 'test'}, 1); +}, /^TypeError: First argument must be a string or Buffer$/); + +// addTrailers +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.addTrailers(); +}, /^TypeError: Cannot convert undefined or null to object$/); + +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.addTrailers({'あ': 'value'}); +}, /^TypeError: Trailer name must be a valid HTTP Token \["あ"\]$/); + +assert.throws(() => { + const outgoingMessage = new OutgoingMessage(); + outgoingMessage.addTrailers({404: 'あ'}); +}, /^TypeError: The trailer content contains invalid characters$/); diff --git a/test/parallel/test-http-parser-bad-ref.js b/test/parallel/test-http-parser-bad-ref.js index 73d5f7eb13049c..97b4685e18382b 100644 --- a/test/parallel/test-http-parser-bad-ref.js +++ b/test/parallel/test-http-parser-bad-ref.js @@ -5,16 +5,16 @@ // Flags: --expose_gc require('../common'); -var assert = require('assert'); -var HTTPParser = process.binding('http_parser').HTTPParser; +const assert = require('assert'); +const HTTPParser = process.binding('http_parser').HTTPParser; -var kOnHeaders = HTTPParser.kOnHeaders | 0; -var kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; -var kOnBody = HTTPParser.kOnBody | 0; -var kOnMessageComplete = HTTPParser.kOnMessageComplete | 0; +const kOnHeaders = HTTPParser.kOnHeaders | 0; +const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; +const kOnBody = HTTPParser.kOnBody | 0; +const kOnMessageComplete = HTTPParser.kOnMessageComplete | 0; -var headersComplete = 0; -var messagesComplete = 0; +let headersComplete = 0; +let messagesComplete = 0; function flushPool() { Buffer.allocUnsafe(Buffer.poolSize - 1); @@ -24,7 +24,7 @@ function flushPool() { function demoBug(part1, part2) { flushPool(); - var parser = new HTTPParser('REQUEST'); + const parser = new HTTPParser('REQUEST'); parser.headers = []; parser.url = ''; @@ -49,7 +49,7 @@ function demoBug(part1, part2) { // We use a function to eliminate references to the Buffer b // We want b to be GCed. The parser will hold a bad reference to it. (function() { - var b = Buffer.from(part1); + const b = Buffer.from(part1); flushPool(); console.log('parse the first part of the message'); @@ -59,7 +59,7 @@ function demoBug(part1, part2) { flushPool(); (function() { - var b = Buffer.from(part2); + const b = Buffer.from(part2); console.log('parse the second part of the message'); parser.execute(b, 0, b.length); @@ -83,7 +83,7 @@ demoBug('POST /1/22 HTTP/1.1\r\n' + /* eslint-enable align-function-arguments */ process.on('exit', function() { - assert.equal(2, headersComplete); - assert.equal(2, messagesComplete); + assert.strictEqual(2, headersComplete); + assert.strictEqual(2, messagesComplete); console.log('done!'); }); diff --git a/test/parallel/test-http-parser-free.js b/test/parallel/test-http-parser-free.js index 125374bbedde63..aff0fa6198ef44 100644 --- a/test/parallel/test-http-parser-free.js +++ b/test/parallel/test-http-parser-free.js @@ -1,20 +1,20 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var N = 100; -var responses = 0; +const assert = require('assert'); +const http = require('http'); +const N = 100; +let responses = 0; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.end('Hello'); }); server.listen(0, function() { http.globalAgent.maxSockets = 1; - var parser; - for (var i = 0; i < N; ++i) { + let parser; + for (let i = 0; i < N; ++i) { (function makeRequest(i) { - var req = http.get({port: server.address().port}, function(res) { + const req = http.get({port: server.address().port}, function(res) { if (!parser) { parser = req.parser; } else { @@ -31,5 +31,5 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.equal(responses, N); + assert.strictEqual(responses, N); }); diff --git a/test/parallel/test-http-parser.js b/test/parallel/test-http-parser.js index abc1d096dff0d8..ba987876e63142 100644 --- a/test/parallel/test-http-parser.js +++ b/test/parallel/test-http-parser.js @@ -1,19 +1,19 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); const binding = process.binding('http_parser'); const methods = binding.methods; const HTTPParser = binding.HTTPParser; -var CRLF = '\r\n'; -var REQUEST = HTTPParser.REQUEST; -var RESPONSE = HTTPParser.RESPONSE; +const CRLF = '\r\n'; +const REQUEST = HTTPParser.REQUEST; +const RESPONSE = HTTPParser.RESPONSE; -var kOnHeaders = HTTPParser.kOnHeaders | 0; -var kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; -var kOnBody = HTTPParser.kOnBody | 0; -var kOnMessageComplete = HTTPParser.kOnMessageComplete | 0; +const kOnHeaders = HTTPParser.kOnHeaders | 0; +const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; +const kOnBody = HTTPParser.kOnBody | 0; +const kOnMessageComplete = HTTPParser.kOnMessageComplete | 0; // The purpose of this test is not to check HTTP compliance but to test the // binding. Tests for pathological http messages should be submitted @@ -22,7 +22,7 @@ var kOnMessageComplete = HTTPParser.kOnMessageComplete | 0; function newParser(type) { - var parser = new HTTPParser(type); + const parser = new HTTPParser(type); parser.headers = []; parser.url = ''; @@ -35,9 +35,7 @@ function newParser(type) { parser[kOnHeadersComplete] = function(info) { }; - parser[kOnBody] = function(b, start, len) { - assert.ok(false, 'Function should not be called.'); - }; + parser[kOnBody] = common.fail; parser[kOnMessageComplete] = function() { }; @@ -47,11 +45,11 @@ function newParser(type) { function mustCall(f, times) { - var actual = 0; + let actual = 0; process.setMaxListeners(256); process.on('exit', function() { - assert.equal(actual, times || 1); + assert.strictEqual(actual, times || 1); }); return function() { @@ -63,8 +61,8 @@ function mustCall(f, times) { function expectBody(expected) { return mustCall(function(buf, start, len) { - var body = '' + buf.slice(start, start + len); - assert.equal(body, expected); + const body = '' + buf.slice(start, start + len); + assert.strictEqual(body, expected); }); } @@ -447,11 +445,11 @@ function expectBody(expected) { assert.strictEqual(expected_body, ''); } - for (var i = 1; i < request.length - 1; ++i) { - var a = request.slice(0, i); + for (let i = 1; i < request.length - 1; ++i) { + const a = request.slice(0, i); console.error('request.slice(0, ' + i + ') = ', JSON.stringify(a.toString())); - var b = request.slice(i); + const b = request.slice(i); console.error('request.slice(' + i + ') = ', JSON.stringify(b.toString())); test(a, b); @@ -535,10 +533,10 @@ function expectBody(expected) { const onHeadersComplete1 = function(versionMajor, versionMinor, headers, method, url, statusCode, statusMessage, upgrade, shouldKeepAlive) { - assert.equal(method, methods.indexOf('PUT')); - assert.equal(url, '/this'); - assert.equal(versionMajor, 1); - assert.equal(versionMinor, 1); + assert.strictEqual(method, methods.indexOf('PUT')); + assert.strictEqual(url, '/this'); + assert.strictEqual(versionMajor, 1); + assert.strictEqual(versionMinor, 1); assert.deepStrictEqual( headers, ['Content-Type', 'text/plain', 'Transfer-Encoding', 'chunked']); @@ -571,11 +569,11 @@ function expectBody(expected) { // Test parser 'this' safety // https://github.com/joyent/node/issues/6690 assert.throws(function() { - var request = Buffer.from( + const request = Buffer.from( 'GET /hello HTTP/1.1' + CRLF + CRLF); - var parser = newParser(REQUEST); - var notparser = { execute: parser.execute }; + const parser = newParser(REQUEST); + const notparser = { execute: parser.execute }; notparser.execute(request, 0, request.length); }, TypeError); diff --git a/test/parallel/test-http-pause.js b/test/parallel/test-http-pause.js index f6562b3afc94ae..440cab413c50a5 100644 --- a/test/parallel/test-http-pause.js +++ b/test/parallel/test-http-pause.js @@ -1,14 +1,14 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var expectedServer = 'Request Body from Client'; -var resultServer = ''; -var expectedClient = 'Response Body from Server'; -var resultClient = ''; +const expectedServer = 'Request Body from Client'; +let resultServer = ''; +const expectedClient = 'Response Body from Server'; +let resultClient = ''; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { console.error('pause server request'); req.pause(); setTimeout(function() { @@ -27,7 +27,7 @@ var server = http.createServer(function(req, res) { }); server.listen(0, function() { - var req = http.request({ + const req = http.request({ port: this.address().port, path: '/', method: 'POST' @@ -50,6 +50,6 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.equal(expectedServer, resultServer); - assert.equal(expectedClient, resultClient); + assert.strictEqual(expectedServer, resultServer); + assert.strictEqual(expectedClient, resultClient); }); diff --git a/test/parallel/test-http-pipe-fs.js b/test/parallel/test-http-pipe-fs.js index 3205802d7ab0f2..5348637bd07145 100644 --- a/test/parallel/test-http-pipe-fs.js +++ b/test/parallel/test-http-pipe-fs.js @@ -1,15 +1,15 @@ 'use strict'; -var common = require('../common'); -var http = require('http'); -var fs = require('fs'); -var path = require('path'); +const common = require('../common'); +const http = require('http'); +const fs = require('fs'); +const path = require('path'); common.refreshTmpDir(); -var file = path.join(common.tmpDir, 'http-pipe-fs-test.txt'); +const file = path.join(common.tmpDir, 'http-pipe-fs-test.txt'); -var server = http.createServer(common.mustCall(function(req, res) { - var stream = fs.createWriteStream(file); +const server = http.createServer(common.mustCall(function(req, res) { + const stream = fs.createWriteStream(file); req.pipe(stream); stream.on('close', function() { res.writeHead(200); @@ -18,9 +18,9 @@ var server = http.createServer(common.mustCall(function(req, res) { }, 2)).listen(0, function() { http.globalAgent.maxSockets = 1; - for (var i = 0; i < 2; ++i) { + for (let i = 0; i < 2; ++i) { (function(i) { - var req = http.request({ + const req = http.request({ port: server.address().port, method: 'POST', headers: { diff --git a/test/parallel/test-http-pipeline-flood.js b/test/parallel/test-http-pipeline-flood.js index 4f6775656e4e49..99e4c3e7b5b9fe 100644 --- a/test/parallel/test-http-pipeline-flood.js +++ b/test/parallel/test-http-pipeline-flood.js @@ -26,7 +26,7 @@ switch (process.argv[2]) { function parent() { const http = require('http'); const bigResponse = Buffer.alloc(10240, 'x'); - var backloggedReqs = 0; + let backloggedReqs = 0; const server = http.createServer(function(req, res) { res.setHeader('content-length', bigResponse.length); @@ -68,7 +68,7 @@ function child() { const port = +process.argv[3]; const conn = net.connect({ port: port }); - var req = `GET / HTTP/1.1\r\nHost: localhost:${port}\r\nAccept: */*\r\n\r\n`; + let req = `GET / HTTP/1.1\r\nHost: localhost:${port}\r\nAccept: */*\r\n\r\n`; req = new Array(10241).join(req); diff --git a/test/parallel/test-http-pipeline-regr-2639.js b/test/parallel/test-http-pipeline-regr-2639.js index f67803ba159c74..133e4126683d9b 100644 --- a/test/parallel/test-http-pipeline-regr-2639.js +++ b/test/parallel/test-http-pipeline-regr-2639.js @@ -6,9 +6,9 @@ const net = require('net'); const COUNT = 10; -var received = 0; +let received = 0; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { // Close the server, we have only one TCP connection anyway if (received++ === 0) server.close(); @@ -22,12 +22,12 @@ var server = http.createServer(function(req, res) { }).listen(0, function() { const s = net.connect(this.address().port); - var big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT); + const big = 'GET / HTTP/1.0\r\n\r\n'.repeat(COUNT); s.write(big); s.resume(); }); process.on('exit', function() { - assert.equal(received, COUNT); + assert.strictEqual(received, COUNT); }); diff --git a/test/parallel/test-http-pipeline-regr-3332.js b/test/parallel/test-http-pipeline-regr-3332.js index fdbb76bf8d643d..b34ad499850b70 100644 --- a/test/parallel/test-http-pipeline-regr-3332.js +++ b/test/parallel/test-http-pipeline-regr-3332.js @@ -8,9 +8,9 @@ const big = Buffer.alloc(16 * 1024, 'A'); const COUNT = 1e4; -var received = 0; +let received = 0; -var client; +let client; const server = http.createServer(function(req, res) { res.end(big, function() { if (++received === COUNT) { @@ -19,7 +19,7 @@ const server = http.createServer(function(req, res) { } }); }).listen(0, function() { - var req = new Array(COUNT + 1).join('GET / HTTP/1.1\r\n\r\n'); + const req = new Array(COUNT + 1).join('GET / HTTP/1.1\r\n\r\n'); client = net.connect(this.address().port, function() { client.write(req); }); @@ -36,5 +36,5 @@ process.on('exit', function() { // The server should pause connection on pipeline flood, but it shoul still // resume it and finish processing the requests, when its output queue will // be empty again. - assert.equal(received, COUNT); + assert.strictEqual(received, COUNT); }); diff --git a/test/parallel/test-http-pipeline-regr-3508.js b/test/parallel/test-http-pipeline-regr-3508.js index b368bae0d7790e..ff735818f68121 100644 --- a/test/parallel/test-http-pipeline-regr-3508.js +++ b/test/parallel/test-http-pipeline-regr-3508.js @@ -3,18 +3,18 @@ require('../common'); const http = require('http'); const net = require('net'); -var once = false; -var first = null; -var second = null; +let once = false; +let first = null; +let second = null; const chunk = Buffer.alloc(1024, 'X'); -var size = 0; +let size = 0; -var more; -var done; +let more; +let done; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { if (!once) server.close(); once = true; @@ -41,7 +41,7 @@ var server = http.createServer(function(req, res) { }); first.end('hello'); }).listen(0, function() { - var s = net.connect(this.address().port); + const s = net.connect(this.address().port); more = function() { s.write('GET / HTTP/1.1\r\n\r\n'); }; diff --git a/test/parallel/test-http-proxy.js b/test/parallel/test-http-proxy.js index 43feb1e3b3838c..91dce932dc576b 100644 --- a/test/parallel/test-http-proxy.js +++ b/test/parallel/test-http-proxy.js @@ -1,26 +1,26 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); -var cookies = [ +const cookies = [ 'session_token=; path=/; expires=Sun, 15-Sep-2030 13:48:52 GMT', 'prefers_open_id=; path=/; expires=Thu, 01-Jan-1970 00:00:00 GMT' ]; -var headers = {'content-type': 'text/plain', - 'set-cookie': cookies, - 'hello': 'world' }; +const headers = {'content-type': 'text/plain', + 'set-cookie': cookies, + 'hello': 'world' }; -var backend = http.createServer(function(req, res) { +const backend = http.createServer(function(req, res) { console.error('backend request'); res.writeHead(200, headers); res.write('hello world\n'); res.end(); }); -var proxy = http.createServer(function(req, res) { +const proxy = http.createServer(function(req, res) { console.error('proxy req headers: ' + JSON.stringify(req.headers)); http.get({ port: backend.address().port, @@ -29,8 +29,8 @@ var proxy = http.createServer(function(req, res) { console.error('proxy res headers: ' + JSON.stringify(proxy_res.headers)); - assert.equal('world', proxy_res.headers['hello']); - assert.equal('text/plain', proxy_res.headers['content-type']); + assert.strictEqual('world', proxy_res.headers['hello']); + assert.strictEqual('text/plain', proxy_res.headers['content-type']); assert.deepStrictEqual(cookies, proxy_res.headers['set-cookie']); res.writeHead(proxy_res.statusCode, proxy_res.headers); @@ -46,9 +46,9 @@ var proxy = http.createServer(function(req, res) { }); }); -var body = ''; +let body = ''; -var nlistening = 0; +let nlistening = 0; function startReq() { nlistening++; if (nlistening < 2) return; @@ -58,10 +58,10 @@ function startReq() { path: '/test' }, function(res) { console.error('got res'); - assert.equal(200, res.statusCode); + assert.strictEqual(200, res.statusCode); - assert.equal('world', res.headers['hello']); - assert.equal('text/plain', res.headers['content-type']); + assert.strictEqual('world', res.headers['hello']); + assert.strictEqual('text/plain', res.headers['content-type']); assert.deepStrictEqual(cookies, res.headers['set-cookie']); res.setEncoding('utf8'); @@ -82,5 +82,5 @@ console.error('listen backend'); backend.listen(0, startReq); process.on('exit', function() { - assert.equal(body, 'hello world\n'); + assert.strictEqual(body, 'hello world\n'); }); diff --git a/test/parallel/test-http-raw-headers.js b/test/parallel/test-http-raw-headers.js index 2e2e9631490395..7ae0c35e3d8d11 100644 --- a/test/parallel/test-http-raw-headers.js +++ b/test/parallel/test-http-raw-headers.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); http.createServer(function(req, res) { - var expectRawHeaders = [ + const expectRawHeaders = [ 'Host', `localhost:${this.address().port}`, 'transfer-ENCODING', @@ -15,13 +15,13 @@ http.createServer(function(req, res) { 'Connection', 'close' ]; - var expectHeaders = { + const expectHeaders = { host: `localhost:${this.address().port}`, 'transfer-encoding': 'CHUNKED', 'x-bar': 'yoyoyo', connection: 'close' }; - var expectRawTrailers = [ + const expectRawTrailers = [ 'x-bAr', 'yOyOyOy', 'x-baR', @@ -31,7 +31,7 @@ http.createServer(function(req, res) { 'X-baR', 'OyOyOyO' ]; - var expectTrailers = { 'x-bar': 'yOyOyOy, OyOyOyO, yOyOyOy, OyOyOyO' }; + const expectTrailers = { 'x-bar': 'yOyOyOy, OyOyOyO, yOyOyOy, OyOyOyO' }; this.close(); @@ -53,7 +53,7 @@ http.createServer(function(req, res) { ]); res.end('x f o o'); }).listen(0, function() { - var req = http.request({ port: this.address().port, path: '/' }); + const req = http.request({ port: this.address().port, path: '/' }); req.addTrailers([ ['x-bAr', 'yOyOyOy'], ['x-baR', 'OyOyOyO'], @@ -64,7 +64,7 @@ http.createServer(function(req, res) { req.setHeader('x-BaR', 'yoyoyo'); req.end('y b a r'); req.on('response', function(res) { - var expectRawHeaders = [ + const expectRawHeaders = [ 'Trailer', 'x-foo', 'Date', @@ -74,7 +74,7 @@ http.createServer(function(req, res) { 'Transfer-Encoding', 'chunked' ]; - var expectHeaders = { + const expectHeaders = { trailer: 'x-foo', date: null, connection: 'close', @@ -85,7 +85,7 @@ http.createServer(function(req, res) { assert.deepStrictEqual(res.rawHeaders, expectRawHeaders); assert.deepStrictEqual(res.headers, expectHeaders); res.on('end', function() { - var expectRawTrailers = [ + const expectRawTrailers = [ 'x-fOo', 'xOxOxOx', 'x-foO', @@ -95,7 +95,7 @@ http.createServer(function(req, res) { 'X-foO', 'OxOxOxO' ]; - var expectTrailers = { 'x-foo': 'xOxOxOx, OxOxOxO, xOxOxOx, OxOxOxO' }; + const expectTrailers = { 'x-foo': 'xOxOxOx, OxOxOxO, xOxOxOx, OxOxOxO' }; assert.deepStrictEqual(res.rawTrailers, expectRawTrailers); assert.deepStrictEqual(res.trailers, expectTrailers); diff --git a/test/parallel/test-http-remove-header-stays-removed.js b/test/parallel/test-http-remove-header-stays-removed.js index 9b8ff35b0fe5d3..c38a042283dbb9 100644 --- a/test/parallel/test-http-remove-header-stays-removed.js +++ b/test/parallel/test-http-remove-header-stays-removed.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); -var server = http.createServer(function(request, response) { +const server = http.createServer(function(request, response) { // removed headers should stay removed, even if node automatically adds them // to the output: response.removeHeader('connection'); @@ -20,16 +20,16 @@ var server = http.createServer(function(request, response) { this.close(); }); -var response = ''; +let response = ''; process.on('exit', function() { - assert.equal('beep boop\n', response); + assert.strictEqual('beep boop\n', response); console.log('ok'); }); server.listen(0, function() { http.get({ port: this.address().port }, function(res) { - assert.equal(200, res.statusCode); + assert.strictEqual(200, res.statusCode); assert.deepStrictEqual(res.headers, { date: 'coffee o clock' }); res.setEncoding('ascii'); diff --git a/test/parallel/test-http-request-dont-override-options.js b/test/parallel/test-http-request-dont-override-options.js index 5570dd49a2fc1b..33ed2ed6c0070d 100644 --- a/test/parallel/test-http-request-dont-override-options.js +++ b/test/parallel/test-http-request-dont-override-options.js @@ -4,7 +4,7 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); -var requests = 0; +let requests = 0; http.createServer(function(req, res) { res.writeHead(200); @@ -12,13 +12,13 @@ http.createServer(function(req, res) { requests++; }).listen(0, function() { - var agent = new http.Agent(); + const agent = new http.Agent(); agent.defaultPort = this.address().port; // options marked as explicitly undefined for readability // in this test, they should STAY undefined as options should not // be mutable / modified - var options = { + const options = { host: undefined, hostname: common.localhostIPv4, port: undefined, @@ -33,7 +33,7 @@ http.createServer(function(req, res) { }).end(); process.on('exit', function() { - assert.equal(requests, 1); + assert.strictEqual(requests, 1); assert.strictEqual(options.host, undefined); assert.strictEqual(options.hostname, common.localhostIPv4); diff --git a/test/parallel/test-http-request-end-twice.js b/test/parallel/test-http-request-end-twice.js index 230175be8e95c1..ab30c0a1eef8a1 100644 --- a/test/parallel/test-http-request-end-twice.js +++ b/test/parallel/test-http-request-end-twice.js @@ -1,14 +1,14 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var server = http.Server(function(req, res) { +const server = http.Server(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('hello world\n'); }); server.listen(0, function() { - var req = http.get({port: this.address().port}, function(res) { + const req = http.get({port: this.address().port}, function(res) { res.on('end', function() { assert.ok(!req.end()); server.close(); diff --git a/test/parallel/test-http-request-end.js b/test/parallel/test-http-request-end.js index 6beedae20d9e00..dd4a8caf105329 100644 --- a/test/parallel/test-http-request-end.js +++ b/test/parallel/test-http-request-end.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var expected = 'Post Body For Test'; +const expected = 'Post Body For Test'; -var server = http.Server(function(req, res) { - var result = ''; +const server = http.Server(function(req, res) { + let result = ''; req.setEncoding('utf8'); req.on('data', function(chunk) { diff --git a/test/parallel/test-http-request-methods.js b/test/parallel/test-http-request-methods.js index 7f42a9c00a85f3..e4579791ef301a 100644 --- a/test/parallel/test-http-request-methods.js +++ b/test/parallel/test-http-request-methods.js @@ -1,13 +1,13 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); -var http = require('http'); +const assert = require('assert'); +const net = require('net'); +const http = require('http'); // Test that the DELETE, PATCH and PURGE verbs get passed through correctly ['DELETE', 'PATCH', 'PURGE'].forEach(function(method, index) { - var server = http.createServer(common.mustCall(function(req, res) { + const server = http.createServer(common.mustCall(function(req, res) { assert.strictEqual(req.method, method); res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('hello '); @@ -17,8 +17,8 @@ var http = require('http'); server.listen(0); server.on('listening', common.mustCall(function() { - var c = net.createConnection(this.address().port); - var server_response = ''; + const c = net.createConnection(this.address().port); + let server_response = ''; c.setEncoding('utf8'); diff --git a/test/parallel/test-http-res-write-after-end.js b/test/parallel/test-http-res-write-after-end.js index 5a91c556340b1c..45db9fe13f7655 100644 --- a/test/parallel/test-http-res-write-after-end.js +++ b/test/parallel/test-http-res-write-after-end.js @@ -1,9 +1,9 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var server = http.Server(common.mustCall(function(req, res) { +const server = http.Server(common.mustCall(function(req, res) { res.on('error', common.mustCall(function onResError(err) { assert.strictEqual(err.message, 'write after end'); })); @@ -11,8 +11,8 @@ var server = http.Server(common.mustCall(function(req, res) { res.write('This should write.'); res.end(); - var r = res.write('This should raise an error.'); - assert.equal(r, true, 'write after end should return true'); + const r = res.write('This should raise an error.'); + assert.strictEqual(r, true, 'write after end should return true'); })); server.listen(0, function() { diff --git a/test/parallel/test-http-res-write-end-dont-take-array.js b/test/parallel/test-http-res-write-end-dont-take-array.js index 5c14b0678520c4..6964ec15965a96 100644 --- a/test/parallel/test-http-res-write-end-dont-take-array.js +++ b/test/parallel/test-http-res-write-end-dont-take-array.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var test = 1; +let test = 1; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); if (test === 1) { // write should accept string diff --git a/test/parallel/test-http-response-close.js b/test/parallel/test-http-response-close.js index 54ee61efccf1ea..de179c113e1db1 100644 --- a/test/parallel/test-http-response-close.js +++ b/test/parallel/test-http-response-close.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var http = require('http'); +const http = require('http'); -var server = http.createServer(common.mustCall(function(req, res) { +const server = http.createServer(common.mustCall(function(req, res) { res.writeHead(200); res.write('a'); diff --git a/test/parallel/test-http-response-multi-content-length.js b/test/parallel/test-http-response-multi-content-length.js index 3290f74c16e250..5d53f7dcd5c621 100644 --- a/test/parallel/test-http-response-multi-content-length.js +++ b/test/parallel/test-http-response-multi-content-length.js @@ -24,7 +24,7 @@ const server = http.createServer((req, res) => { res.end('ok'); }); -var count = 0; +let count = 0; server.listen(0, common.mustCall(() => { for (let n = 1; n <= MAX_COUNT; n++) { @@ -35,11 +35,11 @@ server.listen(0, common.mustCall(() => { http.get( {port: server.address().port, headers: {'x-num': n}}, (res) => { - assert(false, 'client allowed multiple content-length headers.'); + common.fail('client allowed multiple content-length headers.'); } ).on('error', common.mustCall((err) => { assert(/^Parse Error/.test(err.message)); - assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); + assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); count++; if (count === MAX_COUNT) server.close(); @@ -48,5 +48,5 @@ server.listen(0, common.mustCall(() => { })); process.on('exit', () => { - assert.equal(count, MAX_COUNT); + assert.strictEqual(count, MAX_COUNT); }); diff --git a/test/parallel/test-http-response-multiheaders.js b/test/parallel/test-http-response-multiheaders.js index f4c1fd4116b735..5739dac31d690b 100644 --- a/test/parallel/test-http-response-multiheaders.js +++ b/test/parallel/test-http-response-multiheaders.js @@ -29,7 +29,7 @@ const norepeat = [ ]; const server = http.createServer(function(req, res) { - var num = req.headers['x-num']; + const num = req.headers['x-num']; if (num === '1') { for (const name of norepeat) { res.setHeader(name, ['A', 'B']); @@ -47,7 +47,7 @@ const server = http.createServer(function(req, res) { }); server.listen(0, common.mustCall(function() { - var count = 0; + let count = 0; for (let n = 1; n <= 2; n++) { // this runs twice, the first time, the server will use // setHeader, the second time it uses writeHead. The @@ -60,9 +60,9 @@ server.listen(0, common.mustCall(function() { common.mustCall(function(res) { if (++count === 2) server.close(); for (const name of norepeat) { - assert.equal(res.headers[name], 'A'); + assert.strictEqual(res.headers[name], 'A'); } - assert.equal(res.headers['x-a'], 'A, B'); + assert.strictEqual(res.headers['x-a'], 'A, B'); }) ); } diff --git a/test/parallel/test-http-response-no-headers.js b/test/parallel/test-http-response-no-headers.js index 4a3460bc645140..e10571af4ccf25 100644 --- a/test/parallel/test-http-response-no-headers.js +++ b/test/parallel/test-http-response-no-headers.js @@ -1,38 +1,38 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); -var expected = { +const expected = { '0.9': 'I AM THE WALRUS', '1.0': 'I AM THE WALRUS', '1.1': '' }; function test(httpVersion, callback) { - var server = net.createServer(function(conn) { - var reply = 'HTTP/' + httpVersion + ' 200 OK\r\n\r\n' + - expected[httpVersion]; + const server = net.createServer(function(conn) { + const reply = 'HTTP/' + httpVersion + ' 200 OK\r\n\r\n' + + expected[httpVersion]; conn.end(reply); }); server.listen(0, '127.0.0.1', common.mustCall(function() { - var options = { + const options = { host: '127.0.0.1', port: this.address().port }; - var req = http.get(options, common.mustCall(function(res) { - var body = ''; + const req = http.get(options, common.mustCall(function(res) { + let body = ''; res.on('data', function(data) { body += data; }); res.on('end', common.mustCall(function() { - assert.equal(body, expected[httpVersion]); + assert.strictEqual(body, expected[httpVersion]); server.close(); if (callback) process.nextTick(callback); })); diff --git a/test/parallel/test-http-response-readable.js b/test/parallel/test-http-response-readable.js index 1d561ca4704808..a4906643d3d35b 100644 --- a/test/parallel/test-http-response-readable.js +++ b/test/parallel/test-http-response-readable.js @@ -1,18 +1,19 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var testServer = new http.Server(function(req, res) { +const testServer = new http.Server(function(req, res) { res.writeHead(200); res.end('Hello world'); }); testServer.listen(0, function() { http.get({ port: this.address().port }, function(res) { - assert.equal(res.readable, true, 'res.readable initially true'); + assert.strictEqual(res.readable, true, 'res.readable initially true'); res.on('end', function() { - assert.equal(res.readable, false, 'res.readable set to false after end'); + assert.strictEqual(res.readable, false, + 'res.readable set to false after end'); testServer.close(); }); res.resume(); diff --git a/test/parallel/test-http-response-splitting.js b/test/parallel/test-http-response-splitting.js index e4021e78317759..f6c3a04064ec1c 100644 --- a/test/parallel/test-http-response-splitting.js +++ b/test/parallel/test-http-response-splitting.js @@ -17,7 +17,7 @@ const str = '/welcome?lang=bar%c4%8d%c4%8aContent­Length:%200%c4%8d%c4%8a%c' + const x = 'fooഊSet-Cookie: foo=barഊഊ'; const y = 'foo⠊Set-Cookie: foo=bar'; -var count = 0; +let count = 0; const server = http.createServer((req, res) => { switch (count++) { diff --git a/test/parallel/test-http-response-status-message.js b/test/parallel/test-http-response-status-message.js index b14c1f2faf0fce..95859634ac394a 100644 --- a/test/parallel/test-http-response-status-message.js +++ b/test/parallel/test-http-response-status-message.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); -var testsComplete = 0; +let testsComplete = 0; -var testCases = [ +const testCases = [ { path: '/200', statusMessage: 'OK', response: 'HTTP/1.1 200 OK\r\n\r\n' }, { path: '/500', statusMessage: 'Internal Server Error', @@ -19,7 +19,7 @@ var testCases = [ response: 'HTTP/1.1 200\r\n\r\n' } ]; testCases.findByPath = function(path) { - var matching = this.filter(function(testCase) { + const matching = this.filter(function(testCase) { return testCase.path === path; }); if (matching.length === 0) { @@ -28,18 +28,18 @@ testCases.findByPath = function(path) { return matching[0]; }; -var server = net.createServer(function(connection) { +const server = net.createServer(function(connection) { connection.on('data', function(data) { - var path = data.toString().match(/GET (.*) HTTP.1.1/)[1]; - var testCase = testCases.findByPath(path); + const path = data.toString().match(/GET (.*) HTTP.1.1/)[1]; + const testCase = testCases.findByPath(path); connection.write(testCase.response); connection.end(); }); }); -var runTest = function(testCaseIndex) { - var testCase = testCases[testCaseIndex]; +const runTest = function(testCaseIndex) { + const testCase = testCases[testCaseIndex]; http.get({ port: server.address().port, @@ -47,7 +47,7 @@ var runTest = function(testCaseIndex) { }, function(response) { console.log('client: expected status message: ' + testCase.statusMessage); console.log('client: actual status message: ' + response.statusMessage); - assert.equal(testCase.statusMessage, response.statusMessage); + assert.strictEqual(testCase.statusMessage, response.statusMessage); response.on('end', function() { testsComplete++; @@ -66,5 +66,5 @@ var runTest = function(testCaseIndex) { server.listen(0, function() { runTest(0); }); process.on('exit', function() { - assert.equal(testCases.length, testsComplete); + assert.strictEqual(testCases.length, testsComplete); }); diff --git a/test/parallel/test-http-response-statuscode.js b/test/parallel/test-http-response-statuscode.js index 3314506339b564..ed3676b03e1f0c 100644 --- a/test/parallel/test-http-response-statuscode.js +++ b/test/parallel/test-http-response-statuscode.js @@ -3,70 +3,79 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); -const MAX_REQUESTS = 12; -var reqNum = 0; +const MAX_REQUESTS = 13; +let reqNum = 0; + +const createErrorMessage = (code) => { + return new RegExp(`^RangeError: Invalid status code: ${code}$`); +}; const server = http.Server(common.mustCall(function(req, res) { switch (reqNum) { case 0: assert.throws(common.mustCall(() => { res.writeHead(-1); - }, /invalid status code/i)); + }), createErrorMessage(-1)); break; case 1: assert.throws(common.mustCall(() => { res.writeHead(Infinity); - }, /invalid status code/i)); + }), createErrorMessage(0)); break; case 2: assert.throws(common.mustCall(() => { res.writeHead(NaN); - }, /invalid status code/i)); + }), createErrorMessage(0)); break; case 3: assert.throws(common.mustCall(() => { res.writeHead({}); - }, /invalid status code/i)); + }), createErrorMessage(0)); break; case 4: assert.throws(common.mustCall(() => { res.writeHead(99); - }, /invalid status code/i)); + }), createErrorMessage(99)); break; case 5: assert.throws(common.mustCall(() => { res.writeHead(1000); - }, /invalid status code/i)); + }), createErrorMessage(1000)); break; case 6: assert.throws(common.mustCall(() => { res.writeHead('1000'); - }, /invalid status code/i)); + }), createErrorMessage(1000)); break; case 7: assert.throws(common.mustCall(() => { res.writeHead(null); - }, /invalid status code/i)); + }), createErrorMessage(0)); break; case 8: assert.throws(common.mustCall(() => { res.writeHead(true); - }, /invalid status code/i)); + }), createErrorMessage(1)); break; case 9: assert.throws(common.mustCall(() => { res.writeHead([]); - }, /invalid status code/i)); + }), createErrorMessage(0)); break; case 10: assert.throws(common.mustCall(() => { res.writeHead('this is not valid'); - }, /invalid status code/i)); + }), createErrorMessage(0)); break; case 11: assert.throws(common.mustCall(() => { res.writeHead('404 this is not valid either'); - }, /invalid status code/i)); + }), createErrorMessage(0)); + break; + case 12: + assert.throws(common.mustCall(() => { + res.writeHead(); + }), createErrorMessage(0)); this.close(); break; default: diff --git a/test/parallel/test-http-server-client-error.js b/test/parallel/test-http-server-client-error.js index cd20b7321a63f7..88c224f8374145 100644 --- a/test/parallel/test-http-server-client-error.js +++ b/test/parallel/test-http-server-client-error.js @@ -21,18 +21,18 @@ server.listen(0, function() { const client = net.connect(server.address().port); client.end('Oopsie-doopsie\r\n'); - var chunks = ''; + let chunks = ''; client.on('data', function(chunk) { chunks += chunk; }); client.once('end', function() { - assert.equal(chunks, 'HTTP/1.1 400 Bad Request\r\n\r\n'); + assert.strictEqual(chunks, 'HTTP/1.1 400 Bad Request\r\n\r\n'); }); } // Normal request http.get({ port: this.address().port, path: '/' }, function(res) { - assert.equal(res.statusCode, 200); + assert.strictEqual(res.statusCode, 200); res.resume(); res.once('end', next); }); diff --git a/test/parallel/test-http-server-multiheaders.js b/test/parallel/test-http-server-multiheaders.js index 5b41ee89d87e50..a89d45fd6c6195 100644 --- a/test/parallel/test-http-server-multiheaders.js +++ b/test/parallel/test-http-server-multiheaders.js @@ -4,19 +4,20 @@ // that support it, and dropping duplicates for other fields. require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var srv = http.createServer(function(req, res) { - assert.equal(req.headers.accept, 'abc, def, ghijklmnopqrst'); - assert.equal(req.headers.host, 'foo'); - assert.equal(req.headers['www-authenticate'], 'foo, bar, baz'); - assert.equal(req.headers['proxy-authenticate'], 'foo, bar, baz'); - assert.equal(req.headers['x-foo'], 'bingo'); - assert.equal(req.headers['x-bar'], 'banjo, bango'); - assert.equal(req.headers['sec-websocket-protocol'], 'chat, share'); - assert.equal(req.headers['sec-websocket-extensions'], 'foo; 1, bar; 2, baz'); - assert.equal(req.headers['constructor'], 'foo, bar, baz'); +const srv = http.createServer(function(req, res) { + assert.strictEqual(req.headers.accept, 'abc, def, ghijklmnopqrst'); + assert.strictEqual(req.headers.host, 'foo'); + assert.strictEqual(req.headers['www-authenticate'], 'foo, bar, baz'); + assert.strictEqual(req.headers['proxy-authenticate'], 'foo, bar, baz'); + assert.strictEqual(req.headers['x-foo'], 'bingo'); + assert.strictEqual(req.headers['x-bar'], 'banjo, bango'); + assert.strictEqual(req.headers['sec-websocket-protocol'], 'chat, share'); + assert.strictEqual(req.headers['sec-websocket-extensions'], + 'foo; 1, bar; 2, baz'); + assert.strictEqual(req.headers['constructor'], 'foo, bar, baz'); res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('EOF'); diff --git a/test/parallel/test-http-server-multiheaders2.js b/test/parallel/test-http-server-multiheaders2.js index 9f6d41e6a10cea..53e68e6f0d3e74 100644 --- a/test/parallel/test-http-server-multiheaders2.js +++ b/test/parallel/test-http-server-multiheaders2.js @@ -4,10 +4,10 @@ // that support it, and dropping duplicates for other fields. require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var multipleAllowed = [ +const multipleAllowed = [ 'Accept', 'Accept-Charset', 'Accept-Encoding', @@ -31,7 +31,7 @@ var multipleAllowed = [ 'X-Some-Random-Header', ]; -var multipleForbidden = [ +const multipleForbidden = [ 'Content-Type', 'User-Agent', 'Referer', @@ -48,14 +48,14 @@ var multipleForbidden = [ //'Content-Length', ]; -var srv = http.createServer(function(req, res) { +const srv = http.createServer(function(req, res) { multipleForbidden.forEach(function(header) { - assert.equal(req.headers[header.toLowerCase()], - 'foo', 'header parsed incorrectly: ' + header); + assert.strictEqual(req.headers[header.toLowerCase()], + 'foo', 'header parsed incorrectly: ' + header); }); multipleAllowed.forEach(function(header) { - assert.equal(req.headers[header.toLowerCase()], - 'foo, bar', 'header parsed incorrectly: ' + header); + assert.strictEqual(req.headers[header.toLowerCase()], + 'foo, bar', 'header parsed incorrectly: ' + header); }); res.writeHead(200, {'Content-Type': 'text/plain'}); @@ -70,7 +70,7 @@ function makeHeader(value) { }; } -var headers = [] +const headers = [] .concat(multipleAllowed.map(makeHeader('foo'))) .concat(multipleForbidden.map(makeHeader('foo'))) .concat(multipleAllowed.map(makeHeader('bar'))) diff --git a/test/parallel/test-http-server-reject-chunked-with-content-length.js b/test/parallel/test-http-server-reject-chunked-with-content-length.js index d8697cd38cde72..b158fda75c5846 100644 --- a/test/parallel/test-http-server-reject-chunked-with-content-length.js +++ b/test/parallel/test-http-server-reject-chunked-with-content-length.js @@ -14,7 +14,7 @@ const server = http.createServer((req, res) => { }); server.on('clientError', common.mustCall((err) => { assert(/^Parse Error/.test(err.message)); - assert.equal(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); + assert.strictEqual(err.code, 'HPE_UNEXPECTED_CONTENT_LENGTH'); server.close(); })); server.listen(0, () => { diff --git a/test/parallel/test-http-server-reject-cr-no-lf.js b/test/parallel/test-http-server-reject-cr-no-lf.js index 81a7208d982334..73508cf08e9b7a 100644 --- a/test/parallel/test-http-server-reject-cr-no-lf.js +++ b/test/parallel/test-http-server-reject-cr-no-lf.js @@ -16,7 +16,7 @@ const server = http.createServer((req, res) => { }); server.on('clientError', common.mustCall((err) => { assert(/^Parse Error/.test(err.message)); - assert.equal(err.code, 'HPE_LF_EXPECTED'); + assert.strictEqual(err.code, 'HPE_LF_EXPECTED'); server.close(); })); server.listen(0, () => { diff --git a/test/parallel/test-http-server-stale-close.js b/test/parallel/test-http-server-stale-close.js index 819f503de547e4..3728453c039447 100644 --- a/test/parallel/test-http-server-stale-close.js +++ b/test/parallel/test-http-server-stale-close.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var http = require('http'); -var util = require('util'); -var fork = require('child_process').fork; +const http = require('http'); +const util = require('util'); +const fork = require('child_process').fork; if (process.env.NODE_TEST_FORK_PORT) { - var req = http.request({ + const req = http.request({ headers: {'Content-Length': '42'}, method: 'POST', host: '127.0.0.1', @@ -14,7 +14,7 @@ if (process.env.NODE_TEST_FORK_PORT) { req.write('BAM'); req.end(); } else { - var server = http.createServer(function(req, res) { + const server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Length': '42'}); req.pipe(res); req.on('close', function() { diff --git a/test/parallel/test-http-server-unconsume.js b/test/parallel/test-http-server-unconsume.js index 76238380c7cfde..9f80e9ea82de48 100644 --- a/test/parallel/test-http-server-unconsume.js +++ b/test/parallel/test-http-server-unconsume.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); -var received = ''; +let received = ''; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200); res.end(); @@ -16,7 +16,7 @@ var server = http.createServer(function(req, res) { server.close(); }).listen(0, function() { - var socket = net.connect(this.address().port, function() { + const socket = net.connect(this.address().port, function() { socket.write('PUT / HTTP/1.1\r\n\r\n'); socket.once('data', function() { @@ -26,5 +26,5 @@ var server = http.createServer(function(req, res) { }); process.on('exit', function() { - assert.equal(received, 'hello world'); + assert.strictEqual(received, 'hello world'); }); diff --git a/test/parallel/test-http-server.js b/test/parallel/test-http-server.js index 1870bcc7170726..90c2709ebdbc5c 100644 --- a/test/parallel/test-http-server.js +++ b/test/parallel/test-http-server.js @@ -1,17 +1,17 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); -var http = require('http'); -var url = require('url'); -var qs = require('querystring'); - -var request_number = 0; -var requests_sent = 0; -var server_response = ''; -var client_got_eof = false; - -var server = http.createServer(function(req, res) { +const assert = require('assert'); +const net = require('net'); +const http = require('http'); +const url = require('url'); +const qs = require('querystring'); + +let request_number = 0; +let requests_sent = 0; +let server_response = ''; +let client_got_eof = false; + +const server = http.createServer(function(req, res) { res.id = request_number; req.id = request_number++; @@ -48,7 +48,7 @@ server.listen(0); server.httpAllowHalfOpen = true; server.on('listening', function() { - var c = net.createConnection(this.address().port); + const c = net.createConnection(this.address().port); c.setEncoding('utf8'); @@ -94,10 +94,10 @@ process.on('exit', function() { assert.strictEqual(4, request_number); assert.strictEqual(4, requests_sent); - var hello = new RegExp('/hello'); + const hello = new RegExp('/hello'); assert.notStrictEqual(null, hello.exec(server_response)); - var quit = new RegExp('/quit'); + const quit = new RegExp('/quit'); assert.notStrictEqual(null, quit.exec(server_response)); assert.strictEqual(true, client_got_eof); diff --git a/test/parallel/test-http-set-cookies.js b/test/parallel/test-http-set-cookies.js index 1f00ebb65e34de..7be28b04034fb0 100644 --- a/test/parallel/test-http-set-cookies.js +++ b/test/parallel/test-http-set-cookies.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); -var nresponses = 0; +let nresponses = 0; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { if (req.url === '/one') { res.writeHead(200, [['set-cookie', 'A'], ['content-type', 'text/plain']]); @@ -27,7 +27,7 @@ server.on('listening', function() { // set-cookie headers are always return in an array. // even if there is only one. assert.deepStrictEqual(['A'], res.headers['set-cookie']); - assert.equal('text/plain', res.headers['content-type']); + assert.strictEqual('text/plain', res.headers['content-type']); res.on('data', function(chunk) { console.log(chunk.toString()); @@ -44,7 +44,7 @@ server.on('listening', function() { http.get({ port: this.address().port, path: '/two' }, function(res) { assert.deepStrictEqual(['A', 'B'], res.headers['set-cookie']); - assert.equal('text/plain', res.headers['content-type']); + assert.strictEqual('text/plain', res.headers['content-type']); res.on('data', function(chunk) { console.log(chunk.toString()); @@ -60,5 +60,5 @@ server.on('listening', function() { }); process.on('exit', function() { - assert.equal(2, nresponses); + assert.strictEqual(2, nresponses); }); diff --git a/test/parallel/test-http-set-timeout-server.js b/test/parallel/test-http-set-timeout-server.js index d530503aa1e9aa..097aeb260bdc5e 100644 --- a/test/parallel/test-http-set-timeout-server.js +++ b/test/parallel/test-http-set-timeout-server.js @@ -1,10 +1,10 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); -var tests = []; +const tests = []; function test(fn) { if (!tests.length) @@ -13,7 +13,7 @@ function test(fn) { } function run() { - var fn = tests.shift(); + const fn = tests.shift(); if (fn) { console.log('# %s', fn.name); fn(run); @@ -23,17 +23,17 @@ function run() { } test(function serverTimeout(cb) { - var caughtTimeout = false; + let caughtTimeout = false; process.on('exit', function() { assert(caughtTimeout); }); - var server = http.createServer(function(req, res) { + const server = http.createServer(function(req, res) { // just do nothing, we should get a timeout event. }); server.listen(common.mustCall(function() { http.get({ port: server.address().port }).on('error', function() {}); })); - var s = server.setTimeout(50, function(socket) { + const s = server.setTimeout(50, function(socket) { caughtTimeout = true; socket.destroy(); server.close(); @@ -43,13 +43,13 @@ test(function serverTimeout(cb) { }); test(function serverRequestTimeout(cb) { - var caughtTimeout = false; + let caughtTimeout = false; process.on('exit', function() { assert(caughtTimeout); }); - var server = http.createServer(function(req, res) { + const server = http.createServer(function(req, res) { // just do nothing, we should get a timeout event. - var s = req.setTimeout(50, function() { + const s = req.setTimeout(50, function() { caughtTimeout = true; req.socket.destroy(); server.close(); @@ -58,8 +58,8 @@ test(function serverRequestTimeout(cb) { assert.ok(s instanceof http.IncomingMessage); }); server.listen(common.mustCall(function() { - var port = server.address().port; - var req = http.request({ port: port, method: 'POST' }); + const port = server.address().port; + const req = http.request({ port: port, method: 'POST' }); req.on('error', function() {}); req.write('Hello'); // req is in progress @@ -67,13 +67,13 @@ test(function serverRequestTimeout(cb) { }); test(function serverResponseTimeout(cb) { - var caughtTimeout = false; + let caughtTimeout = false; process.on('exit', function() { assert(caughtTimeout); }); - var server = http.createServer(function(req, res) { + const server = http.createServer(function(req, res) { // just do nothing, we should get a timeout event. - var s = res.setTimeout(50, function() { + const s = res.setTimeout(50, function() { caughtTimeout = true; res.socket.destroy(); server.close(); @@ -82,21 +82,21 @@ test(function serverResponseTimeout(cb) { assert.ok(s instanceof http.OutgoingMessage); }); server.listen(common.mustCall(function() { - var port = server.address().port; + const port = server.address().port; http.get({ port: port }).on('error', function() {}); })); }); test(function serverRequestNotTimeoutAfterEnd(cb) { - var caughtTimeoutOnRequest = false; - var caughtTimeoutOnResponse = false; + let caughtTimeoutOnRequest = false; + let caughtTimeoutOnResponse = false; process.on('exit', function() { assert(!caughtTimeoutOnRequest); assert(caughtTimeoutOnResponse); }); - var server = http.createServer(function(req, res) { + const server = http.createServer(function(req, res) { // just do nothing, we should get a timeout event. - var s = req.setTimeout(50, function(socket) { + const s = req.setTimeout(50, function(socket) { caughtTimeoutOnRequest = true; }); assert.ok(s instanceof http.IncomingMessage); @@ -110,18 +110,18 @@ test(function serverRequestNotTimeoutAfterEnd(cb) { cb(); }); server.listen(common.mustCall(function() { - var port = server.address().port; + const port = server.address().port; http.get({ port: port }).on('error', function() {}); })); }); test(function serverResponseTimeoutWithPipeline(cb) { - var caughtTimeout = ''; + let caughtTimeout = ''; process.on('exit', function() { - assert.equal(caughtTimeout, '/2'); + assert.strictEqual(caughtTimeout, '/2'); }); - var server = http.createServer(function(req, res) { - var s = res.setTimeout(50, function() { + const server = http.createServer(function(req, res) { + const s = res.setTimeout(50, function() { caughtTimeout += req.url; }); assert.ok(s instanceof http.OutgoingMessage); @@ -133,8 +133,8 @@ test(function serverResponseTimeoutWithPipeline(cb) { cb(); }); server.listen(common.mustCall(function() { - var port = server.address().port; - var c = net.connect({ port: port, allowHalfOpen: true }, function() { + const port = server.address().port; + const c = net.connect({ port: port, allowHalfOpen: true }, function() { c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n'); c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n'); c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n'); @@ -143,15 +143,15 @@ test(function serverResponseTimeoutWithPipeline(cb) { }); test(function idleTimeout(cb) { - var caughtTimeoutOnRequest = false; - var caughtTimeoutOnResponse = false; - var caughtTimeoutOnServer = false; + let caughtTimeoutOnRequest = false; + let caughtTimeoutOnResponse = false; + let caughtTimeoutOnServer = false; process.on('exit', function() { assert(!caughtTimeoutOnRequest); assert(!caughtTimeoutOnResponse); assert(caughtTimeoutOnServer); }); - var server = http.createServer(function(req, res) { + const server = http.createServer(function(req, res) { req.on('timeout', function(socket) { caughtTimeoutOnRequest = true; }); @@ -160,7 +160,7 @@ test(function idleTimeout(cb) { }); res.end(); }); - var s = server.setTimeout(50, function(socket) { + const s = server.setTimeout(50, function(socket) { caughtTimeoutOnServer = true; socket.destroy(); server.close(); @@ -168,8 +168,8 @@ test(function idleTimeout(cb) { }); assert.ok(s instanceof http.Server); server.listen(common.mustCall(function() { - var port = server.address().port; - var c = net.connect({ port: port, allowHalfOpen: true }, function() { + const port = server.address().port; + const c = net.connect({ port: port, allowHalfOpen: true }, function() { c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n'); // Keep-Alive }); diff --git a/test/parallel/test-http-set-timeout.js b/test/parallel/test-http-set-timeout.js index e8df29e0ccdc67..965b3486faee95 100644 --- a/test/parallel/test-http-set-timeout.js +++ b/test/parallel/test-http-set-timeout.js @@ -4,9 +4,9 @@ const assert = require('assert'); const http = require('http'); const net = require('net'); -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { console.log('got request. setting 500ms timeout'); - var socket = req.connection.setTimeout(500); + const socket = req.connection.setTimeout(500); assert.ok(socket instanceof net.Socket); req.connection.on('timeout', common.mustCall(function() { req.connection.destroy(); @@ -18,7 +18,7 @@ var server = http.createServer(function(req, res) { server.listen(0, function() { console.log(`Server running at http://127.0.0.1:${this.address().port}/`); - var request = http.get({port: this.address().port, path: '/'}); + const request = http.get({port: this.address().port, path: '/'}); request.on('error', common.mustCall(function() { console.log('HTTP REQUEST COMPLETE (this is good)'); })); diff --git a/test/parallel/test-http-set-trailers.js b/test/parallel/test-http-set-trailers.js index b3f331c6d8b172..7b66933ecd12cd 100644 --- a/test/parallel/test-http-set-trailers.js +++ b/test/parallel/test-http-set-trailers.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); -var outstanding_reqs = 0; +let outstanding_reqs = 0; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200, [['content-type', 'text/plain']]); res.addTrailers({'x-foo': 'bar'}); res.end('stuff' + '\n'); @@ -16,8 +16,8 @@ server.listen(0); // first, we test an HTTP/1.0 request. server.on('listening', function() { - var c = net.createConnection(this.address().port); - var res_buffer = ''; + const c = net.createConnection(this.address().port); + let res_buffer = ''; c.setEncoding('utf8'); @@ -44,9 +44,9 @@ server.on('listening', function() { // now, we test an HTTP/1.1 request. server.on('listening', function() { - var c = net.createConnection(this.address().port); - var res_buffer = ''; - var tid; + const c = net.createConnection(this.address().port); + let res_buffer = ''; + let tid; c.setEncoding('utf8'); diff --git a/test/parallel/test-http-should-keep-alive.js b/test/parallel/test-http-should-keep-alive.js index 3aaa2d3d73acdc..190c8c8d8843ad 100644 --- a/test/parallel/test-http-should-keep-alive.js +++ b/test/parallel/test-http-should-keep-alive.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); -var SERVER_RESPONSES = [ +const SERVER_RESPONSES = [ 'HTTP/1.0 200 ok\r\nContent-Length: 0\r\n\r\n', 'HTTP/1.0 200 ok\r\nContent-Length: 0\r\nConnection: keep-alive\r\n\r\n', 'HTTP/1.0 200 ok\r\nContent-Length: 0\r\nConnection: close\r\n\r\n', @@ -12,7 +12,7 @@ var SERVER_RESPONSES = [ 'HTTP/1.1 200 ok\r\nContent-Length: 0\r\nConnection: keep-alive\r\n\r\n', 'HTTP/1.1 200 ok\r\nContent-Length: 0\r\nConnection: close\r\n\r\n' ]; -var SHOULD_KEEP_ALIVE = [ +const SHOULD_KEEP_ALIVE = [ false, // HTTP/1.0, default true, // HTTP/1.0, Connection: keep-alive false, // HTTP/1.0, Connection: close @@ -20,18 +20,18 @@ var SHOULD_KEEP_ALIVE = [ true, // HTTP/1.1, Connection: keep-alive false // HTTP/1.1, Connection: close ]; -var requests = 0; -var responses = 0; +let requests = 0; +let responses = 0; http.globalAgent.maxSockets = 5; -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { socket.write(SERVER_RESPONSES[requests]); ++requests; }).listen(0, function() { function makeRequest() { - var req = http.get({port: server.address().port}, function(res) { - assert.equal(req.shouldKeepAlive, SHOULD_KEEP_ALIVE[responses], - SERVER_RESPONSES[responses] + ' should ' + + const req = http.get({port: server.address().port}, function(res) { + assert.strictEqual(req.shouldKeepAlive, SHOULD_KEEP_ALIVE[responses], + SERVER_RESPONSES[responses] + ' should ' + (SHOULD_KEEP_ALIVE[responses] ? '' : 'not ') + 'Keep-Alive'); ++responses; @@ -48,6 +48,6 @@ var server = net.createServer(function(socket) { }); process.on('exit', function() { - assert.equal(requests, SERVER_RESPONSES.length); - assert.equal(responses, SHOULD_KEEP_ALIVE.length); + assert.strictEqual(requests, SERVER_RESPONSES.length); + assert.strictEqual(responses, SHOULD_KEEP_ALIVE.length); }); diff --git a/test/parallel/test-http-status-code.js b/test/parallel/test-http-status-code.js index c0086a3e3d672f..111b5db16daecb 100644 --- a/test/parallel/test-http-status-code.js +++ b/test/parallel/test-http-status-code.js @@ -1,20 +1,20 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); +const assert = require('assert'); +const http = require('http'); // Simple test of Node's HTTP ServerResponse.statusCode // ServerResponse.prototype.statusCode -var testsComplete = 0; -var tests = [200, 202, 300, 404, 451, 500]; -var testIdx = 0; +let testsComplete = 0; +const tests = [200, 202, 300, 404, 451, 500]; +let testIdx = 0; -var s = http.createServer(function(req, res) { - var t = tests[testIdx]; +const s = http.createServer(function(req, res) { + const t = tests[testIdx]; res.writeHead(t, {'Content-Type': 'text/plain'}); console.log('--\nserver: statusCode after writeHead: ' + res.statusCode); - assert.equal(res.statusCode, t); + assert.strictEqual(res.statusCode, t); res.end('hello world\n'); }); @@ -25,12 +25,12 @@ function nextTest() { if (testIdx + 1 === tests.length) { return s.close(); } - var test = tests[testIdx]; + const test = tests[testIdx]; http.get({ port: s.address().port }, function(response) { console.log('client: expected status: ' + test); console.log('client: statusCode: ' + response.statusCode); - assert.equal(response.statusCode, test); + assert.strictEqual(response.statusCode, test); response.on('end', function() { testsComplete++; testIdx += 1; @@ -42,5 +42,5 @@ function nextTest() { process.on('exit', function() { - assert.equal(5, testsComplete); + assert.strictEqual(5, testsComplete); }); diff --git a/test/parallel/test-http-status-message.js b/test/parallel/test-http-status-message.js index 6da4b6e4281171..54c683212b8ff1 100644 --- a/test/parallel/test-http-status-message.js +++ b/test/parallel/test-http-status-message.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); -var s = http.createServer(function(req, res) { +const s = http.createServer(function(req, res) { res.statusCode = 200; res.statusMessage = 'Custom Message'; res.end(''); @@ -14,16 +14,16 @@ s.listen(0, test); function test() { - var bufs = []; - var client = net.connect(this.address().port, function() { + const bufs = []; + const client = net.connect(this.address().port, function() { client.write('GET / HTTP/1.1\r\nConnection: close\r\n\r\n'); }); client.on('data', function(chunk) { bufs.push(chunk); }); client.on('end', function() { - var head = Buffer.concat(bufs).toString('latin1').split('\r\n')[0]; - assert.equal('HTTP/1.1 200 Custom Message', head); + const head = Buffer.concat(bufs).toString('latin1').split('\r\n')[0]; + assert.strictEqual('HTTP/1.1 200 Custom Message', head); console.log('ok'); s.close(); }); diff --git a/test/parallel/test-http-status-reason-invalid-chars.js b/test/parallel/test-http-status-reason-invalid-chars.js index 9950eeeee9cdd2..75ccb2c2430c53 100644 --- a/test/parallel/test-http-status-reason-invalid-chars.js +++ b/test/parallel/test-http-status-reason-invalid-chars.js @@ -3,7 +3,6 @@ const common = require('../common'); const assert = require('assert'); const http = require('http'); -const net = require('net'); function explicit(req, res) { assert.throws(() => { @@ -34,8 +33,7 @@ const server = http.createServer((req, res) => { implicit(req, res); } }).listen(0, common.mustCall(() => { - const addr = server.address().address; - const hostname = net.isIPv6(addr) ? `[${addr}1]` : addr; + const hostname = 'localhost'; const url = `http://${hostname}:${server.address().port}`; let left = 2; const check = common.mustCall((res) => { diff --git a/test/parallel/test-http-timeout-overflow.js b/test/parallel/test-http-timeout-overflow.js index 49cf3ec0278fca..755859ddc9992d 100644 --- a/test/parallel/test-http-timeout-overflow.js +++ b/test/parallel/test-http-timeout-overflow.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); -var serverRequests = 0; -var clientRequests = 0; +let serverRequests = 0; +let clientRequests = 0; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { serverRequests++; res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('OK'); @@ -16,7 +16,7 @@ var server = http.createServer(function(req, res) { server.listen(0, function() { function callback() {} - var req = http.request({ + const req = http.request({ port: this.address().port, path: '/', agent: false @@ -37,6 +37,6 @@ server.listen(0, function() { }); process.once('exit', function() { - assert.equal(clientRequests, 1); - assert.equal(serverRequests, 1); + assert.strictEqual(clientRequests, 1); + assert.strictEqual(serverRequests, 1); }); diff --git a/test/parallel/test-http-timeout.js b/test/parallel/test-http-timeout.js index b8a28fc2c4cf32..63f87ed63089ee 100644 --- a/test/parallel/test-http-timeout.js +++ b/test/parallel/test-http-timeout.js @@ -1,24 +1,24 @@ 'use strict'; require('../common'); -var http = require('http'); +const http = require('http'); -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('OK'); }); -var agent = new http.Agent({maxSockets: 1}); +const agent = new http.Agent({maxSockets: 1}); server.listen(0, function() { - for (var i = 0; i < 11; ++i) { + for (let i = 0; i < 11; ++i) { createRequest().end(); } function callback() {} - var count = 0; + let count = 0; function createRequest() { const req = http.request( diff --git a/test/parallel/test-http-unix-socket.js b/test/parallel/test-http-unix-socket.js index d2b99bde95a234..f9308d86325cd1 100644 --- a/test/parallel/test-http-unix-socket.js +++ b/test/parallel/test-http-unix-socket.js @@ -17,12 +17,12 @@ common.refreshTmpDir(); server.listen(common.PIPE, common.mustCall(function() { - var options = { + const options = { socketPath: common.PIPE, path: '/' }; - var req = http.get(options, common.mustCall(function(res) { + const req = http.get(options, common.mustCall(function(res) { assert.strictEqual(res.statusCode, 200); assert.strictEqual(res.headers['content-type'], 'text/plain'); diff --git a/test/parallel/test-http-upgrade-advertise.js b/test/parallel/test-http-upgrade-advertise.js index 3deb71fbea1b75..99a3e8fd353015 100644 --- a/test/parallel/test-http-upgrade-advertise.js +++ b/test/parallel/test-http-upgrade-advertise.js @@ -18,7 +18,7 @@ function fire() { const test = tests.shift(); const done = common.mustCall(function done(result) { - assert.equal(result, test.expected); + assert.strictEqual(result, test.expected); fire(); }); diff --git a/test/parallel/test-http-upgrade-agent.js b/test/parallel/test-http-upgrade-agent.js index 48eaa16f898021..e0e1c6d1f3fb6d 100644 --- a/test/parallel/test-http-upgrade-agent.js +++ b/test/parallel/test-http-upgrade-agent.js @@ -3,14 +3,14 @@ // the HTTP client. This test uses a raw TCP server to better control server // behavior. -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var http = require('http'); -var net = require('net'); +const http = require('http'); +const net = require('net'); // Create a TCP server -var srv = net.createServer(function(c) { +const srv = net.createServer(function(c) { c.on('data', function(d) { c.write('HTTP/1.1 101\r\n'); c.write('hello: world\r\n'); @@ -27,7 +27,7 @@ var srv = net.createServer(function(c) { srv.listen(0, '127.0.0.1', common.mustCall(function() { - var options = { + const options = { port: this.address().port, host: '127.0.0.1', headers: { @@ -35,25 +35,25 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() { 'upgrade': 'websocket' } }; - var name = options.host + ':' + options.port; + const name = options.host + ':' + options.port; - var req = http.request(options); + const req = http.request(options); req.end(); req.on('upgrade', common.mustCall(function(res, socket, upgradeHead) { - var recvData = upgradeHead; + let recvData = upgradeHead; socket.on('data', function(d) { recvData += d; }); socket.on('close', common.mustCall(function() { - assert.equal(recvData, 'nurtzo'); + assert.strictEqual(recvData.toString(), 'nurtzo'); })); console.log(res.headers); - var expectedHeaders = { 'hello': 'world', - 'connection': 'upgrade', - 'upgrade': 'websocket' }; + const expectedHeaders = { 'hello': 'world', + 'connection': 'upgrade', + 'upgrade': 'websocket' }; assert.deepStrictEqual(expectedHeaders, res.headers); // Make sure this request got removed from the pool. diff --git a/test/parallel/test-http-upgrade-client.js b/test/parallel/test-http-upgrade-client.js index 51c70122b99d87..34e3e8f24158e7 100644 --- a/test/parallel/test-http-upgrade-client.js +++ b/test/parallel/test-http-upgrade-client.js @@ -3,14 +3,14 @@ // the HTTP client. This test uses a raw TCP server to better control server // behavior. -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var http = require('http'); -var net = require('net'); +const http = require('http'); +const net = require('net'); // Create a TCP server -var srv = net.createServer(function(c) { +const srv = net.createServer(function(c) { c.on('data', function(d) { c.write('HTTP/1.1 101\r\n'); c.write('hello: world\r\n'); @@ -39,16 +39,16 @@ srv.listen(0, '127.0.0.1', common.mustCall(function() { ['Origin', 'http://www.websocket.org'] ] ]; - var left = headers.length; + let left = headers.length; headers.forEach(function(h) { - var req = http.get({ + const req = http.get({ port: port, headers: h }); - var sawUpgrade = false; + let sawUpgrade = false; req.on('upgrade', common.mustCall(function(res, socket, upgradeHead) { sawUpgrade = true; - var recvData = upgradeHead; + let recvData = upgradeHead; socket.on('data', function(d) { recvData += d; }); diff --git a/test/parallel/test-http-upgrade-client2.js b/test/parallel/test-http-upgrade-client2.js index 0c229a354add48..fa14f8ca51f030 100644 --- a/test/parallel/test-http-upgrade-client2.js +++ b/test/parallel/test-http-upgrade-client2.js @@ -1,10 +1,10 @@ 'use strict'; const common = require('../common'); -var http = require('http'); +const http = require('http'); -var CRLF = '\r\n'; +const CRLF = '\r\n'; -var server = http.createServer(); +const server = http.createServer(); server.on('upgrade', function(req, socket, head) { socket.write('HTTP/1.1 101 Ok' + CRLF + 'Connection: Upgrade' + CRLF + @@ -18,12 +18,12 @@ server.listen(0, common.mustCall(function() { function upgradeRequest(fn) { console.log('req'); - var header = { 'Connection': 'Upgrade', 'Upgrade': 'Test' }; - var request = http.request({ + const header = { 'Connection': 'Upgrade', 'Upgrade': 'Test' }; + const request = http.request({ port: server.address().port, headers: header }); - var wasUpgrade = false; + let wasUpgrade = false; function onUpgrade(res, socket, head) { console.log('client upgraded'); diff --git a/test/parallel/test-http-upgrade-server.js b/test/parallel/test-http-upgrade-server.js index 8570dec899b672..b7335b49e83c5f 100644 --- a/test/parallel/test-http-upgrade-server.js +++ b/test/parallel/test-http-upgrade-server.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var util = require('util'); -var net = require('net'); -var http = require('http'); +const util = require('util'); +const net = require('net'); +const http = require('http'); -var requests_recv = 0; -var requests_sent = 0; -var request_upgradeHead = null; +let requests_recv = 0; +let requests_sent = 0; +let request_upgradeHead = null; function createTestServer() { return new testServer(); @@ -37,7 +37,7 @@ function testServer() { request_upgradeHead = upgradeHead; socket.on('data', function(d) { - var data = d.toString('utf8'); + const data = d.toString('utf8'); if (data === 'kill') { socket.end(); } else { @@ -60,9 +60,9 @@ function writeReq(socket, data, encoding) { connection: Upgrade with listener -----------------------------------------------*/ function test_upgrade_with_listener() { - var conn = net.createConnection(server.address().port); + const conn = net.createConnection(server.address().port); conn.setEncoding('utf8'); - var state = 0; + let state = 0; conn.on('connect', function() { writeReq(conn, @@ -76,20 +76,20 @@ function test_upgrade_with_listener() { conn.on('data', function(data) { state++; - assert.equal('string', typeof data); + assert.strictEqual('string', typeof data); if (state === 1) { - assert.equal('HTTP/1.1 101', data.substr(0, 12)); - assert.equal('WjN}|M(6', request_upgradeHead.toString('utf8')); + assert.strictEqual('HTTP/1.1 101', data.substr(0, 12)); + assert.strictEqual('WjN}|M(6', request_upgradeHead.toString('utf8')); conn.write('test', 'utf8'); } else if (state === 2) { - assert.equal('test', data); + assert.strictEqual('test', data); conn.write('kill', 'utf8'); } }); conn.on('end', function() { - assert.equal(2, state); + assert.strictEqual(2, state); conn.end(); server.removeAllListeners('upgrade'); test_upgrade_no_listener(); @@ -99,10 +99,10 @@ function test_upgrade_with_listener() { /*----------------------------------------------- connection: Upgrade, no listener -----------------------------------------------*/ -var test_upgrade_no_listener_ended = false; +let test_upgrade_no_listener_ended = false; function test_upgrade_no_listener() { - var conn = net.createConnection(server.address().port); + const conn = net.createConnection(server.address().port); conn.setEncoding('utf8'); conn.on('connect', function() { @@ -127,7 +127,7 @@ function test_upgrade_no_listener() { connection: normal -----------------------------------------------*/ function test_standard_http() { - var conn = net.createConnection(server.address().port); + const conn = net.createConnection(server.address().port); conn.setEncoding('utf8'); conn.on('connect', function() { @@ -135,8 +135,8 @@ function test_standard_http() { }); conn.once('data', function(data) { - assert.equal('string', typeof data); - assert.equal('HTTP/1.1 200', data.substr(0, 12)); + assert.strictEqual('string', typeof data); + assert.strictEqual('HTTP/1.1 200', data.substr(0, 12)); conn.end(); }); @@ -146,7 +146,7 @@ function test_standard_http() { } -var server = createTestServer(); +const server = createTestServer(); server.listen(0, function() { // All tests get chained after this: @@ -158,7 +158,7 @@ server.listen(0, function() { Fin. -----------------------------------------------*/ process.on('exit', function() { - assert.equal(3, requests_recv); - assert.equal(3, requests_sent); + assert.strictEqual(3, requests_recv); + assert.strictEqual(3, requests_sent); assert.ok(test_upgrade_no_listener_ended); }); diff --git a/test/parallel/test-http-upgrade-server2.js b/test/parallel/test-http-upgrade-server2.js index 1644f54977af85..3ff33a9c794c25 100644 --- a/test/parallel/test-http-upgrade-server2.js +++ b/test/parallel/test-http-upgrade-server2.js @@ -1,10 +1,10 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { throw new Error('This shouldn\'t happen.'); }); @@ -15,13 +15,13 @@ server.on('upgrade', function(req, socket, upgradeHead) { }); process.on('uncaughtException', common.mustCall(function(e) { - assert.equal('upgrade error', e.message); + assert.strictEqual('upgrade error', e.message); process.exit(0); })); server.listen(0, function() { - var c = net.createConnection(this.address().port); + const c = net.createConnection(this.address().port); c.on('connect', function() { c.write('GET /blah HTTP/1.1\r\n' + diff --git a/test/parallel/test-http-url.parse-auth-with-header-in-request.js b/test/parallel/test-http-url.parse-auth-with-header-in-request.js index fa930bd5ec2e34..d91ec75f60d767 100644 --- a/test/parallel/test-http-url.parse-auth-with-header-in-request.js +++ b/test/parallel/test-http-url.parse-auth-with-header-in-request.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); function check(request) { // the correct authorization header is be passed assert.strictEqual(request.headers.authorization, 'NoAuthForYOU'); } -var server = http.createServer(function(request, response) { +const server = http.createServer(function(request, response) { // run the check function check.call(this, request, response); response.writeHead(200, {}); @@ -18,7 +18,8 @@ var server = http.createServer(function(request, response) { }); server.listen(0, function() { - var testURL = url.parse(`http://asdf:qwer@localhost:${this.address().port}`); + const testURL = url.parse('http://asdf:qwer@localhost:' + + `${this.address().port}`); // the test here is if you set a specific authorization header in the // request we should not override that with basic auth testURL.headers = { diff --git a/test/parallel/test-http-url.parse-auth.js b/test/parallel/test-http-url.parse-auth.js index 0e901ebb599b00..25913f4e49a12a 100644 --- a/test/parallel/test-http-url.parse-auth.js +++ b/test/parallel/test-http-url.parse-auth.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); function check(request) { // the correct authorization header is be passed assert.strictEqual(request.headers.authorization, 'Basic dXNlcjpwYXNzOg=='); } -var server = http.createServer(function(request, response) { +const server = http.createServer(function(request, response) { // run the check function check.call(this, request, response); response.writeHead(200, {}); @@ -20,7 +20,7 @@ var server = http.createServer(function(request, response) { server.listen(0, function() { const port = this.address().port; // username = "user", password = "pass:" - var testURL = url.parse(`http://user:pass%3A@localhost:${port}`); + const testURL = url.parse(`http://user:pass%3A@localhost:${port}`); // make the request http.request(testURL).end(); diff --git a/test/parallel/test-http-url.parse-basic.js b/test/parallel/test-http-url.parse-basic.js index b0d1274b594d7e..ac22b6e38d80e1 100644 --- a/test/parallel/test-http-url.parse-basic.js +++ b/test/parallel/test-http-url.parse-basic.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); -var testURL; +let testURL; // make sure the basics work function check(request) { @@ -17,7 +17,7 @@ function check(request) { testURL.hostname + ':' + testURL.port); } -var server = http.createServer(function(request, response) { +const server = http.createServer(function(request, response) { // run the check function check.call(this, request, response); response.writeHead(200, {}); @@ -29,7 +29,7 @@ server.listen(0, function() { testURL = url.parse(`http://localhost:${this.address().port}`); // make the request - var clientRequest = http.request(testURL); + const clientRequest = http.request(testURL); // since there is a little magic with the agent // make sure that an http request uses the http.Agent assert.ok(clientRequest.agent instanceof http.Agent); diff --git a/test/parallel/test-http-url.parse-https.request.js b/test/parallel/test-http-url.parse-https.request.js index edd83a2d1306f5..ad40e76debee90 100644 --- a/test/parallel/test-http-url.parse-https.request.js +++ b/test/parallel/test-http-url.parse-https.request.js @@ -1,18 +1,18 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var url = require('url'); -var fs = require('fs'); +const url = require('url'); +const fs = require('fs'); // https options -var httpsOptions = { +const httpsOptions = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; @@ -22,7 +22,7 @@ function check(request) { assert.ok(request.socket._secureEstablished); } -var server = https.createServer(httpsOptions, function(request, response) { +const server = https.createServer(httpsOptions, function(request, response) { // run the check function check.call(this, request, response); response.writeHead(200, {}); @@ -31,11 +31,11 @@ var server = https.createServer(httpsOptions, function(request, response) { }); server.listen(0, function() { - var testURL = url.parse(`https://localhost:${this.address().port}`); + const testURL = url.parse(`https://localhost:${this.address().port}`); testURL.rejectUnauthorized = false; // make the request - var clientRequest = https.request(testURL); + const clientRequest = https.request(testURL); // since there is a little magic with the agent // make sure that the request uses the https.Agent assert.ok(clientRequest.agent instanceof https.Agent); diff --git a/test/parallel/test-http-url.parse-only-support-http-https-protocol.js b/test/parallel/test-http-url.parse-only-support-http-https-protocol.js index e7ed82817146ea..b3d7795e72cefa 100644 --- a/test/parallel/test-http-url.parse-only-support-http-https-protocol.js +++ b/test/parallel/test-http-url.parse-only-support-http-https-protocol.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); assert.throws(function() { diff --git a/test/parallel/test-http-url.parse-path.js b/test/parallel/test-http-url.parse-path.js index 73de297d45fca5..6fab8bb0eb3b6b 100644 --- a/test/parallel/test-http-url.parse-path.js +++ b/test/parallel/test-http-url.parse-path.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); function check(request) { // a path should come over assert.strictEqual(request.url, '/asdf'); } -var server = http.createServer(function(request, response) { +const server = http.createServer(function(request, response) { // run the check function check.call(this, request, response); response.writeHead(200, {}); @@ -18,7 +18,7 @@ var server = http.createServer(function(request, response) { }); server.listen(0, function() { - var testURL = url.parse(`http://localhost:${this.address().port}/asdf`); + const testURL = url.parse(`http://localhost:${this.address().port}/asdf`); // make the request http.request(testURL).end(); diff --git a/test/parallel/test-http-url.parse-post.js b/test/parallel/test-http-url.parse-post.js index 0af482c94a875d..d63f404c5403dd 100644 --- a/test/parallel/test-http-url.parse-post.js +++ b/test/parallel/test-http-url.parse-post.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); -var testURL; +let testURL; function check(request) { //url.parse should not mess with the method @@ -16,7 +16,7 @@ function check(request) { testURL.hostname + ':' + testURL.port); } -var server = http.createServer(function(request, response) { +const server = http.createServer(function(request, response) { // run the check function check.call(this, request, response); response.writeHead(200, {}); diff --git a/test/parallel/test-http-url.parse-search.js b/test/parallel/test-http-url.parse-search.js index 9a1e7565572fcc..f2a5d1806d89a2 100644 --- a/test/parallel/test-http-url.parse-search.js +++ b/test/parallel/test-http-url.parse-search.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var http = require('http'); -var url = require('url'); +const assert = require('assert'); +const http = require('http'); +const url = require('url'); function check(request) { // a path should come over with params assert.strictEqual(request.url, '/asdf?qwer=zxcv'); } -var server = http.createServer(function(request, response) { +const server = http.createServer(function(request, response) { // run the check function check.call(this, request, response); response.writeHead(200, {}); @@ -19,7 +19,7 @@ var server = http.createServer(function(request, response) { server.listen(0, function() { const port = this.address().port; - var testURL = url.parse(`http://localhost:${port}/asdf?qwer=zxcv`); + const testURL = url.parse(`http://localhost:${port}/asdf?qwer=zxcv`); // make the request http.request(testURL).end(); diff --git a/test/parallel/test-http-wget.js b/test/parallel/test-http-wget.js index f7fb1a3656c623..a633873c8bb16f 100644 --- a/test/parallel/test-http-wget.js +++ b/test/parallel/test-http-wget.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); -var http = require('http'); +const assert = require('assert'); +const net = require('net'); +const http = require('http'); // wget sends an HTTP/1.0 request with Connection: Keep-Alive // @@ -19,7 +19,7 @@ var http = require('http'); // content-length is not provided, that the connection is in fact // closed. -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('hello '); res.write('world\n'); @@ -28,8 +28,8 @@ var server = http.createServer(function(req, res) { server.listen(0); server.on('listening', common.mustCall(function() { - var c = net.createConnection(this.address().port); - var server_response = ''; + const c = net.createConnection(this.address().port); + let server_response = ''; c.setEncoding('utf8'); diff --git a/test/parallel/test-http-write-callbacks.js b/test/parallel/test-http-write-callbacks.js index b89cdf89af7b90..03250a0030ceff 100644 --- a/test/parallel/test-http-write-callbacks.js +++ b/test/parallel/test-http-write-callbacks.js @@ -1,34 +1,34 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); -var serverEndCb = false; -var serverIncoming = ''; -var serverIncomingExpect = 'bazquuxblerg'; +let serverEndCb = false; +let serverIncoming = ''; +const serverIncomingExpect = 'bazquuxblerg'; -var clientEndCb = false; -var clientIncoming = ''; -var clientIncomingExpect = 'asdffoobar'; +let clientEndCb = false; +let clientIncoming = ''; +const clientIncomingExpect = 'asdffoobar'; process.on('exit', function() { assert(serverEndCb); - assert.equal(serverIncoming, serverIncomingExpect); + assert.strictEqual(serverIncoming, serverIncomingExpect); assert(clientEndCb); - assert.equal(clientIncoming, clientIncomingExpect); + assert.strictEqual(clientIncoming, clientIncomingExpect); console.log('ok'); }); // Verify that we get a callback when we do res.write(..., cb) -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.statusCode = 400; res.end('Bad Request.\nMust send Expect:100-continue\n'); }); server.on('checkContinue', function(req, res) { server.close(); - assert.equal(req.method, 'PUT'); + assert.strictEqual(req.method, 'PUT'); res.writeContinue(function() { // continue has been written req.on('end', function() { @@ -51,7 +51,7 @@ server.on('checkContinue', function(req, res) { }); server.listen(0, function() { - var req = http.request({ + const req = http.request({ port: this.address().port, method: 'PUT', headers: { 'expect': '100-continue' } diff --git a/test/parallel/test-http-write-empty-string.js b/test/parallel/test-http-write-empty-string.js index 534a55823accee..81ebc61eef2af4 100644 --- a/test/parallel/test-http-write-empty-string.js +++ b/test/parallel/test-http-write-empty-string.js @@ -1,10 +1,10 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); -var server = http.createServer(function(request, response) { +const server = http.createServer(function(request, response) { console.log('responding to ' + request.url); response.writeHead(200, {'Content-Type': 'text/plain'}); @@ -19,9 +19,9 @@ var server = http.createServer(function(request, response) { server.listen(0, common.mustCall(function() { http.get({ port: this.address().port }, common.mustCall(function(res) { - var response = ''; + let response = ''; - assert.equal(200, res.statusCode); + assert.strictEqual(200, res.statusCode); res.setEncoding('ascii'); res.on('data', function(chunk) { response += chunk; diff --git a/test/parallel/test-http-write-head.js b/test/parallel/test-http-write-head.js index 32fff6042e7178..2ceba8965c0ea4 100644 --- a/test/parallel/test-http-write-head.js +++ b/test/parallel/test-http-write-head.js @@ -1,16 +1,16 @@ 'use strict'; -require('../common'); -var assert = require('assert'); -var http = require('http'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); // Verify that ServerResponse.writeHead() works as setHeader. // Issue 5036 on github. -var s = http.createServer(function(req, res) { +const s = http.createServer(common.mustCall((req, res) => { res.setHeader('test', '1'); // toLowerCase() is used on the name argument, so it must be a string. - var threw = false; + let threw = false; try { res.setHeader(0xf00, 'bar'); } catch (e) { @@ -25,24 +25,30 @@ var s = http.createServer(function(req, res) { res.setHeader('foo', undefined); } catch (e) { assert.ok(e instanceof Error); - assert.equal(e.message, '"value" required in setHeader("foo", value)'); + assert.strictEqual(e.message, + '"value" required in setHeader("foo", value)'); threw = true; } assert.ok(threw, 'Undefined value should throw'); res.writeHead(200, { Test: '2' }); + + assert.throws(() => { + res.writeHead(100, {}); + }, /^Error: Can't render headers after they are sent to the client$/); + res.end(); -}); +})); -s.listen(0, runTest); +s.listen(0, common.mustCall(runTest)); function runTest() { - http.get({ port: this.address().port }, function(response) { - response.on('end', function() { - assert.equal(response.headers['test'], '2'); + http.get({ port: this.address().port }, common.mustCall((response) => { + response.on('end', common.mustCall(() => { + assert.strictEqual(response.headers['test'], '2'); assert.notStrictEqual(response.rawHeaders.indexOf('Test'), -1); s.close(); - }); + })); response.resume(); - }); + })); } diff --git a/test/parallel/test-http-zero-length-write.js b/test/parallel/test-http-zero-length-write.js index b928aaeb341a88..11db6b1aa17f45 100644 --- a/test/parallel/test-http-zero-length-write.js +++ b/test/parallel/test-http-zero-length-write.js @@ -1,18 +1,18 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var http = require('http'); +const http = require('http'); -var Stream = require('stream'); +const Stream = require('stream'); function getSrc() { // An old-style readable stream. // The Readable class prevents this behavior. - var src = new Stream(); + const src = new Stream(); // start out paused, just so we don't miss anything yet. - var paused = false; + let paused = false; src.pause = function() { paused = true; }; @@ -20,12 +20,12 @@ function getSrc() { paused = false; }; - var chunks = [ '', 'asdf', '', 'foo', '', 'bar', '' ]; - var interval = setInterval(function() { + const chunks = [ '', 'asdf', '', 'foo', '', 'bar', '' ]; + const interval = setInterval(function() { if (paused) return; - var chunk = chunks.shift(); + const chunk = chunks.shift(); if (chunk !== undefined) { src.emit('data', chunk); } else { @@ -38,31 +38,31 @@ function getSrc() { } -var expect = 'asdffoobar'; +const expect = 'asdffoobar'; -var server = http.createServer(function(req, res) { - var actual = ''; +const server = http.createServer(function(req, res) { + let actual = ''; req.setEncoding('utf8'); req.on('data', function(c) { actual += c; }); req.on('end', function() { - assert.equal(actual, expect); + assert.strictEqual(actual, expect); getSrc().pipe(res); }); server.close(); }); server.listen(0, function() { - var req = http.request({ port: this.address().port, method: 'POST' }); - var actual = ''; + const req = http.request({ port: this.address().port, method: 'POST' }); + let actual = ''; req.on('response', function(res) { res.setEncoding('utf8'); res.on('data', function(c) { actual += c; }); res.on('end', function() { - assert.equal(actual, expect); + assert.strictEqual(actual, expect); }); }); getSrc().pipe(req); diff --git a/test/parallel/test-http.js b/test/parallel/test-http.js index f755bca8bc74ec..1178c745e1e12a 100644 --- a/test/parallel/test-http.js +++ b/test/parallel/test-http.js @@ -4,10 +4,10 @@ const assert = require('assert'); const http = require('http'); const url = require('url'); -var responses_sent = 0; -var responses_recvd = 0; -var body0 = ''; -var body1 = ''; +let responses_sent = 0; +let responses_recvd = 0; +let body0 = ''; +let body1 = ''; const server = http.Server(function(req, res) { if (responses_sent === 0) { @@ -36,7 +36,7 @@ const server = http.Server(function(req, res) { }); req.resume(); - //assert.equal('127.0.0.1', res.connection.remoteAddress); + //assert.strictEqual('127.0.0.1', res.connection.remoteAddress); }); server.listen(0); diff --git a/test/parallel/test-https-agent-disable-session-reuse.js b/test/parallel/test-https-agent-disable-session-reuse.js index dc9878d4a1c1ed..7cca9c713ae011 100644 --- a/test/parallel/test-https-agent-disable-session-reuse.js +++ b/test/parallel/test-https-agent-disable-session-reuse.js @@ -19,7 +19,7 @@ const options = { }; const clientSessions = []; -var serverRequests = 0; +let serverRequests = 0; const agent = new https.Agent({ maxCachedSessions: 0 @@ -29,7 +29,7 @@ const server = https.createServer(options, function(req, res) { serverRequests++; res.end('ok'); }).listen(0, function() { - var waiting = TOTAL_REQS; + let waiting = TOTAL_REQS; function request() { const options = { agent: agent, @@ -52,8 +52,8 @@ const server = https.createServer(options, function(req, res) { }); process.on('exit', function() { - assert.equal(serverRequests, TOTAL_REQS); - assert.equal(clientSessions.length, TOTAL_REQS); - assert.notEqual(clientSessions[0].toString('hex'), - clientSessions[1].toString('hex')); + assert.strictEqual(serverRequests, TOTAL_REQS); + assert.strictEqual(clientSessions.length, TOTAL_REQS); + assert.notStrictEqual(clientSessions[0].toString('hex'), + clientSessions[1].toString('hex')); }); diff --git a/test/parallel/test-https-agent-getname.js b/test/parallel/test-https-agent-getname.js index 49c1dcef4fb5fb..9b4f29602b79c6 100644 --- a/test/parallel/test-https-agent-getname.js +++ b/test/parallel/test-https-agent-getname.js @@ -14,7 +14,7 @@ const agent = new https.Agent(); // empty options assert.strictEqual( agent.getName({}), - 'localhost:::::::::' + 'localhost::::::::::' ); // pass all options arguments @@ -33,5 +33,5 @@ const options = { assert.strictEqual( agent.getName(options), - '0.0.0.0:443:192.168.1.1:ca:cert:ciphers:key:pfx:false:localhost' + '0.0.0.0:443:192.168.1.1:ca:cert:ciphers:key:pfx:false:localhost:' ); diff --git a/test/parallel/test-https-agent-secure-protocol.js b/test/parallel/test-https-agent-secure-protocol.js new file mode 100644 index 00000000000000..7cca682101fa0b --- /dev/null +++ b/test/parallel/test-https-agent-secure-protocol.js @@ -0,0 +1,60 @@ +'use strict'; +const assert = require('assert'); +const common = require('../common'); + +if (!common.hasCrypto) { + common.skip('missing crypto'); + return; +} + +const https = require('https'); +const fs = require('fs'); + +const options = { + key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), + cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'), + ca: fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem') +}; + +const server = https.Server(options, function(req, res) { + res.writeHead(200); + res.end('hello world\n'); +}); + +server.listen(0, common.mustCall(function() { + const port = this.address().port; + const globalAgent = https.globalAgent; + globalAgent.keepAlive = true; + https.get({ + path: '/', + port: port, + ca: options.ca, + rejectUnauthorized: true, + servername: 'agent1', + secureProtocol: 'SSLv23_method' + }, common.mustCall(function(res) { + res.resume(); + globalAgent.once('free', common.mustCall(function() { + https.get({ + path: '/', + port: port, + ca: options.ca, + rejectUnauthorized: true, + servername: 'agent1', + secureProtocol: 'TLSv1_method' + }, common.mustCall(function(res) { + res.resume(); + globalAgent.once('free', common.mustCall(function() { + // Verify that two keep-alived connections are created + // due to the different secureProtocol settings: + const keys = Object.keys(globalAgent.freeSockets); + assert.strictEqual(keys.length, 2); + assert.ok(keys[0].includes(':SSLv23_method')); + assert.ok(keys[1].includes(':TLSv1_method')); + globalAgent.destroy(); + server.close(); + })); + })); + })); + })); +})); diff --git a/test/parallel/test-https-agent-servername.js b/test/parallel/test-https-agent-servername.js index 348cf499b65f56..a321f7140396a3 100644 --- a/test/parallel/test-https-agent-servername.js +++ b/test/parallel/test-https-agent-servername.js @@ -1,22 +1,22 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); -var fs = require('fs'); +const https = require('https'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'), ca: fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem') }; -var server = https.Server(options, function(req, res) { +const server = https.Server(options, function(req, res) { res.writeHead(200); res.end('hello world\n'); }); diff --git a/test/parallel/test-https-agent-session-reuse.js b/test/parallel/test-https-agent-session-reuse.js index 73465aa5a98fb9..3f06d1699f2cde 100644 --- a/test/parallel/test-https-agent-session-reuse.js +++ b/test/parallel/test-https-agent-session-reuse.js @@ -117,14 +117,14 @@ process.on('exit', function() { assert.strictEqual(serverRequests, 6); assert.strictEqual(clientSessions['first'].toString('hex'), clientSessions['first-reuse'].toString('hex')); - assert.notEqual(clientSessions['first'].toString('hex'), - clientSessions['cipher-change'].toString('hex')); - assert.notEqual(clientSessions['first'].toString('hex'), - clientSessions['before-drop'].toString('hex')); - assert.notEqual(clientSessions['cipher-change'].toString('hex'), - clientSessions['before-drop'].toString('hex')); - assert.notEqual(clientSessions['before-drop'].toString('hex'), - clientSessions['after-drop'].toString('hex')); + assert.notStrictEqual(clientSessions['first'].toString('hex'), + clientSessions['cipher-change'].toString('hex')); + assert.notStrictEqual(clientSessions['first'].toString('hex'), + clientSessions['before-drop'].toString('hex')); + assert.notStrictEqual(clientSessions['cipher-change'].toString('hex'), + clientSessions['before-drop'].toString('hex')); + assert.notStrictEqual(clientSessions['before-drop'].toString('hex'), + clientSessions['after-drop'].toString('hex')); assert.strictEqual(clientSessions['after-drop'].toString('hex'), clientSessions['after-drop-reuse'].toString('hex')); }); diff --git a/test/parallel/test-https-agent-sni.js b/test/parallel/test-https-agent-sni.js index 4174fd0b9c1fed..9bfbe3d5c6525d 100644 --- a/test/parallel/test-https-agent-sni.js +++ b/test/parallel/test-https-agent-sni.js @@ -16,7 +16,7 @@ const options = { }; const TOTAL = 4; -var waiting = TOTAL; +let waiting = TOTAL; const server = https.Server(options, function(req, res) { if (--waiting === 0) server.close(); @@ -31,14 +31,14 @@ server.listen(0, function() { function expectResponse(id) { return common.mustCall(function(res) { res.resume(); - assert.equal(res.headers['x-sni'], 'sni.' + id); + assert.strictEqual(res.headers['x-sni'], 'sni.' + id); }); } - var agent = new https.Agent({ + const agent = new https.Agent({ maxSockets: 1 }); - for (var j = 0; j < TOTAL; j++) { + for (let j = 0; j < TOTAL; j++) { https.get({ agent: agent, diff --git a/test/parallel/test-https-agent.js b/test/parallel/test-https-agent.js index 221ed2bbd2fe49..392bdcbf033000 100644 --- a/test/parallel/test-https-agent.js +++ b/test/parallel/test-https-agent.js @@ -22,15 +22,15 @@ const server = https.Server(options, function(req, res) { }); -var responses = 0; +let responses = 0; const N = 4; const M = 4; server.listen(0, function() { - for (var i = 0; i < N; i++) { + for (let i = 0; i < N; i++) { setTimeout(function() { - for (var j = 0; j < M; j++) { + for (let j = 0; j < M; j++) { https.get({ path: '/', port: server.address().port, diff --git a/test/parallel/test-https-byteswritten.js b/test/parallel/test-https-byteswritten.js index 58dfb12dbe2eda..cdea4d1ee930f3 100644 --- a/test/parallel/test-https-byteswritten.js +++ b/test/parallel/test-https-byteswritten.js @@ -1,22 +1,22 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var body = 'hello world\n'; +const body = 'hello world\n'; -var httpsServer = https.createServer(options, function(req, res) { +const httpsServer = https.createServer(options, function(req, res) { res.on('finish', function() { assert.strictEqual(typeof req.connection.bytesWritten, 'number'); assert(req.connection.bytesWritten > 0); diff --git a/test/parallel/test-https-client-checkServerIdentity.js b/test/parallel/test-https-client-checkServerIdentity.js index 053a5630050748..688c7e22706e0e 100644 --- a/test/parallel/test-https-client-checkServerIdentity.js +++ b/test/parallel/test-https-client-checkServerIdentity.js @@ -1,22 +1,22 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); -var options = { +const options = { key: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent3-key.pem')), cert: fs.readFileSync(path.join(common.fixturesDir, 'keys/agent3-cert.pem')) }; -var server = https.createServer(options, common.mustCall(function(req, res) { +const server = https.createServer(options, common.mustCall(function(req, res) { res.writeHead(200); res.end(); req.resume(); @@ -25,7 +25,7 @@ var server = https.createServer(options, common.mustCall(function(req, res) { }); function authorized() { - var req = https.request({ + const req = https.request({ port: server.address().port, rejectUnauthorized: true, ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))] @@ -37,7 +37,7 @@ function authorized() { } function override() { - var options = { + const options = { port: server.address().port, rejectUnauthorized: true, ca: [fs.readFileSync(path.join(common.fixturesDir, 'keys/ca2-cert.pem'))], @@ -46,7 +46,7 @@ function override() { } }; options.agent = new https.Agent(options); - var req = https.request(options, function(res) { + const req = https.request(options, function(res) { assert(req.socket.authorized); server.close(); }); diff --git a/test/parallel/test-https-client-get-url.js b/test/parallel/test-https-client-get-url.js index 1a9fdf5f3f808e..caaa7522cef57b 100644 --- a/test/parallel/test-https-client-get-url.js +++ b/test/parallel/test-https-client-get-url.js @@ -3,30 +3,35 @@ const common = require('../common'); // disable strict server certificate validation by the client process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; -var assert = require('assert'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); +const fs = require('fs'); +const url = require('url'); +const URL = url.URL; -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = https.createServer(options, common.mustCall(function(req, res) { - assert.equal('GET', req.method); - assert.equal('/foo?bar', req.url); +const server = https.createServer(options, common.mustCall(function(req, res) { + assert.strictEqual('GET', req.method); + assert.strictEqual('/foo?bar', req.url); res.writeHead(200, {'Content-Type': 'text/plain'}); res.write('hello\n'); res.end(); server.close(); -})); +}, 3)); server.listen(0, function() { - https.get(`https://127.0.0.1:${this.address().port}/foo?bar`); + const u = `https://127.0.0.1:${this.address().port}/foo?bar`; + https.get(u); + https.get(url.parse(u)); + https.get(new URL(u)); }); diff --git a/test/parallel/test-https-client-reject.js b/test/parallel/test-https-client-reject.js index b1708f24b10b83..92bbabe8b3be90 100644 --- a/test/parallel/test-https-client-reject.js +++ b/test/parallel/test-https-client-reject.js @@ -1,22 +1,22 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); -var options = { +const options = { key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')), cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')) }; -var server = https.createServer(options, common.mustCall(function(req, res) { +const server = https.createServer(options, common.mustCall(function(req, res) { res.writeHead(200); res.end(); req.resume(); @@ -25,7 +25,7 @@ var server = https.createServer(options, common.mustCall(function(req, res) { }); function unauthorized() { - var req = https.request({ + const req = https.request({ port: server.address().port, rejectUnauthorized: false }, function(res) { @@ -40,11 +40,11 @@ function unauthorized() { } function rejectUnauthorized() { - var options = { + const options = { port: server.address().port }; options.agent = new https.Agent(options); - var req = https.request(options, common.fail); + const req = https.request(options, common.fail); req.on('error', function(err) { authorized(); }); @@ -52,12 +52,12 @@ function rejectUnauthorized() { } function authorized() { - var options = { + const options = { port: server.address().port, ca: [fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem'))] }; options.agent = new https.Agent(options); - var req = https.request(options, function(res) { + const req = https.request(options, function(res) { res.resume(); assert(req.socket.authorized); server.close(); diff --git a/test/parallel/test-https-client-resume.js b/test/parallel/test-https-client-resume.js index 734e8069021f78..79e1a716bd77cf 100644 --- a/test/parallel/test-https-client-resume.js +++ b/test/parallel/test-https-client-resume.js @@ -2,33 +2,33 @@ // Create an ssl server. First connection, validate that not resume. // Cache session and close connection. Use session on second connection. // ASSERT resumption. -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var tls = require('tls'); -var fs = require('fs'); +const tls = require('tls'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem') }; // create server -var server = https.createServer(options, common.mustCall(function(req, res) { +const server = https.createServer(options, common.mustCall(function(req, res) { res.end('Goodbye'); }, 2)); // start listening server.listen(0, function() { - var session1 = null; - var client1 = tls.connect({ + let session1 = null; + const client1 = tls.connect({ port: this.address().port, rejectUnauthorized: false }, function() { @@ -43,13 +43,13 @@ server.listen(0, function() { client1.on('close', function() { console.log('close1'); - var opts = { + const opts = { port: server.address().port, rejectUnauthorized: false, session: session1 }; - var client2 = tls.connect(opts, function() { + const client2 = tls.connect(opts, function() { console.log('connect2'); assert.ok(client2.isSessionReused(), 'Session *should* be reused.'); client2.write('GET / HTTP/1.0\r\n' + diff --git a/test/parallel/test-https-close.js b/test/parallel/test-https-close.js index f77726ceb68bf9..cf950f29d6f8ad 100644 --- a/test/parallel/test-https-close.js +++ b/test/parallel/test-https-close.js @@ -13,17 +13,17 @@ const options = { cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var connections = {}; +const connections = {}; -var server = https.createServer(options, function(req, res) { - var interval = setInterval(function() { +const server = https.createServer(options, function(req, res) { + const interval = setInterval(function() { res.write('data'); }, 1000); interval.unref(); }); server.on('connection', function(connection) { - var key = connection.remoteAddress + ':' + connection.remotePort; + const key = connection.remoteAddress + ':' + connection.remotePort; connection.on('close', function() { delete connections[key]; }); @@ -33,14 +33,14 @@ server.on('connection', function(connection) { function shutdown() { server.close(common.mustCall(function() {})); - for (var key in connections) { + for (const key in connections) { connections[key].destroy(); delete connections[key]; } } server.listen(0, function() { - var requestOptions = { + const requestOptions = { hostname: '127.0.0.1', port: this.address().port, path: '/', @@ -48,7 +48,7 @@ server.listen(0, function() { rejectUnauthorized: false }; - var req = https.request(requestOptions, function(res) { + const req = https.request(requestOptions, function(res) { res.on('data', function(d) {}); setImmediate(shutdown); }); diff --git a/test/parallel/test-https-connecting-to-http.js b/test/parallel/test-https-connecting-to-http.js index 53158595054714..ae8507f99cbc00 100644 --- a/test/parallel/test-https-connecting-to-http.js +++ b/test/parallel/test-https-connecting-to-http.js @@ -1,19 +1,19 @@ 'use strict'; // This tests the situation where you try to connect a https client // to an http server. You should get an error and exit. -var common = require('../common'); -var http = require('http'); +const common = require('../common'); +const http = require('http'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var server = http.createServer(common.fail); +const server = http.createServer(common.fail); server.listen(0, common.mustCall(function() { - var req = https.get({ port: this.address().port }, common.fail); + const req = https.get({ port: this.address().port }, common.fail); req.on('error', common.mustCall(function(e) { console.log('Got expected error: ', e.message); diff --git a/test/parallel/test-https-drain.js b/test/parallel/test-https-drain.js index 7648469b0f54a7..8e85ca70b97c47 100644 --- a/test/parallel/test-https-drain.js +++ b/test/parallel/test-https-drain.js @@ -1,38 +1,38 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); -var options = { +const options = { key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')), cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')) }; -var bufSize = 1024 * 1024; -var sent = 0; -var received = 0; +const bufSize = 1024 * 1024; +let sent = 0; +let received = 0; -var server = https.createServer(options, function(req, res) { +const server = https.createServer(options, function(req, res) { res.writeHead(200); req.pipe(res); }); server.listen(0, function() { - var resumed = false; - var req = https.request({ + let resumed = false; + const req = https.request({ method: 'POST', port: this.address().port, rejectUnauthorized: false }, function(res) { - var timer; + let timer; res.pause(); console.error('paused'); send(); @@ -71,5 +71,5 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.equal(sent, received); + assert.strictEqual(sent, received); }); diff --git a/test/parallel/test-https-eof-for-eom.js b/test/parallel/test-https-eof-for-eom.js index 1c814714bfef96..cb48f71e51a226 100644 --- a/test/parallel/test-https-eof-for-eom.js +++ b/test/parallel/test-https-eof-for-eom.js @@ -7,25 +7,25 @@ // This test is to be sure that the https client is handling this case // correctly. -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); -var tls = require('tls'); +const https = require('https'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = tls.Server(options, function(socket) { +const server = tls.Server(options, function(socket) { console.log('2) Server got request'); socket.write('HTTP/1.1 200 OK\r\n' + 'Date: Tue, 15 Feb 2011 22:14:54 GMT\r\n' + @@ -52,12 +52,12 @@ server.listen(0, common.mustCall(function() { port: this.address().port, rejectUnauthorized: false }, common.mustCall(function(res) { - var bodyBuffer = ''; + let bodyBuffer = ''; server.close(); console.log('3) Client got response headers.'); - assert.equal('gws', res.headers.server); + assert.strictEqual('gws', res.headers.server); res.setEncoding('utf8'); res.on('data', function(s) { diff --git a/test/parallel/test-https-foafssl.js b/test/parallel/test-https-foafssl.js index 5c9fb613e6fa95..5a9b8eb832cae3 100644 --- a/test/parallel/test-https-foafssl.js +++ b/test/parallel/test-https-foafssl.js @@ -1,24 +1,24 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.opensslCli) { common.skip('node compiled without OpenSSL CLI.'); return; } -var assert = require('assert'); -var join = require('path').join; +const assert = require('assert'); +const join = require('path').join; -var fs = require('fs'); -var spawn = require('child_process').spawn; +const fs = require('fs'); +const spawn = require('child_process').spawn; if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/agent.key'), cert: fs.readFileSync(common.fixturesDir + '/agent.crt'), requestCert: true @@ -34,11 +34,11 @@ const modulus = 'A6F44A9C25791431214F5C87AF9E040177A8BB89AC803F7E09BBC3A5519F' + 'EBDAF1191F4A4E26D71879C4C7867B62FCD508E8CE66E82D128A71E91580' + '9FCF44E8DE774067F1DE5D70B9C03687'; -var CRLF = '\r\n'; -var body = 'hello world\n'; -var cert; +const CRLF = '\r\n'; +const body = 'hello world\n'; +let cert; -var server = https.createServer(options, common.mustCall(function(req, res) { +const server = https.createServer(options, common.mustCall(function(req, res) { console.log('got request'); cert = req.connection.getPeerCertificate(); @@ -51,22 +51,22 @@ var server = https.createServer(options, common.mustCall(function(req, res) { })); server.listen(0, function() { - var args = ['s_client', - '-quiet', - '-connect', `127.0.0.1:${this.address().port}`, - '-cert', join(common.fixturesDir, 'foafssl.crt'), - '-key', join(common.fixturesDir, 'foafssl.key')]; + const args = ['s_client', + '-quiet', + '-connect', `127.0.0.1:${this.address().port}`, + '-cert', join(common.fixturesDir, 'foafssl.crt'), + '-key', join(common.fixturesDir, 'foafssl.key')]; // for the performance and stability issue in s_client on Windows if (common.isWindows) args.push('-no_rand_screen'); - var client = spawn(common.opensslCli, args); + const client = spawn(common.opensslCli, args); client.stdout.on('data', function(data) { - var message = data.toString(); - var contents = message.split(CRLF + CRLF).pop(); - assert.equal(body, contents); + const message = data.toString(); + const contents = message.split(CRLF + CRLF).pop(); + assert.strictEqual(body, contents); server.close(); }); diff --git a/test/parallel/test-https-host-headers.js b/test/parallel/test-https-host-headers.js index e4fd6dfe92ef15..ce18522fc5b5f2 100644 --- a/test/parallel/test-https-host-headers.js +++ b/test/parallel/test-https-host-headers.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); const fs = require('fs'); const options = { @@ -18,10 +18,10 @@ const httpsServer = https.createServer(options, reqHandler); function reqHandler(req, res) { console.log('Got request: ' + req.headers.host + ' ' + req.url); if (req.url === '/setHostFalse5') { - assert.equal(req.headers.host, undefined); + assert.strictEqual(req.headers.host, undefined); } else { - assert.equal(req.headers.host, `localhost:${this.address().port}`, - 'Wrong host header for req[' + req.url + ']: ' + + assert.strictEqual(req.headers.host, `localhost:${this.address().port}`, + 'Wrong host header for req[' + req.url + ']: ' + req.headers.host); } res.writeHead(200, {}); @@ -37,7 +37,7 @@ testHttps(); function testHttps() { - var counter = 0; + let counter = 0; function cb(res) { counter--; @@ -51,9 +51,7 @@ function testHttps() { httpsServer.listen(0, function(er) { console.log(`test https server listening on port ${this.address().port}`); - - if (er) throw er; - + assert.ifError(er); https.get({ method: 'GET', path: '/' + (counter++), diff --git a/test/parallel/test-https-localaddress-bind-error.js b/test/parallel/test-https-localaddress-bind-error.js index 91c3062a6e1896..662d6f080a0fff 100644 --- a/test/parallel/test-https-localaddress-bind-error.js +++ b/test/parallel/test-https-localaddress-bind-error.js @@ -1,21 +1,21 @@ 'use strict'; -var common = require('../common'); -var fs = require('fs'); +const common = require('../common'); +const fs = require('fs'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var invalidLocalAddress = '1.2.3.4'; +const invalidLocalAddress = '1.2.3.4'; -var server = https.createServer(options, function(req, res) { +const server = https.createServer(options, function(req, res) { console.log('Connect from: ' + req.connection.remoteAddress); req.on('end', function() { diff --git a/test/parallel/test-https-localaddress.js b/test/parallel/test-https-localaddress.js index e6aa0c93a2aaaa..1c796f5843c63c 100644 --- a/test/parallel/test-https-localaddress.js +++ b/test/parallel/test-https-localaddress.js @@ -7,21 +7,21 @@ if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); if (!common.hasMultiLocalhost()) { common.skip('platform-specific test.'); return; } -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = https.createServer(options, function(req, res) { +const server = https.createServer(options, function(req, res) { console.log('Connect from: ' + req.connection.remoteAddress); - assert.equal('127.0.0.2', req.connection.remoteAddress); + assert.strictEqual('127.0.0.2', req.connection.remoteAddress); req.on('end', function() { res.writeHead(200, { 'Content-Type': 'text/plain' }); @@ -31,7 +31,7 @@ var server = https.createServer(options, function(req, res) { }); server.listen(0, '127.0.0.1', function() { - var options = { + const options = { host: 'localhost', port: this.address().port, path: '/', @@ -40,7 +40,7 @@ server.listen(0, '127.0.0.1', function() { rejectUnauthorized: false }; - var req = https.request(options, function(res) { + const req = https.request(options, function(res) { res.on('end', function() { server.close(); process.exit(); diff --git a/test/parallel/test-https-pfx.js b/test/parallel/test-https-pfx.js index 02715de60da3c8..0e3a2ba3cd2663 100644 --- a/test/parallel/test-https-pfx.js +++ b/test/parallel/test-https-pfx.js @@ -1,17 +1,17 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const fs = require('fs'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var pfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx'); +const pfx = fs.readFileSync(common.fixturesDir + '/test_cert.pfx'); -var options = { +const options = { host: '127.0.0.1', port: undefined, path: '/', @@ -21,9 +21,10 @@ var options = { rejectUnauthorized: false }; -var server = https.createServer(options, function(req, res) { - assert.equal(req.socket.authorized, false); // not a client cert - assert.equal(req.socket.authorizationError, 'DEPTH_ZERO_SELF_SIGNED_CERT'); +const server = https.createServer(options, function(req, res) { + assert.strictEqual(req.socket.authorized, false); // not a client cert + assert.strictEqual(req.socket.authorizationError, + 'DEPTH_ZERO_SELF_SIGNED_CERT'); res.writeHead(200); res.end('OK'); }); @@ -32,7 +33,7 @@ server.listen(0, options.host, common.mustCall(function() { options.port = this.address().port; https.get(options, common.mustCall(function(res) { - var data = ''; + let data = ''; res.on('data', function(data_) { data += data_; }); res.on('end', common.mustCall(function() { diff --git a/test/parallel/test-https-req-split.js b/test/parallel/test-https-req-split.js index b49c17f28879be..4298abe5eff43d 100644 --- a/test/parallel/test-https-req-split.js +++ b/test/parallel/test-https-req-split.js @@ -7,12 +7,12 @@ if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var tls = require('tls'); -var fs = require('fs'); +const tls = require('tls'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; @@ -20,7 +20,7 @@ var options = { // Force splitting incoming data tls.SLAB_BUFFER_SIZE = 1; -var server = https.createServer(options); +const server = https.createServer(options); server.on('upgrade', common.mustCall(function(req, socket, upgrade) { socket.on('data', function(data) { throw new Error('Unexpected data: ' + data); @@ -29,7 +29,7 @@ server.on('upgrade', common.mustCall(function(req, socket, upgrade) { })); server.listen(0, function() { - var req = https.request({ + const req = https.request({ host: '127.0.0.1', port: this.address().port, agent: false, diff --git a/test/parallel/test-https-resume-after-renew.js b/test/parallel/test-https-resume-after-renew.js index 0efe467932915a..cc712b312485b2 100644 --- a/test/parallel/test-https-resume-after-renew.js +++ b/test/parallel/test-https-resume-after-renew.js @@ -5,28 +5,29 @@ if (!common.hasCrypto) { return; } -var fs = require('fs'); -var https = require('https'); -var crypto = require('crypto'); +const fs = require('fs'); +const https = require('https'); +const crypto = require('crypto'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'), ca: fs.readFileSync(common.fixturesDir + '/keys/ca1-cert.pem') }; -var server = https.createServer(options, function(req, res) { +const server = https.createServer(options, function(req, res) { res.end('hello'); }); -var aes = Buffer.alloc(16, 'S'); -var hmac = Buffer.alloc(16, 'H'); +const aes = Buffer.alloc(16, 'S'); +const hmac = Buffer.alloc(16, 'H'); server._sharedCreds.context.enableTicketKeyCallback(); server._sharedCreds.context.onticketkeycallback = function(name, iv, enc) { + let newName, newIV; if (enc) { - var newName = Buffer.alloc(16, 'A'); - var newIV = crypto.randomBytes(16); + newName = Buffer.alloc(16, 'A'); + newIV = crypto.randomBytes(16); } else { // Renew return [ 2, hmac, aes ]; @@ -36,7 +37,7 @@ server._sharedCreds.context.onticketkeycallback = function(name, iv, enc) { }; server.listen(0, function() { - var addr = this.address(); + const addr = this.address(); function doReq(callback) { https.request({ diff --git a/test/parallel/test-https-set-timeout-server.js b/test/parallel/test-https-set-timeout-server.js index fd00a521a03cb5..d6db87e61cc1d3 100644 --- a/test/parallel/test-https-set-timeout-server.js +++ b/test/parallel/test-https-set-timeout-server.js @@ -1,19 +1,19 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var tls = require('tls'); -var fs = require('fs'); +const tls = require('tls'); +const fs = require('fs'); -var tests = []; +const tests = []; -var serverOptions = { +const serverOptions = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; @@ -25,7 +25,7 @@ function test(fn) { } function run() { - var fn = tests.shift(); + const fn = tests.shift(); if (fn) { console.log('# %s', fn.name); fn(run); @@ -35,11 +35,11 @@ function run() { } test(function serverTimeout(cb) { - var server = https.createServer(serverOptions, function(req, res) { + const server = https.createServer(serverOptions, function(req, res) { // just do nothing, we should get a timeout event. }); server.listen(0, common.mustCall(function() { - var s = server.setTimeout(50, common.mustCall(function(socket) { + const s = server.setTimeout(50, common.mustCall(function(socket) { socket.destroy(); server.close(); cb(); @@ -62,9 +62,9 @@ test(function serverRequestTimeout(cb) { })); } - var server = https.createServer(serverOptions, common.mustCall(handler)); + const server = https.createServer(serverOptions, common.mustCall(handler)); server.listen(0, function() { - var req = https.request({ + const req = https.request({ port: this.address().port, method: 'POST', rejectUnauthorized: false @@ -85,7 +85,7 @@ test(function serverResponseTimeout(cb) { })); } - var server = https.createServer(serverOptions, common.mustCall(handler)); + const server = https.createServer(serverOptions, common.mustCall(handler)); server.listen(0, function() { https.get({ port: this.address().port, @@ -100,7 +100,7 @@ test(function serverRequestNotTimeoutAfterEnd(cb) { req.setTimeout(50, common.fail); res.on('timeout', common.mustCall(function(socket) {})); } - var server = https.createServer(serverOptions, common.mustCall(handler)); + const server = https.createServer(serverOptions, common.mustCall(handler)); server.on('timeout', function(socket) { socket.destroy(); server.close(); @@ -115,11 +115,11 @@ test(function serverRequestNotTimeoutAfterEnd(cb) { }); test(function serverResponseTimeoutWithPipeline(cb) { - var caughtTimeout = ''; + let caughtTimeout = ''; process.on('exit', function() { - assert.equal(caughtTimeout, '/2'); + assert.strictEqual(caughtTimeout, '/2'); }); - var server = https.createServer(serverOptions, function(req, res) { + const server = https.createServer(serverOptions, function(req, res) { res.setTimeout(50, function() { caughtTimeout += req.url; }); @@ -131,12 +131,12 @@ test(function serverResponseTimeoutWithPipeline(cb) { cb(); }); server.listen(0, function() { - var options = { + const options = { port: this.address().port, allowHalfOpen: true, rejectUnauthorized: false }; - var c = tls.connect(options, function() { + const c = tls.connect(options, function() { c.write('GET /1 HTTP/1.1\r\nHost: localhost\r\n\r\n'); c.write('GET /2 HTTP/1.1\r\nHost: localhost\r\n\r\n'); c.write('GET /3 HTTP/1.1\r\nHost: localhost\r\n\r\n'); @@ -145,19 +145,19 @@ test(function serverResponseTimeoutWithPipeline(cb) { }); test(function idleTimeout(cb) { - var server = https.createServer(serverOptions, - common.mustCall(function(req, res) { - req.on('timeout', common.fail); - res.on('timeout', common.fail); - res.end(); - })); + const server = https.createServer(serverOptions, + common.mustCall(function(req, res) { + req.on('timeout', common.fail); + res.on('timeout', common.fail); + res.end(); + })); server.setTimeout(50, common.mustCall(function(socket) { socket.destroy(); server.close(); cb(); })); server.listen(0, function() { - var options = { + const options = { port: this.address().port, allowHalfOpen: true, rejectUnauthorized: false diff --git a/test/parallel/test-https-simple.js b/test/parallel/test-https-simple.js index 0040b9dd054058..8616e6c710c463 100644 --- a/test/parallel/test-https-simple.js +++ b/test/parallel/test-https-simple.js @@ -52,7 +52,7 @@ server.listen(0, function() { }); res.on('end', function() { - assert.equal(responseBody, body); + assert.strictEqual(responseBody, body); testSucceeded(); }); }); @@ -82,11 +82,11 @@ server.listen(0, function() { checkCertReq.end(); checkCertReq.on('error', function(e) { - assert.equal(e.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'); + assert.strictEqual(e.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'); testSucceeded(); }); }); process.on('exit', function() { - assert.equal(successful, tests); + assert.strictEqual(successful, tests); }); diff --git a/test/parallel/test-https-socket-options.js b/test/parallel/test-https-socket-options.js index 70013d1770ff98..05137b35c437ff 100644 --- a/test/parallel/test-https-socket-options.js +++ b/test/parallel/test-https-socket-options.js @@ -1,26 +1,26 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); +const fs = require('fs'); -var http = require('http'); +const http = require('http'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var body = 'hello world\n'; +const body = 'hello world\n'; // Try first with http server -var server_http = http.createServer(function(req, res) { +const server_http = http.createServer(function(req, res) { console.log('got HTTP request'); res.writeHead(200, { 'content-type': 'text/plain' }); res.end(body); @@ -28,7 +28,7 @@ var server_http = http.createServer(function(req, res) { server_http.listen(0, function() { - var req = http.request({ + const req = http.request({ port: this.address().port, rejectUnauthorized: false }, function(res) { @@ -45,14 +45,14 @@ server_http.listen(0, function() { // Then try https server (requires functions to be // mirroed in tls.js's CryptoStream) -var server_https = https.createServer(options, function(req, res) { +const server_https = https.createServer(options, function(req, res) { console.log('got HTTPS request'); res.writeHead(200, { 'content-type': 'text/plain' }); res.end(body); }); server_https.listen(0, function() { - var req = https.request({ + const req = https.request({ port: this.address().port, rejectUnauthorized: false }, function(res) { diff --git a/test/parallel/test-https-strict.js b/test/parallel/test-https-strict.js index 871d9ef94e6960..9c650dc6ab3226 100644 --- a/test/parallel/test-https-strict.js +++ b/test/parallel/test-https-strict.js @@ -3,16 +3,16 @@ const common = require('../common'); // disable strict server certificate validation by the client process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; -var assert = require('assert'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); function file(fname) { return path.resolve(common.fixturesDir, 'keys', fname); @@ -23,60 +23,60 @@ function read(fname) { } // key1 is signed by ca1. -var key1 = read('agent1-key.pem'); -var cert1 = read('agent1-cert.pem'); +const key1 = read('agent1-key.pem'); +const cert1 = read('agent1-cert.pem'); // key2 has a self signed cert -var key2 = read('agent2-key.pem'); -var cert2 = read('agent2-cert.pem'); +const key2 = read('agent2-key.pem'); +const cert2 = read('agent2-cert.pem'); // key3 is signed by ca2. -var key3 = read('agent3-key.pem'); -var cert3 = read('agent3-cert.pem'); +const key3 = read('agent3-key.pem'); +const cert3 = read('agent3-cert.pem'); -var ca1 = read('ca1-cert.pem'); -var ca2 = read('ca2-cert.pem'); +const ca1 = read('ca1-cert.pem'); +const ca2 = read('ca2-cert.pem'); // different agents to use different CA lists. // this api is beyond bad. -var agent0 = new https.Agent(); -var agent1 = new https.Agent({ ca: [ca1] }); -var agent2 = new https.Agent({ ca: [ca2] }); -var agent3 = new https.Agent({ ca: [ca1, ca2] }); +const agent0 = new https.Agent(); +const agent1 = new https.Agent({ ca: [ca1] }); +const agent2 = new https.Agent({ ca: [ca2] }); +const agent3 = new https.Agent({ ca: [ca1, ca2] }); -var options1 = { +const options1 = { key: key1, cert: cert1 }; -var options2 = { +const options2 = { key: key2, cert: cert2 }; -var options3 = { +const options3 = { key: key3, cert: cert3 }; -var server1 = server(options1); -var server2 = server(options2); -var server3 = server(options3); +const server1 = server(options1); +const server2 = server(options2); +const server3 = server(options3); -var listenWait = 0; +let listenWait = 0; server1.listen(0, listening()); server2.listen(0, listening()); server3.listen(0, listening()); -var responseErrors = {}; -var expectResponseCount = 0; -var responseCount = 0; -var pending = 0; +const responseErrors = {}; +let expectResponseCount = 0; +let responseCount = 0; +let pending = 0; -function server(options, port) { - var s = https.createServer(options, handler); +function server(options) { + const s = https.createServer(options, handler); s.requests = []; s.expectCount = 0; return s; @@ -91,7 +91,7 @@ function handler(req, res) { function listening() { listenWait++; - return function() { + return () => { listenWait--; if (listenWait === 0) { allListening(); @@ -101,7 +101,7 @@ function listening() { function makeReq(path, port, error, host, ca) { pending++; - var options = { + const options = { port: port, path: path, ca: ca @@ -125,9 +125,9 @@ function makeReq(path, port, error, host, ca) { if (host) { options.headers = { host: host }; } - var req = https.get(options); + const req = https.get(options); expectResponseCount++; - var server = port === server1.address().port ? server1 : + const server = port === server1.address().port ? server1 : port === server2.address().port ? server2 : port === server3.address().port ? server3 : null; @@ -135,9 +135,9 @@ function makeReq(path, port, error, host, ca) { if (!server) throw new Error('invalid port: ' + port); server.expectCount++; - req.on('response', function(res) { + req.on('response', (res) => { responseCount++; - assert.equal(res.connection.authorizationError, error); + assert.strictEqual(res.connection.authorizationError, error); responseErrors[path] = res.connection.authorizationError; pending--; if (pending === 0) { @@ -195,10 +195,9 @@ function allListening() { } -process.on('exit', function() { - console.error(responseErrors); - assert.equal(server1.requests.length, server1.expectCount); - assert.equal(server2.requests.length, server2.expectCount); - assert.equal(server3.requests.length, server3.expectCount); - assert.equal(responseCount, expectResponseCount); +process.on('exit', () => { + assert.strictEqual(server1.requests.length, server1.expectCount); + assert.strictEqual(server2.requests.length, server2.expectCount); + assert.strictEqual(server3.requests.length, server3.expectCount); + assert.strictEqual(responseCount, expectResponseCount); }); diff --git a/test/parallel/test-https-timeout-server-2.js b/test/parallel/test-https-timeout-server-2.js index 07b7984f2d644b..8729af1ae8b4ba 100644 --- a/test/parallel/test-https-timeout-server-2.js +++ b/test/parallel/test-https-timeout-server-2.js @@ -1,26 +1,26 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var tls = require('tls'); -var fs = require('fs'); +const tls = require('tls'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = https.createServer(options, common.fail); +const server = https.createServer(options, common.fail); server.on('secureConnection', function(cleartext) { - var s = cleartext.setTimeout(50, function() { + const s = cleartext.setTimeout(50, function() { cleartext.destroy(); server.close(); }); diff --git a/test/parallel/test-https-truncate.js b/test/parallel/test-https-truncate.js index 4101a8c974e736..c96b385fc37fde 100644 --- a/test/parallel/test-https-truncate.js +++ b/test/parallel/test-https-truncate.js @@ -1,11 +1,12 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } + +const assert = require('assert'); const https = require('https'); const fs = require('fs'); @@ -14,7 +15,7 @@ const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); // number of bytes discovered empirically to trigger the bug -const data = Buffer.allocUnsafe(1024 * 32 + 1); +const data = Buffer.alloc(1024 * 32 + 1); httpsTest(); @@ -36,12 +37,11 @@ function httpsTest() { } -function test(res) { - res.on('end', function() { +const test = common.mustCall(function(res) { + res.on('end', common.mustCall(function() { assert.strictEqual(res._readableState.length, 0); assert.strictEqual(bytes, data.length); - console.log('ok'); - }); + })); // Pause and then resume on each chunk, to ensure that there will be // a lone byte hanging out at the very end. @@ -49,6 +49,6 @@ function test(res) { res.on('data', function(chunk) { bytes += chunk.length; this.pause(); - setTimeout(this.resume.bind(this)); + setTimeout(this.resume.bind(this), 1); }); -} +}); diff --git a/test/parallel/test-icu-punycode.js b/test/parallel/test-icu-punycode.js index d9b36e7df78882..62508bc9f78f49 100644 --- a/test/parallel/test-icu-punycode.js +++ b/test/parallel/test-icu-punycode.js @@ -1,6 +1,11 @@ 'use strict'; - const common = require('../common'); + +if (!common.hasIntl) { + common.skip('missing Intl'); + return; +} + const icu = getPunycode(); const assert = require('assert'); @@ -12,11 +17,6 @@ function getPunycode() { } } -if (!icu) { - common.skip('icu punycode tests because ICU is not present.'); - return; -} - // Credit for list: http://www.i18nguy.com/markup/idna-examples.html const tests = [ 'افغانستا.icom.museum', diff --git a/test/parallel/test-icu-stringwidth.js b/test/parallel/test-icu-stringwidth.js index 5b66f00c32840c..80e798b13af154 100644 --- a/test/parallel/test-icu-stringwidth.js +++ b/test/parallel/test-icu-stringwidth.js @@ -1,15 +1,15 @@ // Flags: --expose_internals 'use strict'; - const common = require('../common'); -const assert = require('assert'); -const readline = require('internal/readline'); -if (!process.binding('config').hasIntl) { - common.skip('missing intl... skipping test'); +if (!common.hasIntl) { + common.skip('missing Intl'); return; } +const assert = require('assert'); +const readline = require('internal/readline'); + // Test column width assert.strictEqual(readline.getStringWidth('a'), 1); assert.strictEqual(readline.getStringWidth('丁'), 2); diff --git a/test/parallel/test-icu-transcode.js b/test/parallel/test-icu-transcode.js index c099e754ca55d6..0766f8c6d460d8 100644 --- a/test/parallel/test-icu-transcode.js +++ b/test/parallel/test-icu-transcode.js @@ -1,9 +1,14 @@ 'use strict'; -require('../common'); +const common = require('../common'); + +if (!common.hasIntl) { + common.skip('missing Intl'); + return; +} + const buffer = require('buffer'); const assert = require('assert'); - const orig = Buffer.from('tést €', 'utf8'); // Test Transcoding @@ -18,7 +23,7 @@ const tests = { for (const test in tests) { const dest = buffer.transcode(orig, 'utf8', test); assert.strictEqual(dest.length, tests[test].length); - for (var n = 0; n < tests[test].length; n++) + for (let n = 0; n < tests[test].length; n++) assert.strictEqual(dest[n], tests[test][n]); } diff --git a/test/parallel/test-internal-modules-expose.js b/test/parallel/test-internal-modules-expose.js index ed3cecb6f29719..02ddfd87c363fc 100644 --- a/test/parallel/test-internal-modules-expose.js +++ b/test/parallel/test-internal-modules-expose.js @@ -2,6 +2,6 @@ // Flags: --expose_internals require('../common'); -var assert = require('assert'); +const assert = require('assert'); -assert.equal(typeof require('internal/freelist').FreeList, 'function'); +assert.strictEqual(typeof require('internal/freelist').FreeList, 'function'); diff --git a/test/parallel/test-internal-util-assertCrypto.js b/test/parallel/test-internal-util-assertCrypto.js new file mode 100644 index 00000000000000..f3003a2fee04e9 --- /dev/null +++ b/test/parallel/test-internal-util-assertCrypto.js @@ -0,0 +1,12 @@ +// Flags: --expose-internals +'use strict'; +require('../common'); +const assert = require('assert'); +const util = require('internal/util'); + +if (!process.versions.openssl) { + assert.throws(() => util.assertCrypto(), + /^Node.js is not compiled with openssl crypto support$/); +} else { + assert.doesNotThrow(() => util.assertCrypto()); +} diff --git a/test/parallel/test-internal-util-decorate-error-stack.js b/test/parallel/test-internal-util-decorate-error-stack.js new file mode 100644 index 00000000000000..caf31cb2650f17 --- /dev/null +++ b/test/parallel/test-internal-util-decorate-error-stack.js @@ -0,0 +1,75 @@ +// Flags: --expose_internals +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const internalUtil = require('internal/util'); +const binding = process.binding('util'); +const spawnSync = require('child_process').spawnSync; +const path = require('path'); + +const kArrowMessagePrivateSymbolIndex = binding['arrow_message_private_symbol']; +const kDecoratedPrivateSymbolIndex = binding['decorated_private_symbol']; + +assert.doesNotThrow(function() { + internalUtil.decorateErrorStack(); + internalUtil.decorateErrorStack(null); + internalUtil.decorateErrorStack(1); + internalUtil.decorateErrorStack(true); +}); + +// Verify that a stack property is not added to non-Errors +const obj = {}; +internalUtil.decorateErrorStack(obj); +assert.strictEqual(obj.stack, undefined); + +// Verify that the stack is decorated when possible +function checkStack(stack) { + const matches = stack.match(/var foo bar;/g); + assert.strictEqual(Array.isArray(matches), true); + assert.strictEqual(matches.length, 1); +} +let err; +const badSyntaxPath = + path.join(common.fixturesDir, 'syntax', 'bad_syntax') + .replace(/\\/g, '\\\\'); + +try { + require(badSyntaxPath); +} catch (e) { + err = e; +} + +assert(typeof err, 'object'); +checkStack(err.stack); + +// Verify that the stack is only decorated once +internalUtil.decorateErrorStack(err); +internalUtil.decorateErrorStack(err); +checkStack(err.stack); + +// Verify that the stack is only decorated once for uncaught exceptions +const args = [ + '-e', + `require('${badSyntaxPath}')` +]; +const result = spawnSync(process.argv[0], args, { encoding: 'utf8' }); +checkStack(result.stderr); + +// Verify that the stack is unchanged when there is no arrow message +err = new Error('foo'); +let originalStack = err.stack; +internalUtil.decorateErrorStack(err); +assert.strictEqual(originalStack, err.stack); + +// Verify that the arrow message is added to the start of the stack when it +// exists +const arrowMessage = 'arrow_message'; +err = new Error('foo'); +originalStack = err.stack; + +internalUtil.setHiddenValue(err, kArrowMessagePrivateSymbolIndex, arrowMessage); +internalUtil.decorateErrorStack(err); + +assert.strictEqual(err.stack, `${arrowMessage}${originalStack}`); +assert.strictEqual(internalUtil + .getHiddenValue(err, kDecoratedPrivateSymbolIndex), true); diff --git a/test/parallel/test-intl-v8BreakIterator.js b/test/parallel/test-intl-v8BreakIterator.js index 4af3452b576f84..70f0f782bbc7e7 100644 --- a/test/parallel/test-intl-v8BreakIterator.js +++ b/test/parallel/test-intl-v8BreakIterator.js @@ -1,11 +1,11 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); if (!common.hasIntl || Intl.v8BreakIterator === undefined) { - return common.skip('no Intl'); + return common.skip('missing Intl'); } +const assert = require('assert'); const warning = 'Intl.v8BreakIterator is deprecated and will be removed soon.'; common.expectWarning('DeprecationWarning', warning); diff --git a/test/parallel/test-intl.js b/test/parallel/test-intl.js index 1058650830d084..43707e08c03710 100644 --- a/test/parallel/test-intl.js +++ b/test/parallel/test-intl.js @@ -16,6 +16,16 @@ function haveLocale(loc) { return locs.indexOf(loc) !== -1; } +// Always run these. They should always pass, even if the locale +// param is ignored. +assert.strictEqual('Ç'.toLocaleLowerCase('el'), 'ç'); +assert.strictEqual('Ç'.toLocaleLowerCase('tr'), 'ç'); +assert.strictEqual('Ç'.toLowerCase(), 'ç'); + +assert.strictEqual('ç'.toLocaleUpperCase('el'), 'Ç'); +assert.strictEqual('ç'.toLocaleUpperCase('tr'), 'Ç'); +assert.strictEqual('ç'.toUpperCase(), 'Ç'); + if (!common.hasIntl) { const erMsg = '"Intl" object is NOT present but v8_enable_i18n_support is ' + diff --git a/test/parallel/test-listen-fd-cluster.js b/test/parallel/test-listen-fd-cluster.js index 606109030b51d0..98810a39335acc 100644 --- a/test/parallel/test-listen-fd-cluster.js +++ b/test/parallel/test-listen-fd-cluster.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); -var cluster = require('cluster'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); +const cluster = require('cluster'); console.error('Cluster listen fd test', process.argv[2] || 'runner'); @@ -22,7 +22,7 @@ switch (process.argv[2]) { case 'worker': return worker(); } -var ok; +let ok; process.on('exit', function() { assert.ok(ok); @@ -41,7 +41,7 @@ test(function(parent, port) { port: port, path: '/', }).on('response', function(res) { - var s = ''; + let s = ''; res.on('data', function(c) { s += c.toString(); }); @@ -50,8 +50,8 @@ test(function(parent, port) { // it's really annoying when tests leave orphans! parent.kill(); parent.on('exit', function() { - assert.equal(s, 'hello from worker\n'); - assert.equal(res.statusCode, 200); + assert.strictEqual(s, 'hello from worker\n'); + assert.strictEqual(res.statusCode, 200); console.log('ok'); ok = true; }); @@ -61,15 +61,15 @@ test(function(parent, port) { function test(cb) { console.error('about to listen in parent'); - var server = net.createServer(function(conn) { + const server = net.createServer(function(conn) { console.error('connection on parent'); conn.end('hello from parent\n'); }).listen(0, function() { const port = this.address().port; console.error('server listening on %d', port); - var spawn = require('child_process').spawn; - var master = spawn(process.execPath, [__filename, 'master'], { + const spawn = require('child_process').spawn; + const master = spawn(process.execPath, [__filename, 'master'], { stdio: [ 0, 'pipe', 2, server._handle, 'ipc' ], detached: true }); @@ -100,7 +100,7 @@ function master() { cluster.setupMaster({ args: [ 'worker' ] }); - var worker = cluster.fork(); + const worker = cluster.fork(); worker.on('message', function(msg) { if (msg === 'worker ready') { process.send('started worker'); diff --git a/test/parallel/test-listen-fd-detached-inherit.js b/test/parallel/test-listen-fd-detached-inherit.js index 5dfe346a49f441..36e4df28897383 100644 --- a/test/parallel/test-listen-fd-detached-inherit.js +++ b/test/parallel/test-listen-fd-detached-inherit.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); +const spawn = require('child_process').spawn; if (common.isWindows) { common.skip('This test is disabled on windows.'); @@ -23,24 +23,24 @@ switch (process.argv[2]) { // concurrency in HTTP servers! Use the cluster module, or if you want // a more low-level approach, use child process IPC manually. function test() { - var parent = spawn(process.execPath, [__filename, 'parent'], { + const parent = spawn(process.execPath, [__filename, 'parent'], { stdio: [ 0, 'pipe', 2 ] }); - var json = ''; + let json = ''; parent.stdout.on('data', function(c) { json += c.toString(); if (json.indexOf('\n') !== -1) next(); }); function next() { console.error('output from parent = %s', json); - var child = JSON.parse(json); + const child = JSON.parse(json); // now make sure that we can request to the child, then kill it. http.get({ server: 'localhost', port: child.port, path: '/', }).on('response', function(res) { - var s = ''; + let s = ''; res.on('data', function(c) { s += c.toString(); }); @@ -52,8 +52,8 @@ function test() { parent.kill(); } catch (e) {} - assert.equal(s, 'hello from child\n'); - assert.equal(res.statusCode, 200); + assert.strictEqual(s, 'hello from child\n'); + assert.strictEqual(res.statusCode, 200); }); }); } @@ -62,13 +62,13 @@ function test() { // Listen on port, and then pass the handle to the detached child. // Then output the child's pid, and immediately exit. function parent() { - var server = net.createServer(function(conn) { + const server = net.createServer(function(conn) { conn.end('HTTP/1.1 403 Forbidden\r\n\r\nI got problems.\r\n'); throw new Error('Should not see connections on parent'); }).listen(0, function() { console.error('server listening on %d', this.address().port); - var child = spawn(process.execPath, [__filename, 'child'], { + const child = spawn(process.execPath, [__filename, 'child'], { stdio: [ 0, 1, 2, server._handle ], detached: true }); diff --git a/test/parallel/test-listen-fd-detached.js b/test/parallel/test-listen-fd-detached.js index 0629f7ea7970d7..ec9d039e96e3f2 100644 --- a/test/parallel/test-listen-fd-detached.js +++ b/test/parallel/test-listen-fd-detached.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); +const spawn = require('child_process').spawn; if (common.isWindows) { common.skip('This test is disabled on windows.'); @@ -23,24 +23,24 @@ switch (process.argv[2]) { // concurrency in HTTP servers! Use the cluster module, or if you want // a more low-level approach, use child process IPC manually. function test() { - var parent = spawn(process.execPath, [__filename, 'parent'], { + const parent = spawn(process.execPath, [__filename, 'parent'], { stdio: [ 0, 'pipe', 2 ] }); - var json = ''; + let json = ''; parent.stdout.on('data', function(c) { json += c.toString(); if (json.indexOf('\n') !== -1) next(); }); function next() { console.error('output from parent = %s', json); - var child = JSON.parse(json); + const child = JSON.parse(json); // now make sure that we can request to the child, then kill it. http.get({ server: 'localhost', port: child.port, path: '/', }).on('response', function(res) { - var s = ''; + let s = ''; res.on('data', function(c) { s += c.toString(); }); @@ -52,22 +52,22 @@ function test() { parent.kill(); } catch (e) {} - assert.equal(s, 'hello from child\n'); - assert.equal(res.statusCode, 200); + assert.strictEqual(s, 'hello from child\n'); + assert.strictEqual(res.statusCode, 200); }); }); } } function parent() { - var server = net.createServer(function(conn) { + const server = net.createServer(function(conn) { console.error('connection on parent'); conn.end('hello from parent\n'); }).listen(0, function() { console.error('server listening on %d', this.address().port); - var spawn = require('child_process').spawn; - var child = spawn(process.execPath, [__filename, 'child'], { + const spawn = require('child_process').spawn; + const child = spawn(process.execPath, [__filename, 'child'], { stdio: [ 'ignore', 'ignore', 'ignore', server._handle ], detached: true }); diff --git a/test/parallel/test-listen-fd-server.js b/test/parallel/test-listen-fd-server.js index eda75e5c723261..5a1ffbb989cf8d 100644 --- a/test/parallel/test-listen-fd-server.js +++ b/test/parallel/test-listen-fd-server.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); +const net = require('net'); if (common.isWindows) { common.skip('This test is disabled on windows.'); @@ -13,7 +13,7 @@ switch (process.argv[2]) { case 'child': return child(); } -var ok; +let ok; process.on('exit', function() { assert.ok(ok); @@ -31,15 +31,15 @@ test(function(child, port) { port: port, path: '/', }).on('response', function(res) { - var s = ''; + let s = ''; res.on('data', function(c) { s += c.toString(); }); res.on('end', function() { child.kill(); child.on('exit', function() { - assert.equal(s, 'hello from child\n'); - assert.equal(res.statusCode, 200); + assert.strictEqual(s, 'hello from child\n'); + assert.strictEqual(res.statusCode, 200); console.log('ok'); ok = true; }); @@ -67,15 +67,15 @@ function child() { } function test(cb) { - var server = net.createServer(function(conn) { + const server = net.createServer(function(conn) { console.error('connection on parent'); conn.end('hello from parent\n'); }).listen(0, function() { const port = this.address().port; console.error('server listening on %d', port); - var spawn = require('child_process').spawn; - var child = spawn(process.execPath, [__filename, 'child'], { + const spawn = require('child_process').spawn; + const child = spawn(process.execPath, [__filename, 'child'], { stdio: [ 0, 1, 2, server._handle, 'ipc' ] }); diff --git a/test/parallel/test-memory-usage-emfile.js b/test/parallel/test-memory-usage-emfile.js index 92c103669a9a85..c5345079a7f47b 100644 --- a/test/parallel/test-memory-usage-emfile.js +++ b/test/parallel/test-memory-usage-emfile.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var fs = require('fs'); +const fs = require('fs'); -var files = []; +const files = []; while (files.length < 256) files.push(fs.openSync(__filename, 'r')); -var r = process.memoryUsage(); -assert.equal(true, r['rss'] > 0); +const r = process.memoryUsage(); +assert.strictEqual(true, r['rss'] > 0); diff --git a/test/parallel/test-memory-usage.js b/test/parallel/test-memory-usage.js index c5905c537ac613..cba3f9a5172a07 100644 --- a/test/parallel/test-memory-usage.js +++ b/test/parallel/test-memory-usage.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var r = process.memoryUsage(); +const r = process.memoryUsage(); assert.ok(r.rss > 0); assert.ok(r.heapTotal > 0); assert.ok(r.heapUsed > 0); diff --git a/test/parallel/test-microtask-queue-integration-domain.js b/test/parallel/test-microtask-queue-integration-domain.js index 1e07fa5d415ba3..df90b6d3a372da 100644 --- a/test/parallel/test-microtask-queue-integration-domain.js +++ b/test/parallel/test-microtask-queue-integration-domain.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // Requiring the domain module here changes the function that is used by node to // call process.nextTick's callbacks to a variant that specifically handles @@ -9,21 +9,21 @@ var assert = require('assert'); // removed. require('domain'); -var implementations = [ +const implementations = [ function(fn) { Promise.resolve().then(fn); } ]; -var expected = 0; -var done = 0; +let expected = 0; +let done = 0; process.on('exit', function() { - assert.equal(done, expected); + assert.strictEqual(done, expected); }); function test(scheduleMicrotask) { - var nextTickCalled = false; + let nextTickCalled = false; expected++; scheduleMicrotask(function() { diff --git a/test/parallel/test-microtask-queue-integration.js b/test/parallel/test-microtask-queue-integration.js index 2cc608d96aec3d..22704ab4a51d49 100644 --- a/test/parallel/test-microtask-queue-integration.js +++ b/test/parallel/test-microtask-queue-integration.js @@ -1,22 +1,22 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var implementations = [ +const implementations = [ function(fn) { Promise.resolve().then(fn); } ]; -var expected = 0; -var done = 0; +let expected = 0; +let done = 0; process.on('exit', function() { - assert.equal(done, expected); + assert.strictEqual(done, expected); }); function test(scheduleMicrotask) { - var nextTickCalled = false; + let nextTickCalled = false; expected++; scheduleMicrotask(function() { diff --git a/test/parallel/test-microtask-queue-run-domain.js b/test/parallel/test-microtask-queue-run-domain.js index fb5139f71d65aa..8ce2f6cd992648 100644 --- a/test/parallel/test-microtask-queue-run-domain.js +++ b/test/parallel/test-microtask-queue-run-domain.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // Requiring the domain module here changes the function that is used by node to // call process.nextTick's callbacks to a variant that specifically handles @@ -13,10 +13,10 @@ function enqueueMicrotask(fn) { Promise.resolve().then(fn); } -var done = 0; +let done = 0; process.on('exit', function() { - assert.equal(done, 2); + assert.strictEqual(done, 2); }); // no nextTick, microtask @@ -29,7 +29,7 @@ setTimeout(function() { // no nextTick, microtask with nextTick setTimeout(function() { - var called = false; + let called = false; enqueueMicrotask(function() { process.nextTick(function() { diff --git a/test/parallel/test-microtask-queue-run-immediate-domain.js b/test/parallel/test-microtask-queue-run-immediate-domain.js index 4a7729ab98a062..8c4d4d40d46d6b 100644 --- a/test/parallel/test-microtask-queue-run-immediate-domain.js +++ b/test/parallel/test-microtask-queue-run-immediate-domain.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // Requiring the domain module here changes the function that is used by node to // call process.nextTick's callbacks to a variant that specifically handles @@ -13,10 +13,10 @@ function enqueueMicrotask(fn) { Promise.resolve().then(fn); } -var done = 0; +let done = 0; process.on('exit', function() { - assert.equal(done, 2); + assert.strictEqual(done, 2); }); // no nextTick, microtask @@ -29,7 +29,7 @@ setImmediate(function() { // no nextTick, microtask with nextTick setImmediate(function() { - var called = false; + let called = false; enqueueMicrotask(function() { process.nextTick(function() { diff --git a/test/parallel/test-microtask-queue-run-immediate.js b/test/parallel/test-microtask-queue-run-immediate.js index 479062ad4710f4..9fee54b2d741cf 100644 --- a/test/parallel/test-microtask-queue-run-immediate.js +++ b/test/parallel/test-microtask-queue-run-immediate.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); function enqueueMicrotask(fn) { Promise.resolve().then(fn); } -var done = 0; +let done = 0; process.on('exit', function() { - assert.equal(done, 2); + assert.strictEqual(done, 2); }); // no nextTick, microtask @@ -22,7 +22,7 @@ setImmediate(function() { // no nextTick, microtask with nextTick setImmediate(function() { - var called = false; + let called = false; enqueueMicrotask(function() { process.nextTick(function() { diff --git a/test/parallel/test-microtask-queue-run.js b/test/parallel/test-microtask-queue-run.js index ce743d93003249..1a8f8e2ba32bc0 100644 --- a/test/parallel/test-microtask-queue-run.js +++ b/test/parallel/test-microtask-queue-run.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); function enqueueMicrotask(fn) { Promise.resolve().then(fn); } -var done = 0; +let done = 0; process.on('exit', function() { - assert.equal(done, 2); + assert.strictEqual(done, 2); }); // no nextTick, microtask @@ -22,7 +22,7 @@ setTimeout(function() { // no nextTick, microtask with nextTick setTimeout(function() { - var called = false; + let called = false; enqueueMicrotask(function() { process.nextTick(function() { diff --git a/test/parallel/test-module-globalpaths-nodepath.js b/test/parallel/test-module-globalpaths-nodepath.js index 3369df0676015b..ec90f1a3e2c868 100644 --- a/test/parallel/test-module-globalpaths-nodepath.js +++ b/test/parallel/test-module-globalpaths-nodepath.js @@ -1,11 +1,10 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); +const mod = require('module'); -var module = require('module'); - -var partA, partB; -var partC = ''; +let partA, partB; +const partC = ''; if (common.isWindows) { partA = 'C:\\Users\\Rocko Artischocko\\AppData\\Roaming\\npm'; @@ -17,10 +16,10 @@ if (common.isWindows) { process.env['NODE_PATH'] = partA + ':' + partB + ':' + partC; } -module._initPaths(); +mod._initPaths(); -assert.ok(module.globalPaths.indexOf(partA) !== -1); -assert.ok(module.globalPaths.indexOf(partB) !== -1); -assert.ok(module.globalPaths.indexOf(partC) === -1); +assert.ok(mod.globalPaths.indexOf(partA) !== -1); +assert.ok(mod.globalPaths.indexOf(partB) !== -1); +assert.ok(mod.globalPaths.indexOf(partC) === -1); -assert.ok(Array.isArray(module.globalPaths)); +assert.ok(Array.isArray(mod.globalPaths)); diff --git a/test/parallel/test-module-loading-error.js b/test/parallel/test-module-loading-error.js index 145530985401e4..d78f61de60fa14 100644 --- a/test/parallel/test-module-loading-error.js +++ b/test/parallel/test-module-loading-error.js @@ -1,16 +1,16 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); console.error('load test-module-loading-error.js'); -var error_desc = { +const error_desc = { win32: ['%1 is not a valid Win32 application'], linux: ['file too short', 'Exec format error'], sunos: ['unknown file type', 'not an ELF file'], darwin: ['file too short'] }; -var dlerror_msg = error_desc[process.platform]; +const dlerror_msg = error_desc[process.platform]; if (!dlerror_msg) { common.skip('platform not supported.'); @@ -28,11 +28,11 @@ try { try { require(); } catch (e) { - assert.notEqual(e.toString().indexOf('missing path'), -1); + assert.ok(e.toString().includes('missing path')); } try { require({}); } catch (e) { - assert.notEqual(e.toString().indexOf('path must be a string'), -1); + assert.ok(e.toString().includes('path must be a string')); } diff --git a/test/parallel/test-module-version.js b/test/parallel/test-module-version.js index 7f96e8bb60f0ac..04f011bbfacd8e 100644 --- a/test/parallel/test-module-version.js +++ b/test/parallel/test-module-version.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // check for existence assert(process.config.variables.hasOwnProperty('node_module_version')); diff --git a/test/parallel/test-net-after-close.js b/test/parallel/test-net-after-close.js index a73663e7da86db..d46f096116d02e 100644 --- a/test/parallel/test-net-after-close.js +++ b/test/parallel/test-net-after-close.js @@ -1,15 +1,15 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var server = net.createServer(function(s) { +const server = net.createServer(function(s) { console.error('SERVER: got connection'); s.end(); }); server.listen(0, common.mustCall(function() { - var c = net.createConnection(this.address().port); + const c = net.createConnection(this.address().port); c.on('close', common.mustCall(function() { console.error('connection closed'); assert.strictEqual(c._handle, null); diff --git a/test/parallel/test-net-better-error-messages-path.js b/test/parallel/test-net-better-error-messages-path.js index 9222a1cc758aaa..7cdc14b9bd4333 100644 --- a/test/parallel/test-net-better-error-messages-path.js +++ b/test/parallel/test-net-better-error-messages-path.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); -var net = require('net'); -var assert = require('assert'); -var fp = '/tmp/fadagagsdfgsdf'; -var c = net.connect(fp); +const common = require('../common'); +const net = require('net'); +const assert = require('assert'); +const fp = '/tmp/fadagagsdfgsdf'; +const c = net.connect(fp); c.on('connect', common.fail); c.on('error', common.mustCall(function(e) { - assert.equal(e.code, 'ENOENT'); - assert.equal(e.message, 'connect ENOENT ' + fp); + assert.strictEqual(e.code, 'ENOENT'); + assert.strictEqual(e.message, 'connect ENOENT ' + fp); })); diff --git a/test/parallel/test-net-binary.js b/test/parallel/test-net-binary.js index 47e0be8d04dcf6..0c5cac1c37290b 100644 --- a/test/parallel/test-net-binary.js +++ b/test/parallel/test-net-binary.js @@ -3,8 +3,8 @@ require('../common'); const assert = require('assert'); const net = require('net'); -var binaryString = ''; -for (var i = 255; i >= 0; i--) { +let binaryString = ''; +for (let i = 255; i >= 0; i--) { const s = `'\\${i.toString(8)}'`; const S = eval(s); assert.strictEqual(S.charCodeAt(0), i); @@ -13,7 +13,7 @@ for (var i = 255; i >= 0; i--) { } // safe constructor -var echoServer = net.Server(function(connection) { +const echoServer = net.Server(function(connection) { connection.setEncoding('latin1'); connection.on('data', function(chunk) { connection.write(chunk, 'latin1'); @@ -24,10 +24,10 @@ var echoServer = net.Server(function(connection) { }); echoServer.listen(0); -var recv = ''; +let recv = ''; echoServer.on('listening', function() { - var j = 0; + let j = 0; const c = net.createConnection({ port: this.address().port }); @@ -55,7 +55,7 @@ echoServer.on('listening', function() { }); process.on('exit', function() { - assert.equal(2 * 256, recv.length); + assert.strictEqual(2 * 256, recv.length); const a = recv.split(''); diff --git a/test/parallel/test-net-bind-twice.js b/test/parallel/test-net-bind-twice.js index 9b9fc7c5db37dd..c10b4019e4b95f 100644 --- a/test/parallel/test-net-bind-twice.js +++ b/test/parallel/test-net-bind-twice.js @@ -1,15 +1,15 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var server1 = net.createServer(common.fail); +const server1 = net.createServer(common.fail); server1.listen(0, '127.0.0.1', common.mustCall(function() { - var server2 = net.createServer(common.fail); + const server2 = net.createServer(common.fail); server2.listen(this.address().port, '127.0.0.1', common.fail); server2.on('error', common.mustCall(function(e) { - assert.equal(e.code, 'EADDRINUSE'); + assert.strictEqual(e.code, 'EADDRINUSE'); server1.close(); })); })); diff --git a/test/parallel/test-net-buffersize.js b/test/parallel/test-net-buffersize.js index 872d8de7b42f3b..e8ba17a76e6c69 100644 --- a/test/parallel/test-net-buffersize.js +++ b/test/parallel/test-net-buffersize.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var iter = 10; +const iter = 10; -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { socket.on('readable', function() { socket.read(); }); @@ -16,13 +16,13 @@ var server = net.createServer(function(socket) { }); server.listen(0, function() { - var client = net.connect(this.address().port); + const client = net.connect(this.address().port); client.on('finish', function() { assert.strictEqual(client.bufferSize, 0); }); - for (var i = 1; i < iter; i++) { + for (let i = 1; i < iter; i++) { client.write('a'); assert.strictEqual(client.bufferSize, i); } diff --git a/test/parallel/test-net-bytes-read.js b/test/parallel/test-net-bytes-read.js index 52fb577b9e7830..aed14fe279eb5b 100644 --- a/test/parallel/test-net-bytes-read.js +++ b/test/parallel/test-net-bytes-read.js @@ -23,14 +23,14 @@ const server = net.createServer((socket) => { }); socket.on('end', common.mustCall(() => { - assert.equal(socket.bytesRead, prev); - assert.equal(big.length, prev); + assert.strictEqual(socket.bytesRead, prev); + assert.strictEqual(big.length, prev); })); socket.on('close', common.mustCall(() => { assert(!socket._handle); - assert.equal(socket.bytesRead, prev); - assert.equal(big.length, prev); + assert.strictEqual(socket.bytesRead, prev); + assert.strictEqual(big.length, prev); })); }); socket.end(); diff --git a/test/parallel/test-net-bytes-stats.js b/test/parallel/test-net-bytes-stats.js index a8643b03b97250..33e089da50880a 100644 --- a/test/parallel/test-net-bytes-stats.js +++ b/test/parallel/test-net-bytes-stats.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var bytesRead = 0; -var bytesWritten = 0; -var count = 0; +let bytesRead = 0; +let bytesWritten = 0; +let count = 0; -var tcp = net.Server(function(s) { +const tcp = net.Server(function(s) { console.log('tcp server connection'); // trigger old mode. @@ -21,7 +21,7 @@ var tcp = net.Server(function(s) { tcp.listen(0, function doTest() { console.error('listening'); - var socket = net.createConnection(this.address().port); + const socket = net.createConnection(this.address().port); socket.on('connect', function() { count++; @@ -52,6 +52,6 @@ tcp.listen(0, function doTest() { }); process.on('exit', function() { - assert.equal(bytesRead, 12); - assert.equal(bytesWritten, 12); + assert.strictEqual(bytesRead, 12); + assert.strictEqual(bytesWritten, 12); }); diff --git a/test/parallel/test-net-can-reset-timeout.js b/test/parallel/test-net-can-reset-timeout.js index 7dbd5cad2ae6bb..faa460e847aa08 100644 --- a/test/parallel/test-net-can-reset-timeout.js +++ b/test/parallel/test-net-can-reset-timeout.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var net = require('net'); +const net = require('net'); -var server = net.createServer(common.mustCall(function(stream) { +const server = net.createServer(common.mustCall(function(stream) { stream.setTimeout(100); stream.resume(); @@ -20,7 +20,7 @@ var server = net.createServer(common.mustCall(function(stream) { })); server.listen(0, function() { - var c = net.createConnection(this.address().port); + const c = net.createConnection(this.address().port); c.on('data', function() { c.end(); diff --git a/test/parallel/test-net-connect-buffer.js b/test/parallel/test-net-connect-buffer.js index 3ef5b0ea9f075d..1e296675879130 100644 --- a/test/parallel/test-net-connect-buffer.js +++ b/test/parallel/test-net-connect-buffer.js @@ -1,24 +1,24 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var dataWritten = false; -var connectHappened = false; +let dataWritten = false; +let connectHappened = false; -var tcp = net.Server(function(s) { +const tcp = net.Server(function(s) { tcp.close(); console.log('tcp server connection'); - var buf = ''; + let buf = ''; s.on('data', function(d) { buf += d; }); s.on('end', function() { console.error('SERVER: end', buf.toString()); - assert.equal(buf, "L'État, c'est moi"); + assert.strictEqual(buf, "L'État, c'est moi"); console.log('tcp socket disconnect'); s.end(); }); @@ -30,7 +30,7 @@ var tcp = net.Server(function(s) { }); tcp.listen(0, function() { - var socket = net.Stream({ highWaterMark: 0 }); + const socket = net.Stream({ highWaterMark: 0 }); console.log('Connecting to socket '); @@ -41,7 +41,7 @@ tcp.listen(0, function() { console.log('connecting = ' + socket.connecting); - assert.equal('opening', socket.readyState); + assert.strictEqual('opening', socket.readyState); // Make sure that anything besides a buffer or a string throws. [null, @@ -65,29 +65,29 @@ tcp.listen(0, function() { // Write a string that contains a multi-byte character sequence to test that // `bytesWritten` is incremented with the # of bytes, not # of characters. - var a = "L'État, c'est "; - var b = 'moi'; + const a = "L'État, c'est "; + const b = 'moi'; // We're still connecting at this point so the datagram is first pushed onto // the connect queue. Make sure that it's not added to `bytesWritten` again // when the actual write happens. - var r = socket.write(a, function(er) { + const r = socket.write(a, function(er) { console.error('write cb'); dataWritten = true; assert.ok(connectHappened); console.error('socket.bytesWritten', socket.bytesWritten); - //assert.equal(socket.bytesWritten, Buffer.from(a + b).length); + //assert.strictEqual(socket.bytesWritten, Buffer.from(a + b).length); console.error('data written'); }); console.error('socket.bytesWritten', socket.bytesWritten); console.error('write returned', r); - assert.equal(socket.bytesWritten, Buffer.from(a).length); + assert.strictEqual(socket.bytesWritten, Buffer.from(a).length); - assert.equal(false, r); + assert.strictEqual(false, r); socket.end(b); - assert.equal('opening', socket.readyState); + assert.strictEqual('opening', socket.readyState); }); process.on('exit', function() { diff --git a/test/parallel/test-net-connect-local-error.js b/test/parallel/test-net-connect-local-error.js index 197b283bdf3621..23bfacde336f36 100644 --- a/test/parallel/test-net-connect-local-error.js +++ b/test/parallel/test-net-connect-local-error.js @@ -3,13 +3,13 @@ const common = require('../common'); const assert = require('assert'); const net = require('net'); -var client = net.connect({ +const client = net.connect({ port: common.PORT + 1, localPort: common.PORT, localAddress: common.localhostIPv4 }); client.on('error', common.mustCall(function onError(err) { - assert.equal(err.localPort, common.PORT); - assert.equal(err.localAddress, common.localhostIPv4); + assert.strictEqual(err.localPort, common.PORT); + assert.strictEqual(err.localAddress, common.localhostIPv4); })); diff --git a/test/parallel/test-net-connect-options-ipv6.js b/test/parallel/test-net-connect-options-ipv6.js index 7f638d66f59508..e9d8a78cbbefef 100644 --- a/test/parallel/test-net-connect-options-ipv6.js +++ b/test/parallel/test-net-connect-options-ipv6.js @@ -9,9 +9,9 @@ if (!common.hasIPv6) { } const hosts = common.localIPv6Hosts; -var hostIdx = 0; -var host = hosts[hostIdx]; -var localhostTries = 10; +let hostIdx = 0; +let host = hosts[hostIdx]; +let localhostTries = 10; const server = net.createServer({allowHalfOpen: true}, function(socket) { socket.resume(); diff --git a/test/parallel/test-net-connect-options.js b/test/parallel/test-net-connect-options.js index 3446790d7b3c4a..e794c40859856a 100644 --- a/test/parallel/test-net-connect-options.js +++ b/test/parallel/test-net-connect-options.js @@ -1,9 +1,9 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var server = net.createServer({ +const server = net.createServer({ allowHalfOpen: true }, common.mustCall(function(socket) { socket.resume(); @@ -12,7 +12,7 @@ var server = net.createServer({ })); server.listen(0, function() { - var client = net.connect({ + const client = net.connect({ host: '127.0.0.1', port: this.address().port, allowHalfOpen: true diff --git a/test/parallel/test-net-connect-paused-connection.js b/test/parallel/test-net-connect-paused-connection.js index 8c0e1c93cfb208..a0a90eefc1db3e 100644 --- a/test/parallel/test-net-connect-paused-connection.js +++ b/test/parallel/test-net-connect-paused-connection.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); -var net = require('net'); +const net = require('net'); net.createServer(function(conn) { conn.unref(); diff --git a/test/parallel/test-net-create-connection.js b/test/parallel/test-net-create-connection.js index a21f92a3a5674c..dc5981ecd20221 100644 --- a/test/parallel/test-net-create-connection.js +++ b/test/parallel/test-net-create-connection.js @@ -5,8 +5,8 @@ const dns = require('dns'); const net = require('net'); const expectedConnections = 7; -var clientConnected = 0; -var serverConnected = 0; +let clientConnected = 0; +let serverConnected = 0; const server = net.createServer(function(socket) { socket.end(); @@ -102,5 +102,5 @@ server.on('close', function() { }); process.on('exit', function() { - assert.equal(clientConnected, expectedConnections); + assert.strictEqual(clientConnected, expectedConnections); }); diff --git a/test/parallel/test-net-dns-custom-lookup.js b/test/parallel/test-net-dns-custom-lookup.js index 07eb71c5ed5811..c7a01f5fa6faec 100644 --- a/test/parallel/test-net-dns-custom-lookup.js +++ b/test/parallel/test-net-dns-custom-lookup.js @@ -1,16 +1,16 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); function check(addressType, cb) { - var server = net.createServer(function(client) { + const server = net.createServer(function(client) { client.end(); server.close(); cb && cb(); }); - var address = addressType === 4 ? common.localhostIPv4 : '::1'; + const address = addressType === 4 ? common.localhostIPv4 : '::1'; server.listen(0, address, common.mustCall(function() { net.connect({ port: this.address().port, diff --git a/test/parallel/test-net-dns-error.js b/test/parallel/test-net-dns-error.js index b36d84d3e9e214..5ca02313686589 100644 --- a/test/parallel/test-net-dns-error.js +++ b/test/parallel/test-net-dns-error.js @@ -1,22 +1,22 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var net = require('net'); +const net = require('net'); -var host = '*'.repeat(256); +const host = '*'.repeat(256); function do_not_call() { throw new Error('This function should not have been called.'); } -var socket = net.connect(42, host, do_not_call); +const socket = net.connect(42, host, do_not_call); socket.on('error', common.mustCall(function(err) { - assert.equal(err.code, 'ENOTFOUND'); + assert.strictEqual(err.code, 'ENOTFOUND'); })); socket.on('lookup', function(err, ip, type) { assert(err instanceof Error); - assert.equal(err.code, 'ENOTFOUND'); - assert.equal(ip, undefined); - assert.equal(type, undefined); + assert.strictEqual(err.code, 'ENOTFOUND'); + assert.strictEqual(ip, undefined); + assert.strictEqual(type, undefined); }); diff --git a/test/parallel/test-net-dns-lookup-skip.js b/test/parallel/test-net-dns-lookup-skip.js index 513a6d0422498e..0997e6cc6c1c5d 100644 --- a/test/parallel/test-net-dns-lookup-skip.js +++ b/test/parallel/test-net-dns-lookup-skip.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var net = require('net'); +const common = require('../common'); +const net = require('net'); function check(addressType) { - var server = net.createServer(function(client) { + const server = net.createServer(function(client) { client.end(); server.close(); }); - var address = addressType === 4 ? '127.0.0.1' : '::1'; + const address = addressType === 4 ? '127.0.0.1' : '::1'; server.listen(0, address, function() { net.connect(this.address().port, address).on('lookup', common.fail); }); diff --git a/test/parallel/test-net-dns-lookup.js b/test/parallel/test-net-dns-lookup.js index 4f3cd2991cf925..166029f31c482f 100644 --- a/test/parallel/test-net-dns-lookup.js +++ b/test/parallel/test-net-dns-lookup.js @@ -1,9 +1,9 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var server = net.createServer(function(client) { +const server = net.createServer(function(client) { client.end(); server.close(); }); @@ -11,9 +11,9 @@ var server = net.createServer(function(client) { server.listen(0, '127.0.0.1', common.mustCall(function() { net.connect(this.address().port, 'localhost') .on('lookup', common.mustCall(function(err, ip, type, host) { - assert.equal(err, null); - assert.equal(ip, '127.0.0.1'); - assert.equal(type, '4'); - assert.equal(host, 'localhost'); + assert.strictEqual(err, null); + assert.strictEqual(ip, '127.0.0.1'); + assert.strictEqual(type, 4); + assert.strictEqual(host, 'localhost'); })); })); diff --git a/test/parallel/test-net-during-close.js b/test/parallel/test-net-during-close.js index 2649995f89a02f..e8723fb1a692a8 100644 --- a/test/parallel/test-net-during-close.js +++ b/test/parallel/test-net-during-close.js @@ -1,14 +1,14 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { socket.end(); }); server.listen(0, common.mustCall(function() { - var client = net.createConnection(this.address().port); + const client = net.createConnection(this.address().port); server.close(); // server connection event has not yet fired // client is still attempting to connect diff --git a/test/parallel/test-net-eaddrinuse.js b/test/parallel/test-net-eaddrinuse.js index 4741c820797154..cf4293e8230875 100644 --- a/test/parallel/test-net-eaddrinuse.js +++ b/test/parallel/test-net-eaddrinuse.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var server1 = net.createServer(function(socket) { +const server1 = net.createServer(function(socket) { }); -var server2 = net.createServer(function(socket) { +const server2 = net.createServer(function(socket) { }); server1.listen(0, function() { server2.on('error', function(error) { - assert.equal(true, error.message.indexOf('EADDRINUSE') >= 0); + assert.strictEqual(true, error.message.indexOf('EADDRINUSE') >= 0); server1.close(); }); server2.listen(this.address().port); diff --git a/test/parallel/test-net-end-without-connect.js b/test/parallel/test-net-end-without-connect.js index 69abf486316ff2..99324b071d27d6 100644 --- a/test/parallel/test-net-end-without-connect.js +++ b/test/parallel/test-net-end-without-connect.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var net = require('net'); +const net = require('net'); -var sock = new net.Socket(); +const sock = new net.Socket(); sock.end(); // Should not throw. diff --git a/test/parallel/test-net-error-twice.js b/test/parallel/test-net-error-twice.js index 36c33b4b1cc012..79c85631594d4a 100644 --- a/test/parallel/test-net-error-twice.js +++ b/test/parallel/test-net-error-twice.js @@ -1,13 +1,13 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); const net = require('net'); const buf = Buffer.alloc(10 * 1024 * 1024, 0x62); const errs = []; -var clientSocket; -var serverSocket; +let clientSocket; +let serverSocket; function ready() { if (clientSocket && serverSocket) { @@ -16,11 +16,11 @@ function ready() { } } -var srv = net.createServer(function onConnection(conn) { +const srv = net.createServer(function onConnection(conn) { conn.on('error', function(err) { errs.push(err); if (errs.length > 1 && errs[0] === errs[1]) - assert(false, 'We should not be emitting the same error twice'); + common.fail('Should not emit the same error twice'); }); conn.on('close', function() { srv.unref(); @@ -28,7 +28,7 @@ var srv = net.createServer(function onConnection(conn) { serverSocket = conn; ready(); }).listen(0, function() { - var client = net.connect({ port: this.address().port }); + const client = net.connect({ port: this.address().port }); client.on('connect', function() { clientSocket = client; @@ -38,5 +38,5 @@ var srv = net.createServer(function onConnection(conn) { process.on('exit', function() { console.log(errs); - assert.equal(errs.length, 1); + assert.strictEqual(errs.length, 1); }); diff --git a/test/parallel/test-net-internal.js b/test/parallel/test-net-internal.js index 0c8d1cf9e17a0e..a79d022a5d7eaa 100644 --- a/test/parallel/test-net-internal.js +++ b/test/parallel/test-net-internal.js @@ -6,7 +6,7 @@ require('../common'); const assert = require('assert'); const isLegalPort = require('internal/net').isLegalPort; -for (var n = 0; n <= 0xFFFF; n++) { +for (let n = 0; n <= 0xFFFF; n++) { assert(isLegalPort(n)); assert(isLegalPort('' + n)); assert(`0x${n.toString(16)}`); diff --git a/test/parallel/test-net-isip.js b/test/parallel/test-net-isip.js index 6b159b59d8c8c0..626f29488b67ea 100644 --- a/test/parallel/test-net-isip.js +++ b/test/parallel/test-net-isip.js @@ -1,70 +1,72 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -assert.equal(net.isIP('127.0.0.1'), 4); -assert.equal(net.isIP('x127.0.0.1'), 0); -assert.equal(net.isIP('example.com'), 0); -assert.equal(net.isIP('0000:0000:0000:0000:0000:0000:0000:0000'), 6); -assert.equal(net.isIP('0000:0000:0000:0000:0000:0000:0000:0000::0000'), 0); -assert.equal(net.isIP('1050:0:0:0:5:600:300c:326b'), 6); -assert.equal(net.isIP('2001:252:0:1::2008:6'), 6); -assert.equal(net.isIP('2001:dead:beef:1::2008:6'), 6); -assert.equal(net.isIP('2001::'), 6); -assert.equal(net.isIP('2001:dead::'), 6); -assert.equal(net.isIP('2001:dead:beef::'), 6); -assert.equal(net.isIP('2001:dead:beef:1::'), 6); -assert.equal(net.isIP('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'), 6); -assert.equal(net.isIP(':2001:252:0:1::2008:6:'), 0); -assert.equal(net.isIP(':2001:252:0:1::2008:6'), 0); -assert.equal(net.isIP('2001:252:0:1::2008:6:'), 0); -assert.equal(net.isIP('2001:252::1::2008:6'), 0); -assert.equal(net.isIP('::2001:252:1:2008:6'), 6); -assert.equal(net.isIP('::2001:252:1:1.1.1.1'), 6); -assert.equal(net.isIP('::2001:252:1:255.255.255.255'), 6); -assert.equal(net.isIP('::2001:252:1:255.255.255.255.76'), 0); -assert.equal(net.isIP('::anything'), 0); -assert.equal(net.isIP('::1'), 6); -assert.equal(net.isIP('::'), 6); -assert.equal(net.isIP('0000:0000:0000:0000:0000:0000:12345:0000'), 0); -assert.equal(net.isIP('0'), 0); -assert.equal(net.isIP(), 0); -assert.equal(net.isIP(''), 0); -assert.equal(net.isIP(null), 0); -assert.equal(net.isIP(123), 0); -assert.equal(net.isIP(true), 0); -assert.equal(net.isIP({}), 0); -assert.equal(net.isIP({ toString: () => '::2001:252:1:255.255.255.255' }), 6); -assert.equal(net.isIP({ toString: () => '127.0.0.1' }), 4); -assert.equal(net.isIP({ toString: () => 'bla' }), 0); +assert.strictEqual(net.isIP('127.0.0.1'), 4); +assert.strictEqual(net.isIP('x127.0.0.1'), 0); +assert.strictEqual(net.isIP('example.com'), 0); +assert.strictEqual(net.isIP('0000:0000:0000:0000:0000:0000:0000:0000'), 6); +assert.strictEqual(net.isIP('0000:0000:0000:0000:0000:0000:0000:0000::0000'), + 0); +assert.strictEqual(net.isIP('1050:0:0:0:5:600:300c:326b'), 6); +assert.strictEqual(net.isIP('2001:252:0:1::2008:6'), 6); +assert.strictEqual(net.isIP('2001:dead:beef:1::2008:6'), 6); +assert.strictEqual(net.isIP('2001::'), 6); +assert.strictEqual(net.isIP('2001:dead::'), 6); +assert.strictEqual(net.isIP('2001:dead:beef::'), 6); +assert.strictEqual(net.isIP('2001:dead:beef:1::'), 6); +assert.strictEqual(net.isIP('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'), 6); +assert.strictEqual(net.isIP(':2001:252:0:1::2008:6:'), 0); +assert.strictEqual(net.isIP(':2001:252:0:1::2008:6'), 0); +assert.strictEqual(net.isIP('2001:252:0:1::2008:6:'), 0); +assert.strictEqual(net.isIP('2001:252::1::2008:6'), 0); +assert.strictEqual(net.isIP('::2001:252:1:2008:6'), 6); +assert.strictEqual(net.isIP('::2001:252:1:1.1.1.1'), 6); +assert.strictEqual(net.isIP('::2001:252:1:255.255.255.255'), 6); +assert.strictEqual(net.isIP('::2001:252:1:255.255.255.255.76'), 0); +assert.strictEqual(net.isIP('::anything'), 0); +assert.strictEqual(net.isIP('::1'), 6); +assert.strictEqual(net.isIP('::'), 6); +assert.strictEqual(net.isIP('0000:0000:0000:0000:0000:0000:12345:0000'), 0); +assert.strictEqual(net.isIP('0'), 0); +assert.strictEqual(net.isIP(), 0); +assert.strictEqual(net.isIP(''), 0); +assert.strictEqual(net.isIP(null), 0); +assert.strictEqual(net.isIP(123), 0); +assert.strictEqual(net.isIP(true), 0); +assert.strictEqual(net.isIP({}), 0); +assert.strictEqual(net.isIP({ toString: () => '::2001:252:1:255.255.255.255' }), + 6); +assert.strictEqual(net.isIP({ toString: () => '127.0.0.1' }), 4); +assert.strictEqual(net.isIP({ toString: () => 'bla' }), 0); -assert.equal(net.isIPv4('127.0.0.1'), true); -assert.equal(net.isIPv4('example.com'), false); -assert.equal(net.isIPv4('2001:252:0:1::2008:6'), false); -assert.equal(net.isIPv4(), false); -assert.equal(net.isIPv4(''), false); -assert.equal(net.isIPv4(null), false); -assert.equal(net.isIPv4(123), false); -assert.equal(net.isIPv4(true), false); -assert.equal(net.isIPv4({}), false); -assert.equal(net.isIPv4({ +assert.strictEqual(net.isIPv4('127.0.0.1'), true); +assert.strictEqual(net.isIPv4('example.com'), false); +assert.strictEqual(net.isIPv4('2001:252:0:1::2008:6'), false); +assert.strictEqual(net.isIPv4(), false); +assert.strictEqual(net.isIPv4(''), false); +assert.strictEqual(net.isIPv4(null), false); +assert.strictEqual(net.isIPv4(123), false); +assert.strictEqual(net.isIPv4(true), false); +assert.strictEqual(net.isIPv4({}), false); +assert.strictEqual(net.isIPv4({ toString: () => '::2001:252:1:255.255.255.255' }), false); -assert.equal(net.isIPv4({ toString: () => '127.0.0.1' }), true); -assert.equal(net.isIPv4({ toString: () => 'bla' }), false); +assert.strictEqual(net.isIPv4({ toString: () => '127.0.0.1' }), true); +assert.strictEqual(net.isIPv4({ toString: () => 'bla' }), false); -assert.equal(net.isIPv6('127.0.0.1'), false); -assert.equal(net.isIPv6('example.com'), false); -assert.equal(net.isIPv6('2001:252:0:1::2008:6'), true); -assert.equal(net.isIPv6(), false); -assert.equal(net.isIPv6(''), false); -assert.equal(net.isIPv6(null), false); -assert.equal(net.isIPv6(123), false); -assert.equal(net.isIPv6(true), false); -assert.equal(net.isIPv6({}), false); -assert.equal(net.isIPv6({ +assert.strictEqual(net.isIPv6('127.0.0.1'), false); +assert.strictEqual(net.isIPv6('example.com'), false); +assert.strictEqual(net.isIPv6('2001:252:0:1::2008:6'), true); +assert.strictEqual(net.isIPv6(), false); +assert.strictEqual(net.isIPv6(''), false); +assert.strictEqual(net.isIPv6(null), false); +assert.strictEqual(net.isIPv6(123), false); +assert.strictEqual(net.isIPv6(true), false); +assert.strictEqual(net.isIPv6({}), false); +assert.strictEqual(net.isIPv6({ toString: () => '::2001:252:1:255.255.255.255' }), true); -assert.equal(net.isIPv6({ toString: () => '127.0.0.1' }), false); -assert.equal(net.isIPv6({ toString: () => 'bla' }), false); +assert.strictEqual(net.isIPv6({ toString: () => '127.0.0.1' }), false); +assert.strictEqual(net.isIPv6({ toString: () => 'bla' }), false); diff --git a/test/parallel/test-net-keepalive.js b/test/parallel/test-net-keepalive.js index e466f0ff580d06..68ed5f842ff13b 100644 --- a/test/parallel/test-net-keepalive.js +++ b/test/parallel/test-net-keepalive.js @@ -3,9 +3,9 @@ const common = require('../common'); const assert = require('assert'); const net = require('net'); -var serverConnection; -var clientConnection; -var echoServer = net.createServer(function(connection) { +let serverConnection; +let clientConnection; +const echoServer = net.createServer(function(connection) { serverConnection = connection; setTimeout(common.mustCall(function() { // make sure both connections are still open @@ -16,7 +16,7 @@ var echoServer = net.createServer(function(connection) { echoServer.close(); }, 1), common.platformTimeout(100)); connection.setTimeout(0); - assert.notEqual(connection.setKeepAlive, undefined); + assert.notStrictEqual(connection.setKeepAlive, undefined); // send a keepalive packet after 50 ms connection.setKeepAlive(true, common.platformTimeout(50)); connection.on('end', function() { diff --git a/test/parallel/test-net-large-string.js b/test/parallel/test-net-large-string.js index b469b0289546a1..83612111e2a0aa 100644 --- a/test/parallel/test-net-large-string.js +++ b/test/parallel/test-net-large-string.js @@ -1,14 +1,14 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var kPoolSize = 40 * 1024; -var data = 'あ'.repeat(kPoolSize); -var encoding = 'UTF-8'; +const kPoolSize = 40 * 1024; +const data = 'あ'.repeat(kPoolSize); +const encoding = 'UTF-8'; -var server = net.createServer(common.mustCall(function(socket) { - var receivedSize = 0; +const server = net.createServer(common.mustCall(function(socket) { + let receivedSize = 0; socket.setEncoding(encoding); socket.on('data', function(data) { @@ -21,7 +21,7 @@ var server = net.createServer(common.mustCall(function(socket) { })); server.listen(0, function() { - var client = net.createConnection(this.address().port); + const client = net.createConnection(this.address().port); client.on('end', function() { server.close(); }); diff --git a/test/parallel/test-net-listen-close-server-callback-is-not-function.js b/test/parallel/test-net-listen-close-server-callback-is-not-function.js index 03c08d4f51bf15..472ea37e7146b9 100644 --- a/test/parallel/test-net-listen-close-server-callback-is-not-function.js +++ b/test/parallel/test-net-listen-close-server-callback-is-not-function.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var net = require('net'); +const net = require('net'); -var server = net.createServer(common.fail); +const server = net.createServer(common.fail); server.on('close', common.mustCall(function() {})); diff --git a/test/parallel/test-net-listen-close-server.js b/test/parallel/test-net-listen-close-server.js index 92c7274f328918..0a45adecbe83e7 100644 --- a/test/parallel/test-net-listen-close-server.js +++ b/test/parallel/test-net-listen-close-server.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var net = require('net'); +const net = require('net'); -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { }); server.listen(0, common.fail); server.on('error', common.fail); diff --git a/test/parallel/test-net-listen-error.js b/test/parallel/test-net-listen-error.js index 9523fcb2e7f456..7b721d1004f37f 100644 --- a/test/parallel/test-net-listen-error.js +++ b/test/parallel/test-net-listen-error.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var net = require('net'); +const net = require('net'); -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { }); server.listen(1, '1.1.1.1', common.fail); // EACCESS or EADDRNOTAVAIL server.on('error', common.mustCall(function(error) {})); diff --git a/test/parallel/test-net-listen-exclusive-random-ports.js b/test/parallel/test-net-listen-exclusive-random-ports.js index f46f9a01d773ce..1909af067ce4d7 100644 --- a/test/parallel/test-net-listen-exclusive-random-ports.js +++ b/test/parallel/test-net-listen-exclusive-random-ports.js @@ -1,27 +1,27 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var net = require('net'); +const assert = require('assert'); +const cluster = require('cluster'); +const net = require('net'); function noop() {} if (cluster.isMaster) { - var worker1 = cluster.fork(); + const worker1 = cluster.fork(); worker1.on('message', function(port1) { - assert.equal(port1, port1 | 0, 'first worker could not listen'); - var worker2 = cluster.fork(); + assert.strictEqual(port1, port1 | 0, 'first worker could not listen'); + const worker2 = cluster.fork(); worker2.on('message', function(port2) { - assert.equal(port2, port2 | 0, 'second worker could not listen'); - assert.notEqual(port1, port2, 'ports should not be equal'); + assert.strictEqual(port2, port2 | 0, 'second worker could not listen'); + assert.notStrictEqual(port1, port2, 'ports should not be equal'); worker1.kill(); worker2.kill(); }); }); } else { - var server = net.createServer(noop); + const server = net.createServer(noop); server.on('error', function(err) { process.send(err.code); diff --git a/test/parallel/test-net-listen-shared-ports.js b/test/parallel/test-net-listen-shared-ports.js index 2062dd0ce136bb..e7bc036ff3986c 100644 --- a/test/parallel/test-net-listen-shared-ports.js +++ b/test/parallel/test-net-listen-shared-ports.js @@ -1,27 +1,27 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var cluster = require('cluster'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const cluster = require('cluster'); +const net = require('net'); function noop() {} if (cluster.isMaster) { - var worker1 = cluster.fork(); + const worker1 = cluster.fork(); worker1.on('message', function(msg) { - assert.equal(msg, 'success'); - var worker2 = cluster.fork(); + assert.strictEqual(msg, 'success'); + const worker2 = cluster.fork(); worker2.on('message', function(msg) { - assert.equal(msg, 'server2:EADDRINUSE'); + assert.strictEqual(msg, 'server2:EADDRINUSE'); worker1.kill(); worker2.kill(); }); }); } else { - var server1 = net.createServer(noop); - var server2 = net.createServer(noop); + const server1 = net.createServer(noop); + const server2 = net.createServer(noop); server1.on('error', function(err) { // no errors expected diff --git a/test/parallel/test-net-local-address-port.js b/test/parallel/test-net-local-address-port.js index 56f8eab5855c46..b256d93b5f8400 100644 --- a/test/parallel/test-net-local-address-port.js +++ b/test/parallel/test-net-local-address-port.js @@ -3,7 +3,7 @@ const common = require('../common'); const assert = require('assert'); const net = require('net'); -var server = net.createServer(common.mustCall(function(socket) { +const server = net.createServer(common.mustCall(function(socket) { assert.strictEqual(socket.localAddress, common.localhostIPv4); assert.strictEqual(socket.localPort, this.address().port); socket.on('end', function() { @@ -13,7 +13,8 @@ var server = net.createServer(common.mustCall(function(socket) { })); server.listen(0, common.localhostIPv4, function() { - var client = net.createConnection(this.address().port, common.localhostIPv4); + const client = net.createConnection(this.address() + .port, common.localhostIPv4); client.on('connect', function() { client.end(); }); diff --git a/test/parallel/test-net-localport.js b/test/parallel/test-net-localport.js index 4af9dcfd08aeca..b100e4ae768c29 100644 --- a/test/parallel/test-net-localport.js +++ b/test/parallel/test-net-localport.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { console.log(socket.remotePort); assert.strictEqual(socket.remotePort, common.PORT); socket.end(); @@ -11,7 +11,7 @@ var server = net.createServer(function(socket) { server.close(); }); }).listen(0).on('listening', function() { - var client = net.connect({ + const client = net.connect({ host: '127.0.0.1', port: this.address().port, localPort: common.PORT, diff --git a/test/parallel/test-net-pause-resume-connecting.js b/test/parallel/test-net-pause-resume-connecting.js index 6f3e78a94a56df..f441252fed6e70 100644 --- a/test/parallel/test-net-pause-resume-connecting.js +++ b/test/parallel/test-net-pause-resume-connecting.js @@ -9,7 +9,7 @@ let conn; // Server -var server = net.createServer(function(conn) { +const server = net.createServer(function(conn) { connections++; conn.end('This was the year he fell to pieces.'); diff --git a/test/parallel/test-net-persistent-keepalive.js b/test/parallel/test-net-persistent-keepalive.js index d1dfb370167714..8756cd7d1b2960 100644 --- a/test/parallel/test-net-persistent-keepalive.js +++ b/test/parallel/test-net-persistent-keepalive.js @@ -1,22 +1,22 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var serverConnection; -var clientConnection; -var echoServer = net.createServer(function(connection) { +let serverConnection; +let clientConnection; +const echoServer = net.createServer(function(connection) { serverConnection = connection; setTimeout(function() { // make sure both connections are still open - assert.equal(serverConnection.readyState, 'open'); - assert.equal(clientConnection.readyState, 'open'); + assert.strictEqual(serverConnection.readyState, 'open'); + assert.strictEqual(clientConnection.readyState, 'open'); serverConnection.end(); clientConnection.end(); echoServer.close(); }, 600); connection.setTimeout(0); - assert.equal(typeof connection.setKeepAlive, 'function'); + assert.strictEqual(typeof connection.setKeepAlive, 'function'); connection.on('end', function() { connection.end(); }); @@ -27,7 +27,7 @@ echoServer.on('listening', function() { clientConnection = new net.Socket(); // send a keepalive packet after 1000 ms // and make sure it persists - var s = clientConnection.setKeepAlive(true, 400); + const s = clientConnection.setKeepAlive(true, 400); assert.ok(s instanceof net.Socket); clientConnection.connect(this.address().port); clientConnection.setTimeout(0); diff --git a/test/parallel/test-net-persistent-nodelay.js b/test/parallel/test-net-persistent-nodelay.js index e23b8718dfee6d..bb2a9dfd22e5cc 100644 --- a/test/parallel/test-net-persistent-nodelay.js +++ b/test/parallel/test-net-persistent-nodelay.js @@ -1,18 +1,18 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); -var TCPWrap = process.binding('tcp_wrap').TCP; +const assert = require('assert'); +const net = require('net'); +const TCPWrap = process.binding('tcp_wrap').TCP; -var echoServer = net.createServer(function(connection) { +const echoServer = net.createServer(function(connection) { connection.end(); }); echoServer.listen(0); -var callCount = 0; +let callCount = 0; -var Socket = net.Socket; -var setNoDelay = TCPWrap.prototype.setNoDelay; +const Socket = net.Socket; +const setNoDelay = TCPWrap.prototype.setNoDelay; TCPWrap.prototype.setNoDelay = function(enable) { setNoDelay.call(this, enable); @@ -20,15 +20,15 @@ TCPWrap.prototype.setNoDelay = function(enable) { }; echoServer.on('listening', function() { - var sock1 = new Socket(); + const sock1 = new Socket(); // setNoDelay before the handle is created // there is probably a better way to test this - var s = sock1.setNoDelay(); + const s = sock1.setNoDelay(); assert.ok(s instanceof net.Socket); sock1.connect(this.address().port); sock1.on('end', function() { - assert.equal(callCount, 1); + assert.strictEqual(callCount, 1); echoServer.close(); }); }); diff --git a/test/parallel/test-net-persistent-ref-unref.js b/test/parallel/test-net-persistent-ref-unref.js index 32782e7c591444..d8de7ba3f2877a 100644 --- a/test/parallel/test-net-persistent-ref-unref.js +++ b/test/parallel/test-net-persistent-ref-unref.js @@ -1,39 +1,39 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); -var TCPWrap = process.binding('tcp_wrap').TCP; +const assert = require('assert'); +const net = require('net'); +const TCPWrap = process.binding('tcp_wrap').TCP; -var echoServer = net.createServer(function(conn) { +const echoServer = net.createServer(function(conn) { conn.end(); }); -var ref = TCPWrap.prototype.ref; -var unref = TCPWrap.prototype.unref; +const ref = TCPWrap.prototype.ref; +const unref = TCPWrap.prototype.unref; -var refCount = 0; +let refCount = 0; TCPWrap.prototype.ref = function() { ref.call(this); refCount++; - assert.equal(refCount, 0); + assert.strictEqual(refCount, 0); }; TCPWrap.prototype.unref = function() { unref.call(this); refCount--; - assert.equal(refCount, -1); + assert.strictEqual(refCount, -1); }; echoServer.listen(0); echoServer.on('listening', function() { - var sock = new net.Socket(); + const sock = new net.Socket(); sock.unref(); sock.ref(); sock.connect(this.address().port); sock.on('end', function() { - assert.equal(refCount, 0); + assert.strictEqual(refCount, 0); echoServer.close(); }); }); diff --git a/test/parallel/test-net-pingpong.js b/test/parallel/test-net-pingpong.js index b49b3a78778719..9280991f39e5d9 100644 --- a/test/parallel/test-net-pingpong.js +++ b/test/parallel/test-net-pingpong.js @@ -5,9 +5,9 @@ const net = require('net'); function pingPongTest(port, host) { const N = 1000; - var count = 0; - var sentPongs = 0; - var sent_final_ping = false; + let count = 0; + let sentPongs = 0; + let sent_final_ping = false; const server = net.createServer( { allowHalfOpen: true }, diff --git a/test/parallel/test-net-pipe-connect-errors.js b/test/parallel/test-net-pipe-connect-errors.js index 3e00befc341682..2c1332efa11429 100644 --- a/test/parallel/test-net-pipe-connect-errors.js +++ b/test/parallel/test-net-pipe-connect-errors.js @@ -8,7 +8,7 @@ const assert = require('assert'); // Test if ENOTSOCK is fired when trying to connect to a file which is not // a socket. -var emptyTxt; +let emptyTxt; if (common.isWindows) { // on Win, common.PIPE will be a named pipe, so we use an existing empty @@ -34,7 +34,7 @@ if (common.isWindows) { fs.writeFileSync(emptyTxt, ''); } -var notSocketClient = net.createConnection(emptyTxt, function() { +const notSocketClient = net.createConnection(emptyTxt, function() { common.fail('connection callback should not run'); }); @@ -45,7 +45,7 @@ notSocketClient.on('error', common.mustCall(function(err) { // Trying to connect to not-existing socket should result in ENOENT error -var noEntSocketClient = net.createConnection('no-ent-file', function() { +const noEntSocketClient = net.createConnection('no-ent-file', function() { common.fail('connection to non-existent socket, callback should not run'); }); @@ -63,7 +63,7 @@ if (!common.isWindows && process.getuid() !== 0) { accessServer.listen(common.PIPE, common.mustCall(function() { fs.chmodSync(common.PIPE, 0); - var accessClient = net.createConnection(common.PIPE, function() { + const accessClient = net.createConnection(common.PIPE, function() { common.fail('connection should get EACCES, callback should not run'); }); diff --git a/test/parallel/test-net-reconnect-error.js b/test/parallel/test-net-reconnect-error.js index 4e1e3d14984e80..e5e2124434cc89 100644 --- a/test/parallel/test-net-reconnect-error.js +++ b/test/parallel/test-net-reconnect-error.js @@ -10,8 +10,7 @@ let disconnect_count = 0; const c = net.createConnection(common.PORT); c.on('connect', function() { - console.error('CLIENT connected'); - assert.ok(false); + common.fail('client should not have connected'); }); c.on('error', function(e) { diff --git a/test/parallel/test-net-reconnect.js b/test/parallel/test-net-reconnect.js index 980de2637b18bf..c970ad7fc5c135 100644 --- a/test/parallel/test-net-reconnect.js +++ b/test/parallel/test-net-reconnect.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var net = require('net'); +const net = require('net'); -var N = 50; -var client_recv_count = 0; -var client_end_count = 0; -var disconnect_count = 0; +const N = 50; +let client_recv_count = 0; +let client_end_count = 0; +let disconnect_count = 0; -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { console.error('SERVER: got socket connection'); socket.resume(); @@ -23,13 +23,13 @@ var server = net.createServer(function(socket) { socket.on('close', function(had_error) { console.log('SERVER had_error: ' + JSON.stringify(had_error)); - assert.equal(false, had_error); + assert.strictEqual(false, had_error); }); }); server.listen(0, function() { console.log('SERVER listening'); - var client = net.createConnection(this.address().port); + const client = net.createConnection(this.address().port); client.setEncoding('UTF8'); @@ -40,7 +40,7 @@ server.listen(0, function() { client.on('data', function(chunk) { client_recv_count += 1; console.log('client_recv_count ' + client_recv_count); - assert.equal('hello\r\n', chunk); + assert.strictEqual('hello\r\n', chunk); console.error('CLIENT: calling end', client._writableState); client.end(); }); @@ -52,7 +52,7 @@ server.listen(0, function() { client.on('close', function(had_error) { console.log('CLIENT disconnect'); - assert.equal(false, had_error); + assert.strictEqual(false, had_error); if (disconnect_count++ < N) client.connect(server.address().port); // reconnect else @@ -61,7 +61,7 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.equal(N + 1, disconnect_count); - assert.equal(N + 1, client_recv_count); - assert.equal(N + 1, client_end_count); + assert.strictEqual(N + 1, disconnect_count); + assert.strictEqual(N + 1, client_recv_count); + assert.strictEqual(N + 1, client_end_count); }); diff --git a/test/parallel/test-net-remote-address-port.js b/test/parallel/test-net-remote-address-port.js index 62a7ebfe572908..a9d02631be5194 100644 --- a/test/parallel/test-net-remote-address-port.js +++ b/test/parallel/test-net-remote-address-port.js @@ -4,50 +4,50 @@ const assert = require('assert'); const net = require('net'); -var conns_closed = 0; +let conns_closed = 0; -var remoteAddrCandidates = [ common.localhostIPv4 ]; +const remoteAddrCandidates = [ common.localhostIPv4 ]; if (common.hasIPv6) remoteAddrCandidates.push('::ffff:127.0.0.1'); -var remoteFamilyCandidates = ['IPv4']; +const remoteFamilyCandidates = ['IPv4']; if (common.hasIPv6) remoteFamilyCandidates.push('IPv6'); -var server = net.createServer(common.mustCall(function(socket) { - assert.notEqual(-1, remoteAddrCandidates.indexOf(socket.remoteAddress)); - assert.notEqual(-1, remoteFamilyCandidates.indexOf(socket.remoteFamily)); +const server = net.createServer(common.mustCall(function(socket) { + assert.ok(remoteAddrCandidates.includes(socket.remoteAddress)); + assert.ok(remoteFamilyCandidates.includes(socket.remoteFamily)); assert.ok(socket.remotePort); - assert.notEqual(socket.remotePort, this.address().port); + assert.notStrictEqual(socket.remotePort, this.address().port); socket.on('end', function() { if (++conns_closed === 2) server.close(); }); socket.on('close', function() { - assert.notEqual(-1, remoteAddrCandidates.indexOf(socket.remoteAddress)); - assert.notEqual(-1, remoteFamilyCandidates.indexOf(socket.remoteFamily)); + assert.ok(remoteAddrCandidates.includes(socket.remoteAddress)); + assert.ok(remoteFamilyCandidates.includes(socket.remoteFamily)); }); socket.resume(); }, 2)); server.listen(0, 'localhost', function() { - var client = net.createConnection(this.address().port, 'localhost'); - var client2 = net.createConnection(this.address().port); + const client = net.createConnection(this.address().port, 'localhost'); + const client2 = net.createConnection(this.address().port); client.on('connect', function() { - assert.notEqual(-1, remoteAddrCandidates.indexOf(client.remoteAddress)); - assert.notEqual(-1, remoteFamilyCandidates.indexOf(client.remoteFamily)); + assert.ok(remoteAddrCandidates.includes(client.remoteAddress)); + assert.ok(remoteFamilyCandidates.includes(client.remoteFamily)); assert.strictEqual(client.remotePort, server.address().port); client.end(); }); client.on('close', function() { - assert.notEqual(-1, remoteAddrCandidates.indexOf(client.remoteAddress)); - assert.notEqual(-1, remoteFamilyCandidates.indexOf(client.remoteFamily)); + assert.ok(remoteAddrCandidates.includes(client.remoteAddress)); + assert.ok(remoteFamilyCandidates.includes(client.remoteFamily)); }); client2.on('connect', function() { - assert.notEqual(-1, remoteAddrCandidates.indexOf(client2.remoteAddress)); - assert.notEqual(-1, remoteFamilyCandidates.indexOf(client2.remoteFamily)); + assert.ok(remoteAddrCandidates.includes(client2.remoteAddress)); + assert.ok(remoteFamilyCandidates.includes(client2.remoteFamily)); assert.strictEqual(client2.remotePort, server.address().port); client2.end(); }); client2.on('close', function() { - assert.notEqual(-1, remoteAddrCandidates.indexOf(client2.remoteAddress)); - assert.notEqual(-1, remoteFamilyCandidates.indexOf(client2.remoteFamily)); + assert.ok(remoteAddrCandidates.includes(client2.remoteAddress)); + assert.ok(remoteFamilyCandidates.includes(client2.remoteFamily)); }); }); diff --git a/test/parallel/test-net-server-bind.js b/test/parallel/test-net-server-bind.js index c77341418c2c6d..0332b364df1ca2 100644 --- a/test/parallel/test-net-server-bind.js +++ b/test/parallel/test-net-server-bind.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); // With only a callback, server should get a port assigned by the OS -var address0; -var server0 = net.createServer(function(socket) { }); +let address0; +const server0 = net.createServer(function(socket) { }); server0.listen(function() { address0 = server0.address(); @@ -18,9 +18,9 @@ server0.listen(function() { // No callback to listen(), assume we can bind in 100 ms -var address1; -var connectionKey1; -var server1 = net.createServer(function(socket) { }); +let address1; +let connectionKey1; +const server1 = net.createServer(function(socket) { }); server1.listen(common.PORT); @@ -34,8 +34,8 @@ setTimeout(function() { // Callback to listen() -var address2; -var server2 = net.createServer(function(socket) { }); +let address2; +const server2 = net.createServer(function(socket) { }); server2.listen(common.PORT + 1, function() { address2 = server2.address(); @@ -46,8 +46,8 @@ server2.listen(common.PORT + 1, function() { // Backlog argument -var address3; -var server3 = net.createServer(function(socket) { }); +let address3; +const server3 = net.createServer(function(socket) { }); server3.listen(common.PORT + 2, '0.0.0.0', 127, function() { address3 = server3.address(); @@ -58,8 +58,8 @@ server3.listen(common.PORT + 2, '0.0.0.0', 127, function() { // Backlog argument without host argument -var address4; -var server4 = net.createServer(function(socket) { }); +let address4; +const server4 = net.createServer(function(socket) { }); server4.listen(common.PORT + 3, 127, function() { address4 = server4.address(); @@ -70,17 +70,17 @@ server4.listen(common.PORT + 3, 127, function() { process.on('exit', function() { assert.ok(address0.port > 100); - assert.equal(common.PORT, address1.port); + assert.strictEqual(common.PORT, address1.port); - var expectedConnectionKey1; + let expectedConnectionKey1; if (address1.family === 'IPv6') expectedConnectionKey1 = '6::::' + address1.port; else expectedConnectionKey1 = '4:0.0.0.0:' + address1.port; - assert.equal(connectionKey1, expectedConnectionKey1); - assert.equal(common.PORT + 1, address2.port); - assert.equal(common.PORT + 2, address3.port); - assert.equal(common.PORT + 3, address4.port); + assert.strictEqual(connectionKey1, expectedConnectionKey1); + assert.strictEqual(common.PORT + 1, address2.port); + assert.strictEqual(common.PORT + 2, address3.port); + assert.strictEqual(common.PORT + 3, address4.port); }); diff --git a/test/parallel/test-net-server-close.js b/test/parallel/test-net-server-close.js index 006ca529c79ab3..e39f851c3906c4 100644 --- a/test/parallel/test-net-server-close.js +++ b/test/parallel/test-net-server-close.js @@ -1,21 +1,21 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var events = []; -var sockets = []; +const events = []; +const sockets = []; process.on('exit', function() { - assert.equal(server.connections, 0); - assert.equal(events.length, 3); + assert.strictEqual(server.connections, 0); + assert.strictEqual(events.length, 3); // Expect to see one server event and two client events. The order of the // events is undefined because they arrive on the same event loop tick. - assert.equal(events.join(' ').match(/server/g).length, 1); - assert.equal(events.join(' ').match(/client/g).length, 2); + assert.strictEqual(events.join(' ').match(/server/g).length, 1); + assert.strictEqual(events.join(' ').match(/client/g).length, 2); }); -var server = net.createServer(function(c) { +const server = net.createServer(function(c) { c.on('close', function() { events.push('client'); }); diff --git a/test/parallel/test-net-server-connections-child-null.js b/test/parallel/test-net-server-connections-child-null.js new file mode 100644 index 00000000000000..a8a1346fec3370 --- /dev/null +++ b/test/parallel/test-net-server-connections-child-null.js @@ -0,0 +1,44 @@ +'use strict'; +const common = require('../common'); +const assert = require('assert'); +const fork = require('child_process').fork; +const net = require('net'); + +if (process.argv[2] === 'child') { + + process.on('message', (msg, socket) => { + socket.end('goodbye'); + }); + + process.send('hello'); + +} else { + + const child = fork(process.argv[1], ['child']); + + const runTest = common.mustCall(() => { + + const server = net.createServer(); + + // server.connections should start as 0 + assert.strictEqual(server.connections, 0); + server.on('connection', (socket) => { + child.send({what: 'socket'}, socket); + }); + server.on('close', () => { + child.kill(); + }); + + server.listen(0, common.mustCall(() => { + const connect = net.connect(server.address().port); + + connect.on('close', common.mustCall(() => { + // now server.connections should be null + assert.strictEqual(server.connections, null); + server.close(); + })); + })); + }); + + child.on('message', runTest); +} diff --git a/test/parallel/test-net-server-connections.js b/test/parallel/test-net-server-connections.js index ae89d9aac7b3f7..01e535803a8f39 100644 --- a/test/parallel/test-net-server-connections.js +++ b/test/parallel/test-net-server-connections.js @@ -1,12 +1,18 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var net = require('net'); +const net = require('net'); + +const server = new net.Server(); + +const expectedWarning = 'Server.connections property is deprecated. ' + + 'Use Server.getConnections method instead.'; + +common.expectWarning('DeprecationWarning', expectedWarning); // test that server.connections property is no longer enumerable now that it // has been marked as deprecated +assert.strictEqual(Object.keys(server).indexOf('connections'), -1); -var server = new net.Server(); - -assert.equal(Object.keys(server).indexOf('connections'), -1); +assert.strictEqual(server.connections, 0); diff --git a/test/parallel/test-net-server-listen-remove-callback.js b/test/parallel/test-net-server-listen-remove-callback.js index 9bdfd628072798..cd47f325a9580f 100644 --- a/test/parallel/test-net-server-listen-remove-callback.js +++ b/test/parallel/test-net-server-listen-remove-callback.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); // Server should only fire listen callback once -var server = net.createServer(); +const server = net.createServer(); server.on('close', function() { - var listeners = server.listeners('listening'); + const listeners = server.listeners('listening'); console.log('Closed, listeners:', listeners.length); - assert.equal(0, listeners.length); + assert.strictEqual(0, listeners.length); }); server.listen(0, function() { diff --git a/test/parallel/test-net-server-max-connections-close-makes-more-available.js b/test/parallel/test-net-server-max-connections-close-makes-more-available.js index fb9831d05b3e50..4e1f381e0fdb50 100644 --- a/test/parallel/test-net-server-max-connections-close-makes-more-available.js +++ b/test/parallel/test-net-server-max-connections-close-makes-more-available.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var net = require('net'); +const net = require('net'); // Sets the server's maxConnections property to 1. // Open 2 connections (connection 0 and connection 1). @@ -13,23 +13,23 @@ var net = require('net'); // Connection 2 should be accepted. // Connection 3 should be rejected. -var connections = []; -var received = []; -var sent = []; +const connections = []; +const received = []; +const sent = []; -var createConnection = function(index) { +const createConnection = function(index) { console.error('creating connection ' + index); return new Promise(function(resolve, reject) { - var connection = net.createConnection(server.address().port, function() { - var msg = '' + index; + const connection = net.createConnection(server.address().port, function() { + const msg = '' + index; console.error('sending message: ' + msg); this.write(msg); sent.push(msg); }); connection.on('error', function(err) { - assert.equal(err.code, 'ECONNRESET'); + assert.strictEqual(err.code, 'ECONNRESET'); resolve(); }); @@ -47,7 +47,7 @@ var createConnection = function(index) { }); }; -var closeConnection = function(index) { +const closeConnection = function(index) { console.error('closing connection ' + index); return new Promise(function(resolve, reject) { connections[index].on('end', function() { @@ -57,7 +57,7 @@ var closeConnection = function(index) { }); }; -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { socket.on('data', function(data) { console.error('received message: ' + data); received.push('' + data); diff --git a/test/parallel/test-net-server-max-connections.js b/test/parallel/test-net-server-max-connections.js index 99d3b345f40974..f560a7dafc4446 100644 --- a/test/parallel/test-net-server-max-connections.js +++ b/test/parallel/test-net-server-max-connections.js @@ -9,7 +9,7 @@ const net = require('net'); // and the last 10 connections are rejected. const N = 20; -var closes = 0; +let closes = 0; const waits = []; const server = net.createServer(common.mustCall(function(connection) { @@ -26,7 +26,7 @@ server.maxConnections = N / 2; function makeConnection(index) { const c = net.createConnection(server.address().port); - var gotData = false; + let gotData = false; c.on('connect', function() { if (index + 1 < N) { @@ -45,7 +45,7 @@ function makeConnection(index) { } if (closes === N / 2) { - var cb; + let cb; console.error('calling wait callback.'); while (cb = waits.shift()) { cb(); diff --git a/test/parallel/test-net-server-pause-on-connect.js b/test/parallel/test-net-server-pause-on-connect.js index 798175737b80b3..5b42876e6d652e 100644 --- a/test/parallel/test-net-server-pause-on-connect.js +++ b/test/parallel/test-net-server-pause-on-connect.js @@ -3,8 +3,8 @@ const common = require('../common'); const assert = require('assert'); const net = require('net'); const msg = 'test'; -var stopped = true; -var server1Sock; +let stopped = true; +let server1Sock; const server1ConnHandler = function(socket) { @@ -13,7 +13,7 @@ const server1ConnHandler = function(socket) { common.fail('data event should not have happened yet'); } - assert.equal(data.toString(), msg, 'invalid data received'); + assert.strictEqual(data.toString(), msg, 'invalid data received'); socket.end(); server1.close(); }); @@ -25,11 +25,12 @@ const server1 = net.createServer({pauseOnConnect: true}, server1ConnHandler); const server2ConnHandler = function(socket) { socket.on('data', function(data) { - assert.equal(data.toString(), msg, 'invalid data received'); + assert.strictEqual(data.toString(), msg, 'invalid data received'); socket.end(); server2.close(); - assert.equal(server1Sock.bytesRead, 0, 'no data should have been read yet'); + assert.strictEqual(server1Sock.bytesRead, 0, + 'no data should have been read yet'); server1Sock.resume(); stopped = false; }); @@ -47,5 +48,5 @@ server1.listen(0, function() { }); process.on('exit', function() { - assert.equal(stopped, false); + assert.strictEqual(stopped, false); }); diff --git a/test/parallel/test-net-server-unref-persistent.js b/test/parallel/test-net-server-unref-persistent.js index d68e94cfbda8c8..beb91832ea9448 100644 --- a/test/parallel/test-net-server-unref-persistent.js +++ b/test/parallel/test-net-server-unref-persistent.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); -var net = require('net'); -var server = net.createServer(); +const net = require('net'); +const server = net.createServer(); // unref before listening server.unref(); diff --git a/test/parallel/test-net-server-unref.js b/test/parallel/test-net-server-unref.js index 91b25887a28d3e..60df9fc700ec64 100644 --- a/test/parallel/test-net-server-unref.js +++ b/test/parallel/test-net-server-unref.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var net = require('net'); +const net = require('net'); -var s = net.createServer(); +const s = net.createServer(); s.listen(0); s.unref(); diff --git a/test/parallel/test-net-socket-destroy-twice.js b/test/parallel/test-net-socket-destroy-twice.js index 917e9849999b05..998ad05a1d6487 100644 --- a/test/parallel/test-net-socket-destroy-twice.js +++ b/test/parallel/test-net-socket-destroy-twice.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var net = require('net'); +const common = require('../common'); +const net = require('net'); -var conn = net.createConnection(common.PORT); +const conn = net.createConnection(common.PORT); conn.on('error', common.mustCall(function() { conn.destroy(); diff --git a/test/parallel/test-net-socket-local-address.js b/test/parallel/test-net-socket-local-address.js index 82f174dc2c1924..e888667eab4c4f 100644 --- a/test/parallel/test-net-socket-local-address.js +++ b/test/parallel/test-net-socket-local-address.js @@ -9,9 +9,9 @@ if (common.inFreeBSDJail) { return; } -var conns = 0; -var clientLocalPorts = []; -var serverRemotePorts = []; +let conns = 0; +const clientLocalPorts = []; +const serverRemotePorts = []; const client = new net.Socket(); const server = net.createServer((socket) => { serverRemotePorts.push(socket.remotePort); diff --git a/test/parallel/test-net-socket-timeout-unref.js b/test/parallel/test-net-socket-timeout-unref.js index fb4f6a658e21d2..1789ec7a1cabbd 100644 --- a/test/parallel/test-net-socket-timeout-unref.js +++ b/test/parallel/test-net-socket-timeout-unref.js @@ -12,7 +12,7 @@ const server = net.createServer(function(c) { server.listen(0); server.unref(); -var connections = 0; +let connections = 0; const sockets = []; const delays = [8, 5, 3, 6, 2, 4]; diff --git a/test/parallel/test-net-stream.js b/test/parallel/test-net-stream.js index d090038ce753be..9e1ca670e1e145 100644 --- a/test/parallel/test-net-stream.js +++ b/test/parallel/test-net-stream.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var s = new net.Stream(); +const s = new net.Stream(); // test that destroy called on a stream with a server only ever decrements the // server connection count once @@ -12,17 +12,17 @@ s.server = new net.Server(); s.server.connections = 10; s._server = s.server; -assert.equal(10, s.server.connections); +assert.strictEqual(10, s.server.connections); s.destroy(); -assert.equal(9, s.server.connections); +assert.strictEqual(9, s.server.connections); s.destroy(); -assert.equal(9, s.server.connections); +assert.strictEqual(9, s.server.connections); -var SIZE = 2E6; -var N = 10; -var buf = Buffer.alloc(SIZE, 'a'); +const SIZE = 2E6; +const N = 10; +const buf = Buffer.alloc(SIZE, 'a'); -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { socket.setNoDelay(); socket.on('error', function(err) { @@ -31,13 +31,13 @@ var server = net.createServer(function(socket) { server.close(); }); - for (var i = 0; i < N; ++i) { + for (let i = 0; i < N; ++i) { socket.write(buf, function() { }); } socket.end(); }).listen(0, function() { - var conn = net.connect(this.address().port); + const conn = net.connect(this.address().port); conn.on('data', function(buf) { conn.pause(); setTimeout(function() { @@ -47,5 +47,5 @@ var server = net.createServer(function(socket) { }); process.on('exit', function() { - assert.equal(server.connections, 0); + assert.strictEqual(server.connections, 0); }); diff --git a/test/parallel/test-net-sync-cork.js b/test/parallel/test-net-sync-cork.js index 4dff309cb97816..3872f5f96944fc 100644 --- a/test/parallel/test-net-sync-cork.js +++ b/test/parallel/test-net-sync-cork.js @@ -21,13 +21,13 @@ server.listen(0, function() { res = conn.write(buf); conn.uncork(); } - assert.equal(i, N); + assert.strictEqual(i, N); conn.end(); }); }); process.on('exit', function() { - assert.equal(server.connections, 0); + assert.strictEqual(server.connections, 0); }); function handle(socket) { diff --git a/test/parallel/test-net-write-after-close.js b/test/parallel/test-net-write-after-close.js index e01aef80f3635b..0a1dcd98b2b3c7 100644 --- a/test/parallel/test-net-write-after-close.js +++ b/test/parallel/test-net-write-after-close.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var net = require('net'); +const net = require('net'); -var server = net.createServer(common.mustCall(function(socket) { +const server = net.createServer(common.mustCall(function(socket) { socket.resume(); socket.on('error', common.mustCall(function(error) { @@ -17,7 +17,7 @@ var server = net.createServer(common.mustCall(function(socket) { })); server.listen(0, function() { - var client = net.connect(this.address().port, function() { + const client = net.connect(this.address().port, function() { client.end(); }); }); diff --git a/test/parallel/test-net-write-connect-write.js b/test/parallel/test-net-write-connect-write.js index 315db6bc02b309..ee20ede49fb5a5 100644 --- a/test/parallel/test-net-write-connect-write.js +++ b/test/parallel/test-net-write-connect-write.js @@ -1,13 +1,13 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { socket.pipe(socket); }).listen(0, common.mustCall(function() { - var conn = net.connect(this.address().port); - var received = ''; + const conn = net.connect(this.address().port); + let received = ''; conn.setEncoding('utf8'); conn.write('before'); diff --git a/test/parallel/test-net-write-slow.js b/test/parallel/test-net-write-slow.js index 6054e2b7882ac2..c1b2c60e2e202a 100644 --- a/test/parallel/test-net-write-slow.js +++ b/test/parallel/test-net-write-slow.js @@ -1,22 +1,22 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); -var SIZE = 2E5; -var N = 10; -var flushed = 0; -var received = 0; -var buf = Buffer.alloc(SIZE, 'a'); +const SIZE = 2E5; +const N = 10; +let flushed = 0; +let received = 0; +const buf = Buffer.alloc(SIZE, 'a'); -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { socket.setNoDelay(); socket.setTimeout(9999); socket.on('timeout', function() { common.fail(`flushed: ${flushed}, received: ${received}/${SIZE * N}`); }); - for (var i = 0; i < N; ++i) { + for (let i = 0; i < N; ++i) { socket.write(buf, function() { ++flushed; if (flushed === N) { @@ -27,7 +27,7 @@ var server = net.createServer(function(socket) { socket.end(); }).listen(0, common.mustCall(function() { - var conn = net.connect(this.address().port); + const conn = net.connect(this.address().port); conn.on('data', function(buf) { received += buf.length; conn.pause(); diff --git a/test/parallel/test-next-tick-domain.js b/test/parallel/test-next-tick-domain.js index 8f9d9bb4aa50f7..6edb7e3050c067 100644 --- a/test/parallel/test-next-tick-domain.js +++ b/test/parallel/test-next-tick-domain.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var origNextTick = process.nextTick; +const origNextTick = process.nextTick; require('domain'); diff --git a/test/parallel/test-next-tick-errors.js b/test/parallel/test-next-tick-errors.js index 180b769eaa105b..4f47c3f954d92e 100644 --- a/test/parallel/test-next-tick-errors.js +++ b/test/parallel/test-next-tick-errors.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); const order = []; let exceptionHandled = false; diff --git a/test/parallel/test-next-tick-intentional-starvation.js b/test/parallel/test-next-tick-intentional-starvation.js index 414524e5405ecc..ee829c94ab6929 100644 --- a/test/parallel/test-next-tick-intentional-starvation.js +++ b/test/parallel/test-next-tick-intentional-starvation.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // this is the inverse of test-next-tick-starvation. // it verifies that process.nextTick will *always* come before other @@ -9,14 +9,14 @@ var assert = require('assert'); // WARNING: unsafe! process.maxTickDepth = Infinity; -var ran = false; -var starved = false; -var start = +new Date(); -var timerRan = false; +let ran = false; +let starved = false; +const start = +new Date(); +let timerRan = false; function spin() { ran = true; - var now = +new Date(); + const now = +new Date(); if (now - start > 100) { console.log('The timer is starving, just as we planned.'); starved = true; diff --git a/test/parallel/test-next-tick-ordering.js b/test/parallel/test-next-tick-ordering.js index 63f8d37828e53c..ea019facdd8fa0 100644 --- a/test/parallel/test-next-tick-ordering.js +++ b/test/parallel/test-next-tick-ordering.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var i; +const assert = require('assert'); +let i; -var N = 30; -var done = []; +const N = 30; +const done = []; function get_printer(timeout) { return function() { @@ -26,10 +26,10 @@ console.log('Running from main.'); process.on('exit', function() { - assert.equal('nextTick', done[0]); + assert.strictEqual('nextTick', done[0]); /* Disabling this test. I don't think we can ensure the order for (i = 0; i < N; i += 1) { - assert.equal(i, done[i + 1]); + assert.strictEqual(i, done[i + 1]); } */ }); diff --git a/test/parallel/test-next-tick-ordering2.js b/test/parallel/test-next-tick-ordering2.js index 11ac84b5319dda..7cfec867f3ed01 100644 --- a/test/parallel/test-next-tick-ordering2.js +++ b/test/parallel/test-next-tick-ordering2.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var order = []; +const order = []; process.nextTick(function() { setTimeout(function() { order.push('setTimeout'); diff --git a/test/parallel/test-next-tick.js b/test/parallel/test-next-tick.js index 2a98b46da10f17..9d2b1917fae2f7 100644 --- a/test/parallel/test-next-tick.js +++ b/test/parallel/test-next-tick.js @@ -1,6 +1,6 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); process.nextTick(common.mustCall(function() { process.nextTick(common.mustCall(function() { @@ -14,11 +14,11 @@ setTimeout(common.mustCall(function() { process.nextTick(common.mustCall(function() {})); -var obj = {}; +const obj = {}; process.nextTick(function(a, b) { - assert.equal(a, 42); - assert.equal(b, obj); + assert.strictEqual(a, 42); + assert.strictEqual(b, obj); }, 42, obj); process.on('exit', function() { diff --git a/test/parallel/test-no-enter-tickcallback.js b/test/parallel/test-no-enter-tickcallback.js index e06628628955be..aab22c5f3edc72 100644 --- a/test/parallel/test-no-enter-tickcallback.js +++ b/test/parallel/test-no-enter-tickcallback.js @@ -2,8 +2,8 @@ const common = require('../common'); const assert = require('assert'); -var allsGood = false; -var cntr = 0; +let allsGood = false; +let cntr = 0; process.on('exit', () => { assert.ok(cntr > 0, '_tickDomainCallback was never called'); diff --git a/test/parallel/test-npm-install.js b/test/parallel/test-npm-install.js index c7f216fce5f2fa..00a3504fa925ae 100644 --- a/test/parallel/test-npm-install.js +++ b/test/parallel/test-npm-install.js @@ -53,7 +53,7 @@ const proc = spawn(process.execPath, args, { }); function handleExit(code, signalCode) { - assert.equal(code, 0, 'npm install should run without an error'); + assert.strictEqual(code, 0, 'npm install should run without an error'); assert.ok(signalCode === null, 'signalCode should be null'); assert.doesNotThrow(function() { fs.accessSync(installDir + '/node_modules/package-name'); diff --git a/test/parallel/test-os-homedir-no-envvar.js b/test/parallel/test-os-homedir-no-envvar.js index 94d8ab5a08fa14..2f9b1b47a70477 100644 --- a/test/parallel/test-os-homedir-no-envvar.js +++ b/test/parallel/test-os-homedir-no-envvar.js @@ -26,5 +26,5 @@ if (process.argv[2] === 'child') { env: process.env }); - assert.equal(child.status, 0); + assert.strictEqual(child.status, 0); } diff --git a/test/parallel/test-os.js b/test/parallel/test-os.js index 5a0a9f6ad14cbc..ce0d2ee054d1f9 100644 --- a/test/parallel/test-os.js +++ b/test/parallel/test-os.js @@ -107,8 +107,8 @@ switch (platform) { const filter = function(e) { return e.address === '127.0.0.1'; }; const actual = interfaces.lo.filter(filter); const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0', - mac: '00:00:00:00:00:00', family: 'IPv4', - internal: true }]; + mac: '00:00:00:00:00:00', family: 'IPv4', + internal: true }]; assert.deepStrictEqual(actual, expected); break; } @@ -117,8 +117,8 @@ switch (platform) { const filter = function(e) { return e.address === '127.0.0.1'; }; const actual = interfaces['Loopback Pseudo-Interface 1'].filter(filter); const expected = [{ address: '127.0.0.1', netmask: '255.0.0.0', - mac: '00:00:00:00:00:00', family: 'IPv4', - internal: true }]; + mac: '00:00:00:00:00:00', family: 'IPv4', + internal: true }]; assert.deepStrictEqual(actual, expected); break; } diff --git a/test/parallel/test-path-makelong.js b/test/parallel/test-path-makelong.js index 50a77e9d87b8dc..1284f625160ebe 100644 --- a/test/parallel/test-path-makelong.js +++ b/test/parallel/test-path-makelong.js @@ -1,24 +1,25 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var path = require('path'); +const assert = require('assert'); +const path = require('path'); if (common.isWindows) { - var file = path.join(common.fixturesDir, 'a.js'); - var resolvedFile = path.resolve(file); + const file = path.join(common.fixturesDir, 'a.js'); + const resolvedFile = path.resolve(file); - assert.equal('\\\\?\\' + resolvedFile, path._makeLong(file)); - assert.equal('\\\\?\\' + resolvedFile, path._makeLong('\\\\?\\' + file)); - assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile', - path._makeLong('\\\\someserver\\someshare\\somefile')); - assert.equal('\\\\?\\UNC\\someserver\\someshare\\somefile', - path._makeLong('\\\\?\\UNC\\someserver\\someshare\\somefile')); - assert.equal('\\\\.\\pipe\\somepipe', - path._makeLong('\\\\.\\pipe\\somepipe')); + assert.strictEqual('\\\\?\\' + resolvedFile, path._makeLong(file)); + assert.strictEqual('\\\\?\\' + resolvedFile, path._makeLong('\\\\?\\' + + file)); + assert.strictEqual('\\\\?\\UNC\\someserver\\someshare\\somefile', + path._makeLong('\\\\someserver\\someshare\\somefile')); + assert.strictEqual('\\\\?\\UNC\\someserver\\someshare\\somefile', path + ._makeLong('\\\\?\\UNC\\someserver\\someshare\\somefile')); + assert.strictEqual('\\\\.\\pipe\\somepipe', + path._makeLong('\\\\.\\pipe\\somepipe')); } -assert.equal(path._makeLong(null), null); -assert.equal(path._makeLong(100), 100); -assert.equal(path._makeLong(path), path); -assert.equal(path._makeLong(false), false); -assert.equal(path._makeLong(true), true); +assert.strictEqual(path._makeLong(null), null); +assert.strictEqual(path._makeLong(100), 100); +assert.strictEqual(path._makeLong(path), path); +assert.strictEqual(path._makeLong(false), false); +assert.strictEqual(path._makeLong(true), true); diff --git a/test/parallel/test-path-parse-format.js b/test/parallel/test-path-parse-format.js index 2db4c27dce072a..ac0cf62117f09d 100644 --- a/test/parallel/test-path-parse-format.js +++ b/test/parallel/test-path-parse-format.js @@ -154,7 +154,7 @@ trailingTests.forEach(function(test) { failures.push('\n' + message); }); }); -assert.equal(failures.length, 0, failures.join('')); +assert.strictEqual(failures.length, 0, failures.join('')); function checkErrors(path) { errors.forEach(function(errorCase) { @@ -175,7 +175,7 @@ function checkErrors(path) { function checkParseFormat(path, paths) { paths.forEach(function(element) { - var output = path.parse(element); + const output = path.parse(element); assert.strictEqual(typeof output.root, 'string'); assert.strictEqual(typeof output.dir, 'string'); assert.strictEqual(typeof output.base, 'string'); diff --git a/test/parallel/test-path-zero-length-strings.js b/test/parallel/test-path-zero-length-strings.js index b08ef4809201eb..ec9585fafaa169 100644 --- a/test/parallel/test-path-zero-length-strings.js +++ b/test/parallel/test-path-zero-length-strings.js @@ -12,28 +12,28 @@ const pwd = process.cwd(); // join will internally ignore all the zero-length strings and it will return // '.' if the joined string is a zero-length string. -assert.equal(path.posix.join(''), '.'); -assert.equal(path.posix.join('', ''), '.'); -assert.equal(path.win32.join(''), '.'); -assert.equal(path.win32.join('', ''), '.'); -assert.equal(path.join(pwd), pwd); -assert.equal(path.join(pwd, ''), pwd); +assert.strictEqual(path.posix.join(''), '.'); +assert.strictEqual(path.posix.join('', ''), '.'); +assert.strictEqual(path.win32.join(''), '.'); +assert.strictEqual(path.win32.join('', ''), '.'); +assert.strictEqual(path.join(pwd), pwd); +assert.strictEqual(path.join(pwd, ''), pwd); // normalize will return '.' if the input is a zero-length string -assert.equal(path.posix.normalize(''), '.'); -assert.equal(path.win32.normalize(''), '.'); -assert.equal(path.normalize(pwd), pwd); +assert.strictEqual(path.posix.normalize(''), '.'); +assert.strictEqual(path.win32.normalize(''), '.'); +assert.strictEqual(path.normalize(pwd), pwd); // Since '' is not a valid path in any of the common environments, return false -assert.equal(path.posix.isAbsolute(''), false); -assert.equal(path.win32.isAbsolute(''), false); +assert.strictEqual(path.posix.isAbsolute(''), false); +assert.strictEqual(path.win32.isAbsolute(''), false); // resolve, internally ignores all the zero-length strings and returns the // current working directory -assert.equal(path.resolve(''), pwd); -assert.equal(path.resolve('', ''), pwd); +assert.strictEqual(path.resolve(''), pwd); +assert.strictEqual(path.resolve('', ''), pwd); // relative, internally calls resolve. So, '' is actually the current directory -assert.equal(path.relative('', pwd), ''); -assert.equal(path.relative(pwd, ''), ''); -assert.equal(path.relative(pwd, pwd), ''); +assert.strictEqual(path.relative('', pwd), ''); +assert.strictEqual(path.relative(pwd, ''), ''); +assert.strictEqual(path.relative(pwd, pwd), ''); diff --git a/test/parallel/test-path.js b/test/parallel/test-path.js index 0a12b5ce92ca75..b074e83c131a24 100644 --- a/test/parallel/test-path.js +++ b/test/parallel/test-path.js @@ -450,10 +450,10 @@ if (common.isWindows) { // See https://github.com/nodejs/node/issues/7215 const currentDriveLetter = path.parse(process.cwd()).root.substring(0, 2); const resolveFixture = path.join(common.fixturesDir, 'path-resolve.js'); - var spawnResult = child.spawnSync( + const spawnResult = child.spawnSync( process.argv[0], [resolveFixture, currentDriveLetter]); - var resolvedPath = spawnResult.stdout.toString().trim(); - assert.equal(resolvedPath.toLowerCase(), process.cwd().toLowerCase()); + const resolvedPath = spawnResult.stdout.toString().trim(); + assert.strictEqual(resolvedPath.toLowerCase(), process.cwd().toLowerCase()); } diff --git a/test/parallel/test-pipe-address.js b/test/parallel/test-pipe-address.js index 85e3daa3522e78..49f6802d3f7c7a 100644 --- a/test/parallel/test-pipe-address.js +++ b/test/parallel/test-pipe-address.js @@ -1,8 +1,8 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); -var server = net.createServer(common.fail); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); +const server = net.createServer(common.fail); common.refreshTmpDir(); diff --git a/test/parallel/test-pipe-file-to-http.js b/test/parallel/test-pipe-file-to-http.js index f72cfe7d793348..0ea9244ff76946 100644 --- a/test/parallel/test-pipe-file-to-http.js +++ b/test/parallel/test-pipe-file-to-http.js @@ -38,7 +38,7 @@ server.on('listening', function() { const cmd = common.ddCommand(filename, 10240); cp.exec(cmd, function(err) { - if (err) throw err; + assert.ifError(err); makeRequest(); }); }); diff --git a/test/parallel/test-pipe-return-val.js b/test/parallel/test-pipe-return-val.js index a14f925916bee0..5e6e83dbc7a952 100644 --- a/test/parallel/test-pipe-return-val.js +++ b/test/parallel/test-pipe-return-val.js @@ -2,11 +2,11 @@ // This test ensures SourceStream.pipe(DestStream) returns DestStream require('../common'); -var Stream = require('stream').Stream; -var assert = require('assert'); +const Stream = require('stream').Stream; +const assert = require('assert'); -var sourceStream = new Stream(); -var destStream = new Stream(); -var result = sourceStream.pipe(destStream); +const sourceStream = new Stream(); +const destStream = new Stream(); +const result = sourceStream.pipe(destStream); assert.strictEqual(result, destStream); diff --git a/test/parallel/test-pipe-stream.js b/test/parallel/test-pipe-stream.js index 6298495087ac06..8fd9d31d499089 100644 --- a/test/parallel/test-pipe-stream.js +++ b/test/parallel/test-pipe-stream.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); common.refreshTmpDir(); function test(clazz, cb) { - var have_ping = false; - var have_pong = false; + let have_ping = false; + let have_pong = false; function check() { assert.ok(have_ping); @@ -15,7 +15,7 @@ function test(clazz, cb) { } function ping() { - var conn = new clazz(); + const conn = new clazz(); conn.on('error', function(err) { throw err; @@ -26,7 +26,7 @@ function test(clazz, cb) { }); conn.on('data', function(data) { - assert.equal(data.toString(), 'PONG'); + assert.strictEqual(data.toString(), 'PONG'); have_pong = true; conn.destroy(); }); @@ -38,7 +38,7 @@ function test(clazz, cb) { }); conn.on('data', function(data) { - assert.equal(data.toString(), 'PING'); + assert.strictEqual(data.toString(), 'PING'); have_ping = true; conn.write('PONG', 'utf-8'); }); @@ -48,11 +48,11 @@ function test(clazz, cb) { }); } - var timeout = setTimeout(function() { + const timeout = setTimeout(function() { server.close(); }, 2000); - var server = net.Server(); + const server = net.Server(); server.listen(common.PIPE, ping); server.on('connection', pong); server.on('close', function() { diff --git a/test/parallel/test-pipe-unref.js b/test/parallel/test-pipe-unref.js index 35c25524b4cfc8..34b5ef651bf6aa 100644 --- a/test/parallel/test-pipe-unref.js +++ b/test/parallel/test-pipe-unref.js @@ -1,10 +1,10 @@ 'use strict'; -var common = require('../common'); -var net = require('net'); +const common = require('../common'); +const net = require('net'); common.refreshTmpDir(); -var s = net.Server(); +const s = net.Server(); s.listen(common.PIPE); s.unref(); diff --git a/test/parallel/test-pipe-writev.js b/test/parallel/test-pipe-writev.js new file mode 100644 index 00000000000000..6440b5f623761d --- /dev/null +++ b/test/parallel/test-pipe-writev.js @@ -0,0 +1,46 @@ +'use strict'; + +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); + +if (common.isWindows) { + common.skip('Unix-specific test'); + return; +} + +common.refreshTmpDir(); + +const server = net.createServer((connection) => { + connection.on('error', (err) => { + throw err; + }); + + const writev = connection._writev.bind(connection); + connection._writev = common.mustCall(writev); + + connection.cork(); + connection.write('pi'); + connection.write('ng'); + connection.end(); +}); + +server.on('error', (err) => { + throw err; +}); + +server.listen(common.PIPE, () => { + const client = net.connect(common.PIPE); + + client.on('error', (err) => { + throw err; + }); + + client.on('data', common.mustCall((data) => { + assert.strictEqual(data.toString(), 'ping'); + })); + + client.on('end', () => { + server.close(); + }); +}); diff --git a/test/parallel/test-preload.js b/test/parallel/test-preload.js index 4ee564f0520cc5..8dc64cc6c60168 100644 --- a/test/parallel/test-preload.js +++ b/test/parallel/test-preload.js @@ -14,7 +14,7 @@ if (common.isSunOS) { const nodeBinary = process.argv[0]; const preloadOption = function(preloads) { - var option = ''; + let option = ''; preloads.forEach(function(preload, index) { option += '-r ' + preload + ' '; }); @@ -32,43 +32,41 @@ const fixtureD = fixture('define-global.js'); const fixtureThrows = fixture('throws_error4.js'); // test preloading a single module works -childProcess.exec(nodeBinary + ' ' + - preloadOption([fixtureA]) + ' ' + - fixtureB, - function(err, stdout, stderr) { - if (err) throw err; - assert.strictEqual(stdout, 'A\nB\n'); - }); +childProcess.exec(nodeBinary + ' ' + preloadOption([fixtureA]) + ' ' + fixtureB, + function(err, stdout, stderr) { + assert.ifError(err); + assert.strictEqual(stdout, 'A\nB\n'); + }); // test preloading multiple modules works -childProcess.exec(nodeBinary + ' ' + - preloadOption([fixtureA, fixtureB]) + ' ' + - fixtureC, +childProcess.exec( + nodeBinary + ' ' + preloadOption([fixtureA, fixtureB]) + ' ' + fixtureC, function(err, stdout, stderr) { - if (err) throw err; + assert.ifError(err); assert.strictEqual(stdout, 'A\nB\nC\n'); - }); + } +); // test that preloading a throwing module aborts -childProcess.exec(nodeBinary + ' ' + - preloadOption([fixtureA, fixtureThrows]) + ' ' + - fixtureB, +childProcess.exec( + nodeBinary + ' ' + preloadOption([fixtureA, fixtureThrows]) + ' ' + fixtureB, function(err, stdout, stderr) { if (err) { assert.strictEqual(stdout, 'A\n'); } else { throw new Error('Preload should have failed'); } - }); + } +); // test that preload can be used with --eval -childProcess.exec(nodeBinary + ' ' + - preloadOption([fixtureA]) + - '-e "console.log(\'hello\');"', +childProcess.exec( + nodeBinary + ' ' + preloadOption([fixtureA]) + '-e "console.log(\'hello\');"', function(err, stdout, stderr) { - if (err) throw err; + assert.ifError(err); assert.strictEqual(stdout, 'A\nhello\n'); - }); + } +); // test that preload can be used with stdin const stdinProc = childProcess.spawn( @@ -77,7 +75,7 @@ const stdinProc = childProcess.spawn( {stdio: 'pipe'} ); stdinProc.stdin.end("console.log('hello');"); -var stdinStdout = ''; +let stdinStdout = ''; stdinProc.stdout.on('data', function(d) { stdinStdout += d; }); @@ -93,7 +91,7 @@ const replProc = childProcess.spawn( {stdio: 'pipe'} ); replProc.stdin.end('.exit\n'); -var replStdout = ''; +let replStdout = ''; replProc.stdout.on('data', function(d) { replStdout += d; }); @@ -108,42 +106,43 @@ replProc.on('close', function(code) { // test that preload placement at other points in the cmdline // also test that duplicated preload only gets loaded once -childProcess.exec(nodeBinary + ' ' + - preloadOption([fixtureA]) + - '-e "console.log(\'hello\');" ' + - preloadOption([fixtureA, fixtureB]), +childProcess.exec( + nodeBinary + ' ' + preloadOption([fixtureA]) + + '-e "console.log(\'hello\');" ' + preloadOption([fixtureA, fixtureB]), function(err, stdout, stderr) { - if (err) throw err; + assert.ifError(err); assert.strictEqual(stdout, 'A\nB\nhello\n'); - }); + } +); // test that preload works with -i -const interactive = childProcess.exec(nodeBinary + ' ' + - preloadOption([fixtureD]) + - '-i', +const interactive = childProcess.exec( + nodeBinary + ' ' + preloadOption([fixtureD]) + '-i', common.mustCall(function(err, stdout, stderr) { assert.ifError(err); assert.strictEqual(stdout, "> 'test'\n> "); - })); + }) +); interactive.stdin.write('a\n'); interactive.stdin.write('process.exit()\n'); -childProcess.exec(nodeBinary + ' ' + - '--require ' + fixture('cluster-preload.js') + ' ' + - fixture('cluster-preload-test.js'), +childProcess.exec( + nodeBinary + ' ' + '--require ' + fixture('cluster-preload.js') + ' ' + + fixture('cluster-preload-test.js'), function(err, stdout, stderr) { - if (err) throw err; + assert.ifError(err); assert.ok(/worker terminated with code 43/.test(stdout)); - }); + } +); // https://github.com/nodejs/node/issues/1691 process.chdir(common.fixturesDir); -childProcess.exec(nodeBinary + ' ' + - '--expose_debug_as=v8debug ' + - '--require ' + fixture('cluster-preload.js') + ' ' + - 'cluster-preload-test.js', +childProcess.exec( + nodeBinary + ' ' + '--expose_natives_as=v8natives ' + '--require ' + + fixture('cluster-preload.js') + ' ' + 'cluster-preload-test.js', function(err, stdout, stderr) { - if (err) throw err; + assert.ifError(err); assert.ok(/worker terminated with code 43/.test(stdout)); - }); + } +); diff --git a/test/parallel/test-process-argv-0.js b/test/parallel/test-process-argv-0.js index c3aacb60fa5403..8e4f0e695ec6a1 100644 --- a/test/parallel/test-process-argv-0.js +++ b/test/parallel/test-process-argv-0.js @@ -1,20 +1,20 @@ 'use strict'; require('../common'); -var path = require('path'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const path = require('path'); +const assert = require('assert'); +const spawn = require('child_process').spawn; if (process.argv[2] !== 'child') { - var child = spawn(process.execPath, [__filename, 'child'], { + const child = spawn(process.execPath, [__filename, 'child'], { cwd: path.dirname(process.execPath) }); - var childArgv0 = ''; + let childArgv0 = ''; child.stdout.on('data', function(chunk) { childArgv0 += chunk; }); process.on('exit', function() { - assert.equal(childArgv0, process.execPath); + assert.strictEqual(childArgv0, process.execPath); }); } else { process.stdout.write(process.argv[0]); diff --git a/test/parallel/test-process-assert.js b/test/parallel/test-process-assert.js new file mode 100644 index 00000000000000..e386c3d7600c06 --- /dev/null +++ b/test/parallel/test-process-assert.js @@ -0,0 +1,11 @@ +'use strict'; +require('../common'); +const assert = require('assert'); + +assert.strictEqual(process.assert(1, 'error'), undefined); +assert.throws(() => { + process.assert(undefined, 'errorMessage'); +}, /^Error: errorMessage$/); +assert.throws(() => { + process.assert(false); +}, /^Error: assertion error$/); diff --git a/test/parallel/test-process-before-exit.js b/test/parallel/test-process-before-exit.js deleted file mode 100644 index 5d8855869a8e4a..00000000000000 --- a/test/parallel/test-process-before-exit.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; -require('../common'); -var assert = require('assert'); - -var N = 5; -var n = 0; - -function f() { - if (++n < N) setTimeout(f, 5); -} -process.on('beforeExit', f); -process.on('exit', function() { - assert.equal(n, N + 1); // The sixth time we let it through. -}); diff --git a/test/parallel/test-process-beforeexit.js b/test/parallel/test-process-beforeexit.js new file mode 100644 index 00000000000000..4557628c42b611 --- /dev/null +++ b/test/parallel/test-process-beforeexit.js @@ -0,0 +1,39 @@ +'use strict'; +const common = require('../common'); +const net = require('net'); + +process.once('beforeExit', common.mustCall(tryImmediate)); + +function tryImmediate() { + setImmediate(common.mustCall(() => { + process.once('beforeExit', common.mustCall(tryTimer)); + })); +} + +function tryTimer() { + setTimeout(common.mustCall(() => { + process.once('beforeExit', common.mustCall(tryListen)); + }), 1); +} + +function tryListen() { + net.createServer() + .listen(0) + .on('listening', common.mustCall(function() { + this.close(); + process.once('beforeExit', common.mustCall(tryRepeatedTimer)); + })); +} + +// test that a function invoked from the beforeExit handler can use a timer +// to keep the event loop open, which can use another timer to keep the event +// loop open, etc. +function tryRepeatedTimer() { + const N = 5; + let n = 0; + const repeatedTimer = common.mustCall(function() { + if (++n < N) + setTimeout(repeatedTimer, 1); + }, N); + setTimeout(repeatedTimer, 1); +} diff --git a/test/parallel/test-process-binding.js b/test/parallel/test-process-binding.js index 722e9333aff60a..475891aa5d30d8 100644 --- a/test/parallel/test-process-binding.js +++ b/test/parallel/test-process-binding.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); assert.throws( function() { diff --git a/test/parallel/test-process-config.js b/test/parallel/test-process-config.js index ab38a48e5aacdd..a1767464fd5978 100644 --- a/test/parallel/test-process-config.js +++ b/test/parallel/test-process-config.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var fs = require('fs'); -var path = require('path'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); // check for existence assert(process.hasOwnProperty('config')); @@ -10,8 +10,8 @@ assert(process.hasOwnProperty('config')); // ensure that `process.config` is an Object assert.strictEqual(Object(process.config), process.config); -var configPath = path.resolve(__dirname, '..', '..', 'config.gypi'); -var config = fs.readFileSync(configPath, 'utf8'); +const configPath = path.resolve(__dirname, '..', '..', 'config.gypi'); +let config = fs.readFileSync(configPath, 'utf8'); // clean up comment at the first line config = config.split('\n').slice(1).join('\n').replace(/'/g, '"'); diff --git a/test/parallel/test-process-cpuUsage.js b/test/parallel/test-process-cpuUsage.js index 92dc71918585c3..062dac31cf7b5e 100644 --- a/test/parallel/test-process-cpuUsage.js +++ b/test/parallel/test-process-cpuUsage.js @@ -33,31 +33,61 @@ for (let i = 0; i < 10; i++) { assert(diffUsage.system >= 0); } +const invalidUserArgument = + /^TypeError: value of user property of argument is invalid$/; +const invalidSystemArgument = + /^TypeError: value of system property of argument is invalid$/; + // Ensure that an invalid shape for the previous value argument throws an error. -assert.throws(function() { process.cpuUsage(1); }); -assert.throws(function() { process.cpuUsage({}); }); -assert.throws(function() { process.cpuUsage({ user: 'a' }); }); -assert.throws(function() { process.cpuUsage({ system: 'b' }); }); -assert.throws(function() { process.cpuUsage({ user: null, system: 'c' }); }); -assert.throws(function() { process.cpuUsage({ user: 'd', system: null }); }); -assert.throws(function() { process.cpuUsage({ user: -1, system: 2 }); }); -assert.throws(function() { process.cpuUsage({ user: 3, system: -2 }); }); -assert.throws(function() { +assert.throws(() => { + process.cpuUsage(1); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({}); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ user: 'a' }); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ system: 'b' }); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ user: null, system: 'c' }); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ user: 'd', system: null }); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ user: -1, system: 2 }); +}, invalidUserArgument); + +assert.throws(() => { + process.cpuUsage({ user: 3, system: -2 }); +}, invalidSystemArgument); + +assert.throws(() => { process.cpuUsage({ user: Number.POSITIVE_INFINITY, system: 4 }); -}); -assert.throws(function() { +}, invalidUserArgument); + +assert.throws(() => { process.cpuUsage({ user: 5, system: Number.NEGATIVE_INFINITY }); -}); +}, invalidSystemArgument); // Ensure that the return value is the expected shape. function validateResult(result) { - assert.notEqual(result, null); + assert.notStrictEqual(result, null); assert(Number.isFinite(result.user)); assert(Number.isFinite(result.system)); diff --git a/test/parallel/test-process-env.js b/test/parallel/test-process-env.js index 21898d19425ca3..5ea0a4a57efc68 100644 --- a/test/parallel/test-process-env.js +++ b/test/parallel/test-process-env.js @@ -63,8 +63,8 @@ process.env.TZ = 'Europe/Amsterdam'; // time difference between Greenwich and Amsterdam is +2 hours in the summer date = new Date('Fri, 10 Sep 1982 03:15:00 GMT'); -assert.equal(3, date.getUTCHours()); -assert.equal(5, date.getHours()); +assert.strictEqual(3, date.getUTCHours()); +assert.strictEqual(5, date.getHours()); */ /* eslint-enable max-len */ diff --git a/test/parallel/test-process-exec-argv.js b/test/parallel/test-process-exec-argv.js index e32971ae81a893..8125850b424d84 100644 --- a/test/parallel/test-process-exec-argv.js +++ b/test/parallel/test-process-exec-argv.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const assert = require('assert'); +const spawn = require('child_process').spawn; if (process.argv[2] === 'child') { process.stdout.write(JSON.stringify(process.execArgv)); } else { - var execArgv = ['--stack-size=256']; - var args = [__filename, 'child', 'arg0']; - var child = spawn(process.execPath, execArgv.concat(args)); - var out = ''; + const execArgv = ['--stack-size=256']; + const args = [__filename, 'child', 'arg0']; + const child = spawn(process.execPath, execArgv.concat(args)); + let out = ''; child.stdout.on('data', function(chunk) { out += chunk; diff --git a/test/parallel/test-process-exit-code.js b/test/parallel/test-process-exit-code.js index 8d657528d05561..8d0ed1b33bae76 100644 --- a/test/parallel/test-process-exit-code.js +++ b/test/parallel/test-process-exit-code.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); switch (process.argv[2]) { case 'child1': @@ -22,14 +22,14 @@ switch (process.argv[2]) { function child1() { process.exitCode = 42; process.on('exit', function(code) { - assert.equal(code, 42); + assert.strictEqual(code, 42); }); } function child2() { process.exitCode = 99; process.on('exit', function(code) { - assert.equal(code, 42); + assert.strictEqual(code, 42); }); process.exit(42); } @@ -37,7 +37,7 @@ function child2() { function child3() { process.exitCode = 99; process.on('exit', function(code) { - assert.equal(code, 0); + assert.strictEqual(code, 0); }); process.exit(0); } @@ -56,7 +56,7 @@ function child4() { function child5() { process.exitCode = 95; process.on('exit', function(code) { - assert.equal(code, 95); + assert.strictEqual(code, 95); process.exitCode = 99; }); } @@ -70,12 +70,12 @@ function parent() { } function test(arg, exit) { - var spawn = require('child_process').spawn; - var node = process.execPath; - var f = __filename; - var option = { stdio: [ 0, 1, 'ignore' ] }; + const spawn = require('child_process').spawn; + const node = process.execPath; + const f = __filename; + const option = { stdio: [ 0, 1, 'ignore' ] }; spawn(node, [f, arg], option).on('exit', function(code) { - assert.equal(code, exit, 'wrong exit for ' + + assert.strictEqual(code, exit, 'wrong exit for ' + arg + '\nexpected:' + exit + ' but got:' + code); console.log('ok - %s exited with %d', arg, exit); diff --git a/test/parallel/test-process-exit-from-before-exit.js b/test/parallel/test-process-exit-from-before-exit.js index b37df0a5bd340d..82458217c6f062 100644 --- a/test/parallel/test-process-exit-from-before-exit.js +++ b/test/parallel/test-process-exit-from-before-exit.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); process.on('beforeExit', common.mustCall(function() { setTimeout(common.fail, 5); diff --git a/test/parallel/test-process-exit-recursive.js b/test/parallel/test-process-exit-recursive.js index 53426a6b1cdaf0..48ad8259168a90 100644 --- a/test/parallel/test-process-exit-recursive.js +++ b/test/parallel/test-process-exit-recursive.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // recursively calling .exit() should not overflow the call stack -var nexits = 0; +let nexits = 0; process.on('exit', function(code) { - assert.equal(nexits++, 0); - assert.equal(code, 1); + assert.strictEqual(nexits++, 0); + assert.strictEqual(code, 1); // now override the exit code of 1 with 0 so that the test passes process.exit(0); diff --git a/test/parallel/test-process-exit.js b/test/parallel/test-process-exit.js index 0ea36f158eaf9b..a4ea2bf51b53f5 100644 --- a/test/parallel/test-process-exit.js +++ b/test/parallel/test-process-exit.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // calling .exit() from within "exit" should not overflow the call stack -var nexits = 0; +let nexits = 0; process.on('exit', function(code) { - assert.equal(nexits++, 0); - assert.equal(code, 0); + assert.strictEqual(nexits++, 0); + assert.strictEqual(code, 0); process.exit(); }); diff --git a/test/parallel/test-process-getactivehandles.js b/test/parallel/test-process-getactivehandles.js index a9222c984b30ca..8ceb2bcd2a32f7 100644 --- a/test/parallel/test-process-getactivehandles.js +++ b/test/parallel/test-process-getactivehandles.js @@ -6,7 +6,7 @@ const net = require('net'); const NUM = 8; const connections = []; const clients = []; -var clients_counter = 0; +let clients_counter = 0; const server = net.createServer(function listener(c) { connections.push(c); diff --git a/test/parallel/test-process-getactiverequests.js b/test/parallel/test-process-getactiverequests.js index 30773f8f11380a..f1874e4ad09a86 100644 --- a/test/parallel/test-process-getactiverequests.js +++ b/test/parallel/test-process-getactiverequests.js @@ -7,4 +7,4 @@ const fs = require('fs'); for (let i = 0; i < 12; i++) fs.open(__filename, 'r', function() { }); -assert.equal(12, process._getActiveRequests().length); +assert.strictEqual(12, process._getActiveRequests().length); diff --git a/test/parallel/test-process-getgroups.js b/test/parallel/test-process-getgroups.js index 002ec7c1ab4c7c..390f188cf5bf4d 100644 --- a/test/parallel/test-process-getgroups.js +++ b/test/parallel/test-process-getgroups.js @@ -1,26 +1,32 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var exec = require('child_process').exec; + +// Check `id -G` and `process.getgroups()` return same groups. if (common.isOSX) { common.skip('Output of `id -G` is unreliable on Darwin.'); return; } +const assert = require('assert'); +const exec = require('child_process').exec; if (typeof process.getgroups === 'function') { - var groups = process.getgroups(); + const groups = unique(process.getgroups()); assert(Array.isArray(groups)); assert(groups.length > 0); exec('id -G', function(err, stdout) { - if (err) throw err; - var real_groups = stdout.match(/\d+/g).map(Number); - assert.equal(groups.length, real_groups.length); + assert.ifError(err); + const real_groups = unique(stdout.match(/\d+/g).map(Number)); + assert.deepStrictEqual(groups, real_groups); check(groups, real_groups); check(real_groups, groups); }); } function check(a, b) { - for (var i = 0; i < a.length; ++i) assert.notStrictEqual(b.indexOf(a[i]), -1); + for (let i = 0; i < a.length; ++i) assert.notStrictEqual(b.indexOf(a[i]), -1); +} + +function unique(groups) { + return [...new Set(groups)].sort(); } diff --git a/test/parallel/test-process-hrtime.js b/test/parallel/test-process-hrtime.js index db16be0ad9e812..faa598d0a57362 100644 --- a/test/parallel/test-process-hrtime.js +++ b/test/parallel/test-process-hrtime.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // the default behavior, return an Array "tuple" of numbers -var tuple = process.hrtime(); +const tuple = process.hrtime(); // validate the default behavior validateTuple(tuple); @@ -12,16 +12,16 @@ validateTuple(tuple); validateTuple(process.hrtime(tuple)); // test that only an Array may be passed to process.hrtime() -assert.throws(function() { +assert.throws(() => { process.hrtime(1); -}); +}, /^TypeError: process.hrtime\(\) only accepts an Array tuple$/); function validateTuple(tuple) { assert(Array.isArray(tuple)); - assert.equal(2, tuple.length); - tuple.forEach(function(v) { - assert.equal('number', typeof v); - assert(isFinite(v)); + assert.strictEqual(tuple.length, 2); + tuple.forEach((v) => { + assert.strictEqual(typeof v, 'number'); + assert.strictEqual(isFinite(v), true); }); } diff --git a/test/parallel/test-process-kill-null.js b/test/parallel/test-process-kill-null.js index 2516773f08786a..6c0ee8fa049a50 100644 --- a/test/parallel/test-process-kill-null.js +++ b/test/parallel/test-process-kill-null.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const assert = require('assert'); +const spawn = require('child_process').spawn; -var cat = spawn('cat'); -var called; +const cat = spawn('cat'); +let called; assert.ok(process.kill(cat.pid, 0)); diff --git a/test/parallel/test-process-kill-pid.js b/test/parallel/test-process-kill-pid.js index ee0554c32083f6..79dc00163b78f8 100644 --- a/test/parallel/test-process-kill-pid.js +++ b/test/parallel/test-process-kill-pid.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // test variants of pid // @@ -34,9 +34,9 @@ assert.throws(function() { process.kill(1, 'test'); }, Error); // that we don't kill our process group, or try to actually send ANY signals on // windows, which doesn't support them. function kill(tryPid, trySig, expectPid, expectSig) { - var getPid; - var getSig; - var origKill = process._kill; + let getPid; + let getSig; + const origKill = process._kill; process._kill = function(pid, sig) { getPid = pid; getSig = sig; @@ -47,8 +47,8 @@ function kill(tryPid, trySig, expectPid, expectSig) { process.kill(tryPid, trySig); - assert.equal(getPid, expectPid); - assert.equal(getSig, expectSig); + assert.strictEqual(getPid.toString(), expectPid.toString()); + assert.strictEqual(getSig, expectSig); } // Note that SIGHUP and SIGTERM map to 1 and 15 respectively, even on Windows diff --git a/test/parallel/test-process-next-tick.js b/test/parallel/test-process-next-tick.js index 343511445280d4..e67ebae0a29559 100644 --- a/test/parallel/test-process-next-tick.js +++ b/test/parallel/test-process-next-tick.js @@ -1,12 +1,12 @@ 'use strict'; const common = require('../common'); -var N = 2; +const N = 2; function cb() { throw new Error(); } -for (var i = 0; i < N; ++i) { +for (let i = 0; i < N; ++i) { process.nextTick(common.mustCall(cb)); } diff --git a/test/parallel/test-process-raw-debug.js b/test/parallel/test-process-raw-debug.js index ab461902911a93..dc31c3737ae1cb 100644 --- a/test/parallel/test-process-raw-debug.js +++ b/test/parallel/test-process-raw-debug.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var os = require('os'); +const assert = require('assert'); +const os = require('os'); switch (process.argv[2]) { case 'child': @@ -13,10 +13,10 @@ switch (process.argv[2]) { } function parent() { - var spawn = require('child_process').spawn; - var child = spawn(process.execPath, [__filename, 'child']); + const spawn = require('child_process').spawn; + const child = spawn(process.execPath, [__filename, 'child']); - var output = ''; + let output = ''; child.stderr.on('data', function(c) { output += c; @@ -25,7 +25,7 @@ function parent() { child.stderr.setEncoding('utf8'); child.stderr.on('end', function() { - assert.equal(output, 'I can still debug!' + os.EOL); + assert.strictEqual(output, 'I can still debug!' + os.EOL); console.log('ok - got expected message'); }); @@ -42,7 +42,7 @@ function child() { throw new Error('No ticking!'); }; - var stderr = process.stderr; + const stderr = process.stderr; stderr.write = function() { throw new Error('No writing to stderr!'); }; diff --git a/test/parallel/test-process-remove-all-signal-listeners.js b/test/parallel/test-process-remove-all-signal-listeners.js index 131d57cdfccaa7..85db45ff88c7c8 100644 --- a/test/parallel/test-process-remove-all-signal-listeners.js +++ b/test/parallel/test-process-remove-all-signal-listeners.js @@ -14,10 +14,10 @@ if (process.argv[2] !== '--do-test') { // We are the master, fork a child so we can verify it exits with correct // status. process.env.DOTEST = 'y'; - var child = spawn(process.execPath, [__filename, '--do-test']); + const child = spawn(process.execPath, [__filename, '--do-test']); child.once('exit', common.mustCall(function(code, signal) { - assert.equal(signal, 'SIGINT'); + assert.strictEqual(signal, 'SIGINT'); })); return; diff --git a/test/parallel/test-process-versions.js b/test/parallel/test-process-versions.js index 181e3ecef2bdb0..8532b259e01092 100644 --- a/test/parallel/test-process-versions.js +++ b/test/parallel/test-process-versions.js @@ -2,8 +2,8 @@ const common = require('../common'); const assert = require('assert'); -var expected_keys = ['ares', 'http_parser', 'modules', 'node', - 'uv', 'v8', 'zlib']; +const expected_keys = ['ares', 'http_parser', 'modules', 'node', + 'uv', 'v8', 'zlib']; if (common.hasCrypto) { expected_keys.push('openssl'); diff --git a/test/parallel/test-process-wrap.js b/test/parallel/test-process-wrap.js index b5d4dc35e4fe00..fee40a84167023 100644 --- a/test/parallel/test-process-wrap.js +++ b/test/parallel/test-process-wrap.js @@ -1,22 +1,22 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var Process = process.binding('process_wrap').Process; -var Pipe = process.binding('pipe_wrap').Pipe; -var pipe = new Pipe(); -var p = new Process(); +const assert = require('assert'); +const Process = process.binding('process_wrap').Process; +const Pipe = process.binding('pipe_wrap').Pipe; +const pipe = new Pipe(); +const p = new Process(); -var processExited = false; -var gotPipeEOF = false; -var gotPipeData = false; +let processExited = false; +let gotPipeEOF = false; +let gotPipeData = false; p.onexit = function(exitCode, signal) { console.log('exit'); p.close(); pipe.readStart(); - assert.equal(0, exitCode); - assert.equal(0, signal); + assert.strictEqual(0, exitCode); + assert.strictEqual('', signal); processExited = true; }; @@ -45,7 +45,7 @@ p.spawn({ // 'this' safety // https://github.com/joyent/node/issues/6690 assert.throws(function() { - var notp = { spawn: p.spawn }; + const notp = { spawn: p.spawn }; notp.spawn({ file: process.execPath, args: [process.execPath, '-v'], diff --git a/test/parallel/test-promises-unhandled-rejections.js b/test/parallel/test-promises-unhandled-rejections.js index b827dd9e368a94..6ae70fef97a489 100644 --- a/test/parallel/test-promises-unhandled-rejections.js +++ b/test/parallel/test-promises-unhandled-rejections.js @@ -1,17 +1,17 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var domain = require('domain'); +const common = require('../common'); +const assert = require('assert'); +const domain = require('domain'); -var asyncTest = (function() { - var asyncTestsEnabled = false; - var asyncTestLastCheck; - var asyncTestQueue = []; - var asyncTestHandle; - var currentTest = null; +const asyncTest = (function() { + let asyncTestsEnabled = false; + let asyncTestLastCheck; + const asyncTestQueue = []; + let asyncTestHandle; + let currentTest = null; function fail(error) { - var stack = currentTest ? + const stack = currentTest ? error.stack + '\nFrom previous event:\n' + currentTest.stack : error.stack; @@ -23,7 +23,7 @@ var asyncTest = (function() { } function nextAsyncTest() { - var called = false; + let called = false; function done(err) { if (called) return fail(new Error('done called twice')); called = true; @@ -33,7 +33,7 @@ var asyncTest = (function() { } if (asyncTestQueue.length) { - var test = asyncTestQueue.shift(); + const test = asyncTestQueue.shift(); currentTest = test; test.action(done); } else { @@ -42,7 +42,7 @@ var asyncTest = (function() { } return function asyncTest(description, fn) { - var stack = new Error().stack.split('\n').slice(1).join('\n'); + const stack = new Error().stack.split('\n').slice(1).join('\n'); asyncTestQueue.push({ action: fn, stack: stack, @@ -53,7 +53,7 @@ var asyncTest = (function() { asyncTestLastCheck = Date.now(); process.on('uncaughtException', fail); asyncTestHandle = setInterval(function() { - var now = Date.now(); + const now = Date.now(); if (now - asyncTestLastCheck > 10000) { return fail(new Error('Async test timeout exceeded')); } @@ -65,7 +65,7 @@ var asyncTest = (function() { })(); function setupException(fn) { - var listeners = process.listeners('uncaughtException'); + const listeners = process.listeners('uncaughtException'); process.removeAllListeners('uncaughtException'); process.on('uncaughtException', fn); return function clean() { @@ -108,7 +108,7 @@ function onUnhandledFail(done) { asyncTest('synchronously rejected promise should trigger' + ' unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); }); @@ -117,7 +117,7 @@ asyncTest('synchronously rejected promise should trigger' + asyncTest('synchronously rejected promise should trigger' + ' unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); }); @@ -128,7 +128,7 @@ asyncTest('synchronously rejected promise should trigger' + asyncTest('Promise rejected after setImmediate should trigger' + ' unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); }); @@ -141,7 +141,7 @@ asyncTest('Promise rejected after setImmediate should trigger' + asyncTest('Promise rejected after setTimeout(,1) should trigger' + ' unhandled rejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); }); @@ -154,12 +154,12 @@ asyncTest('Promise rejected after setTimeout(,1) should trigger' + asyncTest('Catching a promise rejection after setImmediate is not' + ' soon enough to stop unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); }); - var _reject; - var promise = new Promise(function(_, reject) { + let _reject; + const promise = new Promise(function(_, reject) { _reject = reject; }); _reject(e); @@ -170,13 +170,13 @@ asyncTest('Catching a promise rejection after setImmediate is not' + asyncTest('When re-throwing new errors in a promise catch, only the' + ' re-thrown error should hit unhandledRejection', function(done) { - var e = new Error(); - var e2 = new Error(); + const e = new Error(); + const e2 = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e2, reason); assert.strictEqual(promise2, promise); }); - var promise2 = Promise.reject(e).then(common.fail, function(reason) { + const promise2 = Promise.reject(e).then(common.fail, function(reason) { assert.strictEqual(e, reason); throw e2; }); @@ -184,7 +184,7 @@ asyncTest('When re-throwing new errors in a promise catch, only the' + asyncTest('Test params of unhandledRejection for a synchronously-rejected' + 'promise', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); assert.strictEqual(promise, promise); @@ -195,13 +195,13 @@ asyncTest('Test params of unhandledRejection for a synchronously-rejected' + asyncTest('When re-throwing new errors in a promise catch, only the ' + 're-thrown error should hit unhandledRejection: original promise' + ' rejected async with setTimeout(,1)', function(done) { - var e = new Error(); - var e2 = new Error(); + const e = new Error(); + const e2 = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e2, reason); assert.strictEqual(promise2, promise); }); - var promise2 = new Promise(function(_, reject) { + const promise2 = new Promise(function(_, reject) { setTimeout(function() { reject(e); }, 1); @@ -214,13 +214,13 @@ asyncTest('When re-throwing new errors in a promise catch, only the ' + asyncTest('When re-throwing new errors in a promise catch, only the re-thrown' + ' error should hit unhandledRejection: promise catch attached a' + ' process.nextTick after rejection', function(done) { - var e = new Error(); - var e2 = new Error(); + const e = new Error(); + const e2 = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e2, reason); assert.strictEqual(promise2, promise); }); - var promise = new Promise(function(_, reject) { + const promise = new Promise(function(_, reject) { setTimeout(function() { reject(e); process.nextTick(function() { @@ -231,14 +231,14 @@ asyncTest('When re-throwing new errors in a promise catch, only the re-thrown' + }); }, 1); }); - var promise2; + let promise2; }); asyncTest( 'unhandledRejection should not be triggered if a promise catch is' + ' attached synchronously upon the promise\'s creation', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); Promise.reject(e).then(common.fail, function() {}); } @@ -248,7 +248,7 @@ asyncTest( 'unhandledRejection should not be triggered if a promise catch is' + ' attached synchronously upon the promise\'s creation', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); new Promise(function(_, reject) { reject(e); @@ -258,9 +258,9 @@ asyncTest( asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' + ' prevent unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); - var promise = Promise.reject(e); + const promise = Promise.reject(e); process.nextTick(function() { promise.then(common.fail, function() {}); }); @@ -268,9 +268,9 @@ asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' + asyncTest('Attaching a promise catch in a process.nextTick is soon enough to' + ' prevent unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); - var promise = new Promise(function(_, reject) { + const promise = new Promise(function(_, reject) { reject(e); }); process.nextTick(function() { @@ -297,7 +297,7 @@ asyncTest('While inside setImmediate, catching a rejected promise derived ' + asyncTest('catching a promise which is asynchronously rejected (via' + 'resolution to an asynchronously-rejected promise) prevents' + ' unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); Promise.resolve().then(function() { return new Promise(function(_, reject) { @@ -312,7 +312,7 @@ asyncTest('catching a promise which is asynchronously rejected (via' + asyncTest('Catching a rejected promise derived from throwing in a' + ' fulfillment handler prevents unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); Promise.resolve().then(function() { throw e; @@ -324,7 +324,7 @@ asyncTest('Catching a rejected promise derived from throwing in a' + asyncTest('Catching a rejected promise derived from returning a' + ' synchronously-rejected promise in a fulfillment handler' + ' prevents unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); Promise.resolve().then(function() { return Promise.reject(e); @@ -336,13 +336,12 @@ asyncTest('Catching a rejected promise derived from returning a' + asyncTest('A rejected promise derived from returning an' + ' asynchronously-rejected promise in a fulfillment handler' + ' does trigger unhandledRejection', function(done) { - var e = new Error(); - var _promise; + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); assert.strictEqual(_promise, promise); }); - _promise = Promise.resolve().then(function() { + const _promise = Promise.resolve().then(function() { return new Promise(function(_, reject) { setTimeout(function() { reject(e); @@ -353,13 +352,12 @@ asyncTest('A rejected promise derived from returning an' + asyncTest('A rejected promise derived from throwing in a fulfillment handler' + ' does trigger unhandledRejection', function(done) { - var e = new Error(); - var _promise; + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); assert.strictEqual(_promise, promise); }); - _promise = Promise.resolve().then(function() { + const _promise = Promise.resolve().then(function() { throw e; }); }); @@ -368,13 +366,12 @@ asyncTest( 'A rejected promise derived from returning a synchronously-rejected' + ' promise in a fulfillment handler does trigger unhandledRejection', function(done) { - var e = new Error(); - var _promise; + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); assert.strictEqual(_promise, promise); }); - _promise = Promise.resolve().then(function() { + const _promise = Promise.resolve().then(function() { return Promise.reject(e); }); } @@ -383,7 +380,7 @@ asyncTest( // Combinations with Promise.all asyncTest('Catching the Promise.all() of a collection that includes a' + 'rejected promise prevents unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); Promise.all([Promise.reject(e)]).then(common.fail, function() {}); }); @@ -392,9 +389,9 @@ asyncTest( 'Catching the Promise.all() of a collection that includes a ' + 'nextTick-async rejected promise prevents unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); - var p = new Promise(function(_, reject) { + let p = new Promise(function(_, reject) { process.nextTick(function() { reject(e); }); @@ -409,19 +406,19 @@ asyncTest( asyncTest('Failing to catch the Promise.all() of a collection that includes' + ' a rejected promise triggers unhandledRejection for the returned' + ' promise, not the passed promise', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); assert.strictEqual(p, promise); }); - var p = Promise.all([Promise.reject(e)]); + const p = Promise.all([Promise.reject(e)]); }); asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' + ' unhandledRejection + rejectionHandled pair', function(done) { clean(); - var unhandledPromises = []; - var e = new Error(); + const unhandledPromises = []; + const e = new Error(); process.on('unhandledRejection', function(reason, promise) { assert.strictEqual(e, reason); unhandledPromises.push(promise); @@ -433,7 +430,7 @@ asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' + done(); }); - var thePromise = new Promise(function() { + const thePromise = new Promise(function() { throw e; }); setTimeout(function() { @@ -446,11 +443,11 @@ asyncTest('Waiting setTimeout(, 10) to catch a promise causes an' + asyncTest('Waiting for some combination of process.nextTick + promise' + ' microtasks to attach a catch handler is still soon enough to' + ' prevent unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); - var a = Promise.reject(e); + const a = Promise.reject(e); process.nextTick(function() { Promise.resolve().then(function() { process.nextTick(function() { @@ -465,11 +462,11 @@ asyncTest('Waiting for some combination of process.nextTick + promise' + asyncTest('Waiting for some combination of process.nextTick + promise' + ' microtasks to attach a catch handler is still soon enough to ' + 'prevent unhandledRejection: inside setImmediate', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); setImmediate(function() { - var a = Promise.reject(e); + const a = Promise.reject(e); process.nextTick(function() { Promise.resolve().then(function() { process.nextTick(function() { @@ -485,11 +482,11 @@ asyncTest('Waiting for some combination of process.nextTick + promise' + asyncTest('Waiting for some combination of process.nextTick + promise ' + 'microtasks to attach a catch handler is still soon enough to ' + 'prevent unhandledRejection: inside setTimeout', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); setTimeout(function() { - var a = Promise.reject(e); + const a = Promise.reject(e); process.nextTick(function() { Promise.resolve().then(function() { process.nextTick(function() { @@ -505,11 +502,11 @@ asyncTest('Waiting for some combination of process.nextTick + promise ' + asyncTest('Waiting for some combination of promise microtasks + ' + 'process.nextTick to attach a catch handler is still soon enough' + ' to prevent unhandledRejection', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); - var a = Promise.reject(e); + const a = Promise.reject(e); Promise.resolve().then(function() { process.nextTick(function() { Promise.resolve().then(function() { @@ -526,11 +523,11 @@ asyncTest( ' process.nextTick to attach a catch handler is still soon enough' + ' to prevent unhandledRejection: inside setImmediate', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); setImmediate(function() { - var a = Promise.reject(e); + const a = Promise.reject(e); Promise.resolve().then(function() { process.nextTick(function() { Promise.resolve().then(function() { @@ -547,11 +544,11 @@ asyncTest( asyncTest('Waiting for some combination of promise microtasks +' + ' process.nextTick to attach a catch handler is still soon enough' + ' to prevent unhandledRejection: inside setTimeout', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledFail(done); setTimeout(function() { - var a = Promise.reject(e); + const a = Promise.reject(e); Promise.resolve().then(function() { process.nextTick(function() { Promise.resolve().then(function() { @@ -567,12 +564,12 @@ asyncTest('Waiting for some combination of promise microtasks +' + asyncTest('setImmediate + promise microtasks is too late to attach a catch' + ' handler; unhandledRejection will be triggered in that case.' + ' (setImmediate before promise creation/rejection)', function(done) { - var e = new Error(); + const e = new Error(); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(e, reason); assert.strictEqual(p, promise); }); - var p = Promise.reject(e); + const p = Promise.reject(e); setImmediate(function() { Promise.resolve().then(function() { p.catch(function() {}); @@ -598,7 +595,7 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' + }); }); }); - var p = Promise.reject(); + const p = Promise.reject(); }); asyncTest('setImmediate + promise microtasks is too late to attach a catch' + @@ -608,7 +605,7 @@ asyncTest('setImmediate + promise microtasks is too late to attach a catch' + assert.strictEqual(undefined, reason); assert.strictEqual(p, promise); }); - var p = Promise.reject(); + const p = Promise.reject(); setImmediate(function() { Promise.resolve().then(function() { Promise.resolve().then(function() { @@ -626,14 +623,14 @@ asyncTest( 'Promise unhandledRejection handler does not interfere with domain' + ' error handlers being given exceptions thrown from nextTick.', function(done) { - var d = domain.create(); - var domainReceivedError; + const d = domain.create(); + let domainReceivedError; d.on('error', function(e) { domainReceivedError = e; }); d.run(function() { - var e = new Error('error'); - var domainError = new Error('domain error'); + const e = new Error('error'); + const domainError = new Error('domain error'); onUnhandledSucceed(done, function(reason, promise) { assert.strictEqual(reason, e); assert.strictEqual(domainReceivedError, domainError); @@ -650,9 +647,9 @@ asyncTest( asyncTest('nextTick is immediately scheduled when called inside an event' + ' handler', function(done) { clean(); - var e = new Error('error'); + const e = new Error('error'); process.on('unhandledRejection', function(reason, promise) { - var order = []; + const order = []; process.nextTick(function() { order.push(1); }); @@ -669,17 +666,17 @@ asyncTest('Throwing an error inside a rejectionHandled handler goes to' + ' unhandledException, and does not cause .catch() to throw an' + 'exception', function(done) { clean(); - var e = new Error(); - var e2 = new Error(); - var tearDownException = setupException(function(err) { - assert.equal(e2, err); + const e = new Error(); + const e2 = new Error(); + const tearDownException = setupException(function(err) { + assert.strictEqual(e2, err); tearDownException(); done(); }); process.on('rejectionHandled', function() { throw e2; }); - var p = Promise.reject(e); + const p = Promise.reject(e); setTimeout(function() { try { p.catch(function() {}); diff --git a/test/parallel/test-promises-warning-on-unhandled-rejection.js b/test/parallel/test-promises-warning-on-unhandled-rejection.js index b50a5cae416942..10f95162a09597 100644 --- a/test/parallel/test-promises-warning-on-unhandled-rejection.js +++ b/test/parallel/test-promises-warning-on-unhandled-rejection.js @@ -7,7 +7,7 @@ const common = require('../common'); const assert = require('assert'); -var b = 0; +let b = 0; process.on('warning', common.mustCall((warning) => { switch (b++) { diff --git a/test/parallel/test-punycode.js b/test/parallel/test-punycode.js index 7d969c66ee4e13..60175557042ff9 100644 --- a/test/parallel/test-punycode.js +++ b/test/parallel/test-punycode.js @@ -6,18 +6,33 @@ const assert = require('assert'); assert.strictEqual(punycode.encode('ü'), 'tda'); assert.strictEqual(punycode.encode('Goethe'), 'Goethe-'); assert.strictEqual(punycode.encode('Bücher'), 'Bcher-kva'); -assert.strictEqual(punycode.encode( - 'Willst du die Blüthe des frühen, die Früchte des späteren Jahres'), - 'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'); +assert.strictEqual( + punycode.encode( + 'Willst du die Blüthe des frühen, die Früchte des späteren Jahres' + ), + 'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal' +); assert.strictEqual(punycode.encode('日本語'), 'wgv71a119e'); assert.strictEqual(punycode.decode('tda'), 'ü'); assert.strictEqual(punycode.decode('Goethe-'), 'Goethe'); assert.strictEqual(punycode.decode('Bcher-kva'), 'Bücher'); -assert.strictEqual(punycode.decode( - 'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal'), - 'Willst du die Blüthe des frühen, die Früchte des späteren Jahres'); +assert.strictEqual( + punycode.decode( + 'Willst du die Blthe des frhen, die Frchte des spteren Jahres-x9e96lkal' + ), + 'Willst du die Blüthe des frühen, die Früchte des späteren Jahres' +); assert.strictEqual(punycode.decode('wgv71a119e'), '日本語'); +assert.throws(() => { + punycode.decode(' '); +}, /^RangeError: Invalid input$/); +assert.throws(() => { + punycode.decode('α-'); +}, /^RangeError: Illegal input >= 0x80 \(not a basic code point\)$/); +assert.throws(() => { + punycode.decode('あ'); +}, /^RangeError: Overflow: input needs wider integers to process$/); // http://tools.ietf.org/html/rfc3492#section-7.1 const tests = [ diff --git a/test/parallel/test-querystring-maxKeys-non-finite.js b/test/parallel/test-querystring-maxKeys-non-finite.js index aab7c45f1b6bed..3df381405d650a 100644 --- a/test/parallel/test-querystring-maxKeys-non-finite.js +++ b/test/parallel/test-querystring-maxKeys-non-finite.js @@ -13,7 +13,7 @@ https://github.com/expressjs/body-parser/ blob/ed25264fb494cf0c8bc992b8257092cd4f694d5e/test/urlencoded.js#L636-L651 */ function createManyParams(count) { - var str = ''; + let str = ''; if (count === 0) { return str; @@ -21,8 +21,8 @@ function createManyParams(count) { str += '0=0'; - for (var i = 1; i < count; i++) { - var n = i.toString(36); + for (let i = 1; i < count; i++) { + const n = i.toString(36); str += '&' + n + '=' + n; } @@ -47,9 +47,9 @@ const resultInfinityString = parse(params, undefined, undefined, { const resultNaNString = parse(params, undefined, undefined, {maxKeys: 'NaN'}); // Non Finite maxKeys should return the length of input -assert.equal(Object.keys(resultInfinity).length, count); -assert.equal(Object.keys(resultNaN).length, count); +assert.strictEqual(Object.keys(resultInfinity).length, count); +assert.strictEqual(Object.keys(resultNaN).length, count); // Strings maxKeys should return the maxLength // defined by parses internals -assert.equal(Object.keys(resultInfinityString).length, originalMaxLength); -assert.equal(Object.keys(resultNaNString).length, originalMaxLength); +assert.strictEqual(Object.keys(resultInfinityString).length, originalMaxLength); +assert.strictEqual(Object.keys(resultNaNString).length, originalMaxLength); diff --git a/test/parallel/test-querystring.js b/test/parallel/test-querystring.js index 37cf66705d56d7..6dbd9176c26693 100644 --- a/test/parallel/test-querystring.js +++ b/test/parallel/test-querystring.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // test using assert -var qs = require('querystring'); +const qs = require('querystring'); function createWithNoPrototype(properties) { const noProto = Object.create(null); @@ -15,7 +15,7 @@ function createWithNoPrototype(properties) { // folding block, commented to pass gjslint // {{{ // [ wonkyQS, canonicalQS, obj ] -var qsTestCases = [ +const qsTestCases = [ ['__proto__=1', '__proto__=1', createWithNoPrototype([{key: '__proto__', value: '1'}])], @@ -44,11 +44,11 @@ var qsTestCases = [ ['foo=%EF%BF%BD', 'foo=%EF%BF%BD', {'foo': '\ufffd' }], // See: https://github.com/joyent/node/issues/1707 ['hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz', - 'hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz', - { hasOwnProperty: 'x', - toString: 'foo', - valueOf: 'bar', - __defineGetter__: 'baz' }], + 'hasOwnProperty=x&toString=foo&valueOf=bar&__defineGetter__=baz', + { hasOwnProperty: 'x', + toString: 'foo', + valueOf: 'bar', + __defineGetter__: 'baz' }], // See: https://github.com/joyent/node/issues/3058 ['foo&bar=baz', 'foo=&bar=baz', { foo: '', bar: 'baz' }], [null, '', {}], @@ -56,7 +56,7 @@ var qsTestCases = [ ]; // [ wonkyQS, canonicalQS, obj ] -var qsColonTestCases = [ +const qsColonTestCases = [ ['foo:bar', 'foo:bar', {'foo': 'bar'}], ['foo:bar;foo:quux', 'foo:bar;foo:quux', {'foo': ['bar', 'quux']}], ['foo:1&bar:2;baz:quux', @@ -67,9 +67,9 @@ var qsColonTestCases = [ ]; // [wonkyObj, qs, canonicalObj] -var extendedFunction = function() {}; +const extendedFunction = function() {}; extendedFunction.prototype = {a: 'b'}; -var qsWeirdObjects = [ +const qsWeirdObjects = [ [{regexp: /./g}, 'regexp=', {'regexp': ''}], [{regexp: new RegExp('.', 'g')}, 'regexp=', {'regexp': ''}], [{fn: function() {}}, 'fn=', {'fn': ''}], @@ -87,14 +87,18 @@ var qsWeirdObjects = [ ]; // }}} -var vm = require('vm'); -var foreignObject = vm.runInNewContext('({"foo": ["bar", "baz"]})'); +const vm = require('vm'); +const foreignObject = vm.runInNewContext('({"foo": ["bar", "baz"]})'); -var qsNoMungeTestCases = [ +const qsNoMungeTestCases = [ ['', {}], ['foo=bar&foo=baz', {'foo': ['bar', 'baz']}], ['foo=bar&foo=baz', foreignObject], ['blah=burp', {'blah': 'burp'}], + ['a=!-._~\'()*', {'a': '!-._~\'()*'}], + ['a=abcdefghijklmnopqrstuvwxyz', {'a': 'abcdefghijklmnopqrstuvwxyz'}], + ['a=ABCDEFGHIJKLMNOPQRSTUVWXYZ', {'a': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}], + ['a=0123456789', {'a': '0123456789'}], ['gragh=1&gragh=3&goo=2', {'gragh': ['1', '3'], 'goo': '2'}], ['frappucino=muffin&goat%5B%5D=scone&pond=moose', {'frappucino': 'muffin', 'goat[]': 'scone', 'pond': 'moose'}], @@ -168,15 +172,15 @@ qsNoMungeTestCases.forEach(function(testCase) { // basic qsTestCases.forEach(function(testCase) { - assert.equal(testCase[1], qs.stringify(testCase[2])); + assert.strictEqual(testCase[1], qs.stringify(testCase[2])); }); qsColonTestCases.forEach(function(testCase) { - assert.equal(testCase[1], qs.stringify(testCase[2], ';', ':')); + assert.strictEqual(testCase[1], qs.stringify(testCase[2], ';', ':')); }); qsWeirdObjects.forEach(function(testCase) { - assert.equal(testCase[1], qs.stringify(testCase[0])); + assert.strictEqual(testCase[1], qs.stringify(testCase[0])); }); // invalid surrogate pair throws URIError @@ -201,7 +205,7 @@ assert.strictEqual('foo=', qs.stringify({ foo: Infinity })); y: 'z' }) }); - assert.equal(f, 'a=b&q=x%3Dy%26y%3Dz'); + assert.strictEqual(f, 'a=b&q=x%3Dy%26y%3Dz'); } assert.doesNotThrow(function() { @@ -217,14 +221,14 @@ assert.doesNotThrow(function() { y: 'z' }, ';', ':') }, ';', ':'); - assert.equal(f, 'a:b;q:x%3Ay%3By%3Az'); + assert.strictEqual(f, 'a:b;q:x%3Ay%3By%3Az'); } check(qs.parse(), {}); // Test limiting -assert.equal( +assert.strictEqual( Object.keys(qs.parse('a=1&b=1&c=1', null, null, { maxKeys: 1 })).length, 1); @@ -232,40 +236,47 @@ assert.equal( function testUnlimitedKeys() { const query = {}; - for (var i = 0; i < 2000; i++) query[i] = i; + for (let i = 0; i < 2000; i++) query[i] = i; const url = qs.stringify(query); - assert.equal( + assert.strictEqual( Object.keys(qs.parse(url, null, null, { maxKeys: 0 })).length, 2000); } testUnlimitedKeys(); -var b = qs.unescapeBuffer('%d3%f2Ug%1f6v%24%5e%98%cb' + +const b = qs.unescapeBuffer('%d3%f2Ug%1f6v%24%5e%98%cb' + '%0d%ac%a2%2f%9d%eb%d8%a2%e6'); // -assert.equal(0xd3, b[0]); -assert.equal(0xf2, b[1]); -assert.equal(0x55, b[2]); -assert.equal(0x67, b[3]); -assert.equal(0x1f, b[4]); -assert.equal(0x36, b[5]); -assert.equal(0x76, b[6]); -assert.equal(0x24, b[7]); -assert.equal(0x5e, b[8]); -assert.equal(0x98, b[9]); -assert.equal(0xcb, b[10]); -assert.equal(0x0d, b[11]); -assert.equal(0xac, b[12]); -assert.equal(0xa2, b[13]); -assert.equal(0x2f, b[14]); -assert.equal(0x9d, b[15]); -assert.equal(0xeb, b[16]); -assert.equal(0xd8, b[17]); -assert.equal(0xa2, b[18]); -assert.equal(0xe6, b[19]); +assert.strictEqual(0xd3, b[0]); +assert.strictEqual(0xf2, b[1]); +assert.strictEqual(0x55, b[2]); +assert.strictEqual(0x67, b[3]); +assert.strictEqual(0x1f, b[4]); +assert.strictEqual(0x36, b[5]); +assert.strictEqual(0x76, b[6]); +assert.strictEqual(0x24, b[7]); +assert.strictEqual(0x5e, b[8]); +assert.strictEqual(0x98, b[9]); +assert.strictEqual(0xcb, b[10]); +assert.strictEqual(0x0d, b[11]); +assert.strictEqual(0xac, b[12]); +assert.strictEqual(0xa2, b[13]); +assert.strictEqual(0x2f, b[14]); +assert.strictEqual(0x9d, b[15]); +assert.strictEqual(0xeb, b[16]); +assert.strictEqual(0xd8, b[17]); +assert.strictEqual(0xa2, b[18]); +assert.strictEqual(0xe6, b[19]); + +assert.strictEqual(qs.unescapeBuffer('a+b', true).toString(), 'a b'); +assert.strictEqual(qs.unescapeBuffer('a%').toString(), 'a%'); +assert.strictEqual(qs.unescapeBuffer('a%2').toString(), 'a%2'); +assert.strictEqual(qs.unescapeBuffer('a%20').toString(), 'a '); +assert.strictEqual(qs.unescapeBuffer('a%2g').toString(), 'a%2g'); +assert.strictEqual(qs.unescapeBuffer('a%%').toString(), 'a%%'); // Test custom decode @@ -280,13 +291,13 @@ check(qs.parse('a=a&b=b&c=c', null, null, { decodeURIComponent: demoDecode }), function demoEncode(str) { return str[0]; } -var obj = { aa: 'aa', bb: 'bb', cc: 'cc' }; -assert.equal( +const obj = { aa: 'aa', bb: 'bb', cc: 'cc' }; +assert.strictEqual( qs.stringify(obj, null, null, { encodeURIComponent: demoEncode }), 'a=a&b=b&c=c'); // test overriding .unescape -var prevUnescape = qs.unescape; +const prevUnescape = qs.unescape; qs.unescape = function(str) { return str.replace(/o/g, '_'); }; diff --git a/test/parallel/test-readdouble.js b/test/parallel/test-readdouble.js index a6fc91c351f089..00340a39e631c0 100644 --- a/test/parallel/test-readdouble.js +++ b/test/parallel/test-readdouble.js @@ -9,7 +9,7 @@ const assert = require('assert'); * Test (64 bit) double */ function test(clazz) { - var buffer = new clazz(8); + const buffer = new clazz(8); buffer[0] = 0x55; buffer[1] = 0x55; @@ -19,8 +19,8 @@ function test(clazz) { buffer[5] = 0x55; buffer[6] = 0xd5; buffer[7] = 0x3f; - assert.equal(1.1945305291680097e+103, buffer.readDoubleBE(0)); - assert.equal(0.3333333333333333, buffer.readDoubleLE(0)); + assert.strictEqual(1.1945305291680097e+103, buffer.readDoubleBE(0)); + assert.strictEqual(0.3333333333333333, buffer.readDoubleLE(0)); buffer[0] = 1; buffer[1] = 0; @@ -30,18 +30,18 @@ function test(clazz) { buffer[5] = 0; buffer[6] = 0xf0; buffer[7] = 0x3f; - assert.equal(7.291122019655968e-304, buffer.readDoubleBE(0)); - assert.equal(1.0000000000000002, buffer.readDoubleLE(0)); + assert.strictEqual(7.291122019655968e-304, buffer.readDoubleBE(0)); + assert.strictEqual(1.0000000000000002, buffer.readDoubleLE(0)); buffer[0] = 2; - assert.equal(4.778309726801735e-299, buffer.readDoubleBE(0)); - assert.equal(1.0000000000000004, buffer.readDoubleLE(0)); + assert.strictEqual(4.778309726801735e-299, buffer.readDoubleBE(0)); + assert.strictEqual(1.0000000000000004, buffer.readDoubleLE(0)); buffer[0] = 1; buffer[6] = 0; buffer[7] = 0; - assert.equal(7.291122019556398e-304, buffer.readDoubleBE(0)); - assert.equal(5e-324, buffer.readDoubleLE(0)); + assert.strictEqual(7.291122019556398e-304, buffer.readDoubleBE(0)); + assert.strictEqual(5e-324, buffer.readDoubleLE(0)); buffer[0] = 0xff; buffer[1] = 0xff; @@ -52,12 +52,12 @@ function test(clazz) { buffer[6] = 0x0f; buffer[7] = 0x00; assert.ok(isNaN(buffer.readDoubleBE(0))); - assert.equal(2.225073858507201e-308, buffer.readDoubleLE(0)); + assert.strictEqual(2.225073858507201e-308, buffer.readDoubleLE(0)); buffer[6] = 0xef; buffer[7] = 0x7f; assert.ok(isNaN(buffer.readDoubleBE(0))); - assert.equal(1.7976931348623157e+308, buffer.readDoubleLE(0)); + assert.strictEqual(1.7976931348623157e+308, buffer.readDoubleLE(0)); buffer[0] = 0; buffer[1] = 0; @@ -67,42 +67,42 @@ function test(clazz) { buffer[5] = 0; buffer[6] = 0xf0; buffer[7] = 0x3f; - assert.equal(3.03865e-319, buffer.readDoubleBE(0)); - assert.equal(1, buffer.readDoubleLE(0)); + assert.strictEqual(3.03865e-319, buffer.readDoubleBE(0)); + assert.strictEqual(1, buffer.readDoubleLE(0)); buffer[6] = 0; buffer[7] = 0x40; - assert.equal(3.16e-322, buffer.readDoubleBE(0)); - assert.equal(2, buffer.readDoubleLE(0)); + assert.strictEqual(3.16e-322, buffer.readDoubleBE(0)); + assert.strictEqual(2, buffer.readDoubleLE(0)); buffer[7] = 0xc0; - assert.equal(9.5e-322, buffer.readDoubleBE(0)); - assert.equal(-2, buffer.readDoubleLE(0)); + assert.strictEqual(9.5e-322, buffer.readDoubleBE(0)); + assert.strictEqual(-2, buffer.readDoubleLE(0)); buffer[6] = 0x10; buffer[7] = 0; - assert.equal(2.0237e-320, buffer.readDoubleBE(0)); - assert.equal(2.2250738585072014e-308, buffer.readDoubleLE(0)); + assert.strictEqual(2.0237e-320, buffer.readDoubleBE(0)); + assert.strictEqual(2.2250738585072014e-308, buffer.readDoubleLE(0)); buffer[6] = 0; - assert.equal(0, buffer.readDoubleBE(0)); - assert.equal(0, buffer.readDoubleLE(0)); - assert.equal(false, 1 / buffer.readDoubleLE(0) < 0); + assert.strictEqual(0, buffer.readDoubleBE(0)); + assert.strictEqual(0, buffer.readDoubleLE(0)); + assert.strictEqual(false, 1 / buffer.readDoubleLE(0) < 0); buffer[7] = 0x80; - assert.equal(6.3e-322, buffer.readDoubleBE(0)); - assert.equal(0, buffer.readDoubleLE(0)); - assert.equal(true, 1 / buffer.readDoubleLE(0) < 0); + assert.strictEqual(6.3e-322, buffer.readDoubleBE(0)); + assert.strictEqual(0, buffer.readDoubleLE(0)); + assert.strictEqual(true, 1 / buffer.readDoubleLE(0) < 0); buffer[6] = 0xf0; buffer[7] = 0x7f; - assert.equal(3.0418e-319, buffer.readDoubleBE(0)); - assert.equal(Infinity, buffer.readDoubleLE(0)); + assert.strictEqual(3.0418e-319, buffer.readDoubleBE(0)); + assert.strictEqual(Infinity, buffer.readDoubleLE(0)); buffer[6] = 0xf0; buffer[7] = 0xff; - assert.equal(3.04814e-319, buffer.readDoubleBE(0)); - assert.equal(-Infinity, buffer.readDoubleLE(0)); + assert.strictEqual(3.04814e-319, buffer.readDoubleBE(0)); + assert.strictEqual(-Infinity, buffer.readDoubleLE(0)); } diff --git a/test/parallel/test-readfloat.js b/test/parallel/test-readfloat.js index 533b7caa8f1047..0175c195b8ec22 100644 --- a/test/parallel/test-readfloat.js +++ b/test/parallel/test-readfloat.js @@ -9,62 +9,62 @@ const assert = require('assert'); * Test (32 bit) float */ function test(clazz) { - var buffer = new clazz(4); + const buffer = new clazz(4); buffer[0] = 0; buffer[1] = 0; buffer[2] = 0x80; buffer[3] = 0x3f; - assert.equal(4.600602988224807e-41, buffer.readFloatBE(0)); - assert.equal(1, buffer.readFloatLE(0)); + assert.strictEqual(4.600602988224807e-41, buffer.readFloatBE(0)); + assert.strictEqual(1, buffer.readFloatLE(0)); buffer[0] = 0; buffer[1] = 0; buffer[2] = 0; buffer[3] = 0xc0; - assert.equal(2.6904930515036488e-43, buffer.readFloatBE(0)); - assert.equal(-2, buffer.readFloatLE(0)); + assert.strictEqual(2.6904930515036488e-43, buffer.readFloatBE(0)); + assert.strictEqual(-2, buffer.readFloatLE(0)); buffer[0] = 0xff; buffer[1] = 0xff; buffer[2] = 0x7f; buffer[3] = 0x7f; assert.ok(isNaN(buffer.readFloatBE(0))); - assert.equal(3.4028234663852886e+38, buffer.readFloatLE(0)); + assert.strictEqual(3.4028234663852886e+38, buffer.readFloatLE(0)); buffer[0] = 0xab; buffer[1] = 0xaa; buffer[2] = 0xaa; buffer[3] = 0x3e; - assert.equal(-1.2126478207002966e-12, buffer.readFloatBE(0)); - assert.equal(0.3333333432674408, buffer.readFloatLE(0)); + assert.strictEqual(-1.2126478207002966e-12, buffer.readFloatBE(0)); + assert.strictEqual(0.3333333432674408, buffer.readFloatLE(0)); buffer[0] = 0; buffer[1] = 0; buffer[2] = 0; buffer[3] = 0; - assert.equal(0, buffer.readFloatBE(0)); - assert.equal(0, buffer.readFloatLE(0)); - assert.equal(false, 1 / buffer.readFloatLE(0) < 0); + assert.strictEqual(0, buffer.readFloatBE(0)); + assert.strictEqual(0, buffer.readFloatLE(0)); + assert.strictEqual(false, 1 / buffer.readFloatLE(0) < 0); buffer[3] = 0x80; - assert.equal(1.793662034335766e-43, buffer.readFloatBE(0)); - assert.equal(0, buffer.readFloatLE(0)); - assert.equal(true, 1 / buffer.readFloatLE(0) < 0); + assert.strictEqual(1.793662034335766e-43, buffer.readFloatBE(0)); + assert.strictEqual(0, buffer.readFloatLE(0)); + assert.strictEqual(true, 1 / buffer.readFloatLE(0) < 0); buffer[0] = 0; buffer[1] = 0; buffer[2] = 0x80; buffer[3] = 0x7f; - assert.equal(4.609571298396486e-41, buffer.readFloatBE(0)); - assert.equal(Infinity, buffer.readFloatLE(0)); + assert.strictEqual(4.609571298396486e-41, buffer.readFloatBE(0)); + assert.strictEqual(Infinity, buffer.readFloatLE(0)); buffer[0] = 0; buffer[1] = 0; buffer[2] = 0x80; buffer[3] = 0xff; - assert.equal(4.627507918739843e-41, buffer.readFloatBE(0)); - assert.equal(-Infinity, buffer.readFloatLE(0)); + assert.strictEqual(4.627507918739843e-41, buffer.readFloatBE(0)); + assert.strictEqual(-Infinity, buffer.readFloatLE(0)); } diff --git a/test/parallel/test-readint.js b/test/parallel/test-readint.js index c068ddcb6c554a..97faa1e7d58d77 100644 --- a/test/parallel/test-readint.js +++ b/test/parallel/test-readint.js @@ -9,37 +9,37 @@ const assert = require('assert'); * Test 8 bit signed integers */ function test8(clazz) { - var data = new clazz(4); + const data = new clazz(4); data[0] = 0x23; - assert.equal(0x23, data.readInt8(0)); + assert.strictEqual(0x23, data.readInt8(0)); data[0] = 0xff; - assert.equal(-1, data.readInt8(0)); + assert.strictEqual(-1, data.readInt8(0)); data[0] = 0x87; data[1] = 0xab; data[2] = 0x7c; data[3] = 0xef; - assert.equal(-121, data.readInt8(0)); - assert.equal(-85, data.readInt8(1)); - assert.equal(124, data.readInt8(2)); - assert.equal(-17, data.readInt8(3)); + assert.strictEqual(-121, data.readInt8(0)); + assert.strictEqual(-85, data.readInt8(1)); + assert.strictEqual(124, data.readInt8(2)); + assert.strictEqual(-17, data.readInt8(3)); } function test16(clazz) { - var buffer = new clazz(6); + const buffer = new clazz(6); buffer[0] = 0x16; buffer[1] = 0x79; - assert.equal(0x1679, buffer.readInt16BE(0)); - assert.equal(0x7916, buffer.readInt16LE(0)); + assert.strictEqual(0x1679, buffer.readInt16BE(0)); + assert.strictEqual(0x7916, buffer.readInt16LE(0)); buffer[0] = 0xff; buffer[1] = 0x80; - assert.equal(-128, buffer.readInt16BE(0)); - assert.equal(-32513, buffer.readInt16LE(0)); + assert.strictEqual(-128, buffer.readInt16BE(0)); + assert.strictEqual(-32513, buffer.readInt16LE(0)); /* test offset with weenix */ buffer[0] = 0x77; @@ -48,35 +48,35 @@ function test16(clazz) { buffer[3] = 0x6e; buffer[4] = 0x69; buffer[5] = 0x78; - assert.equal(0x7765, buffer.readInt16BE(0)); - assert.equal(0x6565, buffer.readInt16BE(1)); - assert.equal(0x656e, buffer.readInt16BE(2)); - assert.equal(0x6e69, buffer.readInt16BE(3)); - assert.equal(0x6978, buffer.readInt16BE(4)); - assert.equal(0x6577, buffer.readInt16LE(0)); - assert.equal(0x6565, buffer.readInt16LE(1)); - assert.equal(0x6e65, buffer.readInt16LE(2)); - assert.equal(0x696e, buffer.readInt16LE(3)); - assert.equal(0x7869, buffer.readInt16LE(4)); + assert.strictEqual(0x7765, buffer.readInt16BE(0)); + assert.strictEqual(0x6565, buffer.readInt16BE(1)); + assert.strictEqual(0x656e, buffer.readInt16BE(2)); + assert.strictEqual(0x6e69, buffer.readInt16BE(3)); + assert.strictEqual(0x6978, buffer.readInt16BE(4)); + assert.strictEqual(0x6577, buffer.readInt16LE(0)); + assert.strictEqual(0x6565, buffer.readInt16LE(1)); + assert.strictEqual(0x6e65, buffer.readInt16LE(2)); + assert.strictEqual(0x696e, buffer.readInt16LE(3)); + assert.strictEqual(0x7869, buffer.readInt16LE(4)); } function test32(clazz) { - var buffer = new clazz(6); + const buffer = new clazz(6); buffer[0] = 0x43; buffer[1] = 0x53; buffer[2] = 0x16; buffer[3] = 0x79; - assert.equal(0x43531679, buffer.readInt32BE(0)); - assert.equal(0x79165343, buffer.readInt32LE(0)); + assert.strictEqual(0x43531679, buffer.readInt32BE(0)); + assert.strictEqual(0x79165343, buffer.readInt32LE(0)); buffer[0] = 0xff; buffer[1] = 0xfe; buffer[2] = 0xef; buffer[3] = 0xfa; - assert.equal(-69638, buffer.readInt32BE(0)); - assert.equal(-84934913, buffer.readInt32LE(0)); + assert.strictEqual(-69638, buffer.readInt32BE(0)); + assert.strictEqual(-84934913, buffer.readInt32LE(0)); buffer[0] = 0x42; buffer[1] = 0xc3; @@ -84,12 +84,12 @@ function test32(clazz) { buffer[3] = 0xa9; buffer[4] = 0x36; buffer[5] = 0x17; - assert.equal(0x42c395a9, buffer.readInt32BE(0)); - assert.equal(-1013601994, buffer.readInt32BE(1)); - assert.equal(-1784072681, buffer.readInt32BE(2)); - assert.equal(-1449802942, buffer.readInt32LE(0)); - assert.equal(917083587, buffer.readInt32LE(1)); - assert.equal(389458325, buffer.readInt32LE(2)); + assert.strictEqual(0x42c395a9, buffer.readInt32BE(0)); + assert.strictEqual(-1013601994, buffer.readInt32BE(1)); + assert.strictEqual(-1784072681, buffer.readInt32BE(2)); + assert.strictEqual(-1449802942, buffer.readInt32LE(0)); + assert.strictEqual(917083587, buffer.readInt32LE(1)); + assert.strictEqual(389458325, buffer.readInt32LE(2)); } diff --git a/test/parallel/test-readline-interface.js b/test/parallel/test-readline-interface.js index 59b75cd0a86231..53c132dc30ec25 100644 --- a/test/parallel/test-readline-interface.js +++ b/test/parallel/test-readline-interface.js @@ -19,8 +19,8 @@ FakeInput.prototype.write = function() {}; FakeInput.prototype.end = function() {}; function isWarned(emitter) { - for (var name in emitter) { - var listeners = emitter[name]; + for (const name in emitter) { + const listeners = emitter[name]; if (listeners.warned) return true; } return false; @@ -55,14 +55,14 @@ function isWarned(emitter) { } [ true, false ].forEach(function(terminal) { - var fi; - var rli; - var called; + let fi; + let rli; + let called; // disable history fi = new FakeInput(); rli = new readline.Interface({ input: fi, output: fi, terminal: terminal, - historySize: 0 }); + historySize: 0 }); assert.strictEqual(rli.historySize, 0); fi.emit('data', 'asdf\n'); @@ -84,7 +84,7 @@ function isWarned(emitter) { called = false; rli.on('line', function(line) { called = true; - assert.equal(line, 'asdf'); + assert.strictEqual(line, 'asdf'); }); fi.emit('data', 'asdf\n'); assert.ok(called); @@ -95,7 +95,7 @@ function isWarned(emitter) { called = false; rli.on('line', function(line) { called = true; - assert.equal(line, ''); + assert.strictEqual(line, ''); }); fi.emit('data', '\n'); assert.ok(called); @@ -117,7 +117,7 @@ function isWarned(emitter) { called = false; rli.on('line', function(line) { called = true; - assert.equal(line, 'a'); + assert.strictEqual(line, 'a'); }); fi.emit('data', 'a'); assert.ok(!called); @@ -128,14 +128,14 @@ function isWarned(emitter) { // sending multiple newlines at once fi = new FakeInput(); rli = new readline.Interface({ input: fi, output: fi, terminal: terminal }); - var expectedLines = ['foo', 'bar', 'baz']; - var callCount = 0; + let expectedLines = ['foo', 'bar', 'baz']; + let callCount = 0; rli.on('line', function(line) { - assert.equal(line, expectedLines[callCount]); + assert.strictEqual(line, expectedLines[callCount]); callCount++; }); fi.emit('data', expectedLines.join('\n') + '\n'); - assert.equal(callCount, expectedLines.length); + assert.strictEqual(callCount, expectedLines.length); rli.close(); // sending multiple newlines at once that does not end with a new line @@ -144,11 +144,11 @@ function isWarned(emitter) { expectedLines = ['foo', 'bar', 'baz', 'bat']; callCount = 0; rli.on('line', function(line) { - assert.equal(line, expectedLines[callCount]); + assert.strictEqual(line, expectedLines[callCount]); callCount++; }); fi.emit('data', expectedLines.join('\n')); - assert.equal(callCount, expectedLines.length - 1); + assert.strictEqual(callCount, expectedLines.length - 1); rli.close(); // sending multiple newlines at once that does not end with a new(empty) @@ -158,7 +158,7 @@ function isWarned(emitter) { expectedLines = ['foo', 'bar', 'baz', '']; callCount = 0; rli.on('line', function(line) { - assert.equal(line, expectedLines[callCount]); + assert.strictEqual(line, expectedLines[callCount]); callCount++; }); rli.on('close', function() { @@ -166,7 +166,7 @@ function isWarned(emitter) { }); fi.emit('data', expectedLines.join('\n')); fi.emit('end'); - assert.equal(callCount, expectedLines.length); + assert.strictEqual(callCount, expectedLines.length); rli.close(); // sending multiple newlines at once that does not end with a new line @@ -178,11 +178,11 @@ function isWarned(emitter) { expectedLines = ['foo', 'bar', 'baz', 'bat']; callCount = 0; rli.on('line', function(line) { - assert.equal(line, expectedLines[callCount]); + assert.strictEqual(line, expectedLines[callCount]); callCount++; }); fi.emit('data', expectedLines.join('\r\n')); - assert.equal(callCount, expectedLines.length - 1); + assert.strictEqual(callCount, expectedLines.length - 1); rli.close(); // \r\n should emit one line event when split across multiple writes. @@ -191,14 +191,14 @@ function isWarned(emitter) { expectedLines = ['foo', 'bar', 'baz', 'bat']; callCount = 0; rli.on('line', function(line) { - assert.equal(line, expectedLines[callCount]); + assert.strictEqual(line, expectedLines[callCount]); callCount++; }); expectedLines.forEach(function(line) { fi.emit('data', line + '\r'); fi.emit('data', '\n'); }); - assert.equal(callCount, expectedLines.length); + assert.strictEqual(callCount, expectedLines.length); rli.close(); // \r should behave like \n when alone @@ -207,11 +207,11 @@ function isWarned(emitter) { expectedLines = ['foo', 'bar', 'baz', 'bat']; callCount = 0; rli.on('line', function(line) { - assert.equal(line, expectedLines[callCount]); + assert.strictEqual(line, expectedLines[callCount]); callCount++; }); fi.emit('data', expectedLines.join('\r')); - assert.equal(callCount, expectedLines.length - 1); + assert.strictEqual(callCount, expectedLines.length - 1); rli.close(); // \r at start of input should output blank line @@ -220,11 +220,11 @@ function isWarned(emitter) { expectedLines = ['', 'foo' ]; callCount = 0; rli.on('line', function(line) { - assert.equal(line, expectedLines[callCount]); + assert.strictEqual(line, expectedLines[callCount]); callCount++; }); fi.emit('data', '\rfoo\r'); - assert.equal(callCount, expectedLines.length); + assert.strictEqual(callCount, expectedLines.length); rli.close(); // Emit two line events when the delay @@ -245,7 +245,7 @@ function isWarned(emitter) { fi.emit('data', '\r'); setTimeout(common.mustCall(() => { fi.emit('data', '\n'); - assert.equal(callCount, 2); + assert.strictEqual(callCount, 2); rli.close(); }), delay * 2); } @@ -256,7 +256,7 @@ function isWarned(emitter) { rli = new readline.Interface({ input: fi, output: fi, terminal: true }); called = false; rli.on('line', function(line) { - assert.equal(line, '\t'); + assert.strictEqual(line, '\t'); assert.strictEqual(called, false); called = true; }); @@ -267,7 +267,7 @@ function isWarned(emitter) { // \t does not become part of the input when there is a completer function fi = new FakeInput(); - var completer = function(line) { + const completer = function(line) { return [[], line]; }; rli = new readline.Interface({ @@ -278,11 +278,11 @@ function isWarned(emitter) { }); called = false; rli.on('line', function(line) { - assert.equal(line, 'foo'); + assert.strictEqual(line, 'foo'); assert.strictEqual(called, false); called = true; }); - for (var character of '\tfo\to\t') { + for (const character of '\tfo\to\t') { fi.emit('data', character); } fi.emit('data', '\n'); @@ -306,27 +306,27 @@ function isWarned(emitter) { }); // sending a multi-byte utf8 char over multiple writes - var buf = Buffer.from('☮', 'utf8'); + const buf = Buffer.from('☮', 'utf8'); fi = new FakeInput(); rli = new readline.Interface({ input: fi, output: fi, terminal: terminal }); callCount = 0; rli.on('line', function(line) { callCount++; - assert.equal(line, buf.toString('utf8')); + assert.strictEqual(line, buf.toString('utf8')); }); [].forEach.call(buf, function(i) { fi.emit('data', Buffer.from([i])); }); - assert.equal(callCount, 0); + assert.strictEqual(callCount, 0); fi.emit('data', '\n'); - assert.equal(callCount, 1); + assert.strictEqual(callCount, 1); rli.close(); // Regression test for repl freeze, #1968: // check that nothing fails if 'keypress' event throws. fi = new FakeInput(); rli = new readline.Interface({ input: fi, output: fi, terminal: true }); - var keys = []; + const keys = []; fi.on('keypress', function(key) { keys.push(key); if (key === 'X') { @@ -337,7 +337,7 @@ function isWarned(emitter) { fi.emit('data', 'fooX'); } catch (e) { } fi.emit('data', 'bar'); - assert.equal(keys.join(''), 'fooXbar'); + assert.strictEqual(keys.join(''), 'fooXbar'); rli.close(); // calling readline without `new` @@ -346,7 +346,7 @@ function isWarned(emitter) { called = false; rli.on('line', function(line) { called = true; - assert.equal(line, 'asdf'); + assert.strictEqual(line, 'asdf'); }); fi.emit('data', 'asdf\n'); assert.ok(called); @@ -360,9 +360,9 @@ function isWarned(emitter) { rli.question(expectedLines[0], function() { rli.close(); }); - var cursorPos = rli._getCursorPos(); - assert.equal(cursorPos.rows, 0); - assert.equal(cursorPos.cols, expectedLines[0].length); + let cursorPos = rli._getCursorPos(); + assert.strictEqual(cursorPos.rows, 0); + assert.strictEqual(cursorPos.cols, expectedLines[0].length); rli.close(); // sending a multi-line question @@ -373,8 +373,8 @@ function isWarned(emitter) { rli.close(); }); cursorPos = rli._getCursorPos(); - assert.equal(cursorPos.rows, expectedLines.length - 1); - assert.equal(cursorPos.cols, expectedLines.slice(-1)[0].length); + assert.strictEqual(cursorPos.rows, expectedLines.length - 1); + assert.strictEqual(cursorPos.cols, expectedLines.slice(-1)[0].length); rli.close(); } @@ -384,17 +384,21 @@ function isWarned(emitter) { }); // wide characters should be treated as two columns. - assert.equal(internalReadline.isFullWidthCodePoint('a'.charCodeAt(0)), false); - assert.equal(internalReadline.isFullWidthCodePoint('あ'.charCodeAt(0)), true); - assert.equal(internalReadline.isFullWidthCodePoint('谢'.charCodeAt(0)), true); - assert.equal(internalReadline.isFullWidthCodePoint('고'.charCodeAt(0)), true); - assert.equal(internalReadline.isFullWidthCodePoint(0x1f251), true); - assert.equal(internalReadline.getStringWidth('abcde'), 5); - assert.equal(internalReadline.getStringWidth('古池や'), 6); - assert.equal(internalReadline.getStringWidth('ノード.js'), 9); - assert.equal(internalReadline.getStringWidth('你好'), 4); - assert.equal(internalReadline.getStringWidth('안녕하세요'), 10); - assert.equal(internalReadline.getStringWidth('A\ud83c\ude00BC'), 5); + assert.strictEqual(internalReadline.isFullWidthCodePoint('a'.charCodeAt(0)), + false); + assert.strictEqual(internalReadline.isFullWidthCodePoint('あ'.charCodeAt(0)), + true); + assert.strictEqual(internalReadline.isFullWidthCodePoint('谢'.charCodeAt(0)), + true); + assert.strictEqual(internalReadline.isFullWidthCodePoint('고'.charCodeAt(0)), + true); + assert.strictEqual(internalReadline.isFullWidthCodePoint(0x1f251), true); + assert.strictEqual(internalReadline.getStringWidth('abcde'), 5); + assert.strictEqual(internalReadline.getStringWidth('古池や'), 6); + assert.strictEqual(internalReadline.getStringWidth('ノード.js'), 9); + assert.strictEqual(internalReadline.getStringWidth('你好'), 4); + assert.strictEqual(internalReadline.getStringWidth('안녕하세요'), 10); + assert.strictEqual(internalReadline.getStringWidth('A\ud83c\ude00BC'), 5); // check if vt control chars are stripped assert.strictEqual( @@ -413,22 +417,25 @@ function isWarned(emitter) { internalReadline.stripVTControlCharacters('> '), '> ' ); - assert.equal(internalReadline.getStringWidth('\u001b[31m> \u001b[39m'), 2); - assert.equal(internalReadline.getStringWidth('\u001b[31m> \u001b[39m> '), 4); - assert.equal(internalReadline.getStringWidth('\u001b[31m\u001b[39m'), 0); - assert.equal(internalReadline.getStringWidth('> '), 2); + assert.strictEqual(internalReadline + .getStringWidth('\u001b[31m> \u001b[39m'), 2); + assert.strictEqual(internalReadline + .getStringWidth('\u001b[31m> \u001b[39m> '), 4); + assert.strictEqual(internalReadline + .getStringWidth('\u001b[31m\u001b[39m'), 0); + assert.strictEqual(internalReadline.getStringWidth('> '), 2); assert.deepStrictEqual(fi.listeners(terminal ? 'keypress' : 'data'), []); // check EventEmitter memory leak - for (var i = 0; i < 12; i++) { - var rl = readline.createInterface({ + for (let i = 0; i < 12; i++) { + const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.close(); - assert.equal(isWarned(process.stdin._events), false); - assert.equal(isWarned(process.stdout._events), false); + assert.strictEqual(isWarned(process.stdin._events), false); + assert.strictEqual(isWarned(process.stdout._events), false); } //can create a new readline Interface with a null output arugument @@ -438,7 +445,7 @@ function isWarned(emitter) { called = false; rli.on('line', function(line) { called = true; - assert.equal(line, 'asdf'); + assert.strictEqual(line, 'asdf'); }); fi.emit('data', 'asdf\n'); assert.ok(called); diff --git a/test/parallel/test-readline-keys.js b/test/parallel/test-readline-keys.js index 6bbbb2e918470d..f45bcb97e02d55 100644 --- a/test/parallel/test-readline-keys.js +++ b/test/parallel/test-readline-keys.js @@ -1,10 +1,10 @@ 'use strict'; -require('../common'); -var PassThrough = require('stream').PassThrough; -var assert = require('assert'); -var inherits = require('util').inherits; -var extend = require('util')._extend; -var Interface = require('readline').Interface; +const common = require('../common'); +const PassThrough = require('stream').PassThrough; +const assert = require('assert'); +const inherits = require('util').inherits; +const extend = require('util')._extend; +const Interface = require('readline').Interface; function FakeInput() { @@ -13,11 +13,11 @@ function FakeInput() { inherits(FakeInput, PassThrough); -var fi = new FakeInput(); -var fo = new FakeInput(); +const fi = new FakeInput(); +const fo = new FakeInput(); new Interface({ input: fi, output: fo, terminal: true }); -var keys = []; +let keys = []; fi.on('keypress', function(s, k) { keys.push(k); }); @@ -55,7 +55,7 @@ function addTest(sequences, expectedKeys) { const addKeyIntervalTest = (sequences, expectedKeys, interval = 550, assertDelay = 550) => { - return (next) => () => { + const fn = common.mustCall((next) => () => { if (!Array.isArray(sequences)) { sequences = [ sequences ]; @@ -84,7 +84,8 @@ const addKeyIntervalTest = (sequences, expectedKeys, interval = 550, } }; emitKeys(sequences); - }; + }); + return fn; }; // regular alphanumerics diff --git a/test/parallel/test-readline-set-raw-mode.js b/test/parallel/test-readline-set-raw-mode.js index acf0dc44a631c7..389f014bc3e19a 100644 --- a/test/parallel/test-readline-set-raw-mode.js +++ b/test/parallel/test-readline-set-raw-mode.js @@ -1,18 +1,18 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var readline = require('readline'); -var Stream = require('stream'); +const assert = require('assert'); +const readline = require('readline'); +const Stream = require('stream'); -var stream = new Stream(); -var expectedRawMode = true; -var rawModeCalled = false; -var resumeCalled = false; -var pauseCalled = false; +const stream = new Stream(); +let expectedRawMode = true; +let rawModeCalled = false; +let resumeCalled = false; +let pauseCalled = false; stream.setRawMode = function(mode) { rawModeCalled = true; - assert.equal(mode, expectedRawMode); + assert.strictEqual(mode, expectedRawMode); }; stream.resume = function() { resumeCalled = true; @@ -23,7 +23,7 @@ stream.pause = function() { // when the "readline" starts in "terminal" mode, // then setRawMode(true) should be called -var rli = readline.createInterface({ +const rli = readline.createInterface({ input: stream, output: stream, terminal: true @@ -66,4 +66,4 @@ assert(pauseCalled); assert.deepStrictEqual(stream.listeners('keypress'), []); // one data listener for the keypress events. -assert.equal(stream.listeners('data').length, 1); +assert.strictEqual(stream.listeners('data').length, 1); diff --git a/test/parallel/test-readline-undefined-columns.js b/test/parallel/test-readline-undefined-columns.js index 5f8a1c02d3a90b..14895ac637429c 100644 --- a/test/parallel/test-readline-undefined-columns.js +++ b/test/parallel/test-readline-undefined-columns.js @@ -20,7 +20,7 @@ readline.createInterface({ } }); -var output = ''; +let output = ''; oStream.on('data', function(data) { output += data; diff --git a/test/parallel/test-readuint.js b/test/parallel/test-readuint.js index 9fcaf45603fd83..d1507a81b5188a 100644 --- a/test/parallel/test-readuint.js +++ b/test/parallel/test-readuint.js @@ -14,19 +14,19 @@ const assert = require('assert'); * - Correctly interpreting values that are beyond the signed range as unsigned */ function test8(clazz) { - var data = new clazz(4); + const data = new clazz(4); data[0] = 23; data[1] = 23; data[2] = 23; data[3] = 23; - assert.equal(23, data.readUInt8(0)); - assert.equal(23, data.readUInt8(1)); - assert.equal(23, data.readUInt8(2)); - assert.equal(23, data.readUInt8(3)); + assert.strictEqual(23, data.readUInt8(0)); + assert.strictEqual(23, data.readUInt8(1)); + assert.strictEqual(23, data.readUInt8(2)); + assert.strictEqual(23, data.readUInt8(3)); data[0] = 255; /* If it became a signed int, would be -1 */ - assert.equal(255, data.readUInt8(0)); + assert.strictEqual(255, data.readUInt8(0)); } @@ -39,23 +39,23 @@ function test8(clazz) { * - Correctly interpreting values that are beyond the signed range as unsigned */ function test16(clazz) { - var data = new clazz(4); + const data = new clazz(4); data[0] = 0; data[1] = 0x23; data[2] = 0x42; data[3] = 0x3f; - assert.equal(0x23, data.readUInt16BE(0)); - assert.equal(0x2342, data.readUInt16BE(1)); - assert.equal(0x423f, data.readUInt16BE(2)); - assert.equal(0x2300, data.readUInt16LE(0)); - assert.equal(0x4223, data.readUInt16LE(1)); - assert.equal(0x3f42, data.readUInt16LE(2)); + assert.strictEqual(0x23, data.readUInt16BE(0)); + assert.strictEqual(0x2342, data.readUInt16BE(1)); + assert.strictEqual(0x423f, data.readUInt16BE(2)); + assert.strictEqual(0x2300, data.readUInt16LE(0)); + assert.strictEqual(0x4223, data.readUInt16LE(1)); + assert.strictEqual(0x3f42, data.readUInt16LE(2)); data[0] = 0xfe; data[1] = 0xfe; - assert.equal(0xfefe, data.readUInt16BE(0)); - assert.equal(0xfefe, data.readUInt16LE(0)); + assert.strictEqual(0xfefe, data.readUInt16BE(0)); + assert.strictEqual(0xfefe, data.readUInt16LE(0)); } @@ -67,7 +67,7 @@ function test16(clazz) { * - Correctly interpreting values that are beyond the signed range as unsigned */ function test32(clazz) { - var data = new clazz(8); + const data = new clazz(8); data[0] = 0x32; data[1] = 0x65; @@ -75,12 +75,12 @@ function test32(clazz) { data[3] = 0x56; data[4] = 0x23; data[5] = 0xff; - assert.equal(0x32654256, data.readUInt32BE(0)); - assert.equal(0x65425623, data.readUInt32BE(1)); - assert.equal(0x425623ff, data.readUInt32BE(2)); - assert.equal(0x56426532, data.readUInt32LE(0)); - assert.equal(0x23564265, data.readUInt32LE(1)); - assert.equal(0xff235642, data.readUInt32LE(2)); + assert.strictEqual(0x32654256, data.readUInt32BE(0)); + assert.strictEqual(0x65425623, data.readUInt32BE(1)); + assert.strictEqual(0x425623ff, data.readUInt32BE(2)); + assert.strictEqual(0x56426532, data.readUInt32LE(0)); + assert.strictEqual(0x23564265, data.readUInt32LE(1)); + assert.strictEqual(0xff235642, data.readUInt32LE(2)); } diff --git a/test/parallel/test-ref-unref-return.js b/test/parallel/test-ref-unref-return.js index 89ac52d2bcaa50..aec2fff5ce2271 100644 --- a/test/parallel/test-ref-unref-return.js +++ b/test/parallel/test-ref-unref-return.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var net = require('net'); -var dgram = require('dgram'); +const assert = require('assert'); +const net = require('net'); +const dgram = require('dgram'); assert.ok((new net.Server()).ref() instanceof net.Server); assert.ok((new net.Server()).unref() instanceof net.Server); diff --git a/test/parallel/test-regress-GH-1531.js b/test/parallel/test-regress-GH-1531.js index fa0781c2e2fa72..5189e50929105c 100644 --- a/test/parallel/test-regress-GH-1531.js +++ b/test/parallel/test-regress-GH-1531.js @@ -1,20 +1,20 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = https.createServer(options, function(req, res) { +const server = https.createServer(options, function(req, res) { res.writeHead(200); res.end('hello world\n'); }); diff --git a/test/parallel/test-regress-GH-1899.js b/test/parallel/test-regress-GH-1899.js index 7ce83e00092449..a072bc551a5c4f 100644 --- a/test/parallel/test-regress-GH-1899.js +++ b/test/parallel/test-regress-GH-1899.js @@ -1,19 +1,19 @@ 'use strict'; const common = require('../common'); -var path = require('path'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const path = require('path'); +const assert = require('assert'); +const spawn = require('child_process').spawn; -var child = spawn(process.argv[0], [ +const child = spawn(process.argv[0], [ path.join(common.fixturesDir, 'GH-1899-output.js') ]); -var output = ''; +let output = ''; child.stdout.on('data', function(data) { output += data; }); child.on('exit', function(code, signal) { - assert.equal(code, 0); - assert.equal(output, 'hello, world!\n'); + assert.strictEqual(code, 0); + assert.strictEqual(output, 'hello, world!\n'); }); diff --git a/test/parallel/test-regress-GH-2245.js b/test/parallel/test-regress-GH-2245.js index 7558529f9fc50c..c5b0ae4982d993 100644 --- a/test/parallel/test-regress-GH-2245.js +++ b/test/parallel/test-regress-GH-2245.js @@ -1,6 +1,6 @@ /* eslint-disable strict */ require('../common'); -var assert = require('assert'); +const assert = require('assert'); /* In Node.js 0.10, a bug existed that caused strict functions to not capture @@ -10,7 +10,7 @@ their environment when evaluated. When run in 0.10 `test()` fails with a function test() { - var code = [ + const code = [ 'var foo = {m: 1};', '', 'function bar() {', diff --git a/test/parallel/test-regress-GH-3542.js b/test/parallel/test-regress-GH-3542.js index 8db34e72157371..cc0285f7475697 100644 --- a/test/parallel/test-regress-GH-3542.js +++ b/test/parallel/test-regress-GH-3542.js @@ -11,7 +11,7 @@ if (!common.isWindows) { } function test(p) { - var result = fs.realpathSync(p); + const result = fs.realpathSync(p); assert.strictEqual(result.toLowerCase(), path.resolve(p).toLowerCase()); fs.realpath(p, common.mustCall(function(err, result) { diff --git a/test/parallel/test-regress-GH-3739.js b/test/parallel/test-regress-GH-3739.js index aef54c3ea6c7c4..b845a2b7f18f9a 100644 --- a/test/parallel/test-regress-GH-3739.js +++ b/test/parallel/test-regress-GH-3739.js @@ -5,13 +5,13 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); -var dir = path.resolve(common.tmpDir); +let dir = path.resolve(common.tmpDir); // Make sure that the tmp directory is clean common.refreshTmpDir(); // Make a long path. -for (var i = 0; i < 50; i++) { +for (let i = 0; i < 50; i++) { dir = dir + '/1234567890'; try { fs.mkdirSync(dir, '0777'); @@ -27,5 +27,5 @@ assert(common.fileExists(dir), 'Directory is not accessible'); // Test if file exists asynchronously fs.access(dir, function(err) { - assert(!err, 'Directory is not accessible'); + assert.ifError(err); }); diff --git a/test/parallel/test-regress-GH-4948.js b/test/parallel/test-regress-GH-4948.js index 0317778787c2e2..196c973cd093e3 100644 --- a/test/parallel/test-regress-GH-4948.js +++ b/test/parallel/test-regress-GH-4948.js @@ -2,10 +2,10 @@ // https://github.com/joyent/node/issues/4948 require('../common'); -var http = require('http'); +const http = require('http'); -var reqCount = 0; -var server = http.createServer(function(serverReq, serverRes) { +let reqCount = 0; +const server = http.createServer(function(serverReq, serverRes) { if (reqCount) { serverRes.end(); server.close(); @@ -16,8 +16,8 @@ var server = http.createServer(function(serverReq, serverRes) { // normally the use case would be to call an external site // does not require connecting locally or to itself to fail - var r = http.request({hostname: 'localhost', - port: this.address().port}, function(res) { + const r = http.request({hostname: 'localhost', + port: this.address().port}, function(res) { // required, just needs to be in the client response somewhere serverRes.end(); @@ -31,9 +31,9 @@ var server = http.createServer(function(serverReq, serverRes) { serverRes.write('some data'); }).listen(0, function() { // simulate a client request that closes early - var net = require('net'); + const net = require('net'); - var sock = new net.Socket(); + const sock = new net.Socket(); sock.connect(this.address().port, 'localhost'); sock.on('connect', function() { diff --git a/test/parallel/test-regress-GH-5051.js b/test/parallel/test-regress-GH-5051.js index a86d0943d313fe..f2562bd7eb8020 100644 --- a/test/parallel/test-regress-GH-5051.js +++ b/test/parallel/test-regress-GH-5051.js @@ -13,8 +13,8 @@ agent.maxSockets = 0; // localAddress is used when naming requests / sockets // while using the Legacy API agent.addRequest(req, 'localhost', common.PORT, '127.0.0.1'); -assert.equal(Object.keys(agent.requests).length, 1); -assert.equal( +assert.strictEqual(Object.keys(agent.requests).length, 1); +assert.strictEqual( Object.keys(agent.requests)[0], 'localhost:' + common.PORT + ':127.0.0.1'); @@ -25,7 +25,7 @@ agent.addRequest(req, { localAddress: '127.0.0.1', path: '/foo' }); -assert.equal(Object.keys(agent.requests).length, 1); -assert.equal( +assert.strictEqual(Object.keys(agent.requests).length, 1); +assert.strictEqual( Object.keys(agent.requests)[0], 'localhost:' + common.PORT + ':127.0.0.1'); diff --git a/test/parallel/test-regress-GH-5727.js b/test/parallel/test-regress-GH-5727.js index 3f52c55e7aaca6..5fe9776d9b30fc 100644 --- a/test/parallel/test-regress-GH-5727.js +++ b/test/parallel/test-regress-GH-5727.js @@ -10,7 +10,7 @@ net.Server().listen(common.PORT, function() { const address = this.address(); const key = `${address.family.slice(-1)}:${address.address}:${common.PORT}`; - assert.equal(this._connectionKey, key); + assert.strictEqual(this._connectionKey, key); this.close(); }); diff --git a/test/parallel/test-regress-GH-5927.js b/test/parallel/test-regress-GH-5927.js index a23c947c320cfc..7f55356a15e027 100644 --- a/test/parallel/test-regress-GH-5927.js +++ b/test/parallel/test-regress-GH-5927.js @@ -1,20 +1,20 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var readline = require('readline'); +const assert = require('assert'); +const readline = require('readline'); -var rl = readline.createInterface(process.stdin, process.stdout); +const rl = readline.createInterface(process.stdin, process.stdout); rl.resume(); -var hasPaused = false; +let hasPaused = false; -var origPause = rl.pause; +const origPause = rl.pause; rl.pause = function() { hasPaused = true; origPause.apply(this, arguments); }; -var origSetRawMode = rl._setRawMode; +const origSetRawMode = rl._setRawMode; rl._setRawMode = function(mode) { assert.ok(hasPaused); origSetRawMode.apply(this, arguments); diff --git a/test/parallel/test-regress-GH-6235.js b/test/parallel/test-regress-GH-6235.js index 0bf9b8965d1184..10092884670980 100644 --- a/test/parallel/test-regress-GH-6235.js +++ b/test/parallel/test-regress-GH-6235.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); assert.doesNotThrow(function() { require('vm').runInNewContext('"use strict"; var v = 1; v = 2'); diff --git a/test/parallel/test-regress-GH-746.js b/test/parallel/test-regress-GH-746.js index 8bfcb0c3e22f12..9a6e0e8980f311 100644 --- a/test/parallel/test-regress-GH-746.js +++ b/test/parallel/test-regress-GH-746.js @@ -3,11 +3,11 @@ // This is a regression test for GH-746. const common = require('../common'); -var net = require('net'); +const net = require('net'); process.stdin.destroy(); -var server = net.createServer(common.mustCall(function(socket) { +const server = net.createServer(common.mustCall(function(socket) { console.log('accepted'); socket.end(); server.close(); diff --git a/test/parallel/test-regress-GH-7511.js b/test/parallel/test-regress-GH-7511.js index d18a3ae02c0d03..a7ce8311d7237f 100644 --- a/test/parallel/test-regress-GH-7511.js +++ b/test/parallel/test-regress-GH-7511.js @@ -4,7 +4,7 @@ const assert = require('assert'); const vm = require('vm'); assert.doesNotThrow(function() { - var context = vm.createContext({ process: process }); - var result = vm.runInContext('process.env["PATH"]', context); - assert.notEqual(undefined, result); + const context = vm.createContext({ process: process }); + const result = vm.runInContext('process.env["PATH"]', context); + assert.notStrictEqual(undefined, result); }); diff --git a/test/parallel/test-regress-GH-819.js b/test/parallel/test-regress-GH-819.js index 20ca75c793ce24..719d4398251eab 100644 --- a/test/parallel/test-regress-GH-819.js +++ b/test/parallel/test-regress-GH-819.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var net = require('net'); +const net = require('net'); // Connect to something that we need to DNS resolve -var c = net.createConnection(80, 'google.com'); +const c = net.createConnection(80, 'google.com'); c.destroy(); diff --git a/test/parallel/test-regress-GH-node-9326.js b/test/parallel/test-regress-GH-node-9326.js index bb55050d2ce55e..78565e3f596594 100644 --- a/test/parallel/test-regress-GH-node-9326.js +++ b/test/parallel/test-regress-GH-node-9326.js @@ -1,14 +1,14 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var child_process = require('child_process'); +const assert = require('assert'); +const child_process = require('child_process'); // NOTE: Was crashing on FreeBSD -var cp = child_process.spawn(process.execPath, [ +const cp = child_process.spawn(process.execPath, [ '-e', 'process.kill(process.pid, "SIGINT")' ]); cp.on('exit', function(code) { - assert.notEqual(code, 0); + assert.notStrictEqual(code, 0); }); diff --git a/test/parallel/test-repl-.save.load.js b/test/parallel/test-repl-.save.load.js index 247f359e829d25..449dd28e90d59e 100644 --- a/test/parallel/test-repl-.save.load.js +++ b/test/parallel/test-repl-.save.load.js @@ -1,24 +1,24 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var join = require('path').join; -var fs = require('fs'); +const assert = require('assert'); +const join = require('path').join; +const fs = require('fs'); common.refreshTmpDir(); -var repl = require('repl'); +const repl = require('repl'); -var works = [['inner.one'], 'inner.o']; +const works = [['inner.one'], 'inner.o']; const putIn = new common.ArrayStream(); -var testMe = repl.start('', putIn); +const testMe = repl.start('', putIn); -var testFile = [ +const testFile = [ 'var top = function() {', 'var inner = {one:1};' ]; -var saveFileName = join(common.tmpDir, 'test.save.js'); +const saveFileName = join(common.tmpDir, 'test.save.js'); // input some data putIn.run(testFile); @@ -27,7 +27,8 @@ putIn.run(testFile); putIn.run(['.save ' + saveFileName]); // the file should have what I wrote -assert.equal(fs.readFileSync(saveFileName, 'utf8'), testFile.join('\n') + '\n'); +assert.strictEqual(fs.readFileSync(saveFileName, 'utf8'), testFile.join('\n') + + '\n'); { // save .editor mode code @@ -69,12 +70,12 @@ testMe.complete('inner.o', function(error, data) { // clear the REPL putIn.run(['.clear']); -var loadFile = join(common.tmpDir, 'file.does.not.exist'); +let loadFile = join(common.tmpDir, 'file.does.not.exist'); // should not break putIn.write = function(data) { // make sure I get a failed to load message and not some crazy error - assert.equal(data, 'Failed to load:' + loadFile + '\n'); + assert.strictEqual(data, 'Failed to load:' + loadFile + '\n'); // eat me to avoid work putIn.write = function() {}; }; @@ -83,7 +84,8 @@ putIn.run(['.load ' + loadFile]); // throw error on loading directory loadFile = common.tmpDir; putIn.write = function(data) { - assert.equal(data, 'Failed to load:' + loadFile + ' is not a valid file\n'); + assert.strictEqual(data, 'Failed to load:' + loadFile + + ' is not a valid file\n'); putIn.write = function() {}; }; putIn.run(['.load ' + loadFile]); @@ -98,7 +100,7 @@ const invalidFileName = join(common.tmpDir, '\0\0\0\0\0'); // should not break putIn.write = function(data) { // make sure I get a failed to save message and not some other error - assert.equal(data, 'Failed to save:' + invalidFileName + '\n'); + assert.strictEqual(data, 'Failed to save:' + invalidFileName + '\n'); // reset to no-op putIn.write = function() {}; }; diff --git a/test/parallel/test-repl-autolibs.js b/test/parallel/test-repl-autolibs.js index 15f779d3b12269..ce108ba2aa859f 100644 --- a/test/parallel/test-repl-autolibs.js +++ b/test/parallel/test-repl-autolibs.js @@ -1,8 +1,8 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var util = require('util'); -var repl = require('repl'); +const assert = require('assert'); +const util = require('util'); +const repl = require('repl'); // This test adds global variables common.globalCheck = false; @@ -13,15 +13,16 @@ repl.start('', putIn, null, true); test1(); function test1() { - var gotWrite = false; + let gotWrite = false; putIn.write = function(data) { gotWrite = true; if (data.length) { // inspect output matches repl output - assert.equal(data, util.inspect(require('fs'), null, 2, false) + '\n'); + assert.strictEqual(data, util.inspect(require('fs'), null, 2, false) + + '\n'); // globally added lib matches required lib - assert.equal(global.fs, require('fs')); + assert.strictEqual(global.fs, require('fs')); test2(); } }; @@ -31,17 +32,17 @@ function test1() { } function test2() { - var gotWrite = false; + let gotWrite = false; putIn.write = function(data) { gotWrite = true; if (data.length) { // repl response error message - assert.equal(data, '{}\n'); + assert.strictEqual(data, '{}\n'); // original value wasn't overwritten - assert.equal(val, global.url); + assert.strictEqual(val, global.url); } }; - var val = {}; + const val = {}; global.url = val; assert(!gotWrite); putIn.run(['url']); diff --git a/test/parallel/test-repl-console.js b/test/parallel/test-repl-console.js index 98cb958cac8e68..f37dde008044ed 100644 --- a/test/parallel/test-repl-console.js +++ b/test/parallel/test-repl-console.js @@ -6,7 +6,7 @@ const repl = require('repl'); // Create a dummy stream that does nothing const stream = new common.ArrayStream(); -var r = repl.start({ +const r = repl.start({ input: stream, output: stream, useGlobal: false diff --git a/test/parallel/test-repl-definecommand.js b/test/parallel/test-repl-definecommand.js index 6c0c75bca8db79..07732d534e9def 100644 --- a/test/parallel/test-repl-definecommand.js +++ b/test/parallel/test-repl-definecommand.js @@ -6,7 +6,7 @@ const stream = require('stream'); const assert = require('assert'); const repl = require('repl'); -var output = ''; +let output = ''; const inputStream = new stream.PassThrough(); const outputStream = new stream.PassThrough(); outputStream.on('data', function(d) { diff --git a/test/parallel/test-repl-domain.js b/test/parallel/test-repl-domain.js index 3cc88b75f72428..19c85980cdcc72 100644 --- a/test/parallel/test-repl-domain.js +++ b/test/parallel/test-repl-domain.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); -var repl = require('repl'); +const repl = require('repl'); const putIn = new common.ArrayStream(); repl.start('', putIn); diff --git a/test/parallel/test-repl-end-emits-exit.js b/test/parallel/test-repl-end-emits-exit.js index 7f2c4b9eb2893f..c62a51c9626e24 100644 --- a/test/parallel/test-repl-end-emits-exit.js +++ b/test/parallel/test-repl-end-emits-exit.js @@ -9,7 +9,7 @@ let regularExit = 0; const stream = new common.ArrayStream(); function testTerminalMode() { - var r1 = repl.start({ + const r1 = repl.start({ input: stream, output: stream, terminal: true @@ -28,7 +28,7 @@ function testTerminalMode() { } function testRegularMode() { - var r2 = repl.start({ + const r2 = repl.start({ input: stream, output: stream, terminal: false @@ -45,8 +45,8 @@ function testRegularMode() { } process.on('exit', function() { - assert.equal(terminalExit, 1); - assert.equal(regularExit, 1); + assert.strictEqual(terminalExit, 1); + assert.strictEqual(regularExit, 1); }); diff --git a/test/parallel/test-repl-envvars.js b/test/parallel/test-repl-envvars.js index b08f6cbaf621e6..bd4e1fc9afb679 100644 --- a/test/parallel/test-repl-envvars.js +++ b/test/parallel/test-repl-envvars.js @@ -45,15 +45,15 @@ function run(test) { }; REPL.createInternalRepl(env, opts, function(err, repl) { - if (err) throw err; + assert.ifError(err); // The REPL registers 'module' and 'require' globals common.allowGlobals(repl.context.module, repl.context.require); - assert.equal(expected.terminal, repl.terminal, - 'Expected ' + inspect(expected) + ' with ' + inspect(env)); - assert.equal(expected.useColors, repl.useColors, - 'Expected ' + inspect(expected) + ' with ' + inspect(env)); + assert.strictEqual(expected.terminal, repl.terminal, 'Expected ' + + inspect(expected) + ' with ' + inspect(env)); + assert.strictEqual(expected.useColors, repl.useColors, 'Expected ' + + inspect(expected) + ' with ' + inspect(env)); repl.close(); }); } diff --git a/test/parallel/test-repl-harmony.js b/test/parallel/test-repl-harmony.js index a5928800381cfe..743bbe4fabfcd1 100644 --- a/test/parallel/test-repl-harmony.js +++ b/test/parallel/test-repl-harmony.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var spawn = require('child_process').spawn; -var args = ['-i']; -var child = spawn(process.execPath, args); +const spawn = require('child_process').spawn; +const args = ['-i']; +const child = spawn(process.execPath, args); -var input = '(function(){"use strict"; const y=1;y=2})()\n'; -var expectOut = /^> TypeError: Assignment to constant variable.\n/; +const input = '(function(){"use strict"; const y=1;y=2})()\n'; +const expectOut = /^> TypeError: Assignment to constant variable.\n/; child.stderr.setEncoding('utf8'); child.stderr.on('data', function(c) { @@ -15,7 +15,7 @@ child.stderr.on('data', function(c) { }); child.stdout.setEncoding('utf8'); -var out = ''; +let out = ''; child.stdout.on('data', function(c) { out += c; }); diff --git a/test/parallel/test-repl-history-perm.js b/test/parallel/test-repl-history-perm.js index 4a374cb0ab12e8..25d2aa63ff0086 100644 --- a/test/parallel/test-repl-history-perm.js +++ b/test/parallel/test-repl-history-perm.js @@ -18,7 +18,7 @@ const Duplex = require('stream').Duplex; // Invoking the REPL should create a repl history file at the specified path // and mode 600. -var stream = new Duplex(); +const stream = new Duplex(); stream.pause = stream.resume = function() {}; // ends immediately stream._read = function() { @@ -33,8 +33,7 @@ common.refreshTmpDir(); const replHistoryPath = path.join(common.tmpDir, '.node_repl_history'); const checkResults = common.mustCall(function(err, r) { - if (err) - throw err; + assert.ifError(err); // The REPL registers 'module' and 'require' globals common.allowGlobals(r.context.module, r.context.require); diff --git a/test/parallel/test-repl-null.js b/test/parallel/test-repl-null.js index 337e194447d1f8..66d09b28f28b84 100644 --- a/test/parallel/test-repl-null.js +++ b/test/parallel/test-repl-null.js @@ -3,7 +3,7 @@ require('../common'); const repl = require('repl'); const assert = require('assert'); -var replserver = new repl.REPLServer(); +const replserver = new repl.REPLServer(); replserver._inTemplateLiteral = true; diff --git a/test/parallel/test-repl-options.js b/test/parallel/test-repl-options.js index 70244802dd0f45..03db110aca6dbc 100644 --- a/test/parallel/test-repl-options.js +++ b/test/parallel/test-repl-options.js @@ -9,35 +9,35 @@ common.globalCheck = false; const stream = new common.ArrayStream(); // 1, mostly defaults -var r1 = repl.start({ +const r1 = repl.start({ input: stream, output: stream, terminal: true }); -assert.equal(r1.input, stream); -assert.equal(r1.output, stream); -assert.equal(r1.input, r1.inputStream); -assert.equal(r1.output, r1.outputStream); -assert.equal(r1.terminal, true); -assert.equal(r1.useColors, r1.terminal); -assert.equal(r1.useGlobal, false); -assert.equal(r1.ignoreUndefined, false); -assert.equal(r1.replMode, repl.REPL_MODE_SLOPPY); -assert.equal(r1.historySize, 30); +assert.strictEqual(r1.input, stream); +assert.strictEqual(r1.output, stream); +assert.strictEqual(r1.input, r1.inputStream); +assert.strictEqual(r1.output, r1.outputStream); +assert.strictEqual(r1.terminal, true); +assert.strictEqual(r1.useColors, r1.terminal); +assert.strictEqual(r1.useGlobal, false); +assert.strictEqual(r1.ignoreUndefined, false); +assert.strictEqual(r1.replMode, repl.REPL_MODE_SLOPPY); +assert.strictEqual(r1.historySize, 30); // test r1 for backwards compact -assert.equal(r1.rli.input, stream); -assert.equal(r1.rli.output, stream); -assert.equal(r1.rli.input, r1.inputStream); -assert.equal(r1.rli.output, r1.outputStream); -assert.equal(r1.rli.terminal, true); -assert.equal(r1.useColors, r1.rli.terminal); +assert.strictEqual(r1.rli.input, stream); +assert.strictEqual(r1.rli.output, stream); +assert.strictEqual(r1.rli.input, r1.inputStream); +assert.strictEqual(r1.rli.output, r1.outputStream); +assert.strictEqual(r1.rli.terminal, true); +assert.strictEqual(r1.useColors, r1.rli.terminal); // 2 function writer() {} function evaler() {} -var r2 = repl.start({ +const r2 = repl.start({ input: stream, output: stream, terminal: false, @@ -48,26 +48,26 @@ var r2 = repl.start({ writer: writer, replMode: repl.REPL_MODE_STRICT }); -assert.equal(r2.input, stream); -assert.equal(r2.output, stream); -assert.equal(r2.input, r2.inputStream); -assert.equal(r2.output, r2.outputStream); -assert.equal(r2.terminal, false); -assert.equal(r2.useColors, true); -assert.equal(r2.useGlobal, true); -assert.equal(r2.ignoreUndefined, true); -assert.equal(r2.writer, writer); -assert.equal(r2.replMode, repl.REPL_MODE_STRICT); +assert.strictEqual(r2.input, stream); +assert.strictEqual(r2.output, stream); +assert.strictEqual(r2.input, r2.inputStream); +assert.strictEqual(r2.output, r2.outputStream); +assert.strictEqual(r2.terminal, false); +assert.strictEqual(r2.useColors, true); +assert.strictEqual(r2.useGlobal, true); +assert.strictEqual(r2.ignoreUndefined, true); +assert.strictEqual(r2.writer, writer); +assert.strictEqual(r2.replMode, repl.REPL_MODE_STRICT); // test r2 for backwards compact -assert.equal(r2.rli.input, stream); -assert.equal(r2.rli.output, stream); -assert.equal(r2.rli.input, r2.inputStream); -assert.equal(r2.rli.output, r2.outputStream); -assert.equal(r2.rli.terminal, false); +assert.strictEqual(r2.rli.input, stream); +assert.strictEqual(r2.rli.output, stream); +assert.strictEqual(r2.rli.input, r2.inputStream); +assert.strictEqual(r2.rli.output, r2.outputStream); +assert.strictEqual(r2.rli.terminal, false); // testing out "magic" replMode -var r3 = repl.start({ +const r3 = repl.start({ input: stream, output: stream, writer: writer, @@ -75,8 +75,8 @@ var r3 = repl.start({ historySize: 50 }); -assert.equal(r3.replMode, repl.REPL_MODE_MAGIC); -assert.equal(r3.historySize, 50); +assert.strictEqual(r3.replMode, repl.REPL_MODE_MAGIC); +assert.strictEqual(r3.historySize, 50); // Verify that defaults are used when no arguments are provided const r4 = repl.start(); diff --git a/test/parallel/test-repl-persistent-history.js b/test/parallel/test-repl-persistent-history.js index 25fdef81a8d5ab..2b0ceac530a65f 100644 --- a/test/parallel/test-repl-persistent-history.js +++ b/test/parallel/test-repl-persistent-history.js @@ -178,7 +178,7 @@ const tests = [ const numtests = tests.length; -var testsNotRan = tests.length; +let testsNotRan = tests.length; process.on('beforeExit', () => assert.strictEqual(testsNotRan, 0) diff --git a/test/parallel/test-repl-require-cache.js b/test/parallel/test-repl-require-cache.js index 8a5d384935efd4..4ccabe473cdbe8 100644 --- a/test/parallel/test-repl-require-cache.js +++ b/test/parallel/test-repl-require-cache.js @@ -6,8 +6,8 @@ const repl = require('repl'); // https://github.com/joyent/node/issues/3226 require.cache.something = 1; -assert.equal(require.cache.something, 1); +assert.strictEqual(require.cache.something, 1); repl.start({ useGlobal: false }).close(); -assert.equal(require.cache.something, 1); +assert.strictEqual(require.cache.something, 1); diff --git a/test/parallel/test-repl-require.js b/test/parallel/test-repl-require.js index 9dc3b51de7a88a..25aaac47a4ed36 100644 --- a/test/parallel/test-repl-require.js +++ b/test/parallel/test-repl-require.js @@ -18,7 +18,7 @@ const host = common.localhostIPv4; const port = 0; const options = { host, port }; -var answer = ''; +let answer = ''; server.listen(options, function() { options.port = this.address().port; const conn = net.connect(options); diff --git a/test/parallel/test-repl-setprompt.js b/test/parallel/test-repl-setprompt.js index 2708a3e6af5448..8dcc4fe94452da 100644 --- a/test/parallel/test-repl-setprompt.js +++ b/test/parallel/test-repl-setprompt.js @@ -4,18 +4,18 @@ const assert = require('assert'); const spawn = require('child_process').spawn; const os = require('os'); -var args = [ +const args = [ '-e', 'var e = new (require("repl")).REPLServer("foo.. "); e.context.e = e;', ]; -var p = 'bar.. '; +const p = 'bar.. '; -var child = spawn(process.execPath, args); +const child = spawn(process.execPath, args); child.stdout.setEncoding('utf8'); -var data = ''; +let data = ''; child.stdout.on('data', function(d) { data += d; }); child.stdin.end(`e.setPrompt("${p}");${os.EOL}`); @@ -23,6 +23,6 @@ child.stdin.end(`e.setPrompt("${p}");${os.EOL}`); child.on('close', function(code, signal) { assert.strictEqual(code, 0); assert.ok(!signal); - var lines = data.split(/\n/); + const lines = data.split(/\n/); assert.strictEqual(lines.pop(), p); }); diff --git a/test/parallel/test-repl-syntax-error-handling.js b/test/parallel/test-repl-syntax-error-handling.js index 10166b4f06a692..9014f9a02f22be 100644 --- a/test/parallel/test-repl-syntax-error-handling.js +++ b/test/parallel/test-repl-syntax-error-handling.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); switch (process.argv[2]) { case 'child': @@ -12,8 +12,8 @@ switch (process.argv[2]) { } function parent() { - var spawn = require('child_process').spawn; - var child = spawn(process.execPath, [__filename, 'child']); + const spawn = require('child_process').spawn; + const child = spawn(process.execPath, [__filename, 'child']); child.stderr.setEncoding('utf8'); child.stderr.on('data', function(c) { @@ -22,12 +22,12 @@ function parent() { }); child.stdout.setEncoding('utf8'); - var out = ''; + let out = ''; child.stdout.on('data', function(c) { out += c; }); child.stdout.on('end', function() { - assert.equal(out, '10\n'); + assert.strictEqual(out, '10\n'); console.log('ok - got expected output'); }); @@ -38,11 +38,12 @@ function parent() { } function child() { - var vm = require('vm'); + const vm = require('vm'); + let caught; try { vm.runInThisContext('haf!@##&$!@$*!@', { displayErrors: false }); } catch (er) { - var caught = true; + caught = true; } assert(caught); vm.runInThisContext('console.log(10)', { displayErrors: false }); diff --git a/test/parallel/test-repl-tab-complete.js b/test/parallel/test-repl-tab-complete.js index b5f1d3856d3c71..1a1a2a8628809c 100644 --- a/test/parallel/test-repl-tab-complete.js +++ b/test/parallel/test-repl-tab-complete.js @@ -17,9 +17,9 @@ function getNoResultsFunction() { }); } -var works = [['inner.one'], 'inner.o']; +const works = [['inner.one'], 'inner.o']; const putIn = new common.ArrayStream(); -var testMe = repl.start('', putIn); +const testMe = repl.start('', putIn); // Some errors are passed to the domain, but do not callback testMe._domain.on('error', function(err) { @@ -165,7 +165,7 @@ testMe.complete('str.len', common.mustCall(function(error, data) { putIn.run(['.clear']); // tab completion should not break on spaces -var spaceTimeout = setTimeout(function() { +const spaceTimeout = setTimeout(function() { throw new Error('timeout'); }, 1000); @@ -231,6 +231,7 @@ putIn.run([ testMe.complete('proxy.', common.mustCall(function(error, data) { assert.strictEqual(error, null); + assert(Array.isArray(data)); })); // Make sure tab completion does not include integer members of an Array @@ -290,7 +291,7 @@ const testNonGlobal = repl.start({ }); const builtins = [['Infinity', '', 'Int16Array', 'Int32Array', - 'Int8Array'], 'I']; + 'Int8Array'], 'I']; if (common.hasIntl) { builtins[0].push('Intl'); @@ -307,9 +308,7 @@ const testCustomCompleterSyncMode = repl.start({ input: putIn, output: putIn, completer: function completer(line) { - const hits = customCompletions.filter((c) => { - return c.indexOf(line) === 0; - }); + const hits = customCompletions.filter((c) => c.startsWith(line)); // Show all completions if none found. return [hits.length ? hits : customCompletions, line]; } @@ -339,9 +338,7 @@ const testCustomCompleterAsyncMode = repl.start({ input: putIn, output: putIn, completer: function completer(line, callback) { - const hits = customCompletions.filter((c) => { - return c.indexOf(line) === 0; - }); + const hits = customCompletions.filter((c) => c.startsWith(line)); // Show all completions if none found. callback(null, [hits.length ? hits : customCompletions, line]); } diff --git a/test/parallel/test-repl-tab.js b/test/parallel/test-repl-tab.js index c075b8d4f1125f..92168b2e1df56f 100644 --- a/test/parallel/test-repl-tab.js +++ b/test/parallel/test-repl-tab.js @@ -1,17 +1,18 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var repl = require('repl'); -var zlib = require('zlib'); +const assert = require('assert'); +const repl = require('repl'); +const zlib = require('zlib'); // just use builtin stream inherited from Duplex -var putIn = zlib.createGzip(); -var testMe = repl.start('', putIn, function(cmd, context, filename, callback) { +const putIn = zlib.createGzip(); +const testMe = repl.start('', putIn, function(cmd, context, filename, + callback) { callback(null, cmd); }); testMe._domain.on('error', common.fail); testMe.complete('', function(err, results) { - assert.equal(err, null); + assert.strictEqual(err, null); }); diff --git a/test/parallel/test-repl-underscore.js b/test/parallel/test-repl-underscore.js index 97fc508ad9eee4..91f32223e180b9 100644 --- a/test/parallel/test-repl-underscore.js +++ b/test/parallel/test-repl-underscore.js @@ -8,6 +8,7 @@ const stream = require('stream'); testSloppyMode(); testStrictMode(); testResetContext(); +testResetContextGlobal(); testMagicMode(); function testSloppyMode() { @@ -131,7 +132,28 @@ function testResetContext() { ]); } -function initRepl(mode) { +function testResetContextGlobal() { + const r = initRepl(repl.REPL_MODE_STRICT, true); + + r.write(`_ = 10; // explicitly set to 10 + _; // 10 from user input + .clear // No output because useGlobal is true + _; // remains 10 + `); + + assertOutput(r.output, [ + 'Expression assignment to _ now disabled.', + '10', + '10', + '10', + ]); + + // delete globals leaked by REPL when `useGlobal` is `true` + delete global.module; + delete global.require; +} + +function initRepl(mode, useGlobal) { const inputStream = new stream.PassThrough(); const outputStream = new stream.PassThrough(); outputStream.accum = ''; @@ -146,7 +168,8 @@ function initRepl(mode) { useColors: false, terminal: false, prompt: '', - replMode: mode + replMode: mode, + useGlobal: useGlobal }); } diff --git a/test/parallel/test-repl-unexpected-token-recoverable.js b/test/parallel/test-repl-unexpected-token-recoverable.js index 84668c8657c453..0f783d3dcaf27b 100644 --- a/test/parallel/test-repl-unexpected-token-recoverable.js +++ b/test/parallel/test-repl-unexpected-token-recoverable.js @@ -3,16 +3,16 @@ * This is a regression test for https://github.com/joyent/node/issues/8874. */ require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var spawn = require('child_process').spawn; +const spawn = require('child_process').spawn; // use -i to force node into interactive mode, despite stdout not being a TTY -var args = [ '-i' ]; -var child = spawn(process.execPath, args); +const args = [ '-i' ]; +const child = spawn(process.execPath, args); -var input = 'var foo = "bar\\\nbaz"'; +const input = 'var foo = "bar\\\nbaz"'; // Match '...' as well since it marks a multi-line statement -var expectOut = /^> ... undefined\n/; +const expectOut = /^> ... undefined\n/; child.stderr.setEncoding('utf8'); child.stderr.on('data', function(c) { @@ -20,7 +20,7 @@ child.stderr.on('data', function(c) { }); child.stdout.setEncoding('utf8'); -var out = ''; +let out = ''; child.stdout.on('data', function(c) { out += c; }); diff --git a/test/parallel/test-require-cache.js b/test/parallel/test-require-cache.js index 247590197d6126..437dd80e581e38 100644 --- a/test/parallel/test-require-cache.js +++ b/test/parallel/test-require-cache.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); { const relativePath = '../fixtures/semicolon'; diff --git a/test/parallel/test-require-extensions-same-filename-as-dir-trailing-slash.js b/test/parallel/test-require-extensions-same-filename-as-dir-trailing-slash.js index 1837a17bab0add..85fc7ec913482d 100644 --- a/test/parallel/test-require-extensions-same-filename-as-dir-trailing-slash.js +++ b/test/parallel/test-require-extensions-same-filename-as-dir-trailing-slash.js @@ -1,10 +1,10 @@ /* eslint-disable max-len */ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var content = require(common.fixturesDir + +const content = require(common.fixturesDir + '/json-with-directory-name-module/module-stub/one-trailing-slash/two/three.js'); -assert.notEqual(content.rocko, 'artischocko'); -assert.equal(content, 'hello from module-stub!'); +assert.notStrictEqual(content.rocko, 'artischocko'); +assert.strictEqual(content, 'hello from module-stub!'); diff --git a/test/parallel/test-require-process.js b/test/parallel/test-require-process.js index 4e5821add13183..f2a3ac89a862fe 100644 --- a/test/parallel/test-require-process.js +++ b/test/parallel/test-require-process.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var nativeProcess = require('process'); +const nativeProcess = require('process'); assert.strictEqual(nativeProcess, process, 'require("process") should return global process reference'); diff --git a/test/parallel/test-require-symlink.js b/test/parallel/test-require-symlink.js index 0792bc13bb70a7..4e74606bedeed6 100644 --- a/test/parallel/test-require-symlink.js +++ b/test/parallel/test-require-symlink.js @@ -11,13 +11,15 @@ const util = require('util'); common.refreshTmpDir(); const linkTarget = path.join(common.fixturesDir, - '/module-require-symlink/node_modules/dep2/'); + '/module-require-symlink/node_modules/dep2/'); -const linkDir = path.join(common.fixturesDir, - '/module-require-symlink/node_modules/dep1/node_modules/dep2'); +const linkDir = path.join( + common.fixturesDir, + '/module-require-symlink/node_modules/dep1/node_modules/dep2' +); const linkScriptTarget = path.join(common.fixturesDir, - '/module-require-symlink/symlinked.js'); + '/module-require-symlink/symlinked.js'); const linkScript = path.join(common.tmpDir, 'module-require-symlink.js'); diff --git a/test/parallel/test-require-unicode.js b/test/parallel/test-require-unicode.js index 0bccf06916c326..93a8787cdfe7c8 100644 --- a/test/parallel/test-require-unicode.js +++ b/test/parallel/test-require-unicode.js @@ -12,5 +12,5 @@ fs.mkdirSync(dirname); fs.writeFileSync(path.join(dirname, 'file.js'), 'module.exports = 42;'); fs.writeFileSync(path.join(dirname, 'package.json'), JSON.stringify({ name: 'test', main: 'file.js' })); -assert.equal(require(dirname), 42); -assert.equal(require(path.join(dirname, 'file.js')), 42); +assert.strictEqual(require(dirname), 42); +assert.strictEqual(require(path.join(dirname, 'file.js')), 42); diff --git a/test/parallel/test-sigint-infinite-loop.js b/test/parallel/test-sigint-infinite-loop.js index ecd64802acb627..30eb98ecb8a265 100644 --- a/test/parallel/test-sigint-infinite-loop.js +++ b/test/parallel/test-sigint-infinite-loop.js @@ -3,14 +3,14 @@ // Ref(http): // groups.google.com/group/nodejs-dev/browse_thread/thread/e20f2f8df0296d3f const common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const assert = require('assert'); +const spawn = require('child_process').spawn; console.log('start'); -var c = spawn(process.execPath, ['-e', 'while(true) { console.log("hi"); }']); +const c = spawn(process.execPath, ['-e', 'while(true) { console.log("hi"); }']); -var sentKill = false; +let sentKill = false; c.stdout.on('data', function(s) { // Prevent race condition: diff --git a/test/parallel/test-signal-handler.js b/test/parallel/test-signal-handler.js index 079c72a9e56a8a..b796ebb11d211c 100644 --- a/test/parallel/test-signal-handler.js +++ b/test/parallel/test-signal-handler.js @@ -18,7 +18,7 @@ process.on('SIGUSR1', common.mustCall(function() { }, 5); })); -var i = 0; +let i = 0; setInterval(function() { console.log('running process...' + ++i); diff --git a/test/parallel/test-signal-safety.js b/test/parallel/test-signal-safety.js index 7938ae04d6591b..34722b712f8889 100644 --- a/test/parallel/test-signal-safety.js +++ b/test/parallel/test-signal-safety.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var Signal = process.binding('signal_wrap').Signal; +const assert = require('assert'); +const Signal = process.binding('signal_wrap').Signal; // Test Signal `this` safety // https://github.com/joyent/node/issues/6690 assert.throws(function() { - var s = new Signal(); - var nots = { start: s.start }; + const s = new Signal(); + const nots = { start: s.start }; nots.start(9); }, TypeError); diff --git a/test/parallel/test-socket-write-after-fin-error.js b/test/parallel/test-socket-write-after-fin-error.js index 480d5d2edc321e..37d042b4c6031a 100644 --- a/test/parallel/test-socket-write-after-fin-error.js +++ b/test/parallel/test-socket-write-after-fin-error.js @@ -1,20 +1,20 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // This is similar to simple/test-socket-write-after-fin, except that // we don't set allowHalfOpen. Then we write after the client has sent // a FIN, and this is an error. However, the standard "write after end" // message is too vague, and doesn't actually tell you what happens. -var net = require('net'); -var serverData = ''; -var gotServerEnd = false; -var clientData = ''; -var gotClientEnd = false; -var gotServerError = false; +const net = require('net'); +let serverData = ''; +let gotServerEnd = false; +let clientData = ''; +let gotClientEnd = false; +let gotServerError = false; -var server = net.createServer(function(sock) { +const server = net.createServer(function(sock) { sock.setEncoding('utf8'); sock.on('error', function(er) { console.error(er.code + ': ' + er.message); @@ -32,7 +32,7 @@ var server = net.createServer(function(sock) { server.close(); }); server.listen(0, function() { - var sock = net.connect(this.address().port); + const sock = net.connect(this.address().port); sock.setEncoding('utf8'); sock.on('data', function(c) { clientData += c; @@ -43,13 +43,13 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.equal(clientData, ''); - assert.equal(serverData, 'hello1hello2hello3\nTHUNDERMUSCLE!'); + assert.strictEqual(clientData, ''); + assert.strictEqual(serverData, 'hello1hello2hello3\nTHUNDERMUSCLE!'); assert(gotClientEnd); assert(gotServerEnd); assert(gotServerError); - assert.equal(gotServerError.code, 'EPIPE'); - assert.notEqual(gotServerError.message, 'write after end'); + assert.strictEqual(gotServerError.code, 'EPIPE'); + assert.notStrictEqual(gotServerError.message, 'write after end'); console.log('ok'); }); diff --git a/test/parallel/test-socket-write-after-fin.js b/test/parallel/test-socket-write-after-fin.js index 70f0d9bf843f9b..c8ff56871734af 100644 --- a/test/parallel/test-socket-write-after-fin.js +++ b/test/parallel/test-socket-write-after-fin.js @@ -1,13 +1,13 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const assert = require('assert'); +const net = require('net'); const expected = 'hello1hello2hello3\nTHUNDERMUSCLE!'; -var server = net.createServer({ +const server = net.createServer({ allowHalfOpen: true }, common.mustCall(function(sock) { - var serverData = ''; + let serverData = ''; sock.setEncoding('utf8'); sock.on('data', function(c) { @@ -20,8 +20,8 @@ var server = net.createServer({ })); })); server.listen(0, common.mustCall(function() { - var sock = net.connect(this.address().port); - var clientData = ''; + const sock = net.connect(this.address().port); + let clientData = ''; sock.setEncoding('utf8'); sock.on('data', function(c) { diff --git a/test/parallel/test-spawn-cmd-named-pipe.js b/test/parallel/test-spawn-cmd-named-pipe.js index c463bf6140053f..b4264880165d39 100644 --- a/test/parallel/test-spawn-cmd-named-pipe.js +++ b/test/parallel/test-spawn-cmd-named-pipe.js @@ -43,7 +43,7 @@ if (!process.argv[2]) { } const args = ['/c', process.execPath, __filename, 'child', - '<', stdinPipeName, '>', stdoutPipeName]; + '<', stdinPipeName, '>', stdoutPipeName]; const child = spawn(comspec, args); diff --git a/test/parallel/test-stdin-child-proc.js b/test/parallel/test-stdin-child-proc.js index 35ae0c99d3c8ff..5359edc53a42ba 100644 --- a/test/parallel/test-stdin-child-proc.js +++ b/test/parallel/test-stdin-child-proc.js @@ -9,5 +9,5 @@ const cp = child_process.spawn(process.execPath, [path.resolve(__dirname, 'test-stdin-pause-resume.js')]); cp.on('exit', common.mustCall((code) => { - assert.equal(code, 0); + assert.strictEqual(code, 0); })); diff --git a/test/parallel/test-stdin-pipe-resume.js b/test/parallel/test-stdin-pipe-resume.js index cb288070450a1f..e9000933a37cfa 100644 --- a/test/parallel/test-stdin-pipe-resume.js +++ b/test/parallel/test-stdin-pipe-resume.js @@ -1,20 +1,20 @@ 'use strict'; // This tests that piping stdin will cause it to resume() as well. require('../common'); -var assert = require('assert'); +const assert = require('assert'); if (process.argv[2] === 'child') { process.stdin.pipe(process.stdout); } else { - var spawn = require('child_process').spawn; - var buffers = []; - var child = spawn(process.execPath, [__filename, 'child']); + const spawn = require('child_process').spawn; + const buffers = []; + const child = spawn(process.execPath, [__filename, 'child']); child.stdout.on('data', function(c) { buffers.push(c); }); child.stdout.on('close', function() { - var b = Buffer.concat(buffers).toString(); - assert.equal(b, 'Hello, world\n'); + const b = Buffer.concat(buffers).toString(); + assert.strictEqual(b, 'Hello, world\n'); console.log('ok'); }); child.stdin.write('Hel'); diff --git a/test/parallel/test-stdin-script-child.js b/test/parallel/test-stdin-script-child.js index 091c5cb29ad296..a8a161686eeeef 100644 --- a/test/parallel/test-stdin-script-child.js +++ b/test/parallel/test-stdin-script-child.js @@ -9,7 +9,7 @@ const child = spawn(process.execPath, [], { }) }); const wanted = child.pid + '\n'; -var found = ''; +let found = ''; child.stdout.setEncoding('utf8'); child.stdout.on('data', function(c) { diff --git a/test/parallel/test-stdio-closed.js b/test/parallel/test-stdio-closed.js index a85467f76a6d0f..98e4f980d50dd6 100644 --- a/test/parallel/test-stdio-closed.js +++ b/test/parallel/test-stdio-closed.js @@ -2,6 +2,7 @@ const common = require('../common'); const assert = require('assert'); const spawn = require('child_process').spawn; +const fs = require('fs'); if (common.isWindows) { common.skip('platform not supported.'); @@ -9,21 +10,7 @@ if (common.isWindows) { } if (process.argv[2] === 'child') { - try { - process.stdout.write('stdout', function() { - try { - process.stderr.write('stderr', function() { - process.exit(42); - }); - } catch (e) { - process.exit(84); - } - }); - } catch (e) { - assert.strictEqual(e.code, 'EBADF'); - assert.strictEqual(e.message, 'EBADF: bad file descriptor, write'); - process.exit(126); - } + [0, 1, 2].forEach((i) => assert.doesNotThrow(() => fs.fstatSync(i))); return; } @@ -32,5 +19,5 @@ const cmd = `"${process.execPath}" "${__filename}" child 1>&- 2>&-`; const proc = spawn('/bin/sh', ['-c', cmd], { stdio: 'inherit' }); proc.on('exit', common.mustCall(function(exitCode) { - assert.strictEqual(exitCode, common.isAix ? 126 : 42); + assert.strictEqual(exitCode, 0); })); diff --git a/test/parallel/test-stdio-readable-writable.js b/test/parallel/test-stdio-readable-writable.js index 7b9b69d309aec5..0bc7fe269b3303 100644 --- a/test/parallel/test-stdio-readable-writable.js +++ b/test/parallel/test-stdio-readable-writable.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); assert(process.stdout.writable); assert(!process.stdout.readable); diff --git a/test/parallel/test-stdout-cannot-be-closed-child-process-pipe.js b/test/parallel/test-stdout-cannot-be-closed-child-process-pipe.js index a138108fae7e01..d19b522e290ba9 100644 --- a/test/parallel/test-stdout-cannot-be-closed-child-process-pipe.js +++ b/test/parallel/test-stdout-cannot-be-closed-child-process-pipe.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); if (process.argv[2] === 'child') process.stdout.end('foo'); @@ -8,10 +8,10 @@ else parent(); function parent() { - var spawn = require('child_process').spawn; - var child = spawn(process.execPath, [__filename, 'child']); - var out = ''; - var err = ''; + const spawn = require('child_process').spawn; + const child = spawn(process.execPath, [__filename, 'child']); + let out = ''; + let err = ''; child.stdout.setEncoding('utf8'); child.stderr.setEncoding('utf8'); @@ -25,7 +25,7 @@ function parent() { child.on('close', function(code, signal) { assert(code); - assert.equal(out, 'foo'); + assert.strictEqual(out, 'foo'); assert(/process\.stdout cannot be closed/.test(err)); console.log('ok'); }); diff --git a/test/parallel/test-stdout-stderr-reading.js b/test/parallel/test-stdout-stderr-reading.js index e154d41b6bb8d1..11cdcc390768a3 100644 --- a/test/parallel/test-stdout-stderr-reading.js +++ b/test/parallel/test-stdout-stderr-reading.js @@ -1,10 +1,10 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); // verify that stdout is never read from. -var net = require('net'); -var read = net.Socket.prototype.read; +const net = require('net'); +const read = net.Socket.prototype.read; net.Socket.prototype.read = function() { if (this.fd === 1) @@ -20,11 +20,11 @@ else parent(); function parent() { - var spawn = require('child_process').spawn; - var node = process.execPath; + const spawn = require('child_process').spawn; + const node = process.execPath; - var c1 = spawn(node, [__filename, 'child']); - var c1out = ''; + const c1 = spawn(node, [__filename, 'child']); + let c1out = ''; c1.stdout.setEncoding('utf8'); c1.stdout.on('data', function(chunk) { c1out += chunk; @@ -36,12 +36,12 @@ function parent() { c1.on('close', common.mustCall(function(code, signal) { assert(!code); assert(!signal); - assert.equal(c1out, 'ok\n'); + assert.strictEqual(c1out, 'ok\n'); console.log('ok'); })); - var c2 = spawn(node, ['-e', 'console.log("ok")']); - var c2out = ''; + const c2 = spawn(node, ['-e', 'console.log("ok")']); + let c2out = ''; c2.stdout.setEncoding('utf8'); c2.stdout.on('data', function(chunk) { c2out += chunk; @@ -53,7 +53,7 @@ function parent() { c2.on('close', common.mustCall(function(code, signal) { assert(!code); assert(!signal); - assert.equal(c2out, 'ok\n'); + assert.strictEqual(c2out, 'ok\n'); console.log('ok'); })); } diff --git a/test/parallel/test-stdout-to-file.js b/test/parallel/test-stdout-to-file.js index 10391c481a826d..914fe5673ed10c 100644 --- a/test/parallel/test-stdout-to-file.js +++ b/test/parallel/test-stdout-to-file.js @@ -13,13 +13,13 @@ const tmpFile = path.join(common.tmpDir, 'stdout.txt'); common.refreshTmpDir(); function test(size, useBuffer, cb) { - var cmd = '"' + process.argv[0] + '"' + - ' ' + - '"' + (useBuffer ? scriptBuffer : scriptString) + '"' + - ' ' + - size + - ' > ' + - '"' + tmpFile + '"'; + const cmd = '"' + process.argv[0] + '"' + + ' ' + + '"' + (useBuffer ? scriptBuffer : scriptString) + '"' + + ' ' + + size + + ' > ' + + '"' + tmpFile + '"'; try { fs.unlinkSync(tmpFile); @@ -28,11 +28,10 @@ function test(size, useBuffer, cb) { console.log(`${size} chars to ${tmpFile}...`); childProcess.exec(cmd, common.mustCall(function(err) { - if (err) throw err; - + assert.ifError(err); console.log('done!'); - var stat = fs.statSync(tmpFile); + const stat = fs.statSync(tmpFile); console.log(`${tmpFile} has ${stat.size} bytes`); diff --git a/test/parallel/test-stream-base-no-abort.js b/test/parallel/test-stream-base-no-abort.js index 329948836a5f9f..8b85acea2fb7ea 100644 --- a/test/parallel/test-stream-base-no-abort.js +++ b/test/parallel/test-stream-base-no-abort.js @@ -14,24 +14,24 @@ const fs = require('fs'); const net = require('net'); const tls = require('tls'); const providers = Object.keys(async_wrap.Providers); -var flags = 0; +let flags = 0; // Make sure all asserts have run at least once. -process.on('exit', () => assert.equal(flags, 0b111)); +process.on('exit', () => assert.strictEqual(flags, 0b111)); function init(id, provider) { this._external; // Test will abort if nullptr isn't properly checked. switch (providers[provider]) { case 'TCPWRAP': - assert.equal(this.fd, uv.UV_EINVAL); + assert.strictEqual(this.fd, uv.UV_EINVAL); flags |= 0b1; break; case 'TLSWRAP': - assert.equal(this.fd, uv.UV_EINVAL); + assert.strictEqual(this.fd, uv.UV_EINVAL); flags |= 0b10; break; case 'UDPWRAP': - assert.equal(this.fd, uv.UV_EBADF); + assert.strictEqual(this.fd, uv.UV_EBADF); flags |= 0b100; break; } diff --git a/test/parallel/test-stream-big-push.js b/test/parallel/test-stream-big-push.js index 27feef35ef536d..9083820d42b546 100644 --- a/test/parallel/test-stream-big-push.js +++ b/test/parallel/test-stream-big-push.js @@ -18,7 +18,7 @@ function _read() { }, 1); reads++; } else if (reads === 1) { - var ret = r.push(str); + const ret = r.push(str); assert.strictEqual(ret, false); reads++; } else { @@ -32,10 +32,10 @@ r.on('end', common.mustCall(function() {})); // push some data in to start. // we've never gotten any read event at this point. -var ret = r.push(str); +const ret = r.push(str); // should be false. > hwm assert(!ret); -var chunk = r.read(); +let chunk = r.read(); assert.strictEqual(chunk, str); chunk = r.read(); assert.strictEqual(chunk, null); diff --git a/test/parallel/test-stream-duplex.js b/test/parallel/test-stream-duplex.js index 85438c09fdff88..0b71b3d9a50569 100644 --- a/test/parallel/test-stream-duplex.js +++ b/test/parallel/test-stream-duplex.js @@ -5,27 +5,28 @@ const Duplex = require('stream').Transform; const stream = new Duplex({ objectMode: true }); +assert(Duplex() instanceof Duplex); assert(stream._readableState.objectMode); assert(stream._writableState.objectMode); let written; let read; -stream._write = function(obj, _, cb) { +stream._write = (obj, _, cb) => { written = obj; cb(); }; -stream._read = function() {}; +stream._read = () => {}; -stream.on('data', function(obj) { +stream.on('data', (obj) => { read = obj; }); stream.push({ val: 1 }); stream.end({ val: 2 }); -process.on('exit', function() { +process.on('exit', () => { assert.strictEqual(read.val, 1); assert.strictEqual(written.val, 2); }); diff --git a/test/parallel/test-stream-end-paused.js b/test/parallel/test-stream-end-paused.js index 3c46d49ea65d65..4b585fdb999890 100644 --- a/test/parallel/test-stream-end-paused.js +++ b/test/parallel/test-stream-end-paused.js @@ -21,7 +21,7 @@ stream.pause(); setTimeout(common.mustCall(function() { stream.on('end', common.mustCall(function() {})); stream.resume(); -})); +}), 1); process.on('exit', function() { assert(calledRead); diff --git a/test/parallel/test-stream-pipe-await-drain-manual-resume.js b/test/parallel/test-stream-pipe-await-drain-manual-resume.js index 33540b47b3d5e3..96360429e58856 100644 --- a/test/parallel/test-stream-pipe-await-drain-manual-resume.js +++ b/test/parallel/test-stream-pipe-await-drain-manual-resume.js @@ -1,6 +1,7 @@ 'use strict'; const common = require('../common'); const stream = require('stream'); +const assert = require('assert'); // A consumer stream with a very low highWaterMark, which starts in a state // where it buffers the chunk it receives rather than indicating that they @@ -26,6 +27,11 @@ const readable = new stream.Readable({ readable.pipe(writable); readable.once('pause', common.mustCall(() => { + assert.strictEqual( + readable._readableState.awaitDrain, + 1, + 'awaitDrain doesn\'t increase' + ); // First pause, resume manually. The next write() to writable will still // return false, because chunks are still being buffered, so it will increase // the awaitDrain counter again. @@ -34,6 +40,11 @@ readable.once('pause', common.mustCall(() => { })); readable.once('pause', common.mustCall(() => { + assert.strictEqual( + readable._readableState.awaitDrain, + 1, + '.resume() does not reset counter' + ); // Second pause, handle all chunks from now on. Once all callbacks that // are currently queued up are handled, the awaitDrain drain counter should // fall back to 0 and all chunks that are pending on the readable side @@ -50,5 +61,10 @@ readable.push(Buffer.alloc(100)); // Should get through to the writable. readable.push(null); writable.on('finish', common.mustCall(() => { + assert.strictEqual( + readable._readableState.awaitDrain, + 0, + 'awaitDrain not 0 after all chunks are written' + ); // Everything okay, all chunks were written. })); diff --git a/test/parallel/test-stream-pipe-await-drain-push-while-write.js b/test/parallel/test-stream-pipe-await-drain-push-while-write.js index 1dfdfdb80c8d71..67a8f304c31614 100644 --- a/test/parallel/test-stream-pipe-await-drain-push-while-write.js +++ b/test/parallel/test-stream-pipe-await-drain-push-while-write.js @@ -1,16 +1,34 @@ 'use strict'; const common = require('../common'); const stream = require('stream'); +const assert = require('assert'); + +const awaitDrainStates = [ + 1, // after first chunk before callback + 1, // after second chunk before callback + 0 // resolving chunk pushed after first chunk, awaitDrain is decreased +]; // A writable stream which pushes data onto the stream which pipes into it, // but only the first time it's written to. Since it's not paused at this time, // a second write will occur. If the pipe increases awaitDrain twice, we'll // never get subsequent chunks because 'drain' is only emitted once. const writable = new stream.Writable({ - write: common.mustCall((chunk, encoding, cb) => { + write: common.mustCall(function(chunk, encoding, cb) { if (chunk.length === 32 * 1024) { // first chunk - readable.push(new Buffer(33 * 1024)); // above hwm + const beforePush = readable._readableState.awaitDrain; + readable.push(new Buffer(34 * 1024)); // above hwm + // We should check if awaitDrain counter is increased. + const afterPush = readable._readableState.awaitDrain; + assert.strictEqual(afterPush - beforePush, 1, + 'Counter is not increased for awaitDrain'); } + + assert.strictEqual( + awaitDrainStates.shift(), + readable._readableState.awaitDrain, + 'State variable awaitDrain is not correct.' + ); cb(); }, 3) }); diff --git a/test/parallel/test-stream-pipe-await-drain.js b/test/parallel/test-stream-pipe-await-drain.js index fba99ed4563c14..fc822bb60b7aa8 100644 --- a/test/parallel/test-stream-pipe-await-drain.js +++ b/test/parallel/test-stream-pipe-await-drain.js @@ -1,12 +1,14 @@ 'use strict'; const common = require('../common'); const stream = require('stream'); +const assert = require('assert'); // This is very similar to test-stream-pipe-cleanup-pause.js. const reader = new stream.Readable(); const writer1 = new stream.Writable(); const writer2 = new stream.Writable(); +const writer3 = new stream.Writable(); // 560000 is chosen here because it is larger than the (default) highWaterMark // and will cause `.write()` to return false @@ -19,7 +21,10 @@ writer1._write = common.mustCall(function(chunk, encoding, cb) { this.emit('chunk-received'); cb(); }, 1); + writer1.once('chunk-received', function() { + assert.strictEqual(reader._readableState.awaitDrain, 0, + 'initial value is not 0'); setImmediate(function() { // This one should *not* get through to writer1 because writer2 is not // "done" processing. @@ -29,12 +34,26 @@ writer1.once('chunk-received', function() { // A "slow" consumer: writer2._write = common.mustCall(function(chunk, encoding, cb) { + assert.strictEqual( + reader._readableState.awaitDrain, 1, + 'awaitDrain isn\'t 1 after first push' + ); // Not calling cb here to "simulate" slow stream. + // This should be called exactly once, since the first .write() call + // will return false. +}, 1); +writer3._write = common.mustCall(function(chunk, encoding, cb) { + assert.strictEqual( + reader._readableState.awaitDrain, 2, + 'awaitDrain isn\'t 2 after second push' + ); + // Not calling cb here to "simulate" slow stream. // This should be called exactly once, since the first .write() call // will return false. }, 1); reader.pipe(writer1); reader.pipe(writer2); +reader.pipe(writer3); reader.push(buffer); diff --git a/test/parallel/test-stream-pipe-event.js b/test/parallel/test-stream-pipe-event.js index d8601dd04a4d8e..1b5447eaa21ff9 100644 --- a/test/parallel/test-stream-pipe-event.js +++ b/test/parallel/test-stream-pipe-event.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var stream = require('stream'); -var assert = require('assert'); -var util = require('util'); +const stream = require('stream'); +const assert = require('assert'); +const util = require('util'); function Writable() { this.writable = true; @@ -16,14 +16,14 @@ function Readable() { } util.inherits(Readable, stream.Stream); -var passed = false; +let passed = false; -var w = new Writable(); +const w = new Writable(); w.on('pipe', function(src) { passed = true; }); -var r = new Readable(); +const r = new Readable(); r.pipe(w); assert.ok(passed); diff --git a/test/parallel/test-stream-push-order.js b/test/parallel/test-stream-push-order.js index 22a3156f62f502..5fc1f5e89cf156 100644 --- a/test/parallel/test-stream-push-order.js +++ b/test/parallel/test-stream-push-order.js @@ -1,21 +1,21 @@ 'use strict'; require('../common'); -var Readable = require('stream').Readable; -var assert = require('assert'); +const Readable = require('stream').Readable; +const assert = require('assert'); -var s = new Readable({ +const s = new Readable({ highWaterMark: 20, encoding: 'ascii' }); -var list = ['1', '2', '3', '4', '5', '6']; +const list = ['1', '2', '3', '4', '5', '6']; s._read = function(n) { - var one = list.shift(); + const one = list.shift(); if (!one) { s.push(null); } else { - var two = list.shift(); + const two = list.shift(); s.push(one); s.push(two); } diff --git a/test/parallel/test-stream-push-strings.js b/test/parallel/test-stream-push-strings.js index a5ebe4d3e917f6..e77d8a48c679ef 100644 --- a/test/parallel/test-stream-push-strings.js +++ b/test/parallel/test-stream-push-strings.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var Readable = require('stream').Readable; -var util = require('util'); +const Readable = require('stream').Readable; +const util = require('util'); util.inherits(MyStream, Readable); function MyStream(options) { @@ -30,17 +30,17 @@ MyStream.prototype._read = function(n) { } }; -var ms = new MyStream(); -var results = []; +const ms = new MyStream(); +const results = []; ms.on('readable', function() { - var chunk; + let chunk; while (null !== (chunk = ms.read())) results.push(chunk + ''); }); -var expect = [ 'first chunksecond to last chunk', 'last chunk' ]; +const expect = [ 'first chunksecond to last chunk', 'last chunk' ]; process.on('exit', function() { - assert.equal(ms._chunks, -1); + assert.strictEqual(ms._chunks, -1); assert.deepStrictEqual(results, expect); console.log('ok'); }); diff --git a/test/parallel/test-stream-readable-constructor-set-methods.js b/test/parallel/test-stream-readable-constructor-set-methods.js index fb2114f44dad19..e5e3114de456db 100644 --- a/test/parallel/test-stream-readable-constructor-set-methods.js +++ b/test/parallel/test-stream-readable-constructor-set-methods.js @@ -1,19 +1,19 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var Readable = require('stream').Readable; +const Readable = require('stream').Readable; -var _readCalled = false; +let _readCalled = false; function _read(n) { _readCalled = true; this.push(null); } -var r = new Readable({ read: _read }); +const r = new Readable({ read: _read }); r.resume(); process.on('exit', function() { - assert.equal(r._read, _read); + assert.strictEqual(r._read, _read); assert(_readCalled); }); diff --git a/test/parallel/test-stream-readable-event.js b/test/parallel/test-stream-readable-event.js index a20fc2ee732d0f..a8536bdcbab861 100644 --- a/test/parallel/test-stream-readable-event.js +++ b/test/parallel/test-stream-readable-event.js @@ -20,7 +20,7 @@ const Readable = require('stream').Readable; // we're testing what we think we are assert(!r._readableState.reading); r.on('readable', common.mustCall(function() {})); - }); + }, 1); } { @@ -40,7 +40,7 @@ const Readable = require('stream').Readable; // assert we're testing what we think we are assert(r._readableState.reading); r.on('readable', common.mustCall(function() {})); - }); + }, 1); } { @@ -60,5 +60,5 @@ const Readable = require('stream').Readable; // assert we're testing what we think we are assert(!r._readableState.reading); r.on('readable', common.mustCall(function() {})); - }); + }, 1); } diff --git a/test/parallel/test-stream-readable-flow-recursion.js b/test/parallel/test-stream-readable-flow-recursion.js index 0c0b16e8f5ca7e..e29553900511c3 100644 --- a/test/parallel/test-stream-readable-flow-recursion.js +++ b/test/parallel/test-stream-readable-flow-recursion.js @@ -1,20 +1,20 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // this test verifies that passing a huge number to read(size) // will push up the highWaterMark, and cause the stream to read // more data continuously, but without triggering a nextTick // warning or RangeError. -var Readable = require('stream').Readable; +const Readable = require('stream').Readable; // throw an error if we trigger a nextTick warning. process.throwDeprecation = true; -var stream = new Readable({ highWaterMark: 2 }); -var reads = 0; -var total = 5000; +const stream = new Readable({ highWaterMark: 2 }); +let reads = 0; +let total = 5000; stream._read = function(size) { reads++; size = Math.min(size, total); @@ -25,11 +25,11 @@ stream._read = function(size) { stream.push(Buffer.allocUnsafe(size)); }; -var depth = 0; +let depth = 0; function flow(stream, size, callback) { depth += 1; - var chunk = stream.read(size); + const chunk = stream.read(size); if (!chunk) stream.once('readable', flow.bind(null, stream, size, callback)); @@ -45,12 +45,12 @@ flow(stream, 5000, function() { }); process.on('exit', function(code) { - assert.equal(reads, 2); + assert.strictEqual(reads, 2); // we pushed up the high water mark - assert.equal(stream._readableState.highWaterMark, 8192); + assert.strictEqual(stream._readableState.highWaterMark, 8192); // length is 0 right now, because we pulled it all out. - assert.equal(stream._readableState.length, 0); + assert.strictEqual(stream._readableState.length, 0); assert(!code); - assert.equal(depth, 0); + assert.strictEqual(depth, 0); console.log('ok'); }); diff --git a/test/parallel/test-stream-transform-constructor-set-methods.js b/test/parallel/test-stream-transform-constructor-set-methods.js index 720357a01b9839..1423f4de10942d 100644 --- a/test/parallel/test-stream-transform-constructor-set-methods.js +++ b/test/parallel/test-stream-transform-constructor-set-methods.js @@ -1,32 +1,39 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var Transform = require('stream').Transform; +const Transform = require('stream').Transform; -var _transformCalled = false; +let _transformCalled = false; function _transform(d, e, n) { _transformCalled = true; n(); } -var _flushCalled = false; +let _flushCalled = false; function _flush(n) { _flushCalled = true; n(); } -var t = new Transform({ +const t = new Transform({ transform: _transform, flush: _flush }); +const t2 = new Transform({}); + t.end(Buffer.from('blerg')); t.resume(); -process.on('exit', function() { - assert.equal(t._transform, _transform); - assert.equal(t._flush, _flush); - assert(_transformCalled); - assert(_flushCalled); +assert.throws(() => { + t2.end(Buffer.from('blerg')); +}, /^Error: _transform\(\) is not implemented$/); + + +process.on('exit', () => { + assert.strictEqual(t._transform, _transform); + assert.strictEqual(t._flush, _flush); + assert.strictEqual(_transformCalled, true); + assert.strictEqual(_flushCalled, true); }); diff --git a/test/parallel/test-stream-transform-flush-data.js b/test/parallel/test-stream-transform-flush-data.js index dede64ba10f9da..6d6aedd3a72bf8 100644 --- a/test/parallel/test-stream-transform-flush-data.js +++ b/test/parallel/test-stream-transform-flush-data.js @@ -16,7 +16,7 @@ function _flush(n) { n(null, expected); } -var t = new Transform({ +const t = new Transform({ transform: _transform, flush: _flush }); diff --git a/test/parallel/test-stream-transform-objectmode-falsey-value.js b/test/parallel/test-stream-transform-objectmode-falsey-value.js index 429cc1c960eefb..9a05034b206421 100644 --- a/test/parallel/test-stream-transform-objectmode-falsey-value.js +++ b/test/parallel/test-stream-transform-objectmode-falsey-value.js @@ -1,33 +1,30 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var stream = require('stream'); -var PassThrough = stream.PassThrough; +const stream = require('stream'); +const PassThrough = stream.PassThrough; -var src = new PassThrough({ objectMode: true }); -var tx = new PassThrough({ objectMode: true }); -var dest = new PassThrough({ objectMode: true }); +const src = new PassThrough({ objectMode: true }); +const tx = new PassThrough({ objectMode: true }); +const dest = new PassThrough({ objectMode: true }); -var expect = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; -var results = []; -process.on('exit', function() { - assert.deepStrictEqual(results, expect); - console.log('ok'); -}); +const expect = [ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ]; +const results = []; -dest.on('data', function(x) { +dest.on('data', common.mustCall(function(x) { results.push(x); -}); +}, expect.length)); src.pipe(tx).pipe(dest); -var i = -1; -var int = setInterval(function() { - if (i > 10) { +let i = -1; +const int = setInterval(common.mustCall(function() { + if (results.length === expect.length) { src.end(); clearInterval(int); + assert.deepStrictEqual(results, expect); } else { src.write(i++); } -}); +}, expect.length + 1), 1); diff --git a/test/parallel/test-stream-transform-split-objectmode.js b/test/parallel/test-stream-transform-split-objectmode.js index 610f234bead901..52185e18711090 100644 --- a/test/parallel/test-stream-transform-split-objectmode.js +++ b/test/parallel/test-stream-transform-split-objectmode.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var Transform = require('stream').Transform; +const Transform = require('stream').Transform; -var parser = new Transform({ readableObjectMode: true }); +const parser = new Transform({ readableObjectMode: true }); assert(parser._readableState.objectMode); assert(!parser._writableState.objectMode); @@ -15,7 +15,7 @@ parser._transform = function(chunk, enc, callback) { callback(null, { val: chunk[0] }); }; -var parsed; +let parsed; parser.on('data', function(obj) { parsed = obj; @@ -28,7 +28,7 @@ process.on('exit', function() { }); -var serializer = new Transform({ writableObjectMode: true }); +const serializer = new Transform({ writableObjectMode: true }); assert(!serializer._readableState.objectMode); assert(serializer._writableState.objectMode); @@ -39,7 +39,7 @@ serializer._transform = function(obj, _, callback) { callback(null, Buffer.from([obj.val])); }; -var serialized; +let serialized; serializer.on('data', function(chunk) { serialized = chunk; diff --git a/test/parallel/test-stream-unshift-empty-chunk.js b/test/parallel/test-stream-unshift-empty-chunk.js index 477f5c4be56bac..d555fd7cae2330 100644 --- a/test/parallel/test-stream-unshift-empty-chunk.js +++ b/test/parallel/test-stream-unshift-empty-chunk.js @@ -1,14 +1,14 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // This test verifies that stream.unshift(Buffer.alloc(0)) or // stream.unshift('') does not set state.reading=false. -var Readable = require('stream').Readable; +const Readable = require('stream').Readable; -var r = new Readable(); -var nChunks = 10; -var chunk = Buffer.alloc(10, 'x'); +const r = new Readable(); +let nChunks = 10; +const chunk = Buffer.alloc(10, 'x'); r._read = function(n) { setImmediate(function() { @@ -16,10 +16,10 @@ r._read = function(n) { }); }; -var readAll = false; -var seen = []; +let readAll = false; +const seen = []; r.on('readable', function() { - var chunk; + let chunk; while (chunk = r.read()) { seen.push(chunk.toString()); // simulate only reading a certain amount of the data, @@ -27,13 +27,13 @@ r.on('readable', function() { // stream, like a parser might do. We just fill it with // 'y' so that it's easy to see which bits were touched, // and which were not. - var putBack = Buffer.alloc(readAll ? 0 : 5, 'y'); + const putBack = Buffer.alloc(readAll ? 0 : 5, 'y'); readAll = !readAll; r.unshift(putBack); } }); -var expect = +const expect = [ 'xxxxxxxxxx', 'yyyyy', 'xxxxxxxxxx', diff --git a/test/parallel/test-stream-wrap.js b/test/parallel/test-stream-wrap.js index 69e4dee89d3b13..dbcb58a98cd8b2 100644 --- a/test/parallel/test-stream-wrap.js +++ b/test/parallel/test-stream-wrap.js @@ -7,16 +7,16 @@ const Duplex = require('stream').Duplex; const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap; function testShutdown(callback) { - var stream = new Duplex({ + const stream = new Duplex({ read: function() { }, write: function() { } }); - var wrap = new StreamWrap(stream); + const wrap = new StreamWrap(stream); - var req = new ShutdownWrap(); + const req = new ShutdownWrap(); req.oncomplete = function(code) { assert(code < 0); callback(); diff --git a/test/parallel/test-stream-writable-change-default-encoding.js b/test/parallel/test-stream-writable-change-default-encoding.js index d1d4af5b824baf..c3af66ce83701c 100644 --- a/test/parallel/test-stream-writable-change-default-encoding.js +++ b/test/parallel/test-stream-writable-change-default-encoding.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var stream = require('stream'); -var util = require('util'); +const stream = require('stream'); +const util = require('util'); function MyWritable(fn, options) { stream.Writable.call(this, options); @@ -18,16 +18,16 @@ MyWritable.prototype._write = function(chunk, encoding, callback) { }; (function defaultCondingIsUtf8() { - var m = new MyWritable(function(isBuffer, type, enc) { - assert.equal(enc, 'utf8'); + const m = new MyWritable(function(isBuffer, type, enc) { + assert.strictEqual(enc, 'utf8'); }, { decodeStrings: false }); m.write('foo'); m.end(); }()); (function changeDefaultEncodingToAscii() { - var m = new MyWritable(function(isBuffer, type, enc) { - assert.equal(enc, 'ascii'); + const m = new MyWritable(function(isBuffer, type, enc) { + assert.strictEqual(enc, 'ascii'); }, { decodeStrings: false }); m.setDefaultEncoding('ascii'); m.write('bar'); @@ -35,7 +35,7 @@ MyWritable.prototype._write = function(chunk, encoding, callback) { }()); assert.throws(function changeDefaultEncodingToInvalidValue() { - var m = new MyWritable(function(isBuffer, type, enc) { + const m = new MyWritable(function(isBuffer, type, enc) { }, { decodeStrings: false }); m.setDefaultEncoding({}); m.write('bar'); @@ -43,8 +43,8 @@ assert.throws(function changeDefaultEncodingToInvalidValue() { }, TypeError); (function checkVairableCaseEncoding() { - var m = new MyWritable(function(isBuffer, type, enc) { - assert.equal(enc, 'ascii'); + const m = new MyWritable(function(isBuffer, type, enc) { + assert.strictEqual(enc, 'ascii'); }, { decodeStrings: false }); m.setDefaultEncoding('AsCii'); m.write('bar'); diff --git a/test/parallel/test-stream-writable-constructor-set-methods.js b/test/parallel/test-stream-writable-constructor-set-methods.js index 7d7dfb5f1ccfa0..a12112d1ecc266 100644 --- a/test/parallel/test-stream-writable-constructor-set-methods.js +++ b/test/parallel/test-stream-writable-constructor-set-methods.js @@ -1,25 +1,25 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var Writable = require('stream').Writable; +const Writable = require('stream').Writable; -var _writeCalled = false; +let _writeCalled = false; function _write(d, e, n) { _writeCalled = true; } -var w = new Writable({ write: _write }); +const w = new Writable({ write: _write }); w.end(Buffer.from('blerg')); -var _writevCalled = false; -var dLength = 0; +let _writevCalled = false; +let dLength = 0; function _writev(d, n) { dLength = d.length; _writevCalled = true; } -var w2 = new Writable({ writev: _writev }); +const w2 = new Writable({ writev: _writev }); w2.cork(); w2.write(Buffer.from('blerg')); @@ -27,9 +27,9 @@ w2.write(Buffer.from('blerg')); w2.end(); process.on('exit', function() { - assert.equal(w._write, _write); + assert.strictEqual(w._write, _write); assert(_writeCalled); - assert.equal(w2._writev, _writev); - assert.equal(dLength, 2); + assert.strictEqual(w2._writev, _writev); + assert.strictEqual(dLength, 2); assert(_writevCalled); }); diff --git a/test/parallel/test-stream-writable-decoded-encoding.js b/test/parallel/test-stream-writable-decoded-encoding.js index 621e342a3c2d74..4c903a0b012e3e 100644 --- a/test/parallel/test-stream-writable-decoded-encoding.js +++ b/test/parallel/test-stream-writable-decoded-encoding.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var stream = require('stream'); -var util = require('util'); +const stream = require('stream'); +const util = require('util'); function MyWritable(fn, options) { stream.Writable.call(this, options); diff --git a/test/parallel/test-stream-writable-null.js b/test/parallel/test-stream-writable-null.js index 2cc396bd916a3e..438f250a17dde6 100644 --- a/test/parallel/test-stream-writable-null.js +++ b/test/parallel/test-stream-writable-null.js @@ -17,11 +17,11 @@ MyWritable.prototype._write = function(chunk, encoding, callback) { }; assert.throws(() => { - var m = new MyWritable({objectMode: true}); + const m = new MyWritable({objectMode: true}); m.write(null, (err) => assert.ok(err)); }, TypeError, 'May not write null values to stream'); assert.doesNotThrow(() => { - var m = new MyWritable({objectMode: true}).on('error', (e) => { + const m = new MyWritable({objectMode: true}).on('error', (e) => { assert.ok(e); }); m.write(null, (err) => { @@ -30,11 +30,11 @@ assert.doesNotThrow(() => { }); assert.throws(() => { - var m = new MyWritable(); + const m = new MyWritable(); m.write(false, (err) => assert.ok(err)); }, TypeError, 'Invalid non-string/buffer chunk'); assert.doesNotThrow(() => { - var m = new MyWritable().on('error', (e) => { + const m = new MyWritable().on('error', (e) => { assert.ok(e); }); m.write(false, (err) => { @@ -43,11 +43,11 @@ assert.doesNotThrow(() => { }); assert.doesNotThrow(() => { - var m = new MyWritable({objectMode: true}); + const m = new MyWritable({objectMode: true}); m.write(false, (err) => assert.ifError(err)); }); assert.doesNotThrow(() => { - var m = new MyWritable({objectMode: true}).on('error', (e) => { + const m = new MyWritable({objectMode: true}).on('error', (e) => { assert.ifError(e || new Error('should not get here')); }); m.write(false, (err) => { diff --git a/test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js b/test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js index 3751cd9de6461d..dbd306c53f9ccb 100644 --- a/test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js +++ b/test/parallel/test-stream-writableState-uncorked-bufferedRequestCount.js @@ -7,7 +7,7 @@ const stream = require('stream'); const writable = new stream.Writable(); writable._writev = common.mustCall((chunks, cb) => { - assert.equal(chunks.length, 2, 'two chunks to write'); + assert.strictEqual(chunks.length, 2, 'two chunks to write'); cb(); }, 1); diff --git a/test/parallel/test-stream-writev.js b/test/parallel/test-stream-writev.js index 92479fc88f2958..c62488c9e7650a 100644 --- a/test/parallel/test-stream-writev.js +++ b/test/parallel/test-stream-writev.js @@ -1,13 +1,13 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var stream = require('stream'); +const stream = require('stream'); -var queue = []; -for (var decode = 0; decode < 2; decode++) { - for (var uncork = 0; uncork < 2; uncork++) { - for (var multi = 0; multi < 2; multi++) { +const queue = []; +for (let decode = 0; decode < 2; decode++) { + for (let uncork = 0; uncork < 2; uncork++) { + for (let multi = 0; multi < 2; multi++) { queue.push([!!decode, !!uncork, !!multi]); } } @@ -16,7 +16,7 @@ for (var decode = 0; decode < 2; decode++) { run(); function run() { - var t = queue.pop(); + const t = queue.pop(); if (t) test(t[0], t[1], t[2], run); else @@ -25,25 +25,24 @@ function run() { function test(decode, uncork, multi, next) { console.log('# decode=%j uncork=%j multi=%j', decode, uncork, multi); - var counter = 0; - var expectCount = 0; + let counter = 0; + let expectCount = 0; function cnt(msg) { expectCount++; - var expect = expectCount; + const expect = expectCount; return function(er) { - if (er) - throw er; + assert.ifError(er); counter++; - assert.equal(counter, expect); + assert.strictEqual(counter, expect); }; } - var w = new stream.Writable({ decodeStrings: decode }); + const w = new stream.Writable({ decodeStrings: decode }); w._write = function(chunk, e, cb) { - assert(false, 'Should not call _write'); + common.fail('Should not call _write'); }; - var expectChunks = decode ? [ + const expectChunks = decode ? [ { encoding: 'buffer', chunk: [104, 101, 108, 108, 111, 44, 32] }, { encoding: 'buffer', @@ -62,7 +61,7 @@ function test(decode, uncork, multi, next) { { encoding: 'hex', chunk: 'facebea7deadbeefdecafbad' } ]; - var actualChunks; + let actualChunks; w._writev = function(chunks, cb) { actualChunks = chunks.map(function(chunk) { return { diff --git a/test/parallel/test-stream2-base64-single-char-read-end.js b/test/parallel/test-stream2-base64-single-char-read-end.js index 50bafc3737385d..6a9edbd4eaacbe 100644 --- a/test/parallel/test-stream2-base64-single-char-read-end.js +++ b/test/parallel/test-stream2-base64-single-char-read-end.js @@ -1,14 +1,13 @@ 'use strict'; const common = require('../common'); -var R = require('_stream_readable'); -var W = require('_stream_writable'); -var assert = require('assert'); +const R = require('_stream_readable'); +const W = require('_stream_writable'); +const assert = require('assert'); -var src = new R({encoding: 'base64'}); -var dst = new W(); -var hasRead = false; -var accum = []; -var timeout; +const src = new R({encoding: 'base64'}); +const dst = new W(); +let hasRead = false; +const accum = []; src._read = function(n) { if (!hasRead) { @@ -26,12 +25,12 @@ dst._write = function(chunk, enc, cb) { }; src.on('end', function() { - assert.equal(Buffer.concat(accum) + '', 'MQ=='); + assert.strictEqual(Buffer.concat(accum) + '', 'MQ=='); clearTimeout(timeout); }); src.pipe(dst); -timeout = setTimeout(function() { +const timeout = setTimeout(function() { common.fail('timed out waiting for _write'); }, 100); diff --git a/test/parallel/test-stream2-compatibility.js b/test/parallel/test-stream2-compatibility.js index 77312456590b25..a353da8dede305 100644 --- a/test/parallel/test-stream2-compatibility.js +++ b/test/parallel/test-stream2-compatibility.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var R = require('_stream_readable'); -var W = require('_stream_writable'); -var assert = require('assert'); +const R = require('_stream_readable'); +const W = require('_stream_writable'); +const assert = require('assert'); -var util = require('util'); +const util = require('util'); -var ondataCalled = 0; +let ondataCalled = 0; function TestReader() { R.apply(this); @@ -24,9 +24,9 @@ TestReader.prototype._read = function(n) { this._buffer = Buffer.alloc(0); }; -var reader = new TestReader(); +const reader = new TestReader(); setImmediate(function() { - assert.equal(ondataCalled, 1); + assert.strictEqual(ondataCalled, 1); console.log('ok'); reader.push(null); }); @@ -43,7 +43,7 @@ TestWriter.prototype._write = function(chunk, enc, cb) { cb(); }; -var writer = new TestWriter(); +const writer = new TestWriter(); process.on('exit', function() { assert.strictEqual(reader.readable, false); diff --git a/test/parallel/test-stream2-decode-partial.js b/test/parallel/test-stream2-decode-partial.js index b58e192b9c33bb..b43101dbc84c3a 100644 --- a/test/parallel/test-stream2-decode-partial.js +++ b/test/parallel/test-stream2-decode-partial.js @@ -3,7 +3,7 @@ require('../common'); const Readable = require('_stream_readable'); const assert = require('assert'); -var buf = ''; +let buf = ''; const euro = new Buffer([0xE2, 0x82, 0xAC]); const cent = new Buffer([0xC2, 0xA2]); const source = Buffer.concat([euro, cent]); diff --git a/test/parallel/test-stream2-finish-pipe.js b/test/parallel/test-stream2-finish-pipe.js index fb489978f498ad..87edf5a5fa6437 100644 --- a/test/parallel/test-stream2-finish-pipe.js +++ b/test/parallel/test-stream2-finish-pipe.js @@ -1,14 +1,14 @@ 'use strict'; require('../common'); -var stream = require('stream'); -var Buffer = require('buffer').Buffer; +const stream = require('stream'); +const Buffer = require('buffer').Buffer; -var r = new stream.Readable(); +const r = new stream.Readable(); r._read = function(size) { r.push(Buffer.allocUnsafe(size)); }; -var w = new stream.Writable(); +const w = new stream.Writable(); w._write = function(data, encoding, cb) { cb(null); }; diff --git a/test/parallel/test-stream2-httpclient-response-end.js b/test/parallel/test-stream2-httpclient-response-end.js index d674086055e431..6d3da191b06cb9 100644 --- a/test/parallel/test-stream2-httpclient-response-end.js +++ b/test/parallel/test-stream2-httpclient-response-end.js @@ -1,14 +1,14 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var http = require('http'); -var msg = 'Hello'; -var server = http.createServer(function(req, res) { +const assert = require('assert'); +const http = require('http'); +const msg = 'Hello'; +const server = http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end(msg); }).listen(0, function() { http.get({port: this.address().port}, function(res) { - var data = ''; + let data = ''; res.on('readable', common.mustCall(function() { console.log('readable event'); data += res.read(); diff --git a/test/parallel/test-stream2-large-read-stall.js b/test/parallel/test-stream2-large-read-stall.js index 823407d396afb6..2422747f820bc1 100644 --- a/test/parallel/test-stream2-large-read-stall.js +++ b/test/parallel/test-stream2-large-read-stall.js @@ -1,28 +1,29 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); // If everything aligns so that you do a read(n) of exactly the // remaining buffer, then make sure that 'end' still emits. -var READSIZE = 100; -var PUSHSIZE = 20; -var PUSHCOUNT = 1000; -var HWM = 50; +const READSIZE = 100; +const PUSHSIZE = 20; +const PUSHCOUNT = 1000; +const HWM = 50; -var Readable = require('stream').Readable; -var r = new Readable({ +const Readable = require('stream').Readable; +const r = new Readable({ highWaterMark: HWM }); -var rs = r._readableState; +const rs = r._readableState; r._read = push; r.on('readable', function() { console.error('>> readable'); + let ret; do { console.error(' > read(%d)', READSIZE); - var ret = r.read(READSIZE); + ret = r.read(READSIZE); console.error(' < %j (%d remain)', ret && ret.length, rs.length); } while (ret && ret.length === READSIZE); @@ -32,9 +33,11 @@ r.on('readable', function() { rs.length); }); -r.on('end', common.mustCall(function() {})); +r.on('end', common.mustCall(function() { + assert.strictEqual(pushes, PUSHCOUNT + 1); +})); -var pushes = 0; +let pushes = 0; function push() { if (pushes > PUSHCOUNT) return; @@ -46,9 +49,5 @@ function push() { console.error(' push #%d', pushes); if (r.push(Buffer.allocUnsafe(PUSHSIZE))) - setTimeout(push); + setTimeout(push, 1); } - -process.on('exit', function() { - assert.equal(pushes, PUSHCOUNT + 1); -}); diff --git a/test/parallel/test-stream2-objects.js b/test/parallel/test-stream2-objects.js index b18be26dc530fb..cab838fbfc9acb 100644 --- a/test/parallel/test-stream2-objects.js +++ b/test/parallel/test-stream2-objects.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var Readable = require('_stream_readable'); -var Writable = require('_stream_writable'); -var assert = require('assert'); +const Readable = require('_stream_readable'); +const Writable = require('_stream_writable'); +const assert = require('assert'); // tiny node-tap lookalike. -var tests = []; -var count = 0; +const tests = []; +let count = 0; function test(name, fn) { count++; @@ -14,16 +14,16 @@ function test(name, fn) { } function run() { - var next = tests.shift(); + const next = tests.shift(); if (!next) return console.error('ok'); - var name = next[0]; - var fn = next[1]; + const name = next[0]; + const fn = next[1]; console.log('# %s', name); fn({ same: assert.deepStrictEqual, - equal: assert.equal, + equal: assert.strictEqual, end: function() { count--; run(); @@ -39,8 +39,8 @@ process.on('exit', function() { process.nextTick(run); function toArray(callback) { - var stream = new Writable({ objectMode: true }); - var list = []; + const stream = new Writable({ objectMode: true }); + const list = []; stream.write = function(chunk) { list.push(chunk); }; @@ -53,7 +53,7 @@ function toArray(callback) { } function fromArray(list) { - var r = new Readable({ objectMode: true }); + const r = new Readable({ objectMode: true }); r._read = noop; list.forEach(function(chunk) { r.push(chunk); @@ -66,11 +66,11 @@ function fromArray(list) { function noop() {} test('can read objects from stream', function(t) { - var r = fromArray([{ one: '1'}, { two: '2' }]); + const r = fromArray([{ one: '1'}, { two: '2' }]); - var v1 = r.read(); - var v2 = r.read(); - var v3 = r.read(); + const v1 = r.read(); + const v2 = r.read(); + const v3 = r.read(); assert.deepStrictEqual(v1, { one: '1' }); assert.deepStrictEqual(v2, { two: '2' }); @@ -80,7 +80,7 @@ test('can read objects from stream', function(t) { }); test('can pipe objects into stream', function(t) { - var r = fromArray([{ one: '1'}, { two: '2' }]); + const r = fromArray([{ one: '1'}, { two: '2' }]); r.pipe(toArray(function(list) { assert.deepStrictEqual(list, [ @@ -93,9 +93,9 @@ test('can pipe objects into stream', function(t) { }); test('read(n) is ignored', function(t) { - var r = fromArray([{ one: '1'}, { two: '2' }]); + const r = fromArray([{ one: '1'}, { two: '2' }]); - var value = r.read(2); + const value = r.read(2); assert.deepStrictEqual(value, { one: '1' }); @@ -103,10 +103,10 @@ test('read(n) is ignored', function(t) { }); test('can read objects from _read (sync)', function(t) { - var r = new Readable({ objectMode: true }); - var list = [{ one: '1'}, { two: '2' }]; + const r = new Readable({ objectMode: true }); + const list = [{ one: '1'}, { two: '2' }]; r._read = function(n) { - var item = list.shift(); + const item = list.shift(); r.push(item || null); }; @@ -121,10 +121,10 @@ test('can read objects from _read (sync)', function(t) { }); test('can read objects from _read (async)', function(t) { - var r = new Readable({ objectMode: true }); - var list = [{ one: '1'}, { two: '2' }]; + const r = new Readable({ objectMode: true }); + const list = [{ one: '1'}, { two: '2' }]; r._read = function(n) { - var item = list.shift(); + const item = list.shift(); process.nextTick(function() { r.push(item || null); }); @@ -141,11 +141,11 @@ test('can read objects from _read (async)', function(t) { }); test('can read strings as objects', function(t) { - var r = new Readable({ + const r = new Readable({ objectMode: true }); r._read = noop; - var list = ['one', 'two', 'three']; + const list = ['one', 'two', 'three']; list.forEach(function(str) { r.push(str); }); @@ -159,7 +159,7 @@ test('can read strings as objects', function(t) { }); test('read(0) for object streams', function(t) { - var r = new Readable({ + const r = new Readable({ objectMode: true }); r._read = noop; @@ -175,7 +175,7 @@ test('read(0) for object streams', function(t) { }); test('falsey values', function(t) { - var r = new Readable({ + const r = new Readable({ objectMode: true }); r._read = noop; @@ -193,12 +193,12 @@ test('falsey values', function(t) { }); test('high watermark _read', function(t) { - var r = new Readable({ + const r = new Readable({ highWaterMark: 6, objectMode: true }); - var calls = 0; - var list = ['1', '2', '3', '4', '5', '6', '7', '8']; + let calls = 0; + const list = ['1', '2', '3', '4', '5', '6', '7', '8']; r._read = function(n) { calls++; @@ -208,15 +208,15 @@ test('high watermark _read', function(t) { r.push(c); }); - var v = r.read(); + const v = r.read(); assert.strictEqual(calls, 0); assert.strictEqual(v, '1'); - var v2 = r.read(); + const v2 = r.read(); assert.strictEqual(v2, '2'); - var v3 = r.read(); + const v3 = r.read(); assert.strictEqual(v3, '3'); assert.strictEqual(calls, 1); @@ -225,13 +225,13 @@ test('high watermark _read', function(t) { }); test('high watermark push', function(t) { - var r = new Readable({ + const r = new Readable({ highWaterMark: 6, objectMode: true }); r._read = function(n) {}; - for (var i = 0; i < 6; i++) { - var bool = r.push(i); + for (let i = 0; i < 6; i++) { + const bool = r.push(i); assert.strictEqual(bool, i !== 5); } @@ -239,7 +239,7 @@ test('high watermark push', function(t) { }); test('can write objects to stream', function(t) { - var w = new Writable({ objectMode: true }); + const w = new Writable({ objectMode: true }); w._write = function(chunk, encoding, cb) { assert.deepStrictEqual(chunk, { foo: 'bar' }); @@ -255,8 +255,8 @@ test('can write objects to stream', function(t) { }); test('can write multiple objects to stream', function(t) { - var w = new Writable({ objectMode: true }); - var list = []; + const w = new Writable({ objectMode: true }); + const list = []; w._write = function(chunk, encoding, cb) { list.push(chunk); @@ -278,10 +278,10 @@ test('can write multiple objects to stream', function(t) { }); test('can write strings as objects', function(t) { - var w = new Writable({ + const w = new Writable({ objectMode: true }); - var list = []; + const list = []; w._write = function(chunk, encoding, cb) { list.push(chunk); @@ -303,10 +303,10 @@ test('can write strings as objects', function(t) { }); test('buffers finish until cb is called', function(t) { - var w = new Writable({ + const w = new Writable({ objectMode: true }); - var called = false; + let called = false; w._write = function(chunk, encoding, cb) { assert.strictEqual(chunk, 'foo'); diff --git a/test/parallel/test-stream2-pipe-error-handling.js b/test/parallel/test-stream2-pipe-error-handling.js index bdf7a4a9a33a77..cdd1b1a364e183 100644 --- a/test/parallel/test-stream2-pipe-error-handling.js +++ b/test/parallel/test-stream2-pipe-error-handling.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var stream = require('stream'); +const assert = require('assert'); +const stream = require('stream'); { let count = 1000; diff --git a/test/parallel/test-stream2-pipe-error-once-listener.js b/test/parallel/test-stream2-pipe-error-once-listener.js index c9cfd1d1c80c19..908ac1bdb8e4ab 100644 --- a/test/parallel/test-stream2-pipe-error-once-listener.js +++ b/test/parallel/test-stream2-pipe-error-once-listener.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var util = require('util'); -var stream = require('stream'); +const util = require('util'); +const stream = require('stream'); -var Read = function() { +const Read = function() { stream.Readable.call(this); }; util.inherits(Read, stream.Readable); @@ -16,7 +16,7 @@ Read.prototype._read = function(size) { }; -var Write = function() { +const Write = function() { stream.Writable.call(this); }; util.inherits(Write, stream.Writable); @@ -26,8 +26,8 @@ Write.prototype._write = function(buffer, encoding, cb) { this.emit('alldone'); }; -var read = new Read(); -var write = new Write(); +const read = new Read(); +const write = new Write(); write.once('error', function(err) {}); write.once('alldone', function(err) { diff --git a/test/parallel/test-stream2-push.js b/test/parallel/test-stream2-push.js index 445a186715b659..95a98450a3034e 100644 --- a/test/parallel/test-stream2-push.js +++ b/test/parallel/test-stream2-push.js @@ -1,34 +1,33 @@ 'use strict'; require('../common'); -var stream = require('stream'); -var Readable = stream.Readable; -var Writable = stream.Writable; -var assert = require('assert'); +const Readable = require('stream').Readable; +const Writable = require('stream').Writable; +const assert = require('assert'); -var EE = require('events').EventEmitter; +const EE = require('events').EventEmitter; // a mock thing a bit like the net.Socket/tcp_wrap.handle interaction -stream = new Readable({ +const stream = new Readable({ highWaterMark: 16, encoding: 'utf8' }); -var source = new EE(); +const source = new EE(); stream._read = function() { console.error('stream._read'); readStart(); }; -var ended = false; +let ended = false; stream.on('end', function() { ended = true; }); source.on('data', function(chunk) { - var ret = stream.push(chunk); + const ret = stream.push(chunk); console.error('data', stream._readableState.length); if (!ret) readStop(); @@ -38,7 +37,7 @@ source.on('end', function() { stream.push(null); }); -var reading = false; +let reading = false; function readStart() { console.error('readStart'); @@ -49,19 +48,19 @@ function readStop() { console.error('readStop'); reading = false; process.nextTick(function() { - var r = stream.read(); + const r = stream.read(); if (r !== null) writer.write(r); }); } -var writer = new Writable({ +const writer = new Writable({ decodeStrings: false }); -var written = []; +const written = []; -var expectWritten = +const expectWritten = [ 'asdfgasdfgasdfgasdfg', 'asdfgasdfgasdfgasdfg', 'asdfgasdfgasdfgasdfg', @@ -80,9 +79,9 @@ writer.on('finish', finish); // now emit some chunks. -var chunk = 'asdfg'; +const chunk = 'asdfg'; -var set = 0; +let set = 0; readStart(); data(); function data() { diff --git a/test/parallel/test-stream2-read-sync-stack.js b/test/parallel/test-stream2-read-sync-stack.js index b2cfd05f872e30..d4e11af3b8f7c1 100644 --- a/test/parallel/test-stream2-read-sync-stack.js +++ b/test/parallel/test-stream2-read-sync-stack.js @@ -1,16 +1,16 @@ 'use strict'; const common = require('../common'); -var Readable = require('stream').Readable; -var r = new Readable(); -var N = 256 * 1024; +const Readable = require('stream').Readable; +const r = new Readable(); +const N = 256 * 1024; // Go ahead and allow the pathological case for this test. // Yes, it's an infinite loop, that's the point. process.maxTickDepth = N + 2; -var reads = 0; +let reads = 0; r._read = function(n) { - var chunk = reads++ === N ? null : Buffer.allocUnsafe(1); + const chunk = reads++ === N ? null : Buffer.allocUnsafe(1); r.push(chunk); }; diff --git a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js index ccbf087df00bf5..71d6f1e7236db2 100644 --- a/test/parallel/test-stream2-readable-empty-buffer-no-eof.js +++ b/test/parallel/test-stream2-readable-empty-buffer-no-eof.js @@ -69,8 +69,8 @@ function test1() { } function test2() { - var r = new Readable({ encoding: 'base64' }); - var reads = 5; + const r = new Readable({ encoding: 'base64' }); + let reads = 5; r._read = function(n) { if (!reads--) return r.push(null); // EOF @@ -78,9 +78,9 @@ function test2() { return r.push(Buffer.from('x')); }; - var results = []; + const results = []; function flow() { - var chunk; + let chunk; while (null !== (chunk = r.read())) results.push(chunk + ''); } diff --git a/test/parallel/test-stream2-readable-from-list.js b/test/parallel/test-stream2-readable-from-list.js index 2aa0725f734117..54db1d1c182526 100644 --- a/test/parallel/test-stream2-readable-from-list.js +++ b/test/parallel/test-stream2-readable-from-list.js @@ -1,13 +1,13 @@ // Flags: --expose_internals 'use strict'; require('../common'); -var assert = require('assert'); -var fromList = require('_stream_readable')._fromList; -var BufferList = require('internal/streams/BufferList'); +const assert = require('assert'); +const fromList = require('_stream_readable')._fromList; +const BufferList = require('internal/streams/BufferList'); // tiny node-tap lookalike. -var tests = []; -var count = 0; +const tests = []; +let count = 0; function test(name, fn) { count++; @@ -15,16 +15,16 @@ function test(name, fn) { } function run() { - var next = tests.shift(); + const next = tests.shift(); if (!next) return console.error('ok'); - var name = next[0]; - var fn = next[1]; + const name = next[0]; + const fn = next[1]; console.log('# %s', name); fn({ same: assert.deepStrictEqual, - equal: assert.equal, + equal: assert.strictEqual, end: function() { count--; run(); @@ -34,28 +34,28 @@ function run() { function bufferListFromArray(arr) { const bl = new BufferList(); - for (var i = 0; i < arr.length; ++i) + for (let i = 0; i < arr.length; ++i) bl.push(arr[i]); return bl; } // ensure all tests have run process.on('exit', function() { - assert.equal(count, 0); + assert.strictEqual(count, 0); }); process.nextTick(run); test('buffers', function(t) { - var list = [ Buffer.from('foog'), + let list = [ Buffer.from('foog'), Buffer.from('bark'), Buffer.from('bazy'), Buffer.from('kuel') ]; list = bufferListFromArray(list); // read more than the first element. - var ret = fromList(6, { buffer: list, length: 16 }); + let ret = fromList(6, { buffer: list, length: 16 }); t.equal(ret.toString(), 'foogba'); // read exactly the first element. @@ -77,14 +77,14 @@ test('buffers', function(t) { }); test('strings', function(t) { - var list = [ 'foog', + let list = [ 'foog', 'bark', 'bazy', 'kuel' ]; list = bufferListFromArray(list); // read more than the first element. - var ret = fromList(6, { buffer: list, length: 16, decoder: true }); + let ret = fromList(6, { buffer: list, length: 16, decoder: true }); t.equal(ret, 'foogba'); // read exactly the first element. diff --git a/test/parallel/test-stream2-readable-legacy-drain.js b/test/parallel/test-stream2-readable-legacy-drain.js index 8a0687a6ebd90c..d6db6ba232c693 100644 --- a/test/parallel/test-stream2-readable-legacy-drain.js +++ b/test/parallel/test-stream2-readable-legacy-drain.js @@ -1,22 +1,22 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var Stream = require('stream'); -var Readable = Stream.Readable; +const Stream = require('stream'); +const Readable = Stream.Readable; -var r = new Readable(); -var N = 256; -var reads = 0; +const r = new Readable(); +const N = 256; +let reads = 0; r._read = function(n) { return r.push(++reads === N ? null : Buffer.allocUnsafe(1)); }; r.on('end', common.mustCall(function() {})); -var w = new Stream(); +const w = new Stream(); w.writable = true; -var buffered = 0; +let buffered = 0; w.write = function(c) { buffered += c.length; process.nextTick(drain); diff --git a/test/parallel/test-stream2-readable-non-empty-end.js b/test/parallel/test-stream2-readable-non-empty-end.js index c08cc287ce1cbf..46481fe1dcda4c 100644 --- a/test/parallel/test-stream2-readable-non-empty-end.js +++ b/test/parallel/test-stream2-readable-non-empty-end.js @@ -1,22 +1,22 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var Readable = require('_stream_readable'); +const assert = require('assert'); +const Readable = require('_stream_readable'); -var len = 0; -var chunks = new Array(10); -for (var i = 1; i <= 10; i++) { +let len = 0; +const chunks = new Array(10); +for (let i = 1; i <= 10; i++) { chunks[i - 1] = Buffer.allocUnsafe(i); len += i; } -var test = new Readable(); -var n = 0; +const test = new Readable(); +let n = 0; test._read = function(size) { - var chunk = chunks[n++]; + const chunk = chunks[n++]; setTimeout(function() { test.push(chunk === undefined ? null : chunk); - }); + }, 1); }; test.on('end', thrower); @@ -24,14 +24,14 @@ function thrower() { throw new Error('this should not happen!'); } -var bytesread = 0; +let bytesread = 0; test.on('readable', function() { - var b = len - bytesread - 1; - var res = test.read(b); + const b = len - bytesread - 1; + const res = test.read(b); if (res) { bytesread += res.length; console.error('br=%d len=%d', bytesread, len); - setTimeout(next); + setTimeout(next, 1); } test.read(0); }); @@ -43,9 +43,9 @@ function next() { test.on('end', common.mustCall(function() {})); // one to get the last byte - var r = test.read(); + let r = test.read(); assert(r); - assert.equal(r.length, 1); + assert.strictEqual(r.length, 1); r = test.read(); - assert.equal(r, null); + assert.strictEqual(r, null); } diff --git a/test/parallel/test-stream2-readable-wrap-empty.js b/test/parallel/test-stream2-readable-wrap-empty.js index 02de3cf5b4cb23..5b2dae3c5327fa 100644 --- a/test/parallel/test-stream2-readable-wrap-empty.js +++ b/test/parallel/test-stream2-readable-wrap-empty.js @@ -1,14 +1,14 @@ 'use strict'; const common = require('../common'); -var Readable = require('_stream_readable'); -var EE = require('events').EventEmitter; +const Readable = require('_stream_readable'); +const EE = require('events').EventEmitter; -var oldStream = new EE(); +const oldStream = new EE(); oldStream.pause = function() {}; oldStream.resume = function() {}; -var newStream = new Readable().wrap(oldStream); +const newStream = new Readable().wrap(oldStream); newStream .on('readable', function() {}) diff --git a/test/parallel/test-stream2-readable-wrap.js b/test/parallel/test-stream2-readable-wrap.js index 0cbd106d5b4b35..aa091dc3d806f0 100644 --- a/test/parallel/test-stream2-readable-wrap.js +++ b/test/parallel/test-stream2-readable-wrap.js @@ -1,77 +1,63 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); +const Readable = require('_stream_readable'); +const Writable = require('_stream_writable'); +const EE = require('events').EventEmitter; -var Readable = require('_stream_readable'); -var Writable = require('_stream_writable'); -var EE = require('events').EventEmitter; - -var testRuns = 0, completedRuns = 0; function runTest(highWaterMark, objectMode, produce) { - testRuns++; - var old = new EE(); - var r = new Readable({ highWaterMark: highWaterMark, - objectMode: objectMode }); - assert.equal(r, r.wrap(old)); + const old = new EE(); + const r = new Readable({ highWaterMark: highWaterMark, + objectMode: objectMode }); + assert.strictEqual(r, r.wrap(old)); - var ended = false; - r.on('end', function() { - ended = true; - }); + r.on('end', common.mustCall(function() {})); old.pause = function() { - console.error('old.pause()'); old.emit('pause'); flowing = false; }; old.resume = function() { - console.error('old.resume()'); old.emit('resume'); flow(); }; - var flowing; - var chunks = 10; - var oldEnded = false; - var expected = []; + let flowing; + let chunks = 10; + let oldEnded = false; + const expected = []; function flow() { flowing = true; while (flowing && chunks-- > 0) { - var item = produce(); + const item = produce(); expected.push(item); - console.log('old.emit', chunks, flowing); old.emit('data', item); - console.log('after emit', chunks, flowing); } if (chunks <= 0) { oldEnded = true; - console.log('old end', chunks, flowing); old.emit('end'); } } - var w = new Writable({ highWaterMark: highWaterMark * 2, - objectMode: objectMode }); - var written = []; + const w = new Writable({ highWaterMark: highWaterMark * 2, + objectMode: objectMode }); + const written = []; w._write = function(chunk, encoding, cb) { - console.log('_write', chunk); written.push(chunk); - setTimeout(cb); + setTimeout(cb, 1); }; - w.on('finish', function() { - completedRuns++; + w.on('finish', common.mustCall(function() { performAsserts(); - }); + })); r.pipe(w); flow(); function performAsserts() { - assert(ended); assert(oldEnded); assert.deepStrictEqual(written, expected); } @@ -81,10 +67,5 @@ runTest(100, false, function() { return Buffer.allocUnsafe(100); }); runTest(10, false, function() { return Buffer.from('xxxxxxxxxx'); }); runTest(1, true, function() { return { foo: 'bar' }; }); -var objectChunks = [ 5, 'a', false, 0, '', 'xyz', { x: 4 }, 7, [], 555 ]; +const objectChunks = [ 5, 'a', false, 0, '', 'xyz', { x: 4 }, 7, [], 555 ]; runTest(1, true, function() { return objectChunks.shift(); }); - -process.on('exit', function() { - assert.equal(testRuns, completedRuns); - console.log('ok'); -}); diff --git a/test/parallel/test-stream2-set-encoding.js b/test/parallel/test-stream2-set-encoding.js index 3deb67d48e7156..a207168f39a97e 100644 --- a/test/parallel/test-stream2-set-encoding.js +++ b/test/parallel/test-stream2-set-encoding.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var R = require('_stream_readable'); -var util = require('util'); +const assert = require('assert'); +const R = require('_stream_readable'); +const util = require('util'); // tiny node-tap lookalike. -var tests = []; -var count = 0; +const tests = []; +let count = 0; function test(name, fn) { count++; @@ -14,16 +14,16 @@ function test(name, fn) { } function run() { - var next = tests.shift(); + const next = tests.shift(); if (!next) return console.error('ok'); - var name = next[0]; - var fn = next[1]; + const name = next[0]; + const fn = next[1]; console.log('# %s', name); fn({ same: assert.deepStrictEqual, - equal: assert.equal, + equal: assert.strictEqual, end: function() { count--; run(); @@ -33,7 +33,7 @@ function run() { // ensure all tests have run process.on('exit', function() { - assert.equal(count, 0); + assert.strictEqual(count, 0); }); process.nextTick(run); @@ -66,7 +66,7 @@ TestReader.prototype._read = function(n) { } this.pos += n; - var ret = Buffer.alloc(n, 'a'); + const ret = Buffer.alloc(n, 'a'); console.log('this.push(ret)', ret); @@ -75,10 +75,10 @@ TestReader.prototype._read = function(n) { }; test('setEncoding utf8', function(t) { - var tr = new TestReader(100); + const tr = new TestReader(100); tr.setEncoding('utf8'); - var out = []; - var expect = + const out = []; + const expect = [ 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', @@ -91,7 +91,7 @@ test('setEncoding utf8', function(t) { 'aaaaaaaaaa' ]; tr.on('readable', function flow() { - var chunk; + let chunk; while (null !== (chunk = tr.read(10))) out.push(chunk); }); @@ -104,10 +104,10 @@ test('setEncoding utf8', function(t) { test('setEncoding hex', function(t) { - var tr = new TestReader(100); + const tr = new TestReader(100); tr.setEncoding('hex'); - var out = []; - var expect = + const out = []; + const expect = [ '6161616161', '6161616161', '6161616161', @@ -130,7 +130,7 @@ test('setEncoding hex', function(t) { '6161616161' ]; tr.on('readable', function flow() { - var chunk; + let chunk; while (null !== (chunk = tr.read(10))) out.push(chunk); }); @@ -142,10 +142,10 @@ test('setEncoding hex', function(t) { }); test('setEncoding hex with read(13)', function(t) { - var tr = new TestReader(100); + const tr = new TestReader(100); tr.setEncoding('hex'); - var out = []; - var expect = + const out = []; + const expect = [ '6161616161616', '1616161616161', '6161616161616', @@ -165,7 +165,7 @@ test('setEncoding hex with read(13)', function(t) { tr.on('readable', function flow() { console.log('readable once'); - var chunk; + let chunk; while (null !== (chunk = tr.read(13))) out.push(chunk); }); @@ -178,10 +178,10 @@ test('setEncoding hex with read(13)', function(t) { }); test('setEncoding base64', function(t) { - var tr = new TestReader(100); + const tr = new TestReader(100); tr.setEncoding('base64'); - var out = []; - var expect = + const out = []; + const expect = [ 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', @@ -198,7 +198,7 @@ test('setEncoding base64', function(t) { 'FhYQ==' ]; tr.on('readable', function flow() { - var chunk; + let chunk; while (null !== (chunk = tr.read(10))) out.push(chunk); }); @@ -210,9 +210,9 @@ test('setEncoding base64', function(t) { }); test('encoding: utf8', function(t) { - var tr = new TestReader(100, { encoding: 'utf8' }); - var out = []; - var expect = + const tr = new TestReader(100, { encoding: 'utf8' }); + const out = []; + const expect = [ 'aaaaaaaaaa', 'aaaaaaaaaa', 'aaaaaaaaaa', @@ -225,7 +225,7 @@ test('encoding: utf8', function(t) { 'aaaaaaaaaa' ]; tr.on('readable', function flow() { - var chunk; + let chunk; while (null !== (chunk = tr.read(10))) out.push(chunk); }); @@ -238,9 +238,9 @@ test('encoding: utf8', function(t) { test('encoding: hex', function(t) { - var tr = new TestReader(100, { encoding: 'hex' }); - var out = []; - var expect = + const tr = new TestReader(100, { encoding: 'hex' }); + const out = []; + const expect = [ '6161616161', '6161616161', '6161616161', @@ -263,7 +263,7 @@ test('encoding: hex', function(t) { '6161616161' ]; tr.on('readable', function flow() { - var chunk; + let chunk; while (null !== (chunk = tr.read(10))) out.push(chunk); }); @@ -275,9 +275,9 @@ test('encoding: hex', function(t) { }); test('encoding: hex with read(13)', function(t) { - var tr = new TestReader(100, { encoding: 'hex' }); - var out = []; - var expect = + const tr = new TestReader(100, { encoding: 'hex' }); + const out = []; + const expect = [ '6161616161616', '1616161616161', '6161616161616', @@ -296,7 +296,7 @@ test('encoding: hex with read(13)', function(t) { '16161' ]; tr.on('readable', function flow() { - var chunk; + let chunk; while (null !== (chunk = tr.read(13))) out.push(chunk); }); @@ -308,9 +308,9 @@ test('encoding: hex with read(13)', function(t) { }); test('encoding: base64', function(t) { - var tr = new TestReader(100, { encoding: 'base64' }); - var out = []; - var expect = + const tr = new TestReader(100, { encoding: 'base64' }); + const out = []; + const expect = [ 'YWFhYWFhYW', 'FhYWFhYWFh', 'YWFhYWFhYW', @@ -327,7 +327,7 @@ test('encoding: base64', function(t) { 'FhYQ==' ]; tr.on('readable', function flow() { - var chunk; + let chunk; while (null !== (chunk = tr.read(10))) out.push(chunk); }); @@ -339,7 +339,7 @@ test('encoding: base64', function(t) { }); test('chainable', function(t) { - var tr = new TestReader(100); + const tr = new TestReader(100); t.equal(tr.setEncoding('utf8'), tr); t.end(); }); diff --git a/test/parallel/test-stream2-transform.js b/test/parallel/test-stream2-transform.js index 6a4036681f90b7..2695ac21b752c4 100644 --- a/test/parallel/test-stream2-transform.js +++ b/test/parallel/test-stream2-transform.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var PassThrough = require('_stream_passthrough'); -var Transform = require('_stream_transform'); +const assert = require('assert'); +const PassThrough = require('_stream_passthrough'); +const Transform = require('_stream_transform'); // tiny node-tap lookalike. -var tests = []; -var count = 0; +const tests = []; +let count = 0; function test(name, fn) { count++; @@ -14,16 +14,16 @@ function test(name, fn) { } function run() { - var next = tests.shift(); + const next = tests.shift(); if (!next) return console.error('ok'); - var name = next[0]; - var fn = next[1]; + const name = next[0]; + const fn = next[1]; console.log('# %s', name); fn({ same: assert.deepStrictEqual, - equal: assert.equal, + equal: assert.strictEqual, ok: assert, end: function() { count--; @@ -34,7 +34,7 @@ function run() { // ensure all tests have run process.on('exit', function() { - assert.equal(count, 0); + assert.strictEqual(count, 0); }); process.nextTick(run); @@ -42,18 +42,18 @@ process.nextTick(run); ///// test('writable side consumption', function(t) { - var tx = new Transform({ + const tx = new Transform({ highWaterMark: 10 }); - var transformed = 0; + let transformed = 0; tx._transform = function(chunk, encoding, cb) { transformed += chunk.length; tx.push(chunk); cb(); }; - for (var i = 1; i <= 10; i++) { + for (let i = 1; i <= 10; i++) { tx.write(Buffer.allocUnsafe(i)); } tx.end(); @@ -69,7 +69,7 @@ test('writable side consumption', function(t) { }); test('passthrough', function(t) { - var pt = new PassThrough(); + const pt = new PassThrough(); pt.write(Buffer.from('foog')); pt.write(Buffer.from('bark')); @@ -85,7 +85,7 @@ test('passthrough', function(t) { }); test('object passthrough', function(t) { - var pt = new PassThrough({ objectMode: true }); + const pt = new PassThrough({ objectMode: true }); pt.write(1); pt.write(true); @@ -115,9 +115,9 @@ test('passthrough constructor', function(t) { }); test('simple transform', function(t) { - var pt = new Transform(); + const pt = new Transform(); pt._transform = function(c, e, cb) { - var ret = Buffer.alloc(c.length, 'x'); + const ret = Buffer.alloc(c.length, 'x'); pt.push(ret); cb(); }; @@ -136,7 +136,7 @@ test('simple transform', function(t) { }); test('simple object transform', function(t) { - var pt = new Transform({ objectMode: true }); + const pt = new Transform({ objectMode: true }); pt._transform = function(c, e, cb) { pt.push(JSON.stringify(c)); cb(); @@ -162,7 +162,7 @@ test('simple object transform', function(t) { }); test('async passthrough', function(t) { - var pt = new Transform(); + const pt = new Transform(); pt._transform = function(chunk, encoding, cb) { setTimeout(function() { pt.push(chunk); @@ -186,7 +186,7 @@ test('async passthrough', function(t) { }); test('assymetric transform (expand)', function(t) { - var pt = new Transform(); + const pt = new Transform(); // emit each chunk 2 times. pt._transform = function(chunk, encoding, cb) { @@ -218,7 +218,7 @@ test('assymetric transform (expand)', function(t) { }); test('assymetric transform (compress)', function(t) { - var pt = new Transform(); + const pt = new Transform(); // each output is the first char of 3 consecutive chunks, // or whatever's left. @@ -227,7 +227,7 @@ test('assymetric transform (compress)', function(t) { pt._transform = function(chunk, encoding, cb) { if (!chunk) chunk = ''; - var s = chunk.toString(); + const s = chunk.toString(); setTimeout(function() { this.state += s.charAt(0); if (this.state.length === 3) { @@ -273,9 +273,9 @@ test('assymetric transform (compress)', function(t) { // this tests for a stall when data is written to a full stream // that has empty transforms. test('complex transform', function(t) { - var count = 0; - var saved = null; - var pt = new Transform({highWaterMark: 3}); + let count = 0; + let saved = null; + const pt = new Transform({highWaterMark: 3}); pt._transform = function(c, e, cb) { if (count++ === 1) saved = c; @@ -307,8 +307,8 @@ test('complex transform', function(t) { test('passthrough event emission', function(t) { - var pt = new PassThrough(); - var emits = 0; + const pt = new PassThrough(); + let emits = 0; pt.on('readable', function() { console.error('>>> emit readable %d', emits); emits++; @@ -353,8 +353,8 @@ test('passthrough event emission', function(t) { }); test('passthrough event emission reordered', function(t) { - var pt = new PassThrough(); - var emits = 0; + const pt = new PassThrough(); + let emits = 0; pt.on('readable', function() { console.error('emit readable', emits); emits++; @@ -395,8 +395,8 @@ test('passthrough event emission reordered', function(t) { test('passthrough facaded', function(t) { console.error('passthrough facaded'); - var pt = new PassThrough(); - var datas = []; + const pt = new PassThrough(); + const datas = []; pt.on('data', function(chunk) { datas.push(chunk.toString()); }); @@ -423,7 +423,7 @@ test('passthrough facaded', function(t) { test('object transform (json parse)', function(t) { console.error('json parse stream'); - var jp = new Transform({ objectMode: true }); + const jp = new Transform({ objectMode: true }); jp._transform = function(data, encoding, cb) { try { jp.push(JSON.parse(data)); @@ -435,21 +435,21 @@ test('object transform (json parse)', function(t) { // anything except null/undefined is fine. // those are "magic" in the stream API, because they signal EOF. - var objects = [ + const objects = [ { foo: 'bar' }, 100, 'string', { nested: { things: [ { foo: 'bar' }, 100, 'string' ] } } ]; - var ended = false; + let ended = false; jp.on('end', function() { ended = true; }); objects.forEach(function(obj) { jp.write(JSON.stringify(obj)); - var res = jp.read(); + const res = jp.read(); t.same(res, obj); }); @@ -465,7 +465,7 @@ test('object transform (json parse)', function(t) { test('object transform (json stringify)', function(t) { console.error('json parse stream'); - var js = new Transform({ objectMode: true }); + const js = new Transform({ objectMode: true }); js._transform = function(data, encoding, cb) { try { js.push(JSON.stringify(data)); @@ -477,21 +477,21 @@ test('object transform (json stringify)', function(t) { // anything except null/undefined is fine. // those are "magic" in the stream API, because they signal EOF. - var objects = [ + const objects = [ { foo: 'bar' }, 100, 'string', { nested: { things: [ { foo: 'bar' }, 100, 'string' ] } } ]; - var ended = false; + let ended = false; js.on('end', function() { ended = true; }); objects.forEach(function(obj) { js.write(obj); - var res = js.read(); + const res = js.read(); t.equal(res, JSON.stringify(obj)); }); diff --git a/test/parallel/test-stream2-unpipe-leak.js b/test/parallel/test-stream2-unpipe-leak.js index d94e39f7667df4..8800a2bbc68e45 100644 --- a/test/parallel/test-stream2-unpipe-leak.js +++ b/test/parallel/test-stream2-unpipe-leak.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var stream = require('stream'); +const assert = require('assert'); +const stream = require('stream'); -var chunk = Buffer.from('hallo'); +const chunk = Buffer.from('hallo'); -var util = require('util'); +const util = require('util'); function TestWriter() { stream.Writable.call(this); @@ -16,7 +16,7 @@ TestWriter.prototype._write = function(buffer, encoding, callback) { callback(null); }; -var dest = new TestWriter(); +const dest = new TestWriter(); // Set this high so that we'd trigger a nextTick warning // and/or RangeError if we do maybeReadMore wrong. @@ -29,21 +29,21 @@ TestReader.prototype._read = function(size) { this.push(chunk); }; -var src = new TestReader(); +const src = new TestReader(); -for (var i = 0; i < 10; i++) { +for (let i = 0; i < 10; i++) { src.pipe(dest); src.unpipe(dest); } -assert.equal(src.listeners('end').length, 0); -assert.equal(src.listeners('readable').length, 0); +assert.strictEqual(src.listeners('end').length, 0); +assert.strictEqual(src.listeners('readable').length, 0); -assert.equal(dest.listeners('unpipe').length, 0); -assert.equal(dest.listeners('drain').length, 0); -assert.equal(dest.listeners('error').length, 0); -assert.equal(dest.listeners('close').length, 0); -assert.equal(dest.listeners('finish').length, 0); +assert.strictEqual(dest.listeners('unpipe').length, 0); +assert.strictEqual(dest.listeners('drain').length, 0); +assert.strictEqual(dest.listeners('error').length, 0); +assert.strictEqual(dest.listeners('close').length, 0); +assert.strictEqual(dest.listeners('finish').length, 0); console.error(src._readableState); process.on('exit', function() { diff --git a/test/parallel/test-stream2-writable.js b/test/parallel/test-stream2-writable.js index 5ecdd0f76ecb5a..c377ce9a510caa 100644 --- a/test/parallel/test-stream2-writable.js +++ b/test/parallel/test-stream2-writable.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var W = require('_stream_writable'); -var D = require('_stream_duplex'); -var assert = require('assert'); +const W = require('_stream_writable'); +const D = require('_stream_duplex'); +const assert = require('assert'); -var util = require('util'); +const util = require('util'); util.inherits(TestWriter, W); function TestWriter() { @@ -22,14 +22,14 @@ TestWriter.prototype._write = function(chunk, encoding, cb) { }.bind(this), Math.floor(Math.random() * 10)); }; -var chunks = new Array(50); -for (var i = 0; i < chunks.length; i++) { +const chunks = new Array(50); +for (let i = 0; i < chunks.length; i++) { chunks[i] = new Array(i + 1).join('x'); } // tiny node-tap lookalike. -var tests = []; -var count = 0; +const tests = []; +let count = 0; function test(name, fn) { count++; @@ -37,12 +37,12 @@ function test(name, fn) { } function run() { - var next = tests.shift(); + const next = tests.shift(); if (!next) return console.error('ok'); - var name = next[0]; - var fn = next[1]; + const name = next[0]; + const fn = next[1]; console.log('# %s', name); fn({ same: assert.deepStrictEqual, @@ -62,7 +62,7 @@ process.on('exit', function() { process.nextTick(run); test('write fast', function(t) { - var tw = new TestWriter({ + const tw = new TestWriter({ highWaterMark: 100 }); @@ -79,7 +79,7 @@ test('write fast', function(t) { }); test('write slow', function(t) { - var tw = new TestWriter({ + const tw = new TestWriter({ highWaterMark: 100 }); @@ -88,7 +88,7 @@ test('write slow', function(t) { t.end(); }); - var i = 0; + let i = 0; (function W() { tw.write(chunks[i++]); if (i < chunks.length) @@ -99,11 +99,11 @@ test('write slow', function(t) { }); test('write backpressure', function(t) { - var tw = new TestWriter({ + const tw = new TestWriter({ highWaterMark: 50 }); - var drains = 0; + let drains = 0; tw.on('finish', function() { t.same(tw.buffer, chunks, 'got chunks in the right order'); @@ -115,10 +115,11 @@ test('write backpressure', function(t) { drains++; }); - var i = 0; + let i = 0; (function W() { + let ret; do { - var ret = tw.write(chunks[i++]); + ret = tw.write(chunks[i++]); } while (ret !== false && i < chunks.length); if (i < chunks.length) { @@ -131,11 +132,11 @@ test('write backpressure', function(t) { }); test('write bufferize', function(t) { - var tw = new TestWriter({ + const tw = new TestWriter({ highWaterMark: 100 }); - var encodings = + const encodings = [ 'hex', 'utf8', 'utf-8', @@ -154,7 +155,7 @@ test('write bufferize', function(t) { }); chunks.forEach(function(chunk, i) { - var enc = encodings[i % encodings.length]; + const enc = encodings[i % encodings.length]; chunk = Buffer.from(chunk); tw.write(chunk.toString(enc), enc); }); @@ -162,7 +163,7 @@ test('write bufferize', function(t) { }); test('write no bufferize', function(t) { - var tw = new TestWriter({ + const tw = new TestWriter({ highWaterMark: 100, decodeStrings: false }); @@ -173,7 +174,7 @@ test('write no bufferize', function(t) { return TestWriter.prototype._write.call(this, chunk, encoding, cb); }; - var encodings = + const encodings = [ 'hex', 'utf8', 'utf-8', @@ -192,7 +193,7 @@ test('write no bufferize', function(t) { }); chunks.forEach(function(chunk, i) { - var enc = encodings[i % encodings.length]; + const enc = encodings[i % encodings.length]; chunk = Buffer.from(chunk); tw.write(chunk.toString(enc), enc); }); @@ -200,7 +201,7 @@ test('write no bufferize', function(t) { }); test('write callbacks', function(t) { - var callbacks = chunks.map(function(chunk, i) { + const callbacks = chunks.map(function(chunk, i) { return [i, function() { callbacks._called[i] = chunk; }]; @@ -210,7 +211,7 @@ test('write callbacks', function(t) { }, {}); callbacks._called = []; - var tw = new TestWriter({ + const tw = new TestWriter({ highWaterMark: 100 }); @@ -229,28 +230,28 @@ test('write callbacks', function(t) { }); test('end callback', function(t) { - var tw = new TestWriter(); + const tw = new TestWriter(); tw.end(function() { t.end(); }); }); test('end callback with chunk', function(t) { - var tw = new TestWriter(); + const tw = new TestWriter(); tw.end(Buffer.from('hello world'), function() { t.end(); }); }); test('end callback with chunk and encoding', function(t) { - var tw = new TestWriter(); + const tw = new TestWriter(); tw.end('hello world', 'ascii', function() { t.end(); }); }); test('end callback after .write() call', function(t) { - var tw = new TestWriter(); + const tw = new TestWriter(); tw.write(Buffer.from('hello world')); tw.end(function() { t.end(); @@ -258,8 +259,8 @@ test('end callback after .write() call', function(t) { }); test('end callback called after write callback', function(t) { - var tw = new TestWriter(); - var writeCalledback = false; + const tw = new TestWriter(); + let writeCalledback = false; tw.write(Buffer.from('hello world'), function() { writeCalledback = true; }); @@ -270,20 +271,20 @@ test('end callback called after write callback', function(t) { }); test('encoding should be ignored for buffers', function(t) { - var tw = new W(); - var hex = '018b5e9a8f6236ffe30e31baf80d2cf6eb'; + const tw = new W(); + const hex = '018b5e9a8f6236ffe30e31baf80d2cf6eb'; tw._write = function(chunk) { t.equal(chunk.toString('hex'), hex); t.end(); }; - var buf = Buffer.from(hex, 'hex'); + const buf = Buffer.from(hex, 'hex'); tw.write(buf, 'latin1'); }); test('writables are not pipable', function(t) { - var w = new W(); + const w = new W(); w._write = function() {}; - var gotError = false; + let gotError = false; w.on('error', function() { gotError = true; }); @@ -293,10 +294,10 @@ test('writables are not pipable', function(t) { }); test('duplexes are pipable', function(t) { - var d = new D(); + const d = new D(); d._read = function() {}; d._write = function() {}; - var gotError = false; + let gotError = false; d.on('error', function() { gotError = true; }); @@ -306,9 +307,9 @@ test('duplexes are pipable', function(t) { }); test('end(chunk) two times is an error', function(t) { - var w = new W(); + const w = new W(); w._write = function() {}; - var gotError = false; + let gotError = false; w.on('error', function(er) { gotError = true; t.equal(er.message, 'write after end'); @@ -322,8 +323,8 @@ test('end(chunk) two times is an error', function(t) { }); test('dont end while writing', function(t) { - var w = new W(); - var wrote = false; + const w = new W(); + let wrote = false; w._write = function(chunk, e, cb) { assert(!this.writing); wrote = true; @@ -342,8 +343,8 @@ test('dont end while writing', function(t) { }); test('finish does not come before write cb', function(t) { - var w = new W(); - var writeCb = false; + const w = new W(); + let writeCb = false; w._write = function(chunk, e, cb) { setTimeout(function() { writeCb = true; @@ -359,8 +360,8 @@ test('finish does not come before write cb', function(t) { }); test('finish does not come before sync _write cb', function(t) { - var w = new W(); - var writeCb = false; + const w = new W(); + let writeCb = false; w._write = function(chunk, e, cb) { cb(); }; @@ -375,7 +376,7 @@ test('finish does not come before sync _write cb', function(t) { }); test('finish is emitted if last chunk is empty', function(t) { - var w = new W(); + const w = new W(); w._write = function(chunk, e, cb) { process.nextTick(cb); }; diff --git a/test/parallel/test-stream3-cork-end.js b/test/parallel/test-stream3-cork-end.js index a0b611d0da1b66..7227f87ada7fa1 100644 --- a/test/parallel/test-stream3-cork-end.js +++ b/test/parallel/test-stream3-cork-end.js @@ -12,17 +12,17 @@ const Writable = stream.Writable; // node version target: 0.12 const expectedChunks = ['please', 'buffer', 'me', 'kindly']; -var inputChunks = expectedChunks.slice(0); -var seenChunks = []; -var seenEnd = false; +const inputChunks = expectedChunks.slice(0); +let seenChunks = []; +let seenEnd = false; -var w = new Writable(); +const w = new Writable(); // lets arrange to store the chunks w._write = function(chunk, encoding, cb) { // stream end event is not seen before the last write assert.ok(!seenEnd); // default encoding given none was specified - assert.equal(encoding, 'buffer'); + assert.strictEqual(encoding, 'buffer'); seenChunks.push(chunk); cb(); @@ -33,8 +33,8 @@ w.on('finish', () => { }); function writeChunks(remainingChunks, callback) { - var writeChunk = remainingChunks.shift(); - var writeState; + const writeChunk = remainingChunks.shift(); + let writeState; if (writeChunk) { setImmediate(() => { @@ -52,7 +52,7 @@ function writeChunks(remainingChunks, callback) { // do an initial write w.write('stuff'); // the write was immediate -assert.equal(seenChunks.length, 1); +assert.strictEqual(seenChunks.length, 1); // reset the seen chunks seenChunks = []; @@ -62,7 +62,7 @@ w.cork(); // write the bufferedChunks writeChunks(inputChunks, () => { // should not have seen anything yet - assert.equal(seenChunks.length, 0); + assert.strictEqual(seenChunks.length, 0); // trigger flush and ending the stream w.end(); @@ -71,15 +71,15 @@ writeChunks(inputChunks, () => { assert.ok(!seenEnd); // buffered bytes should be seen in current tick - assert.equal(seenChunks.length, 4); + assert.strictEqual(seenChunks.length, 4); // did the chunks match - for (var i = 0, l = expectedChunks.length; i < l; i++) { - var seen = seenChunks[i]; + for (let i = 0, l = expectedChunks.length; i < l; i++) { + const seen = seenChunks[i]; // there was a chunk assert.ok(seen); - var expected = new Buffer(expectedChunks[i]); + const expected = new Buffer(expectedChunks[i]); // it was what we expected assert.ok(seen.equals(expected)); } diff --git a/test/parallel/test-stream3-cork-uncork.js b/test/parallel/test-stream3-cork-uncork.js index cd86e8cf809bac..98f74a45c6624e 100644 --- a/test/parallel/test-stream3-cork-uncork.js +++ b/test/parallel/test-stream3-cork-uncork.js @@ -12,15 +12,15 @@ const Writable = stream.Writable; // node version target: 0.12 const expectedChunks = ['please', 'buffer', 'me', 'kindly']; -var inputChunks = expectedChunks.slice(0); -var seenChunks = []; -var seenEnd = false; +const inputChunks = expectedChunks.slice(0); +let seenChunks = []; +let seenEnd = false; -var w = new Writable(); +const w = new Writable(); // lets arrange to store the chunks w._write = function(chunk, encoding, cb) { // default encoding given none was specified - assert.equal(encoding, 'buffer'); + assert.strictEqual(encoding, 'buffer'); seenChunks.push(chunk); cb(); @@ -31,8 +31,8 @@ w.on('finish', () => { }); function writeChunks(remainingChunks, callback) { - var writeChunk = remainingChunks.shift(); - var writeState; + const writeChunk = remainingChunks.shift(); + let writeState; if (writeChunk) { setImmediate(() => { @@ -50,7 +50,7 @@ function writeChunks(remainingChunks, callback) { // do an initial write w.write('stuff'); // the write was immediate -assert.equal(seenChunks.length, 1); +assert.strictEqual(seenChunks.length, 1); // reset the chunks seen so far seenChunks = []; @@ -60,21 +60,21 @@ w.cork(); // write the bufferedChunks writeChunks(inputChunks, () => { // should not have seen anything yet - assert.equal(seenChunks.length, 0); + assert.strictEqual(seenChunks.length, 0); // trigger writing out the buffer w.uncork(); // buffered bytes shoud be seen in current tick - assert.equal(seenChunks.length, 4); + assert.strictEqual(seenChunks.length, 4); // did the chunks match - for (var i = 0, l = expectedChunks.length; i < l; i++) { - var seen = seenChunks[i]; + for (let i = 0, l = expectedChunks.length; i < l; i++) { + const seen = seenChunks[i]; // there was a chunk assert.ok(seen); - var expected = new Buffer(expectedChunks[i]); + const expected = new Buffer(expectedChunks[i]); // it was what we expected assert.ok(seen.equals(expected)); } diff --git a/test/parallel/test-stream3-pause-then-read.js b/test/parallel/test-stream3-pause-then-read.js index 64d25fefc94c86..a1be563683c0a2 100644 --- a/test/parallel/test-stream3-pause-then-read.js +++ b/test/parallel/test-stream3-pause-then-read.js @@ -1,18 +1,18 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var stream = require('stream'); -var Readable = stream.Readable; -var Writable = stream.Writable; +const stream = require('stream'); +const Readable = stream.Readable; +const Writable = stream.Writable; -var totalChunks = 100; -var chunkSize = 99; -var expectTotalData = totalChunks * chunkSize; -var expectEndingData = expectTotalData; +const totalChunks = 100; +const chunkSize = 99; +const expectTotalData = totalChunks * chunkSize; +let expectEndingData = expectTotalData; -var r = new Readable({ highWaterMark: 1000 }); -var chunks = totalChunks; +const r = new Readable({ highWaterMark: 1000 }); +let chunks = totalChunks; r._read = function(n) { if (!(chunks % 2)) setImmediate(push); @@ -22,9 +22,9 @@ r._read = function(n) { push(); }; -var totalPushed = 0; +let totalPushed = 0; function push() { - var chunk = chunks-- > 0 ? Buffer.alloc(chunkSize, 'x') : null; + const chunk = chunks-- > 0 ? Buffer.alloc(chunkSize, 'x') : null; if (chunk) { totalPushed += chunk.length; } @@ -42,11 +42,11 @@ function readn(n, then) { console.error('read %d', n); expectEndingData -= n; (function read() { - var c = r.read(n); + const c = r.read(n); if (!c) r.once('readable', read); else { - assert.equal(c.length, n); + assert.strictEqual(c.length, n); assert(!r._readableState.flowing); then(); } @@ -57,7 +57,7 @@ function readn(n, then) { function onData() { expectEndingData -= 100; console.error('onData'); - var seen = 0; + let seen = 0; r.on('data', function od(c) { seen += c.length; if (seen >= 100) { @@ -67,7 +67,7 @@ function onData() { if (seen > 100) { // oh no, seen too much! // put the extra back. - var diff = seen - 100; + const diff = seen - 100; r.unshift(c.slice(c.length - diff)); console.error('seen too much', seen, diff); } @@ -82,10 +82,10 @@ function onData() { function pipeLittle() { expectEndingData -= 200; console.error('pipe a little'); - var w = new Writable(); - var written = 0; + const w = new Writable(); + let written = 0; w.on('finish', function() { - assert.equal(written, 200); + assert.strictEqual(written, 200); setImmediate(read1234); }); w._write = function(chunk, encoding, cb) { @@ -95,7 +95,7 @@ function pipeLittle() { w.end(); cb(); if (written > 200) { - var diff = written - 200; + const diff = written - 200; written -= diff; r.unshift(chunk.slice(chunk.length - diff)); } @@ -130,16 +130,16 @@ function resumePause() { function pipe() { console.error('pipe the rest'); - var w = new Writable(); - var written = 0; + const w = new Writable(); + let written = 0; w._write = function(chunk, encoding, cb) { written += chunk.length; cb(); }; w.on('finish', function() { console.error('written', written, totalPushed); - assert.equal(written, expectEndingData); - assert.equal(totalPushed, expectTotalData); + assert.strictEqual(written, expectEndingData); + assert.strictEqual(totalPushed, expectTotalData); console.log('ok'); }); r.pipe(w); diff --git a/test/parallel/test-string-decoder-end.js b/test/parallel/test-string-decoder-end.js index 33b47a034a93bc..6e9eea3193e163 100644 --- a/test/parallel/test-string-decoder-end.js +++ b/test/parallel/test-string-decoder-end.js @@ -4,19 +4,15 @@ // result of the entire buffer. require('../common'); -var assert = require('assert'); -var SD = require('string_decoder').StringDecoder; -var encodings = ['base64', 'hex', 'utf8', 'utf16le', 'ucs2']; +const assert = require('assert'); +const SD = require('string_decoder').StringDecoder; +const encodings = ['base64', 'hex', 'utf8', 'utf16le', 'ucs2']; -var bufs = [ '☃💩', 'asdf' ].map(function(b) { - return Buffer.from(b); -}); +const bufs = [ '☃💩', 'asdf' ].map((b) => Buffer.from(b)); // also test just arbitrary bytes from 0-15. -for (var i = 1; i <= 16; i++) { - var bytes = new Array(i).join('.').split('.').map(function(_, j) { - return j + 0x78; - }); +for (let i = 1; i <= 16; i++) { + const bytes = new Array(i).join('.').split('.').map((_, j) => j + 0x78); bufs.push(Buffer.from(bytes)); } @@ -25,7 +21,7 @@ encodings.forEach(testEncoding); console.log('ok'); function testEncoding(encoding) { - bufs.forEach(function(buf) { + bufs.forEach((buf) => { testBuf(encoding, buf); }); } @@ -34,25 +30,25 @@ function testBuf(encoding, buf) { console.error('# %s', encoding, buf); // write one byte at a time. - var s = new SD(encoding); - var res1 = ''; - for (var i = 0; i < buf.length; i++) { + let s = new SD(encoding); + let res1 = ''; + for (let i = 0; i < buf.length; i++) { res1 += s.write(buf.slice(i, i + 1)); } res1 += s.end(); // write the whole buffer at once. - var res2 = ''; + let res2 = ''; s = new SD(encoding); res2 += s.write(buf); res2 += s.end(); // .toString() on the buffer - var res3 = buf.toString(encoding); + const res3 = buf.toString(encoding); console.log('expect=%j', res3); console.log('res1=%j', res1); console.log('res2=%j', res2); - assert.equal(res1, res3, 'one byte at a time should match toString'); - assert.equal(res2, res3, 'all bytes at once should match toString'); + assert.strictEqual(res1, res3, 'one byte at a time should match toString'); + assert.strictEqual(res2, res3, 'all bytes at once should match toString'); } diff --git a/test/parallel/test-string-decoder.js b/test/parallel/test-string-decoder.js index 151ae8b4e0b11a..a8fdb999a0923f 100644 --- a/test/parallel/test-string-decoder.js +++ b/test/parallel/test-string-decoder.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var inspect = require('util').inspect; -var StringDecoder = require('string_decoder').StringDecoder; +const assert = require('assert'); +const inspect = require('util').inspect; +const StringDecoder = require('string_decoder').StringDecoder; // Test default encoding -var decoder = new StringDecoder(); +let decoder = new StringDecoder(); assert.strictEqual(decoder.encoding, 'utf8'); process.stdout.write('scanning '); @@ -104,28 +104,36 @@ assert.strictEqual(decoder.write(Buffer.from('3DD8', 'hex')), ''); assert.strictEqual(decoder.write(Buffer.from('4D', 'hex')), ''); assert.strictEqual(decoder.end(), '\ud83d'); +assert.throws(() => { + new StringDecoder(1); +}, /^Error: Unknown encoding: 1$/); + +assert.throws(() => { + new StringDecoder('test'); +}, /^Error: Unknown encoding: test$/); + // test verifies that StringDecoder will correctly decode the given input // buffer with the given encoding to the expected output. It will attempt all // possible ways to write() the input buffer, see writeSequences(). The // singleSequence allows for easy debugging of a specific sequence which is // useful in case of test failures. function test(encoding, input, expected, singleSequence) { - var sequences; + let sequences; if (!singleSequence) { sequences = writeSequences(input.length); } else { sequences = [singleSequence]; } - sequences.forEach(function(sequence) { - var decoder = new StringDecoder(encoding); - var output = ''; - sequence.forEach(function(write) { + sequences.forEach((sequence) => { + const decoder = new StringDecoder(encoding); + let output = ''; + sequence.forEach((write) => { output += decoder.write(input.slice(write[0], write[1])); }); output += decoder.end(); process.stdout.write('.'); if (output !== expected) { - var message = + const message = 'Expected "' + unicodeEscape(expected) + '", ' + 'but got "' + unicodeEscape(output) + '"\n' + 'input: ' + input.toString('hex').match(/.{2}/g) + '\n' + @@ -138,8 +146,8 @@ function test(encoding, input, expected, singleSequence) { // unicodeEscape prints the str contents as unicode escape codes. function unicodeEscape(str) { - var r = ''; - for (var i = 0; i < str.length; i++) { + let r = ''; + for (let i = 0; i < str.length; i++) { r += '\\u' + str.charCodeAt(i).toString(16); } return r; @@ -162,10 +170,10 @@ function writeSequences(length, start, sequence) { } else if (start === length) { return [sequence]; } - var sequences = []; - for (var end = length; end > start; end--) { - var subSequence = sequence.concat([[start, end]]); - var subSequences = writeSequences(length, end, subSequence, sequences); + let sequences = []; + for (let end = length; end > start; end--) { + const subSequence = sequence.concat([[start, end]]); + const subSequences = writeSequences(length, end, subSequence, sequences); sequences = sequences.concat(subSequences); } return sequences; diff --git a/test/parallel/test-stringbytes-external.js b/test/parallel/test-stringbytes-external.js index a34612f75d71f6..94b58d9c6eadf0 100644 --- a/test/parallel/test-stringbytes-external.js +++ b/test/parallel/test-stringbytes-external.js @@ -1,29 +1,29 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // minimum string size to overflow into external string space -var EXTERN_APEX = 0xFBEE9; +const EXTERN_APEX = 0xFBEE9; // manually controlled string for checking binary output -var ucs2_control = 'a\u0000'; -var write_str = 'a'; +let ucs2_control = 'a\u0000'; +let write_str = 'a'; // first do basic checks -var b = Buffer.from(write_str, 'ucs2'); +let b = Buffer.from(write_str, 'ucs2'); // first check latin1 -var c = b.toString('latin1'); -assert.equal(b[0], 0x61); -assert.equal(b[1], 0); -assert.equal(ucs2_control, c); +let c = b.toString('latin1'); +assert.strictEqual(b[0], 0x61); +assert.strictEqual(b[1], 0); +assert.strictEqual(ucs2_control, c); // now check binary c = b.toString('binary'); -assert.equal(b[0], 0x61); -assert.equal(b[1], 0); -assert.equal(ucs2_control, c); +assert.strictEqual(b[0], 0x61); +assert.strictEqual(b[1], 0); +assert.strictEqual(ucs2_control, c); // now create big strings -var size = 1 + (1 << 20); +const size = 1 + (1 << 20); write_str = Array(size).join(write_str); ucs2_control = Array(size).join(ucs2_control); @@ -31,40 +31,40 @@ ucs2_control = Array(size).join(ucs2_control); b = Buffer.from(write_str, 'ucs2'); // check fist Buffer created from write string for (let i = 0; i < b.length; i += 2) { - assert.equal(b[i], 0x61); - assert.equal(b[i + 1], 0); + assert.strictEqual(b[i], 0x61); + assert.strictEqual(b[i + 1], 0); } // create another string to create an external string -var b_ucs = b.toString('ucs2'); +const b_ucs = b.toString('ucs2'); // check control against external binary string -var l_bin = b.toString('latin1'); -assert.equal(ucs2_control, l_bin); +const l_bin = b.toString('latin1'); +assert.strictEqual(ucs2_control, l_bin); // check control against external binary string -var b_bin = b.toString('binary'); -assert.equal(ucs2_control, b_bin); +const b_bin = b.toString('binary'); +assert.strictEqual(ucs2_control, b_bin); // create buffer copy from external -var c_bin = Buffer.from(l_bin, 'latin1'); -var c_ucs = Buffer.from(b_ucs, 'ucs2'); +const c_bin = Buffer.from(l_bin, 'latin1'); +const c_ucs = Buffer.from(b_ucs, 'ucs2'); // make sure they're the same length -assert.equal(c_bin.length, c_ucs.length); +assert.strictEqual(c_bin.length, c_ucs.length); // make sure Buffers from externals are the same for (let i = 0; i < c_bin.length; i++) { - assert.equal(c_bin[i], c_ucs[i]); + assert.strictEqual(c_bin[i], c_ucs[i]); } // check resultant strings -assert.equal(c_bin.toString('ucs2'), c_ucs.toString('ucs2')); -assert.equal(c_bin.toString('latin1'), ucs2_control); -assert.equal(c_ucs.toString('latin1'), ucs2_control); +assert.strictEqual(c_bin.toString('ucs2'), c_ucs.toString('ucs2')); +assert.strictEqual(c_bin.toString('latin1'), ucs2_control); +assert.strictEqual(c_ucs.toString('latin1'), ucs2_control); // now let's test BASE64 and HEX ecoding/decoding -var RADIOS = 2; -var PRE_HALF_APEX = Math.ceil(EXTERN_APEX / 2) - RADIOS; -var PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS; +const RADIOS = 2; +const PRE_HALF_APEX = Math.ceil(EXTERN_APEX / 2) - RADIOS; +const PRE_3OF4_APEX = Math.ceil((EXTERN_APEX / 4) * 3) - RADIOS; { for (let j = 0; j < RADIOS * 2; j += 1) { diff --git a/test/parallel/test-sync-io-option.js b/test/parallel/test-sync-io-option.js index fec61ef62f370e..fb0b2333e82e4c 100644 --- a/test/parallel/test-sync-io-option.js +++ b/test/parallel/test-sync-io-option.js @@ -12,20 +12,20 @@ if (process.argv[2] === 'child') { } else { (function runTest(flags) { - var execArgv = [flags.pop()]; - var args = [__filename, 'child']; - var cntr = 0; + const execArgv = [flags.pop()]; + let args = [__filename, 'child']; + let cntr = 0; args = execArgv.concat(args); if (!args[0]) args.shift(); execFile(process.execPath, args, function(err, stdout, stderr) { - assert.equal(err, null); - assert.equal(stdout, ''); + assert.strictEqual(err, null); + assert.strictEqual(stdout, ''); if (/WARNING[\s\S]*fs\.readFileSync/.test(stderr)) cntr++; if (args[0] === '--trace-sync-io') { - assert.equal(cntr, 1); + assert.strictEqual(cntr, 1); } else if (args[0] === __filename) { - assert.equal(cntr, 0); + assert.strictEqual(cntr, 0); } else { throw new Error('UNREACHABLE'); } diff --git a/test/parallel/test-sys.js b/test/parallel/test-sys.js index 3e28f020333c20..234744bb118fd7 100644 --- a/test/parallel/test-sys.js +++ b/test/parallel/test-sys.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var sys = require('sys'); // eslint-disable-line no-restricted-modules -var util = require('util'); +const assert = require('assert'); +const sys = require('sys'); // eslint-disable-line no-restricted-modules +const util = require('util'); assert.strictEqual(sys, util); diff --git a/test/parallel/test-tcp-wrap-connect.js b/test/parallel/test-tcp-wrap-connect.js index 7ce88d194cd648..77f9814db2ebe5 100644 --- a/test/parallel/test-tcp-wrap-connect.js +++ b/test/parallel/test-tcp-wrap-connect.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var TCP = process.binding('tcp_wrap').TCP; -var TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap; -var ShutdownWrap = process.binding('stream_wrap').ShutdownWrap; +const assert = require('assert'); +const TCP = process.binding('tcp_wrap').TCP; +const TCPConnectWrap = process.binding('tcp_wrap').TCPConnectWrap; +const ShutdownWrap = process.binding('stream_wrap').ShutdownWrap; function makeConnection() { - var client = new TCP(); + const client = new TCP(); - var req = new TCPConnectWrap(); - var err = client.connect(req, '127.0.0.1', this.address().port); + const req = new TCPConnectWrap(); + const err = client.connect(req, '127.0.0.1', this.address().port); assert.strictEqual(err, 0); req.oncomplete = function(status, client_, req_, readable, writable) { @@ -19,8 +19,8 @@ function makeConnection() { assert.strictEqual(true, readable); assert.strictEqual(true, writable); - var shutdownReq = new ShutdownWrap(); - var err = client.shutdown(shutdownReq); + const shutdownReq = new ShutdownWrap(); + const err = client.shutdown(shutdownReq); assert.strictEqual(err, 0); shutdownReq.oncomplete = function(status, client_, req_) { @@ -35,11 +35,11 @@ function makeConnection() { ///// -var connectCount = 0; -var endCount = 0; -var shutdownCount = 0; +let connectCount = 0; +let endCount = 0; +let shutdownCount = 0; -var server = require('net').Server(function(s) { +const server = require('net').Server(function(s) { connectCount++; s.resume(); s.on('end', function() { diff --git a/test/parallel/test-tcp-wrap.js b/test/parallel/test-tcp-wrap.js index 18b8fe401f8902..aee0bcc8509fdf 100644 --- a/test/parallel/test-tcp-wrap.js +++ b/test/parallel/test-tcp-wrap.js @@ -1,20 +1,20 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var TCP = process.binding('tcp_wrap').TCP; -var uv = process.binding('uv'); +const TCP = process.binding('tcp_wrap').TCP; +const uv = process.binding('uv'); -var handle = new TCP(); +const handle = new TCP(); // Should be able to bind to the port -var err = handle.bind('0.0.0.0', 0); -assert.equal(err, 0); +let err = handle.bind('0.0.0.0', 0); +assert.strictEqual(err, 0); // Should not be able to bind to the same port again -var out = {}; +const out = {}; handle.getsockname(out); err = handle.bind('0.0.0.0', out.port); -assert.equal(err, uv.UV_EINVAL); +assert.strictEqual(err, uv.UV_EINVAL); handle.close(); diff --git a/test/parallel/test-timer-close.js b/test/parallel/test-timer-close.js index f13078e5a5bed1..aae93f25c55ec0 100644 --- a/test/parallel/test-timer-close.js +++ b/test/parallel/test-timer-close.js @@ -1,16 +1,11 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); -var t = new (process.binding('timer_wrap').Timer)(); -var called = 0; -function onclose() { - called++; -} +// Make sure handle._handle.close(callback) is idempotent by closing a timer +// twice. The first function should be called, the second one should not. -t.close(onclose); -t.close(onclose); +const Timer = process.binding('timer_wrap').Timer; +const t = new Timer(); -process.on('exit', function() { - assert.equal(1, called); -}); +t.close(common.mustCall(function() {})); +t.close(() => common.fail('This should never be called')); diff --git a/test/parallel/test-timers-active.js b/test/parallel/test-timers-active.js index 8677e43971ac89..62707cf18c0ab7 100644 --- a/test/parallel/test-timers-active.js +++ b/test/parallel/test-timers-active.js @@ -4,7 +4,7 @@ const assert = require('assert'); const active = require('timers').active; // active() should create timers for these -var legitTimers = [ +const legitTimers = [ { _idleTimeout: 0 }, { _idleTimeout: 1 } ]; @@ -21,7 +21,7 @@ legitTimers.forEach(function(legit) { // active() should not create a timer for these -var bogusTimers = [ +const bogusTimers = [ { _idleTimeout: -1 }, { _idleTimeout: undefined }, ]; diff --git a/test/parallel/test-timers-args.js b/test/parallel/test-timers-args.js index 21eafd1bcd9ea6..1ba44d8bcf3664 100644 --- a/test/parallel/test-timers-args.js +++ b/test/parallel/test-timers-args.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); function range(n) { return 'x'.repeat(n + 1).split('').map(function(_, i) { return i; }); } function timeout(nargs) { - var args = range(nargs); + const args = range(nargs); setTimeout.apply(null, [callback, 1].concat(args)); function callback() { @@ -17,8 +17,8 @@ function timeout(nargs) { } function interval(nargs) { - var args = range(nargs); - var timer = setTimeout.apply(null, [callback, 1].concat(args)); + const args = range(nargs); + const timer = setTimeout.apply(null, [callback, 1].concat(args)); function callback() { clearInterval(timer); diff --git a/test/parallel/test-timers-clearImmediate.js b/test/parallel/test-timers-clearImmediate.js index ab65b7bf1ce05d..c49fd7622f4ab6 100644 --- a/test/parallel/test-timers-clearImmediate.js +++ b/test/parallel/test-timers-clearImmediate.js @@ -3,14 +3,14 @@ require('../common'); const assert = require('assert'); const N = 3; -var count = 0; +let count = 0; function next() { const immediate = setImmediate(function() { clearImmediate(immediate); ++count; }); } -for (var i = 0; i < N; ++i) +for (let i = 0; i < N; ++i) next(); process.on('exit', () => { diff --git a/test/parallel/test-timers-immediate-queue.js b/test/parallel/test-timers-immediate-queue.js index 62482d510a6608..103cd964511a53 100644 --- a/test/parallel/test-timers-immediate-queue.js +++ b/test/parallel/test-timers-immediate-queue.js @@ -1,20 +1,18 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // setImmediate should run clear its queued cbs once per event loop turn // but immediates queued while processing the current queue should happen // on the next turn of the event loop. -// in v0.10 hit should be 1, because we only process one cb per turn -// in v0.11 and beyond it should be the exact same size of QUEUE -// if we're letting things recursively add to the immediate QUEUE hit will be -// > QUEUE +// hit should be the exact same size of QUEUE, if we're letting things +// recursively add to the immediate QUEUE hit will be > QUEUE -var ticked = false; +let ticked = false; -var hit = 0; -var QUEUE = 1000; +let hit = 0; +const QUEUE = 1000; function run() { if (hit === 0) @@ -26,7 +24,7 @@ function run() { setImmediate(run); } -for (var i = 0; i < QUEUE; i++) +for (let i = 0; i < QUEUE; i++) setImmediate(run); process.on('exit', function() { diff --git a/test/parallel/test-timers-immediate.js b/test/parallel/test-timers-immediate.js index 9632022917f152..4afc642a334101 100644 --- a/test/parallel/test-timers-immediate.js +++ b/test/parallel/test-timers-immediate.js @@ -2,7 +2,6 @@ const common = require('../common'); const assert = require('assert'); -let immediateB; let immediateC; let immediateD; @@ -13,7 +12,7 @@ setImmediate(common.mustCall(function() { clearImmediate(immediateB); })); -immediateB = setImmediate(function() { +const immediateB = setImmediate(function() { common.fail('this immediate should not run'); }); diff --git a/test/parallel/test-timers-nested.js b/test/parallel/test-timers-nested.js index d5d272ed2eae11..0ff228abf50311 100644 --- a/test/parallel/test-timers-nested.js +++ b/test/parallel/test-timers-nested.js @@ -11,7 +11,7 @@ const assert = require('assert'); const scenarios = [0, 100]; scenarios.forEach(function(delay) { - var nestedCalled = false; + let nestedCalled = false; setTimeout(function A() { // Create the nested timer with the same delay as the outer timer so that it diff --git a/test/parallel/test-timers-non-integer-delay.js b/test/parallel/test-timers-non-integer-delay.js index b42053db3b1895..cd7fa5e661dc81 100644 --- a/test/parallel/test-timers-non-integer-delay.js +++ b/test/parallel/test-timers-non-integer-delay.js @@ -1,4 +1,6 @@ 'use strict'; +require('../common'); + /* * This test makes sure that non-integer timer delays do not make the process * hang. See https://github.com/joyent/node/issues/8065 and @@ -15,13 +17,11 @@ * it 100%. */ -require('../common'); - -var TIMEOUT_DELAY = 1.1; -var NB_TIMEOUTS_FIRED = 50; +const TIMEOUT_DELAY = 1.1; +const NB_TIMEOUTS_FIRED = 50; -var nbTimeoutFired = 0; -var interval = setInterval(function() { +let nbTimeoutFired = 0; +const interval = setInterval(function() { ++nbTimeoutFired; if (nbTimeoutFired === NB_TIMEOUTS_FIRED) { clearInterval(interval); diff --git a/test/parallel/test-timers-ordering.js b/test/parallel/test-timers-ordering.js index c23af9d8307e9a..853f80a66a2384 100644 --- a/test/parallel/test-timers-ordering.js +++ b/test/parallel/test-timers-ordering.js @@ -1,22 +1,22 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var Timer = process.binding('timer_wrap').Timer; +const assert = require('assert'); -var N = 30; +const Timer = process.binding('timer_wrap').Timer; +const N = 30; -var last_i = 0; -var last_ts = 0; +let last_i = 0; +let last_ts = 0; -var f = function(i) { +const f = function(i) { if (i <= N) { // check order - assert.equal(i, last_i + 1, 'order is broken: ' + i + ' != ' + + assert.strictEqual(i, last_i + 1, 'order is broken: ' + i + ' != ' + last_i + ' + 1'); last_i = i; // check that this iteration is fired at least 1ms later than the previous - var now = Timer.now(); + const now = Timer.now(); console.log(i, now); assert(now >= last_ts + 1, 'current ts ' + now + ' < prev ts ' + last_ts + ' + 1'); diff --git a/test/parallel/test-timers-reset-process-domain-on-throw.js b/test/parallel/test-timers-reset-process-domain-on-throw.js index 55e7ef57dcafc4..946ae715b0e193 100644 --- a/test/parallel/test-timers-reset-process-domain-on-throw.js +++ b/test/parallel/test-timers-reset-process-domain-on-throw.js @@ -28,7 +28,7 @@ function err() { function handleDomainError(e) { // In the domain's error handler, the current active domain should be the // domain within which the error was thrown. - assert.equal(process.domain, d); + assert.strictEqual(process.domain, d); } } diff --git a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js index 8670c3c2b6e8f3..f42144360b6941 100644 --- a/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js +++ b/test/parallel/test-timers-socket-timeout-removes-other-socket-unref-timer.js @@ -32,7 +32,7 @@ const server = net.createServer(function onClient(client) { }); server.listen(0, common.localhostIPv4, function() { - var nbClientsEnded = 0; + let nbClientsEnded = 0; function addEndedClient(client) { ++nbClientsEnded; diff --git a/test/parallel/test-timers-uncaught-exception.js b/test/parallel/test-timers-uncaught-exception.js index 6b6dc583715849..31a2d7eccd8105 100644 --- a/test/parallel/test-timers-uncaught-exception.js +++ b/test/parallel/test-timers-uncaught-exception.js @@ -1,40 +1,18 @@ 'use strict'; -require('../common'); -var assert = require('assert'); - -var exceptions = 0; -var timer1 = 0; -var timer2 = 0; +const common = require('../common'); +const assert = require('assert'); +const errorMsg = 'BAM!'; // the first timer throws... -console.error('set first timer'); -setTimeout(function() { - console.error('first timer'); - timer1++; - throw new Error('BAM!'); -}, 100); +setTimeout(common.mustCall(function() { + throw new Error(errorMsg); +}), 1); // ...but the second one should still run -console.error('set second timer'); -setTimeout(function() { - console.error('second timer'); - assert.equal(timer1, 1); - timer2++; -}, 100); +setTimeout(common.mustCall(function() {}), 1); function uncaughtException(err) { - console.error('uncaught handler'); - assert.equal(err.message, 'BAM!'); - exceptions++; + assert.strictEqual(err.message, errorMsg); } -process.on('uncaughtException', uncaughtException); -var exited = false; -process.on('exit', function() { - assert(!exited); - exited = true; - process.removeListener('uncaughtException', uncaughtException); - assert.equal(exceptions, 1); - assert.equal(timer1, 1); - assert.equal(timer2, 1); -}); +process.on('uncaughtException', common.mustCall(uncaughtException)); diff --git a/test/parallel/test-timers-unref-active.js b/test/parallel/test-timers-unref-active.js index 69027277ea0ff2..69f6d4e9f1bce4 100644 --- a/test/parallel/test-timers-unref-active.js +++ b/test/parallel/test-timers-unref-active.js @@ -19,8 +19,8 @@ require('../common'); const timers = require('timers'); const assert = require('assert'); -var someObject = {}; -var nbTimeouts = 0; +const someObject = {}; +let nbTimeouts = 0; /* * libuv 0.10.x uses GetTickCount on Windows to implement timers, which uses @@ -47,5 +47,5 @@ someObject._onTimeout = function _onTimeout() { timers._unrefActive(someObject); setTimeout(function() { - assert.equal(nbTimeouts, N); + assert.strictEqual(nbTimeouts, N); }, TEST_DURATION); diff --git a/test/parallel/test-timers-unref-call.js b/test/parallel/test-timers-unref-call.js index edd5865e8f610b..5384441838763a 100644 --- a/test/parallel/test-timers-unref-call.js +++ b/test/parallel/test-timers-unref-call.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var Timer = process.binding('timer_wrap').Timer; +const Timer = process.binding('timer_wrap').Timer; Timer.now = function() { return ++Timer.now.ticks; }; Timer.now.ticks = 0; -var t = setInterval(function() {}, 1); -var o = { _idleStart: 0, _idleTimeout: 1 }; +const t = setInterval(function() {}, 1); +const o = { _idleStart: 0, _idleTimeout: 1 }; t.unref.call(o); setTimeout(clearInterval.bind(null, t), 2); diff --git a/test/parallel/test-timers-unref-leak.js b/test/parallel/test-timers-unref-leak.js index a1b1265763bf1d..8eef00dd4ffe92 100644 --- a/test/parallel/test-timers-unref-leak.js +++ b/test/parallel/test-timers-unref-leak.js @@ -1,17 +1,17 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var called = 0; -var closed = 0; +let called = 0; +let closed = 0; -var timeout = setTimeout(function() { +const timeout = setTimeout(function() { called++; }, 10); timeout.unref(); // Wrap `close` method to check if the handle was closed -var close = timeout._handle.close; +const close = timeout._handle.close; timeout._handle.close = function() { closed++; return close.apply(this, arguments); @@ -22,6 +22,6 @@ setTimeout(function() { }, 50); process.on('exit', function() { - assert.equal(called, 1); - assert.equal(closed, 1); + assert.strictEqual(called, 1); + assert.strictEqual(closed, 1); }); diff --git a/test/parallel/test-timers-unref-remove-other-unref-timers-only-one-fires.js b/test/parallel/test-timers-unref-remove-other-unref-timers-only-one-fires.js index 971c485a4cf986..ce63ad8d2968e7 100644 --- a/test/parallel/test-timers-unref-remove-other-unref-timers-only-one-fires.js +++ b/test/parallel/test-timers-unref-remove-other-unref-timers-only-one-fires.js @@ -14,7 +14,7 @@ require('../common'); const timers = require('timers'); const assert = require('assert'); -var nbTimersFired = 0; +let nbTimersFired = 0; const foo = { _onTimeout: function() { @@ -37,5 +37,5 @@ timers.enroll(foo, 1); timers._unrefActive(foo); setTimeout(function() { - assert.notEqual(nbTimersFired, 2); + assert.notStrictEqual(nbTimersFired, 2); }, 20); diff --git a/test/parallel/test-timers-unref.js b/test/parallel/test-timers-unref.js index 801b34792a1f73..2bde08f914d790 100644 --- a/test/parallel/test-timers-unref.js +++ b/test/parallel/test-timers-unref.js @@ -1,6 +1,6 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); let interval_fired = false; let timeout_fired = false; @@ -9,8 +9,8 @@ let unref_timer = false; let unref_callbacks = 0; let checks = 0; -var LONG_TIME = 10 * 1000; -var SHORT_TIME = 100; +const LONG_TIME = 10 * 1000; +const SHORT_TIME = 100; assert.doesNotThrow(function() { setTimeout(function() {}, 10).unref().ref().unref(); diff --git a/test/parallel/test-timers-unrefd-interval-still-fires.js b/test/parallel/test-timers-unrefd-interval-still-fires.js index 39bb2cdb138205..bf16013f004965 100644 --- a/test/parallel/test-timers-unrefd-interval-still-fires.js +++ b/test/parallel/test-timers-unrefd-interval-still-fires.js @@ -6,7 +6,7 @@ const common = require('../common'); const TEST_DURATION = common.platformTimeout(1000); const N = 3; -var nbIntervalFired = 0; +let nbIntervalFired = 0; const keepOpen = setTimeout(() => { console.error('[FAIL] Interval fired %d/%d times.', nbIntervalFired, N); diff --git a/test/parallel/test-timers-unrefed-in-beforeexit.js b/test/parallel/test-timers-unrefed-in-beforeexit.js index 0ac3311816fb4d..530d97674d8bf7 100644 --- a/test/parallel/test-timers-unrefed-in-beforeexit.js +++ b/test/parallel/test-timers-unrefed-in-beforeexit.js @@ -3,7 +3,7 @@ require('../common'); const assert = require('assert'); -var once = 0; +let once = 0; process.on('beforeExit', () => { if (once > 1) diff --git a/test/parallel/test-timers.js b/test/parallel/test-timers.js index 0b379e0eb45ad0..df2240d2c444af 100644 --- a/test/parallel/test-timers.js +++ b/test/parallel/test-timers.js @@ -1,8 +1,8 @@ 'use strict'; -require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var inputs = [ +const inputs = [ undefined, null, true, @@ -18,35 +18,43 @@ var inputs = [ -10, -1, -0.5, + -0.1, -0.0, 0, 0.0, + 0.1, 0.5, 1, 1.0, - 10, 2147483648, // browser behaviour: timeouts > 2^31-1 run on next tick 12345678901234 // ditto ]; -var timeouts = []; -var intervals = []; +const timeouts = []; +const intervals = []; inputs.forEach(function(value, index) { setTimeout(function() { timeouts[index] = true; }, value); - var handle = setInterval(function() { + const handle = setInterval(function() { clearInterval(handle); // disarm timer or we'll never finish intervals[index] = true; }, value); }); -process.on('exit', function() { - // assert that all timers have run +// All values in inputs array coerce to 1 ms. Therefore, they should all run +// before a timer set here for 2 ms. + +setTimeout(common.mustCall(function() { + // assert that all other timers have run inputs.forEach(function(value, index) { - assert.equal(true, timeouts[index]); - assert.equal(true, intervals[index]); + assert(timeouts[index]); + assert(intervals[index]); }); -}); +}), 2); + +// Test 10 ms timeout separately. +setTimeout(common.mustCall(function() {}), 10); +setInterval(common.mustCall(function() { clearInterval(this); }), 10); diff --git a/test/parallel/test-tls-addca.js b/test/parallel/test-tls-addca.js index 0e9571efdf0abf..7a6f9a77516e22 100644 --- a/test/parallel/test-tls-addca.js +++ b/test/parallel/test-tls-addca.js @@ -1,62 +1,50 @@ 'use strict'; const common = require('../common'); -const fs = require('fs'); -if (!common.hasCrypto) { - common.skip('missing crypto'); - return; -} -const tls = require('tls'); - -function filenamePEM(n) { - return require('path').join(common.fixturesDir, 'keys', n + '.pem'); -} +// Adding a CA certificate to contextWithCert should not also add it to +// contextWithoutCert. This is tested by trying to connect to a server that +// depends on that CA using contextWithoutCert. -function loadPEM(n) { - return fs.readFileSync(filenamePEM(n)); -} +const join = require('path').join; +const { + assert, connect, keys, tls +} = require(join(common.fixturesDir, 'tls-connect'))(); -const caCert = loadPEM('ca1-cert'); const contextWithoutCert = tls.createSecureContext({}); const contextWithCert = tls.createSecureContext({}); -// Adding a CA certificate to contextWithCert should not also add it to -// contextWithoutCert. This is tested by trying to connect to a server that -// depends on that CA using contextWithoutCert. -contextWithCert.context.addCACert(caCert); +contextWithCert.context.addCACert(keys.agent1.ca); const serverOptions = { - key: loadPEM('agent1-key'), - cert: loadPEM('agent1-cert'), + key: keys.agent1.key, + cert: keys.agent1.cert, }; -const server = tls.createServer(serverOptions, function() {}); const clientOptions = { - port: undefined, - ca: [caCert], + ca: [keys.agent1.ca], servername: 'agent1', rejectUnauthorized: true, }; -function startTest() { - // This client should fail to connect because it doesn't trust the CA +// This client should fail to connect because it doesn't trust the CA +// certificate. +clientOptions.secureContext = contextWithoutCert; + +connect({ + client: clientOptions, + server: serverOptions, +}, function(err, pair, cleanup) { + assert(err); + assert.strictEqual(err.message, 'unable to verify the first certificate'); + cleanup(); + + // This time it should connect because contextWithCert includes the needed CA // certificate. - clientOptions.secureContext = contextWithoutCert; - clientOptions.port = server.address().port; - const client = tls.connect(clientOptions, common.fail); - client.on('error', common.mustCall(() => { - client.destroy(); - - // This time it should connect because contextWithCert includes the needed - // CA certificate. - clientOptions.secureContext = contextWithCert; - const client2 = tls.connect(clientOptions, common.mustCall(() => { - client2.destroy(); - server.close(); - })); - client2.on('error', (e) => { - console.log(e); - }); - })); -} - -server.listen(0, startTest); + clientOptions.secureContext = contextWithCert; + connect({ + client: clientOptions, + server: serverOptions, + }, function(err, pair, cleanup) { + assert.ifError(err); + cleanup(); + }); +}); diff --git a/test/parallel/test-tls-alert.js b/test/parallel/test-tls-alert.js index db22443918453b..a8c6016f6218b7 100644 --- a/test/parallel/test-tls-alert.js +++ b/test/parallel/test-tls-alert.js @@ -1,6 +1,6 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.opensslCli) { common.skip('node compiled without OpenSSL CLI.'); @@ -11,12 +11,12 @@ if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var spawn = require('child_process').spawn; +const fs = require('fs'); +const spawn = require('child_process').spawn; -var success = false; +let success = false; function filenamePEM(n) { return require('path').join(common.fixturesDir, 'keys', n + '.pem'); @@ -26,20 +26,20 @@ function loadPEM(n) { return fs.readFileSync(filenamePEM(n)); } -var server = tls.Server({ +const server = tls.Server({ secureProtocol: 'TLSv1_2_server_method', key: loadPEM('agent2-key'), cert: loadPEM('agent2-cert') }, null).listen(0, function() { - var args = ['s_client', '-quiet', '-tls1_1', - '-connect', `127.0.0.1:${this.address().port}`]; + const args = ['s_client', '-quiet', '-tls1_1', + '-connect', `127.0.0.1:${this.address().port}`]; // for the performance and stability issue in s_client on Windows if (common.isWindows) args.push('-no_rand_screen'); - var client = spawn(common.opensslCli, args); - var out = ''; + const client = spawn(common.opensslCli, args); + let out = ''; client.stderr.setEncoding('utf8'); client.stderr.on('data', function(d) { out += d; diff --git a/test/parallel/test-tls-alpn-server-client.js b/test/parallel/test-tls-alpn-server-client.js index 0da2086f4de506..ca5785b09ac05a 100644 --- a/test/parallel/test-tls-alpn-server-client.js +++ b/test/parallel/test-tls-alpn-server-client.js @@ -24,7 +24,7 @@ function loadPEM(n) { return fs.readFileSync(filenamePEM(n)); } -var serverIP = common.localhostIPv4; +const serverIP = common.localhostIPv4; function checkResults(result, expected) { assert.strictEqual(result.server.ALPN, expected.server.ALPN); @@ -36,9 +36,9 @@ function checkResults(result, expected) { function runTest(clientsOptions, serverOptions, cb) { serverOptions.key = loadPEM('agent2-key'); serverOptions.cert = loadPEM('agent2-cert'); - var results = []; - var index = 0; - var server = tls.createServer(serverOptions, function(c) { + const results = []; + let index = 0; + const server = tls.createServer(serverOptions, function(c) { results[index].server = {ALPN: c.alpnProtocol, NPN: c.npnProtocol}; }); @@ -47,13 +47,13 @@ function runTest(clientsOptions, serverOptions, cb) { }); function connectClient(options) { - var opt = options.shift(); + const opt = options.shift(); opt.port = server.address().port; opt.host = serverIP; opt.rejectUnauthorized = false; results[index] = {}; - var client = tls.connect(opt, function() { + const client = tls.connect(opt, function() { results[index].client = {ALPN: client.alpnProtocol, NPN: client.npnProtocol}; client.destroy(); @@ -71,12 +71,12 @@ function runTest(clientsOptions, serverOptions, cb) { // Server: ALPN/NPN, Client: ALPN/NPN function Test1() { - var serverOptions = { + const serverOptions = { ALPNProtocols: ['a', 'b', 'c'], NPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{ + const clientsOptions = [{ ALPNProtocols: ['a', 'b', 'c'], NPNProtocols: ['a', 'b', 'c'] }, { @@ -107,12 +107,12 @@ function Test1() { // Server: ALPN/NPN, Client: ALPN function Test2() { - var serverOptions = { + const serverOptions = { ALPNProtocols: ['a', 'b', 'c'], NPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{ + const clientsOptions = [{ ALPNProtocols: ['a', 'b', 'c'] }, { ALPNProtocols: ['c', 'b', 'e'] @@ -140,12 +140,12 @@ function Test2() { // Server: ALPN/NPN, Client: NPN function Test3() { - var serverOptions = { + const serverOptions = { ALPNProtocols: ['a', 'b', 'c'], NPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{ + const clientsOptions = [{ NPNProtocols: ['a', 'b', 'c'] }, { NPPNProtocols: ['c', 'b', 'e'] @@ -173,12 +173,12 @@ function Test3() { // Server: ALPN/NPN, Client: Nothing function Test4() { - var serverOptions = { + const serverOptions = { ALPNProtocols: ['a', 'b', 'c'], NPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{}, {}, {}]; + const clientsOptions = [{}, {}, {}]; runTest(clientsOptions, serverOptions, function(results) { // nothing is selected by ALPN @@ -200,11 +200,11 @@ function Test4() { // Server: ALPN, Client: ALPN/NPN function Test5() { - var serverOptions = { + const serverOptions = { ALPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{ + const clientsOptions = [{ ALPNProtocols: ['a', 'b', 'c'], NPNProtocols: ['a', 'b', 'c'] }, { @@ -233,11 +233,11 @@ function Test5() { // Server: ALPN, Client: ALPN function Test6() { - var serverOptions = { + const serverOptions = { ALPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{ + const clientsOptions = [{ ALPNProtocols: ['a', 'b', 'c'] }, { ALPNProtocols: ['c', 'b', 'e'] @@ -262,11 +262,11 @@ function Test6() { // Server: ALPN, Client: NPN function Test7() { - var serverOptions = { + const serverOptions = { ALPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{ + const clientsOptions = [{ NPNProtocols: ['a', 'b', 'c'] }, { NPNProtocols: ['c', 'b', 'e'] @@ -292,11 +292,11 @@ function Test7() { // Server: ALPN, Client: Nothing function Test8() { - var serverOptions = { + const serverOptions = { ALPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{}, {}, {}]; + const clientsOptions = [{}, {}, {}]; runTest(clientsOptions, serverOptions, function(results) { // nothing is selected by ALPN @@ -316,11 +316,11 @@ function Test8() { // Server: NPN, Client: ALPN/NPN function Test9() { - var serverOptions = { + const serverOptions = { NPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{ + const clientsOptions = [{ ALPNrotocols: ['a', 'b', 'c'], NPNProtocols: ['a', 'b', 'c'] }, { @@ -349,11 +349,11 @@ function Test9() { // Server: NPN, Client: ALPN function Test10() { - var serverOptions = { + const serverOptions = { NPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{ + const clientsOptions = [{ ALPNProtocols: ['a', 'b', 'c'] }, { ALPNProtocols: ['c', 'b', 'e'] @@ -378,11 +378,11 @@ function Test10() { // Server: NPN, Client: NPN function Test11() { - var serverOptions = { + const serverOptions = { NPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{ + const clientsOptions = [{ NPNProtocols: ['a', 'b', 'c'] }, { NPNProtocols: ['c', 'b', 'e'] @@ -408,11 +408,11 @@ function Test11() { // Server: NPN, Client: Nothing function Test12() { - var serverOptions = { + const serverOptions = { NPNProtocols: ['a', 'b', 'c'] }; - var clientsOptions = [{}, {}, {}]; + const clientsOptions = [{}, {}, {}]; runTest(clientsOptions, serverOptions, function(results) { // nothing is selected @@ -432,9 +432,9 @@ function Test12() { // Server: Nothing, Client: ALPN/NPN function Test13() { - var serverOptions = {}; + const serverOptions = {}; - var clientsOptions = [{ + const clientsOptions = [{ ALPNrotocols: ['a', 'b', 'c'], NPNProtocols: ['a', 'b', 'c'] }, { @@ -463,9 +463,9 @@ function Test13() { // Server: Nothing, Client: ALPN function Test14() { - var serverOptions = {}; + const serverOptions = {}; - var clientsOptions = [{ + const clientsOptions = [{ ALPNrotocols: ['a', 'b', 'c'] }, { ALPNProtocols: ['c', 'b', 'e'] @@ -491,9 +491,9 @@ function Test14() { // Server: Nothing, Client: NPN function Test15() { - var serverOptions = {}; + const serverOptions = {}; - var clientsOptions = [{ + const clientsOptions = [{ NPNProtocols: ['a', 'b', 'c'] }, { NPNProtocols: ['c', 'b', 'e'] @@ -519,9 +519,9 @@ function Test15() { // Server: Nothing, Client: Nothing function Test16() { - var serverOptions = {}; + const serverOptions = {}; - var clientsOptions = [{}, {}, {}]; + const clientsOptions = [{}, {}, {}]; runTest(clientsOptions, serverOptions, function(results) { // nothing is selected diff --git a/test/parallel/test-tls-async-cb-after-socket-end.js b/test/parallel/test-tls-async-cb-after-socket-end.js index dcde224e04344c..be499b84503472 100644 --- a/test/parallel/test-tls-async-cb-after-socket-end.js +++ b/test/parallel/test-tls-async-cb-after-socket-end.js @@ -10,19 +10,19 @@ const path = require('path'); const fs = require('fs'); const SSL_OP_NO_TICKET = require('crypto').constants.SSL_OP_NO_TICKET; -var tls = require('tls'); +const tls = require('tls'); -var options = { +const options = { secureOptions: SSL_OP_NO_TICKET, key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')), cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')) }; -var server = tls.createServer(options, function(c) { +const server = tls.createServer(options, function(c) { }); -var sessionCb = null; -var client = null; +let sessionCb = null; +let client = null; server.on('newSession', function(key, session, done) { done(); @@ -35,18 +35,18 @@ server.on('resumeSession', function(id, cb) { }); server.listen(0, function() { - var clientOpts = { + const clientOpts = { port: this.address().port, rejectUnauthorized: false, session: false }; - var s1 = tls.connect(clientOpts, function() { + const s1 = tls.connect(clientOpts, function() { clientOpts.session = s1.getSession(); console.log('1st secure'); s1.destroy(); - var s2 = tls.connect(clientOpts, function(s) { + const s2 = tls.connect(clientOpts, function(s) { console.log('2nd secure'); s2.destroy(); diff --git a/test/parallel/test-tls-ca-concat.js b/test/parallel/test-tls-ca-concat.js new file mode 100644 index 00000000000000..65c837bed9dc37 --- /dev/null +++ b/test/parallel/test-tls-ca-concat.js @@ -0,0 +1,24 @@ +'use strict'; +const common = require('../common'); + +// Check ca option can contain concatenated certs by prepending an unrelated +// non-CA cert and showing that agent6's CA root is still found. + +const join = require('path').join; +const { + assert, connect, keys +} = require(join(common.fixturesDir, 'tls-connect'))(); + +connect({ + client: { + checkServerIdentity: (servername, cert) => { }, + ca: keys.agent1.cert + '\n' + keys.agent6.ca, + }, + server: { + cert: keys.agent6.cert, + key: keys.agent6.key, + }, +}, function(err, pair, cleanup) { + assert.ifError(err); + return cleanup(); +}); diff --git a/test/parallel/test-tls-cert-chains-concat.js b/test/parallel/test-tls-cert-chains-concat.js new file mode 100644 index 00000000000000..d53edef89842b9 --- /dev/null +++ b/test/parallel/test-tls-cert-chains-concat.js @@ -0,0 +1,50 @@ +'use strict'; +const common = require('../common'); + +// Check cert chain is received by client, and is completed with the ca cert +// known to the client. + +const join = require('path').join; +const { + assert, connect, debug, keys +} = require(join(common.fixturesDir, 'tls-connect'))(); + +// agent6-cert.pem includes cert for agent6 and ca3 +connect({ + client: { + checkServerIdentity: (servername, cert) => { }, + ca: keys.agent6.ca, + }, + server: { + cert: keys.agent6.cert, + key: keys.agent6.key, + }, +}, function(err, pair, cleanup) { + assert.ifError(err); + + const peer = pair.client.conn.getPeerCertificate(); + debug('peer:\n', peer); + assert.strictEqual(peer.subject.emailAddress, 'adam.lippai@tresorit.com'); + assert.strictEqual(peer.subject.CN, 'Ádám Lippai'), + assert.strictEqual(peer.issuer.CN, 'ca3'); + assert.strictEqual(peer.serialNumber, 'C4CD893EF9A75DCC'); + + const next = pair.client.conn.getPeerCertificate(true).issuerCertificate; + const root = next.issuerCertificate; + delete next.issuerCertificate; + debug('next:\n', next); + assert.strictEqual(next.subject.CN, 'ca3'); + assert.strictEqual(next.issuer.CN, 'ca1'); + assert.strictEqual(next.serialNumber, '9A84ABCFB8A72ABF'); + + debug('root:\n', root); + assert.strictEqual(root.subject.CN, 'ca1'); + assert.strictEqual(root.issuer.CN, 'ca1'); + assert.strictEqual(root.serialNumber, '8DF21C01468AF393'); + + // No client cert, so empty object returned. + assert.deepStrictEqual(pair.server.conn.getPeerCertificate(), {}); + assert.deepStrictEqual(pair.server.conn.getPeerCertificate(true), {}); + + return cleanup(); +}); diff --git a/test/parallel/test-tls-cert-chains-in-ca.js b/test/parallel/test-tls-cert-chains-in-ca.js new file mode 100644 index 00000000000000..69f62c3f72d859 --- /dev/null +++ b/test/parallel/test-tls-cert-chains-in-ca.js @@ -0,0 +1,46 @@ +'use strict'; +const common = require('../common'); + +// Check cert chain is received by client, and is completed with the ca cert +// known to the client. + +const join = require('path').join; +const { + assert, connect, debug, keys +} = require(join(common.fixturesDir, 'tls-connect'))(); + + +// agent6-cert.pem includes cert for agent6 and ca3, split it apart and +// provide ca3 in the .ca property. +const agent6Chain = keys.agent6.cert.split('-----END CERTIFICATE-----') + .map((c) => { return c + '-----END CERTIFICATE-----'; }); +const agent6End = agent6Chain[0]; +const agent6Middle = agent6Chain[1]; +connect({ + client: { + checkServerIdentity: (servername, cert) => { }, + ca: keys.agent6.ca, + }, + server: { + cert: agent6End, + key: keys.agent6.key, + ca: agent6Middle, + }, +}, function(err, pair, cleanup) { + assert.ifError(err); + + const peer = pair.client.conn.getPeerCertificate(); + debug('peer:\n', peer); + assert.strictEqual(peer.serialNumber, 'C4CD893EF9A75DCC'); + + const next = pair.client.conn.getPeerCertificate(true).issuerCertificate; + const root = next.issuerCertificate; + delete next.issuerCertificate; + debug('next:\n', next); + assert.strictEqual(next.serialNumber, '9A84ABCFB8A72ABF'); + + debug('root:\n', root); + assert.strictEqual(root.serialNumber, '8DF21C01468AF393'); + + return cleanup(); +}); diff --git a/test/parallel/test-tls-cert-regression.js b/test/parallel/test-tls-cert-regression.js index a26bab7c46e107..ff5827bcf844ee 100644 --- a/test/parallel/test-tls-cert-regression.js +++ b/test/parallel/test-tls-cert-regression.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var cert = +const cert = `-----BEGIN CERTIFICATE----- MIIBfjCCASgCCQDmmNjAojbDQjANBgkqhkiG9w0BAQUFADBFMQswCQYDVQQGEwJB VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0 @@ -21,7 +21,7 @@ uvCyndyeB4d24FlfqEUlkfaWCZlNKRaV9YhLDiEg3BcIreFo4brtKQfZzTRs0GVm KHg= -----END CERTIFICATE-----`; -var key = +const key = `-----BEGIN RSA PRIVATE KEY----- MIIBPQIBAAJBAPKwlfMX6HGZIt1xm7fna72eWcOYfUfSxSugghvqYgJt2Oi3lH+w sU1O9FzRIVmpeIjDXhbpMjsa1HtzSiccPXsCAwEAAQJBAM4uU9aJE0OfdE1p/X+K @@ -33,7 +33,7 @@ AOaJnkQrmurlRdePX6LvN/LgGAQoxwovfjcOYNnZsIVY -----END RSA PRIVATE KEY-----`; function test(cert, key, cb) { - var server = tls.createServer({ + const server = tls.createServer({ cert: cert, key: key }).listen(0, function() { diff --git a/test/parallel/test-tls-cipher-list.js b/test/parallel/test-tls-cipher-list.js index 44ebd3d2f824ad..1533900f861177 100644 --- a/test/parallel/test-tls-cipher-list.js +++ b/test/parallel/test-tls-cipher-list.js @@ -11,7 +11,7 @@ const spawn = require('child_process').spawn; const defaultCoreList = require('crypto').constants.defaultCoreCipherList; function doCheck(arg, check) { - var out = ''; + let out = ''; arg = arg.concat([ '-pe', 'require("crypto").constants.defaultCipherList' @@ -21,7 +21,7 @@ function doCheck(arg, check) { .stdout.on('data', function(chunk) { out += chunk; }).on('end', function() { - assert.equal(out.trim(), check); + assert.strictEqual(out.trim(), check); }).on('error', common.fail); } diff --git a/test/parallel/test-tls-client-abort.js b/test/parallel/test-tls-client-abort.js index d2fcf3e687e676..fcf1d92e3257d5 100644 --- a/test/parallel/test-tls-client-abort.js +++ b/test/parallel/test-tls-client-abort.js @@ -1,22 +1,20 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); -var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')); -var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')); +const cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')); +const key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')); -var conn = tls.connect({cert: cert, key: key, port: common.PORT}, function() { - assert.ok(false); // callback should never be executed -}); +const conn = tls.connect({cert, key, port: common.PORT}, common.fail); conn.on('error', function() { }); assert.doesNotThrow(function() { diff --git a/test/parallel/test-tls-client-abort2.js b/test/parallel/test-tls-client-abort2.js index f3295f6d854a72..3247a2899acdfb 100644 --- a/test/parallel/test-tls-client-abort2.js +++ b/test/parallel/test-tls-client-abort2.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var conn = tls.connect(common.PORT, common.fail); +const conn = tls.connect(common.PORT, common.fail); conn.on('error', common.mustCall(function() { assert.doesNotThrow(function() { conn.destroy(); diff --git a/test/parallel/test-tls-client-default-ciphers.js b/test/parallel/test-tls-client-default-ciphers.js index 33766dfd5b13b2..30095197b1c807 100644 --- a/test/parallel/test-tls-client-default-ciphers.js +++ b/test/parallel/test-tls-client-default-ciphers.js @@ -1,17 +1,17 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); function Done() {} function test1() { - var ciphers = ''; + let ciphers = ''; tls.createSecureContext = function(options) { ciphers = options.ciphers; @@ -23,6 +23,6 @@ function test1() { } catch (e) { assert(e instanceof Done); } - assert.equal(ciphers, tls.DEFAULT_CIPHERS); + assert.strictEqual(ciphers, tls.DEFAULT_CIPHERS); } test1(); diff --git a/test/parallel/test-tls-client-destroy-soon.js b/test/parallel/test-tls-client-destroy-soon.js index 171aa328142e13..016fcfa4da6a95 100644 --- a/test/parallel/test-tls-client-destroy-soon.js +++ b/test/parallel/test-tls-client-destroy-soon.js @@ -3,40 +3,40 @@ // Cache session and close connection. Use session on second connection. // ASSERT resumption. -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem') }; -var big = Buffer.alloc(2 * 1024 * 1024, 'Y'); +const big = Buffer.alloc(2 * 1024 * 1024, 'Y'); // create server -var server = tls.createServer(options, common.mustCall(function(socket) { +const server = tls.createServer(options, common.mustCall(function(socket) { socket.end(big); socket.destroySoon(); })); // start listening server.listen(0, common.mustCall(function() { - var client = tls.connect({ + const client = tls.connect({ port: this.address().port, rejectUnauthorized: false }, common.mustCall(function() { - var bytesRead = 0; + let bytesRead = 0; client.on('readable', function() { - var d = client.read(); + const d = client.read(); if (d) bytesRead += d.length; }); diff --git a/test/parallel/test-tls-client-getephemeralkeyinfo.js b/test/parallel/test-tls-client-getephemeralkeyinfo.js index c1e6597245a612..7d68046de9baae 100644 --- a/test/parallel/test-tls-client-getephemeralkeyinfo.js +++ b/test/parallel/test-tls-client-getephemeralkeyinfo.js @@ -12,27 +12,27 @@ const fs = require('fs'); const key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'); const cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'); -var ntests = 0; -var nsuccess = 0; +let ntests = 0; +let nsuccess = 0; function loadDHParam(n) { - var path = common.fixturesDir; + let path = common.fixturesDir; if (n !== 'error') path += '/keys'; return fs.readFileSync(path + '/dh' + n + '.pem'); } -var cipherlist = { +const cipherlist = { 'NOT_PFS': 'AES128-SHA256', 'DH': 'DHE-RSA-AES128-GCM-SHA256', 'ECDH': 'ECDHE-RSA-AES128-GCM-SHA256' }; function test(size, type, name, next) { - var cipher = type ? cipherlist[type] : cipherlist['NOT_PFS']; + const cipher = type ? cipherlist[type] : cipherlist['NOT_PFS']; if (name) tls.DEFAULT_ECDH_CURVE = name; - var options = { + const options = { key: key, cert: cert, ciphers: cipher @@ -40,22 +40,22 @@ function test(size, type, name, next) { if (type === 'DH') options.dhparam = loadDHParam(size); - var server = tls.createServer(options, function(conn) { + const server = tls.createServer(options, function(conn) { assert.strictEqual(conn.getEphemeralKeyInfo(), null); conn.end(); }); server.on('close', common.mustCall(function(err) { - assert(!err); + assert.ifError(err); if (next) next(); })); server.listen(0, '127.0.0.1', common.mustCall(function() { - var client = tls.connect({ + const client = tls.connect({ port: this.address().port, rejectUnauthorized: false }, function() { - var ekeyinfo = client.getEphemeralKeyInfo(); + const ekeyinfo = client.getEphemeralKeyInfo(); assert.strictEqual(ekeyinfo.type, type); assert.strictEqual(ekeyinfo.size, size); assert.strictEqual(ekeyinfo.name, name); @@ -93,6 +93,6 @@ function testECDHE512() { testNOT_PFS(); process.on('exit', function() { - assert.equal(ntests, nsuccess); - assert.equal(ntests, 5); + assert.strictEqual(ntests, nsuccess); + assert.strictEqual(ntests, 5); }); diff --git a/test/parallel/test-tls-client-mindhsize.js b/test/parallel/test-tls-client-mindhsize.js index 1d812a72093ba9..6bbf90030e85c2 100644 --- a/test/parallel/test-tls-client-mindhsize.js +++ b/test/parallel/test-tls-client-mindhsize.js @@ -1,35 +1,35 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); process.exit(); } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'); -var cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'); +const fs = require('fs'); +const key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'); +const cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'); -var nsuccess = 0; -var nerror = 0; +let nsuccess = 0; +let nerror = 0; function loadDHParam(n) { - var path = common.fixturesDir; + let path = common.fixturesDir; if (n !== 'error') path += '/keys'; return fs.readFileSync(path + '/dh' + n + '.pem'); } function test(size, err, next) { - var options = { + const options = { key: key, cert: cert, dhparam: loadDHParam(size), ciphers: 'DHE-RSA-AES128-GCM-SHA256' }; - var server = tls.createServer(options, function(conn) { + const server = tls.createServer(options, function(conn) { conn.end(); }); @@ -42,7 +42,7 @@ function test(size, err, next) { // client set minimum DH parameter size to 2048 bits so that // it fails when it make a connection to the tls server where // dhparams is 1024 bits - var client = tls.connect({ + const client = tls.connect({ minDHSize: 2048, port: this.address().port, rejectUnauthorized: false @@ -88,6 +88,6 @@ assert.throws(() => test(512, true, common.fail), }); process.on('exit', function() { - assert.equal(nsuccess, 1); - assert.equal(nerror, 1); + assert.strictEqual(nsuccess, 1); + assert.strictEqual(nerror, 1); }); diff --git a/test/parallel/test-tls-client-resume.js b/test/parallel/test-tls-client-resume.js index 75524a3a189b3e..96109d7656dd19 100644 --- a/test/parallel/test-tls-client-resume.js +++ b/test/parallel/test-tls-client-resume.js @@ -3,32 +3,32 @@ // Cache session and close connection. Use session on second connection. // ASSERT resumption. -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem') }; // create server -var server = tls.Server(options, common.mustCall(function(socket) { +const server = tls.Server(options, common.mustCall(function(socket) { socket.end('Goodbye'); }, 2)); // start listening server.listen(0, function() { - var session1 = null; - var client1 = tls.connect({ + let session1 = null; + const client1 = tls.connect({ port: this.address().port, rejectUnauthorized: false }, function() { @@ -40,13 +40,13 @@ server.listen(0, function() { client1.on('close', function() { console.log('close1'); - var opts = { + const opts = { port: server.address().port, rejectUnauthorized: false, session: session1 }; - var client2 = tls.connect(opts, function() { + const client2 = tls.connect(opts, function() { console.log('connect2'); assert.ok(client2.isSessionReused(), 'Session *should* be reused.'); }); diff --git a/test/parallel/test-tls-client-verify.js b/test/parallel/test-tls-client-verify.js index 983d88296eb26f..33d6c95fde50d3 100644 --- a/test/parallel/test-tls-client-verify.js +++ b/test/parallel/test-tls-client-verify.js @@ -12,36 +12,36 @@ const fs = require('fs'); const hosterr = /Hostname\/IP doesn't match certificate's altnames/g; const testCases = - [{ ca: ['ca1-cert'], - key: 'agent2-key', - cert: 'agent2-cert', - servers: [ + [{ ca: ['ca1-cert'], + key: 'agent2-key', + cert: 'agent2-cert', + servers: [ { ok: true, key: 'agent1-key', cert: 'agent1-cert' }, { ok: false, key: 'agent2-key', cert: 'agent2-cert' }, { ok: false, key: 'agent3-key', cert: 'agent3-cert' } - ] - }, + ] + }, - { ca: [], - key: 'agent2-key', - cert: 'agent2-cert', - servers: [ + { ca: [], + key: 'agent2-key', + cert: 'agent2-cert', + servers: [ { ok: false, key: 'agent1-key', cert: 'agent1-cert' }, { ok: false, key: 'agent2-key', cert: 'agent2-cert' }, { ok: false, key: 'agent3-key', cert: 'agent3-cert' } - ] - }, + ] + }, - { ca: ['ca1-cert', 'ca2-cert'], - key: 'agent2-key', - cert: 'agent2-cert', - servers: [ + { ca: ['ca1-cert', 'ca2-cert'], + key: 'agent2-key', + cert: 'agent2-cert', + servers: [ { ok: true, key: 'agent1-key', cert: 'agent1-cert' }, { ok: false, key: 'agent2-key', cert: 'agent2-cert' }, { ok: true, key: 'agent3-key', cert: 'agent3-cert' } - ] - } - ]; + ] + } + ]; function filenamePEM(n) { return require('path').join(common.fixturesDir, 'keys', n + '.pem'); @@ -106,7 +106,7 @@ function testServers(index, servers, clientOptions, cb) { function runTest(testIndex) { - var tcase = testCases[testIndex]; + const tcase = testCases[testIndex]; if (!tcase) return; const clientOptions = { @@ -130,5 +130,5 @@ runTest(0); process.on('exit', function() { console.log('successful tests: %d', successfulTests); - assert.equal(successfulTests, testCases.length); + assert.strictEqual(successfulTests, testCases.length); }); diff --git a/test/parallel/test-tls-close-error.js b/test/parallel/test-tls-close-error.js index 2da7a192c30ebc..91017cdce0667f 100644 --- a/test/parallel/test-tls-close-error.js +++ b/test/parallel/test-tls-close-error.js @@ -1,24 +1,22 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var server = tls.createServer({ +const server = tls.createServer({ key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }, function(c) { }).listen(0, common.mustCall(function() { - var c = tls.connect(this.address().port, function() { - assert(false, 'should not be called'); - }); + const c = tls.connect(this.address().port, common.fail); c.on('error', common.mustCall(function(err) {})); diff --git a/test/parallel/test-tls-close-notify.js b/test/parallel/test-tls-close-notify.js index 51b16746e30533..5d5bc1007749a7 100644 --- a/test/parallel/test-tls-close-notify.js +++ b/test/parallel/test-tls-close-notify.js @@ -1,15 +1,15 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var server = tls.createServer({ +const server = tls.createServer({ key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }, function(c) { @@ -17,7 +17,7 @@ var server = tls.createServer({ if (c._handle.shutdownSSL() !== 1) c._handle.shutdownSSL(); }).listen(0, common.mustCall(function() { - var c = tls.connect(this.address().port, { + const c = tls.connect(this.address().port, { rejectUnauthorized: false }, common.mustCall(function() { // Ensure that we receive 'end' event anyway diff --git a/test/parallel/test-tls-connect-no-host.js b/test/parallel/test-tls-connect-no-host.js index e2e0238ff8d0ad..2e4bcfbc6d4787 100644 --- a/test/parallel/test-tls-connect-no-host.js +++ b/test/parallel/test-tls-connect-no-host.js @@ -1,18 +1,18 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var assert = require('assert'); -var fs = require('fs'); -var path = require('path'); +const assert = require('assert'); +const fs = require('fs'); +const path = require('path'); -var cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')); -var key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')); +const cert = fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')); +const key = fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')); // https://github.com/nodejs/node/issues/1489 // tls.connect(options) with no options.host should accept a cert with @@ -21,7 +21,7 @@ tls.createServer({ key: key, cert: cert }).listen(0, function() { - var socket = tls.connect({ + const socket = tls.connect({ port: this.address().port, ca: cert, // No host set here. 'localhost' is the default, diff --git a/test/parallel/test-tls-connect-pipe.js b/test/parallel/test-tls-connect-pipe.js index 6ec218e00366f6..de60ae084624cf 100644 --- a/test/parallel/test-tls-connect-pipe.js +++ b/test/parallel/test-tls-connect-pipe.js @@ -1,27 +1,27 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; common.refreshTmpDir(); -var server = tls.Server(options, common.mustCall(function(socket) { +const server = tls.Server(options, common.mustCall(function(socket) { server.close(); })); server.listen(common.PIPE, common.mustCall(function() { - var options = { rejectUnauthorized: false }; - var client = tls.connect(common.PIPE, options, common.mustCall(function() { + const options = { rejectUnauthorized: false }; + const client = tls.connect(common.PIPE, options, common.mustCall(function() { client.end(); })); })); diff --git a/test/parallel/test-tls-connect-secure-context.js b/test/parallel/test-tls-connect-secure-context.js index 9e1059f169cf62..d1552a62169207 100644 --- a/test/parallel/test-tls-connect-secure-context.js +++ b/test/parallel/test-tls-connect-secure-context.js @@ -1,37 +1,25 @@ 'use strict'; const common = require('../common'); -if (!common.hasCrypto) { - common.skip('missing crypto'); - return; -} -const tls = require('tls'); +// Verify connection with explicitly created client SecureContext. -const fs = require('fs'); -const path = require('path'); +const join = require('path').join; +const { + assert, connect, keys, tls +} = require(join(common.fixturesDir, 'tls-connect'))(); -const keysDir = path.join(common.fixturesDir, 'keys'); - -const ca = fs.readFileSync(path.join(keysDir, 'ca1-cert.pem')); -const cert = fs.readFileSync(path.join(keysDir, 'agent1-cert.pem')); -const key = fs.readFileSync(path.join(keysDir, 'agent1-key.pem')); - -const server = tls.createServer({ - cert: cert, - key: key -}, function(c) { - c.end(); -}).listen(0, function() { - const secureContext = tls.createSecureContext({ - ca: ca - }); - - const socket = tls.connect({ - secureContext: secureContext, +connect({ + client: { servername: 'agent1', - port: this.address().port - }, common.mustCall(function() { - server.close(); - socket.end(); - })); + secureContext: tls.createSecureContext({ + ca: keys.agent1.ca, + }), + }, + server: { + cert: keys.agent1.cert, + key: keys.agent1.key, + }, +}, function(err, pair, cleanup) { + assert.ifError(err); + return cleanup(); }); diff --git a/test/parallel/test-tls-connect-stream-writes.js b/test/parallel/test-tls-connect-stream-writes.js index 7070f63f497df6..2f4eebf22978a5 100644 --- a/test/parallel/test-tls-connect-stream-writes.js +++ b/test/parallel/test-tls-connect-stream-writes.js @@ -11,34 +11,33 @@ const tls = require('tls'); const stream = require('stream'); const net = require('net'); -var server; -var cert_dir = common.fixturesDir; -var options = { key: fs.readFileSync(cert_dir + '/test_key.pem'), - cert: fs.readFileSync(cert_dir + '/test_cert.pem'), - ca: [ fs.readFileSync(cert_dir + '/test_ca.pem') ], - ciphers: 'AES256-GCM-SHA384' }; -var content = 'hello world'; -var recv_bufs = []; -var send_data = ''; -server = tls.createServer(options, function(s) { +const cert_dir = common.fixturesDir; +const options = { key: fs.readFileSync(cert_dir + '/test_key.pem'), + cert: fs.readFileSync(cert_dir + '/test_cert.pem'), + ca: [ fs.readFileSync(cert_dir + '/test_ca.pem') ], + ciphers: 'AES256-GCM-SHA384' }; +const content = 'hello world'; +const recv_bufs = []; +let send_data = ''; +const server = tls.createServer(options, function(s) { s.on('data', function(c) { recv_bufs.push(c); }); }); server.listen(0, function() { - var raw = net.connect(this.address().port); + const raw = net.connect(this.address().port); - var pending = false; + let pending = false; raw.on('readable', function() { if (pending) p._read(); }); - var p = new stream.Duplex({ + const p = new stream.Duplex({ read: function read() { pending = false; - var chunk = raw.read(); + const chunk = raw.read(); if (chunk) { this.push(chunk); } else { @@ -50,11 +49,11 @@ server.listen(0, function() { } }); - var socket = tls.connect({ + const socket = tls.connect({ socket: p, rejectUnauthorized: false }, function() { - for (var i = 0; i < 50; ++i) { + for (let i = 0; i < 50; ++i) { socket.write(content); send_data += content; } @@ -64,6 +63,6 @@ server.listen(0, function() { }); process.on('exit', function() { - var recv_data = (Buffer.concat(recv_bufs)).toString(); + const recv_data = (Buffer.concat(recv_bufs)).toString(); assert.strictEqual(send_data, recv_data); }); diff --git a/test/parallel/test-tls-connect.js b/test/parallel/test-tls-connect.js index cd4edd89f7b483..abaa1ae3346da5 100644 --- a/test/parallel/test-tls-connect.js +++ b/test/parallel/test-tls-connect.js @@ -1,15 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); // https://github.com/joyent/node/issues/1218 // uncatchable exception on TLS connection error @@ -33,9 +32,7 @@ var path = require('path'); key: key, port: common.PORT, ciphers: 'rick-128-roll' - }, function() { - assert.ok(false); // callback should never be executed - }); + }, common.fail); conn.on('error', common.mustCall(function() {})); } diff --git a/test/parallel/test-tls-delayed-attach-error.js b/test/parallel/test-tls-delayed-attach-error.js index a5fa91383d7d75..47be3f201b463e 100644 --- a/test/parallel/test-tls-delayed-attach-error.js +++ b/test/parallel/test-tls-delayed-attach-error.js @@ -1,24 +1,24 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var fs = require('fs'); -var net = require('net'); +const tls = require('tls'); +const fs = require('fs'); +const net = require('net'); -var bonkers = Buffer.alloc(1024, 42); +const bonkers = Buffer.alloc(1024, 42); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = net.createServer(common.mustCall(function(c) { +const server = net.createServer(common.mustCall(function(c) { setTimeout(common.mustCall(function() { - var s = new tls.TLSSocket(c, { + const s = new tls.TLSSocket(c, { isServer: true, secureContext: tls.createSecureContext(options) }); @@ -31,7 +31,7 @@ var server = net.createServer(common.mustCall(function(c) { }); }), 200); })).listen(0, function() { - var c = net.connect({port: this.address().port}, function() { + const c = net.connect({port: this.address().port}, function() { c.write(bonkers); }); }); diff --git a/test/parallel/test-tls-delayed-attach.js b/test/parallel/test-tls-delayed-attach.js index b1e4beb2313c9a..9d2aca6a7d6c6f 100644 --- a/test/parallel/test-tls-delayed-attach.js +++ b/test/parallel/test-tls-delayed-attach.js @@ -1,27 +1,27 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var net = require('net'); +const fs = require('fs'); +const net = require('net'); -var sent = 'hello world'; -var received = ''; +const sent = 'hello world'; +let received = ''; -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = net.createServer(function(c) { +const server = net.createServer(function(c) { setTimeout(function() { - var s = new tls.TLSSocket(c, { + const s = new tls.TLSSocket(c, { isServer: true, secureContext: tls.createSecureContext(options) }); @@ -36,7 +36,7 @@ var server = net.createServer(function(c) { }); }, 200); }).listen(0, function() { - var c = tls.connect(this.address().port, { + const c = tls.connect(this.address().port, { rejectUnauthorized: false }, function() { c.end(sent); @@ -44,5 +44,5 @@ var server = net.createServer(function(c) { }); process.on('exit', function() { - assert.equal(received, sent); + assert.strictEqual(received, sent); }); diff --git a/test/parallel/test-tls-dhe.js b/test/parallel/test-tls-dhe.js index 92ab415e3ba0a6..1f3f73557a6a2a 100644 --- a/test/parallel/test-tls-dhe.js +++ b/test/parallel/test-tls-dhe.js @@ -1,55 +1,55 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var spawn = require('child_process').spawn; -var fs = require('fs'); -var key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'); -var cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'); -var nsuccess = 0; -var ntests = 0; -var ciphers = 'DHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; +const spawn = require('child_process').spawn; +const fs = require('fs'); +const key = fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'); +const cert = fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'); +let nsuccess = 0; +let ntests = 0; +const ciphers = 'DHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256'; function loadDHParam(n) { - var path = common.fixturesDir; + let path = common.fixturesDir; if (n !== 'error') path += '/keys'; return fs.readFileSync(path + '/dh' + n + '.pem'); } function test(keylen, expectedCipher, cb) { - var options = { + const options = { key: key, cert: cert, ciphers: ciphers, dhparam: loadDHParam(keylen) }; - var server = tls.createServer(options, function(conn) { + const server = tls.createServer(options, function(conn) { conn.end(); }); server.on('close', function(err) { - assert(!err); + assert.ifError(err); if (cb) cb(); }); server.listen(0, '127.0.0.1', function() { - var args = ['s_client', '-connect', `127.0.0.1:${this.address().port}`, - '-cipher', ciphers]; + const args = ['s_client', '-connect', `127.0.0.1:${this.address().port}`, + '-cipher', ciphers]; // for the performance and stability issue in s_client on Windows if (common.isWindows) args.push('-no_rand_screen'); - var client = spawn(common.opensslCli, args); - var out = ''; + const client = spawn(common.opensslCli, args); + let out = ''; client.stdout.setEncoding('utf8'); client.stdout.on('data', function(d) { out += d; @@ -57,7 +57,7 @@ function test(keylen, expectedCipher, cb) { client.stdout.on('end', function() { // DHE key length can be checked -brief option in s_client but it // is only supported in openssl 1.0.2 so we cannot check it. - var reg = new RegExp('Cipher : ' + expectedCipher); + const reg = new RegExp('Cipher : ' + expectedCipher); if (reg.test(out)) { nsuccess++; server.close(); @@ -90,6 +90,6 @@ function testError() { test1024(); process.on('exit', function() { - assert.equal(ntests, nsuccess); - assert.equal(ntests, 3); + assert.strictEqual(ntests, nsuccess); + assert.strictEqual(ntests, 3); }); diff --git a/test/parallel/test-tls-ecdh-disable.js b/test/parallel/test-tls-ecdh-disable.js index c2a7440a686a10..a0555e87781f59 100644 --- a/test/parallel/test-tls-ecdh-disable.js +++ b/test/parallel/test-tls-ecdh-disable.js @@ -1,27 +1,27 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var exec = require('child_process').exec; -var fs = require('fs'); +const exec = require('child_process').exec; +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'), ciphers: 'ECDHE-RSA-RC4-SHA', ecdhCurve: false }; -var server = tls.createServer(options, common.fail); +const server = tls.createServer(options, common.fail); server.listen(0, '127.0.0.1', common.mustCall(function() { - var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers + + let cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers + ` -connect 127.0.0.1:${this.address().port}`; // for the performance and stability issue in s_client on Windows diff --git a/test/parallel/test-tls-ecdh.js b/test/parallel/test-tls-ecdh.js index 99c6e108ab736a..2c68e3d706406e 100644 --- a/test/parallel/test-tls-ecdh.js +++ b/test/parallel/test-tls-ecdh.js @@ -33,7 +33,7 @@ server.listen(0, '127.0.0.1', common.mustCall(function() { cmd += ' -no_rand_screen'; exec(cmd, common.mustCall(function(err, stdout, stderr) { - if (err) throw err; + assert.ifError(err); assert(stdout.includes(reply)); server.close(); })); diff --git a/test/parallel/test-tls-econnreset.js b/test/parallel/test-tls-econnreset.js index d9f6fffd326409..c0df9948f489ea 100644 --- a/test/parallel/test-tls-econnreset.js +++ b/test/parallel/test-tls-econnreset.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var cacert = +const cacert = `-----BEGIN CERTIFICATE----- MIIBxTCCAX8CAnXnMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNVBAYTAlVTMQswCQYD VQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQU3Ryb25n @@ -22,7 +22,7 @@ AVkCAwEAATANBgkqhkiG9w0BAQUFAAMxALA1uS4CqQXRSAyYTfio5oyLGz71a+NM +0AFLBwh5AQjhGd0FcenU4OfHxyDEOJT/Q== -----END CERTIFICATE-----`; -var cert = +const cert = `-----BEGIN CERTIFICATE----- MIIBfDCCATYCAgQaMA0GCSqGSIb3DQEBBQUAMH0xCzAJBgNVBAYTAlVTMQswCQYD VQQIEwJDQTEWMBQGA1UEBxMNU2FuIEZyYW5jaXNjbzEZMBcGA1UEChMQU3Ryb25n @@ -34,7 +34,7 @@ AQABoxkwFzAVBgNVHREEDjAMhwQAAAAAhwR/AAABMA0GCSqGSIb3DQEBBQUAAzEA cGpYrhkrb7mIh9DNhV0qp7pGjqBzlHqB7KQXw2luLDp//6dyHBMexDCQznkhZKRU -----END CERTIFICATE-----`; -var key = +const key = `-----BEGIN RSA PRIVATE KEY----- MIH0AgEAAjEAx+QjQtZTXmk9TAhA0ydFWGE6JuLRNCYBq7wUG2DAR8YrTVal8ZRo mvVrjUrxSrvHAgMBAAECMBCGccvSwC2r8Z9Zh1JtirQVxaL1WWpAQfmVwLe0bAgg @@ -44,18 +44,18 @@ pQIZAMMwxuS3XiO7two2sQF6W+JTYyX1DPCwAQIZAOYg1TvEGT38k8e8jygv8E8w YqrWTeQFNQ== -----END RSA PRIVATE KEY-----`; -var ca = [ cert, cacert ]; +const ca = [ cert, cacert ]; -var clientError = null; -var connectError = null; +let clientError = null; +let connectError = null; -var server = tls.createServer({ ca: ca, cert: cert, key: key }, function(conn) { +const server = tls.createServer({ ca: ca, cert: cert, key: key }, (conn) => { throw 'unreachable'; }).on('tlsClientError', function(err, conn) { assert(!clientError && conn); clientError = err; }).listen(0, function() { - var options = { + const options = { ciphers: 'AES128-GCM-SHA256', port: this.address().port, ca: ca diff --git a/test/parallel/test-tls-env-bad-extra-ca.js b/test/parallel/test-tls-env-bad-extra-ca.js index 1862366e013af0..9b42bbbbd5558e 100644 --- a/test/parallel/test-tls-env-bad-extra-ca.js +++ b/test/parallel/test-tls-env-bad-extra-ca.js @@ -22,15 +22,15 @@ const env = { NODE_EXTRA_CA_CERTS: common.fixturesDir + '/no-such-file-exists', }; -var opts = { +const opts = { env: env, silent: true, }; -var stderr = ''; +let stderr = ''; fork(__filename, opts) .on('exit', common.mustCall(function(status) { - assert.equal(status, 0, 'client did not succeed in connecting'); + assert.strictEqual(status, 0, 'client did not succeed in connecting'); })) .on('close', common.mustCall(function() { assert(stderr.match(new RegExp( diff --git a/test/parallel/test-tls-env-extra-ca.js b/test/parallel/test-tls-env-extra-ca.js index 12e3272bd401a2..89f1b3a6c040d1 100644 --- a/test/parallel/test-tls-env-extra-ca.js +++ b/test/parallel/test-tls-env-extra-ca.js @@ -40,6 +40,6 @@ const server = tls.createServer(options, function(s) { }; fork(__filename, {env: env}).on('exit', common.mustCall(function(status) { - assert.equal(status, 0, 'client did not succeed in connecting'); + assert.strictEqual(status, 0, 'client did not succeed in connecting'); })); })); diff --git a/test/parallel/test-tls-fast-writing.js b/test/parallel/test-tls-fast-writing.js index 034a6296659bdd..b2d6fe6eee88a3 100644 --- a/test/parallel/test-tls-fast-writing.js +++ b/test/parallel/test-tls-fast-writing.js @@ -1,23 +1,23 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var dir = common.fixturesDir; -var options = { key: fs.readFileSync(dir + '/test_key.pem'), - cert: fs.readFileSync(dir + '/test_cert.pem'), - ca: [ fs.readFileSync(dir + '/test_ca.pem') ] }; +const dir = common.fixturesDir; +const options = { key: fs.readFileSync(dir + '/test_key.pem'), + cert: fs.readFileSync(dir + '/test_cert.pem'), + ca: [ fs.readFileSync(dir + '/test_ca.pem') ] }; -var server = tls.createServer(options, onconnection); -var gotChunk = false; -var gotDrain = false; +const server = tls.createServer(options, onconnection); +let gotChunk = false; +let gotDrain = false; setTimeout(function() { console.log('not ok - timed out'); @@ -41,9 +41,9 @@ function onconnection(conn) { } server.listen(0, function() { - var chunk = Buffer.alloc(1024, 'x'); - var opt = { port: this.address().port, rejectUnauthorized: false }; - var conn = tls.connect(opt, function() { + const chunk = Buffer.alloc(1024, 'x'); + const opt = { port: this.address().port, rejectUnauthorized: false }; + const conn = tls.connect(opt, function() { conn.on('drain', ondrain); write(); }); diff --git a/test/parallel/test-tls-friendly-error-message.js b/test/parallel/test-tls-friendly-error-message.js index 9ae69f4016e319..3f3bfe9133fcd6 100644 --- a/test/parallel/test-tls-friendly-error-message.js +++ b/test/parallel/test-tls-friendly-error-message.js @@ -17,7 +17,7 @@ tls.createServer({ key: key, cert: cert }, common.mustCall(function(conn) { conn.end(); this.close(); })).listen(0, common.mustCall(function() { - var options = { port: this.address().port, rejectUnauthorized: true }; + const options = { port: this.address().port, rejectUnauthorized: true }; tls.connect(options).on('error', common.mustCall(function(err) { assert.strictEqual(err.code, 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'); assert.strictEqual(err.message, 'unable to verify the first certificate'); diff --git a/test/parallel/test-tls-handshake-error.js b/test/parallel/test-tls-handshake-error.js index e76a0961fb7ad6..2feb126669cc88 100644 --- a/test/parallel/test-tls-handshake-error.js +++ b/test/parallel/test-tls-handshake-error.js @@ -1,31 +1,29 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var server = tls.createServer({ +const server = tls.createServer({ key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'), rejectUnauthorized: true }, function(c) { }).listen(0, common.mustCall(function() { - var c = tls.connect({ + const c = tls.connect({ port: this.address().port, ciphers: 'RC4' - }, function() { - assert(false, 'should not be called'); - }); + }, common.fail); c.on('error', common.mustCall(function(err) { - assert.notEqual(err.code, 'ECONNRESET'); + assert.notStrictEqual(err.code, 'ECONNRESET'); })); c.on('close', common.mustCall(function(err) { diff --git a/test/parallel/test-tls-handshake-nohang.js b/test/parallel/test-tls-handshake-nohang.js index 052833a50e3462..039c55b486d6a2 100644 --- a/test/parallel/test-tls-handshake-nohang.js +++ b/test/parallel/test-tls-handshake-nohang.js @@ -1,11 +1,11 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); // neither should hang tls.createSecurePair(null, false, false, false); diff --git a/test/parallel/test-tls-honorcipherorder.js b/test/parallel/test-tls-honorcipherorder.js index 81c2440fe26d23..fdfc303146c1fa 100644 --- a/test/parallel/test-tls-honorcipherorder.js +++ b/test/parallel/test-tls-honorcipherorder.js @@ -1,27 +1,27 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var nconns = 0; +const fs = require('fs'); +let nconns = 0; // We explicitly set TLS version to 1.2 so as to be safe when the // default method is updated in the future -var SSL_Method = 'TLSv1_2_method'; -var localhost = '127.0.0.1'; +const SSL_Method = 'TLSv1_2_method'; +const localhost = '127.0.0.1'; process.on('exit', function() { - assert.equal(nconns, 6); + assert.strictEqual(nconns, 6); }); function test(honorCipherOrder, clientCipher, expectedCipher, cb) { - var soptions = { + const soptions = { secureProtocol: SSL_Method, key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem'), @@ -30,7 +30,7 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) { honorCipherOrder: !!honorCipherOrder }; - var server = tls.createServer(soptions, function(cleartextStream) { + const server = tls.createServer(soptions, function(cleartextStream) { nconns++; // End socket to send CLOSE_NOTIFY and TCP FIN packet, otherwise @@ -38,7 +38,7 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) { cleartextStream.end(); }); server.listen(0, localhost, function() { - var coptions = { + const coptions = { rejectUnauthorized: false, secureProtocol: SSL_Method }; @@ -46,11 +46,11 @@ function test(honorCipherOrder, clientCipher, expectedCipher, cb) { coptions.ciphers = clientCipher; } const port = this.address().port; - var client = tls.connect(port, localhost, coptions, function() { - var cipher = client.getCipher(); + const client = tls.connect(port, localhost, coptions, function() { + const cipher = client.getCipher(); client.end(); server.close(); - assert.equal(cipher.name, expectedCipher); + assert.strictEqual(cipher.name, expectedCipher); if (cb) cb(); }); }); diff --git a/test/parallel/test-tls-inception.js b/test/parallel/test-tls-inception.js index 760887d9f25264..183fbe587b366c 100644 --- a/test/parallel/test-tls-inception.js +++ b/test/parallel/test-tls-inception.js @@ -54,7 +54,7 @@ a.listen(0, function() { rejectUnauthorized: false }); ssl.setEncoding('utf8'); - var buf = ''; + let buf = ''; ssl.on('data', function(data) { buf += data; }); diff --git a/test/parallel/test-tls-invoke-queued.js b/test/parallel/test-tls-invoke-queued.js index 4008e5f099e4bc..bd3ad43fe653e5 100644 --- a/test/parallel/test-tls-invoke-queued.js +++ b/test/parallel/test-tls-invoke-queued.js @@ -1,19 +1,19 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var received = ''; +let received = ''; -var server = tls.createServer({ +const server = tls.createServer({ key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }, function(c) { @@ -26,7 +26,7 @@ var server = tls.createServer({ server.close(); }).listen(0, common.mustCall(function() { - var c = tls.connect(this.address().port, { + const c = tls.connect(this.address().port, { rejectUnauthorized: false }, common.mustCall(function() { c.on('data', function(chunk) { diff --git a/test/parallel/test-tls-js-stream.js b/test/parallel/test-tls-js-stream.js index 08095fa99538cf..4e7cf618701173 100644 --- a/test/parallel/test-tls-js-stream.js +++ b/test/parallel/test-tls-js-stream.js @@ -1,23 +1,23 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var stream = require('stream'); -var fs = require('fs'); -var net = require('net'); +const stream = require('stream'); +const fs = require('fs'); +const net = require('net'); -var connected = { +const connected = { client: 0, server: 0 }; -var server = tls.createServer({ +const server = tls.createServer({ key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }, function(c) { @@ -25,19 +25,19 @@ var server = tls.createServer({ connected.server++; c.end('ohai'); }).listen(0, function() { - var raw = net.connect(this.address().port); + const raw = net.connect(this.address().port); - var pending = false; + let pending = false; raw.on('readable', function() { if (pending) p._read(); }); - var p = new stream.Duplex({ + const p = new stream.Duplex({ read: function read() { pending = false; - var chunk = raw.read(); + const chunk = raw.read(); if (chunk) { console.log('read', chunk); this.push(chunk); @@ -51,7 +51,7 @@ var server = tls.createServer({ } }); - var socket = tls.connect({ + const socket = tls.connect({ socket: p, rejectUnauthorized: false }, function() { @@ -71,6 +71,6 @@ var server = tls.createServer({ }); process.once('exit', function() { - assert.equal(connected.client, 1); - assert.equal(connected.server, 1); + assert.strictEqual(connected.client, 1); + assert.strictEqual(connected.server, 1); }); diff --git a/test/parallel/test-tls-legacy-onselect.js b/test/parallel/test-tls-legacy-onselect.js index 72c748248e448d..9af65c43a0661c 100644 --- a/test/parallel/test-tls-legacy-onselect.js +++ b/test/parallel/test-tls-legacy-onselect.js @@ -1,15 +1,15 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var net = require('net'); +const tls = require('tls'); +const net = require('net'); -var server = net.Server(common.mustCall(function(raw) { - var pair = tls.createSecurePair(null, true, false, false); +const server = net.Server(common.mustCall(function(raw) { + const pair = tls.createSecurePair(null, true, false, false); pair.on('error', function() {}); pair.ssl.setSNICallback(common.mustCall(function() { raw.destroy(); diff --git a/test/parallel/test-tls-max-send-fragment.js b/test/parallel/test-tls-max-send-fragment.js index 64dd14698916c8..4b81be35e34522 100644 --- a/test/parallel/test-tls-max-send-fragment.js +++ b/test/parallel/test-tls-max-send-fragment.js @@ -1,20 +1,20 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var buf = Buffer.allocUnsafe(10000); -var received = 0; -var maxChunk = 768; +const buf = Buffer.allocUnsafe(10000); +let received = 0; +const maxChunk = 768; -var server = tls.createServer({ +const server = tls.createServer({ key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }, function(c) { @@ -27,7 +27,7 @@ var server = tls.createServer({ c.end(buf); }).listen(0, common.mustCall(function() { - var c = tls.connect(this.address().port, { + const c = tls.connect(this.address().port, { rejectUnauthorized: false }, common.mustCall(function() { c.on('data', function(chunk) { diff --git a/test/parallel/test-tls-multi-key.js b/test/parallel/test-tls-multi-key.js index e29f5ee522829e..e3d5d661a799a7 100644 --- a/test/parallel/test-tls-multi-key.js +++ b/test/parallel/test-tls-multi-key.js @@ -1,15 +1,15 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var fs = require('fs'); +const tls = require('tls'); +const fs = require('fs'); -var options = { +const options = { key: [ fs.readFileSync(common.fixturesDir + '/keys/ec-key.pem'), fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), @@ -20,17 +20,17 @@ var options = { ] }; -var ciphers = []; +const ciphers = []; -var server = tls.createServer(options, function(conn) { +const server = tls.createServer(options, function(conn) { conn.end('ok'); }).listen(0, function() { - var ecdsa = tls.connect(this.address().port, { + const ecdsa = tls.connect(this.address().port, { ciphers: 'ECDHE-ECDSA-AES256-GCM-SHA384', rejectUnauthorized: false }, function() { ciphers.push(ecdsa.getCipher()); - var rsa = tls.connect(server.address().port, { + const rsa = tls.connect(server.address().port, { ciphers: 'ECDHE-RSA-AES256-GCM-SHA384', rejectUnauthorized: false }, function() { diff --git a/test/parallel/test-tls-no-rsa-key.js b/test/parallel/test-tls-no-rsa-key.js index cc04534bf91973..ed5c941b2d33ba 100644 --- a/test/parallel/test-tls-no-rsa-key.js +++ b/test/parallel/test-tls-no-rsa-key.js @@ -1,24 +1,24 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/ec-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/ec-cert.pem') }; -var server = tls.createServer(options, function(conn) { +const server = tls.createServer(options, function(conn) { conn.end('ok'); }).listen(0, common.mustCall(function() { - var c = tls.connect(this.address().port, { + const c = tls.connect(this.address().port, { rejectUnauthorized: false }, common.mustCall(function() { c.on('end', common.mustCall(function() { @@ -27,7 +27,7 @@ var server = tls.createServer(options, function(conn) { })); c.on('data', function(data) { - assert.equal(data, 'ok'); + assert.strictEqual(data.toString(), 'ok'); }); const cert = c.getPeerCertificate(); diff --git a/test/parallel/test-tls-no-sslv23.js b/test/parallel/test-tls-no-sslv23.js index 0db61afe0e97ec..ff1214d167e6a0 100644 --- a/test/parallel/test-tls-no-sslv23.js +++ b/test/parallel/test-tls-no-sslv23.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); assert.throws(function() { tls.createSecureContext({ secureProtocol: 'blargh' }); diff --git a/test/parallel/test-tls-no-sslv3.js b/test/parallel/test-tls-no-sslv3.js index 16a722ef85b9da..fbc7a629611b0d 100644 --- a/test/parallel/test-tls-no-sslv3.js +++ b/test/parallel/test-tls-no-sslv3.js @@ -25,8 +25,8 @@ let stderr = ''; server.listen(0, '127.0.0.1', function() { const address = this.address().address + ':' + this.address().port; const args = ['s_client', - '-ssl3', - '-connect', address]; + '-ssl3', + '-connect', address]; // for the performance and stability issue in s_client on Windows if (common.isWindows) diff --git a/test/parallel/test-tls-npn-server-client.js b/test/parallel/test-tls-npn-server-client.js index a5fe2da3a2a607..3c69204d680d7c 100644 --- a/test/parallel/test-tls-npn-server-client.js +++ b/test/parallel/test-tls-npn-server-client.js @@ -13,7 +13,7 @@ if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); function filenamePEM(n) { @@ -24,7 +24,7 @@ function loadPEM(n) { return fs.readFileSync(filenamePEM(n)); } -var serverOptions = { +const serverOptions = { key: loadPEM('agent2-key'), cert: loadPEM('agent2-cert'), crl: loadPEM('ca2-crl'), @@ -38,7 +38,7 @@ var serverOptions = { NPNProtocols: ['a', 'b', 'c'] }; -var clientsOptions = [{ +const clientsOptions = [{ port: undefined, key: serverOptions.key, cert: serverOptions.cert, @@ -70,7 +70,7 @@ var clientsOptions = [{ const serverResults = []; const clientsResults = []; -var server = tls.createServer(serverOptions, function(c) { +const server = tls.createServer(serverOptions, function(c) { serverResults.push(c.npnProtocol); }); server.listen(0, startTest); @@ -78,7 +78,7 @@ server.listen(0, startTest); function startTest() { function connectClient(options, callback) { options.port = server.address().port; - var client = tls.connect(options, function() { + const client = tls.connect(options, function() { clientsResults.push(client.npnProtocol); client.destroy(); @@ -98,10 +98,10 @@ function startTest() { } process.on('exit', function() { - assert.equal(serverResults[0], clientsResults[0]); - assert.equal(serverResults[1], clientsResults[1]); - assert.equal(serverResults[2], 'http/1.1'); - assert.equal(clientsResults[2], false); - assert.equal(serverResults[3], 'first-priority-unsupported'); - assert.equal(clientsResults[3], false); + assert.strictEqual(serverResults[0], clientsResults[0]); + assert.strictEqual(serverResults[1], clientsResults[1]); + assert.strictEqual(serverResults[2], 'http/1.1'); + assert.strictEqual(clientsResults[2], false); + assert.strictEqual(serverResults[3], 'first-priority-unsupported'); + assert.strictEqual(clientsResults[3], false); }); diff --git a/test/parallel/test-tls-over-http-tunnel.js b/test/parallel/test-tls-over-http-tunnel.js index c030c7482ff6dd..a37913907b5b19 100644 --- a/test/parallel/test-tls-over-http-tunnel.js +++ b/test/parallel/test-tls-over-http-tunnel.js @@ -1,28 +1,28 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); -var net = require('net'); -var http = require('http'); +const fs = require('fs'); +const net = require('net'); +const http = require('http'); -var gotRequest = false; +let gotRequest = false; -var key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); -var cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); +const key = fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'); +const cert = fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem'); -var options = { +const options = { key: key, cert: cert }; -var server = https.createServer(options, function(req, res) { +const server = https.createServer(options, function(req, res) { console.log('SERVER: got request'); res.writeHead(200, { 'content-type': 'text/plain' @@ -31,19 +31,20 @@ var server = https.createServer(options, function(req, res) { res.end('hello world\n'); }); -var proxy = net.createServer(function(clientSocket) { +const proxy = net.createServer(function(clientSocket) { console.log('PROXY: got a client connection'); - var serverSocket = null; + let serverSocket = null; clientSocket.on('data', function(chunk) { if (!serverSocket) { // Verify the CONNECT request - assert.equal(`CONNECT localhost:${server.address().port} HTTP/1.1\r\n` + - 'Proxy-Connections: keep-alive\r\n' + - `Host: localhost:${proxy.address().port}\r\n` + - 'Connection: close\r\n\r\n', - chunk); + assert.strictEqual(`CONNECT localhost:${server.address().port} ` + + 'HTTP/1.1\r\n' + + 'Proxy-Connections: keep-alive\r\n' + + `Host: localhost:${proxy.address().port}\r\n` + + 'Connection: close\r\n\r\n', + chunk.toString()); console.log('PROXY: got CONNECT request'); console.log('PROXY: creating a tunnel'); @@ -80,7 +81,7 @@ server.listen(0); proxy.listen(0, function() { console.log('CLIENT: Making CONNECT request'); - var req = http.request({ + const req = http.request({ port: this.address().port, method: 'CONNECT', path: `localhost:${server.address().port}`, @@ -107,7 +108,7 @@ proxy.listen(0, function() { } function onConnect(res, socket, header) { - assert.equal(200, res.statusCode); + assert.strictEqual(200, res.statusCode); console.log('CLIENT: got CONNECT response'); // detach the socket @@ -130,10 +131,10 @@ proxy.listen(0, function() { agent: false, rejectUnauthorized: false }, function(res) { - assert.equal(200, res.statusCode); + assert.strictEqual(200, res.statusCode); res.on('data', function(chunk) { - assert.equal('hello world\n', chunk); + assert.strictEqual('hello world\n', chunk.toString()); console.log('CLIENT: got HTTPS response'); gotRequest = true; }); diff --git a/test/parallel/test-tls-pause.js b/test/parallel/test-tls-pause.js index 7f4e02a1bfa96d..c5b96b96dd675f 100644 --- a/test/parallel/test-tls-pause.js +++ b/test/parallel/test-tls-pause.js @@ -1,26 +1,26 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); -var options = { +const options = { key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')), cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')) }; -var bufSize = 1024 * 1024; -var sent = 0; -var received = 0; +const bufSize = 1024 * 1024; +let sent = 0; +let received = 0; -var server = tls.Server(options, function(socket) { +const server = tls.Server(options, function(socket) { socket.pipe(socket); socket.on('data', function(c) { console.error('data', c.length); @@ -28,8 +28,8 @@ var server = tls.Server(options, function(socket) { }); server.listen(0, function() { - var resumed = false; - var client = tls.connect({ + let resumed = false; + const client = tls.connect({ port: this.address().port, rejectUnauthorized: false }, function() { @@ -39,7 +39,7 @@ server.listen(0, function() { send(); function send() { console.error('sending'); - var ret = client.write(Buffer.allocUnsafe(bufSize)); + const ret = client.write(Buffer.allocUnsafe(bufSize)); console.error('write => %j', ret); if (false !== ret) { console.error('write again'); @@ -69,5 +69,5 @@ server.listen(0, function() { }); process.on('exit', function() { - assert.equal(sent, received); + assert.strictEqual(sent, received); }); diff --git a/test/parallel/test-tls-peer-certificate-encoding.js b/test/parallel/test-tls-peer-certificate-encoding.js index b59d10faa78bc1..1ae30974aeda83 100644 --- a/test/parallel/test-tls-peer-certificate-encoding.js +++ b/test/parallel/test-tls-peer-certificate-encoding.js @@ -1,35 +1,35 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var util = require('util'); -var join = require('path').join; +const fs = require('fs'); +const util = require('util'); +const join = require('path').join; -var options = { +const options = { key: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent5-key.pem')), cert: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent5-cert.pem')), ca: [ fs.readFileSync(join(common.fixturesDir, 'keys', 'ca2-cert.pem')) ] }; -var server = tls.createServer(options, function(cleartext) { +const server = tls.createServer(options, function(cleartext) { cleartext.end('World'); }); server.listen(0, common.mustCall(function() { - var socket = tls.connect({ + const socket = tls.connect({ port: this.address().port, rejectUnauthorized: false }, common.mustCall(function() { - var peerCert = socket.getPeerCertificate(); + const peerCert = socket.getPeerCertificate(); console.error(util.inspect(peerCert)); - assert.equal(peerCert.subject.CN, 'Ádám Lippai'); + assert.strictEqual(peerCert.subject.CN, 'Ádám Lippai'); server.close(); })); socket.end('Hello'); diff --git a/test/parallel/test-tls-peer-certificate-multi-keys.js b/test/parallel/test-tls-peer-certificate-multi-keys.js index 55bc9f40d3a240..693bb4cb3fa812 100644 --- a/test/parallel/test-tls-peer-certificate-multi-keys.js +++ b/test/parallel/test-tls-peer-certificate-multi-keys.js @@ -1,31 +1,31 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var util = require('util'); -var join = require('path').join; +const fs = require('fs'); +const util = require('util'); +const join = require('path').join; -var options = { +const options = { key: fs.readFileSync(join(common.fixturesDir, 'agent.key')), cert: fs.readFileSync(join(common.fixturesDir, 'multi-alice.crt')) }; -var server = tls.createServer(options, function(cleartext) { +const server = tls.createServer(options, function(cleartext) { cleartext.end('World'); }); server.listen(0, common.mustCall(function() { - var socket = tls.connect({ + const socket = tls.connect({ port: this.address().port, rejectUnauthorized: false }, common.mustCall(function() { - var peerCert = socket.getPeerCertificate(); + const peerCert = socket.getPeerCertificate(); console.error(util.inspect(peerCert)); assert.deepStrictEqual( peerCert.subject.OU, diff --git a/test/parallel/test-tls-peer-certificate.js b/test/parallel/test-tls-peer-certificate.js index ddbbf72a6309e7..eb5be6dcb2241b 100644 --- a/test/parallel/test-tls-peer-certificate.js +++ b/test/parallel/test-tls-peer-certificate.js @@ -1,53 +1,39 @@ 'use strict'; const common = require('../common'); -const assert = require('assert'); -if (!common.hasCrypto) { - common.skip('missing crypto'); - return; -} -const tls = require('tls'); +// Verify that detailed getPeerCertificate() return value has all certs. -const fs = require('fs'); -const util = require('util'); const join = require('path').join; +const { + assert, connect, debug, keys +} = require(join(common.fixturesDir, 'tls-connect'))(); -const options = { - key: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-key.pem')), - cert: fs.readFileSync(join(common.fixturesDir, 'keys', 'agent1-cert.pem')), - ca: [ fs.readFileSync(join(common.fixturesDir, 'keys', 'ca1-cert.pem')) ] -}; +connect({ + client: {rejectUnauthorized: false}, + server: keys.agent1, +}, function(err, pair, cleanup) { + assert.ifError(err); + const socket = pair.client.conn; + let peerCert = socket.getPeerCertificate(); + assert.ok(!peerCert.issuerCertificate); -const server = tls.createServer(options, function(cleartext) { - cleartext.end('World'); -}); -server.listen(0, common.mustCall(function() { - const socket = tls.connect({ - port: this.address().port, - rejectUnauthorized: false - }, common.mustCall(function() { - let peerCert = socket.getPeerCertificate(); - assert.ok(!peerCert.issuerCertificate); + peerCert = socket.getPeerCertificate(true); + debug('peerCert:\n', peerCert); - // Verify that detailed return value has all certs - peerCert = socket.getPeerCertificate(true); - assert.ok(peerCert.issuerCertificate); + assert.ok(peerCert.issuerCertificate); + assert.strictEqual(peerCert.subject.emailAddress, 'ry@tinyclouds.org'); + assert.strictEqual(peerCert.serialNumber, '9A84ABCFB8A72AC0'); + assert.strictEqual(peerCert.exponent, '0x10001'); + assert.strictEqual( + peerCert.fingerprint, + '8D:06:3A:B3:E5:8B:85:29:72:4F:7D:1B:54:CD:95:19:3C:EF:6F:AA' + ); + assert.deepStrictEqual(peerCert.infoAccess['OCSP - URI'], + [ 'http://ocsp.nodejs.org/' ]); - console.error(util.inspect(peerCert)); - assert.strictEqual(peerCert.subject.emailAddress, 'ry@tinyclouds.org'); - assert.strictEqual(peerCert.serialNumber, '9A84ABCFB8A72AC0'); - assert.strictEqual(peerCert.exponent, '0x10001'); - assert.strictEqual( - peerCert.fingerprint, - '8D:06:3A:B3:E5:8B:85:29:72:4F:7D:1B:54:CD:95:19:3C:EF:6F:AA' - ); - assert.deepStrictEqual(peerCert.infoAccess['OCSP - URI'], - [ 'http://ocsp.nodejs.org/' ]); + const issuer = peerCert.issuerCertificate; + assert.strictEqual(issuer.issuerCertificate, issuer); + assert.strictEqual(issuer.serialNumber, '8DF21C01468AF393'); - const issuer = peerCert.issuerCertificate; - assert.strictEqual(issuer.issuerCertificate, issuer); - assert.strictEqual(issuer.serialNumber, '8DF21C01468AF393'); - server.close(); - })); - socket.end('Hello'); -})); + return cleanup(); +}); diff --git a/test/parallel/test-tls-pfx-gh-5100-regr.js b/test/parallel/test-tls-pfx-gh-5100-regr.js index 4670d9ea3da740..142a7de10b841a 100644 --- a/test/parallel/test-tls-pfx-gh-5100-regr.js +++ b/test/parallel/test-tls-pfx-gh-5100-regr.js @@ -28,7 +28,7 @@ const server = tls.createServer({ ); c.end(); })).listen(0, function() { - var client = tls.connect({ + const client = tls.connect({ port: this.address().port, pfx: pfx, passphrase: 'sample', diff --git a/test/parallel/test-tls-request-timeout.js b/test/parallel/test-tls-request-timeout.js index fc793def177f3a..4873a3c696458f 100644 --- a/test/parallel/test-tls-request-timeout.js +++ b/test/parallel/test-tls-request-timeout.js @@ -1,22 +1,22 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var server = tls.Server(options, common.mustCall(function(socket) { - var s = socket.setTimeout(100); +const server = tls.Server(options, common.mustCall(function(socket) { + const s = socket.setTimeout(100); assert.ok(s instanceof tls.TLSSocket); socket.on('timeout', common.mustCall(function(err) { diff --git a/test/parallel/test-tls-securepair-fiftharg.js b/test/parallel/test-tls-securepair-fiftharg.js index 99564055efb807..c79b5cbede8808 100644 --- a/test/parallel/test-tls-securepair-fiftharg.js +++ b/test/parallel/test-tls-securepair-fiftharg.js @@ -15,7 +15,7 @@ const sslcontext = tls.createSecureContext({ key: fs.readFileSync(common.fixturesDir + '/test_key.pem') }); -var catchedServername; +let catchedServername; const pair = tls.createSecurePair(sslcontext, true, false, false, { SNICallback: common.mustCall(function(servername, cb) { catchedServername = servername; diff --git a/test/parallel/test-tls-securepair-server.js b/test/parallel/test-tls-securepair-server.js index 24ac2177c54536..65a7d91a0ca606 100644 --- a/test/parallel/test-tls-securepair-server.js +++ b/test/parallel/test-tls-securepair-server.js @@ -1,31 +1,31 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var join = require('path').join; -var net = require('net'); -var fs = require('fs'); -var spawn = require('child_process').spawn; +const join = require('path').join; +const net = require('net'); +const fs = require('fs'); +const spawn = require('child_process').spawn; -var key = fs.readFileSync(join(common.fixturesDir, 'agent.key')).toString(); -var cert = fs.readFileSync(join(common.fixturesDir, 'agent.crt')).toString(); +const key = fs.readFileSync(join(common.fixturesDir, 'agent.key')).toString(); +const cert = fs.readFileSync(join(common.fixturesDir, 'agent.crt')).toString(); function log(a) { console.error('***server*** ' + a); } -var server = net.createServer(common.mustCall(function(socket) { +const server = net.createServer(common.mustCall(function(socket) { log('connection fd=' + socket.fd); - var sslcontext = tls.createSecureContext({key: key, cert: cert}); + const sslcontext = tls.createSecureContext({key: key, cert: cert}); sslcontext.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA'); - var pair = tls.createSecurePair(sslcontext, true); + const pair = tls.createSecurePair(sslcontext, true); assert.ok(pair.encrypted.writable); assert.ok(pair.cleartext.writable); @@ -84,23 +84,23 @@ var server = net.createServer(common.mustCall(function(socket) { }); })); -var gotHello = false; -var sentWorld = false; -var gotWorld = false; +let gotHello = false; +let sentWorld = false; +let gotWorld = false; server.listen(0, common.mustCall(function() { // To test use: openssl s_client -connect localhost:8000 - var args = ['s_client', '-connect', `127.0.0.1:${this.address().port}`]; + const args = ['s_client', '-connect', `127.0.0.1:${this.address().port}`]; // for the performance and stability issue in s_client on Windows if (common.isWindows) args.push('-no_rand_screen'); - var client = spawn(common.opensslCli, args); + const client = spawn(common.opensslCli, args); - var out = ''; + let out = ''; client.stdout.setEncoding('utf8'); client.stdout.on('data', function(d) { diff --git a/test/parallel/test-tls-server-failed-handshake-emits-clienterror.js b/test/parallel/test-tls-server-failed-handshake-emits-clienterror.js index bd92dc28904183..1ff7decf3cf9cc 100644 --- a/test/parallel/test-tls-server-failed-handshake-emits-clienterror.js +++ b/test/parallel/test-tls-server-failed-handshake-emits-clienterror.js @@ -23,7 +23,7 @@ const server = tls.createServer({}) 'Instance of Error should be passed to error handler'); assert.ok(e.message.match( /SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol/), - 'Expecting SSL unknown protocol'); + 'Expecting SSL unknown protocol'); server.close(); })); diff --git a/test/parallel/test-tls-server-verify.js b/test/parallel/test-tls-server-verify.js index 04c1547384c61e..3b297dd4cea4d7 100644 --- a/test/parallel/test-tls-server-verify.js +++ b/test/parallel/test-tls-server-verify.js @@ -15,88 +15,88 @@ if (!common.opensslCli) { // - accepted and "authorized". const testCases = - [{ title: 'Do not request certs. Everyone is unauthorized.', - requestCert: false, - rejectUnauthorized: false, - renegotiate: false, - CAs: ['ca1-cert'], - clients: - [{ name: 'agent1', shouldReject: false, shouldAuth: false }, + [{ title: 'Do not request certs. Everyone is unauthorized.', + requestCert: false, + rejectUnauthorized: false, + renegotiate: false, + CAs: ['ca1-cert'], + clients: + [{ name: 'agent1', shouldReject: false, shouldAuth: false }, { name: 'agent2', shouldReject: false, shouldAuth: false }, { name: 'agent3', shouldReject: false, shouldAuth: false }, { name: 'nocert', shouldReject: false, shouldAuth: false } - ] - }, - - { title: 'Allow both authed and unauthed connections with CA1', - requestCert: true, - rejectUnauthorized: false, - renegotiate: false, - CAs: ['ca1-cert'], - clients: - [{ name: 'agent1', shouldReject: false, shouldAuth: true }, + ] + }, + + { title: 'Allow both authed and unauthed connections with CA1', + requestCert: true, + rejectUnauthorized: false, + renegotiate: false, + CAs: ['ca1-cert'], + clients: + [{ name: 'agent1', shouldReject: false, shouldAuth: true }, { name: 'agent2', shouldReject: false, shouldAuth: false }, { name: 'agent3', shouldReject: false, shouldAuth: false }, { name: 'nocert', shouldReject: false, shouldAuth: false } - ] - }, - - { title: 'Do not request certs at connection. Do that later', - requestCert: false, - rejectUnauthorized: false, - renegotiate: true, - CAs: ['ca1-cert'], - clients: - [{ name: 'agent1', shouldReject: false, shouldAuth: true }, + ] + }, + + { title: 'Do not request certs at connection. Do that later', + requestCert: false, + rejectUnauthorized: false, + renegotiate: true, + CAs: ['ca1-cert'], + clients: + [{ name: 'agent1', shouldReject: false, shouldAuth: true }, { name: 'agent2', shouldReject: false, shouldAuth: false }, { name: 'agent3', shouldReject: false, shouldAuth: false }, { name: 'nocert', shouldReject: false, shouldAuth: false } - ] - }, - - { title: 'Allow only authed connections with CA1', - requestCert: true, - rejectUnauthorized: true, - renegotiate: false, - CAs: ['ca1-cert'], - clients: - [{ name: 'agent1', shouldReject: false, shouldAuth: true }, + ] + }, + + { title: 'Allow only authed connections with CA1', + requestCert: true, + rejectUnauthorized: true, + renegotiate: false, + CAs: ['ca1-cert'], + clients: + [{ name: 'agent1', shouldReject: false, shouldAuth: true }, { name: 'agent2', shouldReject: true }, { name: 'agent3', shouldReject: true }, { name: 'nocert', shouldReject: true } - ] - }, - - { title: 'Allow only authed connections with CA1 and CA2', - requestCert: true, - rejectUnauthorized: true, - renegotiate: false, - CAs: ['ca1-cert', 'ca2-cert'], - clients: - [{ name: 'agent1', shouldReject: false, shouldAuth: true }, + ] + }, + + { title: 'Allow only authed connections with CA1 and CA2', + requestCert: true, + rejectUnauthorized: true, + renegotiate: false, + CAs: ['ca1-cert', 'ca2-cert'], + clients: + [{ name: 'agent1', shouldReject: false, shouldAuth: true }, { name: 'agent2', shouldReject: true }, { name: 'agent3', shouldReject: false, shouldAuth: true }, { name: 'nocert', shouldReject: true } - ] - }, + ] + }, - { title: 'Allow only certs signed by CA2 but not in the CRL', - requestCert: true, - rejectUnauthorized: true, - renegotiate: false, - CAs: ['ca2-cert'], - crl: 'ca2-crl', - clients: [ + { title: 'Allow only certs signed by CA2 but not in the CRL', + requestCert: true, + rejectUnauthorized: true, + renegotiate: false, + CAs: ['ca2-cert'], + crl: 'ca2-crl', + clients: [ { name: 'agent1', shouldReject: true, shouldAuth: false }, { name: 'agent2', shouldReject: true, shouldAuth: false }, { name: 'agent3', shouldReject: false, shouldAuth: true }, // Agent4 has a cert in the CRL. { name: 'agent4', shouldReject: true, shouldAuth: false }, { name: 'nocert', shouldReject: true } - ] - } - ]; + ] + } + ]; if (!common.hasCrypto) { common.skip('missing crypto'); @@ -216,7 +216,7 @@ function runClient(prefix, port, options, cb) { //client.stdout.pipe(process.stdout); client.on('exit', function(code) { - //assert.equal(0, code, prefix + options.name + + //assert.strictEqual(0, code, prefix + options.name + // ": s_client exited with error code " + code); if (options.shouldReject) { assert.strictEqual(true, rejected, prefix + options.name + @@ -282,7 +282,7 @@ function runTest(port, testIndex) { requestCert: true, rejectUnauthorized: false }, function(err) { - assert(!err); + assert.ifError(err); c.write('\n_renegotiated\n'); handleConnection(c); }); diff --git a/test/parallel/test-tls-session-cache.js b/test/parallel/test-tls-session-cache.js index 60a85701796d72..0b2942215141e3 100644 --- a/test/parallel/test-tls-session-cache.js +++ b/test/parallel/test-tls-session-cache.js @@ -34,9 +34,9 @@ function doTest(testOptions, callback) { ca: [cert], requestCert: true }; - var requestCount = 0; - var resumeCount = 0; - var session; + let requestCount = 0; + let resumeCount = 0; + let session; const server = tls.createServer(options, function(cleartext) { cleartext.on('error', function(er) { @@ -63,7 +63,7 @@ function doTest(testOptions, callback) { server.on('resumeSession', function(id, callback) { ++resumeCount; assert.ok(session); - assert.equal(session.id.toString('hex'), id.toString('hex')); + assert.strictEqual(session.id.toString('hex'), id.toString('hex')); // Just to check that async really works there setTimeout(function() { @@ -90,7 +90,7 @@ function doTest(testOptions, callback) { const client = spawn(common.opensslCli, args, { stdio: [ 0, 1, 'pipe' ] }); - var err = ''; + let err = ''; client.stderr.setEncoding('utf8'); client.stderr.on('data', function(chunk) { err += chunk; @@ -107,7 +107,7 @@ function doTest(testOptions, callback) { } common.fail(`code: ${code}, signal: ${signal}, output: ${err}`); } - assert.equal(code, 0); + assert.strictEqual(code, 0); server.close(common.mustCall(function() { setTimeout(callback, 100); })); @@ -119,13 +119,13 @@ function doTest(testOptions, callback) { process.on('exit', function() { if (testOptions.tickets) { - assert.equal(requestCount, 6); - assert.equal(resumeCount, 0); + assert.strictEqual(requestCount, 6); + assert.strictEqual(resumeCount, 0); } else { // initial request + reconnect requests (5 times) assert.ok(session); - assert.equal(requestCount, 6); - assert.equal(resumeCount, 5); + assert.strictEqual(requestCount, 6); + assert.strictEqual(resumeCount, 5); } }); } diff --git a/test/parallel/test-tls-set-ciphers.js b/test/parallel/test-tls-set-ciphers.js index 5a85e3b22e4c62..a1af1a917eb826 100644 --- a/test/parallel/test-tls-set-ciphers.js +++ b/test/parallel/test-tls-set-ciphers.js @@ -26,7 +26,7 @@ const reply = 'I AM THE WALRUS'; // something recognizable let response = ''; process.on('exit', function() { - assert.notEqual(response.indexOf(reply), -1); + assert.ok(response.includes(reply)); }); const server = tls.createServer(options, common.mustCall(function(conn) { @@ -34,7 +34,7 @@ const server = tls.createServer(options, common.mustCall(function(conn) { })); server.listen(0, '127.0.0.1', function() { - var cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers + + let cmd = '"' + common.opensslCli + '" s_client -cipher ' + options.ciphers + ` -connect 127.0.0.1:${this.address().port}`; // for the performance and stability issue in s_client on Windows @@ -42,7 +42,7 @@ server.listen(0, '127.0.0.1', function() { cmd += ' -no_rand_screen'; exec(cmd, function(err, stdout, stderr) { - if (err) throw err; + assert.ifError(err); response = stdout; server.close(); }); diff --git a/test/parallel/test-tls-sni-option.js b/test/parallel/test-tls-sni-option.js index d9823fa3dabdc4..2e7245336b8b98 100644 --- a/test/parallel/test-tls-sni-option.js +++ b/test/parallel/test-tls-sni-option.js @@ -13,7 +13,7 @@ if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); function filenamePEM(n) { return require('path').join(common.fixturesDir, 'keys', n + '.pem'); @@ -23,13 +23,13 @@ function loadPEM(n) { return fs.readFileSync(filenamePEM(n)); } -var serverOptions = { +const serverOptions = { key: loadPEM('agent2-key'), cert: loadPEM('agent2-cert'), requestCert: true, rejectUnauthorized: false, SNICallback: function(servername, callback) { - var context = SNIContexts[servername]; + const context = SNIContexts[servername]; // Just to test asynchronous callback setTimeout(function() { @@ -45,7 +45,7 @@ var serverOptions = { } }; -var SNIContexts = { +const SNIContexts = { 'a.example.com': { key: loadPEM('agent1-key'), cert: loadPEM('agent1-cert'), @@ -60,7 +60,7 @@ var SNIContexts = { } }; -var clientsOptions = [{ +const clientsOptions = [{ port: undefined, key: loadPEM('agent1-key'), cert: loadPEM('agent1-cert'), @@ -104,7 +104,7 @@ const clientErrors = []; let serverError; let clientError; -var server = tls.createServer(serverOptions, function(c) { +const server = tls.createServer(serverOptions, function(c) { serverResults.push({ sni: c.servername, authorized: c.authorized }); }); @@ -117,12 +117,12 @@ server.listen(0, startTest); function startTest() { function connectClient(i, callback) { - var options = clientsOptions[i]; + const options = clientsOptions[i]; clientError = null; serverError = null; options.port = server.address().port; - var client = tls.connect(options, function() { + const client = tls.connect(options, function() { clientResults.push( /Hostname\/IP doesn't/.test(client.authorizationError || '')); client.destroy(); diff --git a/test/parallel/test-tls-sni-server-client.js b/test/parallel/test-tls-sni-server-client.js index 7a8046c743893d..93fffd3888ffd1 100644 --- a/test/parallel/test-tls-sni-server-client.js +++ b/test/parallel/test-tls-sni-server-client.js @@ -13,7 +13,7 @@ if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); function filenamePEM(n) { return require('path').join(common.fixturesDir, 'keys', n + '.pem'); @@ -23,12 +23,12 @@ function loadPEM(n) { return fs.readFileSync(filenamePEM(n)); } -var serverOptions = { +const serverOptions = { key: loadPEM('agent2-key'), cert: loadPEM('agent2-cert') }; -var SNIContexts = { +const SNIContexts = { 'a.example.com': { key: loadPEM('agent1-key'), cert: loadPEM('agent1-cert') @@ -44,7 +44,7 @@ var SNIContexts = { } }; -var clientsOptions = [{ +const clientsOptions = [{ port: undefined, ca: [loadPEM('ca1-cert')], servername: 'a.example.com', @@ -74,7 +74,7 @@ var clientsOptions = [{ const serverResults = []; const clientResults = []; -var server = tls.createServer(serverOptions, function(c) { +const server = tls.createServer(serverOptions, function(c) { serverResults.push(c.servername); }); @@ -85,15 +85,15 @@ server.addContext('chain.example.com', SNIContexts['chain.example.com']); server.listen(0, startTest); function startTest() { - var i = 0; + let i = 0; function start() { // No options left if (i === clientsOptions.length) return server.close(); - var options = clientsOptions[i++]; + const options = clientsOptions[i++]; options.port = server.address().port; - var client = tls.connect(options, function() { + const client = tls.connect(options, function() { clientResults.push( client.authorizationError && /Hostname\/IP doesn't/.test(client.authorizationError)); diff --git a/test/parallel/test-tls-socket-default-options.js b/test/parallel/test-tls-socket-default-options.js index 5c325570643225..dd62a41090c88e 100644 --- a/test/parallel/test-tls-socket-default-options.js +++ b/test/parallel/test-tls-socket-default-options.js @@ -28,7 +28,7 @@ function testSocketOptions(socket, socketOptions) { s.on('end', function() { server.close(); s.destroy(); - assert.equal(received, sent); + assert.strictEqual(received, sent); setImmediate(runTests); }); }).listen(0, function() { diff --git a/test/parallel/test-tls-socket-failed-handshake-emits-error.js b/test/parallel/test-tls-socket-failed-handshake-emits-error.js index f655dc97b5a99b..ffeb42c8ebd8da 100644 --- a/test/parallel/test-tls-socket-failed-handshake-emits-error.js +++ b/test/parallel/test-tls-socket-failed-handshake-emits-error.js @@ -23,7 +23,7 @@ const server = net.createServer(function(c) { 'Instance of Error should be passed to error handler'); assert.ok(e.message.match( /SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol/), - 'Expecting SSL unknown protocol'); + 'Expecting SSL unknown protocol'); })); s.on('close', function() { diff --git a/test/parallel/test-tls-wrap-timeout.js b/test/parallel/test-tls-wrap-timeout.js index 0454242d92ecb6..d66e1f2d680f77 100644 --- a/test/parallel/test-tls-wrap-timeout.js +++ b/test/parallel/test-tls-wrap-timeout.js @@ -27,8 +27,8 @@ const server = tls.createServer(options, common.mustCall((c) => { }); })); -var socket; -var lastIdleStart; +let socket; +let lastIdleStart; server.listen(0, () => { socket = net.connect(server.address().port, function() { diff --git a/test/parallel/test-umask.js b/test/parallel/test-umask.js index 62f9d82b3312ef..7e4827a4cfc47d 100644 --- a/test/parallel/test-umask.js +++ b/test/parallel/test-umask.js @@ -1,21 +1,21 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); // Note in Windows one can only set the "user" bits. -var mask; +let mask; if (common.isWindows) { mask = '0600'; } else { mask = '0664'; } -var old = process.umask(mask); +const old = process.umask(mask); -assert.equal(parseInt(mask, 8), process.umask(old)); +assert.strictEqual(parseInt(mask, 8), process.umask(old)); // confirm reading the umask does not modify it. // 1. If the test fails, this call will succeed, but the mask will be set to 0 -assert.equal(old, process.umask()); +assert.strictEqual(old, process.umask()); // 2. If the test fails, process.umask() will return 0 -assert.equal(old, process.umask()); +assert.strictEqual(old, process.umask()); diff --git a/test/parallel/test-url.js b/test/parallel/test-url.js index c97caa36429a9c..fa43e1fd5f1330 100644 --- a/test/parallel/test-url.js +++ b/test/parallel/test-url.js @@ -8,7 +8,7 @@ const url = require('url'); // URLs to parse, and expected data // { url : parsed } -var parseTests = { +const parseTests = { '//some_path': { href: '//some_path', pathname: '//some_path', @@ -921,8 +921,8 @@ for (const u in parseTests) { expected = parseTests[u].href; actual = url.format(parseTests[u]); - assert.equal(actual, expected, - 'format(' + u + ') == ' + u + '\nactual:' + actual); + assert.strictEqual(actual, expected, + 'format(' + u + ') == ' + u + '\nactual:' + actual); } function createWithNoPrototype(properties = []) { @@ -942,7 +942,7 @@ function check(actual, expected) { }); } -var parseTestsWithQueryString = { +const parseTestsWithQueryString = { '/foo/bar?baz=quux#frag': { href: '/foo/bar?baz=quux#frag', hash: '#frag', @@ -1013,7 +1013,7 @@ for (const u in parseTestsWithQueryString) { // some extra formatting tests, just to verify // that it'll format slightly wonky content to a valid url. -var formatTests = { +const formatTests = { 'http://example.com?': { href: 'http://example.com/?', protocol: 'http:', @@ -1250,7 +1250,7 @@ for (const u in formatTests) { /* [from, path, expected] */ -var relativeTests = [ +const relativeTests = [ ['/foo/bar/baz', 'quux', '/foo/bar/quux'], ['/foo/bar/baz', 'quux/asdf', '/foo/bar/quux/asdf'], ['/foo/bar/baz', 'quux/baz', '/foo/bar/quux/baz'], @@ -1299,8 +1299,8 @@ var relativeTests = [ relativeTests.forEach(function(relativeTest) { const a = url.resolve(relativeTest[0], relativeTest[1]); const e = relativeTest[2]; - assert.equal(a, e, - 'resolve(' + [relativeTest[0], relativeTest[1]] + ') == ' + e + + assert.strictEqual(a, e, + 'resolve(' + [relativeTest[0], relativeTest[1]] + ') == ' + e + '\n actual=' + a); }); @@ -1329,7 +1329,7 @@ relativeTests.forEach(function(relativeTest) { // // Changes marked with @isaacs -var bases = [ +const bases = [ 'http://a/b/c/d;p?q', 'http://a/b/c/d;p?q=1/2', 'http://a/b/c/d;p=1/2?q', @@ -1338,7 +1338,7 @@ var bases = [ ]; //[to, from, result] -var relativeTests2 = [ +const relativeTests2 = [ // http://lists.w3.org/Archives/Public/uri/2004Feb/0114.html ['../c', 'foo:a/b', 'foo:c'], ['foo:.', 'foo:a', 'foo:'], @@ -1631,8 +1631,8 @@ var relativeTests2 = [ relativeTests2.forEach(function(relativeTest) { const a = url.resolve(relativeTest[1], relativeTest[0]); const e = url.format(relativeTest[2]); - assert.equal(a, e, - 'resolve(' + [relativeTest[1], relativeTest[0]] + ') == ' + e + + assert.strictEqual(a, e, + 'resolve(' + [relativeTest[1], relativeTest[0]] + ') == ' + e + '\n actual=' + a); }); @@ -1641,8 +1641,8 @@ relativeTests2.forEach(function(relativeTest) { //format: [from, path, expected] relativeTests.forEach(function(relativeTest) { - var actual = url.resolveObject(url.parse(relativeTest[0]), relativeTest[1]); - var expected = url.parse(relativeTest[2]); + let actual = url.resolveObject(url.parse(relativeTest[0]), relativeTest[1]); + let expected = url.parse(relativeTest[2]); assert.deepStrictEqual(actual, expected); @@ -1650,8 +1650,8 @@ relativeTests.forEach(function(relativeTest) { expected = relativeTest[2]; actual = url.format(actual); - assert.equal(actual, expected, - 'format(' + actual + ') == ' + expected + '\nactual:' + actual); + assert.strictEqual(actual, expected, + 'format(' + actual + ') == ' + expected + '\nactual:' + actual); }); //format: [to, from, result] @@ -1669,8 +1669,8 @@ if (relativeTests2[181][0] === './/g' && relativeTests2.splice(181, 1); } relativeTests2.forEach(function(relativeTest) { - var actual = url.resolveObject(url.parse(relativeTest[1]), relativeTest[0]); - var expected = url.parse(relativeTest[2]); + let actual = url.resolveObject(url.parse(relativeTest[1]), relativeTest[0]); + let expected = url.parse(relativeTest[2]); assert.deepStrictEqual( actual, @@ -1681,14 +1681,14 @@ relativeTests2.forEach(function(relativeTest) { expected = url.format(relativeTest[2]); actual = url.format(actual); - assert.equal(actual, expected, - 'format(' + relativeTest[1] + ') == ' + expected + + assert.strictEqual(actual, expected, + 'format(' + relativeTest[1] + ') == ' + expected + '\nactual:' + actual); }); // https://github.com/nodejs/node/pull/1036 -var throws = [ +const throws = [ undefined, null, true, diff --git a/test/parallel/test-utf8-scripts.js b/test/parallel/test-utf8-scripts.js index 98c26594bb6540..e9d141d58abab0 100644 --- a/test/parallel/test-utf8-scripts.js +++ b/test/parallel/test-utf8-scripts.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); // üäö console.log('Σὲ γνωρίζω ἀπὸ τὴν κόψη'); -assert.equal(true, /Hellö Wörld/.test('Hellö Wörld')); +assert.strictEqual(true, /Hellö Wörld/.test('Hellö Wörld')); diff --git a/test/parallel/test-util-decorate-error-stack.js b/test/parallel/test-util-decorate-error-stack.js deleted file mode 100644 index 5e4a2bd3b7842d..00000000000000 --- a/test/parallel/test-util-decorate-error-stack.js +++ /dev/null @@ -1,58 +0,0 @@ -// Flags: --expose_internals -'use strict'; -const common = require('../common'); -const assert = require('assert'); -const internalUtil = require('internal/util'); -const spawnSync = require('child_process').spawnSync; -const path = require('path'); - -assert.doesNotThrow(function() { - internalUtil.decorateErrorStack(); - internalUtil.decorateErrorStack(null); - internalUtil.decorateErrorStack(1); - internalUtil.decorateErrorStack(true); -}); - -// Verify that a stack property is not added to non-Errors -const obj = {}; -internalUtil.decorateErrorStack(obj); -assert.strictEqual(obj.stack, undefined); - -// Verify that the stack is decorated when possible -function checkStack(stack) { - const matches = stack.match(/var foo bar;/g); - assert.strictEqual(Array.isArray(matches), true); - assert.strictEqual(matches.length, 1); -} -let err; -const badSyntaxPath = - path.join(common.fixturesDir, 'syntax', 'bad_syntax') - .replace(/\\/g, '\\\\'); - -try { - require(badSyntaxPath); -} catch (e) { - err = e; -} - -assert(typeof err, 'object'); -checkStack(err.stack); - -// Verify that the stack is only decorated once -internalUtil.decorateErrorStack(err); -internalUtil.decorateErrorStack(err); -checkStack(err.stack); - -// Verify that the stack is only decorated once for uncaught exceptions -const args = [ - '-e', - `require('${badSyntaxPath}')` -]; -const result = spawnSync(process.argv[0], args, { encoding: 'utf8' }); -checkStack(result.stderr); - -// Verify that the stack is unchanged when there is no arrow message -err = new Error('foo'); -const originalStack = err.stack; -internalUtil.decorateErrorStack(err); -assert.strictEqual(originalStack, err.stack); diff --git a/test/parallel/test-util-inspect-simd.js b/test/parallel/test-util-inspect-simd.js index ec4ccc1875a817..5e0a2740840c93 100644 --- a/test/parallel/test-util-inspect-simd.js +++ b/test/parallel/test-util-inspect-simd.js @@ -1,12 +1,11 @@ // Flags: --harmony_simd +/* global SIMD */ 'use strict'; require('../common'); const assert = require('assert'); const inspect = require('util').inspect; -const SIMD = global.SIMD; // Pacify eslint. - assert.strictEqual( inspect(SIMD.Bool16x8()), 'Bool16x8 [ false, false, false, false, false, false, false, false ]'); diff --git a/test/parallel/test-util-inspect-tuple-origin.js b/test/parallel/test-util-inspect-tuple-origin.js deleted file mode 100644 index 743651098f60db..00000000000000 --- a/test/parallel/test-util-inspect-tuple-origin.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -require('../common'); -const assert = require('assert'); -const inspect = require('util').inspect; -const originFor = require('url').originFor; - -assert.strictEqual( - inspect(originFor('http://test.com:8000')), - `TupleOrigin { - scheme: http, - host: test.com, - port: 8000, - domain: null - }` - ); - -assert.strictEqual( - inspect(originFor('http://test.com')), - `TupleOrigin { - scheme: http, - host: test.com, - port: undefined, - domain: null - }` - ); - - -assert.strictEqual( - inspect(originFor('https://test.com')), - `TupleOrigin { - scheme: https, - host: test.com, - port: undefined, - domain: null - }` - ); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 1118065f1a09da..62743ebd19d16a 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -42,7 +42,7 @@ assert.strictEqual(util.inspect({'a': {'b': { 'c': 2}}}, false, 1), '{ a: { b: [Object] } }'); assert.strictEqual(util.inspect(Object.create({}, {visible: {value: 1, enumerable: true}, hidden: {value: 2}})), - '{ visible: 1 }' + '{ visible: 1 }' ); { @@ -206,8 +206,9 @@ for (const showHidden of [true, false]) { // Objects without prototype { const out = util.inspect(Object.create(null, - { name: {value: 'Tim', enumerable: true}, - hidden: {value: 'secret'}}), true); + { name: {value: 'Tim', + enumerable: true}, + hidden: {value: 'secret'}}), true); if (out !== "{ [hidden]: 'secret', name: 'Tim' }" && out !== "{ name: 'Tim', [hidden]: 'secret' }") { common.fail(`unexpected value for out ${out}`); @@ -216,8 +217,8 @@ for (const showHidden of [true, false]) { assert.strictEqual( util.inspect(Object.create(null, - {name: {value: 'Tim', enumerable: true}, - hidden: {value: 'secret'}})), + {name: {value: 'Tim', enumerable: true}, + hidden: {value: 'secret'}})), '{ name: \'Tim\' }' ); @@ -232,7 +233,7 @@ assert.strictEqual(util.inspect({get readwrite() {}, set readwrite(val) {}}), assert.strictEqual(util.inspect({set writeonly(val) {}}), '{ writeonly: [Setter] }'); -var value = {}; +let value = {}; value['a'] = value; assert.strictEqual(util.inspect(value), '{ a: [Circular] }'); @@ -270,11 +271,11 @@ assert.strictEqual(util.inspect(value), '{ 2010-02-14T11:48:40.000Z aprop: 42 }' ); // test the internal isDate implementation -var Date2 = require('vm').runInNewContext('Date'); -var d = new Date2(); -var orig = util.inspect(d); +const Date2 = vm.runInNewContext('Date'); +const d = new Date2(); +const orig = util.inspect(d); Date2.prototype.foo = 'bar'; -var after = util.inspect(d); +const after = util.inspect(d); assert.strictEqual(orig, after); // test positive/negative zero @@ -282,7 +283,7 @@ assert.strictEqual(util.inspect(0), '0'); assert.strictEqual(util.inspect(-0), '-0'); // test for sparse array -var a = ['foo', 'bar', 'baz']; +const a = ['foo', 'bar', 'baz']; assert.strictEqual(util.inspect(a), '[ \'foo\', \'bar\', \'baz\' ]'); delete a[1]; assert.strictEqual(util.inspect(a), '[ \'foo\', , \'baz\' ]'); @@ -294,7 +295,7 @@ assert.strictEqual(util.inspect(new Array(5)), '[ , , , , ]'); // test for Array constructor in different context { - const Debug = require('vm').runInDebugContext('Debug'); + const Debug = vm.runInDebugContext('Debug'); const map = new Map(); map.set(1, 2); const mirror = Debug.MakeMirror(map.entries(), true); @@ -308,27 +309,27 @@ assert.strictEqual(util.inspect(new Array(5)), '[ , , , , ]'); } // test for other constructors in different context -var obj = require('vm').runInNewContext('(function(){return {}})()', {}); +let obj = vm.runInNewContext('(function(){return {}})()', {}); assert.strictEqual(util.inspect(obj), '{}'); -obj = require('vm').runInNewContext('var m=new Map();m.set(1,2);m', {}); +obj = vm.runInNewContext('var m=new Map();m.set(1,2);m', {}); assert.strictEqual(util.inspect(obj), 'Map { 1 => 2 }'); -obj = require('vm').runInNewContext('var s=new Set();s.add(1);s.add(2);s', {}); +obj = vm.runInNewContext('var s=new Set();s.add(1);s.add(2);s', {}); assert.strictEqual(util.inspect(obj), 'Set { 1, 2 }'); -obj = require('vm').runInNewContext('fn=function(){};new Promise(fn,fn)', {}); +obj = vm.runInNewContext('fn=function(){};new Promise(fn,fn)', {}); assert.strictEqual(util.inspect(obj), 'Promise { }'); // test for property descriptors -var getter = Object.create(null, { +const getter = Object.create(null, { a: { get: function() { return 'aaa'; } } }); -var setter = Object.create(null, { +const setter = Object.create(null, { b: { set: function() {} } }); -var getterAndSetter = Object.create(null, { +const getterAndSetter = Object.create(null, { c: { get: function() { return 'ccc'; }, set: function() {} @@ -355,7 +356,7 @@ try { } catch (e) { assert.strictEqual(util.inspect(e), e.stack); } -var ex = util.inspect(new Error('FAIL'), true); +const ex = util.inspect(new Error('FAIL'), true); assert(ex.includes('Error: FAIL')); assert(ex.includes('[stack]')); assert(ex.includes('[message]')); @@ -379,19 +380,19 @@ assert.strictEqual(util.inspect(Object.create(Date.prototype)), 'Date {}'); // GH-1944 assert.doesNotThrow(function() { - var d = new Date(); + const d = new Date(); d.toUTCString = null; util.inspect(d); }); assert.doesNotThrow(function() { - var d = new Date(); + const d = new Date(); d.toISOString = null; util.inspect(d); }); assert.doesNotThrow(function() { - var r = /regexp/; + const r = /regexp/; r.toString = null; util.inspect(r); }); @@ -410,14 +411,14 @@ assert.doesNotThrow(function() { } // util.inspect should not display the escaped value of a key. -var w = { +const w = { '\\': 1, '\\\\': 2, '\\\\\\': 3, '\\\\\\\\': 4, }; -var y = ['a', 'b', 'c']; +const y = ['a', 'b', 'c']; y['\\\\\\'] = 'd'; assert.strictEqual( @@ -431,15 +432,15 @@ assert.strictEqual( // util.inspect.styles and util.inspect.colors function test_color_style(style, input, implicit) { - var color_name = util.inspect.styles[style]; - var color = ['', '']; + const color_name = util.inspect.styles[style]; + let color = ['', '']; if (util.inspect.colors[color_name]) color = util.inspect.colors[color_name]; - var without_color = util.inspect(input, false, 0, false); - var with_color = util.inspect(input, false, 0, true); - var expect = '\u001b[' + color[0] + 'm' + without_color + - '\u001b[' + color[1] + 'm'; + const without_color = util.inspect(input, false, 0, false); + const with_color = util.inspect(input, false, 0, true); + const expect = '\u001b[' + color[0] + 'm' + without_color + + '\u001b[' + color[1] + 'm'; assert.strictEqual( with_color, expect, @@ -592,19 +593,19 @@ assert.doesNotThrow(function() { // util.inspect with "colors" option should produce as many lines as without it function test_lines(input) { - var count_lines = function(str) { + const count_lines = function(str) { return (str.match(/\n/g) || []).length; }; - var without_color = util.inspect(input); - var with_color = util.inspect(input, {colors: true}); + const without_color = util.inspect(input); + const with_color = util.inspect(input, {colors: true}); assert.strictEqual(count_lines(without_color), count_lines(with_color)); } test_lines([1, 2, 3, 4, 5, 6, 7]); test_lines(function() { - var big_array = []; - for (var i = 0; i < 100; i++) { + const big_array = []; + for (let i = 0; i < 100; i++) { big_array.push(i); } return big_array; @@ -632,15 +633,15 @@ assert.strictEqual(util.inspect(new Number(-1.1)), '[Number: -1.1]'); assert.strictEqual(util.inspect(new Number(13.37)), '[Number: 13.37]'); // test boxed primitives with own properties -var str = new String('baz'); +const str = new String('baz'); str.foo = 'bar'; assert.strictEqual(util.inspect(str), '{ [String: \'baz\'] foo: \'bar\' }'); -var bool = new Boolean(true); +const bool = new Boolean(true); bool.foo = 'bar'; assert.strictEqual(util.inspect(bool), '{ [Boolean: true] foo: \'bar\' }'); -var num = new Number(13.37); +const num = new Number(13.37); num.foo = 'bar'; assert.strictEqual(util.inspect(num), '{ [Number: 13.37] foo: \'bar\' }'); @@ -674,7 +675,7 @@ if (typeof Symbol !== 'undefined') { // test Set assert.strictEqual(util.inspect(new Set()), 'Set {}'); assert.strictEqual(util.inspect(new Set([1, 2, 3])), 'Set { 1, 2, 3 }'); -var set = new Set(['foo']); +const set = new Set(['foo']); set.bar = 42; assert.strictEqual( util.inspect(set, true), @@ -706,30 +707,30 @@ assert.strictEqual( util.inspect(new Promise(function() {})), 'Promise { }' ); -var promise = Promise.resolve('foo'); +const promise = Promise.resolve('foo'); promise.bar = 42; assert.strictEqual(util.inspect(promise), 'Promise { \'foo\', bar: 42 }'); // Make sure it doesn't choke on polyfills. Unlike Set/Map, there is no standard // interface to synchronously inspect a Promise, so our techniques only work on // a bonafide native Promise. -var oldPromise = Promise; +const oldPromise = Promise; global.Promise = function() { this.bar = 42; }; assert.strictEqual(util.inspect(new Promise()), '{ bar: 42 }'); global.Promise = oldPromise; // Map/Set Iterators -var m = new Map([['foo', 'bar']]); +const m = new Map([['foo', 'bar']]); assert.strictEqual(util.inspect(m.keys()), 'MapIterator { \'foo\' }'); assert.strictEqual(util.inspect(m.values()), 'MapIterator { \'bar\' }'); assert.strictEqual(util.inspect(m.entries()), 'MapIterator { [ \'foo\', \'bar\' ] }'); // make sure the iterator doesn't get consumed -var keys = m.keys(); +let keys = m.keys(); assert.strictEqual(util.inspect(keys), 'MapIterator { \'foo\' }'); assert.strictEqual(util.inspect(keys), 'MapIterator { \'foo\' }'); -var s = new Set([1, 3]); +const s = new Set([1, 3]); assert.strictEqual(util.inspect(s.keys()), 'SetIterator { 1, 3 }'); assert.strictEqual(util.inspect(s.values()), 'SetIterator { 1, 3 }'); assert.strictEqual(util.inspect(s.entries()), @@ -743,10 +744,10 @@ assert.strictEqual(util.inspect(keys), 'SetIterator { 1, 3 }'); // Assumes that the first numeric character is the start of an item. function checkAlignment(container) { - var lines = util.inspect(container).split('\n'); - var pos; + const lines = util.inspect(container).split('\n'); + let pos; lines.forEach(function(line) { - var npos = line.search(/\d/); + const npos = line.search(/\d/); if (npos !== -1) { if (pos !== undefined) assert.strictEqual(pos, npos, 'container items not aligned'); @@ -755,14 +756,14 @@ function checkAlignment(container) { }); } -var big_array = []; -for (var i = 0; i < 100; i++) { +const big_array = []; +for (let i = 0; i < 100; i++) { big_array.push(i); } checkAlignment(big_array); checkAlignment(function() { - var obj = {}; + const obj = {}; big_array.forEach(function(v) { obj[v] = null; }); diff --git a/test/parallel/test-util-log.js b/test/parallel/test-util-log.js index 91f77d994da847..3604b42820063e 100644 --- a/test/parallel/test-util-log.js +++ b/test/parallel/test-util-log.js @@ -1,19 +1,19 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var util = require('util'); +const assert = require('assert'); +const util = require('util'); assert.ok(process.stdout.writable); assert.ok(process.stderr.writable); -var stdout_write = global.process.stdout.write; -var strings = []; +const stdout_write = global.process.stdout.write; +const strings = []; global.process.stdout.write = function(string) { strings.push(string); }; console._stderr = process.stdout; -var tests = [ +const tests = [ {input: 'foo', output: 'foo'}, {input: undefined, output: 'undefined'}, {input: null, output: 'null'}, @@ -32,7 +32,7 @@ tests.forEach(function(test) { const re = (/[0-9]{1,2} [A-Z][a-z]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} - (.+)$/); const match = re.exec(result); assert.ok(match); - assert.equal(match[1], test.output); + assert.strictEqual(match[1], test.output); }); global.process.stdout.write = stdout_write; diff --git a/test/parallel/test-util-sigint-watchdog.js b/test/parallel/test-util-sigint-watchdog.js index 42e4048bd74a36..207f44b011c3a2 100644 --- a/test/parallel/test-util-sigint-watchdog.js +++ b/test/parallel/test-util-sigint-watchdog.js @@ -16,41 +16,41 @@ if (common.isWindows) { assert.strictEqual(hadPendingSignals, false); next(); }, -(next) => { + (next) => { // Test with one call to the watchdog, one signal. - binding.startSigintWatchdog(); - process.kill(process.pid, 'SIGINT'); - waitForPendingSignal(common.mustCall(() => { - const hadPendingSignals = binding.stopSigintWatchdog(); - assert.strictEqual(hadPendingSignals, true); - next(); - })); -}, -(next) => { + binding.startSigintWatchdog(); + process.kill(process.pid, 'SIGINT'); + waitForPendingSignal(common.mustCall(() => { + const hadPendingSignals = binding.stopSigintWatchdog(); + assert.strictEqual(hadPendingSignals, true); + next(); + })); + }, + (next) => { // Nested calls are okay. - binding.startSigintWatchdog(); - binding.startSigintWatchdog(); - process.kill(process.pid, 'SIGINT'); - waitForPendingSignal(common.mustCall(() => { - const hadPendingSignals1 = binding.stopSigintWatchdog(); - const hadPendingSignals2 = binding.stopSigintWatchdog(); - assert.strictEqual(hadPendingSignals1, true); - assert.strictEqual(hadPendingSignals2, false); - next(); - })); -}, -() => { + binding.startSigintWatchdog(); + binding.startSigintWatchdog(); + process.kill(process.pid, 'SIGINT'); + waitForPendingSignal(common.mustCall(() => { + const hadPendingSignals1 = binding.stopSigintWatchdog(); + const hadPendingSignals2 = binding.stopSigintWatchdog(); + assert.strictEqual(hadPendingSignals1, true); + assert.strictEqual(hadPendingSignals2, false); + next(); + })); + }, + () => { // Signal comes in after first call to stop. - binding.startSigintWatchdog(); - binding.startSigintWatchdog(); - const hadPendingSignals1 = binding.stopSigintWatchdog(); - process.kill(process.pid, 'SIGINT'); - waitForPendingSignal(common.mustCall(() => { - const hadPendingSignals2 = binding.stopSigintWatchdog(); - assert.strictEqual(hadPendingSignals1, false); - assert.strictEqual(hadPendingSignals2, true); - })); -}].reduceRight((a, b) => common.mustCall(b).bind(null, a))(); + binding.startSigintWatchdog(); + binding.startSigintWatchdog(); + const hadPendingSignals1 = binding.stopSigintWatchdog(); + process.kill(process.pid, 'SIGINT'); + waitForPendingSignal(common.mustCall(() => { + const hadPendingSignals2 = binding.stopSigintWatchdog(); + assert.strictEqual(hadPendingSignals1, false); + assert.strictEqual(hadPendingSignals2, true); + })); + }].reduceRight((a, b) => common.mustCall(b).bind(null, a))(); function waitForPendingSignal(cb) { if (binding.watchdogHasPendingSigint()) diff --git a/test/parallel/test-util.js b/test/parallel/test-util.js index 0f5ee28e37b59c..3b7e78ea1e464e 100644 --- a/test/parallel/test-util.js +++ b/test/parallel/test-util.js @@ -5,78 +5,78 @@ const util = require('util'); const context = require('vm').runInNewContext; // isArray -assert.equal(true, util.isArray([])); -assert.equal(true, util.isArray(Array())); -assert.equal(true, util.isArray(new Array())); -assert.equal(true, util.isArray(new Array(5))); -assert.equal(true, util.isArray(new Array('with', 'some', 'entries'))); -assert.equal(true, util.isArray(context('Array')())); -assert.equal(false, util.isArray({})); -assert.equal(false, util.isArray({ push: function() {} })); -assert.equal(false, util.isArray(/regexp/)); -assert.equal(false, util.isArray(new Error())); -assert.equal(false, util.isArray(Object.create(Array.prototype))); +assert.strictEqual(true, util.isArray([])); +assert.strictEqual(true, util.isArray(Array())); +assert.strictEqual(true, util.isArray(new Array())); +assert.strictEqual(true, util.isArray(new Array(5))); +assert.strictEqual(true, util.isArray(new Array('with', 'some', 'entries'))); +assert.strictEqual(true, util.isArray(context('Array')())); +assert.strictEqual(false, util.isArray({})); +assert.strictEqual(false, util.isArray({ push: function() {} })); +assert.strictEqual(false, util.isArray(/regexp/)); +assert.strictEqual(false, util.isArray(new Error())); +assert.strictEqual(false, util.isArray(Object.create(Array.prototype))); // isRegExp -assert.equal(true, util.isRegExp(/regexp/)); -assert.equal(true, util.isRegExp(RegExp())); -assert.equal(true, util.isRegExp(new RegExp())); -assert.equal(true, util.isRegExp(context('RegExp')())); -assert.equal(false, util.isRegExp({})); -assert.equal(false, util.isRegExp([])); -assert.equal(false, util.isRegExp(new Date())); -assert.equal(false, util.isRegExp(Object.create(RegExp.prototype))); +assert.strictEqual(true, util.isRegExp(/regexp/)); +assert.strictEqual(true, util.isRegExp(RegExp())); +assert.strictEqual(true, util.isRegExp(new RegExp())); +assert.strictEqual(true, util.isRegExp(context('RegExp')())); +assert.strictEqual(false, util.isRegExp({})); +assert.strictEqual(false, util.isRegExp([])); +assert.strictEqual(false, util.isRegExp(new Date())); +assert.strictEqual(false, util.isRegExp(Object.create(RegExp.prototype))); // isDate -assert.equal(true, util.isDate(new Date())); -assert.equal(true, util.isDate(new Date(0))); +assert.strictEqual(true, util.isDate(new Date())); +assert.strictEqual(true, util.isDate(new Date(0))); // eslint-disable-next-line new-parens -assert.equal(true, util.isDate(new (context('Date')))); -assert.equal(false, util.isDate(Date())); -assert.equal(false, util.isDate({})); -assert.equal(false, util.isDate([])); -assert.equal(false, util.isDate(new Error())); -assert.equal(false, util.isDate(Object.create(Date.prototype))); +assert.strictEqual(true, util.isDate(new (context('Date')))); +assert.strictEqual(false, util.isDate(Date())); +assert.strictEqual(false, util.isDate({})); +assert.strictEqual(false, util.isDate([])); +assert.strictEqual(false, util.isDate(new Error())); +assert.strictEqual(false, util.isDate(Object.create(Date.prototype))); // isError -assert.equal(true, util.isError(new Error())); -assert.equal(true, util.isError(new TypeError())); -assert.equal(true, util.isError(new SyntaxError())); +assert.strictEqual(true, util.isError(new Error())); +assert.strictEqual(true, util.isError(new TypeError())); +assert.strictEqual(true, util.isError(new SyntaxError())); /* eslint-disable new-parens */ -assert.equal(true, util.isError(new (context('Error')))); -assert.equal(true, util.isError(new (context('TypeError')))); -assert.equal(true, util.isError(new (context('SyntaxError')))); +assert.strictEqual(true, util.isError(new (context('Error')))); +assert.strictEqual(true, util.isError(new (context('TypeError')))); +assert.strictEqual(true, util.isError(new (context('SyntaxError')))); /* eslint-enable */ -assert.equal(false, util.isError({})); -assert.equal(false, util.isError({ name: 'Error', message: '' })); -assert.equal(false, util.isError([])); -assert.equal(true, util.isError(Object.create(Error.prototype))); +assert.strictEqual(false, util.isError({})); +assert.strictEqual(false, util.isError({ name: 'Error', message: '' })); +assert.strictEqual(false, util.isError([])); +assert.strictEqual(true, util.isError(Object.create(Error.prototype))); // isObject assert.ok(util.isObject({}) === true); // isPrimitive -assert.equal(false, util.isPrimitive({})); -assert.equal(false, util.isPrimitive(new Error())); -assert.equal(false, util.isPrimitive(new Date())); -assert.equal(false, util.isPrimitive([])); -assert.equal(false, util.isPrimitive(/regexp/)); -assert.equal(false, util.isPrimitive(function() {})); -assert.equal(false, util.isPrimitive(new Number(1))); -assert.equal(false, util.isPrimitive(new String('bla'))); -assert.equal(false, util.isPrimitive(new Boolean(true))); -assert.equal(true, util.isPrimitive(1)); -assert.equal(true, util.isPrimitive('bla')); -assert.equal(true, util.isPrimitive(true)); -assert.equal(true, util.isPrimitive(undefined)); -assert.equal(true, util.isPrimitive(null)); -assert.equal(true, util.isPrimitive(Infinity)); -assert.equal(true, util.isPrimitive(NaN)); -assert.equal(true, util.isPrimitive(Symbol('symbol'))); +assert.strictEqual(false, util.isPrimitive({})); +assert.strictEqual(false, util.isPrimitive(new Error())); +assert.strictEqual(false, util.isPrimitive(new Date())); +assert.strictEqual(false, util.isPrimitive([])); +assert.strictEqual(false, util.isPrimitive(/regexp/)); +assert.strictEqual(false, util.isPrimitive(function() {})); +assert.strictEqual(false, util.isPrimitive(new Number(1))); +assert.strictEqual(false, util.isPrimitive(new String('bla'))); +assert.strictEqual(false, util.isPrimitive(new Boolean(true))); +assert.strictEqual(true, util.isPrimitive(1)); +assert.strictEqual(true, util.isPrimitive('bla')); +assert.strictEqual(true, util.isPrimitive(true)); +assert.strictEqual(true, util.isPrimitive(undefined)); +assert.strictEqual(true, util.isPrimitive(null)); +assert.strictEqual(true, util.isPrimitive(Infinity)); +assert.strictEqual(true, util.isPrimitive(NaN)); +assert.strictEqual(true, util.isPrimitive(Symbol('symbol'))); // isBuffer -assert.equal(false, util.isBuffer('foo')); -assert.equal(true, util.isBuffer(Buffer.from('foo'))); +assert.strictEqual(false, util.isBuffer('foo')); +assert.strictEqual(true, util.isBuffer(Buffer.from('foo'))); // _extend assert.deepStrictEqual(util._extend({a: 1}), {a: 1}); diff --git a/test/parallel/test-v8-flag-type-check.js b/test/parallel/test-v8-flag-type-check.js index 986f37314d605f..b5d4d7c2f12665 100644 --- a/test/parallel/test-v8-flag-type-check.js +++ b/test/parallel/test-v8-flag-type-check.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var v8 = require('v8'); +const assert = require('assert'); +const v8 = require('v8'); assert.throws(function() { v8.setFlagsFromString(1); }, TypeError); assert.throws(function() { v8.setFlagsFromString(); }, TypeError); diff --git a/test/parallel/test-v8-flags.js b/test/parallel/test-v8-flags.js index 50cff9ecefceac..99384080516bb2 100644 --- a/test/parallel/test-v8-flags.js +++ b/test/parallel/test-v8-flags.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var v8 = require('v8'); -var vm = require('vm'); +const assert = require('assert'); +const v8 = require('v8'); +const vm = require('vm'); // Note: changing V8 flags after an isolate started is not guaranteed to work. // Specifically here, V8 may cache compiled scripts between the flip of the diff --git a/test/parallel/test-v8-stats.js b/test/parallel/test-v8-stats.js index 74a9977fbc00c6..02182e2816bbc7 100644 --- a/test/parallel/test-v8-stats.js +++ b/test/parallel/test-v8-stats.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var v8 = require('v8'); +const assert = require('assert'); +const v8 = require('v8'); -var s = v8.getHeapStatistics(); -var keys = [ +const s = v8.getHeapStatistics(); +const keys = [ 'does_zap_garbage', 'heap_size_limit', 'malloced_memory', @@ -16,7 +16,7 @@ var keys = [ 'used_heap_size']; assert.deepStrictEqual(Object.keys(s).sort(), keys); keys.forEach(function(key) { - assert.equal(typeof s[key], 'number'); + assert.strictEqual(typeof s[key], 'number'); }); diff --git a/test/parallel/test-vm-basic.js b/test/parallel/test-vm-basic.js index b2b280c21bd173..2d57cc0d4ba328 100644 --- a/test/parallel/test-vm-basic.js +++ b/test/parallel/test-vm-basic.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); // Test 1: vm.runInNewContext -var sandbox = {}; -var result = vm.runInNewContext( +const sandbox = {}; +let result = vm.runInNewContext( 'foo = "bar"; this.typeofProcess = typeof process; typeof Object;', sandbox ); @@ -16,8 +16,8 @@ assert.deepStrictEqual(sandbox, { assert.strictEqual(result, 'function'); // Test 2: vm.runInContext -var sandbox2 = { foo: 'bar' }; -var context = vm.createContext(sandbox2); +const sandbox2 = { foo: 'bar' }; +const context = vm.createContext(sandbox2); result = vm.runInContext( 'baz = foo; this.typeofProcess = typeof process; typeof Object;', context @@ -45,6 +45,6 @@ assert.strictEqual(global.vmResult, undefined); assert.strictEqual(result, 'undefined'); // Test 5: vm.createContext -var sandbox3 = {}; -var context2 = vm.createContext(sandbox3); +const sandbox3 = {}; +const context2 = vm.createContext(sandbox3); assert.strictEqual(sandbox3, context2); diff --git a/test/parallel/test-vm-cached-data.js b/test/parallel/test-vm-cached-data.js index aa2dd26ad5a8b7..3f74f398b814ca 100644 --- a/test/parallel/test-vm-cached-data.js +++ b/test/parallel/test-vm-cached-data.js @@ -15,8 +15,8 @@ function produce(source, count) { const out = spawnSync(process.execPath, [ '-e', ` 'use strict'; - var assert = require('assert'); - var vm = require('vm'); + const assert = require('assert'); + const vm = require('vm'); var data; for (var i = 0; i < ${count}; i++) { @@ -32,7 +32,7 @@ function produce(source, count) { console.log(data); `, source]); - assert.equal(out.status, 0, out.stderr + ''); + assert.strictEqual(out.status, 0, out.stderr + ''); return Buffer.from(out.stdout.toString(), 'base64'); } @@ -47,7 +47,7 @@ function testProduceConsume() { cachedData: data }); assert(!script.cachedDataRejected); - assert.equal(script.runInThisContext()(), 'original'); + assert.strictEqual(script.runInThisContext()(), 'original'); } testProduceConsume(); @@ -68,7 +68,7 @@ function testRejectInvalid() { cachedData: data }); assert(script.cachedDataRejected); - assert.equal(script.runInThisContext()(), 'invalid_1'); + assert.strictEqual(script.runInThisContext()(), 'invalid_1'); } testRejectInvalid(); diff --git a/test/parallel/test-vm-context-async-script.js b/test/parallel/test-vm-context-async-script.js index b09eda85209807..1e9ed629fb114f 100644 --- a/test/parallel/test-vm-context-async-script.js +++ b/test/parallel/test-vm-context-async-script.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); -var sandbox = { setTimeout: setTimeout }; +const sandbox = { setTimeout: setTimeout }; -var ctx = vm.createContext(sandbox); +const ctx = vm.createContext(sandbox); vm.runInContext('setTimeout(function() { x = 3; }, 0);', ctx); setTimeout(function() { diff --git a/test/parallel/test-vm-context-property-forwarding.js b/test/parallel/test-vm-context-property-forwarding.js index 4034441615ca9e..b77fc45217039f 100644 --- a/test/parallel/test-vm-context-property-forwarding.js +++ b/test/parallel/test-vm-context-property-forwarding.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); -var sandbox = { x: 3 }; +const sandbox = { x: 3 }; -var ctx = vm.createContext(sandbox); +const ctx = vm.createContext(sandbox); assert.strictEqual(vm.runInContext('x;', ctx), 3); vm.runInContext('y = 4;', ctx); diff --git a/test/parallel/test-vm-context.js b/test/parallel/test-vm-context.js index d3269d9035d010..75d91ce8129dcb 100644 --- a/test/parallel/test-vm-context.js +++ b/test/parallel/test-vm-context.js @@ -1,26 +1,26 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var vm = require('vm'); -var Script = vm.Script; -var script = new Script('"passed";'); +const vm = require('vm'); +const Script = vm.Script; +let script = new Script('"passed";'); console.error('run in a new empty context'); -var context = vm.createContext(); -var result = script.runInContext(context); -assert.equal('passed', result); +let context = vm.createContext(); +let result = script.runInContext(context); +assert.strictEqual('passed', result); console.error('create a new pre-populated context'); context = vm.createContext({'foo': 'bar', 'thing': 'lala'}); -assert.equal('bar', context.foo); -assert.equal('lala', context.thing); +assert.strictEqual('bar', context.foo); +assert.strictEqual('lala', context.thing); console.error('test updating context'); script = new Script('foo = 3;'); result = script.runInContext(context); -assert.equal(3, context.foo); -assert.equal('lala', context.thing); +assert.strictEqual(3, context.foo); +assert.strictEqual('lala', context.thing); // Issue GH-227: assert.throws(function() { @@ -29,7 +29,7 @@ assert.throws(function() { // Issue GH-1140: console.error('test runInContext signature'); -var gh1140Exception; +let gh1140Exception; try { vm.runInContext('throw new Error()', context, 'expected-filename.js'); } catch (e) { @@ -48,17 +48,17 @@ assert.ok(gh1140Exception, // Issue GH-693: console.error('test RegExp as argument to assert.throws'); -script = vm.createScript('var assert = require(\'assert\'); assert.throws(' + +script = vm.createScript('const assert = require(\'assert\'); assert.throws(' + 'function() { throw "hello world"; }, /hello/);', 'some.js'); script.runInNewContext({ require: require }); // Issue GH-7529 script = vm.createScript('delete b'); -var ctx = {}; +let ctx = {}; Object.defineProperty(ctx, 'b', { configurable: false }); ctx = vm.createContext(ctx); -assert.equal(script.runInContext(ctx), false); +assert.strictEqual(script.runInContext(ctx), false); // Error on the first line of a module should // have the correct line and column number @@ -75,14 +75,3 @@ assert.throws(function() { // https://github.com/nodejs/node/issues/6158 ctx = new Proxy({}, {}); assert.strictEqual(typeof vm.runInNewContext('String', ctx), 'function'); - -// https://github.com/nodejs/node/issues/10223 -ctx = vm.createContext(); -vm.runInContext('Object.defineProperty(this, "x", { value: 42 })', ctx); -assert.strictEqual(ctx.x, undefined); // Not copied out by cloneProperty(). -assert.strictEqual(vm.runInContext('x', ctx), 42); -vm.runInContext('x = 0', ctx); // Does not throw but x... -assert.strictEqual(vm.runInContext('x', ctx), 42); // ...should be unaltered. -assert.throws(() => vm.runInContext('"use strict"; x = 0', ctx), - /Cannot assign to read only property 'x'/); -assert.strictEqual(vm.runInContext('x', ctx), 42); diff --git a/test/parallel/test-vm-create-and-run-in-context.js b/test/parallel/test-vm-create-and-run-in-context.js index fc92cf2f6cb6eb..7fd3f1d70436ad 100644 --- a/test/parallel/test-vm-create-and-run-in-context.js +++ b/test/parallel/test-vm-create-and-run-in-context.js @@ -1,28 +1,28 @@ 'use strict'; // Flags: --expose-gc require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var vm = require('vm'); +const vm = require('vm'); console.error('run in a new empty context'); -var context = vm.createContext(); -var result = vm.runInContext('"passed";', context); -assert.equal('passed', result); +let context = vm.createContext(); +let result = vm.runInContext('"passed";', context); +assert.strictEqual('passed', result); console.error('create a new pre-populated context'); context = vm.createContext({'foo': 'bar', 'thing': 'lala'}); -assert.equal('bar', context.foo); -assert.equal('lala', context.thing); +assert.strictEqual('bar', context.foo); +assert.strictEqual('lala', context.thing); console.error('test updating context'); result = vm.runInContext('var foo = 3;', context); -assert.equal(3, context.foo); -assert.equal('lala', context.thing); +assert.strictEqual(3, context.foo); +assert.strictEqual('lala', context.thing); // https://github.com/nodejs/node/issues/5768 console.error('run in contextified sandbox without referencing the context'); -var sandbox = {x: 1}; +const sandbox = {x: 1}; vm.createContext(sandbox); global.gc(); vm.runInContext('x = 2', sandbox); diff --git a/test/parallel/test-vm-create-context-accessors.js b/test/parallel/test-vm-create-context-accessors.js index 497bab1a57225f..27d7e6d7fc0274 100644 --- a/test/parallel/test-vm-create-context-accessors.js +++ b/test/parallel/test-vm-create-context-accessors.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); -var ctx = {}; +let ctx = {}; Object.defineProperty(ctx, 'getter', { get: function() { @@ -11,7 +11,7 @@ Object.defineProperty(ctx, 'getter', { } }); -var val; +let val; Object.defineProperty(ctx, 'setter', { set: function(_val) { val = _val; @@ -23,6 +23,6 @@ Object.defineProperty(ctx, 'setter', { ctx = vm.createContext(ctx); -var result = vm.runInContext('setter = "test";[getter,setter]', ctx); +const result = vm.runInContext('setter = "test";[getter,setter]', ctx); assert.strictEqual(result[0], 'ok'); assert.strictEqual(result[1], 'ok=test'); diff --git a/test/parallel/test-vm-create-context-arg.js b/test/parallel/test-vm-create-context-arg.js index a0c29762330133..91bbbc3b7793bc 100644 --- a/test/parallel/test-vm-create-context-arg.js +++ b/test/parallel/test-vm-create-context-arg.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); assert.throws(function() { vm.createContext('string is not supported'); @@ -13,7 +13,7 @@ assert.doesNotThrow(function() { }); assert.doesNotThrow(function() { - var sandbox = {}; + const sandbox = {}; vm.createContext(sandbox); vm.createContext(sandbox); }); diff --git a/test/parallel/test-vm-create-context-circular-reference.js b/test/parallel/test-vm-create-context-circular-reference.js index 248ef24f69ca07..1d7be0db9fdaf4 100644 --- a/test/parallel/test-vm-create-context-circular-reference.js +++ b/test/parallel/test-vm-create-context-circular-reference.js @@ -1,13 +1,13 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); -var sbx = {}; +let sbx = {}; sbx.window = sbx; sbx = vm.createContext(sbx); sbx.test = 123; -assert.equal(sbx.window.window.window.window.window.test, 123); +assert.strictEqual(sbx.window.window.window.window.window.test, 123); diff --git a/test/parallel/test-vm-cross-context.js b/test/parallel/test-vm-cross-context.js index 5674f582426f1f..bafb32accb6a0e 100644 --- a/test/parallel/test-vm-cross-context.js +++ b/test/parallel/test-vm-cross-context.js @@ -1,9 +1,9 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var vm = require('vm'); -var ctx = vm.createContext(global); +const vm = require('vm'); +const ctx = vm.createContext(global); assert.doesNotThrow(function() { vm.runInContext('!function() { var x = console.log; }()', ctx); diff --git a/test/parallel/test-vm-function-declaration.js b/test/parallel/test-vm-function-declaration.js index fd41be7564aab0..668b29885c44cf 100644 --- a/test/parallel/test-vm-function-declaration.js +++ b/test/parallel/test-vm-function-declaration.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var vm = require('vm'); -var o = vm.createContext({ console: console }); +const vm = require('vm'); +const o = vm.createContext({ console: console }); // This triggers the setter callback in node_contextify.cc -var code = 'var a = function() {};\n'; +let code = 'var a = function() {};\n'; // but this does not, since function decls are defineProperties, // not simple sets. @@ -16,12 +16,12 @@ code += 'function b(){}\n'; // we are getting the global function, and not some other thing code += '(function(){return this})().b;\n'; -var res = vm.runInContext(code, o, 'test'); +const res = vm.runInContext(code, o, 'test'); -assert.equal(typeof res, 'function', 'result should be function'); -assert.equal(res.name, 'b', 'res should be named b'); -assert.equal(typeof o.a, 'function', 'a should be function'); -assert.equal(typeof o.b, 'function', 'b should be function'); -assert.equal(res, o.b, 'result should be global b function'); +assert.strictEqual(typeof res, 'function', 'result should be function'); +assert.strictEqual(res.name, 'b', 'res should be named b'); +assert.strictEqual(typeof o.a, 'function', 'a should be function'); +assert.strictEqual(typeof o.b, 'function', 'b should be function'); +assert.strictEqual(res, o.b, 'result should be global b function'); console.log('ok'); diff --git a/test/parallel/test-vm-global-assignment.js b/test/parallel/test-vm-global-assignment.js new file mode 100644 index 00000000000000..3fb3470b4c2a43 --- /dev/null +++ b/test/parallel/test-vm-global-assignment.js @@ -0,0 +1,15 @@ +'use strict'; +// Regression test for https://github.com/nodejs/node/issues/10806 + +require('../common'); +const assert = require('assert'); +const vm = require('vm'); +const ctx = vm.createContext({ open() { } }); +const window = vm.runInContext('this', ctx); +const other = 123; + +assert.notStrictEqual(window.open, other); +window.open = other; +assert.strictEqual(window.open, other); +window.open = other; +assert.strictEqual(window.open, other); diff --git a/test/parallel/test-vm-global-define-property.js b/test/parallel/test-vm-global-define-property.js index 73d1520e0dad69..83f6073d1ceaf1 100644 --- a/test/parallel/test-vm-global-define-property.js +++ b/test/parallel/test-vm-global-define-property.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var vm = require('vm'); +const vm = require('vm'); -var code = +const code = 'Object.defineProperty(this, "f", {\n' + ' get: function() { return x; },\n' + ' set: function(k) { x = k; },\n' + @@ -14,13 +14,13 @@ var code = 'g = f;\n' + 'f;\n'; -var x = {}; -var o = vm.createContext({ console: console, x: x }); +const x = {}; +const o = vm.createContext({ console: console, x: x }); -var res = vm.runInContext(code, o, 'test'); +const res = vm.runInContext(code, o, 'test'); assert(res); -assert.equal(typeof res, 'object'); -assert.equal(res, x); -assert.equal(o.f, res); +assert.strictEqual(typeof res, 'object'); +assert.strictEqual(res, x); +assert.strictEqual(o.f, res); assert.deepStrictEqual(Object.keys(o), ['console', 'x', 'g', 'f']); diff --git a/test/parallel/test-vm-global-identity.js b/test/parallel/test-vm-global-identity.js index 7d90408b64c2c7..ae9fd71b3109ee 100644 --- a/test/parallel/test-vm-global-identity.js +++ b/test/parallel/test-vm-global-identity.js @@ -1,11 +1,11 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); -var ctx = vm.createContext(); +const ctx = vm.createContext(); ctx.window = ctx; -var thisVal = vm.runInContext('this;', ctx); -var windowVal = vm.runInContext('window;', ctx); +const thisVal = vm.runInContext('this;', ctx); +const windowVal = vm.runInContext('window;', ctx); assert.strictEqual(thisVal, windowVal); diff --git a/test/parallel/test-vm-harmony-symbols.js b/test/parallel/test-vm-harmony-symbols.js index 1c1274ef3543f6..80c1a2127f918c 100644 --- a/test/parallel/test-vm-harmony-symbols.js +++ b/test/parallel/test-vm-harmony-symbols.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); // The sandbox should have its own Symbol constructor. -var sandbox = {}; +let sandbox = {}; vm.runInNewContext('this.Symbol = Symbol', sandbox); assert.strictEqual(typeof sandbox.Symbol, 'function'); assert.notStrictEqual(sandbox.Symbol, Symbol); diff --git a/test/parallel/test-vm-is-context.js b/test/parallel/test-vm-is-context.js index cc106a15fbfc61..e58b896fccaa43 100644 --- a/test/parallel/test-vm-is-context.js +++ b/test/parallel/test-vm-is-context.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); assert.throws(function() { vm.isContext('string is not supported'); @@ -13,6 +13,6 @@ assert.strictEqual(vm.isContext([]), false); assert.strictEqual(vm.isContext(vm.createContext()), true); assert.strictEqual(vm.isContext(vm.createContext([])), true); -var sandbox = { foo: 'bar' }; +const sandbox = { foo: 'bar' }; vm.createContext(sandbox); assert.strictEqual(vm.isContext(sandbox), true); diff --git a/test/parallel/test-vm-new-script-new-context.js b/test/parallel/test-vm-new-script-new-context.js index 2af8f05f1c5236..693a041138602f 100644 --- a/test/parallel/test-vm-new-script-new-context.js +++ b/test/parallel/test-vm-new-script-new-context.js @@ -6,12 +6,12 @@ const Script = require('vm').Script; common.globalCheck = false; console.error('run a string'); -var script = new Script('\'passed\';'); +let script = new Script('\'passed\';'); console.error('script created'); const result1 = script.runInNewContext(); const result2 = script.runInNewContext(); -assert.equal('passed', result1); -assert.equal('passed', result2); +assert.strictEqual('passed', result1); +assert.strictEqual('passed', result2); console.error('thrown error'); script = new Script('throw new Error(\'test\');'); @@ -30,7 +30,7 @@ assert.throws(function() { global.hello = 5; script = new Script('hello = 2'); script.runInNewContext(); -assert.equal(5, global.hello); +assert.strictEqual(5, global.hello); console.error('pass values in and out'); @@ -41,23 +41,23 @@ global.foo = 2; global.obj = { foo: 0, baz: 3 }; script = new Script(global.code); /* eslint-disable no-unused-vars */ -var baz = script.runInNewContext(global.obj); +const baz = script.runInNewContext(global.obj); /* eslint-enable no-unused-vars */ -assert.equal(1, global.obj.foo); -assert.equal(2, global.obj.bar); -assert.equal(2, global.foo); +assert.strictEqual(1, global.obj.foo); +assert.strictEqual(2, global.obj.bar); +assert.strictEqual(2, global.foo); console.error('call a function by reference'); script = new Script('f()'); function changeFoo() { global.foo = 100; } script.runInNewContext({ f: changeFoo }); -assert.equal(global.foo, 100); +assert.strictEqual(global.foo, 100); console.error('modify an object by reference'); script = new Script('f.a = 2'); -var f = { a: 1 }; +const f = { a: 1 }; script.runInNewContext({ f: f }); -assert.equal(f.a, 2); +assert.strictEqual(f.a, 2); assert.throws(function() { script.runInNewContext(); diff --git a/test/parallel/test-vm-new-script-this-context.js b/test/parallel/test-vm-new-script-this-context.js index d225fb0d4025d0..3df5dc1b5020d5 100644 --- a/test/parallel/test-vm-new-script-this-context.js +++ b/test/parallel/test-vm-new-script-this-context.js @@ -6,9 +6,9 @@ const Script = require('vm').Script; common.globalCheck = false; console.error('run a string'); -var script = new Script('\'passed\';'); +let script = new Script('\'passed\';'); const result = script.runInThisContext(script); -assert.equal('passed', result); +assert.strictEqual('passed', result); console.error('thrown error'); script = new Script('throw new Error(\'test\');'); @@ -19,7 +19,7 @@ assert.throws(function() { global.hello = 5; script = new Script('hello = 2'); script.runInThisContext(script); -assert.equal(2, global.hello); +assert.strictEqual(2, global.hello); console.error('pass values'); @@ -30,12 +30,12 @@ global.foo = 2; global.obj = { foo: 0, baz: 3 }; script = new Script(global.code); script.runInThisContext(script); -assert.equal(0, global.obj.foo); -assert.equal(2, global.bar); -assert.equal(1, global.foo); +assert.strictEqual(0, global.obj.foo); +assert.strictEqual(2, global.bar); +assert.strictEqual(1, global.foo); console.error('call a function'); global.f = function() { global.foo = 100; }; script = new Script('f()'); script.runInThisContext(script); -assert.equal(100, global.foo); +assert.strictEqual(100, global.foo); diff --git a/test/parallel/test-vm-proxies.js b/test/parallel/test-vm-proxies.js index d908d713748f7f..25e16e8f5ccc55 100644 --- a/test/parallel/test-vm-proxies.js +++ b/test/parallel/test-vm-proxies.js @@ -1,12 +1,12 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); // src/node_contextify.cc filters out the Proxy object from the parent // context. Make sure that the new context has a Proxy object of its own. -var sandbox = {}; +let sandbox = {}; vm.runInNewContext('this.Proxy = Proxy', sandbox); assert.strictEqual(typeof sandbox.Proxy, 'function'); assert.notStrictEqual(sandbox.Proxy, Proxy); diff --git a/test/parallel/test-vm-run-in-new-context.js b/test/parallel/test-vm-run-in-new-context.js index 956e02306d4fb8..7b096ffc3fdc5f 100644 --- a/test/parallel/test-vm-run-in-new-context.js +++ b/test/parallel/test-vm-run-in-new-context.js @@ -5,13 +5,14 @@ const common = require('../common'); const assert = require('assert'); const vm = require('vm'); -assert.equal(typeof global.gc, 'function', 'Run this test with --expose-gc'); +assert.strictEqual(typeof global.gc, 'function', + 'Run this test with --expose-gc'); common.globalCheck = false; console.error('run a string'); const result = vm.runInNewContext('\'passed\';'); -assert.equal('passed', result); +assert.strictEqual('passed', result); console.error('thrown error'); assert.throws(function() { @@ -20,7 +21,7 @@ assert.throws(function() { global.hello = 5; vm.runInNewContext('hello = 2'); -assert.equal(5, global.hello); +assert.strictEqual(5, global.hello); console.error('pass values in and out'); @@ -30,24 +31,24 @@ global.code = 'foo = 1;' + global.foo = 2; global.obj = { foo: 0, baz: 3 }; /* eslint-disable no-unused-vars */ -var baz = vm.runInNewContext(global.code, global.obj); +const baz = vm.runInNewContext(global.code, global.obj); /* eslint-enable no-unused-vars */ -assert.equal(1, global.obj.foo); -assert.equal(2, global.obj.bar); -assert.equal(2, global.foo); +assert.strictEqual(1, global.obj.foo); +assert.strictEqual(2, global.obj.bar); +assert.strictEqual(2, global.foo); console.error('call a function by reference'); function changeFoo() { global.foo = 100; } vm.runInNewContext('f()', { f: changeFoo }); -assert.equal(global.foo, 100); +assert.strictEqual(global.foo, 100); console.error('modify an object by reference'); -var f = { a: 1 }; +const f = { a: 1 }; vm.runInNewContext('f.a = 2', { f: f }); -assert.equal(f.a, 2); +assert.strictEqual(f.a, 2); console.error('use function in context without referencing context'); -var fn = vm.runInNewContext('(function() { obj.p = {}; })', { obj: {} }); +const fn = vm.runInNewContext('(function() { obj.p = {}; })', { obj: {} }); global.gc(); fn(); // Should not crash diff --git a/test/parallel/test-vm-static-this.js b/test/parallel/test-vm-static-this.js index c4f10c183b6ef2..076f81dbf6ff15 100644 --- a/test/parallel/test-vm-static-this.js +++ b/test/parallel/test-vm-static-this.js @@ -1,12 +1,12 @@ /* eslint-disable strict */ -var common = require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const common = require('../common'); +const assert = require('assert'); +const vm = require('vm'); common.globalCheck = false; // Run a string -var result = vm.runInThisContext('\'passed\';'); +const result = vm.runInThisContext('\'passed\';'); assert.strictEqual('passed', result); // thrown error @@ -20,13 +20,14 @@ assert.strictEqual(2, global.hello); // pass values -var code = 'foo = 1;' + - 'bar = 2;' + - 'if (typeof baz !== \'undefined\') throw new Error(\'test fail\');'; +const code = 'foo = 1;' + + 'bar = 2;' + + 'if (typeof baz !== \'undefined\')' + + 'throw new Error(\'test fail\');'; global.foo = 2; global.obj = { foo: 0, baz: 3 }; /* eslint-disable no-unused-vars */ -var baz = vm.runInThisContext(code); +const baz = vm.runInThisContext(code); /* eslint-enable no-unused-vars */ assert.strictEqual(0, global.obj.foo); assert.strictEqual(2, global.bar); diff --git a/test/parallel/test-vm-syntax-error-message.js b/test/parallel/test-vm-syntax-error-message.js index 75748b24e193ee..90f2b8c013406e 100644 --- a/test/parallel/test-vm-syntax-error-message.js +++ b/test/parallel/test-vm-syntax-error-message.js @@ -1,9 +1,9 @@ 'use strict'; -require('../common'); -var assert = require('assert'); -var child_process = require('child_process'); +const common = require('../common'); +const assert = require('assert'); +const child_process = require('child_process'); -var p = child_process.spawn(process.execPath, [ +const p = child_process.spawn(process.execPath, [ '-e', 'vm = require("vm");' + 'context = vm.createContext({});' + @@ -12,15 +12,15 @@ var p = child_process.spawn(process.execPath, [ ]); p.stderr.on('data', function(data) { - assert(false, 'Unexpected stderr data: ' + data); + common.fail(`Unexpected stderr data: ${data}`); }); -var output = ''; +let output = ''; p.stdout.on('data', function(data) { output += data; }); process.on('exit', function() { - assert.equal(output.replace(/[\r\n]+/g, ''), 'boo'); + assert.strictEqual(output.replace(/[\r\n]+/g, ''), 'boo'); }); diff --git a/test/parallel/test-vm-timeout.js b/test/parallel/test-vm-timeout.js index 0536ae37a1b489..5260ca7dc28572 100644 --- a/test/parallel/test-vm-timeout.js +++ b/test/parallel/test-vm-timeout.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); +const assert = require('assert'); +const vm = require('vm'); // Test 1: Timeout of 100ms executing endless loop assert.throws(function() { @@ -23,7 +23,7 @@ vm.runInThisContext('', { timeout: 1000 }); // Test 5: Nested vm timeouts, inner timeout propagates out assert.throws(function() { - var context = { + const context = { log: console.log, runInVM: function(timeout) { vm.runInNewContext('while(true) {}', context, { timeout: timeout }); diff --git a/test/parallel/test-whatwg-url-origin-for.js b/test/parallel/test-whatwg-url-origin-for.js deleted file mode 100644 index 9e015f80510148..00000000000000 --- a/test/parallel/test-whatwg-url-origin-for.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -const common = require('../common'); - -const originFor = require('url').originFor; -const path = require('path'); -const assert = require('assert'); -const tests = require(path.join(common.fixturesDir, 'url-tests.json')); - -for (const test of tests) { - if (typeof test === 'string') - continue; - - if (test.origin) { - const origin = originFor(test.input, test.base); - // Pass true to origin.toString() to enable unicode serialization. - assert.strictEqual(origin.toString(true), test.origin); - } -} diff --git a/test/parallel/test-whatwg-url-parsing.js b/test/parallel/test-whatwg-url-parsing.js index ae14d1ff5060bf..f1fd2ae9051533 100644 --- a/test/parallel/test-whatwg-url-parsing.js +++ b/test/parallel/test-whatwg-url-parsing.js @@ -1,10 +1,11 @@ 'use strict'; const common = require('../common'); +const util = require('util'); if (!common.hasIntl) { // A handful of the tests fail when ICU is not included. - common.skip('missing Intl... skipping test'); + common.skip('missing Intl'); return; } @@ -13,17 +14,30 @@ const path = require('path'); const assert = require('assert'); const tests = require(path.join(common.fixturesDir, 'url-tests.json')); +function verifyURL(url, test) { + if (test.href) assert.strictEqual(url.href, test.href); + if (test.origin) assert.strictEqual(url.origin, test.origin); + if (test.protocol) assert.strictEqual(url.protocol, test.protocol); + if (test.username) assert.strictEqual(url.username, test.username); + if (test.password) assert.strictEqual(url.password, test.password); + if (test.hostname) assert.strictEqual(url.hostname, test.hostname); + if (test.host) assert.strictEqual(url.host, test.host); + if (test.port !== undefined) assert.strictEqual(url.port, test.port); + if (test.pathname) assert.strictEqual(url.pathname, test.pathname); + if (test.search) assert.strictEqual(url.search, test.search); + if (test.hash) assert.strictEqual(url.hash, test.hash); +} + for (const test of tests) { if (typeof test === 'string') continue; if (test.failure) { - assert.throws(() => new URL(test.input, test.base), /Invalid URL/); + assert.throws(() => new URL(test.input, test.base), + /^TypeError: Invalid URL$/); } else { - assert.doesNotThrow(() => { - const url = new URL(test.input, test.base); - assert.strictEqual(url.href, test.href); - }); + const url = new URL(test.input, test.base); + verifyURL(url, test); } } @@ -115,18 +129,10 @@ const additional_tests = [ } ]; -additional_tests.forEach((test) => { - const u = new URL(test.url); - if (test.protocol) assert.strictEqual(test.protocol, u.protocol); - if (test.username) assert.strictEqual(test.username, u.username); - if (test.password) assert.strictEqual(test.password, u.password); - if (test.hostname) assert.strictEqual(test.hostname, u.hostname); - if (test.host) assert.strictEqual(test.host, u.host); - if (test.port !== undefined) assert.strictEqual(test.port, u.port); - if (test.pathname) assert.strictEqual(test.pathname, u.pathname); - if (test.search) assert.strictEqual(test.search, u.search); - if (test.hash) assert.strictEqual(test.hash, u.hash); -}); +for (const test of additional_tests) { + const url = new URL(test.url); + verifyURL(url, test); +} // test inspect const allTests = additional_tests.slice(); @@ -139,8 +145,8 @@ for (const test of allTests) { const url = test.url ? new URL(test.url) : new URL(test.input, test.base); for (const showHidden of [true, false]) { - const res = url.inspect(null, { - showHidden: showHidden + const res = util.inspect(url, { + showHidden }); const lines = res.split('\n'); diff --git a/test/parallel/test-whatwg-url-properties.js b/test/parallel/test-whatwg-url-properties.js index 60cf581ad8da4d..b762659fb6eadc 100644 --- a/test/parallel/test-whatwg-url-properties.js +++ b/test/parallel/test-whatwg-url-properties.js @@ -1,9 +1,11 @@ +// Flags: --expose-internals 'use strict'; require('../common'); const URL = require('url').URL; const assert = require('assert'); +const urlToOptions = require('internal/url').urlToOptions; const url = new URL('http://user:pass@foo.bar.com:21/aaa/zzz?l=24#test'); const oldParams = url.searchParams; // for test of [SameObject] @@ -19,9 +21,9 @@ for (const prop in url) { // https://heycam.github.io/webidl/#es-attributes // https://heycam.github.io/webidl/#es-stringifier const expected = ['toString', - 'href', 'origin', 'protocol', - 'username', 'password', 'host', 'hostname', 'port', - 'pathname', 'search', 'searchParams', 'hash']; + 'href', 'origin', 'protocol', + 'username', 'password', 'host', 'hostname', 'port', + 'pathname', 'search', 'searchParams', 'hash']; assert.deepStrictEqual(props, expected); @@ -43,7 +45,7 @@ assert.strictEqual(url.searchParams, oldParams); // [SameObject] // Note: this error message is subject to change in V8 updates assert.throws(() => url.origin = 'http://foo.bar.com:22', new RegExp('TypeError: Cannot set property origin of' + - ' \\[object Object\\] which has only a getter')); + ' \\[object URL\\] which has only a getter')); assert.strictEqual(url.origin, 'http://foo.bar.com:21'); assert.strictEqual(url.toString(), 'http://user:pass@foo.bar.com:21/aaa/zzz?l=25#test'); @@ -119,9 +121,24 @@ assert.strictEqual(url.hash, '#abcd'); // Note: this error message is subject to change in V8 updates assert.throws(() => url.searchParams = '?k=88', new RegExp('TypeError: Cannot set property searchParams of' + - ' \\[object Object\\] which has only a getter')); + ' \\[object URL\\] which has only a getter')); assert.strictEqual(url.searchParams, oldParams); assert.strictEqual(url.toString(), 'https://user2:pass2@foo.bar.org:23/aaa/bbb?k=99#abcd'); assert.strictEqual((delete url.searchParams), true); assert.strictEqual(url.searchParams, oldParams); + +// Test urlToOptions +{ + const opts = + urlToOptions(new URL('http://user:pass@foo.bar.com:21/aaa/zzz?l=24#test')); + assert.strictEqual(opts instanceof URL, false); + assert.strictEqual(opts.protocol, 'http:'); + assert.strictEqual(opts.auth, 'user:pass'); + assert.strictEqual(opts.hostname, 'foo.bar.com'); + assert.strictEqual(opts.port, 21); + assert.strictEqual(opts.path, '/aaa/zzz?l=24'); + assert.strictEqual(opts.pathname, '/aaa/zzz'); + assert.strictEqual(opts.search, '?l=24'); + assert.strictEqual(opts.hash, '#test'); +} diff --git a/test/parallel/test-whatwg-url-searchparams-append.js b/test/parallel/test-whatwg-url-searchparams-append.js index 1f61cb0d11bb6b..44f49d20b09526 100644 --- a/test/parallel/test-whatwg-url-searchparams-append.js +++ b/test/parallel/test-whatwg-url-searchparams-append.js @@ -2,13 +2,9 @@ require('../common'); const assert = require('assert'); -const URL = require('url').URL; +const URLSearchParams = require('url').URLSearchParams; -const m = new URL('http://example.org'); -let params = m.searchParams; - -// Until we export URLSearchParams -const URLSearchParams = params.constructor; +let params; // Append same name params = new URLSearchParams(); @@ -50,3 +46,10 @@ assert.strictEqual(params.get('third'), '', params.append('first', 10); assert.strictEqual(params.get('first'), '1', 'Search params object has name "first" with value "1"'); + +assert.throws(() => { + params.append.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); +assert.throws(() => { + params.set('a'); +}, /^TypeError: "name" and "value" arguments must be specified$/); diff --git a/test/parallel/test-whatwg-url-searchparams-constructor.js b/test/parallel/test-whatwg-url-searchparams-constructor.js index 98349021586f1a..9b7ca1e4e9c54a 100644 --- a/test/parallel/test-whatwg-url-searchparams-constructor.js +++ b/test/parallel/test-whatwg-url-searchparams-constructor.js @@ -2,13 +2,9 @@ require('../common'); const assert = require('assert'); -const URL = require('url').URL; +const URLSearchParams = require('url').URLSearchParams; -const m = new URL('http://example.org'); -let params = m.searchParams; - -// Until we export URLSearchParams -const URLSearchParams = params.constructor; +let params; // Basic URLSearchParams construction params = new URLSearchParams(); @@ -30,7 +26,7 @@ assert.throws(() => { }); }, TypeError); params = new URLSearchParams(''); -assert.notEqual(params, null, 'constructor returned non-null value.'); +assert.notStrictEqual(params, null, 'constructor returned non-null value.'); // eslint-disable-next-line no-proto assert.strictEqual(params.__proto__, URLSearchParams.prototype, 'expected URLSearchParams.prototype as prototype.'); @@ -40,19 +36,19 @@ assert.strictEqual(params + '', '%5Bobject%20Object%5D='); // URLSearchParams constructor, string. params = new URLSearchParams('a=b'); -assert.notEqual(params, null, 'constructor returned non-null value.'); +assert.notStrictEqual(params, null, 'constructor returned non-null value.'); assert.strictEqual(true, params.has('a'), 'Search params object has name "a"'); assert.strictEqual(false, params.has('b'), 'Search params object has not got name "b"'); params = new URLSearchParams('a=b&c'); -assert.notEqual(params, null, 'constructor returned non-null value.'); +assert.notStrictEqual(params, null, 'constructor returned non-null value.'); assert.strictEqual(true, params.has('a'), 'Search params object has name "a"'); assert.strictEqual(true, params.has('c'), 'Search params object has name "c"'); params = new URLSearchParams('&a&&& &&&&&a+b=& c&m%c3%b8%c3%b8'); -assert.notEqual(params, null, 'constructor returned non-null value.'); +assert.notStrictEqual(params, null, 'constructor returned non-null value.'); assert.strictEqual(true, params.has('a'), 'Search params object has name "a"'); assert.strictEqual(true, params.has('a b'), 'Search params object has name "a b"'); @@ -68,7 +64,7 @@ assert.strictEqual(true, params.has('møø'), // URLSearchParams constructor, object. const seed = new URLSearchParams('a=b&c=d'); params = new URLSearchParams(seed); -assert.notEqual(params, null, 'constructor returned non-null value.'); +assert.notStrictEqual(params, null, 'constructor returned non-null value.'); assert.strictEqual(params.get('a'), 'b'); assert.strictEqual(params.get('c'), 'd'); assert.strictEqual(false, params.has('d')); diff --git a/test/parallel/test-whatwg-url-searchparams-delete.js b/test/parallel/test-whatwg-url-searchparams-delete.js index b08a3b76867572..f39917e8e37712 100644 --- a/test/parallel/test-whatwg-url-searchparams-delete.js +++ b/test/parallel/test-whatwg-url-searchparams-delete.js @@ -2,13 +2,11 @@ require('../common'); const assert = require('assert'); -const URL = require('url').URL; +const url = require('url'); +const URL = url.URL; +const URLSearchParams = url.URLSearchParams; -const m = new URL('http://example.org'); -let params = m.searchParams; - -// Until we export URLSearchParams -const URLSearchParams = params.constructor; +let params; // Delete basics params = new URLSearchParams('a=b&c=d'); @@ -43,6 +41,13 @@ params.delete('first'); assert.strictEqual(false, params.has('first'), 'Search params object has no "first" name'); +assert.throws(() => { + params.delete.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); +assert.throws(() => { + params.delete(); +}, /^TypeError: "name" argument must be specified$/); + // https://github.com/nodejs/node/issues/10480 // Emptying searchParams should correctly update url's query { diff --git a/test/parallel/test-whatwg-url-searchparams-entries.js b/test/parallel/test-whatwg-url-searchparams-entries.js new file mode 100644 index 00000000000000..97f60ceb17fa29 --- /dev/null +++ b/test/parallel/test-whatwg-url-searchparams-entries.js @@ -0,0 +1,33 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); +const URLSearchParams = require('url').URLSearchParams; + +const params = new URLSearchParams('a=b&c=d'); +const entries = params.entries(); +assert.strictEqual(typeof entries[Symbol.iterator], 'function'); +assert.strictEqual(entries[Symbol.iterator](), entries); +assert.deepStrictEqual(entries.next(), { + value: ['a', 'b'], + done: false +}); +assert.deepStrictEqual(entries.next(), { + value: ['c', 'd'], + done: false +}); +assert.deepStrictEqual(entries.next(), { + value: undefined, + done: true +}); +assert.deepStrictEqual(entries.next(), { + value: undefined, + done: true +}); + +assert.throws(() => { + entries.next.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParamsIterator$/); +assert.throws(() => { + params.entries.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); diff --git a/test/parallel/test-whatwg-url-searchparams-foreach.js b/test/parallel/test-whatwg-url-searchparams-foreach.js index b6d684b06743b0..6adbb5789b0c11 100644 --- a/test/parallel/test-whatwg-url-searchparams-foreach.js +++ b/test/parallel/test-whatwg-url-searchparams-foreach.js @@ -1,22 +1,18 @@ 'use strict'; -require('../common'); +const common = require('../common'); const assert = require('assert'); -const URL = require('url').URL; - -const m = new URL('http://example.org'); -let params = m.searchParams; - -// Until we export URLSearchParams -const URLSearchParams = params.constructor; +const url = require('url'); +const URL = url.URL; +const URLSearchParams = url.URLSearchParams; let a, b, i; // ForEach Check -params = new URLSearchParams('a=1&b=2&c=3'); +const params = new URLSearchParams('a=1&b=2&c=3'); const keys = []; const values = []; -params.forEach(function(value, key) { +params.forEach((value, key) => { keys.push(key); values.push(value); }); @@ -39,5 +35,9 @@ assert.deepStrictEqual(c[2], ['z', '3']); a = new URL('http://a.b/c'); b = a.searchParams; for (i of b) { - assert(false, 'should not be reached'); + common.fail('should not be reached'); } + +assert.throws(() => { + params.forEach.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); diff --git a/test/parallel/test-whatwg-url-searchparams-get.js b/test/parallel/test-whatwg-url-searchparams-get.js index 667738f817b707..95c3f47df5eabb 100644 --- a/test/parallel/test-whatwg-url-searchparams-get.js +++ b/test/parallel/test-whatwg-url-searchparams-get.js @@ -2,13 +2,9 @@ require('../common'); const assert = require('assert'); -const URL = require('url').URL; +const URLSearchParams = require('url').URLSearchParams; -const m = new URL('http://example.org'); -let params = m.searchParams; - -// Until we export URLSearchParams -const URLSearchParams = params.constructor; +let params; // Get basics params = new URLSearchParams('a=b&c=d'); @@ -24,7 +20,7 @@ assert.strictEqual(params.get('a'), ''); // More get() basics params = new URLSearchParams('first=second&third&&'); -assert.notEqual(params, null, 'constructor returned non-null value.'); +assert.notStrictEqual(params, null, 'constructor returned non-null value.'); assert.strictEqual(true, params.has('first'), 'Search params object has name "first"'); assert.strictEqual(params.get('first'), 'second', @@ -33,3 +29,10 @@ assert.strictEqual(params.get('third'), '', 'Search params object has name "third" with empty value.'); assert.strictEqual(params.get('fourth'), null, 'Search params object has no "fourth" name and value.'); + +assert.throws(() => { + params.get.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); +assert.throws(() => { + params.get(); +}, /^TypeError: "name" argument must be specified$/); diff --git a/test/parallel/test-whatwg-url-searchparams-getall.js b/test/parallel/test-whatwg-url-searchparams-getall.js index 8333982d688c3b..52f581c0158a90 100644 --- a/test/parallel/test-whatwg-url-searchparams-getall.js +++ b/test/parallel/test-whatwg-url-searchparams-getall.js @@ -2,14 +2,9 @@ require('../common'); const assert = require('assert'); -const URL = require('url').URL; - -const m = new URL('http://example.org'); -let params = m.searchParams; - -// Until we export URLSearchParams -const URLSearchParams = params.constructor; +const URLSearchParams = require('url').URLSearchParams; +let params; let matches; // getAll() basics @@ -41,3 +36,10 @@ assert(matches && matches.length == 1, 'Search params object has values for name "a"'); assert.deepStrictEqual(matches, ['one'], 'Search params object has expected name "a" values'); + +assert.throws(() => { + params.getAll.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); +assert.throws(() => { + params.getAll(); +}, /^TypeError: "name" argument must be specified$/); diff --git a/test/parallel/test-whatwg-url-searchparams-has.js b/test/parallel/test-whatwg-url-searchparams-has.js index c884227e0b0f1d..bab34515d99ac2 100644 --- a/test/parallel/test-whatwg-url-searchparams-has.js +++ b/test/parallel/test-whatwg-url-searchparams-has.js @@ -2,13 +2,9 @@ require('../common'); const assert = require('assert'); -const URL = require('url').URL; +const URLSearchParams = require('url').URLSearchParams; -const m = new URL('http://example.org'); -let params = m.searchParams; - -// Until we export URLSearchParams -const URLSearchParams = params.constructor; +let params; // Has basics params = new URLSearchParams('a=b&c=d'); @@ -37,3 +33,10 @@ assert.strictEqual(false, params.has('d'), params.delete('first'); assert.strictEqual(false, params.has('first'), 'Search params object has no name "first"'); + +assert.throws(() => { + params.has.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); +assert.throws(() => { + params.has(); +}, /^TypeError: "name" argument must be specified$/); diff --git a/test/parallel/test-whatwg-url-searchparams-inspect.js b/test/parallel/test-whatwg-url-searchparams-inspect.js new file mode 100644 index 00000000000000..12472e1df0601a --- /dev/null +++ b/test/parallel/test-whatwg-url-searchparams-inspect.js @@ -0,0 +1,30 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); +const util = require('util'); +const URL = require('url').URL; + +// Until we export URLSearchParams +const m = new URL('http://example.org'); +const URLSearchParams = m.searchParams.constructor; + +const sp = new URLSearchParams('?a=a&b=b&b=c'); +assert.strictEqual(util.inspect(sp), + "URLSearchParams { 'a' => 'a', 'b' => 'b', 'b' => 'c' }"); +assert.strictEqual(util.inspect(sp.keys()), + "URLSearchParamsIterator { 'a', 'b', 'b' }"); +assert.strictEqual(util.inspect(sp.values()), + "URLSearchParamsIterator { 'a', 'b', 'c' }"); + +const iterator = sp.entries(); +assert.strictEqual(util.inspect(iterator), + "URLSearchParamsIterator { [ 'a', 'a' ], [ 'b', 'b' ], " + + "[ 'b', 'c' ] }"); +iterator.next(); +assert.strictEqual(util.inspect(iterator), + "URLSearchParamsIterator { [ 'b', 'b' ], [ 'b', 'c' ] }"); +iterator.next(); +iterator.next(); +assert.strictEqual(util.inspect(iterator), + 'URLSearchParamsIterator { }'); diff --git a/test/parallel/test-whatwg-url-searchparams-keys.js b/test/parallel/test-whatwg-url-searchparams-keys.js new file mode 100644 index 00000000000000..d538422654065c --- /dev/null +++ b/test/parallel/test-whatwg-url-searchparams-keys.js @@ -0,0 +1,34 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); +const URLSearchParams = require('url').URLSearchParams; + +const params = new URLSearchParams('a=b&c=d'); +const keys = params.keys(); + +assert.strictEqual(typeof keys[Symbol.iterator], 'function'); +assert.strictEqual(keys[Symbol.iterator](), keys); +assert.deepStrictEqual(keys.next(), { + value: 'a', + done: false +}); +assert.deepStrictEqual(keys.next(), { + value: 'c', + done: false +}); +assert.deepStrictEqual(keys.next(), { + value: undefined, + done: true +}); +assert.deepStrictEqual(keys.next(), { + value: undefined, + done: true +}); + +assert.throws(() => { + keys.next.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParamsIterator$/); +assert.throws(() => { + params.keys.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); diff --git a/test/parallel/test-whatwg-url-searchparams-set.js b/test/parallel/test-whatwg-url-searchparams-set.js index 2d9ae8aaa8d021..c818cc9f71af48 100644 --- a/test/parallel/test-whatwg-url-searchparams-set.js +++ b/test/parallel/test-whatwg-url-searchparams-set.js @@ -2,13 +2,9 @@ require('../common'); const assert = require('assert'); -const URL = require('url').URL; +const URLSearchParams = require('url').URLSearchParams; -const m = new URL('http://example.org'); -let params = m.searchParams; - -// Until we export URLSearchParams -const URLSearchParams = params.constructor; +let params; // Set basics params = new URLSearchParams('a=b&c=d'); @@ -36,3 +32,10 @@ assert.strictEqual(true, params.has('a'), 'Search params object has name "a"'); assert.strictEqual(params.get('a'), '4', 'Search params object has name "a" with value "4"'); + +assert.throws(() => { + params.set.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); +assert.throws(() => { + params.set('a'); +}, /^TypeError: "name" and "value" arguments must be specified$/); diff --git a/test/parallel/test-whatwg-url-searchparams-stringifier.js b/test/parallel/test-whatwg-url-searchparams-stringifier.js index 0a53df634454b6..ba3f42683b46e6 100644 --- a/test/parallel/test-whatwg-url-searchparams-stringifier.js +++ b/test/parallel/test-whatwg-url-searchparams-stringifier.js @@ -2,13 +2,9 @@ require('../common'); const assert = require('assert'); -const URL = require('url').URL; +const URLSearchParams = require('url').URLSearchParams; -const m = new URL('http://example.org'); -let params = m.searchParams; - -// Until we export URLSearchParams -const URLSearchParams = params.constructor; +let params; // Serialize space // querystring does not currently handle spaces intelligently @@ -114,3 +110,6 @@ assert.strictEqual(params + '', 'a%F0%9F%92%A9b=c'); // The lone '=' _does_ survive the roundtrip. params = new URLSearchParams('a=&a=b'); assert.strictEqual(params.toString(), 'a=&a=b'); +assert.throws(() => { + params.toString.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); diff --git a/test/parallel/test-whatwg-url-searchparams-values.js b/test/parallel/test-whatwg-url-searchparams-values.js new file mode 100644 index 00000000000000..36aa1da9f057bb --- /dev/null +++ b/test/parallel/test-whatwg-url-searchparams-values.js @@ -0,0 +1,34 @@ +'use strict'; + +require('../common'); +const assert = require('assert'); +const URLSearchParams = require('url').URLSearchParams; + +const params = new URLSearchParams('a=b&c=d'); +const values = params.values(); + +assert.strictEqual(typeof values[Symbol.iterator], 'function'); +assert.strictEqual(values[Symbol.iterator](), values); +assert.deepStrictEqual(values.next(), { + value: 'b', + done: false +}); +assert.deepStrictEqual(values.next(), { + value: 'd', + done: false +}); +assert.deepStrictEqual(values.next(), { + value: undefined, + done: true +}); +assert.deepStrictEqual(values.next(), { + value: undefined, + done: true +}); + +assert.throws(() => { + values.next.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParamsIterator$/); +assert.throws(() => { + params.values.call(undefined); +}, /^TypeError: Value of `this` is not a URLSearchParams$/); diff --git a/test/parallel/test-whatwg-url-searchparams.js b/test/parallel/test-whatwg-url-searchparams.js index 54743b97a31da9..8b9e65123d9506 100644 --- a/test/parallel/test-whatwg-url-searchparams.js +++ b/test/parallel/test-whatwg-url-searchparams.js @@ -31,7 +31,7 @@ assert.strictEqual(m.search, `?${serialized}`); assert.strictEqual(sp[Symbol.iterator], sp.entries); -var key, val, n = 0; +let key, val, n = 0; for ([key, val] of sp) { assert.strictEqual(key, 'a'); assert.strictEqual(val, String(values[n++])); @@ -44,6 +44,20 @@ n = 0; for (val of sp.values()) { assert.strictEqual(val, String(values[n++])); } +n = 0; +sp.forEach(function(val, key, obj) { + assert.strictEqual(this, undefined); + assert.strictEqual(key, 'a'); + assert.strictEqual(val, String(values[n++])); + assert.strictEqual(obj, sp); +}); +sp.forEach(function() { + assert.strictEqual(this, m); +}, m); +assert.throws(() => sp.forEach(), + /^TypeError: "callback" argument must be a function$/); +assert.throws(() => sp.forEach(1), + /^TypeError: "callback" argument must be a function$/); m.search = '?a=a&b=b'; assert.strictEqual(sp.toString(), 'a=a&b=b'); diff --git a/test/parallel/test-whatwg-url-setters.js b/test/parallel/test-whatwg-url-setters.js index 3b2aca2afd89d7..8cd9fc51d52ae8 100644 --- a/test/parallel/test-whatwg-url-setters.js +++ b/test/parallel/test-whatwg-url-setters.js @@ -4,7 +4,7 @@ const common = require('../common'); if (!common.hasIntl) { // A handful of the tests fail when ICU is not included. - common.skip('missing Intl... skipping test'); + common.skip('missing Intl'); return; } @@ -17,15 +17,16 @@ for (const attr in attrs) { if (attr === 'comment') continue; const tests = attrs[attr]; - var n = 0; + let n = 0; for (const test of tests) { if (test.skip) continue; n++; const url = new URL(test.href); url[attr] = test.new_value; for (const test_attr in test.expected) { - assert.equal(test.expected[test_attr], url[test_attr], - `${n} ${attr} ${test_attr} ${test.href} ${test.comment}`); + assert.strictEqual(test.expected[test_attr], url[test_attr], + `${n} ${attr} ${test_attr} ` + + `${test.href} ${test.comment}`); } } } diff --git a/test/parallel/test-whatwg-url-tostringtag.js b/test/parallel/test-whatwg-url-tostringtag.js index 9e0927955feaab..83653368a7a4f2 100644 --- a/test/parallel/test-whatwg-url-tostringtag.js +++ b/test/parallel/test-whatwg-url-tostringtag.js @@ -7,15 +7,24 @@ const toString = Object.prototype.toString; const url = new URL('http://example.org'); const sp = url.searchParams; +const spIterator = sp.entries(); const test = [ - [toString.call(url), 'URL'], - [toString.call(Object.getPrototypeOf(url)), 'URLPrototype'], - [toString.call(sp), 'URLSearchParams'], - [toString.call(Object.getPrototypeOf(sp)), 'URLSearchParamsPrototype'] + [url, 'URL'], + [sp, 'URLSearchParams'], + [spIterator, 'URLSearchParamsIterator'], + // Web IDL spec says we have to return 'URLPrototype', but it is too + // expensive to implement; therefore, use Chrome's behavior for now, until + // spec is changed. + [Object.getPrototypeOf(url), 'URL'], + [Object.getPrototypeOf(sp), 'URLSearchParams'], + [Object.getPrototypeOf(spIterator), 'URLSearchParamsIterator'], ]; -test.forEach((row) => { - assert.strictEqual(row[0], `[object ${row[1]}]`, - `${row[0]} !== [object ${row[1]}]`); +test.forEach(([obj, expected]) => { + assert.strictEqual(obj[Symbol.toStringTag], expected, + `${obj[Symbol.toStringTag]} !== ${expected}`); + const str = toString.call(obj); + assert.strictEqual(str, `[object ${expected}]`, + `${str} !== [object ${expected}]`); }); diff --git a/test/parallel/test-writedouble.js b/test/parallel/test-writedouble.js index 107bf521342ef3..fa9c94022d419b 100644 --- a/test/parallel/test-writedouble.js +++ b/test/parallel/test-writedouble.js @@ -6,144 +6,144 @@ require('../common'); const assert = require('assert'); function test(clazz) { - var buffer = new clazz(16); + const buffer = new clazz(16); buffer.writeDoubleBE(2.225073858507201e-308, 0); buffer.writeDoubleLE(2.225073858507201e-308, 8); - assert.equal(0x00, buffer[0]); - assert.equal(0x0f, buffer[1]); - assert.equal(0xff, buffer[2]); - assert.equal(0xff, buffer[3]); - assert.equal(0xff, buffer[4]); - assert.equal(0xff, buffer[5]); - assert.equal(0xff, buffer[6]); - assert.equal(0xff, buffer[7]); - assert.equal(0xff, buffer[8]); - assert.equal(0xff, buffer[9]); - assert.equal(0xff, buffer[10]); - assert.equal(0xff, buffer[11]); - assert.equal(0xff, buffer[12]); - assert.equal(0xff, buffer[13]); - assert.equal(0x0f, buffer[14]); - assert.equal(0x00, buffer[15]); + assert.strictEqual(0x00, buffer[0]); + assert.strictEqual(0x0f, buffer[1]); + assert.strictEqual(0xff, buffer[2]); + assert.strictEqual(0xff, buffer[3]); + assert.strictEqual(0xff, buffer[4]); + assert.strictEqual(0xff, buffer[5]); + assert.strictEqual(0xff, buffer[6]); + assert.strictEqual(0xff, buffer[7]); + assert.strictEqual(0xff, buffer[8]); + assert.strictEqual(0xff, buffer[9]); + assert.strictEqual(0xff, buffer[10]); + assert.strictEqual(0xff, buffer[11]); + assert.strictEqual(0xff, buffer[12]); + assert.strictEqual(0xff, buffer[13]); + assert.strictEqual(0x0f, buffer[14]); + assert.strictEqual(0x00, buffer[15]); buffer.writeDoubleBE(1.0000000000000004, 0); buffer.writeDoubleLE(1.0000000000000004, 8); - assert.equal(0x3f, buffer[0]); - assert.equal(0xf0, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x00, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x00, buffer[6]); - assert.equal(0x02, buffer[7]); - assert.equal(0x02, buffer[8]); - assert.equal(0x00, buffer[9]); - assert.equal(0x00, buffer[10]); - assert.equal(0x00, buffer[11]); - assert.equal(0x00, buffer[12]); - assert.equal(0x00, buffer[13]); - assert.equal(0xf0, buffer[14]); - assert.equal(0x3f, buffer[15]); + assert.strictEqual(0x3f, buffer[0]); + assert.strictEqual(0xf0, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x00, buffer[6]); + assert.strictEqual(0x02, buffer[7]); + assert.strictEqual(0x02, buffer[8]); + assert.strictEqual(0x00, buffer[9]); + assert.strictEqual(0x00, buffer[10]); + assert.strictEqual(0x00, buffer[11]); + assert.strictEqual(0x00, buffer[12]); + assert.strictEqual(0x00, buffer[13]); + assert.strictEqual(0xf0, buffer[14]); + assert.strictEqual(0x3f, buffer[15]); buffer.writeDoubleBE(-2, 0); buffer.writeDoubleLE(-2, 8); - assert.equal(0xc0, buffer[0]); - assert.equal(0x00, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x00, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x00, buffer[6]); - assert.equal(0x00, buffer[7]); - assert.equal(0x00, buffer[8]); - assert.equal(0x00, buffer[9]); - assert.equal(0x00, buffer[10]); - assert.equal(0x00, buffer[11]); - assert.equal(0x00, buffer[12]); - assert.equal(0x00, buffer[13]); - assert.equal(0x00, buffer[14]); - assert.equal(0xc0, buffer[15]); + assert.strictEqual(0xc0, buffer[0]); + assert.strictEqual(0x00, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x00, buffer[6]); + assert.strictEqual(0x00, buffer[7]); + assert.strictEqual(0x00, buffer[8]); + assert.strictEqual(0x00, buffer[9]); + assert.strictEqual(0x00, buffer[10]); + assert.strictEqual(0x00, buffer[11]); + assert.strictEqual(0x00, buffer[12]); + assert.strictEqual(0x00, buffer[13]); + assert.strictEqual(0x00, buffer[14]); + assert.strictEqual(0xc0, buffer[15]); buffer.writeDoubleBE(1.7976931348623157e+308, 0); buffer.writeDoubleLE(1.7976931348623157e+308, 8); - assert.equal(0x7f, buffer[0]); - assert.equal(0xef, buffer[1]); - assert.equal(0xff, buffer[2]); - assert.equal(0xff, buffer[3]); - assert.equal(0xff, buffer[4]); - assert.equal(0xff, buffer[5]); - assert.equal(0xff, buffer[6]); - assert.equal(0xff, buffer[7]); - assert.equal(0xff, buffer[8]); - assert.equal(0xff, buffer[9]); - assert.equal(0xff, buffer[10]); - assert.equal(0xff, buffer[11]); - assert.equal(0xff, buffer[12]); - assert.equal(0xff, buffer[13]); - assert.equal(0xef, buffer[14]); - assert.equal(0x7f, buffer[15]); + assert.strictEqual(0x7f, buffer[0]); + assert.strictEqual(0xef, buffer[1]); + assert.strictEqual(0xff, buffer[2]); + assert.strictEqual(0xff, buffer[3]); + assert.strictEqual(0xff, buffer[4]); + assert.strictEqual(0xff, buffer[5]); + assert.strictEqual(0xff, buffer[6]); + assert.strictEqual(0xff, buffer[7]); + assert.strictEqual(0xff, buffer[8]); + assert.strictEqual(0xff, buffer[9]); + assert.strictEqual(0xff, buffer[10]); + assert.strictEqual(0xff, buffer[11]); + assert.strictEqual(0xff, buffer[12]); + assert.strictEqual(0xff, buffer[13]); + assert.strictEqual(0xef, buffer[14]); + assert.strictEqual(0x7f, buffer[15]); buffer.writeDoubleBE(0 * -1, 0); buffer.writeDoubleLE(0 * -1, 8); - assert.equal(0x80, buffer[0]); - assert.equal(0x00, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x00, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x00, buffer[6]); - assert.equal(0x00, buffer[7]); - assert.equal(0x00, buffer[8]); - assert.equal(0x00, buffer[9]); - assert.equal(0x00, buffer[10]); - assert.equal(0x00, buffer[11]); - assert.equal(0x00, buffer[12]); - assert.equal(0x00, buffer[13]); - assert.equal(0x00, buffer[14]); - assert.equal(0x80, buffer[15]); + assert.strictEqual(0x80, buffer[0]); + assert.strictEqual(0x00, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x00, buffer[6]); + assert.strictEqual(0x00, buffer[7]); + assert.strictEqual(0x00, buffer[8]); + assert.strictEqual(0x00, buffer[9]); + assert.strictEqual(0x00, buffer[10]); + assert.strictEqual(0x00, buffer[11]); + assert.strictEqual(0x00, buffer[12]); + assert.strictEqual(0x00, buffer[13]); + assert.strictEqual(0x00, buffer[14]); + assert.strictEqual(0x80, buffer[15]); buffer.writeDoubleBE(Infinity, 0); buffer.writeDoubleLE(Infinity, 8); - assert.equal(0x7F, buffer[0]); - assert.equal(0xF0, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x00, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x00, buffer[6]); - assert.equal(0x00, buffer[7]); - assert.equal(0x00, buffer[8]); - assert.equal(0x00, buffer[9]); - assert.equal(0x00, buffer[10]); - assert.equal(0x00, buffer[11]); - assert.equal(0x00, buffer[12]); - assert.equal(0x00, buffer[13]); - assert.equal(0xF0, buffer[14]); - assert.equal(0x7F, buffer[15]); - assert.equal(Infinity, buffer.readDoubleBE(0)); - assert.equal(Infinity, buffer.readDoubleLE(8)); + assert.strictEqual(0x7F, buffer[0]); + assert.strictEqual(0xF0, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x00, buffer[6]); + assert.strictEqual(0x00, buffer[7]); + assert.strictEqual(0x00, buffer[8]); + assert.strictEqual(0x00, buffer[9]); + assert.strictEqual(0x00, buffer[10]); + assert.strictEqual(0x00, buffer[11]); + assert.strictEqual(0x00, buffer[12]); + assert.strictEqual(0x00, buffer[13]); + assert.strictEqual(0xF0, buffer[14]); + assert.strictEqual(0x7F, buffer[15]); + assert.strictEqual(Infinity, buffer.readDoubleBE(0)); + assert.strictEqual(Infinity, buffer.readDoubleLE(8)); buffer.writeDoubleBE(-Infinity, 0); buffer.writeDoubleLE(-Infinity, 8); - assert.equal(0xFF, buffer[0]); - assert.equal(0xF0, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x00, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x00, buffer[6]); - assert.equal(0x00, buffer[7]); - assert.equal(0x00, buffer[8]); - assert.equal(0x00, buffer[9]); - assert.equal(0x00, buffer[10]); - assert.equal(0x00, buffer[11]); - assert.equal(0x00, buffer[12]); - assert.equal(0x00, buffer[13]); - assert.equal(0xF0, buffer[14]); - assert.equal(0xFF, buffer[15]); - assert.equal(-Infinity, buffer.readDoubleBE(0)); - assert.equal(-Infinity, buffer.readDoubleLE(8)); + assert.strictEqual(0xFF, buffer[0]); + assert.strictEqual(0xF0, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x00, buffer[6]); + assert.strictEqual(0x00, buffer[7]); + assert.strictEqual(0x00, buffer[8]); + assert.strictEqual(0x00, buffer[9]); + assert.strictEqual(0x00, buffer[10]); + assert.strictEqual(0x00, buffer[11]); + assert.strictEqual(0x00, buffer[12]); + assert.strictEqual(0x00, buffer[13]); + assert.strictEqual(0xF0, buffer[14]); + assert.strictEqual(0xFF, buffer[15]); + assert.strictEqual(-Infinity, buffer.readDoubleBE(0)); + assert.strictEqual(-Infinity, buffer.readDoubleLE(8)); buffer.writeDoubleBE(NaN, 0); buffer.writeDoubleLE(NaN, 8); diff --git a/test/parallel/test-writefloat.js b/test/parallel/test-writefloat.js index 2f76dd57c7b077..aeb62c8c022484 100644 --- a/test/parallel/test-writefloat.js +++ b/test/parallel/test-writefloat.js @@ -6,90 +6,90 @@ require('../common'); const assert = require('assert'); function test(clazz) { - var buffer = new clazz(8); + const buffer = new clazz(8); buffer.writeFloatBE(1, 0); buffer.writeFloatLE(1, 4); - assert.equal(0x3f, buffer[0]); - assert.equal(0x80, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x00, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x80, buffer[6]); - assert.equal(0x3f, buffer[7]); + assert.strictEqual(0x3f, buffer[0]); + assert.strictEqual(0x80, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x80, buffer[6]); + assert.strictEqual(0x3f, buffer[7]); buffer.writeFloatBE(1 / 3, 0); buffer.writeFloatLE(1 / 3, 4); - assert.equal(0x3e, buffer[0]); - assert.equal(0xaa, buffer[1]); - assert.equal(0xaa, buffer[2]); - assert.equal(0xab, buffer[3]); - assert.equal(0xab, buffer[4]); - assert.equal(0xaa, buffer[5]); - assert.equal(0xaa, buffer[6]); - assert.equal(0x3e, buffer[7]); + assert.strictEqual(0x3e, buffer[0]); + assert.strictEqual(0xaa, buffer[1]); + assert.strictEqual(0xaa, buffer[2]); + assert.strictEqual(0xab, buffer[3]); + assert.strictEqual(0xab, buffer[4]); + assert.strictEqual(0xaa, buffer[5]); + assert.strictEqual(0xaa, buffer[6]); + assert.strictEqual(0x3e, buffer[7]); buffer.writeFloatBE(3.4028234663852886e+38, 0); buffer.writeFloatLE(3.4028234663852886e+38, 4); - assert.equal(0x7f, buffer[0]); - assert.equal(0x7f, buffer[1]); - assert.equal(0xff, buffer[2]); - assert.equal(0xff, buffer[3]); - assert.equal(0xff, buffer[4]); - assert.equal(0xff, buffer[5]); - assert.equal(0x7f, buffer[6]); - assert.equal(0x7f, buffer[7]); + assert.strictEqual(0x7f, buffer[0]); + assert.strictEqual(0x7f, buffer[1]); + assert.strictEqual(0xff, buffer[2]); + assert.strictEqual(0xff, buffer[3]); + assert.strictEqual(0xff, buffer[4]); + assert.strictEqual(0xff, buffer[5]); + assert.strictEqual(0x7f, buffer[6]); + assert.strictEqual(0x7f, buffer[7]); buffer.writeFloatLE(1.1754943508222875e-38, 0); buffer.writeFloatBE(1.1754943508222875e-38, 4); - assert.equal(0x00, buffer[0]); - assert.equal(0x00, buffer[1]); - assert.equal(0x80, buffer[2]); - assert.equal(0x00, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x80, buffer[5]); - assert.equal(0x00, buffer[6]); - assert.equal(0x00, buffer[7]); + assert.strictEqual(0x00, buffer[0]); + assert.strictEqual(0x00, buffer[1]); + assert.strictEqual(0x80, buffer[2]); + assert.strictEqual(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x80, buffer[5]); + assert.strictEqual(0x00, buffer[6]); + assert.strictEqual(0x00, buffer[7]); buffer.writeFloatBE(0 * -1, 0); buffer.writeFloatLE(0 * -1, 4); - assert.equal(0x80, buffer[0]); - assert.equal(0x00, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x00, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x00, buffer[6]); - assert.equal(0x80, buffer[7]); + assert.strictEqual(0x80, buffer[0]); + assert.strictEqual(0x00, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x00, buffer[6]); + assert.strictEqual(0x80, buffer[7]); buffer.writeFloatBE(Infinity, 0); buffer.writeFloatLE(Infinity, 4); - assert.equal(0x7F, buffer[0]); - assert.equal(0x80, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x00, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x80, buffer[6]); - assert.equal(0x7F, buffer[7]); - assert.equal(Infinity, buffer.readFloatBE(0)); - assert.equal(Infinity, buffer.readFloatLE(4)); + assert.strictEqual(0x7F, buffer[0]); + assert.strictEqual(0x80, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x80, buffer[6]); + assert.strictEqual(0x7F, buffer[7]); + assert.strictEqual(Infinity, buffer.readFloatBE(0)); + assert.strictEqual(Infinity, buffer.readFloatLE(4)); buffer.writeFloatBE(-Infinity, 0); buffer.writeFloatLE(-Infinity, 4); // Darwin ia32 does the other kind of NaN. // Compiler bug. No one really cares. assert(0xFF === buffer[0] || 0x7F === buffer[0]); - assert.equal(0x80, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x00, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x80, buffer[6]); - assert.equal(0xFF, buffer[7]); - assert.equal(-Infinity, buffer.readFloatBE(0)); - assert.equal(-Infinity, buffer.readFloatLE(4)); + assert.strictEqual(0x80, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x80, buffer[6]); + assert.strictEqual(0xFF, buffer[7]); + assert.strictEqual(-Infinity, buffer.readFloatBE(0)); + assert.strictEqual(-Infinity, buffer.readFloatLE(4)); buffer.writeFloatBE(NaN, 0); buffer.writeFloatLE(NaN, 4); diff --git a/test/parallel/test-writeint.js b/test/parallel/test-writeint.js index 43784fb390a1f9..70599dc17750d7 100644 --- a/test/parallel/test-writeint.js +++ b/test/parallel/test-writeint.js @@ -4,162 +4,163 @@ */ require('../common'); const assert = require('assert'); +const errorOutOfBounds = /^TypeError: "value" argument is out of bounds$/; function test8(clazz) { - var buffer = new clazz(2); + const buffer = new clazz(2); buffer.writeInt8(0x23, 0); buffer.writeInt8(-5, 1); - assert.equal(0x23, buffer[0]); - assert.equal(0xfb, buffer[1]); + assert.strictEqual(0x23, buffer[0]); + assert.strictEqual(0xfb, buffer[1]); /* Make sure we handle truncation correctly */ assert.throws(function() { buffer.writeInt8(0xabc, 0); - }); + }, errorOutOfBounds); assert.throws(function() { buffer.writeInt8(0xabc, 0); - }); + }, errorOutOfBounds); /* Make sure we handle min/max correctly */ buffer.writeInt8(0x7f, 0); buffer.writeInt8(-0x80, 1); - assert.equal(0x7f, buffer[0]); - assert.equal(0x80, buffer[1]); + assert.strictEqual(0x7f, buffer[0]); + assert.strictEqual(0x80, buffer[1]); assert.throws(function() { buffer.writeInt8(0x7f + 1, 0); - }); + }, errorOutOfBounds); assert.throws(function() { buffer.writeInt8(-0x80 - 1, 0); - }); + }, errorOutOfBounds); } function test16(clazz) { - var buffer = new clazz(6); + const buffer = new clazz(6); buffer.writeInt16BE(0x0023, 0); buffer.writeInt16LE(0x0023, 2); - assert.equal(0x00, buffer[0]); - assert.equal(0x23, buffer[1]); - assert.equal(0x23, buffer[2]); - assert.equal(0x00, buffer[3]); + assert.strictEqual(0x00, buffer[0]); + assert.strictEqual(0x23, buffer[1]); + assert.strictEqual(0x23, buffer[2]); + assert.strictEqual(0x00, buffer[3]); buffer.writeInt16BE(-5, 0); buffer.writeInt16LE(-5, 2); - assert.equal(0xff, buffer[0]); - assert.equal(0xfb, buffer[1]); - assert.equal(0xfb, buffer[2]); - assert.equal(0xff, buffer[3]); + assert.strictEqual(0xff, buffer[0]); + assert.strictEqual(0xfb, buffer[1]); + assert.strictEqual(0xfb, buffer[2]); + assert.strictEqual(0xff, buffer[3]); buffer.writeInt16BE(-1679, 1); buffer.writeInt16LE(-1679, 3); - assert.equal(0xf9, buffer[1]); - assert.equal(0x71, buffer[2]); - assert.equal(0x71, buffer[3]); - assert.equal(0xf9, buffer[4]); + assert.strictEqual(0xf9, buffer[1]); + assert.strictEqual(0x71, buffer[2]); + assert.strictEqual(0x71, buffer[3]); + assert.strictEqual(0xf9, buffer[4]); /* Make sure we handle min/max correctly */ buffer.writeInt16BE(0x7fff, 0); buffer.writeInt16BE(-0x8000, 2); - assert.equal(0x7f, buffer[0]); - assert.equal(0xff, buffer[1]); - assert.equal(0x80, buffer[2]); - assert.equal(0x00, buffer[3]); + assert.strictEqual(0x7f, buffer[0]); + assert.strictEqual(0xff, buffer[1]); + assert.strictEqual(0x80, buffer[2]); + assert.strictEqual(0x00, buffer[3]); assert.throws(function() { buffer.writeInt16BE(0x7fff + 1, 0); - }); + }, errorOutOfBounds); assert.throws(function() { buffer.writeInt16BE(-0x8000 - 1, 0); - }); + }, errorOutOfBounds); buffer.writeInt16LE(0x7fff, 0); buffer.writeInt16LE(-0x8000, 2); - assert.equal(0xff, buffer[0]); - assert.equal(0x7f, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x80, buffer[3]); + assert.strictEqual(0xff, buffer[0]); + assert.strictEqual(0x7f, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x80, buffer[3]); assert.throws(function() { buffer.writeInt16LE(0x7fff + 1, 0); - }); + }, errorOutOfBounds); assert.throws(function() { buffer.writeInt16LE(-0x8000 - 1, 0); - }); + }, errorOutOfBounds); } function test32(clazz) { - var buffer = new clazz(8); + const buffer = new clazz(8); buffer.writeInt32BE(0x23, 0); buffer.writeInt32LE(0x23, 4); - assert.equal(0x00, buffer[0]); - assert.equal(0x00, buffer[1]); - assert.equal(0x00, buffer[2]); - assert.equal(0x23, buffer[3]); - assert.equal(0x23, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x00, buffer[6]); - assert.equal(0x00, buffer[7]); + assert.strictEqual(0x00, buffer[0]); + assert.strictEqual(0x00, buffer[1]); + assert.strictEqual(0x00, buffer[2]); + assert.strictEqual(0x23, buffer[3]); + assert.strictEqual(0x23, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x00, buffer[6]); + assert.strictEqual(0x00, buffer[7]); buffer.writeInt32BE(-5, 0); buffer.writeInt32LE(-5, 4); - assert.equal(0xff, buffer[0]); - assert.equal(0xff, buffer[1]); - assert.equal(0xff, buffer[2]); - assert.equal(0xfb, buffer[3]); - assert.equal(0xfb, buffer[4]); - assert.equal(0xff, buffer[5]); - assert.equal(0xff, buffer[6]); - assert.equal(0xff, buffer[7]); + assert.strictEqual(0xff, buffer[0]); + assert.strictEqual(0xff, buffer[1]); + assert.strictEqual(0xff, buffer[2]); + assert.strictEqual(0xfb, buffer[3]); + assert.strictEqual(0xfb, buffer[4]); + assert.strictEqual(0xff, buffer[5]); + assert.strictEqual(0xff, buffer[6]); + assert.strictEqual(0xff, buffer[7]); buffer.writeInt32BE(-805306713, 0); buffer.writeInt32LE(-805306713, 4); - assert.equal(0xcf, buffer[0]); - assert.equal(0xff, buffer[1]); - assert.equal(0xfe, buffer[2]); - assert.equal(0xa7, buffer[3]); - assert.equal(0xa7, buffer[4]); - assert.equal(0xfe, buffer[5]); - assert.equal(0xff, buffer[6]); - assert.equal(0xcf, buffer[7]); + assert.strictEqual(0xcf, buffer[0]); + assert.strictEqual(0xff, buffer[1]); + assert.strictEqual(0xfe, buffer[2]); + assert.strictEqual(0xa7, buffer[3]); + assert.strictEqual(0xa7, buffer[4]); + assert.strictEqual(0xfe, buffer[5]); + assert.strictEqual(0xff, buffer[6]); + assert.strictEqual(0xcf, buffer[7]); /* Make sure we handle min/max correctly */ buffer.writeInt32BE(0x7fffffff, 0); buffer.writeInt32BE(-0x80000000, 4); - assert.equal(0x7f, buffer[0]); - assert.equal(0xff, buffer[1]); - assert.equal(0xff, buffer[2]); - assert.equal(0xff, buffer[3]); - assert.equal(0x80, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x00, buffer[6]); - assert.equal(0x00, buffer[7]); + assert.strictEqual(0x7f, buffer[0]); + assert.strictEqual(0xff, buffer[1]); + assert.strictEqual(0xff, buffer[2]); + assert.strictEqual(0xff, buffer[3]); + assert.strictEqual(0x80, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x00, buffer[6]); + assert.strictEqual(0x00, buffer[7]); assert.throws(function() { buffer.writeInt32BE(0x7fffffff + 1, 0); - }); + }, errorOutOfBounds); assert.throws(function() { buffer.writeInt32BE(-0x80000000 - 1, 0); - }); + }, errorOutOfBounds); buffer.writeInt32LE(0x7fffffff, 0); buffer.writeInt32LE(-0x80000000, 4); - assert.equal(0xff, buffer[0]); - assert.equal(0xff, buffer[1]); - assert.equal(0xff, buffer[2]); - assert.equal(0x7f, buffer[3]); - assert.equal(0x00, buffer[4]); - assert.equal(0x00, buffer[5]); - assert.equal(0x00, buffer[6]); - assert.equal(0x80, buffer[7]); + assert.strictEqual(0xff, buffer[0]); + assert.strictEqual(0xff, buffer[1]); + assert.strictEqual(0xff, buffer[2]); + assert.strictEqual(0x7f, buffer[3]); + assert.strictEqual(0x00, buffer[4]); + assert.strictEqual(0x00, buffer[5]); + assert.strictEqual(0x00, buffer[6]); + assert.strictEqual(0x80, buffer[7]); assert.throws(function() { buffer.writeInt32LE(0x7fffffff + 1, 0); - }); + }, errorOutOfBounds); assert.throws(function() { buffer.writeInt32LE(-0x80000000 - 1, 0); - }); + }, errorOutOfBounds); } diff --git a/test/parallel/test-writeuint.js b/test/parallel/test-writeuint.js index 0cccd4bc150436..e91e1d256d0261 100644 --- a/test/parallel/test-writeuint.js +++ b/test/parallel/test-writeuint.js @@ -13,121 +13,121 @@ const assert = require('assert'); * - Correctly interpreting values that are beyond the signed range as unsigned */ function test8(clazz) { - var data = new clazz(4); + const data = new clazz(4); data.writeUInt8(23, 0); data.writeUInt8(23, 1); data.writeUInt8(23, 2); data.writeUInt8(23, 3); - assert.equal(23, data[0]); - assert.equal(23, data[1]); - assert.equal(23, data[2]); - assert.equal(23, data[3]); + assert.strictEqual(23, data[0]); + assert.strictEqual(23, data[1]); + assert.strictEqual(23, data[2]); + assert.strictEqual(23, data[3]); data.writeUInt8(23, 0); data.writeUInt8(23, 1); data.writeUInt8(23, 2); data.writeUInt8(23, 3); - assert.equal(23, data[0]); - assert.equal(23, data[1]); - assert.equal(23, data[2]); - assert.equal(23, data[3]); + assert.strictEqual(23, data[0]); + assert.strictEqual(23, data[1]); + assert.strictEqual(23, data[2]); + assert.strictEqual(23, data[3]); data.writeUInt8(255, 0); - assert.equal(255, data[0]); + assert.strictEqual(255, data[0]); data.writeUInt8(255, 0); - assert.equal(255, data[0]); + assert.strictEqual(255, data[0]); } function test16(clazz) { - var value = 0x2343; - var data = new clazz(4); + let value = 0x2343; + const data = new clazz(4); data.writeUInt16BE(value, 0); - assert.equal(0x23, data[0]); - assert.equal(0x43, data[1]); + assert.strictEqual(0x23, data[0]); + assert.strictEqual(0x43, data[1]); data.writeUInt16BE(value, 1); - assert.equal(0x23, data[1]); - assert.equal(0x43, data[2]); + assert.strictEqual(0x23, data[1]); + assert.strictEqual(0x43, data[2]); data.writeUInt16BE(value, 2); - assert.equal(0x23, data[2]); - assert.equal(0x43, data[3]); + assert.strictEqual(0x23, data[2]); + assert.strictEqual(0x43, data[3]); data.writeUInt16LE(value, 0); - assert.equal(0x23, data[1]); - assert.equal(0x43, data[0]); + assert.strictEqual(0x23, data[1]); + assert.strictEqual(0x43, data[0]); data.writeUInt16LE(value, 1); - assert.equal(0x23, data[2]); - assert.equal(0x43, data[1]); + assert.strictEqual(0x23, data[2]); + assert.strictEqual(0x43, data[1]); data.writeUInt16LE(value, 2); - assert.equal(0x23, data[3]); - assert.equal(0x43, data[2]); + assert.strictEqual(0x23, data[3]); + assert.strictEqual(0x43, data[2]); value = 0xff80; data.writeUInt16LE(value, 0); - assert.equal(0xff, data[1]); - assert.equal(0x80, data[0]); + assert.strictEqual(0xff, data[1]); + assert.strictEqual(0x80, data[0]); data.writeUInt16BE(value, 0); - assert.equal(0xff, data[0]); - assert.equal(0x80, data[1]); + assert.strictEqual(0xff, data[0]); + assert.strictEqual(0x80, data[1]); } function test32(clazz) { - var data = new clazz(6); - var value = 0xe7f90a6d; + const data = new clazz(6); + const value = 0xe7f90a6d; data.writeUInt32BE(value, 0); - assert.equal(0xe7, data[0]); - assert.equal(0xf9, data[1]); - assert.equal(0x0a, data[2]); - assert.equal(0x6d, data[3]); + assert.strictEqual(0xe7, data[0]); + assert.strictEqual(0xf9, data[1]); + assert.strictEqual(0x0a, data[2]); + assert.strictEqual(0x6d, data[3]); data.writeUInt32BE(value, 1); - assert.equal(0xe7, data[1]); - assert.equal(0xf9, data[2]); - assert.equal(0x0a, data[3]); - assert.equal(0x6d, data[4]); + assert.strictEqual(0xe7, data[1]); + assert.strictEqual(0xf9, data[2]); + assert.strictEqual(0x0a, data[3]); + assert.strictEqual(0x6d, data[4]); data.writeUInt32BE(value, 2); - assert.equal(0xe7, data[2]); - assert.equal(0xf9, data[3]); - assert.equal(0x0a, data[4]); - assert.equal(0x6d, data[5]); + assert.strictEqual(0xe7, data[2]); + assert.strictEqual(0xf9, data[3]); + assert.strictEqual(0x0a, data[4]); + assert.strictEqual(0x6d, data[5]); data.writeUInt32LE(value, 0); - assert.equal(0xe7, data[3]); - assert.equal(0xf9, data[2]); - assert.equal(0x0a, data[1]); - assert.equal(0x6d, data[0]); + assert.strictEqual(0xe7, data[3]); + assert.strictEqual(0xf9, data[2]); + assert.strictEqual(0x0a, data[1]); + assert.strictEqual(0x6d, data[0]); data.writeUInt32LE(value, 1); - assert.equal(0xe7, data[4]); - assert.equal(0xf9, data[3]); - assert.equal(0x0a, data[2]); - assert.equal(0x6d, data[1]); + assert.strictEqual(0xe7, data[4]); + assert.strictEqual(0xf9, data[3]); + assert.strictEqual(0x0a, data[2]); + assert.strictEqual(0x6d, data[1]); data.writeUInt32LE(value, 2); - assert.equal(0xe7, data[5]); - assert.equal(0xf9, data[4]); - assert.equal(0x0a, data[3]); - assert.equal(0x6d, data[2]); + assert.strictEqual(0xe7, data[5]); + assert.strictEqual(0xf9, data[4]); + assert.strictEqual(0x0a, data[3]); + assert.strictEqual(0x6d, data[2]); } function testUint(clazz) { const data = new clazz(8); - var val = 1; + let val = 1; // Test 0 to 5 bytes. - for (var i = 0; i <= 5; i++) { + for (let i = 0; i <= 5; i++) { const errmsg = `byteLength: ${i}`; assert.throws(function() { data.writeUIntBE(val, 0, i); diff --git a/test/parallel/test-zerolengthbufferbug.js b/test/parallel/test-zerolengthbufferbug.js index 9e2cde6b2fadae..42e6994e1b6389 100644 --- a/test/parallel/test-zerolengthbufferbug.js +++ b/test/parallel/test-zerolengthbufferbug.js @@ -2,13 +2,13 @@ // Serving up a zero-length buffer should work. const common = require('../common'); -var http = require('http'); +const http = require('http'); -var server = http.createServer(function(req, res) { - var buffer = Buffer.alloc(0); +const server = http.createServer(function(req, res) { + const buffer = Buffer.alloc(0); // FIXME: WTF gjslint want this? res.writeHead(200, {'Content-Type': 'text/html', - 'Content-Length': buffer.length}); + 'Content-Length': buffer.length}); res.end(buffer); }); diff --git a/test/parallel/test-zlib-const.js b/test/parallel/test-zlib-const.js index cafa4f8caaf28a..ba6bb5fb8a26b4 100644 --- a/test/parallel/test-zlib-const.js +++ b/test/parallel/test-zlib-const.js @@ -4,14 +4,14 @@ const assert = require('assert'); const zlib = require('zlib'); -assert.equal(zlib.constants.Z_OK, 0, 'Z_OK should be 0'); +assert.strictEqual(zlib.constants.Z_OK, 0, 'Z_OK should be 0'); zlib.constants.Z_OK = 1; -assert.equal(zlib.constants.Z_OK, 0, 'Z_OK should be 0'); +assert.strictEqual(zlib.constants.Z_OK, 0, 'Z_OK should be 0'); -assert.equal(zlib.codes.Z_OK, 0, 'Z_OK should be 0'); +assert.strictEqual(zlib.codes.Z_OK, 0, 'Z_OK should be 0'); zlib.codes.Z_OK = 1; -assert.equal(zlib.codes.Z_OK, 0, 'zlib.codes.Z_OK should be 0'); +assert.strictEqual(zlib.codes.Z_OK, 0, 'zlib.codes.Z_OK should be 0'); zlib.codes = {Z_OK: 1}; -assert.equal(zlib.codes.Z_OK, 0, 'zlib.codes.Z_OK should be 0'); +assert.strictEqual(zlib.codes.Z_OK, 0, 'zlib.codes.Z_OK should be 0'); assert.ok(Object.isFrozen(zlib.codes), 'zlib.codes should be frozen'); diff --git a/test/parallel/test-zlib-convenience-methods.js b/test/parallel/test-zlib-convenience-methods.js index 3aac0142b55d66..9b9419c7bfaf47 100644 --- a/test/parallel/test-zlib-convenience-methods.js +++ b/test/parallel/test-zlib-convenience-methods.js @@ -5,7 +5,7 @@ require('../common'); const assert = require('assert'); const zlib = require('zlib'); -var hadRun = 0; +let hadRun = 0; const expect = 'blahblahblahblahblahblah'; const opts = { @@ -22,8 +22,8 @@ const opts = { zlib[method[0]](expect, opts, function(err, result) { zlib[method[1]](result, opts, function(err, result) { - assert.equal(result, expect, - 'Should get original string after ' + + assert.strictEqual(result.toString(), expect, + 'Should get original string after ' + method[0] + '/' + method[1] + ' with options.'); hadRun++; }); @@ -31,29 +31,29 @@ const opts = { zlib[method[0]](expect, function(err, result) { zlib[method[1]](result, function(err, result) { - assert.equal(result, expect, - 'Should get original string after ' + + assert.strictEqual(result.toString(), expect, + 'Should get original string after ' + method[0] + '/' + method[1] + ' without options.'); hadRun++; }); }); - var result = zlib[method[0] + 'Sync'](expect, opts); + let result = zlib[method[0] + 'Sync'](expect, opts); result = zlib[method[1] + 'Sync'](result, opts); - assert.equal(result, expect, - 'Should get original string after ' + + assert.strictEqual(result.toString(), expect, + 'Should get original string after ' + method[0] + '/' + method[1] + ' with options.'); hadRun++; result = zlib[method[0] + 'Sync'](expect); result = zlib[method[1] + 'Sync'](result); - assert.equal(result, expect, - 'Should get original string after ' + + assert.strictEqual(result.toString(), expect, + 'Should get original string after ' + method[0] + '/' + method[1] + ' without options.'); hadRun++; }); process.on('exit', function() { - assert.equal(hadRun, 16, 'expect 16 compressions'); + assert.strictEqual(hadRun, 16, 'expect 16 compressions'); }); diff --git a/test/parallel/test-zlib-flush-drain.js b/test/parallel/test-zlib-flush-drain.js index 45cca584858322..d446f048b06586 100644 --- a/test/parallel/test-zlib-flush-drain.js +++ b/test/parallel/test-zlib-flush-drain.js @@ -13,8 +13,8 @@ const opts = { const deflater = zlib.createDeflate(opts); // shim deflater.flush so we can count times executed -var flushCount = 0; -var drainCount = 0; +let flushCount = 0; +let drainCount = 0; const flush = deflater.flush; deflater.flush = function(kind, callback) { @@ -26,7 +26,7 @@ deflater.write(bigData); const ws = deflater._writableState; const beforeFlush = ws.needDrain; -var afterFlush = ws.needDrain; +let afterFlush = ws.needDrain; deflater.flush(function(err) { afterFlush = ws.needDrain; @@ -37,12 +37,12 @@ deflater.on('drain', function() { }); process.once('exit', function() { - assert.equal(beforeFlush, true, - 'before calling flush, writable stream should need to drain'); - assert.equal(afterFlush, false, - 'after calling flush, writable stream should not need to drain'); - assert.equal(drainCount, 1, - 'the deflater should have emitted a single drain event'); - assert.equal(flushCount, 2, - 'flush should be called twice'); + assert.strictEqual(beforeFlush, true, 'before calling flush, writable ' + + 'stream should need to drain'); + assert.strictEqual(afterFlush, false, 'after calling flush, writable ' + + 'stream should not need to drain'); + assert.strictEqual(drainCount, 1, + 'the deflater should have emitted a single drain event'); + assert.strictEqual(flushCount, 2, + 'flush should be called twice'); }); diff --git a/test/parallel/test-zlib-flush.js b/test/parallel/test-zlib-flush.js index 7f0021434f4c18..0eec5da7dd835e 100644 --- a/test/parallel/test-zlib-flush.js +++ b/test/parallel/test-zlib-flush.js @@ -22,7 +22,8 @@ deflater.write(chunk, function() { deflater.flush(zlib.constants.Z_NO_FLUSH, function() { actualNone = deflater.read(); deflater.flush(function() { - var bufs = [], buf; + const bufs = []; + let buf; while (buf = deflater.read()) bufs.push(buf); actualFull = Buffer.concat(bufs); diff --git a/test/parallel/test-zlib-from-concatenated-gzip.js b/test/parallel/test-zlib-from-concatenated-gzip.js index 998a086eb76514..f59b6796357e3b 100644 --- a/test/parallel/test-zlib-from-concatenated-gzip.js +++ b/test/parallel/test-zlib-from-concatenated-gzip.js @@ -15,16 +15,18 @@ const data = Buffer.concat([ defEncoded ]); -assert.equal(zlib.gunzipSync(data).toString(), 'abcdef'); +assert.strictEqual(zlib.gunzipSync(data).toString(), 'abcdef'); zlib.gunzip(data, common.mustCall((err, result) => { assert.ifError(err); - assert.equal(result, 'abcdef', 'result should match original string'); + assert.strictEqual(result.toString(), 'abcdef', + 'result should match original string'); })); zlib.unzip(data, common.mustCall((err, result) => { assert.ifError(err); - assert.equal(result, 'abcdef', 'result should match original string'); + assert.strictEqual(result.toString(), 'abcdef', + 'result should match original string'); })); // Multi-member support does not apply to zlib inflate/deflate. @@ -33,7 +35,8 @@ zlib.unzip(Buffer.concat([ zlib.deflateSync('def') ]), common.mustCall((err, result) => { assert.ifError(err); - assert.equal(result, 'abc', 'result should match contents of first "member"'); + assert.strictEqual(result.toString(), 'abc', + 'result should match contents of first "member"'); })); // files that have the "right" magic bytes for starting a new gzip member diff --git a/test/parallel/test-zlib-from-gzip-with-trailing-garbage.js b/test/parallel/test-zlib-from-gzip-with-trailing-garbage.js index 37f89f5b94bf08..872c2581c53b90 100644 --- a/test/parallel/test-zlib-from-gzip-with-trailing-garbage.js +++ b/test/parallel/test-zlib-from-gzip-with-trailing-garbage.js @@ -12,11 +12,15 @@ let data = Buffer.concat([ Buffer(10).fill(0) ]); -assert.equal(zlib.gunzipSync(data).toString(), 'abcdef'); +assert.strictEqual(zlib.gunzipSync(data).toString(), 'abcdef'); zlib.gunzip(data, common.mustCall((err, result) => { assert.ifError(err); - assert.equal(result, 'abcdef', 'result should match original string'); + assert.strictEqual( + result.toString(), + 'abcdef', + 'result should match original string' + ); })); // if the trailing garbage happens to look like a gzip header, it should @@ -28,10 +32,16 @@ data = Buffer.concat([ Buffer(10).fill(0) ]); -assert.throws(() => zlib.gunzipSync(data)); +assert.throws( + () => zlib.gunzipSync(data), + /^Error: unknown compression method$/ +); zlib.gunzip(data, common.mustCall((err, result) => { - assert(err); + assert(err instanceof Error); + assert.strictEqual(err.code, 'Z_DATA_ERROR'); + assert.strictEqual(err.message, 'unknown compression method'); + assert.strictEqual(result, undefined); })); // In this case the trailing junk is too short to be a gzip segment @@ -42,8 +52,14 @@ data = Buffer.concat([ Buffer([0x1f, 0x8b, 0xff, 0xff]) ]); -assert.throws(() => zlib.gunzipSync(data)); +assert.throws( + () => zlib.gunzipSync(data), + /^Error: unknown compression method$/ +); zlib.gunzip(data, common.mustCall((err, result) => { - assert(err); + assert(err instanceof Error); + assert.strictEqual(err.code, 'Z_DATA_ERROR'); + assert.strictEqual(err.message, 'unknown compression method'); + assert.strictEqual(result, undefined); })); diff --git a/test/parallel/test-zlib-from-gzip.js b/test/parallel/test-zlib-from-gzip.js index 3739d8f9b48b28..ac01fc03d11c6f 100644 --- a/test/parallel/test-zlib-from-gzip.js +++ b/test/parallel/test-zlib-from-gzip.js @@ -23,8 +23,8 @@ const out = fs.createWriteStream(outputFile); inp.pipe(gunzip).pipe(out); out.on('close', function() { const actual = fs.readFileSync(outputFile); - assert.equal(actual.length, expect.length, 'length should match'); - for (var i = 0, l = actual.length; i < l; i++) { - assert.equal(actual[i], expect[i], 'byte[' + i + ']'); + assert.strictEqual(actual.length, expect.length, 'length should match'); + for (let i = 0, l = actual.length; i < l; i++) { + assert.strictEqual(actual[i], expect[i], 'byte[' + i + ']'); } }); diff --git a/test/parallel/test-zlib-from-string.js b/test/parallel/test-zlib-from-string.js index f3b8426eb4d862..ab2f7d023d8bc8 100644 --- a/test/parallel/test-zlib-from-string.js +++ b/test/parallel/test-zlib-from-string.js @@ -34,8 +34,8 @@ const expectedBase64Gzip = 'H4sIAAAAAAAAA11RS05DMQy8yhzg6d2BPSAkJPZu4laWkjiN4' + 'sHnHNzRtagj5AQAA'; zlib.deflate(inputString, function(err, buffer) { - assert.equal(buffer.toString('base64'), expectedBase64Deflate, - 'deflate encoded string should match'); + assert.strictEqual(buffer.toString('base64'), expectedBase64Deflate, + 'deflate encoded string should match'); }); zlib.gzip(inputString, function(err, buffer) { @@ -46,19 +46,19 @@ zlib.gzip(inputString, function(err, buffer) { // result that we're expecting, and this should match what we get // from inflating the known valid deflate data. zlib.gunzip(buffer, function(err, gunzipped) { - assert.equal(gunzipped.toString(), inputString, - 'Should get original string after gzip/gunzip'); + assert.strictEqual(gunzipped.toString(), inputString, + 'Should get original string after gzip/gunzip'); }); }); -var buffer = Buffer.from(expectedBase64Deflate, 'base64'); +let buffer = Buffer.from(expectedBase64Deflate, 'base64'); zlib.unzip(buffer, function(err, buffer) { - assert.equal(buffer.toString(), inputString, - 'decoded inflated string should match'); + assert.strictEqual(buffer.toString(), inputString, + 'decoded inflated string should match'); }); buffer = Buffer.from(expectedBase64Gzip, 'base64'); zlib.unzip(buffer, function(err, buffer) { - assert.equal(buffer.toString(), inputString, - 'decoded gunzipped string should match'); + assert.strictEqual(buffer.toString(), inputString, + 'decoded gunzipped string should match'); }); diff --git a/test/parallel/test-zlib-invalid-input.js b/test/parallel/test-zlib-invalid-input.js index ee2ee85d73ff09..7b0e1fcaae8ce6 100644 --- a/test/parallel/test-zlib-invalid-input.js +++ b/test/parallel/test-zlib-invalid-input.js @@ -21,10 +21,10 @@ nonStringInputs.forEach(function(input) { console.error('Doing the unzips'); // zlib.Unzip classes need to get valid data, or else they'll throw. const unzips = [ zlib.Unzip(), - zlib.Gunzip(), - zlib.Inflate(), - zlib.InflateRaw() ]; -var hadError = []; + zlib.Gunzip(), + zlib.Inflate(), + zlib.InflateRaw() ]; +const hadError = []; unzips.forEach(function(uz, i) { console.error('Error for ' + uz.constructor.name); uz.on('error', function(er) { diff --git a/test/parallel/test-zlib-params.js b/test/parallel/test-zlib-params.js index 0dce05be4d40f6..40799637ecdac7 100644 --- a/test/parallel/test-zlib-params.js +++ b/test/parallel/test-zlib-params.js @@ -21,7 +21,7 @@ deflater.write(chunk1, function() { while (deflater.read()); deflater.end(chunk2, function() { const bufs = []; - var buf; + let buf; while (buf = deflater.read()) bufs.push(buf); actual = Buffer.concat(bufs); diff --git a/test/parallel/test-zlib-random-byte-pipes.js b/test/parallel/test-zlib-random-byte-pipes.js index 6037703f7bf2ca..d4cd4319f93c21 100644 --- a/test/parallel/test-zlib-random-byte-pipes.js +++ b/test/parallel/test-zlib-random-byte-pipes.js @@ -72,14 +72,14 @@ RandomReadStream.prototype._process = function() { // figure out how many bytes to output // if finished, then just emit end. - var block = this._opt.block; + let block = this._opt.block; const jitter = this._opt.jitter; if (jitter) { block += Math.ceil(Math.random() * jitter - (jitter / 2)); } block = Math.min(block, this._remaining); const buf = Buffer.allocUnsafe(block); - for (var i = 0; i < block; i++) { + for (let i = 0; i < block; i++) { buf[i] = Math.random() * 256; } @@ -129,10 +129,10 @@ HashStream.prototype.end = function(c) { }; -var inp = new RandomReadStream({ total: 1024, block: 256, jitter: 16 }); -var out = new HashStream(); -var gzip = zlib.createGzip(); -var gunz = zlib.createGunzip(); +const inp = new RandomReadStream({ total: 1024, block: 256, jitter: 16 }); +const out = new HashStream(); +const gzip = zlib.createGzip(); +const gunz = zlib.createGunzip(); inp.pipe(gzip).pipe(gunz).pipe(out); @@ -154,5 +154,5 @@ out.on('data', function(c) { out.on('data', common.mustCall(function(c) { console.error('hash=%s', c); - assert.equal(c, inp._hash, 'hashes should match'); + assert.strictEqual(c, inp._hash, 'hashes should match'); })); diff --git a/test/parallel/test-zlib-sync-no-event.js b/test/parallel/test-zlib-sync-no-event.js index 46ea97fbf4dd83..d6eb1f3c9df6a3 100644 --- a/test/parallel/test-zlib-sync-no-event.js +++ b/test/parallel/test-zlib-sync-no-event.js @@ -17,5 +17,5 @@ const unzipper = new zlib.Gunzip(); unzipper.on('close', shouldNotBeCalled); const unzipped = unzipper._processChunk(zipped, zlib.constants.Z_FINISH); -assert.notEqual(zipped.toString(), message); +assert.notStrictEqual(zipped.toString(), message); assert.strictEqual(unzipped.toString(), message); diff --git a/test/parallel/test-zlib-truncated.js b/test/parallel/test-zlib-truncated.js index 92a18a538c1ee4..c7b84c0d703711 100644 --- a/test/parallel/test-zlib-truncated.js +++ b/test/parallel/test-zlib-truncated.js @@ -22,7 +22,7 @@ const inputString = 'ΩΩLorem ipsum dolor sit amet, consectetur adipiscing eli' { comp: 'deflateRaw', decomp: 'inflateRaw', decompSync: 'inflateRawSync' } ].forEach(function(methods) { zlib[methods.comp](inputString, function(err, compressed) { - assert(!err); + assert.ifError(err); const truncated = compressed.slice(0, compressed.length / 2); const toUTF8 = (buffer) => buffer.toString('utf-8'); diff --git a/test/parallel/test-zlib-write-after-flush.js b/test/parallel/test-zlib-write-after-flush.js index 89edaf93043d88..e0e962218269dd 100644 --- a/test/parallel/test-zlib-write-after-flush.js +++ b/test/parallel/test-zlib-write-after-flush.js @@ -8,7 +8,7 @@ const gunz = zlib.createUnzip(); gzip.pipe(gunz); -var output = ''; +let output = ''; const input = 'A line of data\n'; gunz.setEncoding('utf8'); gunz.on('data', function(c) { @@ -16,10 +16,10 @@ gunz.on('data', function(c) { }); process.on('exit', function() { - assert.equal(output, input); + assert.strictEqual(output, input); // Make sure that the flush flag was set back to normal - assert.equal(gzip._flushFlag, zlib.constants.Z_NO_FLUSH); + assert.strictEqual(gzip._flushFlag, zlib.constants.Z_NO_FLUSH); console.log('ok'); }); diff --git a/test/parallel/test-zlib-zero-byte.js b/test/parallel/test-zlib-zero-byte.js index ca58d06ff272ba..cd4cf41f98ac07 100644 --- a/test/parallel/test-zlib-zero-byte.js +++ b/test/parallel/test-zlib-zero-byte.js @@ -5,7 +5,7 @@ const assert = require('assert'); const zlib = require('zlib'); const gz = zlib.Gzip(); const emptyBuffer = Buffer.alloc(0); -var received = 0; +let received = 0; gz.on('data', function(c) { received += c.length; }); diff --git a/test/parallel/test-zlib.js b/test/parallel/test-zlib.js index ea158ded48b5c1..fdd5d0a9400f25 100644 --- a/test/parallel/test-zlib.js +++ b/test/parallel/test-zlib.js @@ -7,7 +7,7 @@ const fs = require('fs'); const util = require('util'); const stream = require('stream'); -var zlibPairs = [ +let zlibPairs = [ [zlib.Deflate, zlib.Inflate], [zlib.Gzip, zlib.Gunzip], [zlib.Deflate, zlib.Unzip], @@ -16,18 +16,18 @@ var zlibPairs = [ ]; // how fast to trickle through the slowstream -var trickle = [128, 1024, 1024 * 1024]; +let trickle = [128, 1024, 1024 * 1024]; // tunable options for zlib classes. // several different chunk sizes -var chunkSize = [128, 1024, 1024 * 16, 1024 * 1024]; +let chunkSize = [128, 1024, 1024 * 16, 1024 * 1024]; // this is every possible value. -var level = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; -var windowBits = [8, 9, 10, 11, 12, 13, 14, 15]; -var memLevel = [1, 2, 3, 4, 5, 6, 7, 8, 9]; -var strategy = [0, 1, 2, 3, 4]; +let level = [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; +let windowBits = [8, 9, 10, 11, 12, 13, 14, 15]; +let memLevel = [1, 2, 3, 4, 5, 6, 7, 8, 9]; +let strategy = [0, 1, 2, 3, 4]; // it's nice in theory to test every combination, but it // takes WAY too long. Maybe a pummel test could do this? @@ -40,7 +40,7 @@ if (!process.env.PUMMEL) { strategy = [0]; } -var testFiles = ['person.jpg', 'elipses.txt', 'empty.txt']; +let testFiles = ['person.jpg', 'elipses.txt', 'empty.txt']; if (process.env.FAST) { zlibPairs = [[zlib.Gzip, zlib.Unzip]]; @@ -72,8 +72,8 @@ BufferStream.prototype.write = function(c) { BufferStream.prototype.end = function(c) { if (c) this.write(c); // flatten - var buf = Buffer.allocUnsafe(this.length); - var i = 0; + const buf = Buffer.allocUnsafe(this.length); + let i = 0; this.chunks.forEach(function(c) { c.copy(buf, i); i += c.length; @@ -108,8 +108,8 @@ SlowStream.prototype.resume = function() { this.ended = true; return this.emit('end'); } - var end = Math.min(this.offset + this.trickle, this.length); - var c = this.chunk.slice(this.offset, end); + const end = Math.min(this.offset + this.trickle, this.length); + const c = this.chunk.slice(this.offset, end); this.offset += c.length; this.emit('data', c); process.nextTick(emit); @@ -134,12 +134,12 @@ SlowStream.prototype.end = function(chunk) { // for each of the files, make sure that compressing and // decompressing results in the same data, for every combination // of the options set above. -var failures = 0; -var total = 0; -var done = 0; +let failures = 0; +let total = 0; +let done = 0; Object.keys(tests).forEach(function(file) { - var test = tests[file]; + const test = tests[file]; chunkSize.forEach(function(chunkSize) { trickle.forEach(function(trickle) { windowBits.forEach(function(windowBits) { @@ -147,29 +147,30 @@ Object.keys(tests).forEach(function(file) { memLevel.forEach(function(memLevel) { strategy.forEach(function(strategy) { zlibPairs.forEach(function(pair) { - var Def = pair[0]; - var Inf = pair[1]; - var opts = { level: level, - windowBits: windowBits, - memLevel: memLevel, - strategy: strategy }; + const Def = pair[0]; + const Inf = pair[1]; + const opts = { level: level, + windowBits: windowBits, + memLevel: memLevel, + strategy: strategy }; total++; - var def = new Def(opts); - var inf = new Inf(opts); - var ss = new SlowStream(trickle); - var buf = new BufferStream(); + const def = new Def(opts); + const inf = new Inf(opts); + const ss = new SlowStream(trickle); + const buf = new BufferStream(); // verify that the same exact buffer comes out the other end. buf.on('data', function(c) { - var msg = file + ' ' + - chunkSize + ' ' + - JSON.stringify(opts) + ' ' + - Def.name + ' -> ' + Inf.name; - var ok = true; - var testNum = ++done; - for (var i = 0; i < Math.max(c.length, test.length); i++) { + const msg = file + ' ' + + chunkSize + ' ' + + JSON.stringify(opts) + ' ' + + Def.name + ' -> ' + Inf.name; + let ok = true; + const testNum = ++done; + let i; + for (i = 0; i < Math.max(c.length, test.length); i++) { if (c[i] !== test[i]) { ok = false; failures++; diff --git a/test/pseudo-tty/no_dropped_stdio.js b/test/pseudo-tty/no_dropped_stdio.js index 1a20889073ce06..b24d234a38b2b7 100644 --- a/test/pseudo-tty/no_dropped_stdio.js +++ b/test/pseudo-tty/no_dropped_stdio.js @@ -6,7 +6,7 @@ require('../common'); // 1000 bytes wrapped at 50 columns // \n turns into a double-byte character // (48 + {2}) * 20 = 1000 -var out = ('o'.repeat(48) + '\n').repeat(20); +let out = ('o'.repeat(48) + '\n').repeat(20); // Add the remaining 24 bytes and terminate with an 'O'. // This results in 1025 bytes, just enough to overflow the 1kb OS X TTY buffer. out += 'o'.repeat(24) + 'O'; diff --git a/test/pseudo-tty/no_interleaved_stdio.js b/test/pseudo-tty/no_interleaved_stdio.js index 778b2c09583b90..ff3ed8594a0baa 100644 --- a/test/pseudo-tty/no_interleaved_stdio.js +++ b/test/pseudo-tty/no_interleaved_stdio.js @@ -6,7 +6,7 @@ require('../common'); // 1000 bytes wrapped at 50 columns // \n turns into a double-byte character // (48 + {2}) * 20 = 1000 -var out = ('o'.repeat(48) + '\n').repeat(20); +let out = ('o'.repeat(48) + '\n').repeat(20); // Add the remaining 24 bytes and terminate with an 'O'. // This results in 1025 bytes, just enough to overflow the 1kb OS X TTY buffer. out += 'o'.repeat(24) + 'O'; diff --git a/test/pseudo-tty/pseudo-tty.status b/test/pseudo-tty/pseudo-tty.status index e16bb28cd7be61..50f54de029d874 100644 --- a/test/pseudo-tty/pseudo-tty.status +++ b/test/pseudo-tty/pseudo-tty.status @@ -4,3 +4,5 @@ prefix pseudo-tty # test issue only, covered under https://github.com/nodejs/node/issues/7973 no_dropped_stdio : SKIP no_interleaved_stdio : SKIP +# being investigated under https://github.com/nodejs/node/issues/9728 +test-tty-wrap : FAIL, PASS diff --git a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js index f1a95559b9dc92..f828e92afbe71c 100644 --- a/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js +++ b/test/pseudo-tty/test-stderr-stdout-handle-sigwinch.js @@ -5,7 +5,7 @@ const originalRefreshSizeStderr = process.stderr._refreshSize; const originalRefreshSizeStdout = process.stdout._refreshSize; const wrap = (fn, ioStream, string) => { - return () => { + const wrapped = common.mustCall(() => { // The console.log() call prints a string that is in the .out file. In other // words, the console.log() is part of the test, not extraneous debugging. console.log(string); @@ -16,7 +16,8 @@ const wrap = (fn, ioStream, string) => { if (!common.isSunOS || e.code !== 'EINVAL') throw e; } - }; + }); + return wrapped; }; process.stderr._refreshSize = wrap(originalRefreshSizeStderr, diff --git a/test/pummel/test-abort-fatal-error.js b/test/pummel/test-abort-fatal-error.js index 0bb2cb2c39998e..d1a8d3daa65e4c 100644 --- a/test/pummel/test-abort-fatal-error.js +++ b/test/pummel/test-abort-fatal-error.js @@ -1,15 +1,15 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); if (common.isWindows) { common.skip('no RLIMIT_NOFILE on Windows'); return; } -var exec = require('child_process').exec; +const exec = require('child_process').exec; -var cmdline = 'ulimit -c 0; ' + process.execPath; +let cmdline = 'ulimit -c 0; ' + process.execPath; cmdline += ' --max-old-space-size=4 --max-semi-space-size=1'; cmdline += ' -e "a = []; for (i = 0; i < 1e9; i++) { a.push({}) }"'; diff --git a/test/pummel/test-child-process-spawn-loop.js b/test/pummel/test-child-process-spawn-loop.js index 7e686cada244b3..41d9ff1e49c17b 100644 --- a/test/pummel/test-child-process-spawn-loop.js +++ b/test/pummel/test-child-process-spawn-loop.js @@ -1,29 +1,29 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var spawn = require('child_process').spawn; +const spawn = require('child_process').spawn; -var SIZE = 1000 * 1024; -var N = 40; -var finished = false; +const SIZE = 1000 * 1024; +const N = 40; +let finished = false; function doSpawn(i) { - var child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']); - var count = 0; + const child = spawn('python', ['-c', 'print ' + SIZE + ' * "C"']); + let count = 0; child.stdout.setEncoding('ascii'); - child.stdout.on('data', function(chunk) { + child.stdout.on('data', (chunk) => { count += chunk.length; }); - child.stderr.on('data', function(chunk) { + child.stderr.on('data', (chunk) => { console.log('stderr: ' + chunk); }); - child.on('close', function() { + child.on('close', () => { // + 1 for \n or + 2 for \r\n on Windows - assert.equal(SIZE + (common.isWindows ? 2 : 1), count); + assert.strictEqual(SIZE + (common.isWindows ? 2 : 1), count); if (i < N) { doSpawn(i + 1); } else { @@ -34,6 +34,6 @@ function doSpawn(i) { doSpawn(0); -process.on('exit', function() { +process.on('exit', () => { assert.ok(finished); }); diff --git a/test/pummel/test-crypto-dh.js b/test/pummel/test-crypto-dh.js index 7656d0ffa92e84..64c2800f16ae8d 100644 --- a/test/pummel/test-crypto-dh.js +++ b/test/pummel/test-crypto-dh.js @@ -18,7 +18,7 @@ assert.throws(function() { crypto.getDiffieHellman('modp1').setPublicKey(''); }); -var hashes = { +const hashes = { modp1: '630e9acd2cc63f7e80d8507624ba60ac0757201a', modp2: '18f7aa964484137f57bca64b21917a385b6a0b60', modp5: 'c0a8eec0c2c8a5ec2f9c26f9661eb339a010ec61', @@ -30,24 +30,24 @@ var hashes = { }; for (const name in hashes) { - var group = crypto.getDiffieHellman(name); - var private_key = group.getPrime('hex'); - var hash1 = hashes[name]; - var hash2 = crypto.createHash('sha1') + const group = crypto.getDiffieHellman(name); + const private_key = group.getPrime('hex'); + const hash1 = hashes[name]; + const hash2 = crypto.createHash('sha1') .update(private_key.toUpperCase()).digest('hex'); - assert.equal(hash1, hash2); - assert.equal(group.getGenerator('hex'), '02'); + assert.strictEqual(hash1, hash2); + assert.strictEqual(group.getGenerator('hex'), '02'); } for (const name in hashes) { // modp1 is 768 bits, FIPS requires >= 1024 if (name === 'modp1' && common.hasFipsCrypto) continue; - var group1 = crypto.getDiffieHellman(name); - var group2 = crypto.getDiffieHellman(name); + const group1 = crypto.getDiffieHellman(name); + const group2 = crypto.getDiffieHellman(name); group1.generateKeys(); group2.generateKeys(); - var key1 = group1.computeSecret(group2.getPublicKey()); - var key2 = group2.computeSecret(group1.getPublicKey()); + const key1 = group1.computeSecret(group2.getPublicKey()); + const key2 = group2.computeSecret(group1.getPublicKey()); assert.deepStrictEqual(key1, key2); } diff --git a/test/pummel/test-dh-regr.js b/test/pummel/test-dh-regr.js index 448319318b44a4..5be6abb9a8b29c 100644 --- a/test/pummel/test-dh-regr.js +++ b/test/pummel/test-dh-regr.js @@ -1,16 +1,16 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var crypto = require('crypto'); +const crypto = require('crypto'); -var p = crypto.createDiffieHellman(1024).getPrime(); +const p = crypto.createDiffieHellman(1024).getPrime(); -for (var i = 0; i < 2000; i++) { +for (let i = 0; i < 2000; i++) { const a = crypto.createDiffieHellman(p); const b = crypto.createDiffieHellman(p); diff --git a/test/pummel/test-dtrace-jsstack.js b/test/pummel/test-dtrace-jsstack.js index 1949045888c138..6c8423c2c9c83b 100644 --- a/test/pummel/test-dtrace-jsstack.js +++ b/test/pummel/test-dtrace-jsstack.js @@ -1,7 +1,7 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); -var os = require('os'); +const assert = require('assert'); +const os = require('os'); if (!common.isSunOS) { common.skip('no DTRACE support'); @@ -11,37 +11,37 @@ if (!common.isSunOS) { /* * Some functions to create a recognizable stack. */ -var frames = [ 'stalloogle', 'bagnoogle', 'doogle' ]; +const frames = [ 'stalloogle', 'bagnoogle', 'doogle' ]; -var stalloogle = function(str) { +const stalloogle = function(str) { global.expected = str; os.loadavg(); }; -var bagnoogle = function(arg0, arg1) { +const bagnoogle = function(arg0, arg1) { stalloogle(arg0 + ' is ' + arg1 + ' except that it is read-only'); }; -var done = false; +let done = false; -var doogle = function() { +const doogle = function() { if (!done) setTimeout(doogle, 10); bagnoogle('The bfs command', '(almost) like ed(1)'); }; -var spawn = require('child_process').spawn; +const spawn = require('child_process').spawn; /* * We're going to use DTrace to stop us, gcore us, and set us running again * when we call getloadavg() -- with the implicit assumption that our * deepest function is the only caller of os.loadavg(). */ -var dtrace = spawn('dtrace', [ '-qwn', 'syscall::getloadavg:entry/pid == ' + +const dtrace = spawn('dtrace', [ '-qwn', 'syscall::getloadavg:entry/pid == ' + process.pid + '/{ustack(100, 8192); exit(0); }' ]); -var output = ''; +let output = ''; dtrace.stderr.on('data', function(data) { console.log('dtrace: ' + data); @@ -59,23 +59,24 @@ dtrace.on('exit', function(code) { done = true; - var sentinel = '(anon) as '; - var lines = output.split('\n'); + const sentinel = '(anon) as '; + const lines = output.split('\n'); - for (var i = 0; i < lines.length; i++) { - var line = lines[i]; + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; if (line.indexOf(sentinel) === -1 || frames.length === 0) continue; - var frame = line.substr(line.indexOf(sentinel) + sentinel.length); - var top = frames.shift(); + const frame = line.substr(line.indexOf(sentinel) + sentinel.length); + const top = frames.shift(); - assert.equal(frame.indexOf(top), 0, 'unexpected frame where ' + + assert.strictEqual(frame.indexOf(top), 0, 'unexpected frame where ' + top + ' was expected'); } - assert.equal(frames.length, 0, 'did not find expected frame ' + frames[0]); + assert.strictEqual(frames.length, 0, + 'did not find expected frame ' + frames[0]); process.exit(0); }); diff --git a/test/pummel/test-exec.js b/test/pummel/test-exec.js index 6f6e1511b14442..131b214fc53f42 100644 --- a/test/pummel/test-exec.js +++ b/test/pummel/test-exec.js @@ -1,9 +1,9 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var exec = require('child_process').exec; +const common = require('../common'); +const assert = require('assert'); +const exec = require('child_process').exec; -var SLEEP3_COMMAND; +let SLEEP3_COMMAND; if (!common.isWindows) { // Unix. SLEEP3_COMMAND = 'sleep 3'; @@ -14,8 +14,8 @@ if (!common.isWindows) { } -var success_count = 0; -var error_count = 0; +let success_count = 0; +let error_count = 0; exec( @@ -55,19 +55,21 @@ exec('thisisnotavalidcommand', function(err, stdout, stderr) { }); -var sleeperStart = new Date(); +const sleeperStart = new Date(); exec(SLEEP3_COMMAND, { timeout: 50 }, function(err, stdout, stderr) { - var diff = (new Date()) - sleeperStart; + const diff = (new Date()) - sleeperStart; console.log('\'sleep 3\' with timeout 50 took %d ms', diff); assert.ok(diff < 500); assert.ok(err); assert.ok(err.killed); assert.strictEqual(err.signal, 'SIGTERM'); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); }); -var startSleep3 = new Date(); -var killMeTwice = exec(SLEEP3_COMMAND, {timeout: 1000}, killMeTwiceCallback); +const startSleep3 = new Date(); +const killMeTwice = exec(SLEEP3_COMMAND, {timeout: 1000}, killMeTwiceCallback); process.nextTick(function() { console.log('kill pid %d', killMeTwice.pid); @@ -79,12 +81,14 @@ process.nextTick(function() { }); function killMeTwiceCallback(err, stdout, stderr) { - var diff = (new Date()) - startSleep3; + const diff = (new Date()) - startSleep3; // We should have already killed this process. Assert that the timeout still // works and that we are getting the proper callback parameters. assert.ok(err); assert.ok(err.killed); assert.strictEqual(err.signal, 'SIGTERM'); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); // the timeout should still be in effect console.log('\'sleep 3\' was already killed. Took %d ms', diff); @@ -96,6 +100,8 @@ exec('python -c "print 200000*\'C\'"', {maxBuffer: 1000}, function(err, stdout, stderr) { assert.ok(err); assert.ok(/maxBuffer/.test(err.message)); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, ''); }); diff --git a/test/pummel/test-fs-watch-file-slow.js b/test/pummel/test-fs-watch-file-slow.js index 508de487f6dc23..1e9b5eb1f219ff 100644 --- a/test/pummel/test-fs-watch-file-slow.js +++ b/test/pummel/test-fs-watch-file-slow.js @@ -1,13 +1,13 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); -var FILENAME = path.join(common.tmpDir, 'watch-me'); -var TIMEOUT = 1300; +const FILENAME = path.join(common.tmpDir, 'watch-me'); +const TIMEOUT = 1300; -var nevents = 0; +let nevents = 0; try { fs.unlinkSync(FILENAME); @@ -19,14 +19,14 @@ fs.watchFile(FILENAME, {interval: TIMEOUT - 250}, function(curr, prev) { console.log([curr, prev]); switch (++nevents) { case 1: - assert.equal(common.fileExists(FILENAME), false); + assert.strictEqual(common.fileExists(FILENAME), false); break; case 2: case 3: - assert.equal(common.fileExists(FILENAME), true); + assert.strictEqual(common.fileExists(FILENAME), true); break; case 4: - assert.equal(common.fileExists(FILENAME), false); + assert.strictEqual(common.fileExists(FILENAME), false); fs.unwatchFile(FILENAME); break; default: @@ -35,7 +35,7 @@ fs.watchFile(FILENAME, {interval: TIMEOUT - 250}, function(curr, prev) { }); process.on('exit', function() { - assert.equal(nevents, 4); + assert.strictEqual(nevents, 4); }); setTimeout(createFile, TIMEOUT); diff --git a/test/pummel/test-fs-watch-file.js b/test/pummel/test-fs-watch-file.js index 4e08e9e9d1cc9b..913f97737c8a54 100644 --- a/test/pummel/test-fs-watch-file.js +++ b/test/pummel/test-fs-watch-file.js @@ -1,36 +1,36 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); -var watchSeenOne = 0; -var watchSeenTwo = 0; -var watchSeenThree = 0; -var watchSeenFour = 0; +let watchSeenOne = 0; +let watchSeenTwo = 0; +let watchSeenThree = 0; +let watchSeenFour = 0; -var testDir = common.tmpDir; +const testDir = common.tmpDir; -var filenameOne = 'watch.txt'; -var filepathOne = path.join(testDir, filenameOne); +const filenameOne = 'watch.txt'; +const filepathOne = path.join(testDir, filenameOne); -var filenameTwo = 'hasOwnProperty'; -var filepathTwo = filenameTwo; -var filepathTwoAbs = path.join(testDir, filenameTwo); +const filenameTwo = 'hasOwnProperty'; +const filepathTwo = filenameTwo; +const filepathTwoAbs = path.join(testDir, filenameTwo); -var filenameThree = 'charm'; // because the third time is +const filenameThree = 'charm'; // because the third time is -var filenameFour = 'get'; +const filenameFour = 'get'; process.on('exit', function() { fs.unlinkSync(filepathOne); fs.unlinkSync(filepathTwoAbs); fs.unlinkSync(filenameThree); fs.unlinkSync(filenameFour); - assert.equal(1, watchSeenOne); - assert.equal(2, watchSeenTwo); - assert.equal(1, watchSeenThree); - assert.equal(1, watchSeenFour); + assert.strictEqual(1, watchSeenOne); + assert.strictEqual(2, watchSeenTwo); + assert.strictEqual(1, watchSeenThree); + assert.strictEqual(1, watchSeenFour); }); @@ -41,13 +41,13 @@ assert.throws( fs.watchFile(filepathOne); }, function(e) { - return e.message === 'watchFile requires a listener function'; + return e.message === '"watchFile()" requires a listener function'; } ); assert.doesNotThrow( function() { - fs.watchFile(filepathOne, function(curr, prev) { + fs.watchFile(filepathOne, function() { fs.unwatchFile(filepathOne); ++watchSeenOne; }); @@ -68,17 +68,17 @@ assert.throws( fs.watchFile(filepathTwo); }, function(e) { - return e.message === 'watchFile requires a listener function'; + return e.message === '"watchFile()" requires a listener function'; } ); assert.doesNotThrow( function() { - function a(curr, prev) { + function a() { fs.unwatchFile(filepathTwo, a); ++watchSeenTwo; } - function b(curr, prev) { + function b() { fs.unwatchFile(filepathTwo, b); ++watchSeenTwo; } @@ -93,16 +93,13 @@ setTimeout(function() { assert.doesNotThrow( function() { - function a(curr, prev) { - assert.ok(0); // should not run - } - function b(curr, prev) { + function b() { fs.unwatchFile(filenameThree, b); ++watchSeenThree; } - fs.watchFile(filenameThree, a); + fs.watchFile(filenameThree, common.fail); fs.watchFile(filenameThree, b); - fs.unwatchFile(filenameThree, a); + fs.unwatchFile(filenameThree, common.fail); } ); @@ -120,9 +117,9 @@ setTimeout(function() { assert.doesNotThrow( function() { - function a(curr, prev) { + function a() { ++watchSeenFour; - assert.equal(1, watchSeenFour); + assert.strictEqual(1, watchSeenFour); fs.unwatchFile('.' + path.sep + filenameFour, a); } fs.watchFile(filenameFour, a); diff --git a/test/pummel/test-fs-watch-non-recursive.js b/test/pummel/test-fs-watch-non-recursive.js index ead7de9e28dc47..b7c19b9c360818 100644 --- a/test/pummel/test-fs-watch-non-recursive.js +++ b/test/pummel/test-fs-watch-non-recursive.js @@ -1,11 +1,11 @@ 'use strict'; -var common = require('../common'); -var path = require('path'); -var fs = require('fs'); +const common = require('../common'); +const path = require('path'); +const fs = require('fs'); -var testDir = common.tmpDir; -var testsubdir = path.join(testDir, 'testsubdir'); -var filepath = path.join(testsubdir, 'watch.txt'); +const testDir = common.tmpDir; +const testsubdir = path.join(testDir, 'testsubdir'); +const filepath = path.join(testsubdir, 'watch.txt'); function cleanup() { try { fs.unlinkSync(filepath); } catch (e) { } @@ -18,7 +18,7 @@ try { fs.mkdirSync(testsubdir, 0o700); } catch (e) {} // Need a grace period, else the mkdirSync() above fires off an event. setTimeout(function() { - var watcher = fs.watch(testDir, { persistent: true }, common.fail); + const watcher = fs.watch(testDir, { persistent: true }, common.fail); setTimeout(function() { fs.writeFileSync(filepath, 'test'); }, 100); diff --git a/test/pummel/test-http-client-reconnect-bug.js b/test/pummel/test-http-client-reconnect-bug.js index 395a538178fe79..98d21c5cba7bc5 100644 --- a/test/pummel/test-http-client-reconnect-bug.js +++ b/test/pummel/test-http-client-reconnect-bug.js @@ -3,17 +3,17 @@ const common = require('../common'); const net = require('net'); const http = require('http'); -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { socket.end(); }); server.on('listening', common.mustCall(function() { - var client = http.createClient(common.PORT); + const client = http.createClient(common.PORT); client.on('error', common.mustCall(function(err) {})); client.on('end', common.mustCall(function() {})); - var request = client.request('GET', '/', {'host': 'localhost'}); + const request = client.request('GET', '/', {'host': 'localhost'}); request.end(); request.on('response', function(response) { console.log('STATUS: ' + response.statusCode); diff --git a/test/pummel/test-http-many-keep-alive-connections.js b/test/pummel/test-http-many-keep-alive-connections.js index 293c6ab748e9c2..ee616e1d918e66 100644 --- a/test/pummel/test-http-many-keep-alive-connections.js +++ b/test/pummel/test-http-many-keep-alive-connections.js @@ -1,16 +1,16 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var http = require('http'); +const common = require('../common'); +const assert = require('assert'); +const http = require('http'); -var expected = 10000; -var responses = 0; -var requests = 0; -var connection; +const expected = 10000; +let responses = 0; +let requests = 0; +let connection; -var server = http.Server(function(req, res) { +const server = http.Server(function(req, res) { requests++; - assert.equal(req.connection, connection); + assert.strictEqual(req.connection, connection); res.writeHead(200); res.end('hello world\n'); }); @@ -20,7 +20,7 @@ server.once('connection', function(c) { }); server.listen(common.PORT, function connect() { - var request = http.get({ + const request = http.get({ port: common.PORT, path: '/', headers: { @@ -43,6 +43,6 @@ server.listen(common.PORT, function connect() { }); process.on('exit', function() { - assert.equal(expected, responses); - assert.equal(expected, requests); + assert.strictEqual(expected, responses); + assert.strictEqual(expected, requests); }); diff --git a/test/pummel/test-http-upload-timeout.js b/test/pummel/test-http-upload-timeout.js index 15bc267ff61947..da91ab3f0909e7 100644 --- a/test/pummel/test-http-upload-timeout.js +++ b/test/pummel/test-http-upload-timeout.js @@ -24,18 +24,18 @@ server.on('request', function(req, res) { }); server.listen(common.PORT, '127.0.0.1', function() { - for (var i = 0; i < 10; i++) { + for (let i = 0; i < 10; i++) { connections++; setTimeout(function() { - var request = http.request({ + const request = http.request({ port: common.PORT, method: 'POST', path: '/' }); function ping() { - var nextPing = (Math.random() * 900).toFixed(); + const nextPing = (Math.random() * 900).toFixed(); if (nextPing > 600) { request.end(); return; diff --git a/test/pummel/test-https-ci-reneg-attack.js b/test/pummel/test-https-ci-reneg-attack.js index 8bda7cc10286e9..6113ee54ce904b 100644 --- a/test/pummel/test-https-ci-reneg-attack.js +++ b/test/pummel/test-https-ci-reneg-attack.js @@ -1,16 +1,16 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var https = require('https'); +const tls = require('tls'); +const https = require('https'); -var fs = require('fs'); +const fs = require('fs'); if (!common.opensslCli) { common.skip('node compiled without OpenSSL CLI.'); @@ -18,7 +18,7 @@ if (!common.opensslCli) { } // renegotiation limits to test -var LIMITS = [0, 1, 2, 3, 5, 10, 16]; +const LIMITS = [0, 1, 2, 3, 5, 10, 16]; { let n = 0; @@ -31,15 +31,15 @@ var LIMITS = [0, 1, 2, 3, 5, 10, 16]; } function test(next) { - var options = { + const options = { cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'), key: fs.readFileSync(common.fixturesDir + '/test_key.pem') }; - var seenError = false; + let seenError = false; - var server = https.createServer(options, function(req, res) { - var conn = req.connection; + const server = https.createServer(options, function(req, res) { + const conn = req.connection; conn.on('error', function(err) { console.error('Caught exception: ' + err); assert(/TLS session renegotiation attack/.test(err)); @@ -50,8 +50,8 @@ function test(next) { }); server.listen(common.PORT, function() { - var args = ('s_client -connect 127.0.0.1:' + common.PORT).split(' '); - var child = spawn(common.opensslCli, args); + const args = ('s_client -connect 127.0.0.1:' + common.PORT).split(' '); + const child = spawn(common.opensslCli, args); //child.stdout.pipe(process.stdout); //child.stderr.pipe(process.stderr); @@ -60,8 +60,8 @@ function test(next) { child.stderr.resume(); // count handshakes, start the attack after the initial handshake is done - var handshakes = 0; - var renegs = 0; + let handshakes = 0; + let renegs = 0; child.stderr.on('data', function(data) { if (seenError) return; @@ -71,19 +71,19 @@ function test(next) { }); child.on('exit', function() { - assert.equal(renegs, tls.CLIENT_RENEG_LIMIT + 1); + assert.strictEqual(renegs, tls.CLIENT_RENEG_LIMIT + 1); server.close(); process.nextTick(next); }); - var closed = false; + let closed = false; child.stdin.on('error', function(err) { switch (err.code) { case 'ECONNRESET': case 'EPIPE': break; default: - assert.equal(err.code, 'ECONNRESET'); + assert.strictEqual(err.code, 'ECONNRESET'); break; } closed = true; diff --git a/test/pummel/test-https-large-response.js b/test/pummel/test-https-large-response.js index a122e47bc57a57..39256aa6304b74 100644 --- a/test/pummel/test-https-large-response.js +++ b/test/pummel/test-https-large-response.js @@ -1,25 +1,25 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var fs = require('fs'); +const fs = require('fs'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; process.stdout.write('build body...'); -var body = 'hello world\n'.repeat(1024 * 1024); +const body = 'hello world\n'.repeat(1024 * 1024); process.stdout.write('done\n'); -var server = https.createServer(options, common.mustCall(function(req, res) { +const server = https.createServer(options, common.mustCall(function(req, res) { console.log('got request'); res.writeHead(200, { 'content-type': 'text/plain' }); res.end(body); @@ -32,7 +32,7 @@ server.listen(common.PORT, common.mustCall(function() { }, common.mustCall(function(res) { console.log('response!'); - var count = 0; + let count = 0; res.on('data', function(d) { process.stdout.write('.'); diff --git a/test/pummel/test-https-no-reader.js b/test/pummel/test-https-no-reader.js index fab59591993a69..a08676277af6ce 100644 --- a/test/pummel/test-https-no-reader.js +++ b/test/pummel/test-https-no-reader.js @@ -1,34 +1,34 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var Buffer = require('buffer').Buffer; -var fs = require('fs'); -var path = require('path'); +const Buffer = require('buffer').Buffer; +const fs = require('fs'); +const path = require('path'); -var options = { +const options = { key: fs.readFileSync(path.join(common.fixturesDir, 'test_key.pem')), cert: fs.readFileSync(path.join(common.fixturesDir, 'test_cert.pem')) }; -var buf = Buffer.allocUnsafe(1024 * 1024); +const buf = Buffer.allocUnsafe(1024 * 1024); -var server = https.createServer(options, function(req, res) { +const server = https.createServer(options, function(req, res) { res.writeHead(200); - for (var i = 0; i < 50; i++) { + for (let i = 0; i < 50; i++) { res.write(buf); } res.end(); }); server.listen(common.PORT, function() { - var req = https.request({ + const req = https.request({ method: 'POST', port: common.PORT, rejectUnauthorized: false diff --git a/test/pummel/test-keep-alive.js b/test/pummel/test-keep-alive.js index 1861b2df970e18..a9e91e201bb19b 100644 --- a/test/pummel/test-keep-alive.js +++ b/test/pummel/test-keep-alive.js @@ -1,19 +1,19 @@ 'use strict'; // This test requires the program 'wrk' -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; -var http = require('http'); -var url = require('url'); +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; +const http = require('http'); +const url = require('url'); if (common.isWindows) { common.skip('no `wrk` on windows'); return; } -var body = 'hello world\n'; -var server = http.createServer(function(req, res) { +const body = 'hello world\n'; +const server = http.createServer(function(req, res) { res.writeHead(200, { 'Content-Length': body.length, 'Content-Type': 'text/plain' @@ -22,12 +22,12 @@ var server = http.createServer(function(req, res) { res.end(); }); -var keepAliveReqSec = 0; -var normalReqSec = 0; +let keepAliveReqSec = 0; +let normalReqSec = 0; function runAb(opts, callback) { - var args = [ + const args = [ '-c', opts.concurrent || 100, '-t', opts.threads || 2, '-d', opts.duration || '10s', @@ -41,13 +41,11 @@ function runAb(opts, callback) { args.push(url.format({ hostname: '127.0.0.1', port: common.PORT, protocol: 'http'})); - //console.log(comm, args.join(' ')); - - var child = spawn('wrk', args); + const child = spawn('wrk', args); child.stderr.pipe(process.stderr); child.stdout.setEncoding('utf8'); - var stdout; + let stdout; child.stdout.on('data', function(data) { stdout += data; @@ -60,11 +58,11 @@ function runAb(opts, callback) { return; } - var matches = /Requests\/sec:\s*(\d+)\./mi.exec(stdout); - var reqSec = parseInt(matches[1]); + let matches = /Requests\/sec:\s*(\d+)\./mi.exec(stdout); + const reqSec = parseInt(matches[1]); matches = /Keep-Alive requests:\s*(\d+)/mi.exec(stdout); - var keepAliveRequests; + let keepAliveRequests; if (matches) { keepAliveRequests = parseInt(matches[1]); } else { @@ -75,21 +73,19 @@ function runAb(opts, callback) { }); } -server.listen(common.PORT, function() { - runAb({ keepalive: true }, function(reqSec) { +server.listen(common.PORT, () => { + runAb({ keepalive: true }, (reqSec) => { keepAliveReqSec = reqSec; - console.log('keep-alive:', keepAliveReqSec, 'req/sec'); runAb({ keepalive: false }, function(reqSec) { normalReqSec = reqSec; - console.log('normal:' + normalReqSec + ' req/sec'); server.close(); }); }); }); process.on('exit', function() { - assert.equal(true, normalReqSec > 50); - assert.equal(true, keepAliveReqSec > 50); - assert.equal(true, normalReqSec < keepAliveReqSec); + assert.strictEqual(true, normalReqSec > 50); + assert.strictEqual(true, keepAliveReqSec > 50); + assert.strictEqual(true, normalReqSec < keepAliveReqSec); }); diff --git a/test/pummel/test-net-connect-econnrefused.js b/test/pummel/test-net-connect-econnrefused.js index 2b6dc84f37195c..4ac55da40553e0 100644 --- a/test/pummel/test-net-connect-econnrefused.js +++ b/test/pummel/test-net-connect-econnrefused.js @@ -1,23 +1,24 @@ 'use strict'; // verify that connect reqs are properly cleaned up -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); -var ROUNDS = 10; -var ATTEMPTS_PER_ROUND = 100; -var rounds = 1; -var reqs = 0; +const ROUNDS = 10; +const ATTEMPTS_PER_ROUND = 100; +let rounds = 1; +let reqs = 0; pummel(); function pummel() { console.log('Round', rounds, '/', ROUNDS); - for (var pending = 0; pending < ATTEMPTS_PER_ROUND; pending++) { + let pending; + for (pending = 0; pending < ATTEMPTS_PER_ROUND; pending++) { net.createConnection(common.PORT).on('error', function(err) { - assert.equal(err.code, 'ECONNREFUSED'); + assert.strictEqual(err.code, 'ECONNREFUSED'); if (--pending > 0) return; if (rounds === ROUNDS) return check(); rounds++; @@ -29,15 +30,15 @@ function pummel() { function check() { setTimeout(function() { - assert.equal(process._getActiveRequests().length, 0); - assert.equal(process._getActiveHandles().length, 1); // the timer + assert.strictEqual(process._getActiveRequests().length, 0); + assert.strictEqual(process._getActiveHandles().length, 1); // the timer check_called = true; }, 0); } -var check_called = false; +let check_called = false; process.on('exit', function() { - assert.equal(rounds, ROUNDS); - assert.equal(reqs, ROUNDS * ATTEMPTS_PER_ROUND); + assert.strictEqual(rounds, ROUNDS); + assert.strictEqual(reqs, ROUNDS * ATTEMPTS_PER_ROUND); assert(check_called); }); diff --git a/test/pummel/test-net-connect-memleak.js b/test/pummel/test-net-connect-memleak.js index 3b91a110eaa585..f16034e4773510 100644 --- a/test/pummel/test-net-connect-memleak.js +++ b/test/pummel/test-net-connect-memleak.js @@ -1,9 +1,9 @@ 'use strict'; // Flags: --expose-gc -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); assert.strictEqual( typeof global.gc, @@ -12,7 +12,7 @@ assert.strictEqual( ); net.createServer(function() {}).listen(common.PORT); -var before = 0; +let before = 0; { // 2**26 == 64M entries global.gc(); @@ -29,8 +29,8 @@ var before = 0; function done() { global.gc(); - var after = process.memoryUsage().rss; - var reclaimed = (before - after) / 1024; + const after = process.memoryUsage().rss; + const reclaimed = (before - after) / 1024; console.log('%d kB reclaimed', reclaimed); assert(reclaimed > 128 * 1024); // It's around 256 MB on x64. process.exit(); diff --git a/test/pummel/test-net-many-clients.js b/test/pummel/test-net-many-clients.js index 52d05b35cbe2c4..fdcdf1198f8df2 100644 --- a/test/pummel/test-net-many-clients.js +++ b/test/pummel/test-net-many-clients.js @@ -1,19 +1,19 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); // settings -var bytes = 1024 * 40; -var concurrency = 100; -var connections_per_client = 5; +const bytes = 1024 * 40; +const concurrency = 100; +const connections_per_client = 5; // measured -var total_connections = 0; +let total_connections = 0; -var body = 'C'.repeat(bytes); +const body = 'C'.repeat(bytes); -var server = net.createServer(function(c) { +const server = net.createServer(function(c) { console.log('connected'); total_connections++; console.log('#'); @@ -22,7 +22,7 @@ var server = net.createServer(function(c) { }); function runClient(callback) { - var client = net.createConnection(common.PORT); + const client = net.createConnection(common.PORT); client.connections = 0; @@ -49,8 +49,8 @@ function runClient(callback) { client.on('close', function(had_error) { console.log('.'); - assert.equal(false, had_error); - assert.equal(bytes, client.recved.length); + assert.strictEqual(false, had_error); + assert.strictEqual(bytes, client.recved.length); if (client.fd) { console.log(client.fd); @@ -66,8 +66,8 @@ function runClient(callback) { } server.listen(common.PORT, function() { - var finished_clients = 0; - for (var i = 0; i < concurrency; i++) { + let finished_clients = 0; + for (let i = 0; i < concurrency; i++) { runClient(function() { if (++finished_clients === concurrency) server.close(); }); @@ -75,6 +75,6 @@ server.listen(common.PORT, function() { }); process.on('exit', function() { - assert.equal(connections_per_client * concurrency, total_connections); + assert.strictEqual(connections_per_client * concurrency, total_connections); console.log('\nokay!'); }); diff --git a/test/pummel/test-net-pause.js b/test/pummel/test-net-pause.js index b0c51260436e0c..6a701d56869afb 100644 --- a/test/pummel/test-net-pause.js +++ b/test/pummel/test-net-pause.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); -var N = 200; -var recv = '', chars_recved = 0; +const N = 200; +let recv = '', chars_recved = 0; -var server = net.createServer(function(connection) { +const server = net.createServer(function(connection) { function write(j) { if (j >= N) { connection.end(); @@ -21,7 +21,7 @@ var server = net.createServer(function(connection) { }); server.on('listening', function() { - var client = net.createConnection(common.PORT); + const client = net.createConnection(common.PORT); client.setEncoding('ascii'); client.on('data', function(d) { console.log(d); @@ -31,11 +31,11 @@ server.on('listening', function() { setTimeout(function() { chars_recved = recv.length; console.log('pause at: ' + chars_recved); - assert.equal(true, chars_recved > 1); + assert.strictEqual(true, chars_recved > 1); client.pause(); setTimeout(function() { console.log('resume at: ' + chars_recved); - assert.equal(chars_recved, recv.length); + assert.strictEqual(chars_recved, recv.length); client.resume(); setTimeout(function() { @@ -45,7 +45,7 @@ server.on('listening', function() { setTimeout(function() { console.log('resume at: ' + chars_recved); - assert.equal(chars_recved, recv.length); + assert.strictEqual(chars_recved, recv.length); client.resume(); }, 500); @@ -64,6 +64,6 @@ server.on('listening', function() { server.listen(common.PORT); process.on('exit', function() { - assert.equal(N, recv.length); + assert.strictEqual(N, recv.length); console.error('Exit'); }); diff --git a/test/pummel/test-net-pingpong-delay.js b/test/pummel/test-net-pingpong-delay.js index c9cac778d59f4e..2236ba83a88f02 100644 --- a/test/pummel/test-net-pingpong-delay.js +++ b/test/pummel/test-net-pingpong-delay.js @@ -1,64 +1,64 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); function pingPongTest(port, host, on_complete) { - var N = 100; - var DELAY = 1; - var count = 0; - var client_ended = false; + const N = 100; + const DELAY = 1; + let count = 0; + let client_ended = false; - var server = net.createServer({ allowHalfOpen: true }, function(socket) { + const server = net.createServer({ allowHalfOpen: true }, function(socket) { socket.setEncoding('utf8'); socket.on('data', function(data) { console.log(data); - assert.equal('PING', data); - assert.equal('open', socket.readyState); - assert.equal(true, count <= N); + assert.strictEqual('PING', data); + assert.strictEqual('open', socket.readyState); + assert.strictEqual(true, count <= N); setTimeout(function() { - assert.equal('open', socket.readyState); + assert.strictEqual('open', socket.readyState); socket.write('PONG'); }, DELAY); }); socket.on('timeout', function() { console.error('server-side timeout!!'); - assert.equal(false, true); + assert.strictEqual(false, true); }); socket.on('end', function() { console.log('server-side socket EOF'); - assert.equal('writeOnly', socket.readyState); + assert.strictEqual('writeOnly', socket.readyState); socket.end(); }); socket.on('close', function(had_error) { console.log('server-side socket.end'); - assert.equal(false, had_error); - assert.equal('closed', socket.readyState); + assert.strictEqual(false, had_error); + assert.strictEqual('closed', socket.readyState); socket.server.close(); }); }); server.listen(port, host, common.mustCall(function() { - var client = net.createConnection(port, host); + const client = net.createConnection(port, host); client.setEncoding('utf8'); client.on('connect', function() { - assert.equal('open', client.readyState); + assert.strictEqual('open', client.readyState); client.write('PING'); }); client.on('data', function(data) { console.log(data); - assert.equal('PONG', data); - assert.equal('open', client.readyState); + assert.strictEqual('PONG', data); + assert.strictEqual('open', client.readyState); setTimeout(function() { - assert.equal('open', client.readyState); + assert.strictEqual('open', client.readyState); if (count++ < N) { client.write('PING'); } else { @@ -71,12 +71,12 @@ function pingPongTest(port, host, on_complete) { client.on('timeout', function() { console.error('client-side timeout!!'); - assert.equal(false, true); + assert.strictEqual(false, true); }); client.on('close', common.mustCall(function() { console.log('client.end'); - assert.equal(N + 1, count); + assert.strictEqual(N + 1, count); assert.ok(client_ended); if (on_complete) on_complete(); })); diff --git a/test/pummel/test-net-pingpong.js b/test/pummel/test-net-pingpong.js index 85dce02b6cf635..5e0950285739a1 100644 --- a/test/pummel/test-net-pingpong.js +++ b/test/pummel/test-net-pingpong.js @@ -1,26 +1,26 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); -var tests_run = 0; +let tests_run = 0; function pingPongTest(port, host, on_complete) { - var N = 1000; - var count = 0; - var sent_final_ping = false; - - var server = net.createServer({ allowHalfOpen: true }, function(socket) { - assert.equal(true, socket.remoteAddress !== null); - assert.equal(true, socket.remoteAddress !== undefined); - var address = socket.remoteAddress; + const N = 1000; + let count = 0; + let sent_final_ping = false; + + const server = net.createServer({ allowHalfOpen: true }, function(socket) { + assert.strictEqual(true, socket.remoteAddress !== null); + assert.strictEqual(true, socket.remoteAddress !== undefined); + const address = socket.remoteAddress; if (host === '127.0.0.1') { - assert.equal(address, '127.0.0.1'); + assert.strictEqual(address, '127.0.0.1'); } else if (host == null || host === 'localhost') { assert(address === '127.0.0.1' || address === '::ffff:127.0.0.1'); } else { console.log('host = ' + host + ', remoteAddress = ' + address); - assert.equal(address, '::1'); + assert.strictEqual(address, '::1'); } socket.setEncoding('utf8'); @@ -29,46 +29,46 @@ function pingPongTest(port, host, on_complete) { socket.on('data', function(data) { console.log('server got: ' + JSON.stringify(data)); - assert.equal('open', socket.readyState); - assert.equal(true, count <= N); + assert.strictEqual('open', socket.readyState); + assert.strictEqual(true, count <= N); if (/PING/.exec(data)) { socket.write('PONG'); } }); socket.on('end', function() { - assert.equal('writeOnly', socket.readyState); + assert.strictEqual('writeOnly', socket.readyState); socket.end(); }); socket.on('close', function(had_error) { - assert.equal(false, had_error); - assert.equal('closed', socket.readyState); + assert.strictEqual(false, had_error); + assert.strictEqual('closed', socket.readyState); socket.server.close(); }); }); server.listen(port, host, function() { - var client = net.createConnection(port, host); + const client = net.createConnection(port, host); client.setEncoding('utf8'); client.on('connect', function() { - assert.equal('open', client.readyState); + assert.strictEqual('open', client.readyState); client.write('PING'); }); client.on('data', function(data) { console.log('client got: ' + data); - assert.equal('PONG', data); + assert.strictEqual('PONG', data); count += 1; if (sent_final_ping) { - assert.equal('readOnly', client.readyState); + assert.strictEqual('readOnly', client.readyState); return; } else { - assert.equal('open', client.readyState); + assert.strictEqual('open', client.readyState); } if (count < N) { @@ -81,8 +81,8 @@ function pingPongTest(port, host, on_complete) { }); client.on('close', function() { - assert.equal(N + 1, count); - assert.equal(true, sent_final_ping); + assert.strictEqual(N + 1, count); + assert.strictEqual(true, sent_final_ping); if (on_complete) on_complete(); tests_run += 1; }); @@ -97,5 +97,5 @@ pingPongTest(common.PORT + 1, null); if (!common.isSunOS) pingPongTest(common.PORT + 2, '::1'); process.on('exit', function() { - assert.equal(common.isSunOS ? 2 : 3, tests_run); + assert.strictEqual(common.isSunOS ? 2 : 3, tests_run); }); diff --git a/test/pummel/test-net-throttle.js b/test/pummel/test-net-throttle.js index d2f32ec25b6ff2..c222d0bb17ccfa 100644 --- a/test/pummel/test-net-throttle.js +++ b/test/pummel/test-net-throttle.js @@ -5,18 +5,18 @@ const net = require('net'); const N = 1024 * 1024; const part_N = N / 3; -var chars_recved = 0; -var npauses = 0; +let chars_recved = 0; +let npauses = 0; console.log('build big string'); const body = 'C'.repeat(N); console.log('start server on port ' + common.PORT); -var server = net.createServer(function(connection) { +const server = net.createServer(function(connection) { connection.write(body.slice(0, part_N)); connection.write(body.slice(part_N, 2 * part_N)); - assert.equal(false, connection.write(body.slice(2 * part_N, N))); + assert.strictEqual(false, connection.write(body.slice(2 * part_N, N))); console.log('bufferSize: ' + connection.bufferSize, 'expecting', N); assert.ok(0 <= connection.bufferSize && connection._writableState.length <= N); @@ -24,8 +24,8 @@ var server = net.createServer(function(connection) { }); server.listen(common.PORT, function() { - var paused = false; - var client = net.createConnection(common.PORT); + let paused = false; + const client = net.createConnection(common.PORT); client.setEncoding('ascii'); client.on('data', function(d) { chars_recved += d.length; @@ -35,9 +35,9 @@ server.listen(common.PORT, function() { npauses += 1; paused = true; console.log('pause'); - var x = chars_recved; + const x = chars_recved; setTimeout(function() { - assert.equal(chars_recved, x); + assert.strictEqual(chars_recved, x); client.resume(); console.log('resume'); paused = false; @@ -53,6 +53,6 @@ server.listen(common.PORT, function() { process.on('exit', function() { - assert.equal(N, chars_recved); - assert.equal(true, npauses > 2); + assert.strictEqual(N, chars_recved); + assert.strictEqual(true, npauses > 2); }); diff --git a/test/pummel/test-net-timeout.js b/test/pummel/test-net-timeout.js index 415523763eef3c..faec443a007f20 100644 --- a/test/pummel/test-net-timeout.js +++ b/test/pummel/test-net-timeout.js @@ -1,14 +1,14 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var net = require('net'); +const common = require('../common'); +const assert = require('assert'); +const net = require('net'); -var exchanges = 0; -var starttime = null; -var timeouttime = null; -var timeout = 1000; +let exchanges = 0; +let starttime = null; +let timeouttime = null; +const timeout = 1000; -var echo_server = net.createServer(function(socket) { +const echo_server = net.createServer(function(socket) { socket.setTimeout(timeout); socket.on('timeout', function() { @@ -36,7 +36,7 @@ var echo_server = net.createServer(function(socket) { echo_server.listen(common.PORT, function() { console.log('server listening at ' + common.PORT); - var client = net.createConnection(common.PORT); + const client = net.createConnection(common.PORT); client.setEncoding('UTF8'); client.setTimeout(0); // disable the timeout for client client.on('connect', function() { @@ -45,7 +45,7 @@ echo_server.listen(common.PORT, function() { }); client.on('data', function(chunk) { - assert.equal('hello\r\n', chunk); + assert.strictEqual('hello\r\n', chunk); if (exchanges++ < 5) { setTimeout(function() { console.log('client write "hello"'); @@ -79,7 +79,7 @@ process.on('exit', function() { assert.ok(starttime != null); assert.ok(timeouttime != null); - var diff = timeouttime - starttime; + const diff = timeouttime - starttime; console.log('diff = ' + diff); assert.ok(timeout < diff); diff --git a/test/pummel/test-net-timeout2.js b/test/pummel/test-net-timeout2.js index 7af47a47a8b634..a3d0abceb6c765 100644 --- a/test/pummel/test-net-timeout2.js +++ b/test/pummel/test-net-timeout2.js @@ -2,16 +2,16 @@ // socket.write was not resetting the timeout timer. See // https://github.com/joyent/node/issues/2002 -var common = require('../common'); -var net = require('net'); +const common = require('../common'); +const net = require('net'); -var seconds = 5; -var counter = 0; +const seconds = 5; +let counter = 0; -var server = net.createServer(function(socket) { +const server = net.createServer(function(socket) { socket.setTimeout((seconds / 2) * 1000, common.fail); - var interval = setInterval(function() { + const interval = setInterval(function() { counter++; if (counter === seconds) { @@ -28,6 +28,6 @@ var server = net.createServer(function(socket) { server.listen(common.PORT, function() { - var s = net.connect(common.PORT); + const s = net.connect(common.PORT); s.pipe(process.stdout); }); diff --git a/test/pummel/test-net-write-callbacks.js b/test/pummel/test-net-write-callbacks.js index 21eae0f5ab72d0..b29ae6ef808292 100644 --- a/test/pummel/test-net-write-callbacks.js +++ b/test/pummel/test-net-write-callbacks.js @@ -1,12 +1,12 @@ 'use strict'; -var common = require('../common'); -var net = require('net'); -var assert = require('assert'); +const common = require('../common'); +const net = require('net'); +const assert = require('assert'); -var cbcount = 0; -var N = 500000; +let cbcount = 0; +const N = 500000; -var server = net.Server(function(socket) { +const server = net.Server(function(socket) { socket.on('data', function(d) { console.error('got %d bytes', d.length); }); @@ -18,9 +18,9 @@ var server = net.Server(function(socket) { }); }); -var lastCalled = -1; +let lastCalled = -1; function makeCallback(c) { - var called = false; + let called = false; return function() { if (called) throw new Error('called callback #' + c + ' more than once'); @@ -34,10 +34,10 @@ function makeCallback(c) { } server.listen(common.PORT, function() { - var client = net.createConnection(common.PORT); + const client = net.createConnection(common.PORT); client.on('connect', function() { - for (var i = 0; i < N; i++) { + for (let i = 0; i < N; i++) { client.write('hello world', makeCallback(i)); } client.end(); @@ -45,5 +45,5 @@ server.listen(common.PORT, function() { }); process.on('exit', function() { - assert.equal(N, cbcount); + assert.strictEqual(N, cbcount); }); diff --git a/test/pummel/test-next-tick-infinite-calls.js b/test/pummel/test-next-tick-infinite-calls.js index 18223885d6cc19..afce6ef846b10f 100644 --- a/test/pummel/test-next-tick-infinite-calls.js +++ b/test/pummel/test-next-tick-infinite-calls.js @@ -1,7 +1,7 @@ 'use strict'; require('../common'); -var complete = 0; +let complete = 0; // This will fail with: // FATAL ERROR: JS Allocation failed - process out of memory diff --git a/test/pummel/test-process-hrtime.js b/test/pummel/test-process-hrtime.js index 04225bae421b1a..d02b9c79822a88 100644 --- a/test/pummel/test-process-hrtime.js +++ b/test/pummel/test-process-hrtime.js @@ -1,18 +1,18 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var start = process.hrtime(); +const start = process.hrtime(); // process.hrtime() should return an Array assert(Array.isArray(start)); // busy-loop for 2 seconds -var now = Date.now(); +const now = Date.now(); while (Date.now() - now < 2000); // get a diff reading -var diff = process.hrtime(start); +const diff = process.hrtime(start); // should be at least 1 second, at most 2 seconds later // (the while loop will usually exit a few nanoseconds before 2) diff --git a/test/pummel/test-process-uptime.js b/test/pummel/test-process-uptime.js index 8d2d88b74f736f..5c09d59b06d55c 100644 --- a/test/pummel/test-process-uptime.js +++ b/test/pummel/test-process-uptime.js @@ -1,14 +1,14 @@ 'use strict'; require('../common'); -var assert = require('assert'); +const assert = require('assert'); console.error(process.uptime()); assert.ok(process.uptime() <= 2); -var original = process.uptime(); +const original = process.uptime(); setTimeout(function() { - var uptime = process.uptime(); + const uptime = process.uptime(); // some wiggle room to account for timer // granularity, processor speed, and scheduling assert.ok(uptime >= original + 2); diff --git a/test/pummel/test-regress-GH-814.js b/test/pummel/test-regress-GH-814.js index 7bbd13dd196457..20323360debfe3 100644 --- a/test/pummel/test-regress-GH-814.js +++ b/test/pummel/test-regress-GH-814.js @@ -2,9 +2,10 @@ // Flags: --expose_gc const common = require('../common'); +const assert = require('assert'); function newBuffer(size, value) { - var buffer = Buffer.allocUnsafe(size); + const buffer = Buffer.allocUnsafe(size); while (size--) { buffer[size] = value; } @@ -13,19 +14,19 @@ function newBuffer(size, value) { return buffer; } -var fs = require('fs'); -var testFileName = require('path').join(common.tmpDir, 'GH-814_testFile.txt'); -var testFileFD = fs.openSync(testFileName, 'w'); +const fs = require('fs'); +const testFileName = require('path').join(common.tmpDir, 'GH-814_testFile.txt'); +const testFileFD = fs.openSync(testFileName, 'w'); console.log(testFileName); -var kBufSize = 128 * 1024; -var PASS = true; -var neverWrittenBuffer = newBuffer(kBufSize, 0x2e); //0x2e === '.' -var bufPool = []; +const kBufSize = 128 * 1024; +let PASS = true; +const neverWrittenBuffer = newBuffer(kBufSize, 0x2e); //0x2e === '.' +const bufPool = []; -var tail = require('child_process').spawn('tail', ['-f', testFileName]); +const tail = require('child_process').spawn('tail', ['-f', testFileName]); tail.stdout.on('data', tailCB); function tailCB(data) { @@ -33,13 +34,13 @@ function tailCB(data) { } -var timeToQuit = Date.now() + 8e3; //Test during no more than this seconds. +const timeToQuit = Date.now() + 8e3; //Test during no more than this seconds. (function main() { if (PASS) { fs.write(testFileFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, cb); global.gc(); - var nuBuf = Buffer.allocUnsafe(kBufSize); + const nuBuf = Buffer.allocUnsafe(kBufSize); neverWrittenBuffer.copy(nuBuf); if (bufPool.push(nuBuf) > 100) { bufPool.length = 0; @@ -59,7 +60,5 @@ var timeToQuit = Date.now() + 8e3; //Test during no more than this seconds. function cb(err, written) { - if (err) { - throw err; - } + assert.ifError(err); } diff --git a/test/pummel/test-regress-GH-814_2.js b/test/pummel/test-regress-GH-814_2.js index 7909a461f37956..233e8530459545 100644 --- a/test/pummel/test-regress-GH-814_2.js +++ b/test/pummel/test-regress-GH-814_2.js @@ -1,15 +1,16 @@ 'use strict'; // Flags: --expose_gc -var common = require('../common'); +const common = require('../common'); +const assert = require('assert'); -var fs = require('fs'); -var testFileName = require('path').join(common.tmpDir, 'GH-814_test.txt'); -var testFD = fs.openSync(testFileName, 'w'); +const fs = require('fs'); +const testFileName = require('path').join(common.tmpDir, 'GH-814_test.txt'); +const testFD = fs.openSync(testFileName, 'w'); console.error(testFileName + '\n'); -var tailProc = require('child_process').spawn('tail', ['-f', testFileName]); +const tailProc = require('child_process').spawn('tail', ['-f', testFileName]); tailProc.stdout.on('data', tailCB); function tailCB(data) { @@ -26,12 +27,12 @@ function tailCB(data) { } -var PASS = true; -var bufPool = []; -var kBufSize = 16 * 1024 * 1024; -var neverWrittenBuffer = newBuffer(kBufSize, 0x2e); //0x2e === '.' +let PASS = true; +const bufPool = []; +const kBufSize = 16 * 1024 * 1024; +const neverWrittenBuffer = newBuffer(kBufSize, 0x2e); //0x2e === '.' -var timeToQuit = Date.now() + 5e3; //Test should last no more than this. +const timeToQuit = Date.now() + 5e3; //Test should last no more than this. writer(); function writer() { @@ -50,7 +51,7 @@ function writer() { global.gc(); global.gc(); global.gc(); - var nuBuf = Buffer.allocUnsafe(kBufSize); + const nuBuf = Buffer.allocUnsafe(kBufSize); neverWrittenBuffer.copy(nuBuf); if (bufPool.push(nuBuf) > 100) { bufPool.length = 0; @@ -64,9 +65,7 @@ function writer() { function writerCB(err, written) { //console.error('cb.'); - if (err) { - throw err; - } + assert.ifError(err); } @@ -74,7 +73,7 @@ function writerCB(err, written) { function newBuffer(size, value) { - var buffer = Buffer.allocUnsafe(size); + const buffer = Buffer.allocUnsafe(size); while (size--) { buffer[size] = value; } diff --git a/test/pummel/test-regress-GH-892.js b/test/pummel/test-regress-GH-892.js index 8bbf3c8f1a0ff4..3ec44dfa12bb5b 100644 --- a/test/pummel/test-regress-GH-892.js +++ b/test/pummel/test-regress-GH-892.js @@ -5,43 +5,44 @@ // to POST a 32mb file to us. A bug in the pause/resume functionality of the // TLS server causes the child process to exit cleanly before having sent // the entire buffer. -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var https = require('https'); +const https = require('https'); -var fs = require('fs'); +const fs = require('fs'); -var bytesExpected = 1024 * 1024 * 32; +const bytesExpected = 1024 * 1024 * 32; -var started = false; +let started = false; -var childScript = require('path').join(common.fixturesDir, 'GH-892-request.js'); +const childScript = require('path').join(common.fixturesDir, + 'GH-892-request.js'); function makeRequest() { if (started) return; started = true; - var stderrBuffer = ''; + let stderrBuffer = ''; // Pass along --trace-deprecation/--throw-deprecation in // process.execArgv to track down nextTick recursion errors // more easily. Also, this is handy when using this test to // view V8 opt/deopt behavior. - var args = process.execArgv.concat([ childScript, - common.PORT, - bytesExpected ]); + const args = process.execArgv.concat([ childScript, + common.PORT, + bytesExpected ]); - var child = spawn(process.execPath, args); + const child = spawn(process.execPath, args); child.on('exit', function(code) { assert.ok(/DONE/.test(stderrBuffer)); - assert.equal(0, code); + assert.strictEqual(0, code); }); // The following two lines forward the stdio from the child @@ -58,14 +59,14 @@ function makeRequest() { } -var serverOptions = { +const serverOptions = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; -var uploadCount = 0; +let uploadCount = 0; -var server = https.Server(serverOptions, function(req, res) { +const server = https.Server(serverOptions, function(req, res) { // Close the server immediately. This test is only doing a single upload. // We need to make sure the server isn't keeping the event loop alive // while the upload is in progress. @@ -77,7 +78,7 @@ var server = https.Server(serverOptions, function(req, res) { }); req.on('end', function() { - assert.equal(bytesExpected, uploadCount); + assert.strictEqual(bytesExpected, uploadCount); res.writeHead(200, {'content-type': 'text/plain'}); res.end('successful upload\n'); }); @@ -90,5 +91,5 @@ server.listen(common.PORT, function() { process.on('exit', function() { console.error('got %d bytes', uploadCount); - assert.equal(uploadCount, bytesExpected); + assert.strictEqual(uploadCount, bytesExpected); }); diff --git a/test/pummel/test-stream-pipe-multi.js b/test/pummel/test-stream-pipe-multi.js index 897b9d6dc27d46..478b61c822d4e0 100644 --- a/test/pummel/test-stream-pipe-multi.js +++ b/test/pummel/test-stream-pipe-multi.js @@ -3,16 +3,16 @@ // doesn't break anything. require('../common'); -var assert = require('assert'); -var Stream = require('stream').Stream; -var rr = []; -var ww = []; -var cnt = 100; -var chunks = 1000; -var chunkSize = 250; -var data = Buffer.allocUnsafe(chunkSize); -var wclosed = 0; -var rclosed = 0; +const assert = require('assert'); +const Stream = require('stream').Stream; +const rr = []; +const ww = []; +const cnt = 100; +const chunks = 1000; +const chunkSize = 250; +const data = Buffer.allocUnsafe(chunkSize); +let wclosed = 0; +let rclosed = 0; function FakeStream() { Stream.apply(this); @@ -45,8 +45,8 @@ FakeStream.prototype.close = function() { // expect all streams to close properly. process.on('exit', function() { - assert.equal(cnt, wclosed, 'writable streams closed'); - assert.equal(cnt, rclosed, 'readable streams closed'); + assert.strictEqual(cnt, wclosed, 'writable streams closed'); + assert.strictEqual(cnt, rclosed, 'readable streams closed'); }); for (let i = 0; i < chunkSize; i++) { @@ -54,14 +54,14 @@ for (let i = 0; i < chunkSize; i++) { } for (let i = 0; i < cnt; i++) { - var r = new FakeStream(); + const r = new FakeStream(); r.on('close', function() { console.error(this.ID, 'read close'); rclosed++; }); rr.push(r); - var w = new FakeStream(); + const w = new FakeStream(); w.on('close', function() { console.error(this.ID, 'write close'); wclosed++; @@ -75,8 +75,8 @@ for (let i = 0; i < cnt; i++) { // now start passing through data // simulate a relatively fast async stream. rr.forEach(function(r) { - var cnt = chunks; - var paused = false; + let cnt = chunks; + let paused = false; r.on('pause', function() { paused = true; diff --git a/test/pummel/test-stream2-basic.js b/test/pummel/test-stream2-basic.js index 6bb2386b0b17dc..0e2bf3e8e302ce 100644 --- a/test/pummel/test-stream2-basic.js +++ b/test/pummel/test-stream2-basic.js @@ -1,10 +1,10 @@ 'use strict'; require('../common'); -var R = require('_stream_readable'); -var assert = require('assert'); +const R = require('_stream_readable'); +const assert = require('assert'); -var util = require('util'); -var EE = require('events').EventEmitter; +const util = require('util'); +const EE = require('events').EventEmitter; function TestReader(n) { R.apply(this); @@ -16,9 +16,9 @@ function TestReader(n) { util.inherits(TestReader, R); TestReader.prototype._read = function(n) { - var max = this._buffer.length - this._pos; + const max = this._buffer.length - this._pos; n = Math.max(n, 0); - var toRead = Math.min(n, max); + const toRead = Math.min(n, max); if (toRead === 0) { // simulate the read buffer filling up with some more bytes some time // in the future. @@ -39,7 +39,7 @@ TestReader.prototype._read = function(n) { return; } - var ret = this._buffer.slice(this._pos, this._pos + toRead); + const ret = this._buffer.slice(this._pos, this._pos + toRead); this._pos += toRead; this.push(ret); }; @@ -68,8 +68,8 @@ TestWriter.prototype.end = function(c) { //////// // tiny node-tap lookalike. -var tests = []; -var count = 0; +const tests = []; +let count = 0; function test(name, fn) { count++; @@ -77,17 +77,17 @@ function test(name, fn) { } function run() { - var next = tests.shift(); + const next = tests.shift(); if (!next) return console.error('ok'); - var name = next[0]; - var fn = next[1]; + const name = next[0]; + const fn = next[1]; console.log('# %s', name); fn({ same: assert.deepStrictEqual, ok: assert, - equal: assert.equal, + equal: assert.strictEqual, end: function() { count--; run(); @@ -97,41 +97,41 @@ function run() { // ensure all tests have run process.on('exit', function() { - assert.equal(count, 0); + assert.strictEqual(count, 0); }); process.nextTick(run); test('a most basic test', function(t) { - var r = new TestReader(20); - - var reads = []; - var expect = [ 'x', - 'xx', - 'xxx', - 'xxxx', - 'xxxxx', - 'xxxxxxxxx', - 'xxxxxxxxxx', - 'xxxxxxxxxxxx', - 'xxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxxxxxxxxxx', - 'xxxxxxxxxxxxxxxxxxxxx' ]; + const r = new TestReader(20); + + const reads = []; + const expect = [ 'x', + 'xx', + 'xxx', + 'xxxx', + 'xxxxx', + 'xxxxxxxxx', + 'xxxxxxxxxx', + 'xxxxxxxxxxxx', + 'xxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxxxxxxxxxx', + 'xxxxxxxxxxxxxxxxxxxxx' ]; r.on('end', function() { t.same(reads, expect); t.end(); }); - var readSize = 1; + let readSize = 1; function flow() { - var res; + let res; while (null !== (res = r.read(readSize++))) { reads.push(res.toString()); } @@ -142,20 +142,20 @@ test('a most basic test', function(t) { }); test('pipe', function(t) { - var r = new TestReader(5); + const r = new TestReader(5); - var expect = [ 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx' ]; + const expect = [ 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx' ]; - var w = new TestWriter(); + const w = new TestWriter(); w.on('end', function(received) { t.same(received, expect); @@ -168,10 +168,10 @@ test('pipe', function(t) { [1, 2, 3, 4, 5, 6, 7, 8, 9].forEach(function(SPLIT) { test('unpipe', function(t) { - var r = new TestReader(5); + const r = new TestReader(5); // unpipe after 3 writes, then write to another stream instead. - var expect = [ 'xxxxx', + let expect = [ 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', @@ -183,9 +183,9 @@ test('pipe', function(t) { 'xxxxx' ]; expect = [ expect.slice(0, SPLIT), expect.slice(SPLIT) ]; - var w = [ new TestWriter(), new TestWriter() ]; + const w = [ new TestWriter(), new TestWriter() ]; - var writes = SPLIT; + let writes = SPLIT; w[0].on('write', function() { if (--writes === 0) { r.unpipe(); @@ -196,10 +196,10 @@ test('pipe', function(t) { } }); - var ended = 0; + let ended = 0; - var ended0 = false; - var ended1 = false; + let ended0 = false; + let ended1 = false; w[0].on('end', function(results) { t.equal(ended0, false); ended0 = true; @@ -223,21 +223,21 @@ test('pipe', function(t) { // both writers should get the same exact data. test('multipipe', function(t) { - var r = new TestReader(5); - var w = [ new TestWriter(), new TestWriter() ]; - - var expect = [ 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx', - 'xxxxx' ]; - - var c = 2; + const r = new TestReader(5); + const w = [ new TestWriter(), new TestWriter() ]; + + const expect = [ 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx', + 'xxxxx' ]; + + let c = 2; w[0].on('end', function(received) { t.same(received, expect, 'first'); if (--c === 0) t.end(); @@ -254,10 +254,10 @@ test('multipipe', function(t) { [1, 2, 3, 4, 5, 6, 7, 8, 9].forEach(function(SPLIT) { test('multi-unpipe', function(t) { - var r = new TestReader(5); + const r = new TestReader(5); // unpipe after 3 writes, then write to another stream instead. - var expect = [ 'xxxxx', + let expect = [ 'xxxxx', 'xxxxx', 'xxxxx', 'xxxxx', @@ -269,9 +269,9 @@ test('multipipe', function(t) { 'xxxxx' ]; expect = [ expect.slice(0, SPLIT), expect.slice(SPLIT) ]; - var w = [ new TestWriter(), new TestWriter(), new TestWriter() ]; + const w = [ new TestWriter(), new TestWriter(), new TestWriter() ]; - var writes = SPLIT; + let writes = SPLIT; w[0].on('write', function() { if (--writes === 0) { r.unpipe(); @@ -280,7 +280,7 @@ test('multipipe', function(t) { } }); - var ended = 0; + let ended = 0; w[0].on('end', function(results) { ended++; @@ -302,19 +302,19 @@ test('multipipe', function(t) { test('back pressure respected', function(t) { function noop() {} - var r = new R({ objectMode: true }); + const r = new R({ objectMode: true }); r._read = noop; - var counter = 0; + let counter = 0; r.push(['one']); r.push(['two']); r.push(['three']); r.push(['four']); r.push(null); - var w1 = new R(); + const w1 = new R(); w1.write = function(chunk) { console.error('w1.emit("close")'); - assert.equal(chunk[0], 'one'); + assert.strictEqual(chunk[0], 'one'); w1.emit('close'); process.nextTick(function() { r.pipe(w2); @@ -325,13 +325,13 @@ test('back pressure respected', function(t) { r.pipe(w1); - var expected = ['two', 'two', 'three', 'three', 'four', 'four']; + const expected = ['two', 'two', 'three', 'three', 'four', 'four']; - var w2 = new R(); + const w2 = new R(); w2.write = function(chunk) { console.error('w2 write', chunk, counter); - assert.equal(chunk[0], expected.shift()); - assert.equal(counter, 0); + assert.strictEqual(chunk[0], expected.shift()); + assert.strictEqual(counter, 0); counter++; @@ -349,11 +349,11 @@ test('back pressure respected', function(t) { }; w2.end = noop; - var w3 = new R(); + const w3 = new R(); w3.write = function(chunk) { console.error('w3 write', chunk, counter); - assert.equal(chunk[0], expected.shift()); - assert.equal(counter, 1); + assert.strictEqual(chunk[0], expected.shift()); + assert.strictEqual(counter, 1); counter++; @@ -370,36 +370,36 @@ test('back pressure respected', function(t) { return false; }; w3.end = function() { - assert.equal(counter, 2); - assert.equal(expected.length, 0); + assert.strictEqual(counter, 2); + assert.strictEqual(expected.length, 0); t.end(); }; }); test('read(0) for ended streams', function(t) { - var r = new R(); - var written = false; - var ended = false; + const r = new R(); + let written = false; + let ended = false; r._read = function(n) {}; r.push(Buffer.from('foo')); r.push(null); - var v = r.read(0); + const v = r.read(0); - assert.equal(v, null); + assert.strictEqual(v, null); - var w = new R(); + const w = new R(); w.write = function(buffer) { written = true; - assert.equal(ended, false); - assert.equal(buffer.toString(), 'foo'); + assert.strictEqual(ended, false); + assert.strictEqual(buffer.toString(), 'foo'); }; w.end = function() { ended = true; - assert.equal(written, true); + assert.strictEqual(written, true); t.end(); }; @@ -407,8 +407,8 @@ test('read(0) for ended streams', function(t) { }); test('sync _read ending', function(t) { - var r = new R(); - var called = false; + const r = new R(); + let called = false; r._read = function(n) { r.push(null); }; @@ -420,15 +420,15 @@ test('sync _read ending', function(t) { r.read(); process.nextTick(function() { - assert.equal(called, true); + assert.strictEqual(called, true); t.end(); }); }); test('adding readable triggers data flow', function(t) { - var r = new R({ highWaterMark: 5 }); - var onReadable = false; - var readCalled = 0; + const r = new R({ highWaterMark: 5 }); + let onReadable = false; + let readCalled = 0; r._read = function(n) { if (readCalled++ === 2) @@ -450,9 +450,9 @@ test('adding readable triggers data flow', function(t) { }); test('chainable', function(t) { - var r = new R(); + const r = new R(); r._read = function() {}; - var r2 = r.setEncoding('utf8').pause().resume().pause(); + const r2 = r.setEncoding('utf8').pause().resume().pause(); t.equal(r, r2); t.end(); }); diff --git a/test/pummel/test-timer-wrap.js b/test/pummel/test-timer-wrap.js index 659912d1fc28ce..d30661716bd2b2 100644 --- a/test/pummel/test-timer-wrap.js +++ b/test/pummel/test-timer-wrap.js @@ -1,10 +1,10 @@ 'use strict'; const common = require('../common'); -var Timer = process.binding('timer_wrap').Timer; -var kOnTimeout = Timer.kOnTimeout; +const Timer = process.binding('timer_wrap').Timer; +const kOnTimeout = Timer.kOnTimeout; -var t = new Timer(); +const t = new Timer(); t.start(1000); diff --git a/test/pummel/test-timer-wrap2.js b/test/pummel/test-timer-wrap2.js index 87497b2685f5d3..4bae86f8cefb0c 100644 --- a/test/pummel/test-timer-wrap2.js +++ b/test/pummel/test-timer-wrap2.js @@ -4,5 +4,5 @@ require('../common'); // Test that allocating a timer does not increase the loop's reference // count. -var Timer = process.binding('timer_wrap').Timer; +const Timer = process.binding('timer_wrap').Timer; new Timer(); diff --git a/test/pummel/test-timers.js b/test/pummel/test-timers.js index 588d2327ff37dd..600b7ce35b0913 100644 --- a/test/pummel/test-timers.js +++ b/test/pummel/test-timers.js @@ -1,44 +1,44 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var WINDOW = 200; // why is does this need to be so big? +const WINDOW = 200; // why is does this need to be so big? -var interval_count = 0; +let interval_count = 0; // check that these don't blow up. clearTimeout(null); clearInterval(null); -assert.equal(true, setTimeout instanceof Function); -var starttime = new Date(); +assert.strictEqual(true, setTimeout instanceof Function); +const starttime = new Date(); setTimeout(common.mustCall(function() { - var endtime = new Date(); + const endtime = new Date(); - var diff = endtime - starttime; + const diff = endtime - starttime; assert.ok(diff > 0); console.error('diff: ' + diff); - assert.equal(true, 1000 - WINDOW < diff && diff < 1000 + WINDOW); + assert.strictEqual(true, 1000 - WINDOW < diff && diff < 1000 + WINDOW); }), 1000); // this timer shouldn't execute -var id = setTimeout(function() { assert.equal(true, false); }, 500); +const id = setTimeout(function() { assert.strictEqual(true, false); }, 500); clearTimeout(id); setInterval(function() { interval_count += 1; - var endtime = new Date(); + const endtime = new Date(); - var diff = endtime - starttime; + const diff = endtime - starttime; assert.ok(diff > 0); console.error('diff: ' + diff); - var t = interval_count * 1000; + const t = interval_count * 1000; - assert.equal(true, t - WINDOW < diff && diff < t + WINDOW); + assert.strictEqual(true, t - WINDOW < diff && diff < t + WINDOW); - assert.equal(true, interval_count <= 3); + assert.strictEqual(true, interval_count <= 3); if (interval_count === 3) clearInterval(this); }, 1000); @@ -46,13 +46,13 @@ setInterval(function() { // Single param: setTimeout(function(param) { - assert.equal('test param', param); + assert.strictEqual('test param', param); }, 1000, 'test param'); -var interval_count2 = 0; +let interval_count2 = 0; setInterval(function(param) { ++interval_count2; - assert.equal('test param', param); + assert.strictEqual('test param', param); if (interval_count2 === 3) clearInterval(this); @@ -61,29 +61,29 @@ setInterval(function(param) { // Multiple param setTimeout(function(param1, param2) { - assert.equal('param1', param1); - assert.equal('param2', param2); + assert.strictEqual('param1', param1); + assert.strictEqual('param2', param2); }, 1000, 'param1', 'param2'); -var interval_count3 = 0; +let interval_count3 = 0; setInterval(function(param1, param2) { ++interval_count3; - assert.equal('param1', param1); - assert.equal('param2', param2); + assert.strictEqual('param1', param1); + assert.strictEqual('param2', param2); if (interval_count3 === 3) clearInterval(this); }, 1000, 'param1', 'param2'); // setInterval(cb, 0) should be called multiple times. -var count4 = 0; -var interval4 = setInterval(function() { +let count4 = 0; +const interval4 = setInterval(function() { if (++count4 > 10) clearInterval(interval4); }, 0); // we should be able to clearTimeout multiple times without breakage. -var expectedTimeouts = 3; +let expectedTimeouts = 3; function t() { expectedTimeouts--; @@ -91,7 +91,7 @@ function t() { setTimeout(t, 200); setTimeout(t, 200); -var y = setTimeout(t, 200); +const y = setTimeout(t, 200); clearTimeout(y); setTimeout(t, 200); @@ -99,7 +99,8 @@ clearTimeout(y); process.on('exit', function() { - assert.equal(3, interval_count); - assert.equal(11, count4); - assert.equal(0, expectedTimeouts, 'clearTimeout cleared too many timeouts'); + assert.strictEqual(3, interval_count); + assert.strictEqual(11, count4); + assert.strictEqual(0, expectedTimeouts, + 'clearTimeout cleared too many timeouts'); }); diff --git a/test/pummel/test-tls-ci-reneg-attack.js b/test/pummel/test-tls-ci-reneg-attack.js index 5075806c1085b6..9c2d3da5c3f6b1 100644 --- a/test/pummel/test-tls-ci-reneg-attack.js +++ b/test/pummel/test-tls-ci-reneg-attack.js @@ -1,15 +1,15 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); if (!common.opensslCli) { common.skip('node compiled without OpenSSL CLI.'); @@ -17,7 +17,7 @@ if (!common.opensslCli) { } // renegotiation limits to test -var LIMITS = [0, 1, 2, 3, 5, 10, 16]; +const LIMITS = [0, 1, 2, 3, 5, 10, 16]; { let n = 0; @@ -30,14 +30,14 @@ var LIMITS = [0, 1, 2, 3, 5, 10, 16]; } function test(next) { - var options = { + const options = { cert: fs.readFileSync(common.fixturesDir + '/test_cert.pem'), key: fs.readFileSync(common.fixturesDir + '/test_key.pem') }; - var seenError = false; + let seenError = false; - var server = tls.createServer(options, function(conn) { + const server = tls.createServer(options, function(conn) { conn.on('error', function(err) { console.error('Caught exception: ' + err); assert(/TLS session renegotiation attack/.test(err)); @@ -48,8 +48,8 @@ function test(next) { }); server.listen(common.PORT, function() { - var args = ('s_client -connect 127.0.0.1:' + common.PORT).split(' '); - var child = spawn(common.opensslCli, args); + const args = ('s_client -connect 127.0.0.1:' + common.PORT).split(' '); + const child = spawn(common.opensslCli, args); //child.stdout.pipe(process.stdout); //child.stderr.pipe(process.stderr); @@ -58,8 +58,8 @@ function test(next) { child.stderr.resume(); // count handshakes, start the attack after the initial handshake is done - var handshakes = 0; - var renegs = 0; + let handshakes = 0; + let renegs = 0; child.stderr.on('data', function(data) { if (seenError) return; @@ -69,19 +69,19 @@ function test(next) { }); child.on('exit', function() { - assert.equal(renegs, tls.CLIENT_RENEG_LIMIT + 1); + assert.strictEqual(renegs, tls.CLIENT_RENEG_LIMIT + 1); server.close(); process.nextTick(next); }); - var closed = false; + let closed = false; child.stdin.on('error', function(err) { switch (err.code) { case 'ECONNRESET': case 'EPIPE': break; default: - assert.equal(err.code, 'ECONNRESET'); + assert.strictEqual(err.code, 'ECONNRESET'); break; } closed = true; diff --git a/test/pummel/test-tls-connect-memleak.js b/test/pummel/test-tls-connect-memleak.js index b55e33cee0afc4..b1d1f05190c39d 100644 --- a/test/pummel/test-tls-connect-memleak.js +++ b/test/pummel/test-tls-connect-memleak.js @@ -1,16 +1,16 @@ 'use strict'; // Flags: --expose-gc -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); +const fs = require('fs'); assert.strictEqual( typeof global.gc, @@ -38,10 +38,10 @@ tls.createServer({ } function done() { - var before = process.memoryUsage().rss; + const before = process.memoryUsage().rss; global.gc(); - var after = process.memoryUsage().rss; - var reclaimed = (before - after) / 1024; + const after = process.memoryUsage().rss; + const reclaimed = (before - after) / 1024; console.log('%d kB reclaimed', reclaimed); assert(reclaimed > 256 * 1024); // it's more like 512M on x64 process.exit(); diff --git a/test/pummel/test-tls-securepair-client.js b/test/pummel/test-tls-securepair-client.js index 7a1b8770132e96..cd9299cb790958 100644 --- a/test/pummel/test-tls-securepair-client.js +++ b/test/pummel/test-tls-securepair-client.js @@ -1,7 +1,7 @@ 'use strict'; // -var common = require('../common'); +const common = require('../common'); if (!common.opensslCli) { common.skip('node compiled without OpenSSL CLI.'); @@ -13,12 +13,12 @@ if (!common.hasCrypto) { return; } -var join = require('path').join; -var net = require('net'); -var assert = require('assert'); -var fs = require('fs'); -var tls = require('tls'); -var spawn = require('child_process').spawn; +const join = require('path').join; +const net = require('net'); +const assert = require('assert'); +const fs = require('fs'); +const tls = require('tls'); +const spawn = require('child_process').spawn; test1(); @@ -31,31 +31,32 @@ function test1() { function test2() { function check(pair) { // "TLS Web Client Authentication" - assert.equal(pair.cleartext.getPeerCertificate().ext_key_usage.length, 1); - assert.equal(pair.cleartext.getPeerCertificate().ext_key_usage[0], - '1.3.6.1.5.5.7.3.2'); + assert.strictEqual(pair.cleartext.getPeerCertificate().ext_key_usage.length, + 1); + assert.strictEqual(pair.cleartext.getPeerCertificate().ext_key_usage[0], + '1.3.6.1.5.5.7.3.2'); } test('keys/agent4-key.pem', 'keys/agent4-cert.pem', check); } function test(keyfn, certfn, check, next) { keyfn = join(common.fixturesDir, keyfn); - var key = fs.readFileSync(keyfn).toString(); + const key = fs.readFileSync(keyfn).toString(); certfn = join(common.fixturesDir, certfn); - var cert = fs.readFileSync(certfn).toString(); + const cert = fs.readFileSync(certfn).toString(); - var server = spawn(common.opensslCli, ['s_server', - '-accept', common.PORT, - '-cert', certfn, - '-key', keyfn]); + const server = spawn(common.opensslCli, ['s_server', + '-accept', common.PORT, + '-cert', certfn, + '-key', keyfn]); server.stdout.pipe(process.stdout); server.stderr.pipe(process.stdout); - var state = 'WAIT-ACCEPT'; + let state = 'WAIT-ACCEPT'; - var serverStdoutBuffer = ''; + let serverStdoutBuffer = ''; server.stdout.setEncoding('utf8'); server.stdout.on('data', function(s) { serverStdoutBuffer += s; @@ -86,13 +87,13 @@ function test(keyfn, certfn, check, next) { }); - var timeout = setTimeout(function() { + const timeout = setTimeout(function() { server.kill(); process.exit(1); }, 5000); - var gotWriteCallback = false; - var serverExitCode = -1; + let gotWriteCallback = false; + let serverExitCode = -1; server.on('exit', function(code) { serverExitCode = code; @@ -102,12 +103,12 @@ function test(keyfn, certfn, check, next) { function startClient() { - var s = new net.Stream(); + const s = new net.Stream(); - var sslcontext = tls.createSecureContext({key: key, cert: cert}); + const sslcontext = tls.createSecureContext({key: key, cert: cert}); sslcontext.context.setCiphers('RC4-SHA:AES128-SHA:AES256-SHA'); - var pair = tls.createSecurePair(sslcontext, false); + const pair = tls.createSecurePair(sslcontext, false); assert.ok(pair.encrypted.writable); assert.ok(pair.cleartext.writable); @@ -158,8 +159,8 @@ function test(keyfn, certfn, check, next) { process.on('exit', function() { - assert.equal(0, serverExitCode); - assert.equal('WAIT-SERVER-CLOSE', state); + assert.strictEqual(0, serverExitCode); + assert.strictEqual('WAIT-SERVER-CLOSE', state); assert.ok(gotWriteCallback); }); } diff --git a/test/pummel/test-tls-server-large-request.js b/test/pummel/test-tls-server-large-request.js index 66d700ae4bc6a9..41393120fcd1e2 100644 --- a/test/pummel/test-tls-server-large-request.js +++ b/test/pummel/test-tls-server-large-request.js @@ -1,20 +1,20 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); +const tls = require('tls'); -var fs = require('fs'); -var stream = require('stream'); -var util = require('util'); +const fs = require('fs'); +const stream = require('stream'); +const util = require('util'); -var request = Buffer.from(new Array(1024 * 256).join('ABCD')); // 1mb +const request = Buffer.from(new Array(1024 * 256).join('ABCD')); // 1mb -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') }; @@ -30,19 +30,19 @@ Mediator.prototype._write = function _write(data, enc, cb) { setTimeout(cb, 0); if (this.buf.length >= request.length) { - assert.equal(this.buf, request.toString()); + assert.strictEqual(this.buf, request.toString()); server.close(); } }; -var mediator = new Mediator(); +const mediator = new Mediator(); -var server = tls.Server(options, common.mustCall(function(socket) { +const server = tls.Server(options, common.mustCall(function(socket) { socket.pipe(mediator); })); server.listen(common.PORT, common.mustCall(function() { - var client1 = tls.connect({ + const client1 = tls.connect({ port: common.PORT, rejectUnauthorized: false }, common.mustCall(function() { diff --git a/test/pummel/test-tls-session-timeout.js b/test/pummel/test-tls-session-timeout.js index c23a8afcf7fe9a..c194188b3682a9 100644 --- a/test/pummel/test-tls-session-timeout.js +++ b/test/pummel/test-tls-session-timeout.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); if (!common.opensslCli) { common.skip('node compiled without OpenSSL CLI.'); @@ -22,19 +22,19 @@ doTest(); // that we used has expired by now. function doTest() { - var assert = require('assert'); - var tls = require('tls'); - var fs = require('fs'); - var join = require('path').join; - var spawn = require('child_process').spawn; + const assert = require('assert'); + const tls = require('tls'); + const fs = require('fs'); + const join = require('path').join; + const spawn = require('child_process').spawn; - var SESSION_TIMEOUT = 1; + const SESSION_TIMEOUT = 1; - var keyFile = join(common.fixturesDir, 'agent.key'); - var certFile = join(common.fixturesDir, 'agent.crt'); - var key = fs.readFileSync(keyFile); - var cert = fs.readFileSync(certFile); - var options = { + const keyFile = join(common.fixturesDir, 'agent.key'); + const certFile = join(common.fixturesDir, 'agent.crt'); + const key = fs.readFileSync(keyFile); + const cert = fs.readFileSync(certFile); + const options = { key: key, cert: cert, ca: [cert], @@ -47,41 +47,41 @@ function doTest() { // file containing a proper serialization of a session ticket. // To avoid a source control diff, we copy the ticket to a temporary file. - var sessionFileName = (function() { - var ticketFileName = 'tls-session-ticket.txt'; - var fixturesPath = join(common.fixturesDir, ticketFileName); - var tmpPath = join(common.tmpDir, ticketFileName); + const sessionFileName = (function() { + const ticketFileName = 'tls-session-ticket.txt'; + const fixturesPath = join(common.fixturesDir, ticketFileName); + const tmpPath = join(common.tmpDir, ticketFileName); fs.writeFileSync(tmpPath, fs.readFileSync(fixturesPath)); return tmpPath; }()); // Expects a callback -- cb(connectionType : enum ['New'|'Reused']) - var Client = function(cb) { - var flags = [ + const Client = function(cb) { + const flags = [ 's_client', '-connect', 'localhost:' + common.PORT, '-sess_in', sessionFileName, '-sess_out', sessionFileName ]; - var client = spawn(common.opensslCli, flags, { + const client = spawn(common.opensslCli, flags, { stdio: ['ignore', 'pipe', 'ignore'] }); - var clientOutput = ''; + let clientOutput = ''; client.stdout.on('data', function(data) { clientOutput += data.toString(); }); client.on('exit', function(code) { - var connectionType; - var grepConnectionType = function(line) { - var matches = line.match(/(New|Reused), /); + let connectionType; + const grepConnectionType = function(line) { + const matches = line.match(/(New|Reused), /); if (matches) { connectionType = matches[1]; return true; } }; - var lines = clientOutput.split('\n'); + const lines = clientOutput.split('\n'); if (!lines.some(grepConnectionType)) { throw new Error('unexpected output from openssl client'); } @@ -89,7 +89,7 @@ function doTest() { }); }; - var server = tls.createServer(options, function(cleartext) { + const server = tls.createServer(options, function(cleartext) { cleartext.on('error', function(er) { if (er.code !== 'ECONNRESET') throw er; diff --git a/test/pummel/test-tls-throttle.js b/test/pummel/test-tls-throttle.js index a93793989f0b2b..e427e0bf89f877 100644 --- a/test/pummel/test-tls-throttle.js +++ b/test/pummel/test-tls-throttle.js @@ -2,33 +2,33 @@ // Server sends a large string. Client counts bytes and pauses every few // seconds. Makes sure that pause and resume work properly. -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); if (!common.hasCrypto) { common.skip('missing crypto'); return; } -var tls = require('tls'); -var fs = require('fs'); +const tls = require('tls'); +const fs = require('fs'); process.stdout.write('build body...'); -var body = 'hello world\n'.repeat(1024 * 1024); +const body = 'hello world\n'.repeat(1024 * 1024); process.stdout.write('done\n'); -var options = { +const options = { key: fs.readFileSync(common.fixturesDir + '/keys/agent2-key.pem'), cert: fs.readFileSync(common.fixturesDir + '/keys/agent2-cert.pem') }; -var server = tls.Server(options, common.mustCall(function(socket) { +const server = tls.Server(options, common.mustCall(function(socket) { socket.end(body); })); -var recvCount = 0; +let recvCount = 0; server.listen(common.PORT, function() { - var client = tls.connect({ + const client = tls.connect({ port: common.PORT, rejectUnauthorized: false }); @@ -58,10 +58,10 @@ function displayCounts() { } -var timeout = setTimeout(displayCounts, 10 * 1000); +const timeout = setTimeout(displayCounts, 10 * 1000); process.on('exit', function() { displayCounts(); - assert.equal(body.length, recvCount); + assert.strictEqual(body.length, recvCount); }); diff --git a/test/pummel/test-vm-memleak.js b/test/pummel/test-vm-memleak.js index c6623991922da9..8503e2389b44a7 100644 --- a/test/pummel/test-vm-memleak.js +++ b/test/pummel/test-vm-memleak.js @@ -2,23 +2,23 @@ // Flags: --max_old_space_size=32 require('../common'); -var assert = require('assert'); +const assert = require('assert'); -var start = Date.now(); -var maxMem = 0; +const start = Date.now(); +let maxMem = 0; -var ok = process.execArgv.some(function(arg) { +const ok = process.execArgv.some(function(arg) { return arg === '--max_old_space_size=32'; }); assert(ok, 'Run this test with --max_old_space_size=32.'); -var interval = setInterval(function() { +const interval = setInterval(function() { try { require('vm').runInNewContext('throw 1;'); } catch (e) { } - var rss = process.memoryUsage().rss; + const rss = process.memoryUsage().rss; maxMem = Math.max(rss, maxMem); if (Date.now() - start > 5 * 1000) { @@ -30,7 +30,7 @@ var interval = setInterval(function() { }, 1); function testContextLeak() { - for (var i = 0; i < 1000; i++) + for (let i = 0; i < 1000; i++) require('vm').createContext({}); } diff --git a/test/pummel/test-watch-file.js b/test/pummel/test-watch-file.js index 8fdf6b32b2d78c..90909875d74a15 100644 --- a/test/pummel/test-watch-file.js +++ b/test/pummel/test-watch-file.js @@ -1,18 +1,15 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var fs = require('fs'); -var path = require('path'); +const fs = require('fs'); +const path = require('path'); -var f = path.join(common.fixturesDir, 'x.txt'); +const f = path.join(common.fixturesDir, 'x.txt'); -console.log('watching for changes of ' + f); - -var changes = 0; +let changes = 0; function watchFile() { - fs.watchFile(f, function(curr, prev) { - console.log(f + ' change'); + fs.watchFile(f, (curr, prev) => { changes++; assert.notDeepStrictEqual(curr.mtime, prev.mtime); fs.unwatchFile(f); @@ -24,7 +21,7 @@ function watchFile() { watchFile(); -var fd = fs.openSync(f, 'w+'); +const fd = fs.openSync(f, 'w+'); fs.writeSync(fd, 'xyz\n'); fs.closeSync(fd); diff --git a/test/sequential/test-child-process-execsync.js b/test/sequential/test-child-process-execsync.js index 137ddbda425f2c..20a35b98b36c6f 100644 --- a/test/sequential/test-child-process-execsync.js +++ b/test/sequential/test-child-process-execsync.js @@ -1,16 +1,16 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var execSync = require('child_process').execSync; -var execFileSync = require('child_process').execFileSync; +const execSync = require('child_process').execSync; +const execFileSync = require('child_process').execFileSync; -var TIMER = 200; -var SLEEP = 2000; +const TIMER = 200; +const SLEEP = 2000; -var start = Date.now(); -var err; -var caught = false; +const start = Date.now(); +let err; +let caught = false; // Verify that stderr is not accessed when a bad shell is used assert.throws( @@ -24,9 +24,10 @@ assert.throws( 'execFileSync did not throw the expected exception!' ); +let cmd, ret; try { - var cmd = `"${process.execPath}" -e "setTimeout(function(){}, ${SLEEP});"`; - var ret = execSync(cmd, {timeout: TIMER}); + cmd = `"${process.execPath}" -e "setTimeout(function(){}, ${SLEEP});"`; + ret = execSync(cmd, {timeout: TIMER}); } catch (e) { caught = true; assert.strictEqual(e.errno, 'ETIMEDOUT'); @@ -34,7 +35,7 @@ try { } finally { assert.strictEqual(ret, undefined, 'we should not have a return value'); assert.strictEqual(caught, true, 'execSync should throw'); - var end = Date.now() - start; + const end = Date.now() - start; assert(end < SLEEP); assert(err.status > 128 || err.signal); } @@ -43,8 +44,8 @@ assert.throws(function() { execSync('iamabadcommand'); }, /Command failed: iamabadcommand/); -var msg = 'foobar'; -var msgBuf = Buffer.from(msg + '\n'); +const msg = 'foobar'; +const msgBuf = Buffer.from(msg + '\n'); // console.log ends every line with just '\n', even on Windows. @@ -59,7 +60,7 @@ ret = execSync(cmd, { encoding: 'utf8' }); assert.strictEqual(ret, msg + '\n', 'execSync encoding result should match'); -var args = [ +const args = [ '-e', `console.log("${msg}");` ]; diff --git a/test/sequential/test-child-process-fork-getconnections.js b/test/sequential/test-child-process-fork-getconnections.js index 4d6b1a25ef16cc..355a45913c8699 100644 --- a/test/sequential/test-child-process-fork-getconnections.js +++ b/test/sequential/test-child-process-fork-getconnections.js @@ -20,7 +20,7 @@ if (process.argv[2] === 'child') { } if (m.cmd === 'close') { - assert.equal(socket, undefined); + assert.strictEqual(socket, undefined); if (sockets[m.id].destroyed) { // Workaround for https://github.com/nodejs/node/issues/2610 sendClosed(m.id); @@ -92,8 +92,8 @@ if (process.argv[2] === 'child') { server.listen(common.PORT, '127.0.0.1'); process.on('exit', function() { - assert.equal(sent, count); - assert.equal(disconnected, count); + assert.strictEqual(sent, count); + assert.strictEqual(disconnected, count); assert.ok(closeEmitted); console.log('ok'); }); diff --git a/test/sequential/test-crypto-timing-safe-equal.js b/test/sequential/test-crypto-timing-safe-equal.js index 9c4265a672cc0f..7a1f8d2993669b 100644 --- a/test/sequential/test-crypto-timing-safe-equal.js +++ b/test/sequential/test-crypto-timing-safe-equal.js @@ -24,14 +24,14 @@ assert.strictEqual( assert.throws(function() { crypto.timingSafeEqual(Buffer.from([1, 2, 3]), Buffer.from([1, 2])); }, /^TypeError: Input buffers must have the same length$/, - 'should throw when given buffers with different lengths'); + 'should throw when given buffers with different lengths'); assert.throws(function() { crypto.timingSafeEqual('not a buffer', Buffer.from([1, 2])); }, /^TypeError: First argument must be a buffer$/, - 'should throw if the first argument is not a buffer'); + 'should throw if the first argument is not a buffer'); assert.throws(function() { crypto.timingSafeEqual(Buffer.from([1, 2]), 'not a buffer'); }, /^TypeError: Second argument must be a buffer$/, - 'should throw if the second argument is not a buffer'); + 'should throw if the second argument is not a buffer'); diff --git a/test/sequential/test-debugger-debug-brk.js b/test/sequential/test-debugger-debug-brk.js index 3b54f853bc8de3..26c3418171e8df 100644 --- a/test/sequential/test-debugger-debug-brk.js +++ b/test/sequential/test-debugger-debug-brk.js @@ -1,16 +1,16 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var spawn = require('child_process').spawn; +const common = require('../common'); +const assert = require('assert'); +const spawn = require('child_process').spawn; -var script = common.fixturesDir + '/empty.js'; +const script = common.fixturesDir + '/empty.js'; function fail() { assert(0); // `node --debug-brk script.js` should not quit } function test(arg) { - var child = spawn(process.execPath, [arg, script]); + const child = spawn(process.execPath, [arg, script]); child.on('exit', fail); // give node time to start up the debugger diff --git a/test/sequential/test-deprecation-flags.js b/test/sequential/test-deprecation-flags.js index e9f5ee673d23bd..3bd2e99033beb1 100644 --- a/test/sequential/test-deprecation-flags.js +++ b/test/sequential/test-deprecation-flags.js @@ -20,25 +20,25 @@ const traceDep = ['--trace-deprecation', depmod]; execFile(node, normal, function(er, stdout, stderr) { console.error('normal: show deprecation warning'); - assert.equal(er, null); - assert.equal(stdout, ''); + assert.strictEqual(er, null); + assert.strictEqual(stdout, ''); assert(/util\.debug is deprecated/.test(stderr)); console.log('normal ok'); }); execFile(node, noDep, function(er, stdout, stderr) { console.error('--no-deprecation: silence deprecations'); - assert.equal(er, null); - assert.equal(stdout, ''); - assert.equal(stderr, 'DEBUG: This is deprecated\n'); + assert.strictEqual(er, null); + assert.strictEqual(stdout, ''); + assert.strictEqual(stderr, 'DEBUG: This is deprecated\n'); console.log('silent ok'); }); execFile(node, traceDep, function(er, stdout, stderr) { console.error('--trace-deprecation: show stack'); - assert.equal(er, null); - assert.equal(stdout, ''); - var stack = stderr.trim().split('\n'); + assert.strictEqual(er, null); + assert.strictEqual(stdout, ''); + const stack = stderr.trim().split('\n'); // just check the top and bottom. assert(/util.debug is deprecated. Use console.error instead./.test(stack[1])); assert(/DEBUG: This is deprecated/.test(stack[0])); @@ -47,8 +47,8 @@ execFile(node, traceDep, function(er, stdout, stderr) { execFile(node, [depUserlandFunction], function(er, stdout, stderr) { console.error('normal: testing deprecated userland function'); - assert.equal(er, null); - assert.equal(stdout, ''); + assert.strictEqual(er, null); + assert.strictEqual(stdout, ''); assert(/deprecatedFunction is deprecated/.test(stderr)); console.error('normal: ok'); }); diff --git a/test/parallel/test-fs-readfile-tostring-fail.js b/test/sequential/test-fs-readfile-tostring-fail.js similarity index 97% rename from test/parallel/test-fs-readfile-tostring-fail.js rename to test/sequential/test-fs-readfile-tostring-fail.js index 8ed9658a25889a..593b8da0fd8afa 100644 --- a/test/parallel/test-fs-readfile-tostring-fail.js +++ b/test/sequential/test-fs-readfile-tostring-fail.js @@ -23,7 +23,7 @@ const stream = fs.createWriteStream(file, { const size = kStringMaxLength / 200; const a = Buffer.alloc(size, 'a'); -for (var i = 0; i < 201; i++) { +for (let i = 0; i < 201; i++) { stream.write(a); } diff --git a/test/sequential/test-fs-watch.js b/test/sequential/test-fs-watch.js index 43b23bd5bd0a79..34e53f59aa0961 100644 --- a/test/sequential/test-fs-watch.js +++ b/test/sequential/test-fs-watch.js @@ -1,25 +1,25 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); -var expectFilePath = common.isWindows || - common.isLinux || - common.isOSX; +const expectFilePath = common.isWindows || + common.isLinux || + common.isOSX; -var watchSeenOne = 0; -var watchSeenTwo = 0; -var watchSeenThree = 0; +let watchSeenOne = 0; +let watchSeenTwo = 0; +let watchSeenThree = 0; -var testDir = common.tmpDir; +const testDir = common.tmpDir; -var filenameOne = 'watch.txt'; -var filepathOne = path.join(testDir, filenameOne); +const filenameOne = 'watch.txt'; +const filepathOne = path.join(testDir, filenameOne); -var filenameTwo = 'hasOwnProperty'; -var filepathTwo = filenameTwo; -var filepathTwoAbs = path.join(testDir, filenameTwo); +const filenameTwo = 'hasOwnProperty'; +const filepathTwo = filenameTwo; +const filepathTwoAbs = path.join(testDir, filenameTwo); process.on('exit', function() { assert.ok(watchSeenOne > 0); @@ -33,12 +33,12 @@ fs.writeFileSync(filepathOne, 'hello'); assert.doesNotThrow( function() { - var watcher = fs.watch(filepathOne); + const watcher = fs.watch(filepathOne); watcher.on('change', function(event, filename) { - assert.equal('change', event); + assert.strictEqual('change', event); if (expectFilePath) { - assert.equal('watch.txt', filename); + assert.strictEqual('watch.txt', filename); } watcher.close(); ++watchSeenOne; @@ -57,11 +57,11 @@ fs.writeFileSync(filepathTwoAbs, 'howdy'); assert.doesNotThrow( function() { - var watcher = fs.watch(filepathTwo, function(event, filename) { - assert.equal('change', event); + const watcher = fs.watch(filepathTwo, function(event, filename) { + assert.strictEqual('change', event); if (expectFilePath) { - assert.equal('hasOwnProperty', filename); + assert.strictEqual('hasOwnProperty', filename); } watcher.close(); ++watchSeenTwo; @@ -79,13 +79,13 @@ const filepathThree = path.join(testsubdir, filenameThree); assert.doesNotThrow( function() { - var watcher = fs.watch(testsubdir, function(event, filename) { - var renameEv = common.isSunOS ? 'change' : 'rename'; - assert.equal(renameEv, event); + const watcher = fs.watch(testsubdir, function(event, filename) { + const renameEv = common.isSunOS ? 'change' : 'rename'; + assert.strictEqual(renameEv, event); if (expectFilePath) { - assert.equal('newfile.txt', filename); + assert.strictEqual('newfile.txt', filename); } else { - assert.equal(null, filename); + assert.strictEqual(null, filename); } watcher.close(); ++watchSeenThree; @@ -94,7 +94,7 @@ assert.doesNotThrow( ); setImmediate(function() { - var fd = fs.openSync(filepathThree, 'w'); + const fd = fs.openSync(filepathThree, 'w'); fs.closeSync(fd); }); @@ -106,9 +106,9 @@ fs.watch(__filename, {persistent: false}, function() { // whitebox test to ensure that wrapped FSEvent is safe // https://github.com/joyent/node/issues/6690 -var oldhandle; +let oldhandle; assert.throws(function() { - var w = fs.watch(__filename, function(event, filename) { }); + const w = fs.watch(__filename, function(event, filename) { }); oldhandle = w._handle; w._handle = { close: w._handle.close }; w.close(); @@ -116,7 +116,7 @@ assert.throws(function() { oldhandle.close(); // clean up assert.throws(function() { - var w = fs.watchFile(__filename, {persistent: false}, function() {}); + const w = fs.watchFile(__filename, {persistent: false}, function() {}); oldhandle = w._handle; w._handle = { stop: w._handle.stop }; w.stop(); diff --git a/test/sequential/test-http-regr-gh-2928.js b/test/sequential/test-http-regr-gh-2928.js index b4ae7054d72bb9..55e3a93bc98eaa 100644 --- a/test/sequential/test-http-regr-gh-2928.js +++ b/test/sequential/test-http-regr-gh-2928.js @@ -11,11 +11,11 @@ const net = require('net'); const COUNT = httpCommon.parsers.max + 1; const parsers = new Array(COUNT); -for (var i = 0; i < parsers.length; i++) +for (let i = 0; i < parsers.length; i++) parsers[i] = httpCommon.parsers.alloc(); -var gotRequests = 0; -var gotResponses = 0; +let gotRequests = 0; +let gotResponses = 0; function execAndClose() { if (parsers.length === 0) @@ -50,7 +50,7 @@ function execAndClose() { }; } -var server = net.createServer(function(c) { +const server = net.createServer(function(c) { if (++gotRequests === COUNT) server.close(); c.end('HTTP/1.1 200 OK\r\n\r\n', function() { @@ -59,5 +59,5 @@ var server = net.createServer(function(c) { }).listen(common.PORT, execAndClose); process.on('exit', function() { - assert.equal(gotResponses, COUNT); + assert.strictEqual(gotResponses, COUNT); }); diff --git a/test/sequential/test-module-loading.js b/test/sequential/test-module-loading.js index 61746a282f5eaa..dd4e7ba76b611f 100644 --- a/test/sequential/test-module-loading.js +++ b/test/sequential/test-module-loading.js @@ -1,8 +1,8 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); console.error('load test-module-loading.js'); @@ -15,21 +15,21 @@ assert.strictEqual(process.mainModule, module, require('../fixtures/not-main-module.js'); // require a file with a request that includes the extension -var a_js = require('../fixtures/a.js'); +const a_js = require('../fixtures/a.js'); assert.strictEqual(42, a_js.number); // require a file without any extensions -var foo_no_ext = require('../fixtures/foo'); +const foo_no_ext = require('../fixtures/foo'); assert.strictEqual('ok', foo_no_ext.foo); -var a = require('../fixtures/a'); -var c = require('../fixtures/b/c'); -var d = require('../fixtures/b/d'); -var d2 = require('../fixtures/b/d'); +const a = require('../fixtures/a'); +const c = require('../fixtures/b/c'); +const d = require('../fixtures/b/d'); +const d2 = require('../fixtures/b/d'); // Absolute -var d3 = require(path.join(__dirname, '../fixtures/b/d')); +const d3 = require(path.join(__dirname, '../fixtures/b/d')); // Relative -var d4 = require('../fixtures/b/d'); +const d4 = require('../fixtures/b/d'); assert.strictEqual(false, false, 'testing the test program.'); @@ -96,12 +96,12 @@ require('../fixtures/node_modules/foo'); console.error('test name clashes'); // this one exists and should import the local module -var my_path = require('../fixtures/path'); +const my_path = require('../fixtures/path'); assert.ok(my_path.path_func instanceof Function); // this one does not exist and should throw assert.throws(function() { require('./utils'); }); -var errorThrown = false; +let errorThrown = false; try { require('../fixtures/throws_error'); } catch (e) { @@ -113,7 +113,7 @@ assert.strictEqual(require('path').dirname(__filename), __dirname); console.error('load custom file types with extensions'); require.extensions['.test'] = function(module, filename) { - var content = fs.readFileSync(filename).toString(); + let content = fs.readFileSync(filename).toString(); assert.strictEqual('this is custom source\n', content); content = content.replace('this is custom source', 'exports.test = \'passed\''); @@ -175,13 +175,13 @@ assert.strictEqual(require(loadOrder + 'file9').file9, 'file9/index.reg2', msg); // make sure that module.require() is the same as // doing require() inside of that module. -var parent = require('../fixtures/module-require/parent/'); -var child = require('../fixtures/module-require/child/'); +const parent = require('../fixtures/module-require/parent/'); +const child = require('../fixtures/module-require/child/'); assert.strictEqual(child.loaded, parent.loaded); // #1357 Loading JSON files with require() -var json = require('../fixtures/packages/main/package.json'); +const json = require('../fixtures/packages/main/package.json'); assert.deepStrictEqual(json, { name: 'package-name', version: '1.2.3', @@ -193,8 +193,8 @@ assert.deepStrictEqual(json, { // modules that we've required, and that all of them contain // the appropriate children, and so on. -var children = module.children.reduce(function red(set, child) { - var id = path.relative(path.dirname(__dirname), child.id); +const children = module.children.reduce(function red(set, child) { + let id = path.relative(path.dirname(__dirname), child.id); id = id.replace(/\\/g, '/'); set[id] = child.children.reduce(red, {}); return set; diff --git a/test/sequential/test-net-GH-5504.js b/test/sequential/test-net-GH-5504.js index 3ebf9db548d4db..a7f64c2e73da10 100644 --- a/test/sequential/test-net-GH-5504.js +++ b/test/sequential/test-net-GH-5504.js @@ -1,5 +1,5 @@ 'use strict'; -var common = require('../common'); +const common = require('../common'); // this test only fails with CentOS 6.3 using kernel version 2.6.32 // On other linuxes and darwin, the `read` call gets an ECONNRESET in @@ -18,8 +18,8 @@ switch (process.argv[2]) { } function server() { - var net = require('net'); - var content = Buffer.alloc(64 * 1024 * 1024, '#'); + const net = require('net'); + const content = Buffer.alloc(64 * 1024 * 1024, '#'); net.createServer(function(socket) { this.close(); socket.on('end', function() { @@ -35,8 +35,8 @@ function server() { } function client() { - var net = require('net'); - var client = net.connect({ + const net = require('net'); + const client = net.connect({ host: common.localhostIPv4, port: common.PORT }, function() { @@ -45,15 +45,15 @@ function client() { } function parent() { - var spawn = require('child_process').spawn; - var node = process.execPath; + const spawn = require('child_process').spawn; + const node = process.execPath; - var s = spawn(node, [__filename, 'server'], { + const s = spawn(node, [__filename, 'server'], { env: Object.assign(process.env, { NODE_DEBUG: 'net' }) }); - var c; + let c; wrap(s.stderr, process.stderr, 'SERVER 2>'); wrap(s.stdout, process.stdout, 'SERVER 1>'); diff --git a/test/sequential/test-process-warnings.js b/test/sequential/test-process-warnings.js index 1e8b2b13a20a78..d4894f8bffeb36 100644 --- a/test/sequential/test-process-warnings.js +++ b/test/sequential/test-process-warnings.js @@ -12,22 +12,22 @@ const traceWarn = ['--trace-warnings', warnmod]; execFile(node, normal, function(er, stdout, stderr) { // Show Process Warnings - assert.equal(er, null); - assert.equal(stdout, ''); + assert.strictEqual(er, null); + assert.strictEqual(stdout, ''); assert(/^\(.+\)\sWarning: a bad practice warning/.test(stderr)); }); execFile(node, noWarn, function(er, stdout, stderr) { // Hide Process Warnings - assert.equal(er, null); - assert.equal(stdout, ''); + assert.strictEqual(er, null); + assert.strictEqual(stdout, ''); assert(!/^\(.+\)\sWarning: a bad practice warning/.test(stderr)); }); execFile(node, traceWarn, function(er, stdout, stderr) { // Show Warning Trace - assert.equal(er, null); - assert.equal(stdout, ''); + assert.strictEqual(er, null); + assert.strictEqual(stdout, ''); assert(/^\(.+\)\sWarning: a bad practice warning/.test(stderr)); assert(/at Object\.\s\(.+warnings.js:3:9\)/.test(stderr)); }); diff --git a/test/sequential/test-regress-GH-1697.js b/test/sequential/test-regress-GH-1697.js index 1511cfd1cfcf6b..d99acf9e468bb3 100644 --- a/test/sequential/test-regress-GH-1697.js +++ b/test/sequential/test-regress-GH-1697.js @@ -6,7 +6,7 @@ const cp = require('child_process'); if (process.argv[2] === 'server') { // Server - var server = net.createServer(function(conn) { + const server = net.createServer(function(conn) { conn.on('data', function(data) { console.log('server received ' + data.length + ' bytes'); }); @@ -23,22 +23,22 @@ if (process.argv[2] === 'server') { } else { // Client - var serverProcess = cp.spawn(process.execPath, [process.argv[1], 'server']); + const serverProcess = cp.spawn(process.execPath, [process.argv[1], 'server']); serverProcess.stdout.pipe(process.stdout); serverProcess.stderr.pipe(process.stdout); serverProcess.stdout.once('data', function() { - var client = net.createConnection(common.PORT, '127.0.0.1'); + const client = net.createConnection(common.PORT, '127.0.0.1'); client.on('connect', function() { const alot = Buffer.allocUnsafe(1024); const alittle = Buffer.allocUnsafe(1); - for (var i = 0; i < 100; i++) { + for (let i = 0; i < 100; i++) { client.write(alot); } // Block the event loop for 1 second - var start = (new Date()).getTime(); + const start = (new Date()).getTime(); while ((new Date()).getTime() < start + 1000) {} client.write(alittle); diff --git a/test/sequential/test-regress-GH-1726.js b/test/sequential/test-regress-GH-1726.js index c5f0bba1335264..c464193b23f3e4 100644 --- a/test/sequential/test-regress-GH-1726.js +++ b/test/sequential/test-regress-GH-1726.js @@ -5,11 +5,11 @@ // https://github.com/joyent/node/issues/1726 require('../common'); -var assert = require('assert'); -var ch = require('child_process'); +const assert = require('assert'); +const ch = require('child_process'); -var gen = +(process.argv[2] || 0); -var maxGen = 5; +const gen = +(process.argv[2] || 0); +const maxGen = 5; if (gen === maxGen) { @@ -17,7 +17,7 @@ if (gen === maxGen) { return; } -var child = ch.spawn(process.execPath, [__filename, gen + 1], { +const child = ch.spawn(process.execPath, [__filename, gen + 1], { stdio: [ 'ignore', 'pipe', 'ignore' ] }); assert.ok(!child.stdin); diff --git a/test/sequential/test-regress-GH-4015.js b/test/sequential/test-regress-GH-4015.js index 7f0e03f9ac08e1..249817de1d2068 100644 --- a/test/sequential/test-regress-GH-4015.js +++ b/test/sequential/test-regress-GH-4015.js @@ -1,10 +1,10 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var exec = require('child_process').exec; +const common = require('../common'); +const assert = require('assert'); +const exec = require('child_process').exec; -var cmd = '"' + process.execPath + '" ' + - '"' + common.fixturesDir + '/test-regress-GH-4015.js"'; +const cmd = '"' + process.execPath + '" ' + + '"' + common.fixturesDir + '/test-regress-GH-4015.js"'; exec(cmd, function(err, stdout, stderr) { assert(/RangeError: Maximum call stack size exceeded/.test(stderr)); diff --git a/test/sequential/test-regress-GH-4027.js b/test/sequential/test-regress-GH-4027.js index aa1ec12c30f609..8d9c6bb1ad795a 100644 --- a/test/sequential/test-regress-GH-4027.js +++ b/test/sequential/test-regress-GH-4027.js @@ -1,17 +1,17 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); -var path = require('path'); -var fs = require('fs'); +const common = require('../common'); +const assert = require('assert'); +const path = require('path'); +const fs = require('fs'); common.refreshTmpDir(); -var filename = path.join(common.tmpDir, 'watched'); +const filename = path.join(common.tmpDir, 'watched'); fs.writeFileSync(filename, 'quis custodiet ipsos custodes'); setTimeout(fs.unlinkSync, 100, filename); fs.watchFile(filename, { interval: 50 }, common.mustCall(function(curr, prev) { - assert.equal(prev.nlink, 1); - assert.equal(curr.nlink, 0); + assert.strictEqual(prev.nlink, 1); + assert.strictEqual(curr.nlink, 0); fs.unwatchFile(filename); })); diff --git a/test/sequential/test-regress-GH-784.js b/test/sequential/test-regress-GH-784.js index 0c70337de7f146..0bfa407ec10dc3 100644 --- a/test/sequential/test-regress-GH-784.js +++ b/test/sequential/test-regress-GH-784.js @@ -7,13 +7,13 @@ // The next two are made with server on - they should come back successful. // The next two are made with the server off - and so on. Without the fix // we were experiencing parse errors and instead of ECONNREFUSED. -var common = require('../common'); -var http = require('http'); -var assert = require('assert'); +const common = require('../common'); +const http = require('http'); +const assert = require('assert'); -var server = http.createServer(function(req, res) { - var body = ''; +const server = http.createServer(function(req, res) { + let body = ''; req.setEncoding('utf8'); req.on('data', function(chunk) { @@ -21,7 +21,7 @@ var server = http.createServer(function(req, res) { }); req.on('end', function() { - assert.equal('PING', body); + assert.strictEqual('PING', body); res.writeHead(200); res.end('PONG'); }); @@ -43,7 +43,7 @@ function serverOff() { pingping(); } -var responses = []; +const responses = []; function afterPing(result) { @@ -81,14 +81,14 @@ function afterPing(result) { function ping() { console.error('making req'); - var opt = { + const opt = { port: common.PORT, path: '/ping', method: 'POST' }; - var req = http.request(opt, function(res) { - var body = ''; + const req = http.request(opt, function(res) { + let body = ''; res.setEncoding('utf8'); res.on('data', function(chunk) { @@ -96,7 +96,7 @@ function ping() { }); res.on('end', function() { - assert.equal('PONG', body); + assert.strictEqual('PONG', body); assert.ok(!hadError); gotEnd = true; afterPing('success'); @@ -105,8 +105,8 @@ function ping() { req.end('PING'); - var gotEnd = false; - var hadError = false; + let gotEnd = false; + let hadError = false; req.on('error', function(error) { console.log('Error making ping req: ' + error); @@ -128,5 +128,5 @@ process.on('exit', function() { console.error("process.on('exit')"); console.error(responses); - assert.equal(8, responses.length); + assert.strictEqual(8, responses.length); }); diff --git a/test/sequential/test-regress-GH-877.js b/test/sequential/test-regress-GH-877.js index 5b0aac802e16a3..1a0d7a48e5758c 100644 --- a/test/sequential/test-regress-GH-877.js +++ b/test/sequential/test-regress-GH-877.js @@ -1,43 +1,43 @@ 'use strict'; -var common = require('../common'); -var http = require('http'); -var assert = require('assert'); +const common = require('../common'); +const http = require('http'); +const assert = require('assert'); -var N = 20; -var responses = 0; -var maxQueued = 0; +const N = 20; +let responses = 0; +let maxQueued = 0; -var agent = http.globalAgent; +const agent = http.globalAgent; agent.maxSockets = 10; -var server = http.createServer(function(req, res) { +const server = http.createServer(function(req, res) { res.writeHead(200); res.end('Hello World\n'); }); -var addrString = agent.getName({ host: '127.0.0.1', port: common.PORT }); +const addrString = agent.getName({ host: '127.0.0.1', port: common.PORT }); server.listen(common.PORT, '127.0.0.1', function() { - for (var i = 0; i < N; i++) { - var options = { + for (let i = 0; i < N; i++) { + const options = { host: '127.0.0.1', port: common.PORT }; - var req = http.get(options, function(res) { + const req = http.get(options, function(res) { if (++responses === N) { server.close(); } res.resume(); }); - assert.equal(req.agent, agent); + assert.strictEqual(req.agent, agent); console.log('Socket: ' + agent.sockets[addrString].length + '/' + agent.maxSockets + ' queued: ' + (agent.requests[addrString] ? agent.requests[addrString].length : 0)); - var agentRequests = agent.requests[addrString] ? + const agentRequests = agent.requests[addrString] ? agent.requests[addrString].length : 0; if (maxQueued < agentRequests) { diff --git a/test/sequential/test-regress-GH-897.js b/test/sequential/test-regress-GH-897.js deleted file mode 100644 index 7b1297efd5a1b7..00000000000000 --- a/test/sequential/test-regress-GH-897.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -// Test for bug where a timer duration greater than 0 ms but less than 1 ms -// resulted in the duration being set for 1000 ms. The expected behavior is -// that the timeout would be set for 1 ms, and thus fire more-or-less -// immediately. -// -// Ref: https://github.com/nodejs/node-v0.x-archive/pull/897 - -const common = require('../common'); -const assert = require('assert'); - -const t = Date.now(); -setTimeout(common.mustCall(function() { - const diff = Date.now() - t; - assert.ok(diff < 100, `timer fired after ${diff} ms`); -}), 0.1); diff --git a/test/sequential/test-repl-timeout-throw.js b/test/sequential/test-repl-timeout-throw.js index 0188b3b8c502d8..69664195567882 100644 --- a/test/sequential/test-repl-timeout-throw.js +++ b/test/sequential/test-repl-timeout-throw.js @@ -8,7 +8,7 @@ const child = spawn(process.execPath, [ '-i' ], { stdio: [null, null, 2] }); -var stdout = ''; +let stdout = ''; child.stdout.setEncoding('utf8'); child.stdout.on('data', function(c) { process.stdout.write(c); @@ -30,14 +30,14 @@ child.stdout.once('data', function() { setTimeout(fsTest, 50); function fsTest() { - var f = JSON.stringify(__filename); + const f = JSON.stringify(__filename); child.stdin.write('fs.readFile(' + f + ', thrower);\n'); setTimeout(eeTest, 50); } function eeTest() { child.stdin.write('setTimeout(function() {\n' + - ' var events = require("events");\n' + + ' const events = require("events");\n' + ' var e = new events.EventEmitter;\n' + ' process.nextTick(function() {\n' + ' e.on("x", thrower);\n' + @@ -54,6 +54,6 @@ child.stdout.once('data', function() { child.on('close', function(c) { assert.strictEqual(c, 0); // make sure we got 3 throws, in the end. - var lastLine = stdout.trim().split(/\r?\n/).pop(); + const lastLine = stdout.trim().split(/\r?\n/).pop(); assert.strictEqual(lastLine, '> 3'); }); diff --git a/test/sequential/test-require-cache-without-stat.js b/test/sequential/test-require-cache-without-stat.js index 2571583f7690b5..d90bbd2b7bb71f 100644 --- a/test/sequential/test-require-cache-without-stat.js +++ b/test/sequential/test-require-cache-without-stat.js @@ -2,17 +2,17 @@ // We've experienced a regression where the module loader stats a bunch of // directories on require() even if it's been called before. The require() // should caching the request. -var common = require('../common'); -var fs = require('fs'); -var assert = require('assert'); +const common = require('../common'); +const fs = require('fs'); +const assert = require('assert'); -var counter = 0; +let counter = 0; // Switch out the two stat implementations so that they increase a counter // each time they are called. -var _statSync = fs.statSync; -var _stat = fs.stat; +const _statSync = fs.statSync; +const _stat = fs.stat; fs.statSync = function() { counter++; @@ -31,7 +31,7 @@ require('./../fixtures/a.js'); require('http'); console.log('counterBefore = %d', counter); -var counterBefore = counter; +const counterBefore = counter; // Now load the module a bunch of times with equivalent paths. // stat should not be called. @@ -47,6 +47,6 @@ for (let i = 0; i < 100; i++) { } console.log('counterAfter = %d', counter); -var counterAfter = counter; +const counterAfter = counter; -assert.equal(counterBefore, counterAfter); +assert.strictEqual(counterBefore, counterAfter); diff --git a/test/sequential/test-stream2-fs.js b/test/sequential/test-stream2-fs.js index 7baba6e63b81b0..58a66ef99df9cf 100644 --- a/test/sequential/test-stream2-fs.js +++ b/test/sequential/test-stream2-fs.js @@ -1,19 +1,19 @@ 'use strict'; -var common = require('../common'); -var assert = require('assert'); +const common = require('../common'); +const assert = require('assert'); -var fs = require('fs'); -var FSReadable = fs.ReadStream; +const fs = require('fs'); +const FSReadable = fs.ReadStream; -var path = require('path'); -var file = path.resolve(common.fixturesDir, 'x1024.txt'); +const path = require('path'); +const file = path.resolve(common.fixturesDir, 'x1024.txt'); -var size = fs.statSync(file).size; +const size = fs.statSync(file).size; -var expectLengths = [1024]; +const expectLengths = [1024]; -var util = require('util'); -var Stream = require('stream'); +const util = require('util'); +const Stream = require('stream'); util.inherits(TestWriter, Stream); @@ -34,12 +34,12 @@ TestWriter.prototype.end = function(c) { this.emit('results', this.buffer); }; -var r = new FSReadable(file); -var w = new TestWriter(); +const r = new FSReadable(file); +const w = new TestWriter(); w.on('results', function(res) { console.error(res, w.length); - assert.equal(w.length, size); + assert.strictEqual(w.length, size); assert.deepStrictEqual(res.map(function(c) { return c.length; }), expectLengths); diff --git a/test/sequential/test-stream2-stderr-sync.js b/test/sequential/test-stream2-stderr-sync.js index c7daaa6b083205..08f35e597ce357 100644 --- a/test/sequential/test-stream2-stderr-sync.js +++ b/test/sequential/test-stream2-stderr-sync.js @@ -4,19 +4,19 @@ require('../common'); function parent() { - var spawn = require('child_process').spawn; - var assert = require('assert'); - var i = 0; + const spawn = require('child_process').spawn; + const assert = require('assert'); + let i = 0; children.forEach(function(_, c) { - var child = spawn(process.execPath, [__filename, '' + c]); - var err = ''; + const child = spawn(process.execPath, [__filename, '' + c]); + let err = ''; child.stderr.on('data', function(c) { err += c; }); child.on('close', function() { - assert.equal(err, 'child ' + c + '\nfoo\nbar\nbaz\n'); + assert.strictEqual(err, 'child ' + c + '\nfoo\nbar\nbaz\n'); console.log('ok %d child #%d', ++i, c); if (i === children.length) console.log('1..' + i); @@ -42,8 +42,8 @@ function child1() { // using a net socket function child2() { - var net = require('net'); - var socket = new net.Socket({ + const net = require('net'); + const socket = new net.Socket({ fd: 2, readable: false, writable: true}); @@ -62,7 +62,7 @@ function child4() { process.stderr.write('child 4\nfoo\nbar\nbaz\n'); } -var children = [ child0, child1, child2, child3, child4 ]; +const children = [ child0, child1, child2, child3, child4 ]; if (!process.argv[2]) { parent(); diff --git a/test/sequential/test-timers-blocking-callback.js b/test/sequential/test-timers-blocking-callback.js index e4e85cddc6302d..73b0f13997716d 100644 --- a/test/sequential/test-timers-blocking-callback.js +++ b/test/sequential/test-timers-blocking-callback.js @@ -28,9 +28,9 @@ const Timer = process.binding('timer_wrap').Timer; const TIMEOUT = 100; -var nbBlockingCallbackCalls = 0; -var latestDelay = 0; -var timeCallbackScheduled = 0; +let nbBlockingCallbackCalls = 0; +let latestDelay = 0; +let timeCallbackScheduled = 0; function initTest() { nbBlockingCallbackCalls = 0; diff --git a/test/sequential/test-util-debug.js b/test/sequential/test-util-debug.js index 1159278efa475d..08988997e735a6 100644 --- a/test/sequential/test-util-debug.js +++ b/test/sequential/test-util-debug.js @@ -1,6 +1,6 @@ 'use strict'; const common = require('../common'); -var assert = require('assert'); +const assert = require('assert'); if (process.argv[2] === 'child') child(); @@ -17,44 +17,43 @@ function parent() { } function test(environ, shouldWrite) { - var expectErr = ''; + let expectErr = ''; if (shouldWrite) { expectErr = 'TUD %PID%: this { is: \'a\' } /debugging/\n' + 'TUD %PID%: number=1234 string=asdf obj={"foo":"bar"}\n'; } - var expectOut = 'ok\n'; + const expectOut = 'ok\n'; - var spawn = require('child_process').spawn; - var child = spawn(process.execPath, [__filename, 'child'], { + const spawn = require('child_process').spawn; + const child = spawn(process.execPath, [__filename, 'child'], { env: Object.assign(process.env, { NODE_DEBUG: environ }) }); expectErr = expectErr.split('%PID%').join(child.pid); - var err = ''; + let err = ''; child.stderr.setEncoding('utf8'); - child.stderr.on('data', function(c) { + child.stderr.on('data', (c) => { err += c; }); - var out = ''; + let out = ''; child.stdout.setEncoding('utf8'); - child.stdout.on('data', function(c) { + child.stdout.on('data', (c) => { out += c; }); - child.on('close', common.mustCall(function(c) { + child.on('close', common.mustCall((c) => { assert(!c); - assert.equal(err, expectErr); - assert.equal(out, expectOut); - console.log('ok %j %j', environ, shouldWrite); + assert.strictEqual(err, expectErr); + assert.strictEqual(out, expectOut); })); } function child() { - var util = require('util'); - var debug = util.debuglog('tud'); + const util = require('util'); + const debug = util.debuglog('tud'); debug('this', { is: 'a' }, /debugging/); debug('number=%d string=%s obj=%j', 1234, 'asdf', { foo: 'bar' }); console.log('ok'); diff --git a/test/sequential/test-vm-timeout-rethrow.js b/test/sequential/test-vm-timeout-rethrow.js index f0f9c0b9c51063..a434e2ae3e6978 100644 --- a/test/sequential/test-vm-timeout-rethrow.js +++ b/test/sequential/test-vm-timeout-rethrow.js @@ -1,15 +1,15 @@ 'use strict'; require('../common'); -var assert = require('assert'); -var vm = require('vm'); -var spawn = require('child_process').spawn; +const assert = require('assert'); +const vm = require('vm'); +const spawn = require('child_process').spawn; if (process.argv[2] === 'child') { - var code = 'var j = 0;\n' + - 'for (var i = 0; i < 1000000; i++) j += add(i, i + 1);\n' + - 'j;'; + const code = 'let j = 0;\n' + + 'for (let i = 0; i < 1000000; i++) j += add(i, i + 1);\n' + + 'j;'; - var ctx = vm.createContext({ + const ctx = vm.createContext({ add: function(x, y) { return x + y; } @@ -17,8 +17,8 @@ if (process.argv[2] === 'child') { vm.runInContext(code, ctx, { timeout: 1 }); } else { - var proc = spawn(process.execPath, process.argv.slice(1).concat('child')); - var err = ''; + const proc = spawn(process.execPath, process.argv.slice(1).concat('child')); + let err = ''; proc.stderr.on('data', function(data) { err += data; }); diff --git a/test/timers/test-timers-reliability.js b/test/timers/test-timers-reliability.js index 0626c45826781b..9a9834aefecc7f 100644 --- a/test/timers/test-timers-reliability.js +++ b/test/timers/test-timers-reliability.js @@ -3,11 +3,11 @@ require('../common'); -var Timer = process.binding('timer_wrap').Timer; -var assert = require('assert'); +const Timer = process.binding('timer_wrap').Timer; +const assert = require('assert'); -var timerFired = false; -var intervalFired = false; +let timerFired = false; +let intervalFired = false; /* * This test case aims at making sure that timing utilities such @@ -31,7 +31,7 @@ var intervalFired = false; * is vulnerable to time drift or inconsistent time changes. */ -var monoTimer = new Timer(); +const monoTimer = new Timer(); monoTimer[Timer.kOnTimeout] = function() { /* * Make sure that setTimeout's and setInterval's callbacks have @@ -48,7 +48,7 @@ setTimeout(function() { timerFired = true; }, 200); -var interval = setInterval(function() { +const interval = setInterval(function() { intervalFired = true; clearInterval(interval); }, 200); diff --git a/tools/doc/README.md b/tools/doc/README.md index 6985bc130d62c5..0535243e92f63b 100644 --- a/tools/doc/README.md +++ b/tools/doc/README.md @@ -99,10 +99,9 @@ This event is emitted on instances of SomeClass, not on the module itself. ``` -* Modules have (description, Properties, Functions, Classes, Examples) -* Properties have (type, description) -* Functions have (list of arguments, description) * Classes have (description, Properties, Methods, Events) * Events have (list of arguments, description) +* Functions have (list of arguments, description) * Methods have (list of arguments, description) +* Modules have (description, Properties, Functions, Classes, Examples) * Properties have (type, description) diff --git a/tools/doc/generate.js b/tools/doc/generate.js index 31b23c52a08ba7..b7fcf0d4f90da5 100644 --- a/tools/doc/generate.js +++ b/tools/doc/generate.js @@ -11,16 +11,19 @@ let format = 'json'; let template = null; let inputFile = null; let nodeVersion = null; +let analytics = null; args.forEach(function(arg) { - if (!arg.match(/^--/)) { + if (!arg.startsWith('--')) { inputFile = arg; - } else if (arg.match(/^--format=/)) { + } else if (arg.startsWith('--format=')) { format = arg.replace(/^--format=/, ''); - } else if (arg.match(/^--template=/)) { + } else if (arg.startsWith('--template=')) { template = arg.replace(/^--template=/, ''); - } else if (arg.match(/^--node-version=/)) { + } else if (arg.startsWith('--node-version=')) { nodeVersion = arg.replace(/^--node-version=/, ''); + } else if (arg.startsWith('--analytics=')) { + analytics = arg.replace(/^--analytics=/, ''); } }); @@ -54,6 +57,7 @@ function next(er, input) { filename: inputFile, template: template, nodeVersion: nodeVersion, + analytics: analytics, }, function(er, html) { diff --git a/tools/doc/html.js b/tools/doc/html.js index c0790ffca5f0d4..4b1c0a0e69b2c1 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -67,6 +67,7 @@ function toHTML(opts, cb) { filename: opts.filename, template: template, nodeVersion: nodeVersion, + analytics: opts.analytics, }, cb); }); } @@ -128,6 +129,13 @@ function render(opts, cb) { gtocData.replace('class="nav-' + id, 'class="nav-' + id + ' active') ); + if (opts.analytics) { + template = template.replace( + '', + analyticsScript(opts.analytics) + ); + } + // content has to be the last thing we do with // the lexed tokens, because it's destructive. const content = marked.parser(lexed); @@ -137,6 +145,23 @@ function render(opts, cb) { }); } +function analyticsScript(analytics) { + return ` + + + `; +} + // handle general body-text replacements // for example, link man page references to the actual page function parseText(lexed) { diff --git a/tools/doc/type-parser.js b/tools/doc/type-parser.js index 38451b0e16b358..0ac15a14b93341 100644 --- a/tools/doc/type-parser.js +++ b/tools/doc/type-parser.js @@ -1,9 +1,8 @@ 'use strict'; const nodeDocUrl = ''; -const jsDocUrl = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/' + - 'Reference/Global_Objects/'; -const jsPrimitiveUrl = 'https://developer.mozilla.org/en-US/docs/Web/' + - 'JavaScript/Data_structures'; +const jsDocPrefix = 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/'; +const jsDocUrl = jsDocPrefix + 'Reference/Global_Objects/'; +const jsPrimitiveUrl = jsDocPrefix + 'Data_structures'; const jsPrimitives = { 'Integer': 'Number', // this is for extending 'Number': 'Number', @@ -37,6 +36,8 @@ const typeMap = { 'http.IncomingMessage': 'http.html#http_class_http_incomingmessage', 'http.Server': 'http.html#http_class_http_server', 'http.ServerResponse': 'http.html#http_class_http_serverresponse', + 'Iterator': jsDocPrefix + + 'Reference/Iteration_protocols#The_iterator_protocol' }; module.exports = { diff --git a/tools/eslint-rules/align-function-arguments.js b/tools/eslint-rules/align-function-arguments.js deleted file mode 100644 index 015552489a9d44..00000000000000 --- a/tools/eslint-rules/align-function-arguments.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * @fileoverview Align arguments in multiline function calls - * @author Rich Trott - */ -'use strict'; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -function checkArgumentAlignment(context, node) { - - function isNodeFirstInLine(node, byEndLocation) { - const firstToken = byEndLocation === true ? context.getLastToken(node, 1) : - context.getTokenBefore(node); - const startLine = byEndLocation === true ? node.loc.end.line : - node.loc.start.line; - const endLine = firstToken ? firstToken.loc.end.line : -1; - - return startLine !== endLine; - } - - if (node.arguments.length === 0) - return; - - var msg = ''; - const first = node.arguments[0]; - var currentLine = first.loc.start.line; - const firstColumn = first.loc.start.column; - - const ignoreTypes = [ - 'ArrowFunctionExpression', - 'FunctionExpression', - 'ObjectExpression', - ]; - - const args = node.arguments; - - // For now, don't bother trying to validate potentially complicating things - // like closures. Different people will have very different ideas and it's - // probably best to implement configuration options. - if (args.some((node) => { return ignoreTypes.indexOf(node.type) !== -1; })) { - return; - } - - if (!isNodeFirstInLine(node)) { - return; - } - - var misaligned; - - args.slice(1).forEach((argument) => { - if (!misaligned) { - if (argument.loc.start.line === currentLine + 1) { - if (argument.loc.start.column !== firstColumn) { - if (isNodeFirstInLine(argument)) { - msg = 'Function argument in column ' + - `${argument.loc.start.column + 1}, ` + - `expected in ${firstColumn + 1}`; - misaligned = argument; - } - } - } - } - currentLine = argument.loc.start.line; - }); - - if (msg) - context.report(misaligned, msg); -} - -module.exports = function(context) { - return { - 'CallExpression': (node) => checkArgumentAlignment(context, node) - }; -}; diff --git a/tools/eslint-rules/no-useless-regex-char-class-escape.js b/tools/eslint-rules/no-useless-regex-char-class-escape.js deleted file mode 100644 index e18077098daee2..00000000000000 --- a/tools/eslint-rules/no-useless-regex-char-class-escape.js +++ /dev/null @@ -1,190 +0,0 @@ -/** - * @fileoverview Disallow useless escape in regex character class - * Based on 'no-useless-escape' rule - */ -'use strict'; - -//------------------------------------------------------------------------------ -// Rule Definition -//------------------------------------------------------------------------------ - -const REGEX_CHARCLASS_ESCAPES = new Set('\\bcdDfnrsStvwWxu0123456789]'); - -/** - * Parses a regular expression into a list of regex character class list. - * @param {string} regExpText raw text used to create the regular expression - * @returns {Object[]} A list of character classes tokens with index and - * escape info - * @example - * - * parseRegExpCharClass('a\\b[cd-]') - * - * returns: - * [ - * { - * empty: false, - * start: 4, - * end: 6, - * chars: [ - * {text: 'c', index: 4, escaped: false}, - * {text: 'd', index: 5, escaped: false}, - * {text: '-', index: 6, escaped: false} - * ] - * } - * ] - */ - -function parseRegExpCharClass(regExpText) { - const charList = []; - let charListIdx = -1; - const initState = { - escapeNextChar: false, - inCharClass: false, - startingCharClass: false - }; - - regExpText.split('').reduce((state, char, index) => { - if (!state.escapeNextChar) { - if (char === '\\') { - return Object.assign(state, { escapeNextChar: true }); - } - if (char === '[' && !state.inCharClass) { - charListIdx += 1; - charList.push({ start: index + 1, chars: [], end: -1 }); - return Object.assign(state, { - inCharClass: true, - startingCharClass: true - }); - } - if (char === ']' && state.inCharClass) { - const charClass = charList[charListIdx]; - charClass.empty = charClass.chars.length === 0; - if (charClass.empty) { - charClass.start = charClass.end = -1; - } else { - charList[charListIdx].end = index - 1; - } - return Object.assign(state, { - inCharClass: false, - startingCharClass: false - }); - } - } - if (state.inCharClass) { - charList[charListIdx].chars.push({ - text: char, - index, escaped: - state.escapeNextChar - }); - } - return Object.assign(state, { - escapeNextChar: false, - startingCharClass: false - }); - }, initState); - - return charList; -} - -module.exports = { - meta: { - docs: { - description: 'disallow unnecessary regex characer class escape sequences', - category: 'Best Practices', - recommended: false - }, - fixable: 'code', - schema: [{ - 'type': 'object', - 'properties': { - 'override': { - 'type': 'array', - 'items': { 'type': 'string' }, - 'uniqueItems': true - } - }, - 'additionalProperties': false - }] - }, - - create(context) { - const overrideSet = new Set(context.options.length ? - context.options[0].override || [] : - []); - - /** - * Reports a node - * @param {ASTNode} node The node to report - * @param {number} startOffset The backslash's offset - * from the start of the node - * @param {string} character The uselessly escaped character - * (not including the backslash) - * @returns {void} - */ - function report(node, startOffset, character) { - context.report({ - node, - loc: { - line: node.loc.start.line, - column: node.loc.start.column + startOffset - }, - message: 'Unnecessary regex escape in character' + - ' class: \\{{character}}', - data: { character }, - fix: (fixer) => { - const start = node.range[0] + startOffset; - return fixer.replaceTextRange([start, start + 1], ''); - } - }); - } - - /** - * Checks if a node has superflous escape character - * in regex character class. - * - * @param {ASTNode} node - node to check. - * @returns {void} - */ - function check(node) { - if (node.regex) { - parseRegExpCharClass(node.regex.pattern) - .forEach((charClass) => { - charClass - .chars - // The '-' character is a special case if is not at - // either edge of the character class. To account for this, - // filter out '-' characters that appear in the middle of a - // character class. - .filter((charInfo) => !(charInfo.text === '-' && - (charInfo.index !== charClass.start && - charInfo.index !== charClass.end))) - - // The '^' character is a special case if it's at the beginning - // of the character class. To account for this, filter out '^' - // characters that appear at the start of a character class. - // - .filter((charInfo) => !(charInfo.text === '^' && - charInfo.index === charClass.start)) - - // Filter out characters that aren't escaped. - .filter((charInfo) => charInfo.escaped) - - // Filter out characters that are valid to escape, based on - // their position in the regular expression. - .filter((charInfo) => !REGEX_CHARCLASS_ESCAPES.has(charInfo.text)) - - // Filter out overridden character list. - .filter((charInfo) => !overrideSet.has(charInfo.text)) - - // Report all the remaining characters. - .forEach((charInfo) => - report(node, charInfo.index, charInfo.text)); - }); - } - } - - return { - Literal: check - }; - } -}; diff --git a/tools/eslint-rules/prefer-assert-iferror.js b/tools/eslint-rules/prefer-assert-iferror.js new file mode 100644 index 00000000000000..0da272d5f670e3 --- /dev/null +++ b/tools/eslint-rules/prefer-assert-iferror.js @@ -0,0 +1,42 @@ +/** + * @fileoverview Prohibit the `if (err) throw err;` pattern + * @author Teddy Katz + */ + +'use strict'; + +module.exports = { + create(context) { + const sourceCode = context.getSourceCode(); + + function hasSameTokens(nodeA, nodeB) { + const aTokens = sourceCode.getTokens(nodeA); + const bTokens = sourceCode.getTokens(nodeB); + + return aTokens.length === bTokens.length && + aTokens.every((token, index) => { + return token.type === bTokens[index].type && + token.value === bTokens[index].value; + }); + } + + return { + IfStatement(node) { + const firstStatement = node.consequent.type === 'BlockStatement' ? + node.consequent.body[0] : + node.consequent; + if ( + firstStatement && + firstStatement.type === 'ThrowStatement' && + hasSameTokens(node.test, firstStatement.argument) + ) { + context.report({ + node: firstStatement, + message: 'Use assert.ifError({{argument}}) instead.', + data: {argument: sourceCode.getText(node.test)} + }); + } + } + }; + } +}; diff --git a/tools/eslint-rules/timer-arguments.js b/tools/eslint-rules/timer-arguments.js new file mode 100644 index 00000000000000..4dd7816ff82ff2 --- /dev/null +++ b/tools/eslint-rules/timer-arguments.js @@ -0,0 +1,25 @@ +/** + * @fileoverview Require at least two arguments when calling setTimeout() or + * setInterval(). + * @author Rich Trott + */ +'use strict'; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +function isTimer(name) { + return ['setTimeout', 'setInterval'].includes(name); +} + +module.exports = function(context) { + return { + 'CallExpression': function(node) { + const name = node.callee.name; + if (isTimer(name) && node.arguments.length < 2) { + context.report(node, `${name} must have at least 2 arguments`); + } + } + }; +}; diff --git a/tools/eslint/LICENSE b/tools/eslint/LICENSE index d41bdf7951f077..777939e8fc1a7f 100644 --- a/tools/eslint/LICENSE +++ b/tools/eslint/LICENSE @@ -1,5 +1,5 @@ ESLint -Copyright jQuery Foundation and other contributors, https://jquery.org/ +Copyright JS Foundation and other contributors, https://js.foundation 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/tools/eslint/README.md b/tools/eslint/README.md index 4d84a7e3dfd5cd..dcd42cff46685a 100644 --- a/tools/eslint/README.md +++ b/tools/eslint/README.md @@ -13,7 +13,7 @@ [Rules](http://eslint.org/docs/rules/) | [Contributing](http://eslint.org/docs/developer-guide/contributing) | [Reporting Bugs](http://eslint.org/docs/developer-guide/contributing/reporting-bugs) | -[Code of Conduct](https://jquery.org/conduct/) | +[Code of Conduct](https://js.foundation/conduct/) | [Twitter](https://twitter.com/geteslint) | [Mailing List](https://groups.google.com/group/eslint) | [Chat Room](https://gitter.im/eslint/eslint) @@ -210,10 +210,7 @@ ESLint has full support for ECMAScript 6. By default, this support is off. You c ESLint doesn't natively support experimental ECMAScript language features. You can use [babel-eslint](https://github.com/babel/babel-eslint) to use any option available in Babel. -Once a language feature has been adopted into the ECMAScript standard, we will accept -issues and pull requests related to the new feature, subject to our [contributing -guidelines](http://eslint.org/docs/developer-guide/contributing). Until then, please use -the appropriate parser and plugin(s) for your experimental feature. +Once a language feature has been adopted into the ECMAScript standard (stage 4 according to the [TC39 process](https://tc39.github.io/process-document/)), we will accept issues and pull requests related to the new feature, subject to our [contributing guidelines](http://eslint.org/docs/developer-guide/contributing). Until then, please use the appropriate parser and plugin(s) for your experimental feature. ### Where to ask for help? diff --git a/tools/eslint/bin/eslint.js b/tools/eslint/bin/eslint.js index d85d29d7a5bdae..bf534971f24d9b 100755 --- a/tools/eslint/bin/eslint.js +++ b/tools/eslint/bin/eslint.js @@ -5,7 +5,7 @@ * @author Nicholas C. Zakas */ -/* eslint no-console:off, no-process-exit:off */ +/* eslint no-console:off */ "use strict"; @@ -36,7 +36,7 @@ const concat = require("concat-stream"), // Execution //------------------------------------------------------------------------------ -process.on("uncaughtException", function(err) { +process.once("uncaughtException", err => { // lazy load const lodash = require("lodash"); @@ -51,17 +51,17 @@ process.on("uncaughtException", function(err) { console.log(err.stack); } - process.exit(1); + process.exitCode = 1; }); if (useStdIn) { - process.stdin.pipe(concat({ encoding: "string" }, function(text) { + process.stdin.pipe(concat({ encoding: "string" }, text => { process.exitCode = cli.execute(process.argv, text); })); } else if (init) { const configInit = require("../lib/config/config-initializer"); - configInit.initializeConfig(function(err) { + configInit.initializeConfig(err => { if (err) { process.exitCode = 1; console.error(err.message); diff --git a/tools/eslint/conf/eslint.json b/tools/eslint/conf/eslint.json index 4d54e3ab6dac6a..81f5bb8aa5ee82 100755 --- a/tools/eslint/conf/eslint.json +++ b/tools/eslint/conf/eslint.json @@ -4,6 +4,7 @@ "rules": { "no-alert": "off", "no-array-constructor": "off", + "no-await-in-loop": "off", "no-bitwise": "off", "no-caller": "off", "no-case-declarations": "error", @@ -41,7 +42,7 @@ "no-fallthrough": "error", "no-floating-decimal": "off", "no-func-assign": "error", - "no-global-assign": "off", + "no-global-assign": "error", "no-implicit-coercion": "off", "no-implicit-globals": "off", "no-implied-eval": "off", @@ -63,9 +64,9 @@ "no-multi-spaces": "off", "no-multi-str": "off", "no-multiple-empty-lines": "off", - "no-native-reassign": "error", + "no-native-reassign": "off", "no-negated-condition": "off", - "no-negated-in-lhs": "error", + "no-negated-in-lhs": "off", "no-nested-ternary": "off", "no-new": "off", "no-new-func": "off", @@ -91,6 +92,7 @@ "no-restricted-properties": "off", "no-restricted-syntax": "off", "no-return-assign": "off", + "no-return-await": "off", "no-script-url": "off", "no-self-assign": "error", "no-self-compare": "off", @@ -115,7 +117,7 @@ "no-unneeded-ternary": "off", "no-unreachable": "error", "no-unsafe-finally": "error", - "no-unsafe-negation": "off", + "no-unsafe-negation": "error", "no-unused-expressions": "off", "no-unused-labels": "error", "no-unused-vars": "error", @@ -126,6 +128,7 @@ "no-useless-constructor": "off", "no-useless-escape": "off", "no-useless-rename": "off", + "no-useless-return": "off", "no-void": "off", "no-var": "off", "no-warning-comments": "off", @@ -141,6 +144,7 @@ "brace-style": "off", "callback-return": "off", "camelcase": "off", + "capitalized-comments": "off", "class-methods-use-this": "off", "comma-dangle": "off", "comma-spacing": "off", @@ -200,6 +204,7 @@ "padded-blocks": "off", "prefer-arrow-callback": "off", "prefer-const": "off", + "prefer-destructuring": "off", "prefer-numeric-literals": "off", "prefer-reflect": "off", "prefer-rest-params": "off", @@ -208,6 +213,7 @@ "quote-props": "off", "quotes": "off", "radix": "off", + "require-await": "off", "require-jsdoc": "off", "require-yield": "error", "rest-spread-spacing": "off", diff --git a/tools/eslint/lib/ast-utils.js b/tools/eslint/lib/ast-utils.js index 9e171ea316fc31..46dfebe101caa2 100644 --- a/tools/eslint/lib/ast-utils.js +++ b/tools/eslint/lib/ast-utils.js @@ -10,6 +10,7 @@ //------------------------------------------------------------------------------ const esutils = require("esutils"); +const lodash = require("lodash"); //------------------------------------------------------------------------------ // Helpers @@ -21,7 +22,7 @@ const arrayOrTypedArrayPattern = /Array$/; const arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/; const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/; const breakableTypePattern = /^(?:(?:Do)?While|For(?:In|Of)?|Switch)Statement$/; -const thisTagPattern = /^[\s\*]*@this/m; +const thisTagPattern = /^[\s*]*@this/m; /** * Checks reference if is non initializer and writable. @@ -83,6 +84,56 @@ function getUpperFunction(node) { return null; } +/** + * Checks whether a given node is a function node or not. + * The following types are function nodes: + * + * - ArrowFunctionExpression + * - FunctionDeclaration + * - FunctionExpression + * + * @param {ASTNode|null} node - A node to check. + * @returns {boolean} `true` if the node is a function node. + */ +function isFunction(node) { + return Boolean(node && anyFunctionPattern.test(node.type)); +} + +/** + * Checks whether a given node is a loop node or not. + * The following types are loop nodes: + * + * - DoWhileStatement + * - ForInStatement + * - ForOfStatement + * - ForStatement + * - WhileStatement + * + * @param {ASTNode|null} node - A node to check. + * @returns {boolean} `true` if the node is a loop node. + */ +function isLoop(node) { + return Boolean(node && anyLoopPattern.test(node.type)); +} + +/** + * Checks whether the given node is in a loop or not. + * + * @param {ASTNode} node - The node to check. + * @returns {boolean} `true` if the node is in a loop. + */ +function isInLoop(node) { + while (node && !isFunction(node)) { + if (isLoop(node)) { + return true; + } + + node = node.parent; + } + + return false; +} + /** * Checks whether or not a node is `null` or `undefined`. * @param {ASTNode} node - A node to check. @@ -176,9 +227,7 @@ function hasJSDocThisTag(node, sourceCode) { // because callbacks don't have its JSDoc comment. // e.g. // sinon.test(/* @this sinon.Sandbox */function() { this.spy(); }); - return sourceCode.getComments(node).leading.some(function(comment) { - return thisTagPattern.test(comment.value); - }); + return sourceCode.getComments(node).leading.some(comment => thisTagPattern.test(comment.value)); } /** @@ -197,6 +246,59 @@ function isParenthesised(sourceCode, node) { nextToken.value === ")" && nextToken.range[0] >= node.range[1]; } +/** + * Gets the `=>` token of the given arrow function node. + * + * @param {ASTNode} node - The arrow function node to get. + * @param {SourceCode} sourceCode - The source code object to get tokens. + * @returns {Token} `=>` token. + */ +function getArrowToken(node, sourceCode) { + let token = sourceCode.getTokenBefore(node.body); + + while (token.value !== "=>") { + token = sourceCode.getTokenBefore(token); + } + + return token; +} + +/** + * Gets the `(` token of the given function node. + * + * @param {ASTNode} node - The function node to get. + * @param {SourceCode} sourceCode - The source code object to get tokens. + * @returns {Token} `(` token. + */ +function getOpeningParenOfParams(node, sourceCode) { + let token = node.id ? sourceCode.getTokenAfter(node.id) : sourceCode.getFirstToken(node); + + while (token.value !== "(") { + token = sourceCode.getTokenAfter(token); + } + + return token; +} + +const lineIndexCache = new WeakMap(); + +/** + * Gets the range index for the first character in each of the lines of `sourceCode`. + * @param {SourceCode} sourceCode A sourceCode object + * @returns {number[]} The indices of the first characters in the each of the lines of the code + */ +function getLineIndices(sourceCode) { + + if (!lineIndexCache.has(sourceCode)) { + const lineIndices = (sourceCode.text.match(/[^\r\n\u2028\u2029]*(\r\n|\r|\n|\u2028|\u2029)/g) || []) + .reduce((indices, line) => indices.concat(indices[indices.length - 1] + line.length), [0]); + + // Store the sourceCode object in a WeakMap to avoid iterating over all of the lines every time a sourceCode object is passed in. + lineIndexCache.set(sourceCode, lineIndices); + } + return lineIndexCache.get(sourceCode); +} + //------------------------------------------------------------------------------ // Public Interface //------------------------------------------------------------------------------ @@ -218,6 +320,9 @@ module.exports = { isCallee, isES5Constructor, getUpperFunction, + isFunction, + isLoop, + isInLoop, isArrayFromMethod, isParenthesised, @@ -583,35 +688,23 @@ module.exports = { }, /** - * Checks whether a given node is a loop node or not. - * The following types are loop nodes: + * Checks whether the given node is an empty block node or not. * - * - DoWhileStatement - * - ForInStatement - * - ForOfStatement - * - ForStatement - * - WhileStatement - * - * @param {ASTNode|null} node - A node to check. - * @returns {boolean} `true` if the node is a loop node. + * @param {ASTNode|null} node - The node to check. + * @returns {boolean} `true` if the node is an empty block. */ - isLoop(node) { - return Boolean(node && anyLoopPattern.test(node.type)); + isEmptyBlock(node) { + return Boolean(node && node.type === "BlockStatement" && node.body.length === 0); }, /** - * Checks whether a given node is a function node or not. - * The following types are function nodes: + * Checks whether the given node is an empty function node or not. * - * - ArrowFunctionExpression - * - FunctionDeclaration - * - FunctionExpression - * - * @param {ASTNode|null} node - A node to check. - * @returns {boolean} `true` if the node is a function node. + * @param {ASTNode|null} node - The node to check. + * @returns {boolean} `true` if the node is an empty function. */ - isFunction(node) { - return Boolean(node && anyFunctionPattern.test(node.type)); + isEmptyFunction(node) { + return isFunction(node) && module.exports.isEmptyBlock(node.body); }, /** @@ -738,5 +831,271 @@ module.exports = { */ isDecimalInteger(node) { return node.type === "Literal" && typeof node.value === "number" && /^(0|[1-9]\d*)$/.test(node.raw); + }, + + /** + * Gets the name and kind of the given function node. + * + * - `function foo() {}` .................... `function 'foo'` + * - `(function foo() {})` .................. `function 'foo'` + * - `(function() {})` ...................... `function` + * - `function* foo() {}` ................... `generator function 'foo'` + * - `(function* foo() {})` ................. `generator function 'foo'` + * - `(function*() {})` ..................... `generator function` + * - `() => {}` ............................. `arrow function` + * - `async () => {}` ....................... `async arrow function` + * - `({ foo: function foo() {} })` ......... `method 'foo'` + * - `({ foo: function() {} })` ............. `method 'foo'` + * - `({ ['foo']: function() {} })` ......... `method 'foo'` + * - `({ [foo]: function() {} })` ........... `method` + * - `({ foo() {} })` ....................... `method 'foo'` + * - `({ foo: function* foo() {} })` ........ `generator method 'foo'` + * - `({ foo: function*() {} })` ............ `generator method 'foo'` + * - `({ ['foo']: function*() {} })` ........ `generator method 'foo'` + * - `({ [foo]: function*() {} })` .......... `generator method` + * - `({ *foo() {} })` ...................... `generator method 'foo'` + * - `({ foo: async function foo() {} })` ... `async method 'foo'` + * - `({ foo: async function() {} })` ....... `async method 'foo'` + * - `({ ['foo']: async function() {} })` ... `async method 'foo'` + * - `({ [foo]: async function() {} })` ..... `async method` + * - `({ async foo() {} })` ................. `async method 'foo'` + * - `({ get foo() {} })` ................... `getter 'foo'` + * - `({ set foo(a) {} })` .................. `setter 'foo'` + * - `class A { constructor() {} }` ......... `constructor` + * - `class A { foo() {} }` ................. `method 'foo'` + * - `class A { *foo() {} }` ................ `generator method 'foo'` + * - `class A { async foo() {} }` ........... `async method 'foo'` + * - `class A { ['foo']() {} }` ............. `method 'foo'` + * - `class A { *['foo']() {} }` ............ `generator method 'foo'` + * - `class A { async ['foo']() {} }` ....... `async method 'foo'` + * - `class A { [foo]() {} }` ............... `method` + * - `class A { *[foo]() {} }` .............. `generator method` + * - `class A { async [foo]() {} }` ......... `async method` + * - `class A { get foo() {} }` ............. `getter 'foo'` + * - `class A { set foo(a) {} }` ............ `setter 'foo'` + * - `class A { static foo() {} }` .......... `static method 'foo'` + * - `class A { static *foo() {} }` ......... `static generator method 'foo'` + * - `class A { static async foo() {} }` .... `static async method 'foo'` + * - `class A { static get foo() {} }` ...... `static getter 'foo'` + * - `class A { static set foo(a) {} }` ..... `static setter 'foo'` + * + * @param {ASTNode} node - The function node to get. + * @returns {string} The name and kind of the function node. + */ + getFunctionNameWithKind(node) { + const parent = node.parent; + const tokens = []; + + if (parent.type === "MethodDefinition" && parent.static) { + tokens.push("static"); + } + if (node.async) { + tokens.push("async"); + } + if (node.generator) { + tokens.push("generator"); + } + + if (node.type === "ArrowFunctionExpression") { + tokens.push("arrow", "function"); + } else if (parent.type === "Property" || parent.type === "MethodDefinition") { + if (parent.kind === "constructor") { + return "constructor"; + } else if (parent.kind === "get") { + tokens.push("getter"); + } else if (parent.kind === "set") { + tokens.push("setter"); + } else { + tokens.push("method"); + } + } else { + tokens.push("function"); + } + + if (node.id) { + tokens.push(`'${node.id.name}'`); + } else { + const name = module.exports.getStaticPropertyName(parent); + + if (name) { + tokens.push(`'${name}'`); + } + } + + return tokens.join(" "); + }, + + /** + * Gets the location of the given function node for reporting. + * + * - `function foo() {}` + * ^^^^^^^^^^^^ + * - `(function foo() {})` + * ^^^^^^^^^^^^ + * - `(function() {})` + * ^^^^^^^^ + * - `function* foo() {}` + * ^^^^^^^^^^^^^ + * - `(function* foo() {})` + * ^^^^^^^^^^^^^ + * - `(function*() {})` + * ^^^^^^^^^ + * - `() => {}` + * ^^ + * - `async () => {}` + * ^^ + * - `({ foo: function foo() {} })` + * ^^^^^^^^^^^^^^^^^ + * - `({ foo: function() {} })` + * ^^^^^^^^^^^^^ + * - `({ ['foo']: function() {} })` + * ^^^^^^^^^^^^^^^^^ + * - `({ [foo]: function() {} })` + * ^^^^^^^^^^^^^^^ + * - `({ foo() {} })` + * ^^^ + * - `({ foo: function* foo() {} })` + * ^^^^^^^^^^^^^^^^^^ + * - `({ foo: function*() {} })` + * ^^^^^^^^^^^^^^ + * - `({ ['foo']: function*() {} })` + * ^^^^^^^^^^^^^^^^^^ + * - `({ [foo]: function*() {} })` + * ^^^^^^^^^^^^^^^^ + * - `({ *foo() {} })` + * ^^^^ + * - `({ foo: async function foo() {} })` + * ^^^^^^^^^^^^^^^^^^^^^^^ + * - `({ foo: async function() {} })` + * ^^^^^^^^^^^^^^^^^^^ + * - `({ ['foo']: async function() {} })` + * ^^^^^^^^^^^^^^^^^^^^^^^ + * - `({ [foo]: async function() {} })` + * ^^^^^^^^^^^^^^^^^^^^^ + * - `({ async foo() {} })` + * ^^^^^^^^^ + * - `({ get foo() {} })` + * ^^^^^^^ + * - `({ set foo(a) {} })` + * ^^^^^^^ + * - `class A { constructor() {} }` + * ^^^^^^^^^^^ + * - `class A { foo() {} }` + * ^^^ + * - `class A { *foo() {} }` + * ^^^^ + * - `class A { async foo() {} }` + * ^^^^^^^^^ + * - `class A { ['foo']() {} }` + * ^^^^^^^ + * - `class A { *['foo']() {} }` + * ^^^^^^^^ + * - `class A { async ['foo']() {} }` + * ^^^^^^^^^^^^^ + * - `class A { [foo]() {} }` + * ^^^^^ + * - `class A { *[foo]() {} }` + * ^^^^^^ + * - `class A { async [foo]() {} }` + * ^^^^^^^^^^^ + * - `class A { get foo() {} }` + * ^^^^^^^ + * - `class A { set foo(a) {} }` + * ^^^^^^^ + * - `class A { static foo() {} }` + * ^^^^^^^^^^ + * - `class A { static *foo() {} }` + * ^^^^^^^^^^^ + * - `class A { static async foo() {} }` + * ^^^^^^^^^^^^^^^^ + * - `class A { static get foo() {} }` + * ^^^^^^^^^^^^^^ + * - `class A { static set foo(a) {} }` + * ^^^^^^^^^^^^^^ + * + * @param {ASTNode} node - The function node to get. + * @param {SourceCode} sourceCode - The source code object to get tokens. + * @returns {string} The location of the function node for reporting. + */ + getFunctionHeadLoc(node, sourceCode) { + const parent = node.parent; + let start = null; + let end = null; + + if (node.type === "ArrowFunctionExpression") { + const arrowToken = getArrowToken(node, sourceCode); + + start = arrowToken.loc.start; + end = arrowToken.loc.end; + } else if (parent.type === "Property" || parent.type === "MethodDefinition") { + start = parent.loc.start; + end = getOpeningParenOfParams(node, sourceCode).loc.start; + } else { + start = node.loc.start; + end = getOpeningParenOfParams(node, sourceCode).loc.start; + } + + return { + start: Object.assign({}, start), + end: Object.assign({}, end), + }; + }, + + /* + * Converts a range index into a (line, column) pair. + * @param {SourceCode} sourceCode A SourceCode object + * @param {number} rangeIndex The range index of a character in a file + * @returns {Object} A {line, column} location object with a 0-indexed column + */ + getLocationFromRangeIndex(sourceCode, rangeIndex) { + const lineIndices = getLineIndices(sourceCode); + + /* + * lineIndices is a sorted list of indices of the first character of each line. + * To figure out which line rangeIndex is on, determine the last index at which rangeIndex could + * be inserted into lineIndices to keep the list sorted. + */ + const lineNumber = lodash.sortedLastIndex(lineIndices, rangeIndex); + + return { line: lineNumber, column: rangeIndex - lineIndices[lineNumber - 1] }; + + }, + + /** + * Converts a (line, column) pair into a range index. + * @param {SourceCode} sourceCode A SourceCode object + * @param {Object} loc A line/column location + * @param {number} loc.line The line number of the location (1-indexed) + * @param {number} loc.column The column number of the location (0-indexed) + * @returns {number} The range index of the location in the file. + */ + getRangeIndexFromLocation(sourceCode, loc) { + return getLineIndices(sourceCode)[loc.line - 1] + loc.column; + }, + + /** + * Gets the parenthesized text of a node. This is similar to sourceCode.getText(node), but it also includes any parentheses + * surrounding the node. + * @param {SourceCode} sourceCode The source code object + * @param {ASTNode} node An expression node + * @returns {string} The text representing the node, with all surrounding parentheses included + */ + getParenthesisedText(sourceCode, node) { + let leftToken = sourceCode.getFirstToken(node); + let rightToken = sourceCode.getLastToken(node); + + while ( + sourceCode.getTokenBefore(leftToken) && + sourceCode.getTokenBefore(leftToken).type === "Punctuator" && + sourceCode.getTokenBefore(leftToken).value === "(" && + sourceCode.getTokenAfter(rightToken) && + sourceCode.getTokenAfter(rightToken).type === "Punctuator" && + sourceCode.getTokenAfter(rightToken).value === ")" + ) { + leftToken = sourceCode.getTokenBefore(leftToken); + rightToken = sourceCode.getTokenAfter(rightToken); + } + + return sourceCode.getText().slice(leftToken.range[0], rightToken.range[1]); } }; diff --git a/tools/eslint/lib/cli-engine.js b/tools/eslint/lib/cli-engine.js index b9019932fe9b54..de875a4d352926 100644 --- a/tools/eslint/lib/cli-engine.js +++ b/tools/eslint/lib/cli-engine.js @@ -90,7 +90,7 @@ const debug = require("debug")("eslint:cli-engine"); * @private */ function calculateStatsPerFile(messages) { - return messages.reduce(function(stat, message) { + return messages.reduce((stat, message) => { if (message.fatal || message.severity === 2) { stat.errorCount++; } else { @@ -110,7 +110,7 @@ function calculateStatsPerFile(messages) { * @private */ function calculateStatsPerRun(results) { - return results.reduce(function(stat, result) { + return results.reduce((stat, result) => { stat.errorCount += result.errorCount; stat.warningCount += result.warningCount; return stat; @@ -241,7 +241,7 @@ function processText(text, configHelper, filename, fix, allowInlineConfig) { const parsedBlocks = processor.preprocess(text, filename); const unprocessedMessages = []; - parsedBlocks.forEach(function(block) { + parsedBlocks.forEach(block => { unprocessedMessages.push(eslint.verify(block, config, { filename, allowInlineConfig @@ -320,11 +320,11 @@ function createIgnoreResult(filePath, baseDir) { const isInBowerComponents = baseDir && /^bower_components/.test(path.relative(baseDir, filePath)); if (isHidden) { - message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern \'!\'\") to override."; + message = "File ignored by default. Use a negated ignore pattern (like \"--ignore-pattern '!'\") to override."; } else if (isInNodeModules) { - message = "File ignored by default. Use \"--ignore-pattern \'!node_modules/*\'\" to override."; + message = "File ignored by default. Use \"--ignore-pattern '!node_modules/*'\" to override."; } else if (isInBowerComponents) { - message = "File ignored by default. Use \"--ignore-pattern \'!bower_components/*\'\" to override."; + message = "File ignored by default. Use \"--ignore-pattern '!bower_components/*'\" to override."; } else { message = "File ignored because of a matching ignore pattern. Use \"--no-ignore\" to override."; } @@ -442,7 +442,7 @@ function CLIEngine(options) { options = Object.assign( Object.create(null), defaultOptions, - {cwd: process.cwd()}, + { cwd: process.cwd() }, options ); @@ -466,15 +466,15 @@ function CLIEngine(options) { if (this.options.rulePaths) { const cwd = this.options.cwd; - this.options.rulePaths.forEach(function(rulesdir) { + this.options.rulePaths.forEach(rulesdir => { debug(`Loading rules from ${rulesdir}`); rules.load(rulesdir, cwd); }); } - Object.keys(this.options.rules || {}).forEach(function(name) { + Object.keys(this.options.rules || {}).forEach(name => { validator.validateRuleOptions(name, this.options.rules[name], "CLI"); - }.bind(this)); + }); } /** @@ -526,7 +526,7 @@ CLIEngine.getFormatter = function(format) { CLIEngine.getErrorResults = function(results) { const filtered = []; - results.forEach(function(result) { + results.forEach(result => { const filteredMessages = result.messages.filter(isErrorMessage); if (filteredMessages.length > 0) { @@ -549,9 +549,7 @@ CLIEngine.getErrorResults = function(results) { * @returns {void} */ CLIEngine.outputFixes = function(report) { - report.results.filter(function(result) { - return result.hasOwnProperty("output"); - }).forEach(function(result) { + report.results.filter(result => result.hasOwnProperty("output")).forEach(result => { fs.writeFileSync(result.filePath, result.output); }); }; @@ -708,7 +706,7 @@ CLIEngine.prototype = { patterns = this.resolveFileGlobPatterns(patterns); const fileList = globUtil.listFilesToProcess(patterns, options); - fileList.forEach(function(fileInfo) { + fileList.forEach(fileInfo => { executeOnFile(fileInfo.filename, fileInfo.ignored); }); @@ -794,4 +792,6 @@ CLIEngine.prototype = { }; +CLIEngine.version = pkg.version; + module.exports = CLIEngine; diff --git a/tools/eslint/lib/code-path-analysis/code-path-analyzer.js b/tools/eslint/lib/code-path-analysis/code-path-analyzer.js index 655211430b4e2e..cb8b1e1bf8ce8c 100644 --- a/tools/eslint/lib/code-path-analysis/code-path-analyzer.js +++ b/tools/eslint/lib/code-path-analysis/code-path-analyzer.js @@ -569,21 +569,20 @@ function postprocess(analyzer, node) { /** * The class to analyze code paths. * This class implements the EventGenerator interface. - * - * @constructor - * @param {EventGenerator} eventGenerator - An event generator to wrap. */ -function CodePathAnalyzer(eventGenerator) { - this.original = eventGenerator; - this.emitter = eventGenerator.emitter; - this.codePath = null; - this.idGenerator = new IdGenerator("s"); - this.currentNode = null; - this.onLooped = this.onLooped.bind(this); -} +class CodePathAnalyzer { -CodePathAnalyzer.prototype = { - constructor: CodePathAnalyzer, + /** + * @param {EventGenerator} eventGenerator - An event generator to wrap. + */ + constructor(eventGenerator) { + this.original = eventGenerator; + this.emitter = eventGenerator.emitter; + this.codePath = null; + this.idGenerator = new IdGenerator("s"); + this.currentNode = null; + this.onLooped = this.onLooped.bind(this); + } /** * Does the process to enter a given AST node. @@ -608,7 +607,7 @@ CodePathAnalyzer.prototype = { this.original.enterNode(node); this.currentNode = null; - }, + } /** * Does the process to leave a given AST node. @@ -631,7 +630,7 @@ CodePathAnalyzer.prototype = { postprocess(this, node); this.currentNode = null; - }, + } /** * This is called on a code path looped. @@ -652,6 +651,6 @@ CodePathAnalyzer.prototype = { ); } } -}; +} module.exports = CodePathAnalyzer; diff --git a/tools/eslint/lib/code-path-analysis/code-path-segment.js b/tools/eslint/lib/code-path-analysis/code-path-segment.js index b3966c415b0aac..db1eba4560c251 100644 --- a/tools/eslint/lib/code-path-analysis/code-path-segment.js +++ b/tools/eslint/lib/code-path-analysis/code-path-segment.js @@ -68,174 +68,175 @@ function isReachable(segment) { /** * A code path segment. - * - * @constructor - * @param {string} id - An identifier. - * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments. - * This array includes unreachable segments. - * @param {boolean} reachable - A flag which shows this is reachable. */ -function CodePathSegment(id, allPrevSegments, reachable) { +class CodePathSegment { /** - * The identifier of this code path. - * Rules use it to store additional information of each rule. - * @type {string} + * @param {string} id - An identifier. + * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments. + * This array includes unreachable segments. + * @param {boolean} reachable - A flag which shows this is reachable. */ - this.id = id; + constructor(id, allPrevSegments, reachable) { + + /** + * The identifier of this code path. + * Rules use it to store additional information of each rule. + * @type {string} + */ + this.id = id; + + /** + * An array of the next segments. + * @type {CodePathSegment[]} + */ + this.nextSegments = []; + + /** + * An array of the previous segments. + * @type {CodePathSegment[]} + */ + this.prevSegments = allPrevSegments.filter(isReachable); + + /** + * An array of the next segments. + * This array includes unreachable segments. + * @type {CodePathSegment[]} + */ + this.allNextSegments = []; + + /** + * An array of the previous segments. + * This array includes unreachable segments. + * @type {CodePathSegment[]} + */ + this.allPrevSegments = allPrevSegments; + + /** + * A flag which shows this is reachable. + * @type {boolean} + */ + this.reachable = reachable; + + // Internal data. + Object.defineProperty(this, "internal", { + value: { + used: false, + loopedPrevSegments: [] + } + }); - /** - * An array of the next segments. - * @type {CodePathSegment[]} - */ - this.nextSegments = []; + /* istanbul ignore if */ + if (debug.enabled) { + this.internal.nodes = []; + this.internal.exitNodes = []; + } + } /** - * An array of the previous segments. - * @type {CodePathSegment[]} + * Checks a given previous segment is coming from the end of a loop. + * + * @param {CodePathSegment} segment - A previous segment to check. + * @returns {boolean} `true` if the segment is coming from the end of a loop. */ - this.prevSegments = allPrevSegments.filter(isReachable); + isLoopedPrevSegment(segment) { + return this.internal.loopedPrevSegments.indexOf(segment) !== -1; + } /** - * An array of the next segments. - * This array includes unreachable segments. - * @type {CodePathSegment[]} + * Creates the root segment. + * + * @param {string} id - An identifier. + * @returns {CodePathSegment} The created segment. */ - this.allNextSegments = []; + static newRoot(id) { + return new CodePathSegment(id, [], true); + } /** - * An array of the previous segments. - * This array includes unreachable segments. - * @type {CodePathSegment[]} + * Creates a segment that follows given segments. + * + * @param {string} id - An identifier. + * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments. + * @returns {CodePathSegment} The created segment. */ - this.allPrevSegments = allPrevSegments; + static newNext(id, allPrevSegments) { + return new CodePathSegment( + id, + flattenUnusedSegments(allPrevSegments), + allPrevSegments.some(isReachable)); + } /** - * A flag which shows this is reachable. - * @type {boolean} + * Creates an unreachable segment that follows given segments. + * + * @param {string} id - An identifier. + * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments. + * @returns {CodePathSegment} The created segment. */ - this.reachable = reachable; - - // Internal data. - Object.defineProperty(this, "internal", {value: { - used: false, - loopedPrevSegments: [] - }}); - - /* istanbul ignore if */ - if (debug.enabled) { - this.internal.nodes = []; - this.internal.exitNodes = []; - } -} + static newUnreachable(id, allPrevSegments) { + const segment = new CodePathSegment(id, flattenUnusedSegments(allPrevSegments), false); -CodePathSegment.prototype = { - constructor: CodePathSegment, + // In `if (a) return a; foo();` case, the unreachable segment preceded by + // the return statement is not used but must not be remove. + CodePathSegment.markUsed(segment); + + return segment; + } /** - * Checks a given previous segment is coming from the end of a loop. + * Creates a segment that follows given segments. + * This factory method does not connect with `allPrevSegments`. + * But this inherits `reachable` flag. * - * @param {CodePathSegment} segment - A previous segment to check. - * @returns {boolean} `true` if the segment is coming from the end of a loop. + * @param {string} id - An identifier. + * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments. + * @returns {CodePathSegment} The created segment. */ - isLoopedPrevSegment(segment) { - return this.internal.loopedPrevSegments.indexOf(segment) !== -1; + static newDisconnected(id, allPrevSegments) { + return new CodePathSegment(id, [], allPrevSegments.some(isReachable)); } -}; - -/** - * Creates the root segment. - * - * @param {string} id - An identifier. - * @returns {CodePathSegment} The created segment. - */ -CodePathSegment.newRoot = function(id) { - return new CodePathSegment(id, [], true); -}; -/** - * Creates a segment that follows given segments. - * - * @param {string} id - An identifier. - * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments. - * @returns {CodePathSegment} The created segment. - */ -CodePathSegment.newNext = function(id, allPrevSegments) { - return new CodePathSegment( - id, - flattenUnusedSegments(allPrevSegments), - allPrevSegments.some(isReachable)); -}; - -/** - * Creates an unreachable segment that follows given segments. - * - * @param {string} id - An identifier. - * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments. - * @returns {CodePathSegment} The created segment. - */ -CodePathSegment.newUnreachable = function(id, allPrevSegments) { - const segment = new CodePathSegment(id, flattenUnusedSegments(allPrevSegments), false); - - // In `if (a) return a; foo();` case, the unreachable segment preceded by - // the return statement is not used but must not be remove. - CodePathSegment.markUsed(segment); - - return segment; -}; - -/** - * Creates a segment that follows given segments. - * This factory method does not connect with `allPrevSegments`. - * But this inherits `reachable` flag. - * - * @param {string} id - An identifier. - * @param {CodePathSegment[]} allPrevSegments - An array of the previous segments. - * @returns {CodePathSegment} The created segment. - */ -CodePathSegment.newDisconnected = function(id, allPrevSegments) { - return new CodePathSegment(id, [], allPrevSegments.some(isReachable)); -}; - -/** - * Makes a given segment being used. - * - * And this function registers the segment into the previous segments as a next. - * - * @param {CodePathSegment} segment - A segment to mark. - * @returns {void} - */ -CodePathSegment.markUsed = function(segment) { - if (segment.internal.used) { - return; - } - segment.internal.used = true; + /** + * Makes a given segment being used. + * + * And this function registers the segment into the previous segments as a next. + * + * @param {CodePathSegment} segment - A segment to mark. + * @returns {void} + */ + static markUsed(segment) { + if (segment.internal.used) { + return; + } + segment.internal.used = true; - let i; + let i; - if (segment.reachable) { - for (i = 0; i < segment.allPrevSegments.length; ++i) { - const prevSegment = segment.allPrevSegments[i]; + if (segment.reachable) { + for (i = 0; i < segment.allPrevSegments.length; ++i) { + const prevSegment = segment.allPrevSegments[i]; - prevSegment.allNextSegments.push(segment); - prevSegment.nextSegments.push(segment); - } - } else { - for (i = 0; i < segment.allPrevSegments.length; ++i) { - segment.allPrevSegments[i].allNextSegments.push(segment); + prevSegment.allNextSegments.push(segment); + prevSegment.nextSegments.push(segment); + } + } else { + for (i = 0; i < segment.allPrevSegments.length; ++i) { + segment.allPrevSegments[i].allNextSegments.push(segment); + } } } -}; -/** - * Marks a previous segment as looped. - * - * @param {CodePathSegment} segment - A segment. - * @param {CodePathSegment} prevSegment - A previous segment to mark. - * @returns {void} - */ -CodePathSegment.markPrevSegmentAsLooped = function(segment, prevSegment) { - segment.internal.loopedPrevSegments.push(prevSegment); -}; + /** + * Marks a previous segment as looped. + * + * @param {CodePathSegment} segment - A segment. + * @param {CodePathSegment} prevSegment - A previous segment to mark. + * @returns {void} + */ + static markPrevSegmentAsLooped(segment, prevSegment) { + segment.internal.loopedPrevSegments.push(prevSegment); + } +} module.exports = CodePathSegment; diff --git a/tools/eslint/lib/code-path-analysis/code-path-state.js b/tools/eslint/lib/code-path-analysis/code-path-state.js index 3b0b1606e2c993..64779c0d3c8b12 100644 --- a/tools/eslint/lib/code-path-analysis/code-path-state.js +++ b/tools/eslint/lib/code-path-analysis/code-path-state.js @@ -221,36 +221,35 @@ function finalizeTestSegmentsOfFor(context, choiceContext, head) { /** * A class which manages state to analyze code paths. - * - * @constructor - * @param {IdGenerator} idGenerator - An id generator to generate id for code - * path segments. - * @param {Function} onLooped - A callback function to notify looping. */ -function CodePathState(idGenerator, onLooped) { - this.idGenerator = idGenerator; - this.notifyLooped = onLooped; - this.forkContext = ForkContext.newRoot(idGenerator); - this.choiceContext = null; - this.switchContext = null; - this.tryContext = null; - this.loopContext = null; - this.breakContext = null; - - this.currentSegments = []; - this.initialSegment = this.forkContext.head[0]; - - // returnedSegments and thrownSegments push elements into finalSegments also. - const final = this.finalSegments = []; - const returned = this.returnedForkContext = []; - const thrown = this.thrownForkContext = []; - - returned.add = addToReturnedOrThrown.bind(null, returned, thrown, final); - thrown.add = addToReturnedOrThrown.bind(null, thrown, returned, final); -} +class CodePathState { -CodePathState.prototype = { - constructor: CodePathState, + /** + * @param {IdGenerator} idGenerator - An id generator to generate id for code + * path segments. + * @param {Function} onLooped - A callback function to notify looping. + */ + constructor(idGenerator, onLooped) { + this.idGenerator = idGenerator; + this.notifyLooped = onLooped; + this.forkContext = ForkContext.newRoot(idGenerator); + this.choiceContext = null; + this.switchContext = null; + this.tryContext = null; + this.loopContext = null; + this.breakContext = null; + + this.currentSegments = []; + this.initialSegment = this.forkContext.head[ 0 ]; + + // returnedSegments and thrownSegments push elements into finalSegments also. + const final = this.finalSegments = []; + const returned = this.returnedForkContext = []; + const thrown = this.thrownForkContext = []; + + returned.add = addToReturnedOrThrown.bind(null, returned, thrown, final); + thrown.add = addToReturnedOrThrown.bind(null, thrown, returned, final); + } /** * The head segments. @@ -258,7 +257,7 @@ CodePathState.prototype = { */ get headSegments() { return this.forkContext.head; - }, + } /** * The parent forking context. @@ -269,7 +268,7 @@ CodePathState.prototype = { const current = this.forkContext; return current && current.upper; - }, + } /** * Creates and stacks new forking context. @@ -285,7 +284,7 @@ CodePathState.prototype = { ); return this.forkContext; - }, + } /** * Pops and merges the last forking context. @@ -298,7 +297,7 @@ CodePathState.prototype = { this.forkContext.replaceHead(lastContext.makeNext(0, -1)); return lastContext; - }, + } /** * Creates a new path. @@ -306,7 +305,7 @@ CodePathState.prototype = { */ forkPath() { this.forkContext.add(this.parentForkContext.makeNext(-1, -1)); - }, + } /** * Creates a bypass path. @@ -316,7 +315,7 @@ CodePathState.prototype = { */ forkBypassPath() { this.forkContext.add(this.parentForkContext.head); - }, + } //-------------------------------------------------------------------------- // ConditionalExpression, LogicalExpression, IfStatement @@ -362,7 +361,7 @@ CodePathState.prototype = { falseForkContext: ForkContext.newEmpty(this.forkContext), processed: false }; - }, + } /** * Pops the last choice context and finalizes it. @@ -449,7 +448,7 @@ CodePathState.prototype = { forkContext.replaceHead(prevForkContext.makeNext(0, -1)); return context; - }, + } /** * Makes a code path segment of the right-hand operand of a logical @@ -494,7 +493,7 @@ CodePathState.prototype = { forkContext.replaceHead(forkContext.makeNext(-1, -1)); } - }, + } /** * Makes a code path segment of the `if` block. @@ -521,7 +520,7 @@ CodePathState.prototype = { forkContext.replaceHead( context.trueForkContext.makeNext(0, -1) ); - }, + } /** * Makes a code path segment of the `else` block. @@ -544,7 +543,7 @@ CodePathState.prototype = { forkContext.replaceHead( context.falseForkContext.makeNext(0, -1) ); - }, + } //-------------------------------------------------------------------------- // SwitchStatement @@ -570,7 +569,7 @@ CodePathState.prototype = { }; this.pushBreakContext(true, label); - }, + } /** * Pops the last context of SwitchStatement and finalizes it. @@ -649,7 +648,7 @@ CodePathState.prototype = { * This is a path after switch statement. */ this.forkContext.replaceHead(brokenForkContext.makeNext(0, -1)); - }, + } /** * Makes a code path segment for a `SwitchCase` node. @@ -696,7 +695,7 @@ CodePathState.prototype = { context.lastIsDefault = isDefault; context.countForks += 1; - }, + } //-------------------------------------------------------------------------- // TryStatement @@ -723,7 +722,7 @@ CodePathState.prototype = { lastOfTryIsReachable: false, lastOfCatchIsReachable: false }; - }, + } /** * Pops the last context of TryStatement and finalizes it. @@ -777,7 +776,7 @@ CodePathState.prototype = { if (!context.lastOfTryIsReachable && !context.lastOfCatchIsReachable) { this.forkContext.makeUnreachable(); } - }, + } /** * Makes a code path segment for a `catch` block. @@ -802,7 +801,7 @@ CodePathState.prototype = { this.pushForkContext(); this.forkBypassPath(); this.forkContext.add(thrownSegments); - }, + } /** * Makes a code path segment for a `finally` block. @@ -863,7 +862,7 @@ CodePathState.prototype = { this.pushForkContext(true); this.forkContext.add(segments); - }, + } /** * Makes a code path segment from the first throwable node to the `catch` @@ -889,7 +888,7 @@ CodePathState.prototype = { context.thrownForkContext.add(forkContext.head); forkContext.replaceHead(forkContext.makeNext(-1, -1)); - }, + } //-------------------------------------------------------------------------- // Loop Statements @@ -969,7 +968,7 @@ CodePathState.prototype = { default: throw new Error(`unknown type: "${type}"`); } - }, + } /** * Pops the last context of a loop statement and finalizes it. @@ -1039,7 +1038,7 @@ CodePathState.prototype = { } else { forkContext.replaceHead(brokenForkContext.makeNext(0, -1)); } - }, + } /** * Makes a code path segment for the test part of a WhileStatement. @@ -1056,7 +1055,7 @@ CodePathState.prototype = { context.test = test; context.continueDestSegments = testSegments; forkContext.replaceHead(testSegments); - }, + } /** * Makes a code path segment for the body part of a WhileStatement. @@ -1078,7 +1077,7 @@ CodePathState.prototype = { context.brokenForkContext.addAll(choiceContext.falseForkContext); } forkContext.replaceHead(choiceContext.trueForkContext.makeNext(0, -1)); - }, + } /** * Makes a code path segment for the body part of a DoWhileStatement. @@ -1093,7 +1092,7 @@ CodePathState.prototype = { // Update state. context.entrySegments = bodySegments; forkContext.replaceHead(bodySegments); - }, + } /** * Makes a code path segment for the test part of a DoWhileStatement. @@ -1114,7 +1113,7 @@ CodePathState.prototype = { forkContext.replaceHead(testSegments); } - }, + } /** * Makes a code path segment for the test part of a ForStatement. @@ -1133,7 +1132,7 @@ CodePathState.prototype = { context.endOfInitSegments = endOfInitSegments; context.continueDestSegments = context.testSegments = testSegments; forkContext.replaceHead(testSegments); - }, + } /** * Makes a code path segment for the update part of a ForStatement. @@ -1160,7 +1159,7 @@ CodePathState.prototype = { context.continueDestSegments = context.updateSegments = updateSegments; forkContext.replaceHead(updateSegments); - }, + } /** * Makes a code path segment for the body part of a ForStatement. @@ -1211,7 +1210,7 @@ CodePathState.prototype = { } context.continueDestSegments = context.continueDestSegments || bodySegments; forkContext.replaceHead(bodySegments); - }, + } /** * Makes a code path segment for the left part of a ForInStatement and a @@ -1228,7 +1227,7 @@ CodePathState.prototype = { context.prevSegments = forkContext.head; context.leftSegments = context.continueDestSegments = leftSegments; forkContext.replaceHead(leftSegments); - }, + } /** * Makes a code path segment for the right part of a ForInStatement and a @@ -1247,7 +1246,7 @@ CodePathState.prototype = { // Update state. context.endOfLeftSegments = forkContext.head; forkContext.replaceHead(rightSegments); - }, + } /** * Makes a code path segment for the body part of a ForInStatement and a @@ -1269,7 +1268,7 @@ CodePathState.prototype = { // Update state. context.brokenForkContext.add(forkContext.head); forkContext.replaceHead(bodySegments); - }, + } //-------------------------------------------------------------------------- // Control Statements @@ -1291,7 +1290,7 @@ CodePathState.prototype = { brokenForkContext: ForkContext.newEmpty(this.forkContext) }; return this.breakContext; - }, + } /** * Removes the top item of the break context stack. @@ -1315,7 +1314,7 @@ CodePathState.prototype = { } return context; - }, + } /** * Makes a path for a `break` statement. @@ -1341,7 +1340,7 @@ CodePathState.prototype = { } forkContext.replaceHead(forkContext.makeUnreachable(-1, -1)); - }, + } /** * Makes a path for a `continue` statement. @@ -1377,7 +1376,7 @@ CodePathState.prototype = { } } forkContext.replaceHead(forkContext.makeUnreachable(-1, -1)); - }, + } /** * Makes a path for a `return` statement. @@ -1394,7 +1393,7 @@ CodePathState.prototype = { getReturnContext(this).returnedForkContext.add(forkContext.head); forkContext.replaceHead(forkContext.makeUnreachable(-1, -1)); } - }, + } /** * Makes a path for a `throw` statement. @@ -1411,7 +1410,7 @@ CodePathState.prototype = { getThrowContext(this).thrownForkContext.add(forkContext.head); forkContext.replaceHead(forkContext.makeUnreachable(-1, -1)); } - }, + } /** * Makes the final path. @@ -1424,6 +1423,6 @@ CodePathState.prototype = { this.returnedForkContext.add(segments); } } -}; +} module.exports = CodePathState; diff --git a/tools/eslint/lib/code-path-analysis/code-path.js b/tools/eslint/lib/code-path-analysis/code-path.js index 96363423c23ed5..6ef07b4a2d93b2 100644 --- a/tools/eslint/lib/code-path-analysis/code-path.js +++ b/tools/eslint/lib/code-path-analysis/code-path.js @@ -18,47 +18,56 @@ const IdGenerator = require("./id-generator"); /** * A code path. - * - * @constructor - * @param {string} id - An identifier. - * @param {CodePath|null} upper - The code path of the upper function scope. - * @param {Function} onLooped - A callback function to notify looping. */ -function CodePath(id, upper, onLooped) { +class CodePath { /** - * The identifier of this code path. - * Rules use it to store additional information of each rule. - * @type {string} + * @param {string} id - An identifier. + * @param {CodePath|null} upper - The code path of the upper function scope. + * @param {Function} onLooped - A callback function to notify looping. */ - this.id = id; + constructor(id, upper, onLooped) { - /** - * The code path of the upper function scope. - * @type {CodePath|null} - */ - this.upper = upper; + /** + * The identifier of this code path. + * Rules use it to store additional information of each rule. + * @type {string} + */ + this.id = id; - /** - * The code paths of nested function scopes. - * @type {CodePath[]} - */ - this.childCodePaths = []; + /** + * The code path of the upper function scope. + * @type {CodePath|null} + */ + this.upper = upper; + + /** + * The code paths of nested function scopes. + * @type {CodePath[]} + */ + this.childCodePaths = []; - // Initializes internal state. - Object.defineProperty( - this, - "internal", - {value: new CodePathState(new IdGenerator(`${id}_`), onLooped)}); + // Initializes internal state. + Object.defineProperty( + this, + "internal", + { value: new CodePathState(new IdGenerator(`${id}_`), onLooped) }); - // Adds this into `childCodePaths` of `upper`. - if (upper) { - upper.childCodePaths.push(this); + // Adds this into `childCodePaths` of `upper`. + if (upper) { + upper.childCodePaths.push(this); + } } -} -CodePath.prototype = { - constructor: CodePath, + /** + * Gets the state of a given code path. + * + * @param {CodePath} codePath - A code path to get. + * @returns {CodePathState} The state of the code path. + */ + static getState(codePath) { + return codePath.internal; + } /** * The initial code path segment. @@ -66,7 +75,7 @@ CodePath.prototype = { */ get initialSegment() { return this.internal.initialSegment; - }, + } /** * Final code path segments. @@ -75,7 +84,7 @@ CodePath.prototype = { */ get finalSegments() { return this.internal.finalSegments; - }, + } /** * Final code path segments which is with `return` statements. @@ -85,7 +94,7 @@ CodePath.prototype = { */ get returnedSegments() { return this.internal.returnedForkContext; - }, + } /** * Final code path segments which is with `throw` statements. @@ -93,7 +102,7 @@ CodePath.prototype = { */ get thrownSegments() { return this.internal.thrownForkContext; - }, + } /** * Current code path segments. @@ -101,7 +110,7 @@ CodePath.prototype = { */ get currentSegments() { return this.internal.currentSegments; - }, + } /** * Traverses all segments in this code path. @@ -219,16 +228,6 @@ CodePath.prototype = { } } } -}; - -/** - * Gets the state of a given code path. - * - * @param {CodePath} codePath - A code path to get. - * @returns {CodePathState} The state of the code path. - */ -CodePath.getState = function getState(codePath) { - return codePath.internal; -}; +} module.exports = CodePath; diff --git a/tools/eslint/lib/code-path-analysis/debug-helpers.js b/tools/eslint/lib/code-path-analysis/debug-helpers.js index 5e311eb352b986..622bd6081fa546 100644 --- a/tools/eslint/lib/code-path-analysis/debug-helpers.js +++ b/tools/eslint/lib/code-path-analysis/debug-helpers.js @@ -108,7 +108,7 @@ module.exports = { } if (segment.internal.nodes.length > 0) { - text += segment.internal.nodes.map(function(node) { + text += segment.internal.nodes.map(node => { switch (node.type) { case "Identifier": return `${node.type} (${node.name})`; case "Literal": return `${node.type} (${node.value})`; @@ -116,7 +116,7 @@ module.exports = { } }).join("\\n"); } else if (segment.internal.exitNodes.length > 0) { - text += segment.internal.exitNodes.map(function(node) { + text += segment.internal.exitNodes.map(node => { switch (node.type) { case "Identifier": return `${node.type}:exit (${node.name})`; case "Literal": return `${node.type}:exit (${node.value})`; @@ -176,7 +176,7 @@ module.exports = { stack.push([nextSegment, 0]); } - codePath.returnedSegments.forEach(function(finalSegment) { + codePath.returnedSegments.forEach(finalSegment => { if (lastId === finalSegment.id) { text += "->final"; } else { @@ -185,7 +185,7 @@ module.exports = { lastId = null; }); - codePath.thrownSegments.forEach(function(finalSegment) { + codePath.thrownSegments.forEach(finalSegment => { if (lastId === finalSegment.id) { text += "->thrown"; } else { diff --git a/tools/eslint/lib/code-path-analysis/fork-context.js b/tools/eslint/lib/code-path-analysis/fork-context.js index 6996af1dcc1f71..7423c13199b3ff 100644 --- a/tools/eslint/lib/code-path-analysis/fork-context.js +++ b/tools/eslint/lib/code-path-analysis/fork-context.js @@ -99,21 +99,20 @@ function mergeExtraSegments(context, segments) { /** * A class to manage forking. - * - * @constructor - * @param {IdGenerator} idGenerator - An identifier generator for segments. - * @param {ForkContext|null} upper - An upper fork context. - * @param {number} count - A number of parallel segments. */ -function ForkContext(idGenerator, upper, count) { - this.idGenerator = idGenerator; - this.upper = upper; - this.count = count; - this.segmentsList = []; -} +class ForkContext { -ForkContext.prototype = { - constructor: ForkContext, + /** + * @param {IdGenerator} idGenerator - An identifier generator for segments. + * @param {ForkContext|null} upper - An upper fork context. + * @param {number} count - A number of parallel segments. + */ + constructor(idGenerator, upper, count) { + this.idGenerator = idGenerator; + this.upper = upper; + this.count = count; + this.segmentsList = []; + } /** * The head segments. @@ -123,7 +122,7 @@ ForkContext.prototype = { const list = this.segmentsList; return list.length === 0 ? [] : list[list.length - 1]; - }, + } /** * A flag which shows empty. @@ -131,7 +130,7 @@ ForkContext.prototype = { */ get empty() { return this.segmentsList.length === 0; - }, + } /** * A flag which shows reachable. @@ -141,7 +140,7 @@ ForkContext.prototype = { const segments = this.head; return segments.length > 0 && segments.some(isReachable); - }, + } /** * Creates new segments from this context. @@ -152,7 +151,7 @@ ForkContext.prototype = { */ makeNext(begin, end) { return makeSegments(this, begin, end, CodePathSegment.newNext); - }, + } /** * Creates new segments from this context. @@ -164,7 +163,7 @@ ForkContext.prototype = { */ makeUnreachable(begin, end) { return makeSegments(this, begin, end, CodePathSegment.newUnreachable); - }, + } /** * Creates new segments from this context. @@ -177,7 +176,7 @@ ForkContext.prototype = { */ makeDisconnected(begin, end) { return makeSegments(this, begin, end, CodePathSegment.newDisconnected); - }, + } /** * Adds segments into this context. @@ -190,7 +189,7 @@ ForkContext.prototype = { assert(segments.length >= this.count, `${segments.length} >= ${this.count}`); this.segmentsList.push(mergeExtraSegments(this, segments)); - }, + } /** * Replaces the head segments with given segments. @@ -203,7 +202,7 @@ ForkContext.prototype = { assert(segments.length >= this.count, `${segments.length} >= ${this.count}`); this.segmentsList.splice(-1, 1, mergeExtraSegments(this, segments)); - }, + } /** * Adds all segments of a given fork context into this context. @@ -219,7 +218,7 @@ ForkContext.prototype = { for (let i = 0; i < source.length; ++i) { this.segmentsList.push(source[i]); } - }, + } /** * Clears all secments in this context. @@ -229,34 +228,34 @@ ForkContext.prototype = { clear() { this.segmentsList = []; } -}; -/** - * Creates the root fork context. - * - * @param {IdGenerator} idGenerator - An identifier generator for segments. - * @returns {ForkContext} New fork context. - */ -ForkContext.newRoot = function(idGenerator) { - const context = new ForkContext(idGenerator, null, 1); + /** + * Creates the root fork context. + * + * @param {IdGenerator} idGenerator - An identifier generator for segments. + * @returns {ForkContext} New fork context. + */ + static newRoot(idGenerator) { + const context = new ForkContext(idGenerator, null, 1); - context.add([CodePathSegment.newRoot(idGenerator.next())]); + context.add([CodePathSegment.newRoot(idGenerator.next())]); - return context; -}; + return context; + } -/** - * Creates an empty fork context preceded by a given context. - * - * @param {ForkContext} parentContext - The parent fork context. - * @param {boolean} forkLeavingPath - A flag which shows inside of `finally` block. - * @returns {ForkContext} New fork context. - */ -ForkContext.newEmpty = function(parentContext, forkLeavingPath) { - return new ForkContext( - parentContext.idGenerator, - parentContext, - (forkLeavingPath ? 2 : 1) * parentContext.count); -}; + /** + * Creates an empty fork context preceded by a given context. + * + * @param {ForkContext} parentContext - The parent fork context. + * @param {boolean} forkLeavingPath - A flag which shows inside of `finally` block. + * @returns {ForkContext} New fork context. + */ + static newEmpty(parentContext, forkLeavingPath) { + return new ForkContext( + parentContext.idGenerator, + parentContext, + (forkLeavingPath ? 2 : 1) * parentContext.count); + } +} module.exports = ForkContext; diff --git a/tools/eslint/lib/code-path-analysis/id-generator.js b/tools/eslint/lib/code-path-analysis/id-generator.js index f33858cacd4071..062058ddc12639 100644 --- a/tools/eslint/lib/code-path-analysis/id-generator.js +++ b/tools/eslint/lib/code-path-analysis/id-generator.js @@ -15,29 +15,32 @@ /** * A generator for unique ids. - * - * @constructor - * @param {string} prefix - Optional. A prefix of generated ids. - */ -function IdGenerator(prefix) { - this.prefix = String(prefix); - this.n = 0; -} - -/** - * Generates id. - * - * @returns {string} A generated id. */ -IdGenerator.prototype.next = function() { - this.n = 1 + this.n | 0; +class IdGenerator { - /* istanbul ignore if */ - if (this.n < 0) { - this.n = 1; + /** + * @param {string} prefix - Optional. A prefix of generated ids. + */ + constructor(prefix) { + this.prefix = String(prefix); + this.n = 0; } - return this.prefix + this.n; -}; + /** + * Generates id. + * + * @returns {string} A generated id. + */ + next() { + this.n = 1 + this.n | 0; + + /* istanbul ignore if */ + if (this.n < 0) { + this.n = 1; + } + + return this.prefix + this.n; + } +} module.exports = IdGenerator; diff --git a/tools/eslint/lib/config.js b/tools/eslint/lib/config.js index 9ff203c16d9e45..9c56e7ad988e28 100644 --- a/tools/eslint/lib/config.js +++ b/tools/eslint/lib/config.js @@ -179,155 +179,159 @@ function getLocalConfig(thisConfig, directory) { //------------------------------------------------------------------------------ /** - * Config - * @constructor - * @class Config - * @param {Object} options Options to be passed in + * Configuration class */ -function Config(options) { - options = options || {}; +class Config { - this.ignore = options.ignore; - this.ignorePath = options.ignorePath; - this.cache = {}; - this.parser = options.parser; - this.parserOptions = options.parserOptions || {}; + /** + * Config options + * @param {Object} options Options to be passed in + */ + constructor(options) { + options = options || {}; - this.baseConfig = options.baseConfig ? loadConfig(options.baseConfig) : { rules: {} }; + this.ignore = options.ignore; + this.ignorePath = options.ignorePath; + this.cache = {}; + this.parser = options.parser; + this.parserOptions = options.parserOptions || {}; - this.useEslintrc = (options.useEslintrc !== false); + this.baseConfig = options.baseConfig ? loadConfig(options.baseConfig) : { rules: {} }; - this.env = (options.envs || []).reduce(function(envs, name) { - envs[name] = true; - return envs; - }, {}); + this.useEslintrc = (options.useEslintrc !== false); - /* - * Handle declared globals. - * For global variable foo, handle "foo:false" and "foo:true" to set - * whether global is writable. - * If user declares "foo", convert to "foo:false". - */ - this.globals = (options.globals || []).reduce(function(globals, def) { - const parts = def.split(":"); + this.env = (options.envs || []).reduce((envs, name) => { + envs[ name ] = true; + return envs; + }, {}); - globals[parts[0]] = (parts.length > 1 && parts[1] === "true"); + /* + * Handle declared globals. + * For global variable foo, handle "foo:false" and "foo:true" to set + * whether global is writable. + * If user declares "foo", convert to "foo:false". + */ + this.globals = (options.globals || []).reduce((globals, def) => { + const parts = def.split(":"); - return globals; - }, {}); + globals[parts[0]] = (parts.length > 1 && parts[1] === "true"); - const useConfig = options.configFile; + return globals; + }, {}); - this.options = options; + const useConfig = options.configFile; - if (useConfig) { - debug(`Using command line config ${useConfig}`); - if (isResolvable(useConfig) || isResolvable(`eslint-config-${useConfig}`) || useConfig.charAt(0) === "@") { - this.useSpecificConfig = loadConfig(useConfig); - } else { - this.useSpecificConfig = loadConfig(path.resolve(this.options.cwd, useConfig)); + this.options = options; + + if (useConfig) { + debug(`Using command line config ${useConfig}`); + if (isResolvable(useConfig) || isResolvable(`eslint-config-${useConfig}`) || useConfig.charAt(0) === "@") { + this.useSpecificConfig = loadConfig(useConfig); + } else { + this.useSpecificConfig = loadConfig(path.resolve(this.options.cwd, useConfig)); + } } } -} -/** - * Build a config object merging the base config (conf/eslint.json), the - * environments config (conf/environments.js) and eventually the user config. - * @param {string} filePath a file in whose directory we start looking for a local config - * @returns {Object} config object - */ -Config.prototype.getConfig = function(filePath) { - const directory = filePath ? path.dirname(filePath) : this.options.cwd; - let config, - userConfig; + /** + * Build a config object merging the base config (conf/eslint.json), the + * environments config (conf/environments.js) and eventually the user config. + * @param {string} filePath a file in whose directory we start looking for a local config + * @returns {Object} config object + */ + getConfig(filePath) { + const directory = filePath ? path.dirname(filePath) : this.options.cwd; + let config, + userConfig; - debug(`Constructing config for ${filePath ? filePath : "text"}`); + debug(`Constructing config for ${filePath ? filePath : "text"}`); - config = this.cache[directory]; + config = this.cache[directory]; - if (config) { - debug("Using config from cache"); - return config; - } + if (config) { + debug("Using config from cache"); + return config; + } - // Step 1: Determine user-specified config from .eslintrc.* and package.json files - if (this.useEslintrc) { - debug("Using .eslintrc and package.json files"); - userConfig = getLocalConfig(this, directory); - } else { - debug("Not using .eslintrc or package.json files"); - userConfig = {}; - } + // Step 1: Determine user-specified config from .eslintrc.* and package.json files + if (this.useEslintrc) { + debug("Using .eslintrc and package.json files"); + userConfig = getLocalConfig(this, directory); + } else { + debug("Not using .eslintrc or package.json files"); + userConfig = {}; + } - // Step 2: Create a copy of the baseConfig - config = ConfigOps.merge({}, this.baseConfig); + // Step 2: Create a copy of the baseConfig + config = ConfigOps.merge({}, this.baseConfig); - // Step 3: Merge in the user-specified configuration from .eslintrc and package.json - config = ConfigOps.merge(config, userConfig); + // Step 3: Merge in the user-specified configuration from .eslintrc and package.json + config = ConfigOps.merge(config, userConfig); - // Step 4: Merge in command line config file - if (this.useSpecificConfig) { - debug("Merging command line config file"); + // Step 4: Merge in command line config file + if (this.useSpecificConfig) { + debug("Merging command line config file"); - config = ConfigOps.merge(config, this.useSpecificConfig); - } + config = ConfigOps.merge(config, this.useSpecificConfig); + } - // Step 5: Merge in command line environments - debug("Merging command line environment settings"); - config = ConfigOps.merge(config, { env: this.env }); + // Step 5: Merge in command line environments + debug("Merging command line environment settings"); + config = ConfigOps.merge(config, { env: this.env }); - // Step 6: Merge in command line rules - if (this.options.rules) { - debug("Merging command line rules"); - config = ConfigOps.merge(config, { rules: this.options.rules }); - } + // Step 6: Merge in command line rules + if (this.options.rules) { + debug("Merging command line rules"); + config = ConfigOps.merge(config, { rules: this.options.rules }); + } - // Step 7: Merge in command line globals - config = ConfigOps.merge(config, { globals: this.globals }); + // Step 7: Merge in command line globals + config = ConfigOps.merge(config, { globals: this.globals }); - // Only override parser if it is passed explicitly through the command line or if it's not - // defined yet (because the final object will at least have the parser key) - if (this.parser || !config.parser) { - config = ConfigOps.merge(config, { - parser: this.parser - }); - } + // Only override parser if it is passed explicitly through the command line or if it's not + // defined yet (because the final object will at least have the parser key) + if (this.parser || !config.parser) { + config = ConfigOps.merge(config, { + parser: this.parser + }); + } - if (this.parserOptions) { - config = ConfigOps.merge(config, { - parserOptions: this.parserOptions - }); - } + if (this.parserOptions) { + config = ConfigOps.merge(config, { + parserOptions: this.parserOptions + }); + } - // Step 8: Merge in command line plugins - if (this.options.plugins) { - debug("Merging command line plugins"); - Plugins.loadAll(this.options.plugins); - config = ConfigOps.merge(config, { plugins: this.options.plugins }); - } + // Step 8: Merge in command line plugins + if (this.options.plugins) { + debug("Merging command line plugins"); + Plugins.loadAll(this.options.plugins); + config = ConfigOps.merge(config, { plugins: this.options.plugins }); + } - // Step 9: Apply environments to the config if present - if (config.env) { - config = ConfigOps.applyEnvironments(config); - } + // Step 9: Apply environments to the config if present + if (config.env) { + config = ConfigOps.applyEnvironments(config); + } - this.cache[directory] = config; + this.cache[directory] = config; - return config; -}; + return config; + } -/** - * Find local config files from directory and parent directories. - * @param {string} directory The directory to start searching from. - * @returns {string[]} The paths of local config files found. - */ -Config.prototype.findLocalConfigFiles = function(directory) { + /** + * Find local config files from directory and parent directories. + * @param {string} directory The directory to start searching from. + * @returns {string[]} The paths of local config files found. + */ + findLocalConfigFiles(directory) { - if (!this.localConfigFinder) { - this.localConfigFinder = new FileFinder(ConfigFile.CONFIG_FILES, this.options.cwd); - } + if (!this.localConfigFinder) { + this.localConfigFinder = new FileFinder(ConfigFile.CONFIG_FILES, this.options.cwd); + } - return this.localConfigFinder.findAllInDirectoryAndParents(directory); -}; + return this.localConfigFinder.findAllInDirectoryAndParents(directory); + } +} module.exports = Config; diff --git a/tools/eslint/lib/config/autoconfig.js b/tools/eslint/lib/config/autoconfig.js index dd25bcd49191bc..23fdbe69803afc 100644 --- a/tools/eslint/lib/config/autoconfig.js +++ b/tools/eslint/lib/config/autoconfig.js @@ -49,14 +49,12 @@ const MAX_CONFIG_COMBINATIONS = 17, // 16 combinations + 1 for severity only * @returns {Object} registryItems for each rule in provided rulesConfig */ function makeRegistryItems(rulesConfig) { - return Object.keys(rulesConfig).reduce(function(accumulator, ruleId) { - accumulator[ruleId] = rulesConfig[ruleId].map(function(config) { - return { - config, - specificity: config.length || 1, - errorCount: void 0 - }; - }); + return Object.keys(rulesConfig).reduce((accumulator, ruleId) => { + accumulator[ruleId] = rulesConfig[ruleId].map(config => ({ + config, + specificity: config.length || 1, + errorCount: void 0 + })); return accumulator; }, {}); } @@ -173,10 +171,8 @@ Registry.prototype = { newRegistry = new Registry(); newRegistry.rules = Object.assign({}, this.rules); - ruleIds.forEach(function(ruleId) { - const errorFreeItems = newRegistry.rules[ruleId].filter(function(registryItem) { - return (registryItem.errorCount === 0); - }); + ruleIds.forEach(ruleId => { + const errorFreeItems = newRegistry.rules[ruleId].filter(registryItem => (registryItem.errorCount === 0)); if (errorFreeItems.length > 0) { newRegistry.rules[ruleId] = errorFreeItems; @@ -198,10 +194,8 @@ Registry.prototype = { newRegistry = new Registry(); newRegistry.rules = Object.assign({}, this.rules); - ruleIds.forEach(function(ruleId) { - newRegistry.rules[ruleId] = newRegistry.rules[ruleId].filter(function(registryItem) { - return (typeof registryItem.errorCount !== "undefined"); - }); + ruleIds.forEach(ruleId => { + newRegistry.rules[ruleId] = newRegistry.rules[ruleId].filter(registryItem => (typeof registryItem.errorCount !== "undefined")); }); return newRegistry; @@ -218,15 +212,13 @@ Registry.prototype = { const ruleIds = Object.keys(this.rules), failingRegistry = new Registry(); - ruleIds.forEach(function(ruleId) { - const failingConfigs = this.rules[ruleId].filter(function(registryItem) { - return (registryItem.errorCount > 0); - }); + ruleIds.forEach(ruleId => { + const failingConfigs = this.rules[ruleId].filter(registryItem => (registryItem.errorCount > 0)); if (failingConfigs && failingConfigs.length === this.rules[ruleId].length) { failingRegistry.rules[ruleId] = failingConfigs; } - }.bind(this)); + }); return failingRegistry; }, @@ -239,13 +231,13 @@ Registry.prototype = { */ createConfig() { const ruleIds = Object.keys(this.rules), - config = {rules: {}}; + config = { rules: {} }; - ruleIds.forEach(function(ruleId) { + ruleIds.forEach(ruleId => { if (this.rules[ruleId].length === 1) { config.rules[ruleId] = this.rules[ruleId][0].config; } - }.bind(this)); + }); return config; }, @@ -261,11 +253,9 @@ Registry.prototype = { newRegistry = new Registry(); newRegistry.rules = Object.assign({}, this.rules); - ruleIds.forEach(function(ruleId) { - newRegistry.rules[ruleId] = this.rules[ruleId].filter(function(registryItem) { - return (registryItem.specificity === specificity); - }); - }.bind(this)); + ruleIds.forEach(ruleId => { + newRegistry.rules[ruleId] = this.rules[ruleId].filter(registryItem => (registryItem.specificity === specificity)); + }); return newRegistry; }, @@ -294,16 +284,16 @@ Registry.prototype = { const filenames = Object.keys(sourceCodes); const totalFilesLinting = filenames.length * ruleSets.length; - filenames.forEach(function(filename) { + filenames.forEach(filename => { debug(`Linting file: ${filename}`); ruleSetIdx = 0; - ruleSets.forEach(function(ruleSet) { - const lintConfig = Object.assign({}, config, {rules: ruleSet}); + ruleSets.forEach(ruleSet => { + const lintConfig = Object.assign({}, config, { rules: ruleSet }); const lintResults = eslint.verify(sourceCodes[filename], lintConfig); - lintResults.forEach(function(result) { + lintResults.forEach(result => { // It is possible that the error is from a configuration comment // in a linted file, in which case there may not be a config @@ -342,11 +332,9 @@ function extendFromRecommended(config) { ConfigOps.normalizeToStrings(newConfig); - const recRules = Object.keys(recConfig.rules).filter(function(ruleId) { - return ConfigOps.isErrorSeverity(recConfig.rules[ruleId]); - }); + const recRules = Object.keys(recConfig.rules).filter(ruleId => ConfigOps.isErrorSeverity(recConfig.rules[ruleId])); - recRules.forEach(function(ruleId) { + recRules.forEach(ruleId => { if (lodash.isEqual(recConfig.rules[ruleId], newConfig.rules[ruleId])) { delete newConfig.rules[ruleId]; } diff --git a/tools/eslint/lib/config/config-file.js b/tools/eslint/lib/config/config-file.js index c11a55fad8413d..90015097a3db97 100644 --- a/tools/eslint/lib/config/config-file.js +++ b/tools/eslint/lib/config/config-file.js @@ -235,7 +235,7 @@ function loadConfigFile(file) { function writeJSONConfigFile(config, filePath) { debug(`Writing JSON config file: ${filePath}`); - const content = stringify(config, {cmp: sortByKey, space: 4}); + const content = stringify(config, { cmp: sortByKey, space: 4 }); fs.writeFileSync(filePath, content, "utf8"); } @@ -253,7 +253,7 @@ function writeYAMLConfigFile(config, filePath) { // lazy load YAML to improve performance when not used const yaml = require("js-yaml"); - const content = yaml.safeDump(config, {sortKeys: true}); + const content = yaml.safeDump(config, { sortKeys: true }); fs.writeFileSync(filePath, content, "utf8"); } @@ -268,7 +268,7 @@ function writeYAMLConfigFile(config, filePath) { function writeJSConfigFile(config, filePath) { debug(`Writing JS config file: ${filePath}`); - const content = `module.exports = ${stringify(config, {cmp: sortByKey, space: 4})};`; + const content = `module.exports = ${stringify(config, { cmp: sortByKey, space: 4 })};`; fs.writeFileSync(filePath, content, "utf8"); } @@ -359,7 +359,7 @@ function applyExtends(config, filePath, relativeTo) { } // Make the last element in an array take the highest precedence - config = configExtends.reduceRight(function(previousValue, parentPath) { + config = configExtends.reduceRight((previousValue, parentPath) => { if (parentPath === "eslint:recommended") { @@ -430,7 +430,7 @@ function normalizePackageName(name, prefix) { * it's a scoped package * package name is "eslint-config", or just a username */ - const scopedPackageShortcutRegex = new RegExp(`^(@[^\/]+)(?:\/(?:${prefix})?)?$`), + const scopedPackageShortcutRegex = new RegExp(`^(@[^/]+)(?:/(?:${prefix})?)?$`), scopedPackageNameRegex = new RegExp(`^${prefix}(-|$)`); if (scopedPackageShortcutRegex.test(name)) { @@ -441,7 +441,7 @@ function normalizePackageName(name, prefix) { * for scoped packages, insert the eslint-config after the first / unless * the path is already @scope/eslint or @scope/eslint-config-xxx */ - name = name.replace(/^@([^\/]+)\/(.*)$/, `@$1/${prefix}-$2`); + name = name.replace(/^@([^/]+)\/(.*)$/, `@$1/${prefix}-$2`); } } else if (name.indexOf(`${prefix}-`) !== 0) { name = `${prefix}-${name}`; diff --git a/tools/eslint/lib/config/config-initializer.js b/tools/eslint/lib/config/config-initializer.js index e3aef07baef388..502a73bd6c3ed1 100644 --- a/tools/eslint/lib/config/config-initializer.js +++ b/tools/eslint/lib/config/config-initializer.js @@ -44,10 +44,14 @@ function writeFile(config, format) { extname = ".json"; } + const installedESLint = config.installedESLint; + + delete config.installedESLint; + ConfigFile.write(config, `./.eslintrc${extname}`); log.info(`Successfully created .eslintrc${extname} file in ${process.cwd()}`); - if (config.installedESLint) { + if (installedESLint) { log.info("ESLint was installed locally. We recommend using this local copy instead of your globally-installed copy."); } } @@ -62,9 +66,7 @@ function installModules(config) { // Create a list of modules which should be installed based on config if (config.plugins) { - modules = modules.concat(config.plugins.map(function(name) { - return `eslint-plugin-${name}`; - })); + modules = modules.concat(config.plugins.map(name => `eslint-plugin-${name}`)); } if (config.extends && config.extends.indexOf("eslint:") === -1) { modules.push(`eslint-config-${config.extends}`); @@ -81,7 +83,7 @@ function installModules(config) { const installStatus = npmUtil.checkDevDeps(modules); // Install packages which aren't already installed - const modulesToInstall = Object.keys(installStatus).filter(function(module) { + const modulesToInstall = Object.keys(installStatus).filter(module => { const notInstalled = installStatus[module] === false; if (module === "eslint" && notInstalled) { @@ -128,7 +130,7 @@ function configureRules(answers, config) { const patterns = answers.patterns.split(/[\s]+/); try { - sourceCodes = getSourceCodeOfFiles(patterns, { baseConfig: newConfig, useEslintrc: false }, function(total) { + sourceCodes = getSourceCodeOfFiles(patterns, { baseConfig: newConfig, useEslintrc: false }, total => { bar.tick((BAR_SOURCE_CODE_TOTAL / total)); }); } catch (e) { @@ -147,20 +149,18 @@ function configureRules(answers, config) { registry.populateFromCoreRules(); // Lint all files with each rule config in the registry - registry = registry.lintSourceCode(sourceCodes, newConfig, function(total) { + registry = registry.lintSourceCode(sourceCodes, newConfig, total => { bar.tick((BAR_TOTAL - BAR_SOURCE_CODE_TOTAL) / total); // Subtract out ticks used at beginning }); - debug(`\nRegistry: ${util.inspect(registry.rules, {depth: null})}`); + debug(`\nRegistry: ${util.inspect(registry.rules, { depth: null })}`); // Create a list of recommended rules, because we don't want to disable them - const recRules = Object.keys(recConfig.rules).filter(function(ruleId) { - return ConfigOps.isErrorSeverity(recConfig.rules[ruleId]); - }); + const recRules = Object.keys(recConfig.rules).filter(ruleId => ConfigOps.isErrorSeverity(recConfig.rules[ruleId])); // Find and disable rules which had no error-free configuration const failingRegistry = registry.getFailingRulesRegistry(); - Object.keys(failingRegistry.rules).forEach(function(ruleId) { + Object.keys(failingRegistry.rules).forEach(ruleId => { // If the rule is recommended, set it to error, otherwise disable it disabledConfigs[ruleId] = (recRules.indexOf(ruleId) !== -1) ? 2 : 0; @@ -194,9 +194,7 @@ function configureRules(answers, config) { // Log out some stats to let the user know what happened const finalRuleIds = Object.keys(newConfig.rules); const totalRules = finalRuleIds.length; - const enabledRules = finalRuleIds.filter(function(ruleId) { - return (newConfig.rules[ruleId] !== 0); - }).length; + const enabledRules = finalRuleIds.filter(ruleId => (newConfig.rules[ruleId] !== 0)).length; const resultMessage = [ `\nEnabled ${enabledRules} out of ${totalRules}`, `rules based on ${fileQty}`, @@ -215,7 +213,7 @@ function configureRules(answers, config) { * @returns {Object} config object */ function processAnswers(answers) { - let config = {rules: {}, env: {}}; + let config = { rules: {}, env: {} }; if (answers.es6) { config.env.es6 = true; @@ -227,7 +225,7 @@ function processAnswers(answers) { if (answers.commonjs) { config.env.commonjs = true; } - answers.env.forEach(function(env) { + answers.env.forEach(env => { config.env[env] = true; }); if (answers.jsx) { @@ -266,9 +264,10 @@ function processAnswers(answers) { */ function getConfigForStyleGuide(guide) { const guides = { - google: {extends: "google"}, - airbnb: {extends: "airbnb", plugins: ["react", "jsx-a11y", "import"]}, - standard: {extends: "standard", plugins: ["standard", "promise"]} + google: { extends: "google" }, + airbnb: { extends: "airbnb", plugins: ["react", "jsx-a11y", "import"] }, + "airbnb-base": { extends: "airbnb-base", plugins: ["import"] }, + standard: { extends: "standard", plugins: ["standard", "promise"] } }; if (!guides[guide]) { @@ -296,21 +295,30 @@ function promptUser(callback) { message: "How would you like to configure ESLint?", default: "prompt", choices: [ - {name: "Answer questions about your style", value: "prompt"}, - {name: "Use a popular style guide", value: "guide"}, - {name: "Inspect your JavaScript file(s)", value: "auto"} + { name: "Answer questions about your style", value: "prompt" }, + { name: "Use a popular style guide", value: "guide" }, + { name: "Inspect your JavaScript file(s)", value: "auto" } ] }, { type: "list", name: "styleguide", message: "Which style guide do you want to follow?", - choices: [{name: "Google", value: "google"}, {name: "Airbnb", value: "airbnb"}, {name: "Standard", value: "standard"}], + choices: [{ name: "Google", value: "google" }, { name: "Airbnb", value: "airbnb" }, { name: "Standard", value: "standard" }], when(answers) { answers.packageJsonExists = npmUtil.checkPackageJson(); return answers.source === "guide" && answers.packageJsonExists; } }, + { + type: "confirm", + name: "airbnbReact", + message: "Do you use React?", + default: false, + when(answers) { + return answers.styleguide === "airbnb"; + }, + }, { type: "input", name: "patterns", @@ -335,7 +343,7 @@ function promptUser(callback) { return ((answers.source === "guide" && answers.packageJsonExists) || answers.source === "auto"); } } - ], function(earlyAnswers) { + ], earlyAnswers => { // early exit if you are using a style guide if (earlyAnswers.source === "guide") { @@ -343,7 +351,9 @@ function promptUser(callback) { log.info("A package.json is necessary to install plugins such as style guides. Run `npm init` to create a package.json file and try again."); return; } - + if (earlyAnswers.styleguide === "airbnb" && !earlyAnswers.airbnbReact) { + earlyAnswers.styleguide = "airbnb-base"; + } try { config = getConfigForStyleGuide(earlyAnswers.styleguide); writeFile(config, earlyAnswers.format); @@ -376,7 +386,7 @@ function promptUser(callback) { name: "env", message: "Where will your code run?", default: ["browser"], - choices: [{name: "Browser", value: "browser"}, {name: "Node", value: "node"}] + choices: [{ name: "Browser", value: "browser" }, { name: "Node", value: "node" }] }, { type: "confirm", @@ -384,9 +394,7 @@ function promptUser(callback) { message: "Do you use CommonJS?", default: false, when(answers) { - return answers.env.some(function(env) { - return env === "browser"; - }); + return answers.env.some(env => env === "browser"); } }, { @@ -398,13 +406,13 @@ function promptUser(callback) { { type: "confirm", name: "react", - message: "Do you use React", + message: "Do you use React?", default: false, when(answers) { return answers.jsx; } } - ], function(secondAnswers) { + ], secondAnswers => { // early exit if you are using automatic style generation if (earlyAnswers.source === "auto") { @@ -428,21 +436,21 @@ function promptUser(callback) { name: "indent", message: "What style of indentation do you use?", default: "tab", - choices: [{name: "Tabs", value: "tab"}, {name: "Spaces", value: 4}] + choices: [{ name: "Tabs", value: "tab" }, { name: "Spaces", value: 4 }] }, { type: "list", name: "quotes", message: "What quotes do you use for strings?", default: "double", - choices: [{name: "Double", value: "double"}, {name: "Single", value: "single"}] + choices: [{ name: "Double", value: "double" }, { name: "Single", value: "single" }] }, { type: "list", name: "linebreak", message: "What line endings do you use?", default: "unix", - choices: [{name: "Unix", value: "unix"}, {name: "Windows", value: "windows"}] + choices: [{ name: "Unix", value: "unix" }, { name: "Windows", value: "windows" }] }, { type: "confirm", @@ -457,7 +465,7 @@ function promptUser(callback) { default: "JavaScript", choices: ["JavaScript", "YAML", "JSON"] } - ], function(answers) { + ], answers => { try { const totalAnswers = Object.assign({}, earlyAnswers, secondAnswers, answers); @@ -465,10 +473,8 @@ function promptUser(callback) { installModules(config); writeFile(config, answers.format); } catch (err) { - callback(err); - return; + callback(err); // eslint-disable-line callback-return } - return; }); }); }); diff --git a/tools/eslint/lib/config/config-ops.js b/tools/eslint/lib/config/config-ops.js index 42b0fe81b90615..52dea1a106df79 100644 --- a/tools/eslint/lib/config/config-ops.js +++ b/tools/eslint/lib/config/config-ops.js @@ -18,7 +18,7 @@ const debug = require("debug")("eslint:config-ops"); //------------------------------------------------------------------------------ const RULE_SEVERITY_STRINGS = ["off", "warn", "error"], - RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce(function(map, value, index) { + RULE_SEVERITY = RULE_SEVERITY_STRINGS.reduce((map, value, index) => { map[value] = index; return map; }, {}), @@ -57,9 +57,7 @@ module.exports = { envConfig.env = env; - Object.keys(env).filter(function(name) { - return env[name]; - }).forEach(function(name) { + Object.keys(env).filter(name => env[name]).forEach(name => { const environment = Environments.get(name); if (environment) { @@ -149,7 +147,7 @@ module.exports = { if (typeof src !== "object" && !Array.isArray(src)) { src = [src]; } - Object.keys(src).forEach(function(e, i) { + Object.keys(src).forEach((e, i) => { e = src[i]; if (typeof dst[i] === "undefined") { dst[i] = e; @@ -171,11 +169,11 @@ module.exports = { }); } else { if (target && typeof target === "object") { - Object.keys(target).forEach(function(key) { + Object.keys(target).forEach(key => { dst[key] = target[key]; }); } - Object.keys(src).forEach(function(key) { + Object.keys(src).forEach(key => { if (Array.isArray(src[key]) || Array.isArray(target[key])) { dst[key] = deepmerge(target[key], src[key], key === "plugins", isRule); } else if (typeof src[key] !== "object" || !src[key] || key === "exported" || key === "astGlobals") { @@ -199,7 +197,7 @@ module.exports = { normalize(config) { if (config.rules) { - Object.keys(config.rules).forEach(function(ruleId) { + Object.keys(config.rules).forEach(ruleId => { const ruleConfig = config.rules[ruleId]; if (typeof ruleConfig === "string") { @@ -221,7 +219,7 @@ module.exports = { normalizeToStrings(config) { if (config.rules) { - Object.keys(config.rules).forEach(function(ruleId) { + Object.keys(config.rules).forEach(ruleId => { const ruleConfig = config.rules[ruleId]; if (typeof ruleConfig === "number") { @@ -269,8 +267,6 @@ module.exports = { * @returns {boolean} `true` if the configuration has valid severity. */ isEverySeverityValid(config) { - return Object.keys(config).every(function(ruleId) { - return this.isValidSeverity(config[ruleId]); - }, this); + return Object.keys(config).every(ruleId => this.isValidSeverity(config[ruleId])); } }; diff --git a/tools/eslint/lib/config/config-rule.js b/tools/eslint/lib/config/config-rule.js index eb5c23fe8c840a..d495198aed454b 100644 --- a/tools/eslint/lib/config/config-rule.js +++ b/tools/eslint/lib/config/config-rule.js @@ -23,7 +23,7 @@ const rules = require("../rules"), * @returns {Array[]} An array of arrays. */ function explodeArray(xs) { - return xs.reduce(function(accumulator, x) { + return xs.reduce((accumulator, x) => { accumulator.push([x]); return accumulator; }, []); @@ -49,8 +49,8 @@ function combineArrays(arr1, arr2) { if (arr2.length === 0) { return explodeArray(arr1); } - arr1.forEach(function(x1) { - arr2.forEach(function(x2) { + arr1.forEach(x1 => { + arr2.forEach(x2 => { res.push([].concat(x1, x2)); }); }); @@ -78,16 +78,14 @@ function combineArrays(arr1, arr2) { * @returns {Array[]} Array of arrays of objects grouped by property */ function groupByProperty(objects) { - const groupedObj = objects.reduce(function(accumulator, obj) { + const groupedObj = objects.reduce((accumulator, obj) => { const prop = Object.keys(obj)[0]; accumulator[prop] = accumulator[prop] ? accumulator[prop].concat(obj) : [obj]; return accumulator; }, {}); - return Object.keys(groupedObj).map(function(prop) { - return groupedObj[prop]; - }); + return Object.keys(groupedObj).map(prop => groupedObj[prop]); } @@ -152,16 +150,16 @@ function combinePropertyObjects(objArr1, objArr2) { if (objArr2.length === 0) { return objArr1; } - objArr1.forEach(function(obj1) { - objArr2.forEach(function(obj2) { + objArr1.forEach(obj1 => { + objArr2.forEach(obj2 => { const combinedObj = {}; const obj1Props = Object.keys(obj1); const obj2Props = Object.keys(obj2); - obj1Props.forEach(function(prop1) { + obj1Props.forEach(prop1 => { combinedObj[prop1] = obj1[prop1]; }); - obj2Props.forEach(function(prop2) { + obj2Props.forEach(prop2 => { combinedObj[prop2] = obj2[prop2]; }); res.push(combinedObj); @@ -205,7 +203,7 @@ RuleConfigSet.prototype = { addErrorSeverity(severity) { severity = severity || 2; - this.ruleConfigs = this.ruleConfigs.map(function(config) { + this.ruleConfigs = this.ruleConfigs.map(config => { config.unshift(severity); return config; }); @@ -241,9 +239,7 @@ RuleConfigSet.prototype = { }, combine() { - this.objectConfigs = groupByProperty(this.objectConfigs).reduce(function(accumulator, objArr) { - return combinePropertyObjects(accumulator, objArr); - }, []); + this.objectConfigs = groupByProperty(this.objectConfigs).reduce((accumulator, objArr) => combinePropertyObjects(accumulator, objArr), []); } }; @@ -251,7 +247,7 @@ RuleConfigSet.prototype = { * The object schema could have multiple independent properties. * If any contain enums or booleans, they can be added and then combined */ - Object.keys(obj.properties).forEach(function(prop) { + Object.keys(obj.properties).forEach(prop => { if (obj.properties[prop].enum) { objectConfigSet.add(prop, obj.properties[prop].enum); } @@ -276,7 +272,7 @@ function generateConfigsFromSchema(schema) { const configSet = new RuleConfigSet(); if (Array.isArray(schema)) { - schema.forEach(function(opt) { + schema.forEach(opt => { if (opt.enum) { configSet.addEnums(opt.enum); } @@ -302,7 +298,7 @@ function generateConfigsFromSchema(schema) { function createCoreRuleConfigs() { const ruleList = loadRules(); - return Object.keys(ruleList).reduce(function(accumulator, id) { + return Object.keys(ruleList).reduce((accumulator, id) => { const rule = rules.get(id); const schema = (typeof rule === "function") ? rule.schema : rule.meta.schema; diff --git a/tools/eslint/lib/config/config-validator.js b/tools/eslint/lib/config/config-validator.js index ef285eae4e6032..c5268169b92356 100644 --- a/tools/eslint/lib/config/config-validator.js +++ b/tools/eslint/lib/config/config-validator.js @@ -54,65 +54,59 @@ function getRuleOptionsSchema(id) { } /** - * Validates a rule's options against its schema. - * @param {string} id The rule's unique name. - * @param {array|number} options The given options for the rule. - * @param {string} source The name of the configuration source. - * @returns {void} - */ -function validateRuleOptions(id, options, source) { - const schema = getRuleOptionsSchema(id); - let validateRule = validators.rules[id], - severity, - localOptions, - validSeverity = true; - - if (!validateRule && schema) { - validateRule = schemaValidator(schema, { verbose: true }); - validators.rules[id] = validateRule; +* Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid. +* @param {options} options The given options for the rule. +* @returns {number|string} The rule's severity value +*/ +function validateRuleSeverity(options) { + const severity = Array.isArray(options) ? options[0] : options; + + if (severity !== 0 && severity !== 1 && severity !== 2 && !(typeof severity === "string" && /^(?:off|warn|error)$/i.test(severity))) { + throw new Error(`\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '${util.inspect(severity).replace(/'/g, "\"").replace(/\n/g, "")}').\n`); } - // if it's not an array, it should be just a severity - if (Array.isArray(options)) { - localOptions = options.concat(); // clone - severity = localOptions.shift(); - } else { - severity = options; - localOptions = []; + return severity; +} + +/** +* Validates the non-severity options passed to a rule, based on its schema. +* @param {string} id The rule's unique name +* @param {array} localOptions The options for the rule, excluding severity +* @returns {void} +*/ +function validateRuleSchema(id, localOptions) { + const schema = getRuleOptionsSchema(id); + + if (!validators.rules[id] && schema) { + validators.rules[id] = schemaValidator(schema, { verbose: true }); } - validSeverity = ( - severity === 0 || severity === 1 || severity === 2 || - (typeof severity === "string" && /^(?:off|warn|error)$/i.test(severity)) - ); + const validateRule = validators.rules[id]; if (validateRule) { validateRule(localOptions); + if (validateRule.errors) { + throw new Error(validateRule.errors.map(error => `\tValue "${error.value}" ${error.message}.\n`).join("")); + } } +} - if ((validateRule && validateRule.errors) || !validSeverity) { - const message = [ - source, ":\n", - "\tConfiguration for rule \"", id, "\" is invalid:\n" - ]; - - if (!validSeverity) { - message.push( - "\tSeverity should be one of the following: 0 = off, 1 = warn, 2 = error (you passed '", - util.inspect(severity).replace(/'/g, "\"").replace(/\n/g, ""), - "').\n" - ); - } +/** + * Validates a rule's options against its schema. + * @param {string} id The rule's unique name. + * @param {array|number} options The given options for the rule. + * @param {string} source The name of the configuration source. + * @returns {void} + */ +function validateRuleOptions(id, options, source) { + try { + const severity = validateRuleSeverity(options); - if (validateRule && validateRule.errors) { - validateRule.errors.forEach(function(error) { - message.push( - "\tValue \"", error.value, "\" ", error.message, ".\n" - ); - }); + if (severity !== 0 && !(typeof severity === "string" && severity.toLowerCase() === "off")) { + validateRuleSchema(id, Array.isArray(options) ? options.slice(1) : []); } - - throw new Error(message.join("")); + } catch (err) { + throw new Error(`${source}:\n\tConfiguration for rule "${id}" is invalid:\n${err.message}`); } } @@ -134,7 +128,7 @@ function validateEnvironment(environment, source) { } if (typeof environment === "object") { - Object.keys(environment).forEach(function(env) { + Object.keys(environment).forEach(env => { if (!Environments.get(env)) { const message = [ source, ":\n", @@ -158,7 +152,7 @@ function validateEnvironment(environment, source) { function validate(config, source) { if (typeof config.rules === "object") { - Object.keys(config.rules).forEach(function(id) { + Object.keys(config.rules).forEach(id => { validateRuleOptions(id, config.rules[id], source); }); } diff --git a/tools/eslint/lib/config/environments.js b/tools/eslint/lib/config/environments.js index 36b989068ff6da..5c34da9328a4da 100644 --- a/tools/eslint/lib/config/environments.js +++ b/tools/eslint/lib/config/environments.js @@ -22,7 +22,7 @@ let environments = new Map(); * @private */ function load() { - Object.keys(envs).forEach(function(envName) { + Object.keys(envs).forEach(envName => { environments.set(envName, envs[envName]); }); } @@ -65,9 +65,9 @@ module.exports = { */ importPlugin(plugin, pluginName) { if (plugin.environments) { - Object.keys(plugin.environments).forEach(function(envName) { + Object.keys(plugin.environments).forEach(envName => { this.define(`${pluginName}/${envName}`, plugin.environments[envName]); - }, this); + }); } }, diff --git a/tools/eslint/lib/eslint.js b/tools/eslint/lib/eslint.js index fd7685f49257c6..3ae7cfe9c68103 100755 --- a/tools/eslint/lib/eslint.js +++ b/tools/eslint/lib/eslint.js @@ -26,7 +26,22 @@ const assert = require("assert"), Traverser = require("./util/traverser"), RuleContext = require("./rule-context"), rules = require("./rules"), - timing = require("./timing"); + timing = require("./timing"), + + pkg = require("../package.json"); + + +//------------------------------------------------------------------------------ +// Typedefs +//------------------------------------------------------------------------------ + +/** + * The result of a parsing operation from parseForESLint() + * @typedef {Object} CustomParseResult + * @property {ASTNode} ast The ESTree AST Program node. + * @property {Object} services An object containing additional services related + * to the parser. + */ //------------------------------------------------------------------------------ // Helpers @@ -45,7 +60,7 @@ function parseBooleanConfig(string, comment) { // Collapse whitespace around `:` and `,` to make parsing easier string = string.replace(/\s*([:,])\s*/g, "$1"); - string.split(/\s|,+/).forEach(function(name) { + string.split(/\s|,+/).forEach(name => { if (!name) { return; } @@ -95,7 +110,7 @@ function parseJsonConfig(string, location, messages) { // Optionator cannot parse commaless notations. // But we are supporting that. So this is a fallback for that. items = {}; - string = string.replace(/([a-zA-Z0-9\-\/]+):/g, "\"$1\":").replace(/(\]|[0-9])\s+(?=")/, "$1,"); + string = string.replace(/([a-zA-Z0-9\-/]+):/g, "\"$1\":").replace(/(]|[0-9])\s+(?=")/, "$1,"); try { items = JSON.parse(`{${string}}`); } catch (ex) { @@ -126,7 +141,7 @@ function parseListConfig(string) { // Collapse whitespace around , string = string.replace(/\s*,\s*/g, ","); - string.split(/,+/).forEach(function(name) { + string.split(/,+/).forEach(name => { name = name.trim(); if (!name) { return; @@ -153,7 +168,7 @@ function addDeclaredGlobals(program, globalScope, config) { Object.assign(declaredGlobals, builtin); - Object.keys(config.env).forEach(function(name) { + Object.keys(config.env).forEach(name => { if (config.env[name]) { const env = Environments.get(name), environmentGlobals = env && env.globals; @@ -168,7 +183,7 @@ function addDeclaredGlobals(program, globalScope, config) { Object.assign(declaredGlobals, config.globals); Object.assign(explicitGlobals, config.astGlobals); - Object.keys(declaredGlobals).forEach(function(name) { + Object.keys(declaredGlobals).forEach(name => { let variable = globalScope.set.get(name); if (!variable) { @@ -180,7 +195,7 @@ function addDeclaredGlobals(program, globalScope, config) { variable.writeable = declaredGlobals[name]; }); - Object.keys(explicitGlobals).forEach(function(name) { + Object.keys(explicitGlobals).forEach(name => { let variable = globalScope.set.get(name); if (!variable) { @@ -194,7 +209,7 @@ function addDeclaredGlobals(program, globalScope, config) { }); // mark all exported variables as such - Object.keys(exportedGlobals).forEach(function(name) { + Object.keys(exportedGlobals).forEach(name => { const variable = globalScope.set.get(name); if (variable) { @@ -207,7 +222,7 @@ function addDeclaredGlobals(program, globalScope, config) { * Since we augment the global scope using configuration, we need to update * references and remove the ones that were added by configuration. */ - globalScope.through = globalScope.through.filter(function(reference) { + globalScope.through = globalScope.through.filter(reference => { const name = reference.identifier.name; const variable = globalScope.set.get(name); @@ -238,7 +253,7 @@ function addDeclaredGlobals(program, globalScope, config) { function disableReporting(reportingConfig, start, rulesToDisable) { if (rulesToDisable.length) { - rulesToDisable.forEach(function(rule) { + rulesToDisable.forEach(rule => { reportingConfig.push({ start, end: null, @@ -266,7 +281,7 @@ function enableReporting(reportingConfig, start, rulesToEnable) { let i; if (rulesToEnable.length) { - rulesToEnable.forEach(function(rule) { + rulesToEnable.forEach(rule => { for (i = reportingConfig.length - 1; i >= 0; i--) { if (!reportingConfig[i].end && reportingConfig[i].rule === rule) { reportingConfig[i].end = start; @@ -313,7 +328,7 @@ function modifyConfigsFromComments(filename, ast, config, reportingConfig, messa }; const commentRules = {}; - ast.comments.forEach(function(comment) { + ast.comments.forEach(comment => { let value = comment.value.trim(); const match = /^(eslint(-\w+){0,3}|exported|globals?)(\s|$)/.exec(value); @@ -347,7 +362,7 @@ function modifyConfigsFromComments(filename, ast, config, reportingConfig, messa case "eslint": { const items = parseJsonConfig(value, comment.loc, messages); - Object.keys(items).forEach(function(name) { + Object.keys(items).forEach(name => { const ruleValue = items[name]; validator.validateRuleOptions(name, ruleValue, `${filename} line ${comment.loc.start.line}`); @@ -371,7 +386,7 @@ function modifyConfigsFromComments(filename, ast, config, reportingConfig, messa }); // apply environment configs - Object.keys(commentConfig.env).forEach(function(name) { + Object.keys(commentConfig.env).forEach(name => { const env = Environments.get(name); if (env) { @@ -442,11 +457,11 @@ function prepareConfig(config) { let parserOptions = {}; if (typeof config.rules === "object") { - Object.keys(config.rules).forEach(function(k) { + Object.keys(config.rules).forEach(k => { const rule = config.rules[k]; if (rule === null) { - throw new Error(`Invalid config for rule '${k}'\.`); + throw new Error(`Invalid config for rule '${k}'.`); } if (Array.isArray(rule)) { copiedRules[k] = rule.slice(); @@ -458,7 +473,7 @@ function prepareConfig(config) { // merge in environment parserOptions if (typeof config.env === "object") { - Object.keys(config.env).forEach(function(envName) { + Object.keys(config.env).forEach(envName => { const env = Environments.get(envName); if (config.env[envName] && env && env.parserOptions) { @@ -598,7 +613,8 @@ module.exports = (function() { * @param {string} text The text to parse. * @param {Object} config The ESLint configuration object. * @param {string} filePath The path to the file being parsed. - * @returns {ASTNode} The AST if successful or null if not. + * @returns {ASTNode|CustomParseResult} The AST or parse result if successful, + * or null if not. * @private */ function parse(text, config, filePath) { @@ -642,7 +658,11 @@ module.exports = (function() { * problem that ESLint identified just like any other. */ try { - return parser.parse(text, parserOptions); + if (typeof parser.parseForESLint === "function") { + return parser.parseForESLint(text, parserOptions); + } else { + return parser.parse(text, parserOptions); + } } catch (ex) { // If the message includes a leading line number, strip it: @@ -738,6 +758,7 @@ module.exports = (function() { api.verify = function(textOrSourceCode, config, filenameOrOptions, saveState) { const text = (typeof textOrSourceCode === "string") ? textOrSourceCode : null; let ast, + parseResult, shebang, allowInlineConfig; @@ -759,7 +780,7 @@ module.exports = (function() { if (envInFile) { if (!config || !config.env) { - config = Object.assign({}, config || {}, {env: envInFile}); + config = Object.assign({}, config || {}, { env: envInFile }); } else { config = Object.assign({}, config); config.env = Object.assign({}, config.env, envInFile); @@ -778,8 +799,8 @@ module.exports = (function() { return messages; } - ast = parse( - stripUnicodeBOM(text).replace(/^#!([^\r\n]+)/, function(match, captured) { + parseResult = parse( + stripUnicodeBOM(text).replace(/^#!([^\r\n]+)/, (match, captured) => { shebang = captured; return `//${captured}`; }), @@ -787,6 +808,14 @@ module.exports = (function() { currentFilename ); + // if this result is from a parseForESLint() method, normalize + if (parseResult && parseResult.ast) { + ast = parseResult.ast; + } else { + ast = parseResult; + parseResult = null; + } + if (ast) { sourceCode = new SourceCode(text, ast); } @@ -808,9 +837,7 @@ module.exports = (function() { ConfigOps.normalize(config); // enable appropriate rules - Object.keys(config.rules).filter(function(key) { - return getRuleSeverity(config.rules[key]) > 0; - }).forEach(function(key) { + Object.keys(config.rules).filter(key => getRuleSeverity(config.rules[key]) > 0).forEach(key => { let ruleCreator; ruleCreator = rules.get(key); @@ -832,13 +859,16 @@ module.exports = (function() { try { const ruleContext = new RuleContext( key, api, severity, options, - config.settings, config.parserOptions, config.parser, ruleCreator.meta); + config.settings, config.parserOptions, config.parser, + ruleCreator.meta, + (parseResult && parseResult.services ? parseResult.services : {}) + ); const rule = ruleCreator.create ? ruleCreator.create(ruleContext) : ruleCreator(ruleContext); // add all the node types as listeners - Object.keys(rule).forEach(function(nodeType) { + Object.keys(rule).forEach(nodeType => { api.on(nodeType, timing.enabled ? timing.time(key, rule[nodeType]) : rule[nodeType] @@ -904,7 +934,7 @@ module.exports = (function() { } // sort by line and column - messages.sort(function(a, b) { + messages.sort((a, b) => { const lineDiff = a.line - b.line; if (lineDiff === 0) { @@ -957,7 +987,7 @@ module.exports = (function() { } if (opts) { - message = message.replace(/\{\{\s*([^{}]+?)\s*\}\}/g, function(fullMatch, term) { + message = message.replace(/\{\{\s*([^{}]+?)\s*\}\}/g, (fullMatch, term) => { if (term in opts) { return opts[term]; } @@ -1027,7 +1057,7 @@ module.exports = (function() { }; // copy over methods - Object.keys(externalMethods).forEach(function(methodName) { + Object.keys(externalMethods).forEach(methodName => { const exMethodName = externalMethods[methodName]; // All functions expected to have less arguments than 5. @@ -1152,7 +1182,7 @@ module.exports = (function() { * @returns {void} */ api.defineRules = function(rulesToDefine) { - Object.getOwnPropertyNames(rulesToDefine).forEach(function(ruleId) { + Object.getOwnPropertyNames(rulesToDefine).forEach(ruleId => { defineRule(ruleId, rulesToDefine[ruleId]); }); }; @@ -1165,6 +1195,16 @@ module.exports = (function() { return require("../conf/eslint.json"); }; + /** + * Gets an object with all loaded rules. + * @returns {Map} All loaded rules + */ + api.getRules = function() { + return rules.getAllLoadedRules(); + }; + + api.version = pkg.version; + /** * Gets variables that are declared by a specified node. * diff --git a/tools/eslint/lib/file-finder.js b/tools/eslint/lib/file-finder.js index 18f3b65133d7a3..acb886c9d1e2c2 100644 --- a/tools/eslint/lib/file-finder.js +++ b/tools/eslint/lib/file-finder.js @@ -31,22 +31,6 @@ function getDirectoryEntries(directory) { } } -//------------------------------------------------------------------------------ -// API -//------------------------------------------------------------------------------ - -/** - * FileFinder - * @constructor - * @param {string[]} files The basename(s) of the file(s) to find. - * @param {stirng} cwd Current working directory - */ -function FileFinder(files, cwd) { - this.fileNames = Array.isArray(files) ? files : [files]; - this.cwd = cwd || process.cwd(); - this.cache = {}; -} - /** * Create a hash of filenames from a directory listing * @param {string[]} entries Array of directory entries. @@ -57,7 +41,7 @@ function FileFinder(files, cwd) { function normalizeDirectoryEntries(entries, directory, supportedConfigs) { const fileHash = {}; - entries.forEach(function(entry) { + entries.forEach(entry => { if (supportedConfigs.indexOf(entry) >= 0) { const resolvedEntry = path.resolve(directory, entry); @@ -69,69 +53,89 @@ function normalizeDirectoryEntries(entries, directory, supportedConfigs) { return fileHash; } +//------------------------------------------------------------------------------ +// API +//------------------------------------------------------------------------------ + /** - * Find all instances of files with the specified file names, in directory and - * parent directories. Cache the results. - * Does not check if a matching directory entry is a file. - * Searches for all the file names in this.fileNames. - * Is currently used by lib/config.js to find .eslintrc and package.json files. - * @param {string} directory The directory to start the search from. - * @returns {string[]} The file paths found. + * FileFinder class */ -FileFinder.prototype.findAllInDirectoryAndParents = function(directory) { - const cache = this.cache; - - if (directory) { - directory = path.resolve(this.cwd, directory); - } else { - directory = this.cwd; +class FileFinder { + + /** + * @param {string[]} files The basename(s) of the file(s) to find. + * @param {stirng} cwd Current working directory + */ + constructor(files, cwd) { + this.fileNames = Array.isArray(files) ? files : [files]; + this.cwd = cwd || process.cwd(); + this.cache = {}; } - if (cache.hasOwnProperty(directory)) { - return cache[directory]; - } + /** + * Find all instances of files with the specified file names, in directory and + * parent directories. Cache the results. + * Does not check if a matching directory entry is a file. + * Searches for all the file names in this.fileNames. + * Is currently used by lib/config.js to find .eslintrc and package.json files. + * @param {string} directory The directory to start the search from. + * @returns {string[]} The file paths found. + */ + findAllInDirectoryAndParents(directory) { + const cache = this.cache; + + if (directory) { + directory = path.resolve(this.cwd, directory); + } else { + directory = this.cwd; + } - const dirs = []; - const fileNames = this.fileNames; - let searched = 0; + if (cache.hasOwnProperty(directory)) { + return cache[directory]; + } - do { - dirs[searched++] = directory; - cache[directory] = []; + const dirs = []; + const fileNames = this.fileNames; + let searched = 0; - const filesMap = normalizeDirectoryEntries(getDirectoryEntries(directory), directory, fileNames); + do { + dirs[searched++] = directory; + cache[directory] = []; - if (Object.keys(filesMap).length) { - for (let k = 0; k < fileNames.length; k++) { + const filesMap = normalizeDirectoryEntries(getDirectoryEntries(directory), directory, fileNames); - if (filesMap[fileNames[k]]) { - const filePath = filesMap[fileNames[k]]; + if (Object.keys(filesMap).length) { + for (let k = 0; k < fileNames.length; k++) { - // Add the file path to the cache of each directory searched. - for (let j = 0; j < searched; j++) { - cache[dirs[j]].push(filePath); - } + if (filesMap[fileNames[k]]) { + const filePath = filesMap[fileNames[k]]; + + // Add the file path to the cache of each directory searched. + for (let j = 0; j < searched; j++) { + cache[dirs[j]].push(filePath); + } - break; + break; + } } } - } - const child = directory; + const child = directory; + + // Assign parent directory to directory. + directory = path.dirname(directory); - // Assign parent directory to directory. - directory = path.dirname(directory); + if (directory === child) { + return cache[dirs[0]]; + } + } while (!cache.hasOwnProperty(directory)); - if (directory === child) { - return cache[dirs[0]]; + // Add what has been cached previously to the cache of each directory searched. + for (let i = 0; i < searched; i++) { + dirs.push.apply(cache[dirs[i]], cache[directory]); } - } while (!cache.hasOwnProperty(directory)); - // Add what has been cached previously to the cache of each directory searched. - for (let i = 0; i < searched; i++) { - dirs.push.apply(cache[dirs[i]], cache[directory]); + return cache[dirs[0]]; } - - return cache[dirs[0]]; -}; +} module.exports = FileFinder; diff --git a/tools/eslint/lib/formatters/checkstyle.js b/tools/eslint/lib/formatters/checkstyle.js index 0beedcf6895217..5985ad0eff5752 100644 --- a/tools/eslint/lib/formatters/checkstyle.js +++ b/tools/eslint/lib/formatters/checkstyle.js @@ -35,12 +35,12 @@ module.exports = function(results) { output += ""; output += ""; - results.forEach(function(result) { + results.forEach(result => { const messages = result.messages; output += ``; - messages.forEach(function(message) { + messages.forEach(message => { output += [ ` 0 ? "red" : "yellow"; + const summary = []; + + if (errors > 0) { + summary.push(`${errors} ${pluralize("error", errors)}`); + } + + if (warnings > 0) { + summary.push(`${warnings} ${pluralize("warning", warnings)}`); + } + + return chalk[summaryColor].bold(`${summary.join(" and ")} found.`); +} + +//------------------------------------------------------------------------------ +// Public Interface +//------------------------------------------------------------------------------ + +module.exports = function(results) { + let errors = 0; + let warnings = 0; + const resultsWithMessages = results.filter(result => result.messages.length > 0); + + let output = resultsWithMessages.reduce((resultsOutput, result) => { + const messages = result.messages.map(message => { + if (message.fatal || message.severity === 2) { + errors++; + } else { + warnings++; + } + + return `${formatMessage(message, result)}\n\n`; + }); + + return resultsOutput.concat(messages); + }, []).join("\n"); + + output += "\n"; + output += formatSummary(errors, warnings); + + return (errors + warnings) > 0 ? output : ""; +}; diff --git a/tools/eslint/lib/formatters/compact.js b/tools/eslint/lib/formatters/compact.js index 9c7aeb87d7c064..c641039ff284c6 100644 --- a/tools/eslint/lib/formatters/compact.js +++ b/tools/eslint/lib/formatters/compact.js @@ -32,13 +32,13 @@ module.exports = function(results) { let output = "", total = 0; - results.forEach(function(result) { + results.forEach(result => { const messages = result.messages; total += messages.length; - messages.forEach(function(message) { + messages.forEach(message => { output += `${result.filePath}: `; output += `line ${message.line || 0}`; diff --git a/tools/eslint/lib/formatters/html.js b/tools/eslint/lib/formatters/html.js index 66e89d372cb8db..e61fdea6a93eec 100644 --- a/tools/eslint/lib/formatters/html.js +++ b/tools/eslint/lib/formatters/html.js @@ -70,7 +70,7 @@ function renderMessages(messages, parentIndex) { * @param {Object} message Message. * @returns {string} HTML (table row) describing a message. */ - return lodash.map(messages, function(message) { + return lodash.map(messages, message => { const lineNumber = message.line || 0; const columnNumber = message.column || 0; @@ -91,15 +91,13 @@ function renderMessages(messages, parentIndex) { * @returns {string} HTML string describing the results. */ function renderResults(results) { - return lodash.map(results, function(result, index) { - return resultTemplate({ - index, - color: renderColor(result.errorCount, result.warningCount), - filePath: result.filePath, - summary: renderSummary(result.errorCount, result.warningCount) - - }) + renderMessages(result.messages, index); - }).join("\n"); + return lodash.map(results, (result, index) => resultTemplate({ + index, + color: renderColor(result.errorCount, result.warningCount), + filePath: result.filePath, + summary: renderSummary(result.errorCount, result.warningCount) + + }) + renderMessages(result.messages, index)).join("\n"); } //------------------------------------------------------------------------------ @@ -114,7 +112,7 @@ module.exports = function(results) { totalWarnings = 0; // Iterate over results to get totals - results.forEach(function(result) { + results.forEach(result => { totalErrors += result.errorCount; totalWarnings += result.warningCount; }); diff --git a/tools/eslint/lib/formatters/jslint-xml.js b/tools/eslint/lib/formatters/jslint-xml.js index 7cfa893d32fad2..14743430d8ff94 100644 --- a/tools/eslint/lib/formatters/jslint-xml.js +++ b/tools/eslint/lib/formatters/jslint-xml.js @@ -17,12 +17,12 @@ module.exports = function(results) { output += ""; output += ""; - results.forEach(function(result) { + results.forEach(result => { const messages = result.messages; output += ``; - messages.forEach(function(message) { + messages.forEach(message => { output += [ `\n"; output += "\n"; - results.forEach(function(result) { + results.forEach(result => { const messages = result.messages; @@ -43,7 +43,7 @@ module.exports = function(results) { output += `\n`; } - messages.forEach(function(message) { + messages.forEach(message => { const type = message.fatal ? "error" : "failure"; output += ``; diff --git a/tools/eslint/lib/formatters/stylish.js b/tools/eslint/lib/formatters/stylish.js index 578a146c010f57..a176d03ab83e0b 100644 --- a/tools/eslint/lib/formatters/stylish.js +++ b/tools/eslint/lib/formatters/stylish.js @@ -33,7 +33,7 @@ module.exports = function(results) { warnings = 0, summaryColor = "yellow"; - results.forEach(function(result) { + results.forEach(result => { const messages = result.messages; if (messages.length === 0) { @@ -44,7 +44,7 @@ module.exports = function(results) { output += `${chalk.underline(result.filePath)}\n`; output += `${table( - messages.map(function(message) { + messages.map(message => { let messageType; if (message.fatal || message.severity === 2) { @@ -71,11 +71,7 @@ module.exports = function(results) { return chalk.stripColor(str).length; } } - ).split("\n").map(function(el) { - return el.replace(/(\d+)\s+(\d+)/, function(m, p1, p2) { - return chalk.dim(`${p1}:${p2}`); - }); - }).join("\n")}\n\n`; + ).split("\n").map(el => el.replace(/(\d+)\s+(\d+)/, (m, p1, p2) => chalk.dim(`${p1}:${p2}`))).join("\n")}\n\n`; }); if (total > 0) { diff --git a/tools/eslint/lib/formatters/table.js b/tools/eslint/lib/formatters/table.js index cd09626cc79381..b4859154ba610d 100644 --- a/tools/eslint/lib/formatters/table.js +++ b/tools/eslint/lib/formatters/table.js @@ -36,7 +36,7 @@ function drawTable(messages) { chalk.bold("Rule ID") ]); - messages.forEach(function(message) { + messages.forEach(message => { let messageType; if (message.fatal || message.severity === 2) { @@ -92,7 +92,7 @@ function drawTable(messages) { function drawReport(results) { let files; - files = results.map(function(result) { + files = results.map(result => { if (!result.messages.length) { return ""; } @@ -100,9 +100,7 @@ function drawReport(results) { return `\n${result.filePath}\n\n${drawTable(result.messages)}`; }); - files = files.filter(function(content) { - return content.trim(); - }); + files = files.filter(content => content.trim()); return files.join(""); } @@ -120,7 +118,7 @@ module.exports = function(report) { errorCount = 0; warningCount = 0; - report.forEach(function(fileReport) { + report.forEach(fileReport => { errorCount += fileReport.errorCount; warningCount += fileReport.warningCount; }); diff --git a/tools/eslint/lib/formatters/tap.js b/tools/eslint/lib/formatters/tap.js index 568ac1e8b64548..27825d0ba996e7 100644 --- a/tools/eslint/lib/formatters/tap.js +++ b/tools/eslint/lib/formatters/tap.js @@ -44,7 +44,7 @@ function outputDiagnostics(diagnostic) { module.exports = function(results) { let output = `TAP version 13\n1..${results.length}\n`; - results.forEach(function(result, id) { + results.forEach((result, id) => { const messages = result.messages; let testResult = "ok"; let diagnostics = {}; @@ -52,7 +52,7 @@ module.exports = function(results) { if (messages.length > 0) { testResult = "not ok"; - messages.forEach(function(message) { + messages.forEach(message => { const diagnostic = { message: message.message, severity: getMessageType(message), diff --git a/tools/eslint/lib/formatters/unix.js b/tools/eslint/lib/formatters/unix.js index 867bbd5b49fcd3..a5635278bc3fa9 100644 --- a/tools/eslint/lib/formatters/unix.js +++ b/tools/eslint/lib/formatters/unix.js @@ -31,13 +31,13 @@ module.exports = function(results) { let output = "", total = 0; - results.forEach(function(result) { + results.forEach(result => { const messages = result.messages; total += messages.length; - messages.forEach(function(message) { + messages.forEach(message => { output += `${result.filePath}:`; output += `${message.line || 0}:`; diff --git a/tools/eslint/lib/formatters/visualstudio.js b/tools/eslint/lib/formatters/visualstudio.js index 134a04a5134ca0..feb7fb4bef382b 100644 --- a/tools/eslint/lib/formatters/visualstudio.js +++ b/tools/eslint/lib/formatters/visualstudio.js @@ -33,13 +33,13 @@ module.exports = function(results) { let output = "", total = 0; - results.forEach(function(result) { + results.forEach(result => { const messages = result.messages; total += messages.length; - messages.forEach(function(message) { + messages.forEach(message => { output += result.filePath; output += `(${message.line || 0}`; diff --git a/tools/eslint/lib/ignored-paths.js b/tools/eslint/lib/ignored-paths.js index bc2db8aaac8dc0..bace73db6a394b 100644 --- a/tools/eslint/lib/ignored-paths.js +++ b/tools/eslint/lib/ignored-paths.js @@ -72,160 +72,161 @@ function mergeDefaultOptions(options) { //------------------------------------------------------------------------------ /** - * IgnoredPaths - * @constructor - * @class IgnoredPaths - * @param {Object} options object containing 'ignore', 'ignorePath' and 'patterns' properties + * IgnoredPaths class */ -function IgnoredPaths(options) { - - options = mergeDefaultOptions(options); - - /** - * add pattern to node-ignore instance - * @param {Object} ig, instance of node-ignore - * @param {string} pattern, pattern do add to ig - * @returns {array} raw ignore rules - */ - function addPattern(ig, pattern) { - return ig.addPattern(pattern); - } +class IgnoredPaths { /** - * add ignore file to node-ignore instance - * @param {Object} ig, instance of node-ignore - * @param {string} filepath, file to add to ig - * @returns {array} raw ignore rules + * @param {Object} options object containing 'ignore', 'ignorePath' and 'patterns' properties */ - function addIgnoreFile(ig, filepath) { - ig.ignoreFiles.push(filepath); - return ig.add(fs.readFileSync(filepath, "utf8")); - } - - this.defaultPatterns = [].concat(DEFAULT_IGNORE_DIRS, options.patterns || []); - this.baseDir = options.cwd; - - this.ig = { - custom: ignore(), - default: ignore() - }; + constructor(options) { + options = mergeDefaultOptions(options); + + /** + * add pattern to node-ignore instance + * @param {Object} ig, instance of node-ignore + * @param {string} pattern, pattern do add to ig + * @returns {array} raw ignore rules + */ + function addPattern(ig, pattern) { + return ig.addPattern(pattern); + } - // Add a way to keep track of ignored files. This was present in node-ignore - // 2.x, but dropped for now as of 3.0.10. - this.ig.custom.ignoreFiles = []; - this.ig.default.ignoreFiles = []; + /** + * add ignore file to node-ignore instance + * @param {Object} ig, instance of node-ignore + * @param {string} filepath, file to add to ig + * @returns {array} raw ignore rules + */ + function addIgnoreFile(ig, filepath) { + ig.ignoreFiles.push(filepath); + return ig.add(fs.readFileSync(filepath, "utf8")); + } - if (options.dotfiles !== true) { + this.defaultPatterns = [].concat(DEFAULT_IGNORE_DIRS, options.patterns || []); + this.baseDir = options.cwd; - /* - * ignore files beginning with a dot, but not files in a parent or - * ancestor directory (which in relative format will begin with `../`). - */ - addPattern(this.ig.default, [".*", "!../"]); - } + this.ig = { + custom: ignore(), + default: ignore() + }; - addPattern(this.ig.default, this.defaultPatterns); + // Add a way to keep track of ignored files. This was present in node-ignore + // 2.x, but dropped for now as of 3.0.10. + this.ig.custom.ignoreFiles = []; + this.ig.default.ignoreFiles = []; - if (options.ignore !== false) { - let ignorePath; + if (options.dotfiles !== true) { - if (options.ignorePath) { - debug("Using specific ignore file"); + /* + * ignore files beginning with a dot, but not files in a parent or + * ancestor directory (which in relative format will begin with `../`). + */ + addPattern(this.ig.default, [".*", "!../"]); + } - try { - fs.statSync(options.ignorePath); - ignorePath = options.ignorePath; - } catch (e) { - e.message = `Cannot read ignore file: ${options.ignorePath}\nError: ${e.message}`; - throw e; + addPattern(this.ig.default, this.defaultPatterns); + + if (options.ignore !== false) { + let ignorePath; + + if (options.ignorePath) { + debug("Using specific ignore file"); + + try { + fs.statSync(options.ignorePath); + ignorePath = options.ignorePath; + } catch (e) { + e.message = `Cannot read ignore file: ${options.ignorePath}\nError: ${e.message}`; + throw e; + } + } else { + debug(`Looking for ignore file in ${options.cwd}`); + ignorePath = findIgnoreFile(options.cwd); + + try { + fs.statSync(ignorePath); + debug(`Loaded ignore file ${ignorePath}`); + } catch (e) { + debug("Could not find ignore file in cwd"); + this.options = options; + } } - } else { - debug(`Looking for ignore file in ${options.cwd}`); - ignorePath = findIgnoreFile(options.cwd); - - try { - fs.statSync(ignorePath); - debug(`Loaded ignore file ${ignorePath}`); - } catch (e) { - debug("Could not find ignore file in cwd"); - this.options = options; + + if (ignorePath) { + debug(`Adding ${ignorePath}`); + this.baseDir = path.dirname(path.resolve(options.cwd, ignorePath)); + addIgnoreFile(this.ig.custom, ignorePath); + addIgnoreFile(this.ig.default, ignorePath); } - } - if (ignorePath) { - debug(`Adding ${ignorePath}`); - this.baseDir = path.dirname(path.resolve(options.cwd, ignorePath)); - addIgnoreFile(this.ig.custom, ignorePath); - addIgnoreFile(this.ig.default, ignorePath); + if (options.ignorePattern) { + addPattern(this.ig.custom, options.ignorePattern); + addPattern(this.ig.default, options.ignorePattern); + } } - if (options.ignorePattern) { - addPattern(this.ig.custom, options.ignorePattern); - addPattern(this.ig.default, options.ignorePattern); - } + this.options = options; } - this.options = options; + /** + * Determine whether a file path is included in the default or custom ignore patterns + * @param {string} filepath Path to check + * @param {string} [category=null] check 'default', 'custom' or both (null) + * @returns {boolean} true if the file path matches one or more patterns, false otherwise + */ + contains(filepath, category) { -} + let result = false; + const absolutePath = path.resolve(this.options.cwd, filepath); + const relativePath = pathUtil.getRelativePath(absolutePath, this.options.cwd); -/** - * Determine whether a file path is included in the default or custom ignore patterns - * @param {string} filepath Path to check - * @param {string} [category=null] check 'default', 'custom' or both (null) - * @returns {boolean} true if the file path matches one or more patterns, false otherwise - */ -IgnoredPaths.prototype.contains = function(filepath, category) { + if ((typeof category === "undefined") || (category === "default")) { + result = result || (this.ig.default.filter([relativePath]).length === 0); + } - let result = false; - const absolutePath = path.resolve(this.options.cwd, filepath); - const relativePath = pathUtil.getRelativePath(absolutePath, this.options.cwd); + if ((typeof category === "undefined") || (category === "custom")) { + result = result || (this.ig.custom.filter([relativePath]).length === 0); + } - if ((typeof category === "undefined") || (category === "default")) { - result = result || (this.ig.default.filter([relativePath]).length === 0); - } + return result; - if ((typeof category === "undefined") || (category === "custom")) { - result = result || (this.ig.custom.filter([relativePath]).length === 0); } - return result; - -}; - -/** - * Returns a list of dir patterns for glob to ignore - * @returns {function()} method to check whether a folder should be ignored by glob. - */ -IgnoredPaths.prototype.getIgnoredFoldersGlobChecker = function() { + /** + * Returns a list of dir patterns for glob to ignore + * @returns {function()} method to check whether a folder should be ignored by glob. + */ + getIgnoredFoldersGlobChecker() { - const ig = ignore().add(DEFAULT_IGNORE_DIRS); + const ig = ignore().add(DEFAULT_IGNORE_DIRS); - if (this.options.ignore) { - ig.add(this.ig.custom); - } + if (this.options.ignore) { + ig.add(this.ig.custom); + } - const filter = ig.createFilter(); + const filter = ig.createFilter(); - /** - * TODO - * 1. - * Actually, it should be `this.options.baseDir`, which is the base dir of `ignore-path`, - * as well as Line 177. - * But doing this leads to a breaking change and fails tests. - * Related to #6759 - */ - const base = this.options.cwd; + /** + * TODO + * 1. + * Actually, it should be `this.options.baseDir`, which is the base dir of `ignore-path`, + * as well as Line 177. + * But doing this leads to a breaking change and fails tests. + * Related to #6759 + */ + const base = this.options.cwd; - return function(absolutePath) { - const relative = pathUtil.getRelativePath(absolutePath, base); + return function(absolutePath) { + const relative = pathUtil.getRelativePath(absolutePath, base); - if (!relative) { - return false; - } + if (!relative) { + return false; + } - return !filter(relative); - }; -}; + return !filter(relative); + }; + } +} module.exports = IgnoredPaths; diff --git a/tools/eslint/lib/internal-rules/internal-consistent-docs-description.js b/tools/eslint/lib/internal-rules/internal-consistent-docs-description.js index 3e4671aa7b151d..a4a5dca03fbbf2 100644 --- a/tools/eslint/lib/internal-rules/internal-consistent-docs-description.js +++ b/tools/eslint/lib/internal-rules/internal-consistent-docs-description.js @@ -95,7 +95,6 @@ function checkMetaDocsDescription(context, exportsNode) { firstWord } }); - return; } } diff --git a/tools/eslint/lib/internal-rules/internal-no-invalid-meta.js b/tools/eslint/lib/internal-rules/internal-no-invalid-meta.js index 783a1109e76571..d1c78efa61e557 100644 --- a/tools/eslint/lib/internal-rules/internal-no-invalid-meta.js +++ b/tools/eslint/lib/internal-rules/internal-no-invalid-meta.js @@ -147,7 +147,6 @@ function checkMetaValidity(context, exportsNode, ruleIsFixable) { if (ruleIsFixable && !hasMetaFixable(metaProperty)) { context.report(metaProperty, "Rule is fixable, but is missing a meta.fixable property."); - return; } } @@ -216,7 +215,7 @@ module.exports = { "Program:exit"() { if (!isCorrectExportsFormat(exportsNode)) { - context.report(exportsNode, "Rule does not export an Object. Make sure the rule follows the new rule format."); + context.report({ node: exportsNode, message: "Rule does not export an Object. Make sure the rule follows the new rule format." }); return; } diff --git a/tools/eslint/lib/load-rules.js b/tools/eslint/lib/load-rules.js index c698faa5e132d0..92fb7bf20ada0c 100644 --- a/tools/eslint/lib/load-rules.js +++ b/tools/eslint/lib/load-rules.js @@ -31,7 +31,7 @@ module.exports = function(rulesDir, cwd) { const rules = Object.create(null); - fs.readdirSync(rulesDir).forEach(function(file) { + fs.readdirSync(rulesDir).forEach(file => { if (path.extname(file) !== ".js") { return; } diff --git a/tools/eslint/lib/rule-context.js b/tools/eslint/lib/rule-context.js index ded5dab962d70c..9c80d2e1a31cc6 100644 --- a/tools/eslint/lib/rule-context.js +++ b/tools/eslint/lib/rule-context.js @@ -61,36 +61,41 @@ const PASSTHROUGHS = [ //------------------------------------------------------------------------------ /** + * Rule context class * Acts as an abstraction layer between rules and the main eslint object. - * @constructor - * @param {string} ruleId The ID of the rule using this object. - * @param {eslint} eslint The eslint object. - * @param {number} severity The configured severity level of the rule. - * @param {Array} options The configuration information to be added to the rule. - * @param {Object} settings The configuration settings passed from the config file. - * @param {Object} parserOptions The parserOptions settings passed from the config file. - * @param {Object} parserPath The parser setting passed from the config file. - * @param {Object} meta The metadata of the rule */ -function RuleContext(ruleId, eslint, severity, options, settings, parserOptions, parserPath, meta) { +class RuleContext { - // public. - this.id = ruleId; - this.options = options; - this.settings = settings; - this.parserOptions = parserOptions; - this.parserPath = parserPath; - this.meta = meta; + /** + * @param {string} ruleId The ID of the rule using this object. + * @param {eslint} eslint The eslint object. + * @param {number} severity The configured severity level of the rule. + * @param {Array} options The configuration information to be added to the rule. + * @param {Object} settings The configuration settings passed from the config file. + * @param {Object} parserOptions The parserOptions settings passed from the config file. + * @param {Object} parserPath The parser setting passed from the config file. + * @param {Object} meta The metadata of the rule + * @param {Object} parserServices The parser services for the rule. + */ + constructor(ruleId, eslint, severity, options, settings, parserOptions, parserPath, meta, parserServices) { - // private. - this.eslint = eslint; - this.severity = severity; + // public. + this.id = ruleId; + this.options = options; + this.settings = settings; + this.parserOptions = parserOptions; + this.parserPath = parserPath; + this.meta = meta; - Object.freeze(this); -} + // create a separate copy and freeze it (it's not nice to freeze other people's objects) + this.parserServices = Object.freeze(Object.assign({}, parserServices)); -RuleContext.prototype = { - constructor: RuleContext, + // private. + this.eslint = eslint; + this.severity = severity; + + Object.freeze(this); + } /** * Passthrough to eslint.getSourceCode(). @@ -98,7 +103,7 @@ RuleContext.prototype = { */ getSourceCode() { return this.eslint.getSourceCode(); - }, + } /** * Passthrough to eslint.report() that automatically assigns the rule ID and severity. @@ -147,7 +152,7 @@ RuleContext.prototype = { this.meta ); } -}; +} // Copy over passthrough methods. All functions will have 5 or fewer parameters. PASSTHROUGHS.forEach(function(name) { diff --git a/tools/eslint/lib/rules.js b/tools/eslint/lib/rules.js index 128a6bcd15b652..80f83882d331cb 100644 --- a/tools/eslint/lib/rules.js +++ b/tools/eslint/lib/rules.js @@ -40,7 +40,7 @@ function define(ruleId, ruleModule) { function load(rulesDir, cwd) { const newRules = loadRules(rulesDir, cwd); - Object.keys(newRules).forEach(function(ruleId) { + Object.keys(newRules).forEach(ruleId => { define(ruleId, newRules[ruleId]); }); } @@ -53,7 +53,7 @@ function load(rulesDir, cwd) { */ function importPlugin(plugin, pluginName) { if (plugin.rules) { - Object.keys(plugin.rules).forEach(function(ruleId) { + Object.keys(plugin.rules).forEach(ruleId => { const qualifiedRuleId = `${pluginName}/${ruleId}`, rule = plugin.rules[ruleId]; @@ -75,6 +75,21 @@ function getHandler(ruleId) { } } +/** + * Get an object with all currently loaded rules + * @returns {Map} All loaded rules + */ +function getAllLoadedRules() { + const allRules = new Map(); + + Object.keys(rules).forEach(name => { + const rule = getHandler(name); + + allRules.set(name, rule); + }); + return allRules; +} + /** * Reset rules storage. * Should be used only in tests. @@ -89,6 +104,7 @@ module.exports = { load, importPlugin, get: getHandler, + getAllLoadedRules, testClear, /** diff --git a/tools/eslint/lib/rules/accessor-pairs.js b/tools/eslint/lib/rules/accessor-pairs.js index 7e8870edc8c8e1..4afdc7136ca2a6 100644 --- a/tools/eslint/lib/rules/accessor-pairs.js +++ b/tools/eslint/lib/rules/accessor-pairs.js @@ -139,9 +139,9 @@ module.exports = { } if (checkSetWithoutGet && isSetPresent && !isGetPresent) { - context.report(node, "Getter is not present."); + context.report({ node, message: "Getter is not present." }); } else if (checkGetWithoutSet && isGetPresent && !isSetPresent) { - context.report(node, "Setter is not present."); + context.report({ node, message: "Setter is not present." }); } } diff --git a/tools/eslint/lib/rules/array-bracket-spacing.js b/tools/eslint/lib/rules/array-bracket-spacing.js index 9bd7e944951a77..73cfbdc3c1fa8e 100644 --- a/tools/eslint/lib/rules/array-bracket-spacing.js +++ b/tools/eslint/lib/rules/array-bracket-spacing.js @@ -179,8 +179,10 @@ module.exports = { const first = sourceCode.getFirstToken(node), second = sourceCode.getFirstToken(node, 1), - penultimate = sourceCode.getLastToken(node, 1), - last = sourceCode.getLastToken(node), + last = node.typeAnnotation + ? sourceCode.getTokenBefore(node.typeAnnotation) + : sourceCode.getLastToken(node), + penultimate = sourceCode.getTokenBefore(last), firstElement = node.elements[0], lastElement = node.elements[node.elements.length - 1]; diff --git a/tools/eslint/lib/rules/arrow-body-style.js b/tools/eslint/lib/rules/arrow-body-style.js index 038aeeb5af2550..9778a6776f5e1f 100644 --- a/tools/eslint/lib/rules/arrow-body-style.js +++ b/tools/eslint/lib/rules/arrow-body-style.js @@ -37,7 +37,7 @@ module.exports = { { type: "object", properties: { - requireReturnForObjectLiteral: {type: "boolean"} + requireReturnForObjectLiteral: { type: "boolean" } }, additionalProperties: false } @@ -46,7 +46,9 @@ module.exports = { maxItems: 2 } ] - } + }, + + fixable: "code" }, create(context) { @@ -55,6 +57,7 @@ module.exports = { const asNeeded = !options[0] || options[0] === "as-needed"; const never = options[0] === "never"; const requireReturnForObjectLiteral = options[1] && options[1].requireReturnForObjectLiteral; + const sourceCode = context.getSourceCode(); /** * Determines whether a arrow function body needs braces @@ -65,38 +68,85 @@ module.exports = { const arrowBody = node.body; if (arrowBody.type === "BlockStatement") { - if (never) { + const blockBody = arrowBody.body; + + if (blockBody.length !== 1 && !never) { + return; + } + + if (asNeeded && requireReturnForObjectLiteral && blockBody[0].type === "ReturnStatement" && + blockBody[0].argument && blockBody[0].argument.type === "ObjectExpression") { + return; + } + + if (never || asNeeded && blockBody[0].type === "ReturnStatement") { context.report({ node, loc: arrowBody.loc.start, - message: "Unexpected block statement surrounding arrow body." + message: "Unexpected block statement surrounding arrow body.", + fix(fixer) { + if (blockBody.length !== 1 || blockBody[0].type !== "ReturnStatement" || !blockBody[0].argument) { + return null; + } + + const sourceText = sourceCode.getText(); + const returnKeyword = sourceCode.getFirstToken(blockBody[0]); + const firstValueToken = sourceCode.getTokenAfter(returnKeyword); + let lastValueToken = sourceCode.getLastToken(blockBody[0]); + + if (lastValueToken.type === "Punctuator" && lastValueToken.value === ";") { + + /* The last token of the returned value is the last token of the ReturnExpression (if + * the ReturnExpression has no semicolon), or the second-to-last token (if the ReturnExpression + * has a semicolon). + */ + lastValueToken = sourceCode.getTokenBefore(lastValueToken); + } + + const tokenAfterArrowBody = sourceCode.getTokenAfter(arrowBody); + + if (tokenAfterArrowBody && tokenAfterArrowBody.type === "Punctuator" && /^[([/`+-]/.test(tokenAfterArrowBody.value)) { + + // Don't do a fix if the next token would cause ASI issues when preceded by the returned value. + return null; + } + + const textBeforeReturn = sourceText.slice(arrowBody.range[0] + 1, returnKeyword.range[0]); + const textBetweenReturnAndValue = sourceText.slice(returnKeyword.range[1], firstValueToken.range[0]); + const rawReturnValueText = sourceText.slice(firstValueToken.range[0], lastValueToken.range[1]); + const returnValueText = firstValueToken.value === "{" ? `(${rawReturnValueText})` : rawReturnValueText; + const textAfterValue = sourceText.slice(lastValueToken.range[1], blockBody[0].range[1] - 1); + const textAfterReturnStatement = sourceText.slice(blockBody[0].range[1], arrowBody.range[1] - 1); + + /* + * For fixes that only contain spaces around the return value, remove the extra spaces. + * This avoids ugly fixes that end up with extra spaces after the arrow, e.g. `() => 0 ;` + */ + return fixer.replaceText( + arrowBody, + (textBeforeReturn + textBetweenReturnAndValue).replace(/^\s*$/, "") + returnValueText + (textAfterValue + textAfterReturnStatement).replace(/^\s*$/, "") + ); + } }); - } else { - const blockBody = arrowBody.body; - - if (blockBody.length !== 1) { - return; - } - - if (asNeeded && requireReturnForObjectLiteral && blockBody[0].type === "ReturnStatement" && - blockBody[0].argument.type === "ObjectExpression") { - return; - } - - if (asNeeded && blockBody[0].type === "ReturnStatement") { - context.report({ - node, - loc: arrowBody.loc.start, - message: "Unexpected block statement surrounding arrow body." - }); - } } } else { if (always || (asNeeded && requireReturnForObjectLiteral && arrowBody.type === "ObjectExpression")) { context.report({ node, loc: arrowBody.loc.start, - message: "Expected block statement surrounding arrow body." + message: "Expected block statement surrounding arrow body.", + fix(fixer) { + const lastTokenBeforeBody = sourceCode.getTokensBetween(sourceCode.getFirstToken(node), arrowBody) + .reverse() + .find(token => token.value !== "("); + + const firstBodyToken = sourceCode.getTokenAfter(lastTokenBeforeBody); + + return fixer.replaceTextRange( + [firstBodyToken.range[0], node.range[1]], + `{return ${sourceCode.getText().slice(firstBodyToken.range[0], node.range[1])}}` + ); + } }); } } diff --git a/tools/eslint/lib/rules/arrow-parens.js b/tools/eslint/lib/rules/arrow-parens.js index 67bfdf541c2955..e069e307eb2040 100644 --- a/tools/eslint/lib/rules/arrow-parens.js +++ b/tools/eslint/lib/rules/arrow-parens.js @@ -58,7 +58,9 @@ module.exports = { requireForBlockBody && node.params.length === 1 && node.params[0].type === "Identifier" && - node.body.type !== "BlockStatement" + !node.params[0].typeAnnotation && + node.body.type !== "BlockStatement" && + !node.returnType ) { if (token.type === "Punctuator" && token.value === "(") { context.report({ @@ -95,7 +97,12 @@ module.exports = { } // "as-needed": x => x - if (asNeeded && node.params.length === 1 && node.params[0].type === "Identifier") { + if (asNeeded && + node.params.length === 1 && + node.params[0].type === "Identifier" && + !node.params[0].typeAnnotation && + !node.returnType + ) { if (token.type === "Punctuator" && token.value === "(") { context.report({ node, diff --git a/tools/eslint/lib/rules/block-scoped-var.js b/tools/eslint/lib/rules/block-scoped-var.js index 0f4705a1f140d9..bb0931a3ceb63f 100644 --- a/tools/eslint/lib/rules/block-scoped-var.js +++ b/tools/eslint/lib/rules/block-scoped-var.js @@ -47,10 +47,7 @@ module.exports = { function report(reference) { const identifier = reference.identifier; - context.report( - identifier, - "'{{name}}' used outside of binding context.", - {name: identifier.name}); + context.report({ node: identifier, message: "'{{name}}' used outside of binding context.", data: { name: identifier.name } }); } /** diff --git a/tools/eslint/lib/rules/block-spacing.js b/tools/eslint/lib/rules/block-spacing.js index f18b3cceba3132..9c0a7f388ba3bb 100644 --- a/tools/eslint/lib/rules/block-spacing.js +++ b/tools/eslint/lib/rules/block-spacing.js @@ -22,7 +22,7 @@ module.exports = { fixable: "whitespace", schema: [ - {enum: ["always", "never"]} + { enum: ["always", "never"] } ] }, diff --git a/tools/eslint/lib/rules/brace-style.js b/tools/eslint/lib/rules/brace-style.js index 6bd8a8f4c87edb..197767b07c19a5 100644 --- a/tools/eslint/lib/rules/brace-style.js +++ b/tools/eslint/lib/rules/brace-style.js @@ -30,7 +30,9 @@ module.exports = { }, additionalProperties: false } - ] + ], + + fixable: "whitespace" }, create(context) { @@ -69,6 +71,28 @@ module.exports = { return token.value === "{" || token.value === "}"; } + /** + * Reports a place where a newline unexpectedly appears + * @param {ASTNode} node The node to report + * @param {string} message The message to report + * @param {Token} firstToken The token before the unexpected newline + * @returns {void} + */ + function reportExtraNewline(node, message, firstToken) { + context.report({ + node, + message, + fix(fixer) { + const secondToken = sourceCode.getTokenAfter(firstToken); + const textBetween = sourceCode.getText().slice(firstToken.range[1], secondToken.range[0]); + const NEWLINE_REGEX = /\r\n|\r|\n|\u2028|\u2029/g; + + // Don't do a fix if there is a comment between the tokens. + return textBetween.trim() ? null : fixer.replaceTextRange([firstToken.range[1], secondToken.range[0]], textBetween.replace(NEWLINE_REGEX, "")); + } + }); + } + /** * Binds a list of properties to a function that verifies that the opening * curly brace is on the same line as its controlling statement of a given @@ -81,7 +105,7 @@ module.exports = { const blockProperties = arguments; return function(node) { - Array.prototype.forEach.call(blockProperties, function(blockProp) { + Array.prototype.forEach.call(blockProperties, blockProp => { const block = node[blockProp]; if (!isBlock(block)) { @@ -98,9 +122,13 @@ module.exports = { } if (style !== "allman" && previousToken.loc.start.line !== curlyToken.loc.start.line) { - context.report(node, OPEN_MESSAGE); + reportExtraNewline(node, OPEN_MESSAGE, previousToken); } else if (style === "allman" && previousToken.loc.start.line === curlyToken.loc.start.line) { - context.report(node, OPEN_MESSAGE_ALLMAN); + context.report({ + node, + message: OPEN_MESSAGE_ALLMAN, + fix: fixer => fixer.insertTextBefore(curlyToken, "\n") + }); } if (!block.body.length) { @@ -108,11 +136,19 @@ module.exports = { } if (curlyToken.loc.start.line === block.body[0].loc.start.line) { - context.report(block.body[0], BODY_MESSAGE); + context.report({ + node: block.body[0], + message: BODY_MESSAGE, + fix: fixer => fixer.insertTextAfter(curlyToken, "\n") + }); } - if (curlyTokenEnd.loc.start.line === block.body[block.body.length - 1].loc.start.line) { - context.report(block.body[block.body.length - 1], CLOSE_MESSAGE_SINGLE); + if (curlyTokenEnd.loc.start.line === block.body[block.body.length - 1].loc.end.line) { + context.report({ + node: block.body[block.body.length - 1], + message: CLOSE_MESSAGE_SINGLE, + fix: fixer => fixer.insertTextBefore(curlyTokenEnd, "\n") + }); } }); }; @@ -135,10 +171,14 @@ module.exports = { if (tokens[0].loc.start.line !== tokens[1].loc.start.line && node.consequent.type === "BlockStatement" && isCurlyPunctuator(tokens[0])) { - context.report(node.alternate, CLOSE_MESSAGE); + reportExtraNewline(node.alternate, CLOSE_MESSAGE, tokens[0]); } } else if (tokens[0].loc.start.line === tokens[1].loc.start.line) { - context.report(node.alternate, CLOSE_MESSAGE_STROUSTRUP_ALLMAN); + context.report({ + node: node.alternate, + message: CLOSE_MESSAGE_STROUSTRUP_ALLMAN, + fix: fixer => fixer.insertTextAfter(tokens[0], "\n") + }); } } @@ -158,10 +198,14 @@ module.exports = { if (style === "1tbs") { if (tokens[0].loc.start.line !== tokens[1].loc.start.line) { - context.report(node.finalizer, CLOSE_MESSAGE); + reportExtraNewline(node.finalizer, CLOSE_MESSAGE, tokens[0]); } } else if (tokens[0].loc.start.line === tokens[1].loc.start.line) { - context.report(node.finalizer, CLOSE_MESSAGE_STROUSTRUP_ALLMAN); + context.report({ + node: node.finalizer, + message: CLOSE_MESSAGE_STROUSTRUP_ALLMAN, + fix: fixer => fixer.insertTextAfter(tokens[0], "\n") + }); } } } @@ -181,11 +225,15 @@ module.exports = { if (isBlock(node.body)) { if (style === "1tbs") { if (previousToken.loc.start.line !== firstToken.loc.start.line) { - context.report(node, CLOSE_MESSAGE); + reportExtraNewline(node, CLOSE_MESSAGE, previousToken); } } else { if (previousToken.loc.start.line === firstToken.loc.start.line) { - context.report(node, CLOSE_MESSAGE_STROUSTRUP_ALLMAN); + context.report({ + node, + message: CLOSE_MESSAGE_STROUSTRUP_ALLMAN, + fix: fixer => fixer.insertTextAfter(previousToken, "\n") + }); } } } @@ -207,9 +255,13 @@ module.exports = { } if (style !== "allman" && tokens[0].loc.start.line !== tokens[1].loc.start.line) { - context.report(node, OPEN_MESSAGE); + reportExtraNewline(node, OPEN_MESSAGE, tokens[0]); } else if (style === "allman" && tokens[0].loc.start.line === tokens[1].loc.start.line) { - context.report(node, OPEN_MESSAGE_ALLMAN); + context.report({ + node, + message: OPEN_MESSAGE_ALLMAN, + fix: fixer => fixer.insertTextBefore(tokens[1], "\n") + }); } } diff --git a/tools/eslint/lib/rules/callback-return.js b/tools/eslint/lib/rules/callback-return.js index 242ef666d2ac6e..08600c01e58cd1 100644 --- a/tools/eslint/lib/rules/callback-return.js +++ b/tools/eslint/lib/rules/callback-return.js @@ -164,7 +164,7 @@ module.exports = { // as long as you're the child of a function at this point you should be asked to return if (findClosestParentOfType(node, ["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression"])) { - context.report(node, "Expected return with your callback function."); + context.report({ node, message: "Expected return with your callback function." }); } } diff --git a/tools/eslint/lib/rules/camelcase.js b/tools/eslint/lib/rules/camelcase.js index 1b22c25e675ca3..6fb1475b21dbcd 100644 --- a/tools/eslint/lib/rules/camelcase.js +++ b/tools/eslint/lib/rules/camelcase.js @@ -38,6 +38,7 @@ module.exports = { // contains reported nodes to avoid reporting twice on destructuring with shorthand notation const reported = []; + const ALLOWED_PARENT_TYPES = new Set(["CallExpression", "NewExpression"]); /** * Checks if a string contains an underscore and isn't all upper-case @@ -60,7 +61,7 @@ module.exports = { function report(node) { if (reported.indexOf(node) < 0) { reported.push(node); - context.report(node, "Identifier '{{name}}' is not in camel case.", { name: node.name }); + context.report({ node, message: "Identifier '{{name}}' is not in camel case.", data: { name: node.name } }); } } @@ -118,7 +119,7 @@ module.exports = { return; } - if (isUnderscored(name) && effectiveParent.type !== "CallExpression") { + if (isUnderscored(name) && !ALLOWED_PARENT_TYPES.has(effectiveParent.type)) { report(node); } @@ -131,7 +132,7 @@ module.exports = { } // Report anything that is underscored that isn't a CallExpression - } else if (isUnderscored(name) && effectiveParent.type !== "CallExpression") { + } else if (isUnderscored(name) && !ALLOWED_PARENT_TYPES.has(effectiveParent.type)) { report(node); } } diff --git a/tools/eslint/lib/rules/capitalized-comments.js b/tools/eslint/lib/rules/capitalized-comments.js new file mode 100644 index 00000000000000..29cff4450b535a --- /dev/null +++ b/tools/eslint/lib/rules/capitalized-comments.js @@ -0,0 +1,301 @@ +/** + * @fileoverview enforce or disallow capitalization of the first letter of a comment + * @author Kevin Partington + */ +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const LETTER_PATTERN = require("../util/patterns/letters"); + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +const ALWAYS_MESSAGE = "Comments should not begin with a lowercase character", + NEVER_MESSAGE = "Comments should not begin with an uppercase character", + DEFAULT_IGNORE_PATTERN = /^\s*(?:eslint|istanbul|jscs|jshint|globals?|exported)\b/, + WHITESPACE = /\s/g, + MAYBE_URL = /^\s*[^:/?#\s]+:\/\/[^?#]/, // TODO: Combine w/ max-len pattern? + DEFAULTS = { + ignorePattern: null, + ignoreInlineComments: false, + ignoreConsecutiveComments: false + }; + +/* + * Base schema body for defining the basic capitalization rule, ignorePattern, + * and ignoreInlineComments values. + * This can be used in a few different ways in the actual schema. + */ +const SCHEMA_BODY = { + type: "object", + properties: { + ignorePattern: { + type: "string" + }, + ignoreInlineComments: { + type: "boolean" + }, + ignoreConsecutiveComments: { + type: "boolean" + } + }, + additionalProperties: false +}; + +/** + * Get normalized options for either block or line comments from the given + * user-provided options. + * - If the user-provided options is just a string, returns a normalized + * set of options using default values for all other options. + * - If the user-provided options is an object, then a normalized option + * set is returned. Options specified in overrides will take priority + * over options specified in the main options object, which will in + * turn take priority over the rule's defaults. + * + * @param {Object|string} rawOptions The user-provided options. + * @param {string} which Either "line" or "block". + * @returns {Object} The normalized options. + */ +function getNormalizedOptions(rawOptions, which) { + if (!rawOptions) { + return Object.assign({}, DEFAULTS); + } + + return Object.assign({}, DEFAULTS, rawOptions[which] || rawOptions); +} + +/** + * Get normalized options for block and line comments. + * + * @param {Object|string} rawOptions The user-provided options. + * @returns {Object} An object with "Line" and "Block" keys and corresponding + * normalized options objects. + */ +function getAllNormalizedOptions(rawOptions) { + return { + Line: getNormalizedOptions(rawOptions, "line"), + Block: getNormalizedOptions(rawOptions, "block") + }; +} + +/** + * Creates a regular expression for each ignorePattern defined in the rule + * options. + * + * This is done in order to avoid invoking the RegExp constructor repeatedly. + * + * @param {Object} normalizedOptions The normalized rule options. + * @returns {void} + */ +function createRegExpForIgnorePatterns(normalizedOptions) { + Object.keys(normalizedOptions).forEach(key => { + const ignorePatternStr = normalizedOptions[key].ignorePattern; + + if (ignorePatternStr) { + const regExp = RegExp(`^\\s*(?:${ignorePatternStr})`); + + normalizedOptions[key].ignorePatternRegExp = regExp; + } + }); +} + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + docs: { + description: "enforce or disallow capitalization of the first letter of a comment", + category: "Stylistic Issues", + recommended: false + }, + fixable: "code", + schema: [ + { enum: ["always", "never"] }, + { + oneOf: [ + SCHEMA_BODY, + { + type: "object", + properties: { + line: SCHEMA_BODY, + block: SCHEMA_BODY + }, + additionalProperties: false + } + ] + } + ] + }, + + create(context) { + + const capitalize = context.options[0] || "always", + normalizedOptions = getAllNormalizedOptions(context.options[1]), + sourceCode = context.getSourceCode(); + + createRegExpForIgnorePatterns(normalizedOptions); + + //---------------------------------------------------------------------- + // Helpers + //---------------------------------------------------------------------- + + /** + * Checks whether a comment is an inline comment. + * + * For the purpose of this rule, a comment is inline if: + * 1. The comment is preceded by a token on the same line; and + * 2. The command is followed by a token on the same line. + * + * Note that the comment itself need not be single-line! + * + * Also, it follows from this definition that only block comments can + * be considered as possibly inline. This is because line comments + * would consume any following tokens on the same line as the comment. + * + * @param {ASTNode} comment The comment node to check. + * @returns {boolean} True if the comment is an inline comment, false + * otherwise. + */ + function isInlineComment(comment) { + const previousToken = sourceCode.getTokenOrCommentBefore(comment), + nextToken = sourceCode.getTokenOrCommentAfter(comment); + + return Boolean( + previousToken && + nextToken && + comment.loc.start.line === previousToken.loc.end.line && + comment.loc.end.line === nextToken.loc.start.line + ); + } + + /** + * Determine if a comment follows another comment. + * + * @param {ASTNode} comment The comment to check. + * @returns {boolean} True if the comment follows a valid comment. + */ + function isConsecutiveComment(comment) { + const previousTokenOrComment = sourceCode.getTokenOrCommentBefore(comment); + + return Boolean( + previousTokenOrComment && + ["Block", "Line"].indexOf(previousTokenOrComment.type) !== -1 + ); + } + + /** + * Check a comment to determine if it is valid for this rule. + * + * @param {ASTNode} comment The comment node to process. + * @param {Object} options The options for checking this comment. + * @returns {boolean} True if the comment is valid, false otherwise. + */ + function isCommentValid(comment, options) { + + // 1. Check for default ignore pattern. + if (DEFAULT_IGNORE_PATTERN.test(comment.value)) { + return true; + } + + // 2. Check for custom ignore pattern. + const commentWithoutAsterisks = comment.value + .replace(/\*/g, ""); + + if (options.ignorePatternRegExp && options.ignorePatternRegExp.test(commentWithoutAsterisks)) { + return true; + } + + // 3. Check for inline comments. + if (options.ignoreInlineComments && isInlineComment(comment)) { + return true; + } + + // 4. Is this a consecutive comment (and are we tolerating those)? + if (options.ignoreConsecutiveComments && isConsecutiveComment(comment)) { + return true; + } + + // 5. Does the comment start with a possible URL? + if (MAYBE_URL.test(commentWithoutAsterisks)) { + return true; + } + + // 6. Is the initial word character a letter? + const commentWordCharsOnly = commentWithoutAsterisks + .replace(WHITESPACE, ""); + + if (commentWordCharsOnly.length === 0) { + return true; + } + + const firstWordChar = commentWordCharsOnly[0]; + + if (!LETTER_PATTERN.test(firstWordChar)) { + return true; + } + + // 7. Check the case of the initial word character. + const isUppercase = firstWordChar !== firstWordChar.toLocaleLowerCase(), + isLowercase = firstWordChar !== firstWordChar.toLocaleUpperCase(); + + if (capitalize === "always" && isLowercase) { + return false; + } else if (capitalize === "never" && isUppercase) { + return false; + } + + return true; + } + + /** + * Process a comment to determine if it needs to be reported. + * + * @param {ASTNode} comment The comment node to process. + * @returns {void} + */ + function processComment(comment) { + const options = normalizedOptions[comment.type], + commentValid = isCommentValid(comment, options); + + if (!commentValid) { + const message = capitalize === "always" ? + ALWAYS_MESSAGE : + NEVER_MESSAGE; + + context.report({ + node: null, // Intentionally using loc instead + loc: comment.loc, + message, + fix(fixer) { + const match = comment.value.match(LETTER_PATTERN); + + return fixer.replaceTextRange( + + // Offset match.index by 2 to account for the first 2 characters that start the comment (// or /*) + [comment.range[0] + match.index + 2, comment.range[0] + match.index + 3], + capitalize === "always" ? match[0].toLocaleUpperCase() : match[0].toLocaleLowerCase() + ); + } + }); + } + } + + //---------------------------------------------------------------------- + // Public + //---------------------------------------------------------------------- + + return { + Program() { + const comments = sourceCode.getAllComments(); + + comments.forEach(processComment); + } + }; + } +}; diff --git a/tools/eslint/lib/rules/comma-dangle.js b/tools/eslint/lib/rules/comma-dangle.js index 763ee89fd5d55e..af7ab2767f5566 100644 --- a/tools/eslint/lib/rules/comma-dangle.js +++ b/tools/eslint/lib/rules/comma-dangle.js @@ -112,11 +112,11 @@ module.exports = { { type: "object", properties: { - arrays: {$refs: "#/defs/valueWithIgnore"}, - objects: {$refs: "#/defs/valueWithIgnore"}, - imports: {$refs: "#/defs/valueWithIgnore"}, - exports: {$refs: "#/defs/valueWithIgnore"}, - functions: {$refs: "#/defs/valueWithIgnore"} + arrays: { $refs: "#/defs/valueWithIgnore" }, + objects: { $refs: "#/defs/valueWithIgnore" }, + imports: { $refs: "#/defs/valueWithIgnore" }, + exports: { $refs: "#/defs/valueWithIgnore" }, + functions: { $refs: "#/defs/valueWithIgnore" } }, additionalProperties: false } @@ -171,15 +171,10 @@ module.exports = { function getTrailingToken(node, lastItem) { switch (node.type) { case "ObjectExpression": - case "ObjectPattern": case "ArrayExpression": - case "ArrayPattern": case "CallExpression": case "NewExpression": return sourceCode.getLastToken(node, 1); - case "FunctionDeclaration": - case "FunctionExpression": - return sourceCode.getTokenBefore(node.body, 1); default: { const nextToken = sourceCode.getTokenAfter(lastItem); diff --git a/tools/eslint/lib/rules/comma-spacing.js b/tools/eslint/lib/rules/comma-spacing.js index 72b5bad6badabe..f571cfa199675a 100644 --- a/tools/eslint/lib/rules/comma-spacing.js +++ b/tools/eslint/lib/rules/comma-spacing.js @@ -141,7 +141,7 @@ module.exports = { function addNullElementsToIgnoreList(node) { let previousToken = sourceCode.getFirstToken(node); - node.elements.forEach(function(element) { + node.elements.forEach(element => { let token; if (element === null) { @@ -164,7 +164,7 @@ module.exports = { return { "Program:exit"() { - tokensAndComments.forEach(function(token, i) { + tokensAndComments.forEach((token, i) => { if (!isComma(token)) { return; diff --git a/tools/eslint/lib/rules/comma-style.js b/tools/eslint/lib/rules/comma-style.js index f707ce80557e09..bb290f90b980d1 100644 --- a/tools/eslint/lib/rules/comma-style.js +++ b/tools/eslint/lib/rules/comma-style.js @@ -41,10 +41,22 @@ module.exports = { create(context) { const style = context.options[0] || "last", sourceCode = context.getSourceCode(); - let exceptions = {}; + const exceptions = { + ArrayPattern: true, + ArrowFunctionExpression: true, + CallExpression: true, + FunctionDeclaration: true, + FunctionExpression: true, + ImportDeclaration: true, + ObjectPattern: true, + }; if (context.options.length === 2 && context.options[1].hasOwnProperty("exceptions")) { - exceptions = context.options[1].exceptions; + const keys = Object.keys(context.options[1].exceptions); + + for (let i = 0; i < keys.length; i++) { + exceptions[keys[i]] = context.options[1].exceptions[keys[i]]; + } } //-------------------------------------------------------------------------- @@ -119,7 +131,7 @@ module.exports = { if (astUtils.isTokenOnSameLine(commaToken, currentItemToken) && astUtils.isTokenOnSameLine(previousItemToken, commaToken)) { - return; + // do nothing. } else if (!astUtils.isTokenOnSameLine(commaToken, currentItemToken) && !astUtils.isTokenOnSameLine(previousItemToken, commaToken)) { @@ -166,14 +178,14 @@ module.exports = { */ function validateComma(node, property) { const items = node[property], - arrayLiteral = (node.type === "ArrayExpression"); + arrayLiteral = (node.type === "ArrayExpression" || node.type === "ArrayPattern"); if (items.length > 1 || arrayLiteral) { // seed as opening [ let previousItemToken = sourceCode.getFirstToken(node); - items.forEach(function(item) { + items.forEach(item => { const commaToken = item ? sourceCode.getTokenBefore(item) : previousItemToken, currentItemToken = item ? sourceCode.getFirstToken(item) : sourceCode.getTokenAfter(commaToken), reportItem = item || currentItemToken, @@ -245,11 +257,46 @@ module.exports = { validateComma(node, "properties"); }; } + if (!exceptions.ObjectPattern) { + nodes.ObjectPattern = function(node) { + validateComma(node, "properties"); + }; + } if (!exceptions.ArrayExpression) { nodes.ArrayExpression = function(node) { validateComma(node, "elements"); }; } + if (!exceptions.ArrayPattern) { + nodes.ArrayPattern = function(node) { + validateComma(node, "elements"); + }; + } + if (!exceptions.FunctionDeclaration) { + nodes.FunctionDeclaration = function(node) { + validateComma(node, "params"); + }; + } + if (!exceptions.FunctionExpression) { + nodes.FunctionExpression = function(node) { + validateComma(node, "params"); + }; + } + if (!exceptions.ArrowFunctionExpression) { + nodes.ArrowFunctionExpression = function(node) { + validateComma(node, "params"); + }; + } + if (!exceptions.CallExpression) { + nodes.CallExpression = function(node) { + validateComma(node, "arguments"); + }; + } + if (!exceptions.ImportDeclaration) { + nodes.ImportDeclaration = function(node) { + validateComma(node, "specifiers"); + }; + } return nodes; } diff --git a/tools/eslint/lib/rules/complexity.js b/tools/eslint/lib/rules/complexity.js index 0d837e74d3b650..2f3e4040799872 100644 --- a/tools/eslint/lib/rules/complexity.js +++ b/tools/eslint/lib/rules/complexity.js @@ -91,7 +91,7 @@ module.exports = { } if (complexity > THRESHOLD) { - context.report(node, "Function '{{name}}' has a complexity of {{complexity}}.", { name, complexity }); + context.report({ node, message: "Function '{{name}}' has a complexity of {{complexity}}.", data: { name, complexity } }); } } diff --git a/tools/eslint/lib/rules/consistent-return.js b/tools/eslint/lib/rules/consistent-return.js index eed69c2cb78ac3..0c1a6a7493f663 100644 --- a/tools/eslint/lib/rules/consistent-return.js +++ b/tools/eslint/lib/rules/consistent-return.js @@ -33,6 +33,18 @@ function isUnreachable(segment) { return !segment.reachable; } +/** +* Checks whether a given node is a `constructor` method in an ES6 class +* @param {ASTNode} node A node to check +* @returns {boolean} `true` if the node is a `constructor` method +*/ +function isClassConstructor(node) { + return node.type === "FunctionExpression" && + node.parent && + node.parent.type === "MethodDefinition" && + node.parent.kind === "constructor"; +} + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -77,7 +89,8 @@ module.exports = { */ if (!funcInfo.hasReturnValue || funcInfo.codePath.currentSegments.every(isUnreachable) || - astUtils.isES5Constructor(node) + astUtils.isES5Constructor(node) || + isClassConstructor(node) ) { return; } @@ -86,7 +99,7 @@ module.exports = { if (node.type === "Program") { // The head of program. - loc = {line: 1, column: 0}; + loc = { line: 1, column: 0 }; type = "program"; } else if (node.type === "ArrowFunctionExpression") { @@ -113,7 +126,7 @@ module.exports = { node, loc, message: "Expected to return a value at the end of this {{type}}.", - data: {type} + data: { type } }); } diff --git a/tools/eslint/lib/rules/consistent-this.js b/tools/eslint/lib/rules/consistent-this.js index 2a068ed1fc2add..35c2d56272a638 100644 --- a/tools/eslint/lib/rules/consistent-this.js +++ b/tools/eslint/lib/rules/consistent-this.js @@ -43,9 +43,7 @@ module.exports = { * @returns {void} */ function reportBadAssignment(node, alias) { - context.report(node, - "Designated alias '{{alias}}' is not assigned to 'this'.", - { alias }); + context.report({ node, message: "Designated alias '{{alias}}' is not assigned to 'this'.", data: { alias } }); } /** @@ -64,8 +62,7 @@ module.exports = { reportBadAssignment(node, name); } } else if (isThis) { - context.report(node, - "Unexpected alias '{{name}}' for 'this'.", { name }); + context.report({ node, message: "Unexpected alias '{{name}}' for 'this'.", data: { name } }); } } @@ -84,16 +81,14 @@ module.exports = { return; } - if (variable.defs.some(function(def) { - return def.node.type === "VariableDeclarator" && - def.node.init !== null; - })) { + if (variable.defs.some(def => def.node.type === "VariableDeclarator" && + def.node.init !== null)) { return; } // The alias has been declared and not assigned: check it was // assigned later in the same scope. - if (!variable.references.some(function(reference) { + if (!variable.references.some(reference => { const write = reference.writeExpr; return ( @@ -102,9 +97,7 @@ module.exports = { write.parent.operator === "=" ); })) { - variable.defs.map(function(def) { - return def.node; - }).forEach(function(node) { + variable.defs.map(def => def.node).forEach(node => { reportBadAssignment(node, alias); }); } @@ -117,7 +110,7 @@ module.exports = { function ensureWasAssigned() { const scope = context.getScope(); - aliases.forEach(function(alias) { + aliases.forEach(alias => { checkWasAssigned(alias, scope); }); } diff --git a/tools/eslint/lib/rules/constructor-super.js b/tools/eslint/lib/rules/constructor-super.js index 49271cee5899be..e84df7e81da025 100644 --- a/tools/eslint/lib/rules/constructor-super.js +++ b/tools/eslint/lib/rules/constructor-super.js @@ -261,8 +261,8 @@ module.exports = { const isRealLoop = toSegment.prevSegments.length >= 2; funcInfo.codePath.traverseSegments( - {first: toSegment, last: fromSegment}, - function(segment) { + { first: toSegment, last: fromSegment }, + segment => { const info = segInfoMap[segment.id]; const prevSegments = segment.prevSegments; diff --git a/tools/eslint/lib/rules/curly.js b/tools/eslint/lib/rules/curly.js index 02d74a1e037560..801552d69e151b 100644 --- a/tools/eslint/lib/rules/curly.js +++ b/tools/eslint/lib/rules/curly.js @@ -74,10 +74,11 @@ module.exports = { * @private */ function isCollapsedOneLiner(node) { - const before = sourceCode.getTokenBefore(node), - last = sourceCode.getLastToken(node); + const before = sourceCode.getTokenBefore(node); + const last = sourceCode.getLastToken(node); + const lastExcludingSemicolon = last.type === "Punctuator" && last.value === ";" ? sourceCode.getTokenBefore(last) : last; - return before.loc.start.line === last.loc.end.line; + return before.loc.start.line === lastExcludingSemicolon.loc.end.line; } /** @@ -195,7 +196,7 @@ module.exports = { return true; } - if (/^[(\[\/`+-]/.test(tokenAfter.value)) { + if (/^[([/`+-]/.test(tokenAfter.value)) { // If the next token starts with a character that would disrupt ASI, insert a semicolon. return true; @@ -289,7 +290,9 @@ module.exports = { } } else if (multiOrNest) { if (hasBlock && body.body.length === 1 && isOneLiner(body.body[0])) { - expected = false; + const leadingComments = sourceCode.getComments(body.body[0]).leading; + + expected = leadingComments.length > 0; } else if (!isOneLiner(body)) { expected = true; } @@ -337,14 +340,14 @@ module.exports = { * all have braces. * If all nodes shouldn't have braces, make sure they don't. */ - const expected = preparedChecks.some(function(preparedCheck) { + const expected = preparedChecks.some(preparedCheck => { if (preparedCheck.expected !== null) { return preparedCheck.expected; } return preparedCheck.actual; }); - preparedChecks.forEach(function(preparedCheck) { + preparedChecks.forEach(preparedCheck => { preparedCheck.expected = expected; }); } @@ -359,7 +362,7 @@ module.exports = { return { IfStatement(node) { if (node.parent.type !== "IfStatement") { - prepareIfChecks(node).forEach(function(preparedCheck) { + prepareIfChecks(node).forEach(preparedCheck => { preparedCheck.check(); }); } diff --git a/tools/eslint/lib/rules/default-case.js b/tools/eslint/lib/rules/default-case.js index e062798db235ab..070ff3c7a9666b 100644 --- a/tools/eslint/lib/rules/default-case.js +++ b/tools/eslint/lib/rules/default-case.js @@ -4,7 +4,7 @@ */ "use strict"; -const DEFAULT_COMMENT_PATTERN = /^no default$/; +const DEFAULT_COMMENT_PATTERN = /^no default$/i; //------------------------------------------------------------------------------ // Rule Definition @@ -67,9 +67,7 @@ module.exports = { return; } - const hasDefault = node.cases.some(function(v) { - return v.test === null; - }); + const hasDefault = node.cases.some(v => v.test === null); if (!hasDefault) { @@ -83,7 +81,7 @@ module.exports = { } if (!comment || !commentPattern.test(comment.value.trim())) { - context.report(node, "Expected a default case."); + context.report({ node, message: "Expected a default case." }); } } } diff --git a/tools/eslint/lib/rules/eqeqeq.js b/tools/eslint/lib/rules/eqeqeq.js index 4d61399f207ba7..d77607afb5f2aa 100644 --- a/tools/eslint/lib/rules/eqeqeq.js +++ b/tools/eslint/lib/rules/eqeqeq.js @@ -47,7 +47,9 @@ module.exports = { additionalItems: false } ] - } + }, + + fixable: "code" }, create(context) { @@ -112,22 +114,32 @@ module.exports = { function getOperatorLocation(node) { const opToken = sourceCode.getTokenAfter(node.left); - return {line: opToken.loc.start.line, column: opToken.loc.start.column}; + return { line: opToken.loc.start.line, column: opToken.loc.start.column }; } /** * Reports a message for this rule. * @param {ASTNode} node The binary expression node that was checked - * @param {string} message The message to report + * @param {string} expectedOperator The operator that was expected (either '==', '!=', '===', or '!==') * @returns {void} * @private */ - function report(node, message) { + function report(node, expectedOperator) { context.report({ node, loc: getOperatorLocation(node), - message, - data: { op: node.operator.charAt(0) } + message: "Expected '{{expectedOperator}}' and instead saw '{{actualOperator}}'.", + data: { expectedOperator, actualOperator: node.operator }, + fix(fixer) { + + // If the comparison is a `typeof` comparison or both sides are literals with the same type, then it's safe to fix. + if (isTypeOfBinary(node) || areLiteralsAndSameType(node)) { + const operatorToken = sourceCode.getTokensBetween(node.left, node.right).find(token => token.value === node.operator); + + return fixer.replaceText(operatorToken, expectedOperator); + } + return null; + } }); } @@ -137,7 +149,7 @@ module.exports = { if (node.operator !== "==" && node.operator !== "!=") { if (enforceInverseRuleForNull && isNull) { - report(node, "Expected '{{op}}=' and instead saw '{{op}}=='."); + report(node, node.operator.slice(0, -1)); } return; } @@ -151,7 +163,7 @@ module.exports = { return; } - report(node, "Expected '{{op}}==' and instead saw '{{op}}='."); + report(node, `${node.operator}=`); } }; diff --git a/tools/eslint/lib/rules/func-call-spacing.js b/tools/eslint/lib/rules/func-call-spacing.js index 417f2bdf313e17..5c416f0373fcac 100644 --- a/tools/eslint/lib/rules/func-call-spacing.js +++ b/tools/eslint/lib/rules/func-call-spacing.js @@ -120,7 +120,14 @@ module.exports = { loc: lastCalleeToken.loc.start, message: "Unexpected space between function name and paren.", fix(fixer) { - return fixer.removeRange([prevToken.range[1], parenToken.range[0]]); + + // Only autofix if there is no newline + // https://github.com/eslint/eslint/issues/7787 + if (!hasNewline) { + return fixer.removeRange([prevToken.range[1], parenToken.range[0]]); + } + + return null; } }); } else if (!never && !hasWhitespace) { diff --git a/tools/eslint/lib/rules/func-name-matching.js b/tools/eslint/lib/rules/func-name-matching.js index d4d760cbe45f1b..4eed7a68ea2b51 100644 --- a/tools/eslint/lib/rules/func-name-matching.js +++ b/tools/eslint/lib/rules/func-name-matching.js @@ -54,6 +54,17 @@ function isIdentifier(name, ecmaVersion) { // Rule Definition //------------------------------------------------------------------------------ +const alwaysOrNever = { enum: ["always", "never"] }; +const optionsObject = { + type: "object", + properties: { + includeCommonJSModuleExports: { + type: "boolean" + } + }, + additionalProperties: false +}; + module.exports = { meta: { docs: { @@ -62,24 +73,35 @@ module.exports = { recommended: false }, - schema: [ - { - type: "object", - properties: { - includeCommonJSModuleExports: { - type: "boolean" - } - }, - additionalProperties: false - } - ] + schema: { + anyOf: [{ + type: "array", + additionalItems: false, + items: [alwaysOrNever, optionsObject] + }, { + type: "array", + additionalItems: false, + items: [optionsObject] + }] + } }, create(context) { - - const includeModuleExports = context.options[0] && context.options[0].includeCommonJSModuleExports; + const options = (typeof context.options[0] === "object" ? context.options[0] : context.options[1]) || {}; + const nameMatches = typeof context.options[0] === "string" ? context.options[0] : "always"; + const includeModuleExports = options.includeCommonJSModuleExports; const ecmaVersion = context.parserOptions && context.parserOptions.ecmaVersion ? context.parserOptions.ecmaVersion : 5; + /** + * Compares identifiers based on the nameMatches option + * @param {string} x the first identifier + * @param {string} y the second identifier + * @returns {boolean} whether the two identifiers should warn. + */ + function shouldWarn(x, y) { + return (nameMatches === "always" && x !== y) || (nameMatches === "never" && x === y); + } + /** * Reports * @param {ASTNode} node The node to report @@ -89,10 +111,20 @@ module.exports = { * @returns {void} */ function report(node, name, funcName, isProp) { + let message; + + if (nameMatches === "always" && isProp) { + message = "Function name `{{funcName}}` should match property name `{{name}}`"; + } else if (nameMatches === "always") { + message = "Function name `{{funcName}}` should match variable name `{{name}}`"; + } else if (isProp) { + message = "Function name `{{funcName}}` should not match property name `{{name}}`"; + } else { + message = "Function name `{{funcName}}` should not match variable name `{{name}}`"; + } context.report({ node, - message: isProp ? "Function name `{{funcName}}` should match property name `{{name}}`" - : "Function name `{{funcName}}` should match variable name `{{name}}`", + message, data: { name, funcName @@ -110,7 +142,7 @@ module.exports = { if (!node.init || node.init.type !== "FunctionExpression") { return; } - if (node.init.id && node.id.name !== node.init.id.name) { + if (node.init.id && shouldWarn(node.id.name, node.init.id.name)) { report(node, node.id.name, node.init.id.name, false); } }, @@ -126,7 +158,7 @@ module.exports = { const isProp = node.left.type === "MemberExpression" ? true : false; const name = isProp ? astUtils.getStaticPropertyName(node.left) : node.left.name; - if (node.right.id && isIdentifier(name) && name !== node.right.id.name) { + if (node.right.id && isIdentifier(name) && shouldWarn(name, node.right.id.name)) { report(node, name, node.right.id.name, isProp); } }, @@ -135,12 +167,13 @@ module.exports = { if (node.value.type !== "FunctionExpression" || !node.value.id || node.computed && node.key.type !== "Literal") { return; } - if (node.key.type === "Identifier" && node.key.name !== node.value.id.name) { + if (node.key.type === "Identifier" && shouldWarn(node.key.name, node.value.id.name)) { report(node, node.key.name, node.value.id.name, true); - } else if (node.key.type === "Literal" && - isIdentifier(node.key.value, ecmaVersion) && - node.key.value !== node.value.id.name - ) { + } else if ( + node.key.type === "Literal" && + isIdentifier(node.key.value, ecmaVersion) && + shouldWarn(node.key.value, node.value.id.name) + ) { report(node, node.key.value, node.value.id.name, true); } } diff --git a/tools/eslint/lib/rules/func-names.js b/tools/eslint/lib/rules/func-names.js index 397ef37e91614d..0d8567149493dc 100644 --- a/tools/eslint/lib/rules/func-names.js +++ b/tools/eslint/lib/rules/func-names.js @@ -28,21 +28,23 @@ module.exports = { schema: [ { - enum: ["always", "never"] + enum: ["always", "as-needed", "never"] } ] }, create(context) { const never = context.options[0] === "never"; + const asNeeded = context.options[0] === "as-needed"; /** * Determines whether the current FunctionExpression node is a get, set, or * shorthand method in an object literal or a class. + * @param {ASTNode} node - A node to check. * @returns {boolean} True if the node is a get, set, or shorthand method. */ - function isObjectOrClassMethod() { - const parent = context.getAncestors().pop(); + function isObjectOrClassMethod(node) { + const parent = node.parent; return (parent.type === "MethodDefinition" || ( parent.type === "Property" && ( @@ -53,6 +55,23 @@ module.exports = { )); } + /** + * Determines whether the current FunctionExpression node has a name that would be + * inferred from context in a conforming ES6 environment. + * @param {ASTNode} node - A node to check. + * @returns {boolean} True if the node would have a name assigned automatically. + */ + function hasInferredName(node) { + const parent = node.parent; + + return isObjectOrClassMethod(node) || + (parent.type === "VariableDeclarator" && parent.id.type === "Identifier" && parent.init === node) || + (parent.type === "Property" && parent.value === node) || + (parent.type === "AssignmentExpression" && parent.left.type === "Identifier" && parent.right === node) || + (parent.type === "ExportDefaultDeclaration" && parent.declaration === node) || + (parent.type === "AssignmentPattern" && parent.right === node); + } + return { "FunctionExpression:exit"(node) { @@ -67,11 +86,11 @@ module.exports = { if (never) { if (name) { - context.report(node, "Unexpected function expression name."); + context.report({ node, message: "Unexpected function expression name." }); } } else { - if (!name && !isObjectOrClassMethod()) { - context.report(node, "Missing function expression name."); + if (!name && (asNeeded ? !hasInferredName(node) : !isObjectOrClassMethod(node))) { + context.report({ node, message: "Missing function expression name." }); } } } diff --git a/tools/eslint/lib/rules/func-style.js b/tools/eslint/lib/rules/func-style.js index e0974209c4bb78..123eae3d8a406f 100644 --- a/tools/eslint/lib/rules/func-style.js +++ b/tools/eslint/lib/rules/func-style.js @@ -44,7 +44,7 @@ module.exports = { stack.push(false); if (!enforceDeclarations && node.parent.type !== "ExportDefaultDeclaration") { - context.report(node, "Expected a function expression."); + context.report({ node, message: "Expected a function expression." }); } }, "FunctionDeclaration:exit"() { @@ -55,7 +55,7 @@ module.exports = { stack.push(false); if (enforceDeclarations && node.parent.type === "VariableDeclarator") { - context.report(node.parent, "Expected a function declaration."); + context.report({ node: node.parent, message: "Expected a function declaration." }); } }, "FunctionExpression:exit"() { @@ -78,7 +78,7 @@ module.exports = { const hasThisExpr = stack.pop(); if (enforceDeclarations && !hasThisExpr && node.parent.type === "VariableDeclarator") { - context.report(node.parent, "Expected a function declaration."); + context.report({ node: node.parent, message: "Expected a function declaration." }); } }; } diff --git a/tools/eslint/lib/rules/generator-star-spacing.js b/tools/eslint/lib/rules/generator-star-spacing.js index f9ec3a4af52c25..fc676d0cbbb85f 100644 --- a/tools/eslint/lib/rules/generator-star-spacing.js +++ b/tools/eslint/lib/rules/generator-star-spacing.js @@ -28,8 +28,8 @@ module.exports = { { type: "object", properties: { - before: {type: "boolean"}, - after: {type: "boolean"} + before: { type: "boolean" }, + after: { type: "boolean" } }, additionalProperties: false } diff --git a/tools/eslint/lib/rules/global-require.js b/tools/eslint/lib/rules/global-require.js index 3d6492cfde4671..bfd01433957e3e 100644 --- a/tools/eslint/lib/rules/global-require.js +++ b/tools/eslint/lib/rules/global-require.js @@ -23,10 +23,8 @@ const ACCEPTABLE_PARENTS = [ * @returns {Reference|null} Returns the found reference or null if none were found. */ function findReference(scope, node) { - const references = scope.references.filter(function(reference) { - return reference.identifier.range[0] === node.range[0] && - reference.identifier.range[1] === node.range[1]; - }); + const references = scope.references.filter(reference => reference.identifier.range[0] === node.range[0] && + reference.identifier.range[1] === node.range[1]); /* istanbul ignore else: correctly returns null */ if (references.length === 1) { @@ -65,12 +63,10 @@ module.exports = { const currentScope = context.getScope(); if (node.callee.name === "require" && !isShadowed(currentScope, node.callee)) { - const isGoodRequire = context.getAncestors().every(function(parent) { - return ACCEPTABLE_PARENTS.indexOf(parent.type) > -1; - }); + const isGoodRequire = context.getAncestors().every(parent => ACCEPTABLE_PARENTS.indexOf(parent.type) > -1); if (!isGoodRequire) { - context.report(node, "Unexpected require()."); + context.report({ node, message: "Unexpected require()." }); } } } diff --git a/tools/eslint/lib/rules/guard-for-in.js b/tools/eslint/lib/rules/guard-for-in.js index 7ccfec90c1c572..754830f6a64be3 100644 --- a/tools/eslint/lib/rules/guard-for-in.js +++ b/tools/eslint/lib/rules/guard-for-in.js @@ -33,7 +33,7 @@ module.exports = { const body = node.body.type === "BlockStatement" ? node.body.body[0] : node.body; if (body && body.type !== "IfStatement") { - context.report(node, "The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype."); + context.report({ node, message: "The body of a for-in should be wrapped in an if statement to filter unwanted properties from the prototype." }); } } }; diff --git a/tools/eslint/lib/rules/handle-callback-err.js b/tools/eslint/lib/rules/handle-callback-err.js index e8c6d1b3b8f647..de36a0c1b002c6 100644 --- a/tools/eslint/lib/rules/handle-callback-err.js +++ b/tools/eslint/lib/rules/handle-callback-err.js @@ -59,9 +59,7 @@ module.exports = { * @returns {array} All parameters of the given scope. */ function getParameters(scope) { - return scope.variables.filter(function(variable) { - return variable.defs[0] && variable.defs[0].type === "Parameter"; - }); + return scope.variables.filter(variable => variable.defs[0] && variable.defs[0].type === "Parameter"); } /** @@ -76,7 +74,7 @@ module.exports = { if (firstParameter && matchesConfiguredErrorName(firstParameter.name)) { if (firstParameter.references.length === 0) { - context.report(node, "Expected error to be handled."); + context.report({ node, message: "Expected error to be handled." }); } } } diff --git a/tools/eslint/lib/rules/id-blacklist.js b/tools/eslint/lib/rules/id-blacklist.js index 8795cfc6be6964..f94f6d0a4684d4 100644 --- a/tools/eslint/lib/rules/id-blacklist.js +++ b/tools/eslint/lib/rules/id-blacklist.js @@ -67,9 +67,9 @@ module.exports = { * @private */ function report(node) { - context.report(node, "Identifier '{{name}}' is blacklisted.", { + context.report({ node, message: "Identifier '{{name}}' is blacklisted.", data: { name: node.name - }); + } }); } return { diff --git a/tools/eslint/lib/rules/id-length.js b/tools/eslint/lib/rules/id-length.js index 1747552707901c..6a6c69d1017e8c 100644 --- a/tools/eslint/lib/rules/id-length.js +++ b/tools/eslint/lib/rules/id-length.js @@ -50,7 +50,7 @@ module.exports = { const maxLength = typeof options.max !== "undefined" ? options.max : Infinity; const properties = options.properties !== "never"; const exceptions = (options.exceptions ? options.exceptions : []) - .reduce(function(obj, item) { + .reduce((obj, item) => { obj[item] = true; return obj; @@ -102,13 +102,13 @@ module.exports = { const isValidExpression = SUPPORTED_EXPRESSIONS[parent.type]; if (isValidExpression && (isValidExpression === true || isValidExpression(parent, node))) { - context.report( + context.report({ node, - isShort ? + message: isShort ? "Identifier name '{{name}}' is too short (< {{min}})." : "Identifier name '{{name}}' is too long (> {{max}}).", - { name, min: minLength, max: maxLength } - ); + data: { name, min: minLength, max: maxLength } + }); } } }; diff --git a/tools/eslint/lib/rules/id-match.js b/tools/eslint/lib/rules/id-match.js index 961a1859049d24..29d06c36024c57 100644 --- a/tools/eslint/lib/rules/id-match.js +++ b/tools/eslint/lib/rules/id-match.js @@ -75,10 +75,10 @@ module.exports = { * @private */ function report(node) { - context.report(node, "Identifier '{{name}}' does not match the pattern '{{pattern}}'.", { + context.report({ node, message: "Identifier '{{name}}' does not match the pattern '{{pattern}}'.", data: { name: node.name, pattern - }); + } }); } return { diff --git a/tools/eslint/lib/rules/indent.js b/tools/eslint/lib/rules/indent.js index 2b069011f99d02..6c3c27c8e1941a 100644 --- a/tools/eslint/lib/rules/indent.js +++ b/tools/eslint/lib/rules/indent.js @@ -113,6 +113,44 @@ module.exports = { minimum: 0 } } + }, + CallExpression: { + type: "object", + properties: { + parameters: { + oneOf: [ + { + type: "integer", + minimum: 0 + }, + { + enum: ["first"] + } + ] + } + } + }, + ArrayExpression: { + oneOf: [ + { + type: "integer", + minimum: 0 + }, + { + enum: ["first"] + } + ] + }, + ObjectExpression: { + oneOf: [ + { + type: "integer", + minimum: 0 + }, + { + enum: ["first"] + } + ] } }, additionalProperties: false @@ -142,7 +180,12 @@ module.exports = { FunctionExpression: { parameters: DEFAULT_PARAMETER_INDENT, body: DEFAULT_FUNCTION_BODY_INDENT - } + }, + CallExpression: { + arguments: DEFAULT_PARAMETER_INDENT + }, + ArrayExpression: 1, + ObjectExpression: 1 }; const sourceCode = context.getSourceCode(); @@ -187,6 +230,18 @@ module.exports = { if (typeof opts.FunctionExpression === "object") { Object.assign(options.FunctionExpression, opts.FunctionExpression); } + + if (typeof opts.CallExpression === "object") { + Object.assign(options.CallExpression, opts.CallExpression); + } + + if (typeof opts.ArrayExpression === "number" || typeof opts.ArrayExpression === "string") { + options.ArrayExpression = opts.ArrayExpression; + } + + if (typeof opts.ObjectExpression === "number" || typeof opts.ObjectExpression === "string") { + options.ObjectExpression = opts.ObjectExpression; + } } } @@ -229,10 +284,10 @@ module.exports = { * @param {int} gottenTabs Indentation tab count in the actual node/code * @param {Object=} loc Error line and column location * @param {boolean} isLastNodeCheck Is the error for last node check + * @param {int} lastNodeCheckEndOffset Number of charecters to skip from the end * @returns {void} */ function report(node, needed, gottenSpaces, gottenTabs, loc, isLastNodeCheck) { - if (gottenSpaces && gottenTabs) { // To avoid conflicts with `no-mixed-spaces-and-tabs`, don't report lines that have both spaces and tabs. @@ -242,8 +297,8 @@ module.exports = { const desiredIndent = (indentType === "space" ? " " : "\t").repeat(needed); const textRange = isLastNodeCheck - ? [node.range[1] - gottenSpaces - gottenTabs - 1, node.range[1] - 1] - : [node.range[0] - gottenSpaces - gottenTabs, node.range[0]]; + ? [node.range[1] - node.loc.end.column, node.range[1] - node.loc.end.column + gottenSpaces + gottenTabs] + : [node.range[0] - node.loc.start.column, node.range[0] - node.loc.start.column + gottenSpaces + gottenTabs]; context.report({ node, @@ -319,6 +374,24 @@ module.exports = { checkNodeIndent(node.alternate, neededIndent); } } + + if (node.type === "TryStatement" && node.handler) { + const catchToken = sourceCode.getFirstToken(node.handler); + + checkNodeIndent(catchToken, neededIndent); + } + + if (node.type === "TryStatement" && node.finalizer) { + const finallyToken = sourceCode.getTokenBefore(node.finalizer); + + checkNodeIndent(finallyToken, neededIndent); + } + + if (node.type === "DoWhileStatement") { + const whileToken = sourceCode.getTokenAfter(node.body); + + checkNodeIndent(whileToken, neededIndent); + } } /** @@ -354,6 +427,45 @@ module.exports = { } } + /** + * Check last node line indent this detects, that block closed correctly + * This function for more complicated return statement case, where closing parenthesis may be followed by ';' + * @param {ASTNode} node Node to examine + * @param {int} firstLineIndent first line needed indent + * @returns {void} + */ + function checkLastReturnStatementLineIndent(node, firstLineIndent) { + const nodeLastToken = sourceCode.getLastToken(node); + let lastToken = nodeLastToken; + + // in case if return statement ends with ');' we have traverse back to ')' + // otherwise we'll measure indent for ';' and replace ')' + while (lastToken.value !== ")") { + lastToken = sourceCode.getTokenBefore(lastToken); + } + + const textBeforeClosingParenthesis = sourceCode.getText(lastToken, lastToken.loc.start.column).slice(0, -1); + + if (textBeforeClosingParenthesis.trim()) { + + // There are tokens before the closing paren, don't report this case + return; + } + + const endIndent = getNodeIndent(lastToken, true); + + if (endIndent.goodChar !== firstLineIndent) { + report( + node, + firstLineIndent, + endIndent.space, + endIndent.tab, + { line: lastToken.loc.start.line, column: lastToken.loc.start.column }, + true + ); + } + } + /** * Check first node line indent is correct * @param {ASTNode} node Node to examine @@ -379,12 +491,17 @@ module.exports = { * if not present then return null * @param {ASTNode} node node to examine * @param {string} type type that is being looked for + * @param {string} stopAtList end points for the evaluating code * @returns {ASTNode|void} if found then node otherwise null */ - function getParentNodeByType(node, type) { + function getParentNodeByType(node, type, stopAtList) { let parent = node.parent; - while (parent.type !== type && parent.type !== "Program") { + if (!stopAtList) { + stopAtList = ["Program"]; + } + + while (parent.type !== type && stopAtList.indexOf(parent.type) === -1 && parent.type !== "Program") { parent = parent.parent; } @@ -401,16 +518,6 @@ module.exports = { return getParentNodeByType(node, "VariableDeclarator"); } - /** - * Returns the ExpressionStatement based on the current node - * if not present then return null - * @param {ASTNode} node node to examine - * @returns {ASTNode|void} if found then node otherwise null - */ - function getAssignmentExpressionNode(node) { - return getParentNodeByType(node, "AssignmentExpression"); - } - /** * Check to see if the node is part of the multi-line variable declaration. * Also if its on the same line as the varNode @@ -604,14 +711,7 @@ module.exports = { let elements = (node.type === "ArrayExpression") ? node.elements : node.properties; // filter out empty elements example would be [ , 2] so remove first element as espree considers it as null - elements = elements.filter(function(elem) { - return elem !== null; - }); - - // Skip if first element is in same line with this node - if (elements.length > 0 && elements[0].loc.start.line === node.loc.start.line) { - return; - } + elements = elements.filter(elem => elem !== null); let nodeIndent; let elementsIndent; @@ -620,41 +720,59 @@ module.exports = { // TODO - come up with a better strategy in future if (isNodeFirstInLine(node)) { const parent = node.parent; - let effectiveParent = parent; - if (parent.type === "MemberExpression") { - if (isNodeFirstInLine(parent)) { - effectiveParent = parent.parent.parent; - } else { - effectiveParent = parent.parent; - } - } - nodeIndent = getNodeIndent(effectiveParent).goodChar; - if (parentVarNode && parentVarNode.loc.start.line !== node.loc.start.line) { + nodeIndent = getNodeIndent(parent).goodChar; + if (!parentVarNode || parentVarNode.loc.start.line !== node.loc.start.line) { if (parent.type !== "VariableDeclarator" || parentVarNode === parentVarNode.parent.declarations[0]) { - if (parent.type === "VariableDeclarator" && parentVarNode.loc.start.line === effectiveParent.loc.start.line) { + if (parent.type === "VariableDeclarator" && parentVarNode.loc.start.line === parent.loc.start.line) { nodeIndent = nodeIndent + (indentSize * options.VariableDeclarator[parentVarNode.parent.kind]); - } else if ( - parent.type === "ObjectExpression" || - parent.type === "ArrayExpression" || - parent.type === "CallExpression" || - parent.type === "ArrowFunctionExpression" || - parent.type === "NewExpression" || - parent.type === "LogicalExpression" - ) { - nodeIndent = nodeIndent + indentSize; + } else if (parent.type === "ObjectExpression" || parent.type === "ArrayExpression") { + const parentElements = node.parent.type === "ObjectExpression" ? node.parent.properties : node.parent.elements; + + if (parentElements[0].loc.start.line === parent.loc.start.line && parentElements[0].loc.end.line !== parent.loc.start.line) { + + /* + * If the first element of the array spans multiple lines, don't increase the expected indentation of the rest. + * e.g. [{ + * foo: 1 + * }, + * { + * bar: 1 + * }] + * the second object is not indented. + */ + } else if (typeof options[parent.type] === "number") { + nodeIndent += options[parent.type] * indentSize; + } else { + nodeIndent = parentElements[0].loc.start.column; + } + } else if (parent.type === "CallExpression" || parent.type === "NewExpression") { + if (typeof options.CallExpression.arguments === "number") { + nodeIndent += options.CallExpression.arguments * indentSize; + } else if (options.CallExpression.arguments === "first") { + if (parent.arguments.indexOf(node) !== -1) { + nodeIndent = parent.arguments[0].loc.start.column; + } + } else { + nodeIndent += indentSize; + } + } else if (parent.type === "LogicalExpression" || parent.type === "ArrowFunctionExpression") { + nodeIndent += indentSize; } } - } else if (!parentVarNode && !isFirstArrayElementOnSameLine(parent) && effectiveParent.type !== "MemberExpression" && effectiveParent.type !== "ExpressionStatement" && effectiveParent.type !== "AssignmentExpression" && effectiveParent.type !== "Property") { + } else if (!parentVarNode && !isFirstArrayElementOnSameLine(parent) && parent.type !== "MemberExpression" && parent.type !== "ExpressionStatement" && parent.type !== "AssignmentExpression" && parent.type !== "Property") { nodeIndent = nodeIndent + indentSize; } - elementsIndent = nodeIndent + indentSize; - checkFirstNodeLineIndent(node, nodeIndent); } else { nodeIndent = getNodeIndent(node).goodChar; - elementsIndent = nodeIndent + indentSize; + } + + if (options[node.type] === "first") { + elementsIndent = elements.length ? elements[0].loc.start.column : 0; // If there are no elements, elementsIndent doesn't matter. + } else { + elementsIndent = nodeIndent + indentSize * options[node.type]; } /* @@ -675,7 +793,7 @@ module.exports = { } } - checkLastNodeLineIndent(node, elementsIndent - indentSize); + checkLastNodeLineIndent(node, nodeIndent + (isNodeInVarOnTop(node, parentVarNode) ? options.VariableDeclarator[parentVarNode.parent.kind] * indentSize : 0)); } /** @@ -717,11 +835,13 @@ module.exports = { * not from the beginning of the block. */ const statementsWithProperties = [ - "IfStatement", "WhileStatement", "ForStatement", "ForInStatement", "ForOfStatement", "DoWhileStatement", "ClassDeclaration" + "IfStatement", "WhileStatement", "ForStatement", "ForInStatement", "ForOfStatement", "DoWhileStatement", "ClassDeclaration", "TryStatement" ]; if (node.parent && statementsWithProperties.indexOf(node.parent.type) !== -1 && isNodeBodyBlock(node)) { indent = getNodeIndent(node.parent).goodChar; + } else if (node.parent && node.parent.type === "CatchClause") { + indent = getNodeIndent(node.parent.parent).goodChar; } else { indent = getNodeIndent(node).goodChar; } @@ -750,7 +870,7 @@ module.exports = { * @returns {ASTNode[]} Filtered elements */ function filterOutSameLineVars(node) { - return node.declarations.reduce(function(finalCollection, elem) { + return node.declarations.reduce((finalCollection, elem) => { const lastElem = finalCollection[finalCollection.length - 1]; if ((elem.loc.start.line !== node.loc.start.line && !lastElem) || @@ -832,6 +952,20 @@ module.exports = { } } + /** + * Checks wether a return statement is wrapped in () + * @param {ASTNode} node node to examine + * @returns {boolean} the result + */ + function isWrappedInParenthesis(node) { + const regex = /^return\s*?\(\s*?\);*?/; + + const statementWithoutArgument = sourceCode.getText(node).replace( + sourceCode.getText(node.argument), ""); + + return regex.test(statementWithoutArgument); + } + return { Program(node) { if (node.body.length > 0) { @@ -876,6 +1010,7 @@ module.exports = { }, MemberExpression(node) { + if (typeof options.MemberExpression === "undefined") { return; } @@ -888,11 +1023,11 @@ module.exports = { // alter the expectation of correct indentation. Skip them. // TODO: Add appropriate configuration options for variable // declarations and assignments. - if (getVariableDeclaratorNode(node)) { + if (getParentNodeByType(node, "VariableDeclarator", ["FunctionExpression", "ArrowFunctionExpression"])) { return; } - if (getAssignmentExpressionNode(node)) { + if (getParentNodeByType(node, "AssignmentExpression", ["FunctionExpression"])) { return; } @@ -952,7 +1087,34 @@ module.exports = { } else if (options.FunctionExpression.parameters !== null) { checkNodesIndent(node.params, getNodeIndent(node).goodChar + indentSize * options.FunctionExpression.parameters); } + }, + + ReturnStatement(node) { + if (isSingleLineNode(node)) { + return; + } + + const firstLineIndent = getNodeIndent(node).goodChar; + + // in case if return statement is wrapped in parenthesis + if (isWrappedInParenthesis(node)) { + checkLastReturnStatementLineIndent(node, firstLineIndent); + } else { + checkNodeIndent(node, firstLineIndent); + } + }, + + CallExpression(node) { + if (isSingleLineNode(node)) { + return; + } + if (options.CallExpression.arguments === "first" && node.arguments.length) { + checkNodesIndent(node.arguments.slice(1), node.arguments[0].loc.start.column); + } else if (options.CallExpression.arguments !== null) { + checkNodesIndent(node.arguments, getNodeIndent(node).goodChar + indentSize * options.CallExpression.arguments); + } } + }; } diff --git a/tools/eslint/lib/rules/jsx-quotes.js b/tools/eslint/lib/rules/jsx-quotes.js index 2b6a57b961d88f..5653922d9495d5 100644 --- a/tools/eslint/lib/rules/jsx-quotes.js +++ b/tools/eslint/lib/rules/jsx-quotes.js @@ -48,7 +48,7 @@ module.exports = { schema: [ { - enum: [ "prefer-single", "prefer-double" ] + enum: ["prefer-single", "prefer-double"] } ] }, diff --git a/tools/eslint/lib/rules/key-spacing.js b/tools/eslint/lib/rules/key-spacing.js index b195d31d32a4ee..8d7564a5bbf246 100644 --- a/tools/eslint/lib/rules/key-spacing.js +++ b/tools/eslint/lib/rules/key-spacing.js @@ -417,8 +417,8 @@ module.exports = { function report(property, side, whitespace, expected, mode) { const diff = whitespace.length - expected, nextColon = getNextColon(property.key), - tokenBeforeColon = sourceCode.getTokenBefore(nextColon), - tokenAfterColon = sourceCode.getTokenAfter(nextColon), + tokenBeforeColon = sourceCode.getTokenOrCommentBefore(nextColon), + tokenAfterColon = sourceCode.getTokenOrCommentAfter(nextColon), isKeySide = side === "key", locStart = isKeySide ? tokenBeforeColon.loc.start : tokenAfterColon.loc.start, isExtra = diff > 0, @@ -514,7 +514,7 @@ module.exports = { return [node.properties]; } - return node.properties.reduce(function(groups, property) { + return node.properties.reduce((groups, property) => { const currentGroup = last(groups), prev = last(currentGroup); @@ -579,7 +579,7 @@ module.exports = { * @returns {void} */ function verifyAlignment(node) { - createGroups(node).forEach(function(group) { + createGroups(node).forEach(group => { verifyGroupAlignment(group.filter(isKeyValueProperty)); }); } diff --git a/tools/eslint/lib/rules/keyword-spacing.js b/tools/eslint/lib/rules/keyword-spacing.js index 4a6a024552111c..1dfc291f6e827b 100644 --- a/tools/eslint/lib/rules/keyword-spacing.js +++ b/tools/eslint/lib/rules/keyword-spacing.js @@ -16,10 +16,10 @@ const astUtils = require("../ast-utils"), // Constants //------------------------------------------------------------------------------ -const PREV_TOKEN = /^[\)\]\}>]$/; -const NEXT_TOKEN = /^(?:[\(\[\{<~!]|\+\+?|--?)$/; -const PREV_TOKEN_M = /^[\)\]\}>*]$/; -const NEXT_TOKEN_M = /^[\{*]$/; +const PREV_TOKEN = /^[)\]}>]$/; +const NEXT_TOKEN = /^(?:[([{<~!]|\+\+?|--?)$/; +const PREV_TOKEN_M = /^[)\]}>*]$/; +const NEXT_TOKEN_M = /^[{*]$/; const TEMPLATE_OPEN_PAREN = /\$\{$/; const TEMPLATE_CLOSE_PAREN = /^\}/; const CHECK_TYPE = /^(?:JSXElement|RegularExpression|String|Template)$/; @@ -77,16 +77,16 @@ module.exports = { { type: "object", properties: { - before: {type: "boolean"}, - after: {type: "boolean"}, + before: { type: "boolean" }, + after: { type: "boolean" }, overrides: { type: "object", - properties: KEYS.reduce(function(retv, key) { + properties: KEYS.reduce((retv, key) => { retv[key] = { type: "object", properties: { - before: {type: "boolean"}, - after: {type: "boolean"} + before: { type: "boolean" }, + after: { type: "boolean" } }, additionalProperties: false }; diff --git a/tools/eslint/lib/rules/lines-around-comment.js b/tools/eslint/lib/rules/lines-around-comment.js index 094fefa74f4646..83751cd6a50ad6 100644 --- a/tools/eslint/lib/rules/lines-around-comment.js +++ b/tools/eslint/lib/rules/lines-around-comment.js @@ -21,16 +21,10 @@ const lodash = require("lodash"), * @returns {Array} An array of line numbers. */ function getEmptyLineNums(lines) { - const emptyLines = lines.map(function(line, i) { - return { - code: line.trim(), - num: i + 1 - }; - }).filter(function(line) { - return !line.code; - }).map(function(line) { - return line.num; - }); + const emptyLines = lines.map((line, i) => ({ + code: line.trim(), + num: i + 1 + })).filter(line => !line.code).map(line => line.num); return emptyLines; } @@ -43,7 +37,7 @@ function getEmptyLineNums(lines) { function getCommentLineNums(comments) { const lines = []; - comments.forEach(function(token) { + comments.forEach(token => { const start = token.loc.start.line; const end = token.loc.end.line; diff --git a/tools/eslint/lib/rules/lines-around-directive.js b/tools/eslint/lib/rules/lines-around-directive.js index f0f0ebd0b9037b..b1e54e940b8f64 100644 --- a/tools/eslint/lib/rules/lines-around-directive.js +++ b/tools/eslint/lib/rules/lines-around-directive.js @@ -63,15 +63,32 @@ module.exports = { return node.loc.start.line - tokenLineBefore >= 2; } + /** + * Gets the last token of a node that is on the same line as the rest of the node. + * This will usually be the last token of the node, but it will be the second-to-last token if the node has a trailing + * semicolon on a different line. + * @param {ASTNode} node A directive node + * @returns {Token} The last token of the node on the line + */ + function getLastTokenOnLine(node) { + const lastToken = sourceCode.getLastToken(node); + const secondToLastToken = sourceCode.getTokenBefore(lastToken); + + return lastToken.type === "Punctuator" && lastToken.value === ";" && lastToken.loc.start.line > secondToLastToken.loc.end.line + ? secondToLastToken + : lastToken; + } + /** * Check if node is followed by a blank newline. * @param {ASTNode} node Node to check. * @returns {boolean} Whether or not the passed in node is followed by a blank newline. */ function hasNewlineAfter(node) { - const tokenAfter = sourceCode.getTokenOrCommentAfter(node); + const lastToken = getLastTokenOnLine(node); + const tokenAfter = sourceCode.getTokenOrCommentAfter(lastToken); - return tokenAfter.loc.start.line - node.loc.end.line >= 2; + return tokenAfter.loc.start.line - lastToken.loc.end.line >= 2; } /** @@ -91,10 +108,12 @@ module.exports = { location }, fix(fixer) { + const lastToken = getLastTokenOnLine(node); + if (expected) { - return location === "before" ? fixer.insertTextBefore(node, "\n") : fixer.insertTextAfter(node, "\n"); + return location === "before" ? fixer.insertTextBefore(node, "\n") : fixer.insertTextAfter(lastToken, "\n"); } - return fixer.removeRange(location === "before" ? [node.range[0] - 1, node.range[0]] : [node.range[1], node.range[1] + 1]); + return fixer.removeRange(location === "before" ? [node.range[0] - 1, node.range[0]] : [lastToken.range[1], lastToken.range[1] + 1]); } }); } diff --git a/tools/eslint/lib/rules/max-depth.js b/tools/eslint/lib/rules/max-depth.js index 35b7e9ce8946de..74c13ffa9fad2e 100644 --- a/tools/eslint/lib/rules/max-depth.js +++ b/tools/eslint/lib/rules/max-depth.js @@ -91,8 +91,7 @@ module.exports = { const len = ++functionStack[functionStack.length - 1]; if (len > maxDepth) { - context.report(node, "Blocks are nested too deeply ({{depth}}).", - { depth: len }); + context.report({ node, message: "Blocks are nested too deeply ({{depth}}).", data: { depth: len } }); } } diff --git a/tools/eslint/lib/rules/max-len.js b/tools/eslint/lib/rules/max-len.js index d1f6df2996f9aa..dd5a4e1ef62553 100644 --- a/tools/eslint/lib/rules/max-len.js +++ b/tools/eslint/lib/rules/max-len.js @@ -39,6 +39,9 @@ const OPTIONS_SCHEMA = { ignoreTemplateLiterals: { type: "boolean" }, + ignoreRegExpLiterals: { + type: "boolean" + }, ignoreTrailingComments: { type: "boolean" } @@ -100,7 +103,7 @@ module.exports = { function computeLineLength(line, tabWidth) { let extraCharacterCount = 0; - line.replace(/\t/g, function(match, offset) { + line.replace(/\t/g, (match, offset) => { const totalOffset = offset + extraCharacterCount, previousTabStopOffset = tabWidth ? totalOffset % tabWidth : 0, spaceCount = tabWidth - previousTabStopOffset; @@ -129,6 +132,7 @@ module.exports = { ignoreComments = options.ignoreComments || false, ignoreStrings = options.ignoreStrings || false, ignoreTemplateLiterals = options.ignoreTemplateLiterals || false, + ignoreRegExpLiterals = options.ignoreRegExpLiterals || false, ignoreTrailingComments = options.ignoreTrailingComments || options.ignoreComments || false, ignoreUrls = options.ignoreUrls || false, maxCommentLength = options.comments; @@ -209,9 +213,7 @@ module.exports = { * @returns {ASTNode[]} An array of string nodes. */ function getAllStrings() { - return sourceCode.ast.tokens.filter(function(token) { - return token.type === "String"; - }); + return sourceCode.ast.tokens.filter(token => token.type === "String"); } /** @@ -220,9 +222,17 @@ module.exports = { * @returns {ASTNode[]} An array of template literal nodes. */ function getAllTemplateLiterals() { - return sourceCode.ast.tokens.filter(function(token) { - return token.type === "Template"; - }); + return sourceCode.ast.tokens.filter(token => token.type === "Template"); + } + + + /** + * Retrieves an array containing all RegExp literals in the source code. + * + * @returns {ASTNode[]} An array of RegExp literal nodes. + */ + function getAllRegExpLiterals() { + return sourceCode.ast.tokens.filter(token => token.type === "RegularExpression"); } @@ -264,7 +274,10 @@ module.exports = { const templateLiterals = getAllTemplateLiterals(sourceCode); const templateLiteralsByLine = templateLiterals.reduce(groupByLineNumber, {}); - lines.forEach(function(line, i) { + const regExpLiterals = getAllRegExpLiterals(sourceCode); + const regExpLiteralsByLine = regExpLiterals.reduce(groupByLineNumber, {}); + + lines.forEach((line, i) => { // i is zero-indexed, line numbers are one-indexed const lineNumber = i + 1; @@ -299,7 +312,8 @@ module.exports = { if (ignorePattern && ignorePattern.test(line) || ignoreUrls && URL_REGEXP.test(line) || ignoreStrings && stringsByLine[lineNumber] || - ignoreTemplateLiterals && templateLiteralsByLine[lineNumber] + ignoreTemplateLiterals && templateLiteralsByLine[lineNumber] || + ignoreRegExpLiterals && regExpLiteralsByLine[lineNumber] ) { // ignore this line diff --git a/tools/eslint/lib/rules/max-lines.js b/tools/eslint/lib/rules/max-lines.js index a54ad9e3538dbc..08cf9f6084b2a1 100644 --- a/tools/eslint/lib/rules/max-lines.js +++ b/tools/eslint/lib/rules/max-lines.js @@ -114,26 +114,18 @@ module.exports = { return { "Program:exit"() { - let lines = sourceCode.lines.map(function(text, i) { - return { lineNumber: i + 1, text }; - }); + let lines = sourceCode.lines.map((text, i) => ({ lineNumber: i + 1, text })); if (skipBlankLines) { - lines = lines.filter(function(l) { - return l.text.trim() !== ""; - }); + lines = lines.filter(l => l.text.trim() !== ""); } if (skipComments) { const comments = sourceCode.getAllComments(); - const commentLines = lodash.flatten(comments.map(function(comment) { - return getLinesWithoutCode(comment); - })); + const commentLines = lodash.flatten(comments.map(comment => getLinesWithoutCode(comment))); - lines = lines.filter(function(l) { - return !lodash.includes(commentLines, l.lineNumber); - }); + lines = lines.filter(l => !lodash.includes(commentLines, l.lineNumber)); } if (lines.length > max) { diff --git a/tools/eslint/lib/rules/max-nested-callbacks.js b/tools/eslint/lib/rules/max-nested-callbacks.js index 7e0c3d24738862..a89f49ae02094e 100644 --- a/tools/eslint/lib/rules/max-nested-callbacks.js +++ b/tools/eslint/lib/rules/max-nested-callbacks.js @@ -81,9 +81,9 @@ module.exports = { } if (callbackStack.length > THRESHOLD) { - const opts = {num: callbackStack.length, max: THRESHOLD}; + const opts = { num: callbackStack.length, max: THRESHOLD }; - context.report(node, "Too many nested callbacks ({{num}}). Maximum allowed is {{max}}.", opts); + context.report({ node, message: "Too many nested callbacks ({{num}}). Maximum allowed is {{max}}.", data: opts }); } } diff --git a/tools/eslint/lib/rules/max-params.js b/tools/eslint/lib/rules/max-params.js index fc84efcd40b285..bbf087092e5057 100644 --- a/tools/eslint/lib/rules/max-params.js +++ b/tools/eslint/lib/rules/max-params.js @@ -66,10 +66,10 @@ module.exports = { */ function checkFunction(node) { if (node.params.length > numParams) { - context.report(node, "This function has too many parameters ({{count}}). Maximum allowed is {{max}}.", { + context.report({ node, message: "This function has too many parameters ({{count}}). Maximum allowed is {{max}}.", data: { count: node.params.length, max: numParams - }); + } }); } } diff --git a/tools/eslint/lib/rules/max-statements.js b/tools/eslint/lib/rules/max-statements.js index 1232930c6e68f1..63d51fa571b7b0 100644 --- a/tools/eslint/lib/rules/max-statements.js +++ b/tools/eslint/lib/rules/max-statements.js @@ -84,10 +84,20 @@ module.exports = { */ function reportIfTooManyStatements(node, count, max) { if (count > max) { - context.report( + const messageEnd = " has too many statements ({{count}}). Maximum allowed is {{max}}."; + let name = "This function"; + + if (node.id) { + name = `Function '${node.id.name}'`; + } else if (node.parent.type === "MethodDefinition" || node.parent.type === "Property") { + name = `Function '${context.getSource(node.parent.key)}'`; + } + + context.report({ node, - "This function has too many statements ({{count}}). Maximum allowed is {{max}}.", - { count, max }); + message: name + messageEnd, + data: { count, max } + }); } } @@ -110,7 +120,7 @@ module.exports = { const count = functionStack.pop(); if (ignoreTopLevelFunctions && functionStack.length === 0) { - topLevelFunctions.push({ node, count}); + topLevelFunctions.push({ node, count }); } else { reportIfTooManyStatements(node, count, maxStatements); } @@ -146,7 +156,7 @@ module.exports = { return; } - topLevelFunctions.forEach(function(element) { + topLevelFunctions.forEach(element => { const count = element.count; const node = element.node; diff --git a/tools/eslint/lib/rules/new-cap.js b/tools/eslint/lib/rules/new-cap.js index 6fcd582a694d1a..e7f7f1ab893396 100644 --- a/tools/eslint/lib/rules/new-cap.js +++ b/tools/eslint/lib/rules/new-cap.js @@ -227,7 +227,7 @@ module.exports = { callee = callee.property; } - context.report(node, callee.loc.start, message); + context.report({ node, loc: callee.loc.start, message }); } //-------------------------------------------------------------------------- diff --git a/tools/eslint/lib/rules/new-parens.js b/tools/eslint/lib/rules/new-parens.js index 29f4b5c2082152..b0fc5ba97950b7 100644 --- a/tools/eslint/lib/rules/new-parens.js +++ b/tools/eslint/lib/rules/new-parens.js @@ -29,20 +29,6 @@ function isClosingParen(token) { return token.type === "Punctuator" && token.value === ")"; } -/** - * Checks whether the given node is inside of another given node. - * - * @param {ASTNode|Token} inner - The inner node to check. - * @param {ASTNode|Token} outer - The outer node to check. - * @returns {boolean} `true` if the `inner` is in `outer`. - */ -function isInRange(inner, outer) { - const ir = inner.range; - const or = outer.range; - - return or[0] <= ir[0] && ir[1] <= or[1]; -} - //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -65,14 +51,15 @@ module.exports = { return { NewExpression(node) { - let token = sourceCode.getTokenAfter(node.callee); - - // Skip ')' - while (token && isClosingParen(token)) { - token = sourceCode.getTokenAfter(token); + if (node.arguments.length !== 0) { + return; // shortcut: if there are arguments, there have to be parens } - if (!(token && isOpeningParen(token) && isInRange(token, node))) { + const lastToken = sourceCode.getLastToken(node); + const hasLastParen = lastToken && isClosingParen(lastToken); + const hasParens = hasLastParen && isOpeningParen(sourceCode.getTokenBefore(lastToken)); + + if (!hasParens) { context.report({ node, message: "Missing '()' invoking a constructor.", diff --git a/tools/eslint/lib/rules/newline-after-var.js b/tools/eslint/lib/rules/newline-after-var.js index 440652b1c10696..51130e23db9ffe 100644 --- a/tools/eslint/lib/rules/newline-after-var.js +++ b/tools/eslint/lib/rules/newline-after-var.js @@ -21,7 +21,9 @@ module.exports = { { enum: ["never", "always"] } - ] + ], + + fixable: "whitespace" }, create(context) { @@ -35,7 +37,7 @@ module.exports = { const mode = context.options[0] === "never" ? "never" : "always"; // Cache starting and ending line numbers of comments for faster lookup - const commentEndLine = sourceCode.getAllComments().reduce(function(result, token) { + const commentEndLine = sourceCode.getAllComments().reduce((result, token) => { result[token.loc.start.line] = token.loc.end.line; return result; }, {}); @@ -119,6 +121,17 @@ module.exports = { return !token || (token.type === "Punctuator" && token.value === "}"); } + /** + * Gets the last line of a group of consecutive comments + * @param {number} commentStartLine The starting line of the group + * @returns {number} The number of the last comment line of the group + */ + function getLastCommentLineOfBlock(commentStartLine) { + const currentCommentEnd = commentEndLine[commentStartLine]; + + return commentEndLine[currentCommentEnd + 1] ? getLastCommentLineOfBlock(currentCommentEnd + 1) : currentCommentEnd; + } + /** * Determine if a token starts more than one line after a comment ends * @param {token} token The token being checked @@ -126,14 +139,7 @@ module.exports = { * @returns {boolean} True if `token` does not start immediately after a comment */ function hasBlankLineAfterComment(token, commentStartLine) { - const commentEnd = commentEndLine[commentStartLine]; - - // If there's another comment, repeat check for blank line - if (commentEndLine[commentEnd + 1]) { - return hasBlankLineAfterComment(token, commentEnd + 1); - } - - return (token.loc.start.line > commentEndLine[commentStartLine] + 1); + return token.loc.start.line > getLastCommentLineOfBlock(commentStartLine) + 1; } /** @@ -145,8 +151,18 @@ module.exports = { * @returns {void} */ function checkForBlankLine(node) { + + /* + * lastToken is the last token on the node's line. It will usually also be the last token of the node, but it will + * sometimes be second-last if there is a semicolon on a different line. + */ const lastToken = getLastToken(node), - nextToken = sourceCode.getTokenAfter(node), + + /* + * If lastToken is the last token of the node, nextToken should be the token after the node. Otherwise, nextToken + * is the last token of the node. + */ + nextToken = lastToken === sourceCode.getLastToken(node) ? sourceCode.getTokenAfter(node) : sourceCode.getLastToken(node), nextLineNum = lastToken.loc.end.line + 1; // Ignore if there is no following statement @@ -180,7 +196,17 @@ module.exports = { const hasNextLineComment = (typeof commentEndLine[nextLineNum] !== "undefined"); if (mode === "never" && noNextLineToken && !hasNextLineComment) { - context.report(node, NEVER_MESSAGE, { identifier: node.name }); + context.report({ + node, + message: NEVER_MESSAGE, + data: { identifier: node.name }, + fix(fixer) { + const NEWLINE_REGEX = /\r\n|\r|\n|\u2028|\u2029/; + const linesBetween = sourceCode.getText().slice(lastToken.range[1], nextToken.range[0]).split(NEWLINE_REGEX); + + return fixer.replaceTextRange([lastToken.range[1], nextToken.range[0]], `${linesBetween.slice(0, -1).join("")}\n${linesBetween[linesBetween.length - 1]}`); + } + }); } // Token on the next line, or comment without blank line @@ -190,7 +216,18 @@ module.exports = { hasNextLineComment && !hasBlankLineAfterComment(nextToken, nextLineNum) ) ) { - context.report(node, ALWAYS_MESSAGE, { identifier: node.name }); + context.report({ + node, + message: ALWAYS_MESSAGE, + data: { identifier: node.name }, + fix(fixer) { + if ((noNextLineToken ? getLastCommentLineOfBlock(nextLineNum) : lastToken.loc.end.line) === nextToken.loc.start.line) { + return fixer.insertTextBefore(nextToken, "\n\n"); + } + + return fixer.insertTextBeforeRange([nextToken.range[0] - nextToken.loc.start.column, nextToken.range[1]], "\n"); + } + }); } } diff --git a/tools/eslint/lib/rules/newline-before-return.js b/tools/eslint/lib/rules/newline-before-return.js index 7d297fd0035313..e8cd74b2c7b728 100644 --- a/tools/eslint/lib/rules/newline-before-return.js +++ b/tools/eslint/lib/rules/newline-before-return.js @@ -36,9 +36,7 @@ module.exports = { function isPrecededByTokens(node, testTokens) { const tokenBefore = sourceCode.getTokenBefore(node); - return testTokens.some(function(token) { - return tokenBefore.value === token; - }); + return testTokens.some(token => tokenBefore.value === token); } /** @@ -82,7 +80,7 @@ module.exports = { return numLinesComments; } - comments.forEach(function(comment) { + comments.forEach(comment => { numLinesComments++; if (comment.type === "Block") { diff --git a/tools/eslint/lib/rules/no-alert.js b/tools/eslint/lib/rules/no-alert.js index 96b5d64c6c4e6b..f2cfc3a87762d2 100644 --- a/tools/eslint/lib/rules/no-alert.js +++ b/tools/eslint/lib/rules/no-alert.js @@ -41,10 +41,8 @@ function report(context, node, identifierName) { * @returns {Reference|null} Returns the found reference or null if none were found. */ function findReference(scope, node) { - const references = scope.references.filter(function(reference) { - return reference.identifier.range[0] === node.range[0] && - reference.identifier.range[1] === node.range[1]; - }); + const references = scope.references.filter(reference => reference.identifier.range[0] === node.range[0] && + reference.identifier.range[1] === node.range[1]); if (references.length === 1) { return references[0]; diff --git a/tools/eslint/lib/rules/no-array-constructor.js b/tools/eslint/lib/rules/no-array-constructor.js index 2c29217d720fcc..70dc8b4cd5ded8 100644 --- a/tools/eslint/lib/rules/no-array-constructor.js +++ b/tools/eslint/lib/rules/no-array-constructor.js @@ -34,7 +34,7 @@ module.exports = { node.callee.type === "Identifier" && node.callee.name === "Array" ) { - context.report(node, "The array literal notation [] is preferrable."); + context.report({ node, message: "The array literal notation [] is preferrable." }); } } diff --git a/tools/eslint/lib/rules/no-await-in-loop.js b/tools/eslint/lib/rules/no-await-in-loop.js new file mode 100644 index 00000000000000..a75f7f2934bc23 --- /dev/null +++ b/tools/eslint/lib/rules/no-await-in-loop.js @@ -0,0 +1,75 @@ +/** + * @fileoverview Rule to disallow uses of await inside of loops. + * @author Nat Mote (nmote) + */ +"use strict"; + +// Node types which are considered loops. +const loopTypes = new Set([ + "ForStatement", + "ForOfStatement", + "ForInStatement", + "WhileStatement", + "DoWhileStatement", +]); + +// Node types at which we should stop looking for loops. For example, it is fine to declare an async +// function within a loop, and use await inside of that. +const boundaryTypes = new Set([ + "FunctionDeclaration", + "FunctionExpression", + "ArrowFunctionExpression", +]); + +module.exports = { + meta: { + docs: { + description: "disallow `await` inside of loops", + category: "Possible Errors", + recommended: false, + }, + schema: [], + }, + create(context) { + return { + AwaitExpression(node) { + const ancestors = context.getAncestors(); + + // Reverse so that we can traverse from the deepest node upwards. + ancestors.reverse(); + + // Create a set of all the ancestors plus this node so that we can check + // if this use of await appears in the body of the loop as opposed to + // the right-hand side of a for...of, for example. + const ancestorSet = new Set(ancestors).add(node); + + for (let i = 0; i < ancestors.length; i++) { + const ancestor = ancestors[i]; + + if (boundaryTypes.has(ancestor.type)) { + + // Short-circuit out if we encounter a boundary type. Loops above + // this do not matter. + return; + } + if (loopTypes.has(ancestor.type)) { + + // Only report if we are actually in the body or another part that gets executed on + // every iteration. + if ( + ancestorSet.has(ancestor.body) || + ancestorSet.has(ancestor.test) || + ancestorSet.has(ancestor.update) + ) { + context.report({ + node, + message: "Unexpected `await` inside a loop." + }); + return; + } + } + } + }, + }; + } +}; diff --git a/tools/eslint/lib/rules/no-bitwise.js b/tools/eslint/lib/rules/no-bitwise.js index 2c6456912f70f8..28028028cae090 100644 --- a/tools/eslint/lib/rules/no-bitwise.js +++ b/tools/eslint/lib/rules/no-bitwise.js @@ -57,7 +57,7 @@ module.exports = { * @returns {void} */ function report(node) { - context.report(node, "Unexpected use of '{{operator}}'.", { operator: node.operator }); + context.report({ node, message: "Unexpected use of '{{operator}}'.", data: { operator: node.operator } }); } /** diff --git a/tools/eslint/lib/rules/no-caller.js b/tools/eslint/lib/rules/no-caller.js index 16c5fa414b0cb8..55a37b7d86406a 100644 --- a/tools/eslint/lib/rules/no-caller.js +++ b/tools/eslint/lib/rules/no-caller.js @@ -29,7 +29,7 @@ module.exports = { propertyName = node.property.name; if (objectName === "arguments" && !node.computed && propertyName && propertyName.match(/^calle[er]$/)) { - context.report(node, "Avoid arguments.{{property}}.", { property: propertyName }); + context.report({ node, message: "Avoid arguments.{{property}}.", data: { property: propertyName } }); } } diff --git a/tools/eslint/lib/rules/no-catch-shadow.js b/tools/eslint/lib/rules/no-catch-shadow.js index 7f2523333239a7..7cffae3b99d758 100644 --- a/tools/eslint/lib/rules/no-catch-shadow.js +++ b/tools/eslint/lib/rules/no-catch-shadow.js @@ -58,8 +58,7 @@ module.exports = { } if (paramIsShadowing(scope, node.param.name)) { - context.report(node, "Value of '{{name}}' may be overwritten in IE 8 and earlier.", - { name: node.param.name }); + context.report({ node, message: "Value of '{{name}}' may be overwritten in IE 8 and earlier.", data: { name: node.param.name } }); } } }; diff --git a/tools/eslint/lib/rules/no-class-assign.js b/tools/eslint/lib/rules/no-class-assign.js index cbd4b1da81fe42..4b0443abc72858 100644 --- a/tools/eslint/lib/rules/no-class-assign.js +++ b/tools/eslint/lib/rules/no-class-assign.js @@ -30,11 +30,8 @@ module.exports = { * @returns {void} */ function checkVariable(variable) { - astUtils.getModifyingReferences(variable.references).forEach(function(reference) { - context.report( - reference.identifier, - "'{{name}}' is a class.", - {name: reference.identifier.name}); + astUtils.getModifyingReferences(variable.references).forEach(reference => { + context.report({ node: reference.identifier, message: "'{{name}}' is a class.", data: { name: reference.identifier.name } }); }); } diff --git a/tools/eslint/lib/rules/no-cond-assign.js b/tools/eslint/lib/rules/no-cond-assign.js index 2d66f55a5ba77b..3e94d12a539942 100644 --- a/tools/eslint/lib/rules/no-cond-assign.js +++ b/tools/eslint/lib/rules/no-cond-assign.js @@ -125,9 +125,9 @@ module.exports = { const ancestor = findConditionalAncestor(node); if (ancestor) { - context.report(ancestor, "Unexpected assignment within {{type}}.", { + context.report({ node: ancestor, message: "Unexpected assignment within {{type}}.", data: { type: NODE_DESCRIPTIONS[ancestor.type] || ancestor.type - }); + } }); } } diff --git a/tools/eslint/lib/rules/no-confusing-arrow.js b/tools/eslint/lib/rules/no-confusing-arrow.js index 5e1b051423d674..d6edbcc810e4fb 100644 --- a/tools/eslint/lib/rules/no-confusing-arrow.js +++ b/tools/eslint/lib/rules/no-confusing-arrow.js @@ -36,7 +36,7 @@ module.exports = { schema: [{ type: "object", properties: { - allowParens: {type: "boolean"} + allowParens: { type: "boolean" } }, additionalProperties: false }] @@ -55,7 +55,7 @@ module.exports = { const body = node.body; if (isConditional(body) && !(config.allowParens && astUtils.isParenthesised(sourceCode, body))) { - context.report(node, "Arrow function used ambiguously with a conditional expression."); + context.report({ node, message: "Arrow function used ambiguously with a conditional expression." }); } } diff --git a/tools/eslint/lib/rules/no-const-assign.js b/tools/eslint/lib/rules/no-const-assign.js index 232e9446fd7955..db1848a9819f00 100644 --- a/tools/eslint/lib/rules/no-const-assign.js +++ b/tools/eslint/lib/rules/no-const-assign.js @@ -30,11 +30,8 @@ module.exports = { * @returns {void} */ function checkVariable(variable) { - astUtils.getModifyingReferences(variable.references).forEach(function(reference) { - context.report( - reference.identifier, - "'{{name}}' is constant.", - {name: reference.identifier.name}); + astUtils.getModifyingReferences(variable.references).forEach(reference => { + context.report({ node: reference.identifier, message: "'{{name}}' is constant.", data: { name: reference.identifier.name } }); }); } diff --git a/tools/eslint/lib/rules/no-constant-condition.js b/tools/eslint/lib/rules/no-constant-condition.js index f78ddbc2e972b0..7178d5dbecc10e 100644 --- a/tools/eslint/lib/rules/no-constant-condition.js +++ b/tools/eslint/lib/rules/no-constant-condition.js @@ -122,7 +122,7 @@ module.exports = { */ function checkConstantCondition(node) { if (node.test && isConstant(node.test, true)) { - context.report(node, "Unexpected constant condition."); + context.report({ node, message: "Unexpected constant condition." }); } } diff --git a/tools/eslint/lib/rules/no-continue.js b/tools/eslint/lib/rules/no-continue.js index b8956da4b75025..2615fba13e2401 100644 --- a/tools/eslint/lib/rules/no-continue.js +++ b/tools/eslint/lib/rules/no-continue.js @@ -24,7 +24,7 @@ module.exports = { return { ContinueStatement(node) { - context.report(node, "Unexpected use of continue statement."); + context.report({ node, message: "Unexpected use of continue statement." }); } }; diff --git a/tools/eslint/lib/rules/no-control-regex.js b/tools/eslint/lib/rules/no-control-regex.js index 466f5666ac181f..1ebf9800009371 100644 --- a/tools/eslint/lib/rules/no-control-regex.js +++ b/tools/eslint/lib/rules/no-control-regex.js @@ -85,7 +85,7 @@ module.exports = { stringControlChars = regexStr.slice(subStrIndex, -1) .split(consecutiveSlashes) .filter(Boolean) - .map(function(x) { + .map(x => { const match = x.match(stringControlCharWithoutSlash) || [x]; return `\\${match[0]}`; @@ -93,7 +93,7 @@ module.exports = { } } - return controlChars.map(function(x) { + return controlChars.map(x => { const hexCode = `0${x.charCodeAt(0).toString(16)}`.slice(-2); return `\\x${hexCode}`; diff --git a/tools/eslint/lib/rules/no-debugger.js b/tools/eslint/lib/rules/no-debugger.js index 6356d5269b61f1..897b3dbb6094f9 100644 --- a/tools/eslint/lib/rules/no-debugger.js +++ b/tools/eslint/lib/rules/no-debugger.js @@ -24,7 +24,7 @@ module.exports = { return { DebuggerStatement(node) { - context.report(node, "Unexpected 'debugger' statement."); + context.report({ node, message: "Unexpected 'debugger' statement." }); } }; diff --git a/tools/eslint/lib/rules/no-delete-var.js b/tools/eslint/lib/rules/no-delete-var.js index dce202dc834c7e..adc1b5bb9c2c01 100644 --- a/tools/eslint/lib/rules/no-delete-var.js +++ b/tools/eslint/lib/rules/no-delete-var.js @@ -26,7 +26,7 @@ module.exports = { UnaryExpression(node) { if (node.operator === "delete" && node.argument.type === "Identifier") { - context.report(node, "Variables should not be deleted."); + context.report({ node, message: "Variables should not be deleted." }); } } }; diff --git a/tools/eslint/lib/rules/no-div-regex.js b/tools/eslint/lib/rules/no-div-regex.js index c5ffa7ce7e2e7a..84a9b9a3aaa9a6 100644 --- a/tools/eslint/lib/rules/no-div-regex.js +++ b/tools/eslint/lib/rules/no-div-regex.js @@ -29,7 +29,7 @@ module.exports = { const token = sourceCode.getFirstToken(node); if (token.type === "RegularExpression" && token.value[1] === "=") { - context.report(node, "A regular expression literal can be confused with '/='."); + context.report({ node, message: "A regular expression literal can be confused with '/='." }); } } }; diff --git a/tools/eslint/lib/rules/no-dupe-args.js b/tools/eslint/lib/rules/no-dupe-args.js index 0d420eb92aaaf9..cdb38035c0a01f 100644 --- a/tools/eslint/lib/rules/no-dupe-args.js +++ b/tools/eslint/lib/rules/no-dupe-args.js @@ -54,7 +54,7 @@ module.exports = { context.report({ node, message: "Duplicate param '{{name}}'.", - data: {name: variable.name} + data: { name: variable.name } }); } } diff --git a/tools/eslint/lib/rules/no-dupe-class-members.js b/tools/eslint/lib/rules/no-dupe-class-members.js index 3b857a67fb9e65..07b999fab19bb9 100644 --- a/tools/eslint/lib/rules/no-dupe-class-members.js +++ b/tools/eslint/lib/rules/no-dupe-class-members.js @@ -38,8 +38,8 @@ module.exports = { if (!stateMap[key]) { stateMap[key] = { - nonStatic: {init: false, get: false, set: false}, - static: {init: false, get: false, set: false} + nonStatic: { init: false, get: false, set: false }, + static: { init: false, get: false, set: false } }; } @@ -101,7 +101,7 @@ module.exports = { } if (isDuplicate) { - context.report(node, "Duplicate name '{{name}}'.", {name}); + context.report({ node, message: "Duplicate name '{{name}}'.", data: { name } }); } } }; diff --git a/tools/eslint/lib/rules/no-dupe-keys.js b/tools/eslint/lib/rules/no-dupe-keys.js index f34c323f1ed491..f056b1fcbeb43e 100644 --- a/tools/eslint/lib/rules/no-dupe-keys.js +++ b/tools/eslint/lib/rules/no-dupe-keys.js @@ -42,7 +42,7 @@ class ObjectInfo { const name = astUtils.getStaticPropertyName(node); if (!this.properties.has(name)) { - this.properties.set(name, {get: false, set: false}); + this.properties.set(name, { get: false, set: false }); } return this.properties.get(name); } @@ -123,7 +123,7 @@ module.exports = { node: info.node, loc: node.key.loc, message: "Duplicate key '{{name}}'.", - data: {name}, + data: { name }, }); } diff --git a/tools/eslint/lib/rules/no-duplicate-case.js b/tools/eslint/lib/rules/no-duplicate-case.js index 5b20fc3d582980..07823f284c1c3d 100644 --- a/tools/eslint/lib/rules/no-duplicate-case.js +++ b/tools/eslint/lib/rules/no-duplicate-case.js @@ -28,11 +28,11 @@ module.exports = { SwitchStatement(node) { const mapping = {}; - node.cases.forEach(function(switchCase) { + node.cases.forEach(switchCase => { const key = sourceCode.getText(switchCase.test); if (mapping[key]) { - context.report(switchCase, "Duplicate case label."); + context.report({ node: switchCase, message: "Duplicate case label." }); } else { mapping[key] = switchCase; } diff --git a/tools/eslint/lib/rules/no-else-return.js b/tools/eslint/lib/rules/no-else-return.js index 07b596238caf2b..43564346b043e2 100644 --- a/tools/eslint/lib/rules/no-else-return.js +++ b/tools/eslint/lib/rules/no-else-return.js @@ -33,7 +33,7 @@ module.exports = { * @returns {void} */ function displayReport(node) { - context.report(node, "Unnecessary 'else' after 'return'."); + context.report({ node, message: "Unnecessary 'else' after 'return'." }); } /** diff --git a/tools/eslint/lib/rules/no-empty-character-class.js b/tools/eslint/lib/rules/no-empty-character-class.js index 723cebc9450f00..f36c6c9f0d8b19 100644 --- a/tools/eslint/lib/rules/no-empty-character-class.js +++ b/tools/eslint/lib/rules/no-empty-character-class.js @@ -21,7 +21,7 @@ plain-English description of the following regexp: 4. `[gimuy]*`: optional regexp flags 5. `$`: fix the match at the end of the string */ -const regex = /^\/([^\\[]|\\.|\[([^\\\]]|\\.)+\])*\/[gimuy]*$/; +const regex = /^\/([^\\[]|\\.|\[([^\\\]]|\\.)+])*\/[gimuy]*$/; //------------------------------------------------------------------------------ // Rule Definition @@ -47,7 +47,7 @@ module.exports = { const token = sourceCode.getFirstToken(node); if (token.type === "RegularExpression" && !regex.test(token.value)) { - context.report(node, "Empty class."); + context.report({ node, message: "Empty class." }); } } diff --git a/tools/eslint/lib/rules/no-empty-function.js b/tools/eslint/lib/rules/no-empty-function.js index 8299f40685ca52..65f9c9e1515342 100644 --- a/tools/eslint/lib/rules/no-empty-function.js +++ b/tools/eslint/lib/rules/no-empty-function.js @@ -108,7 +108,7 @@ module.exports = { properties: { allow: { type: "array", - items: {enum: ALLOW_OPTIONS}, + items: { enum: ALLOW_OPTIONS }, uniqueItems: true } }, diff --git a/tools/eslint/lib/rules/no-empty-pattern.js b/tools/eslint/lib/rules/no-empty-pattern.js index 77302fc8d73f9d..11f50b54142e04 100644 --- a/tools/eslint/lib/rules/no-empty-pattern.js +++ b/tools/eslint/lib/rules/no-empty-pattern.js @@ -23,12 +23,12 @@ module.exports = { return { ObjectPattern(node) { if (node.properties.length === 0) { - context.report(node, "Unexpected empty object pattern."); + context.report({ node, message: "Unexpected empty object pattern." }); } }, ArrayPattern(node) { if (node.elements.length === 0) { - context.report(node, "Unexpected empty array pattern."); + context.report({ node, message: "Unexpected empty array pattern." }); } } }; diff --git a/tools/eslint/lib/rules/no-empty.js b/tools/eslint/lib/rules/no-empty.js index 8514b9cf89d0c8..a9b0776c933b07 100644 --- a/tools/eslint/lib/rules/no-empty.js +++ b/tools/eslint/lib/rules/no-empty.js @@ -63,13 +63,13 @@ module.exports = { return; } - context.report(node, "Empty block statement."); + context.report({ node, message: "Empty block statement." }); }, SwitchStatement(node) { if (typeof node.cases === "undefined" || node.cases.length === 0) { - context.report(node, "Empty switch statement."); + context.report({ node, message: "Empty switch statement." }); } } }; diff --git a/tools/eslint/lib/rules/no-eq-null.js b/tools/eslint/lib/rules/no-eq-null.js index 62215d05f1b0eb..7e915a8c726f9f 100644 --- a/tools/eslint/lib/rules/no-eq-null.js +++ b/tools/eslint/lib/rules/no-eq-null.js @@ -30,7 +30,7 @@ module.exports = { if (node.right.type === "Literal" && node.right.raw === "null" && badOperator || node.left.type === "Literal" && node.left.raw === "null" && badOperator) { - context.report(node, "Use ‘===’ to compare with ‘null’."); + context.report({ node, message: "Use ‘===’ to compare with ‘null’." }); } } }; diff --git a/tools/eslint/lib/rules/no-eval.js b/tools/eslint/lib/rules/no-eval.js index af87e4289fcc31..fe1456cba0a431 100644 --- a/tools/eslint/lib/rules/no-eval.js +++ b/tools/eslint/lib/rules/no-eval.js @@ -86,7 +86,7 @@ module.exports = { { type: "object", properties: { - allowIndirect: {type: "boolean"} + allowIndirect: { type: "boolean" } }, additionalProperties: false } diff --git a/tools/eslint/lib/rules/no-ex-assign.js b/tools/eslint/lib/rules/no-ex-assign.js index 6ffa8408677292..20869d5cd107c9 100644 --- a/tools/eslint/lib/rules/no-ex-assign.js +++ b/tools/eslint/lib/rules/no-ex-assign.js @@ -30,10 +30,8 @@ module.exports = { * @returns {void} */ function checkVariable(variable) { - astUtils.getModifyingReferences(variable.references).forEach(function(reference) { - context.report( - reference.identifier, - "Do not assign to the exception parameter."); + astUtils.getModifyingReferences(variable.references).forEach(reference => { + context.report({ node: reference.identifier, message: "Do not assign to the exception parameter." }); }); } diff --git a/tools/eslint/lib/rules/no-extend-native.js b/tools/eslint/lib/rules/no-extend-native.js index 27de9b5bd36deb..c44a2e894699e9 100644 --- a/tools/eslint/lib/rules/no-extend-native.js +++ b/tools/eslint/lib/rules/no-extend-native.js @@ -44,14 +44,10 @@ module.exports = { const config = context.options[0] || {}; const exceptions = config.exceptions || []; - let modifiedBuiltins = Object.keys(globals.builtin).filter(function(builtin) { - return builtin[0].toUpperCase() === builtin[0]; - }); + let modifiedBuiltins = Object.keys(globals.builtin).filter(builtin => builtin[0].toUpperCase() === builtin[0]); if (exceptions.length) { - modifiedBuiltins = modifiedBuiltins.filter(function(builtIn) { - return exceptions.indexOf(builtIn) === -1; - }); + modifiedBuiltins = modifiedBuiltins.filter(builtIn => exceptions.indexOf(builtIn) === -1); } return { @@ -72,7 +68,7 @@ module.exports = { return; } - modifiedBuiltins.forEach(function(builtin) { + modifiedBuiltins.forEach(builtin => { if (lhs.object.object.name === builtin) { context.report({ node, diff --git a/tools/eslint/lib/rules/no-extra-boolean-cast.js b/tools/eslint/lib/rules/no-extra-boolean-cast.js index 89a193b2d12435..123a7cacc5256a 100644 --- a/tools/eslint/lib/rules/no-extra-boolean-cast.js +++ b/tools/eslint/lib/rules/no-extra-boolean-cast.js @@ -17,10 +17,13 @@ module.exports = { recommended: true }, - schema: [] + schema: [], + + fixable: "code" }, create(context) { + const sourceCode = context.getSourceCode(); // Node types which have a test which will coerce values to booleans. const BOOLEAN_NODE_TYPES = [ @@ -70,7 +73,11 @@ module.exports = { grandparent.callee.type === "Identifier" && grandparent.callee.name === "Boolean") ) { - context.report(node, "Redundant double negation."); + context.report({ + node, + message: "Redundant double negation.", + fix: fixer => fixer.replaceText(parent, sourceCode.getText(node.argument)) + }); } }, CallExpression(node) { @@ -81,7 +88,11 @@ module.exports = { } if (isInBooleanContext(node, parent)) { - context.report(node, "Redundant Boolean call."); + context.report({ + node, + message: "Redundant Boolean call.", + fix: fixer => fixer.replaceText(node, sourceCode.getText(node.arguments[0])) + }); } } }; diff --git a/tools/eslint/lib/rules/no-extra-label.js b/tools/eslint/lib/rules/no-extra-label.js index b34e075163472d..22afbf405b7ea9 100644 --- a/tools/eslint/lib/rules/no-extra-label.js +++ b/tools/eslint/lib/rules/no-extra-label.js @@ -23,10 +23,13 @@ module.exports = { recommended: false }, - schema: [] + schema: [], + + fixable: "code" }, create(context) { + const sourceCode = context.getSourceCode(); let scopeInfo = null; /** @@ -37,7 +40,7 @@ module.exports = { */ function enterBreakableStatement(node) { scopeInfo = { - label: astUtils.getLabel(node), + label: node.parent.type === "LabeledStatement" ? node.parent.label : null, breakable: true, upper: scopeInfo }; @@ -64,7 +67,7 @@ module.exports = { function enterLabeledStatement(node) { if (!astUtils.isBreakableStatement(node.body)) { scopeInfo = { - label: node.label.name, + label: node.label, breakable: false, upper: scopeInfo }; @@ -99,22 +102,24 @@ module.exports = { } const labelNode = node.label; - const label = labelNode.name; - let info = scopeInfo; - while (info) { - if (info.breakable || info.label === label) { - if (info.breakable && info.label === label) { + for (let info = scopeInfo; info !== null; info = info.upper) { + if (info.breakable || info.label && info.label.name === labelNode.name) { + if (info.breakable && info.label && info.label.name === labelNode.name) { context.report({ node: labelNode, message: "This label '{{name}}' is unnecessary.", - data: labelNode + data: labelNode, + fix(fixer) { + return fixer.replaceTextRange( + [info.label.range[0], labelNode.range[1]], + sourceCode.text.slice(info.label.parent.body.range[0], sourceCode.getFirstToken(node).range[1]) + ); + } }); } return; } - - info = info.upper; } } diff --git a/tools/eslint/lib/rules/no-extra-parens.js b/tools/eslint/lib/rules/no-extra-parens.js index efa3d53bbd3328..004d431701a574 100644 --- a/tools/eslint/lib/rules/no-extra-parens.js +++ b/tools/eslint/lib/rules/no-extra-parens.js @@ -42,9 +42,9 @@ module.exports = { { type: "object", properties: { - conditionalAssign: {type: "boolean"}, - nestedBinaryExpressions: {type: "boolean"}, - returnAssign: {type: "boolean"} + conditionalAssign: { type: "boolean" }, + nestedBinaryExpressions: { type: "boolean" }, + returnAssign: { type: "boolean" } }, additionalProperties: false } @@ -348,12 +348,12 @@ module.exports = { report(node.callee); } if (node.arguments.length === 1) { - if (hasDoubleExcessParens(node.arguments[0]) && precedence(node.arguments[0]) >= precedence({type: "AssignmentExpression"})) { + if (hasDoubleExcessParens(node.arguments[0]) && precedence(node.arguments[0]) >= precedence({ type: "AssignmentExpression" })) { report(node.arguments[0]); } } else { - [].forEach.call(node.arguments, function(arg) { - if (hasExcessParens(arg) && precedence(arg) >= precedence({type: "AssignmentExpression"})) { + [].forEach.call(node.arguments, arg => { + if (hasExcessParens(arg) && precedence(arg) >= precedence({ type: "AssignmentExpression" })) { report(arg); } }); @@ -381,8 +381,8 @@ module.exports = { return { ArrayExpression(node) { - [].forEach.call(node.elements, function(e) { - if (e && hasExcessParens(e) && precedence(e) >= precedence({type: "AssignmentExpression"})) { + [].forEach.call(node.elements, e => { + if (e && hasExcessParens(e) && precedence(e) >= precedence({ type: "AssignmentExpression" })) { report(e); } }); @@ -394,7 +394,7 @@ module.exports = { } if (node.body.type !== "BlockStatement") { - if (sourceCode.getFirstToken(node.body).value !== "{" && hasExcessParens(node.body) && precedence(node.body) >= precedence({type: "AssignmentExpression"})) { + if (sourceCode.getFirstToken(node.body).value !== "{" && hasExcessParens(node.body) && precedence(node.body) >= precedence({ type: "AssignmentExpression" })) { report(node.body); return; } @@ -402,7 +402,6 @@ module.exports = { // Object literals *must* be parenthesised if (node.body.type === "ObjectExpression" && hasDoubleExcessParens(node.body)) { report(node.body); - return; } } }, @@ -425,15 +424,15 @@ module.exports = { return; } - if (hasExcessParens(node.test) && precedence(node.test) >= precedence({type: "LogicalExpression", operator: "||"})) { + if (hasExcessParens(node.test) && precedence(node.test) >= precedence({ type: "LogicalExpression", operator: "||" })) { report(node.test); } - if (hasExcessParens(node.consequent) && precedence(node.consequent) >= precedence({type: "AssignmentExpression"})) { + if (hasExcessParens(node.consequent) && precedence(node.consequent) >= precedence({ type: "AssignmentExpression" })) { report(node.consequent); } - if (hasExcessParens(node.alternate) && precedence(node.alternate) >= precedence({type: "AssignmentExpression"})) { + if (hasExcessParens(node.alternate) && precedence(node.alternate) >= precedence({ type: "AssignmentExpression" })) { report(node.alternate); } }, @@ -509,7 +508,7 @@ module.exports = { !( (node.object.type === "Literal" && typeof node.object.value === "number" && - /^[0-9]+$/.test(sourceCode.getFirstToken(node.object).value)) + astUtils.isDecimalInteger(node.object)) || // RegExp literal is allowed to have parens (#1589) @@ -532,10 +531,10 @@ module.exports = { NewExpression: dryCallNew, ObjectExpression(node) { - [].forEach.call(node.properties, function(e) { + [].forEach.call(node.properties, e => { const v = e.value; - if (v && hasExcessParens(v) && precedence(v) >= precedence({type: "AssignmentExpression"})) { + if (v && hasExcessParens(v) && precedence(v) >= precedence({ type: "AssignmentExpression" })) { report(v); } }); @@ -558,7 +557,7 @@ module.exports = { }, SequenceExpression(node) { - [].forEach.call(node.expressions, function(e) { + [].forEach.call(node.expressions, e => { if (hasExcessParens(e) && precedence(e) >= precedence(node)) { report(e); } @@ -591,7 +590,7 @@ module.exports = { VariableDeclarator(node) { if (node.init && hasExcessParens(node.init) && - precedence(node.init) >= precedence({type: "AssignmentExpression"}) && + precedence(node.init) >= precedence({ type: "AssignmentExpression" }) && // RegExp literal is allowed to have parens (#1589) !(node.init.type === "Literal" && node.init.regex)) { diff --git a/tools/eslint/lib/rules/no-fallthrough.js b/tools/eslint/lib/rules/no-fallthrough.js index 380a53634be1cb..30d13da06ddc8f 100644 --- a/tools/eslint/lib/rules/no-fallthrough.js +++ b/tools/eslint/lib/rules/no-fallthrough.js @@ -109,7 +109,7 @@ module.exports = { if (fallthroughCase && !hasFallthroughComment(node, context, fallthroughCommentPattern)) { context.report({ message: "Expected a 'break' statement before '{{type}}'.", - data: {type: node.test ? "case" : "default"}, + data: { type: node.test ? "case" : "default" }, node }); } diff --git a/tools/eslint/lib/rules/no-func-assign.js b/tools/eslint/lib/rules/no-func-assign.js index daa6fa52ba7301..ea86365b2914eb 100644 --- a/tools/eslint/lib/rules/no-func-assign.js +++ b/tools/eslint/lib/rules/no-func-assign.js @@ -30,11 +30,8 @@ module.exports = { * @returns {void} */ function checkReference(references) { - astUtils.getModifyingReferences(references).forEach(function(reference) { - context.report( - reference.identifier, - "'{{name}}' is a function.", - {name: reference.identifier.name}); + astUtils.getModifyingReferences(references).forEach(reference => { + context.report({ node: reference.identifier, message: "'{{name}}' is a function.", data: { name: reference.identifier.name } }); }); } diff --git a/tools/eslint/lib/rules/no-global-assign.js b/tools/eslint/lib/rules/no-global-assign.js index 2bc38cb5d70bb6..caf2500231e14a 100644 --- a/tools/eslint/lib/rules/no-global-assign.js +++ b/tools/eslint/lib/rules/no-global-assign.js @@ -23,7 +23,7 @@ module.exports = { properties: { exceptions: { type: "array", - items: {type: "string"}, + items: { type: "string" }, uniqueItems: true } }, diff --git a/tools/eslint/lib/rules/no-implicit-globals.js b/tools/eslint/lib/rules/no-implicit-globals.js index fd49f0c5ac3011..f0962cdc7a864a 100644 --- a/tools/eslint/lib/rules/no-implicit-globals.js +++ b/tools/eslint/lib/rules/no-implicit-globals.js @@ -25,27 +25,27 @@ module.exports = { Program() { const scope = context.getScope(); - scope.variables.forEach(function(variable) { + scope.variables.forEach(variable => { if (variable.writeable) { return; } - variable.defs.forEach(function(def) { + variable.defs.forEach(def => { if (def.type === "FunctionName" || (def.type === "Variable" && def.parent.kind === "var")) { - context.report(def.node, "Implicit global variable, assign as global property instead."); + context.report({ node: def.node, message: "Implicit global variable, assign as global property instead." }); } }); }); - scope.implicit.variables.forEach(function(variable) { + scope.implicit.variables.forEach(variable => { const scopeVariable = scope.set.get(variable.name); if (scopeVariable && scopeVariable.writeable) { return; } - variable.defs.forEach(function(def) { - context.report(def.node, "Implicit global variable, assign as global property instead."); + variable.defs.forEach(def => { + context.report({ node: def.node, message: "Implicit global variable, assign as global property instead." }); }); }); } diff --git a/tools/eslint/lib/rules/no-implied-eval.js b/tools/eslint/lib/rules/no-implied-eval.js index 9b48e896821363..4daadd8fb8733d 100644 --- a/tools/eslint/lib/rules/no-implied-eval.js +++ b/tools/eslint/lib/rules/no-implied-eval.js @@ -21,7 +21,7 @@ module.exports = { }, create(context) { - const CALLEE_RE = /set(?:Timeout|Interval)|execScript/; + const CALLEE_RE = /^(setTimeout|setInterval|execScript)$/; /* * Figures out if we should inspect a given binary expression. Is a stack @@ -105,7 +105,7 @@ module.exports = { // remove the entire substack, to avoid duplicate reports const substack = impliedEvalAncestorsStack.pop(); - context.report(substack[0], "Implied eval. Consider passing a function instead of a string."); + context.report({ node: substack[0], message: "Implied eval. Consider passing a function instead of a string." }); } } diff --git a/tools/eslint/lib/rules/no-inline-comments.js b/tools/eslint/lib/rules/no-inline-comments.js index d51a59a183c199..46815d15418f6a 100644 --- a/tools/eslint/lib/rules/no-inline-comments.js +++ b/tools/eslint/lib/rules/no-inline-comments.js @@ -46,7 +46,7 @@ module.exports = { // Should be empty if there was only whitespace around the comment if (!isDirective && (preamble || postamble)) { - context.report(node, "Unexpected comment inline with code."); + context.report({ node, message: "Unexpected comment inline with code." }); } } diff --git a/tools/eslint/lib/rules/no-inner-declarations.js b/tools/eslint/lib/rules/no-inner-declarations.js index e5a186133cc34e..01cc67863ffff5 100644 --- a/tools/eslint/lib/rules/no-inner-declarations.js +++ b/tools/eslint/lib/rules/no-inner-declarations.js @@ -36,8 +36,8 @@ module.exports = { generation = 1; while (ancestor && ["Program", "FunctionDeclaration", - "FunctionExpression", "ArrowFunctionExpression" - ].indexOf(ancestor.type) < 0) { + "FunctionExpression", "ArrowFunctionExpression" + ].indexOf(ancestor.type) < 0) { generation += 1; ancestor = ancestors.pop(); } @@ -63,14 +63,12 @@ module.exports = { body.distance === 2); if (!valid) { - context.report(node, "Move {{type}} declaration to {{body}} root.", - { - type: (node.type === "FunctionDeclaration" ? + context.report({ node, message: "Move {{type}} declaration to {{body}} root.", data: { + type: (node.type === "FunctionDeclaration" ? "function" : "variable"), - body: (body.type === "Program" ? + body: (body.type === "Program" ? "program" : "function body") - } - ); + } }); } } diff --git a/tools/eslint/lib/rules/no-invalid-this.js b/tools/eslint/lib/rules/no-invalid-this.js index fe2bc3a1baa647..64ef4882e252ec 100644 --- a/tools/eslint/lib/rules/no-invalid-this.js +++ b/tools/eslint/lib/rules/no-invalid-this.js @@ -114,7 +114,7 @@ module.exports = { const current = stack.getCurrent(); if (current && !current.valid) { - context.report(node, "Unexpected 'this'."); + context.report({ node, message: "Unexpected 'this'." }); } } }; diff --git a/tools/eslint/lib/rules/no-irregular-whitespace.js b/tools/eslint/lib/rules/no-irregular-whitespace.js index 74a3c10fed1c9d..b1949fbc735479 100644 --- a/tools/eslint/lib/rules/no-irregular-whitespace.js +++ b/tools/eslint/lib/rules/no-irregular-whitespace.js @@ -76,7 +76,7 @@ module.exports = { const locStart = node.loc.start; const locEnd = node.loc.end; - errors = errors.filter(function(error) { + errors = errors.filter(error => { const errorLoc = error[1]; if (errorLoc.line >= locStart.line && errorLoc.line <= locEnd.line) { @@ -142,7 +142,7 @@ module.exports = { function checkForIrregularWhitespace(node) { const sourceLines = sourceCode.lines; - sourceLines.forEach(function(sourceLine, lineIndex) { + sourceLines.forEach((sourceLine, lineIndex) => { const lineNumber = lineIndex + 1; let match; @@ -233,7 +233,7 @@ module.exports = { } // If we have any errors remaining report on them - errors.forEach(function(error) { + errors.forEach(error => { context.report.apply(context, error); }); }; diff --git a/tools/eslint/lib/rules/no-iterator.js b/tools/eslint/lib/rules/no-iterator.js index faa5153335bd76..3677dd94d9f938 100644 --- a/tools/eslint/lib/rules/no-iterator.js +++ b/tools/eslint/lib/rules/no-iterator.js @@ -29,7 +29,7 @@ module.exports = { if (node.property && (node.property.type === "Identifier" && node.property.name === "__iterator__" && !node.computed) || (node.property.type === "Literal" && node.property.value === "__iterator__")) { - context.report(node, "Reserved name '__iterator__'."); + context.report({ node, message: "Reserved name '__iterator__'." }); } } }; diff --git a/tools/eslint/lib/rules/no-label-var.js b/tools/eslint/lib/rules/no-label-var.js index 450c9a91fca893..00133685613609 100644 --- a/tools/eslint/lib/rules/no-label-var.js +++ b/tools/eslint/lib/rules/no-label-var.js @@ -57,7 +57,7 @@ module.exports = { // Recursively find the identifier walking up the scope, starting // with the innermost scope. if (findIdentifier(scope, node.label.name)) { - context.report(node, "Found identifier with same name as label."); + context.report({ node, message: "Found identifier with same name as label." }); } } diff --git a/tools/eslint/lib/rules/no-lone-blocks.js b/tools/eslint/lib/rules/no-lone-blocks.js index 9945147129cd81..9528421ca5bd39 100644 --- a/tools/eslint/lib/rules/no-lone-blocks.js +++ b/tools/eslint/lib/rules/no-lone-blocks.js @@ -34,10 +34,10 @@ module.exports = { function report(node) { const parent = context.getAncestors().pop(); - context.report(node, parent.type === "Program" ? + context.report({ node, message: parent.type === "Program" ? "Block is redundant." : "Nested block is redundant." - ); + }); } /** diff --git a/tools/eslint/lib/rules/no-lonely-if.js b/tools/eslint/lib/rules/no-lonely-if.js index 19517bc3dc491a..31f47b90e06595 100644 --- a/tools/eslint/lib/rules/no-lonely-if.js +++ b/tools/eslint/lib/rules/no-lonely-if.js @@ -55,7 +55,7 @@ module.exports = { node.consequent.type !== "BlockStatement" && lastIfToken.value !== ";" && tokenAfterElseBlock && ( node.consequent.loc.end.line === tokenAfterElseBlock.loc.start.line || - /^[(\[\/+`-]/.test(tokenAfterElseBlock.value) || + /^[([/+`-]/.test(tokenAfterElseBlock.value) || lastIfToken.value === "++" || lastIfToken.value === "--" ) diff --git a/tools/eslint/lib/rules/no-loop-func.js b/tools/eslint/lib/rules/no-loop-func.js index 6db7a95f7c7254..b8bed958652e46 100644 --- a/tools/eslint/lib/rules/no-loop-func.js +++ b/tools/eslint/lib/rules/no-loop-func.js @@ -185,7 +185,7 @@ module.exports = { if (references.length > 0 && !references.every(isSafe.bind(null, node, loopNode)) ) { - context.report(node, "Don't make functions within a loop."); + context.report({ node, message: "Don't make functions within a loop." }); } } diff --git a/tools/eslint/lib/rules/no-mixed-operators.js b/tools/eslint/lib/rules/no-mixed-operators.js index 12779f8e738c68..b066d74a0c40e0 100644 --- a/tools/eslint/lib/rules/no-mixed-operators.js +++ b/tools/eslint/lib/rules/no-mixed-operators.js @@ -62,9 +62,7 @@ function normalizeOptions(options) { * @returns {boolean} `true` if such group existed. */ function includesBothInAGroup(groups, left, right) { - return groups.some(function(group) { - return group.indexOf(left) !== -1 && group.indexOf(right) !== -1; - }); + return groups.some(group => group.indexOf(left) !== -1 && group.indexOf(right) !== -1); } //------------------------------------------------------------------------------ @@ -86,7 +84,7 @@ module.exports = { type: "array", items: { type: "array", - items: {enum: ALL_OPERATORS}, + items: { enum: ALL_OPERATORS }, minItems: 2, uniqueItems: true }, diff --git a/tools/eslint/lib/rules/no-mixed-requires.js b/tools/eslint/lib/rules/no-mixed-requires.js index 89ba345c248f61..4d51d3ab3a07a4 100644 --- a/tools/eslint/lib/rules/no-mixed-requires.js +++ b/tools/eslint/lib/rules/no-mixed-requires.js @@ -169,7 +169,7 @@ module.exports = { function isMixed(declarations) { const contains = {}; - declarations.forEach(function(declaration) { + declarations.forEach(declaration => { const type = getDeclarationType(declaration.init); contains[type] = true; @@ -190,7 +190,7 @@ module.exports = { function isGrouped(declarations) { const found = {}; - declarations.forEach(function(declaration) { + declarations.forEach(declaration => { if (getDeclarationType(declaration.init) === DECL_REQUIRE) { found[inferModuleType(declaration.init)] = true; } @@ -205,15 +205,9 @@ module.exports = { VariableDeclaration(node) { if (isMixed(node.declarations)) { - context.report( - node, - "Do not mix 'require' and other declarations." - ); + context.report({ node, message: "Do not mix 'require' and other declarations." }); } else if (grouping && !isGrouped(node.declarations)) { - context.report( - node, - "Do not mix core, module, file and computed requires." - ); + context.report({ node, message: "Do not mix core, module, file and computed requires." }); } } }; diff --git a/tools/eslint/lib/rules/no-mixed-spaces-and-tabs.js b/tools/eslint/lib/rules/no-mixed-spaces-and-tabs.js index 0e2dcb1b8a8672..2b8e89d3c87123 100644 --- a/tools/eslint/lib/rules/no-mixed-spaces-and-tabs.js +++ b/tools/eslint/lib/rules/no-mixed-spaces-and-tabs.js @@ -89,11 +89,11 @@ module.exports = { const lines = sourceCode.lines, comments = sourceCode.getAllComments(); - comments.forEach(function(comment) { + comments.forEach(comment => { ignoredLocs.push(comment.loc); }); - ignoredLocs.sort(function(first, second) { + ignoredLocs.sort((first, second) => { if (beforeLoc(first, second.start.line, second.start.column)) { return 1; } @@ -114,7 +114,7 @@ module.exports = { regex = /^(?=[\t ]* \t)/; } - lines.forEach(function(line, i) { + lines.forEach((line, i) => { const match = regex.exec(line); if (match) { @@ -132,7 +132,7 @@ module.exports = { return; } - context.report(node, { line: lineNumber, column }, "Mixed spaces and tabs."); + context.report({ node, loc: { line: lineNumber, column }, message: "Mixed spaces and tabs." }); } }); } diff --git a/tools/eslint/lib/rules/no-multi-spaces.js b/tools/eslint/lib/rules/no-multi-spaces.js index 43e26a4415353e..64eeebec55a383 100644 --- a/tools/eslint/lib/rules/no-multi-spaces.js +++ b/tools/eslint/lib/rules/no-multi-spaces.js @@ -47,7 +47,7 @@ module.exports = { lastCommentIndex = 0; if (options && options.exceptions) { - Object.keys(options.exceptions).forEach(function(key) { + Object.keys(options.exceptions).forEach(key => { if (options.exceptions[key]) { exceptions[key] = true; } else { diff --git a/tools/eslint/lib/rules/no-multi-str.js b/tools/eslint/lib/rules/no-multi-str.js index 092226f7cad355..6cf5840e30264b 100644 --- a/tools/eslint/lib/rules/no-multi-str.js +++ b/tools/eslint/lib/rules/no-multi-str.js @@ -42,7 +42,7 @@ module.exports = { const lineBreak = /\n/; if (lineBreak.test(node.raw) && !isJSXElement(node.parent)) { - context.report(node, "Multiline support is limited to browsers supporting ES5 only."); + context.report({ node, message: "Multiline support is limited to browsers supporting ES5 only." }); } } }; diff --git a/tools/eslint/lib/rules/no-multiple-empty-lines.js b/tools/eslint/lib/rules/no-multiple-empty-lines.js index 9d44064d23f1d3..c45c7aa1678927 100644 --- a/tools/eslint/lib/rules/no-multiple-empty-lines.js +++ b/tools/eslint/lib/rules/no-multiple-empty-lines.js @@ -5,6 +5,8 @@ */ "use strict"; +const astUtils = require("../ast-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -56,8 +58,6 @@ module.exports = { } const sourceCode = context.getSourceCode(); - const fullLines = sourceCode.text.match(/.*(\r\n|\r|\n|\u2028|\u2029)/g) || []; - const lineStartLocations = fullLines.reduce((startIndices, nextLine) => startIndices.concat(startIndices[startIndices.length - 1] + nextLine.length), [0]); // Swallow the final newline, as some editors add it automatically and we don't want it to cause an issue const allLines = sourceCode.lines[sourceCode.lines.length - 1] === "" ? sourceCode.lines.slice(0, -1) : sourceCode.lines; @@ -81,7 +81,12 @@ module.exports = { return allLines // Given a list of lines, first get a list of line numbers that are non-empty. - .reduce((nonEmptyLineNumbers, line, index) => nonEmptyLineNumbers.concat(line.trim() || templateLiteralLines.has(index + 1) ? [index + 1] : []), []) + .reduce((nonEmptyLineNumbers, line, index) => { + if (line.trim() || templateLiteralLines.has(index + 1)) { + nonEmptyLineNumbers.push(index + 1); + } + return nonEmptyLineNumbers; + }, []) // Add a value at the end to allow trailing empty lines to be checked. .concat(allLines.length + 1) @@ -104,10 +109,15 @@ module.exports = { if (lineNumber - lastLineNumber - 1 > maxAllowed) { context.report({ node, - loc: {start: {line: lastLineNumber + 1, column: 0}, end: {line: lineNumber, column: 0}}, + loc: { start: { line: lastLineNumber + 1, column: 0 }, end: { line: lineNumber, column: 0 } }, message, - data: {max: maxAllowed, pluralizedLines: maxAllowed === 1 ? "line" : "lines"}, - fix: fixer => fixer.removeRange([lineStartLocations[lastLineNumber], lineStartLocations[lineNumber - maxAllowed - 1]]) + data: { max: maxAllowed, pluralizedLines: maxAllowed === 1 ? "line" : "lines" }, + fix(fixer) { + return fixer.removeRange([ + astUtils.getRangeIndexFromLocation(sourceCode, { line: lastLineNumber + 1, column: 0 }), + astUtils.getRangeIndexFromLocation(sourceCode, { line: lineNumber - maxAllowed, column: 0 }) + ]); + } }); } diff --git a/tools/eslint/lib/rules/no-native-reassign.js b/tools/eslint/lib/rules/no-native-reassign.js index 2b1c41b2d100b0..f721fc278fe3ec 100644 --- a/tools/eslint/lib/rules/no-native-reassign.js +++ b/tools/eslint/lib/rules/no-native-reassign.js @@ -27,7 +27,7 @@ module.exports = { properties: { exceptions: { type: "array", - items: {type: "string"}, + items: { type: "string" }, uniqueItems: true } }, diff --git a/tools/eslint/lib/rules/no-negated-condition.js b/tools/eslint/lib/rules/no-negated-condition.js index ea8b1210774f16..8ea8559ea1c96f 100644 --- a/tools/eslint/lib/rules/no-negated-condition.js +++ b/tools/eslint/lib/rules/no-negated-condition.js @@ -69,12 +69,12 @@ module.exports = { } if (isNegatedIf(node)) { - context.report(node, "Unexpected negated condition."); + context.report({ node, message: "Unexpected negated condition." }); } }, ConditionalExpression(node) { if (isNegatedIf(node)) { - context.report(node, "Unexpected negated condition."); + context.report({ node, message: "Unexpected negated condition." }); } } }; diff --git a/tools/eslint/lib/rules/no-negated-in-lhs.js b/tools/eslint/lib/rules/no-negated-in-lhs.js index 6631336ea74d9f..143518060b33bd 100644 --- a/tools/eslint/lib/rules/no-negated-in-lhs.js +++ b/tools/eslint/lib/rules/no-negated-in-lhs.js @@ -29,7 +29,7 @@ module.exports = { BinaryExpression(node) { if (node.operator === "in" && node.left.type === "UnaryExpression" && node.left.operator === "!") { - context.report(node, "The 'in' expression's left operand is negated."); + context.report({ node, message: "The 'in' expression's left operand is negated." }); } } }; diff --git a/tools/eslint/lib/rules/no-nested-ternary.js b/tools/eslint/lib/rules/no-nested-ternary.js index 50265913b02ecf..4fe49fc9c01e58 100644 --- a/tools/eslint/lib/rules/no-nested-ternary.js +++ b/tools/eslint/lib/rules/no-nested-ternary.js @@ -26,7 +26,7 @@ module.exports = { ConditionalExpression(node) { if (node.alternate.type === "ConditionalExpression" || node.consequent.type === "ConditionalExpression") { - context.report(node, "Do not nest ternary expressions."); + context.report({ node, message: "Do not nest ternary expressions." }); } } }; diff --git a/tools/eslint/lib/rules/no-new-func.js b/tools/eslint/lib/rules/no-new-func.js index e78bcc0772a024..17ca7c9f03d6b3 100644 --- a/tools/eslint/lib/rules/no-new-func.js +++ b/tools/eslint/lib/rules/no-new-func.js @@ -34,7 +34,7 @@ module.exports = { */ function validateCallee(node) { if (node.callee.name === "Function") { - context.report(node, "The Function constructor is eval."); + context.report({ node, message: "The Function constructor is eval." }); } } diff --git a/tools/eslint/lib/rules/no-new-object.js b/tools/eslint/lib/rules/no-new-object.js index d11a2ebc615350..d4d77b55147a62 100644 --- a/tools/eslint/lib/rules/no-new-object.js +++ b/tools/eslint/lib/rules/no-new-object.js @@ -26,7 +26,7 @@ module.exports = { NewExpression(node) { if (node.callee.name === "Object") { - context.report(node, "The object literal notation {} is preferrable."); + context.report({ node, message: "The object literal notation {} is preferrable." }); } } }; diff --git a/tools/eslint/lib/rules/no-new-require.js b/tools/eslint/lib/rules/no-new-require.js index eed2028de351fa..f9ea1f84bf3bb3 100644 --- a/tools/eslint/lib/rules/no-new-require.js +++ b/tools/eslint/lib/rules/no-new-require.js @@ -26,7 +26,7 @@ module.exports = { NewExpression(node) { if (node.callee.type === "Identifier" && node.callee.name === "require") { - context.report(node, "Unexpected use of new with require."); + context.report({ node, message: "Unexpected use of new with require." }); } } }; diff --git a/tools/eslint/lib/rules/no-new-symbol.js b/tools/eslint/lib/rules/no-new-symbol.js index c65e7c9df90afb..5743a4748a9275 100644 --- a/tools/eslint/lib/rules/no-new-symbol.js +++ b/tools/eslint/lib/rules/no-new-symbol.js @@ -28,11 +28,11 @@ module.exports = { const variable = globalScope.set.get("Symbol"); if (variable && variable.defs.length === 0) { - variable.references.forEach(function(ref) { + variable.references.forEach(ref => { const node = ref.identifier; if (node.parent && node.parent.type === "NewExpression") { - context.report(node, "`Symbol` cannot be called as a constructor."); + context.report({ node, message: "`Symbol` cannot be called as a constructor." }); } }); } diff --git a/tools/eslint/lib/rules/no-new-wrappers.js b/tools/eslint/lib/rules/no-new-wrappers.js index 67e69ee0fefe0a..65bf79b87c50b3 100644 --- a/tools/eslint/lib/rules/no-new-wrappers.js +++ b/tools/eslint/lib/rules/no-new-wrappers.js @@ -28,7 +28,7 @@ module.exports = { const wrapperObjects = ["String", "Number", "Boolean", "Math", "JSON"]; if (wrapperObjects.indexOf(node.callee.name) > -1) { - context.report(node, "Do not use {{fn}} as a constructor.", { fn: node.callee.name }); + context.report({ node, message: "Do not use {{fn}} as a constructor.", data: { fn: node.callee.name } }); } } }; diff --git a/tools/eslint/lib/rules/no-new.js b/tools/eslint/lib/rules/no-new.js index 639ae22685a96b..e0f45de1bd298b 100644 --- a/tools/eslint/lib/rules/no-new.js +++ b/tools/eslint/lib/rules/no-new.js @@ -28,7 +28,7 @@ module.exports = { ExpressionStatement(node) { if (node.expression.type === "NewExpression") { - context.report(node, "Do not use 'new' for side effects."); + context.report({ node, message: "Do not use 'new' for side effects." }); } } }; diff --git a/tools/eslint/lib/rules/no-obj-calls.js b/tools/eslint/lib/rules/no-obj-calls.js index bd9b6ee4f04f76..0ca8a5effb6e86 100644 --- a/tools/eslint/lib/rules/no-obj-calls.js +++ b/tools/eslint/lib/rules/no-obj-calls.js @@ -28,8 +28,8 @@ module.exports = { if (node.callee.type === "Identifier") { const name = node.callee.name; - if (name === "Math" || name === "JSON") { - context.report(node, "'{{name}}' is not a function.", { name }); + if (name === "Math" || name === "JSON" || name === "Reflect") { + context.report({ node, message: "'{{name}}' is not a function.", data: { name } }); } } } diff --git a/tools/eslint/lib/rules/no-octal-escape.js b/tools/eslint/lib/rules/no-octal-escape.js index 25a5b022e92402..04bfb6aae3357c 100644 --- a/tools/eslint/lib/rules/no-octal-escape.js +++ b/tools/eslint/lib/rules/no-octal-escape.js @@ -36,8 +36,7 @@ module.exports = { // \0 is actually not considered an octal if (match[2] !== "0" || typeof match[3] !== "undefined") { - context.report(node, "Don't use octal: '\\{{octalDigit}}'. Use '\\u....' instead.", - { octalDigit }); + context.report({ node, message: "Don't use octal: '\\{{octalDigit}}'. Use '\\u....' instead.", data: { octalDigit } }); } } } diff --git a/tools/eslint/lib/rules/no-octal.js b/tools/eslint/lib/rules/no-octal.js index ebc5e3252d9771..58082d0d1cfb04 100644 --- a/tools/eslint/lib/rules/no-octal.js +++ b/tools/eslint/lib/rules/no-octal.js @@ -26,7 +26,7 @@ module.exports = { Literal(node) { if (typeof node.value === "number" && /^0[0-7]/.test(node.raw)) { - context.report(node, "Octal literals should not be used."); + context.report({ node, message: "Octal literals should not be used." }); } } }; diff --git a/tools/eslint/lib/rules/no-param-reassign.js b/tools/eslint/lib/rules/no-param-reassign.js index c20f340d7ab43a..31f5be3cb25972 100644 --- a/tools/eslint/lib/rules/no-param-reassign.js +++ b/tools/eslint/lib/rules/no-param-reassign.js @@ -22,7 +22,7 @@ module.exports = { { type: "object", properties: { - props: {type: "boolean"} + props: { type: "boolean" } }, additionalProperties: false } @@ -102,15 +102,9 @@ module.exports = { (index === 0 || references[index - 1].identifier !== identifier) ) { if (reference.isWrite()) { - context.report( - identifier, - "Assignment to function parameter '{{name}}'.", - {name: identifier.name}); + context.report({ node: identifier, message: "Assignment to function parameter '{{name}}'.", data: { name: identifier.name } }); } else if (props && isModifyingProp(reference)) { - context.report( - identifier, - "Assignment to property of function parameter '{{name}}'.", - {name: identifier.name}); + context.report({ node: identifier, message: "Assignment to property of function parameter '{{name}}'.", data: { name: identifier.name } }); } } } diff --git a/tools/eslint/lib/rules/no-path-concat.js b/tools/eslint/lib/rules/no-path-concat.js index 6b27678aedc8f8..1e153a43b6c683 100644 --- a/tools/eslint/lib/rules/no-path-concat.js +++ b/tools/eslint/lib/rules/no-path-concat.js @@ -39,7 +39,7 @@ module.exports = { (right.type === "Identifier" && MATCHER.test(right.name))) ) { - context.report(node, "Use path.join() or path.resolve() instead of + to create paths."); + context.report({ node, message: "Use path.join() or path.resolve() instead of + to create paths." }); } } diff --git a/tools/eslint/lib/rules/no-process-env.js b/tools/eslint/lib/rules/no-process-env.js index a2ae1fd408ac44..ef58b38e3cccd4 100644 --- a/tools/eslint/lib/rules/no-process-env.js +++ b/tools/eslint/lib/rules/no-process-env.js @@ -28,7 +28,7 @@ module.exports = { propertyName = node.property.name; if (objectName === "process" && !node.computed && propertyName && propertyName === "env") { - context.report(node, "Unexpected use of process.env."); + context.report({ node, message: "Unexpected use of process.env." }); } } diff --git a/tools/eslint/lib/rules/no-process-exit.js b/tools/eslint/lib/rules/no-process-exit.js index 69023e58e1b109..c0c2455545afab 100644 --- a/tools/eslint/lib/rules/no-process-exit.js +++ b/tools/eslint/lib/rules/no-process-exit.js @@ -33,7 +33,7 @@ module.exports = { if (callee.type === "MemberExpression" && callee.object.name === "process" && callee.property.name === "exit" ) { - context.report(node, "Don't use process.exit(); throw an error instead."); + context.report({ node, message: "Don't use process.exit(); throw an error instead." }); } } diff --git a/tools/eslint/lib/rules/no-proto.js b/tools/eslint/lib/rules/no-proto.js index 03eb88273c4bc2..933746f559cd4b 100644 --- a/tools/eslint/lib/rules/no-proto.js +++ b/tools/eslint/lib/rules/no-proto.js @@ -29,7 +29,7 @@ module.exports = { if (node.property && (node.property.type === "Identifier" && node.property.name === "__proto__" && !node.computed) || (node.property.type === "Literal" && node.property.value === "__proto__")) { - context.report(node, "The '__proto__' property is deprecated."); + context.report({ node, message: "The '__proto__' property is deprecated." }); } } }; diff --git a/tools/eslint/lib/rules/no-prototype-builtins.js b/tools/eslint/lib/rules/no-prototype-builtins.js index e9f46881597333..b9f040eaf67497 100644 --- a/tools/eslint/lib/rules/no-prototype-builtins.js +++ b/tools/eslint/lib/rules/no-prototype-builtins.js @@ -41,7 +41,7 @@ module.exports = { context.report({ message: "Do not access Object.prototype method '{{prop}}' from target object.", loc: node.callee.property.loc.start, - data: {prop: propName}, + data: { prop: propName }, node }); } diff --git a/tools/eslint/lib/rules/no-redeclare.js b/tools/eslint/lib/rules/no-redeclare.js index fcd4943460b421..deb896289b76f0 100644 --- a/tools/eslint/lib/rules/no-redeclare.js +++ b/tools/eslint/lib/rules/no-redeclare.js @@ -21,7 +21,7 @@ module.exports = { { type: "object", properties: { - builtinGlobals: {type: "boolean"} + builtinGlobals: { type: "boolean" } }, additionalProperties: false } @@ -40,20 +40,15 @@ module.exports = { * @private */ function findVariablesInScope(scope) { - scope.variables.forEach(function(variable) { + scope.variables.forEach(variable => { const hasBuiltin = options.builtinGlobals && "writeable" in variable; const count = (hasBuiltin ? 1 : 0) + variable.identifiers.length; if (count >= 2) { - variable.identifiers.sort(function(a, b) { - return a.range[1] - b.range[1]; - }); + variable.identifiers.sort((a, b) => a.range[1] - b.range[1]); for (let i = (hasBuiltin ? 0 : 1), l = variable.identifiers.length; i < l; i++) { - context.report( - variable.identifiers[i], - "'{{a}}' is already defined.", - {a: variable.name}); + context.report({ node: variable.identifiers[i], message: "'{{a}}' is already defined.", data: { a: variable.name } }); } } }); diff --git a/tools/eslint/lib/rules/no-regex-spaces.js b/tools/eslint/lib/rules/no-regex-spaces.js index c6e26ac3980020..05ac86e87a9db3 100644 --- a/tools/eslint/lib/rules/no-regex-spaces.js +++ b/tools/eslint/lib/rules/no-regex-spaces.js @@ -46,7 +46,7 @@ module.exports = { context.report({ node, message: "Spaces are hard to count. Use {{{count}}}.", - data: {count}, + data: { count }, fix(fixer) { return fixer.replaceTextRange( [valueStart + regexResults.index, valueStart + regexResults.index + count], diff --git a/tools/eslint/lib/rules/no-restricted-globals.js b/tools/eslint/lib/rules/no-restricted-globals.js index 07ff8b532d2307..603a6b2d3762ae 100644 --- a/tools/eslint/lib/rules/no-restricted-globals.js +++ b/tools/eslint/lib/rules/no-restricted-globals.js @@ -40,9 +40,9 @@ module.exports = { * @private */ function reportReference(reference) { - context.report(reference.identifier, "Unexpected use of '{{name}}'.", { + context.report({ node: reference.identifier, message: "Unexpected use of '{{name}}'.", data: { name: reference.identifier.name - }); + } }); } /** @@ -60,14 +60,14 @@ module.exports = { const scope = context.getScope(); // Report variables declared elsewhere (ex: variables defined as "global" by eslint) - scope.variables.forEach(function(variable) { + scope.variables.forEach(variable => { if (!variable.defs.length && isRestricted(variable.name)) { variable.references.forEach(reportReference); } }); // Report variables not declared at all - scope.through.forEach(function(reference) { + scope.through.forEach(reference => { if (isRestricted(reference.identifier.name)) { reportReference(reference); } diff --git a/tools/eslint/lib/rules/no-restricted-imports.js b/tools/eslint/lib/rules/no-restricted-imports.js index 87f9af2a6477e0..c245f22a0a4494 100644 --- a/tools/eslint/lib/rules/no-restricted-imports.js +++ b/tools/eslint/lib/rules/no-restricted-imports.js @@ -8,6 +8,16 @@ // Rule Definition //------------------------------------------------------------------------------ +const ignore = require("ignore"); + +const arrayOfStrings = { + type: "array", + items: { + type: "string" + }, + uniqueItems: true +}; + module.exports = { meta: { docs: { @@ -17,31 +27,55 @@ module.exports = { }, schema: { - type: "array", - items: { - type: "string" - }, - uniqueItems: true + anyOf: [ + arrayOfStrings, + { + type: "array", + items: [{ + type: "object", + properties: { + paths: arrayOfStrings, + patterns: arrayOfStrings + }, + additionalProperties: false + }], + additionalItems: false + } + ] } }, create(context) { - const restrictedImports = context.options; + const options = Array.isArray(context.options) ? context.options : []; + const isStringArray = typeof options[0] !== "object"; + const restrictedPaths = new Set(isStringArray ? context.options : options[0].paths || []); + const restrictedPatterns = isStringArray ? [] : options[0].patterns || []; // if no imports are restricted we don"t need to check - if (restrictedImports.length === 0) { + if (restrictedPaths.size === 0 && restrictedPatterns.length === 0) { return {}; } + const ig = ignore().add(restrictedPatterns); + return { ImportDeclaration(node) { if (node && node.source && node.source.value) { - const value = node.source.value.trim(); + const importName = node.source.value.trim(); - if (restrictedImports.indexOf(value) !== -1) { - context.report(node, "'{{importName}}' import is restricted from being used.", { - importName: value + if (restrictedPaths.has(importName)) { + context.report({ + node, + message: "'{{importName}}' import is restricted from being used.", + data: { importName } + }); + } + if (restrictedPatterns.length > 0 && ig.ignores(importName)) { + context.report({ + node, + message: "'{{importName}}' import is restricted from being used by a pattern.", + data: { importName } }); } } diff --git a/tools/eslint/lib/rules/no-restricted-modules.js b/tools/eslint/lib/rules/no-restricted-modules.js index 1a46c40a81dbe2..3a9634de9e18d1 100644 --- a/tools/eslint/lib/rules/no-restricted-modules.js +++ b/tools/eslint/lib/rules/no-restricted-modules.js @@ -8,6 +8,16 @@ // Rule Definition //------------------------------------------------------------------------------ +const ignore = require("ignore"); + +const arrayOfStrings = { + type: "array", + items: { + type: "string" + }, + uniqueItems: true +}; + module.exports = { meta: { docs: { @@ -17,24 +27,37 @@ module.exports = { }, schema: { - type: "array", - items: { - type: "string" - }, - uniqueItems: true + anyOf: [ + arrayOfStrings, + { + type: "array", + items: [{ + type: "object", + properties: { + paths: arrayOfStrings, + patterns: arrayOfStrings + }, + additionalProperties: false + }], + additionalItems: false + } + ] } }, create(context) { + const options = Array.isArray(context.options) ? context.options : []; + const isStringArray = typeof options[0] !== "object"; + const restrictedPaths = new Set(isStringArray ? context.options : options[0].paths || []); + const restrictedPatterns = isStringArray ? [] : options[0].patterns || []; - // trim restricted module names - const restrictedModules = context.options; - - // if no modules are restricted we don't need to check the CallExpressions - if (restrictedModules.length === 0) { + // if no imports are restricted we don"t need to check + if (restrictedPaths.size === 0 && restrictedPatterns.length === 0) { return {}; } + const ig = ignore().add(restrictedPatterns); + /** * Function to check if a node is a string literal. * @param {ASTNode} node The node to check. @@ -53,36 +76,30 @@ module.exports = { return node.callee.type === "Identifier" && node.callee.name === "require"; } - /** - * Function to check if a node has an argument that is an restricted module and return its name. - * @param {ASTNode} node The node to check - * @returns {undefined|string} restricted module name or undefined if node argument isn't restricted. - */ - function getRestrictedModuleName(node) { - let moduleName; - - // node has arguments and first argument is string - if (node.arguments.length && isString(node.arguments[0])) { - const argumentValue = node.arguments[0].value.trim(); - - // check if argument value is in restricted modules array - if (restrictedModules.indexOf(argumentValue) !== -1) { - moduleName = argumentValue; - } - } - - return moduleName; - } - return { CallExpression(node) { if (isRequireCall(node)) { - const restrictedModuleName = getRestrictedModuleName(node); - if (restrictedModuleName) { - context.report(node, "'{{moduleName}}' module is restricted from being used.", { - moduleName: restrictedModuleName - }); + // node has arguments and first argument is string + if (node.arguments.length && isString(node.arguments[0])) { + const moduleName = node.arguments[0].value.trim(); + + // check if argument value is in restricted modules array + if (restrictedPaths.has(moduleName)) { + context.report({ + node, + message: "'{{moduleName}}' module is restricted from being used.", + data: { moduleName } + }); + } + + if (restrictedPatterns.length > 0 && ig.ignores(moduleName)) { + context.report({ + node, + message: "'{{moduleName}}' module is restricted from being used by a pattern.", + data: { moduleName } + }); + } } } } diff --git a/tools/eslint/lib/rules/no-restricted-properties.js b/tools/eslint/lib/rules/no-restricted-properties.js index f8bd47ba4b2c18..b6c584c57e32e3 100644 --- a/tools/eslint/lib/rules/no-restricted-properties.js +++ b/tools/eslint/lib/rules/no-restricted-properties.js @@ -77,9 +77,9 @@ module.exports = { const propertyName = option.property; if (typeof objectName === "undefined") { - globallyRestrictedProperties.set(propertyName, {message: option.message}); + globallyRestrictedProperties.set(propertyName, { message: option.message }); } else if (typeof propertyName === "undefined") { - globallyRestrictedObjects.set(objectName, {message: option.message}); + globallyRestrictedObjects.set(objectName, { message: option.message }); } else { if (!restrictedProperties.has(objectName)) { restrictedProperties.set(objectName, new Map()); @@ -109,18 +109,18 @@ module.exports = { if (matchedObjectProperty) { const message = matchedObjectProperty.message ? ` ${matchedObjectProperty.message}` : ""; - context.report(node, "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", { + context.report({ node, message: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{message}}", data: { objectName, propertyName, message - }); + } }); } else if (globalMatchedProperty) { const message = globalMatchedProperty.message ? ` ${globalMatchedProperty.message}` : ""; - context.report(node, "'{{propertyName}}' is restricted from being used.{{message}}", { + context.report({ node, message: "'{{propertyName}}' is restricted from being used.{{message}}", data: { propertyName, message - }); + } }); } } diff --git a/tools/eslint/lib/rules/no-restricted-syntax.js b/tools/eslint/lib/rules/no-restricted-syntax.js index ab6c36923a69b0..830452d995dab4 100644 --- a/tools/eslint/lib/rules/no-restricted-syntax.js +++ b/tools/eslint/lib/rules/no-restricted-syntax.js @@ -22,9 +22,7 @@ module.exports = { type: "array", items: [ { - enum: Object.keys(nodeTypes).map(function(k) { - return nodeTypes[k]; - }) + enum: Object.keys(nodeTypes).map(k => nodeTypes[k]) } ], uniqueItems: true, @@ -40,10 +38,10 @@ module.exports = { * @returns {void} */ function warn(node) { - context.report(node, "Using '{{type}}' is not allowed.", node); + context.report({ node, message: "Using '{{type}}' is not allowed.", data: node }); } - return context.options.reduce(function(result, nodeType) { + return context.options.reduce((result, nodeType) => { result[nodeType] = warn; return result; diff --git a/tools/eslint/lib/rules/no-return-await.js b/tools/eslint/lib/rules/no-return-await.js new file mode 100644 index 00000000000000..bc0498cb044d70 --- /dev/null +++ b/tools/eslint/lib/rules/no-return-await.js @@ -0,0 +1,94 @@ +/** + * @fileoverview Disallows unnecessary `return await` + * @author Jordan Harband + */ +"use strict"; + +const astUtils = require("../ast-utils"); + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +const message = "Redundant use of `await` on a return value."; + +module.exports = { + meta: { + docs: { + description: "disallow unnecessary `return await`", + category: "Best Practices", + recommended: false // TODO: set to true + }, + fixable: false, + schema: [ + ] + }, + + create(context) { + + /** + * Reports a found unnecessary `await` expression. + * @param {ASTNode} node The node representing the `await` expression to report + * @returns {void} + */ + function reportUnnecessaryAwait(node) { + context.report({ + node: context.getSourceCode().getFirstToken(node), + loc: node.loc, + message, + }); + } + + /** + * Determines whether a thrown error from this node will be caught/handled within this function rather than immediately halting + * this function. For example, a statement in a `try` block will always have an error handler. A statement in + * a `catch` block will only have an error handler if there is also a `finally` block. + * @param {ASTNode} node A node representing a location where an could be thrown + * @returns {boolean} `true` if a thrown error will be caught/handled in this function + */ + function hasErrorHandler(node) { + let ancestor = node; + + while (!astUtils.isFunction(ancestor) && ancestor.type !== "Program") { + if (ancestor.parent.type === "TryStatement" && (ancestor === ancestor.parent.block || ancestor === ancestor.parent.handler && ancestor.parent.finalizer)) { + return true; + } + ancestor = ancestor.parent; + } + return false; + } + + /** + * Checks if a node is placed in tail call position. Once `return` arguments (or arrow function expressions) can be a complex expression, + * an `await` expression could or could not be unnecessary by the definition of this rule. So we're looking for `await` expressions that are in tail position. + * @param {ASTNode} node A node representing the `await` expression to check + * @returns {boolean} The checking result + */ + function isInTailCallPosition(node) { + if (node.parent.type === "ArrowFunctionExpression") { + return true; + } + if (node.parent.type === "ReturnStatement") { + return !hasErrorHandler(node.parent); + } + if (node.parent.type === "ConditionalExpression" && (node === node.parent.consequent || node === node.parent.alternate)) { + return isInTailCallPosition(node.parent); + } + if (node.parent.type === "LogicalExpression" && node === node.parent.right) { + return isInTailCallPosition(node.parent); + } + if (node.parent.type === "SequenceExpression" && node === node.parent.expressions[node.parent.expressions.length - 1]) { + return isInTailCallPosition(node.parent); + } + return false; + } + + return { + AwaitExpression(node) { + if (isInTailCallPosition(node) && !hasErrorHandler(node)) { + reportUnnecessaryAwait(node); + } + }, + }; + } +}; diff --git a/tools/eslint/lib/rules/no-script-url.js b/tools/eslint/lib/rules/no-script-url.js index fd2f1e8c3e8954..98f988ff1a3b96 100644 --- a/tools/eslint/lib/rules/no-script-url.js +++ b/tools/eslint/lib/rules/no-script-url.js @@ -31,7 +31,7 @@ module.exports = { const value = node.value.toLowerCase(); if (value.indexOf("javascript:") === 0) { - context.report(node, "Script URL is a form of eval."); + context.report({ node, message: "Script URL is a form of eval." }); } } } diff --git a/tools/eslint/lib/rules/no-self-compare.js b/tools/eslint/lib/rules/no-self-compare.js index 17ce77a939d53e..54f907f594be06 100644 --- a/tools/eslint/lib/rules/no-self-compare.js +++ b/tools/eslint/lib/rules/no-self-compare.js @@ -31,7 +31,7 @@ module.exports = { if (operators.indexOf(node.operator) > -1 && (node.left.type === "Identifier" && node.right.type === "Identifier" && node.left.name === node.right.name || node.left.type === "Literal" && node.right.type === "Literal" && node.left.value === node.right.value)) { - context.report(node, "Comparing to itself is potentially pointless."); + context.report({ node, message: "Comparing to itself is potentially pointless." }); } } }; diff --git a/tools/eslint/lib/rules/no-sequences.js b/tools/eslint/lib/rules/no-sequences.js index 49f20ea43ff61a..67f9d8212fd4e5 100644 --- a/tools/eslint/lib/rules/no-sequences.js +++ b/tools/eslint/lib/rules/no-sequences.js @@ -101,7 +101,7 @@ module.exports = { const child = sourceCode.getTokenAfter(node.expressions[0]); - context.report(node, child.loc.start, "Unexpected use of comma operator."); + context.report({ node, loc: child.loc.start, message: "Unexpected use of comma operator." }); } }; diff --git a/tools/eslint/lib/rules/no-shadow.js b/tools/eslint/lib/rules/no-shadow.js index 27ea10ef9217aa..e093d48c810aeb 100644 --- a/tools/eslint/lib/rules/no-shadow.js +++ b/tools/eslint/lib/rules/no-shadow.js @@ -27,8 +27,8 @@ module.exports = { { type: "object", properties: { - builtinGlobals: {type: "boolean"}, - hoist: {enum: ["all", "functions", "never"]}, + builtinGlobals: { type: "boolean" }, + hoist: { enum: ["all", "functions", "never"] }, allow: { type: "array", items: { diff --git a/tools/eslint/lib/rules/no-sparse-arrays.js b/tools/eslint/lib/rules/no-sparse-arrays.js index 31bd6f2bbffb00..3044896c612d17 100644 --- a/tools/eslint/lib/rules/no-sparse-arrays.js +++ b/tools/eslint/lib/rules/no-sparse-arrays.js @@ -33,7 +33,7 @@ module.exports = { const emptySpot = node.elements.indexOf(null) > -1; if (emptySpot) { - context.report(node, "Unexpected comma in middle of array."); + context.report({ node, message: "Unexpected comma in middle of array." }); } } diff --git a/tools/eslint/lib/rules/no-tabs.js b/tools/eslint/lib/rules/no-tabs.js index d57ac324c1d58b..19983c57ba9ed4 100644 --- a/tools/eslint/lib/rules/no-tabs.js +++ b/tools/eslint/lib/rules/no-tabs.js @@ -17,7 +17,7 @@ const regex = /\t/; module.exports = { meta: { docs: { - description: "disallow tabs in file", + description: "disallow all tabs", category: "Stylistic Issues", recommended: false }, @@ -31,14 +31,10 @@ module.exports = { const match = regex.exec(line); if (match) { - context.report( - node, - { - line: index + 1, - column: match.index + 1 - }, - "Unexpected tab character." - ); + context.report({ node, loc: { + line: index + 1, + column: match.index + 1 + }, message: "Unexpected tab character." }); } }); } diff --git a/tools/eslint/lib/rules/no-ternary.js b/tools/eslint/lib/rules/no-ternary.js index 2408cd9c39a0ea..3e254f68126f5a 100644 --- a/tools/eslint/lib/rules/no-ternary.js +++ b/tools/eslint/lib/rules/no-ternary.js @@ -25,7 +25,7 @@ module.exports = { return { ConditionalExpression(node) { - context.report(node, "Ternary operator used."); + context.report({ node, message: "Ternary operator used." }); } }; diff --git a/tools/eslint/lib/rules/no-this-before-super.js b/tools/eslint/lib/rules/no-this-before-super.js index 80a769a481a44a..c8d5dc4698d7b0 100644 --- a/tools/eslint/lib/rules/no-this-before-super.js +++ b/tools/eslint/lib/rules/no-this-before-super.js @@ -179,7 +179,7 @@ module.exports = { return; } - codePath.traverseSegments(function(segment, controller) { + codePath.traverseSegments((segment, controller) => { const info = segInfoMap[segment.id]; for (let i = 0; i < info.invalidNodes.length; ++i) { @@ -236,8 +236,8 @@ module.exports = { // Update information inside of the loop. funcInfo.codePath.traverseSegments( - {first: toSegment, last: fromSegment}, - function(segment, controller) { + { first: toSegment, last: fromSegment }, + (segment, controller) => { const info = segInfoMap[segment.id]; if (info.superCalled) { diff --git a/tools/eslint/lib/rules/no-throw-literal.js b/tools/eslint/lib/rules/no-throw-literal.js index 034361c7a620c9..0d1f42985f89ec 100644 --- a/tools/eslint/lib/rules/no-throw-literal.js +++ b/tools/eslint/lib/rules/no-throw-literal.js @@ -65,10 +65,10 @@ module.exports = { ThrowStatement(node) { if (!couldBeError(node.argument)) { - context.report(node, "Expected an object to be thrown."); + context.report({ node, message: "Expected an object to be thrown." }); } else if (node.argument.type === "Identifier") { if (node.argument.name === "undefined") { - context.report(node, "Do not throw undefined."); + context.report({ node, message: "Do not throw undefined." }); } } diff --git a/tools/eslint/lib/rules/no-undef-init.js b/tools/eslint/lib/rules/no-undef-init.js index ca9f0272ba5bf5..9df40e9cebb186 100644 --- a/tools/eslint/lib/rules/no-undef-init.js +++ b/tools/eslint/lib/rules/no-undef-init.js @@ -41,7 +41,7 @@ module.exports = { context.report({ node, message: "It's not necessary to initialize '{{name}}' to undefined.", - data: {name}, + data: { name }, fix(fixer) { if (node.id.type === "ArrayPattern" || node.id.type === "ObjectPattern") { diff --git a/tools/eslint/lib/rules/no-undef.js b/tools/eslint/lib/rules/no-undef.js index 2cd2980f840581..74a33dd9973234 100644 --- a/tools/eslint/lib/rules/no-undef.js +++ b/tools/eslint/lib/rules/no-undef.js @@ -52,7 +52,7 @@ module.exports = { "Program:exit"(/* node */) { const globalScope = context.getScope(); - globalScope.through.forEach(function(ref) { + globalScope.through.forEach(ref => { const identifier = ref.identifier; if (!considerTypeOf && hasTypeOfOperator(identifier)) { diff --git a/tools/eslint/lib/rules/no-undefined.js b/tools/eslint/lib/rules/no-undefined.js index 2aad3d0d1f4b55..18e1d98641dc86 100644 --- a/tools/eslint/lib/rules/no-undefined.js +++ b/tools/eslint/lib/rules/no-undefined.js @@ -28,7 +28,7 @@ module.exports = { const parent = context.getAncestors().pop(); if (!parent || parent.type !== "MemberExpression" || node !== parent.property || parent.computed) { - context.report(node, "Unexpected use of undefined."); + context.report({ node, message: "Unexpected use of undefined." }); } } } diff --git a/tools/eslint/lib/rules/no-underscore-dangle.js b/tools/eslint/lib/rules/no-underscore-dangle.js index abc5967b5348be..6803cc68fc7e81 100644 --- a/tools/eslint/lib/rules/no-underscore-dangle.js +++ b/tools/eslint/lib/rules/no-underscore-dangle.js @@ -57,9 +57,7 @@ module.exports = { * @private */ function isAllowed(identifier) { - return ALLOWED_VARIABLES.some(function(ident) { - return ident === identifier; - }); + return ALLOWED_VARIABLES.some(ident => ident === identifier); } /** diff --git a/tools/eslint/lib/rules/no-unexpected-multiline.js b/tools/eslint/lib/rules/no-unexpected-multiline.js index 5208813dadada0..bae4833983b14e 100644 --- a/tools/eslint/lib/rules/no-unexpected-multiline.js +++ b/tools/eslint/lib/rules/no-unexpected-multiline.js @@ -45,7 +45,7 @@ module.exports = { } if (openParen.loc.start.line !== nodeExpressionEnd.loc.end.line) { - context.report(node, openParen.loc.start, msg, { char: openParen.value }); + context.report({ node, loc: openParen.loc.start, message: msg, data: { char: openParen.value } }); } } @@ -66,7 +66,7 @@ module.exports = { if (node.tag.loc.end.line === node.quasi.loc.start.line) { return; } - context.report(node, node.loc.start, TAGGED_TEMPLATE_MESSAGE); + context.report({ node, loc: node.loc.start, message: TAGGED_TEMPLATE_MESSAGE }); }, CallExpression(node) { diff --git a/tools/eslint/lib/rules/no-unneeded-ternary.js b/tools/eslint/lib/rules/no-unneeded-ternary.js index c755f5f4b4fd11..cba83ea48140ec 100644 --- a/tools/eslint/lib/rules/no-unneeded-ternary.js +++ b/tools/eslint/lib/rules/no-unneeded-ternary.js @@ -5,6 +5,19 @@ "use strict"; +const astUtils = require("../ast-utils"); + +// Operators that always result in a boolean value +const BOOLEAN_OPERATORS = new Set(["==", "===", "!=", "!==", ">", ">=", "<", "<=", "in", "instanceof"]); +const OPERATOR_INVERSES = { + "==": "!=", + "!=": "==", + "===": "!==", + "!==": "===" + + // Operators like < and >= are not true inverses, since both will return false with NaN. +}; + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ @@ -27,12 +40,15 @@ module.exports = { }, additionalProperties: false } - ] + ], + + fixable: "code" }, create(context) { const options = context.options[0] || {}; const defaultAssignment = options.defaultAssignment !== false; + const sourceCode = context.getSourceCode(); /** * Test if the node is a boolean literal @@ -44,6 +60,34 @@ module.exports = { return node.type === "Literal" && typeof node.value === "boolean"; } + /** + * Creates an expression that represents the boolean inverse of the expression represented by the original node + * @param {ASTNode} node A node representing an expression + * @returns {string} A string representing an inverted expression + */ + function invertExpression(node) { + if (node.type === "BinaryExpression" && Object.prototype.hasOwnProperty.call(OPERATOR_INVERSES, node.operator)) { + const operatorToken = sourceCode.getTokensBetween(node.left, node.right).find(token => token.value === node.operator); + + return sourceCode.getText().slice(node.range[0], operatorToken.range[0]) + OPERATOR_INVERSES[node.operator] + sourceCode.getText().slice(operatorToken.range[1], node.range[1]); + } + + if (astUtils.getPrecedence(node) < astUtils.getPrecedence({ type: "UnaryExpression" })) { + return `!(${astUtils.getParenthesisedText(sourceCode, node)})`; + } + return `!${astUtils.getParenthesisedText(sourceCode, node)}`; + } + + /** + * Tests if a given node always evaluates to a boolean value + * @param {ASTNode} node - An expression node + * @returns {boolean} True if it is determined that the node will always evaluate to a boolean value + */ + function isBooleanExpression(node) { + return node.type === "BinaryExpression" && BOOLEAN_OPERATORS.has(node.operator) || + node.type === "UnaryExpression" && node.operator === "!"; + } + /** * Test if the node matches the pattern id ? id : expression * @param {ASTNode} node - The ConditionalExpression to check. @@ -60,9 +104,34 @@ module.exports = { ConditionalExpression(node) { if (isBooleanLiteral(node.alternate) && isBooleanLiteral(node.consequent)) { - context.report(node, node.consequent.loc.start, "Unnecessary use of boolean literals in conditional expression."); + context.report({ + node, + loc: node.consequent.loc.start, + message: "Unnecessary use of boolean literals in conditional expression.", + fix(fixer) { + if (node.consequent.value === node.alternate.value) { + + // Replace `foo ? true : true` with just `true`, but don't replace `foo() ? true : true` + return node.test.type === "Identifier" ? fixer.replaceText(node, node.consequent.value.toString()) : null; + } + if (node.alternate.value) { + + // Replace `foo() ? false : true` with `!(foo())` + return fixer.replaceText(node, invertExpression(node.test)); + } + + // Replace `foo ? true : false` with `foo` if `foo` is guaranteed to be a boolean, or `!!foo` otherwise. + + return fixer.replaceText(node, isBooleanExpression(node.test) ? astUtils.getParenthesisedText(sourceCode, node.test) : `!${invertExpression(node.test)}`); + } + }); } else if (!defaultAssignment && matchesDefaultAssignment(node)) { - context.report(node, node.consequent.loc.start, "Unnecessary use of conditional expression for default assignment."); + context.report({ + node, + loc: node.consequent.loc.start, + message: "Unnecessary use of conditional expression for default assignment.", + fix: fixer => fixer.replaceText(node, `${astUtils.getParenthesisedText(sourceCode, node.test)} || ${astUtils.getParenthesisedText(sourceCode, node.alternate)}`) + }); } } }; diff --git a/tools/eslint/lib/rules/no-unused-expressions.js b/tools/eslint/lib/rules/no-unused-expressions.js index cdabca204a64df..548e02f463e71a 100644 --- a/tools/eslint/lib/rules/no-unused-expressions.js +++ b/tools/eslint/lib/rules/no-unused-expressions.js @@ -108,7 +108,7 @@ module.exports = { return { ExpressionStatement(node) { if (!isValidExpression(node.expression) && !isDirective(node, context.getAncestors())) { - context.report(node, "Expected an assignment or function call and instead saw an expression."); + context.report({ node, message: "Expected an assignment or function call and instead saw an expression." }); } } }; diff --git a/tools/eslint/lib/rules/no-unused-vars.js b/tools/eslint/lib/rules/no-unused-vars.js index 683176e944f357..ac8f2ed1c0a20a 100644 --- a/tools/eslint/lib/rules/no-unused-vars.js +++ b/tools/eslint/lib/rules/no-unused-vars.js @@ -156,28 +156,6 @@ module.exports = { return false; } - /** - * Checks whether a given node is inside of a loop or not. - * - * @param {ASTNode} node - A node to check. - * @returns {boolean} `true` if the node is inside of a loop. - * @private - */ - function isInsideOfLoop(node) { - while (node) { - if (astUtils.isLoop(node)) { - return true; - } - if (astUtils.isFunction(node)) { - return false; - } - - node = node.parent; - } - - return false; - } - /** * Checks the position of given nodes. * @@ -215,7 +193,7 @@ module.exports = { const granpa = parent.parent; const refScope = ref.from.variableScope; const varScope = ref.resolved.scope.variableScope; - const canBeUsedLater = refScope !== varScope || isInsideOfLoop(id); + const canBeUsedLater = refScope !== varScope || astUtils.isInLoop(id); /* * Inherits the previous node if this reference is in the node. @@ -390,15 +368,11 @@ module.exports = { * @private */ function isUsedVariable(variable) { - const functionNodes = variable.defs.filter(function(def) { - return def.type === "FunctionName"; - }).map(function(def) { - return def.node; - }), + const functionNodes = variable.defs.filter(def => def.type === "FunctionName").map(def => def.node), isFunctionDefinition = functionNodes.length > 0; let rhsNode = null; - return variable.references.some(function(ref) { + return variable.references.some(ref => { if (isForInRef(ref)) { return true; } diff --git a/tools/eslint/lib/rules/no-use-before-define.js b/tools/eslint/lib/rules/no-use-before-define.js index 01c899ca3920c4..ea1cf301f29af4 100644 --- a/tools/eslint/lib/rules/no-use-before-define.js +++ b/tools/eslint/lib/rules/no-use-before-define.js @@ -29,7 +29,7 @@ function parseOptions(options) { classes = options.classes !== false; } - return {functions, classes}; + return { functions, classes }; } /** @@ -154,8 +154,8 @@ module.exports = { { type: "object", properties: { - functions: {type: "boolean"}, - classes: {type: "boolean"} + functions: { type: "boolean" }, + classes: { type: "boolean" } }, additionalProperties: false } @@ -187,7 +187,7 @@ module.exports = { * @private */ function findVariablesInScope(scope) { - scope.references.forEach(function(reference) { + scope.references.forEach(reference => { const variable = reference.resolved; // Skips when the reference is: diff --git a/tools/eslint/lib/rules/no-useless-call.js b/tools/eslint/lib/rules/no-useless-call.js index 2be665992a08e5..eb67bcb3b25271 100644 --- a/tools/eslint/lib/rules/no-useless-call.js +++ b/tools/eslint/lib/rules/no-useless-call.js @@ -96,10 +96,7 @@ module.exports = { const thisArg = node.arguments[0]; if (isValidThisArg(expectedThis, thisArg, sourceCode)) { - context.report( - node, - "unnecessary '.{{name}}()'.", - {name: node.callee.property.name}); + context.report({ node, message: "unnecessary '.{{name}}()'.", data: { name: node.callee.property.name } }); } } }; diff --git a/tools/eslint/lib/rules/no-useless-concat.js b/tools/eslint/lib/rules/no-useless-concat.js index d9cf6a2c354b8b..ed0ef66a2441e1 100644 --- a/tools/eslint/lib/rules/no-useless-concat.js +++ b/tools/eslint/lib/rules/no-useless-concat.js @@ -93,10 +93,11 @@ module.exports = { operatorToken = sourceCode.getTokenAfter(operatorToken); } - context.report( + context.report({ node, - operatorToken.loc.start, - "Unexpected string concatenation of literals."); + loc: operatorToken.loc.start, + message: "Unexpected string concatenation of literals." + }); } } }; diff --git a/tools/eslint/lib/rules/no-useless-escape.js b/tools/eslint/lib/rules/no-useless-escape.js index 629a52a7ec9b9f..b9266bbbafa69a 100644 --- a/tools/eslint/lib/rules/no-useless-escape.js +++ b/tools/eslint/lib/rules/no-useless-escape.js @@ -5,57 +5,70 @@ "use strict"; +const astUtils = require("../ast-utils"); + //------------------------------------------------------------------------------ // Rule Definition //------------------------------------------------------------------------------ -const VALID_STRING_ESCAPES = [ - "\\", - "n", - "r", - "v", - "t", - "b", - "f", - "u", - "x", - "\n", - "\r" -]; - -const VALID_REGEX_ESCAPES = [ - "\\", - ".", - "-", - "^", - "$", - "*", - "+", - "?", - "{", - "}", - "[", - "]", - "|", - "(", - ")", - "b", - "B", - "c", - "d", - "D", - "f", - "n", - "r", - "s", - "S", - "t", - "v", - "w", - "W", - "x", - "u" -]; +/** +* Returns the union of two sets. +* @param {Set} setA The first set +* @param {Set} setB The second set +* @returns {Set} The union of the two sets +*/ +function union(setA, setB) { + return new Set(function *() { + yield* setA; + yield* setB; + }()); +} + +const VALID_STRING_ESCAPES = new Set("\\nrvtbfux\n\r\u2028\u2029"); +const REGEX_GENERAL_ESCAPES = new Set("\\bcdDfnrsStvwWxu0123456789]"); +const REGEX_NON_CHARCLASS_ESCAPES = union(REGEX_GENERAL_ESCAPES, new Set("^/.$*+?[{}|()B")); + +/** +* Parses a regular expression into a list of characters with character class info. +* @param {string} regExpText The raw text used to create the regular expression +* @returns {Object[]} A list of characters, each with info on escaping and whether they're in a character class. +* @example +* +* parseRegExp('a\\b[cd-]') +* +* returns: +* [ +* {text: 'a', index: 0, escaped: false, inCharClass: false, startsCharClass: false, endsCharClass: false}, +* {text: 'b', index: 2, escaped: true, inCharClass: false, startsCharClass: false, endsCharClass: false}, +* {text: 'c', index: 4, escaped: false, inCharClass: true, startsCharClass: true, endsCharClass: false}, +* {text: 'd', index: 5, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false}, +* {text: '-', index: 6, escaped: false, inCharClass: true, startsCharClass: false, endsCharClass: false} +* ] +*/ +function parseRegExp(regExpText) { + const charList = []; + + regExpText.split("").reduce((state, char, index) => { + if (!state.escapeNextChar) { + if (char === "\\") { + return Object.assign(state, { escapeNextChar: true }); + } + if (char === "[" && !state.inCharClass) { + return Object.assign(state, { inCharClass: true, startingCharClass: true }); + } + if (char === "]" && state.inCharClass) { + if (charList.length && charList[charList.length - 1].inCharClass) { + charList[charList.length - 1].endsCharClass = true; + } + return Object.assign(state, { inCharClass: false, startingCharClass: false }); + } + } + charList.push({ text: char, index, escaped: state.escapeNextChar, inCharClass: state.inCharClass, startsCharClass: state.startingCharClass, endsCharClass: false }); + return Object.assign(state, { escapeNextChar: false, startingCharClass: false }); + }, { escapeNextChar: false, inCharClass: false, startingCharClass: false }); + + return charList; +} module.exports = { meta: { @@ -69,20 +82,36 @@ module.exports = { }, create(context) { + const sourceCode = context.getSourceCode(); + + /** + * Reports a node + * @param {ASTNode} node The node to report + * @param {number} startOffset The backslash's offset from the start of the node + * @param {string} character The uselessly escaped character (not including the backslash) + * @returns {void} + */ + function report(node, startOffset, character) { + context.report({ + node, + loc: astUtils.getLocationFromRangeIndex(sourceCode, astUtils.getRangeIndexFromLocation(sourceCode, node.loc.start) + startOffset), + message: "Unnecessary escape character: \\{{character}}.", + data: { character } + }); + } /** - * Checks if the escape character in given slice is unnecessary. + * Checks if the escape character in given string slice is unnecessary. * * @private - * @param {string[]} escapes - list of valid escapes * @param {ASTNode} node - node to validate. * @param {string} match - string slice to validate. * @returns {void} */ - function validate(escapes, node, match) { + function validateString(node, match) { const isTemplateElement = node.type === "TemplateElement"; const escapedChar = match[0][1]; - let isUnnecessaryEscape = escapes.indexOf(escapedChar) === -1; + let isUnnecessaryEscape = !VALID_STRING_ESCAPES.has(escapedChar); let isQuoteEscape; if (isTemplateElement) { @@ -105,17 +134,7 @@ module.exports = { } if (isUnnecessaryEscape && !isQuoteEscape) { - context.report({ - node, - loc: { - line: node.loc.start.line, - column: node.loc.start.column + match.index - }, - message: "Unnecessary escape character: {{character}}.", - data: { - character: match[0] - } - }); + report(node, match.index + 1, match[0].slice(1)); } } @@ -127,10 +146,12 @@ module.exports = { */ function check(node) { const isTemplateElement = node.type === "TemplateElement"; - const value = isTemplateElement ? node.value.raw : node.raw; - const pattern = /\\[^\d]/g; - let nodeEscapes, - match; + + if (isTemplateElement && node.parent && node.parent.parent && node.parent.parent.type === "TaggedTemplateExpression") { + + // Don't report tagged template literals, because the backslash character is accessible to the tag function. + return; + } if (typeof node.value === "string" || isTemplateElement) { @@ -138,20 +159,46 @@ module.exports = { * JSXAttribute doesn't have any escape sequence: https://facebook.github.io/jsx/. * In addition, backticks are not supported by JSX yet: https://github.com/facebook/jsx/issues/25. */ - if (node.parent.type === "JSXAttribute") { + if (node.parent.type === "JSXAttribute" || node.parent.type === "JSXElement") { return; } - nodeEscapes = VALID_STRING_ESCAPES; + const value = isTemplateElement ? node.value.raw : node.raw.slice(1, -1); + const pattern = /\\[^\d]/g; + let match; + + while ((match = pattern.exec(value))) { + validateString(node, match); + } } else if (node.regex) { - nodeEscapes = VALID_REGEX_ESCAPES; - } else { - return; - } + parseRegExp(node.regex.pattern) - while ((match = pattern.exec(value))) { - validate(nodeEscapes, node, match); + /* + * The '-' character is a special case, because it's only valid to escape it if it's in a character + * class, and is not at either edge of the character class. To account for this, don't consider '-' + * characters to be valid in general, and filter out '-' characters that appear in the middle of a + * character class. + */ + .filter(charInfo => !(charInfo.text === "-" && charInfo.inCharClass && !charInfo.startsCharClass && !charInfo.endsCharClass)) + + /* + * The '^' character is also a special case; it must always be escaped outside of character classes, but + * it only needs to be escaped in character classes if it's at the beginning of the character class. To + * account for this, consider it to be a valid escape character outside of character classes, and filter + * out '^' characters that appear at the start of a character class. + */ + .filter(charInfo => !(charInfo.text === "^" && charInfo.startsCharClass)) + + // Filter out characters that aren't escaped. + .filter(charInfo => charInfo.escaped) + + // Filter out characters that are valid to escape, based on their position in the regular expression. + .filter(charInfo => !(charInfo.inCharClass ? REGEX_GENERAL_ESCAPES : REGEX_NON_CHARCLASS_ESCAPES).has(charInfo.text)) + + // Report all the remaining characters. + .forEach(charInfo => report(node, charInfo.index, charInfo.text)); } + } return { diff --git a/tools/eslint/lib/rules/no-useless-return.js b/tools/eslint/lib/rules/no-useless-return.js new file mode 100644 index 00000000000000..e2a6da03183501 --- /dev/null +++ b/tools/eslint/lib/rules/no-useless-return.js @@ -0,0 +1,293 @@ +/** + * @fileoverview Disallow redundant return statements + * @author Teddy Katz + */ +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const astUtils = require("../ast-utils"); + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +/** + * Adds all elements of 2nd argument into 1st argument. + * + * @param {Array} array - The destination array to add. + * @param {Array} elements - The source array to add. + * @returns {void} + */ +const pushAll = Function.apply.bind(Array.prototype.push); + +/** + * Removes the given element from the array. + * + * @param {Array} array - The source array to remove. + * @param {any} element - The target item to remove. + * @returns {void} + */ +function remove(array, element) { + const index = array.indexOf(element); + + if (index !== -1) { + array.splice(index, 1); + } +} + +/** + * Checks whether it can remove the given return statement or not. + * + * @param {ASTNode} node - The return statement node to check. + * @returns {boolean} `true` if the node is removeable. + */ +function isRemovable(node) { + const parent = node.parent; + + return ( + parent.type === "Program" || + parent.type === "BlockStatement" || + parent.type === "SwitchCase" + ); +} + +/** + * Checks whether the given return statement is in a `finally` block or not. + * + * @param {ASTNode} node - The return statement node to check. + * @returns {boolean} `true` if the node is in a `finally` block. + */ +function isInFinally(node) { + while (node && node.parent && !astUtils.isFunction(node)) { + if (node.parent.type === "TryStatement" && node.parent.finalizer === node) { + return true; + } + + node = node.parent; + } + + return false; +} + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + docs: { + description: "disallow redundant return statements", + category: "Best Practices", + recommended: false + }, + fixable: "code", + schema: [] + }, + + create(context) { + const segmentInfoMap = new WeakMap(); + const usedUnreachableSegments = new WeakSet(); + let scopeInfo = null; + + /** + * Checks whether the given segment is terminated by a return statement or not. + * + * @param {CodePathSegment} segment - The segment to check. + * @returns {boolean} `true` if the segment is terminated by a return statement, or if it's still a part of unreachable. + */ + function isReturned(segment) { + const info = segmentInfoMap.get(segment); + + return !info || info.returned; + } + + /** + * Collects useless return statements from the given previous segments. + * + * A previous segment may be an unreachable segment. + * In that case, the information object of the unreachable segment is not + * initialized because `onCodePathSegmentStart` event is not notified for + * unreachable segments. + * This goes to the previous segments of the unreachable segment recursively + * if the unreachable segment was generated by a return statement. Otherwise, + * this ignores the unreachable segment. + * + * This behavior would simulate code paths for the case that the return + * statement does not exist. + * + * @param {ASTNode[]} uselessReturns - The collected return statements. + * @param {CodePathSegment[]} prevSegments - The previous segments to traverse. + * @param {WeakSet} [traversedSegments] A set of segments that have already been traversed in this call + * @returns {ASTNode[]} `uselessReturns`. + */ + function getUselessReturns(uselessReturns, prevSegments, traversedSegments) { + if (!traversedSegments) { + traversedSegments = new WeakSet(); + } + for (const segment of prevSegments) { + if (!segment.reachable) { + if (!traversedSegments.has(segment)) { + traversedSegments.add(segment); + getUselessReturns( + uselessReturns, + segment.allPrevSegments.filter(isReturned), + traversedSegments + ); + } + continue; + } + + pushAll(uselessReturns, segmentInfoMap.get(segment).uselessReturns); + } + + return uselessReturns; + } + + /** + * Removes the return statements on the given segment from the useless return + * statement list. + * + * This segment may be an unreachable segment. + * In that case, the information object of the unreachable segment is not + * initialized because `onCodePathSegmentStart` event is not notified for + * unreachable segments. + * This goes to the previous segments of the unreachable segment recursively + * if the unreachable segment was generated by a return statement. Otherwise, + * this ignores the unreachable segment. + * + * This behavior would simulate code paths for the case that the return + * statement does not exist. + * + * @param {CodePathSegment} segment - The segment to get return statements. + * @returns {void} + */ + function markReturnStatementsOnSegmentAsUsed(segment) { + if (!segment.reachable) { + usedUnreachableSegments.add(segment); + segment.allPrevSegments + .filter(isReturned) + .filter(prevSegment => !usedUnreachableSegments.has(prevSegment)) + .forEach(markReturnStatementsOnSegmentAsUsed); + return; + } + + const info = segmentInfoMap.get(segment); + + for (const node of info.uselessReturns) { + remove(scopeInfo.uselessReturns, node); + } + info.uselessReturns = []; + } + + /** + * Removes the return statements on the current segments from the useless + * return statement list. + * + * This function will be called at every statement except FunctionDeclaration, + * BlockStatement, and BreakStatement. + * + * - FunctionDeclarations are always executed whether it's returned or not. + * - BlockStatements do nothing. + * - BreakStatements go the next merely. + * + * @returns {void} + */ + function markReturnStatementsOnCurrentSegmentsAsUsed() { + scopeInfo + .codePath + .currentSegments + .forEach(markReturnStatementsOnSegmentAsUsed); + } + + //---------------------------------------------------------------------- + // Public + //---------------------------------------------------------------------- + + return { + + // Makes and pushs a new scope information. + onCodePathStart(codePath) { + scopeInfo = { + upper: scopeInfo, + uselessReturns: [], + codePath, + }; + }, + + // Reports useless return statements if exist. + onCodePathEnd() { + for (const node of scopeInfo.uselessReturns) { + context.report({ + node, + loc: node.loc, + message: "Unnecessary return statement.", + fix(fixer) { + return isRemovable(node) ? fixer.remove(node) : null; + }, + }); + } + + scopeInfo = scopeInfo.upper; + }, + + // Initializes segments. + // NOTE: This event is notified for only reachable segments. + onCodePathSegmentStart(segment) { + const info = { + uselessReturns: getUselessReturns([], segment.allPrevSegments), + returned: false, + }; + + // Stores the info. + segmentInfoMap.set(segment, info); + }, + + // Adds ReturnStatement node to check whether it's useless or not. + ReturnStatement(node) { + if (node.argument) { + markReturnStatementsOnCurrentSegmentsAsUsed(); + } + if (node.argument || astUtils.isInLoop(node) || isInFinally(node)) { + return; + } + + for (const segment of scopeInfo.codePath.currentSegments) { + const info = segmentInfoMap.get(segment); + + if (info) { + info.uselessReturns.push(node); + info.returned = true; + } + } + scopeInfo.uselessReturns.push(node); + }, + + // Registers for all statement nodes except FunctionDeclaration, BlockStatement, BreakStatement. + // Removes return statements of the current segments from the useless return statement list. + ClassDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, + ContinueStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + DebuggerStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + DoWhileStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + EmptyStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + ExpressionStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + ForInStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + ForOfStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + ForStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + IfStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + ImportDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, + LabeledStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + SwitchStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + ThrowStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + TryStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + VariableDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, + WhileStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + WithStatement: markReturnStatementsOnCurrentSegmentsAsUsed, + ExportNamedDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, + ExportDefaultDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, + ExportAllDeclaration: markReturnStatementsOnCurrentSegmentsAsUsed, + }; + } +}; diff --git a/tools/eslint/lib/rules/no-var.js b/tools/eslint/lib/rules/no-var.js index 0e98170e65e7c1..3c22f009c63bb6 100644 --- a/tools/eslint/lib/rules/no-var.js +++ b/tools/eslint/lib/rules/no-var.js @@ -5,10 +5,67 @@ "use strict"; +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const astUtils = require("../ast-utils"); + //------------------------------------------------------------------------------ // Helpers //------------------------------------------------------------------------------ +/** + * Finds the nearest function scope or global scope walking up the scope + * hierarchy. + * + * @param {escope.Scope} scope - The scope to traverse. + * @returns {escope.Scope} a function scope or global scope containing the given + * scope. + */ +function getEnclosingFunctionScope(scope) { + while (scope.type !== "function" && scope.type !== "global") { + scope = scope.upper; + } + return scope; +} + +/** + * Checks whether the given variable has any references from a more specific + * function expression (i.e. a closure). + * + * @param {escope.Variable} variable - A variable to check. + * @returns {boolean} `true` if the variable is used from a closure. + */ +function isReferencedInClosure(variable) { + const enclosingFunctionScope = getEnclosingFunctionScope(variable.scope); + + return variable.references.some(reference => + getEnclosingFunctionScope(reference.from) !== enclosingFunctionScope); +} + +/** + * Checks whether the given node is the assignee of a loop. + * + * @param {ASTNode} node - A VariableDeclaration node to check. + * @returns {boolean} `true` if the declaration is assigned as part of loop + * iteration. + */ +function isLoopAssignee(node) { + return (node.parent.type === "ForOfStatement" || node.parent.type === "ForInStatement") && + node === node.parent.left; +} + +/** + * Checks whether the given variable declaration is immediately initialized. + * + * @param {ASTNode} node - A VariableDeclaration node to check. + * @returns {boolean} `true` if the declaration has an initializer. + */ +function isDeclarationInitialized(node) { + return node.declarations.every(declarator => declarator.init !== null); +} + const SCOPE_NODE_TYPE = /^(?:Program|BlockStatement|SwitchStatement|ForStatement|ForInStatement|ForOfStatement)$/; /** @@ -97,6 +154,8 @@ module.exports = { * - A variable is declared on a SwitchCase node. * - A variable is redeclared. * - A variable is used from outside the scope. + * - A variable is used from a closure within a loop. + * - A variable might be used before it is assigned within a loop. * * ## A variable is declared on a SwitchCase node. * @@ -115,6 +174,25 @@ module.exports = { * The language spec disallows accesses from outside of the scope for * `let` declarations. Those variables would cause reference errors. * + * ## A variable is used from a closure within a loop. + * + * A `var` declaration within a loop shares the same variable instance + * across all loop iterations, while a `let` declaration creates a new + * instance for each iteration. This means if a variable in a loop is + * referenced by any closure, changing it from `var` to `let` would + * change the behavior in a way that is generally unsafe. + * + * ## A variable might be used before it is assigned within a loop. + * + * Within a loop, a `let` declaration without an initializer will be + * initialized to null, while a `var` declaration will retain its value + * from the previous iteration, so it is only safe to change `var` to + * `let` if we can statically determine that the variable is always + * assigned a value before its first access in the loop body. To keep + * the implementation simple, we only convert `var` to `let` within + * loops when the variable is a loop assignee or the declaration has an + * initializer. + * * @param {ASTNode} node - A variable declaration node to check. * @returns {boolean} `true` if it can fix the node. */ @@ -122,11 +200,22 @@ module.exports = { const variables = context.getDeclaredVariables(node); const scopeNode = getScopeNode(node); - return !( - node.parent.type === "SwitchCase" || - variables.some(isRedeclared) || - variables.some(isUsedFromOutsideOf(scopeNode)) - ); + if (node.parent.type === "SwitchCase" || + variables.some(isRedeclared) || + variables.some(isUsedFromOutsideOf(scopeNode))) { + return false; + } + + if (astUtils.isInLoop(node)) { + if (variables.some(isReferencedInClosure)) { + return false; + } + if (!isLoopAssignee(node) && !isDeclarationInitialized(node)) { + return false; + } + } + + return true; } /** diff --git a/tools/eslint/lib/rules/no-void.js b/tools/eslint/lib/rules/no-void.js index 16a36fb3a56df1..5202fa49a8543a 100644 --- a/tools/eslint/lib/rules/no-void.js +++ b/tools/eslint/lib/rules/no-void.js @@ -28,7 +28,7 @@ module.exports = { return { UnaryExpression(node) { if (node.operator === "void") { - context.report(node, "Expected 'undefined' and instead saw 'void'."); + context.report({ node, message: "Expected 'undefined' and instead saw 'void'." }); } } }; diff --git a/tools/eslint/lib/rules/no-warning-comments.js b/tools/eslint/lib/rules/no-warning-comments.js index 511bd9bb48d6ed..bda43086865a1c 100644 --- a/tools/eslint/lib/rules/no-warning-comments.js +++ b/tools/eslint/lib/rules/no-warning-comments.js @@ -54,7 +54,7 @@ module.exports = { * @returns {RegExp} The term converted to a RegExp */ function convertToRegExp(term) { - const escaped = term.replace(/[-\/\\$\^*+?.()|\[\]{}]/g, "\\$&"); + const escaped = term.replace(/[-/\\$^*+?.()|[\]{}]/g, "\\$&"); let prefix; /* @@ -95,7 +95,7 @@ module.exports = { function commentContainsWarningTerm(comment) { const matches = []; - warningRegExps.forEach(function(regex, index) { + warningRegExps.forEach((regex, index) => { if (regex.test(comment)) { matches.push(warningTerms[index]); } @@ -116,7 +116,7 @@ module.exports = { const matches = commentContainsWarningTerm(node.value); - matches.forEach(function(matchedTerm) { + matches.forEach(matchedTerm => { context.report({ node, message: "Unexpected '{{matchedTerm}}' comment.", diff --git a/tools/eslint/lib/rules/no-with.js b/tools/eslint/lib/rules/no-with.js index 6d5bfd8e61605e..be9e3463606404 100644 --- a/tools/eslint/lib/rules/no-with.js +++ b/tools/eslint/lib/rules/no-with.js @@ -24,7 +24,7 @@ module.exports = { return { WithStatement(node) { - context.report(node, "Unexpected use of 'with' statement."); + context.report({ node, message: "Unexpected use of 'with' statement." }); } }; diff --git a/tools/eslint/lib/rules/object-curly-newline.js b/tools/eslint/lib/rules/object-curly-newline.js index 3ba786a6f1e2c2..88fc79463cb6ae 100644 --- a/tools/eslint/lib/rules/object-curly-newline.js +++ b/tools/eslint/lib/rules/object-curly-newline.js @@ -61,7 +61,7 @@ function normalizeOptionValue(value) { multiline = true; } - return {multiline, minProperties}; + return { multiline, minProperties }; } /** @@ -80,7 +80,7 @@ function normalizeOptions(options) { const value = normalizeOptionValue(options); - return {ObjectExpression: value, ObjectPattern: value}; + return { ObjectExpression: value, ObjectPattern: value }; } //------------------------------------------------------------------------------ diff --git a/tools/eslint/lib/rules/object-property-newline.js b/tools/eslint/lib/rules/object-property-newline.js index f06cb41843e534..a64420be93a910 100644 --- a/tools/eslint/lib/rules/object-property-newline.js +++ b/tools/eslint/lib/rules/object-property-newline.js @@ -27,7 +27,9 @@ module.exports = { }, additionalProperties: false } - ] + ], + + fixable: "whitespace" }, create(context) { @@ -61,7 +63,18 @@ module.exports = { context.report({ node, loc: firstTokenOfCurrentProperty.loc.start, - message: errorMessage + message: errorMessage, + fix(fixer) { + const comma = sourceCode.getTokenBefore(firstTokenOfCurrentProperty); + const rangeAfterComma = [comma.range[1], firstTokenOfCurrentProperty.range[0]]; + + // Don't perform a fix if there are any comments between the comma and the next property. + if (sourceCode.text.slice(rangeAfterComma[0], rangeAfterComma[1]).trim()) { + return null; + } + + return fixer.replaceTextRange(rangeAfterComma, "\n"); + } }); } } diff --git a/tools/eslint/lib/rules/object-shorthand.js b/tools/eslint/lib/rules/object-shorthand.js index 3ef782461a4018..43997f90692de5 100644 --- a/tools/eslint/lib/rules/object-shorthand.js +++ b/tools/eslint/lib/rules/object-shorthand.js @@ -77,6 +77,9 @@ module.exports = { }, avoidQuotes: { type: "boolean" + }, + avoidExplicitReturnArrows: { + type: "boolean" } }, additionalProperties: false @@ -100,6 +103,8 @@ module.exports = { const PARAMS = context.options[1] || {}; const IGNORE_CONSTRUCTORS = PARAMS.ignoreConstructors; const AVOID_QUOTES = PARAMS.avoidQuotes; + const AVOID_EXPLICIT_RETURN_ARROWS = !!PARAMS.avoidExplicitReturnArrows; + const sourceCode = context.getSourceCode(); //-------------------------------------------------------------------------- // Helpers @@ -188,7 +193,7 @@ module.exports = { // We have at least 1 shorthand property if (shorthandProperties.length > 0) { - context.report(node, "Unexpected mix of shorthand and non-shorthand properties."); + context.report({ node, message: "Unexpected mix of shorthand and non-shorthand properties." }); } else if (checkRedundancy) { // If all properties of the object contain a method or value with a name matching it's key, @@ -196,18 +201,143 @@ module.exports = { const canAlwaysUseShorthand = properties.every(isRedundant); if (canAlwaysUseShorthand) { - context.report(node, "Expected shorthand for all properties."); + context.report({ node, message: "Expected shorthand for all properties." }); } } } } } + /** + * Fixes a FunctionExpression node by making it into a shorthand property. + * @param {SourceCodeFixer} fixer The fixer object + * @param {ASTNode} node A `Property` node that has a `FunctionExpression` or `ArrowFunctionExpression` as its value + * @returns {Object} A fix for this node + */ + function makeFunctionShorthand(fixer, node) { + const firstKeyToken = node.computed ? sourceCode.getTokens(node).find(token => token.value === "[") : sourceCode.getFirstToken(node.key); + const lastKeyToken = node.computed ? sourceCode.getTokensBetween(node.key, node.value).find(token => token.value === "]") : sourceCode.getLastToken(node.key); + const keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]); + let keyPrefix = ""; + + if (node.value.generator) { + keyPrefix = "*"; + } else if (node.value.async) { + keyPrefix = "async "; + } + + if (node.value.type === "FunctionExpression") { + const functionToken = sourceCode.getTokens(node.value).find(token => token.type === "Keyword" && token.value === "function"); + const tokenBeforeParams = node.value.generator ? sourceCode.getTokenAfter(functionToken) : functionToken; + + return fixer.replaceTextRange([firstKeyToken.range[0], tokenBeforeParams.range[1]], keyPrefix + keyText); + } else { + const arrowToken = sourceCode.getTokens(node.value).find(token => token.value === "=>"); + const tokenBeforeArrow = sourceCode.getTokenBefore(arrowToken); + const hasParensAroundParameters = tokenBeforeArrow.type === "Punctuator" && tokenBeforeArrow.value === ")"; + const oldParamText = sourceCode.text.slice(sourceCode.getFirstToken(node.value, node.value.async ? 1 : 0).range[0], tokenBeforeArrow.range[1]); + const newParamText = hasParensAroundParameters ? oldParamText : `(${oldParamText})`; + + return fixer.replaceTextRange([firstKeyToken.range[0], arrowToken.range[1]], keyPrefix + keyText + newParamText); + } + } + + /** + * Fixes a FunctionExpression node by making it into a longform property. + * @param {SourceCodeFixer} fixer The fixer object + * @param {ASTNode} node A `Property` node that has a `FunctionExpression` as its value + * @returns {Object} A fix for this node + */ + function makeFunctionLongform(fixer, node) { + const firstKeyToken = node.computed ? sourceCode.getTokens(node).find(token => token.value === "[") : sourceCode.getFirstToken(node.key); + const lastKeyToken = node.computed ? sourceCode.getTokensBetween(node.key, node.value).find(token => token.value === "]") : sourceCode.getLastToken(node.key); + const keyText = sourceCode.text.slice(firstKeyToken.range[0], lastKeyToken.range[1]); + let functionHeader = "function"; + + if (node.value.generator) { + functionHeader = "function*"; + } else if (node.value.async) { + functionHeader = "async function"; + } + + return fixer.replaceTextRange([node.range[0], lastKeyToken.range[1]], `${keyText}: ${functionHeader}`); + } + + /* + * To determine whether a given arrow function has a lexical identifier (`this`, `arguments`, `super`, or `new.target`), + * create a stack of functions that define these identifiers (i.e. all functions except arrow functions) as the AST is + * traversed. Whenever a new function is encountered, create a new entry on the stack (corresponding to a different lexical + * scope of `this`), and whenever a function is exited, pop that entry off the stack. When an arrow function is entered, + * keep a reference to it on the current stack entry, and remove that reference when the arrow function is exited. + * When a lexical identifier is encountered, mark all the arrow functions on the current stack entry by adding them + * to an `arrowsWithLexicalIdentifiers` set. Any arrow function in that set will not be reported by this rule, + * because converting it into a method would change the value of one of the lexical identifiers. + */ + const lexicalScopeStack = []; + const arrowsWithLexicalIdentifiers = new WeakSet(); + const argumentsIdentifiers = new WeakSet(); + + /** + * Enters a function. This creates a new lexical identifier scope, so a new Set of arrow functions is pushed onto the stack. + * Also, this marks all `arguments` identifiers so that they can be detected later. + * @returns {void} + */ + function enterFunction() { + lexicalScopeStack.unshift(new Set()); + context.getScope().variables.filter(variable => variable.name === "arguments").forEach(variable => { + variable.references.map(ref => ref.identifier).forEach(identifier => argumentsIdentifiers.add(identifier)); + }); + } + + /** + * Exits a function. This pops the current set of arrow functions off the lexical scope stack. + * @returns {void} + */ + function exitFunction() { + lexicalScopeStack.shift(); + } + + /** + * Marks the current function as having a lexical keyword. This implies that all arrow functions + * in the current lexical scope contain a reference to this lexical keyword. + * @returns {void} + */ + function reportLexicalIdentifier() { + lexicalScopeStack[0].forEach(arrowFunction => arrowsWithLexicalIdentifiers.add(arrowFunction)); + } + //-------------------------------------------------------------------------- // Public //-------------------------------------------------------------------------- return { + Program: enterFunction, + FunctionDeclaration: enterFunction, + FunctionExpression: enterFunction, + "Program:exit": exitFunction, + "FunctionDeclaration:exit": exitFunction, + "FunctionExpression:exit": exitFunction, + + ArrowFunctionExpression(node) { + lexicalScopeStack[0].add(node); + }, + "ArrowFunctionExpression:exit"(node) { + lexicalScopeStack[0].delete(node); + }, + + ThisExpression: reportLexicalIdentifier, + Super: reportLexicalIdentifier, + MetaProperty(node) { + if (node.meta.name === "new" && node.property.name === "target") { + reportLexicalIdentifier(); + } + }, + Identifier(node) { + if (argumentsIdentifiers.has(node)) { + reportLexicalIdentifier(); + } + }, + ObjectExpression(node) { if (APPLY_CONSISTENT) { checkConsistency(node, false); @@ -216,7 +346,7 @@ module.exports = { } }, - Property(node) { + "Property:exit"(node) { const isConciseProperty = node.method || node.shorthand; // Ignore destructuring assignment @@ -230,59 +360,31 @@ module.exports = { } // only computed methods can fail the following checks - if (node.computed && node.value.type !== "FunctionExpression") { + if (node.computed && node.value.type !== "FunctionExpression" && node.value.type !== "ArrowFunctionExpression") { return; } //-------------------------------------------------------------- // Checks for property/method shorthand. if (isConciseProperty) { + if (node.method && (APPLY_NEVER || AVOID_QUOTES && isStringLiteral(node.key))) { - // if we're "never" and concise we should warn now - if (APPLY_NEVER) { - const type = node.method ? "method" : "property"; - + // { x() {} } should be written as { x: function() {} } context.report({ node, - message: "Expected longform {{type}} syntax.", - data: { - type - }, - fix(fixer) { - if (node.method) { - if (node.value.generator) { - return fixer.replaceTextRange([node.range[0], node.key.range[1]], `${node.key.name}: function*`); - } - - return fixer.insertTextAfter(node.key, ": function"); - } - - return fixer.insertTextAfter(node.key, `: ${node.key.name}`); - } + message: `Expected longform method syntax${APPLY_NEVER ? "" : " for string literal keys"}.`, + fix: fixer => makeFunctionLongform(fixer, node) }); - } + } else if (APPLY_NEVER) { - // {'xyz'() {}} should be written as {'xyz': function() {}} - if (AVOID_QUOTES && isStringLiteral(node.key)) { + // { x } should be written as { x: x } context.report({ node, - message: "Expected longform method syntax for string literal keys.", - fix(fixer) { - if (node.computed) { - return fixer.insertTextAfterRange([node.key.range[0], node.key.range[1] + 1], ": function"); - } - - return fixer.insertTextAfter(node.key, ": function"); - } + message: "Expected longform property syntax.", + fix: fixer => fixer.insertTextAfter(node.key, `: ${node.key.name}`) }); } - - return; - } - - //-------------------------------------------------------------- - // Checks for longform properties. - if (node.value.type === "FunctionExpression" && !node.value.id && APPLY_TO_METHODS) { + } else if (APPLY_TO_METHODS && !node.value.id && (node.value.type === "FunctionExpression" || node.value.type === "ArrowFunctionExpression")) { if (IGNORE_CONSTRUCTORS && isConstructor(node.key.name)) { return; } @@ -291,39 +393,18 @@ module.exports = { } // {[x]: function(){}} should be written as {[x]() {}} - if (node.computed) { + if (node.value.type === "FunctionExpression" || + node.value.type === "ArrowFunctionExpression" && + node.value.body.type === "BlockStatement" && + AVOID_EXPLICIT_RETURN_ARROWS && + !arrowsWithLexicalIdentifiers.has(node.value) + ) { context.report({ node, message: "Expected method shorthand.", - fix(fixer) { - if (node.value.generator) { - return fixer.replaceTextRange( - [node.key.range[0], node.value.range[0] + "function*".length], - `*[${node.key.name}]` - ); - } - - return fixer.removeRange([node.key.range[1] + 1, node.value.range[0] + "function".length]); - } + fix: fixer => makeFunctionShorthand(fixer, node) }); - return; } - - // {x: function(){}} should be written as {x() {}} - context.report({ - node, - message: "Expected method shorthand.", - fix(fixer) { - if (node.value.generator) { - return fixer.replaceTextRange( - [node.key.range[0], node.value.range[0] + "function*".length], - `*${node.key.name}` - ); - } - - return fixer.removeRange([node.key.range[1], node.value.range[0] + "function".length]); - } - }); } else if (node.value.type === "Identifier" && node.key.name === node.value.name && APPLY_TO_PROPS) { // {x: x} should be written as {x} diff --git a/tools/eslint/lib/rules/one-var-declaration-per-line.js b/tools/eslint/lib/rules/one-var-declaration-per-line.js index eb0d5c3bf1ad74..61b505c82d5d71 100644 --- a/tools/eslint/lib/rules/one-var-declaration-per-line.js +++ b/tools/eslint/lib/rules/one-var-declaration-per-line.js @@ -59,7 +59,7 @@ module.exports = { const declarations = node.declarations; let prev; - declarations.forEach(function(current) { + declarations.forEach(current => { if (prev && prev.loc.end.line === current.loc.start.line) { if (always || prev.init || current.init) { context.report({ diff --git a/tools/eslint/lib/rules/one-var.js b/tools/eslint/lib/rules/one-var.js index 27166559714065..9e40d4ea6f26c1 100644 --- a/tools/eslint/lib/rules/one-var.js +++ b/tools/eslint/lib/rules/one-var.js @@ -66,18 +66,18 @@ module.exports = { }; if (typeof mode === "string") { // simple options configuration with just a string - options.var = { uninitialized: mode, initialized: mode}; - options.let = { uninitialized: mode, initialized: mode}; - options.const = { uninitialized: mode, initialized: mode}; + options.var = { uninitialized: mode, initialized: mode }; + options.let = { uninitialized: mode, initialized: mode }; + options.const = { uninitialized: mode, initialized: mode }; } else if (typeof mode === "object") { // options configuration is an object if (mode.hasOwnProperty("var") && typeof mode.var === "string") { - options.var = { uninitialized: mode.var, initialized: mode.var}; + options.var = { uninitialized: mode.var, initialized: mode.var }; } if (mode.hasOwnProperty("let") && typeof mode.let === "string") { - options.let = { uninitialized: mode.let, initialized: mode.let}; + options.let = { uninitialized: mode.let, initialized: mode.let }; } if (mode.hasOwnProperty("const") && typeof mode.const === "string") { - options.const = { uninitialized: mode.const, initialized: mode.const}; + options.const = { uninitialized: mode.const, initialized: mode.const }; } if (mode.hasOwnProperty("uninitialized")) { if (!options.var) { @@ -123,8 +123,8 @@ module.exports = { */ function startBlock() { blockStack.push({ - let: {initialized: false, uninitialized: false}, - const: {initialized: false, uninitialized: false} + let: { initialized: false, uninitialized: false }, + const: { initialized: false, uninitialized: false } }); } @@ -134,7 +134,7 @@ module.exports = { * @private */ function startFunction() { - functionStack.push({initialized: false, uninitialized: false}); + functionStack.push({ initialized: false, uninitialized: false }); startBlock(); } diff --git a/tools/eslint/lib/rules/operator-assignment.js b/tools/eslint/lib/rules/operator-assignment.js index 5e1dd97b996bc7..e003478c7bc427 100644 --- a/tools/eslint/lib/rules/operator-assignment.js +++ b/tools/eslint/lib/rules/operator-assignment.js @@ -70,6 +70,17 @@ function same(a, b) { } } +/** +* Determines if the left side of a node can be safely fixed (i.e. if it activates the same getters/setters and) +* toString calls regardless of whether assignment shorthand is used) +* @param {ASTNode} node The node on the left side of the expression +* @returns {boolean} `true` if the node can be fixed +*/ +function canBeFixed(node) { + return node.type === "Identifier" || + node.type === "MemberExpression" && node.object.type === "Identifier" && (!node.computed || node.property.type === "Literal"); +} + module.exports = { meta: { docs: { @@ -82,11 +93,24 @@ module.exports = { { enum: ["always", "never"] } - ] + ], + + fixable: "code" }, create(context) { + const sourceCode = context.getSourceCode(); + + /** + * Returns the operator token of an AssignmentExpression or BinaryExpression + * @param {ASTNode} node An AssignmentExpression or BinaryExpression node + * @returns {Token} The operator token in the node + */ + function getOperatorToken(node) { + return sourceCode.getTokensBetween(node.left, node.right).find(token => token.value === node.operator); + } + /** * Ensures that an assignment uses the shorthand form where possible. * @param {ASTNode} node An AssignmentExpression node. @@ -101,13 +125,34 @@ module.exports = { const expr = node.right; const operator = expr.operator; - if (isCommutativeOperatorWithShorthand(operator)) { - if (same(left, expr.left) || same(left, expr.right)) { - context.report(node, "Assignment can be replaced with operator assignment."); - } - } else if (isNonCommutativeOperatorWithShorthand(operator)) { + if (isCommutativeOperatorWithShorthand(operator) || isNonCommutativeOperatorWithShorthand(operator)) { if (same(left, expr.left)) { - context.report(node, "Assignment can be replaced with operator assignment."); + context.report({ + node, + message: "Assignment can be replaced with operator assignment.", + fix(fixer) { + if (canBeFixed(left)) { + const equalsToken = getOperatorToken(node); + const operatorToken = getOperatorToken(expr); + const leftText = sourceCode.getText().slice(node.range[0], equalsToken.range[0]); + const rightText = sourceCode.getText().slice(operatorToken.range[1], node.range[1]); + + return fixer.replaceText(node, `${leftText}${expr.operator}=${rightText}`); + } + return null; + } + }); + } else if (same(left, expr.right) && isCommutativeOperatorWithShorthand(operator)) { + + /* + * This case can't be fixed safely. + * If `a` and `b` both have custom valueOf() behavior, then fixing `a = b * a` to `a *= b` would + * change the execution order of the valueOf() functions. + */ + context.report({ + node, + message: "Assignment can be replaced with operator assignment." + }); } } } @@ -119,7 +164,20 @@ module.exports = { */ function prohibit(node) { if (node.operator !== "=") { - context.report(node, "Unexpected operator assignment shorthand."); + context.report({ + node, + message: "Unexpected operator assignment shorthand.", + fix(fixer) { + if (canBeFixed(node.left)) { + const operatorToken = getOperatorToken(node); + const leftText = sourceCode.getText().slice(node.range[0], operatorToken.range[0]); + const rightText = sourceCode.getText().slice(operatorToken.range[1], node.range[1]); + + return fixer.replaceText(node, `${leftText}= ${leftText}${node.operator.slice(0, -1)}${rightText}`); + } + return null; + } + }); } } diff --git a/tools/eslint/lib/rules/operator-linebreak.js b/tools/eslint/lib/rules/operator-linebreak.js index ce222526e1d410..c8f2b2818e23b2 100644 --- a/tools/eslint/lib/rules/operator-linebreak.js +++ b/tools/eslint/lib/rules/operator-linebreak.js @@ -11,6 +11,8 @@ const astUtils = require("../ast-utils"); // Rule Definition //------------------------------------------------------------------------------ +const LINEBREAK_REGEX = /\r\n|\r|\n|\u2028|\u2029/g; + module.exports = { meta: { docs: { @@ -38,7 +40,9 @@ module.exports = { }, additionalProperties: false } - ] + ], + + fixable: "code" }, create(context) { @@ -62,6 +66,61 @@ module.exports = { // Helpers //-------------------------------------------------------------------------- + /** + * Gets a fixer function to fix rule issues + * @param {Token} operatorToken The operator token of an expression + * @param {string} desiredStyle The style for the rule. One of 'before', 'after', 'none' + * @returns {Function} A fixer function + */ + function getFixer(operatorToken, desiredStyle) { + return fixer => { + const tokenBefore = sourceCode.getTokenBefore(operatorToken); + const tokenAfter = sourceCode.getTokenAfter(operatorToken); + const textBefore = sourceCode.text.slice(tokenBefore.range[1], operatorToken.range[0]); + const textAfter = sourceCode.text.slice(operatorToken.range[1], tokenAfter.range[0]); + const hasLinebreakBefore = !astUtils.isTokenOnSameLine(tokenBefore, operatorToken); + const hasLinebreakAfter = !astUtils.isTokenOnSameLine(operatorToken, tokenAfter); + let newTextBefore, newTextAfter; + + if (hasLinebreakBefore !== hasLinebreakAfter && desiredStyle !== "none") { + + // If there is a comment before and after the operator, don't do a fix. + if (sourceCode.getTokenOrCommentBefore(operatorToken) !== tokenBefore && sourceCode.getTokenOrCommentAfter(operatorToken) !== tokenAfter) { + return null; + } + + /* + * If there is only one linebreak and it's on the wrong side of the operator, swap the text before and after the operator. + * foo && + * bar + * would get fixed to + * foo + * && bar + */ + newTextBefore = textAfter; + newTextAfter = textBefore; + } else { + + // Otherwise, if no linebreak is desired and no comments interfere, replace the linebreaks with empty strings. + newTextBefore = desiredStyle === "before" || textBefore.trim() ? textBefore : textBefore.replace(LINEBREAK_REGEX, ""); + newTextAfter = desiredStyle === "after" || textAfter.trim() ? textAfter : textAfter.replace(LINEBREAK_REGEX, ""); + + // If there was no change (due to interfering comments), don't output a fix. + if (newTextBefore === textBefore && newTextAfter === textAfter) { + return null; + } + } + + if (newTextAfter === "" && tokenAfter.type === "Punctuator" && "+-".includes(operatorToken.value) && tokenAfter.value === operatorToken.value) { + + // To avoid accidentally creating a ++ or -- operator, insert a space if the operator is a +/- and the following token is a unary +/-. + newTextAfter += " "; + } + + return fixer.replaceTextRange([tokenBefore.range[1], tokenAfter.range[0]], newTextBefore + operatorToken.value + newTextAfter); + }; + } + /** * Checks the operator placement * @param {ASTNode} node The node to check @@ -87,12 +146,13 @@ module.exports = { const operator = operatorToken.value; const operatorStyleOverride = styleOverrides[operator]; const style = operatorStyleOverride || globalStyle; + const fix = getFixer(operatorToken, style); // if single line if (astUtils.isTokenOnSameLine(leftToken, operatorToken) && astUtils.isTokenOnSameLine(operatorToken, rightToken)) { - return; + // do nothing. } else if (operatorStyleOverride !== "ignore" && !astUtils.isTokenOnSameLine(leftToken, operatorToken) && !astUtils.isTokenOnSameLine(operatorToken, rightToken)) { @@ -107,7 +167,8 @@ module.exports = { message: "Bad line breaking before and after '{{operator}}'.", data: { operator - } + }, + fix }); } else if (style === "before" && astUtils.isTokenOnSameLine(leftToken, operatorToken)) { @@ -121,7 +182,8 @@ module.exports = { message: "'{{operator}}' should be placed at the beginning of the line.", data: { operator - } + }, + fix }); } else if (style === "after" && astUtils.isTokenOnSameLine(operatorToken, rightToken)) { @@ -135,7 +197,8 @@ module.exports = { message: "'{{operator}}' should be placed at the end of the line.", data: { operator - } + }, + fix }); } else if (style === "none") { @@ -149,7 +212,8 @@ module.exports = { message: "There should be no line break before or after '{{operator}}'.", data: { operator - } + }, + fix }); } diff --git a/tools/eslint/lib/rules/padded-blocks.js b/tools/eslint/lib/rules/padded-blocks.js index a24d421b0f4f23..2b4da39b360214 100644 --- a/tools/eslint/lib/rules/padded-blocks.js +++ b/tools/eslint/lib/rules/padded-blocks.js @@ -173,7 +173,7 @@ module.exports = { if (!blockHasBottomPadding) { context.report({ node, - loc: {line: closeBrace.loc.end.line, column: closeBrace.loc.end.column - 1 }, + loc: { line: closeBrace.loc.end.line, column: closeBrace.loc.end.column - 1 }, fix(fixer) { return fixer.insertTextBefore(closeBrace, "\n"); }, @@ -199,7 +199,7 @@ module.exports = { context.report({ node, - loc: {line: closeBrace.loc.end.line, column: closeBrace.loc.end.column - 1 }, + loc: { line: closeBrace.loc.end.line, column: closeBrace.loc.end.column - 1 }, message: NEVER_MESSAGE, fix(fixer) { return fixer.replaceTextRange([previousToken.end, closeBrace.start - closeBrace.loc.start.column], "\n"); diff --git a/tools/eslint/lib/rules/prefer-arrow-callback.js b/tools/eslint/lib/rules/prefer-arrow-callback.js index 034112093bd405..ee385042f1309e 100644 --- a/tools/eslint/lib/rules/prefer-arrow-callback.js +++ b/tools/eslint/lib/rules/prefer-arrow-callback.js @@ -63,7 +63,7 @@ function getVariableOfArguments(scope) { * {boolean} retv.isLexicalThis - `true` if the node is with `.bind(this)`. */ function getCallbackInfo(node) { - const retv = {isCallback: false, isLexicalThis: false}; + const retv = { isCallback: false, isLexicalThis: false }; let parent = node.parent; while (node) { @@ -176,7 +176,7 @@ module.exports = { * @returns {void} */ function enterScope() { - stack.push({this: false, super: false, meta: false}); + stack.push({ this: false, super: false, meta: false }); } /** diff --git a/tools/eslint/lib/rules/prefer-const.js b/tools/eslint/lib/rules/prefer-const.js index 5255f2745c9384..07d8da82a105c4 100644 --- a/tools/eslint/lib/rules/prefer-const.js +++ b/tools/eslint/lib/rules/prefer-const.js @@ -5,12 +5,6 @@ "use strict"; -//------------------------------------------------------------------------------ -// Requirements -//------------------------------------------------------------------------------ - -const lodash = require("lodash"); - //------------------------------------------------------------------------------ // Helpers //------------------------------------------------------------------------------ @@ -91,6 +85,17 @@ function getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign) { return null; } + /* + * Due to a bug in acorn, code such as `let foo = 1; let foo = 2;` will not throw a syntax error. As a sanity + * check, make sure that the variable only has one declaration. After the parsing bug is fixed, this check + * will no longer be necessary, because variables declared with `let` or `const` should always have exactly one + * declaration. + * https://github.com/ternjs/acorn/issues/487 + */ + if (variable.defs.length > 1) { + return null; + } + // Finds the unique WriteReference. let writer = null; let isReadBeforeInit = false; @@ -244,8 +249,8 @@ module.exports = { { type: "object", properties: { - destructuring: {enum: ["any", "all"]}, - ignoreReadBeforeAssign: {type: "boolean"} + destructuring: { enum: ["any", "all"] }, + ignoreReadBeforeAssign: { type: "boolean" } }, additionalProperties: false } @@ -254,80 +259,10 @@ module.exports = { create(context) { const options = context.options[0] || {}; + const sourceCode = context.getSourceCode(); const checkingMixedDestructuring = options.destructuring !== "all"; const ignoreReadBeforeAssign = options.ignoreReadBeforeAssign === true; - let variables = null; - - /** - * Reports a given Identifier node. - * - * @param {ASTNode} node - An Identifier node to report. - * @returns {void} - */ - function report(node) { - const reportArgs = { - node, - message: "'{{name}}' is never reassigned. Use 'const' instead.", - data: node - }, - varDeclParent = findUp(node, "VariableDeclaration", function(parentNode) { - return lodash.endsWith(parentNode.type, "Statement"); - }), - isNormalVarDecl = (node.parent.parent.parent.type === "ForInStatement" || - node.parent.parent.parent.type === "ForOfStatement" || - node.parent.init), - - isDestructuringVarDecl = - - // {let {a} = obj} should be written as {const {a} = obj} - (node.parent.parent.type === "ObjectPattern" && - - // If options.destucturing is "all", then this warning will not occur unless - // every assignment in the destructuring should be const. In that case, it's safe - // to apply the fix. Otherwise, it's safe to apply the fix if there's only one - // assignment occurring. If there is more than one assignment and options.destructuring - // is not "all", then it's not clear how the developer would want to resolve the issue, - // so we should not attempt to do it programmatically. - (options.destructuring === "all" || node.parent.parent.properties.length === 1)) || - - // {let [a] = [1]} should be written as {const [a] = [1]} - (node.parent.type === "ArrayPattern" && - - // See note above about fixing multiple warnings at once. - (options.destructuring === "all" || node.parent.elements.length === 1)); - - if (varDeclParent && - (isNormalVarDecl || isDestructuringVarDecl) && - - // If there are multiple variable declarations, like {let a = 1, b = 2}, then - // do not attempt to fix if one of the declarations should be `const`. It's - // too hard to know how the developer would want to automatically resolve the issue. - varDeclParent.declarations.length === 1) { - - reportArgs.fix = function(fixer) { - return fixer.replaceTextRange( - [varDeclParent.start, varDeclParent.start + "let".length], - "const" - ); - }; - } - - context.report(reportArgs); - } - - /** - * Reports a given variable if the variable should be declared as const. - * - * @param {escope.Variable} variable - A variable to report. - * @returns {void} - */ - function checkVariable(variable) { - const node = getIdentifierIfShouldBeConst(variable, ignoreReadBeforeAssign); - - if (node) { - report(node); - } - } + const variables = []; /** * Reports given identifier nodes if all of the nodes should be declared @@ -344,25 +279,39 @@ module.exports = { * @returns {void} */ function checkGroup(nodes) { - if (nodes.every(Boolean)) { - nodes.forEach(report); + const nodesToReport = nodes.filter(Boolean); + + if (nodes.length && (checkingMixedDestructuring || nodesToReport.length === nodes.length)) { + const varDeclParent = findUp(nodes[0], "VariableDeclaration", parentNode => parentNode.type.endsWith("Statement")); + const shouldFix = varDeclParent && + + // If there are multiple variable declarations, like {let a = 1, b = 2}, then + // do not attempt to fix if one of the declarations should be `const`. It's + // too hard to know how the developer would want to automatically resolve the issue. + varDeclParent.declarations.length === 1 && + + // Don't do a fix unless the variable is initialized (or it's in a for-in or for-of loop) + (varDeclParent.parent.type === "ForInStatement" || varDeclParent.parent.type === "ForOfStatement" || varDeclParent.declarations[0].init) && + + // If options.destucturing is "all", then this warning will not occur unless + // every assignment in the destructuring should be const. In that case, it's safe + // to apply the fix. + nodesToReport.length === nodes.length; + + nodesToReport.forEach(node => { + context.report({ + node, + message: "'{{name}}' is never reassigned. Use 'const' instead.", + data: node, + fix: shouldFix ? fixer => fixer.replaceText(sourceCode.getFirstToken(varDeclParent), "const") : null + }); + }); } } return { - Program() { - variables = []; - }, - "Program:exit"() { - if (checkingMixedDestructuring) { - variables.forEach(checkVariable); - } else { - groupByDestructuring(variables, ignoreReadBeforeAssign) - .forEach(checkGroup); - } - - variables = null; + groupByDestructuring(variables, ignoreReadBeforeAssign).forEach(checkGroup); }, VariableDeclaration(node) { diff --git a/tools/eslint/lib/rules/prefer-destructuring.js b/tools/eslint/lib/rules/prefer-destructuring.js new file mode 100644 index 00000000000000..c3fbcaa6310fc8 --- /dev/null +++ b/tools/eslint/lib/rules/prefer-destructuring.js @@ -0,0 +1,173 @@ +/** + * @fileoverview Prefer destructuring from arrays and objects + * @author Alex LaFroscia + */ +"use strict"; + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + docs: { + description: "require destructuring from arrays and/or objects", + category: "ECMAScript 6", + recommended: false + }, + + schema: [ + { + type: "object", + properties: { + array: { + type: "boolean" + }, + object: { + type: "boolean" + } + }, + additionalProperties: false + }, + { + type: "object", + properties: { + enforceForRenamedProperties: { + type: "boolean" + } + }, + additionalProperties: false + } + ] + }, + create(context) { + + let checkArrays = true; + let checkObjects = true; + let enforceForRenamedProperties = false; + const enabledTypes = context.options[0]; + const additionalOptions = context.options[1]; + + if (enabledTypes) { + if (typeof enabledTypes.array !== "undefined") { + checkArrays = enabledTypes.array; + } + + if (typeof enabledTypes.object !== "undefined") { + checkObjects = enabledTypes.object; + } + } + + if (additionalOptions) { + if (typeof additionalOptions.enforceForRenamedProperties !== "undefined") { + enforceForRenamedProperties = additionalOptions.enforceForRenamedProperties; + } + } + + //-------------------------------------------------------------------------- + // Helpers + //-------------------------------------------------------------------------- + + /** + * Determines if the given node node is accessing an array index + * + * This is used to differentiate array index access from object property + * access. + * + * @param {ASTNode} node the node to evaluate + * @returns {boolean} whether or not the node is an integer + */ + function isArrayIndexAccess(node) { + return Number.isInteger(node.property.value); + } + + /** + * Report that the given node should use destructuring + * + * @param {ASTNode} reportNode the node to report + * @param {string} type the type of destructuring that should have been done + * @returns {void} + */ + function report(reportNode, type) { + context.report({ node: reportNode, message: `Use ${type} destructuring` }); + } + + /** + * Check that the `prefer-destructuring` rules are followed based on the + * given left- and right-hand side of the assignment. + * + * Pulled out into a separate method so that VariableDeclarators and + * AssignmentExpressions can share the same verification logic. + * + * @param {ASTNode} leftNode the left-hand side of the assignment + * @param {ASTNode} rightNode the right-hand side of the assignment + * @param {ASTNode} reportNode the node to report the error on + * @returns {void} + */ + function performCheck(leftNode, rightNode, reportNode) { + if (rightNode.type !== "MemberExpression") { + return; + } + + if (checkArrays && isArrayIndexAccess(rightNode)) { + report(reportNode, "array"); + return; + } + + if (checkObjects && enforceForRenamedProperties) { + report(reportNode, "object"); + return; + } + + if (checkObjects) { + const property = rightNode.property; + + if ((property.type === "Literal" && leftNode.name === property.value) || + (property.type === "Identifier" && leftNode.name === property.name)) { + report(reportNode, "object"); + } + } + } + + /** + * Check if a given variable declarator is coming from an property access + * that should be using destructuring instead + * + * @param {ASTNode} node the variable declarator to check + * @returns {void} + */ + function checkVariableDeclarator(node) { + + // Skip if variable is declared without assignment + if (!node.init) { + return; + } + + // We only care about member expressions past this point + if (node.init.type !== "MemberExpression") { + return; + } + + performCheck(node.id, node.init, node); + } + + /** + * Run the `prefer-destructuring` check on an AssignmentExpression + * + * @param {ASTNode} node the AssignmentExpression node + * @returns {void} + */ + function checkAssigmentExpression(node) { + performCheck(node.left, node.right, node); + } + + //-------------------------------------------------------------------------- + // Public + //-------------------------------------------------------------------------- + + return { + VariableDeclarator: checkVariableDeclarator, + AssignmentExpression: checkAssigmentExpression + }; + } +}; diff --git a/tools/eslint/lib/rules/prefer-reflect.js b/tools/eslint/lib/rules/prefer-reflect.js index 64db836d04dd89..49e20989ecb00d 100644 --- a/tools/eslint/lib/rules/prefer-reflect.js +++ b/tools/eslint/lib/rules/prefer-reflect.js @@ -1,6 +1,7 @@ /** * @fileoverview Rule to suggest using "Reflect" api over Function/Object methods * @author Keith Cirkel + * @deprecated in ESLint v3.9.0 */ "use strict"; @@ -13,9 +14,12 @@ module.exports = { docs: { description: "require `Reflect` methods where applicable", category: "ECMAScript 6", - recommended: false + recommended: false, + replacedBy: [] }, + deprecated: true, + schema: [ { type: "object", @@ -79,10 +83,10 @@ module.exports = { * @returns {void} */ function report(node, existing, substitute) { - context.report(node, "Avoid using {{existing}}, instead use {{substitute}}.", { + context.report({ node, message: "Avoid using {{existing}}, instead use {{substitute}}.", data: { existing, substitute - }); + } }); } return { diff --git a/tools/eslint/lib/rules/quote-props.js b/tools/eslint/lib/rules/quote-props.js index 2129ce6aa99b87..1dcdd461b598fc 100644 --- a/tools/eslint/lib/rules/quote-props.js +++ b/tools/eslint/lib/rules/quote-props.js @@ -162,7 +162,7 @@ module.exports = { context.report({ node, message: MESSAGE_UNNECESSARY, - data: {property: key.value}, + data: { property: key.value }, fix: fixer => fixer.replaceText(key, getUnquotedKey(key)) }); } @@ -170,14 +170,14 @@ module.exports = { context.report({ node, message: MESSAGE_RESERVED, - data: {property: key.name}, + data: { property: key.name }, fix: fixer => fixer.replaceText(key, getQuotedKey(key)) }); } else if (NUMBERS && key.type === "Literal" && typeof key.value === "number") { context.report({ node, message: MESSAGE_NUMERIC, - data: {property: key.value}, + data: { property: key.value }, fix: fixer => fixer.replaceText(key, getQuotedKey(key)) }); } @@ -195,7 +195,7 @@ module.exports = { context.report({ node, message: MESSAGE_UNQUOTED, - data: {property: key.name || key.value}, + data: { property: key.name || key.value }, fix: fixer => fixer.replaceText(key, getQuotedKey(key)) }); } @@ -213,7 +213,7 @@ module.exports = { let keywordKeyName = null, necessaryQuotes = false; - node.properties.forEach(function(property) { + node.properties.forEach(property => { const key = property.key; let tokens; @@ -257,7 +257,7 @@ module.exports = { context.report({ node: property, message: "Properties should be quoted as '{{property}}' is a reserved word.", - data: {property: keywordKeyName}, + data: { property: keywordKeyName }, fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key)) }); }); @@ -266,7 +266,7 @@ module.exports = { context.report({ node: property, message: "Inconsistently quoted property '{{key}}' found.", - data: {key: property.key.name || property.key.value}, + data: { key: property.key.name || property.key.value }, fix: fixer => fixer.replaceText(property.key, getQuotedKey(property.key)) }); }); diff --git a/tools/eslint/lib/rules/quotes.js b/tools/eslint/lib/rules/quotes.js index 90e68289e05662..5c53c76908c3df 100644 --- a/tools/eslint/lib/rules/quotes.js +++ b/tools/eslint/lib/rules/quotes.js @@ -51,7 +51,7 @@ QUOTE_SETTINGS.backtick.convert = function(str) { if (newQuote === oldQuote) { return str; } - return newQuote + str.slice(1, -1).replace(/\\(\${|\r\n?|\n|.)|["'`]|\${|(\r\n?|\n)/g, function(match, escaped, newline) { + return newQuote + str.slice(1, -1).replace(/\\(\${|\r\n?|\n|.)|["'`]|\${|(\r\n?|\n)/g, (match, escaped, newline) => { if (escaped === oldQuote || oldQuote === "`" && escaped === "${") { return escaped; // unescape } @@ -258,7 +258,11 @@ module.exports = { return; } - const shouldWarn = node.quasis.length === 1 && (node.quasis[0].value.cooked.indexOf("\n") === -1); + /* + * A warning should be produced if the template literal only has one TemplateElement, and has no unescaped newlines. + * An unescaped newline is a newline preceded by an even number of backslashes. + */ + const shouldWarn = node.quasis.length === 1 && !/(^|[^\\])(\\\\)*[\r\n\u2028\u2029]/.test(node.quasis[0].value.raw); if (shouldWarn) { context.report({ @@ -268,6 +272,15 @@ module.exports = { description: settings.description, }, fix(fixer) { + if (isPartOfDirectivePrologue(node)) { + + /* + * TemplateLiterals in a directive prologue aren't actually directives, but if they're + * in the directive prologue, then fixing them might turn them into directives and change + * the behavior of the code. + */ + return null; + } return fixer.replaceText(node, settings.convert(sourceCode.getText(node))); } }); diff --git a/tools/eslint/lib/rules/radix.js b/tools/eslint/lib/rules/radix.js index f36e27d3634b9e..0dfa081b6a3e35 100644 --- a/tools/eslint/lib/rules/radix.js +++ b/tools/eslint/lib/rules/radix.js @@ -145,7 +145,7 @@ module.exports = { // Check `parseInt()` variable = astUtils.getVariableByName(scope, "parseInt"); if (!isShadowed(variable)) { - variable.references.forEach(function(reference) { + variable.references.forEach(reference => { const node = reference.identifier; if (astUtils.isCallee(node)) { @@ -157,7 +157,7 @@ module.exports = { // Check `Number.parseInt()` variable = astUtils.getVariableByName(scope, "Number"); if (!isShadowed(variable)) { - variable.references.forEach(function(reference) { + variable.references.forEach(reference => { const node = reference.identifier.parent; if (isParseIntMethod(node) && astUtils.isCallee(node)) { diff --git a/tools/eslint/lib/rules/require-await.js b/tools/eslint/lib/rules/require-await.js new file mode 100644 index 00000000000000..89b24f75b0f951 --- /dev/null +++ b/tools/eslint/lib/rules/require-await.js @@ -0,0 +1,95 @@ +/** + * @fileoverview Rule to disallow async functions which have no `await` expression. + * @author Toru Nagashima + */ + +"use strict"; + +//------------------------------------------------------------------------------ +// Requirements +//------------------------------------------------------------------------------ + +const astUtils = require("../ast-utils"); + +//------------------------------------------------------------------------------ +// Helpers +//------------------------------------------------------------------------------ + +/** + * Capitalize the 1st letter of the given text. + * + * @param {string} text - The text to capitalize. + * @returns {string} The text that the 1st letter was capitalized. + */ +function capitalizeFirstLetter(text) { + return text[0].toUpperCase() + text.slice(1); +} + +//------------------------------------------------------------------------------ +// Rule Definition +//------------------------------------------------------------------------------ + +module.exports = { + meta: { + docs: { + description: "disallow async functions which have no `await` expression", + category: "Best Practices", + recommended: false + }, + schema: [] + }, + + create(context) { + const sourceCode = context.getSourceCode(); + let scopeInfo = null; + + /** + * Push the scope info object to the stack. + * + * @returns {void} + */ + function enterFunction() { + scopeInfo = { + upper: scopeInfo, + hasAwait: false, + }; + } + + /** + * Pop the top scope info object from the stack. + * Also, it reports the function if needed. + * + * @param {ASTNode} node - The node to report. + * @returns {void} + */ + function exitFunction(node) { + if (node.async && !scopeInfo.hasAwait && !astUtils.isEmptyFunction(node)) { + context.report({ + node, + loc: astUtils.getFunctionHeadLoc(node, sourceCode), + message: "{{name}} has no 'await' expression.", + data: { + name: capitalizeFirstLetter( + astUtils.getFunctionNameWithKind(node) + ) + } + }); + } + + scopeInfo = scopeInfo.upper; + } + + return { + FunctionDeclaration: enterFunction, + FunctionExpression: enterFunction, + ArrowFunctionExpression: enterFunction, + "FunctionDeclaration:exit": exitFunction, + "FunctionExpression:exit": exitFunction, + "ArrowFunctionExpression:exit": exitFunction, + + AwaitExpression() { + scopeInfo.hasAwait = true; + } + }; + } +}; diff --git a/tools/eslint/lib/rules/require-jsdoc.js b/tools/eslint/lib/rules/require-jsdoc.js index 9300fce1baa42b..f1ecde81f959ec 100644 --- a/tools/eslint/lib/rules/require-jsdoc.js +++ b/tools/eslint/lib/rules/require-jsdoc.js @@ -27,6 +27,9 @@ module.exports = { }, FunctionDeclaration: { type: "boolean" + }, + ArrowFunctionExpression: { + type: "boolean" } }, additionalProperties: false @@ -52,7 +55,7 @@ module.exports = { * @returns {void} */ function report(node) { - context.report(node, "Missing JSDoc comment."); + context.report({ node, message: "Missing JSDoc comment." }); } /** @@ -98,6 +101,11 @@ module.exports = { if (options.ClassDeclaration) { checkJsDoc(node); } + }, + ArrowFunctionExpression(node) { + if (options.ArrowFunctionExpression && node.parent.type === "VariableDeclarator") { + checkJsDoc(node); + } } }; } diff --git a/tools/eslint/lib/rules/require-yield.js b/tools/eslint/lib/rules/require-yield.js index 36b4ea11a585aa..5cc2944bc692d6 100644 --- a/tools/eslint/lib/rules/require-yield.js +++ b/tools/eslint/lib/rules/require-yield.js @@ -48,9 +48,7 @@ module.exports = { const countYield = stack.pop(); if (countYield === 0 && node.body.body.length > 0) { - context.report( - node, - "This generator function does not have 'yield'."); + context.report({ node, message: "This generator function does not have 'yield'." }); } } diff --git a/tools/eslint/lib/rules/semi.js b/tools/eslint/lib/rules/semi.js index 2f28f1614d1a42..ee37ab018c82fd 100644 --- a/tools/eslint/lib/rules/semi.js +++ b/tools/eslint/lib/rules/semi.js @@ -39,7 +39,7 @@ module.exports = { { type: "object", properties: { - omitLastInOneLineBlock: {type: "boolean"} + omitLastInOneLineBlock: { type: "boolean" } }, additionalProperties: false } @@ -53,7 +53,7 @@ module.exports = { create(context) { - const OPT_OUT_PATTERN = /^[-[(\/+]$/; // One of [(/+-, but not ++ or -- + const OPT_OUT_PATTERN = /^[-[(/+`]/; // One of [(/+-` const options = context.options[1]; const never = context.options[0] === "never", exceptOneLine = options && options.omitLastInOneLineBlock === true, @@ -127,7 +127,7 @@ module.exports = { const lastTokenLine = lastToken.loc.end.line; const nextTokenLine = nextToken.loc.start.line; - const isOptOutToken = OPT_OUT_PATTERN.test(nextToken.value); + const isOptOutToken = OPT_OUT_PATTERN.test(nextToken.value) && nextToken.value !== "++" && nextToken.value !== "--"; const isDivider = (nextToken.value === "}" || nextToken.value === ";"); return (lastTokenLine !== nextTokenLine && !isOptOutToken) || isDivider; diff --git a/tools/eslint/lib/rules/sort-imports.js b/tools/eslint/lib/rules/sort-imports.js index ae3333c2ac16d7..83f500990239b2 100644 --- a/tools/eslint/lib/rules/sort-imports.js +++ b/tools/eslint/lib/rules/sort-imports.js @@ -39,7 +39,9 @@ module.exports = { }, additionalProperties: false } - ] + ], + + fixable: "code" }, create(context) { @@ -47,7 +49,8 @@ module.exports = { const configuration = context.options[0] || {}, ignoreCase = configuration.ignoreCase || false, ignoreMemberSort = configuration.ignoreMemberSort || false, - memberSyntaxSortOrder = configuration.memberSyntaxSortOrder || ["none", "all", "multiple", "single"]; + memberSyntaxSortOrder = configuration.memberSyntaxSortOrder || ["none", "all", "multiple", "single"], + sourceCode = context.getSourceCode(); let previousDeclaration = null; /** @@ -135,36 +138,49 @@ module.exports = { } } - // Multiple members of an import declaration should also be sorted alphabetically. - if (!ignoreMemberSort && node.specifiers.length > 1) { - let previousSpecifier = null; - let previousSpecifierName = null; + if (!ignoreMemberSort) { + const importSpecifiers = node.specifiers.filter(specifier => specifier.type === "ImportSpecifier"); + const getSortableName = ignoreCase ? specifier => specifier.local.name.toLowerCase() : specifier => specifier.local.name; + const firstUnsortedIndex = importSpecifiers.map(getSortableName).findIndex((name, index, array) => array[index - 1] > name); + + if (firstUnsortedIndex !== -1) { + context.report({ + node: importSpecifiers[firstUnsortedIndex], + message: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.", + data: { memberName: importSpecifiers[firstUnsortedIndex].local.name }, + fix(fixer) { + if (importSpecifiers.some(specifier => sourceCode.getComments(specifier).leading.length || sourceCode.getComments(specifier).trailing.length)) { + + // If there are comments in the ImportSpecifier list, don't rearrange the specifiers. + return null; + } - for (let i = 0; i < node.specifiers.length; ++i) { - const currentSpecifier = node.specifiers[i]; + return fixer.replaceTextRange( + [importSpecifiers[0].range[0], importSpecifiers[importSpecifiers.length - 1].range[1]], + importSpecifiers - if (currentSpecifier.type !== "ImportSpecifier") { - continue; - } + // Clone the importSpecifiers array to avoid mutating it + .slice() - let currentSpecifierName = currentSpecifier.local.name; + // Sort the array into the desired order + .sort((specifierA, specifierB) => { + const aName = getSortableName(specifierA); + const bName = getSortableName(specifierB); - if (ignoreCase) { - currentSpecifierName = currentSpecifierName.toLowerCase(); - } + return aName > bName ? 1 : -1; + }) - if (previousSpecifier && currentSpecifierName < previousSpecifierName) { - context.report({ - node: currentSpecifier, - message: "Member '{{memberName}}' of the import declaration should be sorted alphabetically.", - data: { - memberName: currentSpecifier.local.name - } - }); - } + // Build a string out of the sorted list of import specifiers and the text between the originals + .reduce((sourceText, specifier, index) => { + const textAfterSpecifier = index === importSpecifiers.length - 1 + ? "" + : sourceCode.getText().slice(importSpecifiers[index].range[1], importSpecifiers[index + 1].range[0]); - previousSpecifier = currentSpecifier; - previousSpecifierName = currentSpecifierName; + return sourceText + sourceCode.getText(specifier) + textAfterSpecifier; + }, "") + ); + } + }); } } diff --git a/tools/eslint/lib/rules/sort-vars.js b/tools/eslint/lib/rules/sort-vars.js index 1e1cf3c959e663..e18cc320ef0553 100644 --- a/tools/eslint/lib/rules/sort-vars.js +++ b/tools/eslint/lib/rules/sort-vars.js @@ -37,7 +37,7 @@ module.exports = { return { VariableDeclaration(node) { - node.declarations.reduce(function(memo, decl) { + node.declarations.reduce((memo, decl) => { if (decl.id.type === "ObjectPattern" || decl.id.type === "ArrayPattern") { return memo; } @@ -51,7 +51,7 @@ module.exports = { } if (currenVariableName < lastVariableName) { - context.report(decl, "Variables within the same declaration block should be sorted alphabetically."); + context.report({ node: decl, message: "Variables within the same declaration block should be sorted alphabetically." }); return memo; } else { return decl; diff --git a/tools/eslint/lib/rules/space-in-parens.js b/tools/eslint/lib/rules/space-in-parens.js index c01170b2bc13b4..af838dfa9e8376 100644 --- a/tools/eslint/lib/rules/space-in-parens.js +++ b/tools/eslint/lib/rules/space-in-parens.js @@ -220,7 +220,7 @@ module.exports = { exceptions = getExceptions(); const tokens = sourceCode.tokensAndComments; - tokens.forEach(function(token, i) { + tokens.forEach((token, i) => { const prevToken = tokens[i - 1]; const nextToken = tokens[i + 1]; diff --git a/tools/eslint/lib/rules/space-infix-ops.js b/tools/eslint/lib/rules/space-infix-ops.js index 9831e8e2af6085..d919a1225a2bf5 100644 --- a/tools/eslint/lib/rules/space-infix-ops.js +++ b/tools/eslint/lib/rules/space-infix-ops.js @@ -57,7 +57,7 @@ module.exports = { const op = tokens[i]; if ( - op.type === "Punctuator" && + (op.type === "Punctuator" || op.type === "Keyword") && OPERATORS.indexOf(op.value) >= 0 && (tokens[i - 1].range[1] >= op.range[0] || op.range[1] >= tokens[i + 1].range[0]) ) { diff --git a/tools/eslint/lib/rules/spaced-comment.js b/tools/eslint/lib/rules/spaced-comment.js index a3dce4fa4e3d30..85abd7360e622a 100644 --- a/tools/eslint/lib/rules/spaced-comment.js +++ b/tools/eslint/lib/rules/spaced-comment.js @@ -240,7 +240,7 @@ module.exports = { const config = context.options[1] || {}; const balanced = config.block && config.block.balanced; - const styleRules = ["block", "line"].reduce(function(rule, type) { + const styleRules = ["block", "line"].reduce((rule, type) => { const markers = parseMarkersOption(config[type] && config[type].markers || config.markers); const exceptions = config[type] && config[type].exceptions || config.exceptions || []; const endNeverPattern = "[ \t]+$"; diff --git a/tools/eslint/lib/rules/strict.js b/tools/eslint/lib/rules/strict.js index 1591bd871465d4..34ed443d92c816 100644 --- a/tools/eslint/lib/rules/strict.js +++ b/tools/eslint/lib/rules/strict.js @@ -135,7 +135,7 @@ module.exports = { */ function reportSlice(nodes, start, end, message, fix) { nodes.slice(start, end).forEach(node => { - context.report({node, message, fix: fix ? getFixFunction(node) : null}); + context.report({ node, message, fix: fix ? getFixFunction(node) : null }); }); } @@ -176,19 +176,19 @@ module.exports = { if (isStrict) { if (!isSimpleParameterList(node.params)) { - context.report(useStrictDirectives[0], messages.nonSimpleParameterList); + context.report({ node: useStrictDirectives[0], message: messages.nonSimpleParameterList }); } else if (isParentStrict) { - context.report({node: useStrictDirectives[0], message: messages.unnecessary, fix: getFixFunction(useStrictDirectives[0])}); + context.report({ node: useStrictDirectives[0], message: messages.unnecessary, fix: getFixFunction(useStrictDirectives[0]) }); } else if (isInClass) { - context.report({node: useStrictDirectives[0], message: messages.unnecessaryInClasses, fix: getFixFunction(useStrictDirectives[0])}); + context.report({ node: useStrictDirectives[0], message: messages.unnecessaryInClasses, fix: getFixFunction(useStrictDirectives[0]) }); } reportAllExceptFirst(useStrictDirectives, messages.multiple, true); } else if (isParentGlobal) { if (isSimpleParameterList(node.params)) { - context.report(node, messages.function); + context.report({ node, message: messages.function }); } else { - context.report(node, messages.wrap); + context.report({ node, message: messages.wrap }); } } @@ -221,7 +221,7 @@ module.exports = { if (isSimpleParameterList(node.params)) { reportAll(useStrictDirectives, messages[mode], shouldFix(mode)); } else { - context.report(useStrictDirectives[0], messages.nonSimpleParameterList); + context.report({ node: useStrictDirectives[0], message: messages.nonSimpleParameterList }); reportAllExceptFirst(useStrictDirectives, messages.multiple, true); } } @@ -237,7 +237,7 @@ module.exports = { if (mode === "global") { if (node.body.length > 0 && useStrictDirectives.length === 0) { - context.report(node, messages.global); + context.report({ node, message: messages.global }); } reportAllExceptFirst(useStrictDirectives, messages.multiple, true); } else { diff --git a/tools/eslint/lib/rules/symbol-description.js b/tools/eslint/lib/rules/symbol-description.js index 37ac8be7276656..3f5ffd7463cd5a 100644 --- a/tools/eslint/lib/rules/symbol-description.js +++ b/tools/eslint/lib/rules/symbol-description.js @@ -51,7 +51,7 @@ module.exports = { const variable = astUtils.getVariableByName(scope, "Symbol"); if (variable && variable.defs.length === 0) { - variable.references.forEach(function(reference) { + variable.references.forEach(reference => { const node = reference.identifier; if (astUtils.isCallee(node)) { diff --git a/tools/eslint/lib/rules/template-curly-spacing.js b/tools/eslint/lib/rules/template-curly-spacing.js index 1ac3262fce2597..1d491a24c9c1e2 100644 --- a/tools/eslint/lib/rules/template-curly-spacing.js +++ b/tools/eslint/lib/rules/template-curly-spacing.js @@ -33,7 +33,7 @@ module.exports = { fixable: "whitespace", schema: [ - {enum: ["always", "never"]} + { enum: ["always", "never"] } ] }, diff --git a/tools/eslint/lib/rules/unicode-bom.js b/tools/eslint/lib/rules/unicode-bom.js index 82692894d4a852..2f16a258509e8b 100644 --- a/tools/eslint/lib/rules/unicode-bom.js +++ b/tools/eslint/lib/rules/unicode-bom.js @@ -36,7 +36,7 @@ module.exports = { Program: function checkUnicodeBOM(node) { const sourceCode = context.getSourceCode(), - location = {column: 0, line: 1}, + location = { column: 0, line: 1 }, requireBOM = context.options[0] || "never"; if (!sourceCode.hasBOM && (requireBOM === "always")) { diff --git a/tools/eslint/lib/rules/use-isnan.js b/tools/eslint/lib/rules/use-isnan.js index b4a978b5efe21b..5ec48a0386e1b5 100644 --- a/tools/eslint/lib/rules/use-isnan.js +++ b/tools/eslint/lib/rules/use-isnan.js @@ -25,7 +25,7 @@ module.exports = { return { BinaryExpression(node) { if (/^(?:[<>]|[!=]=)=?$/.test(node.operator) && (node.left.name === "NaN" || node.right.name === "NaN")) { - context.report(node, "Use the isNaN function to compare with NaN."); + context.report({ node, message: "Use the isNaN function to compare with NaN." }); } } }; diff --git a/tools/eslint/lib/rules/valid-jsdoc.js b/tools/eslint/lib/rules/valid-jsdoc.js index 09fc684719a4af..66ad1f8d45de1f 100644 --- a/tools/eslint/lib/rules/valid-jsdoc.js +++ b/tools/eslint/lib/rules/valid-jsdoc.js @@ -202,7 +202,7 @@ module.exports = { elements.forEach(validateType.bind(null, jsdocNode)); - typesToCheck.forEach(function(typeToCheck) { + typesToCheck.forEach(typeToCheck => { if (typeToCheck.expectedType && typeToCheck.expectedType !== typeToCheck.currentType) { context.report({ @@ -246,15 +246,15 @@ module.exports = { } catch (ex) { if (/braces/i.test(ex.message)) { - context.report(jsdocNode, "JSDoc type missing brace."); + context.report({ node: jsdocNode, message: "JSDoc type missing brace." }); } else { - context.report(jsdocNode, "JSDoc syntax error."); + context.report({ node: jsdocNode, message: "JSDoc syntax error." }); } return; } - jsdoc.tags.forEach(function(tag) { + jsdoc.tags.forEach(tag => { switch (tag.title.toLowerCase()) { @@ -262,15 +262,15 @@ module.exports = { case "arg": case "argument": if (!tag.type) { - context.report(jsdocNode, "Missing JSDoc parameter type for '{{name}}'.", { name: tag.name }); + context.report({ node: jsdocNode, message: "Missing JSDoc parameter type for '{{name}}'.", data: { name: tag.name } }); } if (!tag.description && requireParamDescription) { - context.report(jsdocNode, "Missing JSDoc parameter description for '{{name}}'.", { name: tag.name }); + context.report({ node: jsdocNode, message: "Missing JSDoc parameter description for '{{name}}'.", data: { name: tag.name } }); } if (params[tag.name]) { - context.report(jsdocNode, "Duplicate JSDoc parameter '{{name}}'.", { name: tag.name }); + context.report({ node: jsdocNode, message: "Duplicate JSDoc parameter '{{name}}'.", data: { name: tag.name } }); } else if (tag.name.indexOf(".") === -1) { params[tag.name] = 1; } @@ -290,11 +290,11 @@ module.exports = { }); } else { if (requireReturnType && !tag.type) { - context.report(jsdocNode, "Missing JSDoc return type."); + context.report({ node: jsdocNode, message: "Missing JSDoc return type." }); } if (!isValidReturnType(tag) && !tag.description && requireReturnDescription) { - context.report(jsdocNode, "Missing JSDoc return description."); + context.report({ node: jsdocNode, message: "Missing JSDoc return description." }); } } @@ -324,7 +324,7 @@ module.exports = { // check tag preferences if (prefer.hasOwnProperty(tag.title) && tag.title !== prefer[tag.title]) { - context.report(jsdocNode, "Use @{{name}} instead.", { name: prefer[tag.title] }); + context.report({ node: jsdocNode, message: "Use @{{name}} instead.", data: { name: prefer[tag.title] } }); } // validate the types @@ -352,7 +352,7 @@ module.exports = { const jsdocParams = Object.keys(params); if (node.params) { - node.params.forEach(function(param, i) { + node.params.forEach((param, i) => { if (param.type === "AssignmentPattern") { param = param.left; } @@ -362,14 +362,14 @@ module.exports = { // TODO(nzakas): Figure out logical things to do with destructured, default, rest params if (param.type === "Identifier") { if (jsdocParams[i] && (name !== jsdocParams[i])) { - context.report(jsdocNode, "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.", { + context.report({ node: jsdocNode, message: "Expected JSDoc for '{{name}}' but found '{{jsdocName}}'.", data: { name, jsdocName: jsdocParams[i] - }); + } }); } else if (!params[name] && !isOverride) { - context.report(jsdocNode, "Missing JSDoc for parameter '{{name}}'.", { + context.report({ node: jsdocNode, message: "Missing JSDoc for parameter '{{name}}'.", data: { name - }); + } }); } } }); @@ -379,7 +379,7 @@ module.exports = { const regex = new RegExp(options.matchDescription); if (!regex.test(jsdoc.description)) { - context.report(jsdocNode, "JSDoc description does not satisfy the regex pattern."); + context.report({ node: jsdocNode, message: "JSDoc description does not satisfy the regex pattern." }); } } diff --git a/tools/eslint/lib/rules/valid-typeof.js b/tools/eslint/lib/rules/valid-typeof.js index ed0a7c017955f2..94b407b600a43c 100644 --- a/tools/eslint/lib/rules/valid-typeof.js +++ b/tools/eslint/lib/rules/valid-typeof.js @@ -62,10 +62,10 @@ module.exports = { const value = sibling.type === "Literal" ? sibling.value : sibling.quasis[0].value.cooked; if (VALID_TYPES.indexOf(value) === -1) { - context.report(sibling, "Invalid typeof comparison value."); + context.report({ node: sibling, message: "Invalid typeof comparison value." }); } } else if (requireStringLiterals && !isTypeofExpression(sibling)) { - context.report(sibling, "Typeof comparisons should be to string literals."); + context.report({ node: sibling, message: "Typeof comparisons should be to string literals." }); } } } diff --git a/tools/eslint/lib/rules/vars-on-top.js b/tools/eslint/lib/rules/vars-on-top.js index 92ed08e2d4b5de..f74db905b1908d 100644 --- a/tools/eslint/lib/rules/vars-on-top.js +++ b/tools/eslint/lib/rules/vars-on-top.js @@ -100,7 +100,7 @@ module.exports = { */ function globalVarCheck(node, parent) { if (!isVarOnTop(node, parent.body)) { - context.report(node, errorMessage); + context.report({ node, message: errorMessage }); } } @@ -115,7 +115,7 @@ module.exports = { if (!(/Function/.test(grandParent.type) && parent.type === "BlockStatement" && isVarOnTop(node, parent.body))) { - context.report(node, errorMessage); + context.report({ node, message: errorMessage }); } } diff --git a/tools/eslint/lib/rules/yield-star-spacing.js b/tools/eslint/lib/rules/yield-star-spacing.js index ecd33c5b38fafb..eb20fc01b0b9a9 100644 --- a/tools/eslint/lib/rules/yield-star-spacing.js +++ b/tools/eslint/lib/rules/yield-star-spacing.js @@ -28,8 +28,8 @@ module.exports = { { type: "object", properties: { - before: {type: "boolean"}, - after: {type: "boolean"} + before: { type: "boolean" }, + after: { type: "boolean" } }, additionalProperties: false } diff --git a/tools/eslint/lib/rules/yoda.js b/tools/eslint/lib/rules/yoda.js index e463a476ab6be4..ba711c63c2f1ae 100644 --- a/tools/eslint/lib/rules/yoda.js +++ b/tools/eslint/lib/rules/yoda.js @@ -4,6 +4,12 @@ */ "use strict"; +//-------------------------------------------------------------------------- +// Requirements +//-------------------------------------------------------------------------- + +const astUtils = require("../ast-utils"); + //-------------------------------------------------------------------------- // Helpers //-------------------------------------------------------------------------- @@ -54,13 +60,16 @@ function looksLikeLiteral(node) { /** * Attempts to derive a Literal node from nodes that are treated like literals. * @param {ASTNode} node Node to normalize. - * @returns {ASTNode} The original node if the node is already a Literal, or a - * normalized Literal node with the negative number as the - * value if the node represents a negative number literal, - * otherwise null if the node cannot be converted to a - * normalized literal. + * @param {number} [defaultValue] The default value to be returned if the node + * is not a Literal. + * @returns {ASTNode} One of the following options. + * 1. The original node if the node is already a Literal + * 2. A normalized Literal node with the negative number as the value if the + * node represents a negative number literal. + * 3. The Literal node which has the `defaultValue` argument if it exists. + * 4. Otherwise `null`. */ -function getNormalizedLiteral(node) { +function getNormalizedLiteral(node, defaultValue) { if (node.type === "Literal") { return node; } @@ -73,6 +82,14 @@ function getNormalizedLiteral(node) { }; } + if (defaultValue) { + return { + type: "Literal", + value: defaultValue, + raw: String(defaultValue) + }; + } + return null; } @@ -98,12 +115,26 @@ function same(a, b) { case "Literal": return a.value === b.value; - case "MemberExpression": + case "MemberExpression": { + const nameA = astUtils.getStaticPropertyName(a); + + // x.y = x["y"] + if (nameA) { + return ( + same(a.object, b.object) && + nameA === astUtils.getStaticPropertyName(b) + ); + } // x[0] = x[0] // x[y] = x[y] // x.y = x.y - return same(a.object, b.object) && same(a.property, b.property); + return ( + a.computed === b.computed && + same(a.object, b.object) && + same(a.property, b.property) + ); + } case "ThisExpression": return true; @@ -178,7 +209,7 @@ module.exports = { return (node.operator === "&&" && (leftLiteral = getNormalizedLiteral(left.left)) && - (rightLiteral = getNormalizedLiteral(right.right)) && + (rightLiteral = getNormalizedLiteral(right.right, Number.POSITIVE_INFINITY)) && leftLiteral.value <= rightLiteral.value && same(left.right, right.left)); } @@ -191,7 +222,7 @@ module.exports = { let leftLiteral, rightLiteral; return (node.operator === "||" && - (leftLiteral = getNormalizedLiteral(left.right)) && + (leftLiteral = getNormalizedLiteral(left.right, Number.NEGATIVE_INFINITY)) && (rightLiteral = getNormalizedLiteral(right.left)) && leftLiteral.value <= rightLiteral.value && same(left.left, right.right)); diff --git a/tools/eslint/lib/testers/event-generator-tester.js b/tools/eslint/lib/testers/event-generator-tester.js index d85238e9db0471..89693fe94819df 100644 --- a/tools/eslint/lib/testers/event-generator-tester.js +++ b/tools/eslint/lib/testers/event-generator-tester.js @@ -44,19 +44,19 @@ module.exports = { * @returns {void} */ testEventGeneratorInterface(instance) { - this.describe("should implement EventGenerator interface", function() { - this.it("should have `emitter` property.", function() { + this.describe("should implement EventGenerator interface", () => { + this.it("should have `emitter` property.", () => { assert.equal(typeof instance.emitter, "object"); assert.equal(typeof instance.emitter.emit, "function"); }); - this.it("should have `enterNode` property.", function() { + this.it("should have `enterNode` property.", () => { assert.equal(typeof instance.enterNode, "function"); }); - this.it("should have `leaveNode` property.", function() { + this.it("should have `leaveNode` property.", () => { assert.equal(typeof instance.leaveNode, "function"); }); - }.bind(this)); + }); } }; diff --git a/tools/eslint/lib/testers/rule-tester.js b/tools/eslint/lib/testers/rule-tester.js index 25b86993593c4a..5d327ad28b9360 100644 --- a/tools/eslint/lib/testers/rule-tester.js +++ b/tools/eslint/lib/testers/rule-tester.js @@ -252,8 +252,26 @@ RuleTester.prototype = { run(ruleName, rule, test) { const testerConfig = this.testerConfig, + requiredScenarios = ["valid", "invalid"], + scenarioErrors = [], result = {}; + if (lodash.isNil(test) || typeof test !== "object") { + throw new Error(`Test Scenarios for rule ${ruleName} : Could not find test scenario object`); + } + + requiredScenarios.forEach(scenarioType => { + if (lodash.isNil(test[scenarioType])) { + scenarioErrors.push(`Could not find any ${scenarioType} test scenarios`); + } + }); + + if (scenarioErrors.length > 0) { + throw new Error([ + `Test Scenarios for rule ${ruleName} is invalid:` + ].concat(scenarioErrors).join("\n")); + } + /* eslint-disable no-shadow */ /** @@ -307,9 +325,7 @@ RuleTester.prototype = { if (validateSchema.errors) { throw new Error([ `Schema for rule ${ruleName} is invalid:` - ].concat(validateSchema.errors.map(function(error) { - return `\t${error.field}: ${error.message}`; - })).join("\n")); + ].concat(validateSchema.errors.map(error => `\t${error.field}: ${error.message}`)).join("\n")); } } @@ -321,10 +337,10 @@ RuleTester.prototype = { * running the rule under test. */ eslint.reset(); - eslint.on("Program", function(node) { + eslint.on("Program", node => { beforeAST = cloneDeeplyExcludesParent(node); - eslint.on("Program:exit", function(node) { + eslint.on("Program:exit", node => { afterAST = cloneDeeplyExcludesParent(node); }); }); @@ -448,7 +464,7 @@ RuleTester.prototype = { } if (item.errors[i].type) { - assert.equal(messages[i].nodeType, item.errors[i].type, `Error type should be ${item.errors[i].type}`); + assert.equal(messages[i].nodeType, item.errors[i].type, `Error type should be ${item.errors[i].type}, found ${messages[i].nodeType}`); } if (item.errors[i].hasOwnProperty("line")) { @@ -488,18 +504,18 @@ RuleTester.prototype = { * This creates a mocha test suite and pipes all supplied info through * one of the templates above. */ - RuleTester.describe(ruleName, function() { - RuleTester.describe("valid", function() { - test.valid.forEach(function(valid) { - RuleTester.it(valid.code || valid, function() { + RuleTester.describe(ruleName, () => { + RuleTester.describe("valid", () => { + test.valid.forEach(valid => { + RuleTester.it(valid.code || valid, () => { testValidTemplate(ruleName, valid); }); }); }); - RuleTester.describe("invalid", function() { - test.invalid.forEach(function(invalid) { - RuleTester.it(invalid.code, function() { + RuleTester.describe("invalid", () => { + test.invalid.forEach(invalid => { + RuleTester.it(invalid.code, () => { testInvalidTemplate(ruleName, invalid); }); }); diff --git a/tools/eslint/lib/timing.js b/tools/eslint/lib/timing.js index 627aa5f82f8118..20456628640bf6 100644 --- a/tools/eslint/lib/timing.js +++ b/tools/eslint/lib/timing.js @@ -54,18 +54,16 @@ const ALIGN = [alignLeft, alignRight, alignRight]; function display(data) { let total = 0; const rows = Object.keys(data) - .map(function(key) { + .map(key => { const time = data[key]; total += time; return [key, time]; }) - .sort(function(a, b) { - return b[1] - a[1]; - }) + .sort((a, b) => b[1] - a[1]) .slice(0, 10); - rows.forEach(function(row) { + rows.forEach(row => { row.push(`${(row[1] * 100 / total).toFixed(1)}%`); row[1] = row[1].toFixed(3); }); @@ -74,7 +72,7 @@ function display(data) { const widths = []; - rows.forEach(function(row) { + rows.forEach(row => { const len = row.length; for (let i = 0; i < len; i++) { @@ -86,13 +84,13 @@ function display(data) { } }); - const table = rows.map(function(row) { - return row.map(function(cell, index) { - return ALIGN[index](cell, widths[index]); - }).join(" | "); - }); + const table = rows.map(row => + row + .map((cell, index) => ALIGN[index](cell, widths[index])) + .join(" | ") + ); - table.splice(1, 0, widths.map(function(w, index) { + table.splice(1, 0, widths.map((w, index) => { if (index !== 0 && index !== widths.length - 1) { w++; } @@ -130,7 +128,7 @@ module.exports = (function() { } if (enabled) { - process.on("exit", function() { + process.on("exit", () => { display(data); }); } diff --git a/tools/eslint/lib/util/comment-event-generator.js b/tools/eslint/lib/util/comment-event-generator.js index 47cc68f296f87e..dfa7132ff850ef 100644 --- a/tools/eslint/lib/util/comment-event-generator.js +++ b/tools/eslint/lib/util/comment-event-generator.js @@ -20,7 +20,7 @@ */ function emitComments(comments, emitter, locs, eventName) { if (comments.length > 0) { - comments.forEach(function(node) { + comments.forEach(node => { const index = locs.indexOf(node.loc); if (index >= 0) { diff --git a/tools/eslint/lib/util/glob-util.js b/tools/eslint/lib/util/glob-util.js index cba2e694ad5238..198e069e9f0850 100644 --- a/tools/eslint/lib/util/glob-util.js +++ b/tools/eslint/lib/util/glob-util.js @@ -43,9 +43,7 @@ function processPath(options) { const cwd = (options && options.cwd) || process.cwd(); let extensions = (options && options.extensions) || [".js"]; - extensions = extensions.map(function(ext) { - return ext.charAt(0) === "." ? ext.substr(1) : ext; - }); + extensions = extensions.map(ext => ext.replace(/^\./, "")); let suffix = "/**"; @@ -67,7 +65,7 @@ function processPath(options) { const resolvedPath = path.resolve(cwd, pathname); if (shell.test("-d", resolvedPath)) { - newPath = pathname.replace(/[\/\\]$/, "") + suffix; + newPath = pathname.replace(/[/\\]$/, "") + suffix; } return pathUtil.convertPathToPosix(newPath); @@ -145,12 +143,12 @@ function listFilesToProcess(globPatterns, options) { if (added[filename]) { return; } - files.push({filename, ignored}); + files.push({ filename, ignored }); added[filename] = true; } debug("Creating list of files to process."); - globPatterns.forEach(function(pattern) { + globPatterns.forEach(pattern => { const file = path.resolve(cwd, pattern); if (shell.test("-f", file)) { @@ -160,9 +158,9 @@ function listFilesToProcess(globPatterns, options) { } else { // regex to find .hidden or /.hidden patterns, but not ./relative or ../relative - const globIncludesDotfiles = /(?:(?:^\.)|(?:[\/\\]\.))[^\/\\\.].*/.test(pattern); + const globIncludesDotfiles = /(?:(?:^\.)|(?:[/\\]\.))[^/\\.].*/.test(pattern); - const ignoredPaths = new IgnoredPaths(Object.assign({}, options, {dotfiles: options.dotfiles || globIncludesDotfiles})); + const ignoredPaths = new IgnoredPaths(Object.assign({}, options, { dotfiles: options.dotfiles || globIncludesDotfiles })); const shouldIgnore = ignoredPaths.getIgnoredFoldersGlobChecker(); const globOptions = { nodir: true, @@ -170,7 +168,7 @@ function listFilesToProcess(globPatterns, options) { cwd, }; - new GlobSync(pattern, globOptions, shouldIgnore).found.forEach(function(globMatch) { + new GlobSync(pattern, globOptions, shouldIgnore).found.forEach(globMatch => { addFile(path.resolve(cwd, globMatch), false, ignoredPaths); }); } diff --git a/tools/eslint/lib/util/module-resolver.js b/tools/eslint/lib/util/module-resolver.js index 40c107a70e82bd..505c572822699b 100644 --- a/tools/eslint/lib/util/module-resolver.js +++ b/tools/eslint/lib/util/module-resolver.js @@ -30,18 +30,18 @@ const DEFAULT_OPTIONS = { /** * Resolves modules based on a set of options. - * @param {Object} options The options for resolving modules. - * @param {string[]} options.lookupPaths An array of paths to include in the - * lookup with the highest priority paths coming first. - * @constructor */ -function ModuleResolver(options) { - options = options || {}; +class ModuleResolver { - this.options = Object.assign({}, DEFAULT_OPTIONS, options); -} - -ModuleResolver.prototype = { + /** + * Resolves modules based on a set of options. + * @param {Object} options The options for resolving modules. + * @param {string[]} options.lookupPaths An array of paths to include in the + * lookup with the highest priority paths coming first. + */ + constructor(options) { + this.options = Object.assign({}, DEFAULT_OPTIONS, options || {}); + } /** * Resolves the file location of a given module relative to the configured @@ -75,10 +75,8 @@ ModuleResolver.prototype = { } return result; - } - -}; +} //------------------------------------------------------------------------------ // Public API diff --git a/tools/eslint/lib/util/node-event-generator.js b/tools/eslint/lib/util/node-event-generator.js index 95d9132dd2f3b3..1666ae93f53406 100644 --- a/tools/eslint/lib/util/node-event-generator.js +++ b/tools/eslint/lib/util/node-event-generator.js @@ -20,34 +20,33 @@ * leaveNode(node: ASTNode): void; * } * ``` - * - * @param {EventEmitter} emitter - An event emitter which is the destination of events. - * @returns {NodeEventGenerator} new instance. */ -function NodeEventGenerator(emitter) { - this.emitter = emitter; -} +class NodeEventGenerator { -NodeEventGenerator.prototype = { - constructor: NodeEventGenerator, + /** + * @param {EventEmitter} emitter - An event emitter which is the destination of events. + */ + constructor(emitter) { + this.emitter = emitter; + } /** * Emits an event of entering AST node. * @param {ASTNode} node - A node which was entered. * @returns {void} */ - enterNode: function enterNode(node) { + enterNode(node) { this.emitter.emit(node.type, node); - }, + } /** * Emits an event of leaving AST node. * @param {ASTNode} node - A node which was left. * @returns {void} */ - leaveNode: function leaveNode(node) { + leaveNode(node) { this.emitter.emit(`${node.type}:exit`, node); } -}; +} module.exports = NodeEventGenerator; diff --git a/tools/eslint/lib/util/npm-util.js b/tools/eslint/lib/util/npm-util.js index e9131595e7e822..ef1c0c62936347 100644 --- a/tools/eslint/lib/util/npm-util.js +++ b/tools/eslint/lib/util/npm-util.js @@ -53,7 +53,7 @@ function installSyncSaveDev(packages) { if (Array.isArray(packages)) { packages = packages.join(" "); } - shell.exec(`npm i --save-dev ${packages}`, {stdio: "inherit"}); + shell.exec(`npm i --save-dev ${packages}`, { stdio: "inherit" }); } /** @@ -89,7 +89,7 @@ function check(packages, opt) { if (opt.dependencies && typeof fileJson.dependencies === "object") { deps = deps.concat(Object.keys(fileJson.dependencies)); } - return packages.reduce(function(status, pkg) { + return packages.reduce((status, pkg) => { status[pkg] = deps.indexOf(pkg) !== -1; return status; }, {}); @@ -107,7 +107,7 @@ function check(packages, opt) { * and values are booleans indicating installation. */ function checkDeps(packages, rootDir) { - return check(packages, {dependencies: true, startDir: rootDir}); + return check(packages, { dependencies: true, startDir: rootDir }); } /** @@ -121,7 +121,7 @@ function checkDeps(packages, rootDir) { * and values are booleans indicating installation. */ function checkDevDeps(packages) { - return check(packages, {devDependencies: true}); + return check(packages, { devDependencies: true }); } /** diff --git a/tools/eslint/lib/util/patterns/letters.js b/tools/eslint/lib/util/patterns/letters.js new file mode 100644 index 00000000000000..b212cfc9ebd34a --- /dev/null +++ b/tools/eslint/lib/util/patterns/letters.js @@ -0,0 +1,37 @@ +/** + * @fileoverview Pattern for detecting any letter (even letters outside of ASCII). + * NOTE: This file was generated using this script in JSCS based on the Unicode 7.0.0 standard: https://github.com/jscs-dev/node-jscs/blob/f5ed14427deb7e7aac84f3056a5aab2d9f3e563e/publish/helpers/generate-patterns.js + * Do not edit this file by hand-- please use https://github.com/mathiasbynens/regenerate to regenerate the regular expression exported from this file. + * @author Kevin Partington + * @license MIT License (from JSCS). See below. + */ + +/* + * The MIT License (MIT) + * + * Copyright 2013-2016 Dulin Marat and other contributors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +"use strict"; + +module.exports = /[A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0-\u08B2\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58\u0C59\u0C60\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2183\u2184\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005\u3006\u3031-\u3035\u303B\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312D\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FCC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6E5\uA717-\uA71F\uA722-\uA788\uA78B-\uA78E\uA790-\uA7AD\uA7B0\uA7B1\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB5F\uAB64\uAB65\uABC0-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF30-\uDF40\uDF42-\uDF49\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF]|\uD801[\uDC00-\uDC9D\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDE00-\uDE11\uDE13-\uDE2B\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF5D-\uDF61]|\uD805[\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDE00-\uDE2F\uDE44\uDE80-\uDEAA]|\uD806[\uDCA0-\uDCDF\uDCFF\uDEC0-\uDEF8]|\uD808[\uDC00-\uDF98]|[\uD80C\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F]|\uD82C[\uDC00\uDC01]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD87E[\uDC00-\uDE1D]/; + diff --git a/tools/eslint/lib/util/source-code-fixer.js b/tools/eslint/lib/util/source-code-fixer.js index 064a0a1f902443..3b702e509e77a4 100644 --- a/tools/eslint/lib/util/source-code-fixer.js +++ b/tools/eslint/lib/util/source-code-fixer.js @@ -72,7 +72,7 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) { let lastFixPos = text.length + 1, prefix = (sourceCode.hasBOM ? BOM : ""); - messages.forEach(function(problem) { + messages.forEach(problem => { if (problem.hasOwnProperty("fix")) { fixes.push(problem); } else { @@ -84,14 +84,12 @@ SourceCodeFixer.applyFixes = function(sourceCode, messages) { debug("Found fixes to apply"); // sort in reverse order of occurrence - fixes.sort(function(a, b) { - return b.fix.range[1] - a.fix.range[1] || b.fix.range[0] - a.fix.range[0]; - }); + fixes.sort((a, b) => b.fix.range[1] - a.fix.range[1] || b.fix.range[0] - a.fix.range[0]); // split into array of characters for easier manipulation const chars = text.split(""); - fixes.forEach(function(problem) { + fixes.forEach(problem => { const fix = problem.fix; let start = fix.range[0]; const end = fix.range[1]; diff --git a/tools/eslint/lib/util/source-code-util.js b/tools/eslint/lib/util/source-code-util.js index 8e660e0961d330..892c32d22a00e8 100644 --- a/tools/eslint/lib/util/source-code-util.js +++ b/tools/eslint/lib/util/source-code-util.js @@ -29,7 +29,7 @@ const debug = require("debug")("eslint:source-code-util"); */ function getSourceCodeOfFile(filename, options) { debug("getting sourceCode of", filename); - const opts = Object.assign({}, options, { rules: {}}); + const opts = Object.assign({}, options, { rules: {} }); const cli = new CLIEngine(opts); const results = cli.executeOnFiles([filename]); @@ -71,7 +71,7 @@ function getSourceCodeOfFiles(patterns, options, cb) { patterns = [patterns]; } - const defaultOptions = Object.assign({}, baseDefaultOptions, {cwd: process.cwd()}); + const defaultOptions = Object.assign({}, baseDefaultOptions, { cwd: process.cwd() }); if (typeof options === "undefined") { opts = defaultOptions; @@ -84,14 +84,14 @@ function getSourceCodeOfFiles(patterns, options, cb) { debug("constructed options:", opts); patterns = globUtil.resolveFileGlobPatterns(patterns, opts); - const filenames = globUtil.listFilesToProcess(patterns, opts).reduce(function(files, fileInfo) { - return !fileInfo.ignored ? files.concat(fileInfo.filename) : files; - }, []); + const filenames = globUtil.listFilesToProcess(patterns, opts) + .filter(fileInfo => !fileInfo.ignored) + .reduce((files, fileInfo) => files.concat(fileInfo.filename), []); if (filenames.length === 0) { debug(`Did not find any files matching pattern(s): ${patterns}`); } - filenames.forEach(function(filename) { + filenames.forEach(filename => { const sourceCode = getSourceCodeOfFile(filename, opts); if (sourceCode) { diff --git a/tools/eslint/lib/util/source-code.js b/tools/eslint/lib/util/source-code.js index 378bdd328fa50a..5d073039d81cd7 100644 --- a/tools/eslint/lib/util/source-code.js +++ b/tools/eslint/lib/util/source-code.js @@ -117,16 +117,16 @@ function SourceCode(text, ast) { */ this.lines = SourceCode.splitLines(this.text); - this.tokensAndComments = ast.tokens.concat(ast.comments).sort(function(left, right) { - return left.range[0] - right.range[0]; - }); + this.tokensAndComments = ast.tokens + .concat(ast.comments) + .sort((left, right) => left.range[0] - right.range[0]); // create token store methods const tokenStore = createTokenStore(ast.tokens); - Object.keys(tokenStore).forEach(function(methodName) { + Object.keys(tokenStore).forEach(methodName => { this[methodName] = tokenStore[methodName]; - }, this); + }); const tokensAndCommentsStore = createTokenStore(this.tokensAndComments); @@ -280,7 +280,7 @@ SourceCode.prototype = { } }); - return result ? Object.assign({parent: resultParent}, result) : null; + return result ? Object.assign({ parent: resultParent }, result) : null; }, /** diff --git a/tools/eslint/lib/util/traverser.js b/tools/eslint/lib/util/traverser.js index 50d18b045eb6ff..d5710bb8ac7b2d 100644 --- a/tools/eslint/lib/util/traverser.js +++ b/tools/eslint/lib/util/traverser.js @@ -46,9 +46,7 @@ function Traverser() { * @private */ Traverser.getKeys = function(node) { - return Object.keys(node).filter(function(key) { - return KEY_BLACKLIST.indexOf(key) === -1; - }); + return Object.keys(node).filter(key => KEY_BLACKLIST.indexOf(key) === -1); }; module.exports = Traverser; diff --git a/tools/eslint/lib/util/xml-escape.js b/tools/eslint/lib/util/xml-escape.js index 698abaf38eaecf..9f43c99c46a23c 100644 --- a/tools/eslint/lib/util/xml-escape.js +++ b/tools/eslint/lib/util/xml-escape.js @@ -15,7 +15,7 @@ * @private */ module.exports = function(s) { - return (`${s}`).replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/g, function(c) { // eslint-disable-line no-control-regex + return (`${s}`).replace(/[<>&"'\x00-\x1F\x7F\u0080-\uFFFF]/g, c => { // eslint-disable-line no-control-regex switch (c) { case "<": return "<"; diff --git a/tools/eslint/node_modules/.bin/strip-json-comments b/tools/eslint/node_modules/.bin/strip-json-comments deleted file mode 120000 index 63d549f96f3b2f..00000000000000 --- a/tools/eslint/node_modules/.bin/strip-json-comments +++ /dev/null @@ -1 +0,0 @@ -../strip-json-comments/cli.js \ No newline at end of file diff --git a/tools/eslint/node_modules/acorn/.tern-project b/tools/eslint/node_modules/acorn/.tern-project deleted file mode 100644 index 6718ce07e1c8a0..00000000000000 --- a/tools/eslint/node_modules/acorn/.tern-project +++ /dev/null @@ -1,6 +0,0 @@ -{ - "plugins": { - "node": true, - "es_modules": true - } -} \ No newline at end of file diff --git a/tools/eslint/node_modules/acorn/AUTHORS b/tools/eslint/node_modules/acorn/AUTHORS index 314d7086cf5bf2..306404542a3b07 100644 --- a/tools/eslint/node_modules/acorn/AUTHORS +++ b/tools/eslint/node_modules/acorn/AUTHORS @@ -25,6 +25,7 @@ Joel Kemp Johannes Herr Jordan Klassen Jürg Lehni +Kai Cataldo keeyipchan Keheliya Gallaba Kevin Irish @@ -32,6 +33,7 @@ Kevin Kwok krator Marijn Haverbeke Martin Carlberg +Mat Garcia Mathias Bynens Mathieu 'p01' Henri Matthew Bastien diff --git a/tools/eslint/node_modules/acorn/bin/generate-identifier-regex.js b/tools/eslint/node_modules/acorn/bin/generate-identifier-regex.js deleted file mode 100644 index 100e8cf280fc56..00000000000000 --- a/tools/eslint/node_modules/acorn/bin/generate-identifier-regex.js +++ /dev/null @@ -1,55 +0,0 @@ -'use strict'; - -// Which Unicode version should be used? -var version = '9.0.0'; - -var start = require('unicode-' + version + '/Binary_Property/ID_Start/code-points.js') - .filter(function(ch) { return ch > 0x7f; }); -var last = -1; -var cont = [0x200c, 0x200d].concat(require('unicode-' + version + '/Binary_Property/ID_Continue/code-points.js') - .filter(function(ch) { return ch > 0x7f && search(start, ch, last + 1) == -1; })); - -function search(arr, ch, starting) { - for (var i = starting; arr[i] <= ch && i < arr.length; last = i++) - if (arr[i] === ch) - return i; - return -1; -} - -function pad(str, width) { - while (str.length < width) str = "0" + str; - return str; -} - -function esc(code) { - var hex = code.toString(16); - if (hex.length <= 2) return "\\x" + pad(hex, 2); - else return "\\u" + pad(hex, 4); -} - -function generate(chars) { - var astral = [], re = ""; - for (var i = 0, at = 0x10000; i < chars.length; i++) { - var from = chars[i], to = from; - while (i < chars.length - 1 && chars[i + 1] == to + 1) { - i++; - to++; - } - if (to <= 0xffff) { - if (from == to) re += esc(from); - else if (from + 1 == to) re += esc(from) + esc(to); - else re += esc(from) + "-" + esc(to); - } else { - astral.push(from - at, to - from); - at = to; - } - } - return {nonASCII: re, astral: astral}; -} - -var startData = generate(start), contData = generate(cont); - -console.log("let nonASCIIidentifierStartChars = \"" + startData.nonASCII + "\""); -console.log("let nonASCIIidentifierChars = \"" + contData.nonASCII + "\""); -console.log("const astralIdentifierStartCodes = " + JSON.stringify(startData.astral)); -console.log("const astralIdentifierCodes = " + JSON.stringify(contData.astral)); diff --git a/tools/eslint/node_modules/acorn/bin/update_authors.sh b/tools/eslint/node_modules/acorn/bin/update_authors.sh deleted file mode 100755 index e08f57273cdd1e..00000000000000 --- a/tools/eslint/node_modules/acorn/bin/update_authors.sh +++ /dev/null @@ -1,6 +0,0 @@ -# Combine existing list of authors with everyone known in git, sort, add header. -tail --lines=+3 AUTHORS > AUTHORS.tmp -git log --format='%aN' | grep -v abraidwood | grep -v Rich-Harris | grep -v ForbesLindesay >> AUTHORS.tmp -echo -e "List of Acorn contributors. Updated before every release.\n" > AUTHORS -sort -u AUTHORS.tmp >> AUTHORS -rm -f AUTHORS.tmp diff --git a/tools/eslint/node_modules/acorn/dist/acorn.es.js b/tools/eslint/node_modules/acorn/dist/acorn.es.js index adb3dd30f3012a..32dd5954ea0e68 100644 --- a/tools/eslint/node_modules/acorn/dist/acorn.es.js +++ b/tools/eslint/node_modules/acorn/dist/acorn.es.js @@ -1305,7 +1305,12 @@ pp$1.checkVariableExport = function(exports, decls) { } pp$1.shouldParseExportStatement = function() { - return this.type.keyword || this.isLet() || this.isAsyncFunction() + return this.type.keyword === "var" + || this.type.keyword === "const" + || this.type.keyword === "class" + || this.type.keyword === "function" + || this.isLet() + || this.isAsyncFunction() } // Parses a comma-separated list of module exports. @@ -1617,6 +1622,24 @@ pp$2.checkLVal = function(expr, isBinding, checkClashes) { } } +// A recursive descent parser operates by defining functions for all +// syntactic elements, and recursively calling those, each function +// advancing the input stream and returning an AST node. Precedence +// of constructs (for example, the fact that `!x[1]` means `!(x[1])` +// instead of `(!x)[1]` is handled by the fact that the parser +// function that parses unary prefix operators is called first, and +// in turn calls the function that parses `[]` subscripts — that +// way, it'll receive the node for `x[1]` already parsed, and wraps +// *that* in the unary operator node. +// +// Acorn uses an [operator precedence parser][opp] to handle binary +// operator precedence, because it is much more compact than using +// the technique outlined above, which uses different, nesting +// functions to specify precedence, for all of the ten binary +// precedence levels that JavaScript defines. +// +// [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser + var pp$3 = Parser.prototype // Check if property name clashes with already added. @@ -2481,6 +2504,10 @@ pp$5.finishNodeAt = function(node, type, pos, loc) { return finishNodeAt.call(this, node, type, pos, loc) } +// The algorithm used to determine whether a regexp can appear at a +// given point in the program is loosely based on sweet.js' approach. +// See https://github.com/mozilla/sweet.js/wiki/design + var TokContext = function TokContext(token, isExpr, preserveSpace, override) { this.token = token this.isExpr = !!isExpr @@ -3290,7 +3317,28 @@ pp$7.readWord = function() { return this.finishToken(type, word) } -var version = "4.0.3" +// Acorn is a tiny, fast JavaScript parser written in JavaScript. +// +// Acorn was written by Marijn Haverbeke, Ingvar Stepanyan, and +// various contributors and released under an MIT license. +// +// Git repositories for Acorn are available at +// +// http://marijnhaverbeke.nl/git/acorn +// https://github.com/ternjs/acorn.git +// +// Please use the [github bug tracker][ghbt] to report issues. +// +// [ghbt]: https://github.com/ternjs/acorn/issues +// +// This file defines the main parser interface. The library also comes +// with a [error-tolerant parser][dammit] and an +// [abstract syntax tree walker][walk], defined in other files. +// +// [dammit]: acorn_loose.js +// [walk]: util/walk.js + +var version = "4.0.4" // The main exported interface (under `self.acorn` when in the // browser) is a `parse` function that takes a code string and diff --git a/tools/eslint/node_modules/acorn/dist/acorn.js b/tools/eslint/node_modules/acorn/dist/acorn.js index 0fc4086bb72fb6..ea572b3ebd3f4b 100644 --- a/tools/eslint/node_modules/acorn/dist/acorn.js +++ b/tools/eslint/node_modules/acorn/dist/acorn.js @@ -2,3362 +2,3410 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (factory((global.acorn = global.acorn || {}))); -}(this, function (exports) { 'use strict'; - - // Reserved word lists for various dialects of the language - - var reservedWords = { - 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile", - 5: "class enum extends super const export import", - 6: "enum", - strict: "implements interface let package private protected public static yield", - strictBind: "eval arguments" - } - - // And the keywords - - var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this" +}(this, (function (exports) { 'use strict'; + +// Reserved word lists for various dialects of the language + +var reservedWords = { + 3: "abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized throws transient volatile", + 5: "class enum extends super const export import", + 6: "enum", + strict: "implements interface let package private protected public static yield", + strictBind: "eval arguments" +} + +// And the keywords + +var ecma5AndLessKeywords = "break case catch continue debugger default do else finally for function if return switch throw try var while with null true false instanceof typeof void delete new in this" + +var keywords = { + 5: ecma5AndLessKeywords, + 6: ecma5AndLessKeywords + " const class extends export import super" +} + +// ## Character categories + +// Big ugly regular expressions that match characters in the +// whitespace, identifier, and identifier-start categories. These +// are only applied when a character is found to actually have a +// code point above 128. +// Generated by `bin/generate-identifier-regex.js`. + +var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fd5\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ae\ua7b0-\ua7b7\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab65\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc" +var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d4-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d01-\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1cf8\u1cf9\u1dc0-\u1df5\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f" + +var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]") +var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]") + +nonASCIIidentifierStartChars = nonASCIIidentifierChars = null + +// These are a run-length and offset encoded representation of the +// >0xffff code points that are a valid part of identifiers. The +// offset starts at 0x10000, and each pair of numbers represents an +// offset to the next range, and then a size of the range. They were +// generated by bin/generate-identifier-regex.js +var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,10591,541] +var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239] + +// This has a complexity linear to the value of the code. The +// assumption is that looking up astral identifier characters is +// rare. +function isInAstralSet(code, set) { + var pos = 0x10000 + for (var i = 0; i < set.length; i += 2) { + pos += set[i] + if (pos > code) return false + pos += set[i + 1] + if (pos >= code) return true + } +} + +// Test whether a given character code starts an identifier. + +function isIdentifierStart(code, astral) { + if (code < 65) return code === 36 + if (code < 91) return true + if (code < 97) return code === 95 + if (code < 123) return true + if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) + if (astral === false) return false + return isInAstralSet(code, astralIdentifierStartCodes) +} + +// Test whether a given character is part of an identifier. + +function isIdentifierChar(code, astral) { + if (code < 48) return code === 36 + if (code < 58) return true + if (code < 65) return false + if (code < 91) return true + if (code < 97) return code === 95 + if (code < 123) return true + if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) + if (astral === false) return false + return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes) +} + +// ## Token types + +// The assignment of fine-grained, information-carrying type objects +// allows the tokenizer to store the information it has about a +// token in a way that is very cheap for the parser to look up. + +// All token type variables start with an underscore, to make them +// easy to recognize. + +// The `beforeExpr` property is used to disambiguate between regular +// expressions and divisions. It is set on all token types that can +// be followed by an expression (thus, a slash after them would be a +// regular expression). +// +// The `startsExpr` property is used to check if the token ends a +// `yield` expression. It is set on all token types that either can +// directly start an expression (like a quotation mark) or can +// continue an expression (like the body of a string). +// +// `isLoop` marks a keyword as starting a loop, which is important +// to know when parsing a label, in order to allow or disallow +// continue jumps to that label. + +var TokenType = function TokenType(label, conf) { + if ( conf === void 0 ) conf = {}; + + this.label = label + this.keyword = conf.keyword + this.beforeExpr = !!conf.beforeExpr + this.startsExpr = !!conf.startsExpr + this.isLoop = !!conf.isLoop + this.isAssign = !!conf.isAssign + this.prefix = !!conf.prefix + this.postfix = !!conf.postfix + this.binop = conf.binop || null + this.updateContext = null +}; + +function binop(name, prec) { + return new TokenType(name, {beforeExpr: true, binop: prec}) +} +var beforeExpr = {beforeExpr: true}; +var startsExpr = {startsExpr: true}; +// Map keyword names to token types. + +var keywordTypes = {} + +// Succinct definitions of keyword token types +function kw(name, options) { + if ( options === void 0 ) options = {}; + + options.keyword = name + return keywordTypes[name] = new TokenType(name, options) +} + +var tt = { + num: new TokenType("num", startsExpr), + regexp: new TokenType("regexp", startsExpr), + string: new TokenType("string", startsExpr), + name: new TokenType("name", startsExpr), + eof: new TokenType("eof"), + + // Punctuation token types. + bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}), + bracketR: new TokenType("]"), + braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}), + braceR: new TokenType("}"), + parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}), + parenR: new TokenType(")"), + comma: new TokenType(",", beforeExpr), + semi: new TokenType(";", beforeExpr), + colon: new TokenType(":", beforeExpr), + dot: new TokenType("."), + question: new TokenType("?", beforeExpr), + arrow: new TokenType("=>", beforeExpr), + template: new TokenType("template"), + ellipsis: new TokenType("...", beforeExpr), + backQuote: new TokenType("`", startsExpr), + dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}), + + // Operators. These carry several kinds of properties to help the + // parser use them properly (the presence of these properties is + // what categorizes them as operators). + // + // `binop`, when present, specifies that this operator is a binary + // operator, and will refer to its precedence. + // + // `prefix` and `postfix` mark the operator as a prefix or postfix + // unary operator. + // + // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as + // binary operators with a very low precedence, that should result + // in AssignmentExpression nodes. + + eq: new TokenType("=", {beforeExpr: true, isAssign: true}), + assign: new TokenType("_=", {beforeExpr: true, isAssign: true}), + incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}), + prefix: new TokenType("prefix", {beforeExpr: true, prefix: true, startsExpr: true}), + logicalOR: binop("||", 1), + logicalAND: binop("&&", 2), + bitwiseOR: binop("|", 3), + bitwiseXOR: binop("^", 4), + bitwiseAND: binop("&", 5), + equality: binop("==/!=", 6), + relational: binop("", 7), + bitShift: binop("<>", 8), + plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}), + modulo: binop("%", 10), + star: binop("*", 10), + slash: binop("/", 10), + starstar: new TokenType("**", {beforeExpr: true}), + + // Keyword token types. + _break: kw("break"), + _case: kw("case", beforeExpr), + _catch: kw("catch"), + _continue: kw("continue"), + _debugger: kw("debugger"), + _default: kw("default", beforeExpr), + _do: kw("do", {isLoop: true, beforeExpr: true}), + _else: kw("else", beforeExpr), + _finally: kw("finally"), + _for: kw("for", {isLoop: true}), + _function: kw("function", startsExpr), + _if: kw("if"), + _return: kw("return", beforeExpr), + _switch: kw("switch"), + _throw: kw("throw", beforeExpr), + _try: kw("try"), + _var: kw("var"), + _const: kw("const"), + _while: kw("while", {isLoop: true}), + _with: kw("with"), + _new: kw("new", {beforeExpr: true, startsExpr: true}), + _this: kw("this", startsExpr), + _super: kw("super", startsExpr), + _class: kw("class"), + _extends: kw("extends", beforeExpr), + _export: kw("export"), + _import: kw("import"), + _null: kw("null", startsExpr), + _true: kw("true", startsExpr), + _false: kw("false", startsExpr), + _in: kw("in", {beforeExpr: true, binop: 7}), + _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}), + _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}), + _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}), + _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true}) +} + +// Matches a whole line break (where CRLF is considered a single +// line break). Used to count lines. + +var lineBreak = /\r\n?|\n|\u2028|\u2029/ +var lineBreakG = new RegExp(lineBreak.source, "g") + +function isNewLine(code) { + return code === 10 || code === 13 || code === 0x2028 || code === 0x2029 +} + +var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/ + +var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g + +function isArray(obj) { + return Object.prototype.toString.call(obj) === "[object Array]" +} + +// Checks if an object has a property. + +function has(obj, propName) { + return Object.prototype.hasOwnProperty.call(obj, propName) +} + +// These are used when `options.locations` is on, for the +// `startLoc` and `endLoc` properties. + +var Position = function Position(line, col) { + this.line = line + this.column = col +}; + +Position.prototype.offset = function offset (n) { + return new Position(this.line, this.column + n) +}; + +var SourceLocation = function SourceLocation(p, start, end) { + this.start = start + this.end = end + if (p.sourceFile !== null) this.source = p.sourceFile +}; + +// The `getLineInfo` function is mostly useful when the +// `locations` option is off (for performance reasons) and you +// want to find the line/column position for a given character +// offset. `input` should be the code string that the offset refers +// into. + +function getLineInfo(input, offset) { + for (var line = 1, cur = 0;;) { + lineBreakG.lastIndex = cur + var match = lineBreakG.exec(input) + if (match && match.index < offset) { + ++line + cur = match.index + match[0].length + } else { + return new Position(line, offset - cur) + } + } +} + +// A second optional argument can be given to further configure +// the parser process. These options are recognized: + +var defaultOptions = { + // `ecmaVersion` indicates the ECMAScript version to parse. Must + // be either 3, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support + // for strict mode, the set of reserved words, and support for + // new syntax features. The default is 7. + ecmaVersion: 7, + // `sourceType` indicates the mode the code should be parsed in. + // Can be either `"script"` or `"module"`. This influences global + // strict mode and parsing of `import` and `export` declarations. + sourceType: "script", + // `onInsertedSemicolon` can be a callback that will be called + // when a semicolon is automatically inserted. It will be passed + // th position of the comma as an offset, and if `locations` is + // enabled, it is given the location as a `{line, column}` object + // as second argument. + onInsertedSemicolon: null, + // `onTrailingComma` is similar to `onInsertedSemicolon`, but for + // trailing commas. + onTrailingComma: null, + // By default, reserved words are only enforced if ecmaVersion >= 5. + // Set `allowReserved` to a boolean value to explicitly turn this on + // an off. When this option has the value "never", reserved words + // and keywords can also not be used as property names. + allowReserved: null, + // When enabled, a return at the top level is not considered an + // error. + allowReturnOutsideFunction: false, + // When enabled, import/export statements are not constrained to + // appearing at the top of the program. + allowImportExportEverywhere: false, + // When enabled, hashbang directive in the beginning of file + // is allowed and treated as a line comment. + allowHashBang: false, + // When `locations` is on, `loc` properties holding objects with + // `start` and `end` properties in `{line, column}` form (with + // line being 1-based and column 0-based) will be attached to the + // nodes. + locations: false, + // A function can be passed as `onToken` option, which will + // cause Acorn to call that function with object in the same + // format as tokens returned from `tokenizer().getToken()`. Note + // that you are not allowed to call the parser from the + // callback—that will corrupt its internal state. + onToken: null, + // A function can be passed as `onComment` option, which will + // cause Acorn to call that function with `(block, text, start, + // end)` parameters whenever a comment is skipped. `block` is a + // boolean indicating whether this is a block (`/* */`) comment, + // `text` is the content of the comment, and `start` and `end` are + // character offsets that denote the start and end of the comment. + // When the `locations` option is on, two more parameters are + // passed, the full `{line, column}` locations of the start and + // end of the comments. Note that you are not allowed to call the + // parser from the callback—that will corrupt its internal state. + onComment: null, + // Nodes have their start and end characters offsets recorded in + // `start` and `end` properties (directly on the node, rather than + // the `loc` object, which holds line/column data. To also add a + // [semi-standardized][range] `range` property holding a `[start, + // end]` array with the same numbers, set the `ranges` option to + // `true`. + // + // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678 + ranges: false, + // It is possible to parse multiple files into a single AST by + // passing the tree produced by parsing the first file as + // `program` option in subsequent parses. This will add the + // toplevel forms of the parsed file to the `Program` (top) node + // of an existing parse tree. + program: null, + // When `locations` is on, you can pass this to record the source + // file in every node's `loc` object. + sourceFile: null, + // This value, if given, is stored in every node, whether + // `locations` is on or off. + directSourceFile: null, + // When enabled, parenthesized expressions are represented by + // (non-standard) ParenthesizedExpression nodes + preserveParens: false, + plugins: {} +} + +// Interpret and default an options object + +function getOptions(opts) { + var options = {} + + for (var opt in defaultOptions) + options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt] + + if (options.ecmaVersion >= 2015) + options.ecmaVersion -= 2009 + + if (options.allowReserved == null) + options.allowReserved = options.ecmaVersion < 5 + + if (isArray(options.onToken)) { + var tokens = options.onToken + options.onToken = function (token) { return tokens.push(token); } + } + if (isArray(options.onComment)) + options.onComment = pushComment(options, options.onComment) + + return options +} + +function pushComment(options, array) { + return function (block, text, start, end, startLoc, endLoc) { + var comment = { + type: block ? 'Block' : 'Line', + value: text, + start: start, + end: end + } + if (options.locations) + comment.loc = new SourceLocation(this, startLoc, endLoc) + if (options.ranges) + comment.range = [start, end] + array.push(comment) + } +} + +// Registered plugins +var plugins = {} + +function keywordRegexp(words) { + return new RegExp("^(" + words.replace(/ /g, "|") + ")$") +} + +var Parser = function Parser(options, input, startPos) { + this.options = options = getOptions(options) + this.sourceFile = options.sourceFile + this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5]) + var reserved = "" + if (!options.allowReserved) { + for (var v = options.ecmaVersion;; v--) + if (reserved = reservedWords[v]) break + if (options.sourceType == "module") reserved += " await" + } + this.reservedWords = keywordRegexp(reserved) + var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict + this.reservedWordsStrict = keywordRegexp(reservedStrict) + this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind) + this.input = String(input) + + // Used to signal to callers of `readWord1` whether the word + // contained any escape sequences. This is needed because words with + // escape sequences must not be interpreted as keywords. + this.containsEsc = false + + // Load plugins + this.loadPlugins(options.plugins) + + // Set up token state + + // The current position of the tokenizer in the input. + if (startPos) { + this.pos = startPos + this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1 + this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length + } else { + this.pos = this.lineStart = 0 + this.curLine = 1 + } + + // Properties of the current token: + // Its type + this.type = tt.eof + // For tokens that include more information than their type, the value + this.value = null + // Its start and end offset + this.start = this.end = this.pos + // And, if locations are used, the {line, column} object + // corresponding to those offsets + this.startLoc = this.endLoc = this.curPosition() + + // Position information for the previous token + this.lastTokEndLoc = this.lastTokStartLoc = null + this.lastTokStart = this.lastTokEnd = this.pos + + // The context stack is used to superficially track syntactic + // context to predict whether a regular expression is allowed in a + // given position. + this.context = this.initialContext() + this.exprAllowed = true + + // Figure out if it's a module code. + this.strict = this.inModule = options.sourceType === "module" + + // Used to signify the start of a potential arrow function + this.potentialArrowAt = -1 + + // Flags to track whether we are in a function, a generator, an async function. + this.inFunction = this.inGenerator = this.inAsync = false + // Positions to delayed-check that yield/await does not exist in default parameters. + this.yieldPos = this.awaitPos = 0 + // Labels in scope. + this.labels = [] + + // If enabled, skip leading hashbang line. + if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === '#!') + this.skipLineComment(2) +}; + +// DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them +Parser.prototype.isKeyword = function isKeyword (word) { return this.keywords.test(word) }; +Parser.prototype.isReservedWord = function isReservedWord (word) { return this.reservedWords.test(word) }; + +Parser.prototype.extend = function extend (name, f) { + this[name] = f(this[name]) +}; + +Parser.prototype.loadPlugins = function loadPlugins (pluginConfigs) { + var this$1 = this; - var keywords = { - 5: ecma5AndLessKeywords, - 6: ecma5AndLessKeywords + " const class extends export import super" + for (var name in pluginConfigs) { + var plugin = plugins[name] + if (!plugin) throw new Error("Plugin '" + name + "' not found") + plugin(this$1, pluginConfigs[name]) } +}; - // ## Character categories +Parser.prototype.parse = function parse () { + var node = this.options.program || this.startNode() + this.nextToken() + return this.parseTopLevel(node) +}; - // Big ugly regular expressions that match characters in the - // whitespace, identifier, and identifier-start categories. These - // are only applied when a character is found to actually have a - // code point above 128. - // Generated by `bin/generate-identifier-regex.js`. +var pp = Parser.prototype - var nonASCIIidentifierStartChars = "\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u037f\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u052f\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0-\u08b4\u08b6-\u08bd\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0aaa-\u0ab0\u0ab2\u0ab3\u0ab5-\u0ab9\u0abd\u0ad0\u0ae0\u0ae1\u0af9\u0b05-\u0b0c\u0b0f\u0b10\u0b13-\u0b28\u0b2a-\u0b30\u0b32\u0b33\u0b35-\u0b39\u0b3d\u0b5c\u0b5d\u0b5f-\u0b61\u0b71\u0b83\u0b85-\u0b8a\u0b8e-\u0b90\u0b92-\u0b95\u0b99\u0b9a\u0b9c\u0b9e\u0b9f\u0ba3\u0ba4\u0ba8-\u0baa\u0bae-\u0bb9\u0bd0\u0c05-\u0c0c\u0c0e-\u0c10\u0c12-\u0c28\u0c2a-\u0c39\u0c3d\u0c58-\u0c5a\u0c60\u0c61\u0c80\u0c85-\u0c8c\u0c8e-\u0c90\u0c92-\u0ca8\u0caa-\u0cb3\u0cb5-\u0cb9\u0cbd\u0cde\u0ce0\u0ce1\u0cf1\u0cf2\u0d05-\u0d0c\u0d0e-\u0d10\u0d12-\u0d3a\u0d3d\u0d4e\u0d54-\u0d56\u0d5f-\u0d61\u0d7a-\u0d7f\u0d85-\u0d96\u0d9a-\u0db1\u0db3-\u0dbb\u0dbd\u0dc0-\u0dc6\u0e01-\u0e30\u0e32\u0e33\u0e40-\u0e46\u0e81\u0e82\u0e84\u0e87\u0e88\u0e8a\u0e8d\u0e94-\u0e97\u0e99-\u0e9f\u0ea1-\u0ea3\u0ea5\u0ea7\u0eaa\u0eab\u0ead-\u0eb0\u0eb2\u0eb3\u0ebd\u0ec0-\u0ec4\u0ec6\u0edc-\u0edf\u0f00\u0f40-\u0f47\u0f49-\u0f6c\u0f88-\u0f8c\u1000-\u102a\u103f\u1050-\u1055\u105a-\u105d\u1061\u1065\u1066\u106e-\u1070\u1075-\u1081\u108e\u10a0-\u10c5\u10c7\u10cd\u10d0-\u10fa\u10fc-\u1248\u124a-\u124d\u1250-\u1256\u1258\u125a-\u125d\u1260-\u1288\u128a-\u128d\u1290-\u12b0\u12b2-\u12b5\u12b8-\u12be\u12c0\u12c2-\u12c5\u12c8-\u12d6\u12d8-\u1310\u1312-\u1315\u1318-\u135a\u1380-\u138f\u13a0-\u13f5\u13f8-\u13fd\u1401-\u166c\u166f-\u167f\u1681-\u169a\u16a0-\u16ea\u16ee-\u16f8\u1700-\u170c\u170e-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176c\u176e-\u1770\u1780-\u17b3\u17d7\u17dc\u1820-\u1877\u1880-\u18a8\u18aa\u18b0-\u18f5\u1900-\u191e\u1950-\u196d\u1970-\u1974\u1980-\u19ab\u19b0-\u19c9\u1a00-\u1a16\u1a20-\u1a54\u1aa7\u1b05-\u1b33\u1b45-\u1b4b\u1b83-\u1ba0\u1bae\u1baf\u1bba-\u1be5\u1c00-\u1c23\u1c4d-\u1c4f\u1c5a-\u1c7d\u1c80-\u1c88\u1ce9-\u1cec\u1cee-\u1cf1\u1cf5\u1cf6\u1d00-\u1dbf\u1e00-\u1f15\u1f18-\u1f1d\u1f20-\u1f45\u1f48-\u1f4d\u1f50-\u1f57\u1f59\u1f5b\u1f5d\u1f5f-\u1f7d\u1f80-\u1fb4\u1fb6-\u1fbc\u1fbe\u1fc2-\u1fc4\u1fc6-\u1fcc\u1fd0-\u1fd3\u1fd6-\u1fdb\u1fe0-\u1fec\u1ff2-\u1ff4\u1ff6-\u1ffc\u2071\u207f\u2090-\u209c\u2102\u2107\u210a-\u2113\u2115\u2118-\u211d\u2124\u2126\u2128\u212a-\u2139\u213c-\u213f\u2145-\u2149\u214e\u2160-\u2188\u2c00-\u2c2e\u2c30-\u2c5e\u2c60-\u2ce4\u2ceb-\u2cee\u2cf2\u2cf3\u2d00-\u2d25\u2d27\u2d2d\u2d30-\u2d67\u2d6f\u2d80-\u2d96\u2da0-\u2da6\u2da8-\u2dae\u2db0-\u2db6\u2db8-\u2dbe\u2dc0-\u2dc6\u2dc8-\u2dce\u2dd0-\u2dd6\u2dd8-\u2dde\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303c\u3041-\u3096\u309b-\u309f\u30a1-\u30fa\u30fc-\u30ff\u3105-\u312d\u3131-\u318e\u31a0-\u31ba\u31f0-\u31ff\u3400-\u4db5\u4e00-\u9fd5\ua000-\ua48c\ua4d0-\ua4fd\ua500-\ua60c\ua610-\ua61f\ua62a\ua62b\ua640-\ua66e\ua67f-\ua69d\ua6a0-\ua6ef\ua717-\ua71f\ua722-\ua788\ua78b-\ua7ae\ua7b0-\ua7b7\ua7f7-\ua801\ua803-\ua805\ua807-\ua80a\ua80c-\ua822\ua840-\ua873\ua882-\ua8b3\ua8f2-\ua8f7\ua8fb\ua8fd\ua90a-\ua925\ua930-\ua946\ua960-\ua97c\ua984-\ua9b2\ua9cf\ua9e0-\ua9e4\ua9e6-\ua9ef\ua9fa-\ua9fe\uaa00-\uaa28\uaa40-\uaa42\uaa44-\uaa4b\uaa60-\uaa76\uaa7a\uaa7e-\uaaaf\uaab1\uaab5\uaab6\uaab9-\uaabd\uaac0\uaac2\uaadb-\uaadd\uaae0-\uaaea\uaaf2-\uaaf4\uab01-\uab06\uab09-\uab0e\uab11-\uab16\uab20-\uab26\uab28-\uab2e\uab30-\uab5a\uab5c-\uab65\uab70-\uabe2\uac00-\ud7a3\ud7b0-\ud7c6\ud7cb-\ud7fb\uf900-\ufa6d\ufa70-\ufad9\ufb00-\ufb06\ufb13-\ufb17\ufb1d\ufb1f-\ufb28\ufb2a-\ufb36\ufb38-\ufb3c\ufb3e\ufb40\ufb41\ufb43\ufb44\ufb46-\ufbb1\ufbd3-\ufd3d\ufd50-\ufd8f\ufd92-\ufdc7\ufdf0-\ufdfb\ufe70-\ufe74\ufe76-\ufefc\uff21-\uff3a\uff41-\uff5a\uff66-\uffbe\uffc2-\uffc7\uffca-\uffcf\uffd2-\uffd7\uffda-\uffdc" - var nonASCIIidentifierChars = "\u200c\u200d\xb7\u0300-\u036f\u0387\u0483-\u0487\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u0669\u0670\u06d6-\u06dc\u06df-\u06e4\u06e7\u06e8\u06ea-\u06ed\u06f0-\u06f9\u0711\u0730-\u074a\u07a6-\u07b0\u07c0-\u07c9\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0859-\u085b\u08d4-\u08e1\u08e3-\u0903\u093a-\u093c\u093e-\u094f\u0951-\u0957\u0962\u0963\u0966-\u096f\u0981-\u0983\u09bc\u09be-\u09c4\u09c7\u09c8\u09cb-\u09cd\u09d7\u09e2\u09e3\u09e6-\u09ef\u0a01-\u0a03\u0a3c\u0a3e-\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a66-\u0a71\u0a75\u0a81-\u0a83\u0abc\u0abe-\u0ac5\u0ac7-\u0ac9\u0acb-\u0acd\u0ae2\u0ae3\u0ae6-\u0aef\u0b01-\u0b03\u0b3c\u0b3e-\u0b44\u0b47\u0b48\u0b4b-\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b66-\u0b6f\u0b82\u0bbe-\u0bc2\u0bc6-\u0bc8\u0bca-\u0bcd\u0bd7\u0be6-\u0bef\u0c00-\u0c03\u0c3e-\u0c44\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0c66-\u0c6f\u0c81-\u0c83\u0cbc\u0cbe-\u0cc4\u0cc6-\u0cc8\u0cca-\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0ce6-\u0cef\u0d01-\u0d03\u0d3e-\u0d44\u0d46-\u0d48\u0d4a-\u0d4d\u0d57\u0d62\u0d63\u0d66-\u0d6f\u0d82\u0d83\u0dca\u0dcf-\u0dd4\u0dd6\u0dd8-\u0ddf\u0de6-\u0def\u0df2\u0df3\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0e50-\u0e59\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0ed0-\u0ed9\u0f18\u0f19\u0f20-\u0f29\u0f35\u0f37\u0f39\u0f3e\u0f3f\u0f71-\u0f84\u0f86\u0f87\u0f8d-\u0f97\u0f99-\u0fbc\u0fc6\u102b-\u103e\u1040-\u1049\u1056-\u1059\u105e-\u1060\u1062-\u1064\u1067-\u106d\u1071-\u1074\u1082-\u108d\u108f-\u109d\u135d-\u135f\u1369-\u1371\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b4-\u17d3\u17dd\u17e0-\u17e9\u180b-\u180d\u1810-\u1819\u18a9\u1920-\u192b\u1930-\u193b\u1946-\u194f\u19d0-\u19da\u1a17-\u1a1b\u1a55-\u1a5e\u1a60-\u1a7c\u1a7f-\u1a89\u1a90-\u1a99\u1ab0-\u1abd\u1b00-\u1b04\u1b34-\u1b44\u1b50-\u1b59\u1b6b-\u1b73\u1b80-\u1b82\u1ba1-\u1bad\u1bb0-\u1bb9\u1be6-\u1bf3\u1c24-\u1c37\u1c40-\u1c49\u1c50-\u1c59\u1cd0-\u1cd2\u1cd4-\u1ce8\u1ced\u1cf2-\u1cf4\u1cf8\u1cf9\u1dc0-\u1df5\u1dfb-\u1dff\u203f\u2040\u2054\u20d0-\u20dc\u20e1\u20e5-\u20f0\u2cef-\u2cf1\u2d7f\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua620-\ua629\ua66f\ua674-\ua67d\ua69e\ua69f\ua6f0\ua6f1\ua802\ua806\ua80b\ua823-\ua827\ua880\ua881\ua8b4-\ua8c5\ua8d0-\ua8d9\ua8e0-\ua8f1\ua900-\ua909\ua926-\ua92d\ua947-\ua953\ua980-\ua983\ua9b3-\ua9c0\ua9d0-\ua9d9\ua9e5\ua9f0-\ua9f9\uaa29-\uaa36\uaa43\uaa4c\uaa4d\uaa50-\uaa59\uaa7b-\uaa7d\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uaaeb-\uaaef\uaaf5\uaaf6\uabe3-\uabea\uabec\uabed\uabf0-\uabf9\ufb1e\ufe00-\ufe0f\ufe20-\ufe2f\ufe33\ufe34\ufe4d-\ufe4f\uff10-\uff19\uff3f" +// ## Parser utilities - var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]") - var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]") +// Test whether a statement node is the string literal `"use strict"`. - nonASCIIidentifierStartChars = nonASCIIidentifierChars = null +pp.isUseStrict = function(stmt) { + return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && + stmt.expression.type === "Literal" && + stmt.expression.raw.slice(1, -1) === "use strict" +} - // These are a run-length and offset encoded representation of the - // >0xffff code points that are a valid part of identifiers. The - // offset starts at 0x10000, and each pair of numbers represents an - // offset to the next range, and then a size of the range. They were - // generated by bin/generate-identifier-regex.js - var astralIdentifierStartCodes = [0,11,2,25,2,18,2,1,2,14,3,13,35,122,70,52,268,28,4,48,48,31,17,26,6,37,11,29,3,35,5,7,2,4,43,157,19,35,5,35,5,39,9,51,157,310,10,21,11,7,153,5,3,0,2,43,2,1,4,0,3,22,11,22,10,30,66,18,2,1,11,21,11,25,71,55,7,1,65,0,16,3,2,2,2,26,45,28,4,28,36,7,2,27,28,53,11,21,11,18,14,17,111,72,56,50,14,50,785,52,76,44,33,24,27,35,42,34,4,0,13,47,15,3,22,0,2,0,36,17,2,24,85,6,2,0,2,3,2,14,2,9,8,46,39,7,3,1,3,21,2,6,2,1,2,4,4,0,19,0,13,4,159,52,19,3,54,47,21,1,2,0,185,46,42,3,37,47,21,0,60,42,86,25,391,63,32,0,449,56,264,8,2,36,18,0,50,29,881,921,103,110,18,195,2749,1070,4050,582,8634,568,8,30,114,29,19,47,17,3,32,20,6,18,881,68,12,0,67,12,65,0,32,6124,20,754,9486,1,3071,106,6,12,4,8,8,9,5991,84,2,70,2,1,3,0,3,1,3,3,2,11,2,0,2,6,2,64,2,3,3,7,2,6,2,27,2,3,2,4,2,0,4,6,2,339,3,24,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,30,2,24,2,7,4149,196,60,67,1213,3,2,26,2,1,2,0,3,0,2,9,2,3,2,0,2,0,7,0,5,0,2,0,2,0,2,2,2,1,2,0,3,0,2,0,2,0,2,0,2,0,2,1,2,0,3,3,2,6,2,3,2,3,2,0,2,9,2,16,6,2,2,4,2,16,4421,42710,42,4148,12,221,3,5761,10591,541] - var astralIdentifierCodes = [509,0,227,0,150,4,294,9,1368,2,2,1,6,3,41,2,5,0,166,1,1306,2,54,14,32,9,16,3,46,10,54,9,7,2,37,13,2,9,52,0,13,2,49,13,10,2,4,9,83,11,7,0,161,11,6,9,7,3,57,0,2,6,3,1,3,2,10,0,11,1,3,6,4,4,193,17,10,9,87,19,13,9,214,6,3,8,28,1,83,16,16,9,82,12,9,9,84,14,5,9,423,9,838,7,2,7,17,9,57,21,2,13,19882,9,135,4,60,6,26,9,1016,45,17,3,19723,1,5319,4,4,5,9,7,3,6,31,3,149,2,1418,49,513,54,5,49,9,0,15,0,23,4,2,14,1361,6,2,16,3,6,2,1,2,4,2214,6,110,6,6,9,792487,239] +// Predicate that tests whether the next token is of the given +// type, and if yes, consumes it as a side effect. - // This has a complexity linear to the value of the code. The - // assumption is that looking up astral identifier characters is - // rare. - function isInAstralSet(code, set) { - var pos = 0x10000 - for (var i = 0; i < set.length; i += 2) { - pos += set[i] - if (pos > code) return false - pos += set[i + 1] - if (pos >= code) return true - } +pp.eat = function(type) { + if (this.type === type) { + this.next() + return true + } else { + return false } +} - // Test whether a given character code starts an identifier. - - function isIdentifierStart(code, astral) { - if (code < 65) return code === 36 - if (code < 91) return true - if (code < 97) return code === 95 - if (code < 123) return true - if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifierStart.test(String.fromCharCode(code)) - if (astral === false) return false - return isInAstralSet(code, astralIdentifierStartCodes) - } +// Tests whether parsed token is a contextual keyword. - // Test whether a given character is part of an identifier. +pp.isContextual = function(name) { + return this.type === tt.name && this.value === name +} - function isIdentifierChar(code, astral) { - if (code < 48) return code === 36 - if (code < 58) return true - if (code < 65) return false - if (code < 91) return true - if (code < 97) return code === 95 - if (code < 123) return true - if (code <= 0xffff) return code >= 0xaa && nonASCIIidentifier.test(String.fromCharCode(code)) - if (astral === false) return false - return isInAstralSet(code, astralIdentifierStartCodes) || isInAstralSet(code, astralIdentifierCodes) - } +// Consumes contextual keyword if possible. - // ## Token types +pp.eatContextual = function(name) { + return this.value === name && this.eat(tt.name) +} - // The assignment of fine-grained, information-carrying type objects - // allows the tokenizer to store the information it has about a - // token in a way that is very cheap for the parser to look up. +// Asserts that following token is given contextual keyword. - // All token type variables start with an underscore, to make them - // easy to recognize. +pp.expectContextual = function(name) { + if (!this.eatContextual(name)) this.unexpected() +} - // The `beforeExpr` property is used to disambiguate between regular - // expressions and divisions. It is set on all token types that can - // be followed by an expression (thus, a slash after them would be a - // regular expression). - // - // The `startsExpr` property is used to check if the token ends a - // `yield` expression. It is set on all token types that either can - // directly start an expression (like a quotation mark) or can - // continue an expression (like the body of a string). - // - // `isLoop` marks a keyword as starting a loop, which is important - // to know when parsing a label, in order to allow or disallow - // continue jumps to that label. - - var TokenType = function TokenType(label, conf) { - if ( conf === void 0 ) conf = {}; - - this.label = label - this.keyword = conf.keyword - this.beforeExpr = !!conf.beforeExpr - this.startsExpr = !!conf.startsExpr - this.isLoop = !!conf.isLoop - this.isAssign = !!conf.isAssign - this.prefix = !!conf.prefix - this.postfix = !!conf.postfix - this.binop = conf.binop || null - this.updateContext = null - }; - - function binop(name, prec) { - return new TokenType(name, {beforeExpr: true, binop: prec}) - } - var beforeExpr = {beforeExpr: true}; - var startsExpr = {startsExpr: true}; - // Map keyword names to token types. - - var keywordTypes = {} - - // Succinct definitions of keyword token types - function kw(name, options) { - if ( options === void 0 ) options = {}; - - options.keyword = name - return keywordTypes[name] = new TokenType(name, options) - } - - var tt = { - num: new TokenType("num", startsExpr), - regexp: new TokenType("regexp", startsExpr), - string: new TokenType("string", startsExpr), - name: new TokenType("name", startsExpr), - eof: new TokenType("eof"), - - // Punctuation token types. - bracketL: new TokenType("[", {beforeExpr: true, startsExpr: true}), - bracketR: new TokenType("]"), - braceL: new TokenType("{", {beforeExpr: true, startsExpr: true}), - braceR: new TokenType("}"), - parenL: new TokenType("(", {beforeExpr: true, startsExpr: true}), - parenR: new TokenType(")"), - comma: new TokenType(",", beforeExpr), - semi: new TokenType(";", beforeExpr), - colon: new TokenType(":", beforeExpr), - dot: new TokenType("."), - question: new TokenType("?", beforeExpr), - arrow: new TokenType("=>", beforeExpr), - template: new TokenType("template"), - ellipsis: new TokenType("...", beforeExpr), - backQuote: new TokenType("`", startsExpr), - dollarBraceL: new TokenType("${", {beforeExpr: true, startsExpr: true}), - - // Operators. These carry several kinds of properties to help the - // parser use them properly (the presence of these properties is - // what categorizes them as operators). - // - // `binop`, when present, specifies that this operator is a binary - // operator, and will refer to its precedence. - // - // `prefix` and `postfix` mark the operator as a prefix or postfix - // unary operator. - // - // `isAssign` marks all of `=`, `+=`, `-=` etcetera, which act as - // binary operators with a very low precedence, that should result - // in AssignmentExpression nodes. - - eq: new TokenType("=", {beforeExpr: true, isAssign: true}), - assign: new TokenType("_=", {beforeExpr: true, isAssign: true}), - incDec: new TokenType("++/--", {prefix: true, postfix: true, startsExpr: true}), - prefix: new TokenType("prefix", {beforeExpr: true, prefix: true, startsExpr: true}), - logicalOR: binop("||", 1), - logicalAND: binop("&&", 2), - bitwiseOR: binop("|", 3), - bitwiseXOR: binop("^", 4), - bitwiseAND: binop("&", 5), - equality: binop("==/!=", 6), - relational: binop("", 7), - bitShift: binop("<>", 8), - plusMin: new TokenType("+/-", {beforeExpr: true, binop: 9, prefix: true, startsExpr: true}), - modulo: binop("%", 10), - star: binop("*", 10), - slash: binop("/", 10), - starstar: new TokenType("**", {beforeExpr: true}), - - // Keyword token types. - _break: kw("break"), - _case: kw("case", beforeExpr), - _catch: kw("catch"), - _continue: kw("continue"), - _debugger: kw("debugger"), - _default: kw("default", beforeExpr), - _do: kw("do", {isLoop: true, beforeExpr: true}), - _else: kw("else", beforeExpr), - _finally: kw("finally"), - _for: kw("for", {isLoop: true}), - _function: kw("function", startsExpr), - _if: kw("if"), - _return: kw("return", beforeExpr), - _switch: kw("switch"), - _throw: kw("throw", beforeExpr), - _try: kw("try"), - _var: kw("var"), - _const: kw("const"), - _while: kw("while", {isLoop: true}), - _with: kw("with"), - _new: kw("new", {beforeExpr: true, startsExpr: true}), - _this: kw("this", startsExpr), - _super: kw("super", startsExpr), - _class: kw("class"), - _extends: kw("extends", beforeExpr), - _export: kw("export"), - _import: kw("import"), - _null: kw("null", startsExpr), - _true: kw("true", startsExpr), - _false: kw("false", startsExpr), - _in: kw("in", {beforeExpr: true, binop: 7}), - _instanceof: kw("instanceof", {beforeExpr: true, binop: 7}), - _typeof: kw("typeof", {beforeExpr: true, prefix: true, startsExpr: true}), - _void: kw("void", {beforeExpr: true, prefix: true, startsExpr: true}), - _delete: kw("delete", {beforeExpr: true, prefix: true, startsExpr: true}) - } - - // Matches a whole line break (where CRLF is considered a single - // line break). Used to count lines. - - var lineBreak = /\r\n?|\n|\u2028|\u2029/ - var lineBreakG = new RegExp(lineBreak.source, "g") - - function isNewLine(code) { - return code === 10 || code === 13 || code === 0x2028 || code === 0x2029 - } - - var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/ - - var skipWhiteSpace = /(?:\s|\/\/.*|\/\*[^]*?\*\/)*/g - - function isArray(obj) { - return Object.prototype.toString.call(obj) === "[object Array]" - } - - // Checks if an object has a property. - - function has(obj, propName) { - return Object.prototype.hasOwnProperty.call(obj, propName) - } - - // These are used when `options.locations` is on, for the - // `startLoc` and `endLoc` properties. - - var Position = function Position(line, col) { - this.line = line - this.column = col - }; - - Position.prototype.offset = function offset (n) { - return new Position(this.line, this.column + n) - }; - - var SourceLocation = function SourceLocation(p, start, end) { - this.start = start - this.end = end - if (p.sourceFile !== null) this.source = p.sourceFile - }; - - // The `getLineInfo` function is mostly useful when the - // `locations` option is off (for performance reasons) and you - // want to find the line/column position for a given character - // offset. `input` should be the code string that the offset refers - // into. - - function getLineInfo(input, offset) { - for (var line = 1, cur = 0;;) { - lineBreakG.lastIndex = cur - var match = lineBreakG.exec(input) - if (match && match.index < offset) { - ++line - cur = match.index + match[0].length - } else { - return new Position(line, offset - cur) - } - } - } +// Test whether a semicolon can be inserted at the current position. - // A second optional argument can be given to further configure - // the parser process. These options are recognized: - - var defaultOptions = { - // `ecmaVersion` indicates the ECMAScript version to parse. Must - // be either 3, 5, 6 (2015), 7 (2016), or 8 (2017). This influences support - // for strict mode, the set of reserved words, and support for - // new syntax features. The default is 7. - ecmaVersion: 7, - // `sourceType` indicates the mode the code should be parsed in. - // Can be either `"script"` or `"module"`. This influences global - // strict mode and parsing of `import` and `export` declarations. - sourceType: "script", - // `onInsertedSemicolon` can be a callback that will be called - // when a semicolon is automatically inserted. It will be passed - // th position of the comma as an offset, and if `locations` is - // enabled, it is given the location as a `{line, column}` object - // as second argument. - onInsertedSemicolon: null, - // `onTrailingComma` is similar to `onInsertedSemicolon`, but for - // trailing commas. - onTrailingComma: null, - // By default, reserved words are only enforced if ecmaVersion >= 5. - // Set `allowReserved` to a boolean value to explicitly turn this on - // an off. When this option has the value "never", reserved words - // and keywords can also not be used as property names. - allowReserved: null, - // When enabled, a return at the top level is not considered an - // error. - allowReturnOutsideFunction: false, - // When enabled, import/export statements are not constrained to - // appearing at the top of the program. - allowImportExportEverywhere: false, - // When enabled, hashbang directive in the beginning of file - // is allowed and treated as a line comment. - allowHashBang: false, - // When `locations` is on, `loc` properties holding objects with - // `start` and `end` properties in `{line, column}` form (with - // line being 1-based and column 0-based) will be attached to the - // nodes. - locations: false, - // A function can be passed as `onToken` option, which will - // cause Acorn to call that function with object in the same - // format as tokens returned from `tokenizer().getToken()`. Note - // that you are not allowed to call the parser from the - // callback—that will corrupt its internal state. - onToken: null, - // A function can be passed as `onComment` option, which will - // cause Acorn to call that function with `(block, text, start, - // end)` parameters whenever a comment is skipped. `block` is a - // boolean indicating whether this is a block (`/* */`) comment, - // `text` is the content of the comment, and `start` and `end` are - // character offsets that denote the start and end of the comment. - // When the `locations` option is on, two more parameters are - // passed, the full `{line, column}` locations of the start and - // end of the comments. Note that you are not allowed to call the - // parser from the callback—that will corrupt its internal state. - onComment: null, - // Nodes have their start and end characters offsets recorded in - // `start` and `end` properties (directly on the node, rather than - // the `loc` object, which holds line/column data. To also add a - // [semi-standardized][range] `range` property holding a `[start, - // end]` array with the same numbers, set the `ranges` option to - // `true`. - // - // [range]: https://bugzilla.mozilla.org/show_bug.cgi?id=745678 - ranges: false, - // It is possible to parse multiple files into a single AST by - // passing the tree produced by parsing the first file as - // `program` option in subsequent parses. This will add the - // toplevel forms of the parsed file to the `Program` (top) node - // of an existing parse tree. - program: null, - // When `locations` is on, you can pass this to record the source - // file in every node's `loc` object. - sourceFile: null, - // This value, if given, is stored in every node, whether - // `locations` is on or off. - directSourceFile: null, - // When enabled, parenthesized expressions are represented by - // (non-standard) ParenthesizedExpression nodes - preserveParens: false, - plugins: {} - } - - // Interpret and default an options object - - function getOptions(opts) { - var options = {} - - for (var opt in defaultOptions) - options[opt] = opts && has(opts, opt) ? opts[opt] : defaultOptions[opt] - - if (options.ecmaVersion >= 2015) - options.ecmaVersion -= 2009 - - if (options.allowReserved == null) - options.allowReserved = options.ecmaVersion < 5 - - if (isArray(options.onToken)) { - var tokens = options.onToken - options.onToken = function (token) { return tokens.push(token); } - } - if (isArray(options.onComment)) - options.onComment = pushComment(options, options.onComment) +pp.canInsertSemicolon = function() { + return this.type === tt.eof || + this.type === tt.braceR || + lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) +} - return options +pp.insertSemicolon = function() { + if (this.canInsertSemicolon()) { + if (this.options.onInsertedSemicolon) + this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc) + return true } +} - function pushComment(options, array) { - return function (block, text, start, end, startLoc, endLoc) { - var comment = { - type: block ? 'Block' : 'Line', - value: text, - start: start, - end: end - } - if (options.locations) - comment.loc = new SourceLocation(this, startLoc, endLoc) - if (options.ranges) - comment.range = [start, end] - array.push(comment) - } - } +// Consume a semicolon, or, failing that, see if we are allowed to +// pretend that there is a semicolon at this position. - // Registered plugins - var plugins = {} +pp.semicolon = function() { + if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected() +} - function keywordRegexp(words) { - return new RegExp("^(" + words.replace(/ /g, "|") + ")$") +pp.afterTrailingComma = function(tokType, notNext) { + if (this.type == tokType) { + if (this.options.onTrailingComma) + this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc) + if (!notNext) + this.next() + return true } +} - var Parser = function Parser(options, input, startPos) { - this.options = options = getOptions(options) - this.sourceFile = options.sourceFile - this.keywords = keywordRegexp(keywords[options.ecmaVersion >= 6 ? 6 : 5]) - var reserved = "" - if (!options.allowReserved) { - for (var v = options.ecmaVersion;; v--) - if (reserved = reservedWords[v]) break - if (options.sourceType == "module") reserved += " await" - } - this.reservedWords = keywordRegexp(reserved) - var reservedStrict = (reserved ? reserved + " " : "") + reservedWords.strict - this.reservedWordsStrict = keywordRegexp(reservedStrict) - this.reservedWordsStrictBind = keywordRegexp(reservedStrict + " " + reservedWords.strictBind) - this.input = String(input) - - // Used to signal to callers of `readWord1` whether the word - // contained any escape sequences. This is needed because words with - // escape sequences must not be interpreted as keywords. - this.containsEsc = false - - // Load plugins - this.loadPlugins(options.plugins) - - // Set up token state - - // The current position of the tokenizer in the input. - if (startPos) { - this.pos = startPos - this.lineStart = this.input.lastIndexOf("\n", startPos - 1) + 1 - this.curLine = this.input.slice(0, this.lineStart).split(lineBreak).length - } else { - this.pos = this.lineStart = 0 - this.curLine = 1 - } - - // Properties of the current token: - // Its type - this.type = tt.eof - // For tokens that include more information than their type, the value - this.value = null - // Its start and end offset - this.start = this.end = this.pos - // And, if locations are used, the {line, column} object - // corresponding to those offsets - this.startLoc = this.endLoc = this.curPosition() - - // Position information for the previous token - this.lastTokEndLoc = this.lastTokStartLoc = null - this.lastTokStart = this.lastTokEnd = this.pos - - // The context stack is used to superficially track syntactic - // context to predict whether a regular expression is allowed in a - // given position. - this.context = this.initialContext() - this.exprAllowed = true - - // Figure out if it's a module code. - this.strict = this.inModule = options.sourceType === "module" +// Expect a token of a given type. If found, consume it, otherwise, +// raise an unexpected token error. - // Used to signify the start of a potential arrow function - this.potentialArrowAt = -1 +pp.expect = function(type) { + this.eat(type) || this.unexpected() +} - // Flags to track whether we are in a function, a generator, an async function. - this.inFunction = this.inGenerator = this.inAsync = false - // Positions to delayed-check that yield/await does not exist in default parameters. - this.yieldPos = this.awaitPos = 0 - // Labels in scope. - this.labels = [] +// Raise an unexpected token error. - // If enabled, skip leading hashbang line. - if (this.pos === 0 && options.allowHashBang && this.input.slice(0, 2) === '#!') - this.skipLineComment(2) - }; +pp.unexpected = function(pos) { + this.raise(pos != null ? pos : this.start, "Unexpected token") +} - // DEPRECATED Kept for backwards compatibility until 3.0 in case a plugin uses them - Parser.prototype.isKeyword = function isKeyword (word) { return this.keywords.test(word) }; - Parser.prototype.isReservedWord = function isReservedWord (word) { return this.reservedWords.test(word) }; +var DestructuringErrors = function DestructuringErrors() { + this.shorthandAssign = 0 + this.trailingComma = 0 +}; - Parser.prototype.extend = function extend (name, f) { - this[name] = f(this[name]) - }; +pp.checkPatternErrors = function(refDestructuringErrors, andThrow) { + var trailing = refDestructuringErrors && refDestructuringErrors.trailingComma + if (!andThrow) return !!trailing + if (trailing) this.raise(trailing, "Comma is not permitted after the rest element") +} - Parser.prototype.loadPlugins = function loadPlugins (pluginConfigs) { - var this$1 = this; +pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) { + var pos = refDestructuringErrors && refDestructuringErrors.shorthandAssign + if (!andThrow) return !!pos + if (pos) this.raise(pos, "Shorthand property assignments are valid only in destructuring patterns") +} - for (var name in pluginConfigs) { - var plugin = plugins[name] - if (!plugin) throw new Error("Plugin '" + name + "' not found") - plugin(this$1, pluginConfigs[name]) - } - }; +pp.checkYieldAwaitInDefaultParams = function() { + if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) + this.raise(this.yieldPos, "Yield expression cannot be a default value") + if (this.awaitPos) + this.raise(this.awaitPos, "Await expression cannot be a default value") +} - Parser.prototype.parse = function parse () { - var node = this.options.program || this.startNode() - this.nextToken() - return this.parseTopLevel(node) - }; +var pp$1 = Parser.prototype - var pp = Parser.prototype +// ### Statement parsing - // ## Parser utilities +// Parse a program. Initializes the parser, reads any number of +// statements, and wraps them in a Program node. Optionally takes a +// `program` argument. If present, the statements will be appended +// to its body instead of creating a new node. - // Test whether a statement node is the string literal `"use strict"`. +pp$1.parseTopLevel = function(node) { + var this$1 = this; - pp.isUseStrict = function(stmt) { - return this.options.ecmaVersion >= 5 && stmt.type === "ExpressionStatement" && - stmt.expression.type === "Literal" && - stmt.expression.raw.slice(1, -1) === "use strict" + var first = true, exports = {} + if (!node.body) node.body = [] + while (this.type !== tt.eof) { + var stmt = this$1.parseStatement(true, true, exports) + node.body.push(stmt) + if (first) { + if (this$1.isUseStrict(stmt)) this$1.setStrict(true) + first = false + } } + this.next() + if (this.options.ecmaVersion >= 6) { + node.sourceType = this.options.sourceType + } + return this.finishNode(node, "Program") +} + +var loopLabel = {kind: "loop"}; +var switchLabel = {kind: "switch"}; +pp$1.isLet = function() { + if (this.type !== tt.name || this.options.ecmaVersion < 6 || this.value != "let") return false + skipWhiteSpace.lastIndex = this.pos + var skip = skipWhiteSpace.exec(this.input) + var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next) + if (nextCh === 91 || nextCh == 123) return true // '{' and '[' + if (isIdentifierStart(nextCh, true)) { + for (var pos = next + 1; isIdentifierChar(this.input.charCodeAt(pos), true); ++pos) {} + var ident = this.input.slice(next, pos) + if (!this.isKeyword(ident)) return true + } + return false +} + +// check 'async [no LineTerminator here] function' +// - 'async /*foo*/ function' is OK. +// - 'async /*\n*/ function' is invalid. +pp$1.isAsyncFunction = function() { + if (this.type !== tt.name || this.options.ecmaVersion < 8 || this.value != "async") + return false - // Predicate that tests whether the next token is of the given - // type, and if yes, consumes it as a side effect. - - pp.eat = function(type) { - if (this.type === type) { + skipWhiteSpace.lastIndex = this.pos + var skip = skipWhiteSpace.exec(this.input) + var next = this.pos + skip[0].length + return !lineBreak.test(this.input.slice(this.pos, next)) && + this.input.slice(next, next + 8) === "function" && + (next + 8 == this.input.length || !isIdentifierChar(this.input.charAt(next + 8))) +} + +// Parse a single statement. +// +// If expecting a statement and finding a slash operator, parse a +// regular expression literal. This is to handle cases like +// `if (foo) /blah/.exec(foo)`, where looking at the previous token +// does not help. + +pp$1.parseStatement = function(declaration, topLevel, exports) { + var starttype = this.type, node = this.startNode(), kind + + if (this.isLet()) { + starttype = tt._var + kind = "let" + } + + // Most types of statements are recognized by the keyword they + // start with. Many are trivial to parse, some require a bit of + // complexity. + + switch (starttype) { + case tt._break: case tt._continue: return this.parseBreakContinueStatement(node, starttype.keyword) + case tt._debugger: return this.parseDebuggerStatement(node) + case tt._do: return this.parseDoStatement(node) + case tt._for: return this.parseForStatement(node) + case tt._function: + if (!declaration && this.options.ecmaVersion >= 6) this.unexpected() + return this.parseFunctionStatement(node, false) + case tt._class: + if (!declaration) this.unexpected() + return this.parseClass(node, true) + case tt._if: return this.parseIfStatement(node) + case tt._return: return this.parseReturnStatement(node) + case tt._switch: return this.parseSwitchStatement(node) + case tt._throw: return this.parseThrowStatement(node) + case tt._try: return this.parseTryStatement(node) + case tt._const: case tt._var: + kind = kind || this.value + if (!declaration && kind != "var") this.unexpected() + return this.parseVarStatement(node, kind) + case tt._while: return this.parseWhileStatement(node) + case tt._with: return this.parseWithStatement(node) + case tt.braceL: return this.parseBlock() + case tt.semi: return this.parseEmptyStatement(node) + case tt._export: + case tt._import: + if (!this.options.allowImportExportEverywhere) { + if (!topLevel) + this.raise(this.start, "'import' and 'export' may only appear at the top level") + if (!this.inModule) + this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'") + } + return starttype === tt._import ? this.parseImport(node) : this.parseExport(node, exports) + + // If the statement does not start with a statement keyword or a + // brace, it's an ExpressionStatement or LabeledStatement. We + // simply start parsing an expression, and afterwards, if the + // next token is a colon and the expression was a simple + // Identifier node, we switch to interpreting it as a label. + default: + if (this.isAsyncFunction() && declaration) { this.next() - return true - } else { - return false + return this.parseFunctionStatement(node, true) } + + var maybeName = this.value, expr = this.parseExpression() + if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) + return this.parseLabeledStatement(node, maybeName, expr) + else return this.parseExpressionStatement(node, expr) } +} - // Tests whether parsed token is a contextual keyword. +pp$1.parseBreakContinueStatement = function(node, keyword) { + var this$1 = this; - pp.isContextual = function(name) { - return this.type === tt.name && this.value === name + var isBreak = keyword == "break" + this.next() + if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null + else if (this.type !== tt.name) this.unexpected() + else { + node.label = this.parseIdent() + this.semicolon() } - // Consumes contextual keyword if possible. - - pp.eatContextual = function(name) { - return this.value === name && this.eat(tt.name) + // Verify that there is an actual destination to break or + // continue to. + for (var i = 0; i < this.labels.length; ++i) { + var lab = this$1.labels[i] + if (node.label == null || lab.name === node.label.name) { + if (lab.kind != null && (isBreak || lab.kind === "loop")) break + if (node.label && isBreak) break + } + } + if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword) + return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement") +} + +pp$1.parseDebuggerStatement = function(node) { + this.next() + this.semicolon() + return this.finishNode(node, "DebuggerStatement") +} + +pp$1.parseDoStatement = function(node) { + this.next() + this.labels.push(loopLabel) + node.body = this.parseStatement(false) + this.labels.pop() + this.expect(tt._while) + node.test = this.parseParenExpression() + if (this.options.ecmaVersion >= 6) + this.eat(tt.semi) + else + this.semicolon() + return this.finishNode(node, "DoWhileStatement") +} + +// Disambiguating between a `for` and a `for`/`in` or `for`/`of` +// loop is non-trivial. Basically, we have to parse the init `var` +// statement or expression, disallowing the `in` operator (see +// the second parameter to `parseExpression`), and then check +// whether the next token is `in` or `of`. When there is no init +// part (semicolon immediately after the opening parenthesis), it +// is a regular `for` loop. + +pp$1.parseForStatement = function(node) { + this.next() + this.labels.push(loopLabel) + this.expect(tt.parenL) + if (this.type === tt.semi) return this.parseFor(node, null) + var isLet = this.isLet() + if (this.type === tt._var || this.type === tt._const || isLet) { + var init$1 = this.startNode(), kind = isLet ? "let" : this.value + this.next() + this.parseVar(init$1, true, kind) + this.finishNode(init$1, "VariableDeclaration") + if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1 && + !(kind !== "var" && init$1.declarations[0].init)) + return this.parseForIn(node, init$1) + return this.parseFor(node, init$1) + } + var refDestructuringErrors = new DestructuringErrors + var init = this.parseExpression(true, refDestructuringErrors) + if (this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) { + this.checkPatternErrors(refDestructuringErrors, true) + this.toAssignable(init) + this.checkLVal(init) + return this.parseForIn(node, init) + } else { + this.checkExpressionErrors(refDestructuringErrors, true) + } + return this.parseFor(node, init) +} + +pp$1.parseFunctionStatement = function(node, isAsync) { + this.next() + return this.parseFunction(node, true, false, isAsync) +} + +pp$1.isFunction = function() { + return this.type === tt._function || this.isAsyncFunction() +} + +pp$1.parseIfStatement = function(node) { + this.next() + node.test = this.parseParenExpression() + // allow function declarations in branches, but only in non-strict mode + node.consequent = this.parseStatement(!this.strict && this.isFunction()) + node.alternate = this.eat(tt._else) ? this.parseStatement(!this.strict && this.isFunction()) : null + return this.finishNode(node, "IfStatement") +} + +pp$1.parseReturnStatement = function(node) { + if (!this.inFunction && !this.options.allowReturnOutsideFunction) + this.raise(this.start, "'return' outside of function") + this.next() + + // In `return` (and `break`/`continue`), the keywords with + // optional arguments, we eagerly look for a semicolon or the + // possibility to insert one. + + if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null + else { node.argument = this.parseExpression(); this.semicolon() } + return this.finishNode(node, "ReturnStatement") +} + +pp$1.parseSwitchStatement = function(node) { + var this$1 = this; + + this.next() + node.discriminant = this.parseParenExpression() + node.cases = [] + this.expect(tt.braceL) + this.labels.push(switchLabel) + + // Statements under must be grouped (by label) in SwitchCase + // nodes. `cur` is used to keep the node that we are currently + // adding statements to. + + for (var cur, sawDefault = false; this.type != tt.braceR;) { + if (this$1.type === tt._case || this$1.type === tt._default) { + var isCase = this$1.type === tt._case + if (cur) this$1.finishNode(cur, "SwitchCase") + node.cases.push(cur = this$1.startNode()) + cur.consequent = [] + this$1.next() + if (isCase) { + cur.test = this$1.parseExpression() + } else { + if (sawDefault) this$1.raiseRecoverable(this$1.lastTokStart, "Multiple default clauses") + sawDefault = true + cur.test = null + } + this$1.expect(tt.colon) + } else { + if (!cur) this$1.unexpected() + cur.consequent.push(this$1.parseStatement(true)) + } + } + if (cur) this.finishNode(cur, "SwitchCase") + this.next() // Closing brace + this.labels.pop() + return this.finishNode(node, "SwitchStatement") +} + +pp$1.parseThrowStatement = function(node) { + this.next() + if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) + this.raise(this.lastTokEnd, "Illegal newline after throw") + node.argument = this.parseExpression() + this.semicolon() + return this.finishNode(node, "ThrowStatement") +} + +// Reused empty array added for node fields that are always empty. + +var empty = [] + +pp$1.parseTryStatement = function(node) { + this.next() + node.block = this.parseBlock() + node.handler = null + if (this.type === tt._catch) { + var clause = this.startNode() + this.next() + this.expect(tt.parenL) + clause.param = this.parseBindingAtom() + this.checkLVal(clause.param, true) + this.expect(tt.parenR) + clause.body = this.parseBlock() + node.handler = this.finishNode(clause, "CatchClause") + } + node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null + if (!node.handler && !node.finalizer) + this.raise(node.start, "Missing catch or finally clause") + return this.finishNode(node, "TryStatement") +} + +pp$1.parseVarStatement = function(node, kind) { + this.next() + this.parseVar(node, false, kind) + this.semicolon() + return this.finishNode(node, "VariableDeclaration") +} + +pp$1.parseWhileStatement = function(node) { + this.next() + node.test = this.parseParenExpression() + this.labels.push(loopLabel) + node.body = this.parseStatement(false) + this.labels.pop() + return this.finishNode(node, "WhileStatement") +} + +pp$1.parseWithStatement = function(node) { + if (this.strict) this.raise(this.start, "'with' in strict mode") + this.next() + node.object = this.parseParenExpression() + node.body = this.parseStatement(false) + return this.finishNode(node, "WithStatement") +} + +pp$1.parseEmptyStatement = function(node) { + this.next() + return this.finishNode(node, "EmptyStatement") +} + +pp$1.parseLabeledStatement = function(node, maybeName, expr) { + var this$1 = this; + + for (var i = 0; i < this.labels.length; ++i) + if (this$1.labels[i].name === maybeName) this$1.raise(expr.start, "Label '" + maybeName + "' is already declared") + var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null + for (var i$1 = this.labels.length - 1; i$1 >= 0; i$1--) { + var label = this$1.labels[i$1] + if (label.statementStart == node.start) { + label.statementStart = this$1.start + label.kind = kind + } else break + } + this.labels.push({name: maybeName, kind: kind, statementStart: this.start}) + node.body = this.parseStatement(true) + this.labels.pop() + node.label = expr + return this.finishNode(node, "LabeledStatement") +} + +pp$1.parseExpressionStatement = function(node, expr) { + node.expression = expr + this.semicolon() + return this.finishNode(node, "ExpressionStatement") +} + +// Parse a semicolon-enclosed block of statements, handling `"use +// strict"` declarations when `allowStrict` is true (used for +// function bodies). + +pp$1.parseBlock = function(allowStrict) { + var this$1 = this; + + var node = this.startNode(), first = true, oldStrict + node.body = [] + this.expect(tt.braceL) + while (!this.eat(tt.braceR)) { + var stmt = this$1.parseStatement(true) + node.body.push(stmt) + if (first && allowStrict && this$1.isUseStrict(stmt)) { + oldStrict = this$1.strict + this$1.setStrict(this$1.strict = true) + } + first = false + } + if (oldStrict === false) this.setStrict(false) + return this.finishNode(node, "BlockStatement") +} + +// Parse a regular `for` loop. The disambiguation code in +// `parseStatement` will already have parsed the init statement or +// expression. + +pp$1.parseFor = function(node, init) { + node.init = init + this.expect(tt.semi) + node.test = this.type === tt.semi ? null : this.parseExpression() + this.expect(tt.semi) + node.update = this.type === tt.parenR ? null : this.parseExpression() + this.expect(tt.parenR) + node.body = this.parseStatement(false) + this.labels.pop() + return this.finishNode(node, "ForStatement") +} + +// Parse a `for`/`in` and `for`/`of` loop, which are almost +// same from parser's perspective. + +pp$1.parseForIn = function(node, init) { + var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement" + this.next() + node.left = init + node.right = this.parseExpression() + this.expect(tt.parenR) + node.body = this.parseStatement(false) + this.labels.pop() + return this.finishNode(node, type) +} + +// Parse a list of variable declarations. + +pp$1.parseVar = function(node, isFor, kind) { + var this$1 = this; + + node.declarations = [] + node.kind = kind + for (;;) { + var decl = this$1.startNode() + this$1.parseVarId(decl) + if (this$1.eat(tt.eq)) { + decl.init = this$1.parseMaybeAssign(isFor) + } else if (kind === "const" && !(this$1.type === tt._in || (this$1.options.ecmaVersion >= 6 && this$1.isContextual("of")))) { + this$1.unexpected() + } else if (decl.id.type != "Identifier" && !(isFor && (this$1.type === tt._in || this$1.isContextual("of")))) { + this$1.raise(this$1.lastTokEnd, "Complex binding patterns require an initialization value") + } else { + decl.init = null + } + node.declarations.push(this$1.finishNode(decl, "VariableDeclarator")) + if (!this$1.eat(tt.comma)) break + } + return node +} + +pp$1.parseVarId = function(decl) { + decl.id = this.parseBindingAtom() + this.checkLVal(decl.id, true) +} + +// Parse a function declaration or literal (depending on the +// `isStatement` parameter). + +pp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) { + this.initFunction(node) + if (this.options.ecmaVersion >= 6 && !isAsync) + node.generator = this.eat(tt.star) + if (this.options.ecmaVersion >= 8) + node.async = !!isAsync + + if (isStatement) + node.id = this.parseIdent() + + var oldInGen = this.inGenerator, oldInAsync = this.inAsync, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos + this.inGenerator = node.generator + this.inAsync = node.async + this.yieldPos = 0 + this.awaitPos = 0 + + if (!isStatement && this.type === tt.name) + node.id = this.parseIdent() + this.parseFunctionParams(node) + this.parseFunctionBody(node, allowExpressionBody) + + this.inGenerator = oldInGen + this.inAsync = oldInAsync + this.yieldPos = oldYieldPos + this.awaitPos = oldAwaitPos + return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression") +} + +pp$1.parseFunctionParams = function(node) { + this.expect(tt.parenL) + node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8, true) + this.checkYieldAwaitInDefaultParams() +} + +// Parse a class declaration or literal (depending on the +// `isStatement` parameter). + +pp$1.parseClass = function(node, isStatement) { + var this$1 = this; + + this.next() + this.parseClassId(node, isStatement) + this.parseClassSuper(node) + var classBody = this.startNode() + var hadConstructor = false + classBody.body = [] + this.expect(tt.braceL) + while (!this.eat(tt.braceR)) { + if (this$1.eat(tt.semi)) continue + var method = this$1.startNode() + var isGenerator = this$1.eat(tt.star) + var isAsync = false + var isMaybeStatic = this$1.type === tt.name && this$1.value === "static" + this$1.parsePropertyName(method) + method.static = isMaybeStatic && this$1.type !== tt.parenL + if (method.static) { + if (isGenerator) this$1.unexpected() + isGenerator = this$1.eat(tt.star) + this$1.parsePropertyName(method) + } + if (this$1.options.ecmaVersion >= 8 && !isGenerator && !method.computed && + method.key.type === "Identifier" && method.key.name === "async" && this$1.type !== tt.parenL && + !this$1.canInsertSemicolon()) { + isAsync = true + this$1.parsePropertyName(method) + } + method.kind = "method" + var isGetSet = false + if (!method.computed) { + var key = method.key; + if (!isGenerator && !isAsync && key.type === "Identifier" && this$1.type !== tt.parenL && (key.name === "get" || key.name === "set")) { + isGetSet = true + method.kind = key.name + key = this$1.parsePropertyName(method) + } + if (!method.static && (key.type === "Identifier" && key.name === "constructor" || + key.type === "Literal" && key.value === "constructor")) { + if (hadConstructor) this$1.raise(key.start, "Duplicate constructor in the same class") + if (isGetSet) this$1.raise(key.start, "Constructor can't have get/set modifier") + if (isGenerator) this$1.raise(key.start, "Constructor can't be a generator") + if (isAsync) this$1.raise(key.start, "Constructor can't be an async method") + method.kind = "constructor" + hadConstructor = true + } + } + this$1.parseClassMethod(classBody, method, isGenerator, isAsync) + if (isGetSet) { + var paramCount = method.kind === "get" ? 0 : 1 + if (method.value.params.length !== paramCount) { + var start = method.value.start + if (method.kind === "get") + this$1.raiseRecoverable(start, "getter should have no params") + else + this$1.raiseRecoverable(start, "setter should have exactly one param") + } else { + if (method.kind === "set" && method.value.params[0].type === "RestElement") + this$1.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params") + } + } } + node.body = this.finishNode(classBody, "ClassBody") + return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") +} - // Asserts that following token is given contextual keyword. +pp$1.parseClassMethod = function(classBody, method, isGenerator, isAsync) { + method.value = this.parseMethod(isGenerator, isAsync) + classBody.body.push(this.finishNode(method, "MethodDefinition")) +} - pp.expectContextual = function(name) { - if (!this.eatContextual(name)) this.unexpected() - } +pp$1.parseClassId = function(node, isStatement) { + node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null +} - // Test whether a semicolon can be inserted at the current position. +pp$1.parseClassSuper = function(node) { + node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null +} - pp.canInsertSemicolon = function() { - return this.type === tt.eof || - this.type === tt.braceR || - lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) - } +// Parses module export declaration. - pp.insertSemicolon = function() { - if (this.canInsertSemicolon()) { - if (this.options.onInsertedSemicolon) - this.options.onInsertedSemicolon(this.lastTokEnd, this.lastTokEndLoc) - return true +pp$1.parseExport = function(node, exports) { + var this$1 = this; + + this.next() + // export * from '...' + if (this.eat(tt.star)) { + this.expectContextual("from") + node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() + this.semicolon() + return this.finishNode(node, "ExportAllDeclaration") + } + if (this.eat(tt._default)) { // export default ... + this.checkExport(exports, "default", this.lastTokStart) + var parens = this.type == tt.parenL + var expr = this.parseMaybeAssign() + var needsSemi = true + if (!parens && (expr.type == "FunctionExpression" || + expr.type == "ClassExpression")) { + needsSemi = false + if (expr.id) { + expr.type = expr.type == "FunctionExpression" + ? "FunctionDeclaration" + : "ClassDeclaration" + } } + node.declaration = expr + if (needsSemi) this.semicolon() + return this.finishNode(node, "ExportDefaultDeclaration") } + // export var|const|let|function|class ... + if (this.shouldParseExportStatement()) { + node.declaration = this.parseStatement(true) + if (node.declaration.type === "VariableDeclaration") + this.checkVariableExport(exports, node.declaration.declarations) + else + this.checkExport(exports, node.declaration.id.name, node.declaration.id.start) + node.specifiers = [] + node.source = null + } else { // export { x, y as z } [from '...'] + node.declaration = null + node.specifiers = this.parseExportSpecifiers(exports) + if (this.eatContextual("from")) { + node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() + } else { + // check for keywords used as local names + for (var i = 0; i < node.specifiers.length; i++) { + if (this$1.keywords.test(node.specifiers[i].local.name) || this$1.reservedWords.test(node.specifiers[i].local.name)) { + this$1.unexpected(node.specifiers[i].local.start) + } + } - // Consume a semicolon, or, failing that, see if we are allowed to - // pretend that there is a semicolon at this position. - - pp.semicolon = function() { - if (!this.eat(tt.semi) && !this.insertSemicolon()) this.unexpected() + node.source = null + } + this.semicolon() } - - pp.afterTrailingComma = function(tokType, notNext) { - if (this.type == tokType) { - if (this.options.onTrailingComma) - this.options.onTrailingComma(this.lastTokStart, this.lastTokStartLoc) - if (!notNext) - this.next() - return true + return this.finishNode(node, "ExportNamedDeclaration") +} + +pp$1.checkExport = function(exports, name, pos) { + if (!exports) return + if (Object.prototype.hasOwnProperty.call(exports, name)) + this.raiseRecoverable(pos, "Duplicate export '" + name + "'") + exports[name] = true +} + +pp$1.checkPatternExport = function(exports, pat) { + var this$1 = this; + + var type = pat.type + if (type == "Identifier") + this.checkExport(exports, pat.name, pat.start) + else if (type == "ObjectPattern") + for (var i = 0; i < pat.properties.length; ++i) + this$1.checkPatternExport(exports, pat.properties[i].value) + else if (type == "ArrayPattern") + for (var i$1 = 0; i$1 < pat.elements.length; ++i$1) { + var elt = pat.elements[i$1] + if (elt) this$1.checkPatternExport(exports, elt) + } + else if (type == "AssignmentPattern") + this.checkPatternExport(exports, pat.left) + else if (type == "ParenthesizedExpression") + this.checkPatternExport(exports, pat.expression) +} + +pp$1.checkVariableExport = function(exports, decls) { + var this$1 = this; + + if (!exports) return + for (var i = 0; i < decls.length; i++) + this$1.checkPatternExport(exports, decls[i].id) +} + +pp$1.shouldParseExportStatement = function() { + return this.type.keyword === "var" + || this.type.keyword === "const" + || this.type.keyword === "class" + || this.type.keyword === "function" + || this.isLet() + || this.isAsyncFunction() +} + +// Parses a comma-separated list of module exports. + +pp$1.parseExportSpecifiers = function(exports) { + var this$1 = this; + + var nodes = [], first = true + // export { x, y as z } [from '...'] + this.expect(tt.braceL) + while (!this.eat(tt.braceR)) { + if (!first) { + this$1.expect(tt.comma) + if (this$1.afterTrailingComma(tt.braceR)) break + } else first = false + + var node = this$1.startNode() + node.local = this$1.parseIdent(this$1.type === tt._default) + node.exported = this$1.eatContextual("as") ? this$1.parseIdent(true) : node.local + this$1.checkExport(exports, node.exported.name, node.exported.start) + nodes.push(this$1.finishNode(node, "ExportSpecifier")) + } + return nodes +} + +// Parses import declaration. + +pp$1.parseImport = function(node) { + this.next() + // import '...' + if (this.type === tt.string) { + node.specifiers = empty + node.source = this.parseExprAtom() + } else { + node.specifiers = this.parseImportSpecifiers() + this.expectContextual("from") + node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() + } + this.semicolon() + return this.finishNode(node, "ImportDeclaration") +} + +// Parses a comma-separated list of module imports. + +pp$1.parseImportSpecifiers = function() { + var this$1 = this; + + var nodes = [], first = true + if (this.type === tt.name) { + // import defaultObj, { x, y as z } from '...' + var node = this.startNode() + node.local = this.parseIdent() + this.checkLVal(node.local, true) + nodes.push(this.finishNode(node, "ImportDefaultSpecifier")) + if (!this.eat(tt.comma)) return nodes + } + if (this.type === tt.star) { + var node$1 = this.startNode() + this.next() + this.expectContextual("as") + node$1.local = this.parseIdent() + this.checkLVal(node$1.local, true) + nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier")) + return nodes + } + this.expect(tt.braceL) + while (!this.eat(tt.braceR)) { + if (!first) { + this$1.expect(tt.comma) + if (this$1.afterTrailingComma(tt.braceR)) break + } else first = false + + var node$2 = this$1.startNode() + node$2.imported = this$1.parseIdent(true) + if (this$1.eatContextual("as")) { + node$2.local = this$1.parseIdent() + } else { + node$2.local = node$2.imported + if (this$1.isKeyword(node$2.local.name)) this$1.unexpected(node$2.local.start) + if (this$1.reservedWordsStrict.test(node$2.local.name)) this$1.raiseRecoverable(node$2.local.start, "The keyword '" + node$2.local.name + "' is reserved") } + this$1.checkLVal(node$2.local, true) + nodes.push(this$1.finishNode(node$2, "ImportSpecifier")) } + return nodes +} - // Expect a token of a given type. If found, consume it, otherwise, - // raise an unexpected token error. - - pp.expect = function(type) { - this.eat(type) || this.unexpected() - } +var pp$2 = Parser.prototype - // Raise an unexpected token error. +// Convert existing expression atom to assignable pattern +// if possible. - pp.unexpected = function(pos) { - this.raise(pos != null ? pos : this.start, "Unexpected token") - } +pp$2.toAssignable = function(node, isBinding) { + var this$1 = this; - var DestructuringErrors = function DestructuringErrors() { - this.shorthandAssign = 0 - this.trailingComma = 0 - }; + if (this.options.ecmaVersion >= 6 && node) { + switch (node.type) { + case "Identifier": + if (this.inAsync && node.name === "await") + this.raise(node.start, "Can not use 'await' as identifier inside an async function") + break - pp.checkPatternErrors = function(refDestructuringErrors, andThrow) { - var trailing = refDestructuringErrors && refDestructuringErrors.trailingComma - if (!andThrow) return !!trailing - if (trailing) this.raise(trailing, "Comma is not permitted after the rest element") - } + case "ObjectPattern": + case "ArrayPattern": + break - pp.checkExpressionErrors = function(refDestructuringErrors, andThrow) { - var pos = refDestructuringErrors && refDestructuringErrors.shorthandAssign - if (!andThrow) return !!pos - if (pos) this.raise(pos, "Shorthand property assignments are valid only in destructuring patterns") - } + case "ObjectExpression": + node.type = "ObjectPattern" + for (var i = 0; i < node.properties.length; i++) { + var prop = node.properties[i] + if (prop.kind !== "init") this$1.raise(prop.key.start, "Object pattern can't contain getter or setter") + this$1.toAssignable(prop.value, isBinding) + } + break - pp.checkYieldAwaitInDefaultParams = function() { - if (this.yieldPos && (!this.awaitPos || this.yieldPos < this.awaitPos)) - this.raise(this.yieldPos, "Yield expression cannot be a default value") - if (this.awaitPos) - this.raise(this.awaitPos, "Await expression cannot be a default value") - } + case "ArrayExpression": + node.type = "ArrayPattern" + this.toAssignableList(node.elements, isBinding) + break - var pp$1 = Parser.prototype + case "AssignmentExpression": + if (node.operator === "=") { + node.type = "AssignmentPattern" + delete node.operator + this.toAssignable(node.left, isBinding) + // falls through to AssignmentPattern + } else { + this.raise(node.left.end, "Only '=' operator can be used for specifying default value.") + break + } - // ### Statement parsing + case "AssignmentPattern": + break - // Parse a program. Initializes the parser, reads any number of - // statements, and wraps them in a Program node. Optionally takes a - // `program` argument. If present, the statements will be appended - // to its body instead of creating a new node. + case "ParenthesizedExpression": + node.expression = this.toAssignable(node.expression, isBinding) + break - pp$1.parseTopLevel = function(node) { - var this$1 = this; + case "MemberExpression": + if (!isBinding) break - var first = true, exports = {} - if (!node.body) node.body = [] - while (this.type !== tt.eof) { - var stmt = this$1.parseStatement(true, true, exports) - node.body.push(stmt) - if (first) { - if (this$1.isUseStrict(stmt)) this$1.setStrict(true) - first = false - } - } - this.next() - if (this.options.ecmaVersion >= 6) { - node.sourceType = this.options.sourceType - } - return this.finishNode(node, "Program") - } - - var loopLabel = {kind: "loop"}; - var switchLabel = {kind: "switch"}; - pp$1.isLet = function() { - if (this.type !== tt.name || this.options.ecmaVersion < 6 || this.value != "let") return false - skipWhiteSpace.lastIndex = this.pos - var skip = skipWhiteSpace.exec(this.input) - var next = this.pos + skip[0].length, nextCh = this.input.charCodeAt(next) - if (nextCh === 91 || nextCh == 123) return true // '{' and '[' - if (isIdentifierStart(nextCh, true)) { - for (var pos = next + 1; isIdentifierChar(this.input.charCodeAt(pos), true); ++pos) {} - var ident = this.input.slice(next, pos) - if (!this.isKeyword(ident)) return true + default: + this.raise(node.start, "Assigning to rvalue") } - return false } + return node +} - // check 'async [no LineTerminator here] function' - // - 'async /*foo*/ function' is OK. - // - 'async /*\n*/ function' is invalid. - pp$1.isAsyncFunction = function() { - if (this.type !== tt.name || this.options.ecmaVersion < 8 || this.value != "async") - return false +// Convert list of expression atoms to binding list. - skipWhiteSpace.lastIndex = this.pos - var skip = skipWhiteSpace.exec(this.input) - var next = this.pos + skip[0].length - return !lineBreak.test(this.input.slice(this.pos, next)) && - this.input.slice(next, next + 8) === "function" && - (next + 8 == this.input.length || !isIdentifierChar(this.input.charAt(next + 8))) +pp$2.toAssignableList = function(exprList, isBinding) { + var this$1 = this; + + var end = exprList.length + if (end) { + var last = exprList[end - 1] + if (last && last.type == "RestElement") { + --end + } else if (last && last.type == "SpreadElement") { + last.type = "RestElement" + var arg = last.argument + this.toAssignable(arg, isBinding) + if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") + this.unexpected(arg.start) + --end + } + + if (isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") + this.unexpected(last.argument.start) + } + for (var i = 0; i < end; i++) { + var elt = exprList[i] + if (elt) this$1.toAssignable(elt, isBinding) } + return exprList +} - // Parse a single statement. - // - // If expecting a statement and finding a slash operator, parse a - // regular expression literal. This is to handle cases like - // `if (foo) /blah/.exec(foo)`, where looking at the previous token - // does not help. +// Parses spread element. - pp$1.parseStatement = function(declaration, topLevel, exports) { - var starttype = this.type, node = this.startNode(), kind +pp$2.parseSpread = function(refDestructuringErrors) { + var node = this.startNode() + this.next() + node.argument = this.parseMaybeAssign(false, refDestructuringErrors) + return this.finishNode(node, "SpreadElement") +} - if (this.isLet()) { - starttype = tt._var - kind = "let" - } +pp$2.parseRest = function(allowNonIdent) { + var node = this.startNode() + this.next() - // Most types of statements are recognized by the keyword they - // start with. Many are trivial to parse, some require a bit of - // complexity. - - switch (starttype) { - case tt._break: case tt._continue: return this.parseBreakContinueStatement(node, starttype.keyword) - case tt._debugger: return this.parseDebuggerStatement(node) - case tt._do: return this.parseDoStatement(node) - case tt._for: return this.parseForStatement(node) - case tt._function: - if (!declaration && this.options.ecmaVersion >= 6) this.unexpected() - return this.parseFunctionStatement(node, false) - case tt._class: - if (!declaration) this.unexpected() - return this.parseClass(node, true) - case tt._if: return this.parseIfStatement(node) - case tt._return: return this.parseReturnStatement(node) - case tt._switch: return this.parseSwitchStatement(node) - case tt._throw: return this.parseThrowStatement(node) - case tt._try: return this.parseTryStatement(node) - case tt._const: case tt._var: - kind = kind || this.value - if (!declaration && kind != "var") this.unexpected() - return this.parseVarStatement(node, kind) - case tt._while: return this.parseWhileStatement(node) - case tt._with: return this.parseWithStatement(node) - case tt.braceL: return this.parseBlock() - case tt.semi: return this.parseEmptyStatement(node) - case tt._export: - case tt._import: - if (!this.options.allowImportExportEverywhere) { - if (!topLevel) - this.raise(this.start, "'import' and 'export' may only appear at the top level") - if (!this.inModule) - this.raise(this.start, "'import' and 'export' may appear only with 'sourceType: module'") - } - return starttype === tt._import ? this.parseImport(node) : this.parseExport(node, exports) + // RestElement inside of a function parameter must be an identifier + if (allowNonIdent) node.argument = this.type === tt.name ? this.parseIdent() : this.unexpected() + else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected() - // If the statement does not start with a statement keyword or a - // brace, it's an ExpressionStatement or LabeledStatement. We - // simply start parsing an expression, and afterwards, if the - // next token is a colon and the expression was a simple - // Identifier node, we switch to interpreting it as a label. - default: - if (this.isAsyncFunction() && declaration) { - this.next() - return this.parseFunctionStatement(node, true) - } + return this.finishNode(node, "RestElement") +} - var maybeName = this.value, expr = this.parseExpression() - if (starttype === tt.name && expr.type === "Identifier" && this.eat(tt.colon)) - return this.parseLabeledStatement(node, maybeName, expr) - else return this.parseExpressionStatement(node, expr) - } - } +// Parses lvalue (assignable) atom. - pp$1.parseBreakContinueStatement = function(node, keyword) { - var this$1 = this; +pp$2.parseBindingAtom = function() { + if (this.options.ecmaVersion < 6) return this.parseIdent() + switch (this.type) { + case tt.name: + return this.parseIdent() - var isBreak = keyword == "break" + case tt.bracketL: + var node = this.startNode() this.next() - if (this.eat(tt.semi) || this.insertSemicolon()) node.label = null - else if (this.type !== tt.name) this.unexpected() - else { - node.label = this.parseIdent() - this.semicolon() - } + node.elements = this.parseBindingList(tt.bracketR, true, true) + return this.finishNode(node, "ArrayPattern") - // Verify that there is an actual destination to break or - // continue to. - for (var i = 0; i < this.labels.length; ++i) { - var lab = this$1.labels[i] - if (node.label == null || lab.name === node.label.name) { - if (lab.kind != null && (isBreak || lab.kind === "loop")) break - if (node.label && isBreak) break - } - } - if (i === this.labels.length) this.raise(node.start, "Unsyntactic " + keyword) - return this.finishNode(node, isBreak ? "BreakStatement" : "ContinueStatement") - } + case tt.braceL: + return this.parseObj(true) - pp$1.parseDebuggerStatement = function(node) { - this.next() - this.semicolon() - return this.finishNode(node, "DebuggerStatement") + default: + this.unexpected() } +} + +pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNonIdent) { + var this$1 = this; - pp$1.parseDoStatement = function(node) { + var elts = [], first = true + while (!this.eat(close)) { + if (first) first = false + else this$1.expect(tt.comma) + if (allowEmpty && this$1.type === tt.comma) { + elts.push(null) + } else if (allowTrailingComma && this$1.afterTrailingComma(close)) { + break + } else if (this$1.type === tt.ellipsis) { + var rest = this$1.parseRest(allowNonIdent) + this$1.parseBindingListItem(rest) + elts.push(rest) + if (this$1.type === tt.comma) this$1.raise(this$1.start, "Comma is not permitted after the rest element") + this$1.expect(close) + break + } else { + var elem = this$1.parseMaybeDefault(this$1.start, this$1.startLoc) + this$1.parseBindingListItem(elem) + elts.push(elem) + } + } + return elts +} + +pp$2.parseBindingListItem = function(param) { + return param +} + +// Parses assignment pattern around given atom if possible. + +pp$2.parseMaybeDefault = function(startPos, startLoc, left) { + left = left || this.parseBindingAtom() + if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left + var node = this.startNodeAt(startPos, startLoc) + node.left = left + node.right = this.parseMaybeAssign() + return this.finishNode(node, "AssignmentPattern") +} + +// Verify that a node is an lval — something that can be assigned +// to. + +pp$2.checkLVal = function(expr, isBinding, checkClashes) { + var this$1 = this; + + switch (expr.type) { + case "Identifier": + if (this.strict && this.reservedWordsStrictBind.test(expr.name)) + this.raiseRecoverable(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode") + if (checkClashes) { + if (has(checkClashes, expr.name)) + this.raiseRecoverable(expr.start, "Argument name clash") + checkClashes[expr.name] = true + } + break + + case "MemberExpression": + if (isBinding) this.raiseRecoverable(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression") + break + + case "ObjectPattern": + for (var i = 0; i < expr.properties.length; i++) + this$1.checkLVal(expr.properties[i].value, isBinding, checkClashes) + break + + case "ArrayPattern": + for (var i$1 = 0; i$1 < expr.elements.length; i$1++) { + var elem = expr.elements[i$1] + if (elem) this$1.checkLVal(elem, isBinding, checkClashes) + } + break + + case "AssignmentPattern": + this.checkLVal(expr.left, isBinding, checkClashes) + break + + case "RestElement": + this.checkLVal(expr.argument, isBinding, checkClashes) + break + + case "ParenthesizedExpression": + this.checkLVal(expr.expression, isBinding, checkClashes) + break + + default: + this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue") + } +} + +// A recursive descent parser operates by defining functions for all +// syntactic elements, and recursively calling those, each function +// advancing the input stream and returning an AST node. Precedence +// of constructs (for example, the fact that `!x[1]` means `!(x[1])` +// instead of `(!x)[1]` is handled by the fact that the parser +// function that parses unary prefix operators is called first, and +// in turn calls the function that parses `[]` subscripts — that +// way, it'll receive the node for `x[1]` already parsed, and wraps +// *that* in the unary operator node. +// +// Acorn uses an [operator precedence parser][opp] to handle binary +// operator precedence, because it is much more compact than using +// the technique outlined above, which uses different, nesting +// functions to specify precedence, for all of the ten binary +// precedence levels that JavaScript defines. +// +// [opp]: http://en.wikipedia.org/wiki/Operator-precedence_parser + +var pp$3 = Parser.prototype + +// Check if property name clashes with already added. +// Object/class getters and setters are not allowed to clash — +// either with each other or with an init property — and in +// strict mode, init properties are also not allowed to be repeated. + +pp$3.checkPropClash = function(prop, propHash) { + if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) + return + var key = prop.key; + var name + switch (key.type) { + case "Identifier": name = key.name; break + case "Literal": name = String(key.value); break + default: return + } + var kind = prop.kind; + if (this.options.ecmaVersion >= 6) { + if (name === "__proto__" && kind === "init") { + if (propHash.proto) this.raiseRecoverable(key.start, "Redefinition of __proto__ property") + propHash.proto = true + } + return + } + name = "$" + name + var other = propHash[name] + if (other) { + var isGetSet = kind !== "init" + if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init)) + this.raiseRecoverable(key.start, "Redefinition of property") + } else { + other = propHash[name] = { + init: false, + get: false, + set: false + } + } + other[kind] = true +} + +// ### Expression parsing + +// These nest, from the most general expression type at the top to +// 'atomic', nondivisible expression types at the bottom. Most of +// the functions will simply let the function(s) below them parse, +// and, *if* the syntactic construct they handle is present, wrap +// the AST node that the inner parser gave them in another node. + +// Parse a full expression. The optional arguments are used to +// forbid the `in` operator (in for loops initalization expressions) +// and provide reference for storing '=' operator inside shorthand +// property assignment in contexts where both object expression +// and object pattern might appear (so it's possible to raise +// delayed syntax error at correct position). + +pp$3.parseExpression = function(noIn, refDestructuringErrors) { + var this$1 = this; + + var startPos = this.start, startLoc = this.startLoc + var expr = this.parseMaybeAssign(noIn, refDestructuringErrors) + if (this.type === tt.comma) { + var node = this.startNodeAt(startPos, startLoc) + node.expressions = [expr] + while (this.eat(tt.comma)) node.expressions.push(this$1.parseMaybeAssign(noIn, refDestructuringErrors)) + return this.finishNode(node, "SequenceExpression") + } + return expr +} + +// Parse an assignment expression. This includes applications of +// operators like `+=`. + +pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) { + if (this.inGenerator && this.isContextual("yield")) return this.parseYield() + + var ownDestructuringErrors = false + if (!refDestructuringErrors) { + refDestructuringErrors = new DestructuringErrors + ownDestructuringErrors = true + } + var startPos = this.start, startLoc = this.startLoc + if (this.type == tt.parenL || this.type == tt.name) + this.potentialArrowAt = this.start + var left = this.parseMaybeConditional(noIn, refDestructuringErrors) + if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc) + if (this.type.isAssign) { + this.checkPatternErrors(refDestructuringErrors, true) + if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors) + var node = this.startNodeAt(startPos, startLoc) + node.operator = this.value + node.left = this.type === tt.eq ? this.toAssignable(left) : left + refDestructuringErrors.shorthandAssign = 0 // reset because shorthand default was used correctly + this.checkLVal(left) this.next() - this.labels.push(loopLabel) - node.body = this.parseStatement(false) - this.labels.pop() - this.expect(tt._while) - node.test = this.parseParenExpression() - if (this.options.ecmaVersion >= 6) - this.eat(tt.semi) - else - this.semicolon() - return this.finishNode(node, "DoWhileStatement") + node.right = this.parseMaybeAssign(noIn) + return this.finishNode(node, "AssignmentExpression") + } else { + if (ownDestructuringErrors) this.checkExpressionErrors(refDestructuringErrors, true) } + return left +} - // Disambiguating between a `for` and a `for`/`in` or `for`/`of` - // loop is non-trivial. Basically, we have to parse the init `var` - // statement or expression, disallowing the `in` operator (see - // the second parameter to `parseExpression`), and then check - // whether the next token is `in` or `of`. When there is no init - // part (semicolon immediately after the opening parenthesis), it - // is a regular `for` loop. +// Parse a ternary conditional (`?:`) operator. - pp$1.parseForStatement = function(node) { - this.next() - this.labels.push(loopLabel) - this.expect(tt.parenL) - if (this.type === tt.semi) return this.parseFor(node, null) - var isLet = this.isLet() - if (this.type === tt._var || this.type === tt._const || isLet) { - var init$1 = this.startNode(), kind = isLet ? "let" : this.value +pp$3.parseMaybeConditional = function(noIn, refDestructuringErrors) { + var startPos = this.start, startLoc = this.startLoc + var expr = this.parseExprOps(noIn, refDestructuringErrors) + if (this.checkExpressionErrors(refDestructuringErrors)) return expr + if (this.eat(tt.question)) { + var node = this.startNodeAt(startPos, startLoc) + node.test = expr + node.consequent = this.parseMaybeAssign() + this.expect(tt.colon) + node.alternate = this.parseMaybeAssign(noIn) + return this.finishNode(node, "ConditionalExpression") + } + return expr +} + +// Start the precedence parser. + +pp$3.parseExprOps = function(noIn, refDestructuringErrors) { + var startPos = this.start, startLoc = this.startLoc + var expr = this.parseMaybeUnary(refDestructuringErrors, false) + if (this.checkExpressionErrors(refDestructuringErrors)) return expr + return this.parseExprOp(expr, startPos, startLoc, -1, noIn) +} + +// Parse binary operators with the operator precedence parsing +// algorithm. `left` is the left-hand side of the operator. +// `minPrec` provides context that allows the function to stop and +// defer further parser to one of its callers when it encounters an +// operator that has a lower precedence than the set it is parsing. + +pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) { + var prec = this.type.binop + if (prec != null && (!noIn || this.type !== tt._in)) { + if (prec > minPrec) { + var logical = this.type === tt.logicalOR || this.type === tt.logicalAND + var op = this.value this.next() - this.parseVar(init$1, true, kind) - this.finishNode(init$1, "VariableDeclaration") - if ((this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) && init$1.declarations.length === 1 && - !(kind !== "var" && init$1.declarations[0].init)) - return this.parseForIn(node, init$1) - return this.parseFor(node, init$1) + var startPos = this.start, startLoc = this.startLoc + var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn) + var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical) + return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn) + } + } + return left +} + +pp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) { + var node = this.startNodeAt(startPos, startLoc) + node.left = left + node.operator = op + node.right = right + return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression") +} + +// Parse unary operators, both prefix and postfix. + +pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) { + var this$1 = this; + + var startPos = this.start, startLoc = this.startLoc, expr + if (this.inAsync && this.isContextual("await")) { + expr = this.parseAwait(refDestructuringErrors) + sawUnary = true + } else if (this.type.prefix) { + var node = this.startNode(), update = this.type === tt.incDec + node.operator = this.value + node.prefix = true + this.next() + node.argument = this.parseMaybeUnary(null, true) + this.checkExpressionErrors(refDestructuringErrors, true) + if (update) this.checkLVal(node.argument) + else if (this.strict && node.operator === "delete" && + node.argument.type === "Identifier") + this.raiseRecoverable(node.start, "Deleting local variable in strict mode") + else sawUnary = true + expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression") + } else { + expr = this.parseExprSubscripts(refDestructuringErrors) + if (this.checkExpressionErrors(refDestructuringErrors)) return expr + while (this.type.postfix && !this.canInsertSemicolon()) { + var node$1 = this$1.startNodeAt(startPos, startLoc) + node$1.operator = this$1.value + node$1.prefix = false + node$1.argument = expr + this$1.checkLVal(expr) + this$1.next() + expr = this$1.finishNode(node$1, "UpdateExpression") } - var refDestructuringErrors = new DestructuringErrors - var init = this.parseExpression(true, refDestructuringErrors) - if (this.type === tt._in || (this.options.ecmaVersion >= 6 && this.isContextual("of"))) { - this.checkPatternErrors(refDestructuringErrors, true) - this.toAssignable(init) - this.checkLVal(init) - return this.parseForIn(node, init) + } + + if (!sawUnary && this.eat(tt.starstar)) + return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) + else + return expr +} + +// Parse call, dot, and `[]`-subscript expressions. + +pp$3.parseExprSubscripts = function(refDestructuringErrors) { + var startPos = this.start, startLoc = this.startLoc + var expr = this.parseExprAtom(refDestructuringErrors) + var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")" + if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) return expr + return this.parseSubscripts(expr, startPos, startLoc) +} + +pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { + var this$1 = this; + + for (;;) { + var maybeAsyncArrow = this$1.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && !this$1.canInsertSemicolon() + if (this$1.eat(tt.dot)) { + var node = this$1.startNodeAt(startPos, startLoc) + node.object = base + node.property = this$1.parseIdent(true) + node.computed = false + base = this$1.finishNode(node, "MemberExpression") + } else if (this$1.eat(tt.bracketL)) { + var node$1 = this$1.startNodeAt(startPos, startLoc) + node$1.object = base + node$1.property = this$1.parseExpression() + node$1.computed = true + this$1.expect(tt.bracketR) + base = this$1.finishNode(node$1, "MemberExpression") + } else if (!noCalls && this$1.eat(tt.parenL)) { + var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this$1.yieldPos, oldAwaitPos = this$1.awaitPos + this$1.yieldPos = 0 + this$1.awaitPos = 0 + var exprList = this$1.parseExprList(tt.parenR, this$1.options.ecmaVersion >= 8, false, refDestructuringErrors) + if (maybeAsyncArrow && !this$1.canInsertSemicolon() && this$1.eat(tt.arrow)) { + this$1.checkPatternErrors(refDestructuringErrors, true) + this$1.checkYieldAwaitInDefaultParams() + this$1.yieldPos = oldYieldPos + this$1.awaitPos = oldAwaitPos + return this$1.parseArrowExpression(this$1.startNodeAt(startPos, startLoc), exprList, true) + } + this$1.checkExpressionErrors(refDestructuringErrors, true) + this$1.yieldPos = oldYieldPos || this$1.yieldPos + this$1.awaitPos = oldAwaitPos || this$1.awaitPos + var node$2 = this$1.startNodeAt(startPos, startLoc) + node$2.callee = base + node$2.arguments = exprList + base = this$1.finishNode(node$2, "CallExpression") + } else if (this$1.type === tt.backQuote) { + var node$3 = this$1.startNodeAt(startPos, startLoc) + node$3.tag = base + node$3.quasi = this$1.parseTemplate() + base = this$1.finishNode(node$3, "TaggedTemplateExpression") } else { - this.checkExpressionErrors(refDestructuringErrors, true) + return base } - return this.parseFor(node, init) } +} - pp$1.parseFunctionStatement = function(node, isAsync) { - this.next() - return this.parseFunction(node, true, false, isAsync) - } +// Parse an atomic expression — either a single token that is an +// expression, an expression started by a keyword like `function` or +// `new`, or an expression wrapped in punctuation like `()`, `[]`, +// or `{}`. - pp$1.isFunction = function() { - return this.type === tt._function || this.isAsyncFunction() - } +pp$3.parseExprAtom = function(refDestructuringErrors) { + var node, canBeArrow = this.potentialArrowAt == this.start + switch (this.type) { + case tt._super: + if (!this.inFunction) + this.raise(this.start, "'super' outside of function or class") - pp$1.parseIfStatement = function(node) { + case tt._this: + var type = this.type === tt._this ? "ThisExpression" : "Super" + node = this.startNode() this.next() - node.test = this.parseParenExpression() - // allow function declarations in branches, but only in non-strict mode - node.consequent = this.parseStatement(!this.strict && this.isFunction()) - node.alternate = this.eat(tt._else) ? this.parseStatement(!this.strict && this.isFunction()) : null - return this.finishNode(node, "IfStatement") - } + return this.finishNode(node, type) - pp$1.parseReturnStatement = function(node) { - if (!this.inFunction && !this.options.allowReturnOutsideFunction) - this.raise(this.start, "'return' outside of function") - this.next() + case tt.name: + var startPos = this.start, startLoc = this.startLoc + var id = this.parseIdent(this.type !== tt.name) + if (this.options.ecmaVersion >= 8 && id.name === "async" && !this.canInsertSemicolon() && this.eat(tt._function)) + return this.parseFunction(this.startNodeAt(startPos, startLoc), false, false, true) + if (canBeArrow && !this.canInsertSemicolon()) { + if (this.eat(tt.arrow)) + return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false) + if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === tt.name) { + id = this.parseIdent() + if (this.canInsertSemicolon() || !this.eat(tt.arrow)) + this.unexpected() + return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true) + } + } + return id - // In `return` (and `break`/`continue`), the keywords with - // optional arguments, we eagerly look for a semicolon or the - // possibility to insert one. + case tt.regexp: + var value = this.value + node = this.parseLiteral(value.value) + node.regex = {pattern: value.pattern, flags: value.flags} + return node - if (this.eat(tt.semi) || this.insertSemicolon()) node.argument = null - else { node.argument = this.parseExpression(); this.semicolon() } - return this.finishNode(node, "ReturnStatement") - } + case tt.num: case tt.string: + return this.parseLiteral(this.value) - pp$1.parseSwitchStatement = function(node) { - var this$1 = this; + case tt._null: case tt._true: case tt._false: + node = this.startNode() + node.value = this.type === tt._null ? null : this.type === tt._true + node.raw = this.type.keyword + this.next() + return this.finishNode(node, "Literal") + case tt.parenL: + return this.parseParenAndDistinguishExpression(canBeArrow) + + case tt.bracketL: + node = this.startNode() this.next() - node.discriminant = this.parseParenExpression() - node.cases = [] - this.expect(tt.braceL) - this.labels.push(switchLabel) - - // Statements under must be grouped (by label) in SwitchCase - // nodes. `cur` is used to keep the node that we are currently - // adding statements to. - - for (var cur, sawDefault = false; this.type != tt.braceR;) { - if (this$1.type === tt._case || this$1.type === tt._default) { - var isCase = this$1.type === tt._case - if (cur) this$1.finishNode(cur, "SwitchCase") - node.cases.push(cur = this$1.startNode()) - cur.consequent = [] - this$1.next() - if (isCase) { - cur.test = this$1.parseExpression() - } else { - if (sawDefault) this$1.raiseRecoverable(this$1.lastTokStart, "Multiple default clauses") - sawDefault = true - cur.test = null - } - this$1.expect(tt.colon) - } else { - if (!cur) this$1.unexpected() - cur.consequent.push(this$1.parseStatement(true)) - } - } - if (cur) this.finishNode(cur, "SwitchCase") - this.next() // Closing brace - this.labels.pop() - return this.finishNode(node, "SwitchStatement") - } + node.elements = this.parseExprList(tt.bracketR, true, true, refDestructuringErrors) + return this.finishNode(node, "ArrayExpression") + + case tt.braceL: + return this.parseObj(false, refDestructuringErrors) - pp$1.parseThrowStatement = function(node) { + case tt._function: + node = this.startNode() this.next() - if (lineBreak.test(this.input.slice(this.lastTokEnd, this.start))) - this.raise(this.lastTokEnd, "Illegal newline after throw") - node.argument = this.parseExpression() - this.semicolon() - return this.finishNode(node, "ThrowStatement") - } + return this.parseFunction(node, false) - // Reused empty array added for node fields that are always empty. + case tt._class: + return this.parseClass(this.startNode(), false) - var empty = [] + case tt._new: + return this.parseNew() - pp$1.parseTryStatement = function(node) { - this.next() - node.block = this.parseBlock() - node.handler = null - if (this.type === tt._catch) { - var clause = this.startNode() - this.next() - this.expect(tt.parenL) - clause.param = this.parseBindingAtom() - this.checkLVal(clause.param, true) - this.expect(tt.parenR) - clause.body = this.parseBlock() - node.handler = this.finishNode(clause, "CatchClause") - } - node.finalizer = this.eat(tt._finally) ? this.parseBlock() : null - if (!node.handler && !node.finalizer) - this.raise(node.start, "Missing catch or finally clause") - return this.finishNode(node, "TryStatement") - } + case tt.backQuote: + return this.parseTemplate() - pp$1.parseVarStatement = function(node, kind) { - this.next() - this.parseVar(node, false, kind) - this.semicolon() - return this.finishNode(node, "VariableDeclaration") + default: + this.unexpected() } +} - pp$1.parseWhileStatement = function(node) { - this.next() - node.test = this.parseParenExpression() - this.labels.push(loopLabel) - node.body = this.parseStatement(false) - this.labels.pop() - return this.finishNode(node, "WhileStatement") - } +pp$3.parseLiteral = function(value) { + var node = this.startNode() + node.value = value + node.raw = this.input.slice(this.start, this.end) + this.next() + return this.finishNode(node, "Literal") +} - pp$1.parseWithStatement = function(node) { - if (this.strict) this.raise(this.start, "'with' in strict mode") - this.next() - node.object = this.parseParenExpression() - node.body = this.parseStatement(false) - return this.finishNode(node, "WithStatement") - } +pp$3.parseParenExpression = function() { + this.expect(tt.parenL) + var val = this.parseExpression() + this.expect(tt.parenR) + return val +} - pp$1.parseEmptyStatement = function(node) { +pp$3.parseParenAndDistinguishExpression = function(canBeArrow) { + var this$1 = this; + + var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8 + if (this.options.ecmaVersion >= 6) { this.next() - return this.finishNode(node, "EmptyStatement") - } - pp$1.parseLabeledStatement = function(node, maybeName, expr) { - var this$1 = this; + var innerStartPos = this.start, innerStartLoc = this.startLoc + var exprList = [], first = true, lastIsComma = false + var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart, innerParenStart + this.yieldPos = 0 + this.awaitPos = 0 + while (this.type !== tt.parenR) { + first ? first = false : this$1.expect(tt.comma) + if (allowTrailingComma && this$1.afterTrailingComma(tt.parenR, true)) { + lastIsComma = true + break + } else if (this$1.type === tt.ellipsis) { + spreadStart = this$1.start + exprList.push(this$1.parseParenItem(this$1.parseRest())) + if (this$1.type === tt.comma) this$1.raise(this$1.start, "Comma is not permitted after the rest element") + break + } else { + if (this$1.type === tt.parenL && !innerParenStart) { + innerParenStart = this$1.start + } + exprList.push(this$1.parseMaybeAssign(false, refDestructuringErrors, this$1.parseParenItem)) + } + } + var innerEndPos = this.start, innerEndLoc = this.startLoc + this.expect(tt.parenR) - for (var i = 0; i < this.labels.length; ++i) - if (this$1.labels[i].name === maybeName) this$1.raise(expr.start, "Label '" + maybeName + "' is already declared") - var kind = this.type.isLoop ? "loop" : this.type === tt._switch ? "switch" : null - for (var i$1 = this.labels.length - 1; i$1 >= 0; i$1--) { - var label = this$1.labels[i$1] - if (label.statementStart == node.start) { - label.statementStart = this$1.start - label.kind = kind - } else break + if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) { + this.checkPatternErrors(refDestructuringErrors, true) + this.checkYieldAwaitInDefaultParams() + if (innerParenStart) this.unexpected(innerParenStart) + this.yieldPos = oldYieldPos + this.awaitPos = oldAwaitPos + return this.parseParenArrowList(startPos, startLoc, exprList) + } + + if (!exprList.length || lastIsComma) this.unexpected(this.lastTokStart) + if (spreadStart) this.unexpected(spreadStart) + this.checkExpressionErrors(refDestructuringErrors, true) + this.yieldPos = oldYieldPos || this.yieldPos + this.awaitPos = oldAwaitPos || this.awaitPos + + if (exprList.length > 1) { + val = this.startNodeAt(innerStartPos, innerStartLoc) + val.expressions = exprList + this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc) + } else { + val = exprList[0] } - this.labels.push({name: maybeName, kind: kind, statementStart: this.start}) - node.body = this.parseStatement(true) - this.labels.pop() - node.label = expr - return this.finishNode(node, "LabeledStatement") + } else { + val = this.parseParenExpression() } - pp$1.parseExpressionStatement = function(node, expr) { - node.expression = expr - this.semicolon() - return this.finishNode(node, "ExpressionStatement") + if (this.options.preserveParens) { + var par = this.startNodeAt(startPos, startLoc) + par.expression = val + return this.finishNode(par, "ParenthesizedExpression") + } else { + return val } - - // Parse a semicolon-enclosed block of statements, handling `"use - // strict"` declarations when `allowStrict` is true (used for - // function bodies). - - pp$1.parseBlock = function(allowStrict) { - var this$1 = this; - - var node = this.startNode(), first = true, oldStrict - node.body = [] - this.expect(tt.braceL) - while (!this.eat(tt.braceR)) { - var stmt = this$1.parseStatement(true) - node.body.push(stmt) - if (first && allowStrict && this$1.isUseStrict(stmt)) { - oldStrict = this$1.strict - this$1.setStrict(this$1.strict = true) +} + +pp$3.parseParenItem = function(item) { + return item +} + +pp$3.parseParenArrowList = function(startPos, startLoc, exprList) { + return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList) +} + +// New's precedence is slightly tricky. It must allow its argument to +// be a `[]` or dot subscript expression, but not a call — at least, +// not without wrapping it in parentheses. Thus, it uses the noCalls +// argument to parseSubscripts to prevent it from consuming the +// argument list. + +var empty$1 = [] + +pp$3.parseNew = function() { + var node = this.startNode() + var meta = this.parseIdent(true) + if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) { + node.meta = meta + node.property = this.parseIdent(true) + if (node.property.name !== "target") + this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target") + if (!this.inFunction) + this.raiseRecoverable(node.start, "new.target can only be used in functions") + return this.finishNode(node, "MetaProperty") + } + var startPos = this.start, startLoc = this.startLoc + node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true) + if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false) + else node.arguments = empty$1 + return this.finishNode(node, "NewExpression") +} + +// Parse template expression. + +pp$3.parseTemplateElement = function() { + var elem = this.startNode() + elem.value = { + raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, '\n'), + cooked: this.value + } + this.next() + elem.tail = this.type === tt.backQuote + return this.finishNode(elem, "TemplateElement") +} + +pp$3.parseTemplate = function() { + var this$1 = this; + + var node = this.startNode() + this.next() + node.expressions = [] + var curElt = this.parseTemplateElement() + node.quasis = [curElt] + while (!curElt.tail) { + this$1.expect(tt.dollarBraceL) + node.expressions.push(this$1.parseExpression()) + this$1.expect(tt.braceR) + node.quasis.push(curElt = this$1.parseTemplateElement()) + } + this.next() + return this.finishNode(node, "TemplateLiteral") +} + +// Parse an object literal or binding pattern. + +pp$3.parseObj = function(isPattern, refDestructuringErrors) { + var this$1 = this; + + var node = this.startNode(), first = true, propHash = {} + node.properties = [] + this.next() + while (!this.eat(tt.braceR)) { + if (!first) { + this$1.expect(tt.comma) + if (this$1.afterTrailingComma(tt.braceR)) break + } else first = false + + var prop = this$1.startNode(), isGenerator, isAsync, startPos, startLoc + if (this$1.options.ecmaVersion >= 6) { + prop.method = false + prop.shorthand = false + if (isPattern || refDestructuringErrors) { + startPos = this$1.start + startLoc = this$1.startLoc } - first = false + if (!isPattern) + isGenerator = this$1.eat(tt.star) } - if (oldStrict === false) this.setStrict(false) - return this.finishNode(node, "BlockStatement") - } + this$1.parsePropertyName(prop) + if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator && !prop.computed && + prop.key.type === "Identifier" && prop.key.name === "async" && this$1.type !== tt.parenL && + this$1.type !== tt.colon && !this$1.canInsertSemicolon()) { + isAsync = true + this$1.parsePropertyName(prop, refDestructuringErrors) + } else { + isAsync = false + } + this$1.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors) + this$1.checkPropClash(prop, propHash) + node.properties.push(this$1.finishNode(prop, "Property")) + } + return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression") +} + +pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors) { + if ((isGenerator || isAsync) && this.type === tt.colon) + this.unexpected() + + if (this.eat(tt.colon)) { + prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors) + prop.kind = "init" + } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) { + if (isPattern) this.unexpected() + prop.kind = "init" + prop.method = true + prop.value = this.parseMethod(isGenerator, isAsync) + } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && + (prop.key.name === "get" || prop.key.name === "set") && + (this.type != tt.comma && this.type != tt.braceR)) { + if (isGenerator || isAsync || isPattern) this.unexpected() + prop.kind = prop.key.name + this.parsePropertyName(prop) + prop.value = this.parseMethod(false) + var paramCount = prop.kind === "get" ? 0 : 1 + if (prop.value.params.length !== paramCount) { + var start = prop.value.start + if (prop.kind === "get") + this.raiseRecoverable(start, "getter should have no params") + else + this.raiseRecoverable(start, "setter should have exactly one param") + } else { + if (prop.kind === "set" && prop.value.params[0].type === "RestElement") + this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params") + } + } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") { + if (this.keywords.test(prop.key.name) || + (this.strict ? this.reservedWordsStrict : this.reservedWords).test(prop.key.name) || + (this.inGenerator && prop.key.name == "yield") || + (this.inAsync && prop.key.name == "await")) + this.raiseRecoverable(prop.key.start, "'" + prop.key.name + "' can not be used as shorthand property") + prop.kind = "init" + if (isPattern) { + prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key) + } else if (this.type === tt.eq && refDestructuringErrors) { + if (!refDestructuringErrors.shorthandAssign) + refDestructuringErrors.shorthandAssign = this.start + prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key) + } else { + prop.value = prop.key + } + prop.shorthand = true + } else this.unexpected() +} + +pp$3.parsePropertyName = function(prop) { + if (this.options.ecmaVersion >= 6) { + if (this.eat(tt.bracketL)) { + prop.computed = true + prop.key = this.parseMaybeAssign() + this.expect(tt.bracketR) + return prop.key + } else { + prop.computed = false + } + } + return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true) +} + +// Initialize empty function node. + +pp$3.initFunction = function(node) { + node.id = null + if (this.options.ecmaVersion >= 6) { + node.generator = false + node.expression = false + } + if (this.options.ecmaVersion >= 8) + node.async = false +} + +// Parse object or class method. + +pp$3.parseMethod = function(isGenerator, isAsync) { + var node = this.startNode(), oldInGen = this.inGenerator, oldInAsync = this.inAsync, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos + + this.initFunction(node) + if (this.options.ecmaVersion >= 6) + node.generator = isGenerator + if (this.options.ecmaVersion >= 8) + node.async = !!isAsync + + this.inGenerator = node.generator + this.inAsync = node.async + this.yieldPos = 0 + this.awaitPos = 0 + + this.expect(tt.parenL) + node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8) + this.checkYieldAwaitInDefaultParams() + this.parseFunctionBody(node, false) + + this.inGenerator = oldInGen + this.inAsync = oldInAsync + this.yieldPos = oldYieldPos + this.awaitPos = oldAwaitPos + return this.finishNode(node, "FunctionExpression") +} + +// Parse arrow function expression with given parameters. + +pp$3.parseArrowExpression = function(node, params, isAsync) { + var oldInGen = this.inGenerator, oldInAsync = this.inAsync, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos + + this.initFunction(node) + if (this.options.ecmaVersion >= 8) + node.async = !!isAsync + + this.inGenerator = false + this.inAsync = node.async + this.yieldPos = 0 + this.awaitPos = 0 + + node.params = this.toAssignableList(params, true) + this.parseFunctionBody(node, true) + + this.inGenerator = oldInGen + this.inAsync = oldInAsync + this.yieldPos = oldYieldPos + this.awaitPos = oldAwaitPos + return this.finishNode(node, "ArrowFunctionExpression") +} + +// Parse function body and check parameters. + +pp$3.parseFunctionBody = function(node, isArrowFunction) { + var isExpression = isArrowFunction && this.type !== tt.braceL + + if (isExpression) { + node.body = this.parseMaybeAssign() + node.expression = true + } else { + // Start a new scope with regard to labels and the `inFunction` + // flag (restore them to their old value afterwards). + var oldInFunc = this.inFunction, oldLabels = this.labels + this.inFunction = true; this.labels = [] + node.body = this.parseBlock(true) + node.expression = false + this.inFunction = oldInFunc; this.labels = oldLabels + } + + // If this is a strict mode function, verify that argument names + // are not repeated, and it does not try to bind the words `eval` + // or `arguments`. + var useStrict = (!isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) ? node.body.body[0] : null + if (useStrict && this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params)) + this.raiseRecoverable(useStrict.start, "Illegal 'use strict' directive in function with non-simple parameter list") + + if (this.strict || useStrict) { + var oldStrict = this.strict + this.strict = true + if (node.id) + this.checkLVal(node.id, true) + this.checkParams(node) + this.strict = oldStrict + } else if (isArrowFunction || !this.isSimpleParamList(node.params)) { + this.checkParams(node) + } +} + +pp$3.isSimpleParamList = function(params) { + for (var i = 0; i < params.length; i++) + if (params[i].type !== "Identifier") return false + return true +} + +// Checks function params for various disallowed patterns such as using "eval" +// or "arguments" and duplicate parameters. + +pp$3.checkParams = function(node) { + var this$1 = this; + + var nameHash = {} + for (var i = 0; i < node.params.length; i++) this$1.checkLVal(node.params[i], true, nameHash) +} + +// Parses a comma-separated list of expressions, and returns them as +// an array. `close` is the token type that ends the list, and +// `allowEmpty` can be turned on to allow subsequent commas with +// nothing in between them to be parsed as `null` (which is needed +// for array literals). + +pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) { + var this$1 = this; + + var elts = [], first = true + while (!this.eat(close)) { + if (!first) { + this$1.expect(tt.comma) + if (allowTrailingComma && this$1.afterTrailingComma(close)) break + } else first = false + + var elt + if (allowEmpty && this$1.type === tt.comma) + elt = null + else if (this$1.type === tt.ellipsis) { + elt = this$1.parseSpread(refDestructuringErrors) + if (this$1.type === tt.comma && refDestructuringErrors && !refDestructuringErrors.trailingComma) { + refDestructuringErrors.trailingComma = this$1.start + } + } else + elt = this$1.parseMaybeAssign(false, refDestructuringErrors) + elts.push(elt) + } + return elts +} + +// Parse the next token as an identifier. If `liberal` is true (used +// when parsing properties), it will also convert keywords into +// identifiers. + +pp$3.parseIdent = function(liberal) { + var node = this.startNode() + if (liberal && this.options.allowReserved == "never") liberal = false + if (this.type === tt.name) { + if (!liberal && (this.strict ? this.reservedWordsStrict : this.reservedWords).test(this.value) && + (this.options.ecmaVersion >= 6 || + this.input.slice(this.start, this.end).indexOf("\\") == -1)) + this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved") + if (this.inGenerator && this.value === "yield") + this.raiseRecoverable(this.start, "Can not use 'yield' as identifier inside a generator") + if (this.inAsync && this.value === "await") + this.raiseRecoverable(this.start, "Can not use 'await' as identifier inside an async function") + node.name = this.value + } else if (liberal && this.type.keyword) { + node.name = this.type.keyword + } else { + this.unexpected() + } + this.next() + return this.finishNode(node, "Identifier") +} + +// Parses yield expression inside generator. + +pp$3.parseYield = function() { + if (!this.yieldPos) this.yieldPos = this.start + + var node = this.startNode() + this.next() + if (this.type == tt.semi || this.canInsertSemicolon() || (this.type != tt.star && !this.type.startsExpr)) { + node.delegate = false + node.argument = null + } else { + node.delegate = this.eat(tt.star) + node.argument = this.parseMaybeAssign() + } + return this.finishNode(node, "YieldExpression") +} + +pp$3.parseAwait = function() { + if (!this.awaitPos) this.awaitPos = this.start + + var node = this.startNode() + this.next() + node.argument = this.parseMaybeUnary(null, true) + return this.finishNode(node, "AwaitExpression") +} + +var pp$4 = Parser.prototype + +// This function is used to raise exceptions on parse errors. It +// takes an offset integer (into the current `input`) to indicate +// the location of the error, attaches the position to the end +// of the error message, and then raises a `SyntaxError` with that +// message. + +pp$4.raise = function(pos, message) { + var loc = getLineInfo(this.input, pos) + message += " (" + loc.line + ":" + loc.column + ")" + var err = new SyntaxError(message) + err.pos = pos; err.loc = loc; err.raisedAt = this.pos + throw err +} + +pp$4.raiseRecoverable = pp$4.raise + +pp$4.curPosition = function() { + if (this.options.locations) { + return new Position(this.curLine, this.pos - this.lineStart) + } +} + +var Node = function Node(parser, pos, loc) { + this.type = "" + this.start = pos + this.end = 0 + if (parser.options.locations) + this.loc = new SourceLocation(parser, loc) + if (parser.options.directSourceFile) + this.sourceFile = parser.options.directSourceFile + if (parser.options.ranges) + this.range = [pos, 0] +}; + +// Start an AST node, attaching a start offset. + +var pp$5 = Parser.prototype + +pp$5.startNode = function() { + return new Node(this, this.start, this.startLoc) +} + +pp$5.startNodeAt = function(pos, loc) { + return new Node(this, pos, loc) +} + +// Finish an AST node, adding `type` and `end` properties. + +function finishNodeAt(node, type, pos, loc) { + node.type = type + node.end = pos + if (this.options.locations) + node.loc.end = loc + if (this.options.ranges) + node.range[1] = pos + return node +} + +pp$5.finishNode = function(node, type) { + return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc) +} + +// Finish node at given position + +pp$5.finishNodeAt = function(node, type, pos, loc) { + return finishNodeAt.call(this, node, type, pos, loc) +} + +// The algorithm used to determine whether a regexp can appear at a +// given point in the program is loosely based on sweet.js' approach. +// See https://github.com/mozilla/sweet.js/wiki/design + +var TokContext = function TokContext(token, isExpr, preserveSpace, override) { + this.token = token + this.isExpr = !!isExpr + this.preserveSpace = !!preserveSpace + this.override = override +}; + +var types = { + b_stat: new TokContext("{", false), + b_expr: new TokContext("{", true), + b_tmpl: new TokContext("${", true), + p_stat: new TokContext("(", false), + p_expr: new TokContext("(", true), + q_tmpl: new TokContext("`", true, true, function (p) { return p.readTmplToken(); }), + f_expr: new TokContext("function", true) +} + +var pp$6 = Parser.prototype + +pp$6.initialContext = function() { + return [types.b_stat] +} + +pp$6.braceIsBlock = function(prevType) { + if (prevType === tt.colon) { + var parent = this.curContext() + if (parent === types.b_stat || parent === types.b_expr) + return !parent.isExpr + } + if (prevType === tt._return) + return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) + if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof || prevType === tt.parenR) + return true + if (prevType == tt.braceL) + return this.curContext() === types.b_stat + return !this.exprAllowed +} + +pp$6.updateContext = function(prevType) { + var update, type = this.type + if (type.keyword && prevType == tt.dot) + this.exprAllowed = false + else if (update = type.updateContext) + update.call(this, prevType) + else + this.exprAllowed = type.beforeExpr +} - // Parse a regular `for` loop. The disambiguation code in - // `parseStatement` will already have parsed the init statement or - // expression. +// Token-specific context update code - pp$1.parseFor = function(node, init) { - node.init = init - this.expect(tt.semi) - node.test = this.type === tt.semi ? null : this.parseExpression() - this.expect(tt.semi) - node.update = this.type === tt.parenR ? null : this.parseExpression() - this.expect(tt.parenR) - node.body = this.parseStatement(false) - this.labels.pop() - return this.finishNode(node, "ForStatement") +tt.parenR.updateContext = tt.braceR.updateContext = function() { + if (this.context.length == 1) { + this.exprAllowed = true + return } - - // Parse a `for`/`in` and `for`/`of` loop, which are almost - // same from parser's perspective. - - pp$1.parseForIn = function(node, init) { - var type = this.type === tt._in ? "ForInStatement" : "ForOfStatement" - this.next() - node.left = init - node.right = this.parseExpression() - this.expect(tt.parenR) - node.body = this.parseStatement(false) - this.labels.pop() - return this.finishNode(node, type) + var out = this.context.pop() + if (out === types.b_stat && this.curContext() === types.f_expr) { + this.context.pop() + this.exprAllowed = false + } else if (out === types.b_tmpl) { + this.exprAllowed = true + } else { + this.exprAllowed = !out.isExpr + } +} + +tt.braceL.updateContext = function(prevType) { + this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr) + this.exprAllowed = true +} + +tt.dollarBraceL.updateContext = function() { + this.context.push(types.b_tmpl) + this.exprAllowed = true +} + +tt.parenL.updateContext = function(prevType) { + var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while + this.context.push(statementParens ? types.p_stat : types.p_expr) + this.exprAllowed = true +} + +tt.incDec.updateContext = function() { + // tokExprAllowed stays unchanged +} + +tt._function.updateContext = function(prevType) { + if (prevType.beforeExpr && prevType !== tt.semi && prevType !== tt._else && + !((prevType === tt.colon || prevType === tt.braceL) && this.curContext() === types.b_stat)) + this.context.push(types.f_expr) + this.exprAllowed = false +} + +tt.backQuote.updateContext = function() { + if (this.curContext() === types.q_tmpl) + this.context.pop() + else + this.context.push(types.q_tmpl) + this.exprAllowed = false +} + +// Object type used to represent tokens. Note that normally, tokens +// simply exist as properties on the parser object. This is only +// used for the onToken callback and the external tokenizer. + +var Token = function Token(p) { + this.type = p.type + this.value = p.value + this.start = p.start + this.end = p.end + if (p.options.locations) + this.loc = new SourceLocation(p, p.startLoc, p.endLoc) + if (p.options.ranges) + this.range = [p.start, p.end] +}; + +// ## Tokenizer + +var pp$7 = Parser.prototype + +// Are we running under Rhino? +var isRhino = typeof Packages == "object" && Object.prototype.toString.call(Packages) == "[object JavaPackage]" + +// Move to the next token + +pp$7.next = function() { + if (this.options.onToken) + this.options.onToken(new Token(this)) + + this.lastTokEnd = this.end + this.lastTokStart = this.start + this.lastTokEndLoc = this.endLoc + this.lastTokStartLoc = this.startLoc + this.nextToken() +} + +pp$7.getToken = function() { + this.next() + return new Token(this) +} + +// If we're in an ES6 environment, make parsers iterable +if (typeof Symbol !== "undefined") + pp$7[Symbol.iterator] = function () { + var self = this + return {next: function () { + var token = self.getToken() + return { + done: token.type === tt.eof, + value: token + } + }} } - // Parse a list of variable declarations. +// Toggle strict mode. Re-reads the next number or string to please +// pedantic tests (`"use strict"; 010;` should fail). - pp$1.parseVar = function(node, isFor, kind) { - var this$1 = this; +pp$7.setStrict = function(strict) { + var this$1 = this; - node.declarations = [] - node.kind = kind - for (;;) { - var decl = this$1.startNode() - this$1.parseVarId(decl) - if (this$1.eat(tt.eq)) { - decl.init = this$1.parseMaybeAssign(isFor) - } else if (kind === "const" && !(this$1.type === tt._in || (this$1.options.ecmaVersion >= 6 && this$1.isContextual("of")))) { - this$1.unexpected() - } else if (decl.id.type != "Identifier" && !(isFor && (this$1.type === tt._in || this$1.isContextual("of")))) { - this$1.raise(this$1.lastTokEnd, "Complex binding patterns require an initialization value") - } else { - decl.init = null - } - node.declarations.push(this$1.finishNode(decl, "VariableDeclarator")) - if (!this$1.eat(tt.comma)) break + this.strict = strict + if (this.type !== tt.num && this.type !== tt.string) return + this.pos = this.start + if (this.options.locations) { + while (this.pos < this.lineStart) { + this$1.lineStart = this$1.input.lastIndexOf("\n", this$1.lineStart - 2) + 1 + --this$1.curLine } - return node - } - - pp$1.parseVarId = function(decl) { - decl.id = this.parseBindingAtom() - this.checkLVal(decl.id, true) } + this.nextToken() +} - // Parse a function declaration or literal (depending on the - // `isStatement` parameter). +pp$7.curContext = function() { + return this.context[this.context.length - 1] +} - pp$1.parseFunction = function(node, isStatement, allowExpressionBody, isAsync) { - this.initFunction(node) - if (this.options.ecmaVersion >= 6 && !isAsync) - node.generator = this.eat(tt.star) - if (this.options.ecmaVersion >= 8) - node.async = !!isAsync +// Read a single token, updating the parser object's token-related +// properties. - if (isStatement) - node.id = this.parseIdent() +pp$7.nextToken = function() { + var curContext = this.curContext() + if (!curContext || !curContext.preserveSpace) this.skipSpace() - var oldInGen = this.inGenerator, oldInAsync = this.inAsync, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos - this.inGenerator = node.generator - this.inAsync = node.async - this.yieldPos = 0 - this.awaitPos = 0 + this.start = this.pos + if (this.options.locations) this.startLoc = this.curPosition() + if (this.pos >= this.input.length) return this.finishToken(tt.eof) - if (!isStatement && this.type === tt.name) - node.id = this.parseIdent() - this.parseFunctionParams(node) - this.parseFunctionBody(node, allowExpressionBody) + if (curContext.override) return curContext.override(this) + else this.readToken(this.fullCharCodeAtPos()) +} - this.inGenerator = oldInGen - this.inAsync = oldInAsync - this.yieldPos = oldYieldPos - this.awaitPos = oldAwaitPos - return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression") - } +pp$7.readToken = function(code) { + // Identifier or keyword. '\uXXXX' sequences are allowed in + // identifiers, so '\' also dispatches to that. + if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) + return this.readWord() - pp$1.parseFunctionParams = function(node) { - this.expect(tt.parenL) - node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8, true) - this.checkYieldAwaitInDefaultParams() - } + return this.getTokenFromCode(code) +} - // Parse a class declaration or literal (depending on the - // `isStatement` parameter). +pp$7.fullCharCodeAtPos = function() { + var code = this.input.charCodeAt(this.pos) + if (code <= 0xd7ff || code >= 0xe000) return code + var next = this.input.charCodeAt(this.pos + 1) + return (code << 10) + next - 0x35fdc00 +} - pp$1.parseClass = function(node, isStatement) { - var this$1 = this; +pp$7.skipBlockComment = function() { + var this$1 = this; - this.next() - this.parseClassId(node, isStatement) - this.parseClassSuper(node) - var classBody = this.startNode() - var hadConstructor = false - classBody.body = [] - this.expect(tt.braceL) - while (!this.eat(tt.braceR)) { - if (this$1.eat(tt.semi)) continue - var method = this$1.startNode() - var isGenerator = this$1.eat(tt.star) - var isAsync = false - var isMaybeStatic = this$1.type === tt.name && this$1.value === "static" - this$1.parsePropertyName(method) - method.static = isMaybeStatic && this$1.type !== tt.parenL - if (method.static) { - if (isGenerator) this$1.unexpected() - isGenerator = this$1.eat(tt.star) - this$1.parsePropertyName(method) - } - if (this$1.options.ecmaVersion >= 8 && !isGenerator && !method.computed && - method.key.type === "Identifier" && method.key.name === "async" && this$1.type !== tt.parenL && - !this$1.canInsertSemicolon()) { - isAsync = true - this$1.parsePropertyName(method) - } - method.kind = "method" - var isGetSet = false - if (!method.computed) { - var key = method.key; - if (!isGenerator && !isAsync && key.type === "Identifier" && this$1.type !== tt.parenL && (key.name === "get" || key.name === "set")) { - isGetSet = true - method.kind = key.name - key = this$1.parsePropertyName(method) - } - if (!method.static && (key.type === "Identifier" && key.name === "constructor" || - key.type === "Literal" && key.value === "constructor")) { - if (hadConstructor) this$1.raise(key.start, "Duplicate constructor in the same class") - if (isGetSet) this$1.raise(key.start, "Constructor can't have get/set modifier") - if (isGenerator) this$1.raise(key.start, "Constructor can't be a generator") - if (isAsync) this$1.raise(key.start, "Constructor can't be an async method") - method.kind = "constructor" - hadConstructor = true - } - } - this$1.parseClassMethod(classBody, method, isGenerator, isAsync) - if (isGetSet) { - var paramCount = method.kind === "get" ? 0 : 1 - if (method.value.params.length !== paramCount) { - var start = method.value.start - if (method.kind === "get") - this$1.raiseRecoverable(start, "getter should have no params") - else - this$1.raiseRecoverable(start, "setter should have exactly one param") - } else { - if (method.kind === "set" && method.value.params[0].type === "RestElement") - this$1.raiseRecoverable(method.value.params[0].start, "Setter cannot use rest params") - } - } + var startLoc = this.options.onComment && this.curPosition() + var start = this.pos, end = this.input.indexOf("*/", this.pos += 2) + if (end === -1) this.raise(this.pos - 2, "Unterminated comment") + this.pos = end + 2 + if (this.options.locations) { + lineBreakG.lastIndex = start + var match + while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) { + ++this$1.curLine + this$1.lineStart = match.index + match[0].length } - node.body = this.finishNode(classBody, "ClassBody") - return this.finishNode(node, isStatement ? "ClassDeclaration" : "ClassExpression") } + if (this.options.onComment) + this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, + startLoc, this.curPosition()) +} - pp$1.parseClassMethod = function(classBody, method, isGenerator, isAsync) { - method.value = this.parseMethod(isGenerator, isAsync) - classBody.body.push(this.finishNode(method, "MethodDefinition")) - } +pp$7.skipLineComment = function(startSkip) { + var this$1 = this; - pp$1.parseClassId = function(node, isStatement) { - node.id = this.type === tt.name ? this.parseIdent() : isStatement ? this.unexpected() : null + var start = this.pos + var startLoc = this.options.onComment && this.curPosition() + var ch = this.input.charCodeAt(this.pos+=startSkip) + while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) { + ++this$1.pos + ch = this$1.input.charCodeAt(this$1.pos) } + if (this.options.onComment) + this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, + startLoc, this.curPosition()) +} - pp$1.parseClassSuper = function(node) { - node.superClass = this.eat(tt._extends) ? this.parseExprSubscripts() : null - } +// Called at the start of the parse and after every token. Skips +// whitespace and comments, and. - // Parses module export declaration. +pp$7.skipSpace = function() { + var this$1 = this; - pp$1.parseExport = function(node, exports) { - var this$1 = this; - - this.next() - // export * from '...' - if (this.eat(tt.star)) { - this.expectContextual("from") - node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() - this.semicolon() - return this.finishNode(node, "ExportAllDeclaration") - } - if (this.eat(tt._default)) { // export default ... - this.checkExport(exports, "default", this.lastTokStart) - var parens = this.type == tt.parenL - var expr = this.parseMaybeAssign() - var needsSemi = true - if (!parens && (expr.type == "FunctionExpression" || - expr.type == "ClassExpression")) { - needsSemi = false - if (expr.id) { - expr.type = expr.type == "FunctionExpression" - ? "FunctionDeclaration" - : "ClassDeclaration" - } - } - node.declaration = expr - if (needsSemi) this.semicolon() - return this.finishNode(node, "ExportDefaultDeclaration") - } - // export var|const|let|function|class ... - if (this.shouldParseExportStatement()) { - node.declaration = this.parseStatement(true) - if (node.declaration.type === "VariableDeclaration") - this.checkVariableExport(exports, node.declaration.declarations) - else - this.checkExport(exports, node.declaration.id.name, node.declaration.id.start) - node.specifiers = [] - node.source = null - } else { // export { x, y as z } [from '...'] - node.declaration = null - node.specifiers = this.parseExportSpecifiers(exports) - if (this.eatContextual("from")) { - node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() - } else { - // check for keywords used as local names - for (var i = 0; i < node.specifiers.length; i++) { - if (this$1.keywords.test(node.specifiers[i].local.name) || this$1.reservedWords.test(node.specifiers[i].local.name)) { - this$1.unexpected(node.specifiers[i].local.start) - } - } - - node.source = null - } - this.semicolon() - } - return this.finishNode(node, "ExportNamedDeclaration") - } - - pp$1.checkExport = function(exports, name, pos) { - if (!exports) return - if (Object.prototype.hasOwnProperty.call(exports, name)) - this.raiseRecoverable(pos, "Duplicate export '" + name + "'") - exports[name] = true - } - - pp$1.checkPatternExport = function(exports, pat) { - var this$1 = this; - - var type = pat.type - if (type == "Identifier") - this.checkExport(exports, pat.name, pat.start) - else if (type == "ObjectPattern") - for (var i = 0; i < pat.properties.length; ++i) - this$1.checkPatternExport(exports, pat.properties[i].value) - else if (type == "ArrayPattern") - for (var i$1 = 0; i$1 < pat.elements.length; ++i$1) { - var elt = pat.elements[i$1] - if (elt) this$1.checkPatternExport(exports, elt) - } - else if (type == "AssignmentPattern") - this.checkPatternExport(exports, pat.left) - else if (type == "ParenthesizedExpression") - this.checkPatternExport(exports, pat.expression) - } - - pp$1.checkVariableExport = function(exports, decls) { - var this$1 = this; - - if (!exports) return - for (var i = 0; i < decls.length; i++) - this$1.checkPatternExport(exports, decls[i].id) - } - - pp$1.shouldParseExportStatement = function() { - return this.type.keyword || this.isLet() || this.isAsyncFunction() - } - - // Parses a comma-separated list of module exports. - - pp$1.parseExportSpecifiers = function(exports) { - var this$1 = this; - - var nodes = [], first = true - // export { x, y as z } [from '...'] - this.expect(tt.braceL) - while (!this.eat(tt.braceR)) { - if (!first) { - this$1.expect(tt.comma) - if (this$1.afterTrailingComma(tt.braceR)) break - } else first = false - - var node = this$1.startNode() - node.local = this$1.parseIdent(this$1.type === tt._default) - node.exported = this$1.eatContextual("as") ? this$1.parseIdent(true) : node.local - this$1.checkExport(exports, node.exported.name, node.exported.start) - nodes.push(this$1.finishNode(node, "ExportSpecifier")) - } - return nodes - } - - // Parses import declaration. - - pp$1.parseImport = function(node) { - this.next() - // import '...' - if (this.type === tt.string) { - node.specifiers = empty - node.source = this.parseExprAtom() - } else { - node.specifiers = this.parseImportSpecifiers() - this.expectContextual("from") - node.source = this.type === tt.string ? this.parseExprAtom() : this.unexpected() - } - this.semicolon() - return this.finishNode(node, "ImportDeclaration") - } - - // Parses a comma-separated list of module imports. - - pp$1.parseImportSpecifiers = function() { - var this$1 = this; - - var nodes = [], first = true - if (this.type === tt.name) { - // import defaultObj, { x, y as z } from '...' - var node = this.startNode() - node.local = this.parseIdent() - this.checkLVal(node.local, true) - nodes.push(this.finishNode(node, "ImportDefaultSpecifier")) - if (!this.eat(tt.comma)) return nodes - } - if (this.type === tt.star) { - var node$1 = this.startNode() - this.next() - this.expectContextual("as") - node$1.local = this.parseIdent() - this.checkLVal(node$1.local, true) - nodes.push(this.finishNode(node$1, "ImportNamespaceSpecifier")) - return nodes - } - this.expect(tt.braceL) - while (!this.eat(tt.braceR)) { - if (!first) { - this$1.expect(tt.comma) - if (this$1.afterTrailingComma(tt.braceR)) break - } else first = false - - var node$2 = this$1.startNode() - node$2.imported = this$1.parseIdent(true) - if (this$1.eatContextual("as")) { - node$2.local = this$1.parseIdent() - } else { - node$2.local = node$2.imported - if (this$1.isKeyword(node$2.local.name)) this$1.unexpected(node$2.local.start) - if (this$1.reservedWordsStrict.test(node$2.local.name)) this$1.raiseRecoverable(node$2.local.start, "The keyword '" + node$2.local.name + "' is reserved") - } - this$1.checkLVal(node$2.local, true) - nodes.push(this$1.finishNode(node$2, "ImportSpecifier")) - } - return nodes - } - - var pp$2 = Parser.prototype - - // Convert existing expression atom to assignable pattern - // if possible. - - pp$2.toAssignable = function(node, isBinding) { - var this$1 = this; - - if (this.options.ecmaVersion >= 6 && node) { - switch (node.type) { - case "Identifier": - if (this.inAsync && node.name === "await") - this.raise(node.start, "Can not use 'await' as identifier inside an async function") - break - - case "ObjectPattern": - case "ArrayPattern": - break - - case "ObjectExpression": - node.type = "ObjectPattern" - for (var i = 0; i < node.properties.length; i++) { - var prop = node.properties[i] - if (prop.kind !== "init") this$1.raise(prop.key.start, "Object pattern can't contain getter or setter") - this$1.toAssignable(prop.value, isBinding) - } - break - - case "ArrayExpression": - node.type = "ArrayPattern" - this.toAssignableList(node.elements, isBinding) - break - - case "AssignmentExpression": - if (node.operator === "=") { - node.type = "AssignmentPattern" - delete node.operator - this.toAssignable(node.left, isBinding) - // falls through to AssignmentPattern - } else { - this.raise(node.left.end, "Only '=' operator can be used for specifying default value.") - break - } - - case "AssignmentPattern": - break - - case "ParenthesizedExpression": - node.expression = this.toAssignable(node.expression, isBinding) - break - - case "MemberExpression": - if (!isBinding) break - - default: - this.raise(node.start, "Assigning to rvalue") - } - } - return node - } - - // Convert list of expression atoms to binding list. - - pp$2.toAssignableList = function(exprList, isBinding) { - var this$1 = this; - - var end = exprList.length - if (end) { - var last = exprList[end - 1] - if (last && last.type == "RestElement") { - --end - } else if (last && last.type == "SpreadElement") { - last.type = "RestElement" - var arg = last.argument - this.toAssignable(arg, isBinding) - if (arg.type !== "Identifier" && arg.type !== "MemberExpression" && arg.type !== "ArrayPattern") - this.unexpected(arg.start) - --end - } - - if (isBinding && last && last.type === "RestElement" && last.argument.type !== "Identifier") - this.unexpected(last.argument.start) - } - for (var i = 0; i < end; i++) { - var elt = exprList[i] - if (elt) this$1.toAssignable(elt, isBinding) - } - return exprList - } - - // Parses spread element. - - pp$2.parseSpread = function(refDestructuringErrors) { - var node = this.startNode() - this.next() - node.argument = this.parseMaybeAssign(false, refDestructuringErrors) - return this.finishNode(node, "SpreadElement") - } - - pp$2.parseRest = function(allowNonIdent) { - var node = this.startNode() - this.next() - - // RestElement inside of a function parameter must be an identifier - if (allowNonIdent) node.argument = this.type === tt.name ? this.parseIdent() : this.unexpected() - else node.argument = this.type === tt.name || this.type === tt.bracketL ? this.parseBindingAtom() : this.unexpected() - - return this.finishNode(node, "RestElement") - } - - // Parses lvalue (assignable) atom. - - pp$2.parseBindingAtom = function() { - if (this.options.ecmaVersion < 6) return this.parseIdent() - switch (this.type) { - case tt.name: - return this.parseIdent() - - case tt.bracketL: - var node = this.startNode() - this.next() - node.elements = this.parseBindingList(tt.bracketR, true, true) - return this.finishNode(node, "ArrayPattern") - - case tt.braceL: - return this.parseObj(true) - - default: - this.unexpected() - } - } - - pp$2.parseBindingList = function(close, allowEmpty, allowTrailingComma, allowNonIdent) { - var this$1 = this; - - var elts = [], first = true - while (!this.eat(close)) { - if (first) first = false - else this$1.expect(tt.comma) - if (allowEmpty && this$1.type === tt.comma) { - elts.push(null) - } else if (allowTrailingComma && this$1.afterTrailingComma(close)) { - break - } else if (this$1.type === tt.ellipsis) { - var rest = this$1.parseRest(allowNonIdent) - this$1.parseBindingListItem(rest) - elts.push(rest) - if (this$1.type === tt.comma) this$1.raise(this$1.start, "Comma is not permitted after the rest element") - this$1.expect(close) - break - } else { - var elem = this$1.parseMaybeDefault(this$1.start, this$1.startLoc) - this$1.parseBindingListItem(elem) - elts.push(elem) - } - } - return elts - } - - pp$2.parseBindingListItem = function(param) { - return param - } - - // Parses assignment pattern around given atom if possible. - - pp$2.parseMaybeDefault = function(startPos, startLoc, left) { - left = left || this.parseBindingAtom() - if (this.options.ecmaVersion < 6 || !this.eat(tt.eq)) return left - var node = this.startNodeAt(startPos, startLoc) - node.left = left - node.right = this.parseMaybeAssign() - return this.finishNode(node, "AssignmentPattern") - } - - // Verify that a node is an lval — something that can be assigned - // to. - - pp$2.checkLVal = function(expr, isBinding, checkClashes) { - var this$1 = this; - - switch (expr.type) { - case "Identifier": - if (this.strict && this.reservedWordsStrictBind.test(expr.name)) - this.raiseRecoverable(expr.start, (isBinding ? "Binding " : "Assigning to ") + expr.name + " in strict mode") - if (checkClashes) { - if (has(checkClashes, expr.name)) - this.raiseRecoverable(expr.start, "Argument name clash") - checkClashes[expr.name] = true - } - break - - case "MemberExpression": - if (isBinding) this.raiseRecoverable(expr.start, (isBinding ? "Binding" : "Assigning to") + " member expression") - break - - case "ObjectPattern": - for (var i = 0; i < expr.properties.length; i++) - this$1.checkLVal(expr.properties[i].value, isBinding, checkClashes) - break - - case "ArrayPattern": - for (var i$1 = 0; i$1 < expr.elements.length; i$1++) { - var elem = expr.elements[i$1] - if (elem) this$1.checkLVal(elem, isBinding, checkClashes) - } - break - - case "AssignmentPattern": - this.checkLVal(expr.left, isBinding, checkClashes) - break - - case "RestElement": - this.checkLVal(expr.argument, isBinding, checkClashes) - break - - case "ParenthesizedExpression": - this.checkLVal(expr.expression, isBinding, checkClashes) - break - - default: - this.raise(expr.start, (isBinding ? "Binding" : "Assigning to") + " rvalue") - } - } - - var pp$3 = Parser.prototype - - // Check if property name clashes with already added. - // Object/class getters and setters are not allowed to clash — - // either with each other or with an init property — and in - // strict mode, init properties are also not allowed to be repeated. - - pp$3.checkPropClash = function(prop, propHash) { - if (this.options.ecmaVersion >= 6 && (prop.computed || prop.method || prop.shorthand)) - return - var key = prop.key; - var name - switch (key.type) { - case "Identifier": name = key.name; break - case "Literal": name = String(key.value); break - default: return - } - var kind = prop.kind; - if (this.options.ecmaVersion >= 6) { - if (name === "__proto__" && kind === "init") { - if (propHash.proto) this.raiseRecoverable(key.start, "Redefinition of __proto__ property") - propHash.proto = true - } - return - } - name = "$" + name - var other = propHash[name] - if (other) { - var isGetSet = kind !== "init" - if ((this.strict || isGetSet) && other[kind] || !(isGetSet ^ other.init)) - this.raiseRecoverable(key.start, "Redefinition of property") - } else { - other = propHash[name] = { - init: false, - get: false, - set: false - } - } - other[kind] = true - } - - // ### Expression parsing - - // These nest, from the most general expression type at the top to - // 'atomic', nondivisible expression types at the bottom. Most of - // the functions will simply let the function(s) below them parse, - // and, *if* the syntactic construct they handle is present, wrap - // the AST node that the inner parser gave them in another node. - - // Parse a full expression. The optional arguments are used to - // forbid the `in` operator (in for loops initalization expressions) - // and provide reference for storing '=' operator inside shorthand - // property assignment in contexts where both object expression - // and object pattern might appear (so it's possible to raise - // delayed syntax error at correct position). - - pp$3.parseExpression = function(noIn, refDestructuringErrors) { - var this$1 = this; - - var startPos = this.start, startLoc = this.startLoc - var expr = this.parseMaybeAssign(noIn, refDestructuringErrors) - if (this.type === tt.comma) { - var node = this.startNodeAt(startPos, startLoc) - node.expressions = [expr] - while (this.eat(tt.comma)) node.expressions.push(this$1.parseMaybeAssign(noIn, refDestructuringErrors)) - return this.finishNode(node, "SequenceExpression") - } - return expr - } - - // Parse an assignment expression. This includes applications of - // operators like `+=`. - - pp$3.parseMaybeAssign = function(noIn, refDestructuringErrors, afterLeftParse) { - if (this.inGenerator && this.isContextual("yield")) return this.parseYield() - - var ownDestructuringErrors = false - if (!refDestructuringErrors) { - refDestructuringErrors = new DestructuringErrors - ownDestructuringErrors = true - } - var startPos = this.start, startLoc = this.startLoc - if (this.type == tt.parenL || this.type == tt.name) - this.potentialArrowAt = this.start - var left = this.parseMaybeConditional(noIn, refDestructuringErrors) - if (afterLeftParse) left = afterLeftParse.call(this, left, startPos, startLoc) - if (this.type.isAssign) { - this.checkPatternErrors(refDestructuringErrors, true) - if (!ownDestructuringErrors) DestructuringErrors.call(refDestructuringErrors) - var node = this.startNodeAt(startPos, startLoc) - node.operator = this.value - node.left = this.type === tt.eq ? this.toAssignable(left) : left - refDestructuringErrors.shorthandAssign = 0 // reset because shorthand default was used correctly - this.checkLVal(left) - this.next() - node.right = this.parseMaybeAssign(noIn) - return this.finishNode(node, "AssignmentExpression") - } else { - if (ownDestructuringErrors) this.checkExpressionErrors(refDestructuringErrors, true) - } - return left - } - - // Parse a ternary conditional (`?:`) operator. - - pp$3.parseMaybeConditional = function(noIn, refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc - var expr = this.parseExprOps(noIn, refDestructuringErrors) - if (this.checkExpressionErrors(refDestructuringErrors)) return expr - if (this.eat(tt.question)) { - var node = this.startNodeAt(startPos, startLoc) - node.test = expr - node.consequent = this.parseMaybeAssign() - this.expect(tt.colon) - node.alternate = this.parseMaybeAssign(noIn) - return this.finishNode(node, "ConditionalExpression") - } - return expr - } - - // Start the precedence parser. - - pp$3.parseExprOps = function(noIn, refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc - var expr = this.parseMaybeUnary(refDestructuringErrors, false) - if (this.checkExpressionErrors(refDestructuringErrors)) return expr - return this.parseExprOp(expr, startPos, startLoc, -1, noIn) - } - - // Parse binary operators with the operator precedence parsing - // algorithm. `left` is the left-hand side of the operator. - // `minPrec` provides context that allows the function to stop and - // defer further parser to one of its callers when it encounters an - // operator that has a lower precedence than the set it is parsing. - - pp$3.parseExprOp = function(left, leftStartPos, leftStartLoc, minPrec, noIn) { - var prec = this.type.binop - if (prec != null && (!noIn || this.type !== tt._in)) { - if (prec > minPrec) { - var logical = this.type === tt.logicalOR || this.type === tt.logicalAND - var op = this.value - this.next() - var startPos = this.start, startLoc = this.startLoc - var right = this.parseExprOp(this.parseMaybeUnary(null, false), startPos, startLoc, prec, noIn) - var node = this.buildBinary(leftStartPos, leftStartLoc, left, right, op, logical) - return this.parseExprOp(node, leftStartPos, leftStartLoc, minPrec, noIn) - } - } - return left - } - - pp$3.buildBinary = function(startPos, startLoc, left, right, op, logical) { - var node = this.startNodeAt(startPos, startLoc) - node.left = left - node.operator = op - node.right = right - return this.finishNode(node, logical ? "LogicalExpression" : "BinaryExpression") - } - - // Parse unary operators, both prefix and postfix. - - pp$3.parseMaybeUnary = function(refDestructuringErrors, sawUnary) { - var this$1 = this; - - var startPos = this.start, startLoc = this.startLoc, expr - if (this.inAsync && this.isContextual("await")) { - expr = this.parseAwait(refDestructuringErrors) - sawUnary = true - } else if (this.type.prefix) { - var node = this.startNode(), update = this.type === tt.incDec - node.operator = this.value - node.prefix = true - this.next() - node.argument = this.parseMaybeUnary(null, true) - this.checkExpressionErrors(refDestructuringErrors, true) - if (update) this.checkLVal(node.argument) - else if (this.strict && node.operator === "delete" && - node.argument.type === "Identifier") - this.raiseRecoverable(node.start, "Deleting local variable in strict mode") - else sawUnary = true - expr = this.finishNode(node, update ? "UpdateExpression" : "UnaryExpression") - } else { - expr = this.parseExprSubscripts(refDestructuringErrors) - if (this.checkExpressionErrors(refDestructuringErrors)) return expr - while (this.type.postfix && !this.canInsertSemicolon()) { - var node$1 = this$1.startNodeAt(startPos, startLoc) - node$1.operator = this$1.value - node$1.prefix = false - node$1.argument = expr - this$1.checkLVal(expr) - this$1.next() - expr = this$1.finishNode(node$1, "UpdateExpression") - } - } - - if (!sawUnary && this.eat(tt.starstar)) - return this.buildBinary(startPos, startLoc, expr, this.parseMaybeUnary(null, false), "**", false) - else - return expr - } - - // Parse call, dot, and `[]`-subscript expressions. - - pp$3.parseExprSubscripts = function(refDestructuringErrors) { - var startPos = this.start, startLoc = this.startLoc - var expr = this.parseExprAtom(refDestructuringErrors) - var skipArrowSubscripts = expr.type === "ArrowFunctionExpression" && this.input.slice(this.lastTokStart, this.lastTokEnd) !== ")" - if (this.checkExpressionErrors(refDestructuringErrors) || skipArrowSubscripts) return expr - return this.parseSubscripts(expr, startPos, startLoc) - } - - pp$3.parseSubscripts = function(base, startPos, startLoc, noCalls) { - var this$1 = this; - - for (;;) { - var maybeAsyncArrow = this$1.options.ecmaVersion >= 8 && base.type === "Identifier" && base.name === "async" && !this$1.canInsertSemicolon() - if (this$1.eat(tt.dot)) { - var node = this$1.startNodeAt(startPos, startLoc) - node.object = base - node.property = this$1.parseIdent(true) - node.computed = false - base = this$1.finishNode(node, "MemberExpression") - } else if (this$1.eat(tt.bracketL)) { - var node$1 = this$1.startNodeAt(startPos, startLoc) - node$1.object = base - node$1.property = this$1.parseExpression() - node$1.computed = true - this$1.expect(tt.bracketR) - base = this$1.finishNode(node$1, "MemberExpression") - } else if (!noCalls && this$1.eat(tt.parenL)) { - var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this$1.yieldPos, oldAwaitPos = this$1.awaitPos - this$1.yieldPos = 0 - this$1.awaitPos = 0 - var exprList = this$1.parseExprList(tt.parenR, this$1.options.ecmaVersion >= 8, false, refDestructuringErrors) - if (maybeAsyncArrow && !this$1.canInsertSemicolon() && this$1.eat(tt.arrow)) { - this$1.checkPatternErrors(refDestructuringErrors, true) - this$1.checkYieldAwaitInDefaultParams() - this$1.yieldPos = oldYieldPos - this$1.awaitPos = oldAwaitPos - return this$1.parseArrowExpression(this$1.startNodeAt(startPos, startLoc), exprList, true) - } - this$1.checkExpressionErrors(refDestructuringErrors, true) - this$1.yieldPos = oldYieldPos || this$1.yieldPos - this$1.awaitPos = oldAwaitPos || this$1.awaitPos - var node$2 = this$1.startNodeAt(startPos, startLoc) - node$2.callee = base - node$2.arguments = exprList - base = this$1.finishNode(node$2, "CallExpression") - } else if (this$1.type === tt.backQuote) { - var node$3 = this$1.startNodeAt(startPos, startLoc) - node$3.tag = base - node$3.quasi = this$1.parseTemplate() - base = this$1.finishNode(node$3, "TaggedTemplateExpression") - } else { - return base - } - } - } - - // Parse an atomic expression — either a single token that is an - // expression, an expression started by a keyword like `function` or - // `new`, or an expression wrapped in punctuation like `()`, `[]`, - // or `{}`. - - pp$3.parseExprAtom = function(refDestructuringErrors) { - var node, canBeArrow = this.potentialArrowAt == this.start - switch (this.type) { - case tt._super: - if (!this.inFunction) - this.raise(this.start, "'super' outside of function or class") - - case tt._this: - var type = this.type === tt._this ? "ThisExpression" : "Super" - node = this.startNode() - this.next() - return this.finishNode(node, type) - - case tt.name: - var startPos = this.start, startLoc = this.startLoc - var id = this.parseIdent(this.type !== tt.name) - if (this.options.ecmaVersion >= 8 && id.name === "async" && !this.canInsertSemicolon() && this.eat(tt._function)) - return this.parseFunction(this.startNodeAt(startPos, startLoc), false, false, true) - if (canBeArrow && !this.canInsertSemicolon()) { - if (this.eat(tt.arrow)) - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], false) - if (this.options.ecmaVersion >= 8 && id.name === "async" && this.type === tt.name) { - id = this.parseIdent() - if (this.canInsertSemicolon() || !this.eat(tt.arrow)) - this.unexpected() - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), [id], true) - } - } - return id - - case tt.regexp: - var value = this.value - node = this.parseLiteral(value.value) - node.regex = {pattern: value.pattern, flags: value.flags} - return node - - case tt.num: case tt.string: - return this.parseLiteral(this.value) - - case tt._null: case tt._true: case tt._false: - node = this.startNode() - node.value = this.type === tt._null ? null : this.type === tt._true - node.raw = this.type.keyword - this.next() - return this.finishNode(node, "Literal") - - case tt.parenL: - return this.parseParenAndDistinguishExpression(canBeArrow) - - case tt.bracketL: - node = this.startNode() - this.next() - node.elements = this.parseExprList(tt.bracketR, true, true, refDestructuringErrors) - return this.finishNode(node, "ArrayExpression") - - case tt.braceL: - return this.parseObj(false, refDestructuringErrors) - - case tt._function: - node = this.startNode() - this.next() - return this.parseFunction(node, false) - - case tt._class: - return this.parseClass(this.startNode(), false) - - case tt._new: - return this.parseNew() - - case tt.backQuote: - return this.parseTemplate() - - default: - this.unexpected() - } - } - - pp$3.parseLiteral = function(value) { - var node = this.startNode() - node.value = value - node.raw = this.input.slice(this.start, this.end) - this.next() - return this.finishNode(node, "Literal") - } - - pp$3.parseParenExpression = function() { - this.expect(tt.parenL) - var val = this.parseExpression() - this.expect(tt.parenR) - return val - } - - pp$3.parseParenAndDistinguishExpression = function(canBeArrow) { - var this$1 = this; - - var startPos = this.start, startLoc = this.startLoc, val, allowTrailingComma = this.options.ecmaVersion >= 8 - if (this.options.ecmaVersion >= 6) { - this.next() - - var innerStartPos = this.start, innerStartLoc = this.startLoc - var exprList = [], first = true, lastIsComma = false - var refDestructuringErrors = new DestructuringErrors, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos, spreadStart, innerParenStart - this.yieldPos = 0 - this.awaitPos = 0 - while (this.type !== tt.parenR) { - first ? first = false : this$1.expect(tt.comma) - if (allowTrailingComma && this$1.afterTrailingComma(tt.parenR, true)) { - lastIsComma = true - break - } else if (this$1.type === tt.ellipsis) { - spreadStart = this$1.start - exprList.push(this$1.parseParenItem(this$1.parseRest())) - if (this$1.type === tt.comma) this$1.raise(this$1.start, "Comma is not permitted after the rest element") - break - } else { - if (this$1.type === tt.parenL && !innerParenStart) { - innerParenStart = this$1.start - } - exprList.push(this$1.parseMaybeAssign(false, refDestructuringErrors, this$1.parseParenItem)) - } - } - var innerEndPos = this.start, innerEndLoc = this.startLoc - this.expect(tt.parenR) - - if (canBeArrow && !this.canInsertSemicolon() && this.eat(tt.arrow)) { - this.checkPatternErrors(refDestructuringErrors, true) - this.checkYieldAwaitInDefaultParams() - if (innerParenStart) this.unexpected(innerParenStart) - this.yieldPos = oldYieldPos - this.awaitPos = oldAwaitPos - return this.parseParenArrowList(startPos, startLoc, exprList) - } - - if (!exprList.length || lastIsComma) this.unexpected(this.lastTokStart) - if (spreadStart) this.unexpected(spreadStart) - this.checkExpressionErrors(refDestructuringErrors, true) - this.yieldPos = oldYieldPos || this.yieldPos - this.awaitPos = oldAwaitPos || this.awaitPos - - if (exprList.length > 1) { - val = this.startNodeAt(innerStartPos, innerStartLoc) - val.expressions = exprList - this.finishNodeAt(val, "SequenceExpression", innerEndPos, innerEndLoc) - } else { - val = exprList[0] - } - } else { - val = this.parseParenExpression() - } - - if (this.options.preserveParens) { - var par = this.startNodeAt(startPos, startLoc) - par.expression = val - return this.finishNode(par, "ParenthesizedExpression") - } else { - return val - } - } - - pp$3.parseParenItem = function(item) { - return item - } - - pp$3.parseParenArrowList = function(startPos, startLoc, exprList) { - return this.parseArrowExpression(this.startNodeAt(startPos, startLoc), exprList) - } - - // New's precedence is slightly tricky. It must allow its argument to - // be a `[]` or dot subscript expression, but not a call — at least, - // not without wrapping it in parentheses. Thus, it uses the noCalls - // argument to parseSubscripts to prevent it from consuming the - // argument list. - - var empty$1 = [] - - pp$3.parseNew = function() { - var node = this.startNode() - var meta = this.parseIdent(true) - if (this.options.ecmaVersion >= 6 && this.eat(tt.dot)) { - node.meta = meta - node.property = this.parseIdent(true) - if (node.property.name !== "target") - this.raiseRecoverable(node.property.start, "The only valid meta property for new is new.target") - if (!this.inFunction) - this.raiseRecoverable(node.start, "new.target can only be used in functions") - return this.finishNode(node, "MetaProperty") - } - var startPos = this.start, startLoc = this.startLoc - node.callee = this.parseSubscripts(this.parseExprAtom(), startPos, startLoc, true) - if (this.eat(tt.parenL)) node.arguments = this.parseExprList(tt.parenR, this.options.ecmaVersion >= 8, false) - else node.arguments = empty$1 - return this.finishNode(node, "NewExpression") - } - - // Parse template expression. - - pp$3.parseTemplateElement = function() { - var elem = this.startNode() - elem.value = { - raw: this.input.slice(this.start, this.end).replace(/\r\n?/g, '\n'), - cooked: this.value - } - this.next() - elem.tail = this.type === tt.backQuote - return this.finishNode(elem, "TemplateElement") - } - - pp$3.parseTemplate = function() { - var this$1 = this; - - var node = this.startNode() - this.next() - node.expressions = [] - var curElt = this.parseTemplateElement() - node.quasis = [curElt] - while (!curElt.tail) { - this$1.expect(tt.dollarBraceL) - node.expressions.push(this$1.parseExpression()) - this$1.expect(tt.braceR) - node.quasis.push(curElt = this$1.parseTemplateElement()) - } - this.next() - return this.finishNode(node, "TemplateLiteral") - } - - // Parse an object literal or binding pattern. - - pp$3.parseObj = function(isPattern, refDestructuringErrors) { - var this$1 = this; - - var node = this.startNode(), first = true, propHash = {} - node.properties = [] - this.next() - while (!this.eat(tt.braceR)) { - if (!first) { - this$1.expect(tt.comma) - if (this$1.afterTrailingComma(tt.braceR)) break - } else first = false - - var prop = this$1.startNode(), isGenerator, isAsync, startPos, startLoc - if (this$1.options.ecmaVersion >= 6) { - prop.method = false - prop.shorthand = false - if (isPattern || refDestructuringErrors) { - startPos = this$1.start - startLoc = this$1.startLoc - } - if (!isPattern) - isGenerator = this$1.eat(tt.star) - } - this$1.parsePropertyName(prop) - if (!isPattern && this$1.options.ecmaVersion >= 8 && !isGenerator && !prop.computed && - prop.key.type === "Identifier" && prop.key.name === "async" && this$1.type !== tt.parenL && - this$1.type !== tt.colon && !this$1.canInsertSemicolon()) { - isAsync = true - this$1.parsePropertyName(prop, refDestructuringErrors) - } else { - isAsync = false - } - this$1.parsePropertyValue(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors) - this$1.checkPropClash(prop, propHash) - node.properties.push(this$1.finishNode(prop, "Property")) - } - return this.finishNode(node, isPattern ? "ObjectPattern" : "ObjectExpression") - } - - pp$3.parsePropertyValue = function(prop, isPattern, isGenerator, isAsync, startPos, startLoc, refDestructuringErrors) { - if ((isGenerator || isAsync) && this.type === tt.colon) - this.unexpected() - - if (this.eat(tt.colon)) { - prop.value = isPattern ? this.parseMaybeDefault(this.start, this.startLoc) : this.parseMaybeAssign(false, refDestructuringErrors) - prop.kind = "init" - } else if (this.options.ecmaVersion >= 6 && this.type === tt.parenL) { - if (isPattern) this.unexpected() - prop.kind = "init" - prop.method = true - prop.value = this.parseMethod(isGenerator, isAsync) - } else if (this.options.ecmaVersion >= 5 && !prop.computed && prop.key.type === "Identifier" && - (prop.key.name === "get" || prop.key.name === "set") && - (this.type != tt.comma && this.type != tt.braceR)) { - if (isGenerator || isAsync || isPattern) this.unexpected() - prop.kind = prop.key.name - this.parsePropertyName(prop) - prop.value = this.parseMethod(false) - var paramCount = prop.kind === "get" ? 0 : 1 - if (prop.value.params.length !== paramCount) { - var start = prop.value.start - if (prop.kind === "get") - this.raiseRecoverable(start, "getter should have no params") - else - this.raiseRecoverable(start, "setter should have exactly one param") - } else { - if (prop.kind === "set" && prop.value.params[0].type === "RestElement") - this.raiseRecoverable(prop.value.params[0].start, "Setter cannot use rest params") - } - } else if (this.options.ecmaVersion >= 6 && !prop.computed && prop.key.type === "Identifier") { - if (this.keywords.test(prop.key.name) || - (this.strict ? this.reservedWordsStrict : this.reservedWords).test(prop.key.name) || - (this.inGenerator && prop.key.name == "yield") || - (this.inAsync && prop.key.name == "await")) - this.raiseRecoverable(prop.key.start, "'" + prop.key.name + "' can not be used as shorthand property") - prop.kind = "init" - if (isPattern) { - prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key) - } else if (this.type === tt.eq && refDestructuringErrors) { - if (!refDestructuringErrors.shorthandAssign) - refDestructuringErrors.shorthandAssign = this.start - prop.value = this.parseMaybeDefault(startPos, startLoc, prop.key) - } else { - prop.value = prop.key - } - prop.shorthand = true - } else this.unexpected() - } - - pp$3.parsePropertyName = function(prop) { - if (this.options.ecmaVersion >= 6) { - if (this.eat(tt.bracketL)) { - prop.computed = true - prop.key = this.parseMaybeAssign() - this.expect(tt.bracketR) - return prop.key - } else { - prop.computed = false - } - } - return prop.key = this.type === tt.num || this.type === tt.string ? this.parseExprAtom() : this.parseIdent(true) - } - - // Initialize empty function node. - - pp$3.initFunction = function(node) { - node.id = null - if (this.options.ecmaVersion >= 6) { - node.generator = false - node.expression = false - } - if (this.options.ecmaVersion >= 8) - node.async = false - } - - // Parse object or class method. - - pp$3.parseMethod = function(isGenerator, isAsync) { - var node = this.startNode(), oldInGen = this.inGenerator, oldInAsync = this.inAsync, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos - - this.initFunction(node) - if (this.options.ecmaVersion >= 6) - node.generator = isGenerator - if (this.options.ecmaVersion >= 8) - node.async = !!isAsync - - this.inGenerator = node.generator - this.inAsync = node.async - this.yieldPos = 0 - this.awaitPos = 0 - - this.expect(tt.parenL) - node.params = this.parseBindingList(tt.parenR, false, this.options.ecmaVersion >= 8) - this.checkYieldAwaitInDefaultParams() - this.parseFunctionBody(node, false) - - this.inGenerator = oldInGen - this.inAsync = oldInAsync - this.yieldPos = oldYieldPos - this.awaitPos = oldAwaitPos - return this.finishNode(node, "FunctionExpression") - } - - // Parse arrow function expression with given parameters. - - pp$3.parseArrowExpression = function(node, params, isAsync) { - var oldInGen = this.inGenerator, oldInAsync = this.inAsync, oldYieldPos = this.yieldPos, oldAwaitPos = this.awaitPos - - this.initFunction(node) - if (this.options.ecmaVersion >= 8) - node.async = !!isAsync - - this.inGenerator = false - this.inAsync = node.async - this.yieldPos = 0 - this.awaitPos = 0 - - node.params = this.toAssignableList(params, true) - this.parseFunctionBody(node, true) - - this.inGenerator = oldInGen - this.inAsync = oldInAsync - this.yieldPos = oldYieldPos - this.awaitPos = oldAwaitPos - return this.finishNode(node, "ArrowFunctionExpression") - } - - // Parse function body and check parameters. - - pp$3.parseFunctionBody = function(node, isArrowFunction) { - var isExpression = isArrowFunction && this.type !== tt.braceL - - if (isExpression) { - node.body = this.parseMaybeAssign() - node.expression = true - } else { - // Start a new scope with regard to labels and the `inFunction` - // flag (restore them to their old value afterwards). - var oldInFunc = this.inFunction, oldLabels = this.labels - this.inFunction = true; this.labels = [] - node.body = this.parseBlock(true) - node.expression = false - this.inFunction = oldInFunc; this.labels = oldLabels - } - - // If this is a strict mode function, verify that argument names - // are not repeated, and it does not try to bind the words `eval` - // or `arguments`. - var useStrict = (!isExpression && node.body.body.length && this.isUseStrict(node.body.body[0])) ? node.body.body[0] : null - if (useStrict && this.options.ecmaVersion >= 7 && !this.isSimpleParamList(node.params)) - this.raiseRecoverable(useStrict.start, "Illegal 'use strict' directive in function with non-simple parameter list") - - if (this.strict || useStrict) { - var oldStrict = this.strict - this.strict = true - if (node.id) - this.checkLVal(node.id, true) - this.checkParams(node) - this.strict = oldStrict - } else if (isArrowFunction || !this.isSimpleParamList(node.params)) { - this.checkParams(node) - } - } - - pp$3.isSimpleParamList = function(params) { - for (var i = 0; i < params.length; i++) - if (params[i].type !== "Identifier") return false - return true - } - - // Checks function params for various disallowed patterns such as using "eval" - // or "arguments" and duplicate parameters. - - pp$3.checkParams = function(node) { - var this$1 = this; - - var nameHash = {} - for (var i = 0; i < node.params.length; i++) this$1.checkLVal(node.params[i], true, nameHash) - } - - // Parses a comma-separated list of expressions, and returns them as - // an array. `close` is the token type that ends the list, and - // `allowEmpty` can be turned on to allow subsequent commas with - // nothing in between them to be parsed as `null` (which is needed - // for array literals). - - pp$3.parseExprList = function(close, allowTrailingComma, allowEmpty, refDestructuringErrors) { - var this$1 = this; - - var elts = [], first = true - while (!this.eat(close)) { - if (!first) { - this$1.expect(tt.comma) - if (allowTrailingComma && this$1.afterTrailingComma(close)) break - } else first = false - - var elt - if (allowEmpty && this$1.type === tt.comma) - elt = null - else if (this$1.type === tt.ellipsis) { - elt = this$1.parseSpread(refDestructuringErrors) - if (this$1.type === tt.comma && refDestructuringErrors && !refDestructuringErrors.trailingComma) { - refDestructuringErrors.trailingComma = this$1.start - } - } else - elt = this$1.parseMaybeAssign(false, refDestructuringErrors) - elts.push(elt) - } - return elts - } - - // Parse the next token as an identifier. If `liberal` is true (used - // when parsing properties), it will also convert keywords into - // identifiers. - - pp$3.parseIdent = function(liberal) { - var node = this.startNode() - if (liberal && this.options.allowReserved == "never") liberal = false - if (this.type === tt.name) { - if (!liberal && (this.strict ? this.reservedWordsStrict : this.reservedWords).test(this.value) && - (this.options.ecmaVersion >= 6 || - this.input.slice(this.start, this.end).indexOf("\\") == -1)) - this.raiseRecoverable(this.start, "The keyword '" + this.value + "' is reserved") - if (this.inGenerator && this.value === "yield") - this.raiseRecoverable(this.start, "Can not use 'yield' as identifier inside a generator") - if (this.inAsync && this.value === "await") - this.raiseRecoverable(this.start, "Can not use 'await' as identifier inside an async function") - node.name = this.value - } else if (liberal && this.type.keyword) { - node.name = this.type.keyword - } else { - this.unexpected() - } - this.next() - return this.finishNode(node, "Identifier") - } - - // Parses yield expression inside generator. - - pp$3.parseYield = function() { - if (!this.yieldPos) this.yieldPos = this.start - - var node = this.startNode() - this.next() - if (this.type == tt.semi || this.canInsertSemicolon() || (this.type != tt.star && !this.type.startsExpr)) { - node.delegate = false - node.argument = null - } else { - node.delegate = this.eat(tt.star) - node.argument = this.parseMaybeAssign() - } - return this.finishNode(node, "YieldExpression") - } - - pp$3.parseAwait = function() { - if (!this.awaitPos) this.awaitPos = this.start - - var node = this.startNode() - this.next() - node.argument = this.parseMaybeUnary(null, true) - return this.finishNode(node, "AwaitExpression") - } - - var pp$4 = Parser.prototype - - // This function is used to raise exceptions on parse errors. It - // takes an offset integer (into the current `input`) to indicate - // the location of the error, attaches the position to the end - // of the error message, and then raises a `SyntaxError` with that - // message. - - pp$4.raise = function(pos, message) { - var loc = getLineInfo(this.input, pos) - message += " (" + loc.line + ":" + loc.column + ")" - var err = new SyntaxError(message) - err.pos = pos; err.loc = loc; err.raisedAt = this.pos - throw err - } - - pp$4.raiseRecoverable = pp$4.raise - - pp$4.curPosition = function() { - if (this.options.locations) { - return new Position(this.curLine, this.pos - this.lineStart) - } - } - - var Node = function Node(parser, pos, loc) { - this.type = "" - this.start = pos - this.end = 0 - if (parser.options.locations) - this.loc = new SourceLocation(parser, loc) - if (parser.options.directSourceFile) - this.sourceFile = parser.options.directSourceFile - if (parser.options.ranges) - this.range = [pos, 0] - }; - - // Start an AST node, attaching a start offset. - - var pp$5 = Parser.prototype - - pp$5.startNode = function() { - return new Node(this, this.start, this.startLoc) - } - - pp$5.startNodeAt = function(pos, loc) { - return new Node(this, pos, loc) - } - - // Finish an AST node, adding `type` and `end` properties. - - function finishNodeAt(node, type, pos, loc) { - node.type = type - node.end = pos - if (this.options.locations) - node.loc.end = loc - if (this.options.ranges) - node.range[1] = pos - return node - } - - pp$5.finishNode = function(node, type) { - return finishNodeAt.call(this, node, type, this.lastTokEnd, this.lastTokEndLoc) - } - - // Finish node at given position - - pp$5.finishNodeAt = function(node, type, pos, loc) { - return finishNodeAt.call(this, node, type, pos, loc) - } - - var TokContext = function TokContext(token, isExpr, preserveSpace, override) { - this.token = token - this.isExpr = !!isExpr - this.preserveSpace = !!preserveSpace - this.override = override - }; - - var types = { - b_stat: new TokContext("{", false), - b_expr: new TokContext("{", true), - b_tmpl: new TokContext("${", true), - p_stat: new TokContext("(", false), - p_expr: new TokContext("(", true), - q_tmpl: new TokContext("`", true, true, function (p) { return p.readTmplToken(); }), - f_expr: new TokContext("function", true) - } - - var pp$6 = Parser.prototype - - pp$6.initialContext = function() { - return [types.b_stat] - } - - pp$6.braceIsBlock = function(prevType) { - if (prevType === tt.colon) { - var parent = this.curContext() - if (parent === types.b_stat || parent === types.b_expr) - return !parent.isExpr - } - if (prevType === tt._return) - return lineBreak.test(this.input.slice(this.lastTokEnd, this.start)) - if (prevType === tt._else || prevType === tt.semi || prevType === tt.eof || prevType === tt.parenR) - return true - if (prevType == tt.braceL) - return this.curContext() === types.b_stat - return !this.exprAllowed - } - - pp$6.updateContext = function(prevType) { - var update, type = this.type - if (type.keyword && prevType == tt.dot) - this.exprAllowed = false - else if (update = type.updateContext) - update.call(this, prevType) - else - this.exprAllowed = type.beforeExpr - } - - // Token-specific context update code - - tt.parenR.updateContext = tt.braceR.updateContext = function() { - if (this.context.length == 1) { - this.exprAllowed = true - return - } - var out = this.context.pop() - if (out === types.b_stat && this.curContext() === types.f_expr) { - this.context.pop() - this.exprAllowed = false - } else if (out === types.b_tmpl) { - this.exprAllowed = true - } else { - this.exprAllowed = !out.isExpr - } - } - - tt.braceL.updateContext = function(prevType) { - this.context.push(this.braceIsBlock(prevType) ? types.b_stat : types.b_expr) - this.exprAllowed = true - } - - tt.dollarBraceL.updateContext = function() { - this.context.push(types.b_tmpl) - this.exprAllowed = true - } - - tt.parenL.updateContext = function(prevType) { - var statementParens = prevType === tt._if || prevType === tt._for || prevType === tt._with || prevType === tt._while - this.context.push(statementParens ? types.p_stat : types.p_expr) - this.exprAllowed = true - } - - tt.incDec.updateContext = function() { - // tokExprAllowed stays unchanged - } - - tt._function.updateContext = function(prevType) { - if (prevType.beforeExpr && prevType !== tt.semi && prevType !== tt._else && - !((prevType === tt.colon || prevType === tt.braceL) && this.curContext() === types.b_stat)) - this.context.push(types.f_expr) - this.exprAllowed = false - } - - tt.backQuote.updateContext = function() { - if (this.curContext() === types.q_tmpl) - this.context.pop() - else - this.context.push(types.q_tmpl) - this.exprAllowed = false - } - - // Object type used to represent tokens. Note that normally, tokens - // simply exist as properties on the parser object. This is only - // used for the onToken callback and the external tokenizer. - - var Token = function Token(p) { - this.type = p.type - this.value = p.value - this.start = p.start - this.end = p.end - if (p.options.locations) - this.loc = new SourceLocation(p, p.startLoc, p.endLoc) - if (p.options.ranges) - this.range = [p.start, p.end] - }; - - // ## Tokenizer - - var pp$7 = Parser.prototype - - // Are we running under Rhino? - var isRhino = typeof Packages == "object" && Object.prototype.toString.call(Packages) == "[object JavaPackage]" - - // Move to the next token - - pp$7.next = function() { - if (this.options.onToken) - this.options.onToken(new Token(this)) - - this.lastTokEnd = this.end - this.lastTokStart = this.start - this.lastTokEndLoc = this.endLoc - this.lastTokStartLoc = this.startLoc - this.nextToken() - } - - pp$7.getToken = function() { - this.next() - return new Token(this) - } - - // If we're in an ES6 environment, make parsers iterable - if (typeof Symbol !== "undefined") - pp$7[Symbol.iterator] = function () { - var self = this - return {next: function () { - var token = self.getToken() - return { - done: token.type === tt.eof, - value: token - } - }} - } - - // Toggle strict mode. Re-reads the next number or string to please - // pedantic tests (`"use strict"; 010;` should fail). - - pp$7.setStrict = function(strict) { - var this$1 = this; - - this.strict = strict - if (this.type !== tt.num && this.type !== tt.string) return - this.pos = this.start - if (this.options.locations) { - while (this.pos < this.lineStart) { - this$1.lineStart = this$1.input.lastIndexOf("\n", this$1.lineStart - 2) + 1 - --this$1.curLine - } - } - this.nextToken() - } - - pp$7.curContext = function() { - return this.context[this.context.length - 1] - } - - // Read a single token, updating the parser object's token-related - // properties. - - pp$7.nextToken = function() { - var curContext = this.curContext() - if (!curContext || !curContext.preserveSpace) this.skipSpace() - - this.start = this.pos - if (this.options.locations) this.startLoc = this.curPosition() - if (this.pos >= this.input.length) return this.finishToken(tt.eof) - - if (curContext.override) return curContext.override(this) - else this.readToken(this.fullCharCodeAtPos()) - } - - pp$7.readToken = function(code) { - // Identifier or keyword. '\uXXXX' sequences are allowed in - // identifiers, so '\' also dispatches to that. - if (isIdentifierStart(code, this.options.ecmaVersion >= 6) || code === 92 /* '\' */) - return this.readWord() - - return this.getTokenFromCode(code) - } - - pp$7.fullCharCodeAtPos = function() { - var code = this.input.charCodeAt(this.pos) - if (code <= 0xd7ff || code >= 0xe000) return code - var next = this.input.charCodeAt(this.pos + 1) - return (code << 10) + next - 0x35fdc00 - } - - pp$7.skipBlockComment = function() { - var this$1 = this; - - var startLoc = this.options.onComment && this.curPosition() - var start = this.pos, end = this.input.indexOf("*/", this.pos += 2) - if (end === -1) this.raise(this.pos - 2, "Unterminated comment") - this.pos = end + 2 - if (this.options.locations) { - lineBreakG.lastIndex = start - var match - while ((match = lineBreakG.exec(this.input)) && match.index < this.pos) { - ++this$1.curLine - this$1.lineStart = match.index + match[0].length - } - } - if (this.options.onComment) - this.options.onComment(true, this.input.slice(start + 2, end), start, this.pos, - startLoc, this.curPosition()) - } - - pp$7.skipLineComment = function(startSkip) { - var this$1 = this; - - var start = this.pos - var startLoc = this.options.onComment && this.curPosition() - var ch = this.input.charCodeAt(this.pos+=startSkip) - while (this.pos < this.input.length && ch !== 10 && ch !== 13 && ch !== 8232 && ch !== 8233) { - ++this$1.pos - ch = this$1.input.charCodeAt(this$1.pos) - } - if (this.options.onComment) - this.options.onComment(false, this.input.slice(start + startSkip, this.pos), start, this.pos, - startLoc, this.curPosition()) - } - - // Called at the start of the parse and after every token. Skips - // whitespace and comments, and. - - pp$7.skipSpace = function() { - var this$1 = this; - - loop: while (this.pos < this.input.length) { - var ch = this$1.input.charCodeAt(this$1.pos) - switch (ch) { - case 32: case 160: // ' ' - ++this$1.pos - break - case 13: - if (this$1.input.charCodeAt(this$1.pos + 1) === 10) { - ++this$1.pos - } - case 10: case 8232: case 8233: + loop: while (this.pos < this.input.length) { + var ch = this$1.input.charCodeAt(this$1.pos) + switch (ch) { + case 32: case 160: // ' ' + ++this$1.pos + break + case 13: + if (this$1.input.charCodeAt(this$1.pos + 1) === 10) { ++this$1.pos - if (this$1.options.locations) { - ++this$1.curLine - this$1.lineStart = this$1.pos - } - break - case 47: // '/' - switch (this$1.input.charCodeAt(this$1.pos + 1)) { - case 42: // '*' - this$1.skipBlockComment() - break - case 47: - this$1.skipLineComment(2) - break - default: - break loop - } - break - default: - if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) { - ++this$1.pos - } else { + } + case 10: case 8232: case 8233: + ++this$1.pos + if (this$1.options.locations) { + ++this$1.curLine + this$1.lineStart = this$1.pos + } + break + case 47: // '/' + switch (this$1.input.charCodeAt(this$1.pos + 1)) { + case 42: // '*' + this$1.skipBlockComment() + break + case 47: + this$1.skipLineComment(2) + break + default: break loop - } - } - } - } - - // Called at the end of every token. Sets `end`, `val`, and - // maintains `context` and `exprAllowed`, and skips the space after - // the token, so that the next one's `start` will point at the - // right position. - - pp$7.finishToken = function(type, val) { - this.end = this.pos - if (this.options.locations) this.endLoc = this.curPosition() - var prevType = this.type - this.type = type - this.value = val - - this.updateContext(prevType) - } - - // ### Token reading - - // This is the function that is called to fetch the next token. It - // is somewhat obscure, because it works in character codes rather - // than characters, and because operator parsing has been inlined - // into it. - // - // All in the name of speed. - // - pp$7.readToken_dot = function() { - var next = this.input.charCodeAt(this.pos + 1) - if (next >= 48 && next <= 57) return this.readNumber(true) - var next2 = this.input.charCodeAt(this.pos + 2) - if (this.options.ecmaVersion >= 6 && next === 46 && next2 === 46) { // 46 = dot '.' - this.pos += 3 - return this.finishToken(tt.ellipsis) - } else { - ++this.pos - return this.finishToken(tt.dot) - } - } - - pp$7.readToken_slash = function() { // '/' - var next = this.input.charCodeAt(this.pos + 1) - if (this.exprAllowed) {++this.pos; return this.readRegexp()} - if (next === 61) return this.finishOp(tt.assign, 2) - return this.finishOp(tt.slash, 1) - } - - pp$7.readToken_mult_modulo_exp = function(code) { // '%*' - var next = this.input.charCodeAt(this.pos + 1) - var size = 1 - var tokentype = code === 42 ? tt.star : tt.modulo - - // exponentiation operator ** and **= - if (this.options.ecmaVersion >= 7 && next === 42) { - ++size - tokentype = tt.starstar - next = this.input.charCodeAt(this.pos + 2) - } - - if (next === 61) return this.finishOp(tt.assign, size + 1) - return this.finishOp(tokentype, size) - } - - pp$7.readToken_pipe_amp = function(code) { // '|&' - var next = this.input.charCodeAt(this.pos + 1) - if (next === code) return this.finishOp(code === 124 ? tt.logicalOR : tt.logicalAND, 2) - if (next === 61) return this.finishOp(tt.assign, 2) - return this.finishOp(code === 124 ? tt.bitwiseOR : tt.bitwiseAND, 1) - } - - pp$7.readToken_caret = function() { // '^' - var next = this.input.charCodeAt(this.pos + 1) - if (next === 61) return this.finishOp(tt.assign, 2) - return this.finishOp(tt.bitwiseXOR, 1) - } - - pp$7.readToken_plus_min = function(code) { // '+-' - var next = this.input.charCodeAt(this.pos + 1) - if (next === code) { - if (next == 45 && this.input.charCodeAt(this.pos + 2) == 62 && - lineBreak.test(this.input.slice(this.lastTokEnd, this.pos))) { - // A `-->` line comment - this.skipLineComment(3) - this.skipSpace() - return this.nextToken() - } - return this.finishOp(tt.incDec, 2) + } + break + default: + if (ch > 8 && ch < 14 || ch >= 5760 && nonASCIIwhitespace.test(String.fromCharCode(ch))) { + ++this$1.pos + } else { + break loop + } } - if (next === 61) return this.finishOp(tt.assign, 2) - return this.finishOp(tt.plusMin, 1) } - - pp$7.readToken_lt_gt = function(code) { // '<>' - var next = this.input.charCodeAt(this.pos + 1) - var size = 1 - if (next === code) { - size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2 - if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1) - return this.finishOp(tt.bitShift, size) - } - if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && - this.input.charCodeAt(this.pos + 3) == 45) { - if (this.inModule) this.unexpected() - // `` line comment + this.skipLineComment(3) this.skipSpace() return this.nextToken() } - if (next === 61) size = 2 - return this.finishOp(tt.relational, size) - } + return this.finishOp(tt.incDec, 2) + } + if (next === 61) return this.finishOp(tt.assign, 2) + return this.finishOp(tt.plusMin, 1) +} + +pp$7.readToken_lt_gt = function(code) { // '<>' + var next = this.input.charCodeAt(this.pos + 1) + var size = 1 + if (next === code) { + size = code === 62 && this.input.charCodeAt(this.pos + 2) === 62 ? 3 : 2 + if (this.input.charCodeAt(this.pos + size) === 61) return this.finishOp(tt.assign, size + 1) + return this.finishOp(tt.bitShift, size) + } + if (next == 33 && code == 60 && this.input.charCodeAt(this.pos + 2) == 45 && + this.input.charCodeAt(this.pos + 3) == 45) { + if (this.inModule) this.unexpected() + // ` @@ -163,6 +149,11 @@ target.bundle = function(argsArray) { All commands run synchronously, unless otherwise stated. +All commands accept standard bash globbing characters (`*`, `?`, etc.), +compatible with the [node glob module](https://github.com/isaacs/node-glob). + +For less-commonly used commands and features, please check out our [wiki +page](https://github.com/shelljs/shelljs/wiki). ### cd([dir]) @@ -220,17 +211,21 @@ Available options: + `-f`: force (default behavior) + `-n`: no-clobber -+ `-r, -R`: recursive ++ `-u`: only copy if source is newer than dest ++ `-r`, `-R`: recursive ++ `-L`: follow symlinks ++ `-P`: don't follow symlinks Examples: ```javascript cp('file1', 'dir1'); +cp('-R', 'path/to/dir/', '~/newCopy/'); cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp'); cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above ``` -Copies files. The wildcard `*` is accepted. +Copies files. ### rm([options,] file [, file ...]) @@ -248,7 +243,7 @@ rm('some_file.txt', 'another_file.txt'); rm(['some_file.txt', 'another_file.txt']); // same as above ``` -Removes files. The wildcard `*` is accepted. +Removes files. ### mv([options ,] source [, source ...], dest') @@ -266,7 +261,7 @@ mv('file1', 'file2', 'dir/'); mv(['file1', 'file2'], 'dir/'); // same as above ``` -Moves files. The wildcard `*` is accepted. +Moves files. ### mkdir([options,] dir [, dir ...]) @@ -320,10 +315,44 @@ var str = cat(['file1', 'file2']); // same as above Returns a string containing the given file, or a concatenated string containing the files if more than one file is given (a new line character is -introduced between each file). Wildcard `*` accepted. +introduced between each file). + + +### head([{'-n': \},] file [, file ...]) +### head([{'-n': \},] file_array) +Available options: + ++ `-n `: Show the first `` lines of the files + +Examples: + +```javascript +var str = head({'-n': 1}, 'file*.txt'); +var str = head('file1', 'file2'); +var str = head(['file1', 'file2']); // same as above +``` + +Read the start of a file. + + +### tail([{'-n': \},] file [, file ...]) +### tail([{'-n': \},] file_array) +Available options: + ++ `-n `: Show the last `` lines of the files + +Examples: + +```javascript +var str = tail({'-n': 1}, 'file*.txt'); +var str = tail('file1', 'file2'); +var str = tail(['file1', 'file2']); // same as above +``` + +Read the end of a file. -### 'string'.to(file) +### ShellString.prototype.to(file) Examples: @@ -331,11 +360,12 @@ Examples: cat('input.txt').to('output.txt'); ``` -Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as -those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_ +Analogous to the redirection operator `>` in Unix, but works with +ShellStrings (such as those returned by `cat`, `grep`, etc). _Like Unix +redirections, `to()` will overwrite any existing file!_ -### 'string'.toEnd(file) +### ShellString.prototype.toEnd(file) Examples: @@ -343,8 +373,8 @@ Examples: cat('input.txt').toEnd('output.txt'); ``` -Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as -those returned by `cat`, `grep`, etc). +Analogous to the redirect-and-append operator `>>` in Unix, but works with +ShellStrings (such as those returned by `cat`, `grep`, etc). ### sed([options,] search_regex, replacement, file [, file ...]) @@ -364,11 +394,48 @@ Reads an input string from `files` and performs a JavaScript `replace()` on the using the given search regex and replacement string or function. Returns the new string after replacement. +### sort([options,] file [, file ...]) +### sort([options,] file_array) +Available options: + ++ `-r`: Reverse the result of comparisons ++ `-n`: Compare according to numerical value + +Examples: + +```javascript +sort('foo.txt', 'bar.txt'); +sort('-r', 'foo.txt'); +``` + +Return the contents of the files, sorted line-by-line. Sorting multiple +files mixes their content, just like unix sort does. + + +### uniq([options,] [input, [output]]) +Available options: + ++ `-i`: Ignore case while comparing ++ `-c`: Prefix lines by the number of occurrences ++ `-d`: Only print duplicate lines, one for each group of identical lines + +Examples: + +```javascript +uniq('foo.txt'); +uniq('-i', 'foo.txt'); +uniq('-cd', 'foo.txt', 'bar.txt'); +``` + +Filter adjacent matching lines from input + + ### grep([options,] regex_filter, file [, file ...]) ### grep([options,] regex_filter, file_array) Available options: + `-v`: Inverse the sense of the regex and print the lines not matching the criteria. ++ `-l`: Print only filenames of matching files Examples: @@ -378,7 +445,7 @@ grep('GLOBAL_VARIABLE', '*.js'); ``` Reads input string from given files and returns a string containing all lines of the -file that match the given `regex_filter`. Wildcard `*` accepted. +file that match the given `regex_filter`. ### which(command) @@ -394,7 +461,10 @@ Searches for `command` in the system's PATH. On Windows, this uses the Returns string containing the absolute path to the command. -### echo(string [, string ...]) +### echo([options,] string [, string ...]) +Available options: + ++ `-e`: interpret backslash escapes (default) Examples: @@ -517,9 +587,13 @@ exec('some_long_running_process', function(code, stdout, stderr) { ``` Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous -mode returns the object `{ code:..., stdout:... , stderr:... }`, containing the program's -`stdout`, `stderr`, and its exit `code`. Otherwise returns the child process object, -and the `callback` gets the arguments `(code, stdout, stderr)`. +mode, this returns a ShellString (compatible with ShellJS v0.6.x, which returns an object +of the form `{ code:..., stdout:... , stderr:... }`). Otherwise, this returns the child process +object, and the `callback` gets the arguments `(code, stdout, stderr)`. + +Not seeing the behavior you want? `exec()` runs everything through `sh` +by default (or `cmd.exe` on Windows), which differs from `bash`. If you +need bash-specific behavior, try out the `{shell: 'path/to/bash'}` option. **Note:** For long-lived processes, it's best to run `exec()` asynchronously as the current synchronous implementation uses a lot of CPU. This should be getting @@ -553,7 +627,8 @@ Notable exceptions: + There is no "quiet" option since default behavior is to run silent. -### touch([options,] file) +### touch([options,] file [, file ...]) +### touch([options,] file_array) Available options: + `-a`: Change only the access time @@ -580,6 +655,7 @@ Available options: + `+/-e`: exit upon error (`config.fatal`) + `+/-v`: verbose: show all commands (`config.verbose`) ++ `+/-f`: disable filename expansion (globbing) Examples: @@ -607,14 +683,45 @@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.ht ### error() -Tests if error occurred in the last command. Returns `null` if no error occurred, -otherwise returns string explaining the error +Tests if error occurred in the last command. Returns a truthy value if an +error returned and a falsy value otherwise. +**Note**: do not rely on the +return value to be an error message. If you need the last error message, use +the `.stderr` attribute from the last command's return value instead. + + +### ShellString(str) + +Examples: + +```javascript +var foo = ShellString('hello world'); +``` + +Turns a regular string into a string-like object similar to what each +command returns. This has special methods, like `.to()` and `.toEnd()` + + +### Pipes + +Examples: + +```javascript +grep('foo', 'file1.txt', 'file2.txt').sed(/o/g, 'a').to('output.txt'); +echo('files with o\'s in the name:\n' + ls().grep('o')); +cat('test.js').exec('node'); // pipe to exec() call +``` + +Commands can send their output to another command in a pipe-like fashion. +`sed`, `grep`, `cat`, `exec`, `to`, and `toEnd` can appear on the right-hand +side of a pipe. Pipes can be chained. ## Configuration ### config.silent + Example: ```javascript @@ -629,19 +736,22 @@ Suppresses all command output if `true`, except for `echo()` calls. Default is `false`. ### config.fatal + Example: ```javascript require('shelljs/global'); config.fatal = true; // or set('-e'); -cp('this_file_does_not_exist', '/dev/null'); // dies here +cp('this_file_does_not_exist', '/dev/null'); // throws Error here /* more commands... */ ``` -If `true` the script will die on errors. Default is `false`. This is -analogous to Bash's `set -e` +If `true` the script will throw a Javascript error when any shell.js +command encounters an error. Default is `false`. This is analogous to +Bash's `set -e` ### config.verbose + Example: ```javascript @@ -656,3 +766,19 @@ Will print each command as follows: cd dir/ ls subdir/ ``` + +### config.globOptions + +Example: + +```javascript +config.globOptions = {nodir: true}; +``` + +Use this value for calls to `glob.sync()` instead of the default options. + +## Team + +| [![Nate Fischer](https://avatars.githubusercontent.com/u/5801521?s=130)](https://github.com/nfischer) | [![Ari Porad](https://avatars1.githubusercontent.com/u/1817508?v=3&s=130)](http://github.com/ariporad) | +|:---:|:---:| +| [Nate Fischer](https://github.com/nfischer) | [Ari Porad](http://github.com/ariporad) | diff --git a/tools/eslint/node_modules/shelljs/bin/shjs b/tools/eslint/node_modules/shelljs/bin/shjs index aae3bc64ce2b68..75ca58b9d9ac3c 100755 --- a/tools/eslint/node_modules/shelljs/bin/shjs +++ b/tools/eslint/node_modules/shelljs/bin/shjs @@ -32,24 +32,8 @@ for (var i = 0, l = args.length; i < l; i++) { } } -if (scriptName.match(/\.coffee$/)) { - // - // CoffeeScript - // - if (which('coffee')) { - exec('coffee "' + scriptName + '" ' + args.join(' '), function(code) { - process.exit(code); - }); - } else { - console.log('ShellJS: CoffeeScript interpreter not found'); - console.log(); - process.exit(1); - } -} else { - // - // JavaScript - // - exec('node "' + scriptName + '" ' + args.join(' '), function(code) { - process.exit(code); - }); -} +var path = require('path'); +var extensions = require('interpret').extensions; +var rechoir = require('rechoir'); +rechoir.prepare(extensions, scriptName); +require(require.resolve(path.resolve(process.cwd(), scriptName))); diff --git a/tools/eslint/node_modules/shelljs/global.js b/tools/eslint/node_modules/shelljs/global.js index 97f0033cc15303..b232e66d5e9cbc 100644 --- a/tools/eslint/node_modules/shelljs/global.js +++ b/tools/eslint/node_modules/shelljs/global.js @@ -1,3 +1,12 @@ +/* eslint no-extend-native: 0 */ var shell = require('./shell.js'); -for (var cmd in shell) +var common = require('./src/common'); +Object.keys(shell).forEach(function (cmd) { global[cmd] = shell[cmd]; +}); + +var _to = require('./src/to'); +String.prototype.to = common.wrap('to', _to); + +var _toEnd = require('./src/toEnd'); +String.prototype.toEnd = common.wrap('toEnd', _toEnd); diff --git a/tools/eslint/node_modules/shelljs/package.json b/tools/eslint/node_modules/shelljs/package.json index 5dc19b8f524e00..b6cfe9545d9ac0 100644 --- a/tools/eslint/node_modules/shelljs/package.json +++ b/tools/eslint/node_modules/shelljs/package.json @@ -2,53 +2,49 @@ "_args": [ [ { - "raw": "shelljs@^0.6.0", + "raw": "shelljs@^0.7.5", "scope": null, "escapedName": "shelljs", "name": "shelljs", - "rawSpec": "^0.6.0", - "spec": ">=0.6.0 <0.7.0", + "rawSpec": "^0.7.5", + "spec": ">=0.7.5 <0.8.0", "type": "range" }, "/Users/trott/io.js/tools/node_modules/eslint" ] ], - "_from": "shelljs@>=0.6.0 <0.7.0", - "_id": "shelljs@0.6.1", + "_from": "shelljs@>=0.7.5 <0.8.0", + "_id": "shelljs@0.7.5", "_inCache": true, "_location": "/shelljs", - "_nodeVersion": "6.0.0", + "_nodeVersion": "6.7.0", "_npmOperationalInternal": { - "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/shelljs-0.6.1.tgz_1470519555022_0.9348916830495" + "host": "packages-18-east.internal.npmjs.com", + "tmp": "tmp/shelljs-0.7.5.tgz_1477547417527_0.3151172921061516" }, "_npmUser": { "name": "nfischer", "email": "ntfschr@gmail.com" }, - "_npmVersion": "3.5.2", + "_npmVersion": "3.10.8", "_phantomChildren": {}, "_requested": { - "raw": "shelljs@^0.6.0", + "raw": "shelljs@^0.7.5", "scope": null, "escapedName": "shelljs", "name": "shelljs", - "rawSpec": "^0.6.0", - "spec": ">=0.6.0 <0.7.0", + "rawSpec": "^0.7.5", + "spec": ">=0.7.5 <0.8.0", "type": "range" }, "_requiredBy": [ "/eslint" ], - "_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.6.1.tgz", - "_shasum": "ec6211bed1920442088fe0f70b2837232ed2c8a8", + "_resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.5.tgz", + "_shasum": "2eef7a50a21e1ccf37da00df767ec69e30ad0675", "_shrinkwrap": null, - "_spec": "shelljs@^0.6.0", + "_spec": "shelljs@^0.7.5", "_where": "/Users/trott/io.js/tools/node_modules/eslint", - "author": { - "name": "Artur Adib", - "email": "arturadib@gmail.com" - }, "bin": { "shjs": "./bin/shjs" }, @@ -63,26 +59,39 @@ }, { "name": "Nate Fischer", - "email": "ntfschr@gmail.com" + "email": "ntfschr@gmail.com", + "url": "https://github.com/nfischer" } ], - "dependencies": {}, + "dependencies": { + "glob": "^7.0.0", + "interpret": "^1.0.0", + "rechoir": "^0.6.2" + }, "description": "Portable Unix shell commands for Node.js", "devDependencies": { "coffee-script": "^1.10.0", - "jshint": "~2.1.11" + "eslint": "^2.0.0", + "eslint-config-airbnb-base": "^3.0.0", + "eslint-plugin-import": "^1.11.1", + "shelljs-changelog": "^0.2.0", + "shelljs-release": "^0.2.0", + "travis-check-changes": "^0.2.0" }, "directories": {}, "dist": { - "shasum": "ec6211bed1920442088fe0f70b2837232ed2c8a8", - "tarball": "https://registry.npmjs.org/shelljs/-/shelljs-0.6.1.tgz" + "shasum": "2eef7a50a21e1ccf37da00df767ec69e30ad0675", + "tarball": "https://registry.npmjs.org/shelljs/-/shelljs-0.7.5.tgz" }, "engines": { - "node": ">=0.10.0" + "iojs": "*", + "node": ">=0.11.0" }, - "gitHead": "a5b9e2a64ffdf9f837d6ceb15d7f42221875542b", + "gitHead": "1a15022f2747d322d771dd7ae0c00840e469a52a", "homepage": "http://github.com/shelljs/shelljs", "keywords": [ + "shelljs", + "bash", "unix", "shell", "makefile", @@ -114,7 +123,15 @@ "url": "git://github.com/shelljs/shelljs.git" }, "scripts": { + "after-travis": "travis-check-changes", + "changelog": "shelljs-changelog", + "gendocs": "node scripts/generate-docs", + "lint": "eslint .", + "posttest": "npm run lint", + "release:major": "shelljs-release major", + "release:minor": "shelljs-release minor", + "release:patch": "shelljs-release patch", "test": "node scripts/run-tests" }, - "version": "0.6.1" + "version": "0.7.5" } diff --git a/tools/eslint/node_modules/shelljs/plugin.js b/tools/eslint/node_modules/shelljs/plugin.js new file mode 100644 index 00000000000000..f879ab320e666a --- /dev/null +++ b/tools/eslint/node_modules/shelljs/plugin.js @@ -0,0 +1,16 @@ +// Various utilties exposed to plugins + +require('./shell'); // Create the ShellJS instance (mandatory) + +var common = require('./src/common'); + +var exportedAttributes = [ + 'error', // For signaling errors from within commands + 'parseOptions', // For custom option parsing + 'readFromPipe', // For commands with the .canReceivePipe attribute + 'register', // For registering plugins +]; + +exportedAttributes.forEach(function (attr) { + exports[attr] = common[attr]; +}); diff --git a/tools/eslint/node_modules/shelljs/scripts/generate-docs.js b/tools/eslint/node_modules/shelljs/scripts/generate-docs.js index 3a31a91abd2a13..f777c8ad263612 100755 --- a/tools/eslint/node_modules/shelljs/scripts/generate-docs.js +++ b/tools/eslint/node_modules/shelljs/scripts/generate-docs.js @@ -1,5 +1,5 @@ #!/usr/bin/env node -/* globals cat, cd, echo, grep, sed */ +/* globals cat, cd, echo, grep, sed, ShellString */ require('../global'); echo('Appending docs to README.md'); @@ -7,18 +7,19 @@ echo('Appending docs to README.md'); cd(__dirname + '/..'); // Extract docs from shell.js -var docs = grep('//@', 'shell.js'); +var docs = grep('^//@', 'shell.js'); -docs = docs.replace(/\/\/\@include (.+)/g, function(match, path) { - var file = path.match('.js$') ? path : path+'.js'; - return grep('//@', file); +// Now extract docs from the appropriate src/*.js files +docs = docs.replace(/\/\/@include (.+)/g, function (match, path) { + var file = path.match('.js$') ? path : path + '.js'; + return grep('^//@', file); }); // Remove '//@' -docs = docs.replace(/\/\/\@ ?/g, ''); +docs = docs.replace(/\/\/@ ?/g, ''); // Wipe out the old docs -cat('README.md').replace(/## Command reference(.|\n)*/, '## Command reference').to('README.md'); +ShellString(cat('README.md').replace(/## Command reference(.|\n)*\n## Team/, '## Command reference\n## Team')).to('README.md'); // Append new docs to README sed('-i', /## Command reference/, '## Command reference\n\n' + docs, 'README.md'); diff --git a/tools/eslint/node_modules/shelljs/scripts/run-tests.js b/tools/eslint/node_modules/shelljs/scripts/run-tests.js index e8e7ff2f879a82..99205623f9ed6b 100755 --- a/tools/eslint/node_modules/shelljs/scripts/run-tests.js +++ b/tools/eslint/node_modules/shelljs/scripts/run-tests.js @@ -1,55 +1,29 @@ #!/usr/bin/env node -/* globals cd, echo, exec, exit, ls, pwd, test */ +/* globals cd, echo, exec, exit, ls */ require('../global'); -var common = require('../src/common'); var failed = false; -// -// Lint -// -var JSHINT_BIN = 'node_modules/jshint/bin/jshint'; -cd(__dirname + '/..'); - -if (!test('-f', JSHINT_BIN)) { - echo('JSHint not found. Run `npm install` in the root dir first.'); - exit(1); -} - -var jsfiles = common.expand([pwd() + '/*.js', - pwd() + '/scripts/*.js', - pwd() + '/src/*.js', - pwd() + '/test/*.js' - ]).join(' '); -if (exec('node ' + pwd() + '/' + JSHINT_BIN + ' ' + jsfiles).code !== 0) { - failed = true; - echo('*** JSHINT FAILED! (return code != 0)'); - echo(); -} else { - echo('All JSHint tests passed'); - echo(); -} - // // Unit tests // cd(__dirname + '/../test'); -ls('*.js').forEach(function(file) { +ls('*.js').forEach(function (file) { echo('Running test:', file); - if (exec('node ' + file).code !== 123) { // 123 avoids false positives (e.g. premature exit) + if (exec(JSON.stringify(process.execPath) + ' ' + file).code !== 123) { // 123 avoids false positives (e.g. premature exit) failed = true; echo('*** TEST FAILED! (missing exit code "123")'); echo(); } }); +echo(); + if (failed) { - echo(); echo('*******************************************************'); echo('WARNING: Some tests did not pass!'); echo('*******************************************************'); exit(1); } else { - echo(); echo('All tests passed.'); } diff --git a/tools/eslint/node_modules/shelljs/shell.js b/tools/eslint/node_modules/shelljs/shell.js index 93aff709a3931f..9e49ef5e799cdb 100644 --- a/tools/eslint/node_modules/shelljs/shell.js +++ b/tools/eslint/node_modules/shelljs/shell.js @@ -8,86 +8,95 @@ var common = require('./src/common'); - //@ //@ All commands run synchronously, unless otherwise stated. +//@ All commands accept standard bash globbing characters (`*`, `?`, etc.), +//@ compatible with the [node glob module](https://github.com/isaacs/node-glob). +//@ +//@ For less-commonly used commands and features, please check out our [wiki +//@ page](https://github.com/shelljs/shelljs/wiki). //@ +// Boilerplate +// ----------- +// Copy the code block below here & replace variables with appropiate values +// ``` +// //@include ./src/fileName +// var functionName = require('./src/fileName'); +// exports.nameOfCommand = common.wrap(nameOfCommand, functionName, {globStart: firstIndexToExpand}); +// ``` +// +// The //@include includes the docs for that command +// +// firstIndexToExpand should usually be 1 (so, put {globStart: 1}) +// Increase this value if the command takes arguments that shouldn't be expanded +// with wildcards, such as with the regexes for sed & grep + //@include ./src/cd -var _cd = require('./src/cd'); -exports.cd = common.wrap('cd', _cd); +require('./src/cd'); //@include ./src/pwd -var _pwd = require('./src/pwd'); -exports.pwd = common.wrap('pwd', _pwd); +require('./src/pwd'); //@include ./src/ls -var _ls = require('./src/ls'); -exports.ls = common.wrap('ls', _ls); +require('./src/ls'); //@include ./src/find -var _find = require('./src/find'); -exports.find = common.wrap('find', _find); +require('./src/find'); //@include ./src/cp -var _cp = require('./src/cp'); -exports.cp = common.wrap('cp', _cp); +require('./src/cp'); //@include ./src/rm -var _rm = require('./src/rm'); -exports.rm = common.wrap('rm', _rm); +require('./src/rm'); //@include ./src/mv -var _mv = require('./src/mv'); -exports.mv = common.wrap('mv', _mv); +require('./src/mv'); //@include ./src/mkdir -var _mkdir = require('./src/mkdir'); -exports.mkdir = common.wrap('mkdir', _mkdir); +require('./src/mkdir'); //@include ./src/test -var _test = require('./src/test'); -exports.test = common.wrap('test', _test); +require('./src/test'); //@include ./src/cat -var _cat = require('./src/cat'); -exports.cat = common.wrap('cat', _cat); +require('./src/cat'); + +//@include ./src/head +require('./src/head'); + +//@include ./src/tail +require('./src/tail'); //@include ./src/to -var _to = require('./src/to'); -String.prototype.to = common.wrap('to', _to); +require('./src/to'); //@include ./src/toEnd -var _toEnd = require('./src/toEnd'); -String.prototype.toEnd = common.wrap('toEnd', _toEnd); +require('./src/toEnd'); //@include ./src/sed -var _sed = require('./src/sed'); -exports.sed = common.wrap('sed', _sed); +require('./src/sed'); + +//@include ./src/sort +require('./src/sort'); + +//@include ./src/uniq +require('./src/uniq'); //@include ./src/grep -var _grep = require('./src/grep'); -exports.grep = common.wrap('grep', _grep); +require('./src/grep'); //@include ./src/which -var _which = require('./src/which'); -exports.which = common.wrap('which', _which); +require('./src/which'); //@include ./src/echo -var _echo = require('./src/echo'); -exports.echo = _echo; // don't common.wrap() as it could parse '-options' +require('./src/echo'); //@include ./src/dirs -var _dirs = require('./src/dirs').dirs; -exports.dirs = common.wrap("dirs", _dirs); -var _pushd = require('./src/dirs').pushd; -exports.pushd = common.wrap('pushd', _pushd); -var _popd = require('./src/dirs').popd; -exports.popd = common.wrap("popd", _popd); +require('./src/dirs'); //@include ./src/ln -var _ln = require('./src/ln'); -exports.ln = common.wrap('ln', _ln); +require('./src/ln'); //@ //@ ### exit(code) @@ -100,20 +109,16 @@ exports.exit = process.exit; exports.env = process.env; //@include ./src/exec -var _exec = require('./src/exec'); -exports.exec = common.wrap('exec', _exec, {notUnix:true}); +require('./src/exec'); //@include ./src/chmod -var _chmod = require('./src/chmod'); -exports.chmod = common.wrap('chmod', _chmod); +require('./src/chmod'); //@include ./src/touch -var _touch = require('./src/touch'); -exports.touch = common.wrap('touch', _touch); +require('./src/touch'); //@include ./src/set -var _set = require('./src/set'); -exports.set = common.wrap('set', _set); +require('./src/set'); //@ @@ -121,15 +126,29 @@ exports.set = common.wrap('set', _set); //@ //@include ./src/tempdir -var _tempDir = require('./src/tempdir'); -exports.tempdir = common.wrap('tempdir', _tempDir); - +require('./src/tempdir'); //@include ./src/error -var _error = require('./src/error'); -exports.error = _error; +exports.error = require('./src/error'); + +//@include ./src/common +exports.ShellString = common.ShellString; +//@ +//@ ### Pipes +//@ +//@ Examples: +//@ +//@ ```javascript +//@ grep('foo', 'file1.txt', 'file2.txt').sed(/o/g, 'a').to('output.txt'); +//@ echo('files with o\'s in the name:\n' + ls().grep('o')); +//@ cat('test.js').exec('node'); // pipe to exec() call +//@ ``` +//@ +//@ Commands can send their output to another command in a pipe-like fashion. +//@ `sed`, `grep`, `cat`, `exec`, `to`, and `toEnd` can appear on the right-hand +//@ side of a pipe. Pipes can be chained. //@ //@ ## Configuration @@ -139,6 +158,7 @@ exports.config = common.config; //@ //@ ### config.silent +//@ //@ Example: //@ //@ ```javascript @@ -154,20 +174,23 @@ exports.config = common.config; //@ //@ ### config.fatal +//@ //@ Example: //@ //@ ```javascript //@ require('shelljs/global'); //@ config.fatal = true; // or set('-e'); -//@ cp('this_file_does_not_exist', '/dev/null'); // dies here +//@ cp('this_file_does_not_exist', '/dev/null'); // throws Error here //@ /* more commands... */ //@ ``` //@ -//@ If `true` the script will die on errors. Default is `false`. This is -//@ analogous to Bash's `set -e` +//@ If `true` the script will throw a Javascript error when any shell.js +//@ command encounters an error. Default is `false`. This is analogous to +//@ Bash's `set -e` //@ //@ ### config.verbose +//@ //@ Example: //@ //@ ```javascript @@ -182,3 +205,14 @@ exports.config = common.config; //@ cd dir/ //@ ls subdir/ //@ ``` + +//@ +//@ ### config.globOptions +//@ +//@ Example: +//@ +//@ ```javascript +//@ config.globOptions = {nodir: true}; +//@ ``` +//@ +//@ Use this value for calls to `glob.sync()` instead of the default options. diff --git a/tools/eslint/node_modules/shelljs/src/cat.js b/tools/eslint/node_modules/shelljs/src/cat.js index 5840b4ea77b590..a74a25c8424d16 100644 --- a/tools/eslint/node_modules/shelljs/src/cat.js +++ b/tools/eslint/node_modules/shelljs/src/cat.js @@ -1,6 +1,10 @@ var common = require('./common'); var fs = require('fs'); +common.register('cat', _cat, { + canReceivePipe: true, +}); + //@ //@ ### cat(file [, file ...]) //@ ### cat(file_array) @@ -15,26 +19,22 @@ var fs = require('fs'); //@ //@ Returns a string containing the given file, or a concatenated string //@ containing the files if more than one file is given (a new line character is -//@ introduced between each file). Wildcard `*` accepted. +//@ introduced between each file). function _cat(options, files) { - var cat = ''; - - if (!files) - common.error('no paths given'); + var cat = common.readFromPipe(); - if (typeof files === 'string') - files = [].slice.call(arguments, 1); - // if it's array leave it as it is + if (!files && !cat) common.error('no paths given'); - files = common.expand(files); + files = [].slice.call(arguments, 1); - files.forEach(function(file) { - if (!fs.existsSync(file)) + files.forEach(function (file) { + if (!fs.existsSync(file)) { common.error('no such file or directory: ' + file); + } cat += fs.readFileSync(file, 'utf8'); }); - return common.ShellString(cat); + return cat; } module.exports = _cat; diff --git a/tools/eslint/node_modules/shelljs/src/cd.js b/tools/eslint/node_modules/shelljs/src/cd.js index b7b9931b8f41df..634ed835cb0925 100644 --- a/tools/eslint/node_modules/shelljs/src/cd.js +++ b/tools/eslint/node_modules/shelljs/src/cd.js @@ -1,28 +1,38 @@ var fs = require('fs'); var common = require('./common'); +common.register('cd', _cd, {}); + //@ //@ ### cd([dir]) //@ Changes to directory `dir` for the duration of the script. Changes to home //@ directory if no argument is supplied. function _cd(options, dir) { - if (!dir) - dir = common.getUserHome(); + if (!dir) dir = common.getUserHome(); if (dir === '-') { - if (!common.state.previousDir) + if (!process.env.OLDPWD) { common.error('could not find previous directory'); - else - dir = common.state.previousDir; + } else { + dir = process.env.OLDPWD; + } } - if (!fs.existsSync(dir)) - common.error('no such file or directory: ' + dir); - - if (!fs.statSync(dir).isDirectory()) - common.error('not a directory: ' + dir); - - common.state.previousDir = process.cwd(); - process.chdir(dir); + try { + var curDir = process.cwd(); + process.chdir(dir); + process.env.OLDPWD = curDir; + } catch (e) { + // something went wrong, let's figure out the error + var err; + try { + fs.statSync(dir); // if this succeeds, it must be some sort of file + err = 'not a directory: ' + dir; + } catch (e2) { + err = 'no such file or directory: ' + dir; + } + if (err) common.error(err); + } + return ''; } module.exports = _cd; diff --git a/tools/eslint/node_modules/shelljs/src/chmod.js b/tools/eslint/node_modules/shelljs/src/chmod.js index 6c6de10ce12e49..a1afd90e75684f 100644 --- a/tools/eslint/node_modules/shelljs/src/chmod.js +++ b/tools/eslint/node_modules/shelljs/src/chmod.js @@ -4,30 +4,32 @@ var path = require('path'); var PERMS = (function (base) { return { - OTHER_EXEC : base.EXEC, - OTHER_WRITE : base.WRITE, - OTHER_READ : base.READ, + OTHER_EXEC: base.EXEC, + OTHER_WRITE: base.WRITE, + OTHER_READ: base.READ, - GROUP_EXEC : base.EXEC << 3, - GROUP_WRITE : base.WRITE << 3, - GROUP_READ : base.READ << 3, + GROUP_EXEC: base.EXEC << 3, + GROUP_WRITE: base.WRITE << 3, + GROUP_READ: base.READ << 3, - OWNER_EXEC : base.EXEC << 6, - OWNER_WRITE : base.WRITE << 6, - OWNER_READ : base.READ << 6, + OWNER_EXEC: base.EXEC << 6, + OWNER_WRITE: base.WRITE << 6, + OWNER_READ: base.READ << 6, - // Literal octal numbers are apparently not allowed in "strict" javascript. Using parseInt is - // the preferred way, else a jshint warning is thrown. - STICKY : parseInt('01000', 8), - SETGID : parseInt('02000', 8), - SETUID : parseInt('04000', 8), + // Literal octal numbers are apparently not allowed in "strict" javascript. + STICKY: parseInt('01000', 8), + SETGID: parseInt('02000', 8), + SETUID: parseInt('04000', 8), - TYPE_MASK : parseInt('0770000', 8) + TYPE_MASK: parseInt('0770000', 8) }; -})({ - EXEC : 1, - WRITE : 2, - READ : 4 +}({ + EXEC: 1, + WRITE: 2, + READ: 4 +})); + +common.register('chmod', _chmod, { }); //@ @@ -62,11 +64,8 @@ function _chmod(options, mode, filePattern) { // Special case where the specified file permissions started with - to subtract perms, which // get picked up by the option parser as command flags. // If we are down by one argument and options starts with -, shift everything over. - filePattern = mode; - mode = options; - options = ''; - } - else { + [].unshift.call(arguments, ''); + } else { common.error('You must specify a file.'); } } @@ -77,15 +76,14 @@ function _chmod(options, mode, filePattern) { 'v': 'verbose' }); - if (typeof filePattern === 'string') { - filePattern = [ filePattern ]; - } + filePattern = [].slice.call(arguments, 2); var files; + // TODO: replace this with a call to common.expand() if (options.recursive) { files = []; - common.expand(filePattern).forEach(function addFile(expandedFile) { + filePattern.forEach(function addFile(expandedFile) { var stat = fs.lstatSync(expandedFile); if (!stat.isSymbolicLink()) { @@ -98,9 +96,8 @@ function _chmod(options, mode, filePattern) { } } }); - } - else { - files = common.expand(filePattern); + } else { + files = filePattern; } files.forEach(function innerChmod(file) { @@ -124,7 +121,6 @@ function _chmod(options, mode, filePattern) { if (isNaN(parseInt(mode, 8))) { // parse options mode.split(',').forEach(function (symbolicMode) { - /*jshint regexdash:true */ var pattern = /([ugoa]*)([=\+-])([rwxXst]*)/i; var matches = pattern.exec(symbolicMode); @@ -133,19 +129,20 @@ function _chmod(options, mode, filePattern) { var operator = matches[2]; var change = matches[3]; - var changeOwner = applyTo.indexOf('u') != -1 || applyTo === 'a' || applyTo === ''; - var changeGroup = applyTo.indexOf('g') != -1 || applyTo === 'a' || applyTo === ''; - var changeOther = applyTo.indexOf('o') != -1 || applyTo === 'a' || applyTo === ''; + var changeOwner = applyTo.indexOf('u') !== -1 || applyTo === 'a' || applyTo === ''; + var changeGroup = applyTo.indexOf('g') !== -1 || applyTo === 'a' || applyTo === ''; + var changeOther = applyTo.indexOf('o') !== -1 || applyTo === 'a' || applyTo === ''; - var changeRead = change.indexOf('r') != -1; - var changeWrite = change.indexOf('w') != -1; - var changeExec = change.indexOf('x') != -1; - var changeExecDir = change.indexOf('X') != -1; - var changeSticky = change.indexOf('t') != -1; - var changeSetuid = change.indexOf('s') != -1; + var changeRead = change.indexOf('r') !== -1; + var changeWrite = change.indexOf('w') !== -1; + var changeExec = change.indexOf('x') !== -1; + var changeExecDir = change.indexOf('X') !== -1; + var changeSticky = change.indexOf('t') !== -1; + var changeSetuid = change.indexOf('s') !== -1; - if (changeExecDir && isDir) + if (changeExecDir && isDir) { changeExec = true; + } var mask = 0; if (changeOwner) { @@ -175,35 +172,37 @@ function _chmod(options, mode, filePattern) { case '=': newPerms = type + mask; - // According to POSIX, when using = to explicitly set the permissions, setuid and setgid can never be cleared. + // According to POSIX, when using = to explicitly set the + // permissions, setuid and setgid can never be cleared. if (fs.statSync(file).isDirectory()) { newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms; } break; + default: + common.error('Could not recognize operator: `' + operator + '`'); } if (options.verbose) { console.log(file + ' -> ' + newPerms.toString(8)); } - if (perms != newPerms) { + if (perms !== newPerms) { if (!options.verbose && options.changes) { console.log(file + ' -> ' + newPerms.toString(8)); } fs.chmodSync(file, newPerms); perms = newPerms; // for the next round of changes! } - } - else { + } else { common.error('Invalid symbolic mode change: ' + symbolicMode); } }); - } - else { + } else { // they gave us a full number newPerms = type + parseInt(mode, 8); - // POSIX rules are that setuid and setgid can only be added using numeric form, but not cleared. + // POSIX rules are that setuid and setgid can only be added using numeric + // form, but not cleared. if (fs.statSync(file).isDirectory()) { newPerms |= (PERMS.SETUID + PERMS.SETGID) & perms; } @@ -211,5 +210,6 @@ function _chmod(options, mode, filePattern) { fs.chmodSync(file, newPerms); } }); + return ''; } module.exports = _chmod; diff --git a/tools/eslint/node_modules/shelljs/src/common.js b/tools/eslint/node_modules/shelljs/src/common.js index 33198bd8a0a265..8211feff4e4d29 100644 --- a/tools/eslint/node_modules/shelljs/src/common.js +++ b/tools/eslint/node_modules/shelljs/src/common.js @@ -1,68 +1,132 @@ +// Ignore warning about 'new String()' +/* eslint no-new-wrappers: 0 */ +'use strict'; + var os = require('os'); var fs = require('fs'); -var _ls = require('./ls'); +var glob = require('glob'); +var shell = require('..'); + +var shellMethods = Object.create(shell); // Module globals var config = { silent: false, fatal: false, verbose: false, + noglob: false, + globOptions: {}, + maxdepth: 255 }; exports.config = config; var state = { error: null, + errorCode: 0, currentCmd: 'shell.js', - previousDir: null, tempDir: null }; exports.state = state; +delete process.env.OLDPWD; // initially, there's no previous directory + var platform = os.type().match(/^Win/) ? 'win' : 'unix'; exports.platform = platform; +// This is populated by calls to commonl.wrap() +var pipeMethods = []; + function log() { - if (!config.silent) + if (!config.silent) { console.error.apply(console, arguments); + } } exports.log = log; -// Shows error message. Throws unless _continue or config.fatal are true -function error(msg, _continue) { - if (state.error === null) - state.error = ''; - var log_entry = state.currentCmd + ': ' + msg; - if (state.error === '') - state.error = log_entry; - else - state.error += '\n' + log_entry; +// Shows error message. Throws if config.fatal is true +function error(msg, _code, options) { + // Validate input + if (typeof msg !== 'string') throw new Error('msg must be a string'); + + var DEFAULT_OPTIONS = { + continue: false, + code: 1, + prefix: state.currentCmd + ': ', + silent: false, + }; + + if (typeof _code === 'number' && typeof options === 'object') { + options.code = _code; + } else if (typeof _code === 'object') { // no 'code' + options = _code; + } else if (typeof _code === 'number') { // no 'options' + options = { code: _code }; + } else if (typeof _code !== 'number') { // only 'msg' + options = {}; + } + options = objectAssign({}, DEFAULT_OPTIONS, options); + + if (!state.errorCode) state.errorCode = options.code; - if (msg.length > 0) - log(log_entry); + var logEntry = options.prefix + msg; + state.error = state.error ? state.error + '\n' : ''; + state.error += logEntry; - if (config.fatal) - process.exit(1); + // Throw an error, or log the entry + if (config.fatal) throw new Error(logEntry); + if (msg.length > 0 && !options.silent) log(logEntry); - if (!_continue) - throw ''; + if (!options.continue) { + throw { + msg: 'earlyExit', + retValue: (new ShellString('', state.error, state.errorCode)) + }; + } } exports.error = error; -// In the future, when Proxies are default, we can add methods like `.to()` to primitive strings. -// For now, this is a dummy function to bookmark places we need such strings -function ShellString(str) { - return str; +//@ +//@ ### ShellString(str) +//@ +//@ Examples: +//@ +//@ ```javascript +//@ var foo = ShellString('hello world'); +//@ ``` +//@ +//@ Turns a regular string into a string-like object similar to what each +//@ command returns. This has special methods, like `.to()` and `.toEnd()` +function ShellString(stdout, stderr, code) { + var that; + if (stdout instanceof Array) { + that = stdout; + that.stdout = stdout.join('\n'); + if (stdout.length > 0) that.stdout += '\n'; + } else { + that = new String(stdout); + that.stdout = stdout; + } + that.stderr = stderr; + that.code = code; + // A list of all commands that can appear on the right-hand side of a pipe + // (populated by calls to common.wrap()) + pipeMethods.forEach(function (cmd) { + that[cmd] = shellMethods[cmd].bind(that); + }); + return that; } + exports.ShellString = ShellString; // Return the home directory in a platform-agnostic way, with consideration for // older versions of node function getUserHome() { var result; - if (os.homedir) + if (os.homedir) { result = os.homedir(); // node 3+ - else + } else { result = process.env[(process.platform === 'win32') ? 'USERPROFILE' : 'HOME']; + } return result; } exports.getUserHome = getUserHome; @@ -72,49 +136,50 @@ exports.getUserHome = getUserHome; // Returns {'reference': 'string-value', 'bob': false} when passed two dictionaries of the form: // parseOptions({'-r': 'string-value'}, {'r':'reference', 'b':'bob'}); function parseOptions(opt, map) { - if (!map) - error('parseOptions() internal error: no map given'); + if (!map) error('parseOptions() internal error: no map given'); // All options are false by default var options = {}; - for (var letter in map) { - if (map[letter][0] !== '!') + Object.keys(map).forEach(function (letter) { + if (map[letter][0] !== '!') { options[map[letter]] = false; - } + } + }); - if (!opt) - return options; // defaults + if (!opt) return options; // defaults var optionName; if (typeof opt === 'string') { - if (opt[0] !== '-') + if (opt[0] !== '-') { return options; + } // e.g. chars = ['R', 'f'] var chars = opt.slice(1).split(''); - chars.forEach(function(c) { + chars.forEach(function (c) { if (c in map) { optionName = map[c]; - if (optionName[0] === '!') - options[optionName.slice(1, optionName.length-1)] = false; - else + if (optionName[0] === '!') { + options[optionName.slice(1)] = false; + } else { options[optionName] = true; + } } else { - error('option not recognized: '+c); + error('option not recognized: ' + c); } }); } else if (typeof opt === 'object') { - for (var key in opt) { + Object.keys(opt).forEach(function (key) { // key is a string of the form '-r', '-d', etc. var c = key[1]; if (c in map) { optionName = map[c]; options[optionName] = opt[key]; // assign the given value } else { - error('option not recognized: '+c); + error('option not recognized: ' + c); } - } + }); } else { error('options must be strings or key-value pairs'); } @@ -127,29 +192,18 @@ exports.parseOptions = parseOptions; // expand(['file*.js']) = ['file1.js', 'file2.js', ...] // (if the files 'file1.js', 'file2.js', etc, exist in the current dir) function expand(list) { + if (!Array.isArray(list)) { + throw new TypeError('must be an array'); + } var expanded = []; - list.forEach(function(listEl) { - // Wildcard present on directory names ? - if(listEl.search(/\*[^\/]*\//) > -1 || listEl.search(/\*\*[^\/]*\//) > -1) { - var match = listEl.match(/^([^*]+\/|)(.*)/); - var root = match[1]; - var rest = match[2]; - var restRegex = rest.replace(/\*\*/g, ".*").replace(/\*/g, "[^\\/]*"); - restRegex = new RegExp(restRegex); - - _ls('-R', root).filter(function (e) { - return restRegex.test(e); - }).forEach(function(file) { - expanded.push(file); - }); - } - // Wildcard present on file names ? - else if (listEl.search(/\*/) > -1) { - _ls('', listEl).forEach(function(file) { - expanded.push(file); - }); - } else { + list.forEach(function (listEl) { + // Don't expand non-strings + if (typeof listEl !== 'string') { expanded.push(listEl); + } else { + var ret = glob.sync(listEl, config.globOptions); + // if glob fails, interpret the string literally + expanded = expanded.concat(ret.length > 0 ? ret : [listEl]); } }); return expanded; @@ -161,7 +215,7 @@ exports.expand = expand; function unlinkSync(file) { try { fs.unlinkSync(file); - } catch(e) { + } catch (e) { // Try to override file permission if (e.code === 'EPERM') { fs.chmodSync(file, '0666'); @@ -176,78 +230,133 @@ exports.unlinkSync = unlinkSync; // e.g. 'shelljs_a5f185d0443ca...' function randomFileName() { function randomHash(count) { - if (count === 1) - return parseInt(16*Math.random(), 10).toString(16); - else { - var hash = ''; - for (var i=0; i= common.config.maxdepth) { + // Max depth has been reached, end copy. + return; + } + opts.depth++; + + // Create the directory where all our junk is moving to; read the mode of the + // source directory and mirror it try { + var checkDir = fs.statSync(sourceDir); fs.mkdirSync(destDir, checkDir.mode); } catch (e) { - //if the directory already exists, that's okay + // if the directory already exists, that's okay if (e.code !== 'EEXIST') throw e; } var files = fs.readdirSync(sourceDir); for (var i = 0; i < files.length; i++) { - var srcFile = sourceDir + "/" + files[i]; - var destFile = destDir + "/" + files[i]; + var srcFile = sourceDir + '/' + files[i]; + var destFile = destDir + '/' + files[i]; var srcFileStat = fs.lstatSync(srcFile); + var symlinkFull; + if (opts.followsymlink) { + if (cpcheckcycle(sourceDir, srcFile)) { + // Cycle link found. + console.error('Cycle link found.'); + symlinkFull = fs.readlinkSync(srcFile); + fs.symlinkSync(symlinkFull, destFile, os.platform() === 'win32' ? 'junction' : null); + continue; + } + } if (srcFileStat.isDirectory()) { /* recursion this thing right on back. */ cpdirSyncRecursive(srcFile, destFile, opts); - } else if (srcFileStat.isSymbolicLink()) { - var symlinkFull = fs.readlinkSync(srcFile); - fs.symlinkSync(symlinkFull, destFile, os.platform() === "win32" ? "junction" : null); + } else if (srcFileStat.isSymbolicLink() && !opts.followsymlink) { + symlinkFull = fs.readlinkSync(srcFile); + try { + fs.lstatSync(destFile); + common.unlinkSync(destFile); // re-link it + } catch (e) { + // it doesn't exist, so no work needs to be done + } + fs.symlinkSync(symlinkFull, destFile, os.platform() === 'win32' ? 'junction' : null); + } else if (srcFileStat.isSymbolicLink() && opts.followsymlink) { + srcFileStat = fs.statSync(srcFile); + if (srcFileStat.isDirectory()) { + cpdirSyncRecursive(srcFile, destFile, opts); + } else { + copyFileSync(srcFile, destFile, opts); + } } else { /* At this point, we've hit a file actually worth copying... so copy it on over. */ if (fs.existsSync(destFile) && opts.no_force) { common.log('skipping existing file: ' + files[i]); } else { - copyFileSync(srcFile, destFile); + copyFileSync(srcFile, destFile, opts); } } - } // for files } // cpdirSyncRecursive +function cpcheckcycle(sourceDir, srcFile) { + var srcFileStat = fs.lstatSync(srcFile); + if (srcFileStat.isSymbolicLink()) { + // Do cycle check. For example: + // $ mkdir -p 1/2/3/4 + // $ cd 1/2/3/4 + // $ ln -s ../../3 link + // $ cd ../../../.. + // $ cp -RL 1 copy + var cyclecheck = fs.statSync(srcFile); + if (cyclecheck.isDirectory()) { + var sourcerealpath = fs.realpathSync(sourceDir); + var symlinkrealpath = fs.realpathSync(srcFile); + var re = new RegExp(symlinkrealpath); + if (re.test(sourcerealpath)) { + return true; + } + } + } + return false; +} //@ //@ ### cp([options,] source [, source ...], dest) @@ -94,117 +183,92 @@ function cpdirSyncRecursive(sourceDir, destDir, opts) { //@ //@ + `-f`: force (default behavior) //@ + `-n`: no-clobber -//@ + `-r, -R`: recursive +//@ + `-u`: only copy if source is newer than dest +//@ + `-r`, `-R`: recursive +//@ + `-L`: follow symlinks +//@ + `-P`: don't follow symlinks //@ //@ Examples: //@ //@ ```javascript //@ cp('file1', 'dir1'); +//@ cp('-R', 'path/to/dir/', '~/newCopy/'); //@ cp('-Rf', '/tmp/*', '/usr/local/*', '/home/tmp'); //@ cp('-Rf', ['/tmp/*', '/usr/local/*'], '/home/tmp'); // same as above //@ ``` //@ -//@ Copies files. The wildcard `*` is accepted. +//@ Copies files. function _cp(options, sources, dest) { - options = common.parseOptions(options, { - 'f': '!no_force', - 'n': 'no_force', - 'R': 'recursive', - 'r': 'recursive' - }); + // If we're missing -R, it actually implies -L (unless -P is explicit) + if (options.followsymlink) { + options.noFollowsymlink = false; + } + if (!options.recursive && !options.noFollowsymlink) { + options.followsymlink = true; + } // Get sources, dest if (arguments.length < 3) { common.error('missing and/or '); - } else if (arguments.length > 3) { + } else { sources = [].slice.call(arguments, 1, arguments.length - 1); dest = arguments[arguments.length - 1]; - } else if (typeof sources === 'string') { - sources = [sources]; - } else if ('length' in sources) { - sources = sources; // no-op for array - } else { - common.error('invalid arguments'); } - var exists = fs.existsSync(dest), - stats = exists && fs.statSync(dest); + var destExists = fs.existsSync(dest); + var destStat = destExists && fs.statSync(dest); // Dest is not existing dir, but multiple sources given - if ((!exists || !stats.isDirectory()) && sources.length > 1) + if ((!destExists || !destStat.isDirectory()) && sources.length > 1) { common.error('dest is not a directory (too many sources)'); - - // Dest is an existing file, but no -f given - if (exists && stats.isFile() && options.no_force) - common.error('dest file already exists: ' + dest); - - if (options.recursive) { - // Recursive allows the shortcut syntax "sourcedir/" for "sourcedir/*" - // (see Github issue #15) - sources.forEach(function(src, i) { - if (src[src.length - 1] === '/') { - sources[i] += '*'; - // If src is a directory and dest doesn't exist, 'cp -r src dest' should copy src/* into dest - } else if (fs.statSync(src).isDirectory() && !exists) { - sources[i] += '/*'; - } - }); - - // Create dest - try { - fs.mkdirSync(dest, parseInt('0777', 8)); - } catch (e) { - // like Unix's cp, keep going even if we can't create dest dir - } } - sources = common.expand(sources); + // Dest is an existing file, but -n is given + if (destExists && destStat.isFile() && options.no_force) { + return new common.ShellString('', '', 0); + } - sources.forEach(function(src) { + sources.forEach(function (src) { if (!fs.existsSync(src)) { - common.error('no such file or directory: '+src, true); + common.error('no such file or directory: ' + src, { continue: true }); return; // skip file } - - // If here, src exists - if (fs.statSync(src).isDirectory()) { + var srcStat = fs.statSync(src); + if (!options.noFollowsymlink && srcStat.isDirectory()) { if (!options.recursive) { // Non-Recursive - common.log(src + ' is a directory (not copied)'); + common.error("omitting directory '" + src + "'", { continue: true }); } else { // Recursive // 'cp /a/source dest' should create 'source' in 'dest' - var newDest = path.join(dest, path.basename(src)), - checkDir = fs.statSync(src); + var newDest = (destStat && destStat.isDirectory()) ? + path.join(dest, path.basename(src)) : + dest; + try { - fs.mkdirSync(newDest, checkDir.mode); + fs.statSync(path.dirname(dest)); + cpdirSyncRecursive(src, newDest, { no_force: options.no_force, followsymlink: options.followsymlink }); } catch (e) { - //if the directory already exists, that's okay - if (e.code !== 'EEXIST') { - common.error('dest file no such file or directory: ' + newDest, true); - throw e; - } + common.error("cannot create directory '" + dest + "': No such file or directory"); } - - cpdirSyncRecursive(src, newDest, {no_force: options.no_force}); } - return; // done with dir - } + } else { + // If here, src is a file - // If here, src is a file + // When copying to '/path/dir': + // thisDest = '/path/dir/file1' + var thisDest = dest; + if (destStat && destStat.isDirectory()) { + thisDest = path.normalize(dest + '/' + path.basename(src)); + } - // When copying to '/path/dir': - // thisDest = '/path/dir/file1' - var thisDest = dest; - if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) - thisDest = path.normalize(dest + '/' + path.basename(src)); + if (fs.existsSync(thisDest) && options.no_force) { + return; // skip file + } - if (fs.existsSync(thisDest) && options.no_force) { - common.error('dest file already exists: ' + thisDest, true); - return; // skip file + copyFileSync(src, thisDest, options); } - - copyFileSync(src, thisDest); }); // forEach(src) + return new common.ShellString('', common.state.error, common.state.errorCode); } module.exports = _cp; diff --git a/tools/eslint/node_modules/shelljs/src/dirs.js b/tools/eslint/node_modules/shelljs/src/dirs.js index 58fae8b3c6fae3..cf5fe02f50c593 100644 --- a/tools/eslint/node_modules/shelljs/src/dirs.js +++ b/tools/eslint/node_modules/shelljs/src/dirs.js @@ -2,6 +2,16 @@ var common = require('./common'); var _cd = require('./cd'); var path = require('path'); +common.register('dirs', _dirs, { + wrapOutput: false, +}); +common.register('pushd', _pushd, { + wrapOutput: false, +}); +common.register('popd', _popd, { + wrapOutput: false, +}); + // Pushd/popd/dirs internals var _dirStack = []; @@ -13,9 +23,8 @@ function _parseStackIndex(index) { if (_isStackIndex(index)) { if (Math.abs(index) < _dirStack.length + 1) { // +1 for pwd return (/^-/).test(index) ? Number(index) - 1 : Number(index); - } else { - common.error(index + ': directory stack index out of range'); } + common.error(index + ': directory stack index out of range'); } else { common.error(index + ': invalid number'); } @@ -54,7 +63,7 @@ function _pushd(options, dir) { } options = common.parseOptions(options, { - 'n' : 'no-cd' + 'n': 'no-cd' }); var dirs = _actualDirStack(); @@ -120,7 +129,7 @@ function _popd(options, index) { } options = common.parseOptions(options, { - 'n' : 'no-cd' + 'n': 'no-cd' }); if (!_dirStack.length) { @@ -163,10 +172,10 @@ function _dirs(options, index) { } options = common.parseOptions(options, { - 'c' : 'clear' + 'c': 'clear' }); - if (options['clear']) { + if (options.clear) { _dirStack = []; return _dirStack; } diff --git a/tools/eslint/node_modules/shelljs/src/echo.js b/tools/eslint/node_modules/shelljs/src/echo.js index b574adc5c38465..2b0e7d9198186f 100644 --- a/tools/eslint/node_modules/shelljs/src/echo.js +++ b/tools/eslint/node_modules/shelljs/src/echo.js @@ -1,7 +1,14 @@ var common = require('./common'); +common.register('echo', _echo, { + allowGlobbing: false, +}); + +//@ +//@ ### echo([options,] string [, string ...]) +//@ Available options: //@ -//@ ### echo(string [, string ...]) +//@ + `-e`: interpret backslash escapes (default) //@ //@ Examples: //@ @@ -12,9 +19,16 @@ var common = require('./common'); //@ //@ Prints string to stdout, and returns string with additional utility methods //@ like `.to()`. -function _echo() { - var messages = [].slice.call(arguments, 0); +function _echo(opts, messages) { + // allow strings starting with '-', see issue #20 + messages = [].slice.call(arguments, opts ? 0 : 1); + + if (messages[0] === '-e') { + // ignore -e + messages.shift(); + } + console.log.apply(console, messages); - return common.ShellString(messages.join(' ')); + return messages.join(' '); } module.exports = _echo; diff --git a/tools/eslint/node_modules/shelljs/src/error.js b/tools/eslint/node_modules/shelljs/src/error.js index 112563db80311e..507c86ddd7131e 100644 --- a/tools/eslint/node_modules/shelljs/src/error.js +++ b/tools/eslint/node_modules/shelljs/src/error.js @@ -2,8 +2,12 @@ var common = require('./common'); //@ //@ ### error() -//@ Tests if error occurred in the last command. Returns `null` if no error occurred, -//@ otherwise returns string explaining the error +//@ Tests if error occurred in the last command. Returns a truthy value if an +//@ error returned and a falsy value otherwise. +//@ +//@ **Note**: do not rely on the +//@ return value to be an error message. If you need the last error message, use +//@ the `.stderr` attribute from the last command's return value instead. function error() { return common.state.error; } diff --git a/tools/eslint/node_modules/shelljs/src/exec.js b/tools/eslint/node_modules/shelljs/src/exec.js index 4174adbd32d317..f6875b1e5fc4ae 100644 --- a/tools/eslint/node_modules/shelljs/src/exec.js +++ b/tools/eslint/node_modules/shelljs/src/exec.js @@ -5,85 +5,95 @@ var path = require('path'); var fs = require('fs'); var child = require('child_process'); -var DEFAULT_MAXBUFFER_SIZE = 20*1024*1024; +var DEFAULT_MAXBUFFER_SIZE = 20 * 1024 * 1024; + +common.register('exec', _exec, { + unix: false, + canReceivePipe: true, + wrapOutput: false, +}); // Hack to run child_process.exec() synchronously (sync avoids callback hell) // Uses a custom wait loop that checks for a flag file, created when the child process is done. // (Can't do a wait loop that checks for internal Node variables/messages as // Node is single-threaded; callbacks and other internal state changes are done in the // event loop). -function execSync(cmd, opts) { +function execSync(cmd, opts, pipe) { var tempDir = _tempDir(); - var stdoutFile = path.resolve(tempDir+'/'+common.randomFileName()), - stderrFile = path.resolve(tempDir+'/'+common.randomFileName()), - codeFile = path.resolve(tempDir+'/'+common.randomFileName()), - scriptFile = path.resolve(tempDir+'/'+common.randomFileName()), - sleepFile = path.resolve(tempDir+'/'+common.randomFileName()); + var stdoutFile = path.resolve(tempDir + '/' + common.randomFileName()); + var stderrFile = path.resolve(tempDir + '/' + common.randomFileName()); + var codeFile = path.resolve(tempDir + '/' + common.randomFileName()); + var scriptFile = path.resolve(tempDir + '/' + common.randomFileName()); + var sleepFile = path.resolve(tempDir + '/' + common.randomFileName()); opts = common.extend({ silent: common.config.silent, - cwd: _pwd(), + cwd: _pwd().toString(), env: process.env, maxBuffer: DEFAULT_MAXBUFFER_SIZE }, opts); - var previousStdoutContent = '', - previousStderrContent = ''; + var previousStdoutContent = ''; + var previousStderrContent = ''; // Echoes stdout and stderr changes from running process, if not silent function updateStream(streamFile) { - if (opts.silent || !fs.existsSync(streamFile)) + if (opts.silent || !fs.existsSync(streamFile)) { return; + } - var previousStreamContent, - proc_stream; + var previousStreamContent; + var procStream; if (streamFile === stdoutFile) { previousStreamContent = previousStdoutContent; - proc_stream = process.stdout; + procStream = process.stdout; } else { // assume stderr previousStreamContent = previousStderrContent; - proc_stream = process.stderr; + procStream = process.stderr; } var streamContent = fs.readFileSync(streamFile, 'utf8'); // No changes since last time? - if (streamContent.length <= previousStreamContent.length) + if (streamContent.length <= previousStreamContent.length) { return; + } - proc_stream.write(streamContent.substr(previousStreamContent.length)); + procStream.write(streamContent.substr(previousStreamContent.length)); previousStreamContent = streamContent; } - function escape(str) { - return (str+'').replace(/([\\"'])/g, "\\$1").replace(/\0/g, "\\0"); - } - if (fs.existsSync(scriptFile)) common.unlinkSync(scriptFile); if (fs.existsSync(stdoutFile)) common.unlinkSync(stdoutFile); if (fs.existsSync(stderrFile)) common.unlinkSync(stderrFile); if (fs.existsSync(codeFile)) common.unlinkSync(codeFile); - var execCommand = '"'+process.execPath+'" '+scriptFile; + var execCommand = JSON.stringify(process.execPath) + ' ' + JSON.stringify(scriptFile); var script; + opts.cwd = path.resolve(opts.cwd); + var optString = JSON.stringify(opts); + if (typeof child.execSync === 'function') { script = [ "var child = require('child_process')", " , fs = require('fs');", - "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: "+opts.maxBuffer+"}, function(err) {", - " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');", - "});", - "var stdoutStream = fs.createWriteStream('"+escape(stdoutFile)+"');", - "var stderrStream = fs.createWriteStream('"+escape(stderrFile)+"');", - "childProcess.stdout.pipe(stdoutStream, {end: false});", - "childProcess.stderr.pipe(stderrStream, {end: false});", - "childProcess.stdout.pipe(process.stdout);", - "childProcess.stderr.pipe(process.stderr);", - "var stdoutEnded = false, stderrEnded = false;", - "function tryClosingStdout(){ if(stdoutEnded){ stdoutStream.end(); } }", - "function tryClosingStderr(){ if(stderrEnded){ stderrStream.end(); } }", - "childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosingStdout(); });", - "childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosingStderr(); });" - ].join('\n'); + 'var childProcess = child.exec(' + JSON.stringify(cmd) + ', ' + optString + ', function(err) {', + ' fs.writeFileSync(' + JSON.stringify(codeFile) + ", err ? err.code.toString() : '0');", + '});', + 'var stdoutStream = fs.createWriteStream(' + JSON.stringify(stdoutFile) + ');', + 'var stderrStream = fs.createWriteStream(' + JSON.stringify(stderrFile) + ');', + 'childProcess.stdout.pipe(stdoutStream, {end: false});', + 'childProcess.stderr.pipe(stderrStream, {end: false});', + 'childProcess.stdout.pipe(process.stdout);', + 'childProcess.stderr.pipe(process.stderr);' + ].join('\n') + + (pipe ? '\nchildProcess.stdin.end(' + JSON.stringify(pipe) + ');\n' : '\n') + + [ + 'var stdoutEnded = false, stderrEnded = false;', + 'function tryClosingStdout(){ if(stdoutEnded){ stdoutStream.end(); } }', + 'function tryClosingStderr(){ if(stderrEnded){ stderrStream.end(); } }', + "childProcess.stdout.on('end', function(){ stdoutEnded = true; tryClosingStdout(); });", + "childProcess.stderr.on('end', function(){ stderrEnded = true; tryClosingStderr(); });" + ].join('\n'); fs.writeFileSync(scriptFile, script); @@ -94,17 +104,27 @@ function execSync(cmd, opts) { } // Welcome to the future - child.execSync(execCommand, opts); + try { + child.execSync(execCommand, opts); + } catch (e) { + // Clean up immediately if we have an exception + try { common.unlinkSync(scriptFile); } catch (e2) {} + try { common.unlinkSync(stdoutFile); } catch (e2) {} + try { common.unlinkSync(stderrFile); } catch (e2) {} + try { common.unlinkSync(codeFile); } catch (e2) {} + throw e; + } } else { - cmd += ' > '+stdoutFile+' 2> '+stderrFile; // works on both win/unix + cmd += ' > ' + stdoutFile + ' 2> ' + stderrFile; // works on both win/unix script = [ "var child = require('child_process')", " , fs = require('fs');", - "var childProcess = child.exec('"+escape(cmd)+"', {env: process.env, maxBuffer: "+opts.maxBuffer+"}, function(err) {", - " fs.writeFileSync('"+escape(codeFile)+"', err ? err.code.toString() : '0');", - "});" - ].join('\n'); + 'var childProcess = child.exec(' + JSON.stringify(cmd) + ', ' + optString + ', function(err) {', + ' fs.writeFileSync(' + JSON.stringify(codeFile) + ", err ? err.code.toString() : '0');", + '});' + ].join('\n') + + (pipe ? '\nchildProcess.stdin.end(' + JSON.stringify(pipe) + ');\n' : '\n'); fs.writeFileSync(scriptFile, script); @@ -117,6 +137,7 @@ function execSync(cmd, opts) { while (!fs.existsSync(codeFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); } while (!fs.existsSync(stdoutFile)) { updateStream(stdoutFile); fs.writeFileSync(sleepFile, 'a'); } while (!fs.existsSync(stderrFile)) { updateStream(stderrFile); fs.writeFileSync(sleepFile, 'a'); } + try { common.unlinkSync(sleepFile); } catch (e) {} } // At this point codeFile exists, but it's not necessarily flushed yet. @@ -130,53 +151,46 @@ function execSync(cmd, opts) { var stderr = fs.readFileSync(stderrFile, 'utf8'); // No biggie if we can't erase the files now -- they're in a temp dir anyway - try { common.unlinkSync(scriptFile); } catch(e) {} - try { common.unlinkSync(stdoutFile); } catch(e) {} - try { common.unlinkSync(stderrFile); } catch(e) {} - try { common.unlinkSync(codeFile); } catch(e) {} - try { common.unlinkSync(sleepFile); } catch(e) {} - - // some shell return codes are defined as errors, per http://tldp.org/LDP/abs/html/exitcodes.html - if (code === 1 || code === 2 || code >= 126) { - common.error('', true); // unix/shell doesn't really give an error message after non-zero exit codes + try { common.unlinkSync(scriptFile); } catch (e) {} + try { common.unlinkSync(stdoutFile); } catch (e) {} + try { common.unlinkSync(stderrFile); } catch (e) {} + try { common.unlinkSync(codeFile); } catch (e) {} + + if (code !== 0) { + common.error('', code, { continue: true }); } - // True if successful, false if not - var obj = { - code: code, - output: stdout, // deprecated - stdout: stdout, - stderr: stderr - }; + var obj = common.ShellString(stdout, stderr, code); return obj; } // execSync() // Wrapper around exec() to enable echoing output to console in real time -function execAsync(cmd, opts, callback) { +function execAsync(cmd, opts, pipe, callback) { var stdout = ''; var stderr = ''; opts = common.extend({ silent: common.config.silent, - cwd: _pwd(), + cwd: _pwd().toString(), env: process.env, maxBuffer: DEFAULT_MAXBUFFER_SIZE }, opts); - var c = child.exec(cmd, opts, function(err) { - if (callback) + var c = child.exec(cmd, opts, function (err) { + if (callback) { callback(err ? err.code : 0, stdout, stderr); + } }); - c.stdout.on('data', function(data) { + if (pipe) c.stdin.end(pipe); + + c.stdout.on('data', function (data) { stdout += data; - if (!opts.silent) - process.stdout.write(data); + if (!opts.silent) process.stdout.write(data); }); - c.stderr.on('data', function(data) { + c.stderr.on('data', function (data) { stderr += data; - if (!opts.silent) - process.stderr.write(data); + if (!opts.silent) process.stderr.write(data); }); return c; @@ -210,16 +224,22 @@ function execAsync(cmd, opts, callback) { //@ ``` //@ //@ Executes the given `command` _synchronously_, unless otherwise specified. When in synchronous -//@ mode returns the object `{ code:..., stdout:... , stderr:... }`, containing the program's -//@ `stdout`, `stderr`, and its exit `code`. Otherwise returns the child process object, -//@ and the `callback` gets the arguments `(code, stdout, stderr)`. +//@ mode, this returns a ShellString (compatible with ShellJS v0.6.x, which returns an object +//@ of the form `{ code:..., stdout:... , stderr:... }`). Otherwise, this returns the child process +//@ object, and the `callback` gets the arguments `(code, stdout, stderr)`. +//@ +//@ Not seeing the behavior you want? `exec()` runs everything through `sh` +//@ by default (or `cmd.exe` on Windows), which differs from `bash`. If you +//@ need bash-specific behavior, try out the `{shell: 'path/to/bash'}` option. //@ //@ **Note:** For long-lived processes, it's best to run `exec()` asynchronously as //@ the current synchronous implementation uses a lot of CPU. This should be getting //@ fixed soon. function _exec(command, options, callback) { - if (!command) - common.error('must specify command'); + options = options || {}; + if (!command) common.error('must specify command'); + + var pipe = common.readFromPipe(); // Callback is defined instead of options. if (typeof options === 'function') { @@ -238,10 +258,11 @@ function _exec(command, options, callback) { }, options); try { - if (options.async) - return execAsync(command, options, callback); - else - return execSync(command, options); + if (options.async) { + return execAsync(command, options, pipe, callback); + } else { + return execSync(command, options, pipe); + } } catch (e) { common.error('internal error'); } diff --git a/tools/eslint/node_modules/shelljs/src/find.js b/tools/eslint/node_modules/shelljs/src/find.js index c96fb2f7ad51e7..f96a51e7830a62 100644 --- a/tools/eslint/node_modules/shelljs/src/find.js +++ b/tools/eslint/node_modules/shelljs/src/find.js @@ -1,7 +1,10 @@ var fs = require('fs'); +var path = require('path'); var common = require('./common'); var _ls = require('./ls'); +common.register('find', _find, {}); + //@ //@ ### find(path [, path ...]) //@ ### find(path_array) @@ -18,30 +21,30 @@ var _ls = require('./ls'); //@ The main difference from `ls('-R', path)` is that the resulting file names //@ include the base directories, e.g. `lib/resources/file1` instead of just `file1`. function _find(options, paths) { - if (!paths) + if (!paths) { common.error('no path specified'); - else if (typeof paths === 'object') - paths = paths; // assume array - else if (typeof paths === 'string') + } else if (typeof paths === 'string') { paths = [].slice.call(arguments, 1); + } var list = []; function pushFile(file) { - if (common.platform === 'win') + if (common.platform === 'win') { file = file.replace(/\\/g, '/'); + } list.push(file); } // why not simply do ls('-R', paths)? because the output wouldn't give the base dirs // to get the base dir in the output, we need instead ls('-R', 'dir/*') for every directory - paths.forEach(function(file) { + paths.forEach(function (file) { pushFile(file); if (fs.statSync(file).isDirectory()) { - _ls('-RA', file+'/*').forEach(function(subfile) { - pushFile(subfile); + _ls({ recursive: true, all: true }, file).forEach(function (subfile) { + pushFile(path.join(file, subfile)); }); } }); diff --git a/tools/eslint/node_modules/shelljs/src/grep.js b/tools/eslint/node_modules/shelljs/src/grep.js index 78008ce19e6d2f..30842bcb859441 100644 --- a/tools/eslint/node_modules/shelljs/src/grep.js +++ b/tools/eslint/node_modules/shelljs/src/grep.js @@ -1,12 +1,22 @@ var common = require('./common'); var fs = require('fs'); +common.register('grep', _grep, { + globStart: 2, // don't glob-expand the regex + canReceivePipe: true, + cmdOptions: { + 'v': 'inverse', + 'l': 'nameOnly', + }, +}); + //@ //@ ### grep([options,] regex_filter, file [, file ...]) //@ ### grep([options,] regex_filter, file_array) //@ Available options: //@ //@ + `-v`: Inverse the sense of the regex and print the lines not matching the criteria. +//@ + `-l`: Print only filenames of matching files //@ //@ Examples: //@ @@ -16,37 +26,42 @@ var fs = require('fs'); //@ ``` //@ //@ Reads input string from given files and returns a string containing all lines of the -//@ file that match the given `regex_filter`. Wildcard `*` accepted. +//@ file that match the given `regex_filter`. function _grep(options, regex, files) { - options = common.parseOptions(options, { - 'v': 'inverse' - }); + // Check if this is coming from a pipe + var pipe = common.readFromPipe(); - if (!files) - common.error('no paths given'); + if (!files && !pipe) common.error('no paths given', 2); - if (typeof files === 'string') - files = [].slice.call(arguments, 2); - // if it's array leave it as it is + files = [].slice.call(arguments, 2); - files = common.expand(files); + if (pipe) { + files.unshift('-'); + } - var grep = ''; - files.forEach(function(file) { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file, true); + var grep = []; + files.forEach(function (file) { + if (!fs.existsSync(file) && file !== '-') { + common.error('no such file or directory: ' + file, 2, { continue: true }); return; } - var contents = fs.readFileSync(file, 'utf8'), - lines = contents.split(/\r*\n/); - lines.forEach(function(line) { - var matched = line.match(regex); - if ((options.inverse && !matched) || (!options.inverse && matched)) - grep += line + '\n'; - }); + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + var lines = contents.split(/\r*\n/); + if (options.nameOnly) { + if (contents.match(regex)) { + grep.push(file); + } + } else { + lines.forEach(function (line) { + var matched = line.match(regex); + if ((options.inverse && !matched) || (!options.inverse && matched)) { + grep.push(line); + } + }); + } }); - return common.ShellString(grep); + return grep.join('\n') + '\n'; } module.exports = _grep; diff --git a/tools/eslint/node_modules/shelljs/src/head.js b/tools/eslint/node_modules/shelljs/src/head.js new file mode 100644 index 00000000000000..13d5829775e8b2 --- /dev/null +++ b/tools/eslint/node_modules/shelljs/src/head.js @@ -0,0 +1,104 @@ +var common = require('./common'); +var fs = require('fs'); + +common.register('head', _head, { + canReceivePipe: true, + cmdOptions: { + 'n': 'numLines', + }, +}); + +// This reads n or more lines, or the entire file, whichever is less. +function readSomeLines(file, numLines) { + var BUF_LENGTH = 64 * 1024; + var buf = new Buffer(BUF_LENGTH); + var bytesRead = BUF_LENGTH; + var pos = 0; + var fdr = null; + + try { + fdr = fs.openSync(file, 'r'); + } catch (e) { + common.error('cannot read file: ' + file); + } + + var numLinesRead = 0; + var ret = ''; + while (bytesRead === BUF_LENGTH && numLinesRead < numLines) { + bytesRead = fs.readSync(fdr, buf, 0, BUF_LENGTH, pos); + var bufStr = buf.toString('utf8', 0, bytesRead); + numLinesRead += bufStr.split('\n').length - 1; + ret += bufStr; + pos += bytesRead; + } + + fs.closeSync(fdr); + return ret; +} +//@ +//@ ### head([{'-n': \},] file [, file ...]) +//@ ### head([{'-n': \},] file_array) +//@ Available options: +//@ +//@ + `-n `: Show the first `` lines of the files +//@ +//@ Examples: +//@ +//@ ```javascript +//@ var str = head({'-n': 1}, 'file*.txt'); +//@ var str = head('file1', 'file2'); +//@ var str = head(['file1', 'file2']); // same as above +//@ ``` +//@ +//@ Read the start of a file. +function _head(options, files) { + var head = []; + var pipe = common.readFromPipe(); + + if (!files && !pipe) common.error('no paths given'); + + var idx = 1; + if (options.numLines === true) { + idx = 2; + options.numLines = Number(arguments[1]); + } else if (options.numLines === false) { + options.numLines = 10; + } + files = [].slice.call(arguments, idx); + + if (pipe) { + files.unshift('-'); + } + + var shouldAppendNewline = false; + files.forEach(function (file) { + if (!fs.existsSync(file) && file !== '-') { + common.error('no such file or directory: ' + file, { continue: true }); + return; + } + + var contents; + if (file === '-') { + contents = pipe; + } else if (options.numLines < 0) { + contents = fs.readFileSync(file, 'utf8'); + } else { + contents = readSomeLines(file, options.numLines); + } + + var lines = contents.split('\n'); + var hasTrailingNewline = (lines[lines.length - 1] === ''); + if (hasTrailingNewline) { + lines.pop(); + } + shouldAppendNewline = (hasTrailingNewline || options.numLines < lines.length); + + head = head.concat(lines.slice(0, options.numLines)); + }); + + if (shouldAppendNewline) { + head.push(''); // to add a trailing newline once we join + } + return head.join('\n'); +} +module.exports = _head; diff --git a/tools/eslint/node_modules/shelljs/src/ln.js b/tools/eslint/node_modules/shelljs/src/ln.js index 878fda13e23d45..7393d9fcdca7d8 100644 --- a/tools/eslint/node_modules/shelljs/src/ln.js +++ b/tools/eslint/node_modules/shelljs/src/ln.js @@ -2,6 +2,13 @@ var fs = require('fs'); var path = require('path'); var common = require('./common'); +common.register('ln', _ln, { + cmdOptions: { + 's': 'symlink', + 'f': 'force', + }, +}); + //@ //@ ### ln([options,] source, dest) //@ Available options: @@ -18,11 +25,6 @@ var common = require('./common'); //@ //@ Links source to dest. Use -f to force the link, should dest already exist. function _ln(options, source, dest) { - options = common.parseOptions(options, { - 's': 'symlink', - 'f': 'force' - }); - if (!source || !dest) { common.error('Missing and/or '); } @@ -34,7 +36,7 @@ function _ln(options, source, dest) { if (fs.existsSync(dest)) { if (!options.force) { - common.error('Destination file exists', true); + common.error('Destination file exists', { continue: true }); } fs.unlinkSync(dest); @@ -45,19 +47,19 @@ function _ln(options, source, dest) { var linkType = isWindows ? 'file' : null; var resolvedSourcePath = isAbsolute ? sourcePath : path.resolve(process.cwd(), path.dirname(dest), source); if (!fs.existsSync(resolvedSourcePath)) { - common.error('Source file does not exist', true); + common.error('Source file does not exist', { continue: true }); } else if (isWindows && fs.statSync(resolvedSourcePath).isDirectory()) { - linkType = 'junction'; + linkType = 'junction'; } try { - fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath: source, dest, linkType); + fs.symlinkSync(linkType === 'junction' ? resolvedSourcePath : source, dest, linkType); } catch (err) { common.error(err.message); } } else { if (!fs.existsSync(source)) { - common.error('Source file does not exist', true); + common.error('Source file does not exist', { continue: true }); } try { fs.linkSync(source, dest); @@ -65,5 +67,6 @@ function _ln(options, source, dest) { common.error(err.message); } } + return ''; } module.exports = _ln; diff --git a/tools/eslint/node_modules/shelljs/src/ls.js b/tools/eslint/node_modules/shelljs/src/ls.js index 6a54b3a8d8426a..7f25056cd34d7a 100644 --- a/tools/eslint/node_modules/shelljs/src/ls.js +++ b/tools/eslint/node_modules/shelljs/src/ls.js @@ -1,8 +1,19 @@ var path = require('path'); var fs = require('fs'); var common = require('./common'); -var _cd = require('./cd'); -var _pwd = require('./pwd'); +var glob = require('glob'); + +var globPatternRecursive = path.sep + '**' + path.sep + '*'; + +common.register('ls', _ls, { + cmdOptions: { + 'R': 'recursive', + 'A': 'all', + 'a': 'all_deprecated', + 'd': 'directory', + 'l': 'long', + }, +}); //@ //@ ### ls([options,] [path, ...]) @@ -28,14 +39,6 @@ var _pwd = require('./pwd'); //@ //@ Returns array of files in the given path, or in current directory if no path provided. function _ls(options, paths) { - options = common.parseOptions(options, { - 'R': 'recursive', - 'A': 'all', - 'a': 'all_deprecated', - 'd': 'directory', - 'l': 'long' - }); - if (options.all_deprecated) { // We won't support the -a option as it's hard to image why it's useful // (it includes '.' and '..' in addition to '.*' files) @@ -44,125 +47,75 @@ function _ls(options, paths) { options.all = true; } - if (!paths) + if (!paths) { paths = ['.']; - else if (typeof paths === 'object') - paths = paths; // assume array - else if (typeof paths === 'string') + } else { paths = [].slice.call(arguments, 1); + } var list = []; - // Conditionally pushes file to list - returns true if pushed, false otherwise - // (e.g. prevents hidden files to be included unless explicitly told so) - function pushFile(file, query) { - var name = file.name || file; - // hidden file? - if (path.basename(name)[0] === '.') { - // not explicitly asking for hidden files? - if (!options.all && !(path.basename(query)[0] === '.' && path.basename(query).length > 1)) - return false; + function pushFile(abs, relName, stat) { + if (process.platform === 'win32') { + relName = relName.replace(/\\/g, '/'); } - - if (common.platform === 'win') - name = name.replace(/\\/g, '/'); - - if (file.name) { - file.name = name; + if (options.long) { + stat = stat || fs.lstatSync(abs); + list.push(addLsAttributes(relName, stat)); } else { - file = name; + // list.push(path.relative(rel || '.', file)); + list.push(relName); } - list.push(file); - return true; } - paths.forEach(function(p) { - if (fs.existsSync(p)) { - var stats = ls_stat(p); - // Simple file? - if (stats.isFile()) { - if (options.long) { - pushFile(stats, p); - } else { - pushFile(p, p); - } - return; // continue - } + paths.forEach(function (p) { + var stat; - // Simple dir? - if (options.directory) { - pushFile(p, p); - return; - } else if (stats.isDirectory()) { - // Iterate over p contents - fs.readdirSync(p).forEach(function(file) { - var orig_file = file; - if (options.long) - file = ls_stat(path.join(p, file)); - if (!pushFile(file, p)) - return; + try { + stat = fs.lstatSync(p); + } catch (e) { + common.error('no such file or directory: ' + p, 2, { continue: true }); + return; + } - // Recursive? - if (options.recursive) { - var oldDir = _pwd(); - _cd('', p); - if (fs.statSync(orig_file).isDirectory()) - list = list.concat(_ls('-R'+(options.all?'A':''), orig_file+'/*')); - _cd('', oldDir); + // If the stat succeeded + if (stat.isDirectory() && !options.directory) { + if (options.recursive) { + // use glob, because it's simple + glob.sync(p + globPatternRecursive, { dot: options.all }) + .forEach(function (item) { + pushFile(item, path.relative(p, item)); + }); + } else if (options.all) { + // use fs.readdirSync, because it's fast + fs.readdirSync(p).forEach(function (item) { + pushFile(path.join(p, item), item); + }); + } else { + // use fs.readdirSync and then filter out secret files + fs.readdirSync(p).forEach(function (item) { + if (item[0] !== '.') { + pushFile(path.join(p, item), item); } }); - return; // continue } + } else { + pushFile(p, p, stat); } - - // p does not exist - possible wildcard present - - var basename = path.basename(p); - var dirname = path.dirname(p); - // Wildcard present on an existing dir? (e.g. '/tmp/*.js') - if (basename.search(/\*/) > -1 && fs.existsSync(dirname) && fs.statSync(dirname).isDirectory) { - // Escape special regular expression chars - var regexp = basename.replace(/(\^|\$|\(|\)|<|>|\[|\]|\{|\}|\.|\+|\?)/g, '\\$1'); - // Translates wildcard into regex - regexp = '^' + regexp.replace(/\*/g, '.*') + '$'; - // Iterate over directory contents - fs.readdirSync(dirname).forEach(function(file) { - if (file.match(new RegExp(regexp))) { - var file_path = path.join(dirname, file); - file_path = options.long ? ls_stat(file_path) : file_path; - if (file_path.name) - file_path.name = path.normalize(file_path.name); - else - file_path = path.normalize(file_path); - if (!pushFile(file_path, basename)) - return; - - // Recursive? - if (options.recursive) { - var pp = dirname + '/' + file; - if (fs.lstatSync(pp).isDirectory()) - list = list.concat(_ls('-R'+(options.all?'A':''), pp+'/*')); - } // recursive - } // if file matches - }); // forEach - return; - } - - common.error('no such file or directory: ' + p, true); }); + // Add methods, to make this more compatible with ShellStrings return list; } -module.exports = _ls; - -function ls_stat(path) { - var stats = fs.statSync(path); +function addLsAttributes(pathName, stats) { // Note: this object will contain more information than .toString() returns - stats.name = path; - stats.toString = function() { + stats.name = pathName; + stats.toString = function () { // Return a string resembling unix's `ls -l` format return [this.mode, this.nlink, this.uid, this.gid, this.size, this.mtime, this.name].join(' '); }; return stats; } + +module.exports = _ls; diff --git a/tools/eslint/node_modules/shelljs/src/mkdir.js b/tools/eslint/node_modules/shelljs/src/mkdir.js index 8b4fd99075053a..f211bc89b3fbaf 100644 --- a/tools/eslint/node_modules/shelljs/src/mkdir.js +++ b/tools/eslint/node_modules/shelljs/src/mkdir.js @@ -2,10 +2,23 @@ var common = require('./common'); var fs = require('fs'); var path = require('path'); +common.register('mkdir', _mkdir, { + cmdOptions: { + 'p': 'fullpath', + }, +}); + // Recursively creates 'dir' function mkdirSyncRecursive(dir) { var baseDir = path.dirname(dir); + // Prevents some potential problems arising from malformed UNCs or + // insufficient permissions. + /* istanbul ignore next */ + if (baseDir === dir) { + common.error('dirname() failed: [' + dir + ']'); + } + // Base dir exists, no recursion necessary if (fs.existsSync(baseDir)) { fs.mkdirSync(dir, parseInt('0777', 8)); @@ -35,34 +48,45 @@ function mkdirSyncRecursive(dir) { //@ //@ Creates directories. function _mkdir(options, dirs) { - options = common.parseOptions(options, { - 'p': 'fullpath' - }); - if (!dirs) - common.error('no paths given'); + if (!dirs) common.error('no paths given'); - if (typeof dirs === 'string') + if (typeof dirs === 'string') { dirs = [].slice.call(arguments, 1); + } // if it's array leave it as it is - dirs.forEach(function(dir) { - if (fs.existsSync(dir)) { - if (!options.fullpath) - common.error('path already exists: ' + dir, true); + dirs.forEach(function (dir) { + try { + fs.lstatSync(dir); + if (!options.fullpath) { + common.error('path already exists: ' + dir, { continue: true }); + } return; // skip dir + } catch (e) { + // do nothing } // Base dir does not exist, and no -p option given var baseDir = path.dirname(dir); if (!fs.existsSync(baseDir) && !options.fullpath) { - common.error('no such file or directory: ' + baseDir, true); + common.error('no such file or directory: ' + baseDir, { continue: true }); return; // skip dir } - if (options.fullpath) - mkdirSyncRecursive(dir); - else - fs.mkdirSync(dir, parseInt('0777', 8)); + try { + if (options.fullpath) { + mkdirSyncRecursive(dir); + } else { + fs.mkdirSync(dir, parseInt('0777', 8)); + } + } catch (e) { + if (e.code === 'EACCES') { + common.error('cannot create directory ' + dir + ': Permission denied'); + } else { + throw e; + } + } }); + return ''; } // mkdir module.exports = _mkdir; diff --git a/tools/eslint/node_modules/shelljs/src/mv.js b/tools/eslint/node_modules/shelljs/src/mv.js index 69cc03fe1ebe2b..c09bbbc76903c6 100644 --- a/tools/eslint/node_modules/shelljs/src/mv.js +++ b/tools/eslint/node_modules/shelljs/src/mv.js @@ -1,6 +1,15 @@ var fs = require('fs'); var path = require('path'); var common = require('./common'); +var cp = require('./cp'); +var rm = require('./rm'); + +common.register('mv', _mv, { + cmdOptions: { + 'f': '!no_force', + 'n': 'no_force', + }, +}); //@ //@ ### mv([options ,] source [, source ...], dest') @@ -18,13 +27,8 @@ var common = require('./common'); //@ mv(['file1', 'file2'], 'dir/'); // same as above //@ ``` //@ -//@ Moves files. The wildcard `*` is accepted. +//@ Moves files. function _mv(options, sources, dest) { - options = common.parseOptions(options, { - 'f': '!no_force', - 'n': 'no_force' - }); - // Get sources, dest if (arguments.length < 3) { common.error('missing and/or '); @@ -33,28 +37,26 @@ function _mv(options, sources, dest) { dest = arguments[arguments.length - 1]; } else if (typeof sources === 'string') { sources = [sources]; - } else if ('length' in sources) { - sources = sources; // no-op for array } else { common.error('invalid arguments'); } - sources = common.expand(sources); - - var exists = fs.existsSync(dest), - stats = exists && fs.statSync(dest); + var exists = fs.existsSync(dest); + var stats = exists && fs.statSync(dest); // Dest is not existing dir, but multiple sources given - if ((!exists || !stats.isDirectory()) && sources.length > 1) + if ((!exists || !stats.isDirectory()) && sources.length > 1) { common.error('dest is not a directory (too many sources)'); + } // Dest is an existing file, but no -f given - if (exists && stats.isFile() && options.no_force) + if (exists && stats.isFile() && options.no_force) { common.error('dest file already exists: ' + dest); + } - sources.forEach(function(src) { + sources.forEach(function (src) { if (!fs.existsSync(src)) { - common.error('no such file or directory: '+src, true); + common.error('no such file or directory: ' + src, { continue: true }); return; // skip file } @@ -63,20 +65,31 @@ function _mv(options, sources, dest) { // When copying to '/path/dir': // thisDest = '/path/dir/file1' var thisDest = dest; - if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) + if (fs.existsSync(dest) && fs.statSync(dest).isDirectory()) { thisDest = path.normalize(dest + '/' + path.basename(src)); + } if (fs.existsSync(thisDest) && options.no_force) { - common.error('dest file already exists: ' + thisDest, true); + common.error('dest file already exists: ' + thisDest, { continue: true }); return; // skip file } if (path.resolve(src) === path.dirname(path.resolve(thisDest))) { - common.error('cannot move to self: '+src, true); + common.error('cannot move to self: ' + src, { continue: true }); return; // skip file } - fs.renameSync(src, thisDest); + try { + fs.renameSync(src, thisDest); + } catch (e) { + if (e.code === 'EXDEV') { // external partition + // if either of these fails, the appropriate error message will bubble + // up to the top level automatically + cp('-r', src, thisDest); + rm('-rf', src); + } + } }); // forEach(src) + return ''; } // mv module.exports = _mv; diff --git a/tools/eslint/node_modules/shelljs/src/popd.js b/tools/eslint/node_modules/shelljs/src/popd.js index 11ea24fa464a04..d9eac3f56d1303 100644 --- a/tools/eslint/node_modules/shelljs/src/popd.js +++ b/tools/eslint/node_modules/shelljs/src/popd.js @@ -1 +1 @@ -// see dirs.js \ No newline at end of file +// see dirs.js diff --git a/tools/eslint/node_modules/shelljs/src/pushd.js b/tools/eslint/node_modules/shelljs/src/pushd.js index 11ea24fa464a04..d9eac3f56d1303 100644 --- a/tools/eslint/node_modules/shelljs/src/pushd.js +++ b/tools/eslint/node_modules/shelljs/src/pushd.js @@ -1 +1 @@ -// see dirs.js \ No newline at end of file +// see dirs.js diff --git a/tools/eslint/node_modules/shelljs/src/pwd.js b/tools/eslint/node_modules/shelljs/src/pwd.js index 26cefe0a0454d0..38618518b549f6 100644 --- a/tools/eslint/node_modules/shelljs/src/pwd.js +++ b/tools/eslint/node_modules/shelljs/src/pwd.js @@ -1,11 +1,15 @@ var path = require('path'); var common = require('./common'); +common.register('pwd', _pwd, { + allowGlobbing: false, +}); + //@ //@ ### pwd() //@ Returns the current directory. function _pwd() { var pwd = path.resolve(process.cwd()); - return common.ShellString(pwd); + return pwd; } module.exports = _pwd; diff --git a/tools/eslint/node_modules/shelljs/src/rm.js b/tools/eslint/node_modules/shelljs/src/rm.js index cf2e95b6d816bc..d6e484a085cfee 100644 --- a/tools/eslint/node_modules/shelljs/src/rm.js +++ b/tools/eslint/node_modules/shelljs/src/rm.js @@ -1,6 +1,14 @@ var common = require('./common'); var fs = require('fs'); +common.register('rm', _rm, { + cmdOptions: { + 'f': 'force', + 'r': 'recursive', + 'R': 'recursive', + }, +}); + // Recursively removes 'dir' // Adapted from https://github.com/ryanmcgrath/wrench-js // @@ -15,32 +23,21 @@ function rmdirSyncRecursive(dir, force) { files = fs.readdirSync(dir); // Loop through and delete everything in the sub-tree after checking it - for(var i = 0; i < files.length; i++) { - var file = dir + "/" + files[i], - currFile = fs.lstatSync(file); + for (var i = 0; i < files.length; i++) { + var file = dir + '/' + files[i]; + var currFile = fs.lstatSync(file); - if(currFile.isDirectory()) { // Recursive function back to the beginning + if (currFile.isDirectory()) { // Recursive function back to the beginning rmdirSyncRecursive(file, force); - } - - else if(currFile.isSymbolicLink()) { // Unlink symlinks + } else { // Assume it's a file - perhaps a try/catch belongs here? if (force || isWriteable(file)) { try { common.unlinkSync(file); } catch (e) { - common.error('could not remove file (code '+e.code+'): ' + file, true); + common.error('could not remove file (code ' + e.code + '): ' + file, { continue: true }); } } } - - else // Assume it's a file - perhaps a try/catch belongs here? - if (force || isWriteable(file)) { - try { - common.unlinkSync(file); - } catch (e) { - common.error('could not remove file (code '+e.code+'): ' + file, true); - } - } } // Now that we know everything in the sub-tree has been deleted, we can delete the main directory. @@ -53,13 +50,13 @@ function rmdirSyncRecursive(dir, force) { while (true) { try { result = fs.rmdirSync(dir); - if (fs.existsSync(dir)) throw { code: "EAGAIN" }; + if (fs.existsSync(dir)) throw { code: 'EAGAIN' }; break; - } catch(er) { + } catch (er) { // In addition to error codes, also check if the directory still exists and loop again if true - if (process.platform === "win32" && (er.code === "ENOTEMPTY" || er.code === "EBUSY" || er.code === "EPERM" || er.code === "EAGAIN")) { + if (process.platform === 'win32' && (er.code === 'ENOTEMPTY' || er.code === 'EBUSY' || er.code === 'EPERM' || er.code === 'EAGAIN')) { if (Date.now() - start > 1000) throw er; - } else if (er.code === "ENOENT") { + } else if (er.code === 'ENOENT') { // Directory did not exist, deletion was successful break; } else { @@ -67,8 +64,8 @@ function rmdirSyncRecursive(dir, force) { } } } - } catch(e) { - common.error('could not remove directory (code '+e.code+'): ' + dir, true); + } catch (e) { + common.error('could not remove directory (code ' + e.code + '): ' + dir, { continue: true }); } return result; @@ -81,7 +78,7 @@ function isWriteable(file) { try { var __fd = fs.openSync(file, 'a'); fs.closeSync(__fd); - } catch(e) { + } catch (e) { writePermission = false; } @@ -104,53 +101,45 @@ function isWriteable(file) { //@ rm(['some_file.txt', 'another_file.txt']); // same as above //@ ``` //@ -//@ Removes files. The wildcard `*` is accepted. +//@ Removes files. function _rm(options, files) { - options = common.parseOptions(options, { - 'f': 'force', - 'r': 'recursive', - 'R': 'recursive' - }); - if (!files) - common.error('no paths given'); - - if (typeof files === 'string') - files = [].slice.call(arguments, 1); - // if it's array leave it as it is + if (!files) common.error('no paths given'); - files = common.expand(files); + // Convert to array + files = [].slice.call(arguments, 1); - files.forEach(function(file) { - if (!fs.existsSync(file)) { + files.forEach(function (file) { + var stats; + try { + stats = fs.lstatSync(file); // test for existence + } catch (e) { // Path does not exist, no force flag given - if (!options.force) - common.error('no such file or directory: '+file, true); - + if (!options.force) { + common.error('no such file or directory: ' + file, { continue: true }); + } return; // skip file } // If here, path exists - - var stats = fs.lstatSync(file); if (stats.isFile() || stats.isSymbolicLink()) { - // Do not check for file writing permissions if (options.force) { common.unlinkSync(file); return; } - if (isWriteable(file)) + if (isWriteable(file)) { common.unlinkSync(file); - else - common.error('permission denied: '+file, true); + } else { + common.error('permission denied: ' + file, { continue: true }); + } return; } // simple file // Path is an existing directory, but no -r flag given if (stats.isDirectory() && !options.recursive) { - common.error('path is a directory', true); + common.error('path is a directory', { continue: true }); return; // skip path } @@ -159,5 +148,6 @@ function _rm(options, files) { rmdirSyncRecursive(file, options.force); } }); // forEach(file) + return ''; } // rm module.exports = _rm; diff --git a/tools/eslint/node_modules/shelljs/src/sed.js b/tools/eslint/node_modules/shelljs/src/sed.js index baa385ba1167d4..590ba74ffca2f7 100644 --- a/tools/eslint/node_modules/shelljs/src/sed.js +++ b/tools/eslint/node_modules/shelljs/src/sed.js @@ -1,6 +1,14 @@ var common = require('./common'); var fs = require('fs'); +common.register('sed', _sed, { + globStart: 3, // don't glob-expand regexes + canReceivePipe: true, + cmdOptions: { + 'i': 'inplace', + }, +}); + //@ //@ ### sed([options,] search_regex, replacement, file [, file ...]) //@ ### sed([options,] search_regex, replacement, file_array) @@ -18,47 +26,52 @@ var fs = require('fs'); //@ Reads an input string from `files` and performs a JavaScript `replace()` on the input //@ using the given search regex and replacement string or function. Returns the new string after replacement. function _sed(options, regex, replacement, files) { - options = common.parseOptions(options, { - 'i': 'inplace' - }); + // Check if this is coming from a pipe + var pipe = common.readFromPipe(); - if (typeof replacement === 'string' || typeof replacement === 'function') - replacement = replacement; // no-op - else if (typeof replacement === 'number') - replacement = replacement.toString(); // fallback - else - common.error('invalid replacement string'); + if (typeof replacement !== 'string' && typeof replacement !== 'function') { + if (typeof replacement === 'number') { + replacement = replacement.toString(); // fallback + } else { + common.error('invalid replacement string'); + } + } // Convert all search strings to RegExp - if (typeof regex === 'string') + if (typeof regex === 'string') { regex = RegExp(regex); + } - if (!files) + if (!files && !pipe) { common.error('no files given'); + } - if (typeof files === 'string') - files = [].slice.call(arguments, 3); - // if it's array leave it as it is + files = [].slice.call(arguments, 3); - files = common.expand(files); + if (pipe) { + files.unshift('-'); + } var sed = []; - files.forEach(function(file) { - if (!fs.existsSync(file)) { - common.error('no such file or directory: ' + file, true); + files.forEach(function (file) { + if (!fs.existsSync(file) && file !== '-') { + common.error('no such file or directory: ' + file, 2, { continue: true }); return; } - var result = fs.readFileSync(file, 'utf8').split('\n').map(function (line) { + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + var lines = contents.split(/\r*\n/); + var result = lines.map(function (line) { return line.replace(regex, replacement); }).join('\n'); sed.push(result); - if (options.inplace) + if (options.inplace) { fs.writeFileSync(file, result, 'utf8'); + } }); - return common.ShellString(sed.join('\n')); + return sed.join('\n'); } module.exports = _sed; diff --git a/tools/eslint/node_modules/shelljs/src/set.js b/tools/eslint/node_modules/shelljs/src/set.js index 19e26d979d3f4b..3402cd6609b06f 100644 --- a/tools/eslint/node_modules/shelljs/src/set.js +++ b/tools/eslint/node_modules/shelljs/src/set.js @@ -1,11 +1,17 @@ var common = require('./common'); +common.register('set', _set, { + allowGlobbing: false, + wrapOutput: false, +}); + //@ //@ ### set(options) //@ Available options: //@ //@ + `+/-e`: exit upon error (`config.fatal`) //@ + `+/-v`: verbose: show all commands (`config.verbose`) +//@ + `+/-f`: disable filename expansion (globbing) //@ //@ Examples: //@ @@ -18,8 +24,7 @@ var common = require('./common'); function _set(options) { if (!options) { var args = [].slice.call(arguments, 0); - if (args.length < 2) - common.error('must provide an argument'); + if (args.length < 2) common.error('must provide an argument'); options = args[1]; } var negate = (options[0] === '+'); @@ -28,22 +33,23 @@ function _set(options) { } options = common.parseOptions(options, { 'e': 'fatal', - 'v': 'verbose' + 'v': 'verbose', + 'f': 'noglob' }); - var key; if (negate) { - for (key in options) + Object.keys(options).forEach(function (key) { options[key] = !options[key]; + }); } - for (key in options) { + Object.keys(options).forEach(function (key) { // Only change the global config if `negate` is false and the option is true // or if `negate` is true and the option is false (aka negate !== option) if (negate !== options[key]) { common.config[key] = options[key]; } - } + }); return; } module.exports = _set; diff --git a/tools/eslint/node_modules/shelljs/src/sort.js b/tools/eslint/node_modules/shelljs/src/sort.js new file mode 100644 index 00000000000000..041b037725121c --- /dev/null +++ b/tools/eslint/node_modules/shelljs/src/sort.js @@ -0,0 +1,91 @@ +var common = require('./common'); +var fs = require('fs'); + +common.register('sort', _sort, { + canReceivePipe: true, + cmdOptions: { + 'r': 'reverse', + 'n': 'numerical', + }, +}); + +// parse out the number prefix of a line +function parseNumber(str) { + var match = str.match(/^\s*(\d*)\s*(.*)$/); + return { num: Number(match[1]), value: match[2] }; +} + +// compare two strings case-insensitively, but examine case for strings that are +// case-insensitive equivalent +function unixCmp(a, b) { + var aLower = a.toLowerCase(); + var bLower = b.toLowerCase(); + return (aLower === bLower ? + -1 * a.localeCompare(b) : // unix sort treats case opposite how javascript does + aLower.localeCompare(bLower)); +} + +// compare two strings in the fashion that unix sort's -n option works +function numericalCmp(a, b) { + var objA = parseNumber(a); + var objB = parseNumber(b); + if (objA.hasOwnProperty('num') && objB.hasOwnProperty('num')) { + return ((objA.num !== objB.num) ? + (objA.num - objB.num) : + unixCmp(objA.value, objB.value)); + } else { + return unixCmp(objA.value, objB.value); + } +} + +//@ +//@ ### sort([options,] file [, file ...]) +//@ ### sort([options,] file_array) +//@ Available options: +//@ +//@ + `-r`: Reverse the result of comparisons +//@ + `-n`: Compare according to numerical value +//@ +//@ Examples: +//@ +//@ ```javascript +//@ sort('foo.txt', 'bar.txt'); +//@ sort('-r', 'foo.txt'); +//@ ``` +//@ +//@ Return the contents of the files, sorted line-by-line. Sorting multiple +//@ files mixes their content, just like unix sort does. +function _sort(options, files) { + // Check if this is coming from a pipe + var pipe = common.readFromPipe(); + + if (!files && !pipe) common.error('no files given'); + + files = [].slice.call(arguments, 1); + + if (pipe) { + files.unshift('-'); + } + + var lines = []; + files.forEach(function (file) { + if (!fs.existsSync(file) && file !== '-') { + // exit upon any sort of error + common.error('no such file or directory: ' + file); + } + + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + lines = lines.concat(contents.trimRight().split(/\r*\n/)); + }); + + var sorted; + sorted = lines.sort(options.numerical ? numericalCmp : unixCmp); + + if (options.reverse) { + sorted = sorted.reverse(); + } + + return sorted.join('\n') + '\n'; +} + +module.exports = _sort; diff --git a/tools/eslint/node_modules/shelljs/src/tail.js b/tools/eslint/node_modules/shelljs/src/tail.js new file mode 100644 index 00000000000000..7ece654b1ea3a0 --- /dev/null +++ b/tools/eslint/node_modules/shelljs/src/tail.js @@ -0,0 +1,72 @@ +var common = require('./common'); +var fs = require('fs'); + +common.register('tail', _tail, { + canReceivePipe: true, + cmdOptions: { + 'n': 'numLines', + }, +}); + +//@ +//@ ### tail([{'-n': \},] file [, file ...]) +//@ ### tail([{'-n': \},] file_array) +//@ Available options: +//@ +//@ + `-n `: Show the last `` lines of the files +//@ +//@ Examples: +//@ +//@ ```javascript +//@ var str = tail({'-n': 1}, 'file*.txt'); +//@ var str = tail('file1', 'file2'); +//@ var str = tail(['file1', 'file2']); // same as above +//@ ``` +//@ +//@ Read the end of a file. +function _tail(options, files) { + var tail = []; + var pipe = common.readFromPipe(); + + if (!files && !pipe) common.error('no paths given'); + + var idx = 1; + if (options.numLines === true) { + idx = 2; + options.numLines = Number(arguments[1]); + } else if (options.numLines === false) { + options.numLines = 10; + } + options.numLines = -1 * Math.abs(options.numLines); + files = [].slice.call(arguments, idx); + + if (pipe) { + files.unshift('-'); + } + + var shouldAppendNewline = false; + files.forEach(function (file) { + if (!fs.existsSync(file) && file !== '-') { + common.error('no such file or directory: ' + file, { continue: true }); + return; + } + + var contents = file === '-' ? pipe : fs.readFileSync(file, 'utf8'); + + var lines = contents.split('\n'); + if (lines[lines.length - 1] === '') { + lines.pop(); + shouldAppendNewline = true; + } else { + shouldAppendNewline = false; + } + + tail = tail.concat(lines.slice(options.numLines)); + }); + + if (shouldAppendNewline) { + tail.push(''); // to add a trailing newline once we join + } + return tail.join('\n'); +} +module.exports = _tail; diff --git a/tools/eslint/node_modules/shelljs/src/tempdir.js b/tools/eslint/node_modules/shelljs/src/tempdir.js index 79b949f0d4f15b..cfd56b3792e427 100644 --- a/tools/eslint/node_modules/shelljs/src/tempdir.js +++ b/tools/eslint/node_modules/shelljs/src/tempdir.js @@ -2,15 +2,18 @@ var common = require('./common'); var os = require('os'); var fs = require('fs'); +common.register('tempdir', _tempDir, { + allowGlobbing: false, + wrapOutput: false, +}); + // Returns false if 'dir' is not a writeable directory, 'dir' otherwise function writeableDir(dir) { - if (!dir || !fs.existsSync(dir)) - return false; + if (!dir || !fs.existsSync(dir)) return false; - if (!fs.statSync(dir).isDirectory()) - return false; + if (!fs.statSync(dir).isDirectory()) return false; - var testFile = dir+'/'+common.randomFileName(); + var testFile = dir + '/' + common.randomFileName(); try { fs.writeFileSync(testFile, ' '); common.unlinkSync(testFile); @@ -34,15 +37,14 @@ function writeableDir(dir) { //@ Follows Python's [tempfile algorithm](http://docs.python.org/library/tempfile.html#tempfile.tempdir). function _tempDir() { var state = common.state; - if (state.tempDir) - return state.tempDir; // from cache + if (state.tempDir) return state.tempDir; // from cache state.tempDir = writeableDir(os.tmpdir && os.tmpdir()) || // node 0.10+ writeableDir(os.tmpDir && os.tmpDir()) || // node 0.8+ - writeableDir(process.env['TMPDIR']) || - writeableDir(process.env['TEMP']) || - writeableDir(process.env['TMP']) || - writeableDir(process.env['Wimp$ScrapDir']) || // RiscOS + writeableDir(process.env.TMPDIR) || + writeableDir(process.env.TEMP) || + writeableDir(process.env.TMP) || + writeableDir(process.env.Wimp$ScrapDir) || // RiscOS writeableDir('C:\\TEMP') || // Windows writeableDir('C:\\TMP') || // Windows writeableDir('\\TEMP') || // Windows diff --git a/tools/eslint/node_modules/shelljs/src/test.js b/tools/eslint/node_modules/shelljs/src/test.js index 068a1ce06ef4c9..3fb38aec43992d 100644 --- a/tools/eslint/node_modules/shelljs/src/test.js +++ b/tools/eslint/node_modules/shelljs/src/test.js @@ -1,6 +1,22 @@ var common = require('./common'); var fs = require('fs'); +common.register('test', _test, { + cmdOptions: { + 'b': 'block', + 'c': 'character', + 'd': 'directory', + 'e': 'exists', + 'f': 'file', + 'L': 'link', + 'p': 'pipe', + 'S': 'socket', + }, + wrapOutput: false, + allowGlobbing: false, +}); + + //@ //@ ### test(expression) //@ Available expression primaries: @@ -23,63 +39,43 @@ var fs = require('fs'); //@ //@ Evaluates expression using the available primaries and returns corresponding value. function _test(options, path) { - if (!path) - common.error('no path given'); - - // hack - only works with unary primaries - options = common.parseOptions(options, { - 'b': 'block', - 'c': 'character', - 'd': 'directory', - 'e': 'exists', - 'f': 'file', - 'L': 'link', - 'p': 'pipe', - 'S': 'socket' - }); + if (!path) common.error('no path given'); var canInterpret = false; - for (var key in options) + Object.keys(options).forEach(function (key) { if (options[key] === true) { canInterpret = true; - break; } + }); - if (!canInterpret) - common.error('could not interpret expression'); + if (!canInterpret) common.error('could not interpret expression'); if (options.link) { try { return fs.lstatSync(path).isSymbolicLink(); - } catch(e) { + } catch (e) { return false; } } - if (!fs.existsSync(path)) - return false; + if (!fs.existsSync(path)) return false; - if (options.exists) - return true; + if (options.exists) return true; var stats = fs.statSync(path); - if (options.block) - return stats.isBlockDevice(); + if (options.block) return stats.isBlockDevice(); + + if (options.character) return stats.isCharacterDevice(); - if (options.character) - return stats.isCharacterDevice(); + if (options.directory) return stats.isDirectory(); - if (options.directory) - return stats.isDirectory(); + if (options.file) return stats.isFile(); - if (options.file) - return stats.isFile(); + if (options.pipe) return stats.isFIFO(); - if (options.pipe) - return stats.isFIFO(); + if (options.socket) return stats.isSocket(); - if (options.socket) - return stats.isSocket(); + return false; // fallback } // test module.exports = _test; diff --git a/tools/eslint/node_modules/shelljs/src/to.js b/tools/eslint/node_modules/shelljs/src/to.js index 65d6d54af90837..99f194e687b460 100644 --- a/tools/eslint/node_modules/shelljs/src/to.js +++ b/tools/eslint/node_modules/shelljs/src/to.js @@ -2,8 +2,13 @@ var common = require('./common'); var fs = require('fs'); var path = require('path'); +common.register('to', _to, { + pipeOnly: true, + wrapOutput: false, +}); + //@ -//@ ### 'string'.to(file) +//@ ### ShellString.prototype.to(file) //@ //@ Examples: //@ @@ -11,20 +16,21 @@ var path = require('path'); //@ cat('input.txt').to('output.txt'); //@ ``` //@ -//@ Analogous to the redirection operator `>` in Unix, but works with JavaScript strings (such as -//@ those returned by `cat`, `grep`, etc). _Like Unix redirections, `to()` will overwrite any existing file!_ +//@ Analogous to the redirection operator `>` in Unix, but works with +//@ ShellStrings (such as those returned by `cat`, `grep`, etc). _Like Unix +//@ redirections, `to()` will overwrite any existing file!_ function _to(options, file) { - if (!file) - common.error('wrong arguments'); + if (!file) common.error('wrong arguments'); - if (!fs.existsSync( path.dirname(file) )) - common.error('no such file or directory: ' + path.dirname(file)); + if (!fs.existsSync(path.dirname(file))) { + common.error('no such file or directory: ' + path.dirname(file)); + } try { - fs.writeFileSync(file, this.toString(), 'utf8'); + fs.writeFileSync(file, this.stdout || this.toString(), 'utf8'); return this; - } catch(e) { - common.error('could not write to file (code '+e.code+'): '+file, true); + } catch (e) { + common.error('could not write to file (code ' + e.code + '): ' + file, { continue: true }); } } module.exports = _to; diff --git a/tools/eslint/node_modules/shelljs/src/toEnd.js b/tools/eslint/node_modules/shelljs/src/toEnd.js index bf29a6526d0f97..cf91c9401c4ced 100644 --- a/tools/eslint/node_modules/shelljs/src/toEnd.js +++ b/tools/eslint/node_modules/shelljs/src/toEnd.js @@ -2,8 +2,13 @@ var common = require('./common'); var fs = require('fs'); var path = require('path'); +common.register('toEnd', _toEnd, { + pipeOnly: true, + wrapOutput: false, +}); + //@ -//@ ### 'string'.toEnd(file) +//@ ### ShellString.prototype.toEnd(file) //@ //@ Examples: //@ @@ -11,20 +16,20 @@ var path = require('path'); //@ cat('input.txt').toEnd('output.txt'); //@ ``` //@ -//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with JavaScript strings (such as -//@ those returned by `cat`, `grep`, etc). +//@ Analogous to the redirect-and-append operator `>>` in Unix, but works with +//@ ShellStrings (such as those returned by `cat`, `grep`, etc). function _toEnd(options, file) { - if (!file) - common.error('wrong arguments'); + if (!file) common.error('wrong arguments'); - if (!fs.existsSync( path.dirname(file) )) - common.error('no such file or directory: ' + path.dirname(file)); + if (!fs.existsSync(path.dirname(file))) { + common.error('no such file or directory: ' + path.dirname(file)); + } try { - fs.appendFileSync(file, this.toString(), 'utf8'); + fs.appendFileSync(file, this.stdout || this.toString(), 'utf8'); return this; - } catch(e) { - common.error('could not append to file (code '+e.code+'): '+file, true); + } catch (e) { + common.error('could not append to file (code ' + e.code + '): ' + file, { continue: true }); } } module.exports = _toEnd; diff --git a/tools/eslint/node_modules/shelljs/src/touch.js b/tools/eslint/node_modules/shelljs/src/touch.js index bbc2c1968654ab..b672b2d25528b4 100644 --- a/tools/eslint/node_modules/shelljs/src/touch.js +++ b/tools/eslint/node_modules/shelljs/src/touch.js @@ -1,8 +1,19 @@ var common = require('./common'); var fs = require('fs'); +common.register('touch', _touch, { + cmdOptions: { + 'a': 'atime_only', + 'c': 'no_create', + 'd': 'date', + 'm': 'mtime_only', + 'r': 'reference', + }, +}); + //@ -//@ ### touch([options,] file) +//@ ### touch([options,] file [, file ...]) +//@ ### touch([options,] file_array) //@ Available options: //@ //@ + `-a`: Change only the access time @@ -23,28 +34,18 @@ var fs = require('fs'); //@ A FILE argument that does not exist is created empty, unless -c is supplied. //@ This is a partial implementation of *[touch(1)](http://linux.die.net/man/1/touch)*. function _touch(opts, files) { - opts = common.parseOptions(opts, { - 'a': 'atime_only', - 'c': 'no_create', - 'd': 'date', - 'm': 'mtime_only', - 'r': 'reference', - }); - if (!files) { - common.error('no paths given'); - } - - if (Array.isArray(files)) { - files.forEach(function(f) { - touchFile(opts, f); - }); + common.error('no files given'); } else if (typeof files === 'string') { - touchFile(opts, files); + files = [].slice.call(arguments, 1); } else { common.error('file arg should be a string file path or an Array of string file paths'); } + files.forEach(function (f) { + touchFile(opts, f); + }); + return ''; } function touchFile(opts, file) { diff --git a/tools/eslint/node_modules/shelljs/src/uniq.js b/tools/eslint/node_modules/shelljs/src/uniq.js new file mode 100644 index 00000000000000..8f5da00285a3a5 --- /dev/null +++ b/tools/eslint/node_modules/shelljs/src/uniq.js @@ -0,0 +1,80 @@ +var common = require('./common'); +var fs = require('fs'); + +// add c spaces to the left of str +function lpad(c, str) { + var res = '' + str; + if (res.length < c) { + res = Array((c - res.length) + 1).join(' ') + res; + } + return res; +} + +common.register('uniq', _uniq, { + canReceivePipe: true, + cmdOptions: { + 'i': 'ignoreCase', + 'c': 'count', + 'd': 'duplicates', + }, +}); + +//@ +//@ ### uniq([options,] [input, [output]]) +//@ Available options: +//@ +//@ + `-i`: Ignore case while comparing +//@ + `-c`: Prefix lines by the number of occurrences +//@ + `-d`: Only print duplicate lines, one for each group of identical lines +//@ +//@ Examples: +//@ +//@ ```javascript +//@ uniq('foo.txt'); +//@ uniq('-i', 'foo.txt'); +//@ uniq('-cd', 'foo.txt', 'bar.txt'); +//@ ``` +//@ +//@ Filter adjacent matching lines from input +function _uniq(options, input, output) { + // Check if this is coming from a pipe + var pipe = common.readFromPipe(); + + if (!input && !pipe) common.error('no input given'); + + var lines = (input ? fs.readFileSync(input, 'utf8') : pipe). + trimRight(). + split(/\r*\n/); + + var compare = function (a, b) { + return options.ignoreCase ? + a.toLocaleLowerCase().localeCompare(b.toLocaleLowerCase()) : + a.localeCompare(b); + }; + var uniqed = lines.reduceRight(function (res, e) { + // Perform uniq -c on the input + if (res.length === 0) { + return [{ count: 1, ln: e }]; + } else if (compare(res[0].ln, e) === 0) { + return [{ count: res[0].count + 1, ln: e }].concat(res.slice(1)); + } else { + return [{ count: 1, ln: e }].concat(res); + } + }, []).filter(function (obj) { + // Do we want only duplicated objects? + return options.duplicates ? obj.count > 1 : true; + }).map(function (obj) { + // Are we tracking the counts of each line? + return (options.count ? (lpad(7, obj.count) + ' ') : '') + obj.ln; + }).join('\n') + '\n'; + + if (output) { + (new common.ShellString(uniqed)).to(output); + // if uniq writes to output, nothing is passed to the next command in the pipeline (if any) + return ''; + } else { + return uniqed; + } +} + +module.exports = _uniq; diff --git a/tools/eslint/node_modules/shelljs/src/which.js b/tools/eslint/node_modules/shelljs/src/which.js index d17634ee941d96..ef5d185eb0e462 100644 --- a/tools/eslint/node_modules/shelljs/src/which.js +++ b/tools/eslint/node_modules/shelljs/src/which.js @@ -2,23 +2,27 @@ var common = require('./common'); var fs = require('fs'); var path = require('path'); +common.register('which', _which, { + allowGlobbing: false, +}); + // XP's system default value for PATHEXT system variable, just in case it's not // set on Windows. var XP_DEFAULT_PATHEXT = '.com;.exe;.bat;.cmd;.vbs;.vbe;.js;.jse;.wsf;.wsh'; // Cross-platform method for splitting environment PATH variables function splitPath(p) { - if (!p) - return []; + if (!p) return []; - if (common.platform === 'win') + if (common.platform === 'win') { return p.split(';'); - else + } else { return p.split(':'); + } } -function checkPath(path) { - return fs.existsSync(path) && !fs.statSync(path).isDirectory(); +function checkPath(pathName) { + return fs.existsSync(pathName) && !fs.statSync(pathName).isDirectory(); } //@ @@ -34,19 +38,17 @@ function checkPath(path) { //@ `PATHEXT` variable to append the extension if it's not already executable. //@ Returns string containing the absolute path to the command. function _which(options, cmd) { - if (!cmd) - common.error('must specify command'); + if (!cmd) common.error('must specify command'); - var pathEnv = process.env.path || process.env.Path || process.env.PATH, - pathArray = splitPath(pathEnv), - where = null; + var pathEnv = process.env.path || process.env.Path || process.env.PATH; + var pathArray = splitPath(pathEnv); + var where = null; // No relative/absolute paths provided? if (cmd.search(/\//) === -1) { // Search for command in PATH - pathArray.forEach(function(dir) { - if (where) - return; // already found it + pathArray.forEach(function (dir) { + if (where) return; // already found it var attempt = path.resolve(dir, cmd); @@ -88,11 +90,10 @@ function _which(options, cmd) { } // Command not found anywhere? - if (!checkPath(cmd) && !where) - return null; + if (!checkPath(cmd) && !where) return null; where = where || path.resolve(cmd); - return common.ShellString(where); + return where; } module.exports = _which; diff --git a/tools/eslint/node_modules/string-width/package.json b/tools/eslint/node_modules/string-width/package.json index 6fc310fca4230d..b0e9dfdea93cf7 100644 --- a/tools/eslint/node_modules/string-width/package.json +++ b/tools/eslint/node_modules/string-width/package.json @@ -38,8 +38,7 @@ "type": "range" }, "_requiredBy": [ - "/inquirer", - "/table" + "/inquirer" ], "_resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz", "_shasum": "118bdf5b8cdc51a2a7e70d211e07e2b0b9b107d3", diff --git a/tools/eslint/node_modules/strip-ansi/package.json b/tools/eslint/node_modules/strip-ansi/package.json index dced2726e06f26..323a21ebb41a8c 100644 --- a/tools/eslint/node_modules/strip-ansi/package.json +++ b/tools/eslint/node_modules/strip-ansi/package.json @@ -40,7 +40,8 @@ "_requiredBy": [ "/chalk", "/inquirer", - "/string-width" + "/string-width", + "/table/string-width" ], "_resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", "_shasum": "6a385fb8853d952d5ff05d0e8aaf94278dc63dcf", diff --git a/tools/eslint/node_modules/strip-json-comments/cli.js b/tools/eslint/node_modules/strip-json-comments/cli.js deleted file mode 100755 index aec5aa20e4a073..00000000000000 --- a/tools/eslint/node_modules/strip-json-comments/cli.js +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env node -'use strict'; -var fs = require('fs'); -var strip = require('./strip-json-comments'); -var input = process.argv[2]; - - -function getStdin(cb) { - var ret = ''; - - process.stdin.setEncoding('utf8'); - - process.stdin.on('data', function (data) { - ret += data; - }); - - process.stdin.on('end', function () { - cb(ret); - }); -} - -if (process.argv.indexOf('-h') !== -1 || process.argv.indexOf('--help') !== -1) { - console.log('strip-json-comments input-file > output-file'); - console.log('or'); - console.log('strip-json-comments < input-file > output-file'); - return; -} - -if (process.argv.indexOf('-v') !== -1 || process.argv.indexOf('--version') !== -1) { - console.log(require('./package').version); - return; -} - -if (input) { - process.stdout.write(strip(fs.readFileSync(input, 'utf8'))); - return; -} - -getStdin(function (data) { - process.stdout.write(strip(data)); -}); diff --git a/tools/eslint/node_modules/strip-json-comments/index.js b/tools/eslint/node_modules/strip-json-comments/index.js new file mode 100644 index 00000000000000..4e6576e6d3c388 --- /dev/null +++ b/tools/eslint/node_modules/strip-json-comments/index.js @@ -0,0 +1,70 @@ +'use strict'; +var singleComment = 1; +var multiComment = 2; + +function stripWithoutWhitespace() { + return ''; +} + +function stripWithWhitespace(str, start, end) { + return str.slice(start, end).replace(/\S/g, ' '); +} + +module.exports = function (str, opts) { + opts = opts || {}; + + var currentChar; + var nextChar; + var insideString = false; + var insideComment = false; + var offset = 0; + var ret = ''; + var strip = opts.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace; + + for (var i = 0; i < str.length; i++) { + currentChar = str[i]; + nextChar = str[i + 1]; + + if (!insideComment && currentChar === '"') { + var escaped = str[i - 1] === '\\' && str[i - 2] !== '\\'; + if (!escaped) { + insideString = !insideString; + } + } + + if (insideString) { + continue; + } + + if (!insideComment && currentChar + nextChar === '//') { + ret += str.slice(offset, i); + offset = i; + insideComment = singleComment; + i++; + } else if (insideComment === singleComment && currentChar + nextChar === '\r\n') { + i++; + insideComment = false; + ret += strip(str, offset, i); + offset = i; + continue; + } else if (insideComment === singleComment && currentChar === '\n') { + insideComment = false; + ret += strip(str, offset, i); + offset = i; + } else if (!insideComment && currentChar + nextChar === '/*') { + ret += str.slice(offset, i); + offset = i; + insideComment = multiComment; + i++; + continue; + } else if (insideComment === multiComment && currentChar + nextChar === '*/') { + i++; + insideComment = false; + ret += strip(str, offset, i + 1); + offset = i + 1; + continue; + } + } + + return ret + (insideComment ? strip(str.substr(offset)) : str.substr(offset)); +}; diff --git a/tools/eslint/node_modules/strip-json-comments/package.json b/tools/eslint/node_modules/strip-json-comments/package.json index de43cb650fbdcb..6bbd9d717fbf7b 100644 --- a/tools/eslint/node_modules/strip-json-comments/package.json +++ b/tools/eslint/node_modules/strip-json-comments/package.json @@ -2,75 +2,76 @@ "_args": [ [ { - "raw": "strip-json-comments@~1.0.1", + "raw": "strip-json-comments@~2.0.1", "scope": null, "escapedName": "strip-json-comments", "name": "strip-json-comments", - "rawSpec": "~1.0.1", - "spec": ">=1.0.1 <1.1.0", + "rawSpec": "~2.0.1", + "spec": ">=2.0.1 <2.1.0", "type": "range" }, "/Users/trott/io.js/tools/node_modules/eslint" ] ], - "_from": "strip-json-comments@>=1.0.1 <1.1.0", - "_id": "strip-json-comments@1.0.4", + "_from": "strip-json-comments@>=2.0.1 <2.1.0", + "_id": "strip-json-comments@2.0.1", "_inCache": true, "_location": "/strip-json-comments", - "_nodeVersion": "0.12.5", + "_nodeVersion": "4.2.4", + "_npmOperationalInternal": { + "host": "packages-9-west.internal.npmjs.com", + "tmp": "tmp/strip-json-comments-2.0.1.tgz_1455006605207_0.8280157081317157" + }, "_npmUser": { "name": "sindresorhus", "email": "sindresorhus@gmail.com" }, - "_npmVersion": "2.11.2", + "_npmVersion": "3.7.2", "_phantomChildren": {}, "_requested": { - "raw": "strip-json-comments@~1.0.1", + "raw": "strip-json-comments@~2.0.1", "scope": null, "escapedName": "strip-json-comments", "name": "strip-json-comments", - "rawSpec": "~1.0.1", - "spec": ">=1.0.1 <1.1.0", + "rawSpec": "~2.0.1", + "spec": ">=2.0.1 <2.1.0", "type": "range" }, "_requiredBy": [ "/eslint" ], - "_resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz", - "_shasum": "1e15fbcac97d3ee99bf2d73b4c656b082bbafb91", + "_resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz", + "_shasum": "3c531942e908c2697c0ec344858c286c7ca0a60a", "_shrinkwrap": null, - "_spec": "strip-json-comments@~1.0.1", + "_spec": "strip-json-comments@~2.0.1", "_where": "/Users/trott/io.js/tools/node_modules/eslint", "author": { "name": "Sindre Sorhus", "email": "sindresorhus@gmail.com", "url": "sindresorhus.com" }, - "bin": { - "strip-json-comments": "cli.js" - }, "bugs": { "url": "https://github.com/sindresorhus/strip-json-comments/issues" }, "dependencies": {}, "description": "Strip comments from JSON. Lets you use comments in your JSON files!", "devDependencies": { - "mocha": "*" + "ava": "*", + "xo": "*" }, "directories": {}, "dist": { - "shasum": "1e15fbcac97d3ee99bf2d73b4c656b082bbafb91", - "tarball": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-1.0.4.tgz" + "shasum": "3c531942e908c2697c0ec344858c286c7ca0a60a", + "tarball": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz" }, "engines": { - "node": ">=0.8.0" + "node": ">=0.10.0" }, "files": [ - "cli.js", - "strip-json-comments.js" + "index.js" ], - "gitHead": "f58348696368583cc5bb18525fe31eacc9bd00e1", - "homepage": "https://github.com/sindresorhus/strip-json-comments", + "gitHead": "1aef99eaa70d07981156e8aaa722e750c3b4eaf9", + "homepage": "https://github.com/sindresorhus/strip-json-comments#readme", "keywords": [ "json", "strip", @@ -86,12 +87,9 @@ "settings", "util", "env", - "environment", - "cli", - "bin" + "environment" ], "license": "MIT", - "main": "strip-json-comments", "maintainers": [ { "name": "sindresorhus", @@ -106,7 +104,7 @@ "url": "git+https://github.com/sindresorhus/strip-json-comments.git" }, "scripts": { - "test": "mocha --ui tdd" + "test": "xo && ava" }, - "version": "1.0.4" + "version": "2.0.1" } diff --git a/tools/eslint/node_modules/strip-json-comments/readme.md b/tools/eslint/node_modules/strip-json-comments/readme.md index 63ce165b23809f..0ee58dfe3a2e9b 100644 --- a/tools/eslint/node_modules/strip-json-comments/readme.md +++ b/tools/eslint/node_modules/strip-json-comments/readme.md @@ -11,34 +11,23 @@ This is now possible: } ``` -It will remove single-line comments `//` and multi-line comments `/**/`. +It will replace single-line comments `//` and multi-line comments `/**/` with whitespace. This allows JSON error positions to remain as close as possible to the original source. Also available as a [gulp](https://github.com/sindresorhus/gulp-strip-json-comments)/[grunt](https://github.com/sindresorhus/grunt-strip-json-comments)/[broccoli](https://github.com/sindresorhus/broccoli-strip-json-comments) plugin. -- - -*There's also [`json-comments`](https://npmjs.org/package/json-comments), but it's only for Node.js, inefficient, bloated as it also minifies, and comes with a `require` hook, which is :(* - ## Install -```sh -$ npm install --save strip-json-comments -``` - -```sh -$ bower install --save strip-json-comments ``` - -```sh -$ component install sindresorhus/strip-json-comments +$ npm install --save strip-json-comments ``` ## Usage ```js -var json = '{/*rainbows*/"unicorn":"cake"}'; +const json = '{/*rainbows*/"unicorn":"cake"}'; + JSON.parse(stripJsonComments(json)); //=> {unicorn: 'cake'} ``` @@ -46,7 +35,7 @@ JSON.parse(stripJsonComments(json)); ## API -### stripJsonComments(input) +### stripJsonComments(input, [options]) #### input @@ -54,25 +43,20 @@ Type: `string` Accepts a string with JSON and returns a string without comments. +#### options -## CLI +##### whitespace -```sh -$ npm install --global strip-json-comments -``` +Type: `boolean` +Default: `true` -```sh -$ strip-json-comments --help - -strip-json-comments input-file > output-file -# or -strip-json-comments < input-file > output-file -``` +Replace comments with whitespace instead of stripping them entirely. ## Related -- [`strip-css-comments`](https://github.com/sindresorhus/strip-css-comments) +- [strip-json-comments-cli](https://github.com/sindresorhus/strip-json-comments-cli) - CLI for this module +- [strip-css-comments](https://github.com/sindresorhus/strip-css-comments) - Strip comments from CSS ## License diff --git a/tools/eslint/node_modules/strip-json-comments/strip-json-comments.js b/tools/eslint/node_modules/strip-json-comments/strip-json-comments.js deleted file mode 100644 index eb77ce7456b8e5..00000000000000 --- a/tools/eslint/node_modules/strip-json-comments/strip-json-comments.js +++ /dev/null @@ -1,73 +0,0 @@ -/*! - strip-json-comments - Strip comments from JSON. Lets you use comments in your JSON files! - https://github.com/sindresorhus/strip-json-comments - by Sindre Sorhus - MIT License -*/ -(function () { - 'use strict'; - - var singleComment = 1; - var multiComment = 2; - - function stripJsonComments(str) { - var currentChar; - var nextChar; - var insideString = false; - var insideComment = false; - var ret = ''; - - for (var i = 0; i < str.length; i++) { - currentChar = str[i]; - nextChar = str[i + 1]; - - if (!insideComment && currentChar === '"') { - var escaped = str[i - 1] === '\\' && str[i - 2] !== '\\'; - if (!insideComment && !escaped && currentChar === '"') { - insideString = !insideString; - } - } - - if (insideString) { - ret += currentChar; - continue; - } - - if (!insideComment && currentChar + nextChar === '//') { - insideComment = singleComment; - i++; - } else if (insideComment === singleComment && currentChar + nextChar === '\r\n') { - insideComment = false; - i++; - ret += currentChar; - ret += nextChar; - continue; - } else if (insideComment === singleComment && currentChar === '\n') { - insideComment = false; - } else if (!insideComment && currentChar + nextChar === '/*') { - insideComment = multiComment; - i++; - continue; - } else if (insideComment === multiComment && currentChar + nextChar === '*/') { - insideComment = false; - i++; - continue; - } - - if (insideComment) { - continue; - } - - ret += currentChar; - } - - return ret; - } - - if (typeof module !== 'undefined' && module.exports) { - module.exports = stripJsonComments; - } else { - window.stripJsonComments = stripJsonComments; - } -})(); diff --git a/tools/eslint/node_modules/table/dist/alignString.js.map b/tools/eslint/node_modules/table/dist/alignString.js.map deleted file mode 100644 index 9d6e8b84e39b13..00000000000000 --- a/tools/eslint/node_modules/table/dist/alignString.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["alignString.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA;;;;;;AAEA,IAAI,oBAAJ;IACI,kBADJ;IAEI,mBAFJ;IAGI,mBAHJ;;AAKA,aAAa,CACT,MADS,EAET,OAFS,EAGT,QAHS,CAAb;;;;;;;AAWA,YAAY,mBAAC,OAAD,EAAU,KAAV,EAAoB;AAC5B,WAAO,UAAU,sBAAS,GAAT,EAAc,KAAd,CAAjB;AACH,CAFD;;;;;;;AASA,aAAa,oBAAC,OAAD,EAAU,KAAV,EAAoB;AAC7B,WAAO,sBAAS,GAAT,EAAc,KAAd,IAAuB,OAA9B;AACH,CAFD;;;;;;;AASA,cAAc,qBAAC,OAAD,EAAU,KAAV,EAAoB;AAC9B,QAAI,kBAAJ;;AAEA,gBAAY,QAAQ,CAApB;;AAEA,QAAI,YAAY,CAAZ,KAAkB,CAAtB,EAAyB;AACrB,eAAO,sBAAS,GAAT,EAAc,SAAd,IAA2B,OAA3B,GAAqC,sBAAS,GAAT,EAAc,SAAd,CAA5C;AACH,KAFD,MAEO;AACH,oBAAY,qBAAQ,SAAR,CAAZ;;AAEA,eAAO,sBAAS,GAAT,EAAc,SAAd,IAA2B,OAA3B,GAAqC,sBAAS,GAAT,EAAc,YAAY,CAA1B,CAA5C;AACH;AACJ,CAZD;;;;;;;;;;;;kBAuBe,UAAC,OAAD,EAAU,cAAV,EAA0B,SAA1B,EAAwC;AACnD,QAAI,uBAAJ;QACI,qBADJ;;AAGA,QAAI,CAAC,wBAAW,OAAX,CAAL,EAA0B;AACtB,cAAM,IAAI,KAAJ,CAAU,2CAAV,CAAN;AACH;;AAED,QAAI,CAAC,wBAAW,cAAX,CAAL,EAAiC;AAC7B,cAAM,IAAI,KAAJ,CAAU,mDAAV,CAAN;AACH;;AAED,mBAAe,2BAAY,OAAZ,CAAf;;AAEA,QAAI,eAAe,cAAnB,EAAmC;;;AAG/B,cAAM,IAAI,KAAJ,CAAU,2EAAV,CAAN;AACH;;AAED,QAAI,CAAC,wBAAW,SAAX,CAAL,EAA4B;AACxB,cAAM,IAAI,KAAJ,CAAU,6CAAV,CAAN;AACH;;AAED,QAAI,WAAW,OAAX,CAAmB,SAAnB,MAAkC,CAAC,CAAvC,EAA0C;AACtC,cAAM,IAAI,KAAJ,CAAU,4FAAV,CAAN;AACH;;AAED,QAAI,iBAAiB,CAArB,EAAwB;AACpB,eAAO,sBAAS,GAAT,EAAc,cAAd,CAAP;AACH;;AAED,qBAAiB,iBAAiB,YAAlC;;AAEA,QAAI,cAAc,MAAlB,EAA0B;AACtB,eAAO,UAAU,OAAV,EAAmB,cAAnB,CAAP;AACH;;AAED,QAAI,cAAc,OAAlB,EAA2B;AACvB,eAAO,WAAW,OAAX,EAAoB,cAApB,CAAP;AACH;;AAED,WAAO,YAAY,OAAZ,EAAqB,cAArB,CAAP;AACH,C","file":"alignString.js","sourcesContent":["import _ from 'lodash';\nimport stringWidth from 'string-width';\n\nlet alignCenter,\n alignLeft,\n alignRight,\n alignments;\n\nalignments = [\n 'left',\n 'right',\n 'center'\n];\n\n/**\n * @param {string} subject\n * @param {number} width\n * @returns {string}\n */\nalignLeft = (subject, width) => {\n return subject + _.repeat(' ', width);\n};\n\n/**\n * @param {string} subject\n * @param {number} width\n * @returns {string}\n */\nalignRight = (subject, width) => {\n return _.repeat(' ', width) + subject;\n};\n\n/**\n * @param {string} subject\n * @param {number} width\n * @returns {string}\n */\nalignCenter = (subject, width) => {\n let halfWidth;\n\n halfWidth = width / 2;\n\n if (halfWidth % 2 === 0) {\n return _.repeat(' ', halfWidth) + subject + _.repeat(' ', halfWidth);\n } else {\n halfWidth = _.floor(halfWidth);\n\n return _.repeat(' ', halfWidth) + subject + _.repeat(' ', halfWidth + 1);\n }\n};\n\n/**\n * Pads a string to the left and/or right to position the subject\n * text in a desired alignment within a container.\n *\n * @param {string} subject\n * @param {number} containerWidth\n * @param {string} alignment One of the valid options (left, right, center).\n * @returns {string}\n */\nexport default (subject, containerWidth, alignment) => {\n let availableWidth,\n subjectWidth;\n\n if (!_.isString(subject)) {\n throw new Error('Subject parameter value must be a string.');\n }\n\n if (!_.isNumber(containerWidth)) {\n throw new Error('Container width parameter value must be a number.');\n }\n\n subjectWidth = stringWidth(subject);\n\n if (subjectWidth > containerWidth) {\n // console.log('subjectWidth', subjectWidth, 'containerWidth', containerWidth, 'subject', subject);\n\n throw new Error('Subject parameter value width cannot be greater than the container width.');\n }\n\n if (!_.isString(alignment)) {\n throw new Error('Alignment parameter value must be a string.');\n }\n\n if (alignments.indexOf(alignment) === -1) {\n throw new Error('Alignment parameter value must be a known alignment parameter value (left, right, center).');\n }\n\n if (subjectWidth === 0) {\n return _.repeat(' ', containerWidth);\n }\n\n availableWidth = containerWidth - subjectWidth;\n\n if (alignment === 'left') {\n return alignLeft(subject, availableWidth);\n }\n\n if (alignment === 'right') {\n return alignRight(subject, availableWidth);\n }\n\n return alignCenter(subject, availableWidth);\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/alignTableData.js.map b/tools/eslint/node_modules/table/dist/alignTableData.js.map deleted file mode 100644 index 45aea74993674f..00000000000000 --- a/tools/eslint/node_modules/table/dist/alignTableData.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["alignTableData.js"],"names":[],"mappings":";;;;;;;;;;AACA;;;;AACA;;;;;;;;;;;;kBAOe,UAAC,IAAD,EAAO,MAAP,EAAkB;AAC7B,WAAO,mBAAM,IAAN,EAAY,UAAC,KAAD,EAAW;AAC1B,eAAO,mBAAM,KAAN,EAAa,UAAC,KAAD,EAAQ,MAAR,EAAmB;AACnC,gBAAI,eAAJ;;AAEA,qBAAS,OAAO,OAAP,CAAe,MAAf,CAAT;;AAEA,gBAAI,2BAAY,KAAZ,MAAuB,OAAO,KAAlC,EAAyC;AACrC,uBAAO,KAAP;AACH,aAFD,MAEO;AACH,uBAAO,2BAAY,KAAZ,EAAmB,OAAO,KAA1B,EAAiC,OAAO,SAAxC,CAAP;AACH;AACJ,SAVM,CAAP;AAWH,KAZM,CAAP;AAaH,C","file":"alignTableData.js","sourcesContent":["import _ from 'lodash';\nimport alignString from './alignString';\nimport stringWidth from 'string-width';\n\n/**\n * @param {table~row[]} rows\n * @param {Object} config\n * @return {table~row[]}\n */\nexport default (rows, config) => {\n return _.map(rows, (cells) => {\n return _.map(cells, (value, index1) => {\n let column;\n\n column = config.columns[index1];\n\n if (stringWidth(value) === column.width) {\n return value;\n } else {\n return alignString(value, column.width, column.alignment);\n }\n });\n });\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/calculateCellHeight.js b/tools/eslint/node_modules/table/dist/calculateCellHeight.js index f90110adb11d51..b5ec6998d58d0e 100644 --- a/tools/eslint/node_modules/table/dist/calculateCellHeight.js +++ b/tools/eslint/node_modules/table/dist/calculateCellHeight.js @@ -25,7 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @returns {number} */ exports.default = function (value, columnWidth) { - let useWrapWord = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; + let useWrapWord = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; if (!_lodash2.default.isString(value)) { throw new Error('Value must be a string.'); diff --git a/tools/eslint/node_modules/table/dist/calculateCellHeight.js.map b/tools/eslint/node_modules/table/dist/calculateCellHeight.js.map deleted file mode 100644 index 184fdbf02cd47c..00000000000000 --- a/tools/eslint/node_modules/table/dist/calculateCellHeight.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["calculateCellHeight.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AACA;;;;AACA;;;;;;;;;;;;;kBAQe,UAAC,KAAD,EAAQ,WAAR,EAA6C;AAAA,QAAxB,WAAwB,yDAAV,KAAU;;AACxD,QAAI,CAAC,wBAAW,KAAX,CAAL,EAAwB;AACpB,cAAM,IAAI,KAAJ,CAAU,yBAAV,CAAN;AACH;;AAED,QAAI,CAAC,yBAAY,WAAZ,CAAL,EAA+B;AAC3B,cAAM,IAAI,KAAJ,CAAU,kCAAV,CAAN;AACH;;AAED,QAAI,cAAc,CAAlB,EAAqB;AACjB,cAAM,IAAI,KAAJ,CAAU,sCAAV,CAAN;AACH;;AAED,QAAI,WAAJ,EAAiB;AACb,eAAO,wBAAS,KAAT,EAAgB,WAAhB,EAA6B,MAApC;AACH;;AAED,WAAO,oBAAO,2BAAY,KAAZ,IAAqB,WAA5B,CAAP;AACH,C","file":"calculateCellHeight.js","sourcesContent":["import _ from 'lodash';\nimport stringWidth from 'string-width';\nimport wrapWord from './wrapWord';\n\n/**\n * @param {string} value\n * @param {number} columnWidth\n * @param {boolean} useWrapWord\n * @returns {number}\n */\nexport default (value, columnWidth, useWrapWord = false) => {\n if (!_.isString(value)) {\n throw new Error('Value must be a string.');\n }\n\n if (!_.isInteger(columnWidth)) {\n throw new Error('Column width must be an integer.');\n }\n\n if (columnWidth < 1) {\n throw new Error('Column width must be greater than 0.');\n }\n\n if (useWrapWord) {\n return wrapWord(value, columnWidth).length;\n }\n\n return _.ceil(stringWidth(value) / columnWidth);\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/calculateCellWidthIndex.js.map b/tools/eslint/node_modules/table/dist/calculateCellWidthIndex.js.map deleted file mode 100644 index 112a04e8ee6c35..00000000000000 --- a/tools/eslint/node_modules/table/dist/calculateCellWidthIndex.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["calculateCellWidthIndex.js"],"names":[],"mappings":";;;;;;;;;;AACA;;;;;;;;;;;;;kBAQe,UAAC,KAAD,EAAW;AACtB,WAAO,mBAAM,KAAN,EAAa,UAAC,KAAD,EAAW;AAC3B,eAAO,2BAAY,KAAZ,CAAP;AACH,KAFM,CAAP;AAGH,C","file":"calculateCellWidthIndex.js","sourcesContent":["import _ from 'lodash';\nimport stringWidth from 'string-width';\n\n/**\n * Calculates width of each cell contents.\n *\n * @param {string[]} cells\n * @return {number[]}\n */\nexport default (cells) => {\n return _.map(cells, (value) => {\n return stringWidth(value);\n });\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js.map b/tools/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js.map deleted file mode 100644 index ea1e5e9ce49b3e..00000000000000 --- a/tools/eslint/node_modules/table/dist/calculateMaximumColumnWidthIndex.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["calculateMaximumColumnWidthIndex.js"],"names":[],"mappings":";;;;;;;;;;;;;;AACA;;;;;;;;;;;;;kBAQe,UAAC,IAAD,EAAU;AACrB,QAAI,gBAAJ;;AAEA,QAAI,CAAC,KAAK,CAAL,CAAL,EAAc;AACV,cAAM,IAAI,KAAJ,CAAU,qCAAV,CAAN;AACH;;AAED,cAAU,oBAAO,MAAM,KAAK,CAAL,EAAQ,MAAd,CAAP,EAA8B,CAA9B,CAAV;;AAEA,2BAAU,IAAV,EAAgB,UAAC,GAAD,EAAS;AACrB,YAAI,yBAAJ;;AAEA,2BAAmB,uCAAwB,GAAxB,CAAnB;;AAEA,+BAAU,gBAAV,EAA4B,UAAC,UAAD,EAAa,MAAb,EAAwB;AAChD,gBAAI,QAAQ,MAAR,IAAkB,UAAtB,EAAkC;AAC9B,wBAAQ,MAAR,IAAkB,UAAlB;AACH;AACJ,SAJD;AAKH,KAVD;;AAYA,WAAO,OAAP;AACH,C","file":"calculateMaximumColumnWidthIndex.js","sourcesContent":["import _ from 'lodash';\nimport calculateCellWidthIndex from './calculateCellWidthIndex';\n\n/**\n * Produces an array of values that describe the largest value length (width) in every column.\n *\n * @param {Array[]} rows\n * @return {number[]}\n */\nexport default (rows) => {\n let columns;\n\n if (!rows[0]) {\n throw new Error('Dataset must have at least one row.');\n }\n\n columns = _.fill(Array(rows[0].length), 0);\n\n _.forEach(rows, (row) => {\n let columnWidthIndex;\n\n columnWidthIndex = calculateCellWidthIndex(row);\n\n _.forEach(columnWidthIndex, (valueWidth, index0) => {\n if (columns[index0] < valueWidth) {\n columns[index0] = valueWidth;\n }\n });\n });\n\n return columns;\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/calculateRowHeightIndex.js.map b/tools/eslint/node_modules/table/dist/calculateRowHeightIndex.js.map deleted file mode 100644 index 9816a50a9a99a9..00000000000000 --- a/tools/eslint/node_modules/table/dist/calculateRowHeightIndex.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["calculateRowHeightIndex.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AACA;;;;;;;;;;;;;;kBASe,UAAC,IAAD,EAAO,MAAP,EAAkB;AAC7B,QAAI,qBAAJ;QACI,mBADJ;;AAGA,iBAAa,KAAK,CAAL,EAAQ,MAArB;;AAEA,mBAAe,EAAf;;AAEA,2BAAU,IAAV,EAAgB,UAAC,KAAD,EAAW;AACvB,YAAI,wBAAJ;;AAEA,0BAAkB,oBAAO,MAAM,UAAN,CAAP,EAA0B,CAA1B,CAAlB;;AAEA,+BAAU,KAAV,EAAiB,UAAC,KAAD,EAAQ,MAAR,EAAmB;AAChC,gBAAI,CAAC,wBAAW,OAAO,OAAP,CAAe,MAAf,EAAuB,KAAlC,CAAL,EAA+C;AAC3C,sBAAM,IAAI,KAAJ,CAAU,uCAAV,CAAN;AACH;;AAED,gBAAI,CAAC,yBAAY,OAAO,OAAP,CAAe,MAAf,EAAuB,QAAnC,CAAL,EAAmD;AAC/C,sBAAM,IAAI,KAAJ,CAAU,2CAAV,CAAN;AACH;;AAED,4BAAgB,MAAhB,IAA0B,mCAAoB,KAApB,EAA2B,OAAO,OAAP,CAAe,MAAf,EAAuB,KAAlD,EAAyD,OAAO,OAAP,CAAe,MAAf,EAAuB,QAAhF,CAA1B;AACH,SAVD;;AAYA,qBAAa,IAAb,CAAkB,mBAAM,eAAN,CAAlB;AACH,KAlBD;;AAoBA,WAAO,YAAP;AACH,C","file":"calculateRowHeightIndex.js","sourcesContent":["import _ from 'lodash';\nimport calculateCellHeight from './calculateCellHeight';\n\n/**\n * Calculates the vertical row span index.\n *\n * @param {Array[]} rows\n * @param {Object} config\n * @return {number[]}\n */\nexport default (rows, config) => {\n let rowSpanIndex,\n tableWidth;\n\n tableWidth = rows[0].length;\n\n rowSpanIndex = [];\n\n _.forEach(rows, (cells) => {\n let cellHeightIndex;\n\n cellHeightIndex = _.fill(Array(tableWidth), 1);\n\n _.forEach(cells, (value, index1) => {\n if (!_.isNumber(config.columns[index1].width)) {\n throw new Error('column[index].width must be a number.');\n }\n\n if (!_.isBoolean(config.columns[index1].wrapWord)) {\n throw new Error('column[index].wrapWord must be a boolean.');\n }\n\n cellHeightIndex[index1] = calculateCellHeight(value, config.columns[index1].width, config.columns[index1].wrapWord);\n });\n\n rowSpanIndex.push(_.max(cellHeightIndex));\n });\n\n return rowSpanIndex;\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/createStream.js b/tools/eslint/node_modules/table/dist/createStream.js index 1175ec66538da7..f9c3df5035be45 100644 --- a/tools/eslint/node_modules/table/dist/createStream.js +++ b/tools/eslint/node_modules/table/dist/createStream.js @@ -123,7 +123,7 @@ const append = (row, columnWidthIndex, config) => { */ exports.default = function () { - let userConfig = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; const config = (0, _makeStreamConfig2.default)(userConfig); diff --git a/tools/eslint/node_modules/table/dist/createStream.js.map b/tools/eslint/node_modules/table/dist/createStream.js.map deleted file mode 100644 index b3a2563cda052a..00000000000000 --- a/tools/eslint/node_modules/table/dist/createStream.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["createStream.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;AACA;;;;AACA;;AAOA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;;;AAEA,IAAI,eAAJ;IACI,eADJ;IAEI,oBAFJ;;;;;;;;AAUA,SAAS,gBAAC,GAAD,EAAM,gBAAN,EAAwB,MAAxB,EAAmC;AACxC,QAAI,aAAJ;QACI,eADJ;QAEI,aAFJ;;AAIA,WAAO,YAAY,CAAC,GAAD,CAAZ,EAAmB,MAAnB,CAAP;;AAEA,WAAO,mBAAM,IAAN,EAAY,UAAC,UAAD,EAAgB;AAC/B,eAAO,uBAAQ,UAAR,EAAoB,OAAO,MAA3B,CAAP;AACH,KAFM,EAEJ,IAFI,CAEC,EAFD,CAAP;;AAIA,aAAS,EAAT;AACA,cAAU,+BAAc,gBAAd,EAAgC,OAAO,MAAvC,CAAV;AACA,cAAU,IAAV;AACA,cAAU,kCAAiB,gBAAjB,EAAmC,OAAO,MAA1C,CAAV;;AAEA,aAAS,uBAAU,MAAV,CAAT;;AAEA,YAAQ,MAAR,CAAe,KAAf,CAAqB,MAArB;AACH,CAnBD;;;;;;;;AA2BA,SAAS,gBAAC,GAAD,EAAM,gBAAN,EAAwB,MAAxB,EAAmC;AACxC,QAAI,aAAJ;QACI,eADJ;QAEI,aAFJ;;AAIA,WAAO,YAAY,CAAC,GAAD,CAAZ,EAAmB,MAAnB,CAAP;;;;AAIA,WAAO,mBAAM,IAAN,EAAY,UAAC,UAAD,EAAgB;AAC/B,eAAO,uBAAQ,UAAR,EAAoB,OAAO,MAA3B,CAAP;AACH,KAFM,EAEJ,IAFI,CAEC,EAFD,CAAP;;AAIA,aAAS,UAAT;AACA,cAAU,gCAAe,gBAAf,EAAiC,OAAO,MAAxC,CAAV;AACA,cAAU,IAAV;AACA,cAAU,kCAAiB,gBAAjB,EAAmC,OAAO,MAA1C,CAAV;;AAEA,aAAS,uBAAU,MAAV,CAAT;;AAEA,YAAQ,MAAR,CAAe,KAAf,CAAqB,MAArB;AACH,CArBD;;;;;;;AA4BA,cAAc,qBAAC,IAAD,EAAO,MAAP,EAAkB;AAC5B,QAAI,uBAAJ;QACI,aADJ;;AAGA,WAAO,kCAAmB,IAAnB,CAAP;;AAEA,WAAO,iCAAkB,IAAlB,EAAwB,MAAxB,CAAP;;AAEA,qBAAiB,uCAAwB,IAAxB,EAA8B,MAA9B,CAAjB;;AAEA,WAAO,0CAA2B,IAA3B,EAAiC,cAAjC,EAAiD,MAAjD,CAAP;AACA,WAAO,8BAAe,IAAf,EAAqB,MAArB,CAAP;AACA,WAAO,4BAAa,IAAb,EAAmB,MAAnB,CAAP;;AAEA,WAAO,IAAP;AACH,CAfD;;;;;;;kBAqBe,YAAqB;AAAA,QAApB,UAAoB,yDAAP,EAAO;;AAChC,QAAI,yBAAJ;QACI,eADJ;QAEI,cAFJ;;AAIA,aAAS,gCAAiB,UAAjB,CAAT;;AAEA,uBAAmB,yBAAY,OAAO,OAAnB,EAA4B,UAAC,MAAD,EAAY;AACvD,eAAO,OAAO,KAAP,GAAe,OAAO,WAAtB,GAAoC,OAAO,YAAlD;AACH,KAFkB,CAAnB;;AAIA,YAAQ,IAAR;;AAEA,WAAO;;;;;AAKH,eAAO,eAAC,GAAD,EAAS;AACZ,gBAAI,IAAI,MAAJ,KAAe,OAAO,WAA1B,EAAuC;AACnC,sBAAM,IAAI,KAAJ,CAAU,uDAAV,CAAN;AACH;;AAED,gBAAI,KAAJ,EAAW;AACP,wBAAQ,KAAR;;AAEA,uBAAO,OAAO,GAAP,EAAY,gBAAZ,EAA8B,MAA9B,CAAP;AACH,aAJD,MAIO;AACH,uBAAO,OAAO,GAAP,EAAY,gBAAZ,EAA8B,MAA9B,CAAP;AACH;AACJ;AAjBE,KAAP;AAmBH,C","file":"createStream.js","sourcesContent":["import makeStreamConfig from './makeStreamConfig';\nimport drawRow from './drawRow';\nimport {\n drawBorderBottom,\n drawBorderJoin,\n drawBorderTop\n} from './drawBorder';\nimport _ from 'lodash';\n\nimport stringifyTableData from './stringifyTableData';\nimport truncateTableData from './truncateTableData';\nimport mapDataUsingRowHeightIndex from './mapDataUsingRowHeightIndex';\nimport alignTableData from './alignTableData';\nimport padTableData from './padTableData';\nimport calculateRowHeightIndex from './calculateRowHeightIndex';\n\nlet append,\n create,\n prepareData;\n\n/**\n * @param {string[]} row\n * @param {number[]} columnWidthIndex\n * @param {Object} config\n * @returns {undefined}\n */\ncreate = (row, columnWidthIndex, config) => {\n let body,\n output,\n rows;\n\n rows = prepareData([row], config);\n\n body = _.map(rows, (literalRow) => {\n return drawRow(literalRow, config.border);\n }).join('');\n\n output = '';\n output += drawBorderTop(columnWidthIndex, config.border);\n output += body;\n output += drawBorderBottom(columnWidthIndex, config.border);\n\n output = _.trimEnd(output);\n\n process.stdout.write(output);\n};\n\n/**\n * @param {string[]} row\n * @param {number[]} columnWidthIndex\n * @param {Object} config\n * @returns {undefined}\n */\nappend = (row, columnWidthIndex, config) => {\n let body,\n output,\n rows;\n\n rows = prepareData([row], config);\n\n // console.log('rows', rows);\n\n body = _.map(rows, (literalRow) => {\n return drawRow(literalRow, config.border);\n }).join('');\n\n output = '\\r\\x1b[K';\n output += drawBorderJoin(columnWidthIndex, config.border);\n output += body;\n output += drawBorderBottom(columnWidthIndex, config.border);\n\n output = _.trimEnd(output);\n\n process.stdout.write(output);\n};\n\n/**\n * @param {Array} data\n * @param {Object} config\n * @returns {Array}\n */\nprepareData = (data, config) => {\n let rowHeightIndex,\n rows;\n\n rows = stringifyTableData(data);\n\n rows = truncateTableData(data, config);\n\n rowHeightIndex = calculateRowHeightIndex(rows, config);\n\n rows = mapDataUsingRowHeightIndex(rows, rowHeightIndex, config);\n rows = alignTableData(rows, config);\n rows = padTableData(rows, config);\n\n return rows;\n};\n\n/**\n * @param {Object} userConfig\n * @return {Object}\n */\nexport default (userConfig = {}) => {\n let columnWidthIndex,\n config,\n empty;\n\n config = makeStreamConfig(userConfig);\n\n columnWidthIndex = _.mapValues(config.columns, (column) => {\n return column.width + column.paddingLeft + column.paddingRight;\n });\n\n empty = true;\n\n return {\n /**\n * @param {string[]} row\n * @returns {undefined}\n */\n write: (row) => {\n if (row.length !== config.columnCount) {\n throw new Error('Row cell count does not match the config.columnCount.');\n }\n\n if (empty) {\n empty = false;\n\n return create(row, columnWidthIndex, config);\n } else {\n return append(row, columnWidthIndex, config);\n }\n }\n };\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/drawBorder.js.map b/tools/eslint/node_modules/table/dist/drawBorder.js.map deleted file mode 100644 index adbf9d7403d2f9..00000000000000 --- a/tools/eslint/node_modules/table/dist/drawBorder.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["drawBorder.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAEA,IAAI,mBAAJ;IACI,yBADJ;IAEI,uBAFJ;IAGI,sBAHJ;;;;;;;;;;;;;;;AAkBA,QA+EI,UA/EJ,gBAAa,oBAAC,eAAD,EAAkB,KAAlB,EAA4B;AACrC,QAAI,gBAAJ;;AAEA,cAAU,mBAAM,eAAN,EAAuB,UAAC,IAAD,EAAU;AACvC,eAAO,sBAAS,MAAM,IAAf,EAAqB,IAArB,CAAP;AACH,KAFS,CAAV;;AAIA,cAAU,QAAQ,IAAR,CAAa,MAAM,IAAnB,CAAV;;AAEA,WAAO,MAAM,IAAN,GAAa,OAAb,GAAuB,MAAM,KAA7B,GAAqC,IAA5C;AACH,CAVD;;;;;;;;;;;;;;;AAyBA,QAuDI,aAvDJ,mBAAgB,uBAAC,eAAD,EAAkB,KAAlB,EAA4B;AACxC,WAAO,WAAW,eAAX,EAA4B;AAC/B,cAAM,MAAM,OADmB;AAE/B,eAAO,MAAM,QAFkB;AAG/B,cAAM,MAAM,OAHmB;AAI/B,cAAM,MAAM;AAJmB,KAA5B,CAAP;AAMH,CAPD;;;;;;;;;;;;;;;AAsBA,QAkCI,cAlCJ,oBAAiB,wBAAC,eAAD,EAAkB,KAAlB,EAA4B;AACzC,WAAO,WAAW,eAAX,EAA4B;AAC/B,cAAM,MAAM,QADmB;AAE/B,eAAO,MAAM,SAFkB;AAG/B,cAAM,MAAM,QAHmB;AAI/B,cAAM,MAAM;AAJmB,KAA5B,CAAP;AAMH,CAPD;;;;;;;;;;;;;;;AAsBA,QAaI,gBAbJ,sBAAmB,0BAAC,eAAD,EAAkB,KAAlB,EAA4B;AAC3C,WAAO,WAAW,eAAX,EAA4B;AAC/B,cAAM,MAAM,UADmB;AAE/B,eAAO,MAAM,WAFkB;AAG/B,cAAM,MAAM,UAHmB;AAI/B,cAAM,MAAM;AAJmB,KAA5B,CAAP;AAMH,CAPD;;QAUI,U,GAAA,U;QACA,a,GAAA,a;QACA,c,GAAA,c;QACA,gB,GAAA,gB","file":"drawBorder.js","sourcesContent":["import _ from 'lodash';\n\nlet drawBorder,\n drawBorderBottom,\n drawBorderJoin,\n drawBorderTop;\n\n/**\n * @typedef drawBorder~parts\n * @property {string} left\n * @property {string} right\n * @property {string} body\n * @property {string} join\n */\n\n/**\n * @param {number[]} columnSizeIndex\n * @param {drawBorder~parts} parts\n * @returns {string}\n */\ndrawBorder = (columnSizeIndex, parts) => {\n let columns;\n\n columns = _.map(columnSizeIndex, (size) => {\n return _.repeat(parts.body, size);\n });\n\n columns = columns.join(parts.join);\n\n return parts.left + columns + parts.right + '\\n';\n};\n\n/**\n * @typedef drawBorderTop~parts\n * @property {string} topLeft\n * @property {string} topRight\n * @property {string} topBody\n * @property {string} topJoin\n */\n\n/**\n * @param {number[]} columnSizeIndex\n * @param {drawBorderTop~parts} parts\n * @return {string}\n */\ndrawBorderTop = (columnSizeIndex, parts) => {\n return drawBorder(columnSizeIndex, {\n left: parts.topLeft,\n right: parts.topRight,\n body: parts.topBody,\n join: parts.topJoin\n });\n};\n\n/**\n * @typedef drawBorderJoin~parts\n * @property {string} joinLeft\n * @property {string} joinRight\n * @property {string} joinBody\n * @property {string} joinJoin\n */\n\n/**\n * @param {number[]} columnSizeIndex\n * @param {drawBorderJoin~parts} parts\n * @returns {string}\n */\ndrawBorderJoin = (columnSizeIndex, parts) => {\n return drawBorder(columnSizeIndex, {\n left: parts.joinLeft,\n right: parts.joinRight,\n body: parts.joinBody,\n join: parts.joinJoin\n });\n};\n\n/**\n * @typedef drawBorderBottom~parts\n * @property {string} topLeft\n * @property {string} topRight\n * @property {string} topBody\n * @property {string} topJoin\n */\n\n/**\n * @param {number[]} columnSizeIndex\n * @param {drawBorderBottom~parts} parts\n * @returns {string}\n */\ndrawBorderBottom = (columnSizeIndex, parts) => {\n return drawBorder(columnSizeIndex, {\n left: parts.bottomLeft,\n right: parts.bottomRight,\n body: parts.bottomBody,\n join: parts.bottomJoin\n });\n};\n\nexport {\n drawBorder,\n drawBorderTop,\n drawBorderJoin,\n drawBorderBottom\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/drawRow.js.map b/tools/eslint/node_modules/table/dist/drawRow.js.map deleted file mode 100644 index 5cef8565f4cc23..00000000000000 --- a/tools/eslint/node_modules/table/dist/drawRow.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["drawRow.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;kBAYe,UAAC,OAAD,EAAU,MAAV,EAAqB;AAChC,SAAO,OAAO,QAAP,GAAkB,QAAQ,IAAR,CAAa,OAAO,QAApB,CAAlB,GAAkD,OAAO,SAAzD,GAAqE,IAA5E;AACH,C","file":"drawRow.js","sourcesContent":["/**\n * @typedef {Object} drawRow~border\n * @property {string} bodyLeft\n * @property {string} bodyRight\n * @property {string} bodyJoin\n */\n\n/**\n * @param {number[]} columns\n * @param {drawRow~border} border\n * @return {string}\n */\nexport default (columns, border) => {\n return border.bodyLeft + columns.join(border.bodyJoin) + border.bodyRight + '\\n';\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/drawTable.js.map b/tools/eslint/node_modules/table/dist/drawTable.js.map deleted file mode 100644 index 8534c44da3fad4..00000000000000 --- a/tools/eslint/node_modules/table/dist/drawTable.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["drawTable.js"],"names":[],"mappings":";;;;;;;;;;AACA;;AAKA;;;;;;;;;;;;;;;kBAUe,UAAC,IAAD,EAAO,MAAP,EAAe,eAAf,EAAgC,YAAhC,EAA8C,kBAA9C,EAAqE;AAChF,QAAI,eAAJ;QACI,qBADJ;QAEI,iBAFJ;QAGI,kBAHJ;;AAKA,eAAW,KAAK,MAAhB;;AAEA,mBAAe,CAAf;;AAEA,aAAS,EAAT;;AAEA,QAAI,mBAAmB,YAAnB,EAAiC,QAAjC,CAAJ,EAAgD;AAC5C,kBAAU,+BAAc,eAAd,EAA+B,MAA/B,CAAV;AACH;;AAED,2BAAU,IAAV,EAAgB,UAAC,GAAD,EAAM,MAAN,EAAiB;AAC7B,kBAAU,uBAAQ,GAAR,EAAa,MAAb,CAAV;;AAEA,YAAI,CAAC,SAAL,EAAgB;AACZ,wBAAY,aAAa,YAAb,CAAZ;;AAEA;AACH;;AAED;;AAEA,YAAI,cAAc,CAAd,IAAmB,WAAW,WAAW,CAAzC,IAA8C,mBAAmB,YAAnB,EAAiC,QAAjC,CAAlD,EAA8F;AAC1F,sBAAU,gCAAe,eAAf,EAAgC,MAAhC,CAAV;AACH;AACJ,KAdD;;AAgBA,QAAI,mBAAmB,YAAnB,EAAiC,QAAjC,CAAJ,EAAgD;AAC5C,kBAAU,kCAAiB,eAAjB,EAAkC,MAAlC,CAAV;AACH;;AAED,WAAO,MAAP;AACH,C","file":"drawTable.js","sourcesContent":["import _ from 'lodash';\nimport {\n drawBorderTop,\n drawBorderJoin,\n drawBorderBottom\n} from './drawBorder';\nimport drawRow from './drawRow';\n\n/**\n * @param {Array} rows\n * @param {Object} border\n * @param {Array} columnSizeIndex\n * @param {Array} rowSpanIndex\n * @param {Function} drawHorizontalLine\n * @returns {string}\n */\nexport default (rows, border, columnSizeIndex, rowSpanIndex, drawHorizontalLine) => {\n let output,\n realRowIndex,\n rowCount,\n rowHeight;\n\n rowCount = rows.length;\n\n realRowIndex = 0;\n\n output = '';\n\n if (drawHorizontalLine(realRowIndex, rowCount)) {\n output += drawBorderTop(columnSizeIndex, border);\n }\n\n _.forEach(rows, (row, index0) => {\n output += drawRow(row, border);\n\n if (!rowHeight) {\n rowHeight = rowSpanIndex[realRowIndex];\n\n realRowIndex++;\n }\n\n rowHeight--;\n\n if (rowHeight === 0 && index0 !== rowCount - 1 && drawHorizontalLine(realRowIndex, rowCount)) {\n output += drawBorderJoin(columnSizeIndex, border);\n }\n });\n\n if (drawHorizontalLine(realRowIndex, rowCount)) {\n output += drawBorderBottom(columnSizeIndex, border);\n }\n\n return output;\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/getBorderCharacters.js.map b/tools/eslint/node_modules/table/dist/getBorderCharacters.js.map deleted file mode 100644 index 36ba03bf8c00e4..00000000000000 --- a/tools/eslint/node_modules/table/dist/getBorderCharacters.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["getBorderCharacters.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAyBe,UAAC,IAAD,EAAU;AACrB,QAAI,SAAS,WAAb,EAA0B;AACtB,eAAO;AACH,qBAAS,GADN;AAEH,qBAAS,GAFN;AAGH,qBAAS,GAHN;AAIH,sBAAU,GAJP;;AAMH,wBAAY,GANT;AAOH,wBAAY,GAPT;AAQH,wBAAY,GART;AASH,yBAAa,GATV;;AAWH,sBAAU,GAXP;AAYH,uBAAW,GAZR;AAaH,sBAAU,GAbP;;AAeH,sBAAU,GAfP;AAgBH,sBAAU,GAhBP;AAiBH,uBAAW,GAjBR;AAkBH,sBAAU;AAlBP,SAAP;AAoBH;;AAED,QAAI,SAAS,MAAb,EAAqB;AACjB,eAAO;AACH,qBAAS,GADN;AAEH,qBAAS,GAFN;AAGH,qBAAS,GAHN;AAIH,sBAAU,GAJP;;AAMH,wBAAY,GANT;AAOH,wBAAY,GAPT;AAQH,wBAAY,GART;AASH,yBAAa,GATV;;AAWH,sBAAU,GAXP;AAYH,uBAAW,GAZR;AAaH,sBAAU,GAbP;;AAeH,sBAAU,GAfP;AAgBH,sBAAU,GAhBP;AAiBH,uBAAW,GAjBR;AAkBH,sBAAU;AAlBP,SAAP;AAoBH;;AAED,QAAI,SAAS,OAAb,EAAsB;AAClB,eAAO;AACH,qBAAS,GADN;AAEH,qBAAS,GAFN;AAGH,qBAAS,GAHN;AAIH,sBAAU,GAJP;;AAMH,wBAAY,GANT;AAOH,wBAAY,GAPT;AAQH,wBAAY,GART;AASH,yBAAa,GATV;;AAWH,sBAAU,GAXP;AAYH,uBAAW,GAZR;AAaH,sBAAU,GAbP;;AAeH,sBAAU,GAfP;AAgBH,sBAAU,GAhBP;AAiBH,uBAAW,GAjBR;AAkBH,sBAAU;AAlBP,SAAP;AAoBH;;AAED,QAAI,SAAS,MAAb,EAAqB;AACjB,eAAO;AACH,qBAAS,EADN;AAEH,qBAAS,EAFN;AAGH,qBAAS,EAHN;AAIH,sBAAU,EAJP;;AAMH,wBAAY,EANT;AAOH,wBAAY,EAPT;AAQH,wBAAY,EART;AASH,yBAAa,EATV;;AAWH,sBAAU,EAXP;AAYH,uBAAW,EAZR;AAaH,sBAAU,EAbP;;AAeH,sBAAU,EAfP;AAgBH,sBAAU,EAhBP;AAiBH,uBAAW,EAjBR;AAkBH,sBAAU;AAlBP,SAAP;AAoBH;;AAED,UAAM,IAAI,KAAJ,CAAU,oCAAV,CAAN;AACH,C","file":"getBorderCharacters.js","sourcesContent":["/* eslint-disable sorting/sort-object-props */\n\n/**\n * @typedef border\n * @property {string} topBody\n * @property {string} topJoin\n * @property {string} topLeft\n * @property {string} topRight\n * @property {string} bottomBody\n * @property {string} bottomJoin\n * @property {string} bottomLeft\n * @property {string} bottomRight\n * @property {string} bodyLeft\n * @property {string} bodyRight\n * @property {string} bodyJoin\n * @property {string} joinBody\n * @property {string} joinLeft\n * @property {string} joinRight\n * @property {string} joinJoin\n */\n\n/**\n * @param {string} name\n * @returns {border}\n */\nexport default (name) => {\n if (name === 'honeywell') {\n return {\n topBody: '═',\n topJoin: '╤',\n topLeft: '╔',\n topRight: '╗',\n\n bottomBody: '═',\n bottomJoin: '╧',\n bottomLeft: '╚',\n bottomRight: '╝',\n\n bodyLeft: '║',\n bodyRight: '║',\n bodyJoin: '│',\n\n joinBody: '─',\n joinLeft: '╟',\n joinRight: '╢',\n joinJoin: '┼'\n };\n }\n\n if (name === 'norc') {\n return {\n topBody: '─',\n topJoin: '┬',\n topLeft: '┌',\n topRight: '┐',\n\n bottomBody: '─',\n bottomJoin: '┴',\n bottomLeft: '└',\n bottomRight: '┘',\n\n bodyLeft: '│',\n bodyRight: '│',\n bodyJoin: '│',\n\n joinBody: '─',\n joinLeft: '├',\n joinRight: '┤',\n joinJoin: '┼'\n };\n }\n\n if (name === 'ramac') {\n return {\n topBody: '-',\n topJoin: '+',\n topLeft: '+',\n topRight: '+',\n\n bottomBody: '-',\n bottomJoin: '+',\n bottomLeft: '+',\n bottomRight: '+',\n\n bodyLeft: '|',\n bodyRight: '|',\n bodyJoin: '|',\n\n joinBody: '-',\n joinLeft: '|',\n joinRight: '|',\n joinJoin: '|'\n };\n }\n\n if (name === 'void') {\n return {\n topBody: '',\n topJoin: '',\n topLeft: '',\n topRight: '',\n\n bottomBody: '',\n bottomJoin: '',\n bottomLeft: '',\n bottomRight: '',\n\n bodyLeft: '',\n bodyRight: '',\n bodyJoin: '',\n\n joinBody: '',\n joinLeft: '',\n joinRight: '',\n joinJoin: ''\n };\n }\n\n throw new Error('Unknown border template \"${name}\".');\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/index.js.map b/tools/eslint/node_modules/table/dist/index.js.map deleted file mode 100644 index dcf5ef8d344cad..00000000000000 --- a/tools/eslint/node_modules/table/dist/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["index.js"],"names":[],"mappings":";;;;;;;AAAA;;;;AACA;;;;AACA;;;;;;QAGI,Y;QACA,mB","file":"index.js","sourcesContent":["import table from './table';\nimport createStream from './createStream';\nimport getBorderCharacters from './getBorderCharacters';\n\nexport {\n createStream,\n getBorderCharacters\n};\n\nexport default table;\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/makeConfig.js b/tools/eslint/node_modules/table/dist/makeConfig.js index 830ece67ef10ff..45ad8e899ce4be 100644 --- a/tools/eslint/node_modules/table/dist/makeConfig.js +++ b/tools/eslint/node_modules/table/dist/makeConfig.js @@ -29,7 +29,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @returns {Object} */ const makeBorder = function makeBorder() { - let border = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return _lodash2.default.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border); }; @@ -44,8 +44,8 @@ const makeBorder = function makeBorder() { * @returns {Object} */ const makeColumns = function makeColumns(rows) { - let columns = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - let columnDefault = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + let columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + let columnDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; const maximumColumnWidthIndex = (0, _calculateMaximumColumnWidthIndex2.default)(rows); @@ -77,7 +77,7 @@ const makeColumns = function makeColumns(rows) { */ exports.default = function (rows) { - let userConfig = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; (0, _validateConfig2.default)('config.json', userConfig); diff --git a/tools/eslint/node_modules/table/dist/makeConfig.js.map b/tools/eslint/node_modules/table/dist/makeConfig.js.map deleted file mode 100644 index 25c7051d2758e4..00000000000000 --- a/tools/eslint/node_modules/table/dist/makeConfig.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["makeConfig.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA;;;;AACA;;;;AACA;;;;;;AAEA,IAAI,mBAAJ;IACI,oBADJ;;;;;;;;AASA,aAAa,sBAAiB;AAAA,QAAhB,MAAgB,yDAAP,EAAO;;AAC1B,WAAO,sBAAS,EAAT,EAAa,mCAAoB,WAApB,CAAb,EAA+C,MAA/C,CAAP;AACH,CAFD;;;;;;;;;;;AAaA,cAAc,qBAAC,IAAD,EAA4C;AAAA,QAArC,OAAqC,yDAA3B,EAA2B;AAAA,QAAvB,aAAuB,yDAAP,EAAO;;AACtD,QAAI,gCAAJ;;AAEA,8BAA0B,gDAAiC,IAAjC,CAA1B;;AAEA,yBAAQ,KAAK,CAAL,EAAQ,MAAhB,EAAwB,UAAC,KAAD,EAAW;AAC/B,YAAI,2BAAc,QAAQ,KAAR,CAAd,CAAJ,EAAmC;AAC/B,oBAAQ,KAAR,IAAiB,EAAjB;AACH;;AAED,gBAAQ,KAAR,IAAiB,sBAAS;AACtB,uBAAW,MADW;AAEtB,mBAAO,wBAAwB,KAAxB,CAFe;AAGtB,sBAAU,KAHY;AAItB,sBAAU,QAJY;AAKtB,yBAAa,CALS;AAMtB,0BAAc;AANQ,SAAT,EAOd,aAPc,EAOC,QAAQ,KAAR,CAPD,CAAjB;AAQH,KAbD;;AAeA,WAAO,OAAP;AACH,CArBD;;;;;;;;;;;kBA+Be,UAAC,IAAD,EAA2B;AAAA,QAApB,UAAoB,yDAAP,EAAO;;AACtC,QAAI,eAAJ;;AAEA,kCAAe,UAAf;;AAEA,aAAS,yBAAY,UAAZ,CAAT;;AAEA,WAAO,MAAP,GAAgB,WAAW,OAAO,MAAlB,CAAhB;AACA,WAAO,OAAP,GAAiB,YAAY,IAAZ,EAAkB,OAAO,OAAzB,EAAkC,OAAO,aAAzC,CAAjB;;AAEA,QAAI,CAAC,OAAO,kBAAZ,EAAgC;;;;AAI5B,eAAO,kBAAP,GAA4B,YAAM;AAC9B,mBAAO,IAAP;AACH,SAFD;AAGH;;AAED,WAAO,MAAP;AACH,C","file":"makeConfig.js","sourcesContent":["import _ from 'lodash';\nimport getBorderCharacters from './getBorderCharacters';\nimport validateConfig from './validateConfig';\nimport calculateMaximumColumnWidthIndex from './calculateMaximumColumnWidthIndex';\n\nlet makeBorder,\n makeColumns;\n\n/**\n * Merges user provided border characters with the default border (\"honeywell\") characters.\n *\n * @param {Object} border\n * @returns {Object}\n */\nmakeBorder = (border = {}) => {\n return _.assign({}, getBorderCharacters('honeywell'), border);\n};\n\n/**\n * Creates a configuration for every column using default\n * values for the missing configuration properties.\n *\n * @param {Array[]} rows\n * @param {Object} columns\n * @param {Object} columnDefault\n * @returns {Object}\n */\nmakeColumns = (rows, columns = {}, columnDefault = {}) => {\n let maximumColumnWidthIndex;\n\n maximumColumnWidthIndex = calculateMaximumColumnWidthIndex(rows);\n\n _.times(rows[0].length, (index) => {\n if (_.isUndefined(columns[index])) {\n columns[index] = {};\n }\n\n columns[index] = _.assign({\n alignment: 'left',\n width: maximumColumnWidthIndex[index],\n wrapWord: false,\n truncate: Infinity,\n paddingLeft: 1,\n paddingRight: 1\n }, columnDefault, columns[index]);\n });\n\n return columns;\n};\n\n/**\n * Makes a new configuration object out of the userConfig object\n * using default values for the missing configuration properties.\n *\n * @param {Array[]} rows\n * @param {Object} userConfig\n * @returns {Object}\n */\nexport default (rows, userConfig = {}) => {\n let config;\n\n validateConfig(userConfig);\n\n config = _.cloneDeep(userConfig);\n\n config.border = makeBorder(config.border);\n config.columns = makeColumns(rows, config.columns, config.columnDefault);\n\n if (!config.drawHorizontalLine) {\n /**\n * @returns {boolean}\n */\n config.drawHorizontalLine = () => {\n return true;\n };\n }\n\n return config;\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/makeStreamConfig.js b/tools/eslint/node_modules/table/dist/makeStreamConfig.js index 06e212adbfe498..1482dae079ec0d 100644 --- a/tools/eslint/node_modules/table/dist/makeStreamConfig.js +++ b/tools/eslint/node_modules/table/dist/makeStreamConfig.js @@ -25,7 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @returns {Object} */ const makeBorder = function makeBorder() { - let border = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + let border = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; return _lodash2.default.assign({}, (0, _getBorderCharacters2.default)('honeywell'), border); }; @@ -40,8 +40,8 @@ const makeBorder = function makeBorder() { * @returns {Object} */ const makeColumns = function makeColumns(columnCount) { - let columns = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - let columnDefault = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2]; + let columns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; + let columnDefault = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; _lodash2.default.times(columnCount, index => { if (_lodash2.default.isUndefined(columns[index])) { @@ -86,7 +86,7 @@ const makeColumns = function makeColumns(columnCount) { */ exports.default = function () { - let userConfig = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; + let userConfig = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; (0, _validateConfig2.default)('streamConfig.json', userConfig); diff --git a/tools/eslint/node_modules/table/dist/makeStreamConfig.js.map b/tools/eslint/node_modules/table/dist/makeStreamConfig.js.map deleted file mode 100644 index c3c0437ec1e42a..00000000000000 --- a/tools/eslint/node_modules/table/dist/makeStreamConfig.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["makeStreamConfig.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA;;;;AACA;;;;;;AAEA,IAAI,mBAAJ;IACI,oBADJ;;;;;;;;AASA,aAAa,sBAAiB;AAAA,QAAhB,MAAgB,yDAAP,EAAO;;AAC1B,WAAO,sBAAS,EAAT,EAAa,mCAAoB,WAApB,CAAb,EAA+C,MAA/C,CAAP;AACH,CAFD;;;;;;;;;;;AAaA,cAAc,qBAAC,WAAD,EAAmD;AAAA,QAArC,OAAqC,yDAA3B,EAA2B;AAAA,QAAvB,aAAuB,yDAAP,EAAO;;AAC7D,yBAAQ,WAAR,EAAqB,UAAC,KAAD,EAAW;AAC5B,YAAI,2BAAc,QAAQ,KAAR,CAAd,CAAJ,EAAmC;AAC/B,oBAAQ,KAAR,IAAiB,EAAjB;AACH;;AAED,gBAAQ,KAAR,IAAiB,sBAAS;AACtB,uBAAW,MADW;;AAGtB,sBAAU,KAHY;AAItB,sBAAU,QAJY;AAKtB,yBAAa,CALS;AAMtB,0BAAc;AANQ,SAAT,EAOd,aAPc,EAOC,QAAQ,KAAR,CAPD,CAAjB;AAQH,KAbD;;AAeA,WAAO,OAAP;AACH,CAjBD;;;;;;;;;;;;;;;;;;;;;;;;;;;kBA2Ce,YAAqB;AAAA,QAApB,UAAoB,yDAAP,EAAO;;AAChC,QAAI,eAAJ;;AAEA,wCAAqB,UAArB;;AAEA,aAAS,yBAAY,UAAZ,CAAT;;AAEA,QAAI,CAAC,OAAO,aAAR,IAAyB,CAAC,OAAO,aAAP,CAAqB,KAAnD,EAA0D;AACtD,cAAM,IAAI,KAAJ,CAAU,iEAAV,CAAN;AACH;;AAED,QAAI,CAAC,OAAO,WAAZ,EAAyB;AACrB,cAAM,IAAI,KAAJ,CAAU,kCAAV,CAAN;AACH;;AAED,WAAO,MAAP,GAAgB,WAAW,OAAO,MAAlB,CAAhB;AACA,WAAO,OAAP,GAAiB,YAAY,OAAO,WAAnB,EAAgC,OAAO,OAAvC,EAAgD,OAAO,aAAvD,CAAjB;;AAEA,WAAO,MAAP;AACH,C","file":"makeStreamConfig.js","sourcesContent":["import _ from 'lodash';\nimport getBorderCharacters from './getBorderCharacters';\nimport validateStreamConfig from './validateStreamConfig';\n\nlet makeBorder,\n makeColumns;\n\n/**\n * Merges user provided border characters with the default border (\"honeywell\") characters.\n *\n * @param {Object} border\n * @returns {Object}\n */\nmakeBorder = (border = {}) => {\n return _.assign({}, getBorderCharacters('honeywell'), border);\n};\n\n/**\n * Creates a configuration for every column using default\n * values for the missing configuration properties.\n *\n * @param {number} columnCount\n * @param {Object} columns\n * @param {Object} columnDefault\n * @returns {Object}\n */\nmakeColumns = (columnCount, columns = {}, columnDefault = {}) => {\n _.times(columnCount, (index) => {\n if (_.isUndefined(columns[index])) {\n columns[index] = {};\n }\n\n columns[index] = _.assign({\n alignment: 'left',\n // width: columnDefault.width,\n wrapWord: false,\n truncate: Infinity,\n paddingLeft: 1,\n paddingRight: 1\n }, columnDefault, columns[index]);\n });\n\n return columns;\n};\n\n/**\n * @typedef {Object} columnConfig\n * @property {string} alignment\n * @property {number} width\n * @property {number} truncate\n * @property {number} paddingLeft\n * @property {number} paddingRight\n */\n\n/**\n * @typedef {Object} streamConfig\n * @property {columnConfig} columnDefault\n * @property {Object} border\n * @property {columnConfig[]}\n * @property {number} columnCount Number of columns in the table (required).\n */\n\n/**\n * Makes a new configuration object out of the userConfig object\n * using default values for the missing configuration properties.\n *\n * @param {streamConfig} userConfig\n * @returns {Object}\n */\nexport default (userConfig = {}) => {\n let config;\n\n validateStreamConfig(userConfig);\n\n config = _.cloneDeep(userConfig);\n\n if (!config.columnDefault || !config.columnDefault.width) {\n throw new Error('Must provide config.columnDefault.width when creating a stream.');\n }\n\n if (!config.columnCount) {\n throw new Error('Must provide config.columnCount.');\n }\n\n config.border = makeBorder(config.border);\n config.columns = makeColumns(config.columnCount, config.columns, config.columnDefault);\n\n return config;\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js.map b/tools/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js.map deleted file mode 100644 index 4b11dec7deceb3..00000000000000 --- a/tools/eslint/node_modules/table/dist/mapDataUsingRowHeightIndex.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["mapDataUsingRowHeightIndex.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AACA;;;;AACA;;;;;;;;;;;;;kBAQe,UAAC,YAAD,EAAe,cAAf,EAA+B,MAA/B,EAA0C;AACrD,QAAI,mBAAJ;QACI,mBADJ;;AAGA,iBAAa,aAAa,CAAb,EAAgB,MAA7B;;;;AAIA,iBAAa,mBAAM,YAAN,EAAoB,UAAC,KAAD,EAAQ,MAAR,EAAmB;AAChD,YAAI,kBAAJ;;AAEA,oBAAY,mBAAM,MAAM,eAAe,MAAf,CAAN,CAAN,EAAqC,YAAM;AACnD,mBAAO,oBAAO,MAAM,UAAN,CAAP,EAA0B,EAA1B,CAAP;AACH,SAFW,CAAZ;;;;;;;;AAUA,+BAAU,KAAV,EAAiB,UAAC,KAAD,EAAQ,MAAR,EAAmB;AAChC,gBAAI,qBAAJ;;AAEA,gBAAI,OAAO,OAAP,CAAe,MAAf,EAAuB,QAA3B,EAAqC;AACjC,+BAAe,wBAAS,KAAT,EAAgB,OAAO,OAAP,CAAe,MAAf,EAAuB,KAAvC,CAAf;AACH,aAFD,MAEO;AACH,+BAAe,0BAAW,KAAX,EAAkB,OAAO,OAAP,CAAe,MAAf,EAAuB,KAAzC,CAAf;AACH;;;;AAID,mCAAU,YAAV,EAAwB,UAAC,IAAD,EAAO,MAAP,EAAkB;;;AAGtC,0BAAU,MAAV,EAAkB,MAAlB,IAA4B,IAA5B;AACH,aAJD;AAKH,SAhBD;;AAkBA,eAAO,SAAP;AACH,KAhCY,CAAb;;AAkCA,WAAO,uBAAU,UAAV,CAAP;AACH,C","file":"mapDataUsingRowHeightIndex.js","sourcesContent":["import _ from 'lodash';\nimport wrapString from './wrapString';\nimport wrapWord from './wrapWord';\n\n/**\n * @param {Array} unmappedRows\n * @param {number[]} rowHeightIndex\n * @param {Object} config\n * @return {Array}\n */\nexport default (unmappedRows, rowHeightIndex, config) => {\n let mappedRows,\n tableWidth;\n\n tableWidth = unmappedRows[0].length;\n\n // console.log('unmappedRows', unmappedRows, 'rowHeightIndex', rowHeightIndex, 'config', config, 'tableWidth', tableWidth);\n\n mappedRows = _.map(unmappedRows, (cells, index0) => {\n let rowHeight;\n\n rowHeight = _.map(Array(rowHeightIndex[index0]), () => {\n return _.fill(Array(tableWidth), '');\n });\n\n // console.log('rowHeight', rowHeight);\n\n // rowHeight\n // [{row index within rowSaw; index2}]\n // [{cell index within a virtual row; index1}]\n\n _.forEach(cells, (value, index1) => {\n let chunkedValue;\n\n if (config.columns[index1].wrapWord) {\n chunkedValue = wrapWord(value, config.columns[index1].width);\n } else {\n chunkedValue = wrapString(value, config.columns[index1].width);\n }\n\n // console.log('chunkedValue', chunkedValue.length, 'rowHeight', rowHeight.length);\n\n _.forEach(chunkedValue, (part, index2) => {\n // console.log(rowHeight[index2]);\n\n rowHeight[index2][index1] = part;\n });\n });\n\n return rowHeight;\n });\n\n return _.flatten(mappedRows);\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/padTableData.js.map b/tools/eslint/node_modules/table/dist/padTableData.js.map deleted file mode 100644 index e900566a567aa3..00000000000000 --- a/tools/eslint/node_modules/table/dist/padTableData.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["padTableData.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;kBAOe,UAAC,IAAD,EAAO,MAAP,EAAkB;AAC7B,WAAO,mBAAM,IAAN,EAAY,UAAC,KAAD,EAAW;AAC1B,eAAO,mBAAM,KAAN,EAAa,UAAC,KAAD,EAAQ,MAAR,EAAmB;AACnC,gBAAI,eAAJ;;AAEA,qBAAS,OAAO,OAAP,CAAe,MAAf,CAAT;;AAEA,mBAAO,sBAAS,GAAT,EAAc,OAAO,WAArB,IAAoC,KAApC,GAA4C,sBAAS,GAAT,EAAc,OAAO,YAArB,CAAnD;AACH,SANM,CAAP;AAOH,KARM,CAAP;AASH,C","file":"padTableData.js","sourcesContent":["import _ from 'lodash';\n\n/**\n * @param {table~row[]} rows\n * @param {Object} config\n * @return {table~row[]}\n */\nexport default (rows, config) => {\n return _.map(rows, (cells) => {\n return _.map(cells, (value, index1) => {\n let column;\n\n column = config.columns[index1];\n\n return _.repeat(' ', column.paddingLeft) + value + _.repeat(' ', column.paddingRight);\n });\n });\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/stringifyTableData.js.map b/tools/eslint/node_modules/table/dist/stringifyTableData.js.map deleted file mode 100644 index c38e20fa838218..00000000000000 --- a/tools/eslint/node_modules/table/dist/stringifyTableData.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["stringifyTableData.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;kBAQe,UAAC,IAAD,EAAU;AACrB,WAAO,mBAAM,IAAN,EAAY,UAAC,KAAD,EAAW;AAC1B,eAAO,mBAAM,KAAN,EAAa,MAAb,CAAP;AACH,KAFM,CAAP;AAGH,C","file":"stringifyTableData.js","sourcesContent":["import _ from 'lodash';\n\n/**\n * Casts all cell values to a string.\n *\n * @param {table~row[]} rows\n * @return {table~row[]}\n */\nexport default (rows) => {\n return _.map(rows, (cells) => {\n return _.map(cells, String);\n });\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/table.js b/tools/eslint/node_modules/table/dist/table.js index 9066efaee82854..b62ffd2b747c8f 100644 --- a/tools/eslint/node_modules/table/dist/table.js +++ b/tools/eslint/node_modules/table/dist/table.js @@ -109,7 +109,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de * @returns {string} */ exports.default = function (data) { - let userConfig = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; + let userConfig = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; let rows; diff --git a/tools/eslint/node_modules/table/dist/table.js.map b/tools/eslint/node_modules/table/dist/table.js.map deleted file mode 100644 index 843d2e105c9f17..00000000000000 --- a/tools/eslint/node_modules/table/dist/table.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["table.js"],"names":[],"mappings":";;;;;;AAAA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAgEe,UAAC,IAAD,EAA2B;AAAA,MAApB,UAAoB,yDAAP,EAAO;;AACtC,MAAI,uBAAJ;MACI,eADJ;MAEI,uBAFJ;MAGI,aAHJ;;AAKA,mCAAkB,IAAlB;;AAEA,SAAO,kCAAmB,IAAnB,CAAP;;AAEA,WAAS,0BAAW,IAAX,EAAiB,UAAjB,CAAT;;AAEA,SAAO,iCAAkB,IAAlB,EAAwB,MAAxB,CAAP;;AAEA,mBAAiB,uCAAwB,IAAxB,EAA8B,MAA9B,CAAjB;;AAEA,SAAO,0CAA2B,IAA3B,EAAiC,cAAjC,EAAiD,MAAjD,CAAP;AACA,SAAO,8BAAe,IAAf,EAAqB,MAArB,CAAP;AACA,SAAO,4BAAa,IAAb,EAAmB,MAAnB,CAAP;;AAEA,mBAAiB,uCAAwB,KAAK,CAAL,CAAxB,CAAjB;;AAEA,SAAO,yBAAU,IAAV,EAAgB,OAAO,MAAvB,EAA+B,cAA/B,EAA+C,cAA/C,EAA+D,OAAO,kBAAtE,CAAP;AACH,C","file":"table.js","sourcesContent":["import drawTable from './drawTable';\nimport calculateCellWidthIndex from './calculateCellWidthIndex';\nimport makeConfig from './makeConfig';\nimport calculateRowHeightIndex from './calculateRowHeightIndex';\nimport mapDataUsingRowHeightIndex from './mapDataUsingRowHeightIndex';\nimport alignTableData from './alignTableData';\nimport padTableData from './padTableData';\nimport validateTableData from './validateTableData';\nimport stringifyTableData from './stringifyTableData';\nimport truncateTableData from './truncateTableData';\n\n/**\n * @typedef {string} table~cell\n */\n\n/**\n * @typedef {table~cell[]} table~row\n */\n\n/**\n * @typedef {Object} table~columns\n * @property {string} alignment Cell content alignment (enum: left, center, right) (default: left).\n * @property {number} width Column width (default: auto).\n * @property {number} truncate Number of characters are which the content will be truncated (default: Infinity).\n * @property {number} paddingLeft Cell content padding width left (default: 1).\n * @property {number} paddingRight Cell content padding width right (default: 1).\n */\n\n/**\n * @typedef {Object} table~border\n * @property {string} topBody\n * @property {string} topJoin\n * @property {string} topLeft\n * @property {string} topRight\n * @property {string} bottomBody\n * @property {string} bottomJoin\n * @property {string} bottomLeft\n * @property {string} bottomRight\n * @property {string} bodyLeft\n * @property {string} bodyRight\n * @property {string} bodyJoin\n * @property {string} joinBody\n * @property {string} joinLeft\n * @property {string} joinRight\n * @property {string} joinJoin\n */\n\n/**\n * Used to tell whether to draw a horizontal line.\n * This callback is called for each non-content line of the table.\n * The default behavior is to always return true.\n *\n * @typedef {Function} drawHorizontalLine\n * @param {number} index\n * @param {number} size\n * @return {boolean}\n */\n\n/**\n * @typedef {Object} table~config\n * @property {table~border} border\n * @property {table~columns[]} columns Column specific configuration.\n * @property {table~columns} columnDefault Default values for all columns. Column specific settings overwrite the default values.\n * @property {table~drawHorizontalLine} drawHorizontalLine\n */\n\n/**\n * Generates a text table.\n *\n * @param {table~row[]} data\n * @param {table~config} userConfig\n * @return {string}\n */\nexport default (data, userConfig = {}) => {\n let cellWidthIndex,\n config,\n rowHeightIndex,\n rows;\n\n validateTableData(data);\n\n rows = stringifyTableData(data);\n\n config = makeConfig(rows, userConfig);\n\n rows = truncateTableData(data, config);\n\n rowHeightIndex = calculateRowHeightIndex(rows, config);\n\n rows = mapDataUsingRowHeightIndex(rows, rowHeightIndex, config);\n rows = alignTableData(rows, config);\n rows = padTableData(rows, config);\n\n cellWidthIndex = calculateCellWidthIndex(rows[0]);\n\n return drawTable(rows, config.border, cellWidthIndex, rowHeightIndex, config.drawHorizontalLine);\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/truncateTableData.js.map b/tools/eslint/node_modules/table/dist/truncateTableData.js.map deleted file mode 100644 index dca05c3b51cdce..00000000000000 --- a/tools/eslint/node_modules/table/dist/truncateTableData.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["truncateTableData.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;kBAQe,UAAC,IAAD,EAAO,MAAP,EAAkB;AAC7B,WAAO,mBAAM,IAAN,EAAY,UAAC,KAAD,EAAW;AAC1B,eAAO,mBAAM,KAAN,EAAa,UAAC,OAAD,EAAU,KAAV,EAAoB;AACpC,mBAAO,wBAAW,OAAX,EAAoB;AACvB,wBAAQ,OAAO,OAAP,CAAe,KAAf,EAAsB;AADP,aAApB,CAAP;AAGH,SAJM,CAAP;AAKH,KANM,CAAP;AAOH,C","file":"truncateTableData.js","sourcesContent":["import _ from 'lodash';\n\n/**\n * @todo Make it work with ASCII content.\n * @param {table~row[]} rows\n * @param {Object} config\n * @return {table~row[]}\n */\nexport default (rows, config) => {\n return _.map(rows, (cells) => {\n return _.map(cells, (content, index) => {\n return _.truncate(content, {\n length: config.columns[index].truncate\n });\n });\n });\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/validateConfig.js b/tools/eslint/node_modules/table/dist/validateConfig.js index 965ddc5db4654c..caba30134de2e6 100644 --- a/tools/eslint/node_modules/table/dist/validateConfig.js +++ b/tools/eslint/node_modules/table/dist/validateConfig.js @@ -1,62 +1,756 @@ 'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _ajv = require('ajv'); - -var _ajv2 = _interopRequireDefault(_ajv); - -var _ajvKeywords = require('ajv-keywords'); - -var _ajvKeywords2 = _interopRequireDefault(_ajvKeywords); - -var _config = require('./schemas/config.json'); - -var _config2 = _interopRequireDefault(_config); - -var _streamConfig = require('./schemas/streamConfig.json'); - -var _streamConfig2 = _interopRequireDefault(_streamConfig); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -const ajv = new _ajv2.default({ - allErrors: true -}); - -(0, _ajvKeywords2.default)(ajv, 'typeof'); - -ajv.addSchema(_config2.default); -ajv.addSchema(_streamConfig2.default); - -/** - * @param {string} schemaId - * @param {formatData~config} config - * @returns {undefined} - */ - -exports.default = function (schemaId) { - let config = arguments.length <= 1 || arguments[1] === undefined ? {} : arguments[1]; - - if (!ajv.validate(schemaId, config)) { - const errors = ajv.errors.map(error => { - return { - dataPath: error.dataPath, - message: error.message, - params: error.params, - schemaPath: error.schemaPath +var equal = require('ajv/lib/compile/equal'); +var validate = (function() { + var pattern0 = new RegExp('^[0-9]+$'); + var refVal = []; + var refVal1 = (function() { + var pattern0 = new RegExp('^[0-9]+$'); + return function validate(data, dataPath, parentData, parentDataProperty, rootData) { + 'use strict'; + var vErrors = null; + var errors = 0; + if (rootData === undefined) rootData = data; + if ((data && typeof data === "object" && !Array.isArray(data))) { + var errs__0 = errors; + var valid1 = true; + for (var key0 in data) { + var isAdditional0 = !(false || validate.schema.properties[key0]); + if (isAdditional0) { + valid1 = false; + var err = { + keyword: 'additionalProperties', + dataPath: (dataPath || '') + "", + schemaPath: '#/additionalProperties', + params: { + additionalProperty: '' + key0 + '' + }, + message: 'should NOT have additional properties' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + } + if (data.topBody !== undefined) { + var errs_1 = errors; + if (!refVal2(data.topBody, (dataPath || '') + '.topBody', data, 'topBody', rootData)) { + if (vErrors === null) vErrors = refVal2.errors; + else vErrors = vErrors.concat(refVal2.errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.topJoin !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.topJoin, (dataPath || '') + '.topJoin', data, 'topJoin', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.topLeft !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.topLeft, (dataPath || '') + '.topLeft', data, 'topLeft', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.topRight !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.topRight, (dataPath || '') + '.topRight', data, 'topRight', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bottomBody !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bottomBody, (dataPath || '') + '.bottomBody', data, 'bottomBody', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bottomJoin !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bottomJoin, (dataPath || '') + '.bottomJoin', data, 'bottomJoin', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bottomLeft !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bottomLeft, (dataPath || '') + '.bottomLeft', data, 'bottomLeft', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bottomRight !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bottomRight, (dataPath || '') + '.bottomRight', data, 'bottomRight', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bodyLeft !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bodyLeft, (dataPath || '') + '.bodyLeft', data, 'bodyLeft', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bodyRight !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bodyRight, (dataPath || '') + '.bodyRight', data, 'bodyRight', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bodyJoin !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bodyJoin, (dataPath || '') + '.bodyJoin', data, 'bodyJoin', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.joinBody !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.joinBody, (dataPath || '') + '.joinBody', data, 'joinBody', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.joinLeft !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.joinLeft, (dataPath || '') + '.joinLeft', data, 'joinLeft', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.joinRight !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.joinRight, (dataPath || '') + '.joinRight', data, 'joinRight', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.joinJoin !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.joinJoin, (dataPath || '') + '.joinJoin', data, 'joinJoin', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + } else { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + "", + schemaPath: '#/type', + params: { + type: 'object' + }, + message: 'should be object' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + validate.errors = vErrors; + return errors === 0; + }; + })(); + refVal1.schema = { + "type": "object", + "properties": { + "topBody": { + "$ref": "#/definitions/border" + }, + "topJoin": { + "$ref": "#/definitions/border" + }, + "topLeft": { + "$ref": "#/definitions/border" + }, + "topRight": { + "$ref": "#/definitions/border" + }, + "bottomBody": { + "$ref": "#/definitions/border" + }, + "bottomJoin": { + "$ref": "#/definitions/border" + }, + "bottomLeft": { + "$ref": "#/definitions/border" + }, + "bottomRight": { + "$ref": "#/definitions/border" + }, + "bodyLeft": { + "$ref": "#/definitions/border" + }, + "bodyRight": { + "$ref": "#/definitions/border" + }, + "bodyJoin": { + "$ref": "#/definitions/border" + }, + "joinBody": { + "$ref": "#/definitions/border" + }, + "joinLeft": { + "$ref": "#/definitions/border" + }, + "joinRight": { + "$ref": "#/definitions/border" + }, + "joinJoin": { + "$ref": "#/definitions/border" + } + }, + "additionalProperties": false + }; + refVal1.errors = null; + refVal[1] = refVal1; + var refVal2 = (function() { + var pattern0 = new RegExp('^[0-9]+$'); + return function validate(data, dataPath, parentData, parentDataProperty, rootData) { + 'use strict'; + var vErrors = null; + var errors = 0; + if (rootData === undefined) rootData = data; + if (typeof data !== "string") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + "", + schemaPath: '#/type', + params: { + type: 'string' + }, + message: 'should be string' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + validate.errors = vErrors; + return errors === 0; + }; + })(); + refVal2.schema = { + "type": "string" + }; + refVal2.errors = null; + refVal[2] = refVal2; + var refVal3 = (function() { + var pattern0 = new RegExp('^[0-9]+$'); + return function validate(data, dataPath, parentData, parentDataProperty, rootData) { + 'use strict'; + var vErrors = null; + var errors = 0; + if (rootData === undefined) rootData = data; + if ((data && typeof data === "object" && !Array.isArray(data))) { + var errs__0 = errors; + var valid1 = true; + for (var key0 in data) { + var isAdditional0 = !(false || pattern0.test(key0)); + if (isAdditional0) { + valid1 = false; + var err = { + keyword: 'additionalProperties', + dataPath: (dataPath || '') + "", + schemaPath: '#/additionalProperties', + params: { + additionalProperty: '' + key0 + '' + }, + message: 'should NOT have additional properties' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + } + for (var key0 in data) { + if (pattern0.test(key0)) { + var errs_1 = errors; + if (!refVal4(data[key0], (dataPath || '') + '[\'' + key0 + '\']', data, key0, rootData)) { + if (vErrors === null) vErrors = refVal4.errors; + else vErrors = vErrors.concat(refVal4.errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + } + } else { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + "", + schemaPath: '#/type', + params: { + type: 'object' + }, + message: 'should be object' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + validate.errors = vErrors; + return errors === 0; + }; + })(); + refVal3.schema = { + "type": "object", + "patternProperties": { + "^[0-9]+$": { + "$ref": "#/definitions/column" + } + }, + "additionalProperties": false + }; + refVal3.errors = null; + refVal[3] = refVal3; + var refVal4 = (function() { + var pattern0 = new RegExp('^[0-9]+$'); + return function validate(data, dataPath, parentData, parentDataProperty, rootData) { + 'use strict'; + var vErrors = null; + var errors = 0; + if (rootData === undefined) rootData = data; + if ((data && typeof data === "object" && !Array.isArray(data))) { + var errs__0 = errors; + var valid1 = true; + for (var key0 in data) { + var isAdditional0 = !(false || validate.schema.properties[key0]); + if (isAdditional0) { + valid1 = false; + var err = { + keyword: 'additionalProperties', + dataPath: (dataPath || '') + "", + schemaPath: '#/additionalProperties', + params: { + additionalProperty: '' + key0 + '' + }, + message: 'should NOT have additional properties' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + } + var data1 = data.alignment; + if (data1 !== undefined) { + var errs_1 = errors; + var schema1 = validate.schema.properties.alignment.enum; + var valid1; + valid1 = false; + for (var i1 = 0; i1 < schema1.length; i1++) + if (equal(data1, schema1[i1])) { + valid1 = true; + break; + } + if (!valid1) { + var err = { + keyword: 'enum', + dataPath: (dataPath || '') + '.alignment', + schemaPath: '#/properties/alignment/enum', + params: { + allowedValues: schema1 + }, + message: 'should be equal to one of the allowed values' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + if (typeof data1 !== "string") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.alignment', + schemaPath: '#/properties/alignment/type', + params: { + type: 'string' + }, + message: 'should be string' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + if (data.width !== undefined) { + var errs_1 = errors; + if (typeof data.width !== "number") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.width', + schemaPath: '#/properties/width/type', + params: { + type: 'number' + }, + message: 'should be number' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + if (data.wrapWord !== undefined) { + var errs_1 = errors; + if (typeof data.wrapWord !== "boolean") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.wrapWord', + schemaPath: '#/properties/wrapWord/type', + params: { + type: 'boolean' + }, + message: 'should be boolean' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + if (data.truncate !== undefined) { + var errs_1 = errors; + if (typeof data.truncate !== "number") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.truncate', + schemaPath: '#/properties/truncate/type', + params: { + type: 'number' + }, + message: 'should be number' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + if (data.paddingLeft !== undefined) { + var errs_1 = errors; + if (typeof data.paddingLeft !== "number") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.paddingLeft', + schemaPath: '#/properties/paddingLeft/type', + params: { + type: 'number' + }, + message: 'should be number' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + if (data.paddingRight !== undefined) { + var errs_1 = errors; + if (typeof data.paddingRight !== "number") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.paddingRight', + schemaPath: '#/properties/paddingRight/type', + params: { + type: 'number' + }, + message: 'should be number' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + } else { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + "", + schemaPath: '#/type', + params: { + type: 'object' + }, + message: 'should be object' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + validate.errors = vErrors; + return errors === 0; + }; + })(); + refVal4.schema = { + "type": "object", + "properties": { + "alignment": { + "type": "string", + "enum": ["left", "right", "center"] + }, + "width": { + "type": "number" + }, + "wrapWord": { + "type": "boolean" + }, + "truncate": { + "type": "number" + }, + "paddingLeft": { + "type": "number" + }, + "paddingRight": { + "type": "number" + } + }, + "additionalProperties": false + }; + refVal4.errors = null; + refVal[4] = refVal4; + return function validate(data, dataPath, parentData, parentDataProperty, rootData) { + 'use strict'; + var vErrors = null; + var errors = 0; + if (rootData === undefined) rootData = data; + if ((data && typeof data === "object" && !Array.isArray(data))) { + var errs__0 = errors; + var valid1 = true; + for (var key0 in data) { + var isAdditional0 = !(false || key0 == 'border' || key0 == 'columns' || key0 == 'columnDefault' || key0 == 'drawHorizontalLine'); + if (isAdditional0) { + valid1 = false; + var err = { + keyword: 'additionalProperties', + dataPath: (dataPath || '') + "", + schemaPath: '#/additionalProperties', + params: { + additionalProperty: '' + key0 + '' + }, + message: 'should NOT have additional properties' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + } + if (data.border !== undefined) { + var errs_1 = errors; + if (!refVal1(data.border, (dataPath || '') + '.border', data, 'border', rootData)) { + if (vErrors === null) vErrors = refVal1.errors; + else vErrors = vErrors.concat(refVal1.errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.columns !== undefined) { + var errs_1 = errors; + if (!refVal3(data.columns, (dataPath || '') + '.columns', data, 'columns', rootData)) { + if (vErrors === null) vErrors = refVal3.errors; + else vErrors = vErrors.concat(refVal3.errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.columnDefault !== undefined) { + var errs_1 = errors; + if (!refVal[4](data.columnDefault, (dataPath || '') + '.columnDefault', data, 'columnDefault', rootData)) { + if (vErrors === null) vErrors = refVal[4].errors; + else vErrors = vErrors.concat(refVal[4].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.drawHorizontalLine !== undefined) { + var errs_1 = errors; + var errs__1 = errors; + var valid1; + if (!(typeof data.drawHorizontalLine == "function")) { + if (errs__1 == errors) { + var err = { + keyword: 'typeof', + dataPath: (dataPath || '') + '.drawHorizontalLine', + schemaPath: '#/properties/drawHorizontalLine/typeof', + params: { + keyword: 'typeof' + }, + message: 'should pass "typeof" keyword validation' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } else { + for (var i1 = errs__1; i1 < errors; i1++) { + var ruleErr1 = vErrors[i1]; + if (ruleErr1.dataPath === undefined) { + ruleErr1.dataPath = (dataPath || '') + '.drawHorizontalLine'; + } + if (ruleErr1.schemaPath === undefined) { + ruleErr1.schemaPath = "#/properties/drawHorizontalLine/typeof"; + } + } + } + } + var valid1 = errors === errs_1; + } + } else { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + "", + schemaPath: '#/type', + params: { + type: 'object' + }, + message: 'should be object' }; - }); - - /* eslint-disable no-console */ - console.log('config', config); - console.log('errors', errors); - /* eslint-enable no-console */ - - throw new Error('Invalid config.'); + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + validate.errors = vErrors; + return errors === 0; + }; +})(); +validate.schema = { + "id": "config.json", + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "border": { + "$ref": "#/definitions/borders" + }, + "columns": { + "$ref": "#/definitions/columns" + }, + "columnDefault": { + "$ref": "#/definitions/column" + }, + "drawHorizontalLine": { + "typeof": "function" + } + }, + "additionalProperties": false, + "definitions": { + "columns": { + "type": "object", + "patternProperties": { + "^[0-9]+$": { + "$ref": "#/definitions/column" + } + }, + "additionalProperties": false + }, + "column": { + "type": "object", + "properties": { + "alignment": { + "type": "string", + "enum": ["left", "right", "center"] + }, + "width": { + "type": "number" + }, + "wrapWord": { + "type": "boolean" + }, + "truncate": { + "type": "number" + }, + "paddingLeft": { + "type": "number" + }, + "paddingRight": { + "type": "number" + } + }, + "additionalProperties": false + }, + "borders": { + "type": "object", + "properties": { + "topBody": { + "$ref": "#/definitions/border" + }, + "topJoin": { + "$ref": "#/definitions/border" + }, + "topLeft": { + "$ref": "#/definitions/border" + }, + "topRight": { + "$ref": "#/definitions/border" + }, + "bottomBody": { + "$ref": "#/definitions/border" + }, + "bottomJoin": { + "$ref": "#/definitions/border" + }, + "bottomLeft": { + "$ref": "#/definitions/border" + }, + "bottomRight": { + "$ref": "#/definitions/border" + }, + "bodyLeft": { + "$ref": "#/definitions/border" + }, + "bodyRight": { + "$ref": "#/definitions/border" + }, + "bodyJoin": { + "$ref": "#/definitions/border" + }, + "joinBody": { + "$ref": "#/definitions/border" + }, + "joinLeft": { + "$ref": "#/definitions/border" + }, + "joinRight": { + "$ref": "#/definitions/border" + }, + "joinJoin": { + "$ref": "#/definitions/border" + } + }, + "additionalProperties": false + }, + "border": { + "type": "string" + } } }; - -module.exports = exports['default']; \ No newline at end of file +validate.errors = null; +module.exports = validate; \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/validateConfig.js.map b/tools/eslint/node_modules/table/dist/validateConfig.js.map deleted file mode 100644 index ad5e82b80bd67e..00000000000000 --- a/tools/eslint/node_modules/table/dist/validateConfig.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["validateConfig.js"],"names":[],"mappings":";;;;;;AAAA;;;;AACA;;;;;;;;;;;;;;;;;;;kBAce,YAAiB;AAAA,QAAhB,MAAgB,yDAAP,EAAO;;AAC5B,QAAI,eAAJ;;AAEA,aAAS,aAAI,cAAJ,CAAmB,MAAnB,mBAAT;;AAEA,QAAI,CAAC,OAAO,KAAZ,EAAmB;;AAEf,gBAAQ,GAAR,CAAY,QAAZ,EAAsB,MAAtB;AACA,gBAAQ,GAAR,CAAY,OAAZ,EAAqB;AACjB,qBAAS,OAAO,KAAP,CAAa,OADL;AAEjB,oBAAQ,OAAO,KAAP,CAAa,MAFJ;AAGjB,sBAAU,OAAO,KAAP,CAAa,QAHN;AAIjB,wBAAY,OAAO,KAAP,CAAa;AAJR,SAArB;;;AAQA,cAAM,IAAI,KAAJ,CAAU,iBAAV,CAAN;AACH;AACJ,C","file":"validateConfig.js","sourcesContent":["import schema from './schemas/config.json';\nimport tv4 from 'tv4';\n\n/**\n * @typedef {string} cell\n */\n\n/**\n * @typedef {cell[]} validateData~column\n */\n\n/**\n * @param {formatData~config} config\n * @returns {undefined}\n */\nexport default (config = {}) => {\n let result;\n\n result = tv4.validateResult(config, schema);\n\n if (!result.valid) {\n /* eslint-disable no-console */\n console.log('config', config);\n console.log('error', {\n message: result.error.message,\n params: result.error.params,\n dataPath: result.error.dataPath,\n schemaPath: result.error.schemaPath\n });\n /* eslint-enable no-console */\n\n throw new Error('Invalid config.');\n }\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/validateStreamConfig.js b/tools/eslint/node_modules/table/dist/validateStreamConfig.js index e5cc85e3046282..09ea2aac925158 100644 --- a/tools/eslint/node_modules/table/dist/validateStreamConfig.js +++ b/tools/eslint/node_modules/table/dist/validateStreamConfig.js @@ -1,53 +1,742 @@ 'use strict'; - -Object.defineProperty(exports, "__esModule", { - value: true -}); - -var _streamConfig = require('./schemas/streamConfig.json'); - -var _streamConfig2 = _interopRequireDefault(_streamConfig); - -var _tv = require('tv4'); - -var _tv2 = _interopRequireDefault(_tv); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -/** - * @typedef {string} cell - */ - -/** - * @typedef {cell[]} validateData~column - */ - -/** - * @param {formatData~config} config - * @returns {undefined} - */ - -exports.default = function () { - var config = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; - - var result = void 0; - - result = _tv2.default.validateResult(config, _streamConfig2.default); - - if (!result.valid) { - /* eslint-disable no-console */ - console.log('config', config); - console.log('error', { - message: result.error.message, - params: result.error.params, - dataPath: result.error.dataPath, - schemaPath: result.error.schemaPath - }); - /* eslint-enable no-console */ - - throw new Error('Invalid config.'); +var equal = require('ajv/lib/compile/equal'); +var validate = (function() { + var pattern0 = new RegExp('^[0-9]+$'); + var refVal = []; + var refVal1 = (function() { + var pattern0 = new RegExp('^[0-9]+$'); + return function validate(data, dataPath, parentData, parentDataProperty, rootData) { + 'use strict'; + var vErrors = null; + var errors = 0; + if (rootData === undefined) rootData = data; + if ((data && typeof data === "object" && !Array.isArray(data))) { + var errs__0 = errors; + var valid1 = true; + for (var key0 in data) { + var isAdditional0 = !(false || validate.schema.properties[key0]); + if (isAdditional0) { + valid1 = false; + var err = { + keyword: 'additionalProperties', + dataPath: (dataPath || '') + "", + schemaPath: '#/additionalProperties', + params: { + additionalProperty: '' + key0 + '' + }, + message: 'should NOT have additional properties' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + } + if (data.topBody !== undefined) { + var errs_1 = errors; + if (!refVal2(data.topBody, (dataPath || '') + '.topBody', data, 'topBody', rootData)) { + if (vErrors === null) vErrors = refVal2.errors; + else vErrors = vErrors.concat(refVal2.errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.topJoin !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.topJoin, (dataPath || '') + '.topJoin', data, 'topJoin', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.topLeft !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.topLeft, (dataPath || '') + '.topLeft', data, 'topLeft', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.topRight !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.topRight, (dataPath || '') + '.topRight', data, 'topRight', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bottomBody !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bottomBody, (dataPath || '') + '.bottomBody', data, 'bottomBody', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bottomJoin !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bottomJoin, (dataPath || '') + '.bottomJoin', data, 'bottomJoin', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bottomLeft !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bottomLeft, (dataPath || '') + '.bottomLeft', data, 'bottomLeft', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bottomRight !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bottomRight, (dataPath || '') + '.bottomRight', data, 'bottomRight', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bodyLeft !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bodyLeft, (dataPath || '') + '.bodyLeft', data, 'bodyLeft', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bodyRight !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bodyRight, (dataPath || '') + '.bodyRight', data, 'bodyRight', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.bodyJoin !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.bodyJoin, (dataPath || '') + '.bodyJoin', data, 'bodyJoin', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.joinBody !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.joinBody, (dataPath || '') + '.joinBody', data, 'joinBody', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.joinLeft !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.joinLeft, (dataPath || '') + '.joinLeft', data, 'joinLeft', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.joinRight !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.joinRight, (dataPath || '') + '.joinRight', data, 'joinRight', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.joinJoin !== undefined) { + var errs_1 = errors; + if (!refVal[2](data.joinJoin, (dataPath || '') + '.joinJoin', data, 'joinJoin', rootData)) { + if (vErrors === null) vErrors = refVal[2].errors; + else vErrors = vErrors.concat(refVal[2].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + } else { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + "", + schemaPath: '#/type', + params: { + type: 'object' + }, + message: 'should be object' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + validate.errors = vErrors; + return errors === 0; + }; + })(); + refVal1.schema = { + "type": "object", + "properties": { + "topBody": { + "$ref": "#/definitions/border" + }, + "topJoin": { + "$ref": "#/definitions/border" + }, + "topLeft": { + "$ref": "#/definitions/border" + }, + "topRight": { + "$ref": "#/definitions/border" + }, + "bottomBody": { + "$ref": "#/definitions/border" + }, + "bottomJoin": { + "$ref": "#/definitions/border" + }, + "bottomLeft": { + "$ref": "#/definitions/border" + }, + "bottomRight": { + "$ref": "#/definitions/border" + }, + "bodyLeft": { + "$ref": "#/definitions/border" + }, + "bodyRight": { + "$ref": "#/definitions/border" + }, + "bodyJoin": { + "$ref": "#/definitions/border" + }, + "joinBody": { + "$ref": "#/definitions/border" + }, + "joinLeft": { + "$ref": "#/definitions/border" + }, + "joinRight": { + "$ref": "#/definitions/border" + }, + "joinJoin": { + "$ref": "#/definitions/border" + } + }, + "additionalProperties": false + }; + refVal1.errors = null; + refVal[1] = refVal1; + var refVal2 = (function() { + var pattern0 = new RegExp('^[0-9]+$'); + return function validate(data, dataPath, parentData, parentDataProperty, rootData) { + 'use strict'; + var vErrors = null; + var errors = 0; + if (rootData === undefined) rootData = data; + if (typeof data !== "string") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + "", + schemaPath: '#/type', + params: { + type: 'string' + }, + message: 'should be string' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + validate.errors = vErrors; + return errors === 0; + }; + })(); + refVal2.schema = { + "type": "string" + }; + refVal2.errors = null; + refVal[2] = refVal2; + var refVal3 = (function() { + var pattern0 = new RegExp('^[0-9]+$'); + return function validate(data, dataPath, parentData, parentDataProperty, rootData) { + 'use strict'; + var vErrors = null; + var errors = 0; + if (rootData === undefined) rootData = data; + if ((data && typeof data === "object" && !Array.isArray(data))) { + var errs__0 = errors; + var valid1 = true; + for (var key0 in data) { + var isAdditional0 = !(false || pattern0.test(key0)); + if (isAdditional0) { + valid1 = false; + var err = { + keyword: 'additionalProperties', + dataPath: (dataPath || '') + "", + schemaPath: '#/additionalProperties', + params: { + additionalProperty: '' + key0 + '' + }, + message: 'should NOT have additional properties' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + } + for (var key0 in data) { + if (pattern0.test(key0)) { + var errs_1 = errors; + if (!refVal4(data[key0], (dataPath || '') + '[\'' + key0 + '\']', data, key0, rootData)) { + if (vErrors === null) vErrors = refVal4.errors; + else vErrors = vErrors.concat(refVal4.errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + } + } else { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + "", + schemaPath: '#/type', + params: { + type: 'object' + }, + message: 'should be object' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + validate.errors = vErrors; + return errors === 0; + }; + })(); + refVal3.schema = { + "type": "object", + "patternProperties": { + "^[0-9]+$": { + "$ref": "#/definitions/column" + } + }, + "additionalProperties": false + }; + refVal3.errors = null; + refVal[3] = refVal3; + var refVal4 = (function() { + var pattern0 = new RegExp('^[0-9]+$'); + return function validate(data, dataPath, parentData, parentDataProperty, rootData) { + 'use strict'; + var vErrors = null; + var errors = 0; + if (rootData === undefined) rootData = data; + if ((data && typeof data === "object" && !Array.isArray(data))) { + var errs__0 = errors; + var valid1 = true; + for (var key0 in data) { + var isAdditional0 = !(false || validate.schema.properties[key0]); + if (isAdditional0) { + valid1 = false; + var err = { + keyword: 'additionalProperties', + dataPath: (dataPath || '') + "", + schemaPath: '#/additionalProperties', + params: { + additionalProperty: '' + key0 + '' + }, + message: 'should NOT have additional properties' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + } + var data1 = data.alignment; + if (data1 !== undefined) { + var errs_1 = errors; + var schema1 = validate.schema.properties.alignment.enum; + var valid1; + valid1 = false; + for (var i1 = 0; i1 < schema1.length; i1++) + if (equal(data1, schema1[i1])) { + valid1 = true; + break; + } + if (!valid1) { + var err = { + keyword: 'enum', + dataPath: (dataPath || '') + '.alignment', + schemaPath: '#/properties/alignment/enum', + params: { + allowedValues: schema1 + }, + message: 'should be equal to one of the allowed values' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + if (typeof data1 !== "string") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.alignment', + schemaPath: '#/properties/alignment/type', + params: { + type: 'string' + }, + message: 'should be string' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + if (data.width !== undefined) { + var errs_1 = errors; + if (typeof data.width !== "number") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.width', + schemaPath: '#/properties/width/type', + params: { + type: 'number' + }, + message: 'should be number' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + if (data.wrapWord !== undefined) { + var errs_1 = errors; + if (typeof data.wrapWord !== "boolean") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.wrapWord', + schemaPath: '#/properties/wrapWord/type', + params: { + type: 'boolean' + }, + message: 'should be boolean' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + if (data.truncate !== undefined) { + var errs_1 = errors; + if (typeof data.truncate !== "number") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.truncate', + schemaPath: '#/properties/truncate/type', + params: { + type: 'number' + }, + message: 'should be number' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + if (data.paddingLeft !== undefined) { + var errs_1 = errors; + if (typeof data.paddingLeft !== "number") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.paddingLeft', + schemaPath: '#/properties/paddingLeft/type', + params: { + type: 'number' + }, + message: 'should be number' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + if (data.paddingRight !== undefined) { + var errs_1 = errors; + if (typeof data.paddingRight !== "number") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.paddingRight', + schemaPath: '#/properties/paddingRight/type', + params: { + type: 'number' + }, + message: 'should be number' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + } else { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + "", + schemaPath: '#/type', + params: { + type: 'object' + }, + message: 'should be object' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + validate.errors = vErrors; + return errors === 0; + }; + })(); + refVal4.schema = { + "type": "object", + "properties": { + "alignment": { + "type": "string", + "enum": ["left", "right", "center"] + }, + "width": { + "type": "number" + }, + "wrapWord": { + "type": "boolean" + }, + "truncate": { + "type": "number" + }, + "paddingLeft": { + "type": "number" + }, + "paddingRight": { + "type": "number" + } + }, + "additionalProperties": false + }; + refVal4.errors = null; + refVal[4] = refVal4; + return function validate(data, dataPath, parentData, parentDataProperty, rootData) { + 'use strict'; + var vErrors = null; + var errors = 0; + if (rootData === undefined) rootData = data; + if ((data && typeof data === "object" && !Array.isArray(data))) { + var errs__0 = errors; + var valid1 = true; + for (var key0 in data) { + var isAdditional0 = !(false || key0 == 'border' || key0 == 'columns' || key0 == 'columnDefault' || key0 == 'columnCount'); + if (isAdditional0) { + valid1 = false; + var err = { + keyword: 'additionalProperties', + dataPath: (dataPath || '') + "", + schemaPath: '#/additionalProperties', + params: { + additionalProperty: '' + key0 + '' + }, + message: 'should NOT have additional properties' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + } + if (data.border !== undefined) { + var errs_1 = errors; + if (!refVal1(data.border, (dataPath || '') + '.border', data, 'border', rootData)) { + if (vErrors === null) vErrors = refVal1.errors; + else vErrors = vErrors.concat(refVal1.errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.columns !== undefined) { + var errs_1 = errors; + if (!refVal3(data.columns, (dataPath || '') + '.columns', data, 'columns', rootData)) { + if (vErrors === null) vErrors = refVal3.errors; + else vErrors = vErrors.concat(refVal3.errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.columnDefault !== undefined) { + var errs_1 = errors; + if (!refVal[4](data.columnDefault, (dataPath || '') + '.columnDefault', data, 'columnDefault', rootData)) { + if (vErrors === null) vErrors = refVal[4].errors; + else vErrors = vErrors.concat(refVal[4].errors); + errors = vErrors.length; + } + var valid1 = errors === errs_1; + } + if (data.columnCount !== undefined) { + var errs_1 = errors; + if (typeof data.columnCount !== "number") { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + '.columnCount', + schemaPath: '#/properties/columnCount/type', + params: { + type: 'number' + }, + message: 'should be number' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; + } + var valid1 = errors === errs_1; + } + } else { + var err = { + keyword: 'type', + dataPath: (dataPath || '') + "", + schemaPath: '#/type', + params: { + type: 'object' + }, + message: 'should be object' + }; + if (vErrors === null) vErrors = [err]; + else vErrors.push(err); + errors++; } + validate.errors = vErrors; + return errors === 0; + }; +})(); +validate.schema = { + "id": "streamConfig.json", + "$schema": "http://json-schema.org/draft-04/schema#", + "type": "object", + "properties": { + "border": { + "$ref": "#/definitions/borders" + }, + "columns": { + "$ref": "#/definitions/columns" + }, + "columnDefault": { + "$ref": "#/definitions/column" + }, + "columnCount": { + "type": "number" + } + }, + "additionalProperties": false, + "definitions": { + "columns": { + "type": "object", + "patternProperties": { + "^[0-9]+$": { + "$ref": "#/definitions/column" + } + }, + "additionalProperties": false + }, + "column": { + "type": "object", + "properties": { + "alignment": { + "type": "string", + "enum": ["left", "right", "center"] + }, + "width": { + "type": "number" + }, + "wrapWord": { + "type": "boolean" + }, + "truncate": { + "type": "number" + }, + "paddingLeft": { + "type": "number" + }, + "paddingRight": { + "type": "number" + } + }, + "additionalProperties": false + }, + "borders": { + "type": "object", + "properties": { + "topBody": { + "$ref": "#/definitions/border" + }, + "topJoin": { + "$ref": "#/definitions/border" + }, + "topLeft": { + "$ref": "#/definitions/border" + }, + "topRight": { + "$ref": "#/definitions/border" + }, + "bottomBody": { + "$ref": "#/definitions/border" + }, + "bottomJoin": { + "$ref": "#/definitions/border" + }, + "bottomLeft": { + "$ref": "#/definitions/border" + }, + "bottomRight": { + "$ref": "#/definitions/border" + }, + "bodyLeft": { + "$ref": "#/definitions/border" + }, + "bodyRight": { + "$ref": "#/definitions/border" + }, + "bodyJoin": { + "$ref": "#/definitions/border" + }, + "joinBody": { + "$ref": "#/definitions/border" + }, + "joinLeft": { + "$ref": "#/definitions/border" + }, + "joinRight": { + "$ref": "#/definitions/border" + }, + "joinJoin": { + "$ref": "#/definitions/border" + } + }, + "additionalProperties": false + }, + "border": { + "type": "string" + } + } }; - -module.exports = exports['default']; -//# sourceMappingURL=validateStreamConfig.js.map +validate.errors = null; +module.exports = validate; \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/validateStreamConfig.js.map b/tools/eslint/node_modules/table/dist/validateStreamConfig.js.map deleted file mode 100644 index c43bee9d5f1e1e..00000000000000 --- a/tools/eslint/node_modules/table/dist/validateStreamConfig.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["validateStreamConfig.js"],"names":[],"mappings":";;;;;;AAAA;;;;AACA;;;;;;;;;;;;;;;;;;;kBAce,YAAiB;AAAA,QAAhB,MAAgB,yDAAP,EAAO;;AAC5B,QAAI,eAAJ;;AAEA,aAAS,aAAI,cAAJ,CAAmB,MAAnB,yBAAT;;AAEA,QAAI,CAAC,OAAO,KAAZ,EAAmB;;AAEf,gBAAQ,GAAR,CAAY,QAAZ,EAAsB,MAAtB;AACA,gBAAQ,GAAR,CAAY,OAAZ,EAAqB;AACjB,qBAAS,OAAO,KAAP,CAAa,OADL;AAEjB,oBAAQ,OAAO,KAAP,CAAa,MAFJ;AAGjB,sBAAU,OAAO,KAAP,CAAa,QAHN;AAIjB,wBAAY,OAAO,KAAP,CAAa;AAJR,SAArB;;;AAQA,cAAM,IAAI,KAAJ,CAAU,iBAAV,CAAN;AACH;AACJ,C","file":"validateStreamConfig.js","sourcesContent":["import schema from './schemas/streamConfig.json';\nimport tv4 from 'tv4';\n\n/**\n * @typedef {string} cell\n */\n\n/**\n * @typedef {cell[]} validateData~column\n */\n\n/**\n * @param {formatData~config} config\n * @returns {undefined}\n */\nexport default (config = {}) => {\n let result;\n\n result = tv4.validateResult(config, schema);\n\n if (!result.valid) {\n /* eslint-disable no-console */\n console.log('config', config);\n console.log('error', {\n message: result.error.message,\n params: result.error.params,\n dataPath: result.error.dataPath,\n schemaPath: result.error.schemaPath\n });\n /* eslint-enable no-console */\n\n throw new Error('Invalid config.');\n }\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/validateTableData.js.map b/tools/eslint/node_modules/table/dist/validateTableData.js.map deleted file mode 100644 index 92092051fad066..00000000000000 --- a/tools/eslint/node_modules/table/dist/validateTableData.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["validateTableData.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAce,UAAC,IAAD,EAAU;AACrB,QAAI,qBAAJ;;AAEA,QAAI,CAAC,uBAAU,IAAV,CAAL,EAAsB;AAClB,cAAM,IAAI,KAAJ,CAAU,8BAAV,CAAN;AACH;;AAED,QAAI,KAAK,MAAL,KAAgB,CAApB,EAAuB;AACnB,cAAM,IAAI,KAAJ,CAAU,qCAAV,CAAN;AACH;;AAED,QAAI,KAAK,CAAL,EAAQ,MAAR,KAAmB,CAAvB,EAA0B;AACtB,cAAM,IAAI,KAAJ,CAAU,wCAAV,CAAN;AACH;;AAED,mBAAe,KAAK,CAAL,EAAQ,MAAvB;;AAEA,2BAAU,IAAV,EAAgB,UAAC,KAAD,EAAW;AACvB,YAAI,CAAC,uBAAU,KAAV,CAAL,EAAuB;AACnB,kBAAM,IAAI,KAAJ,CAAU,kCAAV,CAAN;AACH;;AAED,YAAI,MAAM,MAAN,KAAiB,YAArB,EAAmC;AAC/B,kBAAM,IAAI,KAAJ,CAAU,+CAAV,CAAN;AACH;;;;AAID,+BAAU,KAAV,EAAiB,UAAC,IAAD,EAAU;AACvB,gBAAI,cAAc,IAAd,CAAmB,IAAnB,CAAJ,EAA8B;AAC1B,sBAAM,IAAI,KAAJ,CAAU,iDAAV,CAAN;AACH;AACJ,SAJD;AAKH,KAhBD;AAiBH,C","file":"validateTableData.js","sourcesContent":["import _ from 'lodash';\n\n/**\n * @typedef {string} cell\n */\n\n/**\n * @typedef {cell[]} validateData~column\n */\n\n/**\n * @param {column[]} rows\n * @returns {undefined}\n */\nexport default (rows) => {\n let columnNumber;\n\n if (!_.isArray(rows)) {\n throw new Error('Table data must be an array.');\n }\n\n if (rows.length === 0) {\n throw new Error('Table must define at least one row.');\n }\n\n if (rows[0].length === 0) {\n throw new Error('Table must define at least one column.');\n }\n\n columnNumber = rows[0].length;\n\n _.forEach(rows, (cells) => {\n if (!_.isArray(cells)) {\n throw new Error('Table row data must be an array.');\n }\n\n if (cells.length !== columnNumber) {\n throw new Error('Table must have a consistent number of cells.');\n }\n\n // @todo Make an exception for newline characters.\n // @see https://github.com/gajus/table/issues/9\n _.forEach(cells, (cell) => {\n if (/[\\x01-\\x1A]/.test(cell)) {\n throw new Error('Table data must not contain control characters.');\n }\n });\n });\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/wrapString.js.map b/tools/eslint/node_modules/table/dist/wrapString.js.map deleted file mode 100644 index 0ba89f7ddd6406..00000000000000 --- a/tools/eslint/node_modules/table/dist/wrapString.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["wrapString.js"],"names":[],"mappings":";;;;;;;;;;AACA;;;;AACA;;;;;;;;;;;;;;;;;;kBAae,UAAC,OAAD,EAAU,IAAV,EAAmB;AAC9B,QAAI,eAAJ;QACI,qBADJ;;AAGA,mBAAe,OAAf;;AAEA,aAAS,EAAT;;AAEA,OAAG;AACC,eAAO,IAAP,CAAY,yBAAM,YAAN,EAAoB,CAApB,EAAuB,IAAvB,CAAZ;;AAEA,uBAAe,oBAAO,yBAAM,YAAN,EAAoB,IAApB,CAAP,CAAf;AACH,KAJD,QAIS,2BAAY,YAAZ,CAJT;;AAMA,WAAO,MAAP;AACH,C","file":"wrapString.js","sourcesContent":["import _ from 'lodash';\nimport slice from 'slice-ansi';\nimport stringWidth from 'string-width';\n\n/**\n * Creates an array of strings split into groups the length of size.\n * This function works with strings that contain ASCII characters.\n *\n * wrapText is different from would-be \"chunk\" implementation\n * in that whitespace characters that occur on a chunk size limit are trimmed.\n *\n * @param {string} subject\n * @param {number} size\n * @returns {Array}\n */\nexport default (subject, size) => {\n let chunks,\n subjectSlice;\n\n subjectSlice = subject;\n\n chunks = [];\n\n do {\n chunks.push(slice(subjectSlice, 0, size));\n\n subjectSlice = _.trim(slice(subjectSlice, size));\n } while (stringWidth(subjectSlice));\n\n return chunks;\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/dist/wrapWord.js.map b/tools/eslint/node_modules/table/dist/wrapWord.js.map deleted file mode 100644 index 92e36ba776c864..00000000000000 --- a/tools/eslint/node_modules/table/dist/wrapWord.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"sources":["wrapWord.js"],"names":[],"mappings":";;;;;;;;;;AACA;;;;AACA;;;;;;;;;;;;kBAOe,UAAC,KAAD,EAAQ,IAAR,EAAiB;AAC5B,QAAI,cAAJ;QACI,eADJ;QAEI,WAFJ;QAGI,gBAHJ;;AAKA,cAAU,KAAV;;AAEA,aAAS,EAAT;;;AAGA,SAAK,IAAI,MAAJ,CAAW,WAAW,IAAX,GAAkB,mBAAlB,IAAyC,OAAO,CAAhD,IAAqD,yBAAhE,CAAL;;AAEA,OAAG;AACC,gBAAQ,QAAQ,KAAR,CAAc,EAAd,CAAR;;;;AAIA,YAAI,KAAJ,EAAW;AACP,oBAAQ,MAAM,CAAN,CAAR;;AAEA,sBAAU,yBAAM,OAAN,EAAe,2BAAY,KAAZ,CAAf,CAAV;;AAEA,oBAAQ,oBAAO,KAAP,CAAR;AACH,SAND,MAMO;AACH,oBAAQ,yBAAM,OAAN,EAAe,CAAf,EAAkB,IAAlB,CAAR;AACA,sBAAU,yBAAM,OAAN,EAAe,IAAf,CAAV;AACH;;AAED,eAAO,IAAP,CAAY,KAAZ;AACH,KAjBD,QAiBS,2BAAY,OAAZ,CAjBT;;AAmBA,WAAO,MAAP;AACH,C","file":"wrapWord.js","sourcesContent":["import _ from 'lodash';\nimport slice from 'slice-ansi';\nimport stringWidth from 'string-width';\n\n/**\n * @param {string} input\n * @param {number} size\n * @returns {Array}\n */\nexport default (input, size) => {\n let chunk,\n chunks,\n re,\n subject;\n\n subject = input;\n\n chunks = [];\n\n // https://regex101.com/r/gY5kZ1/1\n re = new RegExp('(^.{1,' + size + '}(\\\\s+|$))|(^.{1,' + (size - 1) + '}(\\\\\\\\|/|_|\\\\.|,|;|\\-))');\n\n do {\n chunk = subject.match(re);\n\n // console.log('chunk', chunk, re);\n\n if (chunk) {\n chunk = chunk[0];\n\n subject = slice(subject, stringWidth(chunk));\n\n chunk = _.trim(chunk);\n } else {\n chunk = slice(subject, 0, size);\n subject = slice(subject, size);\n }\n\n chunks.push(chunk);\n } while (stringWidth(subject));\n\n return chunks;\n};\n"]} \ No newline at end of file diff --git a/tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/index.js b/tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/index.js new file mode 100644 index 00000000000000..d506327c3e5576 --- /dev/null +++ b/tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/index.js @@ -0,0 +1,46 @@ +'use strict'; +/* eslint-disable yoda */ +module.exports = x => { + if (Number.isNaN(x)) { + return false; + } + + // code points are derived from: + // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt + if ( + x >= 0x1100 && ( + x <= 0x115f || // Hangul Jamo + x === 0x2329 || // LEFT-POINTING ANGLE BRACKET + x === 0x232a || // RIGHT-POINTING ANGLE BRACKET + // CJK Radicals Supplement .. Enclosed CJK Letters and Months + (0x2e80 <= x && x <= 0x3247 && x !== 0x303f) || + // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A + (0x3250 <= x && x <= 0x4dbf) || + // CJK Unified Ideographs .. Yi Radicals + (0x4e00 <= x && x <= 0xa4c6) || + // Hangul Jamo Extended-A + (0xa960 <= x && x <= 0xa97c) || + // Hangul Syllables + (0xac00 <= x && x <= 0xd7a3) || + // CJK Compatibility Ideographs + (0xf900 <= x && x <= 0xfaff) || + // Vertical Forms + (0xfe10 <= x && x <= 0xfe19) || + // CJK Compatibility Forms .. Small Form Variants + (0xfe30 <= x && x <= 0xfe6b) || + // Halfwidth and Fullwidth Forms + (0xff01 <= x && x <= 0xff60) || + (0xffe0 <= x && x <= 0xffe6) || + // Kana Supplement + (0x1b000 <= x && x <= 0x1b001) || + // Enclosed Ideographic Supplement + (0x1f200 <= x && x <= 0x1f251) || + // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane + (0x20000 <= x && x <= 0x3fffd) + ) + ) { + return true; + } + + return false; +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/license b/tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/license similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/code-point-at/node_modules/number-is-nan/license rename to tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/license diff --git a/tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/package.json b/tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/package.json new file mode 100644 index 00000000000000..4f2674f067ec32 --- /dev/null +++ b/tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/package.json @@ -0,0 +1,113 @@ +{ + "_args": [ + [ + { + "raw": "is-fullwidth-code-point@^2.0.0", + "scope": null, + "escapedName": "is-fullwidth-code-point", + "name": "is-fullwidth-code-point", + "rawSpec": "^2.0.0", + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "/Users/trott/io.js/tools/node_modules/table/node_modules/string-width" + ] + ], + "_from": "is-fullwidth-code-point@>=2.0.0 <3.0.0", + "_id": "is-fullwidth-code-point@2.0.0", + "_inCache": true, + "_location": "/table/is-fullwidth-code-point", + "_nodeVersion": "4.5.0", + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/is-fullwidth-code-point-2.0.0.tgz_1474526567505_0.299921662081033" + }, + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "_npmVersion": "3.10.7", + "_phantomChildren": {}, + "_requested": { + "raw": "is-fullwidth-code-point@^2.0.0", + "scope": null, + "escapedName": "is-fullwidth-code-point", + "name": "is-fullwidth-code-point", + "rawSpec": "^2.0.0", + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/table/string-width" + ], + "_resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "_shasum": "a3b30a5c4f199183167aaab93beefae3ddfb654f", + "_shrinkwrap": null, + "_spec": "is-fullwidth-code-point@^2.0.0", + "_where": "/Users/trott/io.js/tools/node_modules/table/node_modules/string-width", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/is-fullwidth-code-point/issues" + }, + "dependencies": {}, + "description": "Check if the character represented by a given Unicode code point is fullwidth", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "a3b30a5c4f199183167aaab93beefae3ddfb654f", + "tarball": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz" + }, + "engines": { + "node": ">=4" + }, + "files": [ + "index.js" + ], + "gitHead": "e94a78056056c5546f2bf4c4cf812a2163a46dae", + "homepage": "https://github.com/sindresorhus/is-fullwidth-code-point#readme", + "keywords": [ + "fullwidth", + "full-width", + "full", + "width", + "unicode", + "character", + "char", + "string", + "str", + "codepoint", + "code", + "point", + "is", + "detect", + "check" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "is-fullwidth-code-point", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/is-fullwidth-code-point.git" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "2.0.0", + "xo": { + "esnext": true + } +} diff --git a/tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/readme.md b/tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/readme.md new file mode 100644 index 00000000000000..093b0281b2c46b --- /dev/null +++ b/tools/eslint/node_modules/table/node_modules/is-fullwidth-code-point/readme.md @@ -0,0 +1,39 @@ +# is-fullwidth-code-point [![Build Status](https://travis-ci.org/sindresorhus/is-fullwidth-code-point.svg?branch=master)](https://travis-ci.org/sindresorhus/is-fullwidth-code-point) + +> Check if the character represented by a given [Unicode code point](https://en.wikipedia.org/wiki/Code_point) is [fullwidth](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) + + +## Install + +``` +$ npm install --save is-fullwidth-code-point +``` + + +## Usage + +```js +const isFullwidthCodePoint = require('is-fullwidth-code-point'); + +isFullwidthCodePoint('谢'.codePointAt()); +//=> true + +isFullwidthCodePoint('a'.codePointAt()); +//=> false +``` + + +## API + +### isFullwidthCodePoint(input) + +#### input + +Type: `number` + +[Code point](https://en.wikipedia.org/wiki/Code_point) of a character. + + +## License + +MIT © [Sindre Sorhus](https://sindresorhus.com) diff --git a/tools/eslint/node_modules/table/node_modules/string-width/index.js b/tools/eslint/node_modules/table/node_modules/string-width/index.js new file mode 100644 index 00000000000000..25a8943c1dcad6 --- /dev/null +++ b/tools/eslint/node_modules/table/node_modules/string-width/index.js @@ -0,0 +1,35 @@ +'use strict'; +const stripAnsi = require('strip-ansi'); +const isFullwidthCodePoint = require('is-fullwidth-code-point'); + +module.exports = str => { + if (typeof str !== 'string' || str.length === 0) { + return 0; + } + + let width = 0; + + str = stripAnsi(str); + + for (let i = 0; i < str.length; i++) { + const code = str.codePointAt(i); + + // ignore control characters + if (code <= 0x1f || (code >= 0x7f && code <= 0x9f)) { + continue; + } + + // surrogates + if (code >= 0x10000) { + i++; + } + + if (isFullwidthCodePoint(code)) { + width += 2; + } else { + width++; + } + } + + return width; +}; diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/license b/tools/eslint/node_modules/table/node_modules/string-width/license similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/node_modules/is-fullwidth-code-point/license rename to tools/eslint/node_modules/table/node_modules/string-width/license diff --git a/tools/eslint/node_modules/table/node_modules/string-width/package.json b/tools/eslint/node_modules/table/node_modules/string-width/package.json new file mode 100644 index 00000000000000..2fd6a297eb8855 --- /dev/null +++ b/tools/eslint/node_modules/table/node_modules/string-width/package.json @@ -0,0 +1,125 @@ +{ + "_args": [ + [ + { + "raw": "string-width@^2.0.0", + "scope": null, + "escapedName": "string-width", + "name": "string-width", + "rawSpec": "^2.0.0", + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "/Users/trott/io.js/tools/node_modules/table" + ] + ], + "_from": "string-width@>=2.0.0 <3.0.0", + "_id": "string-width@2.0.0", + "_inCache": true, + "_location": "/table/string-width", + "_nodeVersion": "4.5.0", + "_npmOperationalInternal": { + "host": "packages-16-east.internal.npmjs.com", + "tmp": "tmp/string-width-2.0.0.tgz_1474527284011_0.7386264291126281" + }, + "_npmUser": { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + }, + "_npmVersion": "3.10.7", + "_phantomChildren": {}, + "_requested": { + "raw": "string-width@^2.0.0", + "scope": null, + "escapedName": "string-width", + "name": "string-width", + "rawSpec": "^2.0.0", + "spec": ">=2.0.0 <3.0.0", + "type": "range" + }, + "_requiredBy": [ + "/table" + ], + "_resolved": "https://registry.npmjs.org/string-width/-/string-width-2.0.0.tgz", + "_shasum": "635c5436cc72a6e0c387ceca278d4e2eec52687e", + "_shrinkwrap": null, + "_spec": "string-width@^2.0.0", + "_where": "/Users/trott/io.js/tools/node_modules/table", + "author": { + "name": "Sindre Sorhus", + "email": "sindresorhus@gmail.com", + "url": "sindresorhus.com" + }, + "bugs": { + "url": "https://github.com/sindresorhus/string-width/issues" + }, + "dependencies": { + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^3.0.0" + }, + "description": "Get the visual width of a string - the number of columns required to display it", + "devDependencies": { + "ava": "*", + "xo": "*" + }, + "directories": {}, + "dist": { + "shasum": "635c5436cc72a6e0c387ceca278d4e2eec52687e", + "tarball": "https://registry.npmjs.org/string-width/-/string-width-2.0.0.tgz" + }, + "engines": { + "node": ">=4" + }, + "files": [ + "index.js" + ], + "gitHead": "523d7ba4dbb24d40cde88d2c36bb1c7124ab6f82", + "homepage": "https://github.com/sindresorhus/string-width#readme", + "keywords": [ + "string", + "str", + "character", + "char", + "unicode", + "width", + "visual", + "column", + "columns", + "fullwidth", + "full-width", + "full", + "ansi", + "escape", + "codes", + "cli", + "command-line", + "terminal", + "console", + "cjk", + "chinese", + "japanese", + "korean", + "fixed-width" + ], + "license": "MIT", + "maintainers": [ + { + "name": "sindresorhus", + "email": "sindresorhus@gmail.com" + } + ], + "name": "string-width", + "optionalDependencies": {}, + "readme": "ERROR: No README data found!", + "repository": { + "type": "git", + "url": "git+https://github.com/sindresorhus/string-width.git" + }, + "scripts": { + "test": "xo && ava" + }, + "version": "2.0.0", + "xo": { + "esnext": true + } +} diff --git a/deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/readme.md b/tools/eslint/node_modules/table/node_modules/string-width/readme.md similarity index 100% rename from deps/npm/node_modules/node-gyp/node_modules/npmlog/node_modules/gauge/node_modules/string-width/readme.md rename to tools/eslint/node_modules/table/node_modules/string-width/readme.md diff --git a/tools/eslint/node_modules/table/package.json b/tools/eslint/node_modules/table/package.json index fb2f250fa08068..33c29ec498b7ce 100644 --- a/tools/eslint/node_modules/table/package.json +++ b/tools/eslint/node_modules/table/package.json @@ -14,20 +14,22 @@ ] ], "_from": "table@>=3.7.8 <4.0.0", - "_id": "table@3.8.0", + "_id": "table@3.8.3", "_inCache": true, "_location": "/table", - "_nodeVersion": "6.4.0", + "_nodeVersion": "6.8.1", "_npmOperationalInternal": { "host": "packages-16-east.internal.npmjs.com", - "tmp": "tmp/table-3.8.0.tgz_1474139512457_0.8613335366826504" + "tmp": "tmp/table-3.8.3.tgz_1476810452789_0.6529890382662416" }, "_npmUser": { "name": "gajus", "email": "gajus@gajus.com" }, - "_npmVersion": "3.10.3", - "_phantomChildren": {}, + "_npmVersion": "3.10.8", + "_phantomChildren": { + "strip-ansi": "3.0.1" + }, "_requested": { "raw": "table@^3.7.8", "scope": null, @@ -40,8 +42,8 @@ "_requiredBy": [ "/eslint" ], - "_resolved": "https://registry.npmjs.org/table/-/table-3.8.0.tgz", - "_shasum": "252166c7f3286684a9d561b0f3a8929caf3a997b", + "_resolved": "https://registry.npmjs.org/table/-/table-3.8.3.tgz", + "_shasum": "2bbc542f0fda9861a755d3947fefd8b3f513855f", "_shrinkwrap": null, "_spec": "table@^3.7.8", "_where": "/Users/trott/io.js/tools/node_modules/eslint", @@ -59,28 +61,33 @@ "chalk": "^1.1.1", "lodash": "^4.0.0", "slice-ansi": "0.0.4", - "string-width": "^1.0.1" + "string-width": "^2.0.0" }, "description": "Formats data into a string table.", "devDependencies": { + "ajv-cli": "^1.1.0", "babel": "^6.5.2", "babel-cli": "^6.14.0", + "babel-core": "^6.14.0", "babel-plugin-add-module-exports": "^0.2.1", + "babel-plugin-istanbul": "^2.0.3", "babel-preset-es2015-node4": "^2.1.0", "babel-register": "^6.14.0", "chai": "^3.4.1", "eslint": "^3.5.0", "eslint-config-canonical": "^1.8.6", "gitdown": "^2.4.0", + "husky": "^0.11.7", "mocha": "^3.0.2", + "nyc": "^8.3.1", "sinon": "^1.17.2" }, "directories": {}, "dist": { - "shasum": "252166c7f3286684a9d561b0f3a8929caf3a997b", - "tarball": "https://registry.npmjs.org/table/-/table-3.8.0.tgz" + "shasum": "2bbc542f0fda9861a755d3947fefd8b3f513855f", + "tarball": "https://registry.npmjs.org/table/-/table-3.8.3.tgz" }, - "gitHead": "076dd77627213007a989b2c845fa2f3a38896eeb", + "gitHead": "2d1c0d9ebad31f9c76e784e6a88f701de8705005", "homepage": "https://github.com/gajus/table#readme", "keywords": [ "ascii", @@ -98,6 +105,17 @@ } ], "name": "table", + "nyc": { + "include": [ + "src/*.js" + ], + "instrument": false, + "lines": 70, + "require": [ + "babel-register" + ], + "sourceMap": false + }, "optionalDependencies": {}, "readme": "ERROR: No README data found!", "repository": { @@ -105,10 +123,13 @@ "url": "git+https://github.com/gajus/table.git" }, "scripts": { - "build": "babel --copy-files ./src --out-dir ./dist", - "lint": "eslint ./src ./tests", - "readme": "gitdown ./.README/README.md --output-file ./README.md", - "test": "mocha --compilers js:babel-register" + "build": "rm -fr ./dist && babel --copy-files ./src --out-dir ./dist && npm run make-validators", + "lint": "npm run build && eslint ./src ./tests", + "make-readme": "gitdown ./.README/README.md --output-file ./README.md", + "make-validators": "ajv compile --all-errors --inline-refs=false -s src/schemas/config -c ajv-keywords/keywords/typeof -o dist/validateConfig.js && ajv compile --all-errors --inline-refs=false -s src/schemas/streamConfig -c ajv-keywords/keywords/typeof -o dist/validateStreamConfig.js", + "precommit": "npm run lint && npm run test", + "prepublish": "NODE_ENV=production npm run build", + "test": "npm run build && nyc --check-coverage mocha" }, - "version": "3.8.0" + "version": "3.8.3" } diff --git a/tools/eslint/node_modules/tryit/package.json b/tools/eslint/node_modules/tryit/package.json index 7a7a28b076f45c..e0b4e1b8dac03e 100644 --- a/tools/eslint/node_modules/tryit/package.json +++ b/tools/eslint/node_modules/tryit/package.json @@ -14,15 +14,19 @@ ] ], "_from": "tryit@>=1.0.1 <2.0.0", - "_id": "tryit@1.0.2", + "_id": "tryit@1.0.3", "_inCache": true, "_location": "/tryit", - "_nodeVersion": "4.1.0", + "_nodeVersion": "6.8.1", + "_npmOperationalInternal": { + "host": "packages-12-west.internal.npmjs.com", + "tmp": "tmp/tryit-1.0.3.tgz_1477606530482_0.8131801665294915" + }, "_npmUser": { "name": "henrikjoreteg", "email": "henrik@joreteg.com" }, - "_npmVersion": "3.3.8", + "_npmVersion": "3.10.8", "_phantomChildren": {}, "_requested": { "raw": "tryit@^1.0.1", @@ -36,8 +40,8 @@ "_requiredBy": [ "/is-resolvable" ], - "_resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.2.tgz", - "_shasum": "c196b0073e6b1c595d93c9c830855b7acc32a453", + "_resolved": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz", + "_shasum": "393be730a9446fd1ead6da59a014308f36c289cb", "_shrinkwrap": null, "_spec": "tryit@^1.0.1", "_where": "/Users/trott/io.js/tools/node_modules/is-resolvable", @@ -56,10 +60,13 @@ }, "directories": {}, "dist": { - "shasum": "c196b0073e6b1c595d93c9c830855b7acc32a453", - "tarball": "https://registry.npmjs.org/tryit/-/tryit-1.0.2.tgz" + "shasum": "393be730a9446fd1ead6da59a014308f36c289cb", + "tarball": "https://registry.npmjs.org/tryit/-/tryit-1.0.3.tgz" }, - "gitHead": "b567b4feb491e2ee89addd3d06f66d6ec2217cf5", + "files": [ + "tryit.js" + ], + "gitHead": "706147151922a456988a641b08984b2d1fcf2a86", "homepage": "https://github.com/HenrikJoreteg/tryit#readme", "keywords": [ "errors", @@ -84,5 +91,5 @@ "scripts": { "test": "node test/test.js | tap-spec" }, - "version": "1.0.2" + "version": "1.0.3" } diff --git a/tools/eslint/node_modules/typedarray/package.json b/tools/eslint/node_modules/typedarray/package.json index ab02da539baf7a..19821370412450 100644 --- a/tools/eslint/node_modules/typedarray/package.json +++ b/tools/eslint/node_modules/typedarray/package.json @@ -2,18 +2,18 @@ "_args": [ [ { - "raw": "typedarray@~0.0.5", + "raw": "typedarray@^0.0.6", "scope": null, "escapedName": "typedarray", "name": "typedarray", - "rawSpec": "~0.0.5", - "spec": ">=0.0.5 <0.1.0", + "rawSpec": "^0.0.6", + "spec": ">=0.0.6 <0.0.7", "type": "range" }, "/Users/trott/io.js/tools/node_modules/concat-stream" ] ], - "_from": "typedarray@>=0.0.5 <0.1.0", + "_from": "typedarray@>=0.0.6 <0.0.7", "_id": "typedarray@0.0.6", "_inCache": true, "_location": "/typedarray", @@ -24,12 +24,12 @@ "_npmVersion": "1.4.3", "_phantomChildren": {}, "_requested": { - "raw": "typedarray@~0.0.5", + "raw": "typedarray@^0.0.6", "scope": null, "escapedName": "typedarray", "name": "typedarray", - "rawSpec": "~0.0.5", - "spec": ">=0.0.5 <0.1.0", + "rawSpec": "^0.0.6", + "spec": ">=0.0.6 <0.0.7", "type": "range" }, "_requiredBy": [ @@ -38,7 +38,7 @@ "_resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "_shasum": "867ac74e3864187b1d3d47d996a78ec5c8830777", "_shrinkwrap": null, - "_spec": "typedarray@~0.0.5", + "_spec": "typedarray@^0.0.6", "_where": "/Users/trott/io.js/tools/node_modules/concat-stream", "author": { "name": "James Halliday", diff --git a/tools/eslint/package.json b/tools/eslint/package.json index f0155d89330b9c..d6c8d488cb5dfa 100644 --- a/tools/eslint/package.json +++ b/tools/eslint/package.json @@ -2,25 +2,25 @@ "_args": [ [ { - "raw": "eslint", + "raw": "eslint@3.13.0", "scope": null, "escapedName": "eslint", "name": "eslint", - "rawSpec": "", - "spec": "latest", - "type": "tag" + "rawSpec": "3.13.0", + "spec": "3.13.0", + "type": "version" }, "/Users/trott/io.js/tools" ] ], - "_from": "eslint@latest", - "_id": "eslint@3.8.0", + "_from": "eslint@3.13.0", + "_id": "eslint@3.13.0", "_inCache": true, "_location": "/eslint", "_nodeVersion": "4.4.7", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", - "tmp": "tmp/eslint-3.8.0.tgz_1476481030547_0.1366094599943608" + "tmp": "tmp/eslint-3.13.0.tgz_1483735229408_0.023912116652354598" }, "_npmUser": { "name": "eslint", @@ -29,21 +29,21 @@ "_npmVersion": "2.15.8", "_phantomChildren": {}, "_requested": { - "raw": "eslint", + "raw": "eslint@3.13.0", "scope": null, "escapedName": "eslint", "name": "eslint", - "rawSpec": "", - "spec": "latest", - "type": "tag" + "rawSpec": "3.13.0", + "spec": "3.13.0", + "type": "version" }, "_requiredBy": [ "#USER" ], - "_resolved": "https://registry.npmjs.org/eslint/-/eslint-3.8.0.tgz", - "_shasum": "4fbbf6833d66654860c23a099c47a0f086de34b7", + "_resolved": "https://registry.npmjs.org/eslint/-/eslint-3.13.0.tgz", + "_shasum": "636925fd163c9babe2e8be7ae43caf518d469577", "_shrinkwrap": null, - "_spec": "eslint", + "_spec": "eslint@3.13.0", "_where": "/Users/trott/io.js/tools", "author": { "name": "Nicholas C. Zakas", @@ -56,6 +56,7 @@ "url": "https://github.com/eslint/eslint/issues/" }, "dependencies": { + "babel-code-frame": "^6.16.0", "chalk": "^1.1.3", "concat-stream": "^1.4.6", "debug": "^2.1.1", @@ -66,8 +67,8 @@ "esutils": "^2.0.2", "file-entry-cache": "^2.0.0", "glob": "^7.0.3", - "globals": "^9.2.0", - "ignore": "^3.1.5", + "globals": "^9.14.0", + "ignore": "^3.2.0", "imurmurhash": "^0.1.4", "inquirer": "^0.12.0", "is-my-json-valid": "^2.10.0", @@ -83,9 +84,9 @@ "pluralize": "^1.2.1", "progress": "^1.1.8", "require-uncached": "^1.0.2", - "shelljs": "^0.6.0", + "shelljs": "^0.7.5", "strip-bom": "^3.0.0", - "strip-json-comments": "~1.0.1", + "strip-json-comments": "~2.0.1", "table": "^3.7.8", "text-table": "~0.2.0", "user-home": "^2.0.0" @@ -118,9 +119,9 @@ "leche": "^2.1.1", "linefix": "^0.1.1", "load-perf": "^0.2.0", - "markdownlint": "^0.2.0", + "markdownlint": "^0.3.1", "mocha": "^2.4.5", - "mock-fs": "^3.10.0", + "mock-fs": "^3.12.1", "npm-license": "^0.3.2", "phantomjs-prebuilt": "^2.1.7", "proxyquire": "^1.7.10", @@ -132,8 +133,8 @@ }, "directories": {}, "dist": { - "shasum": "4fbbf6833d66654860c23a099c47a0f086de34b7", - "tarball": "https://registry.npmjs.org/eslint/-/eslint-3.8.0.tgz" + "shasum": "636925fd163c9babe2e8be7ae43caf518d469577", + "tarball": "https://registry.npmjs.org/eslint/-/eslint-3.13.0.tgz" }, "engines": { "node": ">=4" @@ -146,7 +147,7 @@ "lib", "messages" ], - "gitHead": "82220042725dd0e86b5ddbeac4166e1eb147aa04", + "gitHead": "8571ab82af1d86bf4aa6a9be79ece42493607c69", "homepage": "http://eslint.org", "keywords": [ "ast", @@ -193,5 +194,5 @@ "release": "node Makefile.js release", "test": "node Makefile.js test" }, - "version": "3.8.0" + "version": "3.13.0" } diff --git a/tools/test.py b/tools/test.py index c8edca2b991ad2..b6db2cd68e3f7e 100755 --- a/tools/test.py +++ b/tools/test.py @@ -1628,9 +1628,9 @@ def Main(): tempdir = os.environ.get('NODE_TEST_DIR') or options.temp_dir if tempdir: + os.environ['NODE_TEST_DIR'] = tempdir try: os.makedirs(tempdir) - os.environ['NODE_TEST_DIR'] = tempdir except OSError as exception: if exception.errno != errno.EEXIST: print "Could not create the temporary directory", options.temp_dir