Apply masking to the data of a WebSocket message.

    ``data`` and ``mask`` are bytes-like objects.

    Return :class:`bytes`.
193063
def apply_mask(data: bytes, mask: bytes) -> bytes:
    
    if len(mask) != 4:
        raise ValueError("mask must contain 4 bytes")

    return bytes(b ^ m for b, m in zip(data, itertools.cycle(mask)))
624715
def _CheckFieldMaskMessage(message):
  """"""
  message_descriptor = message.DESCRIPTOR
  if (message_descriptor.name != 'FieldMask' or
      message_descriptor.file.name != 'google/protobuf/field_mask.proto'):
    raise ValueError('Message {0} is not a FieldMask.'.format(
        message_descriptor.full_name))
804419
def server_object_mask
    if parameters[:object_mask] && !parameters[:object_mask].empty?

      # Reduce the masks found in this object to a minimal set
      #
      # If you pass the API a mask that asks for the same property twice (within
      # the same type scope), the API treats it as an error (and throws an exception)
      #
      # We get around that by parsing the various masks that have been given to us
      # merging their properties where possible, thereby removing the duplicates
      # from the mask that actually gets passed to the server. As a side benefit,
      # the mask we send to the server will be streamlined; without too many extraneous
      # characters
      reduced_masks = parameters[:object_mask].inject([]) do |merged_masks, object_mask|
        mergeable_mask = merged_masks.find { |mask| mask.can_merge_with? object_mask }
        if mergeable_mask
          mergeable_mask.merge object_mask
        else
          merged_masks.push object_mask
        end

        merged_masks
      end

      if reduced_masks.count == 1
        reduced_masks[0].to_s
      else
        "[#{reduced_masks.collect{|mask| mask.to_s}.join(',')}]"
      end
    else
      nil
    end
  end
1365321
def putmask(self, mask, value):
        
        values = self.values.copy()
        try:
            np.putmask(values, mask, self._convert_for_op(value))
            return self._shallow_copy(values)
        except (ValueError, TypeError) as err:
            if is_object_dtype(self):
                raise err

            # coerces to object
            return self.astype(object).putmask(mask, value)
379808
def mask(self):
        
        if not hasattr(self, "_mask"):
            self._mask = Mask(self) if self.has_mask() else None
        return self._mask
1186336
def mask(self):
        
        if self.filter_func is None:
            raise RuntimeError("Can't get a mask without a filter function!")
        else:
            # only evaluate if no previous calculation was done
            if self._mask is None:
                # get required columns into the namespace as numpy arrays
                for column in self.columns:
                    if column in self.filter_func:
                        setattr(self, column, self.group[column][:])
                self._mask = eval(self.filter_func)
            return self._mask
46187
def _handle_digital_message(self, port_nr, lsb, msb):
        
        mask = (msb << 7) + lsb
        try:
            self.digital_ports[port_nr]._update(mask)
        except IndexError:
            raise ValueError
429799
function applyMask(mask) {
    var x, y, r3x, r3y;

    switch (mask) {
      case 0:
        for (y = 0; y < width; y++) {
          for (x = 0; x < width; x++) {
            if (!((x + y) & 1) && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 1:
        for (y = 0; y < width; y++) {
          for (x = 0; x < width; x++) {
            if (!(y & 1) && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 2:
        for (y = 0; y < width; y++) {
          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) r3x = 0;

            if (!r3x && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 3:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) r3y = 0;

          for (r3x = r3y, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) r3x = 0;

            if (!r3x && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 4:
        for (y = 0; y < width; y++) {
          for (r3x = 0, r3y = ((y >> 1) & 1), x = 0; x < width; x++, r3x++) {
            if (r3x === 3) {
              r3x = 0;
              r3y = !r3y;
            }

            if (!r3y && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 5:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) r3y = 0;

          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) r3x = 0;

            if (!((x & y & 1) + !(!r3x | !r3y)) && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 6:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) r3y = 0;

          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) r3x = 0;

            if (!(((x & y & 1) + (r3x && (r3x === r3y))) & 1) && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
      case 7:
        for (r3y = 0, y = 0; y < width; y++, r3y++) {
          if (r3y === 3) r3y = 0;

          for (r3x = 0, x = 0; x < width; x++, r3x++) {
            if (r3x === 3) r3x = 0;

            if (!(((r3x && (r3x === r3y)) + ((x + y) & 1)) & 1) && !isMasked(x, y)) {
              frameBuffer[x + y * width] ^= 1;
            }
          }
        }

        break;
    }
  }
114218
def set_on_mask(self, mask):
        """"""
        set_cmd = self._create_set_property_msg('_on_mask', 0x02, mask)
        self._send_method(set_cmd, self._property_set)
494566
def mask(self, masklist):
        
        if not hasattr(masklist, '__len__'):
            masklist = tuple(masklist)

        if len(masklist) != len(self):
            raise Exception("Masklist length (%s) must match length "
                            "of DataTable (%s)" % (len(masklist), len(self)))

        new_datatable = DataTable()
        for field in self.fields:
            new_datatable[field] = list(compress(self[field], masklist))
        return new_datatable
473192
def _format_object_mask(objectmask):
    
    objectmask = objectmask.strip()

    if (not objectmask.startswith('mask') and
            not objectmask.startswith('[')):
        objectmask = "mask[%s]" % objectmask
    return objectmask
624725
def apply_mask(self, x=None):
        '''
        

        '''

        if x is None:
            return np.delete(np.arange(len(self.time)), self.mask)
        else:
            return np.delete(x, self.mask, axis=0)
627052
function(_raw, _mask) {

      Utils.assert(_raw && typeof _raw == 'object', 'Record $decode expected an object');

      // IDEA: let user override serializer
      this.$type.decode(this, _raw, _mask || Utils.READ_MASK);
      if(this.$isNew()) this.$pk = this.$type.inferKey(_raw); // TODO: warn if key changes
      this.$dispatch('after-feed', [_raw]);
      return this;
    }
956789
def prefixlen_to_mask(prefixlen):
    
    prefixlen = prefixlen or '32'
    addr = '0.0.0.0/%s' % prefixlen
    return str(netaddr.IPNetwork(addr).netmask)
1324998
def _unpack(self, data):
        
        msg_magic, msg_length, msg_type = self._unpack_header(data)
        msg_size = self._struct_header_size + msg_length
        # XXX: Message shouldn't be any longer than the data
        payload = data[self._struct_header_size:msg_size]
        return payload.decode('utf-8', 'replace')
606912
function WebSocketFrame(maskBytes, frameHeader, config) {
    this.maskBytes = maskBytes;
    this.frameHeader = frameHeader;
    this.config = config;
    this.maxReceivedFrameSize = config.maxReceivedFrameSize;
    this.protocolError = false;
    this.frameTooLarge = false;
    this.invalidCloseFrameLength = false;
    this.parseState = DECODE_HEADER;
    this.closeStatus = -1;
}
436028
def make_message(self, data):

        

        data = self.codec.loads(data)
        msg = Message(
            data.get("data"),
            *data.get("args",[]),
            **data.get("kwargs",{})
        )
        msg.meta.update(data.get("meta"))
        self.trigger("make_message", data, msg)
        return msg