lib/bit-field.js
/**
   * Decodes an encoded number into it's object representation according to the schema.
   *
   * @param {AnyNumber} data encoded number
   * @returns {UnpackedInt} object representation
   * @example
   *
   * class Person extends BitField {}
   * Person.fields = [
   *  { name: 'age', size: 7 },
   *  { name: 'gender', size: 1 },
   * ];
   * Person.decode(41);
   * //=> { age: 20, gender: 1 }
   */
Decodes an encoded number into it's object representation according to the schema.
@param {AnyNumber} data encoded number
@returns {UnpackedInt} object representation
@example


Decodes an encoded number into it ' s object representation according to the schema . @param { AnyNumber } data encoded number @returns { UnpackedInt } object representation @example
static decode(data) {
    const { fields, masks } = this;
    const result = {};
    let value = data;
    for (let i = 0; i < fields.length; i++) {
      const { name, size } = fields[i];
      result[name] = Number(value & masks[name]);
      value >>= size;
    }
    return result;
  }
static decode ( data ) { const { fields , masks } = this ; const result = { } ; let value = data ; for ( let i = 0 ; i < fields . length ; i ++ ) { const { name , size } = fields [ i ] ; result [ name ] = Number ( value & masks [ name ] ) ; value >>= size ; } return result ; }
Decodes an encoded number into it's object representation according to the schema.
Decodes an encoded number into it ' s object representation according to the schema .