demo/content-disposition/index.js
function format(obj) {
  var parameters = obj.parameters
  var type = obj.type

  if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) {
    throw new TypeError('invalid type')
  }

  // start with normalized type
  var string = String(type).toLowerCase()

  // append parameters
  if (parameters && typeof parameters === 'object') {
    var param
    var params = Object.keys(parameters).sort()

    for (var i = 0; i < params.length; i++) {
      param = params[i]

      var val = param.substr(-1) === '*'
        ? ustring(parameters[param])
        : qstring(parameters[param])

      string += '; ' + param + '=' + val
    }
  }

  return string
}
function format(obj) {
  var parameters = obj.parameters
  var type = obj.type

  if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) {
    throw new TypeError('invalid type')
  }

  // start with normalized type
  var string = String(type).toLowerCase()

  // append parameters
  if (parameters && typeof parameters === 'object') {
    var param
    var params = Object.keys(parameters).sort()

    for (var i = 0; i < params.length; i++) {
      param = params[i]

      var val = param.substr(-1) === '*'
        ? ustring(parameters[param])
        : qstring(parameters[param])

      string += '; ' + param + '=' + val
    }
  }

  return string
}
function format ( obj ) { var parameters = obj . parameters var type = obj . type if ( ! type || typeof type !== 'string' || ! tokenRegExp . test ( type ) ) { throw new TypeError ( 'invalid type' ) } // start with normalized type var string = String ( type ) . toLowerCase ( ) // append parameters if ( parameters && typeof parameters === 'object' ) { var param var params = Object . keys ( parameters ) . sort ( ) for ( var i = 0 ; i < params . length ; i ++ ) { param = params [ i ] var val = param . substr ( - 1 ) === '*' ? ustring ( parameters [ param ] ) : qstring ( parameters [ param ] ) string += '; ' + param + '=' + val } } return string }
Format object to Content-Disposition header.

@param {object} obj
@param {string} obj.type
@param {object} [obj.parameters]
@return {string}
@api private
Format object to Content - Disposition header .