How to use the media-typer.format function in media-typer

To help you get started, we’ve selected a few media-typer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tejasmanohar / twilio-plays-2048 / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github tangdu / mblog / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github andrewshawcare / thoughtworks-email-signature-generator / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github dungeon-revealer / dungeon-revealer / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github jens-maus / RaspberryMatic / buildroot-external / package / neoserver / pkg / mediola / neo_server / node_modules / type-is / index.js View on Github external
function normalizeType (value) {
  // parse the type
  var type = typer.parse(value)

  // remove the parameters
  type.parameters = undefined

  // reformat it
  return typer.format(type)
}
github entermedia-community / entermedia-server / webapp / examples / annotations / workspace / node_modules / express / lib / utils.js View on Github external
exports.setCharset = function(type, charset){
  if (!type || !charset) return type;

  // parse type
  var parsed = typer.parse(type);

  // set charset
  parsed.parameters.charset = charset;

  // format type
  return typer.format(parsed);
};
github arangodb / arangodb / js / common / modules / @arangodb / foxx / check-args.js View on Github external
function normalizeMimeType (mime) {
  if (mime === 'binary') {
    mime = 'application/octet-stream';
  }
  const contentType = mimeTypes.contentType(mime) || mime;
  const parsed = mediaTyper.parse(contentType);
  return mediaTyper.format(_.pick(parsed, [
    'type',
    'subtype',
    'suffix'
  ]));
}
github koush / vysor.io / node_modules / express / node_modules / type-is / index.js View on Github external
function typenormalize(value) {
  try {
    var type = typer.parse(value)
    delete type.parameters
    return typer.format(type)
  } catch (err) {
    return null
  }
}
github apiaryio / gavel.js / lib / units / validateBody.js View on Github external
[
      JsonSchema,
      (expected, actual) => {
        return isJson(actual) && isJsonSchema(expected);
      },
      'json'
    ],
    [JsonExample, both(isJson), 'json']
  ];

  const validator = validators.find(([_name, predicate]) => {
    return predicate(expectedType, actualType);
  });

  if (!validator) {
    const error = `Can't validate actual media type '${mediaTyper.format(
      actualType
    )}' against the expected media type '${mediaTyper.format(expectedType)}'.`;
    return [error, null, null];
  }

  return [null, validator[0], validator[2]];
}

media-typer

Simple RFC 6838 media type parser and formatter

MIT
Latest version published 5 years ago

Package Health Score

69 / 100
Full package analysis

Popular media-typer functions