Skip to content

Commit

Permalink
lib: rename validateInteger to validateSafeInteger
Browse files Browse the repository at this point in the history
  • Loading branch information
zbjornson committed Mar 18, 2019
1 parent ebcd502 commit 006d530
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions lib/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const {
const {
isUint32,
validateMode,
validateInteger,
validateSafeInteger,
validateInt32,
validateUint32
} = require('internal/validators');
Expand Down Expand Up @@ -626,7 +626,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 @@ -667,7 +667,7 @@ function ftruncate(fd, len = 0, callback) {
len = 0;
}
validateUint32(fd, 'fd');
validateInteger(len, 'len');
validateSafeInteger(len, 'len');
len = Math.max(0, len);
const req = new FSReqCallback();
req.oncomplete = makeCallback(callback);
Expand All @@ -676,7 +676,7 @@ function ftruncate(fd, len = 0, callback) {

function ftruncateSync(fd, len = 0) {
validateUint32(fd, 'fd');
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/fs/promises.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const {
} = require('internal/fs/utils');
const {
validateMode,
validateInteger,
validateSafeInteger,
validateUint32
} = require('internal/validators');
const pathModule = require('path');
Expand Down Expand Up @@ -273,7 +273,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
6 changes: 3 additions & 3 deletions lib/internal/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function validateMode(value, name, def) {
throw new ERR_INVALID_ARG_VALUE(name, value, modeDesc);
}

function validateInteger(value, name) {
function validateSafeInteger(value, name) {
let err;

if (typeof value !== 'number')
Expand All @@ -61,7 +61,7 @@ function validateInteger(value, name) {
err = new ERR_OUT_OF_RANGE(name, 'an integer', value);

if (err) {
Error.captureStackTrace(err, validateInteger);
Error.captureStackTrace(err, validateSafeInteger);
throw err;
}

Expand Down Expand Up @@ -127,7 +127,7 @@ module.exports = {
isInt32,
isUint32,
validateMode,
validateInteger,
validateSafeInteger,
validateInt32,
validateUint32,
validateString,
Expand Down

0 comments on commit 006d530

Please sign in to comment.