-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
75 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,10 @@ | ||
function SpecificBuffer (_Buffer) { | ||
const Buffer = function () { | ||
if (typeof arguments[0] === 'number') { | ||
return _Buffer.alloc(...arguments); | ||
} | ||
|
||
return _Buffer.from(...arguments); | ||
} | ||
|
||
Buffer.poolSize = _Buffer.poolSize; | ||
|
||
Object.defineProperty(Buffer, Symbol.hasInstance, { | ||
value: function (instance) { | ||
return instance instanceof _Buffer; | ||
} | ||
}); | ||
|
||
Buffer.isBuffer = function () { | ||
return _Buffer.isBuffer(...arguments); | ||
} | ||
|
||
Buffer.alloc = function () { | ||
return _Buffer.alloc(...arguments); | ||
} | ||
|
||
Buffer.allocUnsafe = function () { | ||
return _Buffer.allocUnsafe(...arguments); | ||
} | ||
|
||
Buffer.allocUnsafeSlow = function () { | ||
return _Buffer.allocUnsafeSlow(...arguments); | ||
function getBufferModule (buffer) { | ||
return { | ||
Buffer: buffer.Buffer, | ||
SlowBuffer: buffer.SlowBuffer, | ||
INSPECT_MAX_BYTES: buffer.INSPECT_MAX_BYTES, | ||
kMaxLength: buffer.kMaxLength | ||
} | ||
|
||
Buffer.from = function () { | ||
return _Buffer.from(...arguments); | ||
} | ||
|
||
Buffer.compare = function () { | ||
return _Buffer.compare(...arguments); | ||
} | ||
|
||
Buffer.isEncoding = function () { | ||
return _Buffer.isEncoding(...arguments); | ||
} | ||
|
||
Buffer.concat = function () { | ||
return _Buffer.concat(...arguments); | ||
} | ||
|
||
Buffer.byteLength = function () { | ||
return _Buffer.byteLength(...arguments); | ||
} | ||
|
||
return Buffer; | ||
} | ||
|
||
module.exports = SpecificBuffer; | ||
module.exports = getBufferModule; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
const SpecificBuffer = require('./buffer'); | ||
const getBufferModule = require('./buffer'); | ||
const SpecificBuffer = require('./specific-buffer'); | ||
const buffer = require('buffer/'); | ||
|
||
module.exports = { | ||
Buffer: SpecificBuffer(buffer.Buffer), | ||
SlowBuffer: buffer.SlowBuffer, | ||
INSPECT_MAX_BYTES: buffer.INSPECT_MAX_BYTES, | ||
kMaxLength: buffer.kMaxLength | ||
} | ||
module.exports = getBufferModule({ | ||
...buffer, | ||
Buffer: SpecificBuffer(buffer.Buffer) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
const SpecificBuffer = require('./buffer'); | ||
const getBufferModule = require('./buffer'); | ||
const SpecificBuffer = require('./specific-buffer'); | ||
const buffer = globalThis._nodeRequires.buffer; | ||
|
||
module.exports = { | ||
module.exports = getBufferModule({ | ||
...buffer, | ||
Buffer: SpecificBuffer(globalThis.Buffer), | ||
SlowBuffer: buffer.SlowBuffer, | ||
INSPECT_MAX_BYTES: buffer.INSPECT_MAX_BYTES, | ||
kMaxLength: buffer.kMaxLength | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
function SpecificBuffer (_Buffer) { | ||
const Buffer = function () { | ||
if (typeof arguments[0] === 'number') { | ||
return _Buffer.alloc(...arguments); | ||
} | ||
|
||
return _Buffer.from(...arguments); | ||
} | ||
|
||
Buffer.poolSize = _Buffer.poolSize; | ||
|
||
Object.defineProperty(Buffer, Symbol.hasInstance, { | ||
value: function (instance) { | ||
return instance instanceof _Buffer; | ||
} | ||
}); | ||
|
||
Buffer.isBuffer = function () { | ||
return _Buffer.isBuffer(...arguments); | ||
}; | ||
|
||
Buffer.alloc = function () { | ||
return _Buffer.alloc(...arguments); | ||
}; | ||
|
||
Buffer.allocUnsafe = function () { | ||
return _Buffer.allocUnsafe(...arguments); | ||
}; | ||
|
||
Buffer.allocUnsafeSlow = function () { | ||
return _Buffer.allocUnsafeSlow(...arguments); | ||
}; | ||
|
||
Buffer.from = function () { | ||
return _Buffer.from(...arguments); | ||
}; | ||
|
||
Buffer.compare = function () { | ||
return _Buffer.compare(...arguments); | ||
}; | ||
|
||
Buffer.isEncoding = function () { | ||
return _Buffer.isEncoding(...arguments); | ||
}; | ||
|
||
Buffer.concat = function () { | ||
return _Buffer.concat(...arguments); | ||
}; | ||
|
||
Buffer.byteLength = function () { | ||
return _Buffer.byteLength(...arguments); | ||
}; | ||
|
||
return Buffer; | ||
} | ||
|
||
module.exports = SpecificBuffer; |