Skip to content

Commit

Permalink
util: add util/types alias module
Browse files Browse the repository at this point in the history
Refs: #31553
Refs: #32953
Refs: #33950
Refs: #34001
Refs: #34002

PR-URL: #34055
Refs: #34962
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
  • Loading branch information
ExE-Boss authored and codebytere committed Nov 22, 2020
1 parent 85c85d3 commit baa87c1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 0 deletions.
6 changes: 6 additions & 0 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,10 @@ The encoding supported by the `TextEncoder` instance. Always set to `'utf-8'`.
## `util.types`
<!-- YAML
added: v10.0.0
changes:
- version: REPLACEME
pr-url: https://github.com/nodejs/node/pull/34055
description: Exposed as `require('util/types')`.
-->

`util.types` provides type checks for different kinds of built-in objects.
Expand All @@ -1301,6 +1305,8 @@ The result generally does not make any guarantees about what kinds of
properties or behavior a value exposes in JavaScript. They are primarily
useful for addon developers who prefer to do type checking in JavaScript.

The API is accessible via `require('util').types` or `require('util/types')`.

### `util.types.isAnyArrayBuffer(value)`
<!-- YAML
added: v10.0.0
Expand Down
3 changes: 3 additions & 0 deletions lib/util/types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
'use strict';

module.exports = require('internal/util/types');
1 change: 1 addition & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@
'lib/tty.js',
'lib/url.js',
'lib/util.js',
'lib/util/types.js',
'lib/v8.js',
'lib/vm.js',
'lib/wasi.js',
Expand Down
6 changes: 6 additions & 0 deletions test/es-module/test-esm-util-types.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import '../common/index.mjs';
import assert from 'assert';
import { types } from 'util';
import utilTypes from 'util/types';

assert.strictEqual(types, utilTypes);
6 changes: 6 additions & 0 deletions test/parallel/test-util-types-exists.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
'use strict';

require('../common');
const assert = require('assert');

assert.strictEqual(require('util/types'), require('util').types);

0 comments on commit baa87c1

Please sign in to comment.