From 91a9462249fcc41c65e2c60468316da52d791f4c Mon Sep 17 00:00:00 2001 From: Frazer Smith Date: Sun, 10 Sep 2023 10:28:28 +0100 Subject: [PATCH] perf: use `node:` prefix to bypass require.cache call for builtins (#108) * perf: use `node:` prefix to bypass require.cache call for builtins See https://github.com/fastify/fastify-static/pull/407 * docs: use `node:` prefix to bypass require.cache call for builtins --- README.md | 2 +- examples/basic.js | 2 +- examples/multiple-consumers.js | 2 +- lib/consumer.js | 4 ++-- lib/producer.js | 4 ++-- test/utils.js | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 4614145..7d56fa9 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ npm i @fastify/kafka ### Usage ```js -const crypto = require('crypto') +const crypto = require('node:crypto') const fastify = require('fastify')() const group = crypto.randomBytes(20).toString('hex') diff --git a/examples/basic.js b/examples/basic.js index 6f383a5..8896243 100644 --- a/examples/basic.js +++ b/examples/basic.js @@ -1,6 +1,6 @@ 'use strict' -const crypto = require('crypto') +const crypto = require('node:crypto') const fastify = require('fastify')({ logger: { level: 'debug' diff --git a/examples/multiple-consumers.js b/examples/multiple-consumers.js index 8a4463c..63634f5 100644 --- a/examples/multiple-consumers.js +++ b/examples/multiple-consumers.js @@ -1,6 +1,6 @@ 'use strict' -const crypto = require('crypto') +const crypto = require('node:crypto') const fastifyKafka = require('..') const fastify = require('fastify') diff --git a/lib/consumer.js b/lib/consumer.js index 98352f0..6ffb0fd 100644 --- a/lib/consumer.js +++ b/lib/consumer.js @@ -1,7 +1,7 @@ 'use strict' -const EE = require('events').EventEmitter -const inherits = require('util').inherits +const EE = require('node:events').EventEmitter +const inherits = require('node:util').inherits const Kafka = require('node-rdkafka') function Consumer (opts, log, next, topicConf, metadataOptions) { diff --git a/lib/producer.js b/lib/producer.js index 3c87893..d508802 100644 --- a/lib/producer.js +++ b/lib/producer.js @@ -1,7 +1,7 @@ 'use strict' -const EE = require('events').EventEmitter -const inherits = require('util').inherits +const EE = require('node:events').EventEmitter +const inherits = require('node:util').inherits const Kafka = require('node-rdkafka') function Producer (opts, log, next, topicConf, metadataOptions) { diff --git a/test/utils.js b/test/utils.js index 8e80e3a..1f2891d 100644 --- a/test/utils.js +++ b/test/utils.js @@ -1,6 +1,6 @@ 'use strict' -const crypto = require('crypto') +const crypto = require('node:crypto') module.exports.getDefaultOptions = function getDefaultOptions () { return {