summaryrefslogtreecommitdiff
path: root/lib/tty.js
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-01-19 15:37:38 +0100
committerRuben Bridgewater <ruben@bridgewater.de>2019-03-05 18:37:39 +0100
commitd4fdec6b6593659cb38e1db9c8083d4fde9bcacb (patch)
treeecaf80b2517373e0cdb264c945209b7d12f65766 /lib/tty.js
parenta52c1ead0221a0c913d55d86ddddbe2ff3d04d5b (diff)
downloadandroid-node-v8-d4fdec6b6593659cb38e1db9c8083d4fde9bcacb.tar.gz
android-node-v8-d4fdec6b6593659cb38e1db9c8083d4fde9bcacb.tar.bz2
android-node-v8-d4fdec6b6593659cb38e1db9c8083d4fde9bcacb.zip
tty: add hasColors function
This adds a small wrapper around the `getColorDepth` function to check if the stream supports at least a specific amount of colors. This is convenient as the other API is not as straight forward and most use cases likely only want to know if a specific amount of colors is supported or not. PR-URL: https://github.com/nodejs/node/pull/26247 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Diffstat (limited to 'lib/tty.js')
-rw-r--r--lib/tty.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/tty.js b/lib/tty.js
index 6efaac6e43..bc568146fd 100644
--- a/lib/tty.js
+++ b/lib/tty.js
@@ -26,7 +26,10 @@ const net = require('net');
const { TTY, isTTY } = internalBinding('tty_wrap');
const errors = require('internal/errors');
const { ERR_INVALID_FD, ERR_TTY_INIT_FAILED } = errors.codes;
-const { getColorDepth } = require('internal/tty');
+const {
+ getColorDepth,
+ hasColors
+} = require('internal/tty');
// Lazy loaded for startup performance.
let readline;
@@ -109,6 +112,8 @@ WriteStream.prototype.isTTY = true;
WriteStream.prototype.getColorDepth = getColorDepth;
+WriteStream.prototype.hasColors = hasColors;
+
WriteStream.prototype._refreshSize = function() {
const oldCols = this.columns;
const oldRows = this.rows;