Skip to content

Commit

Permalink
lib: rename validateInteger to validateSafeInteger
Browse files Browse the repository at this point in the history
PR-URL: #26572
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
Reviewed-By: Ujjwal Sharma <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
  • Loading branch information
zbjornson authored and Trott committed Aug 17, 2019
1 parent c3b8e50 commit 91a4cb7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const {
isUint32,
parseMode,
validateBuffer,
validateInteger,
validateSafeInteger,
validateInt32,
validateUint32
} = require('internal/validators');
Expand Down Expand Up @@ -621,7 +621,7 @@ function truncate(path, len, callback) {
len = 0;
}

validateInteger(len, 'len');
validateSafeInteger(len, 'len');
callback = maybeCallback(callback);
fs.open(path, 'r+', (er, fd) => {
if (er) return callback(er);
Expand Down Expand Up @@ -662,7 +662,7 @@ function ftruncate(fd, len = 0, callback) {
len = 0;
}
validateInt32(fd, 'fd', 0);
validateInteger(len, 'len');
validateSafeInteger(len, 'len');
len = Math.max(0, len);
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
Expand All @@ -671,7 +671,7 @@ function ftruncate(fd, len = 0, callback) {

function ftruncateSync(fd, len = 0) {
validateInt32(fd, 'fd', 0);
validateInteger(len, 'len');
validateSafeInteger(len, 'len');
len = Math.max(0, len);
const ctx = {};
binding.ftruncate(fd, len, undefined, ctx);
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/crypto/scrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { AsyncWrap, Providers } = internalBinding('async_wrap');
const { Buffer } = require('buffer');
const { scrypt: _scrypt } = internalBinding('crypto');
const { validateInteger, validateUint32 } = require('internal/validators');
const { validateSafeInteger, validateUint32 } = require('internal/validators');
const {
ERR_CRYPTO_SCRYPT_INVALID_PARAMETER,
ERR_CRYPTO_SCRYPT_NOT_SUPPORTED,
Expand Down Expand Up @@ -108,7 +108,7 @@ function check(password, salt, keylen, options) {
}
if (options.maxmem !== undefined) {
maxmem = options.maxmem;
validateInteger(maxmem, 'maxmem', 0);
validateSafeInteger(maxmem, 'maxmem', 0);
}
if (N === 0) N = defaults.N;
if (r === 0) r = defaults.r;
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const {
const {
parseMode,
validateBuffer,
validateInteger,
validateSafeInteger,
validateUint32
} = require('internal/validators');
const pathModule = require('path');
Expand Down Expand Up @@ -270,7 +270,7 @@ async function truncate(path, len = 0) {

async function ftruncate(handle, len = 0) {
validateFileHandle(handle);
validateInteger(len, 'len');
validateSafeInteger(len, 'len');
len = Math.max(0, len);
return binding.ftruncate(handle.fd, len, kUsePromises);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function parseMode(value, name, def) {
throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc);
}

const validateInteger = hideStackFrames(
const validateSafeInteger = hideStackFrames(
(value, name, min = MIN_SAFE_INTEGER, max = MAX_SAFE_INTEGER) => {
if (typeof value !== 'number')
throw new ERR_INVALID_ARG_TYPE(name, 'number', value);
Expand Down Expand Up @@ -161,7 +161,7 @@ module.exports = {
parseMode,
validateBuffer,
validateEncoding,
validateInteger,
validateSafeInteger,
validateInt32,
validateUint32,
validateString,
Expand Down

0 comments on commit 91a4cb7

Please sign in to comment.