Skip to content

@graphty/graph-io / @graphty/graph-io / rankFormats

Function: rankFormats() ​

rankFormats(hints, importers, onSniffError?): readonly SniffResult[]

Defined in: sniff.ts:204

Rank a list of importers for an input. Most callers want registry.sniffAll(hints), which passes the registered importers for you. An importer is a candidate when it recognizes the content or its extension or MIME type matches. A content match scores 0.5 to 1 (more with a matching extension or MIME type); a name or MIME type alone scores at most 0.4; a weak content guess (a confidence below 0.5 from the importer, such as plain delimited text for CSV) scores below 0.25 when the file's extension belongs to another format. Ties go to the importer listed first.

Parameters ​

hints ​

SniffHints

{ filename, mimeType, head }, any of them

importers ​

Iterable<GraphImporter<unknown>>

the importers to rank, in tie-break order (registry.importers())

onSniffError? ​

(format, error) => void

called with the format and the error when an importer's sniff() throws (that importer is then treated as not recognizing the head)

Returns ​

readonly SniffResult[]

the candidates, best first; empty when nothing matches