| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 469baa0 commit fc0b361
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -86,7 +86,6 @@ const { | |||
| 86 | 86 | const { | |
| 87 | 87 | isUint32, | |
| 88 | 88 | validateInteger, | |
| 89 | - validateInt32, | ||
| 90 | 89 | validateUint32 | |
| 91 | 90 | } = require('internal/validators'); | |
| 92 | 91 | ||
@@ -788,11 +787,7 @@ fs.ftruncate = function(fd, len = 0, callback) { | |||
| 788 | 787 | len = 0; | |
| 789 | 788 | } | |
| 790 | 789 | validateUint32(fd, 'fd'); | |
| 791 | - // TODO(BridgeAR): This does not seem right. | ||
| 792 | - // There does not seem to be any validation before and if there is any, it | ||
| 793 | - // should work similar to validateUint32 or not have a upper cap at all. | ||
| 794 | - // This applies to all usage of `validateInt32(len, 'len')`. | ||
| 795 | - validateInt32(len, 'len'); | ||
| 790 | + validateInteger(len, 'len'); | ||
| 796 | 791 | len = Math.max(0, len); | |
| 797 | 792 | const req = new FSReqWrap(); | |
| 798 | 793 | req.oncomplete = makeCallback(callback); | |
@@ -801,7 +796,7 @@ fs.ftruncate = function(fd, len = 0, callback) { | |||
| 801 | 796 | ||
| 802 | 797 | fs.ftruncateSync = function(fd, len = 0) { | |
| 803 | 798 | validateUint32(fd, 'fd'); | |
| 804 | - validateInt32(len, 'len'); | ||
| 799 | + validateInteger(len, 'len'); | ||
| 805 | 800 | len = Math.max(0, len); | |
| 806 | 801 | const ctx = {}; | |
| 807 | 802 | binding.ftruncate(fd, len, undefined, ctx); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,7 +33,7 @@ const { | |||
| 33 | 33 | validatePath | |
| 34 | 34 | } = require('internal/fs/utils'); | |
| 35 | 35 | const { | |
| 36 | - validateInt32, | ||
| 36 | + validateInteger, | ||
| 37 | 37 | validateUint32 | |
| 38 | 38 | } = require('internal/validators'); | |
| 39 | 39 | const pathModule = require('path'); | |
@@ -264,7 +264,7 @@ async function truncate(path, len = 0) { | |||
| 264 | 264 | ||
| 265 | 265 | async function ftruncate(handle, len = 0) { | |
| 266 | 266 | validateFileHandle(handle); | |
| 267 | - validateInt32(len, 'len'); | ||
| 267 | + validateInteger(len, 'len'); | ||
| 268 | 268 | len = Math.max(0, len); | |
| 269 | 269 | return binding.ftruncate(handle.fd, len, kUsePromises); | |
| 270 | 270 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -220,17 +220,14 @@ function testFtruncate(cb) { | |||
| 220 | 220 | `an integer. Received ${input}` | |
| 221 | 221 | } | |
| 222 | 222 | ); | |
| 223 | - }); | ||
| 224 | 223 | ||
| 225 | - // 2 ** 31 = 2147483648 | ||
| 226 | - [2147483648, -2147483649].forEach((input) => { | ||
| 227 | 224 | assert.throws( | |
| 228 | 225 | () => fs.ftruncate(fd, input), | |
| 229 | 226 | { | |
| 230 | 227 | code: 'ERR_OUT_OF_RANGE', | |
| 231 | 228 | name: 'RangeError [ERR_OUT_OF_RANGE]', | |
| 232 | 229 | message: 'The value of "len" is out of range. It must be ' + | |
| 233 | - `> -2147483649 && < 2147483648. Received ${input}` | ||
| 230 | + `an integer. Received ${input}` | ||
| 234 | 231 | } | |
| 235 | 232 | ); | |
| 236 | 233 | }); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments