Skip to content

Commit

Permalink
perf: use node: prefix to bypass require.cache call for builtins
Browse files Browse the repository at this point in the history
  • Loading branch information
Fdawgs committed Sep 10, 2023
1 parent 2c633c3 commit a79c3f9
Show file tree
Hide file tree
Showing 24 changed files with 85 additions and 85 deletions.
4 changes: 2 additions & 2 deletions examples/example-legacy.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict'

const fastify = require('fastify')()
const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')
const pump = require('pump')
const form = path.join(__dirname, '..', 'form.html')

Expand Down
8 changes: 4 additions & 4 deletions examples/example.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
'use strict'

const fastify = require('fastify')()
const fs = require('fs')
const util = require('util')
const path = require('path')
const { pipeline } = require('stream')
const fs = require('node:fs')
const util = require('node:util')
const path = require('node:path')
const { pipeline } = require('node:stream')
const pump = util.promisify(pipeline)
const form = path.join(__dirname, '..', 'form.html')

Expand Down
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
'use strict'

const Busboy = require('@fastify/busboy')
const os = require('os')
const os = require('node:os')
const fp = require('fastify-plugin')
const eos = require('end-of-stream')
const { createWriteStream } = require('fs')
const { unlink } = require('fs').promises
const path = require('path')
const { createWriteStream } = require('node:fs')
const { unlink } = require('node:fs').promises
const path = require('node:path')
const { generateId } = require('./lib/generateId')
const util = require('util')
const util = require('node:util')
const createError = require('@fastify/error')
const sendToWormhole = require('stream-wormhole')
const deepmergeAll = require('@fastify/deepmerge')({ all: true })
const { PassThrough, pipeline, Readable } = require('stream')
const { PassThrough, pipeline, Readable } = require('node:stream')
const pump = util.promisify(pipeline)
const secureJSON = require('secure-json-parse')

Expand Down
4 changes: 2 additions & 2 deletions test/big.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const http = require('node:http')
const stream = require('readable-stream')
const Readable = stream.Readable
const pump = stream.pipeline
const crypto = require('crypto')
const crypto = require('node:crypto')
const sendToWormhole = require('stream-wormhole')

// skipping on Github Actions because it takes too long
Expand Down
10 changes: 5 additions & 5 deletions test/fix-313.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const { access } = require('fs').promises
const EventEmitter = require('events')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const { access } = require('node:fs').promises
const EventEmitter = require('node:events')
const { once } = EventEmitter

const filePath = path.join(__dirname, '../README.md')
Expand Down
6 changes: 3 additions & 3 deletions test/legacy/append-body.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('./../..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const pump = require('pump')

const filePath = path.join(__dirname, '..', '..', 'README.md')
Expand Down
4 changes: 2 additions & 2 deletions test/legacy/big.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('./../..')
const http = require('http')
const http = require('node:http')
const stream = require('readable-stream')
const Readable = stream.Readable
const Writable = stream.Writable
const pump = stream.pipeline
const eos = stream.finished
const crypto = require('crypto')
const crypto = require('node:crypto')

// skipping on Github Actions because it takes too long
test('should upload a big file in constant memory', { skip: process.env.CI }, function (t) {
Expand Down
8 changes: 4 additions & 4 deletions test/legacy/multipart.test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'
const os = require('os')
const os = require('node:os')
const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('./../..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const concat = require('concat-stream')
const stream = require('readable-stream')
const pump = stream.pipeline
Expand Down
8 changes: 4 additions & 4 deletions test/multipart-ajv-file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
const test = require('tap').test
const Fastify = require('fastify')
const FormData = require('form-data')
const http = require('http')
const http = require('node:http')
const multipart = require('..')
const { once } = require('events')
const fs = require('fs')
const path = require('path')
const { once } = require('node:events')
const fs = require('node:fs')
const path = require('node:path')

const filePath = path.join(__dirname, '../README.md')

Expand Down
10 changes: 5 additions & 5 deletions test/multipart-attach-body.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const { once } = require('events')
const { Readable } = require('stream')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const { once } = require('node:events')
const { Readable } = require('node:stream')
const pump = require('pump')
const { writableNoopStream } = require('noop-stream')

Expand Down
6 changes: 3 additions & 3 deletions test/multipart-big-stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const crypto = require('crypto')
const http = require('node:http')
const crypto = require('node:crypto')
const { Readable } = require('readable-stream')
const sendToWormhole = require('stream-wormhole')
const EventEmitter = require('events')
const EventEmitter = require('node:events')
const { once } = EventEmitter

test('should emit fileSize limitation error during streaming', async function (t) {
Expand Down
6 changes: 3 additions & 3 deletions test/multipart-body-schema.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')

const filePath = path.join(__dirname, '../README.md')

Expand Down
6 changes: 3 additions & 3 deletions test/multipart-concat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')

const filePath = path.join(__dirname, '../README.md')

Expand Down
12 changes: 6 additions & 6 deletions test/multipart-disk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const crypto = require('crypto')
const http = require('node:http')
const crypto = require('node:crypto')
const { Readable } = require('readable-stream')
const path = require('path')
const fs = require('fs')
const { access } = require('fs').promises
const EventEmitter = require('events')
const path = require('node:path')
const fs = require('node:fs')
const { access } = require('node:fs').promises
const EventEmitter = require('node:events')
const { once } = EventEmitter

const filePath = path.join(__dirname, '../README.md')
Expand Down
8 changes: 4 additions & 4 deletions test/multipart-duplicate-save-request-file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const EventEmitter = require('events')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const EventEmitter = require('node:events')
const { once } = EventEmitter

const filePath = path.join(__dirname, '../README.md')
Expand Down
4 changes: 2 additions & 2 deletions test/multipart-empty-body.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const { once } = require('events')
const http = require('node:http')
const { once } = require('node:events')

test('should not break with a empty request body when attachFieldsToBody is true', async function (t) {
t.plan(5)
Expand Down
8 changes: 4 additions & 4 deletions test/multipart-fileLimit.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict'

const fs = require('fs')
const crypto = require('crypto')
const fs = require('node:fs')
const crypto = require('node:crypto')
const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const EventEmitter = require('events')
const http = require('node:http')
const EventEmitter = require('node:events')
const { once } = EventEmitter

test('should throw fileSize limitation error when consuming the stream', async function (t) {
Expand Down
4 changes: 2 additions & 2 deletions test/multipart-http2.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const h2url = require('h2url')
const path = require('path')
const fs = require('fs')
const path = require('node:path')
const fs = require('node:fs')
const sendToWormhole = require('stream-wormhole')

const filePath = path.join(__dirname, '../README.md')
Expand Down
6 changes: 3 additions & 3 deletions test/multipart-incomplete-upload.test.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'

const util = require('util')
const util = require('node:util')
const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const http = require('node:http')
const sleep = util.promisify(setTimeout)
const { writableNoopStream } = require('noop-stream')
const stream = require('stream')
const stream = require('node:stream')
const pipeline = util.promisify(stream.pipeline)

test('should finish with error on partial upload', async function (t) {
Expand Down
2 changes: 1 addition & 1 deletion test/multipart-json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const http = require('node:http')

test('should parse JSON fields forms if content-type is set', function (t) {
t.plan(5)
Expand Down
10 changes: 5 additions & 5 deletions test/multipart-security.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const crypto = require('crypto')
const EventEmitter = require('events')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const crypto = require('node:crypto')
const EventEmitter = require('node:events')
const { once } = EventEmitter

const filePath = path.join(__dirname, '../README.md')
Expand Down
8 changes: 4 additions & 4 deletions test/multipart-small-stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const EventEmitter = require('events')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const EventEmitter = require('node:events')
const sendToWormhole = require('stream-wormhole')
const { once } = EventEmitter

Expand Down
12 changes: 6 additions & 6 deletions test/multipart.test.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
'use strict'

const util = require('util')
const util = require('node:util')
const test = require('tap').test
const FormData = require('form-data')
const Fastify = require('fastify')
const multipart = require('..')
const http = require('http')
const path = require('path')
const fs = require('fs')
const http = require('node:http')
const path = require('node:path')
const fs = require('node:fs')
const concat = require('concat-stream')
const stream = require('stream')
const { once } = require('events')
const stream = require('node:stream')
const { once } = require('node:events')
const pump = util.promisify(stream.pipeline)
const sendToWormhole = require('stream-wormhole')

Expand Down
4 changes: 2 additions & 2 deletions tester.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const http = require('http')
const Readable = require('stream').Readable
const http = require('node:http')
const Readable = require('node:stream').Readable
const FormData = require('form-data')
const pump = require('pump')
const knownLength = 1024 * 1024 * 1024
Expand Down

0 comments on commit a79c3f9

Please sign in to comment.