Skip to content

Commit

Permalink
Merge pull request #5 from NirbhayK/master
Browse files Browse the repository at this point in the history
Fixed memory leak warning
  • Loading branch information
Borewit committed Jun 13, 2017
2 parents c6cc005 + 481ba50 commit d4d04dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ const util = require('util')
var audioStream = fs.createReadStream('../test/samples/MusicBrainz-multiartist [id3v2.4].V2.mp3')

// create a new music-metadata from a node ReadStream
mm.parseStream(audioStream, {native: true}, function (err, metadata) {
mm.parseStream(audioStream, {native: true}, function (err, metadata, underlayingAudioStream) {
// important note, the stream is not closed by default. To prevent leaks, you must close it yourself
audioStream.close();
underlayingAudioStream.close();
if (err) throw err;

console.log(util.inspect(metadata, {showHidden: false, depth: null}));
Expand All @@ -60,9 +60,9 @@ import * as util from 'util'
let audioStream = fs.createReadStream('../test/samples/MusicBrainz-multiartist [id3v2.4].V2.mp3')

// create a new music-metadata parser from a node ReadStream
mm.parseStream(audioStream, {native: true}, (err, metadata) => {
mm.parseStream(audioStream, {native: true}, (err, metadata, underlayingAudioStream) => {
// important note, the stream is not closed by default. To prevent leaks, you must close it yourself
audioStream.close();
underlayingAudioStream.close();
if (err) throw err;

console.log(util.inspect(metadata, {showHidden: false, depth: null}));
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export interface IAudioMetadata {
format: IFormat;
}

export type ICallbackType = (error?: Error, metadata?: IAudioMetadata) => void;
export type ICallbackType = (error?: Error, metadata?: IAudioMetadata, underlayingAudioStream?: ReadableStream) => void;

export interface IOptions {
path?: string,
Expand Down Expand Up @@ -365,7 +365,7 @@ class MusicMetadataParser {
}

if (callback) {
callback(err, metadata);
callback(err, metadata, stream);
}
return strtok.DONE;
}
Expand Down

0 comments on commit d4d04dc

Please sign in to comment.