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

musicmetadata

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

musicmetadata - npm Package Compare versions

Comparing version 0.3.9 to 0.3.11

lib/browser.js

67

lib/index.js

@@ -5,22 +5,4 @@ var util = require('util');

var strtok = require('strtok2');
var readStream = require('filereader-stream');
var through = require('through')
var fs = require('fs')
function wrapFileWithStream (file) {
if (file instanceof FileList) {
throw new Error('You have passed a FileList object but we expected a File');
}
if (!(file instanceof File || file instanceof Blob)) {
throw new Error('You must provide a valid File or Blob object');
}
var stream = through(null, null, {autoDestroy: false});
stream.fileSize = function (cb) {
process.nextTick(function () {
cb(file.size);
})
}
return readStream(file).pipe(stream);
}
var MusicMetadata = module.exports = function (stream, opts) {

@@ -31,31 +13,21 @@ if (!(this instanceof MusicMetadata)) return new MusicMetadata(stream, opts);

if (process.browser) {
this.stream = wrapFileWithStream(stream);
} else {
stream.fileSize = function (cb) {
if (stream.hasOwnProperty('path')) {
fs.stat(stream.path, function (err, stats) {
if (err) throw err;
cb(stats.size);
});
} else if (opts.fileSize) {
process.nextTick(function() {
cb(opts.fileSize);
});
} else if (opts.duration) {
self.emit(
'done',
Error('for non file streams, specify the size of the stream with a fileSize option'));
}
stream.fileSize = function (cb) {
if (stream.hasOwnProperty('path')) {
fs.stat(stream.path, function (err, stats) {
if (err) throw err;
cb(stats.size);
});
} else if (opts.fileSize) {
process.nextTick(function() {
cb(opts.fileSize);
});
} else if (opts.duration) {
self.emit(
'done',
Error('for non file streams, specify the size of the stream with a fileSize option'));
}
this.stream = stream;
}
events.EventEmitter.call(this);
this.parse(opts);
};
this.stream = stream;
util.inherits(MusicMetadata, events.EventEmitter);
MusicMetadata.prototype.parse = function (opts) {
this.metadata = {

@@ -66,3 +38,3 @@ title: '',

album: '',
year: "",
year: '',
track: { no: 0, of: 0 },

@@ -77,3 +49,2 @@ genre: [],

var self = this;
this.stream.once('data', function (result) {

@@ -99,4 +70,8 @@ var parser = common.getParserForMediaType(headerTypes, result);

}
};
events.EventEmitter.call(this);
}
util.inherits(MusicMetadata, events.EventEmitter);
MusicMetadata.prototype.readEvent = function (event, value) {

@@ -103,0 +78,0 @@ // We only emit aliased events once the 'done' event has been raised,

{
"name": "musicmetadata",
"description": "Streaming music metadata parser for node and the browser.",
"version": "0.3.9",
"version": "0.3.11",
"author": "Lee Treveil",

@@ -30,9 +30,11 @@ "dependencies": {

"main": "lib",
"browser": "lib/browser",
"scripts": {
"pretest": "jshint lib/*.js test/*.js",
"test": "[ ! -d 'test/' ] && echo 'The test directory is not included with the project due to the size of the test audio files. If you want to run the tests you can git clone the project.' || tap test/test-*.js"
"test": "[ ! -d 'test/' ] && echo 'The test directory is not included with the project due to the size of the test audio files. If you want to run the tests you can git clone the project.' || prova test/test-*.js",
"test-browser": "prova test/test-js-* test/js-*.js -b",
"dist": "browserify lib/browser.js --standalone 'musicmetadata' -o dist/musicmetadata.js"
},
"devDependencies": {
"tape": "~2.3.2",
"tap": "~0.4.8",
"prova": "~1.9.0",
"jshint": "~2.4.3"

@@ -39,0 +41,0 @@ },

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