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

perf: use node: prefix to bypass require.cache call for builtins #56

Merged
merged 3 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion benchmark/create.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Module dependencies.
*/
Expand Down
6 changes: 3 additions & 3 deletions benchmark/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs')
const path = require('path')
const spawn = require('child_process').spawn
const fs = require('node:fs')
const path = require('node:path')
const spawn = require('node:child_process').spawn

const exe = process.argv[0]
const cwd = process.cwd()
Expand Down
1 change: 0 additions & 1 deletion benchmark/secret.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Module dependencies.
*/
Expand Down
1 change: 0 additions & 1 deletion benchmark/verify.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

/**
* Module dependencies.
*/
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* MIT Licensed
*/

const crypto = require('crypto')
const crypto = require('node:crypto')

/**
* Token generation/verification class.
Expand Down
8 changes: 4 additions & 4 deletions test/secret.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ test('Tokens.secret: should handle error, Promise', t => {
t.plan(2)

const Tokens = mock('..', {
crypto: {
'node:crypto': {
randomBytes: (_size, cb) => {
cb(new Error('oh no'))
},
createHash: require('crypto').createHash
createHash: require('node:crypto').createHash
}
})

Expand All @@ -94,11 +94,11 @@ test('Tokens.secret: should handle error, callback', t => {
t.plan(2)

const Tokens = mock('..', {
crypto: {
'node:crypto': {
randomBytes: (size, cb) => {
cb(new Error('oh no'))
},
createHash: require('crypto').createHash
createHash: require('node:crypto').createHash
}
})

Expand Down