Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 36.4k
buffer,error: improve bigint, big numbers and more#27228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Uh oh!
There was an error while loading. Please reload this page.
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8dd4ba0
buffer,error: improve bigint, big numbers and more
BridgeAR 1987eeb
fixup! buffer,error: improve bigint, big numbers and more
BridgeAR 9e05154
fixup! buffer,error: improve bigint, big numbers and more
BridgeAR f823287
fixup! buffer,error: improve bigint, big numbers and more
BridgeAR 19aebdc
fixup! buffer,error: improve bigint, big numbers and more
BridgeAR f7c61bb
fixup! buffer,error: improve bigint, big numbers and more
BridgeAR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -10,7 +10,7 @@ | ||
| // value statically and permanently identifies the error. While the error | ||
| // message may change, the code should not. | ||
| const { Object } = primordials; | ||
| const { Object, Math } = primordials; | ||
| const kCode = Symbol('code'); | ||
| const kInfo = Symbol('info'); | ||
| @@ -574,6 +574,17 @@ function oneOf(expected, thing) { | ||
| } | ||
| } | ||
| // Only use this for integers! Decimal numbers do not work with this function. | ||
| function addNumericalSeparator(val) { | ||
| let res = ''; | ||
| let i = val.length; | ||
| const start = val[0] === '-' ? 1 : 0; | ||
| for (; i >= start + 4; i -= 3) { | ||
| res = `_${val.slice(i - 3, i)}${res}`; | ||
| } | ||
| return `${val.slice(0, i)}${res}`; | ||
| } | ||
BridgeAR marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| module.exports = { | ||
| addCodeToName, // Exported for NghttpError | ||
| codes, | ||
| @@ -999,7 +1010,20 @@ E('ERR_OUT_OF_RANGE', | ||
| assert(range, 'Missing "range" argument'); | ||
| let msg = replaceDefaultBoolean ? str : | ||
| `The value of "${str}" is out of range.`; | ||
| msg += ` It must be ${range}. Received ${input}`; | ||
| let received; | ||
| if (Number.isInteger(input) && Math.abs(input) > 2 ** 32) { | ||
| received = addNumericalSeparator(String(input)); | ||
| // eslint-disable-next-line valid-typeof | ||
| } else if (typeof input === 'bigint') { | ||
| received = String(input); | ||
| if (input > 2n ** 32n || input < -(2n ** 32n)) { | ||
| received = addNumericalSeparator(received); | ||
| } | ||
| received += 'n'; | ||
| } else { | ||
| received = lazyInternalUtilInspect().inspect(input); | ||
| } | ||
| msg += ` It must be ${range}. Received ${received}`; | ||
| return msg; | ||
| }, RangeError); | ||
| E('ERR_REQUIRE_ESM', 'Must use import to load ES Module: %s', Error); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.