code: function calc_null_bitmap(values) {
      var val = 0, len = 0, bitmap = [];
      values.map(function(v) {
          val += (v == null || v == undefined ? 1 << len : 0);
          len += 1;
  
          if(len == 8) {
            bitmap.push(val);
            len = val = 0;
          }
          return val;
      });
  
      if(len > 0) {
        bitmap.push(val);
      }
  
      var packed = []
      bitmap.forEach(function(entry, i, bitmap) {
        packed[i] = pack.pack("C*", entry)
      })
  
      return packed
  }
docs: this code hijacked from https://github.com/masuidrive/node-mysql/blob/master/lib/mysql/pack.js