Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util: add util/types alias module #34055

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/api/util.md
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,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 @@ -1248,6 +1252,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 @@ -95,6 +95,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);