Socket
Socket
Sign inDemoInstall

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 2.0.2 to 2.0.3

50

lib/browser.js

@@ -6,13 +6,35 @@ 'use strict'

var musicmetadata = require('./index')
var Stream = require('stream').Stream
var isStream = require('is-stream')
module.exports = function (stream, opts, callback) {
return musicmetadata(wrapFileWithStream(stream), opts, callback)
var wrappedStream = wrapFileWithStream(stream)
if (typeof opts === 'function') {
callback = opts
opts = {}
}
if (opts.autoClose) {
return musicmetadata(wrappedStream.dest, opts, function () {
// Once we have our meta data we abort stream file reader
wrappedStream.abort()
callback.apply(null, arguments)
})
}
return musicmetadata(wrappedStream.dest, opts, callback)
}
function wrapFileWithStream (file) {
var stream = through(function write (data) {
var
streamFileReader,
stream = through(function write (data) {
if (data.length > 0) this.queue(data)
}, null, {autoDestroy: false})
if (file instanceof window.ArrayBuffer) {
return wrapArrayBufferWithStream(file, stream)
}
stream.fileSize = function (cb) {

@@ -24,3 +46,3 @@ process.nextTick(function () {

if (file instanceof Stream) {
if (isStream(file)) {
return file.pipe(stream)

@@ -35,3 +57,21 @@ }

return readStream(file).pipe(stream)
streamFileReader = readStream(file)
streamFileReader.pipe(stream)
return streamFileReader
}
function wrapArrayBufferWithStream (arrayBuffer, throughStream) {
throughStream.fileSize = function (cb) {
process.nextTick(function () {
cb(arrayBuffer.byteLength)
})
}
process.nextTick(function () {
throughStream.write(new Buffer(new Uint8Array(arrayBuffer)))
throughStream.end()
})
return throughStream
}

4

lib/flac.js

@@ -102,3 +102,3 @@ 'use strict'

parse: function (callback, data, done) {
if (data !== 'fLaC') {
if (data.toString() !== 'fLaC') {
done(new Error('expected flac header but was not found'))

@@ -109,3 +109,3 @@ }

getExpectedType: function () {
return new strtok.StringType(4)
return new strtok.BufferType(4)
}

@@ -112,0 +112,0 @@ }

@@ -63,2 +63,18 @@ 'use strict'

case 'SYLT':
// skip text encoding (1 byte),
// language (3 bytes),
// time stamp format (1 byte),
// content type (1 byte),
// content descriptor (1 byte)
offset += 7
output = []
while (offset < length) {
var txt = b.slice(offset, offset = findZero(b, offset, length, encoding))
offset += 5 // push offset forward one + 4 byte timestamp
output.push(decodeString(txt, encoding))
}
break
case 'ULT':

@@ -65,0 +81,0 @@ case 'USLT':

@@ -22,5 +22,6 @@ 'use strict'

cb.state++
return new strtok.StringType(4, 'binary')
return new strtok.BufferType(4)
case 1: // atom name
v = v.toString('binary')
cb.atomName = v

@@ -27,0 +28,0 @@

@@ -182,3 +182,4 @@ 'use strict'

['composer', 'TCOM', 'TCM', '©wrt', 'COMPOSER'],
['duration']
['duration'],
['lyrics', 'SYLT']
]

@@ -185,0 +186,0 @@

@@ -89,3 +89,3 @@ 'use strict'

cb.state++
return new strtok.StringType(v)
return new strtok.BufferType(v)

@@ -105,7 +105,7 @@ case 2: // vendor string

cb.state++
return new strtok.StringType(v)
return new strtok.BufferType(v)
case 5: // comment
cb.commentsRead++
v = v.toString()
var idx = v.indexOf('=')

@@ -112,0 +112,0 @@ var key = v.slice(0, idx).toUpperCase()

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

@@ -9,2 +9,3 @@ "dependencies": {

"filereader-stream": "^0.2.0",
"is-stream": "^1.1.0",
"strtok2": "~1.0.0",

@@ -33,11 +34,13 @@ "sum-component": "^0.1.1",

"pretest": "standard && 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.' || prova test/test-*.js",
"test-browser": "prova -t brfs test/test-*.js -b",
"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.' || tape test/test-*.js",
"test-browser": "for f in test/test-*.js; do browserify -t brfs $f | testling; done",
"dist": "browserify lib/browser.js --standalone 'musicmetadata' -o dist/musicmetadata.js"
},
"devDependencies": {
"prova": "~2.1.1",
"tape": "^4.5.1",
"jshint": "~2.5.10",
"brfs": "1.2.0",
"standard": "^3.0.0"
"standard": "^3.0.0",
"browserify": "^13.0.0",
"testling": "^1.7.1"
},

@@ -44,0 +47,0 @@ "testling": {

@@ -65,3 +65,3 @@ [![Build Status][travis-image]][travis-url] [![NPM version][npm-image]][npm-url] [![npm downloads][npm-downloads-image]][npm-url]

```javascript
var parser = mm(fs.createReadStream('sample.mp3'), { duration: true }, function (err, metadata) {
mm(fs.createReadStream('sample.mp3'), { duration: true }, function (err, metadata) {

@@ -73,3 +73,3 @@ });

```javascript
var parser = mm(fs.createReadStream('sample.mp3'), { duration: true, fileSize: 26838 }, function (err, metadata) {
mm(fs.createReadStream('sample.mp3'), { duration: true, fileSize: 26838 }, function (err, metadata) {

@@ -76,0 +76,0 @@ });

Sorry, the diff of this file is too big to display

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