lib/command/string.js
function setbit(key, offset, value, req) {
  var buf = this.getValueBuffer(key, req, true)
    , zeros
    , pos
    , shift
    , byte
    , bit;
  if(buf === undefined) buf = new Buffer('');
  pos = Math.floor(offset / 8);
  bit = pos >= buf.length ? 0 : this.getbit(key, offset, req);

  if(pos + 1 >= buf.length) {
    zeros = new Buffer(pos + 1 - buf.length);
    zeros.fill('\u0000');
    buf = Buffer.concat([buf, zeros], buf.length + zeros.length);
  }

  shift = 7 - (offset & 0x7);
  byte = buf[pos];
  byte &= ~(1 << shift);
  byte |= ((value & 0x01) << shift);
  buf[pos] = byte;
  this.setKey(key, buf, undefined, undefined, undefined, req);
  return bit;
}
function setbit(key, offset, value, req) {
  var buf = this.getValueBuffer(key, req, true)
    , zeros
    , pos
    , shift
    , byte
    , bit;
  if(buf === undefined) buf = new Buffer('');
  pos = Math.floor(offset / 8);
  bit = pos >= buf.length ? 0 : this.getbit(key, offset, req);

  if(pos + 1 >= buf.length) {
    zeros = new Buffer(pos + 1 - buf.length);
    zeros.fill('\u0000');
    buf = Buffer.concat([buf, zeros], buf.length + zeros.length);
  }

  shift = 7 - (offset & 0x7);
  byte = buf[pos];
  byte &= ~(1 << shift);
  byte |= ((value & 0x01) << shift);
  buf[pos] = byte;
  this.setKey(key, buf, undefined, undefined, undefined, req);
  return bit;
}
function setbit ( key , offset , value , req ) { var buf = this . getValueBuffer ( key , req , true ) , zeros , pos , shift , byte , bit ; if ( buf === undefined ) buf = new Buffer ( '' ) ; pos = Math . floor ( offset / 8 ) ; bit = pos >= buf . length ? 0 : this . getbit ( key , offset , req ) ; if ( pos + 1 >= buf . length ) { zeros = new Buffer ( pos + 1 - buf . length ) ; zeros . fill ( '\u0000' ) ; buf = Buffer . concat ( [ buf , zeros ] , buf . length + zeros . length ) ; } shift = 7 - ( offset & 0x7 ) ; byte = buf [ pos ] ; byte &= ~ ( 1 << shift ) ; byte |= ( ( value & 0x01 ) << shift ) ; buf [ pos ] = byte ; this . setKey ( key , buf , undefined , undefined , undefined , req ) ; return bit ; }
Sets or clears the bit at offset in the string value stored at key.
Sets or clears the bit at offset in the string value stored at key .