Skip to content

Commit 0c33ea7

Browse files
committed
chore: rename to os.guessFileDescriptorType
1 parent 8e394be commit 0c33ea7

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

doc/api/os.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -508,20 +508,20 @@ On POSIX systems, the operating system release is determined by calling
508508
available, `GetVersionExW()` will be used. See
509509
<https://en.wikipedia.org/wiki/Uname#Examples> for more information.
510510

511-
## `os.guessHandleType(handle)`
511+
## `os.guessFileDescriptorType(fd)`
512512

513513
<!-- YAML
514514
added: REPLACEME
515515
-->
516516

517-
* `handle` {integer} The handle number to try and guess the type of.
517+
* `fd` {integer} The file descriptor number to try and guess the type of.
518518

519519
* Returns: {string}
520520

521-
Returns the type of the handle passed in, or `'INVALID'` if the provided handle
521+
Returns the type of the file descriptor passed in, or `'INVALID'` if the provided file descriptor
522522
is invalid.
523523

524-
Currently, the following types for a handle can be returned:
524+
Currently, the following types for a file descriptor can be returned:
525525

526526
* `'TCP'`
527527
* `'TTY'`

lib/os.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ module.exports = {
328328
uptime: getUptime,
329329
version: getOSVersion,
330330
machine: getMachine,
331-
guessHandleType: _guessHandleType,
331+
guessFileDescriptorType: _guessHandleType,
332332
};
333333

334334
ObjectDefineProperties(module.exports, {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
'use strict';
2+
3+
require('../common');
4+
const { strictEqual } = require('assert');
5+
const { guessFileDescriptorType } = require('os');
6+
7+
strictEqual(guessFileDescriptorType(0), 'TTY', 'stdin reported to not be a tty, but it is');
8+
strictEqual(guessFileDescriptorType(1), 'TTY', 'stdout reported to not be a tty, but it is');
9+
strictEqual(guessFileDescriptorType(2), 'TTY', 'stderr reported to not be a tty, but it is');
10+
11+
strictEqual(guessFileDescriptorType(-1), 'INVALID', '-1 reported to be a tty, but it is not');
12+
strictEqual(guessFileDescriptorType(55555), 'UNKNOWN', '55555 reported to be a tty, but it is not');
13+
strictEqual(guessFileDescriptorType(2 ** 31), 'INVALID', '2^31 reported to be a tty, but it is not');
14+
strictEqual(guessFileDescriptorType(1.1), 'INVALID', '1.1 reported to be a tty, but it is not');
15+
strictEqual(guessFileDescriptorType('1'), 'INVALID', '\'1\' reported to be a tty, but it is not');
16+
strictEqual(guessFileDescriptorType({}), 'INVALID', '{} reported to be a tty, but it is not');
17+
strictEqual(guessFileDescriptorType(() => {}), 'INVALID', '() => {} reported to be a tty, but it is not');

test/pseudo-tty/test-os-guessHandleType.js

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)