B2G/gecko/dom/mobilemessage/src/ril/MmsPduHelper.jsm
/**
   * @param data
   *        A wrapped object containing raw PDU data.
   * @param options
   *        Extra context for decoding.
   *
   * @return A decoded object containing `name` and `value` properties or null
   *         in case of a failed parsing. The `name` property must be a string,
   *         but the `value` property can be many different types depending on
   *         `name`.
   *
   * @throws NotWellKnownEncodingError if decoded well-known header field
   *         number is not registered or supported.
   */
@param data
A wrapped object containing raw PDU data.
@param options
Extra context for decoding.

@return A decoded object containing `name` and `value` properties or null
in case of a failed parsing.

@throws NotWellKnownEncodingError if decoded well-known header field
number is not registered or supported.
@param data A wrapped object containing raw PDU data . @param options Extra context for decoding . @return A decoded object containing ` name ` and ` value ` properties or null in case of a failed parsing . @throws NotWellKnownEncodingError if decoded well - known header field number is not registered or supported .
function decode(data, options) {
    let index = WSP.ShortInteger.decode(data);
    let entry = MMS_HEADER_FIELDS[index];
    if (!entry) {
      throw new WSP.NotWellKnownEncodingError(
        "MMS-header: not well known header " + index);
    }
    let cur = data.offset, value;
    try {
      value = entry.coder.decode(data, options);
    } catch (e) {
      data.offset = cur;
      value = WSP.skipValue(data);
      debug("Skip malformed well known header: "
            + JSON.stringify({name: entry.name, value: value}));
      return null;
    }
    return {
      name: entry.name,
      value: value,
    };
  }
function decode ( data , options ) { let index = WSP . ShortInteger . decode ( data ) ; let entry = MMS_HEADER_FIELDS [ index ] ; if ( ! entry ) { throw new WSP . NotWellKnownEncodingError ( "MMS-header: not well known header " + index ) ; } let cur = data . offset , value ; try { value = entry . coder . decode ( data , options ) ; } catch ( e ) { data . offset = cur ; value = WSP . skipValue ( data ) ; debug ( "Skip malformed well known header: " + JSON . stringify ( { name : entry . name , value : value } ) ) ; return null ; } return { name : entry . name , value : value , } ; }
@param data
        A wrapped object containing raw PDU data.
@param data A wrapped object containing raw PDU data .