Non-ASCII characters in /lib get compiled into the node binary,
and may bloat the binary size unnecessarily. A linter rule may
help prevent this.
PR-URL: https://github.com/nodejs/node/pull/18043
Fixes: https://github.com/nodejs/node/issues/11209
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Teddy Katz <teddy.katz@gmail.com>
This lists all function aliases directly below the declared function.
PR-URL: https://github.com/nodejs/node/pull/17707
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Fix and refactor the console benchmark. It did not test console
so it got renamed and mainly tests the different ways of passing
arguments through.
PR-URL: https://github.com/nodejs/node/pull/17707
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Calling write could throw a maximum call stack size error. To make
sure this is not specific to a single engine (version), lazily
populate the correct error message by producing such a error on
demand.
PR-URL: https://github.com/nodejs/node/pull/17707
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This method was previously exposed by V8 (since node 8.0.0) but not
implemented in node.
PR-URL: https://github.com/nodejs/node/pull/17152
Refs: https://github.com/nodejs/node/issues/17128
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Adds the console.debug() method, alias for console.log(). This method is
exposed by V8 and was only available in inspector until now. Also adds
matching test and documentation.
PR-URL: https://github.com/nodejs/node/pull/17033
Refs: https://github.com/nodejs/node/pull/17004
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
If the console destination is a unix pipe (net.Socket), write() is
async. If the destination is broken, we are adding an 'error' event
listener to avoid a process crash. This PR makes sure that we are adding
that listener only once.
Fixes: https://github.com/nodejs/node/issues/16767
PR-URL: https://github.com/nodejs/node/pull/16770
Fixes: https://github.com/nodejs/node/issues/16767
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Preserve indentation for multiline strings, objects that span multiple
lines, etc.
also make groupIndent non-enumerable
Hide the internal `groupIndent` key a bit by making it non-enumerable
and non-configurable.
PR-URL: https://github.com/nodejs/node/pull/14999
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Node.js exposes `console.group()` and `console.groupEnd()` via the
inspector. These functions have no apparent effect when called from
Node.js without the inspector. We cannot easily hide them when Node.js
is started without the inspector because we support opening the
inspector during runtime via `inspector.port()`.
Implement a minimal `console.group()`/`console.groupEnd()`. More
sophisticated implementations are possible, but they can be done in
userland and/or features can be added to this at a later time.
`console.groupCollapsed()` is implemented as an alias for
`console.group()`.
PR-URL: https://github.com/nodejs/node/pull/14910
Fixes: https://github.com/nodejs/node/issues/1716
Ref: https://github.com/nodejs/node/issues/12675
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Per the console spec, the label in console.time() is a string.
Per the console spec, the default value of label is `'default'`.
PR-URL: https://github.com/nodejs/node/pull/14643
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Make a message test more accurate in what it’s testing for.
This requires not swallowing stack overflow RangeErrors in
`console.log` and similar methods, which I would consider a
bugfix in itself.
PR-URL: https://github.com/nodejs/node/pull/14580
Fixes: https://github.com/nodejs/node-v8/issues/5
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Both are simple utility functions defined by the WHATWG
console spec (https://console.spec.whatwg.org/).
PR-URL: https://github.com/nodejs/node/pull/12678
Ref: https://github.com/nodejs/node/issues/12675
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Using a object instead of an Error is sufficient as the Error
itself won't be used but only the stack trace that would
otherwise be created twice.
This improves the overall .trace() performance.
PR-URL: https://github.com/nodejs/node/pull/13743
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Timothy Gu <timothygu99@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Refael Ackermann <refack@gmail.com>
When timeEnd() provided with label that doesn't exists
it emits warning in the console, so developer get know about it.
PR-URL: https://github.com/nodejs/node/pull/5901
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Overall cleanup in code, eliminate reliance on `arguments`.
Benchmarks show that as of v8 5.0.71.32, using rest params + apply
has good performance. The spread operator is not yet well optimized
in v8
```
misc/console.js method=restAndSpread concat=1 n=1000000: 374779.38359
misc/console.js method=restAndSpread concat=0 n=1000000: 375988.30434
misc/console.js method=argumentsAndApply concat=1 n=1000000: 682618.61125
misc/console.js method=argumentsAndApply concat=0 n=1000000: 645093.74443
misc/console.js method=restAndApply concat=1 n=1000000: 682931.41217
misc/console.js method=restAndApply concat=0 n=1000000: 664473.09700
```
PR-URL: https://github.com/nodejs/node/pull/6233
Reviewed-By: Brian White <mscdex@mscdex.net>
`Console` constructor checks that `stdout.write()` is a function but
does not do an equivalent check for `stderr.write()`. If `stderr` is not
specified in the constructor, then `stderr` is set to be `stdout`.
However, if `stderr` is specified, but `stderr.write()` is not a
function, then an exception is not thrown until `console.error()` is
called.
This change adds the same check for 'stderr' in the constructor that is
there for `stdout`. If `stderr` fails the check, then a `TypeError` is
thrown.
Took the opportunity to copyedit the `console` doc a little too.
PR-URL: https://github.com/nodejs/node/pull/5635
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Instead of leaking the arguments object by passing it as an
argument to a function, copy it's contents to a new array,
then pass the array. This allows V8 to optimize the function
that contains this code, improving performance.
PR-URL: https://github.com/nodejs/node/pull/4361
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Util.format is just a stateless function. Apply current console
as `this` is unnecessary.
PR-URL: https://github.com/nodejs/node/pull/5222
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Currently, console timers that have been ended with timeEnd()
are not removed. This has the potential to leak memory. This
commit deletes ended timers from the containing Map.
PR-URL: https://github.com/nodejs/node/pull/3562
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Name it timerName instead of label. It is clearer that way and matches
the description in the doc. It is also how it's named in MDN.
PR-URL: https://github.com/nodejs/node/pull/3166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
This makes the output of console.timeEnd in line with major browsers.
PR-URL: https://github.com/nodejs/node/pull/3166
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Many of the util.is*() methods used to check data types
simply compare against a single value or the result of
typeof. This commit replaces calls to these methods with
equivalent checks. This commit does not touch calls to the
more complex methods (isRegExp(), isDate(), etc.).
Fixes: https://github.com/iojs/io.js/issues/607
PR-URL: https://github.com/iojs/io.js/pull/647
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Console.prototype.timeEnd() returns NaN if the timer label
corresponds to a property on Object.prototype. This commit
uses a Map to construct the _times object.
Fixes: https://github.com/joyent/node/issues/9069
PR-URL: https://github.com/iojs/io.js/pull/563
Reviewed-By: Vladimir Kurchatkin <vladimir.kurchatkin@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
This commit replaces a number of var statements throughout
the lib code with const statements.
PR-URL: https://github.com/iojs/io.js/pull/541
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
The copyright and license notice is already in the LICENSE file. There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
Turn on strict mode for the files in the lib/ directory. It helps
catch bugs and can have a positive effect on performance.
PR-URL: https://github.com/node-forward/node/pull/64
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
This features comes from the need of adding extra options when displaying
the object using console.dir().
console.dir() accepts now a second parameter that is passed to util.inspect()
in order to provide extra options to the output. These options are: depth, color
and showHidden. More information about these options in util.inspect() documentation.
Signed-off-by: Fedor Indutny <fedor@indutny.com>