Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions lib/internal/patches/process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* wraps the internal process module, circumventing issues with some polyfills (see #539) */

/** @type {import('node:process')} */
const process = ((base, esmKey, keys, isValid) => {
// check if top-level es module, in which case it may have a default export
if (esmKey in base && base[esmKey] === true) {
let candidate
for (const key of keys) {
if (!(key in base)) {
continue
}
candidate = base[key]
// sanity check
if (isValid(candidate)) {
return candidate
}
}
}
return base
})(
require('process/'),
'__esModule',
['default', 'process'],
(candidate) => 'nextTick' in candidate
)

module.exports = process
2 changes: 1 addition & 1 deletion lib/internal/streams/destroy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* replacement start */

const process = require('process/')
const process = require('../patches/process')

/* replacement end */

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/duplexify.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* replacement start */

const process = require('process/')
const process = require('../patches/process')

/* replacement end */

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/end-of-stream.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* replacement start */

const process = require('process/')
const process = require('../patches/process')

/* replacement end */
// Ported from https://github.com/mafintosh/end-of-stream with
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/from.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/* replacement start */

const process = require('process/')
const process = require('../patches/process')

/* replacement end */

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/pipeline.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* replacement start */

const process = require('process/')
const process = require('../patches/process')

/* replacement end */
// Ported from https://github.com/mafintosh/pump with
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* replacement start */

const process = require('process/')
const process = require('../patches/process')

/* replacement end */
// Copyright Joyent, Inc. and other Node contributors.
Expand Down
2 changes: 1 addition & 1 deletion lib/internal/streams/writable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* replacement start */

const process = require('process/')
const process = require('../patches/process')

/* replacement end */
// Copyright Joyent, Inc. and other Node contributors.
Expand Down
Loading