From d9574cc562ac454173503caa7b4a328d69ec5b32 Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Sun, 10 Sep 2023 08:31:35 +0100 Subject: [PATCH] perf: use `node:` prefix to bypass require.cache call for builtins See https://github.com/fastify/fastify-static/pull/407 --- benchmark/index.js | 6 +++--- index.js | 2 +- test/secret.test.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/benchmark/index.js b/benchmark/index.js index fb820ca..56c0fe3 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -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() diff --git a/index.js b/index.js index 40c45a3..9ca4edd 100644 --- a/index.js +++ b/index.js @@ -8,7 +8,7 @@ * MIT Licensed */ -const crypto = require('crypto') +const crypto = require('node:crypto') /** * Token generation/verification class. diff --git a/test/secret.test.js b/test/secret.test.js index ca50ddc..ff06b1a 100644 --- a/test/secret.test.js +++ b/test/secret.test.js @@ -80,7 +80,7 @@ test('Tokens.secret: should handle error, Promise', t => { randomBytes: (_size, cb) => { cb(new Error('oh no')) }, - createHash: require('crypto').createHash + createHash: require('node:crypto').createHash } }) @@ -98,7 +98,7 @@ test('Tokens.secret: should handle error, callback', t => { randomBytes: (size, cb) => { cb(new Error('oh no')) }, - createHash: require('crypto').createHash + createHash: require('node:crypto').createHash } })