summaryrefslogtreecommitdiff
path: root/doc/api/util.md
AgeCommit message (Collapse)Author
2018-01-16util: change %o depth defaultRuben Bridgewater
Since the default for depth is changed to `Infinity` it is logical to change the %o default to the same as well. Using %o with `util.format` will now always print the whole object. PR-URL: https://github.com/nodejs/node/pull/17907 Refs: https://github.com/nodejs/node/issues/12693 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2018-01-16util: change util.inspect depth defaultRuben Bridgewater
The current default is not ideal in most use cases. Therefore it is changed to showing unlimited depth in case util.inspect is called directly. The default is kept as before for console.log and similar. Using console.dir will now show a depth of up to five and console.assert / console.trace will show a unlimited depth. PR-URL: https://github.com/nodejs/node/pull/17907 Refs: https://github.com/nodejs/node/issues/12693 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-12-21doc: warn about using util.inspect/util.formatJames M Snell
Because of the potential performance bottlenecks that may be introduced by `util.inspect()` and `util.format()` in production hot path code. Based on real user feedback, it is not obvious that these are intended to be debugging tools. PR-URL: https://github.com/nodejs/node/pull/17791 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-12-21util: fix custom inspect descriptionRuben Bridgewater
Using a custom inspect function on the inspected object is deprecated. Remove the reference from the option description to make sure the user will read about the deprecation in the more detailed description. PR-URL: https://github.com/nodejs/node/pull/17576 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-12-21util: add util.inspect compact optionRuben Bridgewater
The current default formatting is not ideal and this improves the situation by formatting the output more intuitiv. 1) All object keys are now indented by 2 characters instead of sometimes 2 and sometimes 3 characters. 2) Each object key will now use an individual line instead of sharing a line potentially with multiple object keys. 3) Long strings will now be split into multiple lines in case they exceed the "lineBreak" option length (including the current indentation). 4) Opening braces are now directly behind a object property instead of using a new line. 5) Switch inspect "base" order. In case the compact option is set to `false`, inspect will now print "[Function: foo] {\n property: 'data'\n}" instead of "{ [Function: foo]\n property: 'data'\n}". PR-URL: https://github.com/nodejs/node/pull/17576 Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-12-17doc: change "Node.js style cb" to "error-first cb"Ram Goli
Change the awkward "Node.js style callback" phrasing to the more informative "error-first callback." PR-URL: https://github.com/nodejs/node/pull/17638 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2017-12-15util: allow wildcards in NODE_DEBUG variableTyler
PR-URL: https://github.com/nodejs/node/pull/17609 Fixes: https://github.com/nodejs/node/issues/17605 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com>
2017-12-12doc: clearify promisify behavior for bad argumentsRam Goli
Currently the documentation states that promisify() will result in undefined behavior if bad arguments are passed. This is not necessarily the case, since the behavior is well defined, but just not useful. PR-URL: https://github.com/nodejs/node/pull/17593 Fixes: https://github.com/nodejs/node/issues/17569 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-12-12doc: clarify util.inspect usage intentGus Caplan
PR-URL: https://github.com/nodejs/node/pull/17375 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-12-06doc: use arrow functions in util.md sample codeMithun Sasidharan
PR-URL: https://github.com/nodejs/node/pull/17459 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-12-01util: use @@toStringTagGus Caplan
uses @@toStringTag when creating the "tag" for an inspected value PR-URL: https://github.com/nodejs/node/pull/16956 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Brian White <mscdex@mscdex.net> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-11-30doc,test: remove unnecessary await with return instancesRich Trott
Remove unnecessary `await` in combination with `return` in preparation for enabling lint rule. PR-URL: https://github.com/nodejs/node/pull/17265 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-11-28doc: fix typo occuring -> occurringLeko
PR-URL: https://github.com/nodejs/node/pull/17350 Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-26doc: replace function with arrow functionLeko
PR-URL: https://github.com/nodejs/node/pull/17304 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Ron Korving <ron@ronkorving.nl> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Jon Moss <me@jonathanmoss.me> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-11-16util: runtime deprecation for custom .inspect()Rich Trott
Change documentation-only deprecation for custom inspection using `object.inspect` property to a runtime deprecation. This is a breaking change. Custom inspection via `object.inspect` is deprecated because there is a more robust Symbol-based alternative to `.inspect` and the custom inspection via `object.inspect` feature means that people can accidentally break `console.log()` simply by attaching a `.inspect` property to their objects. Note that since this is a deprecation, the custom inspection will still work. The breaking change is simply the printing of a warning which could alarm users, break tests or other things that might be dependent on specific output, etc. PR-URL: https://github.com/nodejs/node/pull/16393 Ref: https://github.com/nodejs/node/issues/15549 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-16util: emit deprecation code only onceRich Trott
If another function has already emitted the deprecation warning with the same code as the warning that is about to be emitted, do not emit the warning. This is a breaking change. Previously, different functions could emit the same deprecation warning multiple times. This was a known bug rather than a feature, but this change is being treated as a breaking change out of caution. Identical deprecation warnings should not be emitted. PR-URL: https://github.com/nodejs/node/pull/16393 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-11-16doc: improve documentation for util.deprecate()Rich Trott
Improve documentation for `util.deprecate()`. In particular, provide complete function signature, document arguments, and document return value. PR-URL: https://github.com/nodejs/node/pull/16393 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-10-31doc: util.isDeepStrictEqual returns booleanLucas Azzola
PR-URL: https://github.com/nodejs/node/pull/16653 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
2017-10-312017-10-31, Version 9.0.0 (Current)James M Snell
* Older experimental APIs have been removed. [[`d731369b1d`](https://github.com/nodejs/node/commit/d731369b1d)] [#14414](https://github.com/nodejs/node/pull/14414) * **Errors** * Improvements have been made to `buffer` module error messages. * The assignment of static error codes to Node.js error continues: * `buffer` * `child_process` * `console` * `crypto` * `dns` * `events` * `fs` * `http` * `inspector` * `net` * `path` * `process` * `querystring` * `readline` * `repl` * `streams` * `string_decoder` * `timers` * `tls` * `url` * `util` * `v8` * `zlib` * **Child Processes** * Errors are emitted on process nextTick. * **Domains** * The long-deprecated `.dispose()` method has been removed. * **fs** * The `fs.ReadStream` and `fs.WriteStream` classes now use `destroy()`. * `fs` module callbacks are now invoked with an undefined context. * **HTTP/1** * A 400 Bad Request response will now be sent when parsing fails. * Socket timeout will be set when the socket connects. * A bug causing the request `'error'` event to fire twice was fixed. * HTTP clients may now use generic `Duplex` streams in addition to `net.Socket`. * **Intl** * The deprecated `Intl.v8BreakIterator` has been removed. * **Modules** * The `require.resolve()` method now supports using custom lookup paths. * **OS** * The `os.EOL` property is now read-only. * **Timers** * `setTimeout()` will emit a warning if the timeout is larger that the maximum 32-bit unsigned integer.
2017-10-25util,assert: expose util.isDeepStrictEqual()Rich Trott
Provide `util.isDeepStrictEqual()` that works like `assert.deepStrictEqual()` but returns a boolean rather than throwing an error. Several userland modules have needed this functionality and implemented it independently. This functionality already exists in Node.js core, so this exposes it for use by modules. Modules that have needed this functionality include `lodash`, `concordance` (used by `ava`), and `qunit`. PR-URL: https://github.com/nodejs/node/pull/16084 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-10-23util: graduate TextEncoder/TextDecoder, testsJames M Snell
Add tests ported from Web Platform Tests. Graduate TextEncoder / TextDecoder from experimental PR-URL: https://github.com/nodejs/node/pull/15743 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
2017-10-19doc: add return value to util.promisifySupamic
PR-URL: https://github.com/nodejs/node/pull/16040 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-10-13doc: clarify usage of util.promisify.customShiya Luo
PR-URL: https://github.com/nodejs/node/pull/16134 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-10-02util: deprecate obj.inspect for custom inspectionRich Trott
The existence of `obj.inspect()` for custom inspection can cause people to unintentionally break `console.log()` and friends. This is a documentation-only deprecation that can hopefully land in 8.x. PR-URL: https://github.com/nodejs/node/pull/15631 Refs: https://github.com/nodejs/node/issues/15549 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-08-28doc: add links to alternative versions of docChris Young
Each page of the API documentation should have links to other versions of the same page. This will make it easier to switch between the current "live" release at nodejs.org and LTS versions. PR-URL: https://github.com/nodejs/node/pull/10958 Fixes: https://github.com/nodejs/node/issues/10726 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2017-08-152017-08-15, Version 8.4.0 (Current)Anna Henningsen
Notable changes * **HTTP2** * Experimental support for the built-in `http2` has been added via the `--expose-http2` flag. [#14239](https://github.com/nodejs/node/pull/14239) * **Inspector** * `require()` is available in the inspector console now. [#8837](https://github.com/nodejs/node/pull/8837) * Multiple contexts, as created by the `vm` module, are supported now. [#14465](https://github.com/nodejs/node/pull/14465) * **N-API** * New APIs for creating number values have been introduced. [#14573](https://github.com/nodejs/node/pull/14573) * **Stream** * For `Duplex` streams, the high water mark option can now be set independently for the readable and the writable side. [#14636](https://github.com/nodejs/node/pull/14636) * **Util** * `util.format` now supports the `%o` and `%O` specifiers for printing objects. [#14558](https://github.com/nodejs/node/pull/14558) PR-URL: https://github.com/nodejs/node/pull/14811
2017-08-13doc: add missing `changes:` metadata for utilAnna Henningsen
Ref: https://github.com/nodejs/node/pull/14558 PR-URL: https://github.com/nodejs/node/pull/14810 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
2017-08-13doc: fix docs style in util.mdDaijiro Wachi
Summary + L582: Cell should be padded + L589: Cell should be padded + L590: Cell should be padded + L600: Cell should be padded + L622: Cell should be padded PR-URL: https://github.com/nodejs/node/pull/14711 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-08-092017-08-09, Version 8.3.0 (Current)Anna Henningsen
V8 6.0: The V8 engine has been upgraded to version 6.0, which has a significantly changed performance profile. [#14574](https://github.com/nodejs/node/pull/14574) More detailed information on performance differences can be found at https://medium.com/the-node-js-collection/get-ready-a-new-v8-is-coming-node-js-performance-is-changing-46a63d6da4de Other notable changes: * **DNS** * Independent DNS resolver instances are supported now, with support for cancelling the corresponding requests. [#14518](https://github.com/nodejs/node/pull/14518) * **N-API** * Multiple N-API functions for error handling have been changed to support assigning error codes. [#13988](https://github.com/nodejs/node/pull/13988) * **REPL** * Autocompletion support for `require()` has been improved. [#14409](https://github.com/nodejs/node/pull/14409) * **Utilities** * The WHATWG Encoding Standard (`TextDecoder` and `TextEncoder`) has been implemented as an experimental feature. [#13644](https://github.com/nodejs/node/pull/13644) * **Added new collaborators** * [XadillaX](https://github.com/XadillaX) – Khaidi Chu * [gabrielschulhof](https://github.com/gabrielschulhof) – Gabriel Schulhof Conflicts: src/node_version.h
2017-08-05encoding: rudimentary TextDecoder support w/o ICUTimothy Gu
Also split up the tests. PR-URL: https://github.com/nodejs/node/pull/14489 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-08-04util: implement %o and %O as formatting specifiersGreg Alexander
Implementing the %o and %O formatting specifiers for util.format. Based on discussion in issue, this specifier should just call util.inspect to format the value. PR-URL: https://github.com/nodejs/node/pull/14558 Fixes: https://github.com/nodejs/node/issues/14545 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Roman Reiss <me@silverwind.io> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
2017-07-28doc: cross-link util.TextDecoder and intl.mdVse Mozhet Byt
Also, note about builds without ICU and ASCII-sort some bottom references. PR-URL: https://github.com/nodejs/node/pull/14486 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-07-24util: implement WHATWG Encoding Standard APIJames M Snell
Provide an (initially experimental) implementation of the WHATWG Encoding Standard API (`TextDecoder` and `TextEncoder`). The is the same API implemented on the browser side. By default, with small-icu, only the UTF-8, UTF-16le and UTF-16be decoders are supported. With full-icu enabled, every encoding other than iso-8859-16 is supported. This provides a basic test, but does not include the full web platform tests. Note: many of the web platform tests for this would fail by default because we ship with small-icu by default. A process warning will be emitted on first use to indicate that the API is still experimental. No runtime flag is required to use the feature. Refs: https://encoding.spec.whatwg.org/ PR-URL: https://github.com/nodejs/node/pull/13644 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-07-192017-07-19, Version 8.2.0 (Current)Jeremiah Senkpiel
Big thanks to @addaleax who prepared the vast majority of this release. Notable changes: * **Async Hooks** * Multiple improvements to Promise support in `async_hooks` have been made. * **Build** * The compiler version requirement to build Node with GCC has been raised to GCC 4.9.4. [[`820b011ed6`](https://github.com/nodejs/node/commit/820b011ed6)] [#13466](https://github.com/nodejs/node/pull/13466) * **Cluster** * Users now have more fine-grained control over the inspector port used by individual cluster workers. Previously, cluster workers would simply increment from the master's debug port. [[`dfc46e262a`](https://github.com/nodejs/node/commit/dfc46e262a)] [#14140](https://github.com/nodejs/node/pull/14140) * **DNS** * The server used for DNS queries can now use a custom port. [[`ebe7bb29aa`](https://github.com/nodejs/node/commit/ebe7bb29aa)] [#13723](https://github.com/nodejs/node/pull/13723) * Support for `dns.resolveAny()` has been added. [[`6e30e2558e`](https://github.com/nodejs/node/commit/6e30e2558e)] [#13137](https://github.com/nodejs/node/pull/13137) * **npm** * The `npm` CLI has been updated to version 5.3.0. In particular, it now comes with the `npx` binary, which is also shipped with Node. [[`dc3f6b9ac1`](https://github.com/nodejs/node/commit/dc3f6b9ac1)] [#14235](https://github.com/nodejs/node/pull/14235) * `npm` Changelogs: - [v5.0.4](https://github.com/npm/npm/releases/tag/v5.0.4) - [v5.1.0](https://github.com/npm/npm/releases/tag/v5.1.0) - [v5.2.0](https://github.com/npm/npm/releases/tag/v5.2.0) - [v5.3.0](https://github.com/npm/npm/releases/tag/v5.3.0) PR-URL: https://github.com/nodejs/node/pull/13744
2017-07-04doc, util, console: clarify ambiguous docsNatanael Log
Add clarification to the documentation on util.format() and console.log() regarding how excessive arguments are treated when the first argument is a non-format string compared to when it is not a string at all. PR-URL: https://github.com/nodejs/node/pull/14027 Fixes: https://github.com/nodejs/node/issues/13908 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-06-29doc: fix indentation issues in sample codeRich Trott
In preparation for stricter ESLint indentation checking, fix a few issues in sample code. PR-URL: https://github.com/nodejs/node/pull/13950 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-06-10util: add callbackifyRefael Ackermann
Add `util.callbackify(function)` for creating callback style functions from functions returning a `Thenable` PR-URL: https://github.com/nodejs/node/pull/12712 Fixes: https://github.com/nodejs/CTC/issues/109 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net>
2017-06-05doc: use prefer-rest-params eslint rule in docsVse Mozhet Byt
Do not promote using of `arguments`. One fragment is left as is because of history nature: it uses a real deprecated code from libs. Refs: http://eslint.org/docs/rules/prefer-rest-params Refs: https://github.com/nodejs/node/blob/99da8e8e02a874a0a044889f863c45700509d02c/lib/util.js#L1002-L1006 PR-URL: https://github.com/nodejs/node/pull/13389 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com>
2017-06-01doc: modernize and fix code examples in util.mdVse Mozhet Byt
* Remove useless constructor. * Use template literals. * Update code example. Now all arrays with just holes are outputted the same way. In the fixed example, it was `[ <101 empty items> ]` twice. PR-URL: https://github.com/nodejs/node/pull/13298 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
2017-05-302017-05-30, Version 8.0.0 (Current)James M Snell
* **Async Hooks** * The `async_hooks` module has landed in core [[`4a7233c178`](https://github.com/nodejs/node/commit/4a7233c178)] [#12892](https://github.com/nodejs/node/pull/12892). * **Buffer** * Using the `--pending-deprecation` flag will cause Node.js to emit a deprecation warning when using `new Buffer(num)` or `Buffer(num)`. [[`d2d32ea5a2`](https://github.com/nodejs/node/commit/d2d32ea5a2)] [#11968](https://github.com/nodejs/node/pull/11968). * `new Buffer(num)` and `Buffer(num)` will zero-fill new `Buffer` instances [[`7eb1b4658e`](https://github.com/nodejs/node/commit/7eb1b4658e)] [#12141](https://github.com/nodejs/node/pull/12141). * Many `Buffer` methods now accept `Uint8Array` as input [[`beca3244e2`](https://github.com/nodejs/node/commit/beca3244e2)] [#10236](https://github.com/nodejs/node/pull/10236). * **Child Process** * Argument and kill signal validations have been improved [[`97a77288ce`](https://github.com/nodejs/node/commit/97a77288ce)] [#12348](https://github.com/nodejs/node/pull/12348), [[`d75fdd96aa`](https://github.com/nodejs/node/commit/d75fdd96aa)] [#10423](https://github.com/nodejs/node/pull/10423). * Child Process methods accept `Uint8Array` as input [[`627ecee9ed`](https://github.com/nodejs/node/commit/627ecee9ed)] [#10653](https://github.com/nodejs/node/pull/10653). * **Console** * Error events emitted when using `console` methods are now supressed. [[`f18e08d820`](https://github.com/nodejs/node/commit/f18e08d820)] [#9744](https://github.com/nodejs/node/pull/9744). * **Dependencies** * The npm client has been updated to 5.0.0 [[`3c3b36af0f`](https://github.com/nodejs/node/commit/3c3b36af0f)] [#12936](https://github.com/nodejs/node/pull/12936). * V8 has been updated to 5.8 with forward ABI stability to 6.0 [[`60d1aac8d2`](https://github.com/nodejs/node/commit/60d1aac8d2)] [#12784](https://github.com/nodejs/node/pull/12784). * **Domains** * Native `Promise` instances are now `Domain` aware [[`84dabe8373`](https://github.com/nodejs/node/commit/84dabe8373)] [#12489](https://github.com/nodejs/node/pull/12489). * **Errors** * We have started assigning static error codes to errors generated by Node.js. This has been done through multiple commits and is still a work in progress. * **File System** * The utility class `fs.SyncWriteStream` has been deprecated [[`7a55e34ef4`](https://github.com/nodejs/node/commit/7a55e34ef4)] [#10467](https://github.com/nodejs/node/pull/10467). * The deprecated `fs.read()` string interface has been removed [[`3c2a9361ff`](https://github.com/nodejs/node/commit/3c2a9361ff)] [#9683](https://github.com/nodejs/node/pull/9683). * **HTTP** * Improved support for userland implemented Agents [[`90403dd1d0`](https://github.com/nodejs/node/commit/90403dd1d0)] [#11567](https://github.com/nodejs/node/pull/11567). * Outgoing Cookie headers are concatenated into a single string [[`d3480776c7`](https://github.com/nodejs/node/commit/d3480776c7)] [#11259](https://github.com/nodejs/node/pull/11259). * The `httpResponse.writeHeader()` method has been deprecated [[`fb71ba4921`](https://github.com/nodejs/node/commit/fb71ba4921)] [#11355](https://github.com/nodejs/node/pull/11355). * New methods for accessing HTTP headers have been added to `OutgoingMessage` [[`3e6f1032a4`](https://github.com/nodejs/node/commit/3e6f1032a4)] [#10805](https://github.com/nodejs/node/pull/10805). * **Lib** * All deprecation messages have been assigned static identifiers [[`5de3cf099c`](https://github.com/nodejs/node/commit/5de3cf099c)] [#10116](https://github.com/nodejs/node/pull/10116). * The legacy `linkedlist` module has been removed [[`84a23391f6`](https://github.com/nodejs/node/commit/84a23391f6)] [#12113](https://github.com/nodejs/node/pull/12113). * **N-API** * Experimental support for the new N-API API has been added [[`56e881d0b0`](https://github.com/nodejs/node/commit/56e881d0b0)] [#11975](https://github.com/nodejs/node/pull/11975). * **Process** * Process warning output can be redirected to a file using the `--redirect-warnings` command-line argument [[`03e89b3ff2`](https://github.com/nodejs/node/commit/03e89b3ff2)] [#10116](https://github.com/nodejs/node/pull/10116). * Process warnings may now include additional detail [[`dd20e68b0f`](https://github.com/nodejs/node/commit/dd20e68b0f)] [#12725](https://github.com/nodejs/node/pull/12725). * **REPL** * REPL magic mode has been deprecated [[`3f27f02da0`](https://github.com/nodejs/node/commit/3f27f02da0)] [#11599](https://github.com/nodejs/node/pull/11599). * **Src** * `NODE_MODULE_VERSION` has been updated to 57 (https://github.com/nodejs/node/commit/ec7cbaf266)] [#12995](https://github.com/nodejs/node/pull/12995). * Add `--pending-deprecation` command-line argument and `NODE_PENDING_DEPRECATION` environment variable [[`a16b570f8c`](https://github.com/nodejs/node/commit/a16b570f8c)] [#11968](https://github.com/nodejs/node/pull/11968). * The `--debug` command-line argument has been deprecated. Note that using `--debug` will enable the *new* Inspector-based debug protocol as the legacy Debugger protocol previously used by Node.js has been removed. [[`010f864426`](https://github.com/nodejs/node/commit/010f864426)] [#12949](https://github.com/nodejs/node/pull/12949). * Throw when the `-c` and `-e` command-line arguments are used at the same time [[`a5f91ab230`](https://github.com/nodejs/node/commit/a5f91ab230)] [#11689](https://github.com/nodejs/node/pull/11689). * Throw when the `--use-bundled-ca` and `--use-openssl-ca` command-line arguments are used at the same time. [[`8a7db9d4b5`](https://github.com/nodejs/node/commit/8a7db9d4b5)] [#12087](https://github.com/nodejs/node/pull/12087). * **Stream** * `Stream` now supports `destroy()` and `_destroy()` APIs [[`b6e1d22fa6`](https://github.com/nodejs/node/commit/b6e1d22fa6)] [#12925](https://github.com/nodejs/node/pull/12925). * `Stream` now supports the `_final()` API [[`07c7f198db`](https://github.com/nodejs/node/commit/07c7f198db)] [#12828](https://github.com/nodejs/node/pull/12828). * **TLS** * The `rejectUnauthorized` option now defaults to `true` [[`348cc80a3c`](https://github.com/nodejs/node/commit/348cc80a3c)] [#5923](https://github.com/nodejs/node/pull/5923). * The `tls.createSecurePair()` API now emits a runtime deprecation [[`a2ae08999b`](https://github.com/nodejs/node/commit/a2ae08999b)] [#11349](https://github.com/nodejs/node/pull/11349). * A runtime deprecation will now be emitted when `dhparam` is less than 2048 bits [[`d523eb9c40`](https://github.com/nodejs/node/commit/d523eb9c40)] [#11447](https://github.com/nodejs/node/pull/11447). * **URL** * The WHATWG URL implementation is now a fully-supported Node.js API [[`d080ead0f9`](https://github.com/nodejs/node/commit/d080ead0f9)] [#12710](https://github.com/nodejs/node/pull/12710). * **Util** * `Symbol` keys are now displayed by default when using `util.inspect()` [[`5bfd13b81e`](https://github.com/nodejs/node/commit/5bfd13b81e)] [#9726](https://github.com/nodejs/node/pull/9726). * `toJSON` errors will be thrown when formatting `%j` [[`455e6f1dd8`](https://github.com/nodejs/node/commit/455e6f1dd8)] [#11708](https://github.com/nodejs/node/pull/11708). * Convert `inspect.styles` and `inspect.colors` to prototype-less objects [[`aab0d202f8`](https://github.com/nodejs/node/commit/aab0d202f8)] [#11624](https://github.com/nodejs/node/pull/11624). * The new `util.promisify()` API has been added [[`99da8e8e02`](https://github.com/nodejs/node/commit/99da8e8e02)] [#12442](https://github.com/nodejs/node/pull/12442). * **Zlib** * Support `Uint8Array` in Zlib convenience methods [[`91383e47fd`](https://github.com/nodejs/node/commit/91383e47fd)] [#12001](https://github.com/nodejs/node/pull/12001). * Zlib errors now use `RangeError` and `TypeError` consistently [[`b514bd231e`](https://github.com/nodejs/node/commit/b514bd231e)] [#11391](https://github.com/nodejs/node/pull/11391).
2017-05-28doc: make spelling of behavior consistentMichael Dawson
In the api docs there were some instances of behaviour and many more with behavior. I was asked as part of a review on a different PR which one to use and went with behavior to be consistent with the majority. Our style guide states that American English spelling is preferred. PR-URL: https://github.com/nodejs/node/pull/13245 Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Kunal Pathak <kunal.pathak@microsoft.com>
2017-05-25doc: make the style of notes consistentAlexey Orlenko
Make the style of "Note:" paragraphs consistent and document the guidelines in `doc/STYLE_GUIDE.md`. PR-URL: https://github.com/nodejs/node/pull/13133 Fixes: https://github.com/nodejs/node/issues/13131 Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
2017-05-09util: add util.promisify()Anna Henningsen
Add `util.promisify(function)` for creating promisified functions. Includes documentation and tests. Fixes: https://github.com/nodejs/CTC/issues/12 PR-URL: https://github.com/nodejs/node/pull/12442 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Myles Borins <myles.borins@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: William Kapke <william.kapke@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
2017-05-08doc: sort bottom-of-file markdown linksSam Roberts
PR-URL: https://github.com/nodejs/node/pull/12726 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-05-01test,lib,doc: use function declarationsRich Trott
Replace function expressions with function declarations in preparation for a lint rule requiring function declarations. PR-URL: https://github.com/nodejs/node/pull/12711 Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
2017-04-25doc: add no-var, prefer-const in doc eslintrcVse Mozhet Byt
PR-URL: https://github.com/nodejs/node/pull/12563 Refs: https://github.com/nodejs/node/pull/12557#issuecomment-296015032 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
2017-04-25doc: conform to rules for eslint-plugin-markdownVse Mozhet Byt
PR-URL: https://github.com/nodejs/node/pull/12563 Refs: https://github.com/nodejs/node/pull/12557#issuecomment-296015032 Reviewed-By: Teddy Katz <teddy.katz@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
2017-04-13doc: add single arg scenario for util.formatTarun Batra
Set the expected outcome of `util.format('%%')` to be `%%` instead of `%`. PR-URL: https://github.com/nodejs/node/pull/12374 Fixes: https://github.com/nodejs/node/issues/12362 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com> Reviewed-By: Alexey Orlenko <eaglexrlnk@gmail.com> Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
2017-03-29util: add %i and %f formatting specifiersRoman Reiss
This change brings formatting specifiers available in `util.format` and consequently, `console.*` closer to what is supported in all major browsers. - `%i` is introduced to format integer values. - `%f` is introduced to format floating point values. Fixes: https://github.com/nodejs/node/issues/10292 PR-URL: https://github.com/nodejs/node/pull/10308 Reviewed-By: James M Snell <jasnell@gmail.com>
2017-03-02doc: consistent case for primitive typesRoman Reiss
PR-URL: https://github.com/nodejs/node/pull/11167 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>