Fill a buffer with a value.

@param {Buffer} buffer
@param {number} value
@return {Buffer}
516349
function fill(buffer, value) {
    $.checkArgumentType(buffer, 'Buffer', 'buffer');
    $.checkArgumentType(value, 'number', 'value');
    var length = buffer.length;
    for (var i = 0; i < length; i++) {
      buffer[i] = value;
    }
    return buffer;
  }
596302
function copyBuffer(buf, pos, len) {
  var copy = utils.newBuffer(len);
  buf.copy(copy, 0, pos, pos + len);
  return copy;
}
1159201
function Buffer(max, mode) {
  if (!(this instanceof Buffer)) {
    return new Buffer(max);
  }

  this.max = max;
  this.singleValueMode = this.max === 1;

  this.mode = mode;

  this.values = null;

  // Single item optimization
  this.singleValue = null; 
}
1123158
function (valueBuffer) {
			var value = this.valueToBigInt(valueBuffer).toString();
			var integerPart = value.length > 8 ? value.substr(0, value.length - 8) : '0';
			var decimalPart = value.length > 8 ? value.substr(value.length - 8) : value;
			while (decimalPart.length < 8) decimalPart = "0" + decimalPart;
			decimalPart = decimalPart.replace(/0*$/, '');
			while (decimalPart.length < 2) decimalPart += "0";
			return integerPart + "." + decimalPart;
		}
1134833
static void putLong(ByteBuffer buffer, long value) {
        value = (value << 1) ^ (value >> 63);
        if (value >>> 7 == 0) {
            buffer.put((byte) value);
        } else {
            buffer.put((byte) ((value & 0x7F) | 0x80));
            if (value >>> 14 == 0) {
                buffer.put((byte) (value >>> 7));
            } else {
                buffer.put((byte) (value >>> 7 | 0x80));
                if (value >>> 21 == 0) {
                    buffer.put((byte) (value >>> 14));
                } else {
                    buffer.put((byte) (value >>> 14 | 0x80));
                    if (value >>> 28 == 0) {
                        buffer.put((byte) (value >>> 21));
                    } else {
                        buffer.put((byte) (value >>> 21 | 0x80));
                        if (value >>> 35 == 0) {
                            buffer.put((byte) (value >>> 28));
                        } else {
                            buffer.put((byte) (value >>> 28 | 0x80));
                            if (value >>> 42 == 0) {
                                buffer.put((byte) (value >>> 35));
                            } else {
                                buffer.put((byte) (value >>> 35 | 0x80));
                                if (value >>> 49 == 0) {
                                    buffer.put((byte) (value >>> 42));
                                } else {
                                    buffer.put((byte) (value >>> 42 | 0x80));
                                    if (value >>> 56 == 0) {
                                        buffer.put((byte) (value >>> 49));
                                    } else {
                                        buffer.put((byte) (value >>> 49 | 0x80));
                                        buffer.put((byte) (value >>> 56));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
888542
function (num, totalBytes) {
  var numBytes = Math.floor(Math.log(num) / Math.log(0xff)) + 1;
  var buffer = new Buffer(totalBytes);

  buffer.fill(0);
  buffer.writeUIntBE(num, totalBytes - numBytes, numBytes);

  return buffer;
}
1099937
function value(val, buf, simple) {
  buf = buf || new Buffer(0);
  var type = typeof val;

  // coerce booleans to integers
  val = type === 'boolean' ? Number(val) : val;

  // treat floats as strings
  if(type === 'number' && parseInt(val) !== val) {
    val = '' + val;
  }

  // String instances are treated as simple strings
  if(val instanceof String) {
    simple = true;
    val = val.toString();
  }

  // re-evaluate type after coercion
  type = typeof val;

  if(val instanceof Buffer) {
    buf = _bst(buf, val);
  }else if(val === null) {
    buf = _nil(buf);
  }else if(Array.isArray(val)) {
    buf = _arr(buf, val);
  }else if(type === 'number'){
    buf = _int(buf, val);
  }else if(type === 'string') {
    buf = simple ? _str(buf, val) : _bst(buf, val);
  }else if(val instanceof Error) {
    buf = _err(buf, val);
  }else{
    assert(false, 'invalid encoder type: ' + type);
  }
  return buf;
}
234367
public void write(int value) throws IOException {
    if (pos >= buf.length) {
      if (pos >= getMaxPacketLength() && !bufferContainDataAfterMark) {
        //buffer is more than a Packet, must flushBuffer()
        flushBuffer(false);
      } else {
        growBuffer(1);
      }
    }
    buf[pos++] = (byte) value;
  }
458537
function(x) {
  var len, i;
  if (x instanceof Buffer) { // Copy
    this.buf = new Buffer(x.length);
    x.copy(this.buf);
  } else if (x instanceof BitBuffer) {
    this.buf = new Buffer(x.buf.length);
    x.buf.copy(this.buf);
  } else { // Size
    if (typeof(x) === 'number') { // Size
      len = x;
    } else {
      len = 128;
    }
    this.buf = new Buffer(len / 8);
    // Zero the buffer before use.
    len = this.buf.length;
    for (i = 0; i < len; i += 1) {
      this.buf[i] = 0;
    }
  }
}
234803
function _fill(string, length, c) {
        if (c === undefined) {
            c = " ";
        }
        while (string.length < length) {
            string += c;
        }
        return string;
    }
52015
function append(key, value, req) {
  var val = this.getKey(key, req)
    , str = typeof val === 'string';
  // doesn't exist becomes the empty string
  if(val === undefined) val = new Buffer('');
  if(!(val instanceof Buffer)) val = new Buffer('' + val);
  if(!(value instanceof Buffer)) value = new Buffer('' + value);
  // coerce numbers to strings
  //val = (val + '') + value;
  //val = val.concat()
  val = Buffer.concat([val, value], val.length + value.length);
  if(str) val = val.toString();
  this.setKey(key, val, undefined, undefined, undefined, req);
  return str ? Buffer.byteLength(val) : val.length;
}
630632
function fromBuffer (buf) {
  const err = validateBuffer(buf)
  if (err) throw err
  return Buffer.from(buf) // copy
}
1257610
protected void fillBytes(int value, long count) throws BitStreamException {
		// if it's short, write bytes directly
		if (count < PAD_LIMIT) {
			for (int i = 0; i < count; i++) writeByte(value);
			return;
		}

		// obtain an array we can use to write the bytes efficiently
		byte b = (byte) value;
		byte[] buffer = getBuffer(b);
		int len;
		if (buffer == null) {
			//TODO should all buffers be cached?
			len = count > PAD_BUFFER ? PAD_BUFFER : (int) count;
			buffer = new byte[len];
			Arrays.fill(buffer, b);
		} else {
			len = PAD_BUFFER;
		}

		// if we can, just do it with a single buffer
		if (count <= len) {
			writeBytes(buffer, 0, (int) count);
			return;
		}

		// write the buffer as many times as we need to
		long limit = count / len;
		for (long i = 0; i < limit; i++) {
			writeBytes(buffer, 0, len);
		}
		int r = (int) (count - limit * len);
		if (r != 0) writeBytes(buffer, 0, r);
	}
488889
function( buffer, offset ) {

    if( !Buffer.isBuffer( buffer ) )
      throw new TypeError( 'Value must be a buffer' )

    offset = offset || 0

    return this.fromNumber( buffer.readUIntLE( offset, 3 ) )

  }
1198441
function concat(buffers) {
  var size = 0;
  for (var i = 0; i < buffers.length; i++) {
    size += buffers[i].length;
  }

  var concatenated = new Buffer(size);
  for (var cursor = 0, j = 0; j < buffers.length; cursor += buffers[j].length, j++) {
    buffers[j].copy(concatenated, cursor);
  }

  return concatenated;
}
115183
function insertIntegerToByteArray (number, buffer, from, size) {
  let value = bigInt(number) // convert a number-like object into a big integer

  for (let pos = 0; pos < size; pos++) {
    const divmod = value.divmod(256)
    buffer[from + pos] = divmod.remainder.toJSNumber()
    value = divmod.quotient
  }

  return buffer
}
307213
public void insert(StringBuilder buffer, Object value, int index) {
        if (buffer == null) {
            throw new NullPointerException("buffer");
        }

        buffer.insert(index, value);
    }