Socket
Book a DemoInstallSign in
Socket

is-midi

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-midi

Check if a Buffer/Uint8Array is a MIDI file

1.0.0
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

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.

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

License

MIT © Chris Vogt

Keywords

mid

FAQs

Package last updated on 19 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.