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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require Node.js 14.16 #44

Merged
merged 17 commits into from
May 10, 2022
Merged

Conversation

Richienb
Copy link
Contributor

@Richienb Richienb commented Apr 18, 2022

The next Node.js version that will actually allow us to improve the code is v16 which has the web crypto API built-in, and v18 which has it exposed as a global.

Still need to test browser support.

Signed-off-by: Richie Bendall <[email protected]>
Signed-off-by: Richie Bendall <[email protected]>
Signed-off-by: Richie Bendall <[email protected]>
Signed-off-by: Richie Bendall <[email protected]>
Signed-off-by: Richie Bendall <[email protected]>
@Richienb Richienb marked this pull request as ready for review April 21, 2022 04:18
@Richienb
Copy link
Contributor Author

@sindresorhus

Signed-off-by: Richie Bendall <[email protected]>
Signed-off-by: Richie Bendall <[email protected]>
Signed-off-by: Richie Bendall <[email protected]>
test.js Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

Did you test it in the browser? Does the uvu thing run in the browser? If so, which one?

package.json Outdated Show resolved Hide resolved
Co-authored-by: Sindre Sorhus <[email protected]>
@Richienb
Copy link
Contributor Author

Richienb commented Apr 21, 2022

Did you test it in the browser? Does the uvu thing run in the browser? If so, which one?

I switched to uvu since AVA only has implicit test suites which are a bit counterproductive since we're trying to run 2 sets of tests which are exactly the same.

To test browser support, the only browser API that is used, crypto.getRandomValues is polyfilled with the crypto.webcrypto.getRandomValues Node.js API and then the browser code is run in Node.

I've manually verified that the browser code runs in Chrome 100.

@Richienb Richienb changed the title Require Node.js 14 Require Node.js 14.14 Apr 21, 2022
@Richienb Richienb changed the title Require Node.js 14.14 Require Node.js 14.16 Apr 21, 2022
@sindresorhus
Copy link
Owner

I switched to uvu since AVA only has implicit test suites which are a bit counterproductive since we're trying to run 2 sets of tests which are exactly the same.

You can still do that with AVA. I know it's not as nice, but I would strongly prefer to use AVA. Not because I made it, but because it's what I use in all my packages. Probably one day the uvu thing will become unmaintained and I will have to spend time migrating back to AVA. It has happened so many times.

You can just call AVA twice with different argument and check for that in the test file: https://github.com/avajs/ava/blob/main/docs/recipes/passing-arguments-to-your-test-files.md#passing-arguments-to-your-test-files

AVA may some day get nicer ways to do this kind of thing: avajs/ava#2980 And new issues are always welcome if you can think of a nice way for AVA to handle this. Maybe AVA could have some kind of matrix functionality, like GitHub Actions.

@Richienb
Copy link
Contributor Author

Thought I had seen it used in another pull request that was merged but turns out that it wasn't in one of your repos. Will fix.

Signed-off-by: Richie Bendall <[email protected]>
@Richienb
Copy link
Contributor Author

@sindresorhus

@@ -48,7 +48,7 @@ cryptoRandomString({length: 10, characters: 'abc'});

Returns a randomized string. [Hex](https://en.wikipedia.org/wiki/Hexadecimal) by default.

### cryptoRandomString.async(options)
### cryptoRandomStringAsync(options)
Copy link
Owner

Choose a reason for hiding this comment

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

We need to indicate somehow that this is a named export and the other one is a default export.

@sindresorhus
Copy link
Owner

@Richienb bump

@Richienb
Copy link
Contributor Author

Richienb commented May 9, 2022

We need to indicate somehow that this is a named export and the other one is a default export.

This is quite a challenging task, haven't found inspiration from other repositories yet. My initial idea was to make the first function name italic but it didn't appear visible enough.

@sindresorhus
Copy link
Owner

For now, I think the best way is just a code a code example that includes the import.

@Richienb Richienb requested a review from sindresorhus May 9, 2022 12:51
@Richienb
Copy link
Contributor Author

Richienb commented May 9, 2022

Extra sanity check added in Node.js 16.15.0 affected the unit tests, fixed now

@sindresorhus sindresorhus merged commit 2123d11 into sindresorhus:main May 10, 2022
@sindresorhus
Copy link
Owner

Nice work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants