npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

id3js

v2.1.1

Published

A modern ID3 parser written completely in JavaScript, making use of typed arrays and the HTML5 File API

Downloads

1,016

Readme

id3.js - Javascript ID3 tag parser

id3.js is a JavaScript library for reading and parsing ID3 tags of MP3 files.

It can parse both ID3v1 and ID3v2 tags within a browser or within Node.

Files can be read from the local disk (Node only), same-origin URLs and File instances (HTML5 File API).

Usage

Install:

$ npm i -S id3js

AJAX

You may parse ID3 tags of a remote MP3 by URL:

<script type="module">
import * as id3 from '//unpkg.com/id3js@^2/lib/id3.js';

id3.fromUrl('/audio/track.mp3').then((tags) => {
  // tags now contains v1, v2 and merged tags
});
</script>

This works by sending a HEAD request for the file and, based on the response, sending subsequent Range requests for the ID3 tags.

This is rather efficient as there is no need for the entire file to be downloaded.

Local Files

You may parse ID3 tags of a local file in Node:

import * as id3 from 'id3js';

id3.fromPath('./test.mp3').then((tags) => {
  // tags now contains v1, v2 and merged tags
});

Keep in mind, Node must be run with --experimental-modules for this to be imported and it cannot be used with require.

File inputs (HTML5)

You may parse ID3 tags of a file input:

<input type="file">

<script type="module">
import * as id3 from '//unpkg.com/id3js@^2/lib/id3.js';

document
  .querySelector('input[type="file"]')
  .addEventListener('change', async (e) => {
    const tags = await id3.fromFile(e.currentTarget.files[0]);
    // tags now contains v1, v2 and merged tags
  });
</script>

This will read the data from the File instance using slices, so the entire file is not loaded into memory but rather only the tags.

Images

An MP3 may have images embedded in the ID3 tags. If this is the case, they can be accessed through the tag.images property and will look like so:

{
  "type": "cover-front",
  "mime": "image/jpeg",
  "description": null,
  "data": ArrayBuffer
}

As you can see, the data is provided as an ArrayBuffer. To access it, you may use a DataView or typed array such as Uint8Array.

License

MIT