lib: rename validateInteger to validateSafeInteger

PR-URL: https://github.com/nodejs/node/pull/26572
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
Zach Bjornson 2019-03-12 00:14:19 -07:00 committed by Rich Trott
parent c3b8e50143
commit 91a4cb7175
4 changed files with 10 additions and 10 deletions

View File

@ -85,7 +85,7 @@ const {
isUint32,
parseMode,
validateBuffer,
validateInteger,
validateSafeInteger,
validateInt32,
validateUint32
} = require('internal/validators');
@ -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);
@ -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);
@ -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);

View File

@ -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,
@ -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;

View File

@ -36,7 +36,7 @@ const {
const {
parseMode,
validateBuffer,
validateInteger,
validateSafeInteger,
validateUint32
} = require('internal/validators');
const pathModule = require('path');
@ -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);
}

View File

@ -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);
@ -161,7 +161,7 @@ module.exports = {
parseMode,
validateBuffer,
validateEncoding,
validateInteger,
validateSafeInteger,
validateInt32,
validateUint32,
validateString,