Liking cljdoc? Tell your friends :D

dk.simongray.whatwg-mime

Parse and sniff MIME types the way browsers do, by the MIME Sniffing Standard.

A MIME type is a plain map:

  • :type and :subtype, in lower case, e.g. "text" and "html"
  • :parameters, when there are any, a map of lower-case names to values in the order of the text

The parameters can also be a vector of name-value pairs. Unlike the map, it keeps its order when you add a ninth parameter.

Every function that takes a MIME type also takes its text, and treats text that doesn't parse as nil.

Parse and sniff MIME types the way browsers do, by the MIME Sniffing
Standard.

A MIME type is a plain map:

- :type and :subtype, in lower case, e.g. "text" and "html"
- :parameters, when there are any, a map of lower-case names to values
  in the order of the text

The parameters can also be a vector of name-value pairs. Unlike the map,
it keeps its order when you add a ninth parameter.

Every function that takes a MIME type also takes its text, and treats
text that doesn't parse as nil.
raw docstring

dk.simongray.whatwg-mime.patterns

The byte patterns of the MIME Sniffing Standard, and the functions that match them against the first bytes of a resource.

The bytes are a byte array on the JVM and a Uint8Array in ClojureScript (a Node Buffer is one). Only the first 1445 count, so a whole body will do. A function returns a MIME type as text, e.g. image/png, or nil when nothing matches.

A row of a table is a map of:

  • :pattern, the bytes to match, with :tt for a space or > after a tag
  • :mask, how much of each byte counts: all of it for 0xFF, all but the case of a letter for 0xDF, and none of it for 0x00
  • :ignored, the bytes that may come before the pattern
  • :type, the MIME type of a match
The byte patterns of the MIME Sniffing Standard, and the functions that
match them against the first bytes of a resource.

The bytes are a byte array on the JVM and a Uint8Array in ClojureScript
(a Node Buffer is one). Only the first 1445 count, so a whole body will
do. A function returns a MIME type as text, e.g. image/png, or nil when
nothing matches.

A row of a table is a map of:

- :pattern, the bytes to match, with :tt for a space or > after a tag
- :mask, how much of each byte counts: all of it for 0xFF, all but the
  case of a letter for 0xDF, and none of it for 0x00
- :ignored, the bytes that may come before the pattern
- :type, the MIME type of a match
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close