Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Fastpath empty strings
if (+end == start)
return '';
// Use native conversion when possible
if (Buffer.isNativeEncoding(encoding))
return original.SlowBufferToString.call(this, encoding, start, end);
// Otherwise, use our decoding method.
if (typeof start == 'undefined') start = 0;
if (typeof end == 'undefined') end = this.length;
return iconv.decode(this.slice(start, end), encoding);
}
original.SlowBufferWrite = SlowBuffer.prototype.write;
SlowBuffer.prototype.write = function(string, offset, length, encoding) {
// Support both (string, offset, length, encoding)
// and the legacy (string, encoding, offset, length)
if (isFinite(offset)) {
if (!isFinite(length)) {
encoding = length;
length = undefined;
}
} else { // legacy
var swap = encoding;
encoding = offset;
offset = length;
length = swap;
}
offset = +offset || 0;
var remaining = this.length - offset;
original.SlowBufferToString = SlowBuffer.prototype.toString;
SlowBuffer.prototype.toString = function(encoding, start, end) {
encoding = String(encoding || 'utf8').toLowerCase();
// Use native conversion when possible
if (Buffer.isNativeEncoding(encoding))
return original.SlowBufferToString.call(this, encoding, start, end);
// Otherwise, use our decoding method.
if (typeof start == 'undefined') start = 0;
if (typeof end == 'undefined') end = this.length;
return iconv.decode(this.slice(start, end), encoding);
}
original.SlowBufferWrite = SlowBuffer.prototype.write;
SlowBuffer.prototype.write = function(string, offset, length, encoding) {
// Support both (string, offset, length, encoding)
// and the legacy (string, encoding, offset, length)
if (isFinite(offset)) {
if (!isFinite(length)) {
encoding = length;
length = undefined;
}
} else { // legacy
var swap = encoding;
encoding = offset;
offset = length;
length = swap;
}
offset = +offset || 0;
var remaining = this.length - offset;
Buffer.prototype[inspectSym] = overwriteInspect(Buffer.prototype[inspectSym]);
}
// does SlowBuffer inherit from Buffer? (node >= v0.7.9)
if (!(exports.NULL instanceof Buffer)) {
debug('extending SlowBuffer\'s prototype since it doesn\'t inherit from Buffer.prototype');
/*!
* SlowBuffer convenience methods.
*/
var SlowBuffer = require('buffer').SlowBuffer;
SlowBuffer.prototype.address = Buffer.prototype.address;
SlowBuffer.prototype.hexAddress = Buffer.prototype.hexAddress;
SlowBuffer.prototype.isNull = Buffer.prototype.isNull;
SlowBuffer.prototype.ref = Buffer.prototype.ref;
SlowBuffer.prototype.deref = Buffer.prototype.deref;
SlowBuffer.prototype.readObject = Buffer.prototype.readObject;
SlowBuffer.prototype.writeObject = Buffer.prototype.writeObject;
SlowBuffer.prototype.readPointer = Buffer.prototype.readPointer;
SlowBuffer.prototype.writePointer = Buffer.prototype.writePointer;
SlowBuffer.prototype.readCString = Buffer.prototype.readCString;
SlowBuffer.prototype.writeCString = Buffer.prototype.writeCString;
SlowBuffer.prototype.reinterpret = Buffer.prototype.reinterpret;
SlowBuffer.prototype.reinterpretUntilZeros = Buffer.prototype.reinterpretUntilZeros;
SlowBuffer.prototype.readInt64BE = Buffer.prototype.readInt64BE;
SlowBuffer.prototype.writeInt64BE = Buffer.prototype.writeInt64BE;
SlowBuffer.prototype.readUInt64BE = Buffer.prototype.readUInt64BE;
SlowBuffer.prototype.writeUInt64BE = Buffer.prototype.writeUInt64BE;
SlowBuffer.prototype.readInt64LE = Buffer.prototype.readInt64LE;
iconv.undoExtendNodeEncodings = function undoExtendNodeEncodings() {
if (!iconv.supportsNodeEncodingsExtension)
return;
if (!original)
throw new Error("require('iconv-lite').undoExtendNodeEncodings(): Nothing to undo; extendNodeEncodings() is not called.")
delete Buffer.isNativeEncoding;
var SlowBuffer = require('buffer').SlowBuffer;
SlowBuffer.prototype.toString = original.SlowBufferToString;
SlowBuffer.prototype.write = original.SlowBufferWrite;
Buffer.isEncoding = original.BufferIsEncoding;
Buffer.byteLength = original.BufferByteLength;
Buffer.prototype.toString = original.BufferToString;
Buffer.prototype.write = original.BufferWrite;
if (iconv.supportsStreams) {
var Readable = require('stream').Readable;
Readable.prototype.setEncoding = original.ReadableSetEncoding;
delete Readable.prototype.collect;
}
original = undefined;
}
SlowBuffer.prototype.address = Buffer.prototype.address
SlowBuffer.prototype.hexAddress = Buffer.prototype.hexAddress
SlowBuffer.prototype.isNull = Buffer.prototype.isNull
SlowBuffer.prototype.ref = Buffer.prototype.ref
SlowBuffer.prototype.deref = Buffer.prototype.deref
SlowBuffer.prototype.readObject = Buffer.prototype.readObject
SlowBuffer.prototype.writeObject = Buffer.prototype.writeObject
SlowBuffer.prototype.readPointer = Buffer.prototype.readPointer
SlowBuffer.prototype.writePointer = Buffer.prototype.writePointer
SlowBuffer.prototype.readCString = Buffer.prototype.readCString
SlowBuffer.prototype.writeCString = Buffer.prototype.writeCString
SlowBuffer.prototype.reinterpret = Buffer.prototype.reinterpret
SlowBuffer.prototype.reinterpretUntilZeros = Buffer.prototype.reinterpretUntilZeros
SlowBuffer.prototype.readInt64BE = Buffer.prototype.readInt64BE
SlowBuffer.prototype.writeInt64BE = Buffer.prototype.writeInt64BE
SlowBuffer.prototype.readUInt64BE = Buffer.prototype.readUInt64BE
SlowBuffer.prototype.writeUInt64BE = Buffer.prototype.writeUInt64BE
SlowBuffer.prototype.readInt64LE = Buffer.prototype.readInt64LE
SlowBuffer.prototype.writeInt64LE = Buffer.prototype.writeInt64LE
SlowBuffer.prototype.readUInt64LE = Buffer.prototype.readUInt64LE
SlowBuffer.prototype.writeUInt64LE = Buffer.prototype.writeUInt64LE
SlowBuffer.prototype.inspect = overwriteInspect(SlowBuffer.prototype.inspect)
}
function overwriteInspect (inspect) {
if (inspect.name === 'refinspect') {
return inspect
} else {
return function refinspect () {
var v = inspect.apply(this, arguments)
return v.replace('Buffer', 'Buffer@0x' + this.hexAddress())
SlowBuffer.prototype.hexAddress = Buffer.prototype.hexAddress
SlowBuffer.prototype.isNull = Buffer.prototype.isNull
SlowBuffer.prototype.ref = Buffer.prototype.ref
SlowBuffer.prototype.deref = Buffer.prototype.deref
SlowBuffer.prototype.readObject = Buffer.prototype.readObject
SlowBuffer.prototype.writeObject = Buffer.prototype.writeObject
SlowBuffer.prototype.readPointer = Buffer.prototype.readPointer
SlowBuffer.prototype.writePointer = Buffer.prototype.writePointer
SlowBuffer.prototype.readCString = Buffer.prototype.readCString
SlowBuffer.prototype.writeCString = Buffer.prototype.writeCString
SlowBuffer.prototype.reinterpret = Buffer.prototype.reinterpret
SlowBuffer.prototype.reinterpretUntilZeros = Buffer.prototype.reinterpretUntilZeros
SlowBuffer.prototype.readInt64BE = Buffer.prototype.readInt64BE
SlowBuffer.prototype.writeInt64BE = Buffer.prototype.writeInt64BE
SlowBuffer.prototype.readUInt64BE = Buffer.prototype.readUInt64BE
SlowBuffer.prototype.writeUInt64BE = Buffer.prototype.writeUInt64BE
SlowBuffer.prototype.readInt64LE = Buffer.prototype.readInt64LE
SlowBuffer.prototype.writeInt64LE = Buffer.prototype.writeInt64LE
SlowBuffer.prototype.readUInt64LE = Buffer.prototype.readUInt64LE
SlowBuffer.prototype.writeUInt64LE = Buffer.prototype.writeUInt64LE
SlowBuffer.prototype.inspect = overwriteInspect(SlowBuffer.prototype.inspect)
}
function overwriteInspect (inspect) {
if (inspect.name === 'refinspect') {
return inspect
} else {
return function refinspect () {
var v = inspect.apply(this, arguments)
return v.replace('Buffer', 'Buffer@0x' + this.hexAddress())
}
}
*/
var SlowBuffer = require('buffer').SlowBuffer;
SlowBuffer.prototype.address = Buffer.prototype.address;
SlowBuffer.prototype.hexAddress = Buffer.prototype.hexAddress;
SlowBuffer.prototype.isNull = Buffer.prototype.isNull;
SlowBuffer.prototype.ref = Buffer.prototype.ref;
SlowBuffer.prototype.deref = Buffer.prototype.deref;
SlowBuffer.prototype.readObject = Buffer.prototype.readObject;
SlowBuffer.prototype.writeObject = Buffer.prototype.writeObject;
SlowBuffer.prototype.readPointer = Buffer.prototype.readPointer;
SlowBuffer.prototype.writePointer = Buffer.prototype.writePointer;
SlowBuffer.prototype.readCString = Buffer.prototype.readCString;
SlowBuffer.prototype.writeCString = Buffer.prototype.writeCString;
SlowBuffer.prototype.reinterpret = Buffer.prototype.reinterpret;
SlowBuffer.prototype.reinterpretUntilZeros = Buffer.prototype.reinterpretUntilZeros;
SlowBuffer.prototype.readInt64BE = Buffer.prototype.readInt64BE;
SlowBuffer.prototype.writeInt64BE = Buffer.prototype.writeInt64BE;
SlowBuffer.prototype.readUInt64BE = Buffer.prototype.readUInt64BE;
SlowBuffer.prototype.writeUInt64BE = Buffer.prototype.writeUInt64BE;
SlowBuffer.prototype.readInt64LE = Buffer.prototype.readInt64LE;
SlowBuffer.prototype.writeInt64LE = Buffer.prototype.writeInt64LE;
SlowBuffer.prototype.readUInt64LE = Buffer.prototype.readUInt64LE;
SlowBuffer.prototype.writeUInt64LE = Buffer.prototype.writeUInt64LE;
/**
* in node 6.9.1, inspect.custom does not give a correct value; so in this case, don't torch the whole process.
* fixed in >6.9.2
*/
if (SlowBuffer.prototype[inspectSym]){
SlowBuffer.prototype[inspectSym] = overwriteInspect(SlowBuffer.prototype[inspectSym]);
}
SlowBuffer.prototype.writeObject = Buffer.prototype.writeObject;
SlowBuffer.prototype.readPointer = Buffer.prototype.readPointer;
SlowBuffer.prototype.writePointer = Buffer.prototype.writePointer;
SlowBuffer.prototype.readCString = Buffer.prototype.readCString;
SlowBuffer.prototype.writeCString = Buffer.prototype.writeCString;
SlowBuffer.prototype.reinterpret = Buffer.prototype.reinterpret;
SlowBuffer.prototype.reinterpretUntilZeros = Buffer.prototype.reinterpretUntilZeros;
SlowBuffer.prototype.readInt64BE = Buffer.prototype.readInt64BE;
SlowBuffer.prototype.writeInt64BE = Buffer.prototype.writeInt64BE;
SlowBuffer.prototype.readUInt64BE = Buffer.prototype.readUInt64BE;
SlowBuffer.prototype.writeUInt64BE = Buffer.prototype.writeUInt64BE;
SlowBuffer.prototype.readInt64LE = Buffer.prototype.readInt64LE;
SlowBuffer.prototype.writeInt64LE = Buffer.prototype.writeInt64LE;
SlowBuffer.prototype.readUInt64LE = Buffer.prototype.readUInt64LE;
SlowBuffer.prototype.writeUInt64LE = Buffer.prototype.writeUInt64LE;
SlowBuffer.prototype.inspect = overwriteInspect(SlowBuffer.prototype.inspect);
}
function overwriteInspect(inspect) {
if (inspect.name === 'refinspect') {
return inspect;
} else {
return function refinspect() {
var v = inspect.apply(this, arguments);
return v.replace('Buffer', 'Buffer@0x' + this.hexAddress());
};
}
}
//# sourceMappingURL=ref.js.map
if (!(exports.NULL instanceof Buffer)) {
debug('extending SlowBuffer\'s prototype since it doesn\'t inherit from Buffer.prototype')
/*!
* SlowBuffer convenience methods.
*/
var SlowBuffer = require('buffer').SlowBuffer
SlowBuffer.prototype.address = Buffer.prototype.address
SlowBuffer.prototype.hexAddress = Buffer.prototype.hexAddress
SlowBuffer.prototype.isNull = Buffer.prototype.isNull
SlowBuffer.prototype.ref = Buffer.prototype.ref
SlowBuffer.prototype.deref = Buffer.prototype.deref
SlowBuffer.prototype.readObject = Buffer.prototype.readObject
SlowBuffer.prototype.writeObject = Buffer.prototype.writeObject
SlowBuffer.prototype.readPointer = Buffer.prototype.readPointer
SlowBuffer.prototype.writePointer = Buffer.prototype.writePointer
SlowBuffer.prototype.readCString = Buffer.prototype.readCString
SlowBuffer.prototype.writeCString = Buffer.prototype.writeCString
SlowBuffer.prototype.reinterpret = Buffer.prototype.reinterpret
SlowBuffer.prototype.reinterpretUntilZeros = Buffer.prototype.reinterpretUntilZeros
SlowBuffer.prototype.readInt64BE = Buffer.prototype.readInt64BE
SlowBuffer.prototype.writeInt64BE = Buffer.prototype.writeInt64BE
SlowBuffer.prototype.readUInt64BE = Buffer.prototype.readUInt64BE
SlowBuffer.prototype.writeUInt64BE = Buffer.prototype.writeUInt64BE
SlowBuffer.prototype.readInt64LE = Buffer.prototype.readInt64LE
SlowBuffer.prototype.writeInt64LE = Buffer.prototype.writeInt64LE
SlowBuffer.prototype.readUInt64LE = Buffer.prototype.readUInt64LE
SlowBuffer.prototype.writeUInt64LE = Buffer.prototype.writeUInt64LE
SlowBuffer.prototype.inspect = overwriteInspect(SlowBuffer.prototype.inspect)
}
SlowBuffer.prototype.deref = Buffer.prototype.deref
SlowBuffer.prototype.readObject = Buffer.prototype.readObject
SlowBuffer.prototype.writeObject = Buffer.prototype.writeObject
SlowBuffer.prototype.readPointer = Buffer.prototype.readPointer
SlowBuffer.prototype.writePointer = Buffer.prototype.writePointer
SlowBuffer.prototype.readCString = Buffer.prototype.readCString
SlowBuffer.prototype.writeCString = Buffer.prototype.writeCString
SlowBuffer.prototype.reinterpret = Buffer.prototype.reinterpret
SlowBuffer.prototype.reinterpretUntilZeros = Buffer.prototype.reinterpretUntilZeros
SlowBuffer.prototype.readInt64BE = Buffer.prototype.readInt64BE
SlowBuffer.prototype.writeInt64BE = Buffer.prototype.writeInt64BE
SlowBuffer.prototype.readUInt64BE = Buffer.prototype.readUInt64BE
SlowBuffer.prototype.writeUInt64BE = Buffer.prototype.writeUInt64BE
SlowBuffer.prototype.readInt64LE = Buffer.prototype.readInt64LE
SlowBuffer.prototype.writeInt64LE = Buffer.prototype.writeInt64LE
SlowBuffer.prototype.readUInt64LE = Buffer.prototype.readUInt64LE
SlowBuffer.prototype.writeUInt64LE = Buffer.prototype.writeUInt64LE
SlowBuffer.prototype.inspect = overwriteInspect(SlowBuffer.prototype.inspect)
}
function overwriteInspect (inspect) {
if (inspect.name === 'refinspect') {
return inspect
} else {
return function refinspect () {
var v = inspect.apply(this, arguments)
return v.replace('Buffer', 'Buffer@0x' + this.hexAddress())
}
}
}