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
  • Loading branch information
ExE-Boss committed Jun 27, 2020
1 parent f63436d commit 86bc1db
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 @@ -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);

0 comments on commit 86bc1db

Please sign in to comment.