diff options
author | James M Snell <jasnell@gmail.com> | 2017-04-26 12:42:18 -0700 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2017-08-02 08:23:07 -0700 |
commit | cc43c8fb54c872fbce2a795d089aa111eccdfb89 (patch) | |
tree | deb7967091a3c733746727ba1777164a7d7f4707 /doc | |
parent | 98bae2930453d40dadf3f36f5ad89eb73b23ef3a (diff) | |
download | node-new-cc43c8fb54c872fbce2a795d089aa111eccdfb89.tar.gz |
console: add console.count() and console.clear()
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>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/api/console.md | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/doc/api/console.md b/doc/api/console.md index 4939ed77be..10f9eba540 100644 --- a/doc/api/console.md +++ b/doc/api/console.md @@ -167,6 +167,76 @@ console.assert(false, 'this message will print, but no error thrown'); console.log('this will also print'); ``` +### console.clear() +<!-- YAML +added: REPLACEME +--> + +When `stdout` is a TTY, calling `console.clear()` will attempt to clear the +TTY. When `stdout` is not a TTY, this method does nothing. + +*Note*: The specific operation of `console.clear()` can vary across operating +systems and terminal types. For most Linux operating systems, `console.clear()` +operates similarly to the `clear` shell command. On Windows, `console.clear()` +will clear only the output in the current terminal viewport for the Node.js +binary. + +### console.count([label]) +<!-- YAML +added: REPLACEME +--> + +* `label` {string} The display label for the counter. Defaults to `'default'`. + +Maintains an internal counter specific to `label` and outputs to `stdout` the +number of times `console.count()` has been called with the given `label`. + +<!-- eslint-skip --> +```js +> console.count() +default: 1 +undefined +> console.count('default') +default: 2 +undefined +> console.count('abc') +abc: 1 +undefined +> console.count('xyz') +xyz: 1 +undefined +> console.count('abc') +abc: 2 +undefined +> console.count() +default: 3 +undefined +> +``` + +### console.countReset([label = 'default']) +<!-- YAML +added: REPLACEME +--> + +* `label` {string} The display label for the counter. Defaults to `'default'`. + +Resets the internal counter specific to `label`. + +<!-- eslint-skip --> +```js +> console.count('abc'); +abc: 1 +undefined +> console.countReset('abc'); +undefined +> console.count('abc'); +abc: 1 +undefined +> +``` +<!-- eslint-enable --> + ### console.dir(obj[, options]) <!-- YAML added: v0.1.101 |