music-metadata
Advanced tools
Comparing version 0.8.3 to 0.8.4
@@ -42,18 +42,8 @@ "use strict"; | ||
if (header.chunkID !== 'FORM') | ||
return null; // Not AIFF format | ||
throw new Error("Invalid Chunk-ID, expected 'FORM'"); // Not AIFF format | ||
return _this.tokenizer.readToken(new Token.StringType(4, 'ascii')).then(function (type) { | ||
_this.metadata.format.dataformat = type; | ||
}).then(function () { | ||
return _this.readChunk().then(function () { | ||
return null; | ||
}); | ||
return _this.readChunk().then(function () { return _this.metadata; }); | ||
}); | ||
}) | ||
.catch(function (err) { | ||
if (err.message === strtok3.endOfFile) { | ||
return _this.metadata; | ||
} | ||
else { | ||
throw err; | ||
} | ||
}); | ||
@@ -87,4 +77,6 @@ }; | ||
} | ||
}).then(function () { | ||
return _this.readChunk(); | ||
}).then(function () { return _this.readChunk(); }).catch(function (err) { | ||
if (err.message !== strtok3.endOfFile) { | ||
throw err; | ||
} | ||
}); | ||
@@ -91,0 +83,0 @@ }; |
@@ -6,7 +6,7 @@ /// <reference types="node" /> | ||
static getParserForAttr(i: DataType): AttributeParser; | ||
static readUInt64LE(buffer: Buffer, offset: number): number; | ||
static parseUnicodeAttr(buf: any): string; | ||
static readUInt64LE(buf: Buffer, offset?: number): number; | ||
private static attributeParsers; | ||
private static parseByteArrayAttr(buf); | ||
private static parseBoolAttr(buf); | ||
private static parseBoolAttr(buf, offset?); | ||
private static parseDWordAttr(buf, offset?); | ||
@@ -13,0 +13,0 @@ private static parseQWordAttr(buf, offset?); |
@@ -10,11 +10,9 @@ "use strict"; | ||
}; | ||
Util.readUInt64LE = function (buffer, offset) { | ||
var high = buffer.slice(offset, offset + 4).readUInt32LE(0); | ||
var low = buffer.slice(offset + 4, offset + 8).readUInt32LE(0); | ||
var maxuint32 = Math.pow(2, 32); | ||
return ((low * maxuint32) + (high >>> 0)); | ||
}; | ||
Util.parseUnicodeAttr = function (buf) { | ||
return common_1.default.stripNulls(common_1.default.decodeString(buf, 'utf16le')); | ||
}; | ||
Util.readUInt64LE = function (buf, offset) { | ||
if (offset === void 0) { offset = 0; } | ||
return buf.readUIntLE(offset, 8); | ||
}; | ||
Util.parseByteArrayAttr = function (buf) { | ||
@@ -25,4 +23,5 @@ var newBuf = new Buffer(buf.length); | ||
}; | ||
Util.parseBoolAttr = function (buf) { | ||
return Util.parseWordAttr(buf) === 1; | ||
Util.parseBoolAttr = function (buf, offset) { | ||
if (offset === void 0) { offset = 0; } | ||
return Util.parseWordAttr(buf, offset) === 1; | ||
}; | ||
@@ -29,0 +28,0 @@ Util.parseDWordAttr = function (buf, offset) { |
@@ -51,3 +51,3 @@ 'use strict'; | ||
if (buf.toString() !== 'fLaC') { | ||
throw new Error('expected flac header but was not found'); | ||
throw new Error("Invalid FLAC preamble"); | ||
} | ||
@@ -54,0 +54,0 @@ return _this.parseBlockHeader(); |
@@ -24,2 +24,4 @@ "use strict"; | ||
return metadata; | ||
else | ||
throw err; | ||
}); | ||
@@ -26,0 +28,0 @@ }; |
@@ -139,26 +139,6 @@ "use strict"; | ||
MP4Parser.read_BE_Signed_Integer = function (value) { | ||
switch (value.length) { | ||
case 1: | ||
case 2: | ||
case 3: | ||
case 4: | ||
return value.readIntBE(0, value.length); | ||
case 8: | ||
return value.readIntBE(2, 6); // JavaScript does not support larger then 6 bytes | ||
default: | ||
throw new Error("Illegal value length for BE-Signed-Integer (type 21): " + value.length); | ||
} | ||
return value.readIntBE(0, value.length); | ||
}; | ||
MP4Parser.read_BE_Unsigned_Integer = function (value) { | ||
switch (value.length) { | ||
case 1: | ||
case 2: | ||
case 3: | ||
case 4: | ||
return value.readUIntBE(0, value.length); | ||
case 8: | ||
return value.readUIntBE(2, 6); // JavaScript does not support larger then 6 bytes | ||
default: | ||
throw new Error("Illegal value length for BE-Unsigned-Integer (type 22): " + value.length); | ||
} | ||
return value.readUIntBE(0, value.length); | ||
}; | ||
@@ -165,0 +145,0 @@ MP4Parser.prototype.parse = function (tokenizer, options) { |
@@ -17,4 +17,2 @@ export declare type TagType = 'vorbis' | 'ID3v1.1' | 'ID3v2.2' | 'ID3v2.3' | 'ID3v2.4' | 'APEv2' | 'asf' | 'iTunes MP4'; | ||
export default class TagMap { | ||
static getCommonTag(tag: CommonTag): ITagInfo; | ||
static isCommonTag(tag: string): boolean; | ||
/** | ||
@@ -35,3 +33,3 @@ * @param alias Name of common tag | ||
*/ | ||
isNativeSingleton(type: any, tag: any): boolean; | ||
isNativeSingleton(type: TagType, tag: string): boolean; | ||
/** | ||
@@ -38,0 +36,0 @@ * @tagTypes Native header tagTypes: e.g.: 'm4a' | 'asf' | 'ID3v1.1' | 'vorbis' |
@@ -30,8 +30,2 @@ "use strict"; | ||
} | ||
TagMap.getCommonTag = function (tag) { | ||
return TagMap.commonTags[tag]; | ||
}; | ||
TagMap.isCommonTag = function (tag) { | ||
return TagMap.commonTags[tag] !== undefined; | ||
}; | ||
/** | ||
@@ -46,7 +40,5 @@ * @param alias Name of common tag | ||
var newMap = {}; | ||
for (var tag in map) { | ||
if (map.hasOwnProperty(tag)) { | ||
newMap[tag.toUpperCase()] = map[tag]; | ||
} | ||
} | ||
Object.keys(map).forEach(function (tag) { | ||
newMap[tag.toUpperCase()] = map[tag]; | ||
}); | ||
return newMap; | ||
@@ -62,4 +54,2 @@ }; | ||
switch (type) { | ||
case 'format': | ||
return true; | ||
case 'ID3v2.3': | ||
@@ -66,0 +56,0 @@ switch (tag) { |
{ | ||
"name": "music-metadata", | ||
"description": "Streaming music metadata parser for node and the browser.", | ||
"version": "0.8.3", | ||
"version": "0.8.4", | ||
"author": { | ||
@@ -46,2 +46,3 @@ "name": "Borewit", | ||
"scripts": { | ||
"clean": "del-cli lib/** src/**/*.js.map src/**/*.d.ts", | ||
"compile-src": "tsc -p src", | ||
@@ -52,3 +53,3 @@ "compile-test": "tsc -p test", | ||
"test": "mocha --require ts-node/register test", | ||
"prepare": "npm run compile", | ||
"prepare": "npm run clean && npm run compile", | ||
"start": "npm-run-all compile lint cover-test", | ||
@@ -68,3 +69,3 @@ "cover-test": "nyc npm run test", | ||
"@types/es6-promise": "0.0.32", | ||
"@types/fs-extra": "^4.0.1", | ||
"@types/fs-extra": "^4.0.2", | ||
"@types/mocha": "^2.2.42", | ||
@@ -74,5 +75,6 @@ "@types/node": "^8.0.26", | ||
"coveralls": "^2.13.1", | ||
"mocha": "^3.5.0", | ||
"del-cli": "^1.1.0", | ||
"mocha": "^3.5.3", | ||
"npm-run-all": "^4.1.1", | ||
"nyc": "^11.1.0", | ||
"nyc": "^11.2.1", | ||
"source-map": "^0.5.7", | ||
@@ -79,0 +81,0 @@ "ts-node": "^3.3.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
252540
15
6185