| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent f700074 commit 4968ebf
7 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 | |
|---|---|---|---|
@@ -67,7 +67,7 @@ function parseFileMode(value, name, def) { | |||
| 67 | 67 | value = NumberParseInt(value, 8); | |
| 68 | 68 | } | |
| 69 | 69 | ||
| 70 | - validateInt32(value, name, 0, 2 ** 32 - 1); | ||
| 70 | + validateUint32(value, name); | ||
| 71 | 71 | return value; | |
| 72 | 72 | } | |
| 73 | 73 | ||
@@ -88,11 +88,8 @@ const validateInt32 = hideStackFrames( | |||
| 88 | 88 | if (typeof value !== 'number') { | |
| 89 | 89 | throw new ERR_INVALID_ARG_TYPE(name, 'number', value); | |
| 90 | 90 | } | |
| 91 | - if (!isInt32(value)) { | ||
| 92 | - if (!NumberIsInteger(value)) { | ||
| 93 | - throw new ERR_OUT_OF_RANGE(name, 'an integer', value); | ||
| 94 | - } | ||
| 95 | - throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value); | ||
| 91 | + if (!NumberIsInteger(value)) { | ||
| 92 | + throw new ERR_OUT_OF_RANGE(name, 'an integer', value); | ||
| 96 | 93 | } | |
| 97 | 94 | if (value < min || value > max) { | |
| 98 | 95 | throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value); | |
@@ -104,16 +101,14 @@ const validateUint32 = hideStackFrames((value, name, positive) => { | |||
| 104 | 101 | if (typeof value !== 'number') { | |
| 105 | 102 | throw new ERR_INVALID_ARG_TYPE(name, 'number', value); | |
| 106 | 103 | } | |
| 107 | - if (!isUint32(value)) { | ||
| 108 | - if (!NumberIsInteger(value)) { | ||
| 109 | - throw new ERR_OUT_OF_RANGE(name, 'an integer', value); | ||
| 110 | - } | ||
| 111 | - const min = positive ? 1 : 0; | ||
| 112 | - // 2 ** 32 === 4294967296 | ||
| 113 | - throw new ERR_OUT_OF_RANGE(name, `>= ${min} && < 4294967296`, value); | ||
| 104 | + if (!NumberIsInteger(value)) { | ||
| 105 | + throw new ERR_OUT_OF_RANGE(name, 'an integer', value); | ||
| 114 | 106 | } | |
| 115 | - if (positive && value === 0) { | ||
| 116 | - throw new ERR_OUT_OF_RANGE(name, '>= 1 && < 4294967296', value); | ||
| 107 | + const min = positive ? 1 : 0; | ||
| 108 | + // 2 ** 32 === 4294967296 | ||
| 109 | + const max = 4_294_967_295; | ||
| 110 | + if (value < min || value > max) { | ||
| 111 | + throw new ERR_OUT_OF_RANGE(name, `>= ${min} && <= ${max}`, value); | ||
| 117 | 112 | } | |
| 118 | 113 | }); | |
| 119 | 114 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1131,8 +1131,6 @@ const sec1EncExp = (cipher) => getRegExpForPEM('EC PRIVATE KEY', cipher); | |||
| 1131 | 1131 | }, common.mustNotCall()), { | |
| 1132 | 1132 | name: 'TypeError', | |
| 1133 | 1133 | code: 'ERR_INVALID_ARG_VALUE', | |
| 1134 | - message: "The property 'options.modulusLength' is invalid. " + | ||
| 1135 | - `Received ${inspect(modulusLength)}` | ||
| 1136 | 1134 | }); | |
| 1137 | 1135 | } | |
| 1138 | 1136 | ||
| 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