summaryrefslogtreecommitdiff
path: root/lib/buffer.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/buffer.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/buffer.js')
-rw-r--r--lib/buffer.js9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/buffer.js b/lib/buffer.js
index 593e10d741..add3303824 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -37,7 +37,14 @@ const {
kMaxLength,
kStringMaxLength
} = process.binding('buffer');
-const { isAnyArrayBuffer } = process.binding('util');
+// We cannot use internalBinding unconditionally here because of the way
+// that test/parallel/test-buffer-bindingobj-no-zerofill.js is written.
+let isAnyArrayBuffer;
+try {
+ isAnyArrayBuffer = internalBinding('types').isAnyArrayBuffer;
+} catch (e) {
+ isAnyArrayBuffer = require('util').types.isAnyArrayBuffer;
+}
const {
customInspectSymbol,
normalizeEncoding,