Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added BigInt support #197

Merged
merged 3 commits into from Dec 15, 2019
Merged

Added BigInt support #197

merged 3 commits into from Dec 15, 2019

Conversation

delvedor
Copy link
Member

As titled! 馃殌

Checklist

  • run npm run test and npm run benchmark
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message and code follows Code of conduct

@delvedor delvedor added the semver-minor Issue or PR that should land as semver minor label Dec 14, 2019
@delvedor delvedor requested a review from a team December 14, 2019 13:06
@@ -214,6 +214,8 @@ function $asNull () {
function $asInteger (i) {
if (isLong && isLong(i)) {
return i.toString()
} else if (typeof i === 'bigint') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library currently tests all the way back to Node 6 --

matrix:
node_6_x:
node_version: 6.x
node_8_x:
node_version: 8.x
node_10_x:
node_version: 10.x
node_11_x:
node_version: 11.x

What will this line do on < 10.13?

Copy link
Member Author

@delvedor delvedor Dec 14, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing, it's just a string comparison, which means that it will always be false.
Anyhow, we will drop Node v6 and v8 once we release Fastify v3 :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. But it still has to work for the versions this will actually target.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does, as you can see all the tests are passing :)
You can use the BigInt syntax only from Node 10.4 and above.
In any other case the typeof will return something else, so the if will never be true.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

if (semver.gt(process.versions.node, '10.3.0')) {
require('./bigint')(t.test, build)
} else {
t.pass('Skip because Node version < 10.4')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn鈥檛 there be at least one test here to show the behavior on old versions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fear that I鈥檓 missing something. Can you propose a test?
As I said above, this is a good old typeof, which will work in any Node version.
In version ma older than 10.4 you can鈥檛 use the BigInt syntax.

@delvedor delvedor merged commit 2da2121 into master Dec 15, 2019
@delvedor delvedor deleted the bigint branch December 15, 2019 17:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-minor Issue or PR that should land as semver minor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants