Skip to content

Commit

Permalink
rename factory method to create()
Browse files Browse the repository at this point in the history
  • Loading branch information
andrasq committed Feb 22, 2019
1 parent 67bfcc4 commit b3a1737
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -65,7 +65,7 @@ name, interoperate with Buffers, and are `instanceof Buffer`. Reversible with `
Restore the global Buffer to the original that was in effect when `sane-buffer` was loaded
(ie, back to OBuffer._Buffer).

### OBuffer._create( arg, [encodingOrOffset, [length]] )
### OBuffer.create( arg, [encodingOrOffset, [length]] )

The factory used internally by the constructor to construct new Buffers. The factory either
uses `new Buffer` or calls a factory method, depending on which is supported in the current
Expand Down
4 changes: 2 additions & 2 deletions sane-buffer.js
Expand Up @@ -17,7 +17,7 @@ var nodeVersion = parseInt(process.version.slice(1)); // version is mocked by
module.exports = OBuffer;

function OBuffer( arg, encOrOffs, length ) {
return _typeconvert(OBuffer._create(arg, encOrOffs, length));
return _typeconvert(OBuffer.create(arg, encOrOffs, length));
}
util.inherits(OBuffer, Buffer);

Expand All @@ -40,7 +40,7 @@ OBuffer.concat = function(list, length) { return _typeconvert(Buffer.concat(list
OBuffer.safe = false;
OBuffer.install = function() { global.Buffer = OBuffer }
OBuffer.uninstall = function() { global.Buffer = Buffer }
OBuffer._create = function _create( arg, encOrOffs, length ) {
OBuffer.create = function create( arg, encOrOffs, length ) {
// node through v9 supported the old constructor semantics, 10 and up deprecate it
return (
(nodeVersion < 10) ? (OBuffer.safe && _isNumber(arg)) ? _fill0(new Buffer(arg)) : new Buffer(arg, encOrOffs, length) :
Expand Down

0 comments on commit b3a1737

Please sign in to comment.