Liking cljdoc? Tell your friends :D

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

archive-patternsclj/s

The table of archive patterns.

The table of archive patterns.
sourceraw docstring

archive-typeclj/s

(archive-type b)

The archive type that the bytes b match, or nil.

The archive type that the bytes `b` match, or nil.
sourceraw docstring

audio-or-video-patternsclj/s

The table of audio and video patterns. The checks for MP4, WebM and MP3 without ID3 come after it.

The table of audio and video patterns. The checks for MP4, WebM and MP3
without ID3 come after it.
sourceraw docstring

audio-or-video-typeclj/s

(audio-or-video-type b)

The audio or video type that the bytes b match, or nil.

The audio or video type that the bytes `b` match, or nil.
sourceraw docstring

feed-typeclj/s

(feed-type b)

The feed type that the bytes b start with, application/rss+xml or application/atom+xml, or nil.

The standard had these rules for a feed served as HTML until 15 July 2024, when it dropped them because no browser follows them. A feed starts with the root element of RSS, Atom or RSS 1.0, after any comments, declarations and processing instructions.

The feed type that the bytes `b` start with, application/rss+xml or
application/atom+xml, or nil.

The standard had these rules for a feed served as HTML until 15 July
2024, when it dropped them because no browser follows them. A feed starts
with the root element of RSS, Atom or RSS 1.0, after any comments,
declarations and processing instructions.
sourceraw docstring

font-patternsclj/s

The table of font patterns.

The table of font patterns.
sourceraw docstring

font-typeclj/s

(font-type b)

The font type that the bytes b match, or nil.

The font type that the bytes `b` match, or nil.
sourceraw docstring

image-patternsclj/s

The table of image patterns.

The table of image patterns.
sourceraw docstring

image-typeclj/s

(image-type b)

The image type that the bytes b match, or nil.

The image type that the bytes `b` match, or nil.
sourceraw docstring

matches?clj/s

(matches? b pattern mask ignored)

Whether the bytes b match the pattern under the mask, after any leading bytes in the set ignored.

Whether the bytes `b` match the `pattern` under the `mask`, after any
leading bytes in the set `ignored`.
sourceraw docstring

resource-header-lengthclj/s

The most bytes of a resource that sniffing reads.

The most bytes of a resource that sniffing reads.
sourceraw docstring

scriptable-patternsclj/s

The table of HTML, XML and PDF patterns, which unknown-type tries only when asked to.

The table of HTML, XML and PDF patterns, which unknown-type tries only
when asked to.
sourceraw docstring

text-or-binaryclj/s

(text-or-binary b)

The type of a resource served as plain text, by its first bytes b: text/plain, or application/octet-stream when they hold a binary control and no byte order mark.

The type of a resource served as plain text, by its first bytes `b`:
text/plain, or application/octet-stream when they hold a binary control
and no byte order mark.
sourceraw docstring

unknown-patternsclj/s

The table of PostScript and the byte order marks of text, which unknown-type always tries.

The table of PostScript and the byte order marks of text, which
unknown-type always tries.
sourceraw docstring

unknown-typeclj/s

(unknown-type b)
(unknown-type b scriptable?)

The type of a resource of unknown type, by its first bytes b, with HTML, XML and PDF among the candidates when scriptable?.

When no table matches, it's text/plain, or application/octet-stream when the bytes hold a control other than tab, LF, FF, CR or ESC.

The type of a resource of unknown type, by its first bytes `b`, with
HTML, XML and PDF among the candidates when `scriptable?`.

When no table matches, it's text/plain, or application/octet-stream when
the bytes hold a control other than tab, LF, FF, CR or ESC.
sourceraw docstring

whitespace-bytesclj/s

The bytes that some patterns ignore before them: tab, LF, FF, CR and space.

The bytes that some patterns ignore before them: tab, LF, FF, CR and
space.
sourceraw 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