B2G/gecko/dom/mobilemessage/src/ril/WspPduHelper.jsm
/**
   * @param data
   *        A wrapped object containing raw PDU data.
   *
   * @return A decoded object containing `name` and `value` properties or null
   *         if something wrong. The `name` property must be a string, but the
   *         `value` property can be many different types depending on `name`.
   *
   * @throws CodeError if decoded IntegerValue is an array.
   * @throws NotWellKnownEncodingError if decoded well-known parameter number
   *         is not registered or supported.
   */
@param data
A wrapped object containing raw PDU data.

@return A decoded object containing `name` and `value` properties or null
if something wrong.

@throws CodeError if decoded IntegerValue is an array.
@throws NotWellKnownEncodingError if decoded well-known parameter number
is not registered or supported.
@param data A wrapped object containing raw PDU data . @return A decoded object containing ` name ` and ` value ` properties or null if something wrong . @throws CodeError if decoded IntegerValue is an array . @throws NotWellKnownEncodingError if decoded well - known parameter number is not registered or supported .
function decodeTypedParameter(data) {
    let numOrArray = IntegerValue.decode(data);
    if (typeof numOrArray != "number") {
      throw new CodeError("Typed-parameter: invalid integer type");
    }
    let number = numOrArray;
    let param = WSP_WELL_KNOWN_PARAMS[number];
    if (!param) {
      throw new NotWellKnownEncodingError(
        "Typed-parameter: not well known parameter " + number);
    }
    let begin = data.offset, value;
    try {
      value = decodeAlternatives(data, null,
                                 param.coder, TextValue, TextString);
    } catch (e) {
      data.offset = begin;
      value = skipValue(data);
      debug("Skip malformed typed parameter: "
            + JSON.stringify({name: param.name, value: value}));
      return null;
    }
    return {
      name: param.name,
      value: value,
    };
  }
function decodeTypedParameter ( data ) { let numOrArray = IntegerValue . decode ( data ) ; if ( typeof numOrArray != "number" ) { throw new CodeError ( "Typed-parameter: invalid integer type" ) ; } let number = numOrArray ; let param = WSP_WELL_KNOWN_PARAMS [ number ] ; if ( ! param ) { throw new NotWellKnownEncodingError ( "Typed-parameter: not well known parameter " + number ) ; } let begin = data . offset , value ; try { value = decodeAlternatives ( data , null , param . coder , TextValue , TextString ) ; } catch ( e ) { data . offset = begin ; value = skipValue ( data ) ; debug ( "Skip malformed typed parameter: " + JSON . stringify ( { name : param . name , value : value } ) ) ; return null ; } return { name : param . name , value : value , } ; }
@param data
        A wrapped object containing raw PDU data.
@param data A wrapped object containing raw PDU data .
// `decodeIntegerValue` can return a array, which doesn't apply here. // Althought Text-string is not included in BNF of Compact-value, but // some service provider might still pass a less-strict text form and // cause a unexpected CodeError raised. For example, the `start` // parameter expects its value of Text-value, but service provider might // gives "<smil>", which contains illegal characters "<" and ">". // Skip current parameter.