Skip to content

Commit

Permalink
node 20
Browse files Browse the repository at this point in the history
  - Add github node 20 test scenario
  - Added native fallback for uuidv4
    - test native fallback
  - replace nyc by c8
  - update dev dependencies
  - wrong contributors link
  • Loading branch information
vademo committed Aug 9, 2023
1 parent 2dd6c13 commit 20f9cda
Show file tree
Hide file tree
Showing 6 changed files with 2,029 additions and 4,418 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x, 14.x, 16.x, 18.x]
node-version: [12.x, 14.x, 16.x, 18.x, 20.x]
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ Pull requests are always welcome, however keep the following things in mind:
* Olivier Van den Mooter (<olivier.vandenmooter@digipolis.be>) - Initial work - [Vademo](https://github.com/vademo)
See also the list of [contributors](https://github.com/digipolisantwerp/authz_module_nodejs/graphs/contributors) who participated in this project.
See also the list of [contributors](https://github.com/digipolisantwerp/log_module_nodejs/graphs/contributors) who participated in this project.
## License
Expand Down
14 changes: 11 additions & 3 deletions lib/helpers/uuid.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
const crypto = require('crypto');

const hasRandomUUID = !!crypto.randomUUID;
function uuidv4js() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'
.replace(/[xy]/g, (c) => {
const r = Math.floor(Math.random() * 16);
// eslint-disable-next-line no-bitwise
const v = (c === 'x') ? r : ((r & 0x3) | 0x8);
return v.toString(16);
});
}

function uuidV4() {
const hasRandomUUID = !!crypto.randomUUID;
if (hasRandomUUID) return crypto.randomUUID();
/* istanbul ignore next */
return '';
return uuidv4js();
}

module.exports = {
Expand Down

0 comments on commit 20f9cda

Please sign in to comment.