Skip to content

Commit

Permalink
perf: use node: prefix to bypass require.cache call for builtins (#125
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Fdawgs authored Sep 10, 2023
1 parent 06bad11 commit 47291c4
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 44 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ Examples
* Parsing (multipart) with default options:

```javascript
const http = require('http');
const { inspect } = require('util');
const http = require('node:http');
const { inspect } = require('node:util');
const Busboy = require('busboy');

http.createServer((req, res) => {
Expand Down Expand Up @@ -103,10 +103,10 @@ http.createServer((req, res) => {
* Save all incoming files to disk:

```javascript
const http = require('http');
const path = require('path');
const os = require('os');
const fs = require('fs');
const http = require('node:http');
const path = require('node:path');
const os = require('node:os');
const fs = require('node:fs');

const Busboy = require('busboy');

Expand All @@ -133,8 +133,8 @@ http.createServer(function(req, res) {
* Parsing (urlencoded) with default options:

```javascript
const http = require('http');
const { inspect } = require('util');
const http = require('node:http');
const { inspect } = require('node:util');

const Busboy = require('busboy');

Expand Down
2 changes: 1 addition & 1 deletion bench/dicer/multiparty-bench-multipart-parser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var assert = require('assert'),
var assert = require('node:assert'),
Form = require('multiparty').Form,
boundary = '-----------------------------168072824752491622650073',
mb = 100,
Expand Down
2 changes: 1 addition & 1 deletion bench/dicer/parted-bench-multipart-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// because otherwise it attempts to do some things above and beyond just parsing
// -- like saving to disk and whatnot

var assert = require('assert');
var assert = require('node:assert');
var Parser = require('./parted-multipart'),
boundary = '-----------------------------168072824752491622650073',
parser = new Parser('boundary=' + boundary),
Expand Down
8 changes: 4 additions & 4 deletions bench/dicer/parted-multipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Copyright (c) 2011, Christopher Jeffrey. (MIT Licensed)
*/

var fs = require('fs')
, path = require('path')
, EventEmitter = require('events').EventEmitter
, StringDecoder = require('string_decoder').StringDecoder
var fs = require('node:fs')
, path = require('node:path')
, EventEmitter = require('node:events').EventEmitter
, StringDecoder = require('node:string_decoder').StringDecoder
, set = require('qs').set
, each = Array.prototype.forEach;

Expand Down
4 changes: 2 additions & 2 deletions benchmarks/common/resultsCombinator.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs')
const path = require('path')
const fs = require('node:fs')
const path = require('node:path')
const getopts = require('getopts')
const systemInformation = require('systeminformation')
const { loadResults } = require('photofinish')
Expand Down
4 changes: 2 additions & 2 deletions deps/dicer/lib/Dicer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const WritableStream = require('stream').Writable
const inherits = require('util').inherits
const WritableStream = require('node:stream').Writable
const inherits = require('node:util').inherits

const StreamSearch = require('../../streamsearch/sbmh')

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

const EventEmitter = require('events').EventEmitter
const inherits = require('util').inherits
const EventEmitter = require('node:events').EventEmitter
const inherits = require('node:util').inherits
const getLimit = require('../../../lib/utils/getLimit')

const StreamSearch = require('../../streamsearch/sbmh')
Expand Down
4 changes: 2 additions & 2 deletions deps/dicer/lib/PartStream.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const inherits = require('util').inherits
const ReadableStream = require('stream').Readable
const inherits = require('node:util').inherits
const ReadableStream = require('node:stream').Readable

function PartStream (opts) {
ReadableStream.call(this, opts)
Expand Down
4 changes: 2 additions & 2 deletions deps/streamsearch/sbmh.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
* Based heavily on the Streaming Boyer-Moore-Horspool C++ implementation
* by Hongli Lai at: https://github.com/FooBarWidget/boyer-moore-horspool
*/
const EventEmitter = require('events').EventEmitter
const inherits = require('util').inherits
const EventEmitter = require('node:events').EventEmitter
const inherits = require('node:util').inherits

function SBMH (needle) {
if (typeof needle === 'string') {
Expand Down
4 changes: 2 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

const WritableStream = require('stream').Writable
const { inherits } = require('util')
const WritableStream = require('node:stream').Writable
const { inherits } = require('node:util')
const Dicer = require('../deps/dicer/lib/Dicer')

const MultipartParser = require('./types/multipart')
Expand Down
4 changes: 2 additions & 2 deletions lib/types/multipart.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// * support limits.fieldNameSize
// -- this will require modifications to utils.parseParams

const { Readable } = require('stream')
const { inherits } = require('util')
const { Readable } = require('node:stream')
const { inherits } = require('node:util')

const Dicer = require('../../deps/dicer/lib/Dicer')

Expand Down
8 changes: 4 additions & 4 deletions test/dicer-multipart-extra-trailer.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const Dicer = require('../deps/dicer/lib/Dicer')
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const inspect = require('util').inspect
const assert = require('node:assert')
const fs = require('node:fs')
const path = require('node:path')
const inspect = require('node:util').inspect

const FIXTURES_ROOT = path.join(__dirname, 'fixtures/')

Expand Down
8 changes: 4 additions & 4 deletions test/dicer-multipart-nolisteners.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const Dicer = require('../deps/dicer/lib/Dicer')
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const inspect = require('util').inspect
const assert = require('node:assert')
const fs = require('node:fs')
const path = require('node:path')
const inspect = require('node:util').inspect

const FIXTURES_ROOT = path.join(__dirname, 'fixtures/')

Expand Down
8 changes: 4 additions & 4 deletions test/dicer-multipart.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const Dicer = require('../deps/dicer/lib/Dicer')
const assert = require('assert')
const fs = require('fs')
const path = require('path')
const inspect = require('util').inspect
const assert = require('node:assert')
const fs = require('node:fs')
const path = require('node:path')
const inspect = require('node:util').inspect

const FIXTURES_ROOT = path.join(__dirname, 'fixtures/')

Expand Down
2 changes: 1 addition & 1 deletion test/multipart-stream-pause.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { inspect } = require('util')
const { inspect } = require('node:util')
const { assert } = require('chai')
const Busboy = require('..')

Expand Down
2 changes: 1 addition & 1 deletion test/parse-params.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { inspect } = require('util')
const { inspect } = require('node:util')
const { assert } = require('chai')
const parseParams = require('../lib/utils/parseParams')

Expand Down
2 changes: 1 addition & 1 deletion test/types-multipart.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Busboy = require('..')

const { inspect } = require('util')
const { inspect } = require('node:util')
const { assert } = require('chai')

const EMPTY_FN = function () {
Expand Down
2 changes: 1 addition & 1 deletion test/types-urlencoded.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { inspect } = require('util')
const { inspect } = require('node:util')
const { assert } = require('chai')
const Busboy = require('..')

Expand Down

0 comments on commit 47291c4

Please sign in to comment.