Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
6 changes: 5 additions & 1 deletion build/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ function processFile (inputLoc, out, replacements) {

data = data.toString()
replacements.forEach(function (replacement) {
data = data.replace.apply(data, replacement)
const regexp = replacement[0]
var arg2 = replacement[1]
if (typeof arg2 === 'function')
arg2 = arg2.bind(data)
data = data.replace(regexp, arg2)
})
if (inputLoc.slice(-3) === '.js') {
const transformed = babel.transform(data, {
Expand Down
20 changes: 20 additions & 0 deletions build/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,23 @@ const headRegexp = /(^module.exports = \w+;?)/m
/if \(typeof Symbol === 'function' && Symbol\.hasInstance\) \{/,
`if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {`
]
, removeOnWriteBind = [
/onwrite\.bind\([^)]+?\)/,
`function(er) { onwrite(stream, er); }`
]
, removeCorkedFinishBind = [
/onCorkedFinish\.bind\([^)]+?\)/,
function (match) {
const code = this
var src = /^function onCorkedFinish[^{]*?\{([\s\S]+?\r?\n)\}/m.exec(code)
src = src[1].trim().replace(/corkReq/g, 'this').replace(/(\r?\n)/mg, ' $1')
return `(err) => {\n${src}\n}`
}
]
, removeOnCorkedFinish = [
/^function onCorkedFinish[\s\S]+?\r?\n\}/m,
''
]

module.exports['_stream_duplex.js'] = [
requireReplacement
Expand Down Expand Up @@ -261,6 +278,9 @@ module.exports['_stream_writable.js'] = [
, bufferShimFix
, bufferStaticMethods
, fixInstanceCheck
, removeOnWriteBind
, removeCorkedFinishBind
, removeOnCorkedFinish
]
module.exports['internal/streams/BufferList.js'] = [
bufferShimFix
Expand Down