How to use the buffer.SlowBuffer.prototype function in buffer

To help you get started, we’ve selected a few buffer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ashtuchkin / iconv-lite / index.js View on Github external
// 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;
github VulcanJS / vulcanjs-cli / node_modules / iconv-lite / lib / extend-node.js View on Github external
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;
github taku-o / myukkurivoice / node_modules / ref-napi / lib / ref.js View on Github external
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;
github CodeTengu / LambdaBaku / functions / share_issue_on_twitter / node_modules / node-fetch / node_modules / encoding / node_modules / iconv-lite / lib / extend-node.js View on Github external
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;
    }
github cmake-js / fastcall / lib / ref-libs / ref.js View on Github external
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())
github cmake-js / fastcall / lib / ref-libs / ref.js View on Github external
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())
    }
  }
github taku-o / myukkurivoice / node_modules / ref-napi / lib / ref.js View on Github external
*/

  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]);
  }
github cmake-js / fastcall / es5 / lib / ref-libs / ref.js View on Github external
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
github cmake-js / fastcall / lib / ref-libs / ref.js View on Github external
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)
}
github sunjw / jstoolnpp / sub-proj / JSFNodeNative / node_modules / ref / lib / ref.js View on Github external
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())
    }
  }
}