Skip to content

Commit

Permalink
perf: use node: prefix to bypass require.cache call for builtins (f…
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs authored Sep 10, 2023
1 parent b3bea04 commit 7502cb3
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion benchmark/bench.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const redisStoreFactory = require('connect-redis')
const Fastify = require('fastify')
const Redis = require('ioredis')
const fileStoreFactory = require('session-file-store')
const { isMainThread } = require('worker_threads')
const { isMainThread } = require('node:worker_threads')

const fastifySession = require('..')
const fastifyCookie = require('@fastify/cookie')
Expand Down
2 changes: 1 addition & 1 deletion lib/idGenerator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

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

const cacheSize = 24 << 7
let pos = 0
Expand Down
2 changes: 1 addition & 1 deletion lib/session.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'

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

const Cookie = require('./cookie')
const { configure: configureStringifier } = require('safe-stable-stringify')
Expand Down
4 changes: 2 additions & 2 deletions lib/store.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const EventEmitter = require('events').EventEmitter
const util = require('util')
const EventEmitter = require('node:events').EventEmitter
const util = require('node:util')

function Store (storeMap = new Map()) {
this.store = storeMap
Expand Down
2 changes: 1 addition & 1 deletion test/fastifySession.checkOptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const test = require('tap').test
const Fastify = require('fastify')
const fastifyCookie = require('@fastify/cookie')
const fastifySession = require('..')
const crypto = require('crypto')
const crypto = require('node:crypto')

test('fastifySession.checkOptions: register should fail if no secret is specified', async t => {
t.plan(1)
Expand Down
2 changes: 1 addition & 1 deletion test/memorystore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const test = require('tap').test
const { MemoryStore } = require('../lib/store')
const { EventEmitter } = require('stream')
const { EventEmitter } = require('node:stream')

test('MemoryStore.constructor: created MemoryStore should be an EventEmitter', (t) => {
t.plan(2)
Expand Down

0 comments on commit 7502cb3

Please sign in to comment.