diff --git a/.eslintrc b/.eslintrc index 35907ef96db347..8e01cc4c94c0e4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -4,7 +4,8 @@ env: rules: # Possible Errors - # https://github.com/eslint/eslint/tree/master/docs/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 @@ -13,6 +14,7 @@ rules: 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 @@ -26,13 +28,32 @@ rules: valid-typeof: 2 # Best Practices - # https://github.com/eslint/eslint/tree/master/docs/rules#best-practices + # http://eslint.org/docs/rules/#best-practices no-fallthrough: 2 no-octal: 2 no-redeclare: 2 + no-self-assign: 2 + no-unused-labels: 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"] # Stylistic Issues - # https://github.com/eslint/eslint/tree/master/docs/rules#stylistic-issues + # http://eslint.org/docs/rules/#stylistic-issues comma-spacing: 2 eol-last: 2 indent: [2, 2, {SwitchCase: 1}] @@ -59,21 +80,11 @@ rules: 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 - # Strict Mode - # https://github.com/eslint/eslint/tree/master/docs/rules#strict-mode - strict: [2, "global"] - - # Variables - # https://github.com/eslint/eslint/tree/master/docs/rules#variables - no-delete-var: 2 - no-undef: 2 - no-unused-vars: [2, {"args": "none"}] - # Custom rules in tools/eslint-rules - require-buffer: 2 new-with-error: [2, "Error", "RangeError", "TypeError", "SyntaxError", "ReferenceError"] diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 00000000000000..c6e8656a72c40e --- /dev/null +++ b/BUILDING.md @@ -0,0 +1,246 @@ +## Building Node.js + +Depending on what platform or features you require the build process may +differ slightly. After you've successfully built a binary, running the +test suite to validate that the binary works as intended is a good next step. + +If you consistently can reproduce a test failure, search for it in the +[Node.js issue tracker](https://github.com/nodejs/node/issues) or +file a new issue. + + +### Unix / Macintosh + +Prerequisites: + +* `gcc` and `g++` 4.8 or newer, or +* `clang` and `clang++` 3.4 or newer +* Python 2.6 or 2.7 +* GNU Make 3.81 or newer +* libexecinfo (FreeBSD and OpenBSD only) + +```text +$ ./configure +$ make +$ [sudo] make install +``` + +If your Python binary is in a non-standard location or has a +non-standard name, run the following instead: + +```text +$ export PYTHON=/path/to/python +$ $PYTHON ./configure +$ make +$ [sudo] make install +``` + +To run the tests: + +```text +$ make test +``` + +To build the documentation: + +```text +$ make doc +``` + +To read the documentation: + +```text +$ man doc/node.1 +``` + +To test if Node.js was built correctly: + +``` +$ node -e "console.log('Hello from Node.js ' + process.version)" +``` + + +### Windows + +Prerequisites: + +* [Python 2.6 or 2.7](https://www.python.org/downloads/) +* Visual Studio 2013 / 2015, all editions including the Community edition, or +* Visual Studio Express 2013 / 2015 for Desktop +* 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`. + +```text +> vcbuild nosign +``` + +To run the tests: + +```text +> vcbuild test +``` + +To test if Node.js was built correctly: + +``` +$ node -e "console.log('Hello from Node.js ' + process.version)" +``` + +### Android / Android based devices, aka. Firefox OS + +Be sure you have downloaded and extracted [Android NDK] +(https://developer.android.com/tools/sdk/ndk/index.html) +before in a folder. Then run: + +``` +$ ./android-configure /path/to/your/android-ndk +$ make +``` + + +### `Intl` (ECMA-402) support: + +[Intl](https://github.com/nodejs/node/wiki/Intl) support is not +enabled by default. + + +#### "small" (English only) support + +This option will build with "small" (English only) support, but +the full `Intl` (ECMA-402) APIs. With `--download=all` it will +download the ICU library as needed. + +##### Unix / Macintosh: + +```text +$ ./configure --with-intl=small-icu --download=all +``` + +##### Windows: + +```text +> vcbuild small-icu download-all +``` + +The `small-icu` mode builds with English-only data. You can add full +data at runtime. + +*Note:* more docs are on +[the node wiki](https://github.com/nodejs/node/wiki/Intl). + +#### Build with full ICU support (all locales supported by ICU): + +With the `--download=all`, this may download ICU if you don't have an +ICU in `deps/icu`. + +##### Unix / Macintosh: + +```text +$ ./configure --with-intl=full-icu --download=all +``` + +##### Windows: + +```text +> vcbuild full-icu download-all +``` + +#### Building without Intl support + +The `Intl` object will not be available. This is the default at +present, so this option is not normally needed. + +##### Unix / Macintosh: + +```text +$ ./configure --with-intl=none +``` + +##### Windows: + +```text +> vcbuild intl-none +``` + +#### Use existing installed ICU (Unix / Macintosh only): + +```text +$ pkg-config --modversion icu-i18n && ./configure --with-intl=system-icu +``` + +If you are cross compiling, your `pkg-config` must be able to supply a path +that works for both your host and target environments. + +#### Build with a specific ICU: + +You can find other ICU releases at +[the ICU homepage](http://icu-project.org/download). +Download the file named something like `icu4c-**##.#**-src.tgz` (or +`.zip`). + +##### Unix / Macintosh + +```text +# from an already-unpacked ICU: +$ ./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu + +# from a local ICU tarball +$ ./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu.tgz + +# from a tarball URL +$ ./configure --with-intl=full-icu --with-icu-source=http://url/to/icu.tgz +``` + +##### Windows + +First unpack latest ICU to `deps/icu` +[icu4c-**##.#**-src.tgz](http://icu-project.org/download) (or `.zip`) +as `deps/icu` (You'll have: `deps/icu/source/...`) + +```text +> vcbuild full-icu +``` + +## Building Node.js with FIPS-compliant OpenSSL + +NOTE: Windows is not yet supported + +It is possible to build Node.js with +[OpenSSL FIPS module](https://www.openssl.org/docs/fips/fipsnotes.html). + +**Note**: building in this way does **not** allow you to claim that the +runtime is FIPS 140-2 validated. Instead you can indicate that the runtime +uses a validated module. See the [security policy](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf) +page 60 for more details. In addition, the validation for the underlying module +is only valid if it is deployed in accordance with its [security policy](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf). +If you need FIPS validated cryptography it is recommended that you read both +the [security policy](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf) +and [user guide](https://openssl.org/docs/fips/UserGuide-2.0.pdf). + +### Instructions + +1. Obtain a copy of openssl-fips-x.x.x.tar.gz. + To comply with the security policy you must ensure the path + through which you get the file complies with the requirements + for a "secure installation" as described in section 6.6 in + the [user guide](https://openssl.org/docs/fips/UserGuide-2.0.pdf). + For evaluation/experimentation you can simply download and verify + `openssl-fips-x.x.x.tar.gz` from https://www.openssl.org/source/ +2. Extract source to `openssl-fips` folder and `cd openssl-fips` +3. `./config` +4. `make` +5. `make install` + (NOTE: to comply with the security policy you must use the exact + commands in steps 3-5 without any additional options as per + Appendix A in the [security policy](http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf). + The only exception is that `./config no-asm` can be + used in place of `./config`, and the FIPSDIR environment variable + may be used to specify a non-standard install folder for the + validated module, as per User Guide sections 4.2.1, 4.2.2, and 4.2.3. +6. Get into Node.js checkout folder +7. `./configure --openssl-fips=/path/to/openssl-fips/installdir` + For example on ubuntu 12 the installation directory was + /usr/local/ssl/fips-2.0 +8. Build Node.js with `make -j` +9. Verify with `node -p "process.versions.openssl"` (`1.0.2a-fips`) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03c0be8813c2e1..6deb07263838f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,140 @@ # Node.js ChangeLog +## 2016-03-22, Version 4.4.1 'Argon' (LTS), @thealphanerd + +This LTS release comes with 113 commits, 56 of which are doc related, +18 of which are build / tooling related, 16 of which are test related +and 7 which are benchmark related. + +### Notable Changes +* **build**: + - Updated Logos for the OSX + Windows installers + - (Rod Vagg) [#5401](https://github.com/nodejs/node/pull/5401) + - (Robert Jefe Lindstaedt) [#5531](https://github.com/nodejs/node/pull/5531) + - New option to select your VS Version in the Windows installer + - (julien.waechter) [#4645](https://github.com/nodejs/node/pull/4645) + - Support Visual C++ Build Tools 2015 + - (João Reis) [#5627](https://github.com/nodejs/node/pull/5627) +* **tools**: + - Gyp now works on OSX without XCode + - (Shigeki Ohtsu) [nodejs/node#1325](https://github.com/nodejs/node/pull/1325) + +### Commits + +* [[`df283f8a03`](https://github.com/nodejs/node/commit/df283f8a03)] - **benchmark**: fix linting issues (Rich Trott) [#5773](https://github.com/nodejs/node/pull/5773) +* [[`c901741c60`](https://github.com/nodejs/node/commit/c901741c60)] - **benchmark**: use strict mode (Rich Trott) [#5773](https://github.com/nodejs/node/pull/5773) +* [[`4be2065dbc`](https://github.com/nodejs/node/commit/4be2065dbc)] - **benchmark**: refactor to eliminate redeclared vars (Rich Trott) [#5773](https://github.com/nodejs/node/pull/5773) +* [[`ddac368533`](https://github.com/nodejs/node/commit/ddac368533)] - **benchmark**: fix lint errors (Rich Trott) [#5773](https://github.com/nodejs/node/pull/5773) +* [[`03b20a73b9`](https://github.com/nodejs/node/commit/03b20a73b9)] - **benchmark**: add benchmark for buf.compare() (Rich Trott) [#5441](https://github.com/nodejs/node/pull/5441) +* [[`b816044845`](https://github.com/nodejs/node/commit/b816044845)] - **buffer**: remove duplicated code in fromObject (HUANG Wei) [#4948](https://github.com/nodejs/node/pull/4948) +* [[`067ce9b905`](https://github.com/nodejs/node/commit/067ce9b905)] - **build**: don't install github templates (Johan Bergström) [#5612](https://github.com/nodejs/node/pull/5612) +* [[`a1772dc515`](https://github.com/nodejs/node/commit/a1772dc515)] - **build**: update Node.js logo on OSX installer (Rod Vagg) [#5401](https://github.com/nodejs/node/pull/5401) +* [[`9058fc0383`](https://github.com/nodejs/node/commit/9058fc0383)] - **build**: correctly detect clang version (Stefan Budeanu) [#5553](https://github.com/nodejs/node/pull/5553) +* [[`1165ecc6f7`](https://github.com/nodejs/node/commit/1165ecc6f7)] - **build**: update Node.js logo on Win installer (Robert Jefe Lindstaedt) [#5531](https://github.com/nodejs/node/pull/5531) +* [[`4990ddad72`](https://github.com/nodejs/node/commit/4990ddad72)] - **build**: remove --quiet from eslint invocation (firedfox) [#5519](https://github.com/nodejs/node/pull/5519) +* [[`46a5d519dd`](https://github.com/nodejs/node/commit/46a5d519dd)] - **build**: skip msi build if WiX is not found (Tsarevich Dmitry) [#5220](https://github.com/nodejs/node/pull/5220) +* [[`dac4e64491`](https://github.com/nodejs/node/commit/dac4e64491)] - **build**: add option to select VS version (julien.waechter) [#4645](https://github.com/nodejs/node/pull/4645) +* [[`7a10fd3a56`](https://github.com/nodejs/node/commit/7a10fd3a56)] - **collaborator_guide**: clarify commit message rules (Wyatt Preul) [#5661](https://github.com/nodejs/node/pull/5661) +* [[`97e95d04c2`](https://github.com/nodejs/node/commit/97e95d04c2)] - **crypto**: PBKDF2 works with `int` not `ssize_t` (Fedor Indutny) [#5397](https://github.com/nodejs/node/pull/5397) +* [[`57b02e6a3e`](https://github.com/nodejs/node/commit/57b02e6a3e)] - **debugger**: remove unneeded callback check (Rich Trott) [#5319](https://github.com/nodejs/node/pull/5319) +* [[`19ae308867`](https://github.com/nodejs/node/commit/19ae308867)] - **deps**: update openssl config (Shigeki Ohtsu) [#5630](https://github.com/nodejs/node/pull/5630) +* [[`d7b81b5bc7`](https://github.com/nodejs/node/commit/d7b81b5bc7)] - **deps**: cherry-pick 2e4da65 from v8's 4.8 upstream (Michael Dawson) [#5293](https://github.com/nodejs/node/pull/5293) +* [[`1e05f371d6`](https://github.com/nodejs/node/commit/1e05f371d6)] - **doc**: fix typo in synchronous randomBytes example (Andrea Giammarchi) [#5781](https://github.com/nodejs/node/pull/5781) +* [[`5f54bd2088`](https://github.com/nodejs/node/commit/5f54bd2088)] - **doc**: topic blocking vs non-blocking (Jarrett Widman) [#5326](https://github.com/nodejs/node/pull/5326) +* [[`0943001563`](https://github.com/nodejs/node/commit/0943001563)] - **doc**: fix invalid path doc comments (Rich Trott) [#5797](https://github.com/nodejs/node/pull/5797) +* [[`bb423bb1e6`](https://github.com/nodejs/node/commit/bb423bb1e6)] - **doc**: update release tweet template (Jeremiah Senkpiel) [#5628](https://github.com/nodejs/node/pull/5628) +* [[`1e877f10aa`](https://github.com/nodejs/node/commit/1e877f10aa)] - **doc**: fix typo in child_process docs (Benjamin Gruenbaum) [#5681](https://github.com/nodejs/node/pull/5681) +* [[`d53dcc599b`](https://github.com/nodejs/node/commit/d53dcc599b)] - **doc**: update fansworld-claudio username on README (Claudio Rodriguez) [#5680](https://github.com/nodejs/node/pull/5680) +* [[`4332f8011e`](https://github.com/nodejs/node/commit/4332f8011e)] - **doc**: fix return value of write methods (Felix Böhm) [#5736](https://github.com/nodejs/node/pull/5736) +* [[`e572542de5`](https://github.com/nodejs/node/commit/e572542de5)] - **doc**: Add note about use of JSON.stringify() (Mithun Patel) [#5723](https://github.com/nodejs/node/pull/5723) +* [[`daf3ef66ef`](https://github.com/nodejs/node/commit/daf3ef66ef)] - **doc**: explain path.format() algorithm (Rich Trott) [#5688](https://github.com/nodejs/node/pull/5688) +* [[`f6d4982aa0`](https://github.com/nodejs/node/commit/f6d4982aa0)] - **doc**: clarify type of first argument in zlib (Kirill Fomichev) [#5685](https://github.com/nodejs/node/pull/5685) +* [[`07e71b2d44`](https://github.com/nodejs/node/commit/07e71b2d44)] - **doc**: fix typo in api/addons (Daijiro Wachi) [#5678](https://github.com/nodejs/node/pull/5678) +* [[`c6dc56175b`](https://github.com/nodejs/node/commit/c6dc56175b)] - **doc**: remove non-standard use of hyphens (Stefano Vozza) +* [[`4c92316972`](https://github.com/nodejs/node/commit/4c92316972)] - **doc**: add fansworld-claudio to collaborators (Claudio Rodriguez) [#5668](https://github.com/nodejs/node/pull/5668) +* [[`0a6e883f85`](https://github.com/nodejs/node/commit/0a6e883f85)] - **doc**: add thekemkid to collaborators (Glen Keane) [#5667](https://github.com/nodejs/node/pull/5667) +* [[`39c7d8a972`](https://github.com/nodejs/node/commit/39c7d8a972)] - **doc**: add AndreasMadsen to collaborators (Andreas Madsen) [#5666](https://github.com/nodejs/node/pull/5666) +* [[`eec3008970`](https://github.com/nodejs/node/commit/eec3008970)] - **doc**: add whitlockjc to collaborators (Jeremy Whitlock) [#5665](https://github.com/nodejs/node/pull/5665) +* [[`e5f254d83c`](https://github.com/nodejs/node/commit/e5f254d83c)] - **doc**: add benjamingr to collaborator list (Benjamin Gruenbaum) [#5664](https://github.com/nodejs/node/pull/5664) +* [[`3f718643c9`](https://github.com/nodejs/node/commit/3f718643c9)] - **doc**: add phillipj to collaborators (Phillip Johnsen) [#5663](https://github.com/nodejs/node/pull/5663) +* [[`2d5527fe69`](https://github.com/nodejs/node/commit/2d5527fe69)] - **doc**: add mattloring to collaborators (Matt Loring) [#5662](https://github.com/nodejs/node/pull/5662) +* [[`51763462bc`](https://github.com/nodejs/node/commit/51763462bc)] - **doc**: include typo in 'unhandledRejection' example (Robert C Jensen) [#5654](https://github.com/nodejs/node/pull/5654) +* [[`cae5da2f0a`](https://github.com/nodejs/node/commit/cae5da2f0a)] - **doc**: fix markdown links (Steve Mao) [#5641](https://github.com/nodejs/node/pull/5641) +* [[`b1b17efcb7`](https://github.com/nodejs/node/commit/b1b17efcb7)] - **doc**: move build instructions to a new document (Johan Bergström) [#5634](https://github.com/nodejs/node/pull/5634) +* [[`13a8bde1fa`](https://github.com/nodejs/node/commit/13a8bde1fa)] - **doc**: fix dns.resolveCname description typo (axvm) [#5622](https://github.com/nodejs/node/pull/5622) +* [[`1faea43c40`](https://github.com/nodejs/node/commit/1faea43c40)] - **doc**: fix typo in fs.symlink (Michaël Zasso) [#5560](https://github.com/nodejs/node/pull/5560) +* [[`98a1bb6989`](https://github.com/nodejs/node/commit/98a1bb6989)] - **doc**: document directories in test directory (Michael Barrett) [#5557](https://github.com/nodejs/node/pull/5557) +* [[`04d3f8a741`](https://github.com/nodejs/node/commit/04d3f8a741)] - **doc**: update link green to match homepage (silverwind) [#5548](https://github.com/nodejs/node/pull/5548) +* [[`1afab6ac9c`](https://github.com/nodejs/node/commit/1afab6ac9c)] - **doc**: add clarification on birthtime in fs stat (Kári Tristan Helgason) [#5479](https://github.com/nodejs/node/pull/5479) +* [[`d871ae2349`](https://github.com/nodejs/node/commit/d871ae2349)] - **doc**: fix typo in child_process documentation (Evan Lucas) [#5474](https://github.com/nodejs/node/pull/5474) +* [[`97a18bdbad`](https://github.com/nodejs/node/commit/97a18bdbad)] - **doc**: update NAN urls in ROADMAP.md and doc/releases.md (ronkorving) [#5472](https://github.com/nodejs/node/pull/5472) +* [[`d4a1fc7acd`](https://github.com/nodejs/node/commit/d4a1fc7acd)] - **doc**: add Testing WG (Rich Trott) [#5461](https://github.com/nodejs/node/pull/5461) +* [[`1642078580`](https://github.com/nodejs/node/commit/1642078580)] - **doc**: fix crypto function indentation level (Brian White) [#5460](https://github.com/nodejs/node/pull/5460) +* [[`2b0c7ad985`](https://github.com/nodejs/node/commit/2b0c7ad985)] - **doc**: fix links in tls, cluster docs (Alexander Makarenko) [#5364](https://github.com/nodejs/node/pull/5364) +* [[`901dbabea6`](https://github.com/nodejs/node/commit/901dbabea6)] - **doc**: fix relative links in net docs (Evan Lucas) [#5358](https://github.com/nodejs/node/pull/5358) +* [[`38d429172d`](https://github.com/nodejs/node/commit/38d429172d)] - **doc**: fix typo in pbkdf2Sync code sample (Marc Cuva) [#5306](https://github.com/nodejs/node/pull/5306) +* [[`d4cfc6f97c`](https://github.com/nodejs/node/commit/d4cfc6f97c)] - **doc**: add missing property in cluster example (Rafael Cepeda) [#5305](https://github.com/nodejs/node/pull/5305) +* [[`b66d6b1458`](https://github.com/nodejs/node/commit/b66d6b1458)] - **doc**: improve httpVersionMajor / httpVersionMajor (Jackson Tian) [#5296](https://github.com/nodejs/node/pull/5296) +* [[`70c872c9c4`](https://github.com/nodejs/node/commit/70c872c9c4)] - **doc**: improve unhandledException doc copy (James M Snell) [#5287](https://github.com/nodejs/node/pull/5287) +* [[`ba5e0b6110`](https://github.com/nodejs/node/commit/ba5e0b6110)] - **doc**: fix buf.readInt16LE output (Chinedu Francis Nwafili) [#5282](https://github.com/nodejs/node/pull/5282) +* [[`1624d5b049`](https://github.com/nodejs/node/commit/1624d5b049)] - **doc**: document base64url encoding support (Tristan Slominski) [#5243](https://github.com/nodejs/node/pull/5243) +* [[`b1d580c9d2`](https://github.com/nodejs/node/commit/b1d580c9d2)] - **doc**: update removeListener behaviour (Vaibhav) [#5201](https://github.com/nodejs/node/pull/5201) +* [[`ca17f91ba8`](https://github.com/nodejs/node/commit/ca17f91ba8)] - **doc**: add note for binary safe string reading (Anton Andesen) [#5155](https://github.com/nodejs/node/pull/5155) +* [[`0830bb4950`](https://github.com/nodejs/node/commit/0830bb4950)] - **doc**: clarify when writable.write callback is called (Kevin Locke) [#4810](https://github.com/nodejs/node/pull/4810) +* [[`17a74305c8`](https://github.com/nodejs/node/commit/17a74305c8)] - **doc**: add info to docs on how to submit docs patch (Sequoia McDowell) [#4591](https://github.com/nodejs/node/pull/4591) +* [[`470a9ca909`](https://github.com/nodejs/node/commit/470a9ca909)] - **doc**: add onboarding resources (Jeremiah Senkpiel) [#3726](https://github.com/nodejs/node/pull/3726) +* [[`3168e6b486`](https://github.com/nodejs/node/commit/3168e6b486)] - **doc**: update V8 URL (Craig Akimoto) [#5530](https://github.com/nodejs/node/pull/5530) +* [[`04d16eb7e8`](https://github.com/nodejs/node/commit/04d16eb7e8)] - **doc**: document fs.datasync(Sync) (Ron Korving) [#5402](https://github.com/nodejs/node/pull/5402) +* [[`29646200f8`](https://github.com/nodejs/node/commit/29646200f8)] - **doc**: add Evan Lucas to the CTC (Rod Vagg) +* [[`a2a32b7810`](https://github.com/nodejs/node/commit/a2a32b7810)] - **doc**: add Rich Trott to the CTC (Rod Vagg) [#5276](https://github.com/nodejs/node/pull/5276) +* [[`4e469d5e47`](https://github.com/nodejs/node/commit/4e469d5e47)] - **doc**: add Ali Ijaz Sheikh to the CTC (Rod Vagg) [#5277](https://github.com/nodejs/node/pull/5277) +* [[`d09b44f59b`](https://github.com/nodejs/node/commit/d09b44f59b)] - **doc**: add Сковорода Никита Андреевич to the CTC (Rod Vagg) [#5278](https://github.com/nodejs/node/pull/5278) +* [[`ebbc64bc97`](https://github.com/nodejs/node/commit/ebbc64bc97)] - **doc**: add "building node with ninja" guide (Jeremiah Senkpiel) [#4767](https://github.com/nodejs/node/pull/4767) +* [[`67245fa0e3`](https://github.com/nodejs/node/commit/67245fa0e3)] - **doc**: clarify code of conduct reporting (Julie Pagano) [#5107](https://github.com/nodejs/node/pull/5107) +* [[`cd78ff9706`](https://github.com/nodejs/node/commit/cd78ff9706)] - **doc**: fix links in Addons docs (Alexander Makarenko) [#5072](https://github.com/nodejs/node/pull/5072) +* [[`20539954ff`](https://github.com/nodejs/node/commit/20539954ff)] - **docs**: fix man pages link if tok type is code (Mithun Patel) [#5721](https://github.com/nodejs/node/pull/5721) +* [[`38d7b0b6ea`](https://github.com/nodejs/node/commit/38d7b0b6ea)] - **docs**: update link to iojs+release ci job (Myles Borins) [#5632](https://github.com/nodejs/node/pull/5632) +* [[`f982632f90`](https://github.com/nodejs/node/commit/f982632f90)] - **http**: remove old, confusing comment (Brian White) [#5233](https://github.com/nodejs/node/pull/5233) +* [[`ca5d7a8bb6`](https://github.com/nodejs/node/commit/ca5d7a8bb6)] - **http**: remove unnecessary check (Brian White) [#5233](https://github.com/nodejs/node/pull/5233) +* [[`2ce83bd8f9`](https://github.com/nodejs/node/commit/2ce83bd8f9)] - **http,util**: fix typos in comments (Alexander Makarenko) [#5279](https://github.com/nodejs/node/pull/5279) +* [[`b690916e5a`](https://github.com/nodejs/node/commit/b690916e5a)] - **lib**: freelist: use .pop() for allocation (Anton Khlynovskiy) [#2174](https://github.com/nodejs/node/pull/2174) +* [[`e7f45f0a17`](https://github.com/nodejs/node/commit/e7f45f0a17)] - **repl**: handle quotes within regexp literal (Prince J Wesley) [#5117](https://github.com/nodejs/node/pull/5117) +* [[`7c3b844f78`](https://github.com/nodejs/node/commit/7c3b844f78)] - **src**: return UV_EAI_NODATA on empty lookup (cjihrig) [#4715](https://github.com/nodejs/node/pull/4715) +* [[`242a65e930`](https://github.com/nodejs/node/commit/242a65e930)] - **stream**: prevent object map change in TransformState (Evan Lucas) [#5032](https://github.com/nodejs/node/pull/5032) +* [[`fb5ba6b928`](https://github.com/nodejs/node/commit/fb5ba6b928)] - **stream**: prevent object map change in ReadableState (Evan Lucas) [#4761](https://github.com/nodejs/node/pull/4761) +* [[`04db9efd78`](https://github.com/nodejs/node/commit/04db9efd78)] - **stream**: fix no data on partial decode (Brian White) [#5226](https://github.com/nodejs/node/pull/5226) +* [[`cc0e36ff98`](https://github.com/nodejs/node/commit/cc0e36ff98)] - **string_decoder**: fix performance regression (Brian White) [#5134](https://github.com/nodejs/node/pull/5134) +* [[`666d3690d8`](https://github.com/nodejs/node/commit/666d3690d8)] - **test**: eval a strict function (Kári Tristan Helgason) [#5250](https://github.com/nodejs/node/pull/5250) +* [[`9952bcf203`](https://github.com/nodejs/node/commit/9952bcf203)] - **test**: bug repro for vm function redefinition (cjihrig) [#5528](https://github.com/nodejs/node/pull/5528) +* [[`063f22f1f0`](https://github.com/nodejs/node/commit/063f22f1f0)] - **test**: check memoryUsage properties The properties on memoryUsage were not checked before, this commit checks them. (Wyatt Preul) [#5546](https://github.com/nodejs/node/pull/5546) +* [[`7a0fcfc127`](https://github.com/nodejs/node/commit/7a0fcfc127)] - **test**: remove broken debugger scenarios (Rich Trott) [#5532](https://github.com/nodejs/node/pull/5532) +* [[`ba9ad2662c`](https://github.com/nodejs/node/commit/ba9ad2662c)] - **test**: apply Linux workaround to Linux only (Rich Trott) [#5471](https://github.com/nodejs/node/pull/5471) +* [[`4aa2c03d31`](https://github.com/nodejs/node/commit/4aa2c03d31)] - **test**: increase timeout for test-tls-fast-writing (Rich Trott) [#5466](https://github.com/nodejs/node/pull/5466) +* [[`b4ef644ce4`](https://github.com/nodejs/node/commit/b4ef644ce4)] - **test**: retry on known SmartOS bug (Rich Trott) [#5454](https://github.com/nodejs/node/pull/5454) +* [[`d681bf24b5`](https://github.com/nodejs/node/commit/d681bf24b5)] - **test**: fix flaky child-process-fork-regr-gh-2847 (Santiago Gimeno) [#5422](https://github.com/nodejs/node/pull/5422) +* [[`b4fbe04514`](https://github.com/nodejs/node/commit/b4fbe04514)] - **test**: fix test-timers.reliability on OS X (Rich Trott) [#5379](https://github.com/nodejs/node/pull/5379) +* [[`99269ffdbf`](https://github.com/nodejs/node/commit/99269ffdbf)] - **test**: increase timeouts on some unref timers tests (Jeremiah Senkpiel) [#5352](https://github.com/nodejs/node/pull/5352) +* [[`85f927a774`](https://github.com/nodejs/node/commit/85f927a774)] - **test**: prevent flakey test on pi2 (Trevor Norris) [#5537](https://github.com/nodejs/node/pull/5537) +* [[`c86902d800`](https://github.com/nodejs/node/commit/c86902d800)] - **test**: mitigate flaky test-http-agent (Rich Trott) [#5346](https://github.com/nodejs/node/pull/5346) +* [[`f242e62817`](https://github.com/nodejs/node/commit/f242e62817)] - **test**: remove flaky designation from fixed tests (Rich Trott) [#5459](https://github.com/nodejs/node/pull/5459) +* [[`a39aacf035`](https://github.com/nodejs/node/commit/a39aacf035)] - **test**: refactor test-dgram-udp4 (Santiago Gimeno) [#5339](https://github.com/nodejs/node/pull/5339) +* [[`6386f62221`](https://github.com/nodejs/node/commit/6386f62221)] - **test**: remove unneeded bind() and related comments (Aayush Naik) [#5023](https://github.com/nodejs/node/pull/5023) +* [[`068b0cbd12`](https://github.com/nodejs/node/commit/068b0cbd12)] - **test**: move cluster tests to parallel (Rich Trott) [#4774](https://github.com/nodejs/node/pull/4774) +* [[`a673c9ae2d`](https://github.com/nodejs/node/commit/a673c9ae2d)] - **tls**: fix assert in context._external accessor (Ben Noordhuis) [#5521](https://github.com/nodejs/node/pull/5521) +* [[`8ffef48fee`](https://github.com/nodejs/node/commit/8ffef48fee)] - **tools**: fix gyp to work on MacOSX without XCode (Shigeki Ohtsu) [nodejs/node#1325](https://github.com/nodejs/node/pull/1325) +* [[`4b6a8f4321`](https://github.com/nodejs/node/commit/4b6a8f4321)] - **tools**: update gyp to b3cef02 (Imran Iqbal) [#3487](https://github.com/nodejs/node/pull/3487) +* [[`7501ddc878`](https://github.com/nodejs/node/commit/7501ddc878)] - **tools**: support testing known issues (cjihrig) [#5528](https://github.com/nodejs/node/pull/5528) +* [[`10ec1d2a6b`](https://github.com/nodejs/node/commit/10ec1d2a6b)] - **tools**: enable linting for benchmarks (Rich Trott) [#5773](https://github.com/nodejs/node/pull/5773) +* [[`deec8bc5f5`](https://github.com/nodejs/node/commit/deec8bc5f5)] - **tools**: reduce verbosity of cpplint (Sakthipriyan Vairamani) [#5578](https://github.com/nodejs/node/pull/5578) +* [[`64d5752711`](https://github.com/nodejs/node/commit/64d5752711)] - **tools**: enable no-self-assign ESLint rule (Rich Trott) [#5552](https://github.com/nodejs/node/pull/5552) +* [[`131ed494e2`](https://github.com/nodejs/node/commit/131ed494e2)] - **tools**: enable no-extra-parens in ESLint (Rich Trott) [#5512](https://github.com/nodejs/node/pull/5512) +* [[`d4b9f02fdc`](https://github.com/nodejs/node/commit/d4b9f02fdc)] - **tools**: apply custom buffer lint rule to /lib only (Rich Trott) [#5371](https://github.com/nodejs/node/pull/5371) +* [[`6867bed4c4`](https://github.com/nodejs/node/commit/6867bed4c4)] - **tools**: enable additional lint rules (Rich Trott) [#5357](https://github.com/nodejs/node/pull/5357) +* [[`5e6b7605ee`](https://github.com/nodejs/node/commit/5e6b7605ee)] - **tools**: add Node.js-specific ESLint rules (Rich Trott) [#5320](https://github.com/nodejs/node/pull/5320) +* [[`6dc49ae203`](https://github.com/nodejs/node/commit/6dc49ae203)] - **tools,benchmark**: increase lint compliance (Rich Trott) [#5773](https://github.com/nodejs/node/pull/5773) +* [[`dff7091fce`](https://github.com/nodejs/node/commit/dff7091fce)] - **url**: group slashed protocols by protocol name (nettofarah) [#5380](https://github.com/nodejs/node/pull/5380) +* [[`0e97a3ea51`](https://github.com/nodejs/node/commit/0e97a3ea51)] - **win,build**: support Visual C++ Build Tools 2015 (João Reis) [#5627](https://github.com/nodejs/node/pull/5627) + ## 2016-03-08, Version 4.4.0 'Argon' (LTS), @thealphanerd In December we announced that we would be doing a minor release in order to diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 8dee836460a3b3..3d0f14d7201279 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,8 +1,6 @@ ## Code of Conduct -This Code of Conduct is adapted from [Rust's wonderful -CoC](http://www.rust-lang.org/conduct.html) as well as the -[Contributor Covenant v1.3.0](http://contributor-covenant.org/version/1/3/0/). +### Conduct * We are committed to providing a friendly, safe and welcoming environment for all, regardless of level of experience, gender @@ -39,3 +37,19 @@ CoC](http://www.rust-lang.org/conduct.html) as well as the * Avoid the use of personal pronouns in code comments or documentation. There is no need to address persons when explaining code (e.g. "When the developer"). + +### Contact +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by: + +* Emailing [report@nodejs.org](mailto:report@nodejs.org) (this will email all TSC members) +* Contacting [individual TSC members](https://nodejs.org/en/foundation/tsc/#current-members-of-the-technical-steering-committee). + +### Moderation +See the TSC's [moderation policy](https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md) for details about moderation. + +### Attribution + +This Code of Conduct is adapted from [Rust's wonderful +CoC](http://www.rust-lang.org/conduct.html) as well as the +[Contributor Covenant v1.3.0](http://contributor-covenant.org/version/1/3/0/). diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index 4e3077163d81e2..90d73e80e9679b 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -93,14 +93,17 @@ information regarding the change process: - A `Reviewed-By: Name ` line for yourself and any other Collaborators who have reviewed the change. -- A `PR-URL:` line that references the full GitHub URL of the original +- A `PR-URL:` line that references the *full* GitHub URL of the original pull request being merged so it's easy to trace a commit back to the conversation that led up to that change. -- A `Fixes: X` line, where _X_ is either includes the full GitHub URL +- A `Fixes: X` line, where _X_ either includes the *full* GitHub URL 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. +Review the commit message to ensure that it adheres to the guidelines +outlined in the [contributing](https://github.com/nodejs/node/blob/master/CONTRIBUTING.md#step-3-commit) guide. + See the commit log for examples such as [this one](https://github.com/nodejs/node/commit/b636ba8186) if unsure exactly how to format your commit messages. diff --git a/Makefile b/Makefile index 65a399b063aa2f..ff0098b70d7b2c 100644 --- a/Makefile +++ b/Makefile @@ -168,6 +168,9 @@ test-internet: all test-debugger: all $(PYTHON) tools/test.py debugger +test-known-issues: all + $(PYTHON) tools/test.py known_issues --expect-fail + test-npm: $(NODE_EXE) NODE=$(NODE) tools/test-npm.sh @@ -367,6 +370,7 @@ $(TARBALL): release-only $(NODE_EXE) doc rm -rf $(TARNAME)/deps/uv/{docs,samples,test} rm -rf $(TARNAME)/deps/openssl/{doc,demos,test} rm -rf $(TARNAME)/deps/zlib/contrib # too big, unused + rm -rf $(TARNAME)/.github # github issue templates find $(TARNAME)/ -type l | xargs rm # annoying on windows tar -cf $(TARNAME).tar $(TARNAME) rm -rf $(TARNAME) @@ -513,8 +517,8 @@ bench-idle: $(NODE) benchmark/idle_clients.js & jslint: - $(NODE) tools/eslint/bin/eslint.js lib src test tools/doc tools/eslint-rules \ - --rulesdir tools/eslint-rules --quiet + $(NODE) tools/eslint/bin/eslint.js benchmark lib src test tools/doc \ + tools/eslint-rules --rulesdir tools/eslint-rules CPPLINT_EXCLUDE ?= CPPLINT_EXCLUDE += src/node_lttng.cc diff --git a/README.md b/README.md index 22883b569a5914..58741e602331a7 100644 --- a/README.md +++ b/README.md @@ -103,246 +103,11 @@ file has been signed by an authorized member of the Node.js team. Once verified, use the SHASUMS256.txt.asc file to get the checksum for the binary verification command above. -## Build +## Building Node.js -### Unix / Macintosh +See [BUILDING.md](BUILDING.md) for instructions on how to build +Node.js from source. -Prerequisites: - -* `gcc` and `g++` 4.8 or newer, or -* `clang` and `clang++` 3.4 or newer -* Python 2.6 or 2.7 -* GNU Make 3.81 or newer -* libexecinfo (FreeBSD and OpenBSD only) - -```text -$ ./configure -$ make -$ [sudo] make install -``` - -If your Python binary is in a non-standard location or has a -non-standard name, run the following instead: - -```text -$ export PYTHON=/path/to/python -$ $PYTHON ./configure -$ make -$ [sudo] make install -``` - -To run the tests: - -```text -$ make test -``` - -To build the documentation: - -```text -$ make doc -``` - -To read the documentation: - -```text -$ man doc/node.1 -``` - -To test if Node.js was built correctly: - -``` -$ node -e "console.log('Hello from Node.js ' + process.version)" -``` - -### Windows - -Prerequisites: - -* [Python 2.6 or 2.7](https://www.python.org/downloads/) -* Visual Studio 2013 / 2015, all editions including the Community edition, or -* Visual Studio Express 2013 / 2015 for Desktop -* 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`. - -```text -> vcbuild nosign -``` - -To run the tests: - -```text -> vcbuild test -``` - -To test if Node.js was built correctly: - -``` -$ node -e "console.log('Hello from Node.js ' + process.version)" -``` - -### Android / Android based devices, aka. Firefox OS - -Be sure you have downloaded and extracted [Android NDK] -(https://developer.android.com/tools/sdk/ndk/index.html) -before in a folder. Then run: - -``` -$ ./android-configure /path/to/your/android-ndk -$ make -``` - -### `Intl` (ECMA-402) support: - -[Intl](https://github.com/nodejs/node/wiki/Intl) support is not -enabled by default. - -#### "small" (English only) support - -This option will build with "small" (English only) support, but -the full `Intl` (ECMA-402) APIs. With `--download=all` it will -download the ICU library as needed. - -Unix / Macintosh: - -```text -$ ./configure --with-intl=small-icu --download=all -``` - -Windows: - -```text -> vcbuild small-icu download-all -``` - -The `small-icu` mode builds with English-only data. You can add full -data at runtime. - -*Note:* more docs are on -[the node wiki](https://github.com/nodejs/node/wiki/Intl). - -#### Build with full ICU support (all locales supported by ICU): - -With the `--download=all`, this may download ICU if you don't have an -ICU in `deps/icu`. - -Unix / Macintosh: - -```text -$ ./configure --with-intl=full-icu --download=all -``` - -Windows: - -```text -> vcbuild full-icu download-all -``` - -#### Build with no Intl support `:-(` - -The `Intl` object will not be available. This is the default at -present, so this option is not normally needed. - -Unix / Macintosh: - -```text -$ ./configure --with-intl=none -``` - -Windows: - -```text -> vcbuild intl-none -``` - -#### Use existing installed ICU (Unix / Macintosh only): - -```text -$ pkg-config --modversion icu-i18n && ./configure --with-intl=system-icu -``` - -If you are cross compiling, your `pkg-config` must be able to supply a path -that works for both your host and target environments. - -#### Build with a specific ICU: - -You can find other ICU releases at -[the ICU homepage](http://icu-project.org/download). -Download the file named something like `icu4c-**##.#**-src.tgz` (or -`.zip`). - -Unix / Macintosh - -```text -# from an already-unpacked ICU: -$ ./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu - -# from a local ICU tarball -$ ./configure --with-intl=[small-icu,full-icu] --with-icu-source=/path/to/icu.tgz - -# from a tarball URL -$ ./configure --with-intl=full-icu --with-icu-source=http://url/to/icu.tgz -``` - -Windows - -First unpack latest ICU to `deps/icu` -[icu4c-**##.#**-src.tgz](http://icu-project.org/download) (or `.zip`) -as `deps/icu` (You'll have: `deps/icu/source/...`) - -```text -> vcbuild full-icu -``` - -# Building Node.js with FIPS-compliant OpenSSL - -NOTE: Windows is not yet supported - -It is possible to build Node.js with -[OpenSSL FIPS module](https://www.openssl.org/docs/fips/fipsnotes.html). - -**Note** that building in this way does **not** allow you to -claim that the runtime is FIPS 140-2 validated. Instead you -can indicate that the runtime uses a validated module. See -the [security policy] -(http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf) -page 60 for more details. In addition, the validation for -the underlying module is only valid if it is deployed in -accordance with its [security policy] -(http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf). -If you need FIPS validated cryptography it is recommended that you -read both the [security policy] -(http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf) -and [user guide] (https://openssl.org/docs/fips/UserGuide-2.0.pdf). - -Instructions: - -1. Obtain a copy of openssl-fips-x.x.x.tar.gz. - To comply with the security policy you must ensure the path - through which you get the file complies with the requirements - for a "secure installation" as described in section 6.6 in - the [user guide] (https://openssl.org/docs/fips/UserGuide-2.0.pdf). - For evaluation/experimentation you can simply download and verify - `openssl-fips-x.x.x.tar.gz` from https://www.openssl.org/source/ -2. Extract source to `openssl-fips` folder and `cd openssl-fips` -3. `./config` -4. `make` -5. `make install` - (NOTE: to comply with the security policy you must use the exact - commands in steps 3-5 without any additional options as per - Appendix A in the [security policy] - (http://csrc.nist.gov/groups/STM/cmvp/documents/140-1/140sp/140sp1747.pdf). - The only exception is that `./config no-asm` can be - used in place of `./config`, and the FIPSDIR environment variable - may be used to specify a non-standard install folder for the - validated module, as per User Guide sections 4.2.1, 4.2.2, and 4.2.3. -6. Get into Node.js checkout folder -7. `./configure --openssl-fips=/path/to/openssl-fips/installdir` - For example on ubuntu 12 the installation directory was - /usr/local/ssl/fips-2.0 -8. Build Node.js with `make -j` -9. Verify with `node -p "process.versions.openssl"` (`1.0.2a-fips`) ## Resources for Newcomers @@ -374,26 +139,31 @@ information about the governance of the Node.js project, see ### CTC (Core Technical Committee) * [bnoordhuis](https://github.com/bnoordhuis) - **Ben Noordhuis** <info@bnoordhuis.nl> +* [ChALkeR](https://github.com/ChALkeR) - **Сковорода Никита Андреевич** <chalkerx@gmail.com> * [chrisdickinson](https://github.com/chrisdickinson) - **Chris Dickinson** <christopher.s.dickinson@gmail.com> * [cjihrig](https://github.com/cjihrig) - **Colin Ihrig** <cjihrig@gmail.com> +* [evanlucas](https://github.com/evanlucas) - **Evan Lucas** <evanlucas@me.com> * [fishrock123](https://github.com/fishrock123) - **Jeremiah Senkpiel** <fishrock123@rocketmail.com> * [indutny](https://github.com/indutny) - **Fedor Indutny** <fedor.indutny@gmail.com> * [jasnell](https://github.com/jasnell) - **James M Snell** <jasnell@gmail.com> * [misterdjules](https://github.com/misterdjules) - **Julien Gilli** <jgilli@nodejs.org> * [mscdex](https://github.com/mscdex) - **Brian White** <mscdex@mscdex.net> +* [ofrobots](https://github.com/ofrobots) - **Ali Ijaz Sheikh** <ofrobots@google.com> * [orangemocha](https://github.com/orangemocha) - **Alexis Campailla** <orangemocha@nodejs.org> * [piscisaureus](https://github.com/piscisaureus) - **Bert Belder** <bertbelder@gmail.com> * [rvagg](https://github.com/rvagg) - **Rod Vagg** <rod@vagg.org> * [shigeki](https://github.com/shigeki) - **Shigeki Ohtsu** <ohtsu@iij.ad.jp> * [trevnorris](https://github.com/trevnorris) - **Trevor Norris** <trev.norris@gmail.com> +* [Trott](https://github.com/Trott) - **Rich Trott** <rtrott@gmail.com> ### Collaborators +* [AndreasMadsen](https://github.com/AndreasMadsen) - **Andreas Madsen** <amwebdk@gmail.com> +* [benjamingr](https://github.com/benjamingr) - **Benjamin Gruenbaum** <benjamingr@gmail.com> * [brendanashworth](https://github.com/brendanashworth) - **Brendan Ashworth** <brendan.ashworth@me.com> * [calvinmetcalf](https://github.com/calvinmetcalf) - **Calvin Metcalf** <calvin.metcalf@gmail.com> -* [ChALkeR](https://github.com/ChALkeR) - **Сковорода Никита Андреевич** <chalkerx@gmail.com> +* [claudiorodriguez](https://github.com/claudiorodriguez) - **Claudio Rodriguez** <cjrodr@yahoo.com> * [domenic](https://github.com/domenic) - **Domenic Denicola** <d@domenic.me> -* [evanlucas](https://github.com/evanlucas) - **Evan Lucas** <evanlucas@me.com> * [geek](https://github.com/geek) - **Wyatt Preul** <wpreul@gmail.com> * [iarna](https://github.com/iarna) - **Rebecca Turner** <me@re-becca.org> * [isaacs](https://github.com/isaacs) - **Isaac Z. Schlueter** <i@izs.me> @@ -402,14 +172,15 @@ information about the governance of the Node.js project, see * [julianduque](https://github.com/julianduque) - **Julian Duque** <julianduquej@gmail.com> * [JungMinu](https://github.com/JungMinu) - **Minwoo Jung** <jmwsoft@gmail.com> * [lxe](https://github.com/lxe) - **Aleksey Smolenchuk** <lxe@lxe.co> +* [matthewloring](https://github.com/matthewloring) - **Matthew Loring** <mattloring@google.com> * [mcollina](https://github.com/mcollina) - **Matteo Collina** <matteo.collina@gmail.com> * [mhdawson](https://github.com/mhdawson) - **Michael Dawson** <michael_dawson@ca.ibm.com> * [micnic](https://github.com/micnic) - **Nicu Micleușanu** <micnic90@gmail.com> * [mikeal](https://github.com/mikeal) - **Mikeal Rogers** <mikeal.rogers@gmail.com> * [monsanto](https://github.com/monsanto) - **Christopher Monsanto** <chris@monsan.to> -* [ofrobots](https://github.com/ofrobots) - **Ali Ijaz Sheikh** <ofrobots@google.com> * [Olegas](https://github.com/Olegas) - **Oleg Elifantiev** <oleg@elifantiev.ru> * [petkaantonov](https://github.com/petkaantonov) - **Petka Antonov** <petka_antonov@hotmail.com> +* [phillipj](https://github.com/phillipj) - **Phillip Johnsen** <johphi@gmail.com> * [qard](https://github.com/qard) - **Stephen Belanger** <admin@stephenbelanger.com> * [rlidwka](https://github.com/rlidwka) - **Alex Kocharin** <alex@kocharin.ru> * [rmg](https://github.com/rmg) - **Ryan Graham** <r.m.graham@gmail.com> @@ -424,10 +195,11 @@ information about the governance of the Node.js project, see * [tellnes](https://github.com/tellnes) - **Christian Tellnes** <christian@tellnes.no> * [thealphanerd](https://github.com/thealphanerd) - **Myles Borins** <myles.borins@gmail.com> * [thefourtheye](https://github.com/thefourtheye) - **Sakthipriyan Vairamani** <thechargingvolcano@gmail.com> +* [thekemkid](https://github.com/thekemkid) - **Glen Keane** <glenkeane.94@gmail.com> * [thlorenz](https://github.com/thlorenz) - **Thorsten Lorenz** <thlorenz@gmx.de> -* [Trott](https://github.com/Trott) - **Rich Trott** <rtrott@gmail.com> * [tunniclm](https://github.com/tunniclm) - **Mike Tunnicliffe** <m.j.tunnicliffe@gmail.com> * [vkurchatkin](https://github.com/vkurchatkin) - **Vladimir Kurchatkin** <vladimir.kurchatkin@gmail.com> +* [whitlockjc](https://github.com/whitlockjc) - **Jeremy Whitlock** <jwhitlock@apache.org> * [yosuke-furukawa](https://github.com/yosuke-furukawa) - **Yosuke Furukawa** <yosuke.furukawa@gmail.com> * [zkat](https://github.com/zkat) - **Kat Marchán** <kzm@sykosomatic.org> diff --git a/ROADMAP.md b/ROADMAP.md index 51b87ae624cadf..ceb69f0473ad11 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -11,9 +11,9 @@ Node.js does not remove stdlib JS API. Shipping with current and well supported dependencies is the best way to ensure long term stability of the platform. When those dependencies are no longer maintained Node.js will take on their continued maintenance as part of our [Long Term Support policy](#long-term-support). Node.js will continue to adopt new V8 releases. -* When V8 ships a breaking change to their C++ API that can be handled by [`nan`](https://github.com/rvagg/nan) +* When V8 ships a breaking change to their C++ API that can be handled by [`nan`](https://github.com/nodejs/nan) the *minor* version of Node.js will be increased. -* When V8 ships a breaking change to their C++ API that can NOT be handled by [`nan`](https://github.com/rvagg/nan) +* When V8 ships a breaking change to their C++ API that can NOT be handled by [`nan`](https://github.com/nodejs/nan) the *major* version of Node.js will be increased. * When new features in the JavaScript language are introduced by V8 the *minor* version number will be increased. TC39 has stated clearly that no diff --git a/WORKING_GROUPS.md b/WORKING_GROUPS.md index 5c062ca7325a9b..1a413fc72a0319 100644 --- a/WORKING_GROUPS.md +++ b/WORKING_GROUPS.md @@ -32,6 +32,7 @@ back in to the CTC. * [Intl](#intl) * [HTTP](#http) * [Documentation](#documentation) +* [Testing](#testing) #### Process: @@ -287,6 +288,18 @@ Its responsibilities are: * Creating and operating a process for documentation review that produces quality documentation and avoids impeding the progress of Core work. +### [Testing](https://github.com/nodejs/testing) + +The Node.js Testing Working Group's purpose is to extend and improve testing of +the Node.js source code. + +It's responsibilities are: + +* Coordinating an overall strategy for improving testing. +* Documenting guidelines around tests. +* Working with the Build Working Group to improve continuous integration. +* Improving tooling for testing. + ## Starting a WG A Working Group is established by first defining a charter that can be diff --git a/benchmark/arrays/var-int.js b/benchmark/arrays/var-int.js index 47a7e62dc7681b..74a73c9515fffa 100644 --- a/benchmark/arrays/var-int.js +++ b/benchmark/arrays/var-int.js @@ -1,6 +1,9 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { - type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), + type: ['Array', 'Buffer', 'Int8Array', 'Uint8Array', 'Int16Array', + 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', + 'Float64Array'], n: [25] }); diff --git a/benchmark/arrays/zero-float.js b/benchmark/arrays/zero-float.js index a6624205bffdea..e2569eed5c4e75 100644 --- a/benchmark/arrays/zero-float.js +++ b/benchmark/arrays/zero-float.js @@ -1,6 +1,9 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { - type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), + type: ['Array', 'Buffer', 'Int8Array', 'Uint8Array', 'Int16Array', + 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', + 'Float64Array'], n: [25] }); diff --git a/benchmark/arrays/zero-int.js b/benchmark/arrays/zero-int.js index 29a2d58b665cbe..8be70c1e87113a 100644 --- a/benchmark/arrays/zero-int.js +++ b/benchmark/arrays/zero-int.js @@ -1,6 +1,9 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { - type: 'Array Buffer Int8Array Uint8Array Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array'.split(' '), + type: ['Array', 'Buffer', 'Int8Array', 'Uint8Array', 'Int16Array', + 'Uint16Array', 'Int32Array', 'Uint32Array', 'Float32Array', + 'Float64Array'], n: [25] }); diff --git a/benchmark/buffers/buffer-base64-decode.js b/benchmark/buffers/buffer-base64-decode.js index 76850c1231eda0..36094f632d4eec 100644 --- a/benchmark/buffers/buffer-base64-decode.js +++ b/benchmark/buffers/buffer-base64-decode.js @@ -1,13 +1,14 @@ -var assert = require('assert'); -var common = require('../common.js'); +'use strict'; +const assert = require('assert'); +const common = require('../common.js'); -var bench = common.createBenchmark(main, {}); +const bench = common.createBenchmark(main, {}); function main(conf) { - for (var s = 'abcd'; s.length < 32 << 20; s += s); + const s = 'abcd'.repeat(8 << 20); s.match(/./); // Flatten string. assert.equal(s.length % 4, 0); - var b = Buffer(s.length / 4 * 3); + const b = Buffer(s.length / 4 * 3); b.write(s, 0, s.length, 'base64'); bench.start(); for (var i = 0; i < 32; i += 1) b.base64Write(s, 0, s.length); diff --git a/benchmark/buffers/buffer-base64-encode.js b/benchmark/buffers/buffer-base64-encode.js index cb520be2a621eb..8e2eec3cf5bb37 100644 --- a/benchmark/buffers/buffer-base64-encode.js +++ b/benchmark/buffers/buffer-base64-encode.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, {}); @@ -6,9 +7,10 @@ function main(conf) { var N = 64 * 1024 * 1024; var b = Buffer(N); var s = ''; - for (var i = 0; i < 256; ++i) s += String.fromCharCode(i); - for (var i = 0; i < N; i += 256) b.write(s, i, 256, 'ascii'); + var i; + for (i = 0; i < 256; ++i) s += String.fromCharCode(i); + for (i = 0; i < N; i += 256) b.write(s, i, 256, 'ascii'); bench.start(); - for (var i = 0; i < 32; ++i) b.toString('base64'); + for (i = 0; i < 32; ++i) b.toString('base64'); bench.end(64); } diff --git a/benchmark/buffers/buffer-bytelength.js b/benchmark/buffers/buffer-bytelength.js index 6a7afe6921aea1..50f420f412d30b 100644 --- a/benchmark/buffers/buffer-bytelength.js +++ b/benchmark/buffers/buffer-bytelength.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common'); var bench = common.createBenchmark(main, { @@ -43,7 +44,7 @@ function main(conf) { var r = Buffer.byteLength(strings[index], encoding); if (r !== results[index]) - throw Error('incorrect return value'); + throw new Error('incorrect return value'); } bench.end(n); } diff --git a/benchmark/buffers/buffer-compare-instance-method.js b/benchmark/buffers/buffer-compare-instance-method.js new file mode 100644 index 00000000000000..0becbeee23a7d7 --- /dev/null +++ b/benchmark/buffers/buffer-compare-instance-method.js @@ -0,0 +1,29 @@ +'use strict'; +const common = require('../common.js'); +const v8 = require('v8'); + +const bench = common.createBenchmark(main, { + size: [16, 512, 1024, 4096, 16386], + 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'); + + b1[size - 1] = 'b'.charCodeAt(0); + + // Force optimization before starting the benchmark + 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); + } + bench.end(iter / 1e6); +} diff --git a/benchmark/buffers/buffer-compare.js b/benchmark/buffers/buffer-compare.js index b02e8a74030042..c83bb67fa24ad8 100644 --- a/benchmark/buffers/buffer-compare.js +++ b/benchmark/buffers/buffer-compare.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { diff --git a/benchmark/buffers/buffer-creation.js b/benchmark/buffers/buffer-creation.js index bc0c55711858de..dfb68467cc54b9 100644 --- a/benchmark/buffers/buffer-creation.js +++ b/benchmark/buffers/buffer-creation.js @@ -1,4 +1,5 @@ -SlowBuffer = require('buffer').SlowBuffer; +'use strict'; +const SlowBuffer = require('buffer').SlowBuffer; var common = require('../common.js'); var bench = common.createBenchmark(main, { @@ -13,7 +14,7 @@ function main(conf) { var clazz = conf.type === 'fast' ? Buffer : SlowBuffer; bench.start(); for (var i = 0; i < n * 1024; i++) { - b = new clazz(len); + new clazz(len); } bench.end(n); } diff --git a/benchmark/buffers/buffer-indexof.js b/benchmark/buffers/buffer-indexof.js index c575f54b6a638c..6f10033020bc74 100644 --- a/benchmark/buffers/buffer-indexof.js +++ b/benchmark/buffers/buffer-indexof.js @@ -1,5 +1,7 @@ +'use strict'; var common = require('../common.js'); var fs = require('fs'); +const path = require('path'); var bench = common.createBenchmark(main, { search: ['@', 'SQ', '10x', '--l', 'Alice', 'Gryphon', 'Panther', @@ -14,7 +16,9 @@ var bench = common.createBenchmark(main, { function main(conf) { var iter = (conf.iter) * 100000; - var aliceBuffer = fs.readFileSync(__dirname + '/../fixtures/alice.html'); + var aliceBuffer = fs.readFileSync( + path.resolve(__dirname, '../fixtures/alice.html') + ); var search = conf.search; var encoding = conf.encoding; diff --git a/benchmark/buffers/buffer-iterate.js b/benchmark/buffers/buffer-iterate.js index 77a0b59b8ac081..fb8abc1aee1c63 100644 --- a/benchmark/buffers/buffer-iterate.js +++ b/benchmark/buffers/buffer-iterate.js @@ -1,3 +1,4 @@ +'use strict'; var SlowBuffer = require('buffer').SlowBuffer; var common = require('../common.js'); var assert = require('assert'); diff --git a/benchmark/buffers/buffer-read.js b/benchmark/buffers/buffer-read.js index 92138bccef99d6..2810aa1b463321 100644 --- a/benchmark/buffers/buffer-read.js +++ b/benchmark/buffers/buffer-read.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { @@ -21,10 +22,10 @@ function main(conf) { buff.writeDoubleLE(0, 0, noAssert); var testFunction = new Function('buff', [ - "for (var i = 0; i !== " + len + "; i++) {", - " buff." + fn + "(0, " + JSON.stringify(noAssert) + ");", - "}" - ].join("\n")); + 'for (var i = 0; i !== ' + len + '; i++) {', + ' buff.' + fn + '(0, ' + JSON.stringify(noAssert) + ');', + '}' + ].join('\n')); bench.start(); testFunction(buff); bench.end(len / 1e6); diff --git a/benchmark/buffers/buffer-slice.js b/benchmark/buffers/buffer-slice.js index f632fa64adff11..70cf3a705c0d8b 100644 --- a/benchmark/buffers/buffer-slice.js +++ b/benchmark/buffers/buffer-slice.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var SlowBuffer = require('buffer').SlowBuffer; diff --git a/benchmark/buffers/buffer-tostring.js b/benchmark/buffers/buffer-tostring.js index 948052042d677b..f71c2b9a2b5127 100644 --- a/benchmark/buffers/buffer-tostring.js +++ b/benchmark/buffers/buffer-tostring.js @@ -14,12 +14,13 @@ function main(conf) { const n = conf.n | 0; const buf = Buffer(len).fill(42); + var i; bench.start(); if (arg) { - for (var i = 0; i < n; i += 1) + for (i = 0; i < n; i += 1) buf.toString('utf8'); } else { - for (var i = 0; i < n; i += 1) + for (i = 0; i < n; i += 1) buf.toString(); } bench.end(n); diff --git a/benchmark/buffers/buffer-write.js b/benchmark/buffers/buffer-write.js index 2a2a0e37e3adda..4e07fc511be12a 100644 --- a/benchmark/buffers/buffer-write.js +++ b/benchmark/buffers/buffer-write.js @@ -1,4 +1,4 @@ - +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { noAssert: [false, true], @@ -48,10 +48,10 @@ function main(conf) { function benchInt(buff, fn, len, noAssert) { var m = mod[fn]; var testFunction = new Function('buff', [ - "for (var i = 0; i !== " + len + "; i++) {", - " buff." + fn + "(i & " + m + ", 0, " + JSON.stringify(noAssert) + ");", - "}" - ].join("\n")); + 'for (var i = 0; i !== ' + len + '; i++) {', + ' buff.' + fn + '(i & ' + m + ', 0, ' + JSON.stringify(noAssert) + ');', + '}' + ].join('\n')); bench.start(); testFunction(buff); bench.end(len / 1e6); @@ -59,10 +59,10 @@ function benchInt(buff, fn, len, noAssert) { function benchFloat(buff, fn, len, noAssert) { var testFunction = new Function('buff', [ - "for (var i = 0; i !== " + len + "; i++) {", - " buff." + fn + "(i, 0, " + JSON.stringify(noAssert) + ");", - "}" - ].join("\n")); + 'for (var i = 0; i !== ' + len + '; i++) {', + ' buff.' + fn + '(i, 0, ' + JSON.stringify(noAssert) + ');', + '}' + ].join('\n')); bench.start(); testFunction(buff); bench.end(len / 1e6); diff --git a/benchmark/buffers/dataview-set.js b/benchmark/buffers/dataview-set.js index ce0064edb6e0cd..ab9c1d1d23b736 100644 --- a/benchmark/buffers/dataview-set.js +++ b/benchmark/buffers/dataview-set.js @@ -1,4 +1,4 @@ - +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { type: ['Uint8', 'Uint16LE', 'Uint16BE', diff --git a/benchmark/common.js b/benchmark/common.js index 511ae384f418bf..69c3d00ee2e1f1 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -1,3 +1,4 @@ +'use strict'; var assert = require('assert'); var fs = require('fs'); var path = require('path'); @@ -27,7 +28,7 @@ if (module === require.main) { var tests = fs.readdirSync(dir); if (testFilter) { - var filteredTests = tests.filter(function(item){ + var filteredTests = tests.filter(function(item) { if (item.lastIndexOf(testFilter) >= 0) { return item; } @@ -48,7 +49,7 @@ function hasWrk() { if (result.error && result.error.code === 'ENOENT') { console.error('Couldn\'t locate `wrk` which is needed for running ' + 'benchmarks. Check benchmark/README.md for further instructions.'); - process.exit(-1); + process.exit(-1); } } @@ -86,7 +87,7 @@ function Benchmark(fn, options) { this.options = options; this.config = parseOpts(options); this._name = require.main.filename.split(/benchmark[\/\\]/).pop(); - this._start = [0,0]; + this._start = [0, 0]; this._started = false; var self = this; @@ -120,7 +121,7 @@ Benchmark.prototype.http = function(p, args, cb) { if (code) { console.error('wrk failed with ' + code); - process.exit(code) + process.exit(code); } var match = out.match(regexp); var qps = match && +match[1]; @@ -140,8 +141,6 @@ Benchmark.prototype._run = function() { // some options weren't set. // run with all combinations var main = require.main.filename; - var settings = []; - var queueLen = 1; var options = this.options; var queue = Object.keys(options).reduce(function(set, key) { @@ -192,7 +191,7 @@ function parseOpts(options) { if (!match || !match[1] || !match[2] || !options[match[1]]) { return null; } else { - conf[match[1]] = isFinite(match[2]) ? +match[2] : match[2] + conf[match[1]] = isFinite(match[2]) ? +match[2] : match[2]; num--; } } @@ -203,7 +202,7 @@ function parseOpts(options) { }); } return num === 0 ? conf : null; -}; +} Benchmark.prototype.start = function() { if (this._started) @@ -221,8 +220,8 @@ Benchmark.prototype.end = function(operations) { if (typeof operations !== 'number') throw new Error('called end() without specifying operation count'); - var time = elapsed[0] + elapsed[1]/1e9; - var rate = operations/time; + var time = elapsed[0] + elapsed[1] / 1e9; + var rate = operations / time; this.report(rate); }; diff --git a/benchmark/compare.js b/benchmark/compare.js index edb116d0c64baa..44854aefa7b5e8 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -1,3 +1,4 @@ +'use strict'; var usage = 'node benchmark/compare.js ' + ' ' + '[--html] [--red|-r] [--green|-g] ' + @@ -36,18 +37,19 @@ for (var i = 2; i < process.argv.length; i++) { } } +var start, green, red, reset, end; if (!html) { - var start = ''; - var green = '\033[1;32m'; - var red = '\033[1;31m'; - var reset = '\033[m'; - var end = ''; + start = ''; + green = '\u001b[1;32m'; + red = '\u001b[1;31m'; + reset = '\u001b[m'; + end = ''; } else { - var start = '
';
-  var green = '';
-  var red = '';
-  var reset = '';
-  var end = '
'; + start = '
';
+  green = '';
+  red = '';
+  reset = '';
+  end = '
'; } var runBench = process.env.NODE_BENCH || 'bench'; @@ -75,10 +77,15 @@ function run() { var out = ''; var child; - if (Array.isArray(benchmarks) && benchmarks.length) - child = spawn(node, ['benchmark/common.js'].concat(benchmarks), { env: env }); - else + if (Array.isArray(benchmarks) && benchmarks.length) { + child = spawn( + node, + ['benchmark/common.js'].concat(benchmarks), + { env: env } + ); + } else { child = spawn('make', [runBench], { env: env }); + } child.stdout.setEncoding('utf8'); child.stdout.on('data', function(c) { out += c; @@ -134,9 +141,20 @@ function compare() { if (show === 'green' && !g || show === 'red' && !r) return; - var r0 = util.format('%s%s: %d%s', g, nodes[0], n0.toPrecision(5), g ? reset : ''); - var r1 = util.format('%s%s: %d%s', r, nodes[1], n1.toPrecision(5), r ? reset : ''); - var pct = c + pct + '%' + reset; + var r0 = util.format( + '%s%s: %d%s', + g, + nodes[0], + n0.toPrecision(5), g ? reset : '' + ); + var r1 = util.format( + '%s%s: %d%s', + r, + nodes[1], + n1.toPrecision(5), r ? reset : '' + ); + pct = c + pct + '%' + reset; + var l = util.format('%s: %s %s', bench, r0, r1); maxLen = Math.max(l.length + pct.length, maxLen); return [l, pct]; diff --git a/benchmark/crypto/aes-gcm-throughput.js b/benchmark/crypto/aes-gcm-throughput.js index 65e1713f0eb1c6..fc379b21b748bf 100644 --- a/benchmark/crypto/aes-gcm-throughput.js +++ b/benchmark/crypto/aes-gcm-throughput.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var crypto = require('crypto'); var keylen = {'aes-128-gcm': 16, 'aes-192-gcm': 24, 'aes-256-gcm': 32}; @@ -30,7 +31,7 @@ function AEAD_Bench(cipher, message, associate_data, key, iv, n, len) { var bob = crypto.createDecipheriv(cipher, key, iv); bob.setAuthTag(tag); bob.setAAD(associate_data); - var clear = bob.update(enc); + bob.update(enc); bob.final(); } diff --git a/benchmark/crypto/cipher-stream.js b/benchmark/crypto/cipher-stream.js index 4e8198931729f4..5da6f2481ecbc3 100644 --- a/benchmark/crypto/cipher-stream.js +++ b/benchmark/crypto/cipher-stream.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { @@ -85,17 +86,17 @@ function streamWrite(alice, bob, message, encoding, writes) { function legacyWrite(alice, bob, message, encoding, writes) { var written = 0; + var enc, dec; for (var i = 0; i < writes; i++) { - var enc = alice.update(message, encoding); - var dec = bob.update(enc); + enc = alice.update(message, encoding); + dec = bob.update(enc); written += dec.length; } - var enc = alice.final(); - var dec = bob.update(enc); + enc = alice.final(); + dec = bob.update(enc); written += dec.length; dec = bob.final(); written += dec.length; - var bits = written * 8; var gbits = written / (1024 * 1024 * 1024); bench.end(gbits); } diff --git a/benchmark/crypto/hash-stream-creation.js b/benchmark/crypto/hash-stream-creation.js index a14aa220120e4e..4bcd37f00aaae8 100644 --- a/benchmark/crypto/hash-stream-creation.js +++ b/benchmark/crypto/hash-stream-creation.js @@ -1,5 +1,6 @@ // throughput benchmark // creates a single hasher, then pushes a bunch of data through it +'use strict'; var common = require('../common.js'); var crypto = require('crypto'); @@ -20,9 +21,6 @@ function main(conf) { api = 'legacy'; } - var crypto = require('crypto'); - var assert = require('assert'); - var message; var encoding; switch (conf.type) { diff --git a/benchmark/crypto/hash-stream-throughput.js b/benchmark/crypto/hash-stream-throughput.js index 2e987f03f5a1cf..050bbeb1ae54d3 100644 --- a/benchmark/crypto/hash-stream-throughput.js +++ b/benchmark/crypto/hash-stream-throughput.js @@ -1,5 +1,6 @@ // throughput benchmark // creates a single hasher, then pushes a bunch of data through it +'use strict'; var common = require('../common.js'); var crypto = require('crypto'); @@ -19,9 +20,6 @@ function main(conf) { api = 'legacy'; } - var crypto = require('crypto'); - var assert = require('assert'); - var message; var encoding; switch (conf.type) { diff --git a/benchmark/crypto/rsa-encrypt-decrypt-throughput.js b/benchmark/crypto/rsa-encrypt-decrypt-throughput.js index 1cd7a5e632910b..cf0579134cfb62 100644 --- a/benchmark/crypto/rsa-encrypt-decrypt-throughput.js +++ b/benchmark/crypto/rsa-encrypt-decrypt-throughput.js @@ -1,3 +1,4 @@ +'use strict'; // throughput benchmark in signing and verifying var common = require('../common.js'); var crypto = require('crypto'); @@ -22,7 +23,6 @@ var bench = common.createBenchmark(main, { }); function main(conf) { - var crypto = require('crypto'); var message = (new Buffer(conf.len)).fill('b'); bench.start(); @@ -38,7 +38,7 @@ function StreamWrite(algo, keylen, message, n, len) { var publicKey = RSA_PublicPem[keylen]; for (var i = 0; i < n; i++) { var enc = crypto.privateEncrypt(privateKey, message); - var clear = crypto.publicDecrypt(publicKey, enc); + crypto.publicDecrypt(publicKey, enc); } bench.end(kbits); diff --git a/benchmark/crypto/rsa-sign-verify-throughput.js b/benchmark/crypto/rsa-sign-verify-throughput.js index fd4260417b2221..779cc8bca1c6a8 100644 --- a/benchmark/crypto/rsa-sign-verify-throughput.js +++ b/benchmark/crypto/rsa-sign-verify-throughput.js @@ -1,3 +1,4 @@ +'use strict'; // throughput benchmark in signing and verifying var common = require('../common.js'); var crypto = require('crypto'); @@ -23,7 +24,6 @@ var bench = common.createBenchmark(main, { }); function main(conf) { - var crypto = require('crypto'); var message = (new Buffer(conf.len)).fill('b'); bench.start(); @@ -36,7 +36,6 @@ function StreamWrite(algo, keylen, message, writes, len) { var kbits = bits / (1024); var privateKey = RSA_PrivatePem[keylen]; - var publicKey = RSA_PublicPem[keylen]; var s = crypto.createSign(algo); var v = crypto.createVerify(algo); @@ -45,7 +44,7 @@ function StreamWrite(algo, keylen, message, writes, len) { v.update(message); } - var sign = s.sign(privateKey, 'binary'); + s.sign(privateKey, 'binary'); s.end(); v.end(); diff --git a/benchmark/events/ee-add-remove.js b/benchmark/events/ee-add-remove.js index cd9fe3cb7de057..99d85367cb8d6f 100644 --- a/benchmark/events/ee-add-remove.js +++ b/benchmark/events/ee-add-remove.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var events = require('events'); @@ -9,14 +10,15 @@ function main(conf) { var ee = new events.EventEmitter(); var listeners = []; - for (var k = 0; k < 10; k += 1) + var k; + for (k = 0; k < 10; k += 1) listeners.push(function() {}); bench.start(); for (var i = 0; i < n; i += 1) { - for (var k = listeners.length; --k >= 0; /* empty */) + for (k = listeners.length; --k >= 0; /* empty */) ee.on('dummy', listeners[k]); - for (var k = listeners.length; --k >= 0; /* empty */) + for (k = listeners.length; --k >= 0; /* empty */) ee.removeListener('dummy', listeners[k]); } bench.end(n); diff --git a/benchmark/events/ee-emit-multi-args.js b/benchmark/events/ee-emit-multi-args.js index 78a892d457095d..b423c216b1ed73 100644 --- a/benchmark/events/ee-emit-multi-args.js +++ b/benchmark/events/ee-emit-multi-args.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var EventEmitter = require('events').EventEmitter; @@ -7,7 +8,6 @@ function main(conf) { var n = conf.n | 0; var ee = new EventEmitter(); - var listeners = []; for (var k = 0; k < 10; k += 1) ee.on('dummy', function() {}); diff --git a/benchmark/events/ee-emit.js b/benchmark/events/ee-emit.js index 4c45bd9b719665..87772222f0a467 100644 --- a/benchmark/events/ee-emit.js +++ b/benchmark/events/ee-emit.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var EventEmitter = require('events').EventEmitter; diff --git a/benchmark/events/ee-listener-count-on-prototype.js b/benchmark/events/ee-listener-count-on-prototype.js index 8d536edd62739b..dfe7e27cd09144 100644 --- a/benchmark/events/ee-listener-count-on-prototype.js +++ b/benchmark/events/ee-listener-count-on-prototype.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var EventEmitter = require('events').EventEmitter; @@ -13,7 +14,7 @@ function main(conf) { bench.start(); for (var i = 0; i < n; i += 1) { - var r = ee.listenerCount('dummy'); + ee.listenerCount('dummy'); } bench.end(n); } diff --git a/benchmark/events/ee-listeners-many.js b/benchmark/events/ee-listeners-many.js index 32721b32e56527..063732e1facb4b 100644 --- a/benchmark/events/ee-listeners-many.js +++ b/benchmark/events/ee-listeners-many.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var EventEmitter = require('events').EventEmitter; @@ -14,7 +15,7 @@ function main(conf) { bench.start(); for (var i = 0; i < n; i += 1) { - var r = ee.listeners('dummy'); + ee.listeners('dummy'); } bench.end(n); } diff --git a/benchmark/events/ee-listeners.js b/benchmark/events/ee-listeners.js index 68339bc3eca77a..e91ca5078f5f98 100644 --- a/benchmark/events/ee-listeners.js +++ b/benchmark/events/ee-listeners.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var EventEmitter = require('events').EventEmitter; @@ -13,7 +14,7 @@ function main(conf) { bench.start(); for (var i = 0; i < n; i += 1) { - var r = ee.listeners('dummy'); + ee.listeners('dummy'); } bench.end(n); } diff --git a/benchmark/fs-write-stream-throughput.js b/benchmark/fs-write-stream-throughput.js index b131d5b736fd38..4c767cf666e579 100644 --- a/benchmark/fs-write-stream-throughput.js +++ b/benchmark/fs-write-stream-throughput.js @@ -1,5 +1,5 @@ - // If there are no args, then this is the root. Run all the benchmarks! +'use strict'; if (!process.argv[2]) parent(); else @@ -39,24 +39,24 @@ function parent() { function runTest(dur, size, type) { if (type !== 'string') type = 'buffer'; + var chunk; switch (type) { case 'string': - var chunk = new Array(size + 1).join('a'); + chunk = new Array(size + 1).join('a'); break; case 'buffer': - var chunk = new Buffer(size); + chunk = new Buffer(size); chunk.fill('a'); break; } - var writes = 0; var fs = require('fs'); try { fs.unlinkSync('write_stream_throughput'); } catch (e) {} - var start + var start; var end; function done() { - var time = end[0] + end[1]/1E9; + var time = end[0] + end[1] / 1E9; var written = fs.statSync('write_stream_throughput').size / 1024; var rate = (written / time).toFixed(2); console.log('fs_write_stream_dur_%d_size_%d_type_%s: %d', diff --git a/benchmark/fs/read-stream-throughput.js b/benchmark/fs/read-stream-throughput.js index a181a2df60291c..c305485cd5f8dc 100644 --- a/benchmark/fs/read-stream-throughput.js +++ b/benchmark/fs/read-stream-throughput.js @@ -1,4 +1,5 @@ // test the throughput of the fs.WriteStream class. +'use strict'; var path = require('path'); var common = require('../common.js'); @@ -11,7 +12,7 @@ var type, encoding, size; var bench = common.createBenchmark(main, { type: ['buf', 'asc', 'utf'], - size: [1024, 4096, 65535, 1024*1024] + size: [1024, 4096, 65535, 1024 * 1024] }); function main(conf) { diff --git a/benchmark/fs/readfile.js b/benchmark/fs/readfile.js index ac3241901b931e..0f39f64f57c418 100644 --- a/benchmark/fs/readfile.js +++ b/benchmark/fs/readfile.js @@ -1,6 +1,7 @@ // Call fs.readFile over and over again really fast. // Then see how many times it got called. // Yes, this is a silly benchmark. Most benchmarks are silly. +'use strict'; var path = require('path'); var common = require('../common.js'); diff --git a/benchmark/fs/write-stream-throughput.js b/benchmark/fs/write-stream-throughput.js index 9ff58389c7959d..4f41d2b4bb4af3 100644 --- a/benchmark/fs/write-stream-throughput.js +++ b/benchmark/fs/write-stream-throughput.js @@ -1,4 +1,5 @@ // test the throughput of the fs.WriteStream class. +'use strict'; var path = require('path'); var common = require('../common.js'); @@ -28,7 +29,7 @@ function main(conf) { encoding = 'ascii'; break; case 'utf': - chunk = new Array(Math.ceil(size/2) + 1).join('ü'); + chunk = new Array(Math.ceil(size / 2) + 1).join('ü'); encoding = 'utf8'; break; default: diff --git a/benchmark/http/_chunky_http_client.js b/benchmark/http/_chunky_http_client.js index 24e14ca2bc9b0e..158be5a0eb6424 100644 --- a/benchmark/http/_chunky_http_client.js +++ b/benchmark/http/_chunky_http_client.js @@ -15,7 +15,6 @@ var bench = common.createBenchmark(main, { function main(conf) { var len = +conf.len; var num = +conf.num; - var type = conf.type; var todo = []; var headers = []; // Chose 7 because 9 showed "Connection error" / "Connection closed" @@ -24,7 +23,7 @@ function main(conf) { headers.push(Array(i + 1).join('o')); function WriteHTTPHeaders(channel, has_keep_alive, extra_header_count) { - todo = [] + todo = []; todo.push('GET / HTTP/1.1'); todo.push('Host: localhost'); todo.push('Connection: keep-alive'); @@ -63,7 +62,7 @@ function main(conf) { var socket = net.connect(PIPE, function() { bench.start(); WriteHTTPHeaders(socket, 1, len); - socket.setEncoding('utf8') + socket.setEncoding('utf8'); socket.on('data', function(d) { var did = false; var pattern = 'HTTP/1.1 200 OK\r\n'; @@ -73,7 +72,7 @@ function main(conf) { success += 1; did = true; } else { - pattern = 'HTTP/1.1 ' + pattern = 'HTTP/1.1 '; if ((d.length === pattern.length && d === pattern) || (d.length > pattern.length && d.slice(0, pattern.length) === pattern)) { diff --git a/benchmark/http/chunked.js b/benchmark/http/chunked.js index 0589ff3166f04d..642f2962cdce78 100644 --- a/benchmark/http/chunked.js +++ b/benchmark/http/chunked.js @@ -6,9 +6,9 @@ // always as hot as it could be. // // Verify that our assumptions are valid. +'use strict'; var common = require('../common.js'); -var PORT = common.PORT; var bench = common.createBenchmark(main, { num: [1, 4, 8, 16], @@ -17,7 +17,7 @@ var bench = common.createBenchmark(main, { }); function main(conf) { - http = require('http'); + const http = require('http'); var chunk = new Buffer(conf.size); chunk.fill('8'); diff --git a/benchmark/http/client-request-body.js b/benchmark/http/client-request-body.js index 1c27dea2a2066e..befa3811ddd1c3 100644 --- a/benchmark/http/client-request-body.js +++ b/benchmark/http/client-request-body.js @@ -1,4 +1,5 @@ // Measure the time it takes for the HTTP client to send a request body. +'use strict'; var common = require('../common.js'); var http = require('http'); diff --git a/benchmark/http/cluster.js b/benchmark/http/cluster.js index 6391704ff7836b..9934883f7c3fa4 100644 --- a/benchmark/http/cluster.js +++ b/benchmark/http/cluster.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var PORT = common.PORT; diff --git a/benchmark/http/end-vs-write-end.js b/benchmark/http/end-vs-write-end.js index c17e2ffb45fa02..4e12e543f0bd92 100644 --- a/benchmark/http/end-vs-write-end.js +++ b/benchmark/http/end-vs-write-end.js @@ -6,9 +6,9 @@ // always as hot as it could be. // // Verify that our assumptions are valid. +'use strict'; var common = require('../common.js'); -var PORT = common.PORT; var bench = common.createBenchmark(main, { type: ['asc', 'utf', 'buf'], @@ -18,7 +18,7 @@ var bench = common.createBenchmark(main, { }); function main(conf) { - http = require('http'); + const http = require('http'); var chunk; var len = conf.kb * 1024; switch (conf.type) { @@ -27,7 +27,6 @@ function main(conf) { chunk.fill('x'); break; case 'utf': - encoding = 'utf8'; chunk = new Array(len / 2 + 1).join('ü'); break; case 'asc': diff --git a/benchmark/http/http_server_for_chunky_client.js b/benchmark/http/http_server_for_chunky_client.js index dede7daa7cdc75..d85e15bcbed4e9 100644 --- a/benchmark/http/http_server_for_chunky_client.js +++ b/benchmark/http/http_server_for_chunky_client.js @@ -4,8 +4,8 @@ var path = require('path'); var http = require('http'); var fs = require('fs'); var spawn = require('child_process').spawn; -var common = require('../common.js') -var test = require('../../test/common.js') +require('../common.js'); +var test = require('../../test/common.js'); var pep = path.dirname(process.argv[1]) + '/_chunky_http_client.js'; var PIPE = test.PIPE; @@ -38,17 +38,17 @@ try { child = spawn(process.execPath, [pep], { }); child.on('error', function(err) { - throw new Error('spawn error: ' + err ); + throw new Error('spawn error: ' + err); }); child.stdout.pipe(process.stdout); child.stderr.pipe(process.stderr); - child.on('close', function (exitCode) { + child.on('close', function(exitCode) { server.close(); }); -} catch(e) { - throw new Error('error: ' + e ); +} catch (e) { + throw new Error('error: ' + e); } diff --git a/benchmark/http/simple.js b/benchmark/http/simple.js index 5bff9283cb51a1..5449c49be97614 100644 --- a/benchmark/http/simple.js +++ b/benchmark/http/simple.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var PORT = common.PORT; @@ -11,7 +12,6 @@ var bench = common.createBenchmark(main, { function main(conf) { process.env.PORT = PORT; - var spawn = require('child_process').spawn; var server = require('../http_simple.js'); setTimeout(function() { var path = '/' + conf.type + '/' + conf.length + '/' + conf.chunks; diff --git a/benchmark/http_bench.js b/benchmark/http_bench.js index a8f99e2f0e7978..354993a2706a95 100644 --- a/benchmark/http_bench.js +++ b/benchmark/http_bench.js @@ -1,3 +1,4 @@ +'use strict'; var spawn = require('child_process').spawn; var cluster = require('cluster'); var http = require('http'); @@ -20,10 +21,10 @@ for (var i = 2; i < process.argv.length; ++i) { } switch (options.mode) { -case 'master': startMaster(); break; -case 'server': startServer(); break; -case 'client': startClient(); break; -default: throw new Error('Bad mode: ' + options.mode); + case 'master': startMaster(); break; + case 'server': startServer(); break; + case 'client': startClient(); break; + default: throw new Error('Bad mode: ' + options.mode); } process.title = 'http_bench[' + options.mode + ']'; @@ -47,7 +48,7 @@ function startMaster() { var forkCount = 0; - cluster.on('online', function () { + cluster.on('online', function() { forkCount = forkCount + 1; if (forkCount === ~~options.servers) { var args = [ diff --git a/benchmark/http_server_lag.js b/benchmark/http_server_lag.js index ca923d5b34afde..a3c18628ec68ba 100644 --- a/benchmark/http_server_lag.js +++ b/benchmark/http_server_lag.js @@ -1,3 +1,5 @@ +'use strict'; + var http = require('http'); var port = parseInt(process.env.PORT, 10) || 8000; var defaultLag = parseInt(process.argv[2], 10) || 100; @@ -6,7 +8,7 @@ http.createServer(function(req, res) { res.writeHead(200, { 'content-type': 'text/plain', 'content-length': '2' }); - var lag = parseInt(req.url.split("/").pop(), 10) || defaultLag; + var lag = parseInt(req.url.split('/').pop(), 10) || defaultLag; setTimeout(function() { res.end('ok'); }, lag); diff --git a/benchmark/http_simple.js b/benchmark/http_simple.js index 36800f2c9dba5a..0f36d3b6ce3ebd 100644 --- a/benchmark/http_simple.js +++ b/benchmark/http_simple.js @@ -1,13 +1,13 @@ -var path = require('path'), - exec = require('child_process').exec, - http = require('http'); +'use strict'; + +var http = require('http'); var port = parseInt(process.env.PORT || 8000); var fixed = makeString(20 * 1024, 'C'), - storedBytes = {}, - storedBuffer = {}, - storedUnicode = {}; + storedBytes = {}, + storedBuffer = {}, + storedUnicode = {}; var useDomains = process.env.NODE_USE_DOMAINS; @@ -22,7 +22,7 @@ if (useDomains) { gdom.enter(); } -var server = module.exports = http.createServer(function (req, res) { +var server = module.exports = http.createServer(function(req, res) { if (useDomains) { var dom = domain.create(); dom.add(req); @@ -36,29 +36,30 @@ var server = module.exports = http.createServer(function (req, res) { var n_chunks = parseInt(commands[3], 10); var status = 200; + var n, i; if (command == 'bytes') { - var n = ~~arg; + n = ~~arg; if (n <= 0) - throw new Error('bytes called with n <= 0') + throw new Error('bytes called with n <= 0'); if (storedBytes[n] === undefined) { storedBytes[n] = makeString(n, 'C'); } body = storedBytes[n]; } else if (command == 'buffer') { - var n = ~~arg; + n = ~~arg; if (n <= 0) throw new Error('buffer called with n <= 0'); if (storedBuffer[n] === undefined) { storedBuffer[n] = new Buffer(n); - for (var i = 0; i < n; i++) { + for (i = 0; i < n; i++) { storedBuffer[n][i] = 'C'.charCodeAt(0); } } body = storedBuffer[n]; } else if (command == 'unicode') { - var n = ~~arg; + n = ~~arg; if (n <= 0) throw new Error('unicode called with n <= 0'); if (storedUnicode[n] === undefined) { @@ -93,7 +94,7 @@ var server = module.exports = http.createServer(function (req, res) { var len = body.length; var step = Math.floor(len / n_chunks) || 1; - for (var i = 0, n = (n_chunks - 1); i < n; ++i) { + for (i = 0, n = (n_chunks - 1); i < n; ++i) { res.write(body.slice(i * step, i * step + step)); } res.end(body.slice((n_chunks - 1) * step)); @@ -114,7 +115,7 @@ function makeString(size, c) { return s; } -server.listen(port, function () { +server.listen(port, function() { if (module === require.main) - console.error('Listening at http://127.0.0.1:'+port+'/'); + console.error('Listening at http://127.0.0.1:' + port + '/'); }); diff --git a/benchmark/http_simple_auto.js b/benchmark/http_simple_auto.js index f72cc01e60aa46..6f56879cc08aaa 100644 --- a/benchmark/http_simple_auto.js +++ b/benchmark/http_simple_auto.js @@ -6,94 +6,95 @@ // Arguments to pass to `ab`. // Target to benchmark, e.g. `bytes/1024` or `buffer/8192`. // +'use strict'; -var path = require("path"); -var http = require("http"); -var spawn = require("child_process").spawn; +var http = require('http'); +var spawn = require('child_process').spawn; var port = parseInt(process.env.PORT || 8000); -var fixed = "" -for (var i = 0; i < 20*1024; i++) { - fixed += "C"; +var fixed = ''; +var i; +for (i = 0; i < 20 * 1024; i++) { + fixed += 'C'; } var stored = {}; var storedBuffer = {}; -var server = http.createServer(function (req, res) { - var commands = req.url.split("/"); +var server = http.createServer(function(req, res) { + var commands = req.url.split('/'); var command = commands[1]; - var body = ""; + var body = ''; var arg = commands[2]; var n_chunks = parseInt(commands[3], 10); var status = 200; + var n; - if (command == "bytes") { - var n = parseInt(arg, 10) + if (command == 'bytes') { + n = parseInt(arg, 10); if (n <= 0) - throw "bytes called with n <= 0" + throw new Error('bytes called with n <= 0'); if (stored[n] === undefined) { - stored[n] = ""; - for (var i = 0; i < n; i++) { - stored[n] += "C" + stored[n] = ''; + for (i = 0; i < n; i++) { + stored[n] += 'C'; } } body = stored[n]; - - } else if (command == "buffer") { - var n = parseInt(arg, 10) - if (n <= 0) throw new Error("bytes called with n <= 0"); + } else if (command == 'buffer') { + n = parseInt(arg, 10); + if (n <= 0) throw new Error('bytes called with n <= 0'); if (storedBuffer[n] === undefined) { storedBuffer[n] = new Buffer(n); - for (var i = 0; i < n; i++) { - storedBuffer[n][i] = "C".charCodeAt(0); + for (i = 0; i < n; i++) { + storedBuffer[n][i] = 'C'.charCodeAt(0); } } body = storedBuffer[n]; - } else if (command == "quit") { + } else if (command == 'quit') { res.connection.server.close(); - body = "quitting"; + body = 'quitting'; - } else if (command == "fixed") { + } else if (command == 'fixed') { body = fixed; - } else if (command == "echo") { - res.writeHead(200, { "Content-Type": "text/plain", - "Transfer-Encoding": "chunked" }); + } else if (command == 'echo') { + res.writeHead(200, { 'Content-Type': 'text/plain', + 'Transfer-Encoding': 'chunked' }); req.pipe(res); return; } else { status = 404; - body = "not found\n"; + body = 'not found\n'; } // example: http://localhost:port/bytes/512/4 // sends a 512 byte body in 4 chunks of 128 bytes if (n_chunks > 0) { - res.writeHead(status, { "Content-Type": "text/plain", - "Transfer-Encoding": "chunked" }); + res.writeHead(status, { 'Content-Type': 'text/plain', + 'Transfer-Encoding': 'chunked' }); // send body in chunks var len = body.length; var step = Math.floor(len / n_chunks) || 1; - for (var i = 0, n = (n_chunks - 1); i < n; ++i) { + for (i = 0, n = (n_chunks - 1); i < n; ++i) { res.write(body.slice(i * step, i * step + step)); } res.end(body.slice((n_chunks - 1) * step)); } else { var content_length = body.length.toString(); - res.writeHead(status, { "Content-Type": "text/plain", - "Content-Length": content_length }); + res.writeHead(status, { 'Content-Type': 'text/plain', + 'Content-Length': content_length }); res.end(body); } }); -server.listen(port, function () { +server.listen(port, function() { var url = 'http://127.0.0.1:' + port + '/'; var n = process.argv.length - 1; @@ -109,10 +110,10 @@ server.listen(port, function () { }); function dump_mm_stats() { - if (typeof gc != 'function') return; + if (typeof global.gc != 'function') return; var before = process.memoryUsage(); - for (var i = 0; i < 10; ++i) gc(); + for (var i = 0; i < 10; ++i) global.gc(); var after = process.memoryUsage(); setTimeout(print_stats, 250); // give GC time to settle diff --git a/benchmark/http_simple_cluster.js b/benchmark/http_simple_cluster.js index 9a886f2ee75dab..f48a2a2599a78f 100644 --- a/benchmark/http_simple_cluster.js +++ b/benchmark/http_simple_cluster.js @@ -1,9 +1,11 @@ -var cluster = require('cluster'); -var os = require('os'); +'use strict'; +const cluster = require('cluster'); +const os = require('os'); +const path = require('path'); if (cluster.isMaster) { console.log('master running on pid %d', process.pid); for (var i = 0, n = os.cpus().length; i < n; ++i) cluster.fork(); } else { - require(__dirname + '/http_simple.js'); + require(path.join(__dirname, 'http_simple.js')); } diff --git a/benchmark/idle_clients.js b/benchmark/idle_clients.js index da96b8ac654db4..d294e685224d8b 100644 --- a/benchmark/idle_clients.js +++ b/benchmark/idle_clients.js @@ -1,27 +1,25 @@ -net = require('net'); +'use strict'; +const net = require('net'); var errors = 0, connections = 0; -var lastClose = 0; - -function connect () { - process.nextTick(function () { +function connect() { + process.nextTick(function() { var s = net.Stream(); var gotConnected = false; s.connect(9000); - s.on('connect', function () { + s.on('connect', function() { gotConnected = true; connections++; connect(); }); - s.on('close', function () { + s.on('close', function() { if (gotConnected) connections--; - lastClose = new Date(); }); - s.on('error', function () { + s.on('error', function() { errors++; }); }); @@ -35,15 +33,15 @@ var oldConnections, oldErrors; // Try to start new connections every so often setInterval(connect, 5000); -setInterval(function () { +setInterval(function() { if (oldConnections != connections) { oldConnections = connections; - console.log("CLIENT %d connections: %d", process.pid, connections); + console.log('CLIENT %d connections: %d', process.pid, connections); } if (oldErrors != errors) { oldErrors = errors; - console.log("CLIENT %d errors: %d", process.pid, errors); + console.log('CLIENT %d errors: %d', process.pid, errors); } }, 1000); diff --git a/benchmark/idle_server.js b/benchmark/idle_server.js index 805c988811ea50..78e496690d1d4e 100644 --- a/benchmark/idle_server.js +++ b/benchmark/idle_server.js @@ -1,12 +1,11 @@ 'use strict'; const net = require('net'); -var connections = 0; var errors = 0; -var server = net.Server(function (socket) { +var server = net.Server(function(socket) { - socket.on('error', function () { + socket.on('error', function() { errors++; }); @@ -18,14 +17,14 @@ server.listen(9000); var oldConnections, oldErrors; -setInterval(function () { +setInterval(function() { if (oldConnections != server.connections) { oldConnections = server.connections; - console.log("SERVER %d connections: %d", process.pid, server.connections); + console.log('SERVER %d connections: %d', process.pid, server.connections); } if (oldErrors != errors) { oldErrors = errors; - console.log("SERVER %d errors: %d", process.pid, errors); + console.log('SERVER %d errors: %d', process.pid, errors); } }, 1000); diff --git a/benchmark/misc/child-process-read.js b/benchmark/misc/child-process-read.js index 894dd55d301249..c1a7474aae32c1 100644 --- a/benchmark/misc/child-process-read.js +++ b/benchmark/misc/child-process-read.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { len: [64, 256, 1024, 4096, 32768], diff --git a/benchmark/misc/domain-fn-args.js b/benchmark/misc/domain-fn-args.js index 36e9e900299bb2..e9b24811c81689 100644 --- a/benchmark/misc/domain-fn-args.js +++ b/benchmark/misc/domain-fn-args.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var domain = require('domain'); @@ -11,17 +12,17 @@ var gargs = [1, 2, 3]; function main(conf) { - var args, ret, n = +conf.n; - var arguments = gargs.slice(0, conf.arguments); + var args, n = +conf.n; + var myArguments = gargs.slice(0, conf.arguments); bench.start(); bdomain.enter(); for (var i = 0; i < n; i++) { - if (arguments.length >= 2) { - args = Array.prototype.slice.call(arguments, 1); - ret = fn.apply(this, args); + if (myArguments.length >= 2) { + args = Array.prototype.slice.call(myArguments, 1); + fn.apply(this, args); } else { - ret = fn.call(this); + fn.call(this); } } bdomain.exit(); @@ -40,4 +41,4 @@ function fn(a, b, c) { c = 3; return a + b + c; -} \ No newline at end of file +} diff --git a/benchmark/misc/freelist.js b/benchmark/misc/freelist.js new file mode 100644 index 00000000000000..7956dc3d6b18c0 --- /dev/null +++ b/benchmark/misc/freelist.js @@ -0,0 +1,38 @@ +'use strict'; + +var common = require('../common.js'); +var FreeList = require('internal/freelist').FreeList; + +var bench = common.createBenchmark(main, { + n: [100000] +}); + +function main(conf) { + var n = conf.n; + var poolSize = 1000; + var list = new FreeList('test', poolSize, Object); + var i; + var j; + var used = []; + + // First, alloc `poolSize` items + for (j = 0; j < poolSize; j++) { + used.push(list.alloc()); + } + + bench.start(); + + for (i = 0; i < n; i++) { + // Return all the items to the pool + for (j = 0; j < poolSize; j++) { + list.free(used[j]); + } + + // Re-alloc from pool + for (j = 0; j < poolSize; j++) { + list.alloc(); + } + } + + bench.end(n); +} diff --git a/benchmark/misc/function_call/index.js b/benchmark/misc/function_call/index.js index fc8542a068ccd6..04f5627093893e 100644 --- a/benchmark/misc/function_call/index.js +++ b/benchmark/misc/function_call/index.js @@ -2,6 +2,7 @@ // relative to a comparable C++ function. // Reports millions of calls per second. // Note that JS speed goes up, while cxx speed stays about the same. +'use strict'; var assert = require('assert'); var common = require('../../common.js'); @@ -27,7 +28,7 @@ assert(js() === cxx()); var bench = common.createBenchmark(main, { type: ['js', 'cxx'], - millions: [1,10,50] + millions: [1, 10, 50] }); function main(conf) { diff --git a/benchmark/misc/module-loader.js b/benchmark/misc/module-loader.js index e53bc4d801164b..1df7a74cbe77e1 100644 --- a/benchmark/misc/module-loader.js +++ b/benchmark/misc/module-loader.js @@ -1,7 +1,7 @@ +'use strict'; var fs = require('fs'); var path = require('path'); var common = require('../common.js'); -var packageJson = '{"main": "index.js"}'; var tmpDirectory = path.join(__dirname, '..', 'tmp'); var benchmarkDirectory = path.join(tmpDirectory, 'nodejs-benchmark-module'); @@ -18,8 +18,14 @@ function main(conf) { var n = +conf.thousands * 1e3; for (var i = 0; i <= n; i++) { fs.mkdirSync(benchmarkDirectory + i); - fs.writeFileSync(benchmarkDirectory + i + '/package.json', '{"main": "index.js"}'); - fs.writeFileSync(benchmarkDirectory + i + '/index.js', 'module.exports = "";'); + fs.writeFileSync( + benchmarkDirectory + i + '/package.json', + '{"main": "index.js"}' + ); + fs.writeFileSync( + benchmarkDirectory + i + '/index.js', + 'module.exports = "";' + ); } measure(n); @@ -38,7 +44,7 @@ function rmrf(location) { var things = fs.readdirSync(location); things.forEach(function(thing) { var cur = path.join(location, thing), - isDirectory = fs.statSync(cur).isDirectory(); + isDirectory = fs.statSync(cur).isDirectory(); if (isDirectory) { rmrf(cur); return; diff --git a/benchmark/misc/next-tick-breadth.js b/benchmark/misc/next-tick-breadth.js index 652408144373f6..87d130f3a7e102 100644 --- a/benchmark/misc/next-tick-breadth.js +++ b/benchmark/misc/next-tick-breadth.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { diff --git a/benchmark/misc/next-tick-depth.js b/benchmark/misc/next-tick-depth.js index 8a2c8e0a6ae148..bc513d338d6d8c 100644 --- a/benchmark/misc/next-tick-depth.js +++ b/benchmark/misc/next-tick-depth.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { millions: [2] diff --git a/benchmark/misc/spawn-echo.js b/benchmark/misc/spawn-echo.js index 2b1b989e679b96..7c9e851aacb641 100644 --- a/benchmark/misc/spawn-echo.js +++ b/benchmark/misc/spawn-echo.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { thousands: [1] diff --git a/benchmark/misc/startup.js b/benchmark/misc/startup.js index aa5b4420f65903..34604911d250f3 100644 --- a/benchmark/misc/startup.js +++ b/benchmark/misc/startup.js @@ -1,10 +1,8 @@ +'use strict'; var common = require('../common.js'); var spawn = require('child_process').spawn; var path = require('path'); var emptyJsFile = path.resolve(__dirname, '../../test/fixtures/semicolon.js'); -var starts = 100; -var i = 0; -var start; var bench = common.createBenchmark(startNode, { dur: [1] @@ -14,7 +12,6 @@ function startNode(conf) { var dur = +conf.dur; var go = true; var starts = 0; - var open = 0; setTimeout(function() { go = false; diff --git a/benchmark/misc/string-creation.js b/benchmark/misc/string-creation.js index 74dabd66c02501..59fb1b52b4ec12 100644 --- a/benchmark/misc/string-creation.js +++ b/benchmark/misc/string-creation.js @@ -1,8 +1,9 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { millions: [100] -}) +}); function main(conf) { var n = +conf.millions * 1e6; @@ -10,7 +11,7 @@ function main(conf) { var s; for (var i = 0; i < n; i++) { s = '01234567890'; - s[1] = "a"; + s[1] = 'a'; } bench.end(n / 1e6); } diff --git a/benchmark/misc/string-decoder.js b/benchmark/misc/string-decoder.js index 14563cee0d7754..b10b0a6e9cbd48 100644 --- a/benchmark/misc/string-decoder.js +++ b/benchmark/misc/string-decoder.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var StringDecoder = require('string_decoder').StringDecoder; @@ -21,6 +22,7 @@ function main(conf) { var chunks = []; var str = ''; var isBase64 = (encoding === 'base64-ascii' || encoding === 'base64-utf8'); + var i; if (encoding === 'ascii' || encoding === 'base64-ascii') alpha = ASC_ALPHA; @@ -31,7 +33,7 @@ function main(conf) { var sd = new StringDecoder(isBase64 ? 'base64' : encoding); - for (var i = 0; i < inLen; ++i) { + for (i = 0; i < inLen; ++i) { if (i > 0 && (i % chunkLen) === 0 && !isBase64) { chunks.push(new Buffer(str, encoding)); str = ''; @@ -52,7 +54,7 @@ function main(conf) { var nChunks = chunks.length; bench.start(); - for (var i = 0; i < n; ++i) { + for (i = 0; i < n; ++i) { for (var j = 0; j < nChunks; ++j) sd.write(chunks[j]); } diff --git a/benchmark/misc/timers.js b/benchmark/misc/timers.js index 23f571bb4528a1..13b18fffc5ead7 100644 --- a/benchmark/misc/timers.js +++ b/benchmark/misc/timers.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { diff --git a/benchmark/misc/url.js b/benchmark/misc/url.js index 6c2799b6cb92b2..4b65300a9c580d 100644 --- a/benchmark/misc/url.js +++ b/benchmark/misc/url.js @@ -1,4 +1,5 @@ -var url = require('url') +'use strict'; +var url = require('url'); var n = 25 * 100; var urls = [ @@ -20,7 +21,7 @@ benchmark('parse()', url.parse); benchmark('format()', url.format); paths.forEach(function(p) { benchmark('resolve("' + p + '")', function(u) { - url.resolve(u, p) + url.resolve(u, p); }); }); diff --git a/benchmark/misc/v8-bench.js b/benchmark/misc/v8-bench.js index 0eb95aa9e2b2bc..0b9a5139ba23cf 100644 --- a/benchmark/misc/v8-bench.js +++ b/benchmark/misc/v8-bench.js @@ -1,4 +1,5 @@ // compare with "google-chrome deps/v8/benchmarks/run.html" +'use strict'; var fs = require('fs'); var path = require('path'); var vm = require('vm'); @@ -19,4 +20,4 @@ global.load = function(filename) { global.RegExp = $RegExp; }; -load('run.js'); +global.load('run.js'); diff --git a/benchmark/net/dgram.js b/benchmark/net/dgram.js index 6a0c5501c62c8e..fed5b873929b98 100644 --- a/benchmark/net/dgram.js +++ b/benchmark/net/dgram.js @@ -1,3 +1,4 @@ +'use strict'; // test UDP send/recv throughput var common = require('../common.js'); @@ -18,7 +19,6 @@ var len; var num; var type; var chunk; -var encoding; function main(conf) { dur = +conf.dur; diff --git a/benchmark/net/net-c2s-cork.js b/benchmark/net/net-c2s-cork.js index 5f8e0fa4357b99..5d1c8a7495ead9 100644 --- a/benchmark/net/net-c2s-cork.js +++ b/benchmark/net/net-c2s-cork.js @@ -1,4 +1,5 @@ // test the speed of .pipe() with sockets +'use strict'; var common = require('../common.js'); var PORT = common.PORT; @@ -35,7 +36,6 @@ function main(conf) { break; default: throw new Error('invalid type: ' + type); - break; } server(); @@ -77,8 +77,8 @@ function server() { socket.on('connect', function() { bench.start(); - socket.on('drain', send) - send() + socket.on('drain', send); + send(); setTimeout(function() { var bytes = writer.received; @@ -88,7 +88,7 @@ function server() { function send() { socket.cork(); - while(socket.write(chunk, encoding)) {} + while (socket.write(chunk, encoding)) {} socket.uncork(); } }); diff --git a/benchmark/net/net-c2s.js b/benchmark/net/net-c2s.js index 49de7c77c9265c..370ff4f138cafd 100644 --- a/benchmark/net/net-c2s.js +++ b/benchmark/net/net-c2s.js @@ -1,4 +1,5 @@ // test the speed of .pipe() with sockets +'use strict'; var common = require('../common.js'); var PORT = common.PORT; @@ -35,7 +36,6 @@ function main(conf) { break; default: throw new Error('invalid type: ' + type); - break; } server(); diff --git a/benchmark/net/net-pipe.js b/benchmark/net/net-pipe.js index 2a5ed8e483659e..ea8af249a35b50 100644 --- a/benchmark/net/net-pipe.js +++ b/benchmark/net/net-pipe.js @@ -1,4 +1,5 @@ // test the speed of .pipe() with sockets +'use strict'; var common = require('../common.js'); var PORT = common.PORT; @@ -35,7 +36,6 @@ function main(conf) { break; default: throw new Error('invalid type: ' + type); - break; } server(); diff --git a/benchmark/net/net-s2c.js b/benchmark/net/net-s2c.js index 79e22494a7b8ed..af40d8d58d8852 100644 --- a/benchmark/net/net-s2c.js +++ b/benchmark/net/net-s2c.js @@ -1,4 +1,5 @@ // test the speed of .pipe() with sockets +'use strict'; var common = require('../common.js'); var PORT = common.PORT; @@ -35,7 +36,6 @@ function main(conf) { break; default: throw new Error('invalid type: ' + type); - break; } server(); diff --git a/benchmark/net/tcp-raw-c2s.js b/benchmark/net/tcp-raw-c2s.js index 0039313f5235ad..e13af85c6774dd 100644 --- a/benchmark/net/tcp-raw-c2s.js +++ b/benchmark/net/tcp-raw-c2s.js @@ -1,5 +1,6 @@ // In this benchmark, we connect a client to the server, and write // as many bytes as we can in the specified time (default = 10s) +'use strict'; var common = require('../common.js'); var util = require('util'); @@ -89,7 +90,6 @@ function client() { break; default: throw new Error('invalid type: ' + type); - break; } var clientHandle = new TCP(); diff --git a/benchmark/net/tcp-raw-pipe.js b/benchmark/net/tcp-raw-pipe.js index 1504d11db5fa53..c05c816855e7a6 100644 --- a/benchmark/net/tcp-raw-pipe.js +++ b/benchmark/net/tcp-raw-pipe.js @@ -1,5 +1,6 @@ // In this benchmark, we connect a client to the server, and write // as many bytes as we can in the specified time (default = 10s) +'use strict'; var common = require('../common.js'); var util = require('util'); @@ -87,7 +88,6 @@ function client() { break; default: throw new Error('invalid type: ' + type); - break; } var clientHandle = new TCP(); diff --git a/benchmark/net/tcp-raw-s2c.js b/benchmark/net/tcp-raw-s2c.js index 502586c2a05e29..822a74c679db12 100644 --- a/benchmark/net/tcp-raw-s2c.js +++ b/benchmark/net/tcp-raw-s2c.js @@ -1,5 +1,6 @@ // In this benchmark, we connect a client to the server, and write // as many bytes as we can in the specified time (default = 10s) +'use strict'; var common = require('../common.js'); var util = require('util'); @@ -61,7 +62,6 @@ function server() { break; default: throw new Error('invalid type: ' + type); - break; } clientHandle.readStart(); diff --git a/benchmark/path/basename.js b/benchmark/path/basename.js index 57d9492746b32c..6c710dbb58ceb6 100644 --- a/benchmark/path/basename.js +++ b/benchmark/path/basename.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var path = require('path'); var v8 = require('v8'); diff --git a/benchmark/path/dirname.js b/benchmark/path/dirname.js index e95adf28811a4e..4a9c04158cdee6 100644 --- a/benchmark/path/dirname.js +++ b/benchmark/path/dirname.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var path = require('path'); var v8 = require('v8'); diff --git a/benchmark/path/extname.js b/benchmark/path/extname.js index c655ee7e3e160a..4f7c6b542d21c4 100644 --- a/benchmark/path/extname.js +++ b/benchmark/path/extname.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var path = require('path'); var v8 = require('v8'); diff --git a/benchmark/path/format.js b/benchmark/path/format.js index bc77f888116963..478a30cbaedbd2 100644 --- a/benchmark/path/format.js +++ b/benchmark/path/format.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var path = require('path'); var v8 = require('v8'); diff --git a/benchmark/path/isAbsolute.js b/benchmark/path/isAbsolute.js index d4c79b99cdbeb7..0d412f925388c6 100644 --- a/benchmark/path/isAbsolute.js +++ b/benchmark/path/isAbsolute.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var path = require('path'); var v8 = require('v8'); diff --git a/benchmark/path/join.js b/benchmark/path/join.js index 58f4dc3e1e9e44..0262e25d249cb0 100644 --- a/benchmark/path/join.js +++ b/benchmark/path/join.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var path = require('path'); var v8 = require('v8'); diff --git a/benchmark/path/normalize.js b/benchmark/path/normalize.js index 6f7f05e4f9e1c8..56a637f401c0cc 100644 --- a/benchmark/path/normalize.js +++ b/benchmark/path/normalize.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var path = require('path'); var v8 = require('v8'); diff --git a/benchmark/path/parse.js b/benchmark/path/parse.js index f3fbb2a1f5c98f..2afc143090c6c8 100644 --- a/benchmark/path/parse.js +++ b/benchmark/path/parse.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var path = require('path'); var v8 = require('v8'); diff --git a/benchmark/path/relative.js b/benchmark/path/relative.js index d61c3961a62d8b..0a72a2ad7bf726 100644 --- a/benchmark/path/relative.js +++ b/benchmark/path/relative.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var path = require('path'); var v8 = require('v8'); diff --git a/benchmark/path/resolve.js b/benchmark/path/resolve.js index 375e8b134ba0ea..5235b94b74d328 100644 --- a/benchmark/path/resolve.js +++ b/benchmark/path/resolve.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var path = require('path'); var v8 = require('v8'); diff --git a/benchmark/querystring/querystring-parse.js b/benchmark/querystring/querystring-parse.js index 6a4d9f5e6169f4..1019a941dfdecb 100644 --- a/benchmark/querystring/querystring-parse.js +++ b/benchmark/querystring/querystring-parse.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var querystring = require('querystring'); var v8 = require('v8'); @@ -27,8 +28,16 @@ function main(conf) { v8.setFlagsFromString('--allow_natives_syntax'); eval('%OptimizeFunctionOnNextCall(querystring.parse)'); - bench.start(); - for (var i = 0; i < n; i += 1) - querystring.parse(input); - bench.end(n); + var i; + if (type !== 'multicharsep') { + bench.start(); + for (i = 0; i < n; i += 1) + querystring.parse(input); + bench.end(n); + } else { + bench.start(); + for (i = 0; i < n; i += 1) + querystring.parse(input, '&&&&&&&&&&'); + bench.end(n); + } } diff --git a/benchmark/querystring/querystring-stringify.js b/benchmark/querystring/querystring-stringify.js index d4bb95c21e5af4..c2f38554166aa4 100644 --- a/benchmark/querystring/querystring-stringify.js +++ b/benchmark/querystring/querystring-stringify.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var querystring = require('querystring'); var v8 = require('v8'); diff --git a/benchmark/report-startup-memory.js b/benchmark/report-startup-memory.js index 14e56231ec2ddd..6d796307f4f437 100644 --- a/benchmark/report-startup-memory.js +++ b/benchmark/report-startup-memory.js @@ -1 +1,2 @@ +'use strict'; console.log(process.memoryUsage().rss); diff --git a/benchmark/static_http_server.js b/benchmark/static_http_server.js index b3a83785e3792f..804f83c208bb39 100644 --- a/benchmark/static_http_server.js +++ b/benchmark/static_http_server.js @@ -1,9 +1,10 @@ +'use strict'; var http = require('http'); var concurrency = 30; var port = 12346; var n = 700; -var bytes = 1024*5; +var bytes = 1024 * 5; var requests = 0; var responses = 0; @@ -19,7 +20,7 @@ var server = http.createServer(function(req, res) { 'Content-Length': body.length }); res.end(body); -}) +}); server.listen(port, function() { var agent = new http.Agent(); diff --git a/benchmark/tls/throughput.js b/benchmark/tls/throughput.js index 442eba338ed643..7b545267ace7fe 100644 --- a/benchmark/tls/throughput.js +++ b/benchmark/tls/throughput.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { dur: [5], @@ -30,7 +31,7 @@ function main(conf) { encoding = 'ascii'; break; case 'utf': - chunk = new Array(size/2 + 1).join('ü'); + chunk = new Array(size / 2 + 1).join('ü'); encoding = 'utf8'; break; default: @@ -44,16 +45,16 @@ function main(conf) { server = tls.createServer(options, onConnection); setTimeout(done, dur * 1000); + var conn; server.listen(common.PORT, function() { var opt = { port: common.PORT, rejectUnauthorized: false }; - var conn = tls.connect(opt, function() { + conn = tls.connect(opt, function() { bench.start(); conn.on('drain', write); write(); }); function write() { - var i = 0; while (false !== conn.write(chunk, encoding)); } }); @@ -68,7 +69,8 @@ function main(conf) { function done() { var mbits = (received * 8) / (1024 * 1024); bench.end(mbits); - conn.destroy(); + if (conn) + conn.destroy(); server.close(); } } diff --git a/benchmark/tls/tls-connect.js b/benchmark/tls/tls-connect.js index 96c9c5ab275f9d..a265989e04db24 100644 --- a/benchmark/tls/tls-connect.js +++ b/benchmark/tls/tls-connect.js @@ -1,7 +1,7 @@ -var assert = require('assert'), - fs = require('fs'), - path = require('path'), - tls = require('tls'); +'use strict'; +var fs = require('fs'), + path = require('path'), + tls = require('tls'); var common = require('../common.js'); var bench = common.createBenchmark(main, { @@ -21,10 +21,10 @@ function main(conf) { concurrency = +conf.concurrency; var cert_dir = path.resolve(__dirname, '../../test/fixtures'), - 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' }; + 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' }; server = tls.createServer(options, onConnection); server.listen(common.PORT, onListening); diff --git a/benchmark/url/url-parse.js b/benchmark/url/url-parse.js index ffa47c4ccd6105..89679548b8f193 100644 --- a/benchmark/url/url-parse.js +++ b/benchmark/url/url-parse.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var url = require('url'); var v8 = require('v8'); diff --git a/benchmark/url/url-resolve.js b/benchmark/url/url-resolve.js index 5f6c1f7600ce4e..18f67e82e30787 100644 --- a/benchmark/url/url-resolve.js +++ b/benchmark/url/url-resolve.js @@ -1,3 +1,4 @@ +'use strict'; var common = require('../common.js'); var url = require('url'); var v8 = require('v8'); diff --git a/benchmark/util/inspect.js b/benchmark/util/inspect.js index 8a59e6b48e54df..3312bd683ba81b 100644 --- a/benchmark/util/inspect.js +++ b/benchmark/util/inspect.js @@ -1,3 +1,4 @@ +'use strict'; var util = require('util'); var common = require('../common.js'); @@ -9,7 +10,7 @@ function main(conf) { bench.start(); for (var i = 0; i < n; i += 1) { - var r = util.inspect({a: 'a', b: 'b', c: 'c', d: 'd'}); + util.inspect({a: 'a', b: 'b', c: 'c', d: 'd'}); } bench.end(n); } diff --git a/configure b/configure index dc0129e512593c..054ebb41cbd8e4 100755 --- a/configure +++ b/configure @@ -433,7 +433,7 @@ def try_check_compiler(cc, lang): # Commands and regular expressions to obtain its version number are taken from # https://github.com/openssl/openssl/blob/OpenSSL_1_0_2-stable/crypto/sha/asm/sha512-x86_64.pl#L112-L129 # -def get_llvm_version(cc): +def get_version_helper(cc, regexp): try: proc = subprocess.Popen(shlex.split(cc) + ['-v'], stdin=subprocess.PIPE, stderr=subprocess.PIPE, stdout=subprocess.PIPE) @@ -446,14 +446,20 @@ def get_llvm_version(cc): ''' sys.exit() - match = re.search(r"(^clang version|based on LLVM) ([3-9]\.[0-9]+)", - proc.communicate()[1]) + match = re.search(regexp, proc.communicate()[1]) if match: return match.group(2) else: return 0 +def get_llvm_version(cc): + return get_version_helper( + cc, r"(^clang version|based on LLVM) ([3-9]\.[0-9]+)") + +def get_xcode_version(cc): + return get_version_helper( + cc, r"(^Apple LLVM version) ([5-9]\.[0-9]+)") def get_gas_version(cc): try: @@ -508,6 +514,8 @@ def check_compiler(o): if is_clang: o['variables']['llvm_version'] = get_llvm_version(CC) + if sys.platform == 'darwin': + o['variables']['xcode_version'] = get_xcode_version(CC) else: o['variables']['gas_version'] = get_gas_version(CC) diff --git a/deps/openssl/config/archs/BSD-x86/opensslconf.h b/deps/openssl/config/archs/BSD-x86/opensslconf.h index 31e9f5416eaa29..769c15e052f9ff 100644 --- a/deps/openssl/config/archs/BSD-x86/opensslconf.h +++ b/deps/openssl/config/archs/BSD-x86/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/BSD-x86_64/opensslconf.h b/deps/openssl/config/archs/BSD-x86_64/opensslconf.h index 865473bac93752..231c8f3628079d 100644 --- a/deps/openssl/config/archs/BSD-x86_64/opensslconf.h +++ b/deps/openssl/config/archs/BSD-x86_64/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/VC-WIN32/opensslconf.h b/deps/openssl/config/archs/VC-WIN32/opensslconf.h index d49ebfa3defa3a..963b384b2221b9 100644 --- a/deps/openssl/config/archs/VC-WIN32/opensslconf.h +++ b/deps/openssl/config/archs/VC-WIN32/opensslconf.h @@ -41,12 +41,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/VC-WIN64A/opensslconf.h b/deps/openssl/config/archs/VC-WIN64A/opensslconf.h index b248dac0208d69..2993295bd4de3d 100644 --- a/deps/openssl/config/archs/VC-WIN64A/opensslconf.h +++ b/deps/openssl/config/archs/VC-WIN64A/opensslconf.h @@ -41,12 +41,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/aix-gcc/opensslconf.h b/deps/openssl/config/archs/aix-gcc/opensslconf.h index 7c71fad1c469d8..0b5a4da2199b20 100644 --- a/deps/openssl/config/archs/aix-gcc/opensslconf.h +++ b/deps/openssl/config/archs/aix-gcc/opensslconf.h @@ -41,12 +41,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -92,12 +98,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/aix64-gcc/opensslconf.h b/deps/openssl/config/archs/aix64-gcc/opensslconf.h index 37490dfb5bbd65..0cca4cae21dd10 100644 --- a/deps/openssl/config/archs/aix64-gcc/opensslconf.h +++ b/deps/openssl/config/archs/aix64-gcc/opensslconf.h @@ -41,12 +41,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -92,12 +98,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/darwin-i386-cc/opensslconf.h b/deps/openssl/config/archs/darwin-i386-cc/opensslconf.h index 02328a5333b06b..584537094dc49b 100644 --- a/deps/openssl/config/archs/darwin-i386-cc/opensslconf.h +++ b/deps/openssl/config/archs/darwin-i386-cc/opensslconf.h @@ -41,12 +41,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -92,12 +98,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/darwin64-x86_64-cc/opensslconf.h b/deps/openssl/config/archs/darwin64-x86_64-cc/opensslconf.h index d7be6bbc4b77e1..1d7932d04b8c0e 100644 --- a/deps/openssl/config/archs/darwin64-x86_64-cc/opensslconf.h +++ b/deps/openssl/config/archs/darwin64-x86_64-cc/opensslconf.h @@ -41,12 +41,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -92,12 +98,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/linux-aarch64/opensslconf.h b/deps/openssl/config/archs/linux-aarch64/opensslconf.h index 92d6937741a2dd..bd4869d4c51d87 100644 --- a/deps/openssl/config/archs/linux-aarch64/opensslconf.h +++ b/deps/openssl/config/archs/linux-aarch64/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/linux-armv4/opensslconf.h b/deps/openssl/config/archs/linux-armv4/opensslconf.h index 24d98356f6e978..4f6aa1c69b9355 100644 --- a/deps/openssl/config/archs/linux-armv4/opensslconf.h +++ b/deps/openssl/config/archs/linux-armv4/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/linux-elf/opensslconf.h b/deps/openssl/config/archs/linux-elf/opensslconf.h index 31e9f5416eaa29..769c15e052f9ff 100644 --- a/deps/openssl/config/archs/linux-elf/opensslconf.h +++ b/deps/openssl/config/archs/linux-elf/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/linux-ppc/opensslconf.h b/deps/openssl/config/archs/linux-ppc/opensslconf.h index f5a03b47e54185..e0d62da24e142e 100644 --- a/deps/openssl/config/archs/linux-ppc/opensslconf.h +++ b/deps/openssl/config/archs/linux-ppc/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/linux-ppc64/opensslconf.h b/deps/openssl/config/archs/linux-ppc64/opensslconf.h index 900aa7017509f2..3f7202d25427e3 100644 --- a/deps/openssl/config/archs/linux-ppc64/opensslconf.h +++ b/deps/openssl/config/archs/linux-ppc64/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/linux-x32/opensslconf.h b/deps/openssl/config/archs/linux-x32/opensslconf.h index 79706e45b2c998..8e184bc815f9cf 100644 --- a/deps/openssl/config/archs/linux-x32/opensslconf.h +++ b/deps/openssl/config/archs/linux-x32/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/linux-x86_64/opensslconf.h b/deps/openssl/config/archs/linux-x86_64/opensslconf.h index 865473bac93752..231c8f3628079d 100644 --- a/deps/openssl/config/archs/linux-x86_64/opensslconf.h +++ b/deps/openssl/config/archs/linux-x86_64/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/solaris-x86-gcc/opensslconf.h b/deps/openssl/config/archs/solaris-x86-gcc/opensslconf.h index 31e9f5416eaa29..769c15e052f9ff 100644 --- a/deps/openssl/config/archs/solaris-x86-gcc/opensslconf.h +++ b/deps/openssl/config/archs/solaris-x86-gcc/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/config/archs/solaris64-x86_64-gcc/opensslconf.h b/deps/openssl/config/archs/solaris64-x86_64-gcc/opensslconf.h index 865473bac93752..231c8f3628079d 100644 --- a/deps/openssl/config/archs/solaris64-x86_64-gcc/opensslconf.h +++ b/deps/openssl/config/archs/solaris64-x86_64-gcc/opensslconf.h @@ -38,12 +38,18 @@ extern "C" { #ifndef OPENSSL_NO_SSL_TRACE # define OPENSSL_NO_SSL_TRACE #endif +#ifndef OPENSSL_NO_SSL2 +# define OPENSSL_NO_SSL2 +#endif #ifndef OPENSSL_NO_STORE # define OPENSSL_NO_STORE #endif #ifndef OPENSSL_NO_UNIT_TEST # define OPENSSL_NO_UNIT_TEST #endif +#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS +# define OPENSSL_NO_WEAK_SSL_CIPHERS +#endif #endif /* OPENSSL_DOING_MAKEDEPEND */ @@ -89,12 +95,18 @@ extern "C" { # if defined(OPENSSL_NO_SSL_TRACE) && !defined(NO_SSL_TRACE) # define NO_SSL_TRACE # endif +# if defined(OPENSSL_NO_SSL2) && !defined(NO_SSL2) +# define NO_SSL2 +# endif # if defined(OPENSSL_NO_STORE) && !defined(NO_STORE) # define NO_STORE # endif # if defined(OPENSSL_NO_UNIT_TEST) && !defined(NO_UNIT_TEST) # define NO_UNIT_TEST # endif +# if defined(OPENSSL_NO_WEAK_SSL_CIPHERS) && !defined(NO_WEAK_SSL_CIPHERS) +# define NO_WEAK_SSL_CIPHERS +# endif #endif diff --git a/deps/openssl/openssl.gyp b/deps/openssl/openssl.gyp index 3a319d91f0df7a..db57033d54e20e 100644 --- a/deps/openssl/openssl.gyp +++ b/deps/openssl/openssl.gyp @@ -8,6 +8,7 @@ 'gcc_version': 0, 'openssl_no_asm%': 0, 'llvm_version%': 0, + 'xcode_version%': 0, 'gas_version%': 0, 'openssl_fips%': 'false', }, diff --git a/deps/openssl/openssl.gypi b/deps/openssl/openssl.gypi index e2e06d8333172c..63286a1a64138c 100644 --- a/deps/openssl/openssl.gypi +++ b/deps/openssl/openssl.gypi @@ -1040,7 +1040,7 @@ # 'conditions': [ ['(OS=="win" and MSVS_VERSION>="2012") or ' - 'llvm_version>="3.3" or gas_version>="2.23"', { + 'llvm_version>="3.3" or xcode_version>="5.0" or gas_version>="2.23"', { 'openssl_sources_x64_win_masm': [ '<@(openssl_sources_asm_latest_x64_win_masm)', '<@(openssl_sources_common_x64_win_masm)', @@ -1252,10 +1252,6 @@ 'PURIFY', '_REENTRANT', - # SSLv2 is known broken and has been superseded by SSLv3 for almost - # twenty years now. - 'OPENSSL_NO_SSL2', - # SSLv3 is susceptible to downgrade attacks (POODLE.) 'OPENSSL_NO_SSL3', diff --git a/deps/v8/src/compiler/ppc/code-generator-ppc.cc b/deps/v8/src/compiler/ppc/code-generator-ppc.cc index cdc1424cc5e72a..c3716b951a54a9 100644 --- a/deps/v8/src/compiler/ppc/code-generator-ppc.cc +++ b/deps/v8/src/compiler/ppc/code-generator-ppc.cc @@ -1198,8 +1198,8 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr, PPCOperandConverter i(this, instr); Label done; ArchOpcode op = instr->arch_opcode(); - bool check_unordered = (op == kPPC_CmpDouble); CRegister cr = cr0; + int reg_value = -1; // Overflow checked for add/sub only. DCHECK((condition != kOverflow && condition != kNotOverflow) || @@ -1211,44 +1211,44 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr, Register reg = i.OutputRegister(instr->OutputCount() - 1); Condition cond = FlagsConditionToCondition(condition); - switch (cond) { - case eq: - case lt: + if (op == kPPC_CmpDouble) { + // check for unordered if necessary + if (cond == le) { + reg_value = 0; __ li(reg, Operand::Zero()); - __ li(kScratchReg, Operand(1)); - __ isel(cond, reg, kScratchReg, reg, cr); - break; - case ne: - case ge: + __ bunordered(&done, cr); + } else if (cond == gt) { + reg_value = 1; __ li(reg, Operand(1)); - __ isel(NegateCondition(cond), reg, r0, reg, cr); - break; - case gt: - if (check_unordered) { - __ li(reg, Operand(1)); + __ bunordered(&done, cr); + } + // Unnecessary for eq/lt & ne/ge since only FU bit will be set. + } + + if (CpuFeatures::IsSupported(ISELECT)) { + switch (cond) { + case eq: + case lt: + case gt: + if (reg_value != 1) __ li(reg, Operand(1)); __ li(kScratchReg, Operand::Zero()); - __ bunordered(&done, cr); __ isel(cond, reg, reg, kScratchReg, cr); - } else { - __ li(reg, Operand::Zero()); - __ li(kScratchReg, Operand(1)); - __ isel(cond, reg, kScratchReg, reg, cr); - } - break; - case le: - if (check_unordered) { - __ li(reg, Operand::Zero()); - __ li(kScratchReg, Operand(1)); - __ bunordered(&done, cr); - __ isel(NegateCondition(cond), reg, r0, kScratchReg, cr); - } else { - __ li(reg, Operand(1)); + break; + case ne: + case ge: + case le: + if (reg_value != 1) __ li(reg, Operand(1)); + // r0 implies logical zero in this form __ isel(NegateCondition(cond), reg, r0, reg, cr); - } - break; + break; default: UNREACHABLE(); break; + } + } else { + if (reg_value != 0) __ li(reg, Operand::Zero()); + __ b(NegateCondition(cond), &done, cr); + __ li(reg, Operand(1)); } __ bind(&done); } diff --git a/doc/api/addons.markdown b/doc/api/addons.markdown index 7f570eb7062380..c330217beffa4d 100644 --- a/doc/api/addons.markdown +++ b/doc/api/addons.markdown @@ -1,9 +1,9 @@ # Addons Node.js Addons are dynamically-linked shared objects, written in C or C++, that -can be loaded into Node.js using the `require()` function, and used just as if -they were an ordinary Node.js module. They are used primarily to provide an -interface between JavaScript running in Node.js and C/C++ libraries. +can be loaded into Node.js using the [`require()`][require] function, and used +just as if they were an ordinary Node.js module. They are used primarily to +provide an interface between JavaScript running in Node.js and C/C++ libraries. At the moment, the method for implementing Addons is rather complicated, involving knowledge of several components and APIs : @@ -12,7 +12,7 @@ involving knowledge of several components and APIs : JavaScript implementation. V8 provides the mechanisms for creating objects, calling functions, etc. V8's API is documented mostly in the `v8.h` header file (`deps/v8/include/v8.h` in the Node.js source - tree), which is also available [online][]. + tree), which is also available [online][v8-docs]. - [libuv][]: The C library that implements the Node.js event loop, its worker threads and all of the asynchronous behaviors of the platform. It also @@ -118,7 +118,7 @@ Node.js as part of `npm`. This version is not made directly available for developers to use and is intended only to support the ability to use the `npm install` command to compile and install Addons. Developers who wish to use `node-gyp` directly can install it using the command -`npm install -g node-gyp`. See the `node-gyp` [installation instructions] for +`npm install -g node-gyp`. See the `node-gyp` [installation instructions][] for more information, including platform-specific requirements.* Once the `binding.gyp` file has been created, use `node-gyp configure` to @@ -134,7 +134,7 @@ version of `node-gyp` to perform this same set of actions, generating a compiled version of the Addon for the user's platform on demand. Once built, the binary Addon can be used from within Node.js by pointing -`require()` to the built `addon.node` module: +[`require()`][require] to the built `addon.node` module: ```js // hello.js @@ -184,17 +184,17 @@ dependencies. ### Loading Addons using require() The filename extension of the compiled Addon binary is `.node` (as opposed -to `.dll` or `.so`). The `require()` function is written to look for files -with the `.node` file extension and initialize those as dynamically-linked +to `.dll` or `.so`). The [`require()`][require] function is written to look for +files with the `.node` file extension and initialize those as dynamically-linked libraries. -When calling `require()`, the `.node` extension can usually be +When calling [`require()`][require], the `.node` extension can usually be omitted and Node.js will still find and initialize the Addon. One caveat, however, is that Node.js will first attempt to locate and load modules or JavaScript files that happen to share the same base name. For instance, if there is a file `addon.js` in the same directory as the binary `addon.node`, -then `require('addon')` will give precedence to the `addon.js` file and load it -instead. +then [`require('addon')`][require] will give precedence to the `addon.js` file +and load it instead. ## Native Abstractions for Node.js @@ -207,7 +207,7 @@ release schedule is designed to minimize the frequency and impact of such changes but there is little that Node.js can do currently to ensure stability of the V8 APIs. -The [Native Abstrations for Node.js][] (or `nan`) provide a set of tools that +The [Native Abstractions for Node.js][] (or `nan`) provide a set of tools that Addon developers are recommended to use to keep compatibility between past and future releases of V8 and Node.js. See the `nan` [examples][] for an illustration of how it can be used. @@ -215,9 +215,10 @@ illustration of how it can be used. ## Addon examples Following are some example Addons intended to help developers get started. The -examples make use of the V8 APIs. Refer to the online [V8 reference][] for help -with the various V8 calls, and V8's [Embedder's Guide][] for an explanation of -several concepts used such as handles, scopes, function templates, etc. +examples make use of the V8 APIs. Refer to the online [V8 reference][v8-docs] +for help with the various V8 calls, and V8's [Embedder's Guide][] for an +explanation of several concepts used such as handles, scopes, function +templates, etc. Each of these examples using the following `binding.gyp` file: @@ -1077,14 +1078,14 @@ Test in JavaScript by running: const addon = require('./build/Release/addon'); ``` -[online]: https://v8docs.nodesource.com/ -[libuv]: https://github.com/libuv/libuv +[bindings]: https://github.com/TooTallNate/node-bindings [download]: https://github.com/nodejs/node-addon-examples -[node-gyp]: https://github.com/nodejs/node-gyp -[V8 reference]: https://v8docs.nodesource.com/ [Embedder's Guide]: https://developers.google.com/v8/embed -[Native Abstrations for Node.js]: https://github.com/nodejs/nan [examples]: https://github.com/nodejs/nan/tree/master/examples/ -[bindings]: https://github.com/TooTallNate/node-bindings -[Linking to Node.js' own dependencies]: #linking-to-nodejs-own-dependencies [installation instructions]: https://github.com/nodejs/node-gyp#installation +[libuv]: https://github.com/libuv/libuv +[Linking to Node.js' own dependencies]: #linking-to-nodejs-own-dependencies +[Native Abstractions for Node.js]: https://github.com/nodejs/nan +[node-gyp]: https://github.com/nodejs/node-gyp +[require]: globals.html#globals_require +[v8-docs]: https://v8docs.nodesource.com/ diff --git a/doc/api/buffer.markdown b/doc/api/buffer.markdown index ac8b5641ea5a2f..6d39ffdba84cf8 100644 --- a/doc/api/buffer.markdown +++ b/doc/api/buffer.markdown @@ -62,7 +62,9 @@ The character encodings currently supported by Node.js include: * `'ucs2'` - Alias of `'utf16le'`. -* `'base64'` - Base64 string encoding. +* `'base64'` - Base64 string encoding. When creating a buffer from a string, + this encoding will also correctly accept "URL and Filename Safe Alphabet" as + specified in [RFC 4648, Section 5]. * `'binary'` - A way of encoding the buffer into a one-byte (`latin-1`) encoded string. The string `'latin-1'` is not supported. Instead, pass @@ -713,7 +715,7 @@ const buf = new Buffer([1,-2,3,4]); buf.readInt16BE(); // returns 510 buf.readInt16LE(1); - // returns -511 + // returns 1022 ``` ### buf.readInt32BE(offset[, noAssert]) @@ -1025,7 +1027,7 @@ console.log(`${len} bytes: ${buf.toString('utf8', 0, len)}`); * `value` {Number} Bytes to be written to Buffer * `offset` {Number} `0 <= offset <= buf.length - 8` * `noAssert` {Boolean} Default: false -* Return: {Number} Numbers of bytes written +* Return: {Number} The offset plus the number of written bytes Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeDoubleBE()` writes big endian, `writeDoubleLE()` writes little @@ -1057,7 +1059,7 @@ console.log(buf); * `value` {Number} Bytes to be written to Buffer * `offset` {Number} `0 <= offset <= buf.length - 4` * `noAssert` {Boolean} Default: false -* Return: {Number} Numbers of bytes written +* Return: {Number} The offset plus the number of written bytes Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeFloatBE()` writes big endian, `writeFloatLE()` writes little @@ -1089,7 +1091,7 @@ console.log(buf); * `value` {Number} Bytes to be written to Buffer * `offset` {Number} `0 <= offset <= buf.length - 1` * `noAssert` {Boolean} Default: false -* Return: {Number} Numbers of bytes written +* Return: {Number} The offset plus the number of written bytes Writes `value` to the Buffer at the specified `offset`. The `value` must be a valid signed 8-bit integer. @@ -1115,7 +1117,7 @@ console.log(buf); * `value` {Number} Bytes to be written to Buffer * `offset` {Number} `0 <= offset <= buf.length - 2` * `noAssert` {Boolean} Default: false -* Return: {Number} Numbers of bytes written +* Return: {Number} The offset plus the number of written bytes Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeInt16BE()` writes big endian, `writeInt16LE()` writes little @@ -1142,7 +1144,7 @@ console.log(buf); * `value` {Number} Bytes to be written to Buffer * `offset` {Number} `0 <= offset <= buf.length - 4` * `noAssert` {Boolean} Default: false -* Return: {Number} Numbers of bytes written +* Return: {Number} The offset plus the number of written bytes Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeInt32BE()` writes big endian, `writeInt32LE()` writes little @@ -1170,7 +1172,7 @@ console.log(buf); * `offset` {Number} `0 <= offset <= buf.length - byteLength` * `byteLength` {Number} `0 < byteLength <= 6` * `noAssert` {Boolean} Default: false -* Return: {Number} Numbers of bytes written +* Return: {Number} The offset plus the number of written bytes Writes `value` to the Buffer at the specified `offset` and `byteLength`. Supports up to 48 bits of accuracy. For example: @@ -1197,7 +1199,7 @@ should not be used unless you are certain of correctness. * `value` {Number} Bytes to be written to Buffer * `offset` {Number} `0 <= offset <= buf.length - 1` * `noAssert` {Boolean} Default: false -* Return: {Number} Numbers of bytes written +* Return: {Number} The offset plus the number of written bytes Writes `value` to the Buffer at the specified `offset`. The `value` must be a valid unsigned 8-bit integer. @@ -1226,7 +1228,7 @@ console.log(buf); * `value` {Number} Bytes to be written to Buffer * `offset` {Number} `0 <= offset <= buf.length - 2` * `noAssert` {Boolean} Default: false -* Return: {Number} Numbers of bytes written +* Return: {Number} The offset plus the number of written bytes Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeUInt16BE()` writes big endian, `writeUInt16LE()` writes little @@ -1260,7 +1262,7 @@ console.log(buf); * `value` {Number} Bytes to be written to Buffer * `offset` {Number} `0 <= offset <= buf.length - 4` * `noAssert` {Boolean} Default: false -* Return: {Number} Numbers of bytes written +* Return: {Number} The offset plus the number of written bytes Writes `value` to the Buffer at the specified `offset` with specified endian format (`writeUInt32BE()` writes big endian, `writeUInt32LE()` writes little @@ -1293,7 +1295,7 @@ console.log(buf); * `offset` {Number} `0 <= offset <= buf.length - byteLength` * `byteLength` {Number} `0 < byteLength <= 6` * `noAssert` {Boolean} Default: false -* Return: {Number} Numbers of bytes written +* Return: {Number} The offset plus the number of written bytes Writes `value` to the Buffer at the specified `offset` and `byteLength`. Supports up to 48 bits of accuracy. For example: @@ -1364,3 +1366,4 @@ has observed undue memory retention in their applications. [`String.prototype.length`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length [`util.inspect()`]: util.html#util_util_inspect_object_options [iterator]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols +[RFC 4648, Section 5]: https://tools.ietf.org/html/rfc4648#section-5 diff --git a/doc/api/child_process.markdown b/doc/api/child_process.markdown index 9ab3b2d368120b..2e7d137f12a65f 100644 --- a/doc/api/child_process.markdown +++ b/doc/api/child_process.markdown @@ -32,7 +32,7 @@ mean that data sent to the child process may not be immediately consumed.* The `child_process.spawn()` method spawns the child process asynchronously, without blocking the Node.js event loop. The `child_process.spawnSync()` function provides equivalent functionality in a synchronous manner that blocks -the event loop until the spawned process either exits of is terminated. +the event loop until the spawned process either exits or is terminated. For convenience, the `child_process` module provides a handful of synchronous and asynchronous alternatives to [`child_process.spawn()`][] and @@ -808,7 +808,7 @@ used to implement flow control. #### Example: sending a server object The `sendHandle` argument can be used, for instance, to pass the handle of -a TSCP server object to the child process as illustrated in the example below: +a TCP server object to the child process as illustrated in the example below: ```js const child = require('child_process').fork('child.js'); @@ -884,6 +884,8 @@ tracking when the socket is destroyed. To indicate this, the `.connections` property becomes `null`. It is recommended not to use `.maxConnections` when this occurs. +*Note: this function uses [`JSON.stringify()`][] internally to serialize the `message`.* + ### child.stderr * {Stream} @@ -978,3 +980,4 @@ to the same value. [`options.stdio`]: #child_process_options_stdio [`stdio`]: #child_process_options_stdio [synchronous counterparts]: #child_process_synchronous_process_creation +[`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify \ No newline at end of file diff --git a/doc/api/cluster.markdown b/doc/api/cluster.markdown index 215e48b12a4286..b14c3aaf2bfc83 100644 --- a/doc/api/cluster.markdown +++ b/doc/api/cluster.markdown @@ -244,7 +244,7 @@ Causes `.suicide` to be set. Note that after a server is closed, it will no longer accept new connections, but connections may be accepted by any other listening worker. Existing connections will be allowed to close as usual. When no more connections exist, -see [server.close()][], the IPC channel to the worker will close allowing it to +see [`server.close()`][], the IPC channel to the worker will close allowing it to die gracefully. The above applies *only* to server connections, client connections are not @@ -624,6 +624,7 @@ cluster.setupMaster({ }); cluster.fork(); // https worker cluster.setupMaster({ + exec: 'worker.js', args: ['--use', 'http'] }); cluster.fork(); // http worker diff --git a/doc/api/crypto.markdown b/doc/api/crypto.markdown index dce83c563c1bd8..de51bb67f92f22 100644 --- a/doc/api/crypto.markdown +++ b/doc/api/crypto.markdown @@ -826,7 +826,7 @@ recent OpenSSL releases, `openssl list-cipher-algorithms` will display the available cipher algorithms. The `password` is used to derive the cipher key and initialization vector (IV). -The value must be either a `'binary'` encoded string or a [`Buffer`[]. +The value must be either a `'binary'` encoded string or a [`Buffer`][]. The implementation of `crypto.createCipher()` derives keys using the OpenSSL function [`EVP_BytesToKey`][] with the digest algorithm set to MD5, one @@ -908,7 +908,7 @@ The `key` is the raw key used by the `algorithm` and `iv` is an [initialization vector][]. Both arguments must be `'binary'` encoded strings or [buffers][`Buffer`]. -## crypto.createDiffieHellman(prime[, prime_encoding][, generator][, generator_encoding]) +### crypto.createDiffieHellman(prime[, prime_encoding][, generator][, generator_encoding]) Creates a `DiffieHellman` key exchange object using the supplied `prime` and an optional specific `generator`. @@ -1131,7 +1131,7 @@ Example: ```js const crypto = require('crypto'); -const key = crypto.pbkdf2sync('secret', 'salt', 100000, 512, 'sha512'); +const key = crypto.pbkdf2Sync('secret', 'salt', 100000, 512, 'sha512'); console.log(key.toString('hex')); // 'c5e478d...1469e50' ``` @@ -1243,7 +1243,7 @@ there is a problem generating the bytes. // Synchronous const buf = crypto.randomBytes(256); console.log( - `${buf.length}` bytes of random data: ${buf.toString('hex')}); + `${buf.length} bytes of random data: ${buf.toString('hex')}`); ``` The `crypto.randomBytes()` method will block until there is sufficient entropy. diff --git a/doc/api/dns.markdown b/doc/api/dns.markdown index 7888f14d723d01..ee520380aa1385 100644 --- a/doc/api/dns.markdown +++ b/doc/api/dns.markdown @@ -181,7 +181,7 @@ will contain an array of IPv6 addresses. Uses the DNS protocol to resolve `CNAME` records for the `hostname`. The `addresses` argument passed to the `callback` function -will contain an of canonical name records available for the `hostname` +will contain an array of canonical name records available for the `hostname` (e.g. `['bar.example.com']`). ## dns.resolveMx(hostname, callback) diff --git a/doc/api/documentation.markdown b/doc/api/documentation.markdown index 0eb9eb9dbd9800..4d357e39efab37 100644 --- a/doc/api/documentation.markdown +++ b/doc/api/documentation.markdown @@ -20,6 +20,10 @@ Every `.html` and `.json` file is generated based on the corresponding documentation is generated using the `tools/doc/generate.js` program. The HTML template is located at `doc/template.html`. + +If you find a error in this documentation, please [submit an issue][] +or see [the contributing guide][] for directions on how to submit a patch. + ## Stability Index @@ -82,3 +86,6 @@ Most Unix syscalls have Windows equivalents, but behavior may differ on Windows relative to Linux and OS X. For an example of the subtle ways in which it's sometimes impossible to replace Unix syscall semantics on Windows, see [Node issue 4760](https://github.com/nodejs/node/issues/4760). + +[submit an issue]: https://github.com/nodejs/node/issues/new +[the contributing guide]: https://github.com/nodejs/node/blob/master/CONTRIBUTING.md diff --git a/doc/api/errors.markdown b/doc/api/errors.markdown index 342fd9710ed2ac..810a8b7e3678ab 100644 --- a/doc/api/errors.markdown +++ b/doc/api/errors.markdown @@ -520,6 +520,8 @@ found [here][online]. encountered by [`http`][] or [`net`][] -- often a sign that a `socket.end()` was not properly called. +[`domain`]: domain.html +[`EvalError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/EvalError [`Error`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error [`fs.readdir`]: fs.html#fs_fs_readdir_path_callback [`fs.readFileSync`]: fs.html#fs_fs_readfilesync_file_options @@ -540,6 +542,7 @@ found [here][online]. [V8's stack trace API]: https://github.com/v8/v8/wiki/Stack-Trace-API [vm]: vm.html [`SyntaxError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError +[`RangeError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError [`ReferenceError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ReferenceError [`TypeError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError -[`domain`]: domain.html +[`URIError`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/URIError diff --git a/doc/api/events.markdown b/doc/api/events.markdown index 0afd583ebc35d7..797b969ecc2824 100644 --- a/doc/api/events.markdown +++ b/doc/api/events.markdown @@ -377,6 +377,43 @@ listener array. If any single listener has been added multiple times to the listener array for the specified `event`, then `removeListener` must be called multiple times to remove each instance. +Note that once an event has been emitted, all listeners attached to it at the +time of emitting will be called in order. This implies that any `removeListener()` +or `removeAllListeners()` calls *after* emitting and *before* the last listener +finishes execution will not remove them from `emit()` in progress. Subsequent +events will behave as expected. + +```js +const myEmitter = new MyEmitter(); + +var callbackA = () => { + console.log('A'); + myEmitter.removeListener('event', callbackB); +}; + +var callbackB = () => { + console.log('B'); +}; + +myEmitter.on('event', callbackA); + +myEmitter.on('event', callbackB); + +// callbackA removes listener callbackB but it will still be called. +// Interal listener array at time of emit [callbackA, callbackB] +myEmitter.emit('event'); + // Prints: + // A + // B + +// callbackB is now removed. +// Interal listener array [callbackA] +myEmitter.emit('event'); + // Prints: + // A + +``` + Because listeners are managed using an internal array, calling this will change the position indices of any listener registered *after* the listener being removed. This will not impact the order in which listeners are called, diff --git a/doc/api/fs.markdown b/doc/api/fs.markdown index 64e4a156fa7d87..9d9d0672b6f488 100644 --- a/doc/api/fs.markdown +++ b/doc/api/fs.markdown @@ -190,10 +190,11 @@ The times in the stat object have the following semantics: * `birthtime` "Birth Time" - Time of file creation. Set once when the file is created. On filesystems where birthtime is not available, this field may instead hold either the `ctime` or - `1970-01-01T00:00Z` (ie, unix epoch timestamp `0`). On Darwin and - other FreeBSD variants, also set if the `atime` is explicitly set to - an earlier value than the current `birthtime` using the `utimes(2)` - system call. + `1970-01-01T00:00Z` (ie, unix epoch timestamp `0`). Note that this + value may be greater than `atime` or `mtime` in this case. On Darwin + and other FreeBSD variants, also set if the `atime` is explicitly + set to an earlier value than the current `birthtime` using the + `utimes(2)` system call. Prior to Node v0.12, the `ctime` held the `birthtime` on Windows systems. Note that as of v0.12, `ctime` is not "creation time", and @@ -429,6 +430,15 @@ to the completion callback. Synchronous fchown(2). Returns `undefined`. +## fs.fdatasync(fd, callback) + +Asynchronous fdatasync(2). No arguments other than a possible exception are +given to the completion callback. + +## fs.fdatasyncSync(fd) + +Synchronous fdatasync(2). Returns `undefined`. + ## fs.fstat(fd, callback) Asynchronous fstat(2). The callback gets two arguments `(err, stats)` where @@ -726,7 +736,7 @@ Here is an example below: fs.symlink('./foo', './new-port'); ``` -It would create a symlic link named with "new-port" that points to "foo". +It creates a symbolic link named "new-port" that points to "foo". ## fs.symlinkSync(target, path[, type]) diff --git a/doc/api/http.markdown b/doc/api/http.markdown index 6d93cf247173c7..0a16435b45d2f7 100644 --- a/doc/api/http.markdown +++ b/doc/api/http.markdown @@ -891,8 +891,8 @@ In case of server request, the HTTP version sent by the client. In the case of client response, the HTTP version of the connected-to server. Probably either `'1.1'` or `'1.0'`. -Also `response.httpVersionMajor` is the first integer and -`response.httpVersionMinor` is the second. +Also `message.httpVersionMajor` is the first integer and +`message.httpVersionMinor` is the second. ### message.method diff --git a/doc/api/net.markdown b/doc/api/net.markdown index bc8aa1a8022dd0..0e2fc4f8e4c406 100644 --- a/doc/api/net.markdown +++ b/doc/api/net.markdown @@ -109,7 +109,7 @@ The last parameter `callback` will be added as a listener for the [`'listening'`][] event. The parameter `backlog` behaves the same as in -[`server.listen(port, \[host\], \[backlog\], \[callback\])`][]. +[`server.listen(port[, hostname][, backlog][, callback])`][`server.listen(port, host, backlog, callback)`]. ### server.listen(options[, callback]) @@ -123,8 +123,8 @@ The parameter `backlog` behaves the same as in The `port`, `host`, and `backlog` properties of `options`, as well as the optional callback function, behave as they do on a call to -[`server.listen(port, \[host\], \[backlog\], \[callback\])`][]. Alternatively, -the `path` option can be used to specify a UNIX socket. +[`server.listen(port[, hostname][, backlog][, callback])`][`server.listen(port, host, backlog, callback)`]. +Alternatively, the `path` option can be used to specify a UNIX socket. If `exclusive` is `false` (default), then cluster workers will use the same underlying handle, allowing connection handling duties to be shared. When @@ -169,7 +169,7 @@ double-backslashes, such as: path.join('\\\\?\\pipe', process.cwd(), 'myctl')) The parameter `backlog` behaves the same as in -[`server.listen(port, \[host\], \[backlog\], \[callback\])`][]. +[`server.listen(port[, hostname][, backlog][, callback])`][`server.listen(port, host, backlog, callback)`]. ### server.listen(port[, hostname][, backlog][, callback]) @@ -389,7 +389,7 @@ The `connectListener` parameter will be added as a listener for the ### socket.connect(path[, connectListener]) ### socket.connect(port[, host][, connectListener]) -As [`socket.connect(options\[, connectListener\])`][], +As [`socket.connect(options\[, connectListener\])`][`socket.connect(options, connectListener)`], with options either as either `{port: port, host: host}` or `{path: path}`. ### socket.destroy() @@ -720,8 +720,8 @@ Returns true if input is a version 6 IP address, otherwise returns false. [`pause()`]: #net_socket_pause [`resume()`]: #net_socket_resume [`server.getConnections()`]: #net_server_getconnections_callback -[`server.listen(port, \[host\], \[backlog\], \[callback\])`]: #net_server_listen_port_hostname_backlog_callback -[`socket.connect(options\[, connectListener\])`]: #net_socket_connect_options_connectlistener +[`server.listen(port, host, backlog, callback)`]: #net_server_listen_port_hostname_backlog_callback +[`socket.connect(options, connectListener)`]: #net_socket_connect_options_connectlistener [`socket.connect`]: #net_socket_connect_options_connectlistener [`socket.setTimeout()`]: #net_socket_settimeout_timeout_callback [`stream.setEncoding()`]: stream.html#stream_readable_setencoding_encoding diff --git a/doc/api/path.markdown b/doc/api/path.markdown index 7cd7abd5dd682b..3d9fa5ba9b64c2 100644 --- a/doc/api/path.markdown +++ b/doc/api/path.markdown @@ -16,12 +16,10 @@ Example: ```js path.basename('/foo/bar/baz/asdf/quux.html') -// returns -'quux.html' +// returns 'quux.html' path.basename('/foo/bar/baz/asdf/quux.html', '.html') -// returns -'quux' +// returns 'quux' ``` ## path.delimiter @@ -35,8 +33,7 @@ console.log(process.env.PATH) // '/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin' process.env.PATH.split(path.delimiter) -// returns -['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin'] +// returns ['/usr/bin', '/bin', '/usr/sbin', '/sbin', '/usr/local/bin'] ``` An example on Windows: @@ -46,8 +43,7 @@ console.log(process.env.PATH) // 'C:\Windows\system32;C:\Windows;C:\Program Files\node\' process.env.PATH.split(path.delimiter) -// returns -['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\'] +// returns ['C:\\Windows\\system32', 'C:\\Windows', 'C:\\Program Files\\node\\'] ``` ## path.dirname(p) @@ -58,8 +54,7 @@ Example: ```js path.dirname('/foo/bar/baz/asdf/quux') -// returns -'/foo/bar/baz/asdf' +// returns '/foo/bar/baz/asdf' ``` ## path.extname(p) @@ -71,29 +66,39 @@ an empty string. Examples: ```js path.extname('index.html') -// returns -'.html' +// returns '.html' path.extname('index.coffee.md') -// returns -'.md' +// returns '.md' path.extname('index.') -// returns -'.' +// returns '.' path.extname('index') -// returns -'' +// returns '' path.extname('.index') -// returns -'' +// returns '' ``` ## path.format(pathObject) -Returns a path string from an object, the opposite of [`path.parse`][]. +Returns a path string from an object. This is the opposite of [`path.parse`][]. + +If `pathObject` has all expected properties, the returned string will be a +concatenation of the `dir` property, the platform-dependent path separator, and +the `base` property. + +If the `dir` property is not supplied, the `root` property will be used as the +`dir` property. However, it will be assumed that the `root` property already +ends with the platform-dependent path separator. In this case, the returned +string will be the concatenation fo the `root` property and the `base` property. + +If both the `dir` and the `root` properties are not supplied, then the returned +string will be the contents of the `base` property. + +If the `base` property is not supplied, a concatenation of the `name` property +and the `ext` property will be used as the `base` property. ```js path.format({ @@ -102,10 +107,19 @@ path.format({ base : "file.txt", ext : ".txt", name : "file" +}); +// returns '/home/user/dir/file.txt' + +// `root` will be used if `dir` is not specified and `name` + `ext` will be used +// if `base` is not specified +path.format({ + root : "/", + ext : ".txt", + name : "file" }) -// returns -'/home/user/dir/file.txt' +// returns '/file.txt' ``` + ## path.isAbsolute(path) Determines whether `path` is an absolute path. An absolute path will always @@ -144,8 +158,7 @@ Example: ```js path.join('/foo', 'bar', 'baz/asdf', 'quux', '..') -// returns -'/foo/bar/baz/asdf' +// returns '/foo/bar/baz/asdf' path.join('foo', {}, 'bar') // throws exception @@ -169,8 +182,7 @@ Example: ```js path.normalize('/foo/bar//baz/asdf/quux/..') -// returns -'/foo/bar/baz/asdf' +// returns '/foo/bar/baz/asdf' ``` *Note:* If the path string passed as argument is a zero-length string then `'.'` @@ -185,13 +197,13 @@ An example on \*nix: ```js path.parse('/home/user/dir/file.txt') // returns -{ - root : "/", - dir : "/home/user/dir", - base : "file.txt", - ext : ".txt", - name : "file" -} +// { +// root : "/", +// dir : "/home/user/dir", +// base : "file.txt", +// ext : ".txt", +// name : "file" +// } ``` An example on Windows: @@ -199,13 +211,13 @@ An example on Windows: ```js path.parse('C:\\path\\dir\\index.html') // returns -{ - root : "C:\\", - dir : "C:\\path\\dir", - base : "index.html", - ext : ".html", - name : "index" -} +// { +// root : "C:\\", +// dir : "C:\\path\\dir", +// base : "index.html", +// ext : ".html", +// name : "index" +// } ``` ## path.posix @@ -229,12 +241,10 @@ Examples: ```js path.relative('C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb') -// returns -'..\\..\\impl\\bbb' +// returns '..\\..\\impl\\bbb' path.relative('/data/orandea/test/aaa', '/data/orandea/impl/bbb') -// returns -'../../impl/bbb' +// returns '../../impl/bbb' ``` *Note:* If the arguments to `relative` have zero-length strings then the current @@ -274,16 +284,14 @@ Examples: ```js path.resolve('/foo/bar', './baz') -// returns -'/foo/bar/baz' +// returns '/foo/bar/baz' path.resolve('/foo/bar', '/tmp/file/') -// returns -'/tmp/file' +// returns '/tmp/file' path.resolve('wwwroot', 'static_files/png/', '../gif/image.gif') // if currently in /home/myself/node, it returns -'/home/myself/node/wwwroot/static_files/gif/image.gif' +// '/home/myself/node/wwwroot/static_files/gif/image.gif' ``` *Note:* If the arguments to `resolve` have zero-length strings then the current @@ -297,16 +305,14 @@ An example on \*nix: ```js 'foo/bar/baz'.split(path.sep) -// returns -['foo', 'bar', 'baz'] +// returns ['foo', 'bar', 'baz'] ``` An example on Windows: ```js 'foo\\bar\\baz'.split(path.sep) -// returns -['foo', 'bar', 'baz'] +// returns ['foo', 'bar', 'baz'] ``` ## path.win32 diff --git a/doc/api/process.markdown b/doc/api/process.markdown index 6027cf4957984d..c7f2567ccf5aff 100644 --- a/doc/api/process.markdown +++ b/doc/api/process.markdown @@ -7,12 +7,13 @@ It is an instance of [`EventEmitter`][]. ## Event: 'beforeExit' -This event is emitted when Node.js empties its event loop and has nothing else to -schedule. Normally, Node.js exits when there is no work scheduled, but a listener -for `'beforeExit'` can make asynchronous calls, and cause Node.js to continue. +This event is emitted when Node.js empties its event loop and has nothing else +to schedule. Normally, Node.js exits when there is no work scheduled, but a +listener for `'beforeExit'` can make asynchronous calls, and cause Node.js to +continue. -`'beforeExit'` is not emitted for conditions causing explicit termination, such as -[`process.exit()`][] or uncaught exceptions, and should not be used as an +`'beforeExit'` is not emitted for conditions causing explicit termination, such +as [`process.exit()`][] or uncaught exceptions, and should not be used as an alternative to the `'exit'` event unless the intention is to schedule more work. ## Event: 'exit' @@ -91,11 +92,12 @@ indefinitely) or upon process exit (more convenient for scripts). ## Event: 'uncaughtException' -Emitted when an exception bubbles all the way back to the event loop. If a -listener is added for this exception, the default action (which is to print -a stack trace and exit) will not occur. +The `'uncaughtException'` event is emitted when an exception bubbles all the +way back to the event loop. By default, Node.js handles such exceptions by +printing the stack trace to stderr and exiting. Adding a handler for the +`'uncaughtException'` event overrides this default behavior. -Example of listening for `'uncaughtException'`: +For example: ```js process.on('uncaughtException', (err) => { @@ -111,26 +113,27 @@ nonexistentFunc(); console.log('This will not run.'); ``` -Note that `'uncaughtException'` is a very crude mechanism for exception -handling. +### Warning: Using `'uncaughtException'` correctly -Do *not* use it as the Node.js equivalent of `On Error Resume Next`. An -unhandled exception means your application - and by extension Node.js itself - -is in an undefined state. Blindly resuming means *anything* could happen. +Note that `'uncaughtException'` is a crude mechanism for exception handling +intended to be used only as a last resort. The event *should not* be used as +an equivalent to `On Error Resume Next`. Unhandled exceptions inherently mean +that an application is in an undefined state. Attempting to resume application +code without properly recovering from the exception can cause additional +unforeseen and unpredictable issues. Exceptions thrown from within the event handler will not be caught. Instead the process will exit with a non zero exit code and the stack trace will be printed. This is to avoid infinite recursion. -Think of resuming as pulling the power cord when you are upgrading your system. -Nine out of ten times nothing happens - but the 10th time, your system is bust. +Attempting to resume normally after an uncaught exception can be similar to +pulling out of the power cord when upgrading a computer -- nine out of ten +times nothing happens - but the 10th time, the system becomes corrupted. -`'uncaughtException'` should be used to perform synchronous cleanup before -shutting down the process. It is not safe to resume normal operation after -`'uncaughtException'`. If you do use it, restart your application after every -unhandled exception! - -You have been warned. +The correct use of `'uncaughtException'` is to perform synchronous cleanup +of allocated resources (e.g. file descriptors, handles, etc) before shutting +down the process. It is not safe to resume normal operation after +`'uncaughtException'`. ## Event: 'unhandledRejection' @@ -142,8 +145,8 @@ a promise chain. This event is useful for detecting and keeping track of promises that were rejected whose rejections were not handled yet. This event is emitted with the following arguments: - - `reason` the object with which the promise was rejected (usually an [`Error`][] -instance). + - `reason` the object with which the promise was rejected (usually an + [`Error`][] instance). - `p` the promise that was rejected. Here is an example that logs every unhandled rejection to the console @@ -160,7 +163,7 @@ event: ```js somePromise.then((res) => { - return reportToUser(JSON.parse(res)); // note the typo + return reportToUser(JSON.pasre(res)); // note the typo (`pasre`) }); // no `.catch` or `.then` ``` @@ -254,10 +257,10 @@ Note: - `SIGUSR1` is reserved by Node.js to start the debugger. It's possible to install a listener but that won't stop the debugger from starting. -- `SIGTERM` and `SIGINT` have default handlers on non-Windows platforms that resets - the terminal mode before exiting with code `128 + signal number`. If one of - these signals has a listener installed, its default behavior will be removed - (Node.js will no longer exit). +- `SIGTERM` and `SIGINT` have default handlers on non-Windows platforms that + resets the terminal mode before exiting with code `128 + signal number`. If + one of these signals has a listener installed, its default behavior will be + removed (Node.js will no longer exit). - `SIGPIPE` is ignored by default. It can have a listener installed. - `SIGHUP` is generated on Windows when the console window is closed, and on other platforms under various similar conditions, see signal(7). It can have a @@ -269,11 +272,12 @@ Note: - `SIGINT` from the terminal is supported on all platforms, and can usually be generated with `CTRL+C` (though this may be configurable). It is not generated when terminal raw mode is enabled. -- `SIGBREAK` is delivered on Windows when `CTRL+BREAK` is pressed, on non-Windows +- `SIGBREAK` is delivered on Windows when `CTRL+BREAK` is pressed, on + non-Windows platforms it can be listened on, but there is no way to send or generate it. -- `SIGWINCH` is delivered when the console has been resized. On Windows, this will - only happen on write to the console when the cursor is being moved, or when a - readable tty is used in raw mode. +- `SIGWINCH` is delivered when the console has been resized. On Windows, this + will only happen on write to the console when the cursor is being moved, or + when a readable tty is used in raw mode. - `SIGKILL` cannot have a listener installed, it will unconditionally terminate Node.js on all platforms. - `SIGSTOP` cannot have a listener installed. @@ -837,6 +841,8 @@ When Node.js is spawned with an IPC channel attached, it can send messages to it parent process using `process.send()`. Each will be received as a [`'message'`][] event on the parent's `ChildProcess` object. +*Note: this function uses [`JSON.stringify()`][] internally to serialize the `message`.* + If Node.js was not spawned with an IPC channel, `process.send()` will be undefined. ## process.setegid(id) @@ -1092,3 +1098,4 @@ Will print something like: [Signal Events]: #process_signal_events [Stream compatibility]: stream.html#stream_compatibility_with_older_node_js_versions [the tty docs]: tty.html#tty_tty +[`JSON.stringify()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify \ No newline at end of file diff --git a/doc/api/stream.markdown b/doc/api/stream.markdown index 16a660813ddf8a..71f0e7ddf0850e 100644 --- a/doc/api/stream.markdown +++ b/doc/api/stream.markdown @@ -416,6 +416,10 @@ potentially mangled if you simply pulled the Buffers directly and called [`buf.toString(encoding)`][] on them. If you want to read the data as strings, always use this method. +Also you can disable any encoding at all with `readable.setEncoding(null)`. +This approach is very useful if you deal with binary data or with large +multi-byte strings spread out over multiple chunks. + ```js var readable = getReadableStreamSomehow(); readable.setEncoding('utf8'); @@ -706,7 +710,9 @@ Flush all data, buffered since [`stream.cork()`][] call. * Returns: {Boolean} `true` if the data was handled completely. This method writes some data to the underlying system, and calls the -supplied callback once the data has been fully handled. +supplied callback once the data has been fully handled. If an error +occurs, the callback may or may not be called with the error as its +first argument. To detect write errors, listen for the `'error'` event. The return value indicates if you should continue writing right now. If the data had to be buffered internally, then it will return diff --git a/doc/api/tls.markdown b/doc/api/tls.markdown index a24bb3dccbfa73..2d23e3f7a801ae 100644 --- a/doc/api/tls.markdown +++ b/doc/api/tls.markdown @@ -61,7 +61,7 @@ server-side resources, which makes it a potential vector for denial-of-service attacks. To mitigate this, renegotiations are limited to three times every 10 minutes. An -error is emitted on the [tls.TLSSocket][] instance when the threshold is +error is emitted on the [`tls.TLSSocket`][] instance when the threshold is exceeded. The limits are configurable: - `tls.CLIENT_RENEG_LIMIT`: renegotiation limit, default is 3. @@ -159,7 +159,7 @@ is expensive. ## Class: CryptoStream - Stability: 0 - Deprecated: Use [`tls.TLSSocket()`][] instead. + Stability: 0 - Deprecated: Use [`tls.TLSSocket`][] instead. This is an encrypted stream. @@ -193,10 +193,10 @@ connections using TLS or SSL. `function (exception, tlsSocket) { }` -When a client connection emits an `'error'` event before secure connection is -established - it will be forwarded here. +When a client connection emits an `'error'` event before a secure connection is +established it will be forwarded here. -`tlsSocket` is the [tls.TLSSocket][] that the error originated from. +`tlsSocket` is the [`tls.TLSSocket`][] that the error originated from. ### Event: 'newSession' @@ -278,7 +278,7 @@ server.on('resumeSession', (id, cb) => { `function (tlsSocket) {}` This event is emitted after a new connection has been successfully -handshaked. The argument is an instance of [tls.TLSSocket][]. It has all the +handshaked. The argument is an instance of [`tls.TLSSocket`][]. It has all the common stream methods and events. `socket.authorized` is a boolean value which indicates if the @@ -370,7 +370,7 @@ Construct a new TLSSocket object from existing TCP socket. - `secureContext`: An optional TLS context object from [`tls.createSecureContext()`][] - - `isServer`: If `true` - TLS socket will be instantiated in server-mode. + - `isServer`: If `true` the TLS socket will be instantiated in server-mode. Default: `false` - `server`: An optional [`net.Server`][] instance @@ -385,9 +385,9 @@ Construct a new TLSSocket object from existing TCP socket. - `session`: Optional, a `Buffer` instance, containing TLS session - - `requestOCSP`: Optional, if `true` - OCSP status request extension would - be added to client hello, and `'OCSPResponse'` event will be emitted on socket - before establishing secure communication + - `requestOCSP`: Optional, if `true` the OCSP status request extension will + be added to the client hello, and an `'OCSPResponse'` event will be emitted + on the socket before establishing a secure communication ### Event: 'OCSPResponse' @@ -406,7 +406,7 @@ The listener will be called no matter if the server's certificate was authorized or not. It is up to the user to test `tlsSocket.authorized` to see if the server certificate was signed by one of the specified CAs. If `tlsSocket.authorized === false` then the error can be found in -`tlsSocket.authorizationError`. Also if NPN was used - you can check +`tlsSocket.authorizationError`. Also if NPN was used you can check `tlsSocket.npnProtocol` for negotiated protocol. ### tlsSocket.address() @@ -446,8 +446,8 @@ information. Returns an object representing the peer's certificate. The returned object has some properties corresponding to the field of the certificate. If `detailed` -argument is `true` - the full chain with `issuer` property will be returned, -if `false` - only the top certificate without `issuer` property. +argument is `true` the full chain with `issuer` property will be returned, +if `false` only the top certificate without `issuer` property. Example: @@ -596,7 +596,7 @@ Creates a new client connection to the given `port` and `host` (old API) or The `callback` parameter will be added as a listener for the [`'secureConnect'`][] event. -`tls.connect()` returns a [tls.TLSSocket][] object. +`tls.connect()` returns a [`tls.TLSSocket`][] object. Here is an example of a client of echo server as described previously: @@ -703,12 +703,12 @@ and the cleartext one is used as a replacement for the initial encrypted stream. automatically reject clients with invalid certificates. Only applies to servers with `requestCert` enabled. - - `options`: An object with common SSL options. See [tls.TLSSocket][]. + - `options`: An object with common SSL options. See [`tls.TLSSocket`][]. `tls.createSecurePair()` returns a SecurePair object with `cleartext` and `encrypted` stream properties. -NOTE: `cleartext` has the same APIs as [tls.TLSSocket][] +NOTE: `cleartext` has the same APIs as [`tls.TLSSocket`][] ## tls.createServer(options[, secureConnectionListener]) @@ -817,7 +817,7 @@ automatically set as a listener for the [`'secureConnection'`][] event. The and `cb`. `SNICallback` should invoke `cb(null, ctx)`, where `ctx` is a SecureContext instance. (You can use `tls.createSecureContext(...)` to get proper - SecureContext). If `SNICallback` wasn't provided - default callback with + SecureContext). If `SNICallback` wasn't provided the default callback with high-level API will be used (see below). - `sessionTimeout`: An integer specifying the seconds after which TLS @@ -918,7 +918,7 @@ console.log(ciphers); // ['AES128-SHA', 'AES256-SHA', ...] [`crypto.getCurves()`]: crypto.html#crypto_crypto_getcurves [`tls.createServer()`]: #tls_tls_createserver_options_secureconnectionlistener [`tls.createSecurePair()`]: #tls_tls_createsecurepair_context_isserver_requestcert_rejectunauthorized_options -[`tls.TLSSocket()`]: #tls_class_tls_tlssocket +[`tls.TLSSocket`]: #tls_class_tls_tlssocket [`net.Server`]: net.html#net_class_net_server [`net.Socket`]: net.html#net_class_net_socket [`net.Server.address()`]: net.html#net_server_address diff --git a/doc/api/v8.markdown b/doc/api/v8.markdown index f6c0ae0f752156..6753c2a4a37ce0 100644 --- a/doc/api/v8.markdown +++ b/doc/api/v8.markdown @@ -40,5 +40,5 @@ v8.setFlagsFromString('--trace_gc'); setTimeout(function() { v8.setFlagsFromString('--notrace_gc'); }, 60e3); ``` -[V8]: https://code.google.com/p/v8/ +[V8]: https://developers.google.com/v8/ [here]: https://github.com/thlorenz/v8-flags/blob/master/flags-0.11.md diff --git a/doc/api/zlib.markdown b/doc/api/zlib.markdown index 60cd7145abbbfb..da20024ca2109f 100644 --- a/doc/api/zlib.markdown +++ b/doc/api/zlib.markdown @@ -324,7 +324,7 @@ Returns a new [Unzip][] object with an [options][]. -All of these take a string or buffer as the first argument, an optional second +All of these take a [Buffer][] or string as the first argument, an optional second argument to supply options to the zlib classes and will call the supplied callback with `callback(error, result)`. @@ -332,45 +332,39 @@ Every method has a `*Sync` counterpart, which accept the same arguments, but without a callback. ### zlib.deflate(buf[, options], callback) +### zlib.deflateSync(buf[, options]) -Compress a string with Deflate. +Compress a Buffer or string with Deflate. ### zlib.deflateRaw(buf[, options], callback) ### zlib.deflateRawSync(buf[, options]) -Compress a string with DeflateRaw. - -### zlib.deflateSync(buf[, options]) - -Compress a string with Deflate. +Compress a Buffer or string with DeflateRaw. ### zlib.gunzip(buf[, options], callback) ### zlib.gunzipSync(buf[, options]) -Decompress a raw Buffer with Gunzip. +Decompress a Buffer or string with Gunzip. ### zlib.gzip(buf[, options], callback) ### zlib.gzipSync(buf[, options]) -Compress a string with Gzip. +Compress a Buffer or string with Gzip. ### zlib.inflate(buf[, options], callback) +### zlib.inflateSync(buf[, options]) -Decompress a raw Buffer with Inflate. +Decompress a Buffer or string with Inflate. ### zlib.inflateRaw(buf[, options], callback) ### zlib.inflateRawSync(buf[, options]) -Decompress a raw Buffer with InflateRaw. - -### zlib.inflateSync(buf[, options]) - -Decompress a raw Buffer with Inflate. +Decompress a Buffer or string with InflateRaw. ### zlib.unzip(buf[, options], callback) ### zlib.unzipSync(buf[, options]) -Decompress a raw Buffer 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 @@ -384,3 +378,4 @@ Decompress a raw Buffer with Unzip. [Inflate]: #zlib_class_zlib_inflate [InflateRaw]: #zlib_class_zlib_inflateraw [Unzip]: #zlib_class_zlib_unzip +[Buffer]: buffer.html diff --git a/doc/api_assets/style.css b/doc/api_assets/style.css index b450b45c465f5d..47f3392395932f 100644 --- a/doc/api_assets/style.css +++ b/doc/api_assets/style.css @@ -33,7 +33,7 @@ pre, tt, code, .pre, span.type, a.type { } a, a:link, a:active { - color: #80bd01; + color: #43853d; text-decoration: none; border-radius: 2px; padding: .1em .2em; @@ -42,7 +42,7 @@ a, a:link, a:active { a:hover, a:focus { color: #fff; - background-color: #80bd01; + background-color: #43853d; outline: none; } @@ -413,13 +413,14 @@ a code { #column2 ul li a.active, #column2 ul li a.active:hover, #column2 ul li a.active:focus { - color: #80bd01; + color: #43853d; border-radius: 0; - border-bottom: 1px solid #80bd01; + border-bottom: 1px solid #43853d; background: none; } -#intro a:hover, #column2 ul li a:hover, #column2 ul li a:focus { +#intro a:hover, #intro a:focus, +#column2 ul li a:hover, #column2 ul li a:focus { color: #fff; background: none; } @@ -433,7 +434,7 @@ span > .mark, span > .mark:visited { } span > .mark:hover, span > .mark:focus, span > .mark:active { - color: #80bd01; + color: #43853d; background: none; } diff --git a/doc/full-white-stripe.jpg b/doc/full-white-stripe.jpg index 54c88fb7a17d0b..798473392fb6d7 100644 Binary files a/doc/full-white-stripe.jpg and b/doc/full-white-stripe.jpg differ diff --git a/doc/guides/building-node-with-ninja.md b/doc/guides/building-node-with-ninja.md new file mode 100644 index 00000000000000..550effa976a468 --- /dev/null +++ b/doc/guides/building-node-with-ninja.md @@ -0,0 +1,39 @@ +# Building Node with Ninja + +The purpose of this guide is to show how to build Node.js using [Ninja][], as doing so can be significantly quicker than using `make`. Please see [Ninja's site][Ninja] for installation instructions (unix only). + +To build Node with ninja, there are 4 steps that must be taken: + +1. Configure the project's OS-based build rules via `./configure` as usual. +2. Use `tools/gyp_node.py -f ninja` to produce Ninja-buildable `gyp` output. +3. Run `ninja -C out/Release` to produce a compiled release binary. +4. Lastly, make symlink to `./node` using `ln -fs out/Release/node node`. + +When running `ninja -C out/Release` you will see output similar to the following if the build has succeeded: +``` +ninja: Entering directory `out/Release` +[4/4] LINK node, POSTBUILDS +``` + +The bottom line will change while building, showing the progress as `[finished/total]` build steps. +This is useful output that `make` does not produce and is one of the benefits of using Ninja. +Also, Ninja will likely compile much faster than even `make -j8` (or `-j`). + +## Considerations + +Ninja builds vary slightly from `make` builds. If you wish to run `make test` after, `make` will likely still need to rebuild some amount of Node. + +As such, if you wish to run the tests, it can be helpful to invoke the test runner directly, like so: +`tools/test.py --mode=release message parallel sequential -J` + +## Alias + +`alias nnode='./configure && tools/gyp_node.py -f ninja && ninja -C out/Release && ln -fs out/Release/node node'` + +## Producing a debug build + +The above alias can be modified slightly to produce a debug build, rather than a release build as shown below: +`alias nnodedebug='./configure && tools/gyp_node.py -f ninja && ninja -C out/Debug && ln -fs out/Debug/node node_g'` + + +[Ninja]: https://martine.github.io/ninja/ diff --git a/doc/onboarding-extras.md b/doc/onboarding-extras.md new file mode 100644 index 00000000000000..2f35e2778c3a2c --- /dev/null +++ b/doc/onboarding-extras.md @@ -0,0 +1,105 @@ +## Who to CC in issues + +* `lib/buffer`: @trevnorris +* `lib/child_process`: @cjihrig, @bnoordhuis, @piscisaereus +* `lib/cluster`: @cjihrig, @bnoordhuis, @piscisaereus +* `lib/{crypto,tls,https}`: @indutny, @shigeki, @nodejs/crypto +* `lib/domains`: @misterdjules +* `lib/{_}http{*}`: @indutny, @bnoordhuis, @nodejs/http +* `lib/net`: @indutny, @bnoordhuis, @piscisaereus, @chrisdickinson, @nodejs/streams +* `lib/{_}stream{s|*}`: @nodejs/streams +* `lib/repl`: @fishrock123 +* `lib/timers`: @fishrock123, @misterdjules +* `lib/zlib`: @indutny, @bnoordhuis + +* `src/async-wrap.*`: @trevnorris +* `src/node_crypto.*`: @indutny, @shigeki, @nodejs/crypto + +* `test/*`: @nodejs/testing, @trott + +* `tools/eslint`, `.eslintrc`: @silverwind, @trott + +* upgrading v8: @bnoordhuis / @targos / @ofrobots +* upgrading npm: @thealphanerd, @fishrock123 + + +When things need extra attention, are controversial, or `semver-major`: @nodejs/ctc + +If you cannot find who to cc for a file, `git shortlog -n -s ` may help. + + +## Labels + +### By Subsystem + +We generally sort issues by a concept of "subsystem" so that we know what part(s) of the codebase it touches. + +**Subsystems generally are**: + +* `lib/*.js` +* `doc`, `build`, `tools`, `test`, `deps`, `lib / src` (special), and there may be others. +* `meta` for anything non-code (process) related + +There may be more than one subsystem valid for any particular issue / PR. + + +### General + +Please use these when possible / appropriate + +* `confirmed-bug` - Bugs you have verified exist +* `discuss` - Things that need larger discussion +* `feature request` - Any issue that requests a new feature (usually not PRs) +* `good first contribution` - Issues suitable for newcomers to process + +* `semver-{minor,major}` + * be conservative – that is, if a change has the remote *chance* of breaking something, go for semver-major + * when adding a semver label, add a comment explaining why you're adding it + * minor vs. patch: roughly: "does it add a new method / does it add a new section to the docs" + * major vs. everything else: run last versions tests against this version, if they pass, **probably** minor or patch + * A breaking change helper ([full source](https://gist.github.com/chrisdickinson/ba532fa0e4e243fb7b44)): + ``` + git checkout $(git show -s --pretty='%T' $(git show-ref -d $(git describe --abbrev=0) | tail -n1 | awk '{print $1}')) -- test; make -j8 test + ``` + + +### Other Labels + +* Operating system labels + * `os x`, `windows`, `solaris` + * No linux, linux is the implied default +* Architecture labels + * `arm`, `mips` + * No x86{_64}, since that is the implied default +* `lts-agenda`, `lts-watch-v*` + * tag things that should be discussed to go into LTS or should go into a specific LTS branch + * (usually only semver-patch things) + * will come more naturally over time + + +## Updating Node.js from Upstream + +* `git remote add upstream git://github.com/nodejs/node.git` + +to update from nodejs/node: +* `git checkout master` +* `git remote update -p` OR `git fetch --all` (I prefer the former) +* `git merge --ff-only upstream/master` (or `REMOTENAME/BRANCH`) + + +## If `git am` fails + +* if `git am` fails – use `git am --abort` + * this usually means the PR needs updated + * prefer to make the originating user update the code, since they have it fresh in mind +* first, reattempt with `git am -3` (3-way merge)` +* if `-3` still fails, and you need to get it merged: + * `git fetch origin pull/N/head:pr-N && git checkout pr-N && git rebase master` + + +## best practices + +* commit often, out to your github fork (origin), open a PR +* when making PRs make sure to spend time on the description: + * every moment you spend writing a good description quarters the amount of time it takes to understand your code. +* usually prefer to only squash at the *end* of your work, depends on the change diff --git a/doc/onboarding.md b/doc/onboarding.md new file mode 100644 index 00000000000000..1646080f3b3bbf --- /dev/null +++ b/doc/onboarding.md @@ -0,0 +1,199 @@ +## pre-setup + +Ensure everyone is added to https://github.com/orgs/nodejs/teams/collaborators + + +## onboarding to nodejs + +### intros + + +### **thank you** for doing this + + * going to cover four things: + * local setup + * some project goals & values + * issues, labels, and reviewing code + * merging code + + +### setup: + + * notifications setup + * use https://github.com/notifications or set up email + * watching the main repo will flood your inbox, so be prepared + + + * git: + * make sure you have whitespace=fix: `git config --global --add core.whitespace fix` + * usually PR from your own github fork + * [**See "Updating Node.js from Upstream"**](./onboarding-extras.md#updating-nodejs-from-upstream) + * make new branches for all commits you make! + + + * `#node-dev` on `chat.freenode.net` is the best place to interact with the CTC / other collaborators + + +### a little deeper about the project + + * collaborators are effectively part owners + * the project has the goals of its contributors + + + * but, there are some higher-level goals and values + * not everything belongs in core (if it can be done reasonably in userland, let it stay in userland) + * empathy towards users matters (this is in part why we onboard people) + * generally: try to be nice to people + + +### managing the issue tracker + + * you have (mostly) free rein – don't hesitate to close an issue if you are confident that it should be closed + * this will come more naturally over time + * IMPORTANT: be nice about closing issues, let people know why, and that issues and PRs can be reopened if necessary + * Still need to follow the Code of Conduct. + + + * labels: + * generally sort issues by a concept of "subsystem" so that we know what part(s) of the codebase it touches, though there are also other useful labels. + * [**See "Labels"**](./onboarding-extras.md#labels) + * `ctc-agenda` if a topic is controversial or isn't coming to a conclusion after an extended time. + * `semver-{minor,major}`: + * be conservative – that is, if a change has the remote *chance* of breaking something, go for `semver-major` + * when adding a semver label, add a comment explaining why you're adding it + * it's cached locally in your brain at that moment! + + + * Notifying humans + * [**See "Who to CC in issues"**](./onboarding-extras.md#who-to-cc-in-issues) + * will also come more naturally over time + + + * reviewing: + * primary goal is for the codebase to improve + * secondary (but not far off) is for the person submitting code to succeed + * helps grow the community + * and draws new people into the project + * Review a bit at a time. It is **very important** to not overwhelm newer people. + * it is tempting to micro-optimize / make everything about relative perf, + don't succumb to that temptation. we change v8 a lot more often now, contortions + that are zippy today may be unnecessary in the future + * be aware: your opinion carries a lot of weight! + * nits are fine, but try to avoid stalling the PR + * note that they are nits when you comment + * if they really are stalling nits, fix them yourself on merge (but try to let PR authors know they can fix these) + * improvement doesn't have to come all at once + * minimum wait for comments time + * There is a minimum waiting time which we try to respect for non-trivial changes, so that people who may have important input in such a distributed project are able to respond. + * It may help to set time limits and expectations: + * the collaborators are very distributed so it is unlikely that they will be looking at stuff the same time as you are. + * before merging code: give folks at least one working day to respond: "If no one objects, tomorrow at