summaryrefslogtreecommitdiff
path: root/lib/util.js
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2018-01-27 22:01:32 +0100
committerAnna Henningsen <anna@addaleax.net>2018-03-05 17:41:26 +0000
commitb20af8088a4d5cccb1901d42107f6d9ca82d306f (patch)
treed443fa727be877dc7ad6e4112503944a8e674490 /lib/util.js
parentbd6e0be0dfbbf6d10f1f054c43b0b82f25c60b16 (diff)
downloadandroid-node-v8-b20af8088a4d5cccb1901d42107f6d9ca82d306f.tar.gz
android-node-v8-b20af8088a4d5cccb1901d42107f6d9ca82d306f.tar.bz2
android-node-v8-b20af8088a4d5cccb1901d42107f6d9ca82d306f.zip
util: introduce `util.types.is[…]` type checks
Provide public APIs for native typechecking that is actually useful. The motivation for this is providing alternatives to userland modules that would currently rely on `process.binding('util')`. PR-URL: https://github.com/nodejs/node/pull/18415 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/util.js b/lib/util.js
index df117782ca..888c005f2f 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -30,6 +30,13 @@ const { previewMapIterator, previewSetIterator } = require('internal/v8');
const {
getPromiseDetails,
getProxyDetails,
+ kPending,
+ kRejected,
+} = process.binding('util');
+
+const types = internalBinding('types');
+Object.assign(types, require('internal/util/types'));
+const {
isAnyArrayBuffer,
isDataView,
isExternal,
@@ -40,13 +47,8 @@ const {
isSetIterator,
isRegExp,
isDate,
- kPending,
- kRejected,
-} = process.binding('util');
-
-const {
isTypedArray
-} = require('internal/util/types');
+} = types;
const {
isDeepStrictEqual
@@ -1149,6 +1151,7 @@ module.exports = exports = {
promisify,
TextDecoder,
TextEncoder,
+ types,
// Deprecated Old Stuff
debug: deprecate(debug,