diff options
author | Sarat Addepalli <sarat.addepalli@paytm.com> | 2018-08-06 15:25:59 +0530 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2018-08-24 11:57:56 -0700 |
commit | 4ea2c8e26ff5812579295dd0dfc191c481e42af9 (patch) | |
tree | a15f75c673efca544b7a76ec9c698bea35e986aa /lib/internal/fs | |
parent | 6bb96a1183d9492a34a745a5d1bb48552a4eef24 (diff) | |
download | android-node-v8-4ea2c8e26ff5812579295dd0dfc191c481e42af9.tar.gz android-node-v8-4ea2c8e26ff5812579295dd0dfc191c481e42af9.tar.bz2 android-node-v8-4ea2c8e26ff5812579295dd0dfc191c481e42af9.zip |
fs: update read to work with any TypedArray/DataView
PR-URL: https://github.com/nodejs/node/pull/22150
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/fs')
-rw-r--r-- | lib/internal/fs/utils.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/internal/fs/utils.js b/lib/internal/fs/utils.js index f065ba41e8..acc566e37b 100644 --- a/lib/internal/fs/utils.js +++ b/lib/internal/fs/utils.js @@ -9,7 +9,7 @@ const { ERR_INVALID_OPT_VALUE_ENCODING, ERR_OUT_OF_RANGE } = require('internal/errors').codes; -const { isUint8Array } = require('internal/util/types'); +const { isUint8Array, isArrayBufferView } = require('internal/util/types'); const pathModule = require('path'); const util = require('util'); const kType = Symbol('type'); @@ -394,9 +394,10 @@ function toUnixTimestamp(time, name = 'time') { } function validateBuffer(buffer) { - if (!isUint8Array(buffer)) { + if (!isArrayBufferView(buffer)) { const err = new ERR_INVALID_ARG_TYPE('buffer', - ['Buffer', 'Uint8Array'], buffer); + ['Buffer', 'TypedArray', 'DataView'], + buffer); Error.captureStackTrace(err, validateBuffer); throw err; } |