| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 27b646e commit 27bcf33
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -38,13 +38,13 @@ const { | |||
| 38 | 38 | ||
| 39 | 39 | function validateTimeout(options) { | |
| 40 | 40 | const { timeout = -1 } = { ...options }; | |
| 41 | - validateInt32(timeout, 'options.timeout', -1, 2 ** 31 - 1); | ||
| 41 | + validateInt32(timeout, 'options.timeout', -1); | ||
| 42 | 42 | return timeout; | |
| 43 | 43 | } | |
| 44 | 44 | ||
| 45 | 45 | function validateTries(options) { | |
| 46 | 46 | const { tries = 4 } = { ...options }; | |
| 47 | - validateInt32(tries, 'options.tries', 1, 2 ** 31 - 1); | ||
| 47 | + validateInt32(tries, 'options.tries', 1); | ||
| 48 | 48 | return tries; | |
| 49 | 49 | } | |
| 50 | 50 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -65,7 +65,7 @@ function parseFileMode(value, name, def) { | |||
| 65 | 65 | value = NumberParseInt(value, 8); | |
| 66 | 66 | } | |
| 67 | 67 | ||
| 68 | - validateInt32(value, name, 0, 2 ** 32 - 1); | ||
| 68 | + validateUint32(value, name); | ||
| 69 | 69 | return value; | |
| 70 | 70 | } | |
| 71 | 71 | ||
@@ -86,11 +86,8 @@ const validateInt32 = hideStackFrames( | |||
| 86 | 86 | if (typeof value !== 'number') { | |
| 87 | 87 | throw new ERR_INVALID_ARG_TYPE(name, 'number', value); | |
| 88 | 88 | } | |
| 89 | - if (!isInt32(value)) { | ||
| 90 | - if (!NumberIsInteger(value)) { | ||
| 91 | - throw new ERR_OUT_OF_RANGE(name, 'an integer', value); | ||
| 92 | - } | ||
| 93 | - throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value); | ||
| 89 | + if (!NumberIsInteger(value)) { | ||
| 90 | + throw new ERR_OUT_OF_RANGE(name, 'an integer', value); | ||
| 94 | 91 | } | |
| 95 | 92 | if (value < min || value > max) { | |
| 96 | 93 | throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value); | |
@@ -102,16 +99,14 @@ const validateUint32 = hideStackFrames((value, name, positive) => { | |||
| 102 | 99 | if (typeof value !== 'number') { | |
| 103 | 100 | throw new ERR_INVALID_ARG_TYPE(name, 'number', value); | |
| 104 | 101 | } | |
| 105 | - if (!isUint32(value)) { | ||
| 106 | - if (!NumberIsInteger(value)) { | ||
| 107 | - throw new ERR_OUT_OF_RANGE(name, 'an integer', value); | ||
| 108 | - } | ||
| 109 | - const min = positive ? 1 : 0; | ||
| 110 | - // 2 ** 32 === 4294967296 | ||
| 111 | - throw new ERR_OUT_OF_RANGE(name, `>= ${min} && < 4294967296`, value); | ||
| 102 | + if (!NumberIsInteger(value)) { | ||
| 103 | + throw new ERR_OUT_OF_RANGE(name, 'an integer', value); | ||
| 112 | 104 | } | |
| 113 | - if (positive && value === 0) { | ||
| 114 | - throw new ERR_OUT_OF_RANGE(name, '>= 1 && < 4294967296', value); | ||
| 105 | + const min = positive ? 1 : 0; | ||
| 106 | + // 2 ** 32 === 4294967296 | ||
| 107 | + const max = 4_294_967_295; | ||
| 108 | + if (value < min || value > max) { | ||
| 109 | + throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value); | ||
| 115 | 110 | } | |
| 116 | 111 | }); | |
| 117 | 112 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -69,8 +69,6 @@ for (const iterations of [-1, 0]) { | |||
| 69 | 69 | { | |
| 70 | 70 | code: 'ERR_OUT_OF_RANGE', | |
| 71 | 71 | name: 'RangeError', | |
| 72 | - message: 'The value of "iterations" is out of range. ' + | ||
| 73 | - `It must be >= 1 && < 4294967296. Received ${iterations}` | ||
| 74 | 72 | } | |
| 75 | 73 | ); | |
| 76 | 74 | } | |
@@ -108,8 +106,6 @@ for (const iterations of [-1, 0]) { | |||
| 108 | 106 | }, { | |
| 109 | 107 | code: 'ERR_OUT_OF_RANGE', | |
| 110 | 108 | name: 'RangeError', | |
| 111 | - message: 'The value of "keylen" is out of range. It must be >= 0 && < ' + | ||
| 112 | - `4294967296. Received ${input === -1 ? '-1' : '4_294_967_297'}` | ||
| 113 | 109 | }); | |
| 114 | 110 | }); | |
| 115 | 111 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,27 +13,28 @@ const { | |||
| 13 | 13 | } = require('fs'); | |
| 14 | 14 | ||
| 15 | 15 | // These should throw, not crash. | |
| 16 | + const invalid = 4_294_967_296; | ||
| 16 | 17 | ||
| 17 | - assert.throws(() => open(__filename, 2176057344, common.mustNotCall()), { | ||
| 18 | + assert.throws(() => open(__filename, invalid, common.mustNotCall()), { | ||
| 18 | 19 | code: 'ERR_OUT_OF_RANGE' | |
| 19 | 20 | }); | |
| 20 | 21 | ||
| 21 | - assert.throws(() => open(__filename, 0, 2176057344, common.mustNotCall()), { | ||
| 22 | + assert.throws(() => open(__filename, 0, invalid, common.mustNotCall()), { | ||
| 22 | 23 | code: 'ERR_OUT_OF_RANGE' | |
| 23 | 24 | }); | |
| 24 | 25 | ||
| 25 | - assert.throws(() => openSync(__filename, 2176057344), { | ||
| 26 | + assert.throws(() => openSync(__filename, invalid), { | ||
| 26 | 27 | code: 'ERR_OUT_OF_RANGE' | |
| 27 | 28 | }); | |
| 28 | 29 | ||
| 29 | - assert.throws(() => openSync(__filename, 0, 2176057344), { | ||
| 30 | + assert.throws(() => openSync(__filename, 0, invalid), { | ||
| 30 | 31 | code: 'ERR_OUT_OF_RANGE' | |
| 31 | 32 | }); | |
| 32 | 33 | ||
| 33 | - assert.rejects(openPromise(__filename, 2176057344), { | ||
| 34 | + assert.rejects(openPromise(__filename, invalid), { | ||
| 34 | 35 | code: 'ERR_OUT_OF_RANGE' | |
| 35 | 36 | }); | |
| 36 | 37 | ||
| 37 | - assert.rejects(openPromise(__filename, 0, 2176057344), { | ||
| 38 | + assert.rejects(openPromise(__filename, 0, invalid), { | ||
| 38 | 39 | code: 'ERR_OUT_OF_RANGE' | |
| 39 | 40 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,8 +29,6 @@ assert.throws( | |||
| 29 | 29 | { | |
| 30 | 30 | code: 'ERR_OUT_OF_RANGE', | |
| 31 | 31 | name: 'RangeError', | |
| 32 | - message: 'The value of "groups[1]" is out of range. ' + | ||
| 33 | - 'It must be >= 0 && < 4294967296. Received -1' | ||
| 34 | 32 | } | |
| 35 | 33 | ); | |
| 36 | 34 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -131,11 +131,7 @@ function assertCursorRowsAndCols(rli, rows, cols) { | |||
| 131 | 131 | input, | |
| 132 | 132 | tabSize: 0 | |
| 133 | 133 | }), | |
| 134 | - { | ||
| 135 | - message: 'The value of "tabSize" is out of range. ' + | ||
| 136 | - 'It must be >= 1 && < 4294967296. Received 0', | ||
| 137 | - code: 'ERR_OUT_OF_RANGE' | ||
| 138 | - } | ||
| 134 | + { code: 'ERR_OUT_OF_RANGE' } | ||
| 139 | 135 | ); | |
| 140 | 136 | ||
| 141 | 137 | assert.throws( | |
| Back | FazBrowse Home | New Git URL |
0 commit comments