Граф коммитов

32 Коммитов

Автор SHA1 Сообщение Дата
Eugene Obrezkov 1c84579031 console: timeEnd() with no label emits warning
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>
2016-04-25 08:28:23 -07:00
James M Snell 33c242e7e9 console: refactor to use rest params and template strings
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>
2016-04-20 14:45:42 -07:00
Rich Trott 6ba5af2c2c console: check that stderr is writable
`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>
2016-03-15 19:10:55 -07:00
Nathan Woltman d0582ef9e1 lib: copy arguments object instead of leaking it
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>
2016-03-10 18:45:08 -08:00
Jackson Tian 0903b6d8a8 console: apply null as `this` for util.format
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>
2016-02-18 11:24:01 +01:00
Vladimir Varankin a5cce79ec3 console: delete timers that have ended
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>
2015-11-13 11:36:45 -05:00
Roman Reiss 9aee2c0e26 console: use 'label' argument for time and timeEnd
Turns out the argument is actually called label in the console spec,
while being wrongly named on MDN. This reverts commit
8c043c1245.

MDN has been updated in:

https://developer.mozilla.org/en-US/docs/Web/API/Console/timeEnd$compare?locale=en-US&to=947893&from=918571
https://developer.mozilla.org/en-US/docs/Web/API/Console/time$compare?locale=en-US&to=947891&from=896987

PR-URL: https://github.com/nodejs/node/pull/3590
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2015-11-10 15:37:06 +01:00
Michaël Zasso 8c043c1245 console: rename argument of time and timeEnd
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>
2015-10-16 21:03:44 +02:00
Michaël Zasso 419f7d4726 console: sub-millisecond accuracy for console.time
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>
2015-10-16 21:00:51 +02:00
Yosuke Furukawa 19ffb5cf1c lib: fix eslint styles
PR-URL: https://github.com/iojs/io.js/pull/1539
Fixes: https://github.com/iojs/io.js/issues/1253
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
2015-05-09 12:10:02 +09:00
cjihrig 6ac8bdc0ab lib: reduce util.is*() usage
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>
2015-01-31 23:47:29 -05:00
cjihrig 3cbb5cdfdb console: allow Object.prototype fields as labels
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>
2015-01-27 18:28:09 -05:00
cjihrig 804e7aa9ab lib: use const to define constants
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>
2015-01-21 16:21:31 -05:00
isaacs 3e1b1dd4a9 Remove excessive copyright/license boilerplate
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.
2015-01-12 15:30:28 -08:00
Ben Noordhuis 21130c7d6f lib: turn on strict mode
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>
2014-11-22 17:23:30 +01:00
Majid Arif Siddiqui 176f0bd3df lib: improved forEach object performance
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
2014-09-05 09:19:32 -07:00
Xavi Magrinyà 1cd48c7ae5 console: console.dir() accepts options object
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>
2014-06-12 10:42:52 -07:00
Xavi Magrinyà e00cafa311 Added support for options parameter in console.dir()
Signed-off-by: Fedor Indutny <fedor@indutny.com>
2014-06-12 10:33:15 -07:00
isaacs 22c68fdc1d src: Replace macros with util functions 2013-08-01 15:08:01 -07:00
Ben Noordhuis 0330bdf519 lib: macro-ify type checks
Increases the grep factor. Makes it easier to harmonize type checks
across the code base.
2013-07-24 21:49:35 +02:00
Nathan Rajlich da8b0eefde console: `console.dir()` bypasses inspect() methods
Use the `customInspect: false` option of `util.inspect()` to bypass any custom
inspect() function on the object being logged.

Closes #2717.
2013-03-12 13:15:03 -07:00
isaacs 539bf1d7b7 console: Support formatting options in trace()
Fix #4589
2013-01-18 15:39:08 -08:00
Nathan Rajlich 025f53c306 console: refactor the console module to be reusable
So that multiple instances can be created pointing
to different writable streams.

This is needed for #3876.
2012-08-24 14:31:32 -07:00
Maciej Małecki 77c18d1e1b console: throw when no such label exists in `console.timeEnd`
Test included.
2012-04-29 22:27:45 +02:00
Ryan Dahl d77ce4b998 Fixes #1860. Remove process.writeError
Breaks a few tests in "make test-message"
2011-10-18 13:12:50 -07:00
Ryan Dahl cdf5d91fe5 Remove tty_legacy 2011-10-11 13:41:33 -07:00
Ben Noordhuis 874260b40f util: add sprintf-like format() function
Fixes #1407.
2011-07-30 02:11:31 +02:00
Ryan Dahl 55048cdf79 Update copyright headers 2011-03-14 17:37:05 -07:00
Ryan Dahl bfb6a67d60 Another fix for process.assert 2011-01-27 16:59:28 -08:00
Sami Samhuri e5a47c8ce1 use util.inspect to format objects and arrays printed to the console 2010-12-30 19:14:30 -08:00
Ryan Dahl f22c248e4c more lint 2010-12-01 17:29:11 -08:00
Ryan Dahl 70188499b0 Lazy load console object 2010-11-30 11:18:02 -08:00