Skip to content

Latest commit

 

History

History
96 lines (56 loc) · 2.56 KB

js.md

File metadata and controls

96 lines (56 loc) · 2.56 KB

Table of Contents

Magika

js/magika.js:64-197

The Magika object.

Example usage:

  const data = await readFile('some file');
  const magika = new Magika();
  await magika.load();
  const prediction = await magika.identifyBytes(data);
  console.log(prediction);

For a Node implementation, see <MAGIKA_REPO>/js/index.js, which you can run with yarn run bin -h.

For a web version, see <MAGIKA_REPO>/docs/src/components/FileClassifierDemo.vue,

load

js/magika.js:73-79

Loads the Magika model and config from URLs.

Parameters

  • $0 Object (optional, default {})

    • $0.modelURL
    • $0.configURL
  • modelURL string The URL where the model is stored.

  • configURL string The URL where the config is stored.Both parameters are optional. If not provided, the model will be loaded from Github.

identifyBytes

js/magika.js:86-88

Identifies the content type of a byte stream.

Parameters

  • fileBytes any a Buffer object (a fixed-length sequence of bytes)

Returns any A dictionary containing the top label and its score,

identifyBytesFull

js/magika.js:95-99

Identifies the content type of a byte stream, returning all probabilities instead of just the top one.

Parameters

  • fileBytes any a Buffer object (a fixed-length sequence of bytes)

Returns any A dictionary containing the top label, its score, and a list of content types and their scores.