diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 1362c9cb29e387..2329084fddebb7 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -1,3 +1,5 @@ +root: true + env: node: true es6: true @@ -43,7 +45,9 @@ rules: no-throw-literal: 2 no-unused-labels: 2 no-useless-call: 2 + no-useless-concat: 2 no-useless-escape: 2 + no-useless-return: 2 no-void: 2 no-with: 2 @@ -101,6 +105,13 @@ rules: new-parens: 2 no-mixed-spaces-and-tabs: 2 no-multiple-empty-lines: [2, {max: 2, maxEOF: 0, maxBOF: 0}] + no-restricted-syntax: [2, { + selector: "CallExpression[callee.name='setTimeout'][arguments.length<2]", + message: "setTimeout() must be invoked with at least two arguments." + }, { + selector: "CallExpression[callee.name='setInterval'][arguments.length<2]", + message: "setInterval() must be invoked with at least 2 arguments" + }] no-tabs: 2 no-trailing-spaces: 2 one-var-declaration-per-line: 2 @@ -135,7 +146,6 @@ rules: assert-fail-single-argument: 2 assert-throws-arguments: [2, { requireTwo: false }] new-with-error: [2, Error, RangeError, TypeError, SyntaxError, ReferenceError] - timer-arguments: 2 # Global scoped method and vars globals: diff --git a/.mailmap b/.mailmap index 722995b6b04b63..a2b1fce896f284 100644 --- a/.mailmap +++ b/.mailmap @@ -1,5 +1,8 @@ +Aaron Bieber Aaron Heckmann Abe Fettig +Akito Ito +Alejandro Oviedo Garcia Alejandro Oviedo Alex Hultman Alex Kocharin Alex Kocharin @@ -7,22 +10,35 @@ Alexey Kupershtokh Alexis Campailla Alexis Sellier Alexis Sellier +Andreas Offenhaeuser anoff Andy Bettisworth +Angel Stoyanov atstojanov Anna Henningsen Aria Stewart Arlo Breault Artem Zaytsev Arnout Kazemier <3rd-Eden@users.noreply.github.com> +Asaf David asafdav2 Atsuo Fukaya +Ben Lugavere blugavere Ben Noordhuis Ben Taber +Benjamin Waters Bert Belder Bert Belder Bert Belder +Beth Griggs Bethany Griggs +Beth Griggs Bethany N Griggs +Beth Griggs BethGriggs +Brad Decker brad-decker Brandon Benvie +Brandon Kobel kobelb +Brendan Ashworth Brian White Brian White Caleb Boyd +Calvin Metcalf +Calvin Metcalf Charles Chew Choon Keat Charles Rudolph @@ -31,6 +47,7 @@ Claudio Rodriguez Colin Ihrig Christopher Lenz Dan Kaplun +Dan Williams Dan.Williams Daniel Berger Daniel Chcouri <333222@gmail.com> Daniel Gröber @@ -50,34 +67,47 @@ EungJun Yi Evan Larkin Evan Lucas Evan Lucas +FangDun Cai Fangdun Cai (Fundon) Farid Neshat Fedor Indutny Felix Böhm Felix Geisendörfer Felix Geisendörfer +Forrest L Norvell Friedemann Altrock Fuji Goro Gabriel de Perthuis +Gibson Fahnestock Gil Pedersen +Greg Sabia Tucker +Hitesh Kanwathirtha Henry Chin Herbert Vojčík Icer Liang Igor Soarez Igor Zinkovsky Imran Iqbal +Ionică Bizău Isaac Z. Schlueter Isaac Z. Schlueter +Italo A. Casas +Jackson Tian Jake Verbaten James Hartig James M Snell Jan Krems +Jenna Vuong Jered Schmidt Jeremiah Senkpiel Jerry Chin +Jesús Leganés-Combarro 'piranna Jesús Leganés Combarro "piranna Joe Shaw Johan Bergström Johan Dahlberg Johann Hofmann +John Barboza jBarz +Johnny Ray Austin Johnny Ray +Jon Tippens legalcodes Jonas Pfenniger Jonathan Ong Jonathan Persson @@ -91,6 +121,7 @@ Jérémy Lal Jérémy Lal Kai Sasaki Lewuathe Karl Skomski +Kathy Truong k3kathy Kazuyuki Yamada Keith M Wesolowski Kelsey Breseman @@ -99,12 +130,13 @@ Kris Kowal Kyle Robinson Young Luke Bayes Maciej Małecki -Malte-Thorben Bruns -Malte-Thorben Bruns +Malte-Thorben Bruns Marcin Cieślak Marcin Cieślak +Marcin Zielinski marzelin Marti Martz Martial James Jefferson +Mathias Buus Mathias Pettersson Matthew Lye Michael Bernstein @@ -115,6 +147,8 @@ Micleusanu Nicu Mikael Bourges-Sevenier Miroslav Bajtoš Mitar Milutinovic +Myles Borins +Myles Borins Nebu Pookins Nicholas Kinsey Nikolai Vavilov @@ -126,7 +160,12 @@ Ratikesh Misra Ray Morgan Ray Solomon Raymond Feng +Rebecca Turner +Refael Ackermann +Reza Akhavan jedireza +Ricardo Sánchez Gregorio richnologies Rick Olson +Rod Machen Roman Klauke Roman Reiss Ron Korving @@ -140,17 +179,25 @@ Sam Shull Sambasiva Suda Sam Roberts San-Tai Hsu +Santiago Gimeno Scott Blomquist +Segu Riluvan Sergey Kryzhanovsky Shannen Saez -Shigeki Ohtsu +Shigeki Ohtsu +Shigeki Ohtsu Siddharth Mahendraker Simon Willison Stanislav Opichal Stefan Budeanu Stefan Bühler -Steve Mao -Steven R. Loomis +Steve Mao +Steven R. Loomis +Stewart X Addison Stewart Addison +Stewart X Addison sxa555 +Suramya shah ss22ever +Tanuja-Sawant +Toby Stableford toboid Todd Kennedy TJ Holowaychuk TJ Holowaychuk @@ -163,12 +210,16 @@ Tim Caswell Tim Price Tim Smart Tim Smart +Timothy Leverett Timothy Tom Hughes Tom Hughes-Croucher +Travis Meisenheimer Trevor Burnham Tyler Larson +Viktor Karpov vitkarpov Vincent Voyer Vladimir de Turckheim +vsemozhetbyt Vse Mozhet Byt Willi Eggeling Yazhong Liu Yazhong Liu Yazhong Liu Yorkie diff --git a/AUTHORS b/AUTHORS index 6d4c9842d4774c..ee864d2d8ff8db 100644 --- a/AUTHORS +++ b/AUTHORS @@ -181,7 +181,7 @@ Ryan Petrello Fuji Goro Siddharth Mahendraker Dave Pacheco -Mathias Buus +Mathias Buus Henry Rawas Yoshihiro KIKUCHI Brett Kiefer @@ -196,7 +196,7 @@ Jeremy Selier Igor Zinkovsky Kip Gebhardt Stefan Rusu -Shigeki Ohtsu +Shigeki Ohtsu Wojciech Wnętrzak Devon Govett Steve Engledow @@ -317,7 +317,7 @@ Domenic Denicola Joshua S. Weinstein Dane Springmeyer Erik Dubbelboer -Malte-Thorben Bruns +Malte-Thorben Bruns Michael Thomas Garen Torikian EungJun Yi @@ -359,7 +359,7 @@ Gil Pedersen Tyler Neylon Josh Erickson Golo Roden -Ron Korving +Ron Korving Brandon Wilson Ian Babrou Bearice Ren @@ -471,7 +471,7 @@ David Björklund Dav Glass Andrew Chilton Antony Bailey -Forrest L Norvell +Forrest L Norvell Evan Solomon Eran Hammer Matthias Bartelmeß @@ -484,7 +484,6 @@ Duan Yao Matthew Aynalem Vsevolod Strukchinsky Jay Beavers -Mathias Buus Eric Schrock Jeff Switzer Glen Mailer @@ -530,7 +529,6 @@ Keith M Wesolowski Maxime Quandalle Oguz Bastemur Yuriy Nemtsov -Benjamin Waters iamdoron Austin Moran Kenan Sulayman @@ -555,19 +553,16 @@ William Bert goussardg Geir Hauge Farrin Reid -Ben Noordhuis Denys Zariaiev Sean McArthur Rasmus Christian Pedersen -Forrest L Norvell Adrian Lang Feross Aboukhadijeh Refael Ackermann Taojie -Greg Sabia Tucker +Greg Sabia Tucker Dan Kaplun Colin Ihrig -Greg Sabia Tucker Mark Stosberg Calvin Metcalf Ryan Cole @@ -585,8 +580,7 @@ Jan Krems Fred K. Schott Chris Dickinson Jonathan Reem -Refael Ackermann -Ionică Bizău +Ionică Bizău Eli Skeggs Andrius Bentkus Ed Umansky @@ -604,7 +598,7 @@ Ezequiel Rabinovich Cheng Zhao Tristan Berger Isaac Burns -Jesús Leganés Combarro "piranna +Jesús Leganés-Combarro 'piranna Majid Arif Siddiqui Trevor Livingston Mathias Schreck @@ -622,21 +616,19 @@ gyson Steve Sharp Victor Widell Evan Rutledge Borden -Johnny Ray -Steve Mao +Johnny Ray Austin +Steve Mao Stiliyan Lazarov Wang Xinyong Ray Donnelly dead-horse Luis Reis -Jackson Tian sudodoki Steven Loomis haoxin Artur Cistov MK Safi Rory Bradford -Calvin Metcalf Nathan Woltman James Cowgill Jamund Ferguson @@ -646,7 +638,7 @@ Carlos Campderrós Leonardo Balter Bryce Kahle The Gitter Badger -Brendan Ashworth +Brendan Ashworth Jose Luis Rivas Evan Lucas Vincent Weevers @@ -656,7 +648,7 @@ Juanjo brian m. carlson Kevin O'Hara Micleusanu Nicu -Alejandro Oviedo +Alejandro Oviedo Garcia Ben Burns Julian Duque teppeis @@ -665,7 +657,6 @@ Tim Ruffles CGavrila Aleksey Smolenchuk Caitlin Potter -Calvin Metcalf Eric Mill pkcs James M Snell @@ -678,7 +669,7 @@ Rui Marinho Jesse cogollo Chris Alley Michal Tehnik -Aaron Bieber +Aaron Bieber Phil Hughes Jongyeol Choi Brenard Cubacub @@ -692,11 +683,9 @@ Todd Kennedy Icer Liang Stephen Belanger Jeremiah Senkpiel -Brendan Ashworth Andres Suarez Jonathan Ong ttrfwork -Johnny Ray Austin Mathias Küsel Qasim Zaidi Sam Newman @@ -727,7 +716,6 @@ h7lin Michael Dawson Ruben Verborgh Ken Perkins -Malte-Thorben Bruns Santiago Gimeno Ali Ijaz Sheikh FangDun Cai @@ -792,7 +780,6 @@ Anne-Gaelle Colom Oleksandr Chekhovskyi Tristian Flanagan Mike Tunnicliffe -Ionică Bizău Danny Nemer Sven Slootweg Dmitry Vasilyev @@ -811,7 +798,7 @@ Charles Rudolph Dave Eddy Justin Chase Jeremy Whitlock -Rod Machen +Rod Machen Martial James Jefferson Doug Shamoo Junliang Yan @@ -822,7 +809,7 @@ David Boivin Liang-Chi Hsieh Timothy Gu Fábio Santos -Myles Borins +Myles Borins Jonas Dohse Коренберг Марк Caleb Boyd @@ -862,7 +849,6 @@ Luigi Pinca Peter A. Bigot Zirak Scott Buchanan -Rebecca Turner Bryce Baril Super Zheng Rafał Pocztarski @@ -878,8 +864,6 @@ Hideki Yamamura Lenny Markus Nelson Pecora Graham Fairweather -Ron Korving -Xotic750 Nicholas Young Chris Johnson Bo Borgerson @@ -905,7 +889,6 @@ Julien Waechter Vitor Cortez Michael Theriot Peter Geiss -Santiago Gimeno Richard Lau José Moreira Tom Atkinson @@ -913,14 +896,13 @@ Glen Arrowsmith Jeff Harris Alexander Makarenko Drew Folta -Myles Borins Jimb Esser Dmitriy Lazarev Adam Langley Kári Tristan Helgason Manuel Valls Prayag Verma -Gibson Fahnestock +Gibson Fahnestock Alan Cohen Christophe Naud-Dulude Matthias Bastian @@ -953,7 +935,6 @@ Daniel Wang Craig Akimoto Michael Barrett Alexander Marchenko -Steve Mao Robert C Jensen Vaibhav Stefano Vozza @@ -1002,7 +983,7 @@ Eric Phetteplace William Luo Siobhan O'Donovan Kevin Donahue -Jenna Vuong +Jenna Vuong Anchika Agarwal Jean Regisser Fangshi He @@ -1056,7 +1037,7 @@ Joran Siu Vitaly Tomilov Ratikesh Misra Alex Perkins -Bethany N Griggs +Beth Griggs Joe Esposito Erin Spiceland Ravindra Barthwal @@ -1082,5 +1063,357 @@ Jason Hedrick David Keeler Zwb Paul Grock +Hubert Mine +Dan Fabulich +Mike Ralphson +Alexis374 <879736822@qq.com> +Angel Stoyanov +Thomas Hunter II +Christopher Dunavan +Peter Ogilvie +Teddy Katz +Kalman Hazins +Ltrlg +Dennis Schwartz +Yevgen Safronov +Tobias Kahse +Sébastien Barbieri +Pavol Otcenas +Alessandro Metta +Dany Shaanan +Ishan Aditya +Rachel +Jason Ginchereau +Paul Kiddie +scott stern +Danny Guo +lrlna +matt-in-a-hat +Thomas van Lankveld +Tarjei Husøy +Wietse Venema +Jonathan Prince +Fikret Burak Gazioglu +delvedor +Jermaine Oppong +Richard Walker +matzavinos +Alfred Cepeda +Niklas Ingholt +Michael-Rainabba Richardson +oogz +Rene Weber +Lauren Spiegel +Lydia Katsamberis +mpmckenna8 +nohmapp +Matt Lang +Marc-Aurèle DARCHE +fen +Christopher Fujino +Richard Hong +Akito Ito +Lydia Kats +Madhav Gharmalkar +Mike Woods +Daniel Stenberg +Abner Chou +Bryan Bess +Michael Macherey +Sudaraka Wijesinghe +Miguel Angel Asencio Hurtado +Suramya shah +Anna Magdalena Kedzierska +Christopn Noelke +Rémy MEJA +Alex Jordan +Mariusz 'koder' Chwalba +Juan Andres Andrango +larissayvette +jessicaquynh +Ilya Frolov +Tanuja-Sawant +Bradley T. Hughes +solebox +John Vilk +Tyler Brazier +Marcin Zielinski +Benji Marinacci +Indrek Ardel +Parambir Singh +maasencioh +Niels Nielsen +Marc Udoff +Oliver Salzburg +Jeena Lee +Deverick +anu0012 +jseagull +Olan Byrne +Emanuele DelBono +Gerges Beshay +Isobel Redelmeier +Brandon Kobel +coderaiser +Pedro Victor +Reza Akhavan +Yangyang Liu +Zeke Sikelianos +Wayne Andrews +Andreas Lind +Adam Majer +Oscar Morrison +Jaideep Bajwa +timathon +Timothy Leverett +imatvieiev +kohta ito +ikasumi_wt +Yoshiya Hinosawa +Syuhei Kobayashi +YutamaKotaro +MURAKAMI Masahiko +Thomas Watson Steen +Daijiro Yamada +Kelvin Jin +Mitsuo Utano +masashi.g +Kenneth Skovhus +Aaron Petcoff +Rahat Ahmed +monkick +Adam Brunner +子丶言 +atrioom +Dan Koster +Pedro Lima +Francis Gulotta +Yosuke Saito +mkamakura +kalrover +Brad Decker +ben_cripps +Walter Beller-Morales +Safia Abdalla +makenova +Adriana Rios +scalkpdev +Ashton Kinslow +Kevin Zurawel +Wes Tyler +shiya +Greg Valdez +Bidur Adhikari +Kyle Carter +adelmann +Daniel Pittman +Ian White +Chris Bystrek +Christine Hong +Oscar Martinez +Aileen +David Bradford +stokingerl +Johnny Reading +Mitchell Stoutin +Matt Wilson +Matt Webb +rajatk +Peter Masucci +Daniel Flores +Harish Tejwani +Jonathan Darling +JDHarmon +bjdelro +Hitesh Kanwathirtha +davidmarkclements +Cesar Hernandez +Konstantin Likhter +Richard Karmazin +Hutson Betts +Kent.Fan +Jay Brownlee +Outsider +Sarah Meyer +Andreas Offenhaeuser +Sean Villars +Kathy Truong +Exlipse7 +Josh Mays +Matt Crummey +michael6 +Raja Panidepu +Ethan Arrowood +Dan Villa +CodeTheInternet +Eric Gonzalez +sxa555 +rgoodwin +Nigel Kibodeaux +fmizzell +cdnadmin +Paul Lucas +levsoroka +Christopher Rokita +Peter Diaz +Michael Alexander +Ilya Potuzhnov +J Scott Chapman +Erez Weiss +Scott Smereka +Fabrice Tatieze +Uttam Pawar +Ben Lugavere +Punit Buch +mark hughes +Russell Sherman +hirabhullar +Paul Chin +Matt Phillips +Daryl Thayil +Deepti Agrawal +Axel Monroy +Jason Humphrey +amrios +Chris Henney +Yojan Shrestha +Rodrigo Palma +Sam Shull +Michael-Bryant Choa +CodeVana +Daniel Sims +Rob Adelmann +Diego Paez +Paul Graham +Jared Young +vazina robertson +Bruce Lai +eudaimos +Kyle Corsi +Luca Maraschi +Karl Böhlmark +Gregory +James Tenenbaum +pallxk +Amar Zavery +Prieto, Marcos +Joyee Cheung +hveldstra +Siddhartha Sahai +Andy Chen +Lucas Holmquist +mfrance +Aaron Williams +Alex Newman +Travis Bretton +Adao Junior +weyj4 +Joe Doyle +Bill Ticehurst +misterpoe +Emanuel Buholzer +Duy Le +Neeraj Sharma +Ashita Nagesh +Jason Wohlgemuth +Segu Riluvan +Emanuel Buholzer +Avery, Frank +Chase Starr +sivaprasanna +Troy Connor +Wallace Zhang +Rico Cai +Kevin Cox +Brian Chirgwin +Ken Russo +Christy Leung +René Schünemann +Jeremy Yallop +malen +Kailean Courtney +sarahmeyer +Fumiya KARASAWA +John Barboza +Paul Graham +Nate +Chris Story +Stewart X Addison +Matthew Garrett +David Goussev +George Adams +Benedikt Meurer +Kai Cataldo +Victor Felder +Yann Pringault +Evan Torrie +Michael Lefkowitz +Viktor Karpov +Lukasz Gasior +Jonathan Boarman +Johannes Rieken +Alexey Orlenko +Nathan Phillip Brink +istinson +Javis Sullivan +Irene Li +Yuya Tanaka +Josh Hollandsworth +Sumit Goel +stefan judis +Mark +Jessica Quynh Tran +Travis Meisenheimer +Vinícius do Carmo +Birunthan Mohanathas +Ricardo Sánchez Gregorio +Jon Tippens +Aashil Patel +Alex Ling +Peter Mescalchin +Joshua Colvin +John Maguire +Marlena Compton +Gonen Dukas +Roee Kasher +nanxiongchao +matsuda-koushi +Myk Melez +Diego Rodríguez Baquero +Umair Ishaq +Timo Tijhof +Sebastian Van Sande +Daiki Arai +ALJCepeda +Sebastian Roeder +Toby Stableford +Shubheksha Jalan +jobala +Asaf David +Sota Yamashita +David Benjamin +樋口 彰 +QianJin2013 +Kenan Yildirim +Alexander +Christopher Hiller +xiaoyu <306766053@qq.com> +Arseniy Maximov +Eric Christie +Tarang Hirani +Dean Coakley +Dmitry Tsvettsikh +Jason Wilson +Karan Thakkar +levsthings +Howard Hellyer +Amelia Clarke +James Ide +Ben Schmidt +James Sumners +Bradley Curran +chiaki-yokoo +Benjamin Fleischer +maurice_hayward # Generated by tools/update-authors.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bf1747aa7b37c..f18cc5b2c8ff3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,7 +28,8 @@ release. - 7.9.0
+ 7.10.0
+ 7.9.0
7.8.0
7.7.4
7.7.3
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 4249ae1ca3ba47..d9ad342881c1a9 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,55 +1,5 @@ # Code of Conduct -## Conduct - -* We are committed to providing a friendly, safe and welcoming - environment for all, regardless of level of experience, gender - identity and expression, sexual orientation, disability, - personal appearance, body size, race, ethnicity, age, religion, - nationality, or other similar characteristic. -* Please avoid using overtly sexual nicknames or other nicknames that - might detract from a friendly, safe and welcoming environment for - all. -* Please be kind and courteous. There's no need to be mean or rude. -* Respect that some individuals and cultures consider the casual use of - profanity and sexualized language offensive and off-putting. -* Respect that people have differences of opinion and that every - design or implementation choice carries a trade-off and numerous - costs. There is seldom a right answer. -* Please keep unstructured critique to a minimum. If you have solid - ideas you want to experiment with, make a fork and see how it works. -* We will exclude you from interaction if you insult, demean or harass - anyone. That is not welcome behavior. We interpret the term - "harassment" as including the definition in the [Citizen Code of - Conduct](http://citizencodeofconduct.org/); if you have any lack of - clarity about what might be included in that concept, please read - their definition. In particular, we don't tolerate behavior that - excludes people in socially marginalized groups. -* Private harassment is also unacceptable. No matter who you are, if - you feel you have been or are being harassed or made uncomfortable - by a community member, please contact one of the channel ops or any - of the TSC members immediately with a capture (log, photo, email) of - the harassment if possible. Whether you're a regular contributor or - a newcomer, we care about making this community a safe place for you - and we've got your back. -* Likewise any spamming, trolling, flaming, baiting or other - attention-stealing behavior is not welcome. -* 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/). +The Node.js Code of Conduct document has moved to +https://github.com/nodejs/TSC/blob/master/CODE_OF_CONDUCT.md. Please update +links to this document accordingly. diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index 4ce11257b707f2..95f625bbfa8e44 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -4,14 +4,14 @@ * [Issues and Pull Requests](#issues-and-pull-requests) * [Accepting Modifications](#accepting-modifications) - - [Internal vs. Public API](#internal-vs-public-api) - - [Breaking Changes](#breaking-changes) - - [Deprecations](#deprecations) - - [Involving the CTC](#involving-the-ctc) + - [Internal vs. Public API](#internal-vs-public-api) + - [Breaking Changes](#breaking-changes) + - [Deprecations](#deprecations) + - [Involving the CTC](#involving-the-ctc) * [Landing Pull Requests](#landing-pull-requests) - - [Technical HOWTO](#technical-howto) - - [I Just Made a Mistake](#i-just-made-a-mistake) - - [Long Term Support](#long-term-support) + - [Technical HOWTO](#technical-howto) + - [I Just Made a Mistake](#i-just-made-a-mistake) + - [Long Term Support](#long-term-support) This document contains information for Collaborators of the Node.js project regarding maintaining the code, documentation and issues. @@ -345,7 +345,7 @@ Additionally: ### Technical HOWTO -_Optional:_ ensure that you are not in a borked `am`/`rebase` state +Clear any `am`/`rebase` that may already be underway. ```text $ git am --abort @@ -358,11 +358,12 @@ Checkout proper target branch $ git checkout master ``` -Update the tree +Update the tree (assumes your repo is set up as detailed in +[CONTRIBUTING.md](CONTRIBUTING.md#step-1-fork)) ```text -$ git fetch origin -$ git merge --ff-only origin/master +$ git fetch upstream +$ git merge --ff-only upstream/master ``` Apply external patches @@ -371,16 +372,28 @@ Apply external patches $ curl -L https://github.com/nodejs/node/pull/xxx.patch | git am --whitespace=fix ``` +If the merge fails even though recent CI runs were successful, then a 3-way merge may +be required. In this case try: + +```text +$ git am --abort +$ curl -L https://github.com/nodejs/node/pull/xxx.patch | git am -3 --whitespace=fix +``` +If the 3-way merge succeeds you can proceed, but make sure to check the changes +against the original PR carefully and build/test on at least one platform +before landing. If the 3-way merge fails, then it is most likely that a conflicting +PR has landed since the CI run and you will have to ask the author to rebase. + Check and re-review the changes ```text -$ git diff origin/master +$ git diff upstream/master ``` Check number of commits and commit messages ```text -$ git log origin/master...master +$ git log upstream/master...master ``` If there are multiple commits that relate to the same feature or @@ -388,7 +401,7 @@ one with a feature and separate with a test for that feature, you'll need to use `squash` or `fixup`: ```text -$ git rebase -i origin/master +$ git rebase -i upstream/master ``` This will open a screen like this (in the default shell editor): @@ -444,10 +457,14 @@ commit logs, ensure that they are properly formatted, and add * The commit message text must conform to the [commit message guidelines](./CONTRIBUTING.md#step-3-commit). +Run tests (`make -j4 test` or `vcbuild test`). Even though there was a +successful continuous integration run, other changes may have landed on master +since then, so running the tests one last time locally is a good practice. + Time to push it: ```text -$ git push origin master +$ git push upstream master ``` * Optional: Force push the amended commit to the branch you used to open the pull request. If your branch is called `bugfix`, then the @@ -462,11 +479,6 @@ your pull request shows the purple merged status then you should still add the "Landed in .." comment if you added multiple commits. -* `./configure && make -j8 test` - * `-j8` builds node in parallel with 8 threads. Adjust to the number - of cores or processor-level threads your processor has (or slightly - more) for best results. - ### I Just Made a Mistake * Ping a CTC member. @@ -540,7 +552,8 @@ LTS release. When you send your pull request, consider including information about whether your change is breaking. If you think your patch can be backported, -please feel free to include that information in the PR thread. +please feel free to include that information in the PR thread. For more +information on backporting, please see the [backporting guide][]. Several LTS related issue and PR labels have been provided: @@ -567,3 +580,5 @@ When the LTS working group determines that a new LTS release is required, selected commits will be picked from the staging branch to be included in the release. This process of making a release will be a collaboration between the LTS working group and the Release team. + +[backporting guide]: doc/guides/backporting-to-release-lines.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4daf126bd16053..ca6d2ace76be89 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,7 +4,7 @@ The Code of Conduct explains the *bare minimum* behavior expectations the Node Foundation requires of its contributors. -[Please read it before participating.](./CODE_OF_CONDUCT.md) +[Please read it before participating.](https://github.com/nodejs/TSC/blob/master/CODE_OF_CONDUCT.md) ## Issue Contributions @@ -62,7 +62,7 @@ does not align with the project team. (Node.js has two IRC channels: [#Node.js](http://webchat.freenode.net/?channels=node.js) for general help and questions, and [#Node-dev](http://webchat.freenode.net/?channels=node-dev) for development of -Node.js core specifically. +Node.js core specifically). For instructions on updating the version of V8 included in the *deps/* directory, please refer to [the Maintaining V8 in Node.js guide](https://github.com/nodejs/node/blob/master/doc/guides/maintaining-V8.md). @@ -100,15 +100,28 @@ $ git commit Writing good commit logs is important. A commit log should describe what changed and why. Follow these guidelines when writing one: -1. The first line should be 50 characters or less and contain a short - description of the change. All words in the description should be in - lowercase with the exception of proper nouns, acronyms, and the ones that - refer to code, like function/variable names. The description should - be prefixed with the name of the changed subsystem and start with an - imperative verb. Example: "net: add localAddress and localPort - to Socket" +1. The first line should: + - contain a short description of the change + - be 50 characters or less + - be entirely in lowercase with the exception of proper nouns, acronyms, and + the words that refer to code, like function/variable names + - be prefixed with the name of the changed subsystem and start with an + imperative verb. Examples: "net: add localAddress and localPort + to Socket", "src: fix typos in node_lttng_provider.h" + - be meaningful; it is what other people see when they + run `git shortlog` or `git log --oneline`.
+ Check the output of `git log --oneline files/you/changed` to find out + what subsystem (or subsystems) your changes touch 2. Keep the second line blank. 3. Wrap all other lines at 72 columns. + - If your patch fixes an open issue, you can add a reference to it at the end + of the log. Use the `Fixes:` prefix and the full issue URL. For other references + use `Refs:`. For example: + ```txt + Fixes: https://github.com/nodejs/node/issues/1337 + Refs: http://eslint.org/docs/rules/space-in-parens.html + Refs: https://github.com/nodejs/node/pull/3615 + ``` A good commit log can look something like this: @@ -123,22 +136,9 @@ The body of the commit message can be several paragraphs, and please do proper word-wrap and keep columns shorter than about 72 characters or so. That way, `git log` will show things nicely even when it is indented. -``` - -The header line should be meaningful; it is what other people see when they -run `git shortlog` or `git log --oneline`. - -Check the output of `git log --oneline files_that_you_changed` to find out -what subsystem (or subsystems) your changes touch. -If your patch fixes an open issue, you can add a reference to it at the end -of the log. Use the `Fixes:` prefix and the full issue URL. For other references -use `Refs:`. For example: - -```txt Fixes: https://github.com/nodejs/node/issues/1337 Refs: http://eslint.org/docs/rules/space-in-parens.html -Refs: https://github.com/nodejs/node/pull/3615 ``` ### Step 4: Rebase @@ -203,9 +203,6 @@ core modules. $ git push origin my-branch ``` -Go to https://github.com/yourusername/node and select your branch. -Click the 'Pull Request' button and fill out the form. - Pull requests are usually reviewed within a few days. ### Step 7: Discuss and update diff --git a/Makefile b/Makefile index f3b41f6c0bd18e..a0323f6c81162e 100644 --- a/Makefile +++ b/Makefile @@ -204,6 +204,9 @@ test-parallel: all test-valgrind: all $(PYTHON) tools/test.py --mode=release --valgrind sequential parallel message +test-check-deopts: all + $(PYTHON) tools/test.py --mode=release --check-deopts parallel sequential -J + # Implicitly depends on $(NODE_EXE). We don't depend on it explicitly because # it always triggers a rebuild due to it being a .PHONY rule. See the comment # near the build-addons rule for more background. @@ -809,10 +812,12 @@ bench: bench-net bench-http bench-fs bench-tls bench-ci: bench jslint: + @echo "Running JS linter..." $(NODE) tools/eslint/bin/eslint.js --cache --rulesdir=tools/eslint-rules \ benchmark lib test tools jslint-ci: + @echo "Running JS linter..." $(NODE) tools/jslint.js $(PARALLEL_ARGS) -f tap -o test-eslint.tap \ benchmark lib test tools @@ -836,11 +841,16 @@ CPPLINT_FILES = $(filter-out $(CPPLINT_EXCLUDE), $(wildcard \ )) cpplint: + @echo "Running C++ linter..." @$(PYTHON) tools/cpplint.py $(CPPLINT_FILES) @$(PYTHON) tools/check-imports.py ifneq ("","$(wildcard tools/eslint/lib/eslint.js)") -lint: jslint cpplint +lint: + @EXIT_STATUS=0 ; \ + $(MAKE) jslint || EXIT_STATUS=$$? ; \ + $(MAKE) cpplint || EXIT_STATUS=$$? ; \ + exit $$EXIT_STATUS CONFLICT_RE=^>>>>>>> [0-9A-Fa-f]+|^<<<<<<< [A-Za-z]+ lint-ci: jslint-ci cpplint @if ! ( grep -IEqrs "$(CONFLICT_RE)" benchmark deps doc lib src test tools ) \ diff --git a/README.md b/README.md index fd1b4a6a98b2fa..2442dcefa0f376 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@

- Node.js + + Node.js +

@@ -14,8 +16,9 @@ open source libraries in the world. The Node.js project is supported by the [Node.js Foundation](https://nodejs.org/en/foundation/). Contributions, policies, and releases are managed under an -[open governance model](./GOVERNANCE.md). We are also bound by a -[Code of Conduct](./CODE_OF_CONDUCT.md). +[open governance model](./GOVERNANCE.md). + +**This project is bound by a [Code of Conduct][].** If you need help using or installing Node.js, please use the [nodejs/help](https://github.com/nodejs/help) issue tracker. @@ -229,8 +232,10 @@ more information about the governance of the Node.js project, see **Andras** <andras@kinvey.com> * [AndreasMadsen](https://github.com/AndreasMadsen) - **Andreas Madsen** <amwebdk@gmail.com> (he/him) +* [AnnaMag](https://github.com/AnnaMag) - +**Anna M. Kedzierska** <anna.m.kedzierska@gmail.com> * [aqrln](https://github.com/aqrln) - -**Alexey Orlenko** <eaglexrlnk@gmail.com> +**Alexey Orlenko** <eaglexrlnk@gmail.com> (he/him) * [bengl](https://github.com/bengl) - **Bryan English** <bryan@bryanenglish.com> (he/him) * [benjamingr](https://github.com/benjamingr) - @@ -249,6 +254,8 @@ more information about the governance of the Node.js project, see **Claudio Rodriguez** <cjrodr@yahoo.com> * [danbev](https://github.com/danbev) - **Daniel Bevenius** <daniel.bevenius@gmail.com> +* [DavidCai1993](https://github.com/DavidCai1993) - +**David Cai** <davidcai1993@yahoo.com> (he/him) * [edsadr](https://github.com/edsadr) - **Adrian Estrada** <edsadr@gmail.com> (he/him) * [eljefedelrodeodeljefe](https://github.com/eljefedelrodeodeljefe) - @@ -279,6 +286,8 @@ more information about the governance of the Node.js project, see **Johan Bergström** <bugs@bergstroem.nu> * [jhamhader](https://github.com/jhamhader) - **Yuval Brik** <yuval@brik.org.il> +* [jkrems](https://github.com/jkrems) - +**Jan Krems** <jan.krems@gmail.com> (he/him) * [joaocgreis](https://github.com/joaocgreis) - **João Reis** <reis@janeasystems.com> * [joshgav](https://github.com/joshgav) - @@ -293,6 +302,8 @@ more information about the governance of the Node.js project, see **Lance Ball** <lball@redhat.com> * [lpinca](https://github.com/lpinca) - **Luigi Pinca** <luigipinca@gmail.com> (he/him) +* [lucamaraschi](https://github.com/lucamaraschi) - +**Luca Maraschi** <luca.maraschi@gmail.com> (he/him) * [lxe](https://github.com/lxe) - **Aleksey Smolenchuk** <lxe@lxe.co> * [matthewloring](https://github.com/matthewloring) - @@ -439,3 +450,4 @@ Information on the current Node.js Working Groups can be found in the [Node.js Moderation Policy]: https://github.com/nodejs/TSC/blob/master/Moderation-Policy.md [#node.js on chat.freenode.net]: https://webchat.freenode.net?channels=node.js&uio=d4 [#node-dev on chat.freenode.net]: https://webchat.freenode.net?channels=node-dev&uio=d4 +[Code of Conduct]: https://github.com/nodejs/TSC/blob/master/CODE_OF_CONDUCT.md diff --git a/benchmark/_cli.js b/benchmark/_cli.js index 17718c4c4d757a..4d92b05b1b82b4 100644 --- a/benchmark/_cli.js +++ b/benchmark/_cli.js @@ -88,6 +88,8 @@ CLI.prototype.benchmarks = function() { const filter = this.optional.filter || false; for (const category of this.items) { + if (benchmarks[category] === undefined) + continue; for (const scripts of benchmarks[category]) { if (filter && scripts.lastIndexOf(filter) === -1) continue; diff --git a/benchmark/buffers/buffer-indexof-number.js b/benchmark/buffers/buffer-indexof-number.js new file mode 100644 index 00000000000000..2e6e10b9f33d40 --- /dev/null +++ b/benchmark/buffers/buffer-indexof-number.js @@ -0,0 +1,23 @@ +'use strict'; +const common = require('../common.js'); +const fs = require('fs'); +const path = require('path'); + +const bench = common.createBenchmark(main, { + value: ['@'.charCodeAt(0)], + n: [1e7] +}); + +function main(conf) { + const n = +conf.n; + const search = +conf.value; + const aliceBuffer = fs.readFileSync( + path.resolve(__dirname, '../fixtures/alice.html') + ); + + bench.start(); + for (var i = 0; i < n; i++) { + aliceBuffer.indexOf(search, 0, undefined); + } + bench.end(n); +} diff --git a/benchmark/buffers/buffer-write-string.js b/benchmark/buffers/buffer-write-string.js new file mode 100644 index 00000000000000..927aa0b68466ef --- /dev/null +++ b/benchmark/buffers/buffer-write-string.js @@ -0,0 +1,70 @@ +'use strict'; + +const common = require('../common.js'); +const bench = common.createBenchmark(main, { + encoding: [ + '', 'utf8', 'ascii', 'hex', 'UCS-2', 'utf16le', 'latin1', 'binary' + ], + args: [ '', 'offset', 'offset+length' ], + len: [10, 2048], + n: [1e7] +}); + +function main(conf) { + const len = +conf.len; + const n = +conf.n; + const encoding = conf.encoding; + const args = conf.args; + + const string = 'a'.repeat(len); + const buf = Buffer.allocUnsafe(len); + + var i; + + switch (args) { + case 'offset': + if (encoding) { + bench.start(); + for (i = 0; i < n; ++i) { + buf.write(string, 0, encoding); + } + bench.end(n); + } else { + bench.start(); + for (i = 0; i < n; ++i) { + buf.write(string, 0); + } + bench.end(n); + } + break; + case 'offset+length': + if (encoding) { + bench.start(); + for (i = 0; i < n; ++i) { + buf.write(string, 0, buf.length, encoding); + } + bench.end(n); + } else { + bench.start(); + for (i = 0; i < n; ++i) { + buf.write(string, 0, buf.length); + } + bench.end(n); + } + break; + default: + if (encoding) { + bench.start(); + for (i = 0; i < n; ++i) { + buf.write(string, encoding); + } + bench.end(n); + } else { + bench.start(); + for (i = 0; i < n; ++i) { + buf.write(string); + } + bench.end(n); + } + } +} diff --git a/benchmark/child_process/child-process-exec-stdout.js b/benchmark/child_process/child-process-exec-stdout.js index 7b93aacff8532d..257a1424927000 100644 --- a/benchmark/child_process/child-process-exec-stdout.js +++ b/benchmark/child_process/child-process-exec-stdout.js @@ -10,7 +10,8 @@ const bench = common.createBenchmark(main, { dur: [5] }); -const exec = require('child_process').exec; +const child_process = require('child_process'); +const exec = child_process.exec; function main(conf) { bench.start(); @@ -28,7 +29,12 @@ function main(conf) { }); setTimeout(function() { - child.kill(); bench.end(bytes); + if (process.platform === 'win32') { + // Sometimes there's a yes.exe process left hanging around on Windows... + child_process.execSync(`taskkill /f /t /pid ${child.pid}`); + } else { + child.kill(); + } }, dur * 1000); } diff --git a/benchmark/child_process/child-process-read.js b/benchmark/child_process/child-process-read.js index b0128eb7969056..6fce35410eeb48 100644 --- a/benchmark/child_process/child-process-read.js +++ b/benchmark/child_process/child-process-read.js @@ -19,7 +19,7 @@ function main(conf) { const dur = +conf.dur; const len = +conf.len; - const msg = '"' + Array(len).join('.') + '"'; + const msg = `"${'.'.repeat(len)}"`; const options = { 'stdio': ['ignore', 'pipe', 'ignore'] }; const child = spawn('yes', [msg], options); diff --git a/benchmark/child_process/spawn-echo.js b/benchmark/child_process/spawn-echo.js index 7c9e851aacb641..72822f87db8aba 100644 --- a/benchmark/child_process/spawn-echo.js +++ b/benchmark/child_process/spawn-echo.js @@ -1,15 +1,15 @@ 'use strict'; var common = require('../common.js'); var bench = common.createBenchmark(main, { - thousands: [1] + n: [1000] }); var spawn = require('child_process').spawn; function main(conf) { - var len = +conf.thousands * 1000; + var n = +conf.n; bench.start(); - go(len, len); + go(n, n); } function go(n, left) { diff --git a/benchmark/common.js b/benchmark/common.js index 77ebe0bd1dc37f..50c8e21244fb45 100644 --- a/benchmark/common.js +++ b/benchmark/common.js @@ -43,7 +43,7 @@ Benchmark.prototype._parseArgs = function(argv, configs) { // Parse configuration arguments for (const arg of argv) { const match = arg.match(/^(.+?)=([\s\S]*)$/); - if (!match || !match[1]) { + if (!match) { console.error('bad argument: ' + arg); process.exit(1); } diff --git a/benchmark/compare.js b/benchmark/compare.js index a671bc9f3d7be6..4d183a10e2b97d 100644 --- a/benchmark/compare.js +++ b/benchmark/compare.js @@ -35,7 +35,7 @@ const runs = cli.optional.runs ? parseInt(cli.optional.runs, 10) : 30; const benchmarks = cli.benchmarks(); if (benchmarks.length === 0) { - console.error('no benchmarks found'); + console.error('No benchmarks found'); process.exitCode = 1; return; } diff --git a/benchmark/es/string-concatenations.js b/benchmark/es/string-concatenations.js new file mode 100644 index 00000000000000..8bdaefa4da7560 --- /dev/null +++ b/benchmark/es/string-concatenations.js @@ -0,0 +1,69 @@ +'use strict'; + +const common = require('../common.js'); + +const configs = { + n: [1e3], + mode: [ + 'multi-concat', + 'multi-join', + 'multi-template', + 'to-string-string', + 'to-string-concat', + 'to-string-template', + ], +}; + +const bench = common.createBenchmark(main, configs); + + +function main(conf) { + const n = +conf.n; + const mode = conf.mode; + + const str = 'abc'; + const num = 123; + + let string; + + switch (mode) { + case 'multi-concat': + bench.start(); + for (let i = 0; i < n; i++) + string = '...' + str + ', ' + num + ', ' + str + ', ' + num + '.'; + bench.end(n); + break; + case 'multi-join': + bench.start(); + for (let i = 0; i < n; i++) + string = ['...', str, ', ', num, ', ', str, ', ', num, '.'].join(''); + bench.end(n); + break; + case 'multi-template': + bench.start(); + for (let i = 0; i < n; i++) + string = `...${str}, ${num}, ${str}, ${num}.`; + bench.end(n); + break; + case 'to-string-string': + bench.start(); + for (let i = 0; i < n; i++) + string = String(num); + bench.end(n); + break; + case 'to-string-concat': + bench.start(); + for (let i = 0; i < n; i++) + string = '' + num; + bench.end(n); + break; + case 'to-string-template': + bench.start(); + for (let i = 0; i < n; i++) + string = `${num}`; + bench.end(n); + break; + } + + return string; +} diff --git a/benchmark/http/_chunky_http_client.js b/benchmark/http/_chunky_http_client.js index d4d60ac84d1796..d9e906927e1ce0 100644 --- a/benchmark/http/_chunky_http_client.js +++ b/benchmark/http/_chunky_http_client.js @@ -20,7 +20,7 @@ function main(conf) { // Chose 7 because 9 showed "Connection error" / "Connection closed" // An odd number could result in a better length dispersion. for (var i = 7; i <= 7 * 7 * 7; i *= 7) - headers.push(Array(i + 1).join('o')); + headers.push('o'.repeat(i)); function WriteHTTPHeaders(channel, has_keep_alive, extra_header_count) { todo = []; diff --git a/benchmark/net/tcp-raw-pipe.js b/benchmark/net/tcp-raw-pipe.js index 0501d13f00c7f9..77d3553062ddae 100644 --- a/benchmark/net/tcp-raw-pipe.js +++ b/benchmark/net/tcp-raw-pipe.js @@ -97,8 +97,6 @@ function client() { if (err) fail(err, 'connect'); - clientHandle.readStart(); - clientHandle.onread = function(nread, buffer) { if (nread < 0) fail(nread, 'read'); @@ -112,6 +110,8 @@ function client() { bench.start(); + clientHandle.readStart(); + setTimeout(function() { // multiply by 2 since we're sending it first one way // then then back again. diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js index 86714df6c196a7..b4a80af4e5eabd 100644 --- a/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js +++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js @@ -7,7 +7,7 @@ const inputs = require('../fixtures/url-inputs.js').searchParams; const bench = common.createBenchmark(main, { type: Object.keys(inputs), method: ['legacy', 'whatwg'], - n: [1e5] + n: [1e6] }); function useLegacy(n, input) { diff --git a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js index 7e56b5fba6e4f8..2b8d2c36a810b3 100644 --- a/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js +++ b/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js @@ -7,7 +7,7 @@ const inputs = require('../fixtures/url-inputs.js').searchParams; const bench = common.createBenchmark(main, { type: Object.keys(inputs), method: ['legacy', 'whatwg'], - n: [1e5] + n: [1e6] }); function useLegacy(n, input, prop) { diff --git a/benchmark/url/url-searchparams-read.js b/benchmark/url/url-searchparams-read.js index 94ddaf1cfa4072..762ffcca03d69d 100644 --- a/benchmark/url/url-searchparams-read.js +++ b/benchmark/url/url-searchparams-read.js @@ -5,7 +5,7 @@ const { URLSearchParams } = require('url'); const bench = common.createBenchmark(main, { method: ['get', 'getAll', 'has'], param: ['one', 'two', 'three', 'nonexistent'], - n: [1e6] + n: [2e7] }); const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd'; diff --git a/benchmark/url/whatwg-url-properties.js b/benchmark/url/whatwg-url-properties.js index 9bdc9778a8c922..3a865d2335ab3c 100644 --- a/benchmark/url/whatwg-url-properties.js +++ b/benchmark/url/whatwg-url-properties.js @@ -8,7 +8,7 @@ const bench = common.createBenchmark(main, { prop: ['href', 'origin', 'protocol', 'username', 'password', 'host', 'hostname', 'port', 'pathname', 'search', 'searchParams', 'hash'], - n: [1e4] + n: [3e5] }); function setAndGet(n, url, prop, alternative) { diff --git a/benchmark/v8/get-stats.js b/benchmark/v8/get-stats.js new file mode 100644 index 00000000000000..34d52d039f8bfa --- /dev/null +++ b/benchmark/v8/get-stats.js @@ -0,0 +1,23 @@ +'use strict'; + +const common = require('../common.js'); +const v8 = require('v8'); + +const bench = common.createBenchmark(main, { + method: [ + 'getHeapStatistics', + 'getHeapSpaceStatistics' + ], + n: [1e6], + flags: ['--ignition --turbo', ''] +}); + +function main(conf) { + const n = +conf.n; + const method = conf.method; + var i = 0; + bench.start(); + for (; i < n; i++) + v8[method](); + bench.end(n); +} diff --git a/common.gypi b/common.gypi index 147cc70fa5d5df..224498b4310ea8 100644 --- a/common.gypi +++ b/common.gypi @@ -38,6 +38,8 @@ ['OS == "win"', { 'os_posix': 0, 'v8_postmortem_support%': 'false', + 'OBJ_DIR': '<(PRODUCT_DIR)/obj', + 'V8_BASE': '<(PRODUCT_DIR)/lib/v8_libbase.lib', }, { 'os_posix': 1, 'v8_postmortem_support%': 'true', @@ -51,8 +53,8 @@ 'OBJ_DIR': '<(PRODUCT_DIR)/obj', 'V8_BASE': '<(PRODUCT_DIR)/obj/deps/v8/src/libv8_base.a', }, { - 'OBJ_DIR': '<(PRODUCT_DIR)/obj.target', - 'V8_BASE': '<(PRODUCT_DIR)/obj.target/deps/v8/src/libv8_base.a', + 'OBJ_DIR%': '<(PRODUCT_DIR)/obj.target', + 'V8_BASE%': '<(PRODUCT_DIR)/obj.target/deps/v8/src/libv8_base.a', }], ], }], diff --git a/configure b/configure index 06ccb26e9be2ab..81131f94e958e0 100755 --- a/configure +++ b/configure @@ -1370,8 +1370,7 @@ if options.prefix: config = '\n'.join(map('='.join, config.iteritems())) + '\n' -write('config.mk', - '# Do not edit. Generated by the configure script.\n' + config) +write('config.mk', do_not_edit + config) gyp_args = [sys.executable, 'tools/gyp_node.py', '--no-parallel'] diff --git a/deps/npm/node_modules/request/node_modules/form-data/README.md b/deps/npm/node_modules/request/node_modules/form-data/README.md deleted file mode 100644 index 642a9d14a800b7..00000000000000 --- a/deps/npm/node_modules/request/node_modules/form-data/README.md +++ /dev/null @@ -1,217 +0,0 @@ -# Form-Data [![NPM Module](https://img.shields.io/npm/v/form-data.svg)](https://www.npmjs.com/package/form-data) [![Join the chat at https://gitter.im/form-data/form-data](http://form-data.github.io/images/gitterbadge.svg)](https://gitter.im/form-data/form-data) - -A library to create readable ```"multipart/form-data"``` streams. Can be used to submit forms and file uploads to other web applications. - -The API of this library is inspired by the [XMLHttpRequest-2 FormData Interface][xhr2-fd]. - -[xhr2-fd]: http://dev.w3.org/2006/webapi/XMLHttpRequest-2/Overview.html#the-formdata-interface - -[![Linux Build](https://img.shields.io/travis/form-data/form-data/v2.1.2.svg?label=linux:0.12-6.x)](https://travis-ci.org/form-data/form-data) -[![MacOS Build](https://img.shields.io/travis/form-data/form-data/v2.1.2.svg?label=macos:0.12-6.x)](https://travis-ci.org/form-data/form-data) -[![Windows Build](https://img.shields.io/appveyor/ci/alexindigo/form-data/v2.1.2.svg?label=windows:0.12-6.x)](https://ci.appveyor.com/project/alexindigo/form-data) - -[![Coverage Status](https://img.shields.io/coveralls/form-data/form-data/v2.1.2.svg?label=code+coverage)](https://coveralls.io/github/form-data/form-data?branch=master) -[![Dependency Status](https://img.shields.io/david/form-data/form-data.svg)](https://david-dm.org/form-data/form-data) -[![bitHound Overall Score](https://www.bithound.io/github/form-data/form-data/badges/score.svg)](https://www.bithound.io/github/form-data/form-data) - -## Install - -``` -npm install --save form-data -``` - -## Usage - -In this example we are constructing a form with 3 fields that contain a string, -a buffer and a file stream. - -``` javascript -var FormData = require('form-data'); -var fs = require('fs'); - -var form = new FormData(); -form.append('my_field', 'my value'); -form.append('my_buffer', new Buffer(10)); -form.append('my_file', fs.createReadStream('/foo/bar.jpg')); -``` - -Also you can use http-response stream: - -``` javascript -var FormData = require('form-data'); -var http = require('http'); - -var form = new FormData(); - -http.request('http://nodejs.org/images/logo.png', function(response) { - form.append('my_field', 'my value'); - form.append('my_buffer', new Buffer(10)); - form.append('my_logo', response); -}); -``` - -Or @mikeal's [request](https://github.com/request/request) stream: - -``` javascript -var FormData = require('form-data'); -var request = require('request'); - -var form = new FormData(); - -form.append('my_field', 'my value'); -form.append('my_buffer', new Buffer(10)); -form.append('my_logo', request('http://nodejs.org/images/logo.png')); -``` - -In order to submit this form to a web application, call ```submit(url, [callback])``` method: - -``` javascript -form.submit('http://example.org/', function(err, res) { - // res – response object (http.IncomingMessage) // - res.resume(); -}); - -``` - -For more advanced request manipulations ```submit()``` method returns ```http.ClientRequest``` object, or you can choose from one of the alternative submission methods. - -### Alternative submission methods - -You can use node's http client interface: - -``` javascript -var http = require('http'); - -var request = http.request({ - method: 'post', - host: 'example.org', - path: '/upload', - headers: form.getHeaders() -}); - -form.pipe(request); - -request.on('response', function(res) { - console.log(res.statusCode); -}); -``` - -Or if you would prefer the `'Content-Length'` header to be set for you: - -``` javascript -form.submit('example.org/upload', function(err, res) { - console.log(res.statusCode); -}); -``` - -To use custom headers and pre-known length in parts: - -``` javascript -var CRLF = '\r\n'; -var form = new FormData(); - -var options = { - header: CRLF + '--' + form.getBoundary() + CRLF + 'X-Custom-Header: 123' + CRLF + CRLF, - knownLength: 1 -}; - -form.append('my_buffer', buffer, options); - -form.submit('http://example.com/', function(err, res) { - if (err) throw err; - console.log('Done'); -}); -``` - -Form-Data can recognize and fetch all the required information from common types of streams (```fs.readStream```, ```http.response``` and ```mikeal's request```), for some other types of streams you'd need to provide "file"-related information manually: - -``` javascript -someModule.stream(function(err, stdout, stderr) { - if (err) throw err; - - var form = new FormData(); - - form.append('file', stdout, { - filename: 'unicycle.jpg', - contentType: 'image/jpg', - knownLength: 19806 - }); - - form.submit('http://example.com/', function(err, res) { - if (err) throw err; - console.log('Done'); - }); -}); -``` - -For edge cases, like POST request to URL with query string or to pass HTTP auth credentials, object can be passed to `form.submit()` as first parameter: - -``` javascript -form.submit({ - host: 'example.com', - path: '/probably.php?extra=params', - auth: 'username:password' -}, function(err, res) { - console.log(res.statusCode); -}); -``` - -In case you need to also send custom HTTP headers with the POST request, you can use the `headers` key in first parameter of `form.submit()`: - -``` javascript -form.submit({ - host: 'example.com', - path: '/surelynot.php', - headers: {'x-test-header': 'test-header-value'} -}, function(err, res) { - console.log(res.statusCode); -}); -``` - -### Integration with other libraries - -#### Request - -Form submission using [request](https://github.com/request/request): - -```javascript -var formData = { - my_field: 'my_value', - my_file: fs.createReadStream(__dirname + '/unicycle.jpg'), -}; - -request.post({url:'http://service.com/upload', formData: formData}, function(err, httpResponse, body) { - if (err) { - return console.error('upload failed:', err); - } - console.log('Upload successful! Server responded with:', body); -}); -``` - -For more details see [request readme](https://github.com/request/request#multipartform-data-multipart-form-uploads). - -#### node-fetch - -You can also submit a form using [node-fetch](https://github.com/bitinn/node-fetch): - -```javascript -var form = new FormData(); - -form.append('a', 1); - -fetch('http://example.com', { method: 'POST', body: form }) - .then(function(res) { - return res.json(); - }).then(function(json) { - console.log(json); - }); -``` - -## Notes - -- ```getLengthSync()``` method DOESN'T calculate length for streams, use ```knownLength``` options as workaround. -- Starting version `2.x` FormData has dropped support for `node@0.10.x`. - -## License - -Form-Data is released under the [MIT](License) license. diff --git a/deps/v8/src/builtins/builtins-object.cc b/deps/v8/src/builtins/builtins-object.cc index 671397d9eacd11..53de00338ae4db 100644 --- a/deps/v8/src/builtins/builtins-object.cc +++ b/deps/v8/src/builtins/builtins-object.cc @@ -300,10 +300,10 @@ void Builtins::Generate_ObjectProtoToString(CodeStubAssembler* assembler) { Node* context = assembler->Parameter(3); assembler->GotoIf( - assembler->Word32Equal(receiver, assembler->UndefinedConstant()), + assembler->WordEqual(receiver, assembler->UndefinedConstant()), &return_undefined); - assembler->GotoIf(assembler->Word32Equal(receiver, assembler->NullConstant()), + assembler->GotoIf(assembler->WordEqual(receiver, assembler->NullConstant()), &return_null); assembler->GotoIf(assembler->WordIsSmi(receiver), &return_number); diff --git a/deps/v8/src/crankshaft/hydrogen-gvn.cc b/deps/v8/src/crankshaft/hydrogen-gvn.cc index e6ddd7526bc448..bf51bad4bb4c43 100644 --- a/deps/v8/src/crankshaft/hydrogen-gvn.cc +++ b/deps/v8/src/crankshaft/hydrogen-gvn.cc @@ -5,6 +5,8 @@ #include "src/crankshaft/hydrogen-gvn.h" #include "src/crankshaft/hydrogen.h" +#include "src/list.h" +#include "src/list-inl.h" #include "src/v8.h" namespace v8 { @@ -650,19 +652,23 @@ SideEffects HGlobalValueNumberingPhase::CollectSideEffectsOnPathsToDominatedBlock( HBasicBlock* dominator, HBasicBlock* dominated) { SideEffects side_effects; - for (int i = 0; i < dominated->predecessors()->length(); ++i) { - HBasicBlock* block = dominated->predecessors()->at(i); - if (dominator->block_id() < block->block_id() && - block->block_id() < dominated->block_id() && - !visited_on_paths_.Contains(block->block_id())) { - visited_on_paths_.Add(block->block_id()); - side_effects.Add(block_side_effects_[block->block_id()]); - if (block->IsLoopHeader()) { - side_effects.Add(loop_side_effects_[block->block_id()]); + List blocks; + for (;;) { + for (int i = 0; i < dominated->predecessors()->length(); ++i) { + HBasicBlock* block = dominated->predecessors()->at(i); + if (dominator->block_id() < block->block_id() && + block->block_id() < dominated->block_id() && + !visited_on_paths_.Contains(block->block_id())) { + visited_on_paths_.Add(block->block_id()); + side_effects.Add(block_side_effects_[block->block_id()]); + if (block->IsLoopHeader()) { + side_effects.Add(loop_side_effects_[block->block_id()]); + } + blocks.Add(block); } - side_effects.Add(CollectSideEffectsOnPathsToDominatedBlock( - dominator, block)); } + if (blocks.is_empty()) break; + dominated = blocks.RemoveLast(); } return side_effects; } diff --git a/deps/v8/src/objects-body-descriptors.h b/deps/v8/src/objects-body-descriptors.h index 91cb8883be8873..a1c3634bd762d7 100644 --- a/deps/v8/src/objects-body-descriptors.h +++ b/deps/v8/src/objects-body-descriptors.h @@ -99,7 +99,7 @@ class FixedBodyDescriptor final : public BodyDescriptorBase { template static inline void IterateBody(HeapObject* obj, int object_size) { - IterateBody(obj); + IterateBody(obj); } }; diff --git a/deps/v8/src/objects-inl.h b/deps/v8/src/objects-inl.h index af1261538e2b55..2549a2ac244c18 100644 --- a/deps/v8/src/objects-inl.h +++ b/deps/v8/src/objects-inl.h @@ -39,6 +39,27 @@ namespace v8 { namespace internal { +template +uint32_t HashTable::Hash(Key key) { + if (Shape::UsesSeed) { + return Shape::SeededHash(key, GetHeap()->HashSeed()); + } else { + return Shape::Hash(key); + } +} + + +template +uint32_t HashTable::HashForObject(Key key, + Object* object) { + if (Shape::UsesSeed) { + return Shape::SeededHashForObject(key, GetHeap()->HashSeed(), object); + } else { + return Shape::HashForObject(key, object); + } +} + + PropertyDetails::PropertyDetails(Smi* smi) { value_ = smi->value(); } diff --git a/deps/v8/src/objects.h b/deps/v8/src/objects.h index 1709cef15e8cd1..a3f9523e8ae9d0 100644 --- a/deps/v8/src/objects.h +++ b/deps/v8/src/objects.h @@ -3352,22 +3352,10 @@ class HashTable : public HashTableBase { public: typedef Shape ShapeT; - // Wrapper methods - inline uint32_t Hash(Key key) { - if (Shape::UsesSeed) { - return Shape::SeededHash(key, GetHeap()->HashSeed()); - } else { - return Shape::Hash(key); - } - } - - inline uint32_t HashForObject(Key key, Object* object) { - if (Shape::UsesSeed) { - return Shape::SeededHashForObject(key, GetHeap()->HashSeed(), object); - } else { - return Shape::HashForObject(key, object); - } - } + // Wrapper methods. Defined in src/objects-inl.h + // to break a cycle with src/heap/heap.h. + inline uint32_t Hash(Key key); + inline uint32_t HashForObject(Key key, Object* object); // Returns a new HashTable object. MUST_USE_RESULT static Handle New( diff --git a/deps/v8/src/v8.gyp b/deps/v8/src/v8.gyp index 9a3824742f4c07..ebf01e26d8b9ff 100644 --- a/deps/v8/src/v8.gyp +++ b/deps/v8/src/v8.gyp @@ -1708,7 +1708,7 @@ # When building Official, the .lib is too large and exceeds the 2G # limit. This breaks it into multiple pieces to avoid the limit. # See http://crbug.com/485155. - 'msvs_shard': 4, + 'msvs_shard': 10, }], ['component=="shared_library"', { 'defines': [ diff --git a/deps/v8/test/mjsunit/regress/regress-crbug-664506.js b/deps/v8/test/mjsunit/regress/regress-crbug-664506.js new file mode 100644 index 00000000000000..b0bf5e7591d4f4 --- /dev/null +++ b/deps/v8/test/mjsunit/regress/regress-crbug-664506.js @@ -0,0 +1,11 @@ +// Copyright 2016 the V8 project authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Flags: --expose-gc --predictable --random-seed=-1109634722 + +gc(); +gc(); +assertEquals("[object Object]", Object.prototype.toString.call({})); +gc(); +assertEquals("[object Array]", Object.prototype.toString.call([])); diff --git a/doc/api/buffer.md b/doc/api/buffer.md index 7ca33c0b8f14a7..44991d2673e978 100644 --- a/doc/api/buffer.md +++ b/doc/api/buffer.md @@ -42,7 +42,7 @@ const buf4 = Buffer.from([1, 2, 3]); const buf5 = Buffer.from('tést'); // Creates a Buffer containing Latin-1 bytes [0x74, 0xe9, 0x73, 0x74]. -const buf6 = Buffer.from('tést', 'latin-1'); +const buf6 = Buffer.from('tést', 'latin1'); ``` ## `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()` diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 4560e5d555a207..54327b8f012a27 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -101,7 +101,9 @@ bat.stderr.on('data', (data) => { bat.on('exit', (code) => { console.log(`Child exited with code ${code}`); }); +``` +```js // OR... const exec = require('child_process').exec; exec('my.bat', (err, stdout, stderr) => { @@ -184,14 +186,14 @@ The `options` argument may be passed as the second argument to customize how the process is spawned. The default options are: ```js -{ +const defaults = { encoding: 'utf8', timeout: 0, maxBuffer: 200*1024, killSignal: 'SIGTERM', cwd: null, env: null -} +}; ``` If `timeout` is greater than `0`, the parent will send the signal @@ -348,10 +350,10 @@ trigger arbitrary command execution.** A third argument may be used to specify additional options, with these defaults: ```js -{ +const defaults = { cwd: undefined, env: process.env -} +}; ``` Use `cwd` to specify the working directory from which the process is spawned. diff --git a/doc/api/console.md b/doc/api/console.md index 1398e3e5bc739e..e6a9d529cbc7f0 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -62,6 +62,9 @@ or `console.Console`: ```js const Console = require('console').Console; +``` + +```js const Console = console.Console; ``` diff --git a/doc/api/crypto.md b/doc/api/crypto.md index 957dff9975fa52..931e99d780f9d4 100644 --- a/doc/api/crypto.md +++ b/doc/api/crypto.md @@ -1584,6 +1584,66 @@ This should normally never take longer than a few milliseconds. The only time when generating the random bytes may conceivably block for a longer period of time is right after boot, when the whole system is still low on entropy. +### crypto.randomFillSync(buffer[, offset][, size]) + + +* `buffer` {Buffer|Uint8Array} Must be supplied. +* `offset` {number} Defaults to `0`. +* `size` {number} Defaults to `buffer.length - offset`. + +Synchronous version of [`crypto.randomFill()`][]. + +Returns `buffer` + +```js +const buf = Buffer.alloc(10); +console.log(crypto.randomFillSync(buf).toString('hex')); + +crypto.randomFillSync(buf, 5); +console.log(buf.toString('hex')); + +// The above is equivalent to the following: +crypto.randomFillSync(buf, 5, 5); +console.log(buf.toString('hex')); +``` + +### crypto.randomFill(buffer[, offset][, size], callback) + + +* `buffer` {Buffer|Uint8Array} Must be supplied. +* `offset` {number} Defaults to `0`. +* `size` {number} Defaults to `buffer.length - offset`. +* `callback` {Function} `function(err, buf) {}`. + +This function is similar to [`crypto.randomBytes()`][] but requires the first +argument to be a [`Buffer`][] that will be filled. It also +requires that a callback is passed in. + +If the `callback` function is not provided, an error will be thrown. + +```js +const buf = Buffer.alloc(10); +crypto.randomFill(buf, (err, buf) => { + if (err) throw err; + console.log(buf.toString('hex')); +}); + +crypto.randomFill(buf, 5, (err, buf) => { + if (err) throw err; + console.log(buf.toString('hex')); +}); + +// The above is equivalent to the following: +crypto.randomFill(buf, 5, 5, (err, buf) => { + if (err) throw err; + console.log(buf.toString('hex')); +}); +``` + ### crypto.setEngine(engine[, flags]) -- `hostname` {string} -- `rrtype` {string} +- `hostname` {string} Hostname to resolve. +- `rrtype` {string} Resource record type. Default: `'A'`. - `callback` {Function} - `err` {Error} - - `addresses` {string[] | Object[] | string[][] | Object} - -Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an -array of the record types specified by `rrtype`. - -Valid values for `rrtype` are: - - * `'A'` - IPV4 addresses, default - * `'AAAA'` - IPV6 addresses - * `'MX'` - mail exchange records - * `'TXT'` - text records - * `'SRV'` - SRV records - * `'PTR'` - PTR records - * `'NS'` - name server records - * `'CNAME'` - canonical name records - * `'SOA'` - start of authority record - * `'NAPTR'` - name authority pointer record - -The `callback` function has arguments `(err, addresses)`. When successful, -`addresses` will be an array, except when resolving an SOA record which returns -an object structured in the same manner as one returned by the -[`dns.resolveSoa()`][] method. The type of each item in `addresses` is -determined by the record type, and described in the documentation for the -corresponding lookup methods. - -On error, `err` is an [`Error`][] object, where `err.code` is -one of the error codes listed [here](#dns_error_codes). + - `records` {string[] | Object[] | string[][] | Object} + +Uses the DNS protocol to resolve a hostname (e.g. `'nodejs.org'`) into an array +of the resource records. The `callback` function has arguments +`(err, records)`. When successful, `records` will be an array of resource +records. The type and structure of individual results varies based on `rrtype`: + +| `rrtype` | `records` contains | Result type | Shorthand method | +|-----------|--------------------------------|-------------|--------------------------| +| `'A'` | IPv4 addresses (default) | {string} | [`dns.resolve4()`][] | +| `'AAAA'` | IPv6 addresses | {string} | [`dns.resolve6()`][] | +| `'CNAME'` | canonical name records | {string} | [`dns.resolveCname()`][] | +| `'MX'` | mail exchange records | {Object} | [`dns.resolveMx()`][] | +| `'NAPTR'` | name authority pointer records | {Object} | [`dns.resolveNaptr()`][] | +| `'NS'` | name server records | {string} | [`dns.resolveNs()`][] | +| `'PTR'` | pointer records | {string} | [`dns.resolvePtr()`][] | +| `'SOA'` | start of authority records | {Object} | [`dns.resolveSoa()`][] | +| `'SRV'` | service records | {Object} | [`dns.resolveSrv()`][] | +| `'TXT'` | text records | {string} | [`dns.resolveTxt()`][] | + +On error, `err` is an [`Error`][] object, where `err.code` is one of the +[DNS error codes](#dns_error_codes). ## dns.resolve4(hostname[, options], callback) ```js const fs = require('fs'); fs.readFile('a file that does not exist', (err, data) => { diff --git a/doc/api/fs.md b/doc/api/fs.md index 1b2a3c791532c0..1dbb16895b3a1d 100644 --- a/doc/api/fs.md +++ b/doc/api/fs.md @@ -217,7 +217,7 @@ synchronous counterparts are of this type. For a regular file [`util.inspect(stats)`][] would return a string very similar to this: -```js +```txt Stats { dev: 2114, ino: 48064969, @@ -630,13 +630,13 @@ default value of 64 kb for the same parameter. `options` is an object or string with the following defaults: ```js -{ +const defaults = { flags: 'r', encoding: null, fd: null, mode: 0o666, autoClose: true -} +}; ``` `options` can include `start` and `end` values to read a range of bytes from @@ -696,13 +696,13 @@ Returns a new [`WriteStream`][] object. (See [Writable Stream][]). `options` is an object or string with the following defaults: ```js -{ +const defaults = { flags: 'w', defaultEncoding: 'utf8', fd: null, mode: 0o666, autoClose: true -} +}; ``` `options` may also include a `start` option to allow writing data at @@ -1442,6 +1442,9 @@ changes: pr-url: https://github.com/nodejs/node/pull/7897 description: The `callback` parameter is no longer optional. Not passing it will emit a deprecation warning. + - version: v6.0.0 + pr-url: https://github.com/nodejs/node/pull/5616 + description: The `options` parameter was added. --> * `path` {string|Buffer} @@ -1913,7 +1916,7 @@ changes: * `persistent` {boolean} Indicates whether the process should continue to run as long as files are being watched. default = `true` * `recursive` {boolean} Indicates whether all subdirectories should be - watched, or only the current directory. The applies when a directory is + watched, or only the current directory. This applies when a directory is specified, and only on supported platforms (See [Caveats][]). default = `false` * `encoding` {string} Specifies the character encoding to be used for the diff --git a/doc/api/http.md b/doc/api/http.md index f9d3d1e52f99cc..e8a8770bb12ea4 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -1161,6 +1161,10 @@ it will switch to implicit header mode and flush the implicit headers. This sends a chunk of the response body. This method may be called multiple times to provide successive parts of the body. +Note that in the `http` module, the response body is omitted when the +request is a HEAD request. Similarly, the `204` and `304` responses +_must not_ include a message body. + `chunk` can be a string or a buffer. If `chunk` is a string, the second parameter specifies how to encode it into a byte stream. By default the `encoding` is `'utf8'`. `callback` will be called when this chunk diff --git a/doc/api/modules.md b/doc/api/modules.md index 65f57314ccd9f2..d40f25d0a99a58 100644 --- a/doc/api/modules.md +++ b/doc/api/modules.md @@ -558,7 +558,8 @@ object, it is common to also reassign `exports`, for example: ```js module.exports = exports = function Constructor() { - // ... etc. + // ... etc. +}; ``` To illustrate the behavior, imagine this hypothetical implementation of diff --git a/doc/api/net.md b/doc/api/net.md index 462835d6376134..db1c6eba351479 100644 --- a/doc/api/net.md +++ b/doc/api/net.md @@ -66,7 +66,7 @@ Returns an object with `port`, `family`, and `address` properties: Example: ```js -var server = net.createServer((socket) => { +const server = net.createServer((socket) => { socket.end('goodbye\n'); }).on('error', (err) => { // handle errors here @@ -211,7 +211,7 @@ double-backslashes, such as: ```js net.createServer().listen( - path.join('\\\\?\\pipe', process.cwd(), 'myctl')) + path.join('\\\\?\\pipe', process.cwd(), 'myctl')); ``` The parameter `backlog` behaves the same as in @@ -894,8 +894,8 @@ server.listen(8124, () => { Test this by using `telnet`: -```sh -telnet localhost 8124 +```console +$ telnet localhost 8124 ``` To listen on the socket `/tmp/echo.sock` the third line from the last would @@ -909,8 +909,8 @@ server.listen('/tmp/echo.sock', () => { Use `nc` to connect to a UNIX domain socket server: -```js -nc -U /tmp/echo.sock +```console +$ nc -U /tmp/echo.sock ``` ## net.isIP(input) diff --git a/doc/api/os.md b/doc/api/os.md index 06779dbb37cf70..3196efb5b0fc83 100644 --- a/doc/api/os.md +++ b/doc/api/os.md @@ -378,9 +378,8 @@ added: v0.3.3 The `os.uptime()` method returns the system uptime in number of seconds. -*Note*: Within Node.js' internals, this number is represented as a `double`. -However, fractional seconds are not returned and the value can typically be -treated as an integer. +*Note*: On Windows the returned value includes fractions of a second. +Use `Math.floor()` to get whole seconds. ## os.userInfo([options]) ```js const Readable = require('stream').Readable; diff --git a/doc/api/tls.md b/doc/api/tls.md index 94281dd3f00c28..ab252034415254 100644 --- a/doc/api/tls.md +++ b/doc/api/tls.md @@ -1224,7 +1224,7 @@ stream. `tls.TLSSocket()`. For example, the code: ```js -pair = tls.createSecurePair( ... ); +pair = tls.createSecurePair(/* ... */); pair.encrypted.pipe(socket); socket.pipe(pair.encrypted); ``` diff --git a/doc/api/url.md b/doc/api/url.md index aa33b554042ff6..4f940ae541c8dd 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -131,6 +131,56 @@ The `slashes` property is a `boolean` with a value of `true` if two ASCII forward-slash characters (`/`) are required following the colon in the `protocol`. +## url.domainToASCII(domain) + + +> Stability: 1 - Experimental + +* `domain` {string} +* Returns: {string} + +Returns the [Punycode][] ASCII serialization of the `domain`. If `domain` is an +invalid domain, the empty string is returned. + +It performs the inverse operation to [`url.domainToUnicode()`][]. + +```js +const url = require('url'); +console.log(url.domainToASCII('español.com')); + // Prints xn--espaol-zwa.com +console.log(url.domainToASCII('中文.com')); + // Prints xn--fiq228c.com +console.log(url.domainToASCII('xn--iñvalid.com')); + // Prints an empty string +``` + +## url.domainToUnicode(domain) + + +> Stability: 1 - Experimental + +* `domain` {string} +* Returns: {string} + +Returns the Unicode serialization of the `domain`. If `domain` is an invalid +domain, the empty string is returned. + +It performs the inverse operation to [`url.domainToASCII()`][]. + +```js +const url = require('url'); +console.log(url.domainToUnicode('xn--espaol-zwa.com')); + // Prints español.com +console.log(url.domainToUnicode('xn--fiq228c.com')); + // Prints 中文.com +console.log(url.domainToUnicode('xn--iñvalid.com')); + // Prints an empty string +``` + ## url.format(urlObject) > Stability: 1 - Experimental @@ -210,7 +263,7 @@ The formatting process operates as follows: fragment, `false` otherwise. Defaults to `true`. * `search` {boolean} `true` if the serialized URL string should include the search query, `false` otherwise. Defaults to `true`. - * `unicode` (Boolean) `true` if Unicode characters appearing in the host + * `unicode` {boolean} `true` if Unicode characters appearing in the host component of the URL string should be encoded directly as opposed to being Punycode encoded. Defaults to `false`. @@ -304,6 +357,9 @@ For example, the ASCII space character (`' '`) is encoded as `%20`. The ASCII forward slash (`/`) character is encoded as `%3C`. ## The WHATWG URL API + > Stability: 1 - Experimental @@ -691,9 +747,13 @@ console.log(JSON.stringify(myURLs)); ``` ### Class: URLSearchParams + The `URLSearchParams` API provides read and write access to the query of a -`URL`. +`URL`. The `URLSearchParams` class can also be used standalone with one of the +four following constructors. The WHATWG `URLSearchParams` interface and the [`querystring`][] module have similar purpose, but the purpose of the [`querystring`][] module is more @@ -701,7 +761,8 @@ general, as it allows the customization of delimiter characters (`&` and `=`). On the other hand, this API is designed purely for URL query strings. ```js -const URL = require('url').URL; +const { URL, URLSearchParams } = require('url'); + const myURL = new URL('https://example.org/?abc=123'); console.log(myURL.searchParams.get('abc')); // Prints 123 @@ -714,11 +775,131 @@ myURL.searchParams.delete('abc'); myURL.searchParams.set('a', 'b'); console.log(myURL.href); // Prints https://example.org/?a=b + +const newSearchParams = new URLSearchParams(myURL.searchParams); +// The above is equivalent to +// const newSearchParams = new URLSearchParams(myURL.search); + +newSearchParams.append('a', 'c'); +console.log(myURL.href); + // Prints https://example.org/?a=b +console.log(newSearchParams.toString()); + // Prints a=b&a=c + +// newSearchParams.toString() is implicitly called +myURL.search = newSearchParams; +console.log(myURL.href); + // Prints https://example.org/?a=b&a=c +newSearchParams.delete('a'); +console.log(myURL.href); + // Prints https://example.org/?a=b&a=c ``` -#### Constructor: new URLSearchParams([init]) +#### Constructor: new URLSearchParams() + +Instantiate a new empty `URLSearchParams` object. + +#### Constructor: new URLSearchParams(string) + +* `string` {string} A query string -* `init` {String} The URL query +Parse the `string` as a query string, and use it to instantiate a new +`URLSearchParams` object. A leading `'?'`, if present, is ignored. + +```js +const { URLSearchParams } = require('url'); +let params; + +params = new URLSearchParams('user=abc&query=xyz'); +console.log(params.get('user')); + // Prints 'abc' +console.log(params.toString()); + // Prints 'user=abc&query=xyz' + +params = new URLSearchParams('?user=abc&query=xyz'); +console.log(params.toString()); + // Prints 'user=abc&query=xyz' +``` + +#### Constructor: new URLSearchParams(obj) + + +* `obj` {Object} An object representing a collection of key-value pairs + +Instantiate a new `URLSearchParams` object with a query hash map. The key and +value of each property of `obj` are always coerced to strings. + +*Note*: Unlike [`querystring`][] module, duplicate keys in the form of array +values are not allowed. Arrays are stringified using [`array.toString()`][], +which simply joins all array elements with commas. + +```js +const { URLSearchParams } = require('url'); +const params = new URLSearchParams({ + user: 'abc', + query: ['first', 'second'] +}); +console.log(params.getAll('query')); + // Prints ['first,second'] +console.log(params.toString()); + // Prints 'user=abc&query=first%2Csecond' +``` + +#### Constructor: new URLSearchParams(iterable) + + +* `iterable` {Iterable} An iterable object whose elements are key-value pairs + +Instantiate a new `URLSearchParams` object with an iterable map in a way that +is similar to [`Map`][]'s constructor. `iterable` can be an Array or any +iterable object. That means `iterable` can be another `URLSearchParams`, in +which case the constructor will simply create a clone of the provided +`URLSearchParams`. Elements of `iterable` are key-value pairs, and can +themselves be any iterable object. + +Duplicate keys are allowed. + +```js +const { URLSearchParams } = require('url'); +let params; + +// Using an array +params = new URLSearchParams([ + ['user', 'abc'], + ['query', 'first'], + ['query', 'second'] +]); +console.log(params.toString()); + // Prints 'user=abc&query=first&query=second' + +// Using a Map object +const map = new Map(); +map.set('user', 'abc'); +map.set('query', 'xyz'); +params = new URLSearchParams(map); +console.log(params.toString()); + // Prints 'user=abc&query=xyz' + +// Using a generator function +function* getQueryPairs() { + yield ['user', 'abc']; + yield ['query', 'first']; + yield ['query', 'second']; +} +params = new URLSearchParams(getQueryPairs()); +console.log(params.toString()); + // Prints 'user=abc&query=first&query=second' + +// Each key-value pair must have exactly two elements +new URLSearchParams([ + ['user', 'abc', 'error'] +]); + // Throws TypeError: Each query pair must be a name/value tuple +``` #### urlSearchParams.append(name, value) @@ -829,6 +1010,9 @@ console.log(params.toString()); ``` #### urlSearchParams.sort() + Sort all existing name-value pairs in-place by their names. Sorting is done with a [stable sorting algorithm][], so relative order between name-value pairs @@ -877,52 +1061,6 @@ for (const [name, value] of params) { // xyz baz ``` -### require('url').domainToASCII(domain) - -* `domain` {string} -* Returns: {string} - -Returns the [Punycode][] ASCII serialization of the `domain`. If `domain` is an -invalid domain, the empty string is returned. - -It performs the inverse operation to [`require('url').domainToUnicode()`][]. - -```js -const url = require('url'); -console.log(url.domainToASCII('español.com')); - // Prints xn--espaol-zwa.com -console.log(url.domainToASCII('中文.com')); - // Prints xn--fiq228c.com -console.log(url.domainToASCII('xn--iñvalid.com')); - // Prints an empty string -``` - -*Note*: The `require('url').domainToASCII()` method is introduced as part of -the new `URL` implementation but is not part of the WHATWG URL standard. - -### require('url').domainToUnicode(domain) - -* `domain` {string} -* Returns: {string} - -Returns the Unicode serialization of the `domain`. If `domain` is an invalid -domain, the empty string is returned. - -It performs the inverse operation to [`require('url').domainToASCII()`][]. - -```js -const url = require('url'); -console.log(url.domainToUnicode('xn--espaol-zwa.com')); - // Prints español.com -console.log(url.domainToUnicode('xn--fiq228c.com')); - // Prints 中文.com -console.log(url.domainToUnicode('xn--iñvalid.com')); - // Prints an empty string -``` - -*Note*: The `require('url').domainToUnicode()` API is introduced as part of the -the new `URL` implementation but is not part of the WHATWG URL standard. - ### Percent-Encoding in the WHATWG URL Standard @@ -933,23 +1071,25 @@ located within the structure of the URL. The WHATWG URL Standard uses a more selective and fine grained approach to selecting encoded characters than that used by the older [`url.parse()`][] and [`url.format()`][] methods. -The WHATWG algorithm defines three "encoding sets" that describe ranges of -characters that must be percent-encoded: +The WHATWG algorithm defines three "percent-encode sets" that describe ranges +of characters that must be percent-encoded: -* The *simple encode set* includes code points in range U+0000 to U+001F - (inclusive) and all code points greater than U+007E. +* The *C0 control percent-encode set* includes code points in range U+0000 to + U+001F (inclusive) and all code points greater than U+007E. -* The *default encode set* includes the *simple encode set* and code points - U+0020, U+0022, U+0023, U+003C, U+003E, U+003F, U+0060, U+007B, and U+007D. +* The *path percent-encode set* includes the *C0 control percent-encode set* + and code points U+0020, U+0022, U+0023, U+003C, U+003E, U+003F, U+0060, + U+007B, and U+007D. -* The *userinfo encode set* includes the *default encode set* and code points - U+002F, U+003A, U+003B, U+003D, U+0040, U+005B, U+005C, U+005D, U+005E, and - U+007C. +* The *userinfo encode set* includes the *path percent-encode set* and code + points U+002F, U+003A, U+003B, U+003D, U+0040, U+005B, U+005C, U+005D, + U+005E, and U+007C. -The *simple encode set* is used primary for URL fragments and certain specific -conditions for the path. The *userinfo encode set* is used specifically for -username and passwords encoded within the URL. The *default encode set* is used -for all other cases. +The *userinfo percent-encode set* is used exclusively for username and +passwords encoded within the URL. The *path percent-encode set* is used for the +path of most URLs. The *C0 control percent-encode set* is used for all +other cases, including URL fragments in particular, but also host and path +under certain specific conditions. When non-ASCII characters appear within a hostname, the hostname is encoded using the [Punycode][] algorithm. Note, however, that a hostname *may* contain @@ -970,11 +1110,15 @@ console.log(myURL.origin); [`TypeError`]: errors.html#errors_class_typeerror [WHATWG URL Standard]: https://url.spec.whatwg.org/ [examples of parsed URLs]: https://url.spec.whatwg.org/#example-url-parsing +[`url.domainToASCII()`]: #url_url_domaintoascii_domain +[`url.domainToUnicode()`]: #url_url_domaintounicode_domain [`url.parse()`]: #url_url_parse_urlstring_parsequerystring_slashesdenotehost [`url.format()`]: #url_url_format_urlobject [`require('url').format()`]: #url_url_format_url_options [`url.toString()`]: #url_url_tostring [Punycode]: https://tools.ietf.org/html/rfc5891#section-4.4 +[`Map`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map +[`array.toString()`]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/toString [WHATWG URL]: #url_the_whatwg_url_api [`new URL()`]: #url_constructor_new_url_input_base [`url.href`]: #url_url_href @@ -983,8 +1127,6 @@ console.log(myURL.origin); [`URLSearchParams`]: #url_class_urlsearchparams [`urlSearchParams.entries()`]: #url_urlsearchparams_entries [`urlSearchParams@@iterator()`]: #url_urlsearchparams_iterator -[`require('url').domainToASCII()`]: #url_require_url_domaintoascii_domain -[`require('url').domainToUnicode()`]: #url_require_url_domaintounicode_domain [stable sorting algorithm]: https://en.wikipedia.org/wiki/Sorting_algorithm#Stability [`JSON.stringify()`]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify [`url.toJSON()`]: #url_url_tojson diff --git a/doc/api/util.md b/doc/api/util.md index 357811cc0fcdeb..8dcc1179381f84 100644 --- a/doc/api/util.md +++ b/doc/api/util.md @@ -135,6 +135,13 @@ Each argument is converted to a string using `util.inspect()`. util.format(1, 2, 3); // '1 2 3' ``` +If only one argument is passed to `util.format()`, it is returned as it is +without any formatting. + +```js +util.format('%% %s'); // '%% %s' +``` + ## util.inherits(constructor, superConstructor)