Negotiate Pushing Milestone

    is-midi

    1.0.0 • Public • Published

    is-midi Build Status codecov

    Check if a Buffer/Uint8Array is a MIDI file

    Install

    $ npm install is-midi
    

    Usage

    Node.js
    const readChunk = require('read-chunk'); // npm install read-chunk
    const isMidi = require('is-midi');
    const buffer = readChunk.sync('song.mid', 0, 4);
     
    isMidi(buffer);
    //=> true
    Browser
    const xhr = new XMLHttpRequest();
    xhr.open('GET', 'song.mid');
    xhr.responseType = 'arraybuffer';
     
    xhr.onload = () => {
        isMidi(new Uint8Array(this.response));
        //=> true
    };
     
    xhr.send();

    API

    isMidi(buffer)

    Accepts a Buffer (Node.js) or Uint8Array.

    It only needs the first 4 bytes.

    Related

    • file-type - Detect the file type of a Buffer/Uint8Array

    License

    MIT © Chris Vogt

    Install

    npm i is-midi

    DownloadsWeekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Unpacked Size

    3.13 kB

    Total Files

    4

    Last publish

    Collaborators

    • chrisvogt