Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

music-metadata-browser

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

music-metadata-browser - npm Package Compare versions

Comparing version 0.3.3 to 0.4.0

karma.conf.js

4

dist/index.d.ts

@@ -26,7 +26,7 @@ import * as mm from 'music-metadata/lib/core';

* Parse Web API File
* @param {File} file
* @param {Blob} blob
* @param {IOptions} options Parsing options
* @returns {Promise<IAudioMetadata>}
*/
export declare function parseFile(file: File, options?: IOptions): Promise<IAudioMetadata>;
export declare function parseBlob(blob: Blob, options?: IOptions): Promise<IAudioMetadata>;
/**

@@ -33,0 +33,0 @@ * Create a dictionary ordered by their tag id (key)

'use strict';
import * as mm from 'music-metadata/lib/core';
import * as toBuffer from 'typedarray-to-buffer';
Object.defineProperty(exports, "__esModule", { value: true });
const mm = require("music-metadata/lib/core");
const toBuffer = require("typedarray-to-buffer");
/**

@@ -11,3 +12,3 @@ * Parse audio Stream

*/
export const parseStream = mm.parseStream;
exports.parseStream = mm.parseStream;
/**

@@ -21,20 +22,21 @@ * Parse audio from Node Buffer

*/
export const parseBuffer = mm.parseBuffer;
exports.parseBuffer = mm.parseBuffer;
/**
* Parse Web API File
* @param {File} file
* @param {Blob} blob
* @param {IOptions} options Parsing options
* @returns {Promise<IAudioMetadata>}
*/
export function parseFile(file, options) {
return convertFileToBuffer(file).then(buf => {
return mm.parseBuffer(buf, file.type, options);
function parseBlob(blob, options) {
return convertBlobToBuffer(blob).then(buf => {
return mm.parseBuffer(buf, blob.type, options);
});
}
exports.parseBlob = parseBlob;
/**
* Convert Web API File to Node Buffer
* @param {File} file Web API File
* @param {Blob} blob Web API Blob
* @returns {Promise<Buffer>}
*/
function convertFileToBuffer(file) {
function convertBlobToBuffer(blob) {
return new Promise((resolve, reject) => {

@@ -55,3 +57,3 @@ const fileReader = new FileReader();

};
fileReader.readAsArrayBuffer(file);
fileReader.readAsArrayBuffer(blob);
});

@@ -64,3 +66,3 @@ }

*/
export const orderTags = mm.orderTags;
exports.orderTags = mm.orderTags;
/**

@@ -71,2 +73,2 @@ * Convert rating to 1-5 star rating

*/
export const ratingToStars = mm.ratingToStars;
exports.ratingToStars = mm.ratingToStars;
{
"name": "music-metadata-browser",
"version": "0.3.3",
"version": "0.4.0",
"description": "Browserifed version of music-metadata",

@@ -48,13 +48,31 @@ "main": "dist/index.js",

"scripts": {
"clean": "del-cli dist/** src/**/*.js src/**/*.js.map src/**/*.d.ts test/**/*.js test/**/*.js.map",
"compile-src": "tsc -p src",
"clean": "del-cli dist/** src/**/*.js src/**/*.js.map src/**/*.d.ts test/**/*.js test/**/*.js.map coverage",
"compile-dist": "tsc -p src/tsconfig.dist.json",
"compile-test": "tsc -p src/tsconfig.spec.json",
"prepublishOnly": "yarn run build",
"build": "yarn run clean && yarn run compile-src",
"lint": "tslint 'src/**/*.ts' --exclude 'src/**/*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts'"
"build": "npm run compile-dist && npm run compile-test",
"lint": "tslint 'src/**/*.ts' --exclude 'src/**/*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts'",
"karma": "karma start",
"travis-karma": "karma start --browsers Firefox --single-run",
"post-coveralls": "coveralls < coverage/lcov.info"
},
"devDependencies": {
"@types/jasmine": "^2.8.8",
"@types/node": "^10.9.4",
"coveralls": "^3.0.2",
"del-cli": "^1.1.0",
"tslint": "^5.11.0 ",
"typescript": "^3.0.3"
"filereader-stream": "^2.0.0",
"jasmine-core": "^3.2.1",
"karma": "^3.0.0",
"karma-chrome-launcher": "^2.2.0",
"karma-coverage-istanbul-reporter": "^2.0.4",
"karma-firefox-launcher": "^1.1.0",
"karma-jasmine": "^1.1.2",
"karma-jasmine-html-reporter": "^1.3.1",
"karma-webpack": "^3.0.5",
"stream-http": "^2.8.3",
"ts-loader": "^5.2.1",
"tslint": "^5.11.0",
"typescript": "^3.0.3",
"webpack": "^4.20.2"
},

@@ -61,0 +79,0 @@ "dependencies": {

@@ -5,2 +5,5 @@ [![Build Status](https://travis-ci.org/Borewit/music-metadata-browser.svg?branch=master)](https://travis-ci.org/Borewit/music-metadata-browser)

[![dependencies Status](https://david-dm.org/Borewit/music-metadata-browser/status.svg)](https://david-dm.org/Borewit/music-metadata-browser)
[![Coverage Status](https://coveralls.io/repos/github/Borewit/music-metadata-browser/badge.svg?branch=master)](https://coveralls.io/github/Borewit/music-metadata-browser?branch=master)
![NPM version](https://img.shields.io/bundlephobia/min/music-metadata-browser.svg)
# music-metadata-browser

@@ -85,8 +88,30 @@

In the browser there is node direct file access available.
Only the [parseStream function](#parseStream) is available.T
There are currently two ways to parse (read) audio tracks:
1) parsing a Web API blob or file with the [parseBlob function](#parseBlob).
2) Using [Node.js streams](https://nodejs.org/api/stream.html) using the [parseStream function](#parseStream).
#### parseBlob function
To convert a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) or [File](https://developer.mozilla.org/en-US/docs/Web/API/File) into a [stream](https://nodejs.org/api/stream.html#stream_readable_streams),
[filereader-stream](https://www.npmjs.com/package/filereader-stream) is used.
```javascript
import * as mm from 'music-metadata-browser';
/**
* @param blob Blob (e.g. Web API File)
*/
function readFromBlob(blob) {
// blob is a Web API Blob or File
mm.parseBlob(blob).then(metadata => {
// metadata has all the metadata found in the blob or file
});
}
```
#### parseStream function
```javascript
import * as mm from 'music-metadata-browser';
mm.parseStream(readableStream)

@@ -116,24 +141,4 @@ .then( metadata => {

The Web API [File interface](https://developer.mozilla.org/en-US/docs/Web/API/File) can be converted into a stream.
```javascript
import fileReaderStream from 'filereader-stream';
import * as mm from 'music-metadata-browser';
If you wish to stream your audio track over HTTP you need HTTP-client which provides a stream like [stream-http](https://www.npmjs.com/package/stream-stream):
/**
* @param file Browser File
*/
function readFromFile(file) {
const stream = fileReaderStream(file);
mm.parseStream(stream).then(metadata => {
// metadata has all the metadata found in file
});
}
```
To convert the [File](https://developer.mozilla.org/en-US/docs/Web/API/File) into a [stream](https://nodejs.org/api/stream.html#stream_readable_streams),
[filereader-stream](https://www.npmjs.com/package/filereader-stream) is used.
If you wish to stream your audio track over HTTP you may want to use [stream-http](https://www.npmjs.com/package/stream-stream):
```javascript

@@ -140,0 +145,0 @@ import * as mm from 'music-metadata-browser';

{
"compileOnSave": false,
"compilerOptions": {
"inlineSources": false,
"sourceMap": true,
"declaration": false,
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"target": "es6"
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
],
"baseUrl": ".",
"paths": {
"stream": [ "node_modules/web-streams-polyfill/dist/polyfill.js" ],
"assert": [ "node_modules/assert-plus/assert.js" ]
}
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc